adding more vesting client tests
This commit is contained in:
@@ -16,7 +16,6 @@ import {
|
||||
GatewayOwnershipResponse,
|
||||
LayerDistribution,
|
||||
MixnetContractVersion,
|
||||
Mixnode,
|
||||
MixNode,
|
||||
MixNodeBond,
|
||||
MixNodeCostParams,
|
||||
@@ -35,7 +34,7 @@ import {
|
||||
StakeSaturationResponse,
|
||||
UnbondedMixnodeResponse,
|
||||
VestingAccountInfo,
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode
|
||||
} from '@nymproject/types';
|
||||
import QueryClient from './query-client';
|
||||
import SigningClient, { ISigningClient } from './signing-client';
|
||||
@@ -547,10 +546,38 @@ export default class ValidatorClient implements INymClient {
|
||||
return this.client.getVestingTokens(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getSpendableVestedTokens(vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.getSpendableVestedTokens(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getSpendableRewards(vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.getSpendableRewards(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getDelegatedCoins(vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.getDelegatedCoins(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getPledgedCoins(vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.getPledgedCoins(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getStakedCoins(vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.getStakedCoins(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getWithdrawnCoins(vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.getWithdrawnCoins(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getStartTime(vestingAccountAddress: string): Promise<string> {
|
||||
return this.client.getStartTime(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getEndTime(vestingAccountAddress: string): Promise<string> {
|
||||
return this.client.getEndTime(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
|
||||
public async getOriginalVestingDetails(vestingAccountAddress: string): Promise<OriginalVestingResponse> {
|
||||
return this.client.getOriginalVestingDetails(this.vestingContract, vestingAccountAddress);
|
||||
}
|
||||
@@ -563,10 +590,14 @@ export default class ValidatorClient implements INymClient {
|
||||
return this.client.getAccountDetails(this.vestingContract, address);
|
||||
}
|
||||
|
||||
public async getMixnode(address: string): Promise<Mixnode> {
|
||||
public async getMixnode(address: string): Promise<VestingAccountNode> {
|
||||
return this.client.getMixnode(this.vestingContract, address);
|
||||
}
|
||||
|
||||
public async getGateway(address: string): Promise<VestingAccountNode> {
|
||||
return this.client.getGateway(this.vestingContract, address);
|
||||
}
|
||||
|
||||
public async getDelegationTimes(mix_id: number, delegatorAddress: string): Promise<DelegationTimes> {
|
||||
return this.client.getDelegationTimes(this.vestingContract, mix_id, delegatorAddress);
|
||||
}
|
||||
@@ -574,4 +605,8 @@ export default class ValidatorClient implements INymClient {
|
||||
public async getAllDelegations(): Promise<Delegations> {
|
||||
return this.client.getAllDelegations(this.vestingContract);
|
||||
}
|
||||
|
||||
public async getCurrentVestingPeriod(address: string): Promise<Period> {
|
||||
return this.client.getCurrentVestingPeriod(this.vestingContract, address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { INyxdQuery } from './query-client';
|
||||
import {
|
||||
Delegation, Mixnode, OriginalVestingResponse, RewardingParams, StakeSaturationResponse, VestingAccountInfo,
|
||||
Delegation, OriginalVestingResponse, RewardingParams, StakeSaturationResponse, VestingAccountInfo,
|
||||
UnbondedMixnodeResponse,
|
||||
GatewayOwnershipResponse,
|
||||
MixnetContractVersion,
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
PagedMixNodeDetailsResponse,
|
||||
PagedUnbondedMixnodesResponse,
|
||||
LayerDistribution,
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode
|
||||
} from '@nymproject/types';
|
||||
import { SmartContractQuery } from './types/shared';
|
||||
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
|
||||
@@ -227,12 +227,54 @@ export default class NyxdQuerier implements INyxdQuery {
|
||||
});
|
||||
}
|
||||
|
||||
getSpendableVestedTokens(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_spendable_vested_coins: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getSpendableRewards(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_spendable_reward_coins: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getDelegatedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_delegated_coins: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getPledgedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_pledged_coins: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getStakedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_staked_coins: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getWithdrawnCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_withdrawn_coins: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getStartTime(vestingContractAddress: string, vestingAccountAddress: string): Promise<string> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_start_time: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getEndTime(vestingContractAddress: string, vestingAccountAddress: string): Promise<string> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_end_time: { vesting_account_address: vestingAccountAddress }
|
||||
});
|
||||
}
|
||||
|
||||
getOriginalVestingDetails(vestingContractAddress: string, vestingAccountAddress: string): Promise<OriginalVestingResponse> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_original_vesting: { vesting_account_address: vestingAccountAddress }
|
||||
@@ -251,12 +293,18 @@ export default class NyxdQuerier implements INyxdQuery {
|
||||
});
|
||||
}
|
||||
|
||||
getMixnode(vestingContractAddress: string, address: string): Promise<Mixnode> {
|
||||
getMixnode(vestingContractAddress: string, address: string): Promise<VestingAccountNode> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_mixnode: { address: address }
|
||||
});
|
||||
}
|
||||
|
||||
getGateway(vestingContractAddress: string, address: string): Promise<VestingAccountNode> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_gateway: { address: address }
|
||||
});
|
||||
}
|
||||
|
||||
getDelegationTimes(vestingContractAddress: string, mix_id: number, address: string): Promise<DelegationTimes> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_delegation_times: { mix_id: mix_id, address: address }
|
||||
@@ -268,4 +316,10 @@ export default class NyxdQuerier implements INyxdQuery {
|
||||
get_all_delegations: {}
|
||||
});
|
||||
}
|
||||
|
||||
getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> {
|
||||
return this.client.queryContractSmart(vestingContractAddress, {
|
||||
get_current_vesting_period: { address: address }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@ import {
|
||||
MixNodeRewarding,
|
||||
OriginalVestingResponse,
|
||||
VestingAccountInfo,
|
||||
Mixnode,
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode
|
||||
} from '@nymproject/types';
|
||||
import NymApiQuerier, { INymApiQuery } from './nym-api-querier';
|
||||
import { ICosmWasmQuery } from './types/shared';
|
||||
@@ -229,10 +228,38 @@ export default class QueryClient extends CosmWasmClient implements IQueryClient
|
||||
return this.nyxdQuerier.getVestingTokens(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getSpendableVestedTokens(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getSpendableVestedTokens(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getSpendableRewards(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getSpendableRewards(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getDelegatedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getDelegatedCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getPledgedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getPledgedCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getStakedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getStakedCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getWithdrawnCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getWithdrawnCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getStartTime(vestingContractAddress: string, vestingAccountAddress: string): Promise<string> {
|
||||
return this.nyxdQuerier.getStartTime(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getEndTime(vestingContractAddress: string, vestingAccountAddress: string): Promise<string> {
|
||||
return this.nyxdQuerier.getEndTime(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getOriginalVestingDetails(vestingContractAddress: string, vestingAccountAddress: string): Promise<OriginalVestingResponse> {
|
||||
return this.nyxdQuerier.getOriginalVestingDetails(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
@@ -245,10 +272,14 @@ export default class QueryClient extends CosmWasmClient implements IQueryClient
|
||||
return this.nyxdQuerier.getAccountDetails(vestingContractAddress, address);
|
||||
}
|
||||
|
||||
getMixnode(vestingContractAddress: string, address: string): Promise<Mixnode> {
|
||||
getMixnode(vestingContractAddress: string, address: string): Promise<VestingAccountNode> {
|
||||
return this.nyxdQuerier.getMixnode(vestingContractAddress, address);
|
||||
}
|
||||
|
||||
getGateway(vestingContractAddress: string, address: string): Promise<VestingAccountNode> {
|
||||
return this.nyxdQuerier.getGateway(vestingContractAddress, address);
|
||||
}
|
||||
|
||||
getDelegationTimes(vestingContractAddress: string, mix_id: number, delegatorAddress: string): Promise<DelegationTimes> {
|
||||
return this.nyxdQuerier.getDelegationTimes(vestingContractAddress, mix_id, delegatorAddress);
|
||||
}
|
||||
@@ -256,4 +287,8 @@ export default class QueryClient extends CosmWasmClient implements IQueryClient
|
||||
getAllDelegations(vestingContractAddress: string): Promise<Delegations> {
|
||||
return this.nyxdQuerier.getAllDelegations(vestingContractAddress);
|
||||
}
|
||||
|
||||
getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> {
|
||||
return this.nyxdQuerier.getCurrentVestingPeriod(vestingContractAddress, address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
GatewayOwnershipResponse,
|
||||
LayerDistribution,
|
||||
MixnetContractVersion,
|
||||
Mixnode,
|
||||
MixNode,
|
||||
MixNodeBond,
|
||||
MixNodeCostParams,
|
||||
@@ -41,7 +40,7 @@ import {
|
||||
RewardingParams,
|
||||
UnbondedMixnodeResponse,
|
||||
VestingAccountInfo,
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations
|
||||
ContractState, VestingAccountsCoinPaged, VestingAccountsPaged, DelegationTimes, Delegations, Period, VestingAccountNode
|
||||
} from '@nymproject/types';
|
||||
import NymApiQuerier from './nym-api-querier';
|
||||
|
||||
@@ -538,10 +537,38 @@ export default class SigningClient extends SigningCosmWasmClient implements ISig
|
||||
return this.nyxdQuerier.getVestingTokens(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getSpendableVestedTokens(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getSpendableVestedTokens(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getSpendableRewards(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getSpendableRewards(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getDelegatedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getDelegatedCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getPledgedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getPledgedCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getStakedCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getStakedCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getWithdrawnCoins(vestingContractAddress: string, vestingAccountAddress: string): Promise<Coin> {
|
||||
return this.nyxdQuerier.getWithdrawnCoins(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getStartTime(vestingContractAddress: string, vestingAccountAddress: string): Promise<string> {
|
||||
return this.nyxdQuerier.getStartTime(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getEndTime(vestingContractAddress: string, vestingAccountAddress: string): Promise<string> {
|
||||
return this.nyxdQuerier.getEndTime(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
|
||||
getOriginalVestingDetails(vestingContractAddress: string, vestingAccountAddress: string): Promise<OriginalVestingResponse> {
|
||||
return this.nyxdQuerier.getOriginalVestingDetails(vestingContractAddress, vestingAccountAddress);
|
||||
}
|
||||
@@ -554,10 +581,14 @@ export default class SigningClient extends SigningCosmWasmClient implements ISig
|
||||
return this.nyxdQuerier.getAccountDetails(vestingContractAddress, address);
|
||||
}
|
||||
|
||||
getMixnode(vestingContractAddress: string, address: string): Promise<Mixnode> {
|
||||
getMixnode(vestingContractAddress: string, address: string): Promise<VestingAccountNode> {
|
||||
return this.nyxdQuerier.getMixnode(vestingContractAddress, address);
|
||||
}
|
||||
|
||||
getGateway(vestingContractAddress: string, address: string): Promise<VestingAccountNode> {
|
||||
return this.nyxdQuerier.getGateway(vestingContractAddress, address);
|
||||
}
|
||||
|
||||
getDelegationTimes(vestingContractAddress: string, mix_id: number, delegatorAddress: string): Promise<DelegationTimes> {
|
||||
return this.nyxdQuerier.getDelegationTimes(vestingContractAddress, mix_id, delegatorAddress);
|
||||
}
|
||||
@@ -565,4 +596,8 @@ export default class SigningClient extends SigningCosmWasmClient implements ISig
|
||||
getAllDelegations(vestingContractAddress: string): Promise<Delegations> {
|
||||
return this.nyxdQuerier.getAllDelegations(vestingContractAddress);
|
||||
}
|
||||
|
||||
getCurrentVestingPeriod(vestingContractAddress: string, address: string): Promise<Period> {
|
||||
return this.nyxdQuerier.getCurrentVestingPeriod(vestingContractAddress, address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,6 @@ export const layerDistribution = {
|
||||
layer3: expect.any(Number)
|
||||
}
|
||||
|
||||
|
||||
export const intervalRewardParams = {
|
||||
reward_pool: expect.any(Number),
|
||||
staking_supply: expect.any(Number),
|
||||
@@ -199,9 +198,6 @@ export const VestingCoinAccounts = {
|
||||
start_next_after: expect.any(String)
|
||||
}
|
||||
|
||||
export const startTime = {
|
||||
}
|
||||
|
||||
export const OriginalVestingDetails = {
|
||||
amount: Coin,
|
||||
number_of_periods: expect.any(Number),
|
||||
@@ -209,7 +205,7 @@ export const OriginalVestingDetails = {
|
||||
}
|
||||
|
||||
export const PledgeCap = {
|
||||
percent: expect.any(String),
|
||||
percent: expect.any(String) || null,
|
||||
};
|
||||
|
||||
export const Periods = [{
|
||||
@@ -218,27 +214,31 @@ export const Periods = [{
|
||||
}]
|
||||
|
||||
export const VestingAccountDetails = {
|
||||
coin: Coin,
|
||||
owner_address: expect.any(String),
|
||||
periods: Periods,
|
||||
pledge_cap: PledgeCap,
|
||||
staking_address: expect.any(String) || null,
|
||||
start_time: expect.any(String),
|
||||
storage_key: expect.any(Number)
|
||||
periods: Periods,
|
||||
coin: Coin,
|
||||
storage_key: expect.any(Number),
|
||||
pledge_cap: PledgeCap
|
||||
}
|
||||
|
||||
export const Mixnode = {
|
||||
export const Node = {
|
||||
amount: Coin,
|
||||
block_time: expect.any(String)
|
||||
}
|
||||
|
||||
export const DelegationTimestamps = [{}]
|
||||
export type VestingPeriod = 'Before' | { In: number } | 'After';
|
||||
|
||||
export const DelegationTimestamps = [
|
||||
expect.any(Number)
|
||||
]
|
||||
|
||||
export const DelegatorTimes = {
|
||||
account_id: expect.any(Number),
|
||||
delegation_timestamps: DelegationTimestamps,
|
||||
mix_id: expect.any(Number),
|
||||
owner: expect.any(String),
|
||||
account_id: expect.any(Number),
|
||||
mix_id: expect.any(Number),
|
||||
delegation_timestamps: DelegationTimestamps
|
||||
}
|
||||
|
||||
export const DelegationBlock = [{
|
||||
@@ -251,4 +251,4 @@ export const DelegationBlock = [{
|
||||
export const Delegations = {
|
||||
delegations: DelegationBlock,
|
||||
start_next_after: expect.any(String) || null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import expect from 'expect';
|
||||
import ValidatorClient from '../../index';
|
||||
import { amountDemon, Delegations, DelegatorTimes, Mixnode, OriginalVestingDetails, startTime, VestingAccountDetails, vestingAccountsPaged, VestingCoinAccounts } from '../expectedResponses';
|
||||
import { amountDemon, Delegations, DelegatorTimes, Node, OriginalVestingDetails, VestingAccountDetails, vestingAccountsPaged, VestingCoinAccounts, VestingPeriod } from '../expectedResponses';
|
||||
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
@@ -20,6 +20,11 @@ describe.only('Vesting queries', () => {
|
||||
);
|
||||
});
|
||||
|
||||
const vesting_account_address = 'n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv';
|
||||
const mixnodeowner = 'n1z93z44vf8ssvdhujjvxcj4rd5e3lz0l60wdk70';
|
||||
const gatewayowner = 'n1un9cuvw9e3xqratmde4j55ucksev0dkeruq800';
|
||||
const mix_id = 79;
|
||||
|
||||
it('can query for contract version', async () => {
|
||||
const contract = await client.getVestingContractVersion();
|
||||
expect(contract).toBeTruthy();
|
||||
@@ -39,77 +44,125 @@ describe.only('Vesting queries', () => {
|
||||
});
|
||||
|
||||
it('can get locked tokens for an account', async () => {
|
||||
const locked = await client.getLockedTokens("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
const locked = await client.getLockedTokens(vesting_account_address);
|
||||
expect(Object.keys(locked)).toEqual(Object.keys(amountDemon));
|
||||
expect(locked).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get spendable tokens for an account', async () => {
|
||||
const spendable = await client.getSpendableTokens("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
const spendable = await client.getSpendableTokens(vesting_account_address);
|
||||
expect(Object.keys(spendable)).toEqual(Object.keys(amountDemon));
|
||||
expect(spendable).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get vested tokens for an account', async () => {
|
||||
const vested = await client.getVestedTokens("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
const vested = await client.getVestedTokens(vesting_account_address);
|
||||
expect(Object.keys(vested)).toEqual(Object.keys(amountDemon));
|
||||
expect(vested).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get vesting tokens for an account', async () => {
|
||||
const vesting = await client.getVestingTokens("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
const vesting = await client.getVestingTokens(vesting_account_address);
|
||||
expect(Object.keys(vesting)).toEqual(Object.keys(amountDemon));
|
||||
expect(vesting).toBeTruthy();
|
||||
});
|
||||
|
||||
// TODO fix this
|
||||
it.skip('can get start time of an account', async () => {
|
||||
const time = await client.getStartTime("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
console.log("----------------")
|
||||
console.log(time)
|
||||
expect(Object.keys(time)).toEqual(Object.keys(startTime));
|
||||
it('can get spendable vested tokens for an account', async () => {
|
||||
const spendable = await client.getSpendableVestedTokens(vesting_account_address);
|
||||
expect(Object.keys(spendable)).toEqual(Object.keys(amountDemon));
|
||||
expect(spendable).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get spendable rewards for an account', async () => {
|
||||
const rewards = await client.getSpendableRewards(vesting_account_address);
|
||||
expect(Object.keys(rewards)).toEqual(Object.keys(amountDemon));
|
||||
expect(rewards).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get delegated coins', async () => {
|
||||
const delegated = await client.getDelegatedCoins(vesting_account_address);
|
||||
expect(Object.keys(delegated)).toEqual(Object.keys(amountDemon));
|
||||
expect(delegated).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get pledged coins', async () => {
|
||||
const pledged = await client.getPledgedCoins(vesting_account_address);
|
||||
expect(Object.keys(pledged)).toEqual(Object.keys(amountDemon));
|
||||
expect(pledged).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get staked coins', async () => {
|
||||
const staked = await client.getStakedCoins(vesting_account_address);
|
||||
expect(Object.keys(staked)).toEqual(Object.keys(amountDemon));
|
||||
expect(staked).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get withdrawn coins', async () => {
|
||||
const withdrawn = await client.getWithdrawnCoins(vesting_account_address);
|
||||
expect(Object.keys(withdrawn)).toEqual(Object.keys(amountDemon));
|
||||
expect(withdrawn).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get start time of an account', async () => {
|
||||
const time = await client.getStartTime(vesting_account_address);
|
||||
expect(typeof time).toBe("string");
|
||||
expect(time).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get end time of an account', async () => {
|
||||
const time = await client.getEndTime(vesting_account_address);
|
||||
expect(typeof time).toBe("string");
|
||||
expect(time).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get account original vesting details', async () => {
|
||||
const original = await client.getOriginalVestingDetails("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
const original = await client.getOriginalVestingDetails(vesting_account_address);
|
||||
expect(Object.keys(original)).toEqual(Object.keys(OriginalVestingDetails));
|
||||
expect(original).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get historic vesting staking rewards', async () => {
|
||||
const rewards = await client.getHistoricStakingRewards("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
const rewards = await client.getHistoricStakingRewards(vesting_account_address);
|
||||
expect(Object.keys(rewards)).toEqual(Object.keys(amountDemon));
|
||||
expect(rewards).toBeTruthy();
|
||||
});
|
||||
|
||||
// TODO VestingAccountInfo autogenerated file needs to be edited/fixed as it's wrong
|
||||
it.skip('can get account details', async () => {
|
||||
const account = await client.getAccountDetails("n14juvj7llvx8eppypnqj6xlrgwss9wfrcuy0nkv");
|
||||
// TODO see if we can use "VestingAccountInfo" type here instead
|
||||
it('can get account details', async () => {
|
||||
const account = await client.getAccountDetails(vesting_account_address);
|
||||
expect(Object.keys(account)).toEqual(Object.keys(VestingAccountDetails));
|
||||
expect(account).toBeTruthy();
|
||||
});
|
||||
|
||||
// TODO add option for if account has no mixnode and expected is null
|
||||
it('can get mixnode', async () => {
|
||||
const mixnode = await client.getMixnode("n1z93z44vf8ssvdhujjvxcj4rd5e3lz0l60wdk70");
|
||||
expect(Object.keys(mixnode)).toEqual(Object.keys(Mixnode));
|
||||
const mixnode = await client.getMixnode(mixnodeowner);
|
||||
expect(Object.keys(mixnode)).toEqual(Object.keys(Node));
|
||||
expect(mixnode).toBeTruthy();
|
||||
});
|
||||
|
||||
// TODO nyxd query returns value in different order to this test, understand why
|
||||
// TODO add option for if account has no gateway and expected is null
|
||||
it('can get gateway', async () => {
|
||||
const gateway = await client.getGateway(gatewayowner);
|
||||
expect(Object.keys(gateway)).toEqual(Object.keys(Node));
|
||||
expect(gateway).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get delegations times', async () => {
|
||||
const delegation = await client.getDelegationTimes(79, "n1z93z44vf8ssvdhujjvxcj4rd5e3lz0l60wdk70");
|
||||
console.log("---")
|
||||
console.log(delegation)
|
||||
console.log("---")
|
||||
const delegation = await client.getDelegationTimes(mix_id, mixnodeowner);
|
||||
expect(Object.keys(delegation)).toEqual(Object.keys(DelegatorTimes));
|
||||
expect(delegation).toBeTruthy();
|
||||
});
|
||||
|
||||
it.only('can get all delegations', async () => {
|
||||
it('can get all delegations', async () => {
|
||||
const delegation = await client.getAllDelegations();
|
||||
expect(Object.keys(delegation)).toEqual(Object.keys(Delegations));
|
||||
expect(delegation).toBeTruthy();
|
||||
});
|
||||
|
||||
it('can get current vesting period', async () => {
|
||||
const period = await client.getCurrentVestingPeriod(gatewayowner);
|
||||
expect(period).toEqual(expect.anything() as unknown as VestingPeriod);
|
||||
expect(period).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -159,7 +159,7 @@ export interface ContractState {
|
||||
params: ContractStateParams;
|
||||
};
|
||||
|
||||
export type Mixnode = {
|
||||
export type VestingAccountNode = {
|
||||
amount: Coin;
|
||||
block_time: string;
|
||||
};
|
||||
@@ -180,12 +180,9 @@ export interface VestingAccountsCoinPaged {
|
||||
still_vesting: Coin;
|
||||
};
|
||||
|
||||
export interface DelegationTimestamps {
|
||||
};
|
||||
|
||||
export interface DelegationTimes {
|
||||
account_id: number;
|
||||
delegation_timestamps: DelegationTimestamps[];
|
||||
delegation_timestamps: [];
|
||||
mix_id: number;
|
||||
owner: string;
|
||||
};
|
||||
@@ -195,10 +192,9 @@ export interface DelegationBlock {
|
||||
amount: string;
|
||||
block_timestamp: number;
|
||||
mix_id: number;
|
||||
}
|
||||
};
|
||||
|
||||
export interface Delegations {
|
||||
delegations: DelegationBlock[];
|
||||
start_next_after: string | null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user