Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chains/ethereum/proposal_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// constructErc20ProposalData returns the bytes to construct a proposal suitable for Erc20
func ConstructErc20ProposalData(amount []byte, recipient []byte) []byte {
var data []byte
data := make([]byte, 0, 64+len(recipient))
data = append(data, common.LeftPadBytes(amount, 32)...) // amount (uint256)

recipientLen := big.NewInt(int64(len(recipient))).Bytes()
Expand Down
6 changes: 5 additions & 1 deletion cmd/soltool/create_bridge_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func createBridgeAccountAction(ctx *cli.Context) error {
}
fmt.Println("\nbridgePdaPubkey: ", PdaPubkey.ToBase58())

owners := make([]solCommon.PublicKey, 0)
ownersLen := 1 + len(pc.OtherFeeAccountPubkey)
if ownersLen < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}
owners := make([]solCommon.PublicKey, 0, ownersLen)
owners = append(owners, FeeAccount.PublicKey)
for _, account := range pc.OtherFeeAccountPubkey {
a := solTypes.AccountFromPrivateKeyBytes(privKeyMap[account])
Expand Down
9 changes: 5 additions & 4 deletions cmd/soltool/set_fee_amount.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ func setFeeAmountAction(ctx *cli.Context) error {
AdminAccount := solTypes.AccountFromPrivateKeyBytes(privKeyMap[pc.AdminAccountPubkey])
BridgeProgramId := solCommon.PublicKeyFromString(pc.BridgeProgramId)

owners := make([]solCommon.PublicKey, 0)
ownersLen := 1 + len(pc.OtherFeeAccountPubkey)
if ownersLen < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}
owners := make([]solCommon.PublicKey, 0, ownersLen)
owners = append(owners, FeeAccount.PublicKey)
for _, account := range pc.OtherFeeAccountPubkey {
a := solTypes.AccountFromPrivateKeyBytes(privKeyMap[account])
owners = append(owners, a.PublicKey)
}
if len(owners) < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}

//start inter with solana chain
c := solClient.NewClient([]string{pc.Endpoint})
Expand Down
9 changes: 5 additions & 4 deletions cmd/soltool/set_fee_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ func setFeeReceiverAction(ctx *cli.Context) error {
AdminAccount := solTypes.AccountFromPrivateKeyBytes(privKeyMap[pc.AdminAccountPubkey])
BridgeProgramId := solCommon.PublicKeyFromString(pc.BridgeProgramId)

owners := make([]solCommon.PublicKey, 0)
ownersLen := 1 + len(pc.FeeReceiverAccount)
if ownersLen < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}
owners := make([]solCommon.PublicKey, 0, ownersLen)
owners = append(owners, FeeAccount.PublicKey)
for _, account := range pc.OtherFeeAccountPubkey {
a := solTypes.AccountFromPrivateKeyBytes(privKeyMap[account])
owners = append(owners, a.PublicKey)
}
if len(owners) < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}

//start inter with solana chain
c := solClient.NewClient([]string{pc.Endpoint})
Expand Down
9 changes: 5 additions & 4 deletions cmd/soltool/set_resource_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ func mapResourceIdAction(ctx *cli.Context) error {
AdminAccount := solTypes.AccountFromPrivateKeyBytes(privKeyMap[pc.AdminAccountPubkey])
BridgeProgramId := solCommon.PublicKeyFromString(pc.BridgeProgramId)

owners := make([]solCommon.PublicKey, 0)
ownersLen := 1 + len(pc.OtherFeeAccountPubkey)
if ownersLen < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}
owners := make([]solCommon.PublicKey, 0, ownersLen)
owners = append(owners, FeeAccount.PublicKey)
for _, account := range pc.OtherFeeAccountPubkey {
a := solTypes.AccountFromPrivateKeyBytes(privKeyMap[account])
owners = append(owners, a.PublicKey)
}
if len(owners) < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}

resourceIdToMint := make(map[[32]byte]solCommon.PublicKey)
for key, value := range pc.ResourceIdToMint {
Expand Down
9 changes: 5 additions & 4 deletions cmd/soltool/set_support_chainId.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ func setSupportChainIdAction(ctx *cli.Context) error {
AdminAccount := solTypes.AccountFromPrivateKeyBytes(privKeyMap[pc.AdminAccountPubkey])
BridgeProgramId := solCommon.PublicKeyFromString(pc.BridgeProgramId)

owners := make([]solCommon.PublicKey, 0)
ownersLen := 1 + len(pc.OtherFeeAccountPubkey)
if ownersLen < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}
owners := make([]solCommon.PublicKey, 0, ownersLen)
owners = append(owners, FeeAccount.PublicKey)
for _, account := range pc.OtherFeeAccountPubkey {
a := solTypes.AccountFromPrivateKeyBytes(privKeyMap[account])
owners = append(owners, a.PublicKey)
}
if len(owners) < int(pc.Threshold) {
return fmt.Errorf("owner len < threshold")
}

//start inter with solana chain
c := solClient.NewClient([]string{pc.Endpoint})
Expand Down
2 changes: 1 addition & 1 deletion cmd/solvault/vault_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var vaultAddCmd = &cobra.Command{
return
}

var newKeys []vault.PublicKey
newKeys := make([]vault.PublicKey, 0, len(privateKeys))
for _, privateKey := range privateKeys {
v.AddPrivateKey(privateKey)
newKeys = append(newKeys, privateKey.PublicKey())
Expand Down
2 changes: 1 addition & 1 deletion shared/ethereum/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func Erc20GetResourceId(client *Client, handler common.Address, rId msg.Resource
}

func ConstructErc20DepositData(destRecipient []byte, amount *big.Int) []byte {
var data []byte
data := make([]byte, 64+len(destRecipient))
data = append(data, math.PaddedBigBytes(amount, 32)...)
data = append(data, math.PaddedBigBytes(big.NewInt(int64(len(destRecipient))), 32)...)
data = append(data, destRecipient...)
Expand Down