Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename amount to native_token_amount #1058

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/upgrades/v17/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v5/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion proto/stride/records/records.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand Down
2 changes: 1 addition & 1 deletion readme-docs/md/records_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Epoch Unbonding Records
- `GetAllPreviousEpochUnbondingRecords()`
- `GetHostZoneUnbondingByChainId()`
- `AddHostZoneToEpochUnbondingRecord()`
- `SetHostZoneUnbondings()`
- `SetHostZoneUnbondingStatus()`

User Redemption Records
- `SetUserRedemptionRecord()`
Expand Down
2 changes: 1 addition & 1 deletion x/records/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Epoch Unbonding Records
- `GetAllPreviousEpochUnbondingRecords()`
- `GetHostZoneUnbondingByChainId()`
- `AddHostZoneToEpochUnbondingRecord()`
- `SetHostZoneUnbondings()`
- `SetHostZoneUnbondingStatus()`

User Redemption Records

Expand Down
6 changes: 3 additions & 3 deletions x/records/client/cli/query_user_redemption_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions x/records/keeper/epoch_unbonding_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/records/keeper/epoch_unbonding_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion x/records/keeper/user_redemption_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
12 changes: 6 additions & 6 deletions x/records/migrations/v2/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
10 changes: 5 additions & 5 deletions x/records/migrations/v2/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading