Skip to content

Commit 9b2cb84

Browse files
authored
chore(sdk) [NET-1452]: Optimize ABI JSON files (#3079)
Optimized SDK bundle size by converting contract ABI JSONs from `json` format to `full` format (https://docs.ethers.org/v6/api/abi/abi-coder/#FormatType). The full `format` is more compact than the `json` format. As we use named parameters in events (e.g. `deploySponsorshipContract()`) and structs (e.g. `convertChainPermissionsToStreamPermissions()`) we can't use the `minimal` format. ## Statistics The `streamr-sdk.web.min.js` bundle decreased 67k in size. ## Conversion These ABIs are converted from the full format ABIs by running this script: ```ts import fs from 'fs' import { Interface } from 'ethers' const filePath = process.argv[2] const rawAbi = JSON.parse(fs.readFileSync(filePath)) const iface = new Interface(rawAbi) const formattedAbi = Object.values(iface.fragments).map(fragment => { // use full format so that we can use named event parameters return fragment.format('full') }) fs.writeFileSync(filePath, JSON.stringify(formattedAbi, undefined, 4)) ```
1 parent 794d78c commit 9b2cb84

File tree

9 files changed

+454
-8224
lines changed

9 files changed

+454
-8224
lines changed

packages/sdk/src/ethereumArtifacts/DATAv2Abi.json

Lines changed: 37 additions & 733 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
11
[
2-
{
3-
"inputs": [
4-
{
5-
"internalType": "bytes32",
6-
"name": "hash",
7-
"type": "bytes32"
8-
},
9-
{
10-
"internalType": "bytes",
11-
"name": "signature",
12-
"type": "bytes"
13-
}
14-
],
15-
"name": "isValidSignature",
16-
"outputs": [
17-
{
18-
"internalType": "bytes4",
19-
"name": "magicValue",
20-
"type": "bytes4"
21-
}
22-
],
23-
"stateMutability": "view",
24-
"type": "function"
25-
}
26-
]
2+
"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4 magicValue)"
3+
]

0 commit comments

Comments
 (0)