wrap-cli
wrap-cli copied to clipboard
Optimize Wrapper ABI
Currently, the WRAP ABI structure has a lot of redundant data. This is because the nested redundant data is useful when generating code, but is unneeded elsewhere.
We should optimize the ABI structure to ensure that it serializes to as small of a size as possible.
Example Optimization
Optimized:
{
name: "uArrayArray",
required: true,
kind: 34,
array: {
type: "[[UInt]]",
required: true,
kind: 18,
array: {
type: "[UInt]",
kind: 18,
scalar: {
type: "UInt",
kind: 4
}
}
}
}
Original:
{
type: "[[UInt]]",
name: "uArrayArray",
required: true,
kind: 34,
array: {
type: "[[UInt]]",
name: "uArrayArray",
required: true,
kind: 18,
array: {
type: "[UInt]",
name: "uArrayArray",
kind: 18,
scalar: {
type: "UInt",
name: "uArrayArray",
kind: 4
},
item: {
type: "UInt",
name: "uArrayArray",
kind: 4
}
},
item: {
type: "[UInt]",
name: "uArrayArray",
kind: 18,
scalar: {
type: "UInt",
name: "uArrayArray",
kind: 4
},
item: {
type: "UInt",
name: "uArrayArray",
kind: 4
}
}
}
}
NOTE: we can add back this redundant data using transformations, that way our codegen string templates do not need to be changed.
I think this is really important! The wrap.info file can get really big right now.
Uniswap v3 example: wrap.info -> 171kb wrap.wasm -> 799kb