neo-one-suite / neo-one

The One for easy, fast, & fun NEO app development.
https://neo-one.io
MIT License
93 stars 34 forks source link

Check that contract address is being computed correctly everywhere #2533

Open spencercorwin opened 3 years ago

spencercorwin commented 3 years ago

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

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)));

spencercorwin commented 3 years ago

Make sure to cover the address in createSmartContract.ts