@@ -3,7 +3,6 @@ package cosmos
3
3
import (
4
4
"context"
5
5
"crypto/sha256"
6
- "encoding/hex"
7
6
"fmt"
8
7
"math/big"
9
8
@@ -16,11 +15,13 @@ import (
16
15
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
17
16
"github.com/cosmos/cosmos-sdk/x/auth/tx"
18
17
bankType "github.com/cosmos/cosmos-sdk/x/bank/types"
18
+ "github.com/renproject/id"
19
19
"github.com/renproject/multichain"
20
20
"github.com/renproject/multichain/api/account"
21
21
"github.com/renproject/multichain/api/address"
22
22
"github.com/renproject/multichain/api/contract"
23
23
"github.com/renproject/pack"
24
+ "github.com/renproject/surge"
24
25
"github.com/tendermint/tendermint/crypto/tmhash"
25
26
)
26
27
@@ -75,15 +76,13 @@ func (builder txBuilder) WithSignMode(signMode int32) txBuilder {
75
76
// BuildTx consumes a list of MsgSend to build and return a cosmos transaction.
76
77
// This transaction is unsigned, and must be signed before submitting to the
77
78
// cosmos chain.
78
- func (builder txBuilder ) BuildTx (ctx context.Context , from , to address.Address , value , nonce , gasLimit , gasPrice , gasCap pack.U256 , payload pack.Bytes ) (account.Tx , error ) {
79
- // We assume the "from" address is a public key as it is required for
80
- // setting the signature.
81
- pubKeyBytes , err := hex .DecodeString (string (from ))
79
+ func (builder txBuilder ) BuildTx (ctx context.Context , fromPubKey * id.PubKey , to address.Address , value , nonce , gasLimit , gasPrice , gasCap pack.U256 , payload pack.Bytes ) (account.Tx , error ) {
80
+ pubKeyBytes , err := surge .ToBinary (fromPubKey )
82
81
if err != nil {
83
82
return nil , err
84
83
}
85
84
pubKey := secp256k1.PubKey {Key : pubKeyBytes }
86
- from = multichain .Address (types .AccAddress (pubKey .Address ()).String ())
85
+ from : = multichain .Address (types .AccAddress (pubKey .Address ()).String ())
87
86
88
87
fromAddr , err := types .AccAddressFromBech32 (string (from ))
89
88
if err != nil {
0 commit comments