Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions modules/bitgo/test/v2/unit/ams/ams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,23 @@ describe('Asset metadata service', () => {
}
staticsCoin.family.should.equal('hypeevm');
});

it('should register a SOL token from statics library if available', async () => {
const bitgo = TestBitGo.decorate(BitGo, { env: 'mock', microservicesUri, useAms: true } as BitGoOptions);
bitgo.initializeTestVars();
await bitgo.registerToken('tsol:usdc');
const coin = bitgo.coin('tsol:usdc');
should.exist(coin);
coin.type.should.equal('tsol:usdc');
coin.getBaseFactor().should.equal(1e9);
});
});

it('should create a custom coin factory from ams response and include SOL tokens from statics', async () => {
bitgo.initCoinFactory(reducedAmsTokenConfig);
const coin = bitgo.coin('tsol:usdc');
should.exist(coin);
coin.type.should.equal('tsol:usdc');
coin.getBaseFactor().should.equal(1e9);
});
});
5 changes: 5 additions & 0 deletions modules/sdk-coin-sol/src/solToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface SolTokenConfig {
network: string;
tokenAddress: string;
decimalPlaces: number;
programId?: string;
}

export class SolToken extends Sol {
Expand Down Expand Up @@ -59,6 +60,10 @@ export class SolToken extends Sol {
return this.tokenConfig.tokenAddress;
}

get programId() {
return this.tokenConfig.programId;
}

getChain() {
return this.tokenConfig.type;
}
Expand Down
2 changes: 2 additions & 0 deletions modules/statics/src/tokenConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type StellarTokenConfig = BaseNetworkConfig;
export type SolTokenConfig = BaseNetworkConfig & {
tokenAddress: string;
contractAddress: string;
programId?: string;
};

export type AdaTokenConfig = BaseNetworkConfig & {
Expand Down Expand Up @@ -832,6 +833,7 @@ function getSolTokenConfig(coin: SolCoin): SolTokenConfig {
tokenAddress: coin.tokenAddress,
decimalPlaces: coin.decimalPlaces,
contractAddress: coin.contractAddress,
programId: coin.programId,
};
}
const getFormattedSolTokens = (customCoinMap = coins) =>
Expand Down
Loading