bostrom-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/clients/graphql.d.ts +1 -0
- package/dist/clients/graphql.js +17 -0
- package/dist/clients/graphql.js.map +1 -0
- package/dist/clients/ipfs.d.ts +1 -0
- package/dist/clients/ipfs.js +15 -0
- package/dist/clients/ipfs.js.map +1 -0
- package/dist/clients/lcd.d.ts +2 -0
- package/dist/clients/lcd.js +14 -0
- package/dist/clients/lcd.js.map +1 -0
- package/dist/clients/rpc.d.ts +1 -0
- package/dist/clients/rpc.js +10 -0
- package/dist/clients/rpc.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/services/economy.d.ts +41 -0
- package/dist/services/economy.js +64 -0
- package/dist/services/economy.js.map +1 -0
- package/dist/services/governance.d.ts +24 -0
- package/dist/services/governance.js +50 -0
- package/dist/services/governance.js.map +1 -0
- package/dist/services/graph.d.ts +30 -0
- package/dist/services/graph.js +62 -0
- package/dist/services/graph.js.map +1 -0
- package/dist/services/infra.d.ts +34 -0
- package/dist/services/infra.js +45 -0
- package/dist/services/infra.js.map +1 -0
- package/dist/services/lithium.d.ts +55 -0
- package/dist/services/lithium.js +146 -0
- package/dist/services/lithium.js.map +1 -0
- package/dist/tools/economy.d.ts +2 -0
- package/dist/tools/economy.js +39 -0
- package/dist/tools/economy.js.map +1 -0
- package/dist/tools/governance.d.ts +2 -0
- package/dist/tools/governance.js +58 -0
- package/dist/tools/governance.js.map +1 -0
- package/dist/tools/graph.d.ts +2 -0
- package/dist/tools/graph.js +58 -0
- package/dist/tools/graph.js.map +1 -0
- package/dist/tools/infra.d.ts +2 -0
- package/dist/tools/infra.js +38 -0
- package/dist/tools/infra.js.map +1 -0
- package/dist/tools/lithium.d.ts +2 -0
- package/dist/tools/lithium.js +208 -0
- package/dist/tools/lithium.js.map +1 -0
- package/dist/util.d.ts +31 -0
- package/dist/util.js +72 -0
- package/dist/util.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cyberia-to
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function graphql<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const GRAPHQL_URL = "https://index.bostrom.cybernode.ai/v1/graphql";
|
|
2
|
+
export async function graphql(query, variables) {
|
|
3
|
+
const res = await fetch(GRAPHQL_URL, {
|
|
4
|
+
method: "POST",
|
|
5
|
+
headers: { "Content-Type": "application/json" },
|
|
6
|
+
body: JSON.stringify({ query, variables }),
|
|
7
|
+
});
|
|
8
|
+
if (!res.ok) {
|
|
9
|
+
throw new Error(`GraphQL ${res.status}: ${res.statusText}`);
|
|
10
|
+
}
|
|
11
|
+
const json = (await res.json());
|
|
12
|
+
if (json.errors?.length) {
|
|
13
|
+
throw new Error(`GraphQL error: ${json.errors[0].message}`);
|
|
14
|
+
}
|
|
15
|
+
return json.data;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/clients/graphql.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,+CAA+C,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,KAAa,EACb,SAAmC;IAEnC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;KAC3C,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAsD,CAAC;IACrF,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,IAAI,CAAC,IAAS,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ipfsGet(cid: string): Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const IPFS_GATEWAY = "https://gateway.ipfs.cybernode.ai";
|
|
2
|
+
export async function ipfsGet(cid) {
|
|
3
|
+
const res = await fetch(`${IPFS_GATEWAY}/ipfs/${cid}`, {
|
|
4
|
+
signal: AbortSignal.timeout(10_000),
|
|
5
|
+
});
|
|
6
|
+
if (!res.ok) {
|
|
7
|
+
throw new Error(`IPFS ${res.status}: ${res.statusText} — CID: ${cid}`);
|
|
8
|
+
}
|
|
9
|
+
const text = await res.text();
|
|
10
|
+
if (text.length > 50_000) {
|
|
11
|
+
return text.slice(0, 50_000) + "\n... (truncated)";
|
|
12
|
+
}
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ipfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs.js","sourceRoot":"","sources":["../../src/clients/ipfs.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,YAAY,SAAS,GAAG,EAAE,EAAE;QACrD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;KACpC,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,WAAW,GAAG,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,mBAAmB,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const LCD_BASE = "https://lcd.bostrom.cybernode.ai";
|
|
2
|
+
export async function lcdGet(path) {
|
|
3
|
+
const url = `${LCD_BASE}${path}`;
|
|
4
|
+
const res = await fetch(url);
|
|
5
|
+
if (!res.ok) {
|
|
6
|
+
throw new Error(`LCD ${res.status}: ${res.statusText} — ${url}`);
|
|
7
|
+
}
|
|
8
|
+
return res.json();
|
|
9
|
+
}
|
|
10
|
+
export async function lcdSmartQuery(contract, query) {
|
|
11
|
+
const encoded = Buffer.from(JSON.stringify(query)).toString("base64");
|
|
12
|
+
return lcdGet(`/cosmwasm/wasm/v1/contract/${contract}/smart/${encoded}`).then((r) => r.data);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=lcd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcd.js","sourceRoot":"","sources":["../../src/clients/lcd.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,kCAAkC,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAc,IAAY;IACpD,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,MAAM,GAAG,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;AAClC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,KAA8B;IAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACtE,OAAO,MAAM,CACX,8BAA8B,QAAQ,UAAU,OAAO,EAAE,CAC1D,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function rpcGet<T = unknown>(path: string): Promise<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const RPC_BASE = "https://rpc.bostrom.cybernode.ai";
|
|
2
|
+
export async function rpcGet(path) {
|
|
3
|
+
const res = await fetch(`${RPC_BASE}${path}`);
|
|
4
|
+
if (!res.ok) {
|
|
5
|
+
throw new Error(`RPC ${res.status}: ${res.statusText}`);
|
|
6
|
+
}
|
|
7
|
+
const json = (await res.json());
|
|
8
|
+
return json.result;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/clients/rpc.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,kCAAkC,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAc,IAAY;IACpD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAmB,CAAC;IAClD,OAAO,IAAI,CAAC,MAAW,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { registerGraphTools } from "./tools/graph.js";
|
|
5
|
+
import { registerEconomyTools } from "./tools/economy.js";
|
|
6
|
+
import { registerLithiumTools } from "./tools/lithium.js";
|
|
7
|
+
import { registerGovernanceTools } from "./tools/governance.js";
|
|
8
|
+
import { registerInfraTools } from "./tools/infra.js";
|
|
9
|
+
const server = new McpServer({
|
|
10
|
+
name: "bostrom",
|
|
11
|
+
version: "0.1.0",
|
|
12
|
+
});
|
|
13
|
+
registerGraphTools(server);
|
|
14
|
+
registerEconomyTools(server);
|
|
15
|
+
registerLithiumTools(server);
|
|
16
|
+
registerGovernanceTools(server);
|
|
17
|
+
registerInfraTools(server);
|
|
18
|
+
async function main() {
|
|
19
|
+
const transport = new StdioServerTransport();
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
}
|
|
22
|
+
main().catch((err) => {
|
|
23
|
+
console.error("Fatal:", err);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC3B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAChC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAE3B,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare function getBalances(address: string): Promise<{
|
|
2
|
+
denom: string;
|
|
3
|
+
amount: string;
|
|
4
|
+
}[]>;
|
|
5
|
+
export declare function getSupply(denom: string): Promise<{
|
|
6
|
+
denom: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function getMintPrice(): Promise<unknown>;
|
|
10
|
+
export declare function getStaking(address: string): Promise<{
|
|
11
|
+
delegations: {
|
|
12
|
+
validator: string;
|
|
13
|
+
amount: {
|
|
14
|
+
denom: string;
|
|
15
|
+
amount: string;
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
total_rewards: never[] | {
|
|
19
|
+
denom: string;
|
|
20
|
+
amount: string;
|
|
21
|
+
}[];
|
|
22
|
+
rewards_by_validator: {
|
|
23
|
+
validator: string;
|
|
24
|
+
reward: {
|
|
25
|
+
denom: string;
|
|
26
|
+
amount: string;
|
|
27
|
+
}[];
|
|
28
|
+
}[];
|
|
29
|
+
unbonding: never[] | {
|
|
30
|
+
validator_address: string;
|
|
31
|
+
entries: Array<{
|
|
32
|
+
balance: string;
|
|
33
|
+
completion_time: string;
|
|
34
|
+
}>;
|
|
35
|
+
}[];
|
|
36
|
+
}>;
|
|
37
|
+
export declare function getPools(): Promise<unknown>;
|
|
38
|
+
export declare function getInflation(): Promise<{
|
|
39
|
+
inflation: string;
|
|
40
|
+
params: unknown;
|
|
41
|
+
}>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { lcdGet } from "../clients/lcd.js";
|
|
2
|
+
export async function getBalances(address) {
|
|
3
|
+
const result = await lcdGet(`/cosmos/bank/v1beta1/balances/${address}`);
|
|
4
|
+
return result.balances;
|
|
5
|
+
}
|
|
6
|
+
export async function getSupply(denom) {
|
|
7
|
+
const result = await lcdGet(`/cosmos/bank/v1beta1/supply/by_denom?denom=${encodeURIComponent(denom)}`);
|
|
8
|
+
return result.amount;
|
|
9
|
+
}
|
|
10
|
+
export async function getMintPrice() {
|
|
11
|
+
try {
|
|
12
|
+
return await lcdGet("/cyber/resources/v1beta1/resources/params");
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
try {
|
|
16
|
+
return await lcdGet("/cyber/resources/v1beta1/params");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return { error: "Resources endpoint not available on this LCD node" };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function getStaking(address) {
|
|
24
|
+
const [delegations, rewards, unbonding] = await Promise.all([
|
|
25
|
+
lcdGet(`/cosmos/staking/v1beta1/delegations/${address}`).catch(() => ({
|
|
26
|
+
delegation_responses: [],
|
|
27
|
+
})),
|
|
28
|
+
lcdGet(`/cosmos/distribution/v1beta1/delegators/${address}/rewards`).catch(() => ({ total: [], rewards: [] })),
|
|
29
|
+
lcdGet(`/cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations`).catch(() => ({ unbonding_responses: [] })),
|
|
30
|
+
]);
|
|
31
|
+
return {
|
|
32
|
+
delegations: delegations.delegation_responses.map((d) => ({
|
|
33
|
+
validator: d.delegation.validator_address,
|
|
34
|
+
amount: d.balance,
|
|
35
|
+
})),
|
|
36
|
+
total_rewards: rewards.total,
|
|
37
|
+
rewards_by_validator: rewards.rewards?.map((r) => ({
|
|
38
|
+
validator: r.validator_address,
|
|
39
|
+
reward: r.reward,
|
|
40
|
+
})),
|
|
41
|
+
unbonding: unbonding.unbonding_responses,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export async function getPools() {
|
|
45
|
+
try {
|
|
46
|
+
return await lcdGet("/cosmos/liquidity/v1beta1/pools");
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
try {
|
|
50
|
+
return await lcdGet("/osmosis/gamm/v1beta1/pools");
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { error: "Liquidity pools endpoint not available" };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function getInflation() {
|
|
58
|
+
const [inflation, params] = await Promise.all([
|
|
59
|
+
lcdGet("/cosmos/mint/v1beta1/inflation").catch(() => ({ inflation: "unknown" })),
|
|
60
|
+
lcdGet("/cosmos/mint/v1beta1/params").catch(() => null),
|
|
61
|
+
]);
|
|
62
|
+
return { inflation: inflation.inflation, params };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=economy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"economy.js","sourceRoot":"","sources":["../../src/services/economy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAe;IAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAExB,iCAAiC,OAAO,EAAE,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,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AC,iBAAiB;YACzC,MAAM,EAAE,CAAC,CAAC,OAAO;SAClB,CAAC,CAAC;QACH,aAAa,EAAE,OAAO,CAAC,KAAK;QAC5B,oBAAoB,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACjD,SAAS,EAAE,CAAC,CAAC,iBAAiB;YAC9B,MAAM,EAAE,CAAC,CAAC,MAAM;SACjB,CAAC,CAAC;QACH,SAAS,EAAE,SAAS,CAAC,mBAAmB;KACzC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,KAAK,EAAE,wCAAwC,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5C,MAAM,CAAwB,gCAAgC,CAAC,CAAC,KAAK,CACnE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CACjC;QACD,MAAM,CAAC,6BAA6B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;KACxD,CAAC,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function getProposals(status: string, limit: number): Promise<{
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
status: string;
|
|
5
|
+
submit_time: string;
|
|
6
|
+
voting_end_time: string;
|
|
7
|
+
total_deposit: {
|
|
8
|
+
denom: string;
|
|
9
|
+
amount: string;
|
|
10
|
+
}[];
|
|
11
|
+
}[]>;
|
|
12
|
+
export declare function getProposalDetail(proposalId: string): Promise<{
|
|
13
|
+
proposal: unknown;
|
|
14
|
+
tally: unknown;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function getValidators(status: string, limit: number): Promise<{
|
|
17
|
+
operator_address: string;
|
|
18
|
+
moniker: string;
|
|
19
|
+
website: string;
|
|
20
|
+
commission_rate: string;
|
|
21
|
+
tokens: string;
|
|
22
|
+
jailed: boolean;
|
|
23
|
+
}[]>;
|
|
24
|
+
export declare function getParams(module: string): Promise<unknown>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { lcdGet } from "../clients/lcd.js";
|
|
2
|
+
export async function getProposals(status, limit) {
|
|
3
|
+
const params = new URLSearchParams({
|
|
4
|
+
"pagination.limit": String(limit),
|
|
5
|
+
"pagination.reverse": "true",
|
|
6
|
+
});
|
|
7
|
+
if (status !== "all") {
|
|
8
|
+
params.set("proposal_status", status);
|
|
9
|
+
}
|
|
10
|
+
const result = await lcdGet(`/cosmos/gov/v1/proposals?${params}`);
|
|
11
|
+
return (result.proposals ?? []).map((p) => ({
|
|
12
|
+
id: p.id,
|
|
13
|
+
title: p.title,
|
|
14
|
+
status: p.status,
|
|
15
|
+
submit_time: p.submit_time,
|
|
16
|
+
voting_end_time: p.voting_end_time,
|
|
17
|
+
total_deposit: p.total_deposit,
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
export async function getProposalDetail(proposalId) {
|
|
21
|
+
const [proposal, tally] = await Promise.all([
|
|
22
|
+
lcdGet(`/cosmos/gov/v1/proposals/${proposalId}`),
|
|
23
|
+
lcdGet(`/cosmos/gov/v1/proposals/${proposalId}/tally`).catch(() => ({ tally: null })),
|
|
24
|
+
]);
|
|
25
|
+
return { proposal: proposal.proposal, tally: tally.tally };
|
|
26
|
+
}
|
|
27
|
+
export async function getValidators(status, limit) {
|
|
28
|
+
const result = await lcdGet(`/cosmos/staking/v1beta1/validators?status=${status}&pagination.limit=${limit}`);
|
|
29
|
+
return (result.validators ?? [])
|
|
30
|
+
.map((v) => ({
|
|
31
|
+
operator_address: v.operator_address,
|
|
32
|
+
moniker: v.description.moniker,
|
|
33
|
+
website: v.description.website,
|
|
34
|
+
commission_rate: v.commission.commission_rates.rate,
|
|
35
|
+
tokens: v.tokens,
|
|
36
|
+
jailed: v.jailed,
|
|
37
|
+
}))
|
|
38
|
+
.sort((a, b) => Number(BigInt(b.tokens) - BigInt(a.tokens)));
|
|
39
|
+
}
|
|
40
|
+
export async function getParams(module) {
|
|
41
|
+
const paths = {
|
|
42
|
+
staking: "/cosmos/staking/v1beta1/params",
|
|
43
|
+
slashing: "/cosmos/slashing/v1beta1/params",
|
|
44
|
+
gov: "/cosmos/gov/v1/params/tallying",
|
|
45
|
+
distribution: "/cosmos/distribution/v1beta1/params",
|
|
46
|
+
mint: "/cosmos/mint/v1beta1/params",
|
|
47
|
+
};
|
|
48
|
+
return lcdGet(paths[module]);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/services/governance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,KAAa;IAC9D,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;QACjC,kBAAkB,EAAE,MAAM,CAAC,KAAK,CAAC;QACjC,oBAAoB,EAAE,MAAM;KAC7B,CAAC,CAAC;IACH,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CASx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QAC9B,eAAe,EAAE,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI;QACnD,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc;IAC5C,MAAM,KAAK,GAA2B;QACpC,OAAO,EAAE,gCAAgC;QACzC,QAAQ,EAAE,iCAAiC;QAC3C,GAAG,EAAE,gCAAgC;QACrC,YAAY,EAAE,qCAAqC;QACnD,IAAI,EAAE,6BAA6B;KACpC,CAAC;IACF,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface Cyberlink {
|
|
2
|
+
particle_from: string;
|
|
3
|
+
particle_to: string;
|
|
4
|
+
neuron: string;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
transaction_hash: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function searchCyberlinks(opts: {
|
|
9
|
+
particle?: string;
|
|
10
|
+
neuron?: string;
|
|
11
|
+
limit: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
total: number;
|
|
15
|
+
links: Cyberlink[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare function getRank(particle: string): Promise<{
|
|
18
|
+
particle: string;
|
|
19
|
+
rank: string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function getNeuron(address: string): Promise<{
|
|
22
|
+
address: string;
|
|
23
|
+
cyberlinks_created: number;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function getParticle(cid: string): Promise<string>;
|
|
26
|
+
export declare function getRecentLinks(limit: number): Promise<Cyberlink[]>;
|
|
27
|
+
export declare function getGraphStats(): Promise<{
|
|
28
|
+
total_cyberlinks: number;
|
|
29
|
+
active_neurons: number;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { graphql } from "../clients/graphql.js";
|
|
2
|
+
import { lcdGet } from "../clients/lcd.js";
|
|
3
|
+
import { ipfsGet } from "../clients/ipfs.js";
|
|
4
|
+
export async function searchCyberlinks(opts) {
|
|
5
|
+
const conditions = [];
|
|
6
|
+
if (opts.particle) {
|
|
7
|
+
conditions.push(`_or: [{particle_from: {_eq: "${opts.particle}"}}, {particle_to: {_eq: "${opts.particle}"}}]`);
|
|
8
|
+
}
|
|
9
|
+
if (opts.neuron) {
|
|
10
|
+
conditions.push(`neuron: {_eq: "${opts.neuron}"}`);
|
|
11
|
+
}
|
|
12
|
+
if (conditions.length === 0)
|
|
13
|
+
throw new Error("Provide at least particle or neuron");
|
|
14
|
+
const where = `{${conditions.join(", ")}}`;
|
|
15
|
+
const result = await graphql(`{
|
|
16
|
+
cyberlinks(where: ${where}, limit: ${opts.limit}, offset: ${opts.offset}, order_by: {timestamp: desc}) {
|
|
17
|
+
particle_from particle_to neuron timestamp transaction_hash
|
|
18
|
+
}
|
|
19
|
+
cyberlinks_aggregate(where: ${where}) { aggregate { count } }
|
|
20
|
+
}`);
|
|
21
|
+
return {
|
|
22
|
+
total: result.cyberlinks_aggregate.aggregate.count,
|
|
23
|
+
links: result.cyberlinks,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export async function getRank(particle) {
|
|
27
|
+
const result = await lcdGet(`/cyber/rank/v1beta1/rank/rank/${particle}`);
|
|
28
|
+
return { particle, rank: result.rank };
|
|
29
|
+
}
|
|
30
|
+
export async function getNeuron(address) {
|
|
31
|
+
const result = await graphql(`{
|
|
32
|
+
cyberlinks_aggregate(where: {neuron: {_eq: "${address}"}}) {
|
|
33
|
+
aggregate { count }
|
|
34
|
+
}
|
|
35
|
+
}`);
|
|
36
|
+
return {
|
|
37
|
+
address,
|
|
38
|
+
cyberlinks_created: result.cyberlinks_aggregate.aggregate.count,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function getParticle(cid) {
|
|
42
|
+
return ipfsGet(cid);
|
|
43
|
+
}
|
|
44
|
+
export async function getRecentLinks(limit) {
|
|
45
|
+
const result = await graphql(`{
|
|
46
|
+
cyberlinks(limit: ${limit}, order_by: {timestamp: desc}) {
|
|
47
|
+
particle_from particle_to neuron timestamp transaction_hash
|
|
48
|
+
}
|
|
49
|
+
}`);
|
|
50
|
+
return result.cyberlinks;
|
|
51
|
+
}
|
|
52
|
+
export async function getGraphStats() {
|
|
53
|
+
const result = await graphql(`{
|
|
54
|
+
cyberlinks_aggregate { aggregate { count } }
|
|
55
|
+
neurons: cyberlinks_aggregate(distinct_on: neuron) { aggregate { count } }
|
|
56
|
+
}`);
|
|
57
|
+
return {
|
|
58
|
+
total_cyberlinks: result.cyberlinks_aggregate.aggregate.count,
|
|
59
|
+
active_neurons: result.neurons.aggregate.count,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAU7C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAKtC;IACC,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClB,UAAU,CAAC,IAAI,CACb,gCAAgC,IAAI,CAAC,QAAQ,6BAA6B,IAAI,CAAC,QAAQ,MAAM,CAC9F,CA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BACpC,KAAK;;;IAGzB,CAAC,CAAC;IACJ,OAAO,MAAM,CAAC,UAAU,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,MAAM,GAAG,MAAM,OAAO,CAGzB;;;IAGD,CAAC,CAAC;IACJ,OAAO;QACL,gBAAgB,EAAE,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK;QAC7D,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare function getChainStatus(): Promise<{
|
|
2
|
+
chain_id: string;
|
|
3
|
+
node_version: string;
|
|
4
|
+
latest_block_height: string;
|
|
5
|
+
latest_block_time: string;
|
|
6
|
+
catching_up: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function searchTxs(opts: {
|
|
9
|
+
sender?: string;
|
|
10
|
+
contract?: string;
|
|
11
|
+
messageType?: string;
|
|
12
|
+
limit: number;
|
|
13
|
+
offset: number;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
total: string;
|
|
16
|
+
txs: {
|
|
17
|
+
txhash: string;
|
|
18
|
+
height: string;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
success: boolean;
|
|
21
|
+
raw_log: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
export declare function getTxDetail(txhash: string): Promise<{
|
|
25
|
+
txhash: string;
|
|
26
|
+
height: string;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
code: number;
|
|
29
|
+
gas_wanted: string;
|
|
30
|
+
gas_used: string;
|
|
31
|
+
raw_log: string;
|
|
32
|
+
logs: unknown[];
|
|
33
|
+
tx: unknown;
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { rpcGet } from "../clients/rpc.js";
|
|
2
|
+
import { lcdGet } from "../clients/lcd.js";
|
|
3
|
+
export async function getChainStatus() {
|
|
4
|
+
const status = await rpcGet("/status");
|
|
5
|
+
return {
|
|
6
|
+
chain_id: status.node_info.network,
|
|
7
|
+
node_version: status.node_info.version,
|
|
8
|
+
latest_block_height: status.sync_info.latest_block_height,
|
|
9
|
+
latest_block_time: status.sync_info.latest_block_time,
|
|
10
|
+
catching_up: status.sync_info.catching_up,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export async function searchTxs(opts) {
|
|
14
|
+
const events = [];
|
|
15
|
+
if (opts.sender)
|
|
16
|
+
events.push(`message.sender='${opts.sender}'`);
|
|
17
|
+
if (opts.contract)
|
|
18
|
+
events.push(`execute._contract_address='${opts.contract}'`);
|
|
19
|
+
if (opts.messageType)
|
|
20
|
+
events.push(`message.action='${opts.messageType}'`);
|
|
21
|
+
if (events.length === 0) {
|
|
22
|
+
throw new Error("Provide at least one filter: sender, contract, or message_type");
|
|
23
|
+
}
|
|
24
|
+
const query = events.join(" AND ");
|
|
25
|
+
const params = new URLSearchParams({
|
|
26
|
+
events: query,
|
|
27
|
+
"pagination.limit": String(opts.limit),
|
|
28
|
+
"pagination.offset": String(opts.offset),
|
|
29
|
+
order_by: "ORDER_BY_DESC",
|
|
30
|
+
});
|
|
31
|
+
const result = await lcdGet(`/cosmos/tx/v1beta1/txs?${params}`);
|
|
32
|
+
const txs = (result.tx_responses ?? []).map((tx) => ({
|
|
33
|
+
txhash: tx.txhash,
|
|
34
|
+
height: tx.height,
|
|
35
|
+
timestamp: tx.timestamp,
|
|
36
|
+
success: tx.code === 0,
|
|
37
|
+
raw_log: tx.raw_log?.slice(0, 200),
|
|
38
|
+
}));
|
|
39
|
+
return { total: result.pagination?.total ?? "0", txs };
|
|
40
|
+
}
|
|
41
|
+
export async function getTxDetail(txhash) {
|
|
42
|
+
const result = await lcdGet(`/cosmos/tx/v1beta1/txs/${txhash}`);
|
|
43
|
+
return result.tx_response;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=infra.js.map
|
|
@@ -0,0 +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B,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACtC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,QAAQ,EAAE,eAAe;KAC1B,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,MAAM,CASxB,0BAA0B,MAAM,EAAE,CAAC,CAAC;IAEvC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACnD,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,SAAS,EAAE,EAAE,CAAC,SAAS;QACvB,OAAO,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC;QACtB,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;KACnC,CAAC,CAAC,CAAC;IAEJ,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAc;IAC9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAYxB,0BAA0B,MAAM,EAAE,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const LITIUM_CORE = "bostrom1wsgx32y0tx5rk6g89ffr8hg2wucnpwp650e9nrdm80jeyku5u4zq5ashgz";
|
|
2
|
+
export declare const LITIUM_MINE = "bostrom1vsfzcplds5z9xxl0llczeskxjxuddckksjm2u5ft2xt03qg28ups04mfes";
|
|
3
|
+
export declare const LITIUM_STAKE = "bostrom1z0s6rxw8eq4wy25kaucy5jydlphlpzpglsle5n7nx2gaqd60rmgqs67tnz";
|
|
4
|
+
export declare const LITIUM_REFER = "bostrom1m8a0jzyyu794cmd5clkt37kr0kkqvxyra23gnqcg5929n63ryhpss3986d";
|
|
5
|
+
export declare function getCoreConfig(contract: string): Promise<unknown>;
|
|
6
|
+
export declare function getBurnStats(contract: string): Promise<unknown>;
|
|
7
|
+
export declare function getTotalMinted(contract: string): Promise<unknown>;
|
|
8
|
+
export declare function isAuthorizedCaller(contract: string, address: string): Promise<unknown>;
|
|
9
|
+
export declare function getMineConfig(contract: string): Promise<unknown>;
|
|
10
|
+
export declare function getSeed(contract: string): Promise<unknown>;
|
|
11
|
+
export declare function getDifficulty(contract: string): Promise<unknown>;
|
|
12
|
+
export declare function getEpochStatus(contract: string): Promise<unknown>;
|
|
13
|
+
export declare function getTarget(contract: string): Promise<unknown>;
|
|
14
|
+
export declare function getProofStats(contract: string): Promise<unknown>;
|
|
15
|
+
export declare function getLithiumEmissionInfo(contract: string): Promise<unknown>;
|
|
16
|
+
export declare function getLithiumMinerEpochStats(contract: string, address: string, epochId: number): Promise<unknown>;
|
|
17
|
+
export declare function getMineStats(contract: string): Promise<unknown>;
|
|
18
|
+
export declare function getMinerStats(contract: string, address: string): Promise<unknown>;
|
|
19
|
+
export declare function verifyProof(contract: string, hash: string, nonce: number, timestamp: number, miner: string): Promise<unknown>;
|
|
20
|
+
export declare function calculateReward(contract: string, difficultyBits: number): Promise<unknown>;
|
|
21
|
+
/** Composite: full mine contract state */
|
|
22
|
+
export declare function getMineState(contract: string): Promise<{
|
|
23
|
+
config: unknown;
|
|
24
|
+
seed: unknown;
|
|
25
|
+
difficulty: unknown;
|
|
26
|
+
stats: unknown;
|
|
27
|
+
epoch_status: unknown;
|
|
28
|
+
proof_stats: unknown;
|
|
29
|
+
emission: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function getStakeConfig(contract: string): Promise<unknown>;
|
|
32
|
+
export declare function getTotalStaked(contract: string): Promise<unknown>;
|
|
33
|
+
export declare function getStakeInfo(contract: string, address: string): Promise<unknown>;
|
|
34
|
+
export declare function getStakingStats(contract: string): Promise<unknown>;
|
|
35
|
+
export declare function getReferConfig(contract: string): Promise<unknown>;
|
|
36
|
+
export declare function getReferrerOf(contract: string, miner: string): Promise<unknown>;
|
|
37
|
+
export declare function getReferralInfo(contract: string, address: string): Promise<unknown>;
|
|
38
|
+
export declare function getCommunityPoolBalance(contract: string): Promise<unknown>;
|
|
39
|
+
interface TxMessage {
|
|
40
|
+
transaction_hash: string;
|
|
41
|
+
value: unknown;
|
|
42
|
+
transaction: {
|
|
43
|
+
block: {
|
|
44
|
+
height: number;
|
|
45
|
+
timestamp: string;
|
|
46
|
+
};
|
|
47
|
+
success: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function getRecentProofs(contract: string, limit: number): Promise<TxMessage[]>;
|
|
51
|
+
export declare function getMinerTxHistory(address: string, limit: number): Promise<{
|
|
52
|
+
total_txs: number;
|
|
53
|
+
recent_txs: TxMessage[];
|
|
54
|
+
}>;
|
|
55
|
+
export {};
|