From e23c4b3c6babd6abc24c4e005cd654df0e54261d Mon Sep 17 00:00:00 2001 From: shellvish <104537253+shellvish@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:25:06 -0700 Subject: [PATCH] rename amount to native_token_amount (#1058) Co-authored-by: Aidan Salzmann Co-authored-by: sampocs --- app/upgrades/v17/upgrades.go | 2 +- app/upgrades/v5/upgrades_test.go | 2 +- proto/stride/records/records.proto | 2 +- readme-docs/md/records_README.md | 2 +- x/records/README.md | 2 +- .../cli/query_user_redemption_record_test.go | 6 +- x/records/keeper/epoch_unbonding_record.go | 3 +- .../keeper/epoch_unbonding_record_test.go | 2 +- .../keeper/user_redemption_record_test.go | 2 +- x/records/migrations/v2/convert.go | 12 +- x/records/migrations/v2/convert_test.go | 10 +- x/records/types/records.pb.go | 154 +++++++++--------- .../keeper/grpc_query_address_unbondings.go | 2 +- x/stakeibc/keeper/icacallbacks_claim.go | 2 +- x/stakeibc/keeper/icacallbacks_claim_test.go | 8 +- x/stakeibc/keeper/icacallbacks_redemption.go | 4 +- x/stakeibc/keeper/icacallbacks_undelegate.go | 4 +- .../msg_server_claim_undelegated_tokens.go | 2 +- ...sg_server_claim_undelegated_tokens_test.go | 16 +- x/stakeibc/keeper/msg_server_redeem_stake.go | 16 +- .../keeper/msg_server_redeem_stake_test.go | 2 +- .../msg_server_restore_interchain_account.go | 4 +- x/stakeibc/keeper/unbonding_records.go | 6 +- ...ords_get_host_zone_unbondings_msgs_test.go | 12 +- 24 files changed, 138 insertions(+), 139 deletions(-) diff --git a/app/upgrades/v17/upgrades.go b/app/upgrades/v17/upgrades.go index 8034b82604..5261d85578 100644 --- a/app/upgrades/v17/upgrades.go +++ b/app/upgrades/v17/upgrades.go @@ -348,7 +348,7 @@ func MigrateUnbondingRecords(ctx sdk.Context, k stakeibckeeper.Keeper) error { continue } - userRedemptionRecord.StTokenAmount = estimatedStTokenConversionRate.Mul(sdkmath.LegacyDec(userRedemptionRecord.Amount)).RoundInt() + userRedemptionRecord.StTokenAmount = estimatedStTokenConversionRate.Mul(sdkmath.LegacyDec(userRedemptionRecord.NativeTokenAmount)).RoundInt() k.RecordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) } } diff --git a/app/upgrades/v5/upgrades_test.go b/app/upgrades/v5/upgrades_test.go index 02ce3c0e9f..c24fca3ea9 100644 --- a/app/upgrades/v5/upgrades_test.go +++ b/app/upgrades/v5/upgrades_test.go @@ -329,7 +329,7 @@ func (s *UpgradeTestSuite) SetupOldRecordStore(codec codec.Codec) func() { userRedemptionRecord, found := s.App.RecordsKeeper.GetUserRedemptionRecord(s.Ctx, userRedemptionRecordId) s.Require().True(found, "redemption record found") s.Require().Equal(userRedemptionRecord.Id, userRedemptionRecordId, "redemption record id") - s.Require().Equal(userRedemptionRecord.Amount, sdkmath.NewInt(1000000), "redemption record amount") + s.Require().Equal(userRedemptionRecord.NativeTokenAmount, sdkmath.NewInt(1000000), "redemption record amount") epochUnbondingRecord, found := s.App.RecordsKeeper.GetEpochUnbondingRecord(s.Ctx, epochNumber) s.Require().True(found, "epoch unbonding record found") diff --git a/proto/stride/records/records.proto b/proto/stride/records/records.proto index a2424b665f..350a229d3b 100644 --- a/proto/stride/records/records.proto +++ b/proto/stride/records/records.proto @@ -9,7 +9,7 @@ option go_package = "github.com/Stride-Labs/stride/v16/x/records/types"; message UserRedemptionRecord { string id = 1; // {chain_id}.{epoch}.{receiver} string receiver = 3; - string amount = 4 [ + string native_token_amount = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; diff --git a/readme-docs/md/records_README.md b/readme-docs/md/records_README.md index d5b9bffea0..af99ec6052 100644 --- a/readme-docs/md/records_README.md +++ b/readme-docs/md/records_README.md @@ -34,7 +34,7 @@ Epoch Unbonding Records - `GetAllPreviousEpochUnbondingRecords()` - `GetHostZoneUnbondingByChainId()` - `AddHostZoneToEpochUnbondingRecord()` -- `SetHostZoneUnbondings()` +- `SetHostZoneUnbondingStatus()` User Redemption Records - `SetUserRedemptionRecord()` diff --git a/x/records/README.md b/x/records/README.md index f3ec678ec5..3bcc8669f7 100644 --- a/x/records/README.md +++ b/x/records/README.md @@ -37,7 +37,7 @@ Epoch Unbonding Records - `GetAllPreviousEpochUnbondingRecords()` - `GetHostZoneUnbondingByChainId()` - `AddHostZoneToEpochUnbondingRecord()` -- `SetHostZoneUnbondings()` +- `SetHostZoneUnbondingStatus()` User Redemption Records diff --git a/x/records/client/cli/query_user_redemption_record_test.go b/x/records/client/cli/query_user_redemption_record_test.go index 213a0250fc..cc3fae1f49 100644 --- a/x/records/client/cli/query_user_redemption_record_test.go +++ b/x/records/client/cli/query_user_redemption_record_test.go @@ -29,9 +29,9 @@ func networkWithUserRedemptionRecordObjects(t *testing.T, n int) (*network.Netwo for i := 0; i < n; i++ { userRedemptionRecord := types.UserRedemptionRecord{ - Id: strconv.Itoa(i), - Amount: sdkmath.NewInt(int64(i)), - StTokenAmount: sdkmath.NewInt(int64(i)), + Id: strconv.Itoa(i), + NativeTokenAmount: sdkmath.NewInt(int64(i)), + StTokenAmount: sdkmath.NewInt(int64(i)), } nullify.Fill(&userRedemptionRecord) state.UserRedemptionRecordList = append(state.UserRedemptionRecordList, userRedemptionRecord) diff --git a/x/records/keeper/epoch_unbonding_record.go b/x/records/keeper/epoch_unbonding_record.go index 6ee59219fa..ca27796bce 100644 --- a/x/records/keeper/epoch_unbonding_record.go +++ b/x/records/keeper/epoch_unbonding_record.go @@ -133,8 +133,7 @@ func (k Keeper) SetHostZoneUnbondingRecord(ctx sdk.Context, epochNumber uint64, } // Updates the status for a given host zone across relevant epoch unbonding record IDs -// TODO [cleanup]: Rename to SetHostZoneUnbondingStatus -func (k Keeper) SetHostZoneUnbondings(ctx sdk.Context, chainId string, epochUnbondingRecordIds []uint64, status types.HostZoneUnbonding_Status) error { +func (k Keeper) SetHostZoneUnbondingStatus(ctx sdk.Context, chainId string, epochUnbondingRecordIds []uint64, status types.HostZoneUnbonding_Status) error { for _, epochUnbondingRecordId := range epochUnbondingRecordIds { k.Logger(ctx).Info(fmt.Sprintf("Updating host zone unbondings on EpochUnbondingRecord %d to status %s", epochUnbondingRecordId, status.String())) // fetch the host zone unbonding diff --git a/x/records/keeper/epoch_unbonding_record_test.go b/x/records/keeper/epoch_unbonding_record_test.go index 84c737c250..364f011f97 100644 --- a/x/records/keeper/epoch_unbonding_record_test.go +++ b/x/records/keeper/epoch_unbonding_record_test.go @@ -161,7 +161,7 @@ func TestSetHostZoneUnbondings(t *testing.T) { } } - err := keeper.SetHostZoneUnbondings(ctx, hostIdToUpdate, epochsToUpdate, newStatus) + err := keeper.SetHostZoneUnbondingStatus(ctx, hostIdToUpdate, epochsToUpdate, newStatus) require.Nil(t, err) actualEpochUnbondingRecord := keeper.GetAllEpochUnbondingRecord(ctx) diff --git a/x/records/keeper/user_redemption_record_test.go b/x/records/keeper/user_redemption_record_test.go index c0ab9967aa..198b3a52b3 100644 --- a/x/records/keeper/user_redemption_record_test.go +++ b/x/records/keeper/user_redemption_record_test.go @@ -20,7 +20,7 @@ func createNUserRedemptionRecord(keeper *keeper.Keeper, ctx sdk.Context, n int) items := make([]types.UserRedemptionRecord, n) for i := range items { items[i].Id = strconv.Itoa(i) - items[i].Amount = sdkmath.NewInt(int64(i)) + items[i].NativeTokenAmount = sdkmath.NewInt(int64(i)) items[i].StTokenAmount = sdkmath.NewInt(int64(i)) keeper.SetUserRedemptionRecord(ctx, items[i]) } diff --git a/x/records/migrations/v2/convert.go b/x/records/migrations/v2/convert.go index cfc8e89899..f43a1be273 100644 --- a/x/records/migrations/v2/convert.go +++ b/x/records/migrations/v2/convert.go @@ -44,11 +44,11 @@ func convertToNewUserRedemptionRecord(oldRedemptionRecord oldrecordstypes.UserRe return recordstypes.UserRedemptionRecord{ Id: oldRedemptionRecord.Id, // Sender: oldRedemptionRecord.Sender, - Receiver: oldRedemptionRecord.Receiver, - Amount: sdkmath.NewIntFromUint64(oldRedemptionRecord.Amount), - Denom: oldRedemptionRecord.Denom, - HostZoneId: oldRedemptionRecord.HostZoneId, - EpochNumber: oldRedemptionRecord.EpochNumber, - ClaimIsPending: oldRedemptionRecord.ClaimIsPending, + Receiver: oldRedemptionRecord.Receiver, + NativeTokenAmount: sdkmath.NewIntFromUint64(oldRedemptionRecord.Amount), + Denom: oldRedemptionRecord.Denom, + HostZoneId: oldRedemptionRecord.HostZoneId, + EpochNumber: oldRedemptionRecord.EpochNumber, + ClaimIsPending: oldRedemptionRecord.ClaimIsPending, } } diff --git a/x/records/migrations/v2/convert_test.go b/x/records/migrations/v2/convert_test.go index 22fee700d3..3bee4ebb64 100644 --- a/x/records/migrations/v2/convert_test.go +++ b/x/records/migrations/v2/convert_test.go @@ -123,11 +123,11 @@ func TestConvertUserRedemptionRecord(t *testing.T) { Id: id, Receiver: receiver, // Sender: sender, - Amount: sdkmath.NewInt(1), - Denom: denom, - HostZoneId: hostZoneId, - EpochNumber: epochNumber, - ClaimIsPending: claimIsPending, + NativeTokenAmount: sdkmath.NewInt(1), + Denom: denom, + HostZoneId: hostZoneId, + EpochNumber: epochNumber, + ClaimIsPending: claimIsPending, } actualNewUserRedemptionRecord := convertToNewUserRedemptionRecord(oldUserRedemptionRecord) diff --git a/x/records/types/records.pb.go b/x/records/types/records.pb.go index 31906256f9..c326a886a8 100644 --- a/x/records/types/records.pb.go +++ b/x/records/types/records.pb.go @@ -163,14 +163,14 @@ func (LSMTokenDeposit_Status) EnumDescriptor() ([]byte, []int) { } type UserRedemptionRecord struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Receiver string `protobuf:"bytes,3,opt,name=receiver,proto3" json:"receiver,omitempty"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` - Denom string `protobuf:"bytes,5,opt,name=denom,proto3" json:"denom,omitempty"` - HostZoneId string `protobuf:"bytes,6,opt,name=host_zone_id,json=hostZoneId,proto3" json:"host_zone_id,omitempty"` - EpochNumber uint64 `protobuf:"varint,7,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` - ClaimIsPending bool `protobuf:"varint,8,opt,name=claim_is_pending,json=claimIsPending,proto3" json:"claim_is_pending,omitempty"` - StTokenAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=st_token_amount,json=stTokenAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"st_token_amount"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Receiver string `protobuf:"bytes,3,opt,name=receiver,proto3" json:"receiver,omitempty"` + NativeTokenAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=native_token_amount,json=nativeTokenAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"native_token_amount"` + Denom string `protobuf:"bytes,5,opt,name=denom,proto3" json:"denom,omitempty"` + HostZoneId string `protobuf:"bytes,6,opt,name=host_zone_id,json=hostZoneId,proto3" json:"host_zone_id,omitempty"` + EpochNumber uint64 `protobuf:"varint,7,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` + ClaimIsPending bool `protobuf:"varint,8,opt,name=claim_is_pending,json=claimIsPending,proto3" json:"claim_is_pending,omitempty"` + StTokenAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=st_token_amount,json=stTokenAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"st_token_amount"` } func (m *UserRedemptionRecord) Reset() { *m = UserRedemptionRecord{} } @@ -579,70 +579,70 @@ func init() { func init() { proto.RegisterFile("stride/records/records.proto", fileDescriptor_295ee594cc85d8ca) } var fileDescriptor_295ee594cc85d8ca = []byte{ - // 995 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x6e, 0xdb, 0x46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d, - 0xba, 0xac, 0x0a, 0xaf, 0x2f, 0xab, 0xc2, 0x5f, 0x97, 0x55, 0xe1, 0xe7, 0xab, 0x6a, 0xea, 0xf5, - 0x55, 0x35, 0xf5, 0xc7, 0x55, 0x35, 0x75, 0x76, 0xb0, 0xa2, 0x7e, 0x9f, 0x6b, 0xf1, 0xa8, 0x63, - 0x8d, 0x58, 0x33, 0xfa, 0xfc, 0x99, 0x1f, 0x3c, 0x6e, 0x7e, 0x1f, 0x7f, 0x04, 0xf1, 0xc3, 0x18, - 0x65, 0xf9, 0xd7, 0xcb, 0x67, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x93, 0x00, 0x42, 0x87, 0x23, - 0x09, 0x00, 0x00, + // 998 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xc1, 0x6e, 0xdb, 0x46, + 0x10, 0x35, 0x45, 0x5a, 0x96, 0xc6, 0x91, 0x4c, 0xaf, 0x95, 0x86, 0x56, 0x1b, 0x45, 0x11, 0x9a, + 0x40, 0x40, 0x11, 0xaa, 0x76, 0x81, 0x1c, 0x8a, 0xa2, 0x28, 0x65, 0xd1, 0x0e, 0x13, 0x45, 0x72, + 0x29, 0xa9, 0x29, 0x7c, 0x28, 0x41, 0x91, 0x0b, 0x6b, 0xe1, 0x88, 0x2b, 0x70, 0x29, 0xa1, 0xed, + 0xa5, 0xa7, 0xde, 0x7b, 0xe8, 0x2f, 0xf4, 0x13, 0xfa, 0x0f, 0x39, 0x15, 0x39, 0x16, 0x3d, 0x04, + 0x85, 0x7d, 0xe8, 0x6f, 0x14, 0x5c, 0x52, 0x94, 0x44, 0xc5, 0x0d, 0x9a, 0xe4, 0x44, 0xf2, 0xcd, + 0xcc, 0x0e, 0x77, 0xe6, 0xcd, 0xdb, 0x85, 0x8f, 0x58, 0xe0, 0x13, 0x17, 0x37, 0x7c, 0xec, 0x50, + 0xdf, 0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29, 0x85, 0x49, + 0xcc, 0xad, 0x78, 0x5e, 0xd1, 0x97, 0x09, 0xd5, 0xf3, 0x9c, 0xea, 0xf7, 0xd3, 0x5d, 0x4a, 0x55, + 0x3d, 0x45, 0xf4, 0xda, 0xef, 0xc2, 0x32, 0x63, 0x5b, 0xfa, 0x69, 0xb7, 0x67, 0xf4, 0xad, 0x53, + 0x9d, 0x53, 0x34, 0x52, 0xa4, 0x35, 0x46, 0x5e, 0xaf, 0x83, 0x7b, 0xb0, 0x93, 0x58, 0x8e, 0x35, + 0xa3, 0xad, 0xb7, 0x64, 0x31, 0x74, 0x6f, 0xe9, 0xfd, 0xee, 0x13, 0xbd, 0x63, 0x9c, 0x2d, 0x0b, + 0xa4, 0x84, 0x2a, 0x50, 0x4e, 0x59, 0x96, 0x97, 0xdb, 0x0c, 0xc7, 0x25, 0x65, 0x8f, 0x17, 0xcd, + 0x36, 0x9f, 0xbc, 0xb8, 0xac, 0x08, 0x2f, 0x2f, 0x2b, 0xc2, 0xdf, 0x97, 0x15, 0xe1, 0x97, 0xab, + 0xca, 0xc6, 0xcb, 0xab, 0xca, 0xc6, 0x9f, 0x57, 0x95, 0x8d, 0xb3, 0x83, 0xa5, 0xea, 0xf7, 0x78, + 0x2d, 0x1e, 0xb4, 0xed, 0x21, 0x6b, 0xc4, 0xd7, 0xa2, 0xd9, 0xc1, 0xc3, 0xc6, 0xf7, 0xc9, 0xe5, + 0x88, 0x37, 0x63, 0x98, 0xe5, 0xb7, 0x9a, 0xcf, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x37, 0x65, + 0xbb, 0x0e, 0x3b, 0x09, 0x00, 0x00, } func (m *UserRedemptionRecord) Marshal() (dAtA []byte, err error) { @@ -705,9 +705,9 @@ func (m *UserRedemptionRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } { - size := m.Amount.Size() + size := m.NativeTokenAmount.Size() i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.NativeTokenAmount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintRecords(dAtA, i, uint64(size)) @@ -1031,7 +1031,7 @@ func (m *UserRedemptionRecord) Size() (n int) { if l > 0 { n += 1 + l + sovRecords(uint64(l)) } - l = m.Amount.Size() + l = m.NativeTokenAmount.Size() n += 1 + l + sovRecords(uint64(l)) l = len(m.Denom) if l > 0 { @@ -1275,7 +1275,7 @@ func (m *UserRedemptionRecord) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NativeTokenAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1303,7 +1303,7 @@ func (m *UserRedemptionRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.NativeTokenAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/stakeibc/keeper/grpc_query_address_unbondings.go b/x/stakeibc/keeper/grpc_query_address_unbondings.go index 332deed626..b6e4eb5c18 100644 --- a/x/stakeibc/keeper/grpc_query_address_unbondings.go +++ b/x/stakeibc/keeper/grpc_query_address_unbondings.go @@ -73,7 +73,7 @@ func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbo Address: req.Address, Receiver: userRedemptionRecord.Receiver, UnbondingEstimatedTime: unbondingTimeStr, - Amount: userRedemptionRecord.Amount, + Amount: userRedemptionRecord.NativeTokenAmount, Denom: userRedemptionRecord.Denom, ClaimIsPending: userRedemptionRecord.ClaimIsPending, EpochNumber: userRedemptionRecord.EpochNumber, diff --git a/x/stakeibc/keeper/icacallbacks_claim.go b/x/stakeibc/keeper/icacallbacks_claim.go index c68126cc73..95eb21977f 100644 --- a/x/stakeibc/keeper/icacallbacks_claim.go +++ b/x/stakeibc/keeper/icacallbacks_claim.go @@ -100,7 +100,7 @@ func (k Keeper) DecrementHostZoneUnbonding(ctx sdk.Context, userRedemptionRecord } // decrement the hzu by the amount claimed - hostZoneUnbonding.NativeTokenAmount = hostZoneUnbonding.NativeTokenAmount.Sub(userRedemptionRecord.Amount) + hostZoneUnbonding.NativeTokenAmount = hostZoneUnbonding.NativeTokenAmount.Sub(userRedemptionRecord.NativeTokenAmount) // save the updated hzu on the epoch unbonding record epochUnbondingRecord, success := k.RecordsKeeper.AddHostZoneToEpochUnbondingRecord(ctx, callbackArgs.EpochNumber, callbackArgs.ChainId, hostZoneUnbonding) diff --git a/x/stakeibc/keeper/icacallbacks_claim_test.go b/x/stakeibc/keeper/icacallbacks_claim_test.go index 6ec8628f80..faa6daa141 100644 --- a/x/stakeibc/keeper/icacallbacks_claim_test.go +++ b/x/stakeibc/keeper/icacallbacks_claim_test.go @@ -37,8 +37,8 @@ func (s *KeeperTestSuite) SetupClaimCallback() ClaimCallbackTestCase { Id: recordId1, // after a user calls ClaimUndelegatedTokens, the record is set to claimIsPending = true // to prevent double claims - ClaimIsPending: true, - Amount: sdkmath.ZeroInt(), + ClaimIsPending: true, + NativeTokenAmount: sdkmath.ZeroInt(), } recordId2 := recordtypes.UserRedemptionRecordKeyFormatter(HostChainId, epochNumber, "other_recevier") userRedemptionRecord2 := recordtypes.UserRedemptionRecord{ @@ -99,7 +99,7 @@ func (s *KeeperTestSuite) SetupClaimCallback() ClaimCallbackTestCase { callbackArgsBz, err := s.App.StakeibcKeeper.MarshalClaimCallbackArgs(s.Ctx, callbackArgs) s.Require().NoError(err) - decrementAmount := userRedemptionRecord1.Amount + decrementAmount := userRedemptionRecord1.NativeTokenAmount return ClaimCallbackTestCase{ initialState: ClaimCallbackState{ @@ -220,7 +220,7 @@ func (s *KeeperTestSuite) TestDecrementHostZoneUnbonding_Success() { hzu1 := epochUnbondingRecord1.HostZoneUnbondings[0] // check that hzu1 has a decremented amount - s.Require().Equal(hzu1.NativeTokenAmount.Sub(userRedemptionRecord.Amount), hzu1.NativeTokenAmount, "hzu1 amount decremented") + s.Require().Equal(hzu1.NativeTokenAmount.Sub(userRedemptionRecord.NativeTokenAmount), hzu1.NativeTokenAmount, "hzu1 amount decremented") } func (s *KeeperTestSuite) TestDecrementHostZoneUnbonding_HzuNotFound() { diff --git a/x/stakeibc/keeper/icacallbacks_redemption.go b/x/stakeibc/keeper/icacallbacks_redemption.go index 7de8349575..b60ded16ed 100644 --- a/x/stakeibc/keeper/icacallbacks_redemption.go +++ b/x/stakeibc/keeper/icacallbacks_redemption.go @@ -64,7 +64,7 @@ func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, icacallbackstypes.AckResponseStatus_FAILURE, packet)) // Reset unbondings record status - err = k.RecordsKeeper.SetHostZoneUnbondings(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { return err } @@ -81,7 +81,7 @@ func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, } // Upon success, update the unbonding record status to CLAIMABLE - err = k.RecordsKeeper.SetHostZoneUnbondings(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_CLAIMABLE) + err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_CLAIMABLE) if err != nil { return err } diff --git a/x/stakeibc/keeper/icacallbacks_undelegate.go b/x/stakeibc/keeper/icacallbacks_undelegate.go index a03da4c86c..8484891dcb 100644 --- a/x/stakeibc/keeper/icacallbacks_undelegate.go +++ b/x/stakeibc/keeper/icacallbacks_undelegate.go @@ -67,7 +67,7 @@ func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, icacallbackstypes.AckResponseStatus_FAILURE, packet)) // Reset unbondings record status - if err := k.RecordsKeeper.SetHostZoneUnbondings( + if err := k.RecordsKeeper.SetHostZoneUnbondingStatus( ctx, chainId, undelegateCallback.EpochUnbondingRecordIds, @@ -108,7 +108,7 @@ func (k Keeper) UndelegateCallback(ctx sdk.Context, packet channeltypes.Packet, } // Upon success, add host zone unbondings to the exit transfer queue - err = k.RecordsKeeper.SetHostZoneUnbondings(ctx, chainId, undelegateCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, undelegateCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { return err } diff --git a/x/stakeibc/keeper/msg_server_claim_undelegated_tokens.go b/x/stakeibc/keeper/msg_server_claim_undelegated_tokens.go index d81586a7fe..119603f9a0 100644 --- a/x/stakeibc/keeper/msg_server_claim_undelegated_tokens.go +++ b/x/stakeibc/keeper/msg_server_claim_undelegated_tokens.go @@ -113,7 +113,7 @@ func (k Keeper) GetRedemptionTransferMsg(ctx sdk.Context, userRedemptionRecord * } var msgs []proto.Message - rrAmt := userRedemptionRecord.Amount + rrAmt := userRedemptionRecord.NativeTokenAmount msgs = append(msgs, &bankTypes.MsgSend{ FromAddress: hostZone.RedemptionIcaAddress, ToAddress: userRedemptionRecord.Receiver, diff --git a/x/stakeibc/keeper/msg_server_claim_undelegated_tokens_test.go b/x/stakeibc/keeper/msg_server_claim_undelegated_tokens_test.go index 9652e8443f..7d56fe8b5c 100644 --- a/x/stakeibc/keeper/msg_server_claim_undelegated_tokens_test.go +++ b/x/stakeibc/keeper/msg_server_claim_undelegated_tokens_test.go @@ -45,13 +45,13 @@ func (s *KeeperTestSuite) SetupClaimUndelegatedTokens() ClaimUndelegatedTestCase } redemptionRecord := recordtypes.UserRedemptionRecord{ - Id: redemptionRecordId, - HostZoneId: HostChainId, - EpochNumber: epochNumber, - Receiver: receiverAddr, - Denom: "uatom", - ClaimIsPending: false, - Amount: sdkmath.NewInt(1000), + Id: redemptionRecordId, + HostZoneId: HostChainId, + EpochNumber: epochNumber, + Receiver: receiverAddr, + Denom: "uatom", + ClaimIsPending: false, + NativeTokenAmount: sdkmath.NewInt(1000), } redemptionAmount := sdk.NewCoins(sdk.NewCoin(redemptionRecord.Denom, sdkmath.NewInt(1000))) @@ -112,7 +112,7 @@ func (s *KeeperTestSuite) TestClaimUndelegatedTokens_Successful() { actualRedemptionRecord, found := s.App.RecordsKeeper.GetUserRedemptionRecord(s.Ctx, redemptionRecordId) s.Require().True(found, "redemption record found") s.Require().True(actualRedemptionRecord.ClaimIsPending, "redemption record should be pending") - s.Require().Equal(expectedRedemptionRecord.Amount, actualRedemptionRecord.Amount, "record has expected amount") + s.Require().Equal(expectedRedemptionRecord.NativeTokenAmount, actualRedemptionRecord.NativeTokenAmount, "record has expected amount") // TODO: check callback data here } diff --git a/x/stakeibc/keeper/msg_server_redeem_stake.go b/x/stakeibc/keeper/msg_server_redeem_stake.go index 28f65950e3..0a78b2ebff 100644 --- a/x/stakeibc/keeper/msg_server_redeem_stake.go +++ b/x/stakeibc/keeper/msg_server_redeem_stake.go @@ -83,17 +83,17 @@ func (k msgServer) RedeemStake(goCtx context.Context, msg *types.MsgRedeemStake) // Add the unbonded amount to the UserRedemptionRecord // The record is set below userRedemptionRecord.StTokenAmount = userRedemptionRecord.StTokenAmount.Add(msg.Amount) - userRedemptionRecord.Amount = userRedemptionRecord.Amount.Add(nativeAmount) + userRedemptionRecord.NativeTokenAmount = userRedemptionRecord.NativeTokenAmount.Add(nativeAmount) } else { // First time a user is redeeming this epoch userRedemptionRecord = recordstypes.UserRedemptionRecord{ - Id: redemptionId, - Receiver: msg.Receiver, - Amount: nativeAmount, - Denom: hostZone.HostDenom, - HostZoneId: hostZone.ChainId, - EpochNumber: epochTracker.EpochNumber, - StTokenAmount: msg.Amount, + Id: redemptionId, + Receiver: msg.Receiver, + NativeTokenAmount: nativeAmount, + Denom: hostZone.HostDenom, + HostZoneId: hostZone.ChainId, + EpochNumber: epochTracker.EpochNumber, + StTokenAmount: msg.Amount, // claimIsPending represents whether a redemption is currently being claimed, // contingent on the host zone unbonding having status CLAIMABLE ClaimIsPending: false, diff --git a/x/stakeibc/keeper/msg_server_redeem_stake_test.go b/x/stakeibc/keeper/msg_server_redeem_stake_test.go index df283b3790..15ac9c74a0 100644 --- a/x/stakeibc/keeper/msg_server_redeem_stake_test.go +++ b/x/stakeibc/keeper/msg_server_redeem_stake_test.go @@ -151,7 +151,7 @@ func (s *KeeperTestSuite) TestRedeemStake_Successful() { s.Require().True(found) s.Require().Equal(msg.Amount, userRedemptionRecord.StTokenAmount, "redemption record sttoken amount") - s.Require().Equal(tc.expectedNativeAmount, userRedemptionRecord.Amount, "redemption record native amount") + s.Require().Equal(tc.expectedNativeAmount, userRedemptionRecord.NativeTokenAmount, "redemption record native amount") s.Require().Equal(msg.Receiver, userRedemptionRecord.Receiver, "redemption record receiver") s.Require().Equal(msg.HostZone, userRedemptionRecord.HostZoneId, "redemption record host zone") s.Require().False(userRedemptionRecord.ClaimIsPending, "redemption record is not claimable") diff --git a/x/stakeibc/keeper/msg_server_restore_interchain_account.go b/x/stakeibc/keeper/msg_server_restore_interchain_account.go index 77736a9e30..48417d3418 100644 --- a/x/stakeibc/keeper/msg_server_restore_interchain_account.go +++ b/x/stakeibc/keeper/msg_server_restore_interchain_account.go @@ -91,7 +91,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms } } // Revert UNBONDING_IN_PROGRESS records to UNBONDING_QUEUE - err := k.RecordsKeeper.SetHostZoneUnbondings(ctx, hostZone.ChainId, epochNumberForPendingUnbondingRecords, recordtypes.HostZoneUnbonding_UNBONDING_QUEUE) + err := k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochNumberForPendingUnbondingRecords, recordtypes.HostZoneUnbonding_UNBONDING_QUEUE) if err != nil { errMsg := fmt.Sprintf("unable to update host zone unbonding record status to %s for chainId: %s and epochUnbondingRecordIds: %v, err: %s", recordtypes.HostZoneUnbonding_UNBONDING_QUEUE.String(), hostZone.ChainId, epochNumberForPendingUnbondingRecords, err) @@ -100,7 +100,7 @@ func (k msgServer) RestoreInterchainAccount(goCtx context.Context, msg *types.Ms } // Revert EXIT_TRANSFER_IN_PROGRESS records to EXIT_TRANSFER_QUEUE - err = k.RecordsKeeper.SetHostZoneUnbondings(ctx, hostZone.ChainId, epochNumberForPendingTransferRecords, recordtypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochNumberForPendingTransferRecords, recordtypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { errMsg := fmt.Sprintf("unable to update host zone unbonding record status to %s for chainId: %s and epochUnbondingRecordIds: %v, err: %s", recordtypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE.String(), hostZone.ChainId, epochNumberForPendingTransferRecords, err) diff --git a/x/stakeibc/keeper/unbonding_records.go b/x/stakeibc/keeper/unbonding_records.go index eb126486b0..160961fd47 100644 --- a/x/stakeibc/keeper/unbonding_records.go +++ b/x/stakeibc/keeper/unbonding_records.go @@ -131,7 +131,7 @@ func (k Keeper) RefreshUserRedemptionRecordNativeAmounts( totalNativeAmount = totalNativeAmount.Add(nativeAmount) // Set the native amount on the record - userRedemptionRecord.Amount = nativeAmount + userRedemptionRecord.NativeTokenAmount = nativeAmount k.RecordsKeeper.SetUserRedemptionRecord(ctx, userRedemptionRecord) } return totalNativeAmount @@ -553,7 +553,7 @@ func (k Keeper) UnbondFromHostZone(ctx sdk.Context, hostZone types.HostZone) err } // Update the epoch unbonding record status - if err := k.RecordsKeeper.SetHostZoneUnbondings( + if err := k.RecordsKeeper.SetHostZoneUnbondingStatus( ctx, hostZone.ChainId, epochUnbondingRecordIds, @@ -715,7 +715,7 @@ func (k Keeper) SweepAllUnbondedTokensForHostZone(ctx sdk.Context, hostZone type k.Logger(ctx).Info(utils.LogWithHostZone(hostZone.ChainId, "ICA MsgSend Successfully Sent")) // Update the host zone unbonding records to status IN_PROGRESS - err = k.RecordsKeeper.SetHostZoneUnbondings(ctx, hostZone.ChainId, epochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_IN_PROGRESS) + err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, hostZone.ChainId, epochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_IN_PROGRESS) if err != nil { k.Logger(ctx).Error(err.Error()) return false, sdkmath.ZeroInt() diff --git a/x/stakeibc/keeper/unbonding_records_get_host_zone_unbondings_msgs_test.go b/x/stakeibc/keeper/unbonding_records_get_host_zone_unbondings_msgs_test.go index 2e806d078f..9e45fdebfd 100644 --- a/x/stakeibc/keeper/unbonding_records_get_host_zone_unbondings_msgs_test.go +++ b/x/stakeibc/keeper/unbonding_records_get_host_zone_unbondings_msgs_test.go @@ -599,18 +599,18 @@ func (s *KeeperTestSuite) TestRefreshUserRedemptionRecordNativeAmounts() { redemptionRate := sdk.MustNewDecFromStr("1.999") expectedUserRedemptionRecords := []recordtypes.UserRedemptionRecord{ // StTokenAmount: 1000 * 1.999 = 1999 Native - {Id: "A", StTokenAmount: sdkmath.NewInt(1000), Amount: sdkmath.NewInt(1999)}, + {Id: "A", StTokenAmount: sdkmath.NewInt(1000), NativeTokenAmount: sdkmath.NewInt(1999)}, // StTokenAmount: 999 * 1.999 = 1997.001, Rounded down to 1997 Native - {Id: "B", StTokenAmount: sdkmath.NewInt(999), Amount: sdkmath.NewInt(1997)}, + {Id: "B", StTokenAmount: sdkmath.NewInt(999), NativeTokenAmount: sdkmath.NewInt(1997)}, // StTokenAmount: 100 * 1.999 = 199.9, Rounded up to 200 Native - {Id: "C", StTokenAmount: sdkmath.NewInt(100), Amount: sdkmath.NewInt(200)}, + {Id: "C", StTokenAmount: sdkmath.NewInt(100), NativeTokenAmount: sdkmath.NewInt(200)}, } expectedTotalNativeAmount := sdkmath.NewInt(1999 + 1997 + 200) // Create the initial records which do not have the end native amount for _, expectedUserRedemptionRecord := range expectedUserRedemptionRecords { initialUserRedemptionRecord := expectedUserRedemptionRecord - initialUserRedemptionRecord.Amount = sdkmath.ZeroInt() + initialUserRedemptionRecord.NativeTokenAmount = sdkmath.ZeroInt() s.App.RecordsKeeper.SetUserRedemptionRecord(s.Ctx, initialUserRedemptionRecord) } @@ -630,7 +630,7 @@ func (s *KeeperTestSuite) TestRefreshUserRedemptionRecordNativeAmounts() { for _, expectedRecord := range expectedUserRedemptionRecords { actualRecord, found := s.App.RecordsKeeper.GetUserRedemptionRecord(s.Ctx, expectedRecord.Id) s.Require().True(found, "record %s should have been found", expectedRecord.Id) - s.Require().Equal(expectedRecord.Amount.Int64(), actualRecord.Amount.Int64(), + s.Require().Equal(expectedRecord.NativeTokenAmount.Int64(), actualRecord.NativeTokenAmount.Int64(), "record %s native amount", expectedRecord.Id) } } @@ -718,7 +718,7 @@ func (s *KeeperTestSuite) TestRefreshUnbondingNativeTokenAmounts() { for id, expectedNativeAmount := range expectedUserNativeAmounts { record, found := s.App.RecordsKeeper.GetUserRedemptionRecord(s.Ctx, id) s.Require().True(found, "user redemption record for %s should have been found", id) - s.Require().Equal(expectedNativeAmount, record.Amount, "user redemption record %s native amount", id) + s.Require().Equal(expectedNativeAmount, record.NativeTokenAmount, "user redemption record %s native amount", id) } // Remove one of the host zones and confirm it errors