Skip to content

simplify tx builder checksum calculation #807

Description

@banteg

im working on adding the tx builder json format support to ape-safe and the way checksum is calculated sticks out to me.

currently it uses some unhinged weird custom encoding, which looks very brittle when you consider porting into other languages.

consider using something like json-stable-stringify instead.

const serializeJSONObject = (json: any): string => {

example of output:

>>> serializeJSONObject(batchFileObject)
'{["chainId","createdAt","meta","transactions","version"]"4",1646321521061,{["checksum","createdFromOwnerAddress","createdFromSafeAddress","name","txBuilderVersion"]"","0x49d4450977E2c95362C13D3a31a09311E0Ea26A6","0xDF8a1Ce35c9a6ACE153B4e0767942f1E2291a1Aa","test batch file","1.4.0",},[{["contractInputsValues","contractMethod","to","value"]{["paramAddress"]"0x49d4450977E2c95362C13D3a31a09311E0Ea26A6",},{["inputs","name","payable"][{["internalType","name","type"]"address","paramAddress","address",}],"testAddress",false,},"0x49d4450977E2c95362C13D3a31a09311E0Ea26A6","0",},{["contractInputsValues","contractMethod","to","value"]{["paramAddress","paramBool"]"","false",},{["inputs","name","payable"][{["internalType","name","type"]"bool","paramBool","bool",}],"testBool",false,},"0x49d4450977E2c95362C13D3a31a09311E0Ea26A6","0",},{["data","to","value"]"0x42f4579000000000000000000000000049d4450977e2c95362c13d3a31a09311e0ea26a6","0x49d4450977E2c95362C13D3a31a09311E0Ea26A6","2000000000000000000",}],"1.0",}'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions