UNPKG

@swaptoshi/governance-client

Version:

Client for interacting with blockchain networks that implements the Swaptoshi governance module

66 lines 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GovernanceEndpointClient = void 0; const client_1 = require("@klayr/client"); class GovernanceEndpointClient { constructor(url, mode) { this._url = url; this._mode = mode; } async getConfig() { const client = await this._getClient(); const result = await client.invoke('governance_getConfig', {}); return result; } async getRegisteredGovernableConfig() { const client = await this._getClient(); const result = await client.invoke('governance_getRegisteredGovernableConfig', {}); return result; } async getCastedVote(params) { const client = await this._getClient(); const result = await client.invoke('governance_getCastedVote', params); return result; } async getBaseVoteScore(params) { const client = await this._getClient(); const result = await client.invoke('governance_getBaseVoteScore', params); return result; } async getProposal(params) { const client = await this._getClient(); const result = await client.invoke('governance_getProposal', params); return result; } async getProposalQueue(params) { const client = await this._getClient(); const result = await client.invoke('governance_getProposalQueue', params); return result; } async getBoostedAccount(params) { const client = await this._getClient(); const result = await client.invoke('governance_getBoostedAccount', params); return result; } async getDelegatedVote(params) { const client = await this._getClient(); const result = await client.invoke('governance_getDelegatedVote', params); return result; } async getNextAvailableProposalId() { const client = await this._getClient(); const result = await client.invoke('governance_getNextAvailableProposalId', {}); return result; } async _getClient() { if (this._mode === 'ipc') { return client_1.apiClient.createIPCClient(this._url); } if (this._mode === 'ws') { return client_1.apiClient.createWSClient(this._url); } throw new Error('unknown mode'); } } exports.GovernanceEndpointClient = GovernanceEndpointClient; //# sourceMappingURL=endpoint.js.map