Check that contract address is being computed correctly everywhere #2533
Labels
area/cli
Categorize issue or PR as cli (@neo-one/cli) related
area/client
Categorize issue or PR as client (@neo-one/client) related
kind/cleanup
Categorizes issue or PR as related to cleaning up code, process, or technical debt.
priority/important-soon
Must be staffed and worked on either currently, or very soon.
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)));
The text was updated successfully, but these errors were encountered: