Skip to content

Commit

Permalink
add chain specific inflation calc
Browse files Browse the repository at this point in the history
  • Loading branch information
ivivanov committed Jan 30, 2024
1 parent 026c2d2 commit 0c7f3be
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
27 changes: 27 additions & 0 deletions chains/mainnet/nolus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"chain_name": "nolus",
"coingecko": "nolus",
"api": [
{"provider": "Nolus", "address": "https://pirin-cl.nolus.network:1317"},
{"provider": "LavenderFive", "address": "https://nolus-api.lavenderfive.com:443"},
{"provider": "Allnodes", "address": "https://nolus-rest.publicnode.com"}
],
"rpc": [
{"provider": "Nolus", "address": "https://pirin-cl.nolus.network:26657"},
{"provider": "LavenderFive", "address": "https://nolus-rpc.lavenderfive.com:443"},
{"provider": "Allnodes", "address": "https://nolus-rpc.publicnode.com:443"}
],
"snapshot_provider": "",
"sdk_version": "v0.47.6",
"coin_type": "118",
"min_tx_fee": "0",
"addr_prefix": "nolus",
"logo": "/logos/nolus.svg",
"assets": [{
"base": "unls",
"symbol": "NLS",
"exponent": "6",
"coingecko_id": "nolus",
"logo": "/logos/nolus.svg"
}]
}
24 changes: 24 additions & 0 deletions src/libs/clients/nolus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { RequestRegistry } from '@/libs/registry'
import { CosmosRestClient } from '@/libs/client';
import { useBlockchain } from '@/stores';

// Blockchain Name
export const name = 'nolus';

// nolus custom request
export const requests: Partial<RequestRegistry> = {
mint_inflation: {
url: '/nolus/mint/v1beta1/annual_inflation',
adapter: async (data: any): Promise<any> => {
try {
const client = CosmosRestClient.newDefault(useBlockchain().endpoint.address)
const staking = await client.getStakingPool()
const inflation = Number(data.annual_inflation) / Number(staking.pool.bonded_tokens) || 0;
return { inflation: inflation.toString() };
} catch (error) {
console.log("Error in adapter:", error);
return { inflation: "0" };
}
}
},
};
4 changes: 2 additions & 2 deletions src/libs/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import type { PaginatedTxs, Tx, TxResponse } from '@/types';
import semver from 'semver'
export interface Request<T> {
url: string;
adapter: (source: any) => T;
adapter: (source: any) => Promise<T>;
}

export interface AbstractRegistry {
Expand Down Expand Up @@ -154,7 +154,7 @@ export interface RequestRegistry extends AbstractRegistry {
interchain_security_ccv_provider_validator_consumer_addr: Request<{consumer_address: string}>
}

export function adapter<T>(source: any): T {
export function adapter<T>(source: any): Promise<T> {
return source;
}

Expand Down

0 comments on commit 0c7f3be

Please sign in to comment.