Merge pull request #286 from CosmWasm/slashing-extension
Add support for slashing queries
This commit is contained in:
commit
0fa5da299c
@ -36,7 +36,11 @@ export {
|
||||
SearchTxsResponse,
|
||||
setupAuthExtension,
|
||||
setupBankExtension,
|
||||
setupSlashingExtension,
|
||||
setupSupplyExtension,
|
||||
SlashingExtension,
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
SupplyExtension,
|
||||
TxsResponse,
|
||||
} from "./lcdapi";
|
||||
|
||||
@ -4,6 +4,12 @@
|
||||
|
||||
export { AuthExtension, AuthAccountsResponse, setupAuthExtension } from "./auth";
|
||||
export { BankBalancesResponse, BankExtension, setupBankExtension } from "./bank";
|
||||
export {
|
||||
setupSlashingExtension,
|
||||
SlashingExtension,
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
} from "./slashing";
|
||||
export { setupSupplyExtension, SupplyExtension, TotalSupplyAllResponse, TotalSupplyResponse } from "./supply";
|
||||
|
||||
//
|
||||
|
||||
49
packages/sdk38/src/lcdapi/slashing.spec.ts
Normal file
49
packages/sdk38/src/lcdapi/slashing.spec.ts
Normal file
@ -0,0 +1,49 @@
|
||||
/* eslint-disable @typescript-eslint/camelcase */
|
||||
import { nonNegativeIntegerMatcher, pendingWithoutWasmd, wasmd } from "../testutils.spec";
|
||||
import { LcdClient } from "./lcdclient";
|
||||
import { setupSlashingExtension, SlashingExtension } from "./slashing";
|
||||
|
||||
function makeSlashingClient(apiUrl: string): LcdClient & SlashingExtension {
|
||||
return LcdClient.withExtensions({ apiUrl }, setupSlashingExtension);
|
||||
}
|
||||
|
||||
describe("SlashingExtension", () => {
|
||||
describe("signingInfos", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = makeSlashingClient(wasmd.endpoint);
|
||||
const response = await client.slashing.signingInfos();
|
||||
expect(response).toEqual({
|
||||
height: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
result: [
|
||||
{
|
||||
address: "cosmosvalcons1yyjaavsv98lwn8he9lzcjhefzyyn4xygfyxls0",
|
||||
start_height: "0",
|
||||
index_offset: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
jailed_until: "1970-01-01T00:00:00Z",
|
||||
tombstoned: false,
|
||||
missed_blocks_counter: "0",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("parameters", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = makeSlashingClient(wasmd.endpoint);
|
||||
const response = await client.slashing.parameters();
|
||||
expect(response).toEqual({
|
||||
height: jasmine.stringMatching(nonNegativeIntegerMatcher),
|
||||
result: {
|
||||
signed_blocks_window: "100",
|
||||
min_signed_per_window: "0.500000000000000000",
|
||||
downtime_jail_duration: "600000000000",
|
||||
slash_fraction_double_sign: "0.050000000000000000",
|
||||
slash_fraction_downtime: "0.010000000000000000",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
46
packages/sdk38/src/lcdapi/slashing.ts
Normal file
46
packages/sdk38/src/lcdapi/slashing.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { LcdClient } from "./lcdclient";
|
||||
|
||||
interface SlashingSigningInfo {
|
||||
readonly address: string;
|
||||
readonly start_height: string;
|
||||
readonly index_offset: string;
|
||||
readonly jailed_until: string;
|
||||
readonly tombstoned: boolean;
|
||||
readonly missed_blocks_counter: string;
|
||||
}
|
||||
|
||||
export interface SlashingSigningInfosResponse {
|
||||
readonly height: string;
|
||||
readonly result: readonly SlashingSigningInfo[];
|
||||
}
|
||||
|
||||
export interface SlashingParametersResponse {
|
||||
readonly height: string;
|
||||
readonly result: {
|
||||
readonly signed_blocks_window: string;
|
||||
readonly min_signed_per_window: string;
|
||||
readonly downtime_jail_duration: string;
|
||||
readonly slash_fraction_double_sign: string;
|
||||
readonly slash_fraction_downtime: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SlashingExtension {
|
||||
readonly slashing: {
|
||||
readonly signingInfos: () => Promise<SlashingSigningInfosResponse>;
|
||||
readonly parameters: () => Promise<SlashingParametersResponse>;
|
||||
};
|
||||
}
|
||||
|
||||
export function setupSlashingExtension(base: LcdClient): SlashingExtension {
|
||||
return {
|
||||
slashing: {
|
||||
signingInfos: async () => {
|
||||
return base.get(`/slashing/signing_infos`);
|
||||
},
|
||||
parameters: async () => {
|
||||
return base.get(`/slashing/parameters`);
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
4
packages/sdk38/types/index.d.ts
vendored
4
packages/sdk38/types/index.d.ts
vendored
@ -34,7 +34,11 @@ export {
|
||||
SearchTxsResponse,
|
||||
setupAuthExtension,
|
||||
setupBankExtension,
|
||||
setupSlashingExtension,
|
||||
setupSupplyExtension,
|
||||
SlashingExtension,
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
SupplyExtension,
|
||||
TxsResponse,
|
||||
} from "./lcdapi";
|
||||
|
||||
6
packages/sdk38/types/lcdapi/index.d.ts
vendored
6
packages/sdk38/types/lcdapi/index.d.ts
vendored
@ -1,5 +1,11 @@
|
||||
export { AuthExtension, AuthAccountsResponse, setupAuthExtension } from "./auth";
|
||||
export { BankBalancesResponse, BankExtension, setupBankExtension } from "./bank";
|
||||
export {
|
||||
setupSlashingExtension,
|
||||
SlashingExtension,
|
||||
SlashingParametersResponse,
|
||||
SlashingSigningInfosResponse,
|
||||
} from "./slashing";
|
||||
export { setupSupplyExtension, SupplyExtension, TotalSupplyAllResponse, TotalSupplyResponse } from "./supply";
|
||||
export {
|
||||
BlockResponse,
|
||||
|
||||
31
packages/sdk38/types/lcdapi/slashing.d.ts
vendored
Normal file
31
packages/sdk38/types/lcdapi/slashing.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import { LcdClient } from "./lcdclient";
|
||||
interface SlashingSigningInfo {
|
||||
readonly address: string;
|
||||
readonly start_height: string;
|
||||
readonly index_offset: string;
|
||||
readonly jailed_until: string;
|
||||
readonly tombstoned: boolean;
|
||||
readonly missed_blocks_counter: string;
|
||||
}
|
||||
export interface SlashingSigningInfosResponse {
|
||||
readonly height: string;
|
||||
readonly result: readonly SlashingSigningInfo[];
|
||||
}
|
||||
export interface SlashingParametersResponse {
|
||||
readonly height: string;
|
||||
readonly result: {
|
||||
readonly signed_blocks_window: string;
|
||||
readonly min_signed_per_window: string;
|
||||
readonly downtime_jail_duration: string;
|
||||
readonly slash_fraction_double_sign: string;
|
||||
readonly slash_fraction_downtime: string;
|
||||
};
|
||||
}
|
||||
export interface SlashingExtension {
|
||||
readonly slashing: {
|
||||
readonly signingInfos: () => Promise<SlashingSigningInfosResponse>;
|
||||
readonly parameters: () => Promise<SlashingParametersResponse>;
|
||||
};
|
||||
}
|
||||
export declare function setupSlashingExtension(base: LcdClient): SlashingExtension;
|
||||
export {};
|
||||
Loading…
Reference in New Issue
Block a user