Skip to content

Commit 168e035

Browse files
Merge pull request #8096 from BitGo/manas/WIN-8902-update-erc-20-registry
feat: support erc20 token registry using custom coin map
2 parents da34b81 + 6005a3e commit 168e035

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)