diff --git a/account/account.go b/account/account.go index cff533d2..3fce9559 100644 --- a/account/account.go +++ b/account/account.go @@ -274,17 +274,14 @@ func (account *Account) TransactionHashDeclare(tx rpc.DeclareTxnType) (*felt.Fel // ref: https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/core/os/contract_address/contract_address.py func (account *Account) PrecomputeAddress(deployerAddress *felt.Felt, salt *felt.Felt, classHash *felt.Felt, constructorCalldata []*felt.Felt) (*felt.Felt, error) { - bigIntArr, err := utils.FeltArrToBigIntArr([]*felt.Felt{ + bigIntArr := utils.FeltArrToBigIntArr([]*felt.Felt{ PREFIX_CONTRACT_ADDRESS, deployerAddress, salt, classHash, }) - if err != nil { - return nil, err - } - constructorCalldataBigIntArr, err := utils.FeltArrToBigIntArr(constructorCalldata) + constructorCalldataBigIntArr := utils.FeltArrToBigIntArr(constructorCalldata) constructorCallDataHashInt, _ := starknetgo.Curve.ComputeHashOnElements(constructorCalldataBigIntArr) bigIntArr = append(bigIntArr, constructorCallDataHashInt) diff --git a/account/hash.go b/account/hash.go index 2db617e2..77d02f18 100644 --- a/account/hash.go +++ b/account/hash.go @@ -9,10 +9,7 @@ import ( // computeHashOnElementsFelt hashes the array of felts provided as input func computeHashOnElementsFelt(feltArr []*felt.Felt) (*felt.Felt, error) { - bigIntArr, err := utils.FeltArrToBigIntArr(feltArr) - if err != nil { - return nil, err - } + bigIntArr := utils.FeltArrToBigIntArr(feltArr) hash, err := starknetgo.Curve.ComputeHashOnElements(bigIntArr) if err != nil { return nil, err diff --git a/utils/Felt.go b/utils/Felt.go index 072a4246..dd5e334d 100644 --- a/utils/Felt.go +++ b/utils/Felt.go @@ -1,7 +1,6 @@ package utils import ( - "errors" "math/big" "github.com/NethermindEth/juno/core/felt" @@ -36,21 +35,10 @@ func BigIntToFelt(big *big.Int) *felt.Felt { return new(felt.Felt).SetBytes(big.Bytes()) } -func FeltArrToBigIntArr(f []*felt.Felt) ([]*big.Int, error) { +func FeltArrToBigIntArr(f []*felt.Felt) []*big.Int { var bigArr []*big.Int for _, felt := range f { bigArr = append(bigArr, FeltToBigInt(felt)) } - return bigArr, nil -} -func FeltArrToBigIntArr(f []*felt.Felt) (*[]*big.Int, error) { - var bigArr []*big.Int - for _, felt := range f { - bint, ok := FeltToBigInt(felt) - if !ok { - return nil, errors.New("Failed to convert felt to big.Int") - } - bigArr = append(bigArr, bint) - } - return &bigArr, nil + return bigArr }