diff --git a/src/common/io.ts b/src/common/io.ts index 628fb558..016b94fc 100644 --- a/src/common/io.ts +++ b/src/common/io.ts @@ -38,6 +38,7 @@ import { AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, + AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, @@ -131,8 +132,8 @@ export class IOReadable implements AoIORead { }); } - async getTokenSupply(): Promise { - return this.process.read({ + async getTokenSupply(): Promise { + return this.process.read({ tags: [{ name: 'Action', value: 'Total-Token-Supply' }], }); } diff --git a/src/io.ts b/src/io.ts index 7d0daf73..4f87e24f 100644 --- a/src/io.ts +++ b/src/io.ts @@ -166,6 +166,16 @@ export type AoEpochData = { distributions: AoEpochDistributionData; }; +export type AoTokenSupplyData = { + total: number; + circulating: number; + locked: number; + withdrawn: number; + delegated: number; + staked: number; + protocolBalance: number; +}; + export type AoGatewayService = { fqdn: string; path: string; @@ -323,7 +333,7 @@ export interface AoIORead { Handlers: string[]; LastTickedEpochIndex: number; }>; - getTokenSupply(): Promise; + getTokenSupply(): Promise; getEpochSettings(params?: EpochInput): Promise; getGateway({ address, diff --git a/tests/e2e/esm/index.test.js b/tests/e2e/esm/index.test.js index 22a56585..24bbdc3d 100644 --- a/tests/e2e/esm/index.test.js +++ b/tests/e2e/esm/index.test.js @@ -71,6 +71,13 @@ describe('IO', async () => { it('should be able to get the total token supply', async () => { const tokenSupply = await io.getTokenSupply(); assert.ok(tokenSupply); + assert(typeof tokenSupply.total === 'number'); + assert(typeof tokenSupply.circulating === 'number'); + assert(typeof tokenSupply.locked === 'number'); + assert(typeof tokenSupply.withdrawn === 'number'); + assert(typeof tokenSupply.delegated === 'number'); + assert(typeof tokenSupply.staked === 'number'); + assert(typeof tokenSupply.protocolBalance === 'number'); }); it('should be able to get first set of arns records', async () => {