Skip to content
Merged
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
2 changes: 1 addition & 1 deletion modules/sdk-coin-eth/src/erc20Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Erc20Token extends Eth {
};

constructor(bitgo: BitGoBase, tokenConfig: Erc20TokenConfig) {
const staticsCoin = coins.get(Erc20Token.coinNames[tokenConfig.network]);
const staticsCoin = coins.get(tokenConfig.coin);
super(bitgo, staticsCoin);
this.tokenConfig = tokenConfig;
this.sendMethodName = 'sendMultiSigToken';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-eth/src/erc7984Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Erc7984Token extends Eth {
};

constructor(bitgo: BitGoBase, tokenConfig: Erc7984TokenConfig) {
const staticsCoin = coins.get(Erc7984Token.coinNames[tokenConfig.network]);
const staticsCoin = coins.get(tokenConfig.coin);
super(bitgo, staticsCoin);
this.tokenConfig = tokenConfig;
// ERC7984 confidential transfers use sendMultiSig (not sendMultiSigToken) because
Expand Down
3 changes: 3 additions & 0 deletions modules/sdk-coin-eth/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Erc7984Token } from './erc7984Token';
import { Eth } from './eth';
import { Gteth } from './gteth';
import { Hteth } from './hteth';
import { Sepeth } from './sepeth';
import { Teth } from './teth';
import { type CoinMap, getFormattedErc20Tokens, getFormattedErc7984Tokens } from '@bitgo/statics';

Expand All @@ -13,6 +14,7 @@ export const register = (sdk: BitGoBase): void => {
sdk.register('gteth', Gteth.createInstance);
sdk.register('teth', Teth.createInstance);
sdk.register('hteth', Hteth.createInstance);
sdk.register('sepeth', Sepeth.createInstance);
Erc20Token.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
Expand All @@ -29,6 +31,7 @@ export const registerWithCoinMap = (sdk: BitGoBase, coinMap: CoinMap): void => {
sdk.register('gteth', Gteth.createInstance);
sdk.register('teth', Teth.createInstance);
sdk.register('hteth', Hteth.createInstance);
sdk.register('sepeth', Sepeth.createInstance);
Erc721Token.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
Expand Down
13 changes: 13 additions & 0 deletions modules/sdk-coin-eth/src/sepeth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import { Eth } from './eth';

export class Sepeth extends Eth {
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo, staticsCoin);
}

static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new Sepeth(bitgo, staticsCoin);
}
}
4 changes: 3 additions & 1 deletion modules/sdk-coin-eth/test/unit/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ describe('ETH Register', function () {
assert.ok(registeredNames.includes('gteth'));
assert.ok(registeredNames.includes('teth'));
assert.ok(registeredNames.includes('hteth'));
assert.ok(registeredNames.includes('sepeth'));

// ERC20, ERC721 and ERC7984 tokens should be registered
const erc20Count = Erc20Token.createTokenConstructors().length;
const erc721Count = Erc721Token.createTokenConstructors().length;
const erc7984Count = Erc7984Token.createTokenConstructors().length;
assert.strictEqual(registerSpy.callCount, 4 + erc20Count + erc721Count + erc7984Count);
assert.strictEqual(registerSpy.callCount, 5 + erc20Count + erc721Count + erc7984Count);
});
});

Expand All @@ -55,6 +56,7 @@ describe('ETH Register', function () {
assert.ok(registeredNames.includes('gteth'));
assert.ok(registeredNames.includes('teth'));
assert.ok(registeredNames.includes('hteth'));
assert.ok(registeredNames.includes('sepeth'));
});

it('should add dynamic ERC20 tokens to the global coin map', function () {
Expand Down
6 changes: 6 additions & 0 deletions modules/statics/src/tokenConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ function getErc20TokenConfig(coin: Erc20Coin): Erc20TokenConfig {
case Networks.test.hoodi.name:
baseCoin = 'hteth';
break;
case Networks.test.sepolia.name:
baseCoin = 'sepeth';
break;
default:
throw new Error(`Erc20 token ${coin.name} has an unsupported network`);
}
Expand Down Expand Up @@ -370,6 +373,9 @@ function getErc7984TokenConfig(coin: Erc7984Coin): Erc7984TokenConfig {
case Networks.test.hoodi.name:
baseCoin = 'hteth';
break;
case Networks.test.sepolia.name:
baseCoin = 'sepeth';
break;
default:
throw new Error(`ERC-7984 token ${coin.name} has an unsupported network`);
}
Expand Down
Loading