@agoric/cosmos 0.34.2-orchestration-dev-096c4e8.0 → 0.34.2-other-dev-3eb1a1d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MAINTAINERS.md +3 -0
- package/Makefile +38 -34
- package/ante/ante.go +1 -4
- package/ante/inbound_test.go +2 -2
- package/app/app.go +198 -137
- package/app/upgrade.go +248 -0
- package/cmd/agd/agvm.go +3 -3
- package/cmd/agd/find_binary.go +2 -2
- package/cmd/agd/main.go +9 -10
- package/cmd/libdaemon/main.go +13 -13
- package/daemon/cmd/root.go +235 -92
- package/daemon/cmd/root_test.go +189 -1
- package/daemon/main.go +3 -2
- package/git-revision.txt +1 -1
- package/go.mod +14 -11
- package/go.sum +20 -19
- package/index.cjs +1 -1
- package/package.json +4 -3
- package/proto/agoric/swingset/genesis.proto +4 -0
- package/proto/agoric/swingset/swingset.proto +26 -1
- package/proto/agoric/vbank/vbank.proto +7 -0
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +7 -8
- package/types/kv_entry_helpers.go +42 -0
- package/upgradegaia.sh +8 -8
- package/util/util.go +21 -0
- package/vm/action.go +1 -1
- package/vm/client.go +15 -13
- package/vm/client_test.go +34 -36
- package/vm/controller.go +3 -38
- package/vm/core_proposals.go +22 -2
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +106 -5
- package/x/swingset/alias.go +2 -0
- package/x/swingset/config.go +234 -0
- package/x/swingset/genesis.go +178 -40
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/keeper/keeper.go +24 -27
- package/x/swingset/keeper/swing_store_exports_handler.go +14 -3
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +24 -9
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/default-params.go +31 -5
- package/x/swingset/types/expected_keepers.go +2 -2
- package/x/swingset/types/genesis.pb.go +78 -25
- package/x/swingset/types/msgs.go +53 -12
- package/x/swingset/types/params.go +53 -43
- package/x/swingset/types/params_test.go +75 -9
- package/x/swingset/types/swingset.pb.go +387 -57
- package/x/vbank/README.md +6 -1
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/keeper/keeper.go +4 -9
- package/x/vbank/keeper/migrations.go +30 -0
- package/x/vbank/module.go +8 -7
- package/x/vbank/types/key.go +3 -3
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/types/params.go +43 -2
- package/x/vbank/types/vbank.pb.go +105 -36
- package/x/vbank/vbank.go +8 -13
- package/x/vbank/vbank_test.go +14 -9
- package/x/vibc/alias.go +1 -1
- package/x/vibc/module.go +2 -7
- package/x/vibc/types/ibc_module.go +9 -3
- package/x/vibc/types/receiver.go +17 -7
- package/x/vlocalchain/handler.go +2 -1
- package/x/vlocalchain/keeper/keeper.go +24 -8
- package/x/vlocalchain/keeper/keeper_test.go +65 -1
- package/x/vlocalchain/types/expected_keepers.go +12 -0
- package/x/vlocalchain/vlocalchain.go +27 -22
- package/x/vlocalchain/vlocalchain_test.go +163 -8
- package/x/vstorage/keeper/grpc_query.go +0 -1
- package/x/vstorage/keeper/keeper.go +9 -17
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +28 -0
- package/x/vtransfer/alias.go +13 -0
- package/x/vtransfer/genesis.go +39 -0
- package/x/vtransfer/genesis_test.go +12 -0
- package/x/vtransfer/handler.go +20 -0
- package/x/vtransfer/ibc_middleware.go +186 -0
- package/x/vtransfer/ibc_middleware_test.go +449 -0
- package/x/vtransfer/keeper/keeper.go +282 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/baseaddr.go +156 -0
- package/x/vtransfer/types/baseaddr_test.go +167 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +328 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/ante/fee.go +0 -97
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
package types_test
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"testing"
|
|
5
|
+
|
|
6
|
+
"github.com/stretchr/testify/require"
|
|
7
|
+
|
|
8
|
+
codec "github.com/cosmos/cosmos-sdk/codec"
|
|
9
|
+
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
10
|
+
|
|
11
|
+
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
|
|
12
|
+
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
|
13
|
+
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
14
|
+
|
|
15
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/types"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
func TestExtractBaseAddress(t *testing.T) {
|
|
19
|
+
bases := []struct {
|
|
20
|
+
name string
|
|
21
|
+
addr string
|
|
22
|
+
}{
|
|
23
|
+
{"agoric address", "agoric1abcdefghiteaneas"},
|
|
24
|
+
{"cosmos address", "cosmos1abcdeffiharceuht"},
|
|
25
|
+
{"hex address", "0xabcdef198189818c93839ibia"},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
prefixes := []struct {
|
|
29
|
+
prefix string
|
|
30
|
+
baseIsWrong bool
|
|
31
|
+
isErr bool
|
|
32
|
+
}{
|
|
33
|
+
{"", false, false},
|
|
34
|
+
{"/", false, true},
|
|
35
|
+
{"orch:/", false, true},
|
|
36
|
+
{"unexpected", true, false},
|
|
37
|
+
{"norch:/", false, true},
|
|
38
|
+
{"orch:", false, true},
|
|
39
|
+
{"norch:", false, true},
|
|
40
|
+
{"\x01", false, true},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
suffixes := []struct {
|
|
44
|
+
suffix string
|
|
45
|
+
baseIsWrong bool
|
|
46
|
+
isErr bool
|
|
47
|
+
}{
|
|
48
|
+
{"", false, false},
|
|
49
|
+
{"/", false, false},
|
|
50
|
+
{"/sub/account", false, false},
|
|
51
|
+
{"?query=something&k=v&k2=v2", false, false},
|
|
52
|
+
{"?query=something&k=v&k2=v2#fragment", false, false},
|
|
53
|
+
{"unexpected", true, false},
|
|
54
|
+
{"\x01", false, true},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for _, b := range bases {
|
|
58
|
+
b := b
|
|
59
|
+
for _, p := range prefixes {
|
|
60
|
+
p := p
|
|
61
|
+
for _, s := range suffixes {
|
|
62
|
+
s := s
|
|
63
|
+
t.Run(b.name+" "+p.prefix+" "+s.suffix, func(t *testing.T) {
|
|
64
|
+
addr := p.prefix + b.addr + s.suffix
|
|
65
|
+
addr, err := types.ExtractBaseAddress(addr)
|
|
66
|
+
if p.isErr || s.isErr {
|
|
67
|
+
require.Error(t, err)
|
|
68
|
+
} else {
|
|
69
|
+
require.NoError(t, err)
|
|
70
|
+
if p.baseIsWrong || s.baseIsWrong {
|
|
71
|
+
require.NotEqual(t, b.addr, addr)
|
|
72
|
+
} else {
|
|
73
|
+
require.Equal(t, b.addr, addr)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
func TestExtractBaseAddressFromPacket(t *testing.T) {
|
|
83
|
+
ir := cdctypes.NewInterfaceRegistry()
|
|
84
|
+
cdc := codec.NewProtoCodec(ir)
|
|
85
|
+
transfertypes.RegisterInterfaces(ir)
|
|
86
|
+
channeltypes.RegisterInterfaces(ir)
|
|
87
|
+
clienttypes.RegisterInterfaces(ir)
|
|
88
|
+
|
|
89
|
+
cases := []struct {
|
|
90
|
+
name string
|
|
91
|
+
addrs map[types.AddressRole]struct{ addr, baseAddr string }
|
|
92
|
+
}{
|
|
93
|
+
{"sender has params",
|
|
94
|
+
map[types.AddressRole]struct{ addr, baseAddr string }{
|
|
95
|
+
types.RoleSender: {"cosmos1abcdeffiharceuht?foo=bar&baz=bot#fragment", "cosmos1abcdeffiharceuht"},
|
|
96
|
+
types.RoleReceiver: {"agoric1abcdefghiteaneas", "agoric1abcdefghiteaneas"},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{"receiver has params",
|
|
100
|
+
map[types.AddressRole]struct{ addr, baseAddr string }{
|
|
101
|
+
types.RoleSender: {"cosmos1abcdeffiharceuht", "cosmos1abcdeffiharceuht"},
|
|
102
|
+
types.RoleReceiver: {"agoric1abcdefghiteaneas?bingo=again", "agoric1abcdefghiteaneas"},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{"both are base",
|
|
106
|
+
map[types.AddressRole]struct{ addr, baseAddr string }{
|
|
107
|
+
types.RoleSender: {"cosmos1abcdeffiharceuht", "cosmos1abcdeffiharceuht"},
|
|
108
|
+
types.RoleReceiver: {"agoric1abcdefghiteaneas", "agoric1abcdefghiteaneas"},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{"both have params",
|
|
112
|
+
map[types.AddressRole]struct{ addr, baseAddr string }{
|
|
113
|
+
types.RoleSender: {"agoric1abcdefghiteaneas?bingo=again", "agoric1abcdefghiteaneas"},
|
|
114
|
+
types.RoleReceiver: {"cosmos1abcdeffiharceuht?foo=bar&baz=bot#fragment", "cosmos1abcdeffiharceuht"},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
for _, tc := range cases {
|
|
120
|
+
tc := tc
|
|
121
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
122
|
+
ftPacketData := transfertypes.NewFungibleTokenPacketData("denom", "100", tc.addrs[types.RoleSender].addr, tc.addrs[types.RoleReceiver].addr, "my-favourite-memo")
|
|
123
|
+
packetBz, err := cdc.MarshalJSON(&ftPacketData)
|
|
124
|
+
require.NoError(t, err)
|
|
125
|
+
packet := channeltypes.NewPacket(packetBz, 1234, "my-port", "my-channel", "their-port", "their-channel", clienttypes.NewHeight(133, 445), 10999)
|
|
126
|
+
|
|
127
|
+
for role, addrs := range tc.addrs {
|
|
128
|
+
addrs := addrs
|
|
129
|
+
role := role
|
|
130
|
+
|
|
131
|
+
t.Run(string(role), func(t *testing.T) {
|
|
132
|
+
baseAddr, err := types.ExtractBaseAddress(addrs.addr)
|
|
133
|
+
require.NoError(t, err)
|
|
134
|
+
require.Equal(t, addrs.baseAddr, baseAddr)
|
|
135
|
+
|
|
136
|
+
packetBaseAddr, err := types.ExtractBaseAddressFromPacket(cdc, packet, role, nil)
|
|
137
|
+
require.NoError(t, err)
|
|
138
|
+
require.Equal(t, addrs.baseAddr, packetBaseAddr)
|
|
139
|
+
|
|
140
|
+
var newPacket channeltypes.Packet
|
|
141
|
+
packetBaseAddr2, err := types.ExtractBaseAddressFromPacket(cdc, packet, role, &newPacket)
|
|
142
|
+
require.NoError(t, err)
|
|
143
|
+
require.Equal(t, addrs.baseAddr, packetBaseAddr2)
|
|
144
|
+
|
|
145
|
+
var basePacketData transfertypes.FungibleTokenPacketData
|
|
146
|
+
err = cdc.UnmarshalJSON(newPacket.GetData(), &basePacketData)
|
|
147
|
+
require.NoError(t, err)
|
|
148
|
+
|
|
149
|
+
// Check that the only difference between the packet data is the baseAddr.
|
|
150
|
+
packetData := basePacketData
|
|
151
|
+
switch role {
|
|
152
|
+
case types.RoleSender:
|
|
153
|
+
require.Equal(t, addrs.baseAddr, basePacketData.Sender)
|
|
154
|
+
packetData.Sender = addrs.addr
|
|
155
|
+
case types.RoleReceiver:
|
|
156
|
+
require.Equal(t, addrs.baseAddr, basePacketData.Receiver)
|
|
157
|
+
packetData.Receiver = addrs.addr
|
|
158
|
+
default:
|
|
159
|
+
t.Fatal("unexpected role", role)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
require.Equal(t, ftPacketData, packetData)
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package types
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
|
+
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
6
|
+
connection "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
|
|
7
|
+
channel "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
|
|
8
|
+
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// ChannelKeeper defines the expected IBC channel keeper
|
|
12
|
+
type ChannelKeeper interface {
|
|
13
|
+
GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channel.Channel, found bool)
|
|
14
|
+
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
|
|
15
|
+
SendPacket(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
16
|
+
WriteAcknowledgement(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
|
|
17
|
+
ChanOpenInit(ctx sdk.Context, order channel.Order, connectionHops []string, portID string,
|
|
18
|
+
portCap *capability.Capability, counterparty channel.Counterparty, version string) (string, *capability.Capability, error)
|
|
19
|
+
WriteOpenInitChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
20
|
+
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
21
|
+
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
22
|
+
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ClientKeeper defines the expected IBC client keeper
|
|
26
|
+
type ClientKeeper interface {
|
|
27
|
+
GetClientConsensusState(ctx sdk.Context, clientID string) (connection ibcexported.ConsensusState, found bool)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ConnectionKeeper defines the expected IBC connection keeper
|
|
31
|
+
type ConnectionKeeper interface {
|
|
32
|
+
GetConnection(ctx sdk.Context, connectionID string) (connection connection.ConnectionEnd, found bool)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// PortKeeper defines the expected IBC port keeper
|
|
36
|
+
type PortKeeper interface {
|
|
37
|
+
BindPort(ctx sdk.Context, portID string) *capability.Capability
|
|
38
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
|
2
|
+
// source: agoric/vtransfer/genesis.proto
|
|
3
|
+
|
|
4
|
+
package types
|
|
5
|
+
|
|
6
|
+
import (
|
|
7
|
+
fmt "fmt"
|
|
8
|
+
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
9
|
+
_ "github.com/gogo/protobuf/gogoproto"
|
|
10
|
+
proto "github.com/gogo/protobuf/proto"
|
|
11
|
+
io "io"
|
|
12
|
+
math "math"
|
|
13
|
+
math_bits "math/bits"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
// Reference imports to suppress errors if they are not otherwise used.
|
|
17
|
+
var _ = proto.Marshal
|
|
18
|
+
var _ = fmt.Errorf
|
|
19
|
+
var _ = math.Inf
|
|
20
|
+
|
|
21
|
+
// This is a compile-time assertion to ensure that this generated file
|
|
22
|
+
// is compatible with the proto package it is being compiled against.
|
|
23
|
+
// A compilation error at this line likely means your copy of the
|
|
24
|
+
// proto package needs to be updated.
|
|
25
|
+
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
|
26
|
+
|
|
27
|
+
// The initial and exported module state.
|
|
28
|
+
type GenesisState struct {
|
|
29
|
+
// The list of account addresses that are being watched by the VM.
|
|
30
|
+
WatchedAddresses []github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,rep,name=watched_addresses,json=watchedAddresses,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"watched_addresses" yaml:"watched_addresses"`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
|
34
|
+
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
|
|
35
|
+
func (*GenesisState) ProtoMessage() {}
|
|
36
|
+
func (*GenesisState) Descriptor() ([]byte, []int) {
|
|
37
|
+
return fileDescriptor_fd0b59a10ad6824e, []int{0}
|
|
38
|
+
}
|
|
39
|
+
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
|
|
40
|
+
return m.Unmarshal(b)
|
|
41
|
+
}
|
|
42
|
+
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
43
|
+
if deterministic {
|
|
44
|
+
return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic)
|
|
45
|
+
} else {
|
|
46
|
+
b = b[:cap(b)]
|
|
47
|
+
n, err := m.MarshalToSizedBuffer(b)
|
|
48
|
+
if err != nil {
|
|
49
|
+
return nil, err
|
|
50
|
+
}
|
|
51
|
+
return b[:n], nil
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
func (m *GenesisState) XXX_Merge(src proto.Message) {
|
|
55
|
+
xxx_messageInfo_GenesisState.Merge(m, src)
|
|
56
|
+
}
|
|
57
|
+
func (m *GenesisState) XXX_Size() int {
|
|
58
|
+
return m.Size()
|
|
59
|
+
}
|
|
60
|
+
func (m *GenesisState) XXX_DiscardUnknown() {
|
|
61
|
+
xxx_messageInfo_GenesisState.DiscardUnknown(m)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
|
|
65
|
+
|
|
66
|
+
func (m *GenesisState) GetWatchedAddresses() []github_com_cosmos_cosmos_sdk_types.AccAddress {
|
|
67
|
+
if m != nil {
|
|
68
|
+
return m.WatchedAddresses
|
|
69
|
+
}
|
|
70
|
+
return nil
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func init() {
|
|
74
|
+
proto.RegisterType((*GenesisState)(nil), "agoric.vtransfer.GenesisState")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func init() { proto.RegisterFile("agoric/vtransfer/genesis.proto", fileDescriptor_fd0b59a10ad6824e) }
|
|
78
|
+
|
|
79
|
+
var fileDescriptor_fd0b59a10ad6824e = []byte{
|
|
80
|
+
// 249 bytes of a gzipped FileDescriptorProto
|
|
81
|
+
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0x4c, 0xcf, 0x2f,
|
|
82
|
+
0xca, 0x4c, 0xd6, 0x2f, 0x2b, 0x29, 0x4a, 0xcc, 0x2b, 0x4e, 0x4b, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd,
|
|
83
|
+
0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0xc8, 0xeb, 0xc1,
|
|
84
|
+
0xe5, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x92, 0xfa, 0x20, 0x16, 0x44, 0x9d, 0xd2, 0x32,
|
|
85
|
+
0x46, 0x2e, 0x1e, 0x77, 0x88, 0xce, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0xa1, 0x7e, 0x46, 0x2e, 0xc1,
|
|
86
|
+
0xf2, 0xc4, 0x92, 0xe4, 0x8c, 0xd4, 0x94, 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0xe2, 0xd4,
|
|
87
|
+
0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x1e, 0xa7, 0xa4, 0x57, 0xf7, 0xe4, 0x31, 0x25, 0x3f, 0xdd,
|
|
88
|
+
0x93, 0x97, 0xa8, 0x4c, 0xcc, 0xcd, 0xb1, 0x52, 0xc2, 0x90, 0x52, 0xfa, 0x75, 0x4f, 0x5e, 0x37,
|
|
89
|
+
0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x39, 0xbf, 0x38, 0x37, 0xbf,
|
|
90
|
+
0x18, 0x4a, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0x39, 0x26, 0x27,
|
|
91
|
+
0x3b, 0x42, 0xf4, 0x04, 0x09, 0x40, 0x0d, 0x71, 0x84, 0x99, 0x61, 0xc5, 0xf2, 0x62, 0x81, 0x3c,
|
|
92
|
+
0x83, 0x53, 0xd8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38,
|
|
93
|
+
0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, 0x20, 0x59,
|
|
94
|
+
0xe0, 0x08, 0x09, 0x15, 0x88, 0xe7, 0xc1, 0x16, 0xa4, 0xe7, 0xe7, 0x24, 0xe6, 0xa5, 0xc3, 0x6c,
|
|
95
|
+
0xae, 0x40, 0x0a, 0x30, 0xb0, 0xd5, 0x49, 0x6c, 0xe0, 0x70, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff,
|
|
96
|
+
0xff, 0x78, 0x52, 0xc9, 0xd5, 0x51, 0x01, 0x00, 0x00,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
|
100
|
+
size := m.Size()
|
|
101
|
+
dAtA = make([]byte, size)
|
|
102
|
+
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
|
103
|
+
if err != nil {
|
|
104
|
+
return nil, err
|
|
105
|
+
}
|
|
106
|
+
return dAtA[:n], nil
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) {
|
|
110
|
+
size := m.Size()
|
|
111
|
+
return m.MarshalToSizedBuffer(dAtA[:size])
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
115
|
+
i := len(dAtA)
|
|
116
|
+
_ = i
|
|
117
|
+
var l int
|
|
118
|
+
_ = l
|
|
119
|
+
if len(m.WatchedAddresses) > 0 {
|
|
120
|
+
for iNdEx := len(m.WatchedAddresses) - 1; iNdEx >= 0; iNdEx-- {
|
|
121
|
+
i -= len(m.WatchedAddresses[iNdEx])
|
|
122
|
+
copy(dAtA[i:], m.WatchedAddresses[iNdEx])
|
|
123
|
+
i = encodeVarintGenesis(dAtA, i, uint64(len(m.WatchedAddresses[iNdEx])))
|
|
124
|
+
i--
|
|
125
|
+
dAtA[i] = 0xa
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return len(dAtA) - i, nil
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
|
|
132
|
+
offset -= sovGenesis(v)
|
|
133
|
+
base := offset
|
|
134
|
+
for v >= 1<<7 {
|
|
135
|
+
dAtA[offset] = uint8(v&0x7f | 0x80)
|
|
136
|
+
v >>= 7
|
|
137
|
+
offset++
|
|
138
|
+
}
|
|
139
|
+
dAtA[offset] = uint8(v)
|
|
140
|
+
return base
|
|
141
|
+
}
|
|
142
|
+
func (m *GenesisState) Size() (n int) {
|
|
143
|
+
if m == nil {
|
|
144
|
+
return 0
|
|
145
|
+
}
|
|
146
|
+
var l int
|
|
147
|
+
_ = l
|
|
148
|
+
if len(m.WatchedAddresses) > 0 {
|
|
149
|
+
for _, b := range m.WatchedAddresses {
|
|
150
|
+
l = len(b)
|
|
151
|
+
n += 1 + l + sovGenesis(uint64(l))
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return n
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
func sovGenesis(x uint64) (n int) {
|
|
158
|
+
return (math_bits.Len64(x|1) + 6) / 7
|
|
159
|
+
}
|
|
160
|
+
func sozGenesis(x uint64) (n int) {
|
|
161
|
+
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
|
162
|
+
}
|
|
163
|
+
func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|
164
|
+
l := len(dAtA)
|
|
165
|
+
iNdEx := 0
|
|
166
|
+
for iNdEx < l {
|
|
167
|
+
preIndex := iNdEx
|
|
168
|
+
var wire uint64
|
|
169
|
+
for shift := uint(0); ; shift += 7 {
|
|
170
|
+
if shift >= 64 {
|
|
171
|
+
return ErrIntOverflowGenesis
|
|
172
|
+
}
|
|
173
|
+
if iNdEx >= l {
|
|
174
|
+
return io.ErrUnexpectedEOF
|
|
175
|
+
}
|
|
176
|
+
b := dAtA[iNdEx]
|
|
177
|
+
iNdEx++
|
|
178
|
+
wire |= uint64(b&0x7F) << shift
|
|
179
|
+
if b < 0x80 {
|
|
180
|
+
break
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
fieldNum := int32(wire >> 3)
|
|
184
|
+
wireType := int(wire & 0x7)
|
|
185
|
+
if wireType == 4 {
|
|
186
|
+
return fmt.Errorf("proto: GenesisState: wiretype end group for non-group")
|
|
187
|
+
}
|
|
188
|
+
if fieldNum <= 0 {
|
|
189
|
+
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
190
|
+
}
|
|
191
|
+
switch fieldNum {
|
|
192
|
+
case 1:
|
|
193
|
+
if wireType != 2 {
|
|
194
|
+
return fmt.Errorf("proto: wrong wireType = %d for field WatchedAddresses", wireType)
|
|
195
|
+
}
|
|
196
|
+
var byteLen int
|
|
197
|
+
for shift := uint(0); ; shift += 7 {
|
|
198
|
+
if shift >= 64 {
|
|
199
|
+
return ErrIntOverflowGenesis
|
|
200
|
+
}
|
|
201
|
+
if iNdEx >= l {
|
|
202
|
+
return io.ErrUnexpectedEOF
|
|
203
|
+
}
|
|
204
|
+
b := dAtA[iNdEx]
|
|
205
|
+
iNdEx++
|
|
206
|
+
byteLen |= int(b&0x7F) << shift
|
|
207
|
+
if b < 0x80 {
|
|
208
|
+
break
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if byteLen < 0 {
|
|
212
|
+
return ErrInvalidLengthGenesis
|
|
213
|
+
}
|
|
214
|
+
postIndex := iNdEx + byteLen
|
|
215
|
+
if postIndex < 0 {
|
|
216
|
+
return ErrInvalidLengthGenesis
|
|
217
|
+
}
|
|
218
|
+
if postIndex > l {
|
|
219
|
+
return io.ErrUnexpectedEOF
|
|
220
|
+
}
|
|
221
|
+
m.WatchedAddresses = append(m.WatchedAddresses, make([]byte, postIndex-iNdEx))
|
|
222
|
+
copy(m.WatchedAddresses[len(m.WatchedAddresses)-1], dAtA[iNdEx:postIndex])
|
|
223
|
+
iNdEx = postIndex
|
|
224
|
+
default:
|
|
225
|
+
iNdEx = preIndex
|
|
226
|
+
skippy, err := skipGenesis(dAtA[iNdEx:])
|
|
227
|
+
if err != nil {
|
|
228
|
+
return err
|
|
229
|
+
}
|
|
230
|
+
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
|
231
|
+
return ErrInvalidLengthGenesis
|
|
232
|
+
}
|
|
233
|
+
if (iNdEx + skippy) > l {
|
|
234
|
+
return io.ErrUnexpectedEOF
|
|
235
|
+
}
|
|
236
|
+
iNdEx += skippy
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if iNdEx > l {
|
|
241
|
+
return io.ErrUnexpectedEOF
|
|
242
|
+
}
|
|
243
|
+
return nil
|
|
244
|
+
}
|
|
245
|
+
func skipGenesis(dAtA []byte) (n int, err error) {
|
|
246
|
+
l := len(dAtA)
|
|
247
|
+
iNdEx := 0
|
|
248
|
+
depth := 0
|
|
249
|
+
for iNdEx < l {
|
|
250
|
+
var wire uint64
|
|
251
|
+
for shift := uint(0); ; shift += 7 {
|
|
252
|
+
if shift >= 64 {
|
|
253
|
+
return 0, ErrIntOverflowGenesis
|
|
254
|
+
}
|
|
255
|
+
if iNdEx >= l {
|
|
256
|
+
return 0, io.ErrUnexpectedEOF
|
|
257
|
+
}
|
|
258
|
+
b := dAtA[iNdEx]
|
|
259
|
+
iNdEx++
|
|
260
|
+
wire |= (uint64(b) & 0x7F) << shift
|
|
261
|
+
if b < 0x80 {
|
|
262
|
+
break
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
wireType := int(wire & 0x7)
|
|
266
|
+
switch wireType {
|
|
267
|
+
case 0:
|
|
268
|
+
for shift := uint(0); ; shift += 7 {
|
|
269
|
+
if shift >= 64 {
|
|
270
|
+
return 0, ErrIntOverflowGenesis
|
|
271
|
+
}
|
|
272
|
+
if iNdEx >= l {
|
|
273
|
+
return 0, io.ErrUnexpectedEOF
|
|
274
|
+
}
|
|
275
|
+
iNdEx++
|
|
276
|
+
if dAtA[iNdEx-1] < 0x80 {
|
|
277
|
+
break
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
case 1:
|
|
281
|
+
iNdEx += 8
|
|
282
|
+
case 2:
|
|
283
|
+
var length int
|
|
284
|
+
for shift := uint(0); ; shift += 7 {
|
|
285
|
+
if shift >= 64 {
|
|
286
|
+
return 0, ErrIntOverflowGenesis
|
|
287
|
+
}
|
|
288
|
+
if iNdEx >= l {
|
|
289
|
+
return 0, io.ErrUnexpectedEOF
|
|
290
|
+
}
|
|
291
|
+
b := dAtA[iNdEx]
|
|
292
|
+
iNdEx++
|
|
293
|
+
length |= (int(b) & 0x7F) << shift
|
|
294
|
+
if b < 0x80 {
|
|
295
|
+
break
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if length < 0 {
|
|
299
|
+
return 0, ErrInvalidLengthGenesis
|
|
300
|
+
}
|
|
301
|
+
iNdEx += length
|
|
302
|
+
case 3:
|
|
303
|
+
depth++
|
|
304
|
+
case 4:
|
|
305
|
+
if depth == 0 {
|
|
306
|
+
return 0, ErrUnexpectedEndOfGroupGenesis
|
|
307
|
+
}
|
|
308
|
+
depth--
|
|
309
|
+
case 5:
|
|
310
|
+
iNdEx += 4
|
|
311
|
+
default:
|
|
312
|
+
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
|
313
|
+
}
|
|
314
|
+
if iNdEx < 0 {
|
|
315
|
+
return 0, ErrInvalidLengthGenesis
|
|
316
|
+
}
|
|
317
|
+
if depth == 0 {
|
|
318
|
+
return iNdEx, nil
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return 0, io.ErrUnexpectedEOF
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
var (
|
|
325
|
+
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
|
|
326
|
+
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
|
|
327
|
+
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
|
|
328
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package types
|
|
2
|
+
|
|
3
|
+
const RouterKey = ModuleName // this was defined in your key.go file
|
|
4
|
+
|
|
5
|
+
type InvokeMemo struct {
|
|
6
|
+
InvokeOnAcknowledgementPacket string `json:"invokeOnAcknowledgementPacket"`
|
|
7
|
+
InvokeOnTimeoutPacket string `json:"invokeOnTimeoutPacket"`
|
|
8
|
+
InvokeWriteAcknowledgement string `json:"invokeWriteAcknowledgement"`
|
|
9
|
+
}
|
package/ante/fee.go
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
package ante
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
|
|
6
|
-
sdkioerrors "cosmossdk.io/errors"
|
|
7
|
-
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
|
-
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
9
|
-
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
// DeductFeeDecorator deducts fees from the first signer of the tx
|
|
13
|
-
// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error
|
|
14
|
-
// Call next AnteHandler if fees successfully deducted
|
|
15
|
-
// CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator
|
|
16
|
-
type DeductFeeDecorator struct {
|
|
17
|
-
ak AccountKeeper
|
|
18
|
-
bankKeeper types.BankKeeper
|
|
19
|
-
feegrantKeeper FeegrantKeeper
|
|
20
|
-
feeCollectorName string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, feeCollectorName string) DeductFeeDecorator {
|
|
24
|
-
return DeductFeeDecorator{
|
|
25
|
-
ak: ak,
|
|
26
|
-
bankKeeper: bk,
|
|
27
|
-
feegrantKeeper: fk,
|
|
28
|
-
feeCollectorName: feeCollectorName,
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
|
|
33
|
-
feeTx, ok := tx.(sdk.FeeTx)
|
|
34
|
-
if !ok {
|
|
35
|
-
return ctx, sdkioerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if addr := dfd.ak.GetModuleAddress(dfd.feeCollectorName); addr == nil {
|
|
39
|
-
return ctx, fmt.Errorf("fee collector module account (%s) has not been set", dfd.feeCollectorName)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
fee := feeTx.GetFee()
|
|
43
|
-
feePayer := feeTx.FeePayer()
|
|
44
|
-
feeGranter := feeTx.FeeGranter()
|
|
45
|
-
|
|
46
|
-
deductFeesFrom := feePayer
|
|
47
|
-
|
|
48
|
-
// if feegranter set deduct fee from feegranter account.
|
|
49
|
-
// this works with only when feegrant enabled.
|
|
50
|
-
if feeGranter != nil {
|
|
51
|
-
if dfd.feegrantKeeper == nil {
|
|
52
|
-
return ctx, sdkioerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee grants are not enabled")
|
|
53
|
-
} else if !feeGranter.Equals(feePayer) {
|
|
54
|
-
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, tx.GetMsgs())
|
|
55
|
-
|
|
56
|
-
if err != nil {
|
|
57
|
-
return ctx, sdkioerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
deductFeesFrom = feeGranter
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
deductFeesFromAcc := dfd.ak.GetAccount(ctx, deductFeesFrom)
|
|
65
|
-
if deductFeesFromAcc == nil {
|
|
66
|
-
return ctx, sdkioerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", deductFeesFrom)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// deduct the fees
|
|
70
|
-
if !feeTx.GetFee().IsZero() {
|
|
71
|
-
err = DeductFees(dfd.bankKeeper, ctx, deductFeesFromAcc, feeTx.GetFee(), dfd.feeCollectorName)
|
|
72
|
-
if err != nil {
|
|
73
|
-
return ctx, err
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx,
|
|
78
|
-
sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()),
|
|
79
|
-
)}
|
|
80
|
-
ctx.EventManager().EmitEvents(events)
|
|
81
|
-
|
|
82
|
-
return next(ctx, tx, simulate)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// DeductFees deducts fees from the given account.
|
|
86
|
-
func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins, feeCollectorName string) error {
|
|
87
|
-
if !fees.IsValid() {
|
|
88
|
-
return sdkioerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), feeCollectorName, fees)
|
|
92
|
-
if err != nil {
|
|
93
|
-
return sdkioerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return nil
|
|
97
|
-
}
|