Add StakingExtension
This commit is contained in:
parent
4f86ba37f5
commit
f239f86047
@ -63,10 +63,14 @@ export {
|
||||
setupGovExtension,
|
||||
setupMintExtension,
|
||||
setupSlashingExtension,
|
||||
setupStakingExtension,
|
||||
setupSupplyExtension,
|
||||
SlashingExtension,
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
StakingExtension,
|
||||
StakingParametersResponse,
|
||||
StakingPoolResponse,
|
||||
SupplyExtension,
|
||||
TxsResponse,
|
||||
} from "./lcdapi";
|
||||
|
||||
@ -42,6 +42,12 @@ export {
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
} from "./slashing";
|
||||
export {
|
||||
setupStakingExtension,
|
||||
StakingExtension,
|
||||
StakingParametersResponse,
|
||||
StakingPoolResponse,
|
||||
} from "./staking";
|
||||
export { setupSupplyExtension, SupplyExtension, TotalSupplyAllResponse, TotalSupplyResponse } from "./supply";
|
||||
|
||||
//
|
||||
|
||||
43
packages/sdk38/src/lcdapi/staking.spec.ts
Normal file
43
packages/sdk38/src/lcdapi/staking.spec.ts
Normal file
@ -0,0 +1,43 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
import { nonNegativeIntegerMatcher, pendingWithoutWasmd, wasmd } from "../testutils.spec";
|
||||
import { LcdClient } from "./lcdclient";
|
||||
import { setupStakingExtension, StakingExtension } from "./staking";
|
||||
|
||||
function makeStakingClient(apiUrl: string): LcdClient & StakingExtension {
|
||||
return LcdClient.withExtensions({ apiUrl }, setupStakingExtension);
|
||||
}
|
||||
|
||||
describe("StakingExtension", () => {
|
||||
describe("pool", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = makeStakingClient(wasmd.endpoint);
|
||||
const response = await client.staking.pool();
|
||||
expect(response).toEqual({
|
||||
height: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
result: {
|
||||
not_bonded_tokens: "0",
|
||||
bonded_tokens: "250000000",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("parameters", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = makeStakingClient(wasmd.endpoint);
|
||||
const response = await client.staking.parameters();
|
||||
expect(response).toEqual({
|
||||
height: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
result: {
|
||||
unbonding_time: "1814400000000000",
|
||||
max_validators: 100,
|
||||
max_entries: 7,
|
||||
historical_entries: 0,
|
||||
bond_denom: "ustake",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
36
packages/sdk38/src/lcdapi/staking.ts
Normal file
36
packages/sdk38/src/lcdapi/staking.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { LcdClient } from "./lcdclient";
|
||||
|
||||
export interface StakingPoolResponse {
|
||||
readonly height: string;
|
||||
readonly result: {
|
||||
readonly not_bonded_tokens: string;
|
||||
readonly bonded_tokens: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface StakingParametersResponse {
|
||||
readonly height: string;
|
||||
readonly result: {
|
||||
readonly unbonding_time: string;
|
||||
readonly max_validators: number;
|
||||
readonly max_entries: number;
|
||||
readonly historical_entries: number;
|
||||
readonly bond_denom: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface StakingExtension {
|
||||
readonly staking: {
|
||||
readonly pool: () => Promise<StakingPoolResponse>;
|
||||
readonly parameters: () => Promise<StakingParametersResponse>;
|
||||
};
|
||||
}
|
||||
|
||||
export function setupStakingExtension(base: LcdClient): StakingExtension {
|
||||
return {
|
||||
staking: {
|
||||
pool: async () => base.get(`/staking/pool`),
|
||||
parameters: async () => base.get(`/staking/parameters`),
|
||||
},
|
||||
};
|
||||
}
|
||||
4
packages/sdk38/types/index.d.ts
vendored
4
packages/sdk38/types/index.d.ts
vendored
@ -61,10 +61,14 @@ export {
|
||||
setupGovExtension,
|
||||
setupMintExtension,
|
||||
setupSlashingExtension,
|
||||
setupStakingExtension,
|
||||
setupSupplyExtension,
|
||||
SlashingExtension,
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
StakingExtension,
|
||||
StakingParametersResponse,
|
||||
StakingPoolResponse,
|
||||
SupplyExtension,
|
||||
TxsResponse,
|
||||
} from "./lcdapi";
|
||||
|
||||
6
packages/sdk38/types/lcdapi/index.d.ts
vendored
6
packages/sdk38/types/lcdapi/index.d.ts
vendored
@ -38,6 +38,12 @@ export {
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
} from "./slashing";
|
||||
export {
|
||||
setupStakingExtension,
|
||||
StakingExtension,
|
||||
StakingParametersResponse,
|
||||
StakingPoolResponse,
|
||||
} from "./staking";
|
||||
export { setupSupplyExtension, SupplyExtension, TotalSupplyAllResponse, TotalSupplyResponse } from "./supply";
|
||||
export {
|
||||
BlockResponse,
|
||||
|
||||
25
packages/sdk38/types/lcdapi/staking.d.ts
vendored
Normal file
25
packages/sdk38/types/lcdapi/staking.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import { LcdClient } from "./lcdclient";
|
||||
export interface StakingPoolResponse {
|
||||
readonly height: string;
|
||||
readonly result: {
|
||||
readonly not_bonded_tokens: string;
|
||||
readonly bonded_tokens: string;
|
||||
};
|
||||
}
|
||||
export interface StakingParametersResponse {
|
||||
readonly height: string;
|
||||
readonly result: {
|
||||
readonly unbonding_time: string;
|
||||
readonly max_validators: number;
|
||||
readonly max_entries: number;
|
||||
readonly historical_entries: number;
|
||||
readonly bond_denom: string;
|
||||
};
|
||||
}
|
||||
export interface StakingExtension {
|
||||
readonly staking: {
|
||||
readonly pool: () => Promise<StakingPoolResponse>;
|
||||
readonly parameters: () => Promise<StakingParametersResponse>;
|
||||
};
|
||||
}
|
||||
export declare function setupStakingExtension(base: LcdClient): StakingExtension;
|
||||
Loading…
Reference in New Issue
Block a user