-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
68 lines (57 loc) · 1.82 KB
/
config.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ibc_tx
import (
"fmt"
"github.com/brc20-collab/brczero/libs/cosmos-sdk/client"
"github.com/brc20-collab/brczero/libs/cosmos-sdk/codec"
ibctx "github.com/brc20-collab/brczero/libs/cosmos-sdk/types/ibc-adapter"
signing2 "github.com/brc20-collab/brczero/libs/cosmos-sdk/types/tx/signing"
signing "github.com/brc20-collab/brczero/libs/cosmos-sdk/x/auth/ibcsigning"
)
type config struct {
handler signing.SignModeHandler
decoder ibctx.IbcTxDecoder
encoder ibctx.IBCTxEncoder
//jsonDecoder ibctx.IBCTxEncoder
jsonEncoder ibctx.IBCTxEncoder
protoCodec codec.ProtoCodecMarshaler
}
// NewTxConfig returns a new protobuf TxConfig using the provided ProtoCodec and sign modes. The
// first enabled sign mode will become the default sign mode.
func NewTxConfig(protoCodec codec.ProtoCodecMarshaler, enabledSignModes []signing2.SignMode) client.TxConfig {
return &config{
handler: makeSignModeHandler(enabledSignModes),
decoder: IbcTxDecoder(protoCodec),
encoder: IbcTxEncoder(),
//jsonDecoder: DefaultJSONTxDecoder(protoCodec),
jsonEncoder: DefaultJSONTxEncoder(protoCodec),
protoCodec: protoCodec,
}
}
func (g config) NewTxBuilder() client.TxBuilder {
return newBuilder()
}
// WrapTxBuilder returns a builder from provided transaction
func (g config) WrapTxBuilder(newTx ibctx.Tx) (client.TxBuilder, error) {
newBuilder, ok := newTx.(*wrapper)
if !ok {
return nil, fmt.Errorf("expected %T, got %T", &wrapper{}, newTx)
}
return newBuilder, nil
}
func (g config) SignModeHandler() signing.SignModeHandler {
return g.handler
}
func (g config) TxEncoder() ibctx.IBCTxEncoder {
return g.encoder
}
func (g config) TxDecoder() ibctx.IbcTxDecoder {
return g.decoder
}
//
func (g config) TxJSONEncoder() ibctx.IBCTxEncoder {
return g.jsonEncoder
}
//
//func (g config) TxJSONDecoder() sdk.TxDecoder {
// return g.jsonDecoder
//}