Skip to content

Commit

Permalink
fix: deploy braavos failed. deploy use argentX params.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhangguiguang committed Jun 30, 2023
1 parent dfc3e9a commit 4c2c79c
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions core/starknet/transaction_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"math/big"

hexTypes "github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/coming-chat/wallet-SDK/core/base"
"github.com/dontpanicdao/caigo"
"github.com/dontpanicdao/caigo/gateway"
Expand Down Expand Up @@ -70,25 +69,55 @@ func (txn *DeployAccountTransaction) SignedTransactionWithAccount(account base.A
}, nil
}

// var newDeployAccountTransaction = newDeployAccountTransactionForArgentX
var newDeployAccountTransaction = newDeployAccountTransactionForBraavos
// var newDeployAccountTransaction = newDeployAccountTransactionForBraavos
var newDeployAccountTransaction = newDeployAccountTransactionForArgentX

// func newDeployAccountTransactionForArgentX(pubkey string, network Network) (*DeployAccountTransaction, error) {
func newDeployAccountTransactionForArgentX(pubkey string, network Network) (*DeployAccountTransaction, error) {
pubkeyInt, err := base.ParseNumber(pubkey)
if err != nil {
return nil, base.ErrInvalidPublicKey
}

txn := DeployAccountTransaction{
ClassHash: types.HexToBN("0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"),
ContractAddressSalt: pubkeyInt,
ConstructorCallData: []*big.Int{
types.HexToBN("0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2"),
types.HexToBN("0x79dc0da7c54b95f10aa182ad0a46400db63156920adb65eca2654c0945a463"),
types.HexToBN("0x2"),
pubkeyInt,
types.HexToBN("0x0"),
},
Version: big.NewInt(1),
MaxFee: big.NewInt(2e14), // 0.0002
Nonce: big.NewInt(0),

Network: network,
}

callerAddress := big.NewInt(0)
txn.ContractAddress, err = txn.ComputeContractAddress(callerAddress)
if err != nil {
return nil, err
}
return &txn, nil
}

// func newDeployAccountTransactionForBraavos(pubkey string, network Network) (*DeployAccountTransaction, error) {
// pubData, err := hexTypes.HexDecodeString(pubkey)
// if err != nil {
// return nil, base.ErrInvalidPublicKey
// }
// pubkeyInt := big.NewInt(0).SetBytes(pubData)

// txn := DeployAccountTransaction{
// ClassHash: types.HexToBN("0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"),
// ClassHash: types.HexToBN("0x03131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e"),
// ContractAddressSalt: pubkeyInt,
// ConstructorCallData: []*big.Int{
// types.HexToBN("0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2"),
// types.HexToBN("0x79dc0da7c54b95f10aa182ad0a46400db63156920adb65eca2654c0945a463"),
// types.HexToBN("0x2"),
// types.HexToBN("0x5aa23d5bb71ddaa783da7ea79d405315bafa7cf0387a74f4593578c3e9e6570"),
// types.HexToBN("0x2dd76e7ad84dbed81c314ffe5e7a7cacfb8f4836f01af4e913f275f89a3de1a"),
// types.HexToBN("0x1"),
// pubkeyInt,
// types.HexToBN("0x0"),
// },
// Version: big.NewInt(1),
// MaxFee: big.NewInt(2e14), // 0.0002
Expand All @@ -105,37 +134,6 @@ var newDeployAccountTransaction = newDeployAccountTransactionForBraavos
// return &txn, nil
// }

func newDeployAccountTransactionForBraavos(pubkey string, network Network) (*DeployAccountTransaction, error) {
pubData, err := hexTypes.HexDecodeString(pubkey)
if err != nil {
return nil, base.ErrInvalidPublicKey
}
pubkeyInt := big.NewInt(0).SetBytes(pubData)

txn := DeployAccountTransaction{
ClassHash: types.HexToBN("0x03131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e"),
ContractAddressSalt: pubkeyInt,
ConstructorCallData: []*big.Int{
types.HexToBN("0x5aa23d5bb71ddaa783da7ea79d405315bafa7cf0387a74f4593578c3e9e6570"),
types.HexToBN("0x2dd76e7ad84dbed81c314ffe5e7a7cacfb8f4836f01af4e913f275f89a3de1a"),
types.HexToBN("0x1"),
pubkeyInt,
},
Version: big.NewInt(1),
MaxFee: big.NewInt(2e14), // 0.0002
Nonce: big.NewInt(0),

Network: network,
}

callerAddress := big.NewInt(0)
txn.ContractAddress, err = txn.ComputeContractAddress(callerAddress)
if err != nil {
return nil, err
}
return &txn, nil
}

// ContractAddress computes the address of a Starknet contract.
func (txn *DeployAccountTransaction) ComputeContractAddress(callerAddress *big.Int) (*big.Int, error) {
prefix := big.NewInt(0).SetBytes([]byte(caigo.CONTRACT_ADDRESS_PREFIX))
Expand Down

0 comments on commit 4c2c79c

Please sign in to comment.