Skip to content

Commit

Permalink
fix merge main conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Sep 29, 2023
1 parent fe0de12 commit 588bc46
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
7 changes: 2 additions & 5 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions account/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 2 additions & 14 deletions utils/Felt.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package utils

import (
"errors"
"math/big"

"github.com/NethermindEth/juno/core/felt"
Expand Down Expand Up @@ -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
}

0 comments on commit 588bc46

Please sign in to comment.