NethermindEth / starknet.go

Golang Library for StarkNet/Cairo
MIT License
143 stars 95 forks source link

Move PrecomputeAddress function to 'contract' package #574

Closed thiagodeev closed 1 week ago

thiagodeev commented 3 weeks ago

The PrecomputeAddress function precomputes the address of a contract instance thus it's not directly related to the 'account' package, but to the 'contract' package. The only use of this function in the 'account' package is to calculate the account contract address for deploying an account, and to satisfy that I created the PrecomputeAccountAddress function in the 'account' package that calls the PrecomputeAddress function passing the proper parameters.

This will prevent developers from generating wrong account addresses when deploying an account as this process requires the 'deployer_address' to be '0', but the previous function was not intuitive when asking for the 'deployerAddress' parameter without describing that it should be '0' in such case. The new account.PrecomputeAccountAddress function passes '0' as 'deployer_address' automatically to the contract.PrecomputeAccount without prompting the user.

https://docs.starknet.io/architecture-and-concepts/smart-contracts/contract-address/