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

fix: low priotity issues #328

Merged
merged 7 commits into from
Feb 21, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Contains all the PRs that improved the code without changing the behaviors.

### Added
- Update outdated dependencies
- fixed old expirations are not removed
- fixed not delegate being used in msg open contract
- fixed the recipient’s IsTransferable field is overwritten to false in MsgClaimThorchain
- fixed genesis state validation

# v1.0.5-Prerelease
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{
"authorization": "STRICT",
"client": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"delegate": "",
"delegate": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"deposit": "3",
"duration": "10",
"height": "2",
Expand Down
12 changes: 2 additions & 10 deletions test/regression/mnt/exports/suites_contracts_subscription.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
"app_state": {
"arkeo": {
"contract_expiration_sets": [
{
"contract_set": {
"contract_ids": [
"1"
]
},
"height": "12"
},
{
"contract_set": {
"contract_ids": [
Expand All @@ -25,7 +17,7 @@
{
"authorization": "STRICT",
"client": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"delegate": "",
"delegate": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"deposit": "100",
"duration": "10",
"height": "2",
Expand All @@ -46,7 +38,7 @@
{
"authorization": "OPEN",
"client": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"delegate": "",
"delegate": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"deposit": "20",
"duration": "5",
"height": "16",
Expand Down
13 changes: 2 additions & 11 deletions test/regression/mnt/exports/suites_sentinel_contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@
"app_name": "arkeo",
"app_state": {
"arkeo": {
"contract_expiration_sets": [
{
"contract_set": {
"contract_ids": [
"1"
]
},
"height": "12"
}
],
"contract_expiration_sets": [],
"contracts": [
{
"authorization": "STRICT",
"client": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"delegate": "",
"delegate": "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem",
"deposit": "100",
"duration": "10",
"height": "2",
Expand Down
1 change: 1 addition & 0 deletions x/arkeo/keeper/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (mgr Manager) ContractEndBlock(ctx cosmos.Context) error {
ctx.Logger().Error("unable to settle contract", "id", contractId, "error", err)
continue
}
mgr.keeper.RemoveContractExpirationSet(ctx, contract.Expiration())
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions x/arkeo/keeper/msg_server_close_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func (k msgServer) CloseContractHandle(ctx cosmos.Context, msg *types.MsgCloseCo
}

if contract.IsPayAsYouGo() {

k.RemoveContractExpirationSet(ctx, contract.Expiration())
// add a new expiration return deposit to user
newHeight := ctx.BlockHeight() + contract.SettlementDuration
expirationSet, err := k.GetContractExpirationSet(ctx, newHeight)
Expand Down
6 changes: 6 additions & 0 deletions x/arkeo/keeper/msg_server_open_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ func (k msgServer) OpenContractValidate(ctx cosmos.Context, msg *types.MsgOpenCo
}

func (k msgServer) OpenContractHandle(ctx cosmos.Context, msg *types.MsgOpenContract) error {

// set back client as delegate if delegate is empty
if msg.Delegate == "" {
msg.Delegate = msg.Client
}

openCost := k.FetchConfig(ctx, configs.OpenContractCost)
if openCost > 0 {
if err := k.SendFromAccountToModule(ctx, msg.MustGetSigner(), types.ModuleName, getCoins(openCost)); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions x/arkeo/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ var (
ErrInvariantMaxSupply = errors.Register(ModuleName, 32, "max supply invariant")
ErrInvalidAuthorization = errors.Register(ModuleName, 33, "invalid authorization")
ErrInvalidVersion = errors.Register(ModuleName, 34, "version cannot be zero or lower")
ErrInvalidBlocksPerYear = errors.Register(ModuleName, 37, "blocks per year cannot be zero or lower")
ErrInvalidEmissionCurve = errors.Register(ModuleName, 38, "emissionCurve set is invalid")
)
3 changes: 2 additions & 1 deletion x/arkeo/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func TestGenesisState_Validate(t *testing.T) {
valid: true,
},
{
desc: "valid genesis state",
desc: "valid genesis state",
genState: &types.GenesisState{
Params: types.DefaultParams(),

// this line is used by starport scaffolding # types/genesis/validField
},
Expand Down
9 changes: 9 additions & 0 deletions x/arkeo/types/params.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"cosmossdk.io/errors"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -32,6 +33,14 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {

// Validate validates the set of params
func (p Params) Validate() error {
if p.BlockPerYear <= 0 {
return errors.Wrap(ErrInvalidBlocksPerYear, "BlockPerYear must be greater than zero")
}

if p.EmissionCurve <= 0 {
return errors.Wrap(ErrInvalidEmissionCurve, "EmissionCurve must be greater than ")
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions x/claim/keeper/msg_server_claim_thorchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (k msgServer) ClaimThorchain(goCtx context.Context, msg *types.MsgClaimThor
AmountClaim: amountClaim,
AmountVote: amountVote,
AmountDelegate: amountDelegate,
IsTransferable: toAddressClaimRecord.IsTransferable,
}
emptyClaimRecord := types.ClaimRecord{
Chain: types.ARKEO,
Expand Down
3 changes: 3 additions & 0 deletions x/claim/keeper/msg_server_claim_thorchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ func TestClaimThorchainTestnetAddress(t *testing.T) {
AmountClaim: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountVote: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountDelegate: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
IsTransferable: false,
}
claimRecordTo := types.ClaimRecord{
Chain: types.ARKEO,
Address: toAddr.String(),
AmountClaim: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountVote: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountDelegate: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
IsTransferable: true,
}
err = keepers.ClaimKeeper.SetClaimRecord(sdkCtx, claimRecordFrom)
require.NoError(t, err)
Expand Down Expand Up @@ -70,6 +72,7 @@ func TestClaimThorchainTestnetAddress(t *testing.T) {
claimRecordTo, err = keepers.ClaimKeeper.GetClaimRecord(sdkCtx, toAddr.String(), types.ARKEO)
require.NoError(t, err)
require.True(t, !claimRecordTo.IsEmpty())
require.Equal(t, claimRecordTo.IsTransferable, true)

require.Equal(t, claimRecordTo.Address, toAddr.String())
require.Equal(t, claimRecordTo.Chain, types.ARKEO)
Expand Down
16 changes: 16 additions & 0 deletions x/claim/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {

// Validate validates the set of params
func (p Params) Validate() error {
if err := validateClaimDenom(p.ClaimDenom); err != nil {
return err
}

if err := validateAirdropStartTime(p.AirdropStartTime); err != nil {
return err
}

if err := validateDurationUntilDecay(p.DurationUntilDecay); err != nil {
return err
}

if err := validateDurationOfDecay(p.DurationOfDecay); err != nil {
return err
}

return nil
}

Expand Down
Loading