Skip to content

Commit 6005a3e

Browse files
feat: support erc20 token registry using custom coin map
TICKET: WIN-8902 TICKET: WIN-8902
1 parent c3a2d01 commit 6005a3e

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

modules/sdk-coin-eth/src/register.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Gteth } from './gteth';
55
import { Hteth } from './hteth';
66
import { Teth } from './teth';
77
import { Erc721Token } from './erc721Token';
8+
import { type CoinMap, getFormattedErc20Tokens } from '@bitgo/statics';
89

910
export const register = (sdk: BitGoBase): void => {
1011
sdk.register('eth', Eth.createInstance);
@@ -18,3 +19,9 @@ export const register = (sdk: BitGoBase): void => {
1819
sdk.register(name, coinConstructor);
1920
});
2021
};
22+
23+
export const registerWithCoinMap = (sdk: BitGoBase, coinMap: CoinMap): void => {
24+
Erc20Token.createTokenConstructors(getFormattedErc20Tokens(coinMap)).forEach(({ name, coinConstructor }) => {
25+
sdk.register(name, coinConstructor);
26+
});
27+
};

modules/statics/src/tokenConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ function getErc20TokenConfig(coin: Erc20Coin): Erc20TokenConfig {
327327
}
328328

329329
// Get the list of ERC-20 tokens from statics and format it properly
330-
const getFormattedErc20Tokens = (customCoinMap = coins) =>
330+
export const getFormattedErc20Tokens = (customCoinMap = coins) =>
331331
customCoinMap.reduce((acc: Erc20TokenConfig[], coin) => {
332332
if (coin instanceof Erc20Coin) {
333333
acc.push(getErc20TokenConfig(coin));

0 commit comments

Comments
 (0)