Skip to content

Commit

Permalink
fix(io): update getTokenSupply to type that returns full breakdown …
Browse files Browse the repository at this point in the history
…of tokens

Note: this is a breaking change, but the API was known to be underdvelopment and not used by many clients, so we will keep it as a fix.
  • Loading branch information
dtfiedler authored and dtfiedler committed Oct 16, 2024
1 parent c404cb8 commit e790055
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
AoGatewayWithAddress,
AoJoinNetworkParams,
AoMessageResult,
AoTokenSupplyData,
AoUpdateGatewaySettingsParams,
AoWeightedObserver,
ContractSigner,
Expand Down Expand Up @@ -131,8 +132,8 @@ export class IOReadable implements AoIORead {
});
}

async getTokenSupply(): Promise<number> {
return this.process.read<number>({
async getTokenSupply(): Promise<AoTokenSupplyData> {
return this.process.read<AoTokenSupplyData>({
tags: [{ name: 'Action', value: 'Total-Token-Supply' }],
});
}
Expand Down
12 changes: 11 additions & 1 deletion src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -323,7 +333,7 @@ export interface AoIORead {
Handlers: string[];
LastTickedEpochIndex: number;
}>;
getTokenSupply(): Promise<number>;
getTokenSupply(): Promise<AoTokenSupplyData>;
getEpochSettings(params?: EpochInput): Promise<AoEpochSettings>;
getGateway({
address,
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/esm/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit e790055

Please sign in to comment.