/
wallet.go
48 lines (39 loc) · 1.07 KB
/
wallet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cosmos
import (
"github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/interchaintest/v3/ibc"
)
var _ ibc.Wallet = &CosmosWallet{}
var _ User = &CosmosWallet{}
type CosmosWallet struct {
mnemonic string
address []byte
keyName string
chainCfg ibc.ChainConfig
}
func NewWallet(keyname string, address []byte, mnemonic string, chainCfg ibc.ChainConfig) ibc.Wallet {
return &CosmosWallet{
mnemonic: mnemonic,
address: address,
keyName: keyname,
chainCfg: chainCfg,
}
}
func (w *CosmosWallet) KeyName() string {
return w.keyName
}
// Get formatted address, passing in a prefix
func (w *CosmosWallet) FormattedAddress() string {
return types.MustBech32ifyAddressBytes(w.chainCfg.Bech32Prefix, w.address)
}
// Get mnemonic, only used for relayer wallets
func (w *CosmosWallet) Mnemonic() string {
return w.mnemonic
}
// Get Address with chain's prefix
func (w *CosmosWallet) Address() []byte {
return w.address
}
func (w *CosmosWallet) FormattedAddressWithPrefix(prefix string) string {
return types.MustBech32ifyAddressBytes(prefix, w.address)
}