adding vesting tests (#3279)

This commit is contained in:
benedetta davico
2023-04-05 10:57:45 +02:00
committed by GitHub
parent 59c1ce2639
commit 5ce017ef3d
4 changed files with 41 additions and 4 deletions
+10 -1
View File
@@ -34,10 +34,11 @@ import {
StakeSaturationResponse, StakeSaturationResponse,
UnbondedMixnodeResponse, UnbondedMixnodeResponse,
VestingAccountInfo, VestingAccountInfo,
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode, DelegationBlock
} from '@nymproject/types'; } from '@nymproject/types';
import QueryClient from './query-client'; import QueryClient from './query-client';
import SigningClient, { ISigningClient } from './signing-client'; import SigningClient, { ISigningClient } from './signing-client';
// import { DelegationBlock } from './types/shared';
export interface INymClient { export interface INymClient {
readonly mixnetContract: string; readonly mixnetContract: string;
@@ -606,6 +607,14 @@ export default class ValidatorClient implements INymClient {
return this.client.getAllDelegations(this.vestingContract); return this.client.getAllDelegations(this.vestingContract);
} }
public async getDelegation(address: string, mix_id: number): Promise<DelegationBlock> {
return this.client.getDelegation(this.vestingContract, address, mix_id );
}
public async getTotalDelegationAmount(address: string, mix_id: number, block_timestamp_sec: number): Promise<Coin> {
return this.client.getTotalDelegationAmount(this.vestingContract, address, mix_id, block_timestamp_sec);
}
public async getCurrentVestingPeriod(address: string): Promise<Period> { public async getCurrentVestingPeriod(address: string): Promise<Period> {
return this.client.getCurrentVestingPeriod(this.vestingContract, address); return this.client.getCurrentVestingPeriod(this.vestingContract, address);
} }
+13 -1
View File
@@ -18,7 +18,7 @@ import {
PagedMixNodeDetailsResponse, PagedMixNodeDetailsResponse,
PagedUnbondedMixnodesResponse, PagedUnbondedMixnodesResponse,
LayerDistribution, LayerDistribution,
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode, DelegationBlock
} from '@nymproject/types'; } from '@nymproject/types';
import { SmartContractQuery } from './types/shared'; import { SmartContractQuery } from './types/shared';
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin'; import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
@@ -317,6 +317,18 @@ export default class NyxdQuerier implements INyxdQuery {
}); });
} }
getDelegation(vestingContractAddress: string, address: string, mix_id: number): Promise<DelegationBlock> {
return this.client.queryContractSmart(vestingContractAddress, {
get_all_delegations: {address: address, mix_id: mix_id}
});
}
getTotalDelegationAmount(vestingContractAddress: string, address: string, mix_id: number, block_timestamp_sec: number): Promise<Coin> {
return this.client.queryContractSmart(vestingContractAddress, {
get_all_delegations: {address: address, mix_id: mix_id, block_timestamp_sec: block_timestamp_sec}
});
}
getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> { getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> {
return this.client.queryContractSmart(vestingContractAddress, { return this.client.queryContractSmart(vestingContractAddress, {
get_current_vesting_period: { address: address } get_current_vesting_period: { address: address }
+9 -1
View File
@@ -22,7 +22,7 @@ import {
MixNodeRewarding, MixNodeRewarding,
OriginalVestingResponse, OriginalVestingResponse,
VestingAccountInfo, VestingAccountInfo,
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode, DelegationBlock
} from '@nymproject/types'; } from '@nymproject/types';
import NymApiQuerier, { INymApiQuery } from './nym-api-querier'; import NymApiQuerier, { INymApiQuery } from './nym-api-querier';
import { ICosmWasmQuery } from './types/shared'; import { ICosmWasmQuery } from './types/shared';
@@ -288,6 +288,14 @@ export default class QueryClient extends CosmWasmClient implements IQueryClient
return this.nyxdQuerier.getAllDelegations(vestingContractAddress); return this.nyxdQuerier.getAllDelegations(vestingContractAddress);
} }
getDelegation(vestingContractAddress: string, vestingAccountAddress: string, mix_id: number): Promise<DelegationBlock> {
return this.nyxdQuerier.getDelegation(vestingContractAddress, vestingAccountAddress, mix_id);
}
getTotalDelegationAmount(vestingContractAddress: string, vestingAccountAddress: string, mix_id: number, block_timestamp_sec: number): Promise<Coin> {
return this.nyxdQuerier.getTotalDelegationAmount(vestingContractAddress, vestingAccountAddress, mix_id, block_timestamp_sec);
}
getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> { getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> {
return this.nyxdQuerier.getCurrentVestingPeriod(vestingContractAddress, address); return this.nyxdQuerier.getCurrentVestingPeriod(vestingContractAddress, address);
} }
+9 -1
View File
@@ -40,7 +40,7 @@ import {
RewardingParams, RewardingParams,
UnbondedMixnodeResponse, UnbondedMixnodeResponse,
VestingAccountInfo, VestingAccountInfo,
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode, DelegationBlock
} from '@nymproject/types'; } from '@nymproject/types';
import NymApiQuerier from './nym-api-querier'; import NymApiQuerier from './nym-api-querier';
@@ -597,6 +597,14 @@ export default class SigningClient extends SigningCosmWasmClient implements ISig
return this.nyxdQuerier.getAllDelegations(vestingContractAddress); return this.nyxdQuerier.getAllDelegations(vestingContractAddress);
} }
getDelegation(vestingContractAddress: string, vestingAccountAddress: string, mix_id: number): Promise<DelegationBlock> {
return this.nyxdQuerier.getDelegation(vestingContractAddress, vestingAccountAddress, mix_id);
}
getTotalDelegationAmount(vestingContractAddress: string, vestingAccountAddress: string, mix_id: number, block_timestamp_sec: number): Promise<Coin> {
return this.nyxdQuerier.getTotalDelegationAmount(vestingContractAddress, vestingAccountAddress, mix_id, block_timestamp_sec);
}
getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> { getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> {
return this.nyxdQuerier.getCurrentVestingPeriod(vestingContractAddress, address); return this.nyxdQuerier.getCurrentVestingPeriod(vestingContractAddress, address);
} }