From 9e59963e4319f1e21c08b0197aec104dc419d407 Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:11:06 +0200 Subject: [PATCH 1/5] Add the compound field --- proto/lum/network/millions/tx.proto | 1 + x/millions/types/tx.pb.go | 220 +++++++++++++++++----------- 2 files changed, 132 insertions(+), 89 deletions(-) diff --git a/proto/lum/network/millions/tx.proto b/proto/lum/network/millions/tx.proto index d07170f8..ee5efb26 100644 --- a/proto/lum/network/millions/tx.proto +++ b/proto/lum/network/millions/tx.proto @@ -126,6 +126,7 @@ message MsgClaimPrize { uint64 draw_id = 2; uint64 prize_id = 3; string winner_address = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + bool compound = 5; } message MsgClaimPrizeResponse {} diff --git a/x/millions/types/tx.pb.go b/x/millions/types/tx.pb.go index 7424ae63..a8ff0156 100644 --- a/x/millions/types/tx.pb.go +++ b/x/millions/types/tx.pb.go @@ -759,6 +759,7 @@ type MsgClaimPrize struct { DrawId uint64 `protobuf:"varint,2,opt,name=draw_id,json=drawId,proto3" json:"draw_id,omitempty"` PrizeId uint64 `protobuf:"varint,3,opt,name=prize_id,json=prizeId,proto3" json:"prize_id,omitempty"` WinnerAddress string `protobuf:"bytes,4,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` + Compound bool `protobuf:"varint,5,opt,name=compound,proto3" json:"compound,omitempty"` } func (m *MsgClaimPrize) Reset() { *m = MsgClaimPrize{} } @@ -822,6 +823,13 @@ func (m *MsgClaimPrize) GetWinnerAddress() string { return "" } +func (m *MsgClaimPrize) GetCompound() bool { + if m != nil { + return m.Compound + } + return false +} + type MsgClaimPrizeResponse struct { } @@ -1278,95 +1286,96 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/tx.proto", fileDescriptor_13b6da814e999511) } var fileDescriptor_13b6da814e999511 = []byte{ - // 1401 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x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, 0x71, - 0x57, 0x81, 0xe9, 0x0f, 0x60, 0x4d, 0x70, 0x96, 0xec, 0x86, 0xe5, 0x60, 0x8f, 0xa3, 0x52, 0x76, - 0x53, 0xdb, 0x5e, 0xdc, 0x5d, 0x37, 0xa4, 0x32, 0x8c, 0x48, 0x19, 0xc6, 0x81, 0x52, 0xce, 0xfe, - 0x42, 0x58, 0xc2, 0x0f, 0x7f, 0x6d, 0x68, 0x66, 0x31, 0x64, 0x8b, 0xa2, 0xee, 0xb1, 0x42, 0x38, - 0x08, 0x01, 0x04, 0x36, 0xea, 0x8d, 0xc4, 0x9e, 0x9b, 0x06, 0x1b, 0xf5, 0x86, 0xb1, 0xbf, 0x80, - 0x55, 0x49, 0x0e, 0xee, 0xb5, 0x5d, 0x19, 0xa3, 0xa0, 0x73, 0x53, 0x40, 0x0b, 0x88, 0x3b, 0x31, - 0x82, 0x84, 0xbe, 0x0b, 0x85, 0x87, 0x18, 0x33, 0x8b, 0x71, 0x74, 0x8a, 0x29, 0x2b, 0xcd, 0x4f, - 0xcd, 0xf7, 0x01, 0xb6, 0xcd, 0xc5, 0x10, 0xe3, 0x58, 0x42, 0xe8, 0x9f, 0xc3, 0x6a, 0x52, 0x99, - 0x82, 0x11, 0x59, 0xed, 0xc2, 0xe4, 0xd5, 0x5e, 0xee, 0x4b, 0x32, 0xe4, 0x43, 0x16, 0x5b, 0x87, - 0x95, 0x8e, 0x98, 0x01, 0x6a, 0x21, 0xc7, 0xa1, 0x98, 0xb1, 0x52, 0x5e, 0xd4, 0x5b, 0xfa, 0xf5, - 0xe7, 0x9d, 0xa2, 0x9a, 0xc3, 0xba, 0xb4, 0x1c, 0x73, 0xea, 0x06, 0x2d, 0x73, 0x59, 0x05, 0xa8, - 0xd3, 0xea, 0x3a, 0xac, 0x5d, 0x98, 0x24, 0x13, 0xb3, 0x36, 0x09, 0x18, 0xae, 0xfe, 0x96, 0x15, - 0x53, 0x66, 0xe2, 0x96, 0xcb, 0x38, 0xa6, 0x47, 0x84, 0x78, 0xfa, 0x3a, 0x2c, 0xd8, 0x27, 0xc8, - 0x0d, 0x2c, 0xd7, 0x91, 0xb3, 0x65, 0xce, 0x8b, 0xe7, 0x86, 0xa3, 0x17, 0x61, 0xce, 0xc1, 0x01, - 0xf1, 0xe5, 0x34, 0x98, 0xf2, 0x41, 0xbf, 0x06, 0x85, 0x00, 0x71, 0xf7, 0x2c, 0xec, 0x7d, 0x68, - 0x14, 0xfa, 0x35, 0x17, 0xe5, 0xd9, 0x81, 0x70, 0xd9, 0x82, 0x25, 0x9b, 0x04, 0x01, 0xb6, 0x45, - 0x1f, 0x5d, 0x47, 0x68, 0x2f, 0x6f, 0x16, 0xfa, 0x87, 0x0d, 0x47, 0xaf, 0x00, 0x9c, 0x21, 0xcf, - 0x75, 0x10, 0x27, 0x94, 0x95, 0xe6, 0x36, 0x67, 0xb7, 0xf3, 0x66, 0xe2, 0x24, 0x65, 0xfc, 0x73, - 0x71, 0xf7, 0x66, 0xfe, 0xd5, 0xf8, 0x1f, 0xc2, 0xd2, 0x80, 0x90, 0x85, 0x2c, 0x16, 0x77, 0xab, - 0xc6, 0xa8, 0x25, 0x6c, 0x24, 0x05, 0xbb, 0x9f, 0x0d, 0x93, 0x9b, 0x05, 0x27, 0x71, 0xa6, 0x1f, - 0xc1, 0xf2, 0xe0, 0x26, 0x51, 0x4a, 0xd8, 0x1a, 0x8d, 0x37, 0xb8, 0x24, 0x24, 0xe0, 0x52, 0x3b, - 0x79, 0xa8, 0xef, 0xc1, 0x6a, 0x13, 0xdb, 0x27, 0x7b, 0xbb, 0x56, 0x9b, 0xe2, 0x87, 0x6e, 0xcf, - 0x42, 0xb6, 0x2d, 0x34, 0x21, 0x05, 0x61, 0x5e, 0x96, 0xd6, 0x23, 0x61, 0xac, 0xdb, 0x76, 0xd8, - 0xfe, 0xe1, 0xa0, 0x33, 0xe4, 0xc9, 0x20, 0x18, 0x0e, 0xba, 0x8f, 0x3c, 0x11, 0x54, 0x87, 0x15, -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0x93, 0x7a, 0xc6, 0xe9, 0x1e, 0x41, 0x71, 0xe4, 0xfc, 0xef, 0x4c, 0x8e, 0x14, 0xf6, - 0xe9, 0x83, 0xa9, 0xdc, 0xe3, 0xec, 0x5f, 0x42, 0xbe, 0x3f, 0xb9, 0xd5, 0xf4, 0x3e, 0x44, 0x3e, - 0xe5, 0x77, 0xc6, 0xfb, 0xc4, 0xe0, 0x8f, 0x35, 0x58, 0x4f, 0x9f, 0xba, 0xdd, 0x54, 0xa4, 0xd4, - 0x98, 0xf2, 0x47, 0xd3, 0xc7, 0x44, 0xd5, 0xec, 0x7f, 0xfa, 0xf4, 0x45, 0x45, 0x7b, 0xf6, 0xa2, - 0xa2, 0xfd, 0xfd, 0xa2, 0xa2, 0x3d, 0x79, 0x59, 0x99, 0x79, 0xf6, 0xb2, 0x32, 0xf3, 0xfb, 0xcb, - 0xca, 0xcc, 0x83, 0x9d, 0xc4, 0xdd, 0xdc, 0xeb, 0xf8, 0x3b, 0xd1, 0x2f, 0x47, 0x02, 0xa7, 0xd6, - 0x4b, 0xfc, 0x62, 0x16, 0x5e, 0xd3, 0x9b, 0x39, 0x71, 0x37, 0xd8, 0xfb, 0x27, 0x00, 0x00, 0xff, - 0xff, 0x54, 0xd3, 0xc7, 0x81, 0x56, 0x13, 0x00, 0x00, + // 1414 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0x3a, 0x8e, 0x13, 0xbf, 0x38, 0x49, 0xbf, 0x5b, 0x37, 0x71, 0xac, 0x6f, 0x9d, 0xd4, + 0x29, 0x55, 0xf8, 0x11, 0x9b, 0x26, 0x42, 0x15, 0x5c, 0x90, 0xd3, 0x14, 0xe4, 0x43, 0xa4, 0x74, + 0xa3, 0x16, 0x28, 0x88, 0xd5, 0x78, 0x77, 0xea, 0xac, 0xb2, 0xbb,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+ 0x56, 0x0e, 0x59, 0xfb, 0x5e, 0x60, 0x23, 0x8e, 0x8f, 0x10, 0x45, 0x1e, 0xd3, 0xbf, 0x02, 0xdd, + 0x73, 0x7c, 0xd3, 0xc6, 0x01, 0x61, 0x0e, 0x37, 0x91, 0x47, 0x3a, 0x3e, 0x2f, 0x69, 0x9b, 0xda, + 0x76, 0x7e, 0xbf, 0xf6, 0xf4, 0xf9, 0x86, 0xf6, 0xc7, 0xf3, 0x8d, 0x1b, 0x6d, 0x87, 0x9f, 0x74, + 0x5a, 0x35, 0x8b, 0x78, 0x2a, 0x4b, 0xf5, 0x67, 0x87, 0xd9, 0xa7, 0x75, 0x7e, 0x1e, 0x60, 0x56, + 0x6b, 0xfa, 0xdc, 0xb8, 0xe4, 0x39, 0xfe, 0x81, 0x04, 0x6a, 0x08, 0x1c, 0xfd, 0x14, 0xca, 0x1e, + 0xea, 0x99, 0x83, 0xd9, 0x98, 0x2d, 0xc4, 0xad, 0x13, 0xcc, 0x4a, 0x99, 0xd7, 0x8a, 0xb2, 0xe6, + 0xa1, 0xde, 0x51, 0x08, 0x78, 0xac, 0xf0, 0xf6, 0x25, 0x9c, 0xde, 0x86, 0x52, 0x3f, 0x98, 0x88, + 0x61, 0x7e, 0xd3, 0x41, 0x3e, 0x77, 0xf8, 0x79, 0x69, 0xf6, 0xb5, 0x42, 0x5d, 0x89, 0x42, 0x89, + 0x10, 0x77, 0x15, 0x98, 0xfe, 0x00, 0xd6, 0x04, 0x67, 0xc9, 0x6a, 0x98, 0x36, 0x76, 0x39, 0x2a, + 0x65, 0x37, 0xb5, 0xed, 0xc5, 0xdd, 0xf5, 0x9a, 0x54, 0x46, 0x2d, 0x52, 0x46, 0xed, 0x40, 0x29, + 0x67, 0x7f, 0x21, 0x4c, 0xe1, 0x87, 0xbf, 0x36, 0x34, 0xa3, 0x18, 0xb2, 0x45, 0x51, 0xf7, 0x58, + 0x21, 0x1c, 0x84, 0x00, 0x02, 0x1b, 0xf5, 0x46, 0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0x5d, 0xa0, 0xfb, + 0x84, 0xb8, 0xf7, 0x91, 0xdb, 0xc1, 0x89, 0x72, 0x8c, 0x66, 0x63, 0x6e, 0x6a, 0x36, 0x4a, 0xb0, + 0x3a, 0x48, 0x46, 0xac, 0x7b, 0x79, 0x97, 0x26, 0x2b, 0x17, 0x1f, 0xfd, 0xac, 0x89, 0xf1, 0x75, + 0xdb, 0x45, 0x8e, 0x27, 0xba, 0x33, 0x9d, 0xc1, 0x35, 0x98, 0x17, 0xa3, 0x23, 0xa6, 0x2f, 0x17, + 0x2e, 0x9b, 0x76, 0x78, 0xf7, 0xca, 0x21, 0xe0, 0xd8, 0x82, 0xb5, 0xac, 0x31, 0x2f, 0xd6, 0x23, + 0x69, 0x9d, 0x52, 0xc9, 0x65, 0x58, 0xb0, 0x88, 0x17, 0x90, 0x8e, 0x6f, 0x2b, 0x1d, 0xc7, 0x6b, + 0xd5, 0xe7, 0xfd, 0xd4, 0xe3, 0x8f, 0xfa, 0x45, 0x13, 0x02, 0xff, 0xcc, 0xe1, 0x27, 0xb6, 0x78, + 0x93, 0x8c, 0xe9, 0xf7, 0xff, 0x44, 0xad, 0xfa, 0x2d, 0x00, 0x4e, 0x26, 0xe6, 0x21, 0xcf, 0x49, + 0x54, 0xd8, 0x06, 0x94, 0x87, 0xbf, 0x26, 0x6e, 0xdb, 0x2d, 0x58, 0xea, 0xaa, 0x23, 0x94, 0xf8, + 0xb6, 0x42, 0x7f, 0xb3, 0x69, 0x57, 0x7f, 0xd4, 0x84, 0x04, 0x86, 0x30, 0x5e, 0xd9, 0xc4, 0x43, + 0xc8, 0x99, 0x61, 0xe4, 0x37, 0xd5, 0xca, 0xd7, 0x60, 0x23, 0x25, 0xbf, 0xb8, 0xaa, 0xdf, 0x6b, + 0x50, 0x08, 0x65, 0x4c, 0x51, 0x77, 0x4c, 0xe2, 0xa9, 0x4a, 0xfd, 0x04, 0x74, 0x71, 0x40, 0x43, + 0xff, 0x29, 0xb2, 0x8d, 0x42, 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a4, 0x54, 0x9f, 0xf2, 0x47, + 0xd3, 0xfb, 0x44, 0xd9, 0xec, 0x7f, 0xfa, 0xf4, 0x45, 0x45, 0x7b, 0xf6, 0xa2, 0xa2, 0xfd, 0xfd, + 0xa2, 0xa2, 0x3d, 0x79, 0x59, 0x99, 0x79, 0xf6, 0xb2, 0x32, 0xf3, 0xfb, 0xcb, 0xca, 0xcc, 0x83, + 0x9d, 0xc4, 0xbb, 0xdd, 0xed, 0x78, 0x3b, 0xd1, 0xaf, 0x4a, 0x02, 0xa7, 0xde, 0x4b, 0xfc, 0x9a, + 0x16, 0x3e, 0xe1, 0x5b, 0x39, 0xf1, 0x6e, 0xd8, 0xfb, 0x27, 0x00, 0x00, 0xff, 0xff, 0x08, 0x94, + 0x11, 0x80, 0x72, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2339,6 +2348,16 @@ func (m *MsgClaimPrize) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Compound { + i-- + if m.Compound { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } if len(m.WinnerAddress) > 0 { i -= len(m.WinnerAddress) copy(dAtA[i:], m.WinnerAddress) @@ -2935,6 +2954,9 @@ func (m *MsgClaimPrize) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.Compound { + n += 2 + } return n } @@ -5036,6 +5058,26 @@ func (m *MsgClaimPrize) Unmarshal(dAtA []byte) error { } m.WinnerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Compound", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Compound = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 1782607bcb083b202462d0ea0666fbfb3cff0983 Mon Sep 17 00:00:00 2001 From: RLM Date: Wed, 6 Sep 2023 22:51:48 +0100 Subject: [PATCH 2/5] Add autocompound option for claimPrize --- app/app.go | 12 + proto/lum/network/millions/deposit.proto | 12 +- proto/lum/network/millions/tx.proto | 3 +- x/millions/client/cli/tx.go | 26 +- x/millions/genesis_test.go | 22 +- x/millions/keeper/keeper_deposit.go | 18 ++ x/millions/keeper/keeper_deposit_test.go | 21 +- x/millions/keeper/keeper_epoch_test.go | 7 + x/millions/keeper/keeper_pool_test.go | 4 + x/millions/keeper/keeper_withdrawal_test.go | 19 ++ x/millions/keeper/msg_server_deposit.go | 2 + x/millions/keeper/msg_server_prize.go | 84 ++++++- x/millions/keeper/msg_server_test.go | 153 ++++++++++-- x/millions/migrations/migrator.go | 6 + x/millions/migrations/v152/store_test.go | 1 + x/millions/migrations/v161/store.go | 21 ++ x/millions/migrations/v161/store_test.go | 189 +++++++++++++++ x/millions/module.go | 5 + x/millions/types/deposit.go | 3 + x/millions/types/deposit.pb.go | 180 +++++++++----- x/millions/types/errors.go | 2 + x/millions/types/events.go | 1 + x/millions/types/keys.go | 2 +- x/millions/types/message_claim_prize.go | 4 + x/millions/types/tx.pb.go | 254 ++++++++++++-------- 25 files changed, 852 insertions(+), 199 deletions(-) create mode 100644 x/millions/migrations/v161/store.go create mode 100644 x/millions/migrations/v161/store_test.go diff --git a/app/app.go b/app/app.go index 21fa6198..7e6a5ff0 100644 --- a/app/app.go +++ b/app/app.go @@ -899,6 +899,13 @@ func (app *App) registerUpgradeHandlers() { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) + app.UpgradeKeeper.SetUpgradeHandler("v1.6.1", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.Logger().Info("Starting v1.6.0 upgrade") + + app.Logger().Info("v1.6.1 upgrade applied") + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) @@ -985,4 +992,9 @@ func (app *App) registerUpgradeHandlers() { storeUpgrades := storetypes.StoreUpgrades{} app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } + + if upgradeInfo.Name == "v1.6.1" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{} + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } } diff --git a/proto/lum/network/millions/deposit.proto b/proto/lum/network/millions/deposit.proto index 599aa7a7..ee8eac28 100644 --- a/proto/lum/network/millions/deposit.proto +++ b/proto/lum/network/millions/deposit.proto @@ -22,6 +22,16 @@ enum DepositState { DEPOSIT_STATE_FAILURE = 4 [ (gogoproto.enumvalue_customname) = "Failure" ]; } +enum DepositOrigin { + option (gogoproto.goproto_enum_prefix) = true; + + DEPOSIT_ORIGIN_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "Unspecified" ]; + DEPOSIT_ORIGIN_DIRECT = 1 [ (gogoproto.enumvalue_customname) = "Direct" ]; + DEPOSIT_ORIGIN_AUTOCOMPOUND = 2 + [ (gogoproto.enumvalue_customname) = "Autocompound" ]; +} + message Deposit { uint64 pool_id = 1; uint64 deposit_id = 2; @@ -35,7 +45,7 @@ message Deposit { string winner_address = 7 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; bool is_sponsor = 8; - reserved 9; + DepositOrigin deposit_origin = 9; int64 created_at_height = 10; int64 updated_at_height = 11; diff --git a/proto/lum/network/millions/tx.proto b/proto/lum/network/millions/tx.proto index 1e0198bf..501260de 100644 --- a/proto/lum/network/millions/tx.proto +++ b/proto/lum/network/millions/tx.proto @@ -127,7 +127,8 @@ message MsgClaimPrize { uint64 draw_id = 2; uint64 prize_id = 3; string winner_address = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - bool compound = 5; + bool is_auto_compound = 5; + bool is_sponsor = 6; } message MsgClaimPrizeResponse {} diff --git a/x/millions/client/cli/tx.go b/x/millions/client/cli/tx.go index 6608222d..f3aa7712 100644 --- a/x/millions/client/cli/tx.go +++ b/x/millions/client/cli/tx.go @@ -238,14 +238,20 @@ $ %s tx %s deposit-edit --winner_address=
--spon func CmdTxClaimPrize() *cobra.Command { cmd := &cobra.Command{ - Use: "claim-prize ", + Use: "claim-prize [autocompound] [sponsor]", Short: "Claim a millions prize", Long: strings.TrimSpace( fmt.Sprintf(`Claim a millions prize to send the funds to the prize winner address. Example: -$ %s tx %s claim-prize `, - version.AppName, types.ModuleName), +$ %s tx %s claim-prize + +To claim a prize and auto compound it (create a new deposit with the prize amount) +$ %s tx %s claim-prize --autocompound=true + +To claim a prize and create a sponsorship from the auto compound deposit (no drawing chances at all) +$ %s tx %s claim-prize --autocompound=true --sponsor=true`, + version.AppName, types.ModuleName, version.AppName, types.ModuleName, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { @@ -275,13 +281,27 @@ $ %s tx %s claim-prize `, return err } + isAutoCompound, err := cmd.Flags().GetBool("autocompound") + if err != nil { + return err + } + + isSponsor, err := cmd.Flags().GetBool("sponsor") + if err != nil { + return err + } + // Build the message msg := types.NewMsgMsgClaimPrize(clientCtx.GetFromAddress().String(), poolID, drawID, prizeID) + msg.IsAutoCompound = isAutoCompound + msg.IsSponsor = isSponsor // Generate the transaction return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) }, } + cmd.Flags().Bool("autocompound", false, "(optional) creates a new auto compound deposit with the prize amount") + cmd.Flags().Bool("sponsor", false, "(optional) active sponsor mode for the new auto compound deposit") flags.AddTxFlagsToCmd(cmd) _ = cmd.MarkFlagRequired(flags.FlagFrom) return cmd diff --git a/x/millions/genesis_test.go b/x/millions/genesis_test.go index 6b2ae5bd..8d4a57b5 100644 --- a/x/millions/genesis_test.go +++ b/x/millions/genesis_test.go @@ -78,17 +78,17 @@ var testGenesis = millionstypes.GenesisState{ }, }, Deposits: []millionstypes.Deposit{ - {PoolId: 1, DepositId: 1, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(100)), State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 1, DepositId: 2, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(101)), State: millionstypes.DepositState_IcaDelegate}, - {PoolId: 1, DepositId: 3, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(102)), State: millionstypes.DepositState_Success}, - {PoolId: 1, DepositId: 4, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(103)), State: millionstypes.DepositState_Failure}, - {PoolId: 1, DepositId: 5, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-1", sdk.NewInt(104)), State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 2, DepositId: 6, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-2", sdk.NewInt(200)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 2, DepositId: 7, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(201)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 2, DepositId: 8, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(202)), State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 3, DepositId: 9, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(300)), State: millionstypes.DepositState_Success}, - {PoolId: 3, DepositId: 10, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(301)), State: millionstypes.DepositState_Success}, - {PoolId: 4, DepositId: 11, DepositorAddress: testAccs[5], WinnerAddress: testAccs[5], Amount: sdk.NewCoin("denom-4", sdk.NewInt(400)), State: millionstypes.DepositState_Success}, + {PoolId: 1, DepositId: 1, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(100)), State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 2, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(101)), State: millionstypes.DepositState_IcaDelegate, DepositOrigin: millionstypes.DepositOrigin_Autocompound}, + {PoolId: 1, DepositId: 3, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(102)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 4, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(103)), State: millionstypes.DepositState_Failure, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 5, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-1", sdk.NewInt(104)), State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 6, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-2", sdk.NewInt(200)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 7, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(201)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 8, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(202)), State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 3, DepositId: 9, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(300)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 3, DepositId: 10, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(301)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Direct}, + {PoolId: 4, DepositId: 11, DepositorAddress: testAccs[5], WinnerAddress: testAccs[5], Amount: sdk.NewCoin("denom-4", sdk.NewInt(400)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Autocompound}, }, Draws: []millionstypes.Draw{ {PoolId: 1, DrawId: 1, RandSeed: 10, TotalWinCount: 100, TotalWinAmount: sdk.NewInt(1000)}, diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index f705496c..9a64fd2d 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -329,6 +329,24 @@ func (k Keeper) hasPoolDeposit(ctx sdk.Context, address string, poolID uint64) b return iterator.Valid() } +// UnsafeUpdateAutoCompoundDeposits raw updates deposit's origin +// It's heavily unsafe and should only be used by store migrations +func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, deposit types.Deposit) (types.Deposit, error) { + // Acquire the deposit + deposit, err := k.GetPoolDeposit(ctx, deposit.PoolId, deposit.DepositId) + if err != nil { + return types.Deposit{}, err + } + + deposit.DepositOrigin = types.DepositOrigin_Direct + // Update pool deposits + k.setPoolDeposit(ctx, &deposit) + // Update account deposits + k.setAccountDeposit(ctx, &deposit) + + return deposit, nil +} + // ListPoolDeposits returns all deposits for a given poolID // Warning: expensive operation func (k Keeper) ListPoolDeposits(ctx sdk.Context, poolID uint64) (deposits []types.Deposit) { diff --git a/x/millions/keeper/keeper_deposit_test.go b/x/millions/keeper/keeper_deposit_test.go index 28eed3d9..23ad8fde 100644 --- a/x/millions/keeper/keeper_deposit_test.go +++ b/x/millions/keeper/keeper_deposit_test.go @@ -31,6 +31,7 @@ func (suite *KeeperTestSuite) TestDeposit_IDsGeneration() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) // Test that depositID is incremented suite.Require().Equal(uint64(i+1), depositID) @@ -43,6 +44,7 @@ func (suite *KeeperTestSuite) TestDeposit_IDsGeneration() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -103,6 +105,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -122,6 +125,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[1].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().NotPanics(panicF) @@ -134,6 +138,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -152,6 +157,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -164,6 +170,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -176,6 +183,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: "", State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -190,6 +198,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -298,6 +307,7 @@ func (suite *KeeperTestSuite) TestDeposit_RemoveDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -312,6 +322,7 @@ func (suite *KeeperTestSuite) TestDeposit_RemoveDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } suite.Require().NotPanics(panicF) @@ -482,6 +493,7 @@ func (suite *KeeperTestSuite) TestDeposit_UpdateDepositStatus() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -580,6 +592,7 @@ func (suite *KeeperTestSuite) TestDeposit_EditDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -669,6 +682,7 @@ func (suite *KeeperTestSuite) TestDeposit_TransferDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -748,6 +762,7 @@ func (suite *KeeperTestSuite) TestDeposit_TransferDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -822,6 +837,7 @@ func (suite *KeeperTestSuite) TestDeposit_DelegateDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -897,6 +913,7 @@ func (suite *KeeperTestSuite) TestDeposit_DelegateDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -982,6 +999,7 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) @@ -1012,7 +1030,6 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { suite.Require().NoError(err) // For remote pools we don't reach the success as k.BroadcastICAMessages fails on OnDelegateDepositOnRemoteZoneCompleted - // Balance should remain unchanged balance = app.BankKeeper.GetBalance(ctx, uatomAddresses[0], "uatom") suite.Require().Equal(balanceBefore.Amount.Int64()-1_000_000, balance.Amount.Int64()) @@ -1069,6 +1086,7 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(2_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(2_000_000))}) suite.Require().NoError(err) @@ -1189,6 +1207,7 @@ func (suite *KeeperTestSuite) TestDeposit_FullDepositProcess() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_epoch_test.go b/x/millions/keeper/keeper_epoch_test.go index fafa80e8..05399f76 100644 --- a/x/millions/keeper/keeper_epoch_test.go +++ b/x/millions/keeper/keeper_epoch_test.go @@ -65,6 +65,7 @@ func (suite *KeeperTestSuite) TestEpoch_BeforeEpochStartHook() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -204,6 +205,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -257,6 +259,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -342,6 +345,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddWithdrawalsToNextAvailableEpoch() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -421,6 +425,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddWithdrawalsToNextAvailableEpoch() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -510,6 +515,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddFailedIcaUndelegationsToEpochUnbondin WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } deposits := app.MillionsKeeper.ListDeposits(ctx) @@ -605,6 +611,7 @@ func (suite *KeeperTestSuite) TestEpoch_RemoveEpochUnbonding() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } deposits := app.MillionsKeeper.ListDeposits(ctx) diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index c40b3ad1..6814a773 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -812,6 +812,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(111)), + DepositOrigin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d1) d2 := millionstypes.Deposit{ @@ -821,6 +822,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[1].String(), WinnerAddress: suite.addrs[1].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(222)), + DepositOrigin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d2) d3 := millionstypes.Deposit{ @@ -830,6 +832,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[2].String(), WinnerAddress: suite.addrs[2].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(333)), + DepositOrigin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d3) @@ -1164,6 +1167,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(5_000_000)), DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) pool, err = app.MillionsKeeper.GetPool(ctx, 2) suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_withdrawal_test.go b/x/millions/keeper/keeper_withdrawal_test.go index 3ac31fc9..14b382f4 100644 --- a/x/millions/keeper/keeper_withdrawal_test.go +++ b/x/millions/keeper/keeper_withdrawal_test.go @@ -111,6 +111,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -141,6 +142,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } @@ -169,6 +171,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) suite.Require().Len(withdrawals, 5) @@ -584,6 +587,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) @@ -622,6 +626,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) @@ -709,6 +714,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -746,6 +752,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) // There should be ne more deposits deposits = app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) @@ -832,6 +839,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -863,6 +871,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -930,6 +939,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -960,6 +970,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) // There should be no more deposits @@ -1029,6 +1040,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BankSend() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1060,6 +1072,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BankSend() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -1144,6 +1157,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1175,6 +1189,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -1229,6 +1244,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1259,6 +1275,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) // There should be no more deposits @@ -1386,6 +1403,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BalanceWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) // Send coin err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) @@ -1404,6 +1422,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BalanceWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) diff --git a/x/millions/keeper/msg_server_deposit.go b/x/millions/keeper/msg_server_deposit.go index 67e80c5a..ad8839ce 100644 --- a/x/millions/keeper/msg_server_deposit.go +++ b/x/millions/keeper/msg_server_deposit.go @@ -61,6 +61,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types Amount: msg.Amount, WinnerAddress: winnerAddress.String(), IsSponsor: msg.GetIsSponsor(), + DepositOrigin: types.DepositOrigin_Direct, CreatedAtHeight: ctx.BlockHeight(), UpdatedAtHeight: ctx.BlockHeight(), CreatedAt: ctx.BlockTime(), @@ -93,6 +94,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types sdk.NewAttribute(types.AttributeKeyWinner, deposit.WinnerAddress), sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(msg.IsSponsor)), + sdk.NewAttribute(types.AttributeKeyDepositOrigin, deposit.DepositOrigin.String()), ), }) diff --git a/x/millions/keeper/msg_server_prize.go b/x/millions/keeper/msg_server_prize.go index 3d7ba3b6..95ec2e45 100644 --- a/x/millions/keeper/msg_server_prize.go +++ b/x/millions/keeper/msg_server_prize.go @@ -4,6 +4,7 @@ import ( "context" "strconv" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/lum-network/chain/x/millions/types" @@ -39,7 +40,88 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( return nil, types.ErrPoolNotFound } - // Move funds + if msg.IsAutoCompound { + // Move claim prize fund to winner address + if err := k.BankKeeper.SendCoins( + ctx, + sdk.MustAccAddressFromBech32(pool.GetLocalAddress()), + winnerAddr, + sdk.NewCoins(prize.Amount), + ); err != nil { + return nil, err + } + + // New deposit instance + deposit := types.Deposit{ + PoolId: pool.PoolId, + State: types.DepositState_IbcTransfer, + DepositorAddress: winnerAddr.String(), + Amount: prize.Amount, + WinnerAddress: winnerAddr.String(), + IsSponsor: msg.GetIsSponsor(), + DepositOrigin: types.DepositOrigin_Autocompound, + CreatedAtHeight: ctx.BlockHeight(), + UpdatedAtHeight: ctx.BlockHeight(), + CreatedAt: ctx.BlockTime(), + UpdatedAt: ctx.BlockTime(), + } + + // Remove prize entity + if err := k.RemovePrize(ctx, prize); err != nil { + return nil, err + } + + // Check pool state before being able to deposit + if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { + return nil, errorsmod.Wrapf( + types.ErrInvalidPoolState, "cannot deposit in pool during state %s", pool.State.String(), + ) + } + + // Double check if deposit denom issued from prize is suitable for pool + if deposit.Amount.Denom != pool.Denom { + return nil, types.ErrInvalidDepositDenom + } + + // Move funds to pool + poolRunner, err := k.GetPoolRunner(pool.PoolType) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidPoolType, err.Error()) + } + if err := poolRunner.SendDepositToPool(ctx, pool, deposit); err != nil { + return nil, err + } + + // Store deposit + k.AddDeposit(ctx, &deposit) + + // Emit event + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + sdk.NewEvent( + types.EventTypeDeposit, + sdk.NewAttribute(types.AttributeKeyPoolID, strconv.FormatUint(deposit.PoolId, 10)), + sdk.NewAttribute(types.AttributeKeyDepositID, strconv.FormatUint(deposit.DepositId, 10)), + sdk.NewAttribute(types.AttributeKeyDepositor, deposit.DepositorAddress), + sdk.NewAttribute(types.AttributeKeyWinner, deposit.WinnerAddress), + sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), + sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(msg.IsSponsor)), + sdk.NewAttribute(types.AttributeKeyDepositOrigin, deposit.DepositOrigin.String()), + ), + }) + + // Transfer to appropriate zone + if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { + return nil, err + } + + return nil, nil + } + + // Move funds for a simple claim if err := k.BankKeeper.SendCoins( ctx, sdk.MustAccAddressFromBech32(pool.GetLocalAddress()), diff --git a/x/millions/keeper/msg_server_test.go b/x/millions/keeper/msg_server_test.go index f04c644c..908c19a9 100644 --- a/x/millions/keeper/msg_server_test.go +++ b/x/millions/keeper/msg_server_test.go @@ -481,6 +481,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -540,6 +541,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -563,6 +565,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], suite.moduleAddrs[0], sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -611,6 +614,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositEdit() { State: millionstypes.DepositState_Success, ErrorState: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -829,6 +833,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) deposits := app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) @@ -844,6 +849,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Failure, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) // List deposits deposits := app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) @@ -974,6 +980,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) err = app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[2].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) @@ -1051,6 +1058,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDepositRetry() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1186,6 +1194,20 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { }) app.MillionsKeeper.AddPool(ctx, pool) + _, err := app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + + // Add a deposit + app.MillionsKeeper.AddDeposit(ctx, &millionstypes.Deposit{ + PoolId: poolID, + DepositorAddress: suite.addrs[0].String(), + WinnerAddress: suite.addrs[0].String(), + State: millionstypes.DepositState_Failure, + ErrorState: millionstypes.DepositState_IbcTransfer, + Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(500_000)), + DepositOrigin: millionstypes.DepositOrigin_Direct, + }) + // Create prizes at various stages app.MillionsKeeper.AddPrize(ctx, millionstypes.Prize{ PoolId: poolID, @@ -1249,27 +1271,120 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { suite.Require().Error(err) suite.Require().ErrorIs(err, millionstypes.ErrPrizeNotFound) + // Test claim autocompound without sponsorship + prizes = app.MillionsKeeper.ListPrizes(ctx) + addr := sdk.MustAccAddressFromBech32(prizes[0].WinnerAddress) + // Get the module balance before claimPrize + moduleBalanceBefore := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().Equal(sdk.NewCoin(localPoolDenom, sdk.NewInt(6_000_000)), moduleBalanceBefore) + // Get the balance before claimPrize + accountBalanceBefore := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + // Check pool tvl + p1, err := app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(0), p1.SponsorshipAmount) + // claimPrize + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: prizes[0].PoolId, + DrawId: prizes[0].DrawId, + PrizeId: prizes[0].PrizeId, + WinnerAddress: addr.String(), + IsAutoCompound: true, + }) + suite.Require().NoError(err) + // Account balance should have not moved (as directly re-deposited) + accountBalance := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + suite.Require().True(accountBalanceBefore.Equal(accountBalance)) + // The new moduleBalance should be less 1_000_000 which is the prize amount + expectedModuleBalance := moduleBalanceBefore.Sub(prizes[0].Amount) + moduleBalance := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) + // There should be 2 prizes left prizes = app.MillionsKeeper.ListPrizes(ctx) + suite.Require().Len(prizes, 2) + // There should be a new deposit + deposits := app.MillionsKeeper.ListDeposits(ctx) + suite.Require().Len(deposits, 2) + suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[1].DepositOrigin) + suite.Require().Equal(millionstypes.DepositState_Success, deposits[1].State) + suite.Require().Equal(millionstypes.DepositState_Unspecified, deposits[1].ErrorState) + // Pool tvl should have increased by 1_000_000 + p1, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(1_500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(0), p1.SponsorshipAmount) - for _, prize := range prizes { - addr := sdk.MustAccAddressFromBech32(prize.WinnerAddress) - // Get the module balance before claimPrize - moduleBalanceBefore := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) - // Get the balance before claimPrize - balanceBefore := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) - // claimPrize - _, err = msgServer.ClaimPrize(goCtx, millionstypes.NewMsgMsgClaimPrize(addr.String(), prize.PoolId, prize.DrawId, prize.PrizeId)) - suite.Require().NoError(err) - // Compare the new balance with the expected balance - balance := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) - expectedBalance := balanceBefore.Add(prize.Amount) - suite.Require().True(expectedBalance.Equal(balance)) - // Compare the new module balance with the expected module balance - expectedModuleBalance := moduleBalanceBefore.Sub(prize.Amount) - moduleBalance := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) - suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) - } - // There should be no more prizes + // Test claim autocompound with sponsorship + prizes = app.MillionsKeeper.ListPrizes(ctx) + addr = sdk.MustAccAddressFromBech32(prizes[0].WinnerAddress) + // Get the module balance before claimPrize + moduleBalanceBefore = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().Equal(sdk.NewCoin(localPoolDenom, sdk.NewInt(5_000_000)), moduleBalanceBefore) + // Get the balance before claimPrize + accountBalanceBefore = app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + // Check pool tvl + p1, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(1_500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(0), p1.SponsorshipAmount) + // claimPrize + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: prizes[0].PoolId, + DrawId: prizes[0].DrawId, + PrizeId: prizes[0].PrizeId, + WinnerAddress: addr.String(), + IsAutoCompound: true, + IsSponsor: true, + }) + suite.Require().NoError(err) + // Account balance should have not moved (as directly re-deposited) + accountBalance = app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + suite.Require().True(accountBalanceBefore.Equal(accountBalance)) + // The new moduleBalance should be less 2_000_000 which is the prize amount + expectedModuleBalance = moduleBalanceBefore.Sub(prizes[0].Amount) + moduleBalance = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) + // There should be 1 prizes left + prizes = app.MillionsKeeper.ListPrizes(ctx) + suite.Require().Len(prizes, 1) + // There should be a new deposit + deposits = app.MillionsKeeper.ListDeposits(ctx) + suite.Require().Len(deposits, 3) + suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[2].DepositOrigin) + suite.Require().Equal(millionstypes.DepositState_Success, deposits[2].State) + suite.Require().Equal(millionstypes.DepositState_Unspecified, deposits[2].ErrorState) + // Pool tvl should have increased by 2_000_000 + p1, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(3_500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(2_000_000), p1.SponsorshipAmount) + + // Test last prize as normal claim + prizes = app.MillionsKeeper.ListPrizes(ctx) + suite.Require().Len(prizes, 1) + addr = sdk.MustAccAddressFromBech32(prizes[0].WinnerAddress) + // Get the module balance before claimPrize + moduleBalanceBefore = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + // Get the balance before claimPrize + accountBalanceBefore = app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + // claimPrize + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: prizes[0].PoolId, + DrawId: prizes[0].DrawId, + PrizeId: prizes[0].PrizeId, + WinnerAddress: addr.String(), + }) + suite.Require().NoError(err) + // Account balance should have increased by the prize amount as it's a simple claim + balance := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + expectedBalance := accountBalanceBefore.Add(prizes[0].Amount) + suite.Require().True(expectedBalance.Equal(balance)) + // The new moduleBalance should be less 3_000_000 which is the prize amount + expectedModuleBalance = moduleBalanceBefore.Sub(prizes[0].Amount) + moduleBalance = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) + // There should be no prize left prizes = app.MillionsKeeper.ListPrizes(ctx) suite.Require().Len(prizes, 0) } diff --git a/x/millions/migrations/migrator.go b/x/millions/migrations/migrator.go index 603a614c..fcf996a2 100644 --- a/x/millions/migrations/migrator.go +++ b/x/millions/migrations/migrator.go @@ -7,6 +7,7 @@ import ( v150 "github.com/lum-network/chain/x/millions/migrations/v150" v152 "github.com/lum-network/chain/x/millions/migrations/v152" v160 "github.com/lum-network/chain/x/millions/migrations/v160" + v161 "github.com/lum-network/chain/x/millions/migrations/v161" ) type Migrator struct { @@ -31,3 +32,8 @@ func (m Migrator) Migrate2To3(ctx sdk.Context) error { func (m Migrator) Migrate3To4(ctx sdk.Context) error { return v160.MigratePoolTypeAndUnbondingFrequency(ctx, m.keeper) } + +// Migrate4To5 migrates from version 4 to 5 +func (m Migrator) Migrate4To5(ctx sdk.Context) error { + return v161.MigrateAutoCompoundDeposits(ctx, m.keeper) +} diff --git a/x/millions/migrations/v152/store_test.go b/x/millions/migrations/v152/store_test.go index 783425be..b1f535f6 100644 --- a/x/millions/migrations/v152/store_test.go +++ b/x/millions/migrations/v152/store_test.go @@ -169,6 +169,7 @@ func (suite *StoreMigrationTestSuite) TestMigrateUndelegations() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("ulum", sdk.NewInt(1_000_0)), + DepositOrigin: millionstypes.DepositOrigin_Direct, }) } diff --git a/x/millions/migrations/v161/store.go b/x/millions/migrations/v161/store.go new file mode 100644 index 00000000..e9ceb25b --- /dev/null +++ b/x/millions/migrations/v161/store.go @@ -0,0 +1,21 @@ +package v161 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + millionskeeper "github.com/lum-network/chain/x/millions/keeper" +) + +func MigrateAutoCompoundDeposits(ctx sdk.Context, k millionskeeper.Keeper) error { + ctx.Logger().Info("Processing autocompound deposits") + + deposits := k.ListDeposits(ctx) + for _, d := range deposits { + if _, err := k.UnsafeUpdateAutoCompoundDeposits(ctx, d); err != nil { + panic(err) + } + } + + ctx.Logger().Info("Successfully updated deposits with autocompound state") + return nil +} diff --git a/x/millions/migrations/v161/store_test.go b/x/millions/migrations/v161/store_test.go new file mode 100644 index 00000000..6eab90a4 --- /dev/null +++ b/x/millions/migrations/v161/store_test.go @@ -0,0 +1,189 @@ +package v161_test + +import ( + "testing" + "time" + + icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + + apptesting "github.com/lum-network/chain/app/testing" + + "github.com/stretchr/testify/suite" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + apptypes "github.com/lum-network/chain/app" + v161 "github.com/lum-network/chain/x/millions/migrations/v161" + millionstypes "github.com/lum-network/chain/x/millions/types" +) + +type StoreMigrationTestSuite struct { + suite.Suite + + ctx sdk.Context + app *apptypes.App + addrs []sdk.AccAddress + moduleAddrs []sdk.AccAddress + valAddrs []sdk.ValAddress +} + +// newValidPool fills up missing params to the pool to make it valid in order to ease testing +func newValidPool(suite *StoreMigrationTestSuite, pool millionstypes.Pool) *millionstypes.Pool { + params := suite.app.MillionsKeeper.GetParams(suite.ctx) + + if pool.Denom == "" { + pool.Denom = suite.app.StakingKeeper.BondDenom(suite.ctx) + } + if pool.NativeDenom == "" { + pool.NativeDenom = suite.app.StakingKeeper.BondDenom(suite.ctx) + } + if pool.ChainId == "" { + pool.ChainId = "lum-network-devnet" + } + + if pool.PoolType == millionstypes.PoolType_Unspecified { + pool.PoolType = millionstypes.PoolType_Staking + } + + if pool.UnbondingDuration == 0 { + pool.UnbondingDuration = millionstypes.DefaultUnbondingDuration + } + if pool.MaxUnbondingEntries.IsNil() { + pool.MaxUnbondingEntries = sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries) + } + + if pool.Validators == nil { + for _, addr := range suite.valAddrs { + pool.Validators = append(pool.Validators, millionstypes.PoolValidator{ + OperatorAddress: addr.String(), + BondedAmount: sdk.ZeroInt(), + IsEnabled: true, + }) + } + } + if pool.Bech32PrefixAccAddr == "" { + pool.Bech32PrefixAccAddr = sdk.GetConfig().GetBech32AccountAddrPrefix() + } + if pool.Bech32PrefixValAddr == "" { + pool.Bech32PrefixValAddr = sdk.GetConfig().GetBech32ValidatorAddrPrefix() + } + if pool.MinDepositAmount.IsNil() { + pool.MinDepositAmount = params.MinDepositAmount + } + if err := pool.DrawSchedule.ValidateBasic(params); err != nil { + pool.DrawSchedule = millionstypes.DrawSchedule{DrawDelta: 1 * time.Hour, InitialDrawAt: time.Now().UTC()} + } + if err := pool.PrizeStrategy.Validate(params); err != nil { + pool.PrizeStrategy = millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 1, DrawProbability: sdk.NewDec(1)}}} + } + if pool.LocalAddress == "" { + pool.LocalAddress = suite.moduleAddrs[0].String() + } + if pool.IcaDepositAddress == "" { + pool.IcaDepositAddress = suite.moduleAddrs[1].String() + } + if pool.IcaPrizepoolAddress == "" { + pool.IcaPrizepoolAddress = suite.moduleAddrs[2].String() + } + if pool.NextDrawId == millionstypes.UnknownID { + pool.NextDrawId = millionstypes.UnknownID + 1 + } + if pool.TvlAmount.IsNil() { + pool.TvlAmount = sdk.ZeroInt() + } + if pool.SponsorshipAmount.IsNil() { + pool.SponsorshipAmount = sdk.ZeroInt() + } + if pool.AvailablePrizePool.IsNil() { + pool.AvailablePrizePool = sdk.NewCoin(pool.Denom, sdk.ZeroInt()) + } + if pool.State == millionstypes.PoolState_Unspecified { + pool.State = millionstypes.PoolState_Ready + } + if pool.CreatedAt.IsZero() { + pool.CreatedAt = suite.ctx.BlockTime() + } + if pool.UpdatedAt.IsZero() { + pool.UpdatedAt = suite.ctx.BlockTime() + } + if pool.IcaDepositPortId == "" { + pool.IcaDepositPortId = icatypes.ControllerPortPrefix + string(millionstypes.NewPoolName(pool.GetPoolId(), millionstypes.ICATypeDeposit)) + } + if pool.IcaPrizepoolPortId == "" { + pool.IcaPrizepoolPortId = icatypes.ControllerPortPrefix + string(millionstypes.NewPoolName(pool.GetPoolId(), millionstypes.ICATypePrizePool)) + } + return &pool +} + +func (suite *StoreMigrationTestSuite) SetupTest() { + app := apptypes.SetupForTesting(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + // Setup the default application + suite.app = app + suite.ctx = ctx.WithChainID("lum-network-devnet").WithBlockTime(time.Now().UTC()) + + // Setup test account addresses + suite.addrs = apptesting.AddTestAddrsWithDenom(app, ctx, 6, sdk.NewInt(10_000_000_000), app.StakingKeeper.BondDenom(ctx)) + for i := 0; i < 6; i++ { + poolAddress := millionstypes.NewPoolAddress(uint64(i+1), "unused-in-test") + apptesting.AddTestModuleAccount(app, ctx, poolAddress) + suite.moduleAddrs = append(suite.moduleAddrs, poolAddress) + } + + // Setup vals for pools + vals := app.StakingKeeper.GetAllValidators(ctx) + suite.valAddrs = []sdk.ValAddress{} + for _, v := range vals { + addr, err := sdk.ValAddressFromBech32(v.OperatorAddress) + suite.Require().NoError(err) + suite.valAddrs = append(suite.valAddrs, addr) + } + + // Setup test params + suite.app.MillionsKeeper.SetParams(ctx, millionstypes.Params{ + MinDepositAmount: sdk.NewInt(millionstypes.MinAcceptableDepositAmount), + MaxPrizeStrategyBatches: 1_000, + MaxPrizeBatchQuantity: 1_000_000, + MinDrawScheduleDelta: 1 * time.Hour, + MaxDrawScheduleDelta: 366 * 24 * time.Hour, + PrizeExpirationDelta: 30 * 24 * time.Hour, + FeesStakers: sdk.ZeroDec(), + MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, + }) +} + +func (suite *StoreMigrationTestSuite) TestMigrateAutoCompoundDeposits() { + poolID := suite.app.MillionsKeeper.GetNextPoolIDAndIncrement(suite.ctx) + suite.app.MillionsKeeper.AddPool(suite.ctx, newValidPool(suite, millionstypes.Pool{PoolId: poolID})) + + // Grab our pool entity + pool, err := suite.app.MillionsKeeper.GetPool(suite.ctx, poolID) + suite.Require().NoError(err) + + for i := 0; i < 5; i++ { + suite.app.MillionsKeeper.AddDeposit(suite.ctx, &millionstypes.Deposit{ + PoolId: pool.PoolId, + DepositorAddress: suite.addrs[i].String(), + WinnerAddress: suite.addrs[i].String(), + State: millionstypes.DepositState_IbcTransfer, + Amount: sdk.NewCoin("ulum", sdk.NewInt(1_000_0)), + DepositOrigin: millionstypes.DepositOrigin_Autocompound, + }) + } + + // Run the migration operation + err = v161.MigrateAutoCompoundDeposits(suite.ctx, *suite.app.MillionsKeeper) + suite.Require().NoError(err) + + deposits := suite.app.MillionsKeeper.ListDeposits(suite.ctx) + for _, d := range deposits { + suite.Require().Equal(millionstypes.DepositOrigin_Direct, d.DepositOrigin) + } + +} + +func TestKeeperSuite(t *testing.T) { + suite.Run(t, new(StoreMigrationTestSuite)) +} diff --git a/x/millions/module.go b/x/millions/module.go index ff166fbf..ca47fb99 100644 --- a/x/millions/module.go +++ b/x/millions/module.go @@ -140,6 +140,11 @@ func (a AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } + + err = cfg.RegisterMigration(types.ModuleName, 4, migrator.Migrate4To5) + if err != nil { + panic(err) + } } func (a AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/millions/types/deposit.go b/x/millions/types/deposit.go index 5880632f..4a7cb64b 100644 --- a/x/millions/types/deposit.go +++ b/x/millions/types/deposit.go @@ -17,6 +17,9 @@ func (deposit *Deposit) ValidateBasic() error { if deposit.State == DepositState_Unspecified { return errorsmod.Wrapf(ErrInvalidDepositState, "no state specified") } + if deposit.DepositOrigin == DepositOrigin_Unspecified { + return errorsmod.Wrapf(ErrInvalidDepositOriginState, "no state specified") + } if _, err := sdk.AccAddressFromBech32(deposit.DepositorAddress); err != nil { return errorsmod.Wrapf(ErrInvalidDepositorAddress, err.Error()) } diff --git a/x/millions/types/deposit.pb.go b/x/millions/types/deposit.pb.go index 0979d879..6cff08dc 100644 --- a/x/millions/types/deposit.pb.go +++ b/x/millions/types/deposit.pb.go @@ -64,19 +64,48 @@ func (DepositState) EnumDescriptor() ([]byte, []int) { return fileDescriptor_5252614e94b18a0e, []int{0} } +type DepositOrigin int32 + +const ( + DepositOrigin_Unspecified DepositOrigin = 0 + DepositOrigin_Direct DepositOrigin = 1 + DepositOrigin_Autocompound DepositOrigin = 2 +) + +var DepositOrigin_name = map[int32]string{ + 0: "DEPOSIT_ORIGIN_UNSPECIFIED", + 1: "DEPOSIT_ORIGIN_DIRECT", + 2: "DEPOSIT_ORIGIN_AUTOCOMPOUND", +} + +var DepositOrigin_value = map[string]int32{ + "DEPOSIT_ORIGIN_UNSPECIFIED": 0, + "DEPOSIT_ORIGIN_DIRECT": 1, + "DEPOSIT_ORIGIN_AUTOCOMPOUND": 2, +} + +func (x DepositOrigin) String() string { + return proto.EnumName(DepositOrigin_name, int32(x)) +} + +func (DepositOrigin) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_5252614e94b18a0e, []int{1} +} + type Deposit struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - DepositId uint64 `protobuf:"varint,2,opt,name=deposit_id,json=depositId,proto3" json:"deposit_id,omitempty"` - State DepositState `protobuf:"varint,3,opt,name=state,proto3,enum=lum.network.millions.DepositState" json:"state,omitempty"` - ErrorState DepositState `protobuf:"varint,4,opt,name=error_state,json=errorState,proto3,enum=lum.network.millions.DepositState" json:"error_state,omitempty"` - DepositorAddress string `protobuf:"bytes,5,opt,name=depositor_address,json=depositorAddress,proto3" json:"depositor_address,omitempty"` - Amount types.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount"` - WinnerAddress string `protobuf:"bytes,7,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` - IsSponsor bool `protobuf:"varint,8,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` - CreatedAtHeight int64 `protobuf:"varint,10,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` - UpdatedAtHeight int64 `protobuf:"varint,11,opt,name=updated_at_height,json=updatedAtHeight,proto3" json:"updated_at_height,omitempty"` - CreatedAt time.Time `protobuf:"bytes,12,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at"` - UpdatedAt time.Time `protobuf:"bytes,13,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + DepositId uint64 `protobuf:"varint,2,opt,name=deposit_id,json=depositId,proto3" json:"deposit_id,omitempty"` + State DepositState `protobuf:"varint,3,opt,name=state,proto3,enum=lum.network.millions.DepositState" json:"state,omitempty"` + ErrorState DepositState `protobuf:"varint,4,opt,name=error_state,json=errorState,proto3,enum=lum.network.millions.DepositState" json:"error_state,omitempty"` + DepositorAddress string `protobuf:"bytes,5,opt,name=depositor_address,json=depositorAddress,proto3" json:"depositor_address,omitempty"` + Amount types.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount"` + WinnerAddress string `protobuf:"bytes,7,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` + IsSponsor bool `protobuf:"varint,8,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` + DepositOrigin DepositOrigin `protobuf:"varint,9,opt,name=deposit_origin,json=depositOrigin,proto3,enum=lum.network.millions.DepositOrigin" json:"deposit_origin,omitempty"` + CreatedAtHeight int64 `protobuf:"varint,10,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` + UpdatedAtHeight int64 `protobuf:"varint,11,opt,name=updated_at_height,json=updatedAtHeight,proto3" json:"updated_at_height,omitempty"` + CreatedAt time.Time `protobuf:"bytes,12,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at"` + UpdatedAt time.Time `protobuf:"bytes,13,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` } func (m *Deposit) Reset() { *m = Deposit{} } @@ -168,6 +197,13 @@ func (m *Deposit) GetIsSponsor() bool { return false } +func (m *Deposit) GetDepositOrigin() DepositOrigin { + if m != nil { + return m.DepositOrigin + } + return DepositOrigin_Unspecified +} + func (m *Deposit) GetCreatedAtHeight() int64 { if m != nil { return m.CreatedAtHeight @@ -198,6 +234,7 @@ func (m *Deposit) GetUpdatedAt() time.Time { func init() { proto.RegisterEnum("lum.network.millions.DepositState", DepositState_name, DepositState_value) + proto.RegisterEnum("lum.network.millions.DepositOrigin", DepositOrigin_name, DepositOrigin_value) proto.RegisterType((*Deposit)(nil), "lum.network.millions.Deposit") } @@ -206,49 +243,55 @@ func init() { } var fileDescriptor_5252614e94b18a0e = []byte{ - // 661 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6e, 0xd3, 0x30, - 0x1c, 0xc7, 0x9b, 0xad, 0xeb, 0x1f, 0x77, 0x7f, 0xba, 0x68, 0x88, 0xac, 0xd2, 0xb2, 0x68, 0x07, - 0x54, 0x4d, 0x5a, 0xa2, 0x8d, 0x03, 0xdc, 0x50, 0x9b, 0xa6, 0x23, 0x68, 0x1a, 0x53, 0x92, 0x5e, - 0xb8, 0x44, 0x69, 0xe2, 0xa5, 0x16, 0x49, 0x1c, 0xc5, 0x0e, 0x83, 0x37, 0x98, 0x76, 0xda, 0x0b, - 0xec, 0xc4, 0x2b, 0xf0, 0x10, 0x3b, 0x4e, 0x9c, 0x38, 0x01, 0xda, 0xde, 0x81, 0x33, 0x4a, 0xec, - 0xb6, 0x0c, 0x26, 0x01, 0x37, 0xfb, 0xf7, 0xfd, 0x7c, 0x7f, 0x7f, 0x6c, 0xcb, 0x60, 0x27, 0xca, - 0x63, 0x2d, 0x81, 0xf4, 0x0c, 0x67, 0x6f, 0xb5, 0x18, 0x45, 0x11, 0xc2, 0x09, 0xd1, 0x02, 0x98, - 0x62, 0x82, 0xa8, 0x9a, 0x66, 0x98, 0x62, 0x71, 0x23, 0xca, 0x63, 0x95, 0x33, 0xea, 0x94, 0xe9, - 0x6c, 0x84, 0x38, 0xc4, 0x25, 0xa0, 0x15, 0x2b, 0xc6, 0x76, 0xb6, 0x43, 0x8c, 0xc3, 0x08, 0x6a, - 0xe5, 0x6e, 0x9c, 0x9f, 0x6a, 0x14, 0xc5, 0x90, 0x50, 0x2f, 0x4e, 0x39, 0x20, 0xfb, 0x98, 0xc4, - 0x98, 0x68, 0x63, 0x8f, 0x40, 0xed, 0xdd, 0xfe, 0x18, 0x52, 0x6f, 0x5f, 0xf3, 0x31, 0x4a, 0xb8, - 0xbe, 0xc9, 0x74, 0x97, 0x65, 0x66, 0x1b, 0x26, 0xed, 0x9c, 0x2f, 0x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60, 0x8f, 0x74, 0xdd, 0xb0, 0xed, 0xf6, 0x62, 0xa7, 0x75, - 0x71, 0xa5, 0xd4, 0xed, 0xdc, 0xf7, 0x8b, 0x1b, 0xfd, 0x83, 0x1b, 0xf6, 0xcc, 0xa3, 0x91, 0x65, - 0xb4, 0xab, 0x8c, 0x1b, 0x7a, 0x28, 0xca, 0x33, 0xd8, 0xa9, 0x9e, 0x7f, 0x94, 0x85, 0xfe, 0xe1, - 0xf5, 0xad, 0x2c, 0xdc, 0xdc, 0xca, 0xc2, 0xf7, 0x5b, 0x59, 0xb8, 0xbc, 0x93, 0x2b, 0x37, 0x77, - 0x72, 0xe5, 0xcb, 0x9d, 0x5c, 0x79, 0xb3, 0x17, 0x22, 0x3a, 0xc9, 0xc7, 0xaa, 0x8f, 0x63, 0x2d, - 0xca, 0xe3, 0xbd, 0xe9, 0xa7, 0xe2, 0x4f, 0x3c, 0x94, 0x68, 0xef, 0xe7, 0x9f, 0x0b, 0xfd, 0x90, - 0x42, 0x32, 0xae, 0x95, 0x07, 0xfe, 0xf4, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xbc, 0x5f, - 0x24, 0x81, 0x04, 0x00, 0x00, + // 759 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x6e, 0xe4, 0x44, + 0x10, 0x86, 0xa7, 0x93, 0xc9, 0x24, 0xd3, 0x93, 0x64, 0xbd, 0x56, 0x10, 0x8e, 0xd1, 0x3a, 0x56, + 0x10, 0x68, 0x14, 0x29, 0xb6, 0xb2, 0x1c, 0xe0, 0x86, 0x3c, 0xb6, 0x13, 0x8c, 0x96, 0x4c, 0x64, + 0x7b, 0x2e, 0x5c, 0x2c, 0x8f, 0xdd, 0x71, 0x5a, 0xd8, 0x6e, 0xcb, 0xdd, 0x66, 0xe1, 0x0d, 0x50, + 0x4e, 0xfb, 0x02, 0x91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1, 0x27, 0x0d, 0x1c, 0xfd, 0x08, 0xe0, 0xce, 0x83, 0x7f, 0x7f, + 0xbf, 0xb1, 0xa9, 0xef, 0x9d, 0x79, 0xe7, 0x8f, 0x5d, 0xfd, 0xa3, 0x55, 0x41, 0x61, 0x70, 0x3c, + 0xdf, 0xb5, 0x43, 0x09, 0xa8, 0xf0, 0xfa, 0x46, 0x1f, 0x38, 0xb8, 0x46, 0x09, 0x93, 0x4f, 0xe0, + 0x07, 0x6f, 0x61, 0xd6, 0x2c, 0x9c, 0xda, 0xd3, 0xaf, 0x2e, 0xa6, 0xb3, 0x73, 0x47, 0x5a, 0x53, + 0xa5, 0xeb, 0x1b, 0x7d, 0xdb, 0x6a, 0x18, 0x49, 0x48, 0x51, 0x91, 0xa6, 0x4c, 0x79, 0x8b, 0x93, + 0xb3, 0xd7, 0xb7, 0x1a, 0x78, 0x73, 0xab, 0x81, 0x3f, 0x6f, 0x35, 0xf0, 0xea, 0x4e, 0xeb, 0xbd, + 0xb9, 0xd3, 0x7a, 0xbf, 0xdd, 0x69, 0xbd, 0xaf, 0x8f, 0x33, 0xcc, 0xae, 0x9a, 0xb9, 0x91, 0x90, + 0xc2, 0xcc, 0x9b, 0xe2, 0x78, 0xf1, 0x7a, 0x26, 0x57, 0x31, 0x2e, 0xcd, 0xef, 0x56, 0xaf, 0x28, + 0xfb, 0xbe, 0x42, 0x74, 0x3e, 0xe8, 0xb6, 0xe1, 0x93, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x29, + 0x85, 0x3e, 0x94, 0x6a, 0x05, 0x00, 0x00, } func (m *Deposit) Marshal() (dAtA []byte, err error) { @@ -297,6 +340,11 @@ func (m *Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x50 } + if m.DepositOrigin != 0 { + i = encodeVarintDeposit(dAtA, i, uint64(m.DepositOrigin)) + i-- + dAtA[i] = 0x48 + } if m.IsSponsor { i-- if m.IsSponsor { @@ -396,6 +444,9 @@ func (m *Deposit) Size() (n int) { if m.IsSponsor { n += 2 } + if m.DepositOrigin != 0 { + n += 1 + sovDeposit(uint64(m.DepositOrigin)) + } if m.CreatedAtHeight != 0 { n += 1 + sovDeposit(uint64(m.CreatedAtHeight)) } @@ -637,6 +688,25 @@ func (m *Deposit) Unmarshal(dAtA []byte) error { } } m.IsSponsor = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositOrigin", wireType) + } + m.DepositOrigin = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDeposit + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DepositOrigin |= DepositOrigin(b&0x7F) << shift + if b < 0x80 { + break + } + } case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CreatedAtHeight", wireType) diff --git a/x/millions/types/errors.go b/x/millions/types/errors.go index 5e84290f..f7336344 100644 --- a/x/millions/types/errors.go +++ b/x/millions/types/errors.go @@ -36,6 +36,8 @@ var ( ErrInvalidDepositState = errorsmod.Register(ModuleName, 1208, "Deposit is in an invalid state") ErrInvalidPoolAccountAddress = errorsmod.Register(ModuleName, 1209, "Invalid pool module account address") ErrInvalidRestorerAddress = errorsmod.Register(ModuleName, 1210, "Invalid restorer address") + ErrInvalidAutoCompoundSponsorCombo = errorsmod.Register(ModuleName, 1211, "Only auto compound operations can sponsor a deposit") + ErrInvalidDepositOriginState = errorsmod.Register(ModuleName, 1212, "Deposit origin is in an invalid state") ErrPoolDrawNotFound = errorsmod.Register(ModuleName, 1300, "Pool draw not found") ErrPoolDrawNotDone = errorsmod.Register(ModuleName, 1301, "Cannot launch a new draw until the previous one is done") ErrInvalidDrawState = errorsmod.Register(ModuleName, 1302, "Invalid draw state") diff --git a/x/millions/types/events.go b/x/millions/types/events.go index 177f97a7..62abceeb 100644 --- a/x/millions/types/events.go +++ b/x/millions/types/events.go @@ -33,4 +33,5 @@ const ( AttributeKeySponsor = "sponsor" AttributeKeyEpochID = "epoch_id" AttributeSeed = "seed" + AttributeKeyDepositOrigin = "deposit_origin" ) diff --git a/x/millions/types/keys.go b/x/millions/types/keys.go index 54f7856e..cc9a3e4e 100644 --- a/x/millions/types/keys.go +++ b/x/millions/types/keys.go @@ -14,7 +14,7 @@ import ( const ( ModuleName = "millions" - ModuleVersion = 4 + ModuleVersion = 5 StoreKey = ModuleName diff --git a/x/millions/types/message_claim_prize.go b/x/millions/types/message_claim_prize.go index d4d1928d..1381138f 100644 --- a/x/millions/types/message_claim_prize.go +++ b/x/millions/types/message_claim_prize.go @@ -44,5 +44,9 @@ func (msg *MsgClaimPrize) ValidateBasic() error { return ErrInvalidID } + if !msg.GetIsAutoCompound() && msg.GetIsSponsor() { + return ErrInvalidAutoCompoundSponsorCombo + } + return nil } diff --git a/x/millions/types/tx.pb.go b/x/millions/types/tx.pb.go index d4ce7112..f9a5cd35 100644 --- a/x/millions/types/tx.pb.go +++ b/x/millions/types/tx.pb.go @@ -755,11 +755,12 @@ func (m *MsgDepositRetryResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDepositRetryResponse proto.InternalMessageInfo type MsgClaimPrize struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - DrawId uint64 `protobuf:"varint,2,opt,name=draw_id,json=drawId,proto3" json:"draw_id,omitempty"` - PrizeId uint64 `protobuf:"varint,3,opt,name=prize_id,json=prizeId,proto3" json:"prize_id,omitempty"` - WinnerAddress string `protobuf:"bytes,4,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` - Compound bool `protobuf:"varint,5,opt,name=compound,proto3" json:"compound,omitempty"` + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + DrawId uint64 `protobuf:"varint,2,opt,name=draw_id,json=drawId,proto3" json:"draw_id,omitempty"` + PrizeId uint64 `protobuf:"varint,3,opt,name=prize_id,json=prizeId,proto3" json:"prize_id,omitempty"` + WinnerAddress string `protobuf:"bytes,4,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` + IsAutoCompound bool `protobuf:"varint,5,opt,name=is_auto_compound,json=isAutoCompound,proto3" json:"is_auto_compound,omitempty"` + IsSponsor bool `protobuf:"varint,6,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` } func (m *MsgClaimPrize) Reset() { *m = MsgClaimPrize{} } @@ -823,9 +824,16 @@ func (m *MsgClaimPrize) GetWinnerAddress() string { return "" } -func (m *MsgClaimPrize) GetCompound() bool { +func (m *MsgClaimPrize) GetIsAutoCompound() bool { if m != nil { - return m.Compound + return m.IsAutoCompound + } + return false +} + +func (m *MsgClaimPrize) GetIsSponsor() bool { + if m != nil { + return m.IsSponsor } return false } @@ -1376,100 +1384,101 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/tx.proto", fileDescriptor_13b6da814e999511) } var fileDescriptor_13b6da814e999511 = []byte{ - // 1473 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcf, 0x6f, 0xdb, 0xc6, - 0x12, 0x36, 0x25, 0x59, 0xb6, 0xc6, 0xbf, 0xf2, 0x18, 0xc5, 0x96, 0x85, 0x17, 0xd9, 0x91, 0xf3, - 0x02, 0xbf, 0xb6, 0x92, 0x1a, 0x1b, 0x45, 0xd0, 0x5e, 0x0a, 0x39, 0x4e, 0x03, 0x1d, 0x0c, 0x38, - 0x34, 0x92, 0xa6, 0x69, 0x51, 0x62, 0x45, 0x6e, 0x64, 0xc2, 0x24, 0x57, 0xd9, 0x5d, 0x59, 0x72, - 0x91, 0x6b, 0x81, 0x02, 0xb9, 0xe4, 0xd8, 0x53, 0xff, 0x8a, 0x5e, 0x7a, 0xee, 0x25, 0x87, 0x1e, - 0x82, 0x1e, 0x8a, 0xa2, 0x87, 0xb4, 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f, 0xa2, - 0x7f, 0x09, 0xb9, 0xfe, 0x08, 0x29, 0x27, 0xd7, 0x21, 0xb4, 0x29, 0xbe, 0x37, 0xde, 0x26, 0x02, - 0x7f, 0xa6, 0xc1, 0x7a, 0x72, 0xfb, 0xef, 0x24, 0x22, 0x25, 0xfa, 0x14, 0x3f, 0x99, 0xde, 0x27, - 0xde, 0x00, 0x03, 0x5d, 0x9e, 0xdc, 0x00, 0x71, 0xb3, 0x0b, 0x1a, 0x60, 0x54, 0x67, 0xef, 0xdd, - 0x7d, 0xf1, 0xba, 0xa4, 0xbd, 0x7c, 0x5d, 0xd2, 0xfe, 0x7a, 0x5d, 0xd2, 0x9e, 0xbf, 0x29, 0xcd, - 0xbc, 0x7c, 0x53, 0x9a, 0xf9, 0xfd, 0x4d, 0x69, 0xe6, 0x51, 0x25, 0xf6, 0x67, 0x8a, 0xdb, 0xf1, - 0x2a, 0xe1, 0x3f, 0xd1, 0x44, 0xb6, 0xb5, 0x5e, 0xec, 0x9f, 0x87, 0xc1, 0x5f, 0x2c, 0xcd, 0xac, - 0x78, 0x26, 0xed, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x08, 0x44, 0x41, 0x61, 0x14, 0x00, - 0x00, + // 1492 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4d, 0x6f, 0xdb, 0x46, + 0x13, 0x36, 0x25, 0x59, 0xb6, 0xc6, 0x9f, 0x2f, 0xe3, 0xd8, 0xb2, 0xf0, 0x46, 0x76, 0xe4, 0xbc, + 0x81, 0xdf, 0xb6, 0x96, 0x1a, 0x1b, 0x45, 0xd0, 0x5e, 0x0a, 0xd9, 0x4e, 0x03, 0x1f, 0x0c, 0x38, + 0x34, 0x92, 0xa6, 0x69, 0x51, 0x62, 0x4d, 0x6e, 0xe4, 0x85, 0x49, 0xae, 0xc2, 0x5d, 0x5a, 0x72, +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4, 0x91, 0xd8, 0x42, 0x7b, 0x05, 0x63, 0xb6, 0xb3, 0x79, 0x60, 0xeb, 0x65, + 0x80, 0x73, 0xe4, 0x10, 0x1b, 0x71, 0xea, 0xb3, 0xe2, 0xe4, 0x7a, 0x76, 0xb3, 0x60, 0x24, 0x76, + 0x52, 0xda, 0x3f, 0x1f, 0x57, 0x6f, 0xe2, 0x1f, 0xb5, 0xff, 0x21, 0xcc, 0x75, 0x09, 0x59, 0xc8, + 0x62, 0x66, 0xbb, 0x52, 0x1d, 0x34, 0x84, 0xab, 0x49, 0xc1, 0xee, 0xe6, 0xc2, 0xe0, 0xc6, 0xac, + 0x9d, 0xd8, 0xd3, 0x8f, 0x60, 0xbe, 0x7b, 0x92, 0x28, 0x25, 0x6c, 0x0c, 0xc6, 0xeb, 0x1e, 0x12, + 0x12, 0x70, 0xae, 0x99, 0xdc, 0xd4, 0x77, 0x60, 0xf9, 0x04, 0x5b, 0xa7, 0x3b, 0xdb, 0x66, 0xd3, + 0xc7, 0x8f, 0x49, 0xdb, 0x44, 0x96, 0x25, 0x34, 0x21, 0x05, 0x61, 0x5c, 0x91, 0xa7, 0x47, 0xe2, + 0xb0, 0x6e, 0x59, 0x61, 0xf9, 0xfb, 0x9d, 0xce, 0x91, 0x23, 0x9d, 0xa0, 0xdf, 0xe9, 0x01, 0x72, + 0x84, 0x53, 0x1d, 0x16, 0x2c, 0x1f, 0x87, 0xa4, 0xc7, 0x9a, 0x9b, 0x19, 0xa6, 0x39, 0xe5, 0x10, + 0x69, 0x6e, 0x5b, 0x68, 0x2e, 0xa9, 0xab, 0x48, 0x73, 0xfa, 0x0a, 0x4c, 0x35, 0x29, 0x75, 0x22, + 0x79, 0xe5, 0x8c, 0x7c, 0xb8, 0x3c, 0xb0, 0x2b, 0xcf, 0xb3, 0x30, 0xd7, 0x11, 0x6a, 0x28, 0xc5, + 0x34, 0x53, 0xfd, 0x46, 0x97, 0x54, 0x32, 0xa1, 0x54, 0x04, 0x69, 0xda,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 0xa3, 0xd2, 0xfb, 0x23, + 0x18, 0xc5, 0xf8, 0x2e, 0x2c, 0xf4, 0xce, 0xca, 0x74, 0x96, 0x7b, 0x2c, 0x4b, 0x1f, 0x8e, 0x6a, + 0x19, 0x87, 0x7b, 0x0a, 0x4b, 0x03, 0x07, 0xd1, 0xd6, 0xe8, 0x48, 0x61, 0x9d, 0x3e, 0x1a, 0xcb, + 0x3c, 0x8e, 0xfe, 0x25, 0x14, 0x3a, 0x23, 0xa4, 0x92, 0x5e, 0x87, 0xc8, 0xa6, 0xf4, 0xde, 0x70, + 0x9b, 0x18, 0xfc, 0x99, 0x06, 0xab, 0xe9, 0xed, 0xbf, 0x9d, 0x8a, 0x94, 0xea, 0x53, 0xfa, 0x64, + 0x7c, 0x9f, 0x64, 0x03, 0x74, 0x75, 0x79, 0x7a, 0x03, 0x24, 0xcd, 0x2e, 0x69, 0x80, 0x41, 0x9d, + 0xbd, 0x7b, 0xf7, 0xc5, 0xeb, 0xb2, 0xf6, 0xf2, 0x75, 0x59, 0xfb, 0xf3, 0x75, 0x59, 0x7b, 0xfe, + 0xa6, 0x3c, 0xf1, 0xf2, 0x4d, 0x79, 0xe2, 0xb7, 0x37, 0xe5, 0x89, 0x47, 0x5b, 0x89, 0xbf, 0x69, + 0x9c, 0xc0, 0xdd, 0x8a, 0xfe, 0xe3, 0x26, 0xb2, 0xad, 0xb5, 0x13, 0xff, 0x69, 0x0c, 0xff, 0xbc, + 0x39, 0xc9, 0x8b, 0x37, 0xd5, 0xce, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xea, 0x31, 0xf6, 0x77, + 0x8e, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2478,9 +2487,19 @@ func (m *MsgClaimPrize) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Compound { + if m.IsSponsor { i-- - if m.Compound { + if m.IsSponsor { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if m.IsAutoCompound { + i-- + if m.IsAutoCompound { dAtA[i] = 1 } else { dAtA[i] = 0 @@ -3142,7 +3161,10 @@ func (m *MsgClaimPrize) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Compound { + if m.IsAutoCompound { + n += 2 + } + if m.IsSponsor { n += 2 } return n @@ -5273,7 +5295,27 @@ func (m *MsgClaimPrize) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Compound", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IsAutoCompound", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsAutoCompound = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSponsor", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -5290,7 +5332,7 @@ func (m *MsgClaimPrize) Unmarshal(dAtA []byte) error { break } } - m.Compound = bool(v != 0) + m.IsSponsor = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 1b6a689806014161e575d913b4b6646fb0b20e77 Mon Sep 17 00:00:00 2001 From: RLM Date: Thu, 7 Sep 2023 11:07:03 +0100 Subject: [PATCH 3/5] Fix typo and improve migration --- app/app.go | 2 +- x/millions/keeper/keeper_deposit.go | 6 ++++-- x/millions/migrations/v161/store.go | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/app.go b/app/app.go index 7e6a5ff0..5018d2f0 100644 --- a/app/app.go +++ b/app/app.go @@ -900,7 +900,7 @@ func (app *App) registerUpgradeHandlers() { }) app.UpgradeKeeper.SetUpgradeHandler("v1.6.1", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - app.Logger().Info("Starting v1.6.0 upgrade") + app.Logger().Info("Starting v1.6.1 upgrade") app.Logger().Info("v1.6.1 upgrade applied") return app.mm.RunMigrations(ctx, app.configurator, fromVM) diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index 9a64fd2d..cd5e69b3 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -331,14 +331,16 @@ func (k Keeper) hasPoolDeposit(ctx sdk.Context, address string, poolID uint64) b // UnsafeUpdateAutoCompoundDeposits raw updates deposit's origin // It's heavily unsafe and should only be used by store migrations -func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, deposit types.Deposit) (types.Deposit, error) { +func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, deposit types.Deposit, depositOrigin types.DepositOrigin) (types.Deposit, error) { // Acquire the deposit deposit, err := k.GetPoolDeposit(ctx, deposit.PoolId, deposit.DepositId) if err != nil { return types.Deposit{}, err } - deposit.DepositOrigin = types.DepositOrigin_Direct + deposit.DepositOrigin = depositOrigin + deposit.UpdatedAtHeight = ctx.BlockHeight() + deposit.UpdatedAt = ctx.BlockTime() // Update pool deposits k.setPoolDeposit(ctx, &deposit) // Update account deposits diff --git a/x/millions/migrations/v161/store.go b/x/millions/migrations/v161/store.go index e9ceb25b..1f6f540a 100644 --- a/x/millions/migrations/v161/store.go +++ b/x/millions/migrations/v161/store.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" millionskeeper "github.com/lum-network/chain/x/millions/keeper" + millionstypes "github.com/lum-network/chain/x/millions/types" ) func MigrateAutoCompoundDeposits(ctx sdk.Context, k millionskeeper.Keeper) error { @@ -11,7 +12,7 @@ func MigrateAutoCompoundDeposits(ctx sdk.Context, k millionskeeper.Keeper) error deposits := k.ListDeposits(ctx) for _, d := range deposits { - if _, err := k.UnsafeUpdateAutoCompoundDeposits(ctx, d); err != nil { + if _, err := k.UnsafeUpdateAutoCompoundDeposits(ctx, d, millionstypes.DepositOrigin_Direct); err != nil { panic(err) } } From 7beb9b7e60e57396ac2625cc7a3649e27f993820 Mon Sep 17 00:00:00 2001 From: RLM Date: Thu, 7 Sep 2023 12:06:09 +0100 Subject: [PATCH 4/5] Apply feedback comments --- x/millions/keeper/keeper_deposit.go | 7 +++---- x/millions/keeper/msg_server_prize.go | 10 +++++----- x/millions/migrations/v161/store.go | 8 ++++++-- x/millions/types/errors.go | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index cd5e69b3..b6e5650f 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -331,9 +331,9 @@ func (k Keeper) hasPoolDeposit(ctx sdk.Context, address string, poolID uint64) b // UnsafeUpdateAutoCompoundDeposits raw updates deposit's origin // It's heavily unsafe and should only be used by store migrations -func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, deposit types.Deposit, depositOrigin types.DepositOrigin) (types.Deposit, error) { +func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, poolID uint64, depositID uint64, depositOrigin types.DepositOrigin) (types.Deposit, error) { // Acquire the deposit - deposit, err := k.GetPoolDeposit(ctx, deposit.PoolId, deposit.DepositId) + deposit, err := k.GetPoolDeposit(ctx, poolID, depositID) if err != nil { return types.Deposit{}, err } @@ -341,9 +341,8 @@ func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, deposit types. deposit.DepositOrigin = depositOrigin deposit.UpdatedAtHeight = ctx.BlockHeight() deposit.UpdatedAt = ctx.BlockTime() - // Update pool deposits + k.setPoolDeposit(ctx, &deposit) - // Update account deposits k.setAccountDeposit(ctx, &deposit) return deposit, nil diff --git a/x/millions/keeper/msg_server_prize.go b/x/millions/keeper/msg_server_prize.go index 95ec2e45..b900281f 100644 --- a/x/millions/keeper/msg_server_prize.go +++ b/x/millions/keeper/msg_server_prize.go @@ -95,6 +95,11 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( // Store deposit k.AddDeposit(ctx, &deposit) + // Transfer to appropriate zone + if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { + return nil, err + } + // Emit event ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -113,11 +118,6 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( ), }) - // Transfer to appropriate zone - if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { - return nil, err - } - return nil, nil } diff --git a/x/millions/migrations/v161/store.go b/x/millions/migrations/v161/store.go index 1f6f540a..14d3ffe6 100644 --- a/x/millions/migrations/v161/store.go +++ b/x/millions/migrations/v161/store.go @@ -1,6 +1,8 @@ package v161 import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" millionskeeper "github.com/lum-network/chain/x/millions/keeper" @@ -11,12 +13,14 @@ func MigrateAutoCompoundDeposits(ctx sdk.Context, k millionskeeper.Keeper) error ctx.Logger().Info("Processing autocompound deposits") deposits := k.ListDeposits(ctx) + updatedEntityCount := 0 for _, d := range deposits { - if _, err := k.UnsafeUpdateAutoCompoundDeposits(ctx, d, millionstypes.DepositOrigin_Direct); err != nil { + if _, err := k.UnsafeUpdateAutoCompoundDeposits(ctx, d.PoolId, d.DepositId, millionstypes.DepositOrigin_Direct); err != nil { panic(err) } + updatedEntityCount++ } - ctx.Logger().Info("Successfully updated deposits with autocompound state") + ctx.Logger().Info(fmt.Sprintf("Successfully updated %d deposits with %s state", updatedEntityCount, millionstypes.DepositOrigin_Direct.String())) return nil } diff --git a/x/millions/types/errors.go b/x/millions/types/errors.go index f7336344..595e6e8d 100644 --- a/x/millions/types/errors.go +++ b/x/millions/types/errors.go @@ -36,7 +36,7 @@ var ( ErrInvalidDepositState = errorsmod.Register(ModuleName, 1208, "Deposit is in an invalid state") ErrInvalidPoolAccountAddress = errorsmod.Register(ModuleName, 1209, "Invalid pool module account address") ErrInvalidRestorerAddress = errorsmod.Register(ModuleName, 1210, "Invalid restorer address") - ErrInvalidAutoCompoundSponsorCombo = errorsmod.Register(ModuleName, 1211, "Only auto compound operations can sponsor a deposit") + ErrInvalidAutoCompoundSponsorCombo = errorsmod.Register(ModuleName, 1211, "Only winners that auto compounds can sponsor a deposit through a claim process") ErrInvalidDepositOriginState = errorsmod.Register(ModuleName, 1212, "Deposit origin is in an invalid state") ErrPoolDrawNotFound = errorsmod.Register(ModuleName, 1300, "Pool draw not found") ErrPoolDrawNotDone = errorsmod.Register(ModuleName, 1301, "Cannot launch a new draw until the previous one is done") From 54075b3931e0fa1746c79c947dd6267b83eb1eaa Mon Sep 17 00:00:00 2001 From: RLM Date: Fri, 8 Sep 2023 15:54:11 +0100 Subject: [PATCH 5/5] Extract CreateDeposit logic to allow flexible origin --- proto/lum/network/millions/deposit.proto | 2 +- x/millions/genesis_test.go | 22 ++-- x/millions/keeper/keeper_deposit.go | 99 +++++++++++++++- x/millions/keeper/keeper_deposit_test.go | 40 +++---- x/millions/keeper/keeper_epoch_test.go | 14 +-- x/millions/keeper/keeper_pool_test.go | 8 +- x/millions/keeper/keeper_withdrawal_test.go | 38 +++---- x/millions/keeper/msg_server_deposit.go | 84 +------------- x/millions/keeper/msg_server_prize.go | 101 +++-------------- x/millions/keeper/msg_server_test.go | 22 ++-- x/millions/migrations/v152/store_test.go | 2 +- x/millions/migrations/v161/store_test.go | 4 +- x/millions/types/deposit.go | 2 +- x/millions/types/deposit.pb.go | 118 ++++++++++---------- x/millions/types/events.go | 3 +- 15 files changed, 256 insertions(+), 303 deletions(-) diff --git a/proto/lum/network/millions/deposit.proto b/proto/lum/network/millions/deposit.proto index ee8eac28..f8d9380c 100644 --- a/proto/lum/network/millions/deposit.proto +++ b/proto/lum/network/millions/deposit.proto @@ -45,7 +45,7 @@ message Deposit { string winner_address = 7 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; bool is_sponsor = 8; - DepositOrigin deposit_origin = 9; + DepositOrigin origin = 9; int64 created_at_height = 10; int64 updated_at_height = 11; diff --git a/x/millions/genesis_test.go b/x/millions/genesis_test.go index 8d4a57b5..9dab1a46 100644 --- a/x/millions/genesis_test.go +++ b/x/millions/genesis_test.go @@ -78,17 +78,17 @@ var testGenesis = millionstypes.GenesisState{ }, }, Deposits: []millionstypes.Deposit{ - {PoolId: 1, DepositId: 1, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(100)), State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 1, DepositId: 2, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(101)), State: millionstypes.DepositState_IcaDelegate, DepositOrigin: millionstypes.DepositOrigin_Autocompound}, - {PoolId: 1, DepositId: 3, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(102)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 1, DepositId: 4, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(103)), State: millionstypes.DepositState_Failure, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 1, DepositId: 5, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-1", sdk.NewInt(104)), State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 2, DepositId: 6, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-2", sdk.NewInt(200)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 2, DepositId: 7, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(201)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 2, DepositId: 8, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(202)), State: millionstypes.DepositState_IbcTransfer, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 3, DepositId: 9, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(300)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 3, DepositId: 10, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(301)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Direct}, - {PoolId: 4, DepositId: 11, DepositorAddress: testAccs[5], WinnerAddress: testAccs[5], Amount: sdk.NewCoin("denom-4", sdk.NewInt(400)), State: millionstypes.DepositState_Success, DepositOrigin: millionstypes.DepositOrigin_Autocompound}, + {PoolId: 1, DepositId: 1, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(100)), State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 2, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(101)), State: millionstypes.DepositState_IcaDelegate, Origin: millionstypes.DepositOrigin_Autocompound}, + {PoolId: 1, DepositId: 3, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(102)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 4, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(103)), State: millionstypes.DepositState_Failure, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 5, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-1", sdk.NewInt(104)), State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 6, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-2", sdk.NewInt(200)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 7, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(201)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 8, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(202)), State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 3, DepositId: 9, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(300)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 3, DepositId: 10, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(301)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 4, DepositId: 11, DepositorAddress: testAccs[5], WinnerAddress: testAccs[5], Amount: sdk.NewCoin("denom-4", sdk.NewInt(400)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Autocompound}, }, Draws: []millionstypes.Draw{ {PoolId: 1, DrawId: 1, RandSeed: 10, TotalWinCount: 100, TotalWinAmount: sdk.NewInt(1000)}, diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index b6e5650f..28adc51e 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -2,6 +2,8 @@ package keeper import ( "fmt" + "strconv" + "strings" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -213,6 +215,101 @@ func (k Keeper) AddDeposit(ctx sdk.Context, deposit *types.Deposit) { k.updatePool(ctx, &pool) } +// CreateDeposit creates a deposit from the transaction message +// Holds the internal validation logic +func (k Keeper) CreateDeposit(ctx sdk.Context, msg *types.MsgDeposit, depositOrigin types.DepositOrigin) (*types.Deposit, error) { + // Get the pool to validate id and denom + pool, err := k.GetPool(ctx, msg.GetPoolId()) + if err != nil { + return nil, types.ErrPoolNotFound + } + + if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { + return nil, errorsmod.Wrapf( + types.ErrInvalidPoolState, "cannot deposit in pool during state %s", pool.State.String(), + ) + } + + depositorAddr, err := sdk.AccAddressFromBech32(msg.GetDepositorAddress()) + if err != nil { + return nil, types.ErrInvalidDepositorAddress + } + + if msg.Amount.Denom != pool.Denom { + return nil, types.ErrInvalidDepositDenom + } + + // Make sure the deposit is sufficient for direct deposits + if depositOrigin == types.DepositOrigin_Direct { + if msg.GetAmount().Amount.LT(pool.MinDepositAmount) { + return nil, types.ErrInsufficientDepositAmount + } + } + + winnerAddress := depositorAddr + if strings.TrimSpace(msg.GetWinnerAddress()) != "" { + winnerAddress, err = sdk.AccAddressFromBech32(msg.GetWinnerAddress()) + if err != nil { + return nil, types.ErrInvalidWinnerAddress + } + } + + if !depositorAddr.Equals(winnerAddress) && msg.GetIsSponsor() { + return nil, types.ErrInvalidSponsorWinnerCombo + } + + // New deposit instance + deposit := types.Deposit{ + PoolId: pool.PoolId, + State: types.DepositState_IbcTransfer, + DepositorAddress: depositorAddr.String(), + Amount: msg.Amount, + WinnerAddress: winnerAddress.String(), + IsSponsor: msg.GetIsSponsor(), + Origin: depositOrigin, + CreatedAtHeight: ctx.BlockHeight(), + UpdatedAtHeight: ctx.BlockHeight(), + CreatedAt: ctx.BlockTime(), + UpdatedAt: ctx.BlockTime(), + } + + // Move funds + poolRunner, err := k.GetPoolRunner(pool.PoolType) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidPoolType, err.Error()) + } + if err := poolRunner.SendDepositToPool(ctx, pool, deposit); err != nil { + return nil, err + } + + // Store deposit + k.AddDeposit(ctx, &deposit) + + if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { + return nil, err + } + + // Emit event + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + sdk.NewEvent( + types.EventTypeDeposit, + sdk.NewAttribute(types.AttributeKeyPoolID, strconv.FormatUint(deposit.DepositId, 10)), + sdk.NewAttribute(types.AttributeKeyDepositID, strconv.FormatUint(deposit.DepositId, 10)), + sdk.NewAttribute(types.AttributeKeyDepositor, deposit.GetDepositorAddress()), + sdk.NewAttribute(types.AttributeKeyWinner, deposit.GetWinnerAddress()), + sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), + sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(deposit.IsSponsor)), + sdk.NewAttribute(types.AttributeKeyOrigin, deposit.Origin.String()), + ), + }) + + return &deposit, nil +} + // RemoveDeposit removes a deposit from a pool // - removes it from the {pool_id, deposit_id} // - removes it from the {address, pool_id, deposit_id} deposits @@ -338,7 +435,7 @@ func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, poolID uint64, return types.Deposit{}, err } - deposit.DepositOrigin = depositOrigin + deposit.Origin = depositOrigin deposit.UpdatedAtHeight = ctx.BlockHeight() deposit.UpdatedAt = ctx.BlockTime() diff --git a/x/millions/keeper/keeper_deposit_test.go b/x/millions/keeper/keeper_deposit_test.go index 23ad8fde..821b2a32 100644 --- a/x/millions/keeper/keeper_deposit_test.go +++ b/x/millions/keeper/keeper_deposit_test.go @@ -31,7 +31,7 @@ func (suite *KeeperTestSuite) TestDeposit_IDsGeneration() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // Test that depositID is incremented suite.Require().Equal(uint64(i+1), depositID) @@ -44,7 +44,7 @@ func (suite *KeeperTestSuite) TestDeposit_IDsGeneration() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -105,7 +105,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -125,7 +125,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[1].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().NotPanics(panicF) @@ -138,7 +138,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -157,7 +157,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -170,7 +170,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: "", State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -198,7 +198,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -307,7 +307,7 @@ func (suite *KeeperTestSuite) TestDeposit_RemoveDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -322,7 +322,7 @@ func (suite *KeeperTestSuite) TestDeposit_RemoveDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().NotPanics(panicF) @@ -493,7 +493,7 @@ func (suite *KeeperTestSuite) TestDeposit_UpdateDepositStatus() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -592,7 +592,7 @@ func (suite *KeeperTestSuite) TestDeposit_EditDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -682,7 +682,7 @@ func (suite *KeeperTestSuite) TestDeposit_TransferDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -762,7 +762,7 @@ func (suite *KeeperTestSuite) TestDeposit_TransferDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -837,7 +837,7 @@ func (suite *KeeperTestSuite) TestDeposit_DelegateDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -913,7 +913,7 @@ func (suite *KeeperTestSuite) TestDeposit_DelegateDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -999,7 +999,7 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) @@ -1086,7 +1086,7 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(2_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(2_000_000))}) suite.Require().NoError(err) @@ -1207,7 +1207,7 @@ func (suite *KeeperTestSuite) TestDeposit_FullDepositProcess() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_epoch_test.go b/x/millions/keeper/keeper_epoch_test.go index 05399f76..96cbb07e 100644 --- a/x/millions/keeper/keeper_epoch_test.go +++ b/x/millions/keeper/keeper_epoch_test.go @@ -65,7 +65,7 @@ func (suite *KeeperTestSuite) TestEpoch_BeforeEpochStartHook() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -205,7 +205,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -259,7 +259,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -345,7 +345,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddWithdrawalsToNextAvailableEpoch() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -425,7 +425,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddWithdrawalsToNextAvailableEpoch() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -515,7 +515,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddFailedIcaUndelegationsToEpochUnbondin WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } deposits := app.MillionsKeeper.ListDeposits(ctx) @@ -611,7 +611,7 @@ func (suite *KeeperTestSuite) TestEpoch_RemoveEpochUnbonding() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } deposits := app.MillionsKeeper.ListDeposits(ctx) diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index 6814a773..0ce8734d 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -812,7 +812,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(111)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d1) d2 := millionstypes.Deposit{ @@ -822,7 +822,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[1].String(), WinnerAddress: suite.addrs[1].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(222)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d2) d3 := millionstypes.Deposit{ @@ -832,7 +832,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[2].String(), WinnerAddress: suite.addrs[2].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(333)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d3) @@ -1167,7 +1167,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(5_000_000)), DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) pool, err = app.MillionsKeeper.GetPool(ctx, 2) suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_withdrawal_test.go b/x/millions/keeper/keeper_withdrawal_test.go index 14b382f4..a34b689f 100644 --- a/x/millions/keeper/keeper_withdrawal_test.go +++ b/x/millions/keeper/keeper_withdrawal_test.go @@ -111,7 +111,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -142,7 +142,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -171,7 +171,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) suite.Require().Len(withdrawals, 5) @@ -587,7 +587,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) @@ -626,7 +626,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) @@ -714,7 +714,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -752,7 +752,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // There should be ne more deposits deposits = app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) @@ -839,7 +839,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -871,7 +871,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -939,7 +939,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -970,7 +970,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // There should be no more deposits @@ -1040,7 +1040,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BankSend() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1072,7 +1072,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BankSend() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -1157,7 +1157,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1189,7 +1189,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -1244,7 +1244,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1275,7 +1275,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // There should be no more deposits @@ -1403,7 +1403,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BalanceWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // Send coin err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) @@ -1422,7 +1422,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BalanceWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) diff --git a/x/millions/keeper/msg_server_deposit.go b/x/millions/keeper/msg_server_deposit.go index ad8839ce..1e7c19ea 100644 --- a/x/millions/keeper/msg_server_deposit.go +++ b/x/millions/keeper/msg_server_deposit.go @@ -15,92 +15,12 @@ import ( func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types.MsgDepositResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Get the pool to validate id and denom - pool, err := k.GetPool(ctx, msg.GetPoolId()) + // Check internal validation before creating a deposit + deposit, err := k.CreateDeposit(ctx, msg, types.DepositOrigin_Direct) if err != nil { - return nil, types.ErrPoolNotFound - } - - if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { - return nil, errorsmod.Wrapf( - types.ErrInvalidPoolState, "cannot deposit in pool during state %s", pool.State.String(), - ) - } - - depositorAddr, err := sdk.AccAddressFromBech32(msg.GetDepositorAddress()) - if err != nil { - return nil, types.ErrInvalidDepositorAddress - } - - if msg.Amount.Denom != pool.Denom { - return nil, types.ErrInvalidDepositDenom - } - - // Make sure the deposit is sufficient - if msg.GetAmount().Amount.LT(pool.MinDepositAmount) { - return nil, types.ErrInsufficientDepositAmount - } - - winnerAddress := depositorAddr - if strings.TrimSpace(msg.GetWinnerAddress()) != "" { - winnerAddress, err = sdk.AccAddressFromBech32(msg.GetWinnerAddress()) - if err != nil { - return nil, types.ErrInvalidWinnerAddress - } - } - - if !depositorAddr.Equals(winnerAddress) && msg.GetIsSponsor() { - return nil, types.ErrInvalidSponsorWinnerCombo - } - - // New deposit instance - deposit := types.Deposit{ - PoolId: pool.PoolId, - State: types.DepositState_IbcTransfer, - DepositorAddress: depositorAddr.String(), - Amount: msg.Amount, - WinnerAddress: winnerAddress.String(), - IsSponsor: msg.GetIsSponsor(), - DepositOrigin: types.DepositOrigin_Direct, - CreatedAtHeight: ctx.BlockHeight(), - UpdatedAtHeight: ctx.BlockHeight(), - CreatedAt: ctx.BlockTime(), - UpdatedAt: ctx.BlockTime(), - } - - // Move funds - poolRunner, err := k.GetPoolRunner(pool.PoolType) - if err != nil { - return nil, errorsmod.Wrapf(types.ErrInvalidPoolType, err.Error()) - } - if err := poolRunner.SendDepositToPool(ctx, pool, deposit); err != nil { return nil, err } - // Store deposit - k.AddDeposit(ctx, &deposit) - - // Emit event - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - ), - sdk.NewEvent( - types.EventTypeDeposit, - sdk.NewAttribute(types.AttributeKeyPoolID, strconv.FormatUint(deposit.PoolId, 10)), - sdk.NewAttribute(types.AttributeKeyDepositID, strconv.FormatUint(deposit.DepositId, 10)), - sdk.NewAttribute(types.AttributeKeyDepositor, deposit.DepositorAddress), - sdk.NewAttribute(types.AttributeKeyWinner, deposit.WinnerAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), - sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(msg.IsSponsor)), - sdk.NewAttribute(types.AttributeKeyDepositOrigin, deposit.DepositOrigin.String()), - ), - }) - - if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { - return nil, err - } return &types.MsgDepositResponse{DepositId: deposit.DepositId}, nil } diff --git a/x/millions/keeper/msg_server_prize.go b/x/millions/keeper/msg_server_prize.go index b900281f..4ba2725f 100644 --- a/x/millions/keeper/msg_server_prize.go +++ b/x/millions/keeper/msg_server_prize.go @@ -4,7 +4,6 @@ import ( "context" "strconv" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/lum-network/chain/x/millions/types" @@ -40,88 +39,7 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( return nil, types.ErrPoolNotFound } - if msg.IsAutoCompound { - // Move claim prize fund to winner address - if err := k.BankKeeper.SendCoins( - ctx, - sdk.MustAccAddressFromBech32(pool.GetLocalAddress()), - winnerAddr, - sdk.NewCoins(prize.Amount), - ); err != nil { - return nil, err - } - - // New deposit instance - deposit := types.Deposit{ - PoolId: pool.PoolId, - State: types.DepositState_IbcTransfer, - DepositorAddress: winnerAddr.String(), - Amount: prize.Amount, - WinnerAddress: winnerAddr.String(), - IsSponsor: msg.GetIsSponsor(), - DepositOrigin: types.DepositOrigin_Autocompound, - CreatedAtHeight: ctx.BlockHeight(), - UpdatedAtHeight: ctx.BlockHeight(), - CreatedAt: ctx.BlockTime(), - UpdatedAt: ctx.BlockTime(), - } - - // Remove prize entity - if err := k.RemovePrize(ctx, prize); err != nil { - return nil, err - } - - // Check pool state before being able to deposit - if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { - return nil, errorsmod.Wrapf( - types.ErrInvalidPoolState, "cannot deposit in pool during state %s", pool.State.String(), - ) - } - - // Double check if deposit denom issued from prize is suitable for pool - if deposit.Amount.Denom != pool.Denom { - return nil, types.ErrInvalidDepositDenom - } - - // Move funds to pool - poolRunner, err := k.GetPoolRunner(pool.PoolType) - if err != nil { - return nil, errorsmod.Wrapf(types.ErrInvalidPoolType, err.Error()) - } - if err := poolRunner.SendDepositToPool(ctx, pool, deposit); err != nil { - return nil, err - } - - // Store deposit - k.AddDeposit(ctx, &deposit) - - // Transfer to appropriate zone - if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { - return nil, err - } - - // Emit event - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - ), - sdk.NewEvent( - types.EventTypeDeposit, - sdk.NewAttribute(types.AttributeKeyPoolID, strconv.FormatUint(deposit.PoolId, 10)), - sdk.NewAttribute(types.AttributeKeyDepositID, strconv.FormatUint(deposit.DepositId, 10)), - sdk.NewAttribute(types.AttributeKeyDepositor, deposit.DepositorAddress), - sdk.NewAttribute(types.AttributeKeyWinner, deposit.WinnerAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), - sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(msg.IsSponsor)), - sdk.NewAttribute(types.AttributeKeyDepositOrigin, deposit.DepositOrigin.String()), - ), - }) - - return nil, nil - } - - // Move funds for a simple claim + // Move funds to winner address if err := k.BankKeeper.SendCoins( ctx, sdk.MustAccAddressFromBech32(pool.GetLocalAddress()), @@ -135,6 +53,22 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( return nil, err } + if msg.IsAutoCompound { + // Construct the deposit msg + msg := types.MsgDeposit{ + PoolId: pool.PoolId, + Amount: prize.Amount, + DepositorAddress: winnerAddr.String(), + WinnerAddress: winnerAddr.String(), + IsSponsor: msg.GetIsSponsor(), + } + + // Check internal validation before creating a deposit + if _, err := k.CreateDeposit(ctx, &msg, types.DepositOrigin_Autocompound); err != nil { + return nil, err + } + } + // Emit event ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -148,6 +82,7 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( sdk.NewAttribute(types.AttributeKeyPrizeID, strconv.FormatUint(prize.PrizeId, 10)), sdk.NewAttribute(types.AttributeKeyWinner, prize.WinnerAddress), sdk.NewAttribute(sdk.AttributeKeyAmount, prize.Amount.String()), + sdk.NewAttribute(types.AttributeKeyAutoCompound, strconv.FormatBool(msg.IsAutoCompound)), ), }) diff --git a/x/millions/keeper/msg_server_test.go b/x/millions/keeper/msg_server_test.go index 908c19a9..8d8e4cde 100644 --- a/x/millions/keeper/msg_server_test.go +++ b/x/millions/keeper/msg_server_test.go @@ -481,7 +481,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -541,7 +541,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -565,7 +565,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], suite.moduleAddrs[0], sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -614,7 +614,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositEdit() { State: millionstypes.DepositState_Success, ErrorState: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -833,7 +833,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) deposits := app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) @@ -849,7 +849,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Failure, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // List deposits deposits := app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) @@ -980,7 +980,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) err = app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[2].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) @@ -1058,7 +1058,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDepositRetry() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1205,7 +1205,7 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(500_000)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) // Create prizes at various stages @@ -1306,7 +1306,7 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { // There should be a new deposit deposits := app.MillionsKeeper.ListDeposits(ctx) suite.Require().Len(deposits, 2) - suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[1].DepositOrigin) + suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[1].Origin) suite.Require().Equal(millionstypes.DepositState_Success, deposits[1].State) suite.Require().Equal(millionstypes.DepositState_Unspecified, deposits[1].ErrorState) // Pool tvl should have increased by 1_000_000 @@ -1351,7 +1351,7 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { // There should be a new deposit deposits = app.MillionsKeeper.ListDeposits(ctx) suite.Require().Len(deposits, 3) - suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[2].DepositOrigin) + suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[2].Origin) suite.Require().Equal(millionstypes.DepositState_Success, deposits[2].State) suite.Require().Equal(millionstypes.DepositState_Unspecified, deposits[2].ErrorState) // Pool tvl should have increased by 2_000_000 diff --git a/x/millions/migrations/v152/store_test.go b/x/millions/migrations/v152/store_test.go index b1f535f6..5cd332e2 100644 --- a/x/millions/migrations/v152/store_test.go +++ b/x/millions/migrations/v152/store_test.go @@ -169,7 +169,7 @@ func (suite *StoreMigrationTestSuite) TestMigrateUndelegations() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("ulum", sdk.NewInt(1_000_0)), - DepositOrigin: millionstypes.DepositOrigin_Direct, + Origin: millionstypes.DepositOrigin_Direct, }) } diff --git a/x/millions/migrations/v161/store_test.go b/x/millions/migrations/v161/store_test.go index 6eab90a4..c2d3c2dc 100644 --- a/x/millions/migrations/v161/store_test.go +++ b/x/millions/migrations/v161/store_test.go @@ -169,7 +169,7 @@ func (suite *StoreMigrationTestSuite) TestMigrateAutoCompoundDeposits() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("ulum", sdk.NewInt(1_000_0)), - DepositOrigin: millionstypes.DepositOrigin_Autocompound, + Origin: millionstypes.DepositOrigin_Autocompound, }) } @@ -179,7 +179,7 @@ func (suite *StoreMigrationTestSuite) TestMigrateAutoCompoundDeposits() { deposits := suite.app.MillionsKeeper.ListDeposits(suite.ctx) for _, d := range deposits { - suite.Require().Equal(millionstypes.DepositOrigin_Direct, d.DepositOrigin) + suite.Require().Equal(millionstypes.DepositOrigin_Direct, d.Origin) } } diff --git a/x/millions/types/deposit.go b/x/millions/types/deposit.go index 4a7cb64b..4132bdcf 100644 --- a/x/millions/types/deposit.go +++ b/x/millions/types/deposit.go @@ -17,7 +17,7 @@ func (deposit *Deposit) ValidateBasic() error { if deposit.State == DepositState_Unspecified { return errorsmod.Wrapf(ErrInvalidDepositState, "no state specified") } - if deposit.DepositOrigin == DepositOrigin_Unspecified { + if deposit.Origin == DepositOrigin_Unspecified { return errorsmod.Wrapf(ErrInvalidDepositOriginState, "no state specified") } if _, err := sdk.AccAddressFromBech32(deposit.DepositorAddress); err != nil { diff --git a/x/millions/types/deposit.pb.go b/x/millions/types/deposit.pb.go index 6cff08dc..51df9300 100644 --- a/x/millions/types/deposit.pb.go +++ b/x/millions/types/deposit.pb.go @@ -101,7 +101,7 @@ type Deposit struct { Amount types.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount"` WinnerAddress string `protobuf:"bytes,7,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` IsSponsor bool `protobuf:"varint,8,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` - DepositOrigin DepositOrigin `protobuf:"varint,9,opt,name=deposit_origin,json=depositOrigin,proto3,enum=lum.network.millions.DepositOrigin" json:"deposit_origin,omitempty"` + Origin DepositOrigin `protobuf:"varint,9,opt,name=origin,proto3,enum=lum.network.millions.DepositOrigin" json:"origin,omitempty"` CreatedAtHeight int64 `protobuf:"varint,10,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` UpdatedAtHeight int64 `protobuf:"varint,11,opt,name=updated_at_height,json=updatedAtHeight,proto3" json:"updated_at_height,omitempty"` CreatedAt time.Time `protobuf:"bytes,12,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at"` @@ -197,9 +197,9 @@ func (m *Deposit) GetIsSponsor() bool { return false } -func (m *Deposit) GetDepositOrigin() DepositOrigin { +func (m *Deposit) GetOrigin() DepositOrigin { if m != nil { - return m.DepositOrigin + return m.Origin } return DepositOrigin_Unspecified } @@ -243,55 +243,55 @@ func init() { } var fileDescriptor_5252614e94b18a0e = []byte{ - // 759 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x6e, 0xe4, 0x44, - 0x10, 0x86, 0xa7, 0x93, 0xc9, 0x24, 0xd3, 0x93, 0x64, 0xbd, 0x56, 0x10, 0x8e, 0xd1, 0x3a, 0x56, - 0x10, 0x68, 0x14, 0x29, 0xb6, 0xb2, 0x1c, 0xe0, 0x86, 0x3c, 0xb6, 0x13, 0x8c, 0x96, 0x4c, 0x64, - 0x7b, 0x2e, 0x5c, 0x2c, 0x8f, 0xdd, 0x71, 0x5a, 0xd8, 0x6e, 0xcb, 0xdd, 0x66, 0xe1, 0x0d, 0x50, - 0x4e, 0xfb, 0x02, 0x91, 0x90, 0x78, 0x05, 0x1e, 0x62, 0x4f, 0x68, 0xc5, 0x89, 0x13, 0xa0, 0xe4, - 0x1d, 0x38, 0x23, 0xbb, 0x7b, 0x66, 0x92, 0x65, 0x45, 0xe0, 0xe6, 0xae, 0xff, 0xfb, 0xab, 0xaa, - 0xcb, 0xa5, 0x86, 0x87, 0x79, 0x53, 0x98, 0x25, 0x62, 0x2f, 0x49, 0xfd, 0x8d, 0x59, 0xe0, 0x3c, - 0xc7, 0xa4, 0xa4, 0x66, 0x8a, 0x2a, 0x42, 0x31, 0x33, 0xaa, 0x9a, 0x30, 0x22, 0xef, 0xe5, 0x4d, - 0x61, 0x08, 0xc6, 0x58, 0x30, 0xea, 0x5e, 0x46, 0x32, 0xd2, 0x01, 0x66, 0xfb, 0xc5, 0x59, 0xf5, - 0x20, 0x23, 0x24, 0xcb, 0x91, 0xd9, 0x9d, 0xe6, 0xcd, 0xa5, 0xc9, 0x70, 0x81, 0x28, 0x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0xeb, 0xbd, - 0xb9, 0xd3, 0x7a, 0xbf, 0xdd, 0x69, 0xbd, 0xaf, 0x8f, 0x33, 0xcc, 0xae, 0x9a, 0xb9, 0x91, 0x90, - 0xc2, 0xcc, 0x9b, 0xe2, 0x78, 0xf1, 0x7a, 0x26, 0x57, 0x31, 0x2e, 0xcd, 0xef, 0x56, 0xaf, 0x28, - 0xfb, 0xbe, 0x42, 0x74, 0x3e, 0xe8, 0xb6, 0xe1, 0x93, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x29, - 0x85, 0x3e, 0x94, 0x6a, 0x05, 0x00, 0x00, + // 756 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0x33, 0x6d, 0x9a, 0x36, 0x93, 0x76, 0xd7, 0x6b, 0x15, 0xe1, 0x1a, 0xad, 0x6b, 0x15, + 0x81, 0xa2, 0x4a, 0xb5, 0xd5, 0xe5, 0x00, 0x12, 0x07, 0xe4, 0xd8, 0x6e, 0xb1, 0xb4, 0x34, 0x95, + 0xed, 0x5c, 0xb8, 0x58, 0x8e, 0x3d, 0x75, 0x47, 0xd8, 0x1e, 0xcb, 0x33, 0x66, 0xe1, 0x1b, 0xa0, + 0x9e, 0xf6, 0x0b, 0x44, 0x42, 0xe2, 0x2b, 0x70, 0xe7, 0xba, 0xc7, 0x15, 0x27, 0x4e, 0x80, 0xda, + 0xef, 0xc0, 0x19, 0xd9, 0x33, 0x49, 0xb6, 0xcb, 0x8a, 0xc2, 0xcd, 0xf3, 0xfe, 0xbf, 0xff, 0x7b, + 0x6f, 0x9e, 0x9f, 0x06, 0x1e, 0xe5, 0x4d, 0x61, 0x96, 0x88, 0xbd, 0x20, 0xf5, 0x37, 0x66, 0x81, + 0xf3, 0x1c, 0x93, 0x92, 0x9a, 0x29, 0xaa, 0x08, 0xc5, 0xcc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c2, 0x91, 0x36, 0x54, 0xe9, 0x66, 0xa1, + 0xef, 0x5a, 0x0d, 0x23, 0x09, 0x29, 0x2a, 0xd2, 0x94, 0x29, 0x6f, 0x71, 0x72, 0xfe, 0xea, 0x56, + 0x03, 0xaf, 0x6f, 0x35, 0xf0, 0xe7, 0xad, 0x06, 0x5e, 0xde, 0x69, 0xbd, 0xd7, 0x77, 0x5a, 0xef, + 0xb7, 0x3b, 0xad, 0xf7, 0xf5, 0x49, 0x86, 0xd9, 0x75, 0x33, 0x37, 0x12, 0x52, 0x98, 0x79, 0x53, + 0x9c, 0x2c, 0x9f, 0xcb, 0xe4, 0x3a, 0xc6, 0xa5, 0xf9, 0xdd, 0xfa, 0xd9, 0x64, 0xdf, 0x57, 0x88, + 0xce, 0x07, 0xdd, 0x36, 0x7c, 0xf2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0xd6, 0x3d, 0xdf, + 0x5b, 0x05, 0x00, 0x00, } func (m *Deposit) Marshal() (dAtA []byte, err error) { @@ -340,8 +340,8 @@ func (m *Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x50 } - if m.DepositOrigin != 0 { - i = encodeVarintDeposit(dAtA, i, uint64(m.DepositOrigin)) + if m.Origin != 0 { + i = encodeVarintDeposit(dAtA, i, uint64(m.Origin)) i-- dAtA[i] = 0x48 } @@ -444,8 +444,8 @@ func (m *Deposit) Size() (n int) { if m.IsSponsor { n += 2 } - if m.DepositOrigin != 0 { - n += 1 + sovDeposit(uint64(m.DepositOrigin)) + if m.Origin != 0 { + n += 1 + sovDeposit(uint64(m.Origin)) } if m.CreatedAtHeight != 0 { n += 1 + sovDeposit(uint64(m.CreatedAtHeight)) @@ -690,9 +690,9 @@ func (m *Deposit) Unmarshal(dAtA []byte) error { m.IsSponsor = bool(v != 0) case 9: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DepositOrigin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType) } - m.DepositOrigin = 0 + m.Origin = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowDeposit @@ -702,7 +702,7 @@ func (m *Deposit) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.DepositOrigin |= DepositOrigin(b&0x7F) << shift + m.Origin |= DepositOrigin(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/millions/types/events.go b/x/millions/types/events.go index 62abceeb..cfc44aa3 100644 --- a/x/millions/types/events.go +++ b/x/millions/types/events.go @@ -33,5 +33,6 @@ const ( AttributeKeySponsor = "sponsor" AttributeKeyEpochID = "epoch_id" AttributeSeed = "seed" - AttributeKeyDepositOrigin = "deposit_origin" + AttributeKeyOrigin = "origin" + AttributeKeyAutoCompound = "auto_compound" )