Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check that contract address is being computed correctly everywhere #2533

@spencercorwin

Description

@spencercorwin

Need to find everywhere that we currently/previously computed a contract's address, like:

  • compileContract.ts (incorrect? see comments in code)
  • LocalUserAccountProvider.ts (correct?)
  • startNode.ts (incorrect?)

Then use the information gathered from there to determine where else we need to look to make sure we're calculating the contract address now.

Then go through and check to see if what's in there now is working. If it's not, or it's determined to be incorrect then make changes. The major change is that now the contract address is based on the signer of the transaction that deploys the contract. Since that is done much later on in most of these processes we may need to return a function as part of compiled contracts that will calculated the address with the given signer. And that value should then maybe be returned up the call stack to be passed back to where the contract address is needed.

How it was previously calculated:
const address = scriptHashToAddress(common.uInt160ToString(crypto.toScriptHash(Buffer.from(contract.contract.script, 'hex'))));

How it should be calculated:
const contractAddress = scriptHashToAddress(common.uInt160ToString(crypto.getContractHash(signer.account, nefFile.checkSum, contractIn.manifest.name)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliCategorize issue or PR as cli (@neo-one/cli) relatedarea/clientCategorize issue or PR as client (@neo-one/client) relatedkind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.priority/important-soonMust be staffed and worked on either currently, or very soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions