Skip to content

Commit

Permalink
chore(sdk-coin-bsc): rename bsc to bnb
Browse files Browse the repository at this point in the history
Ticket: EA-709
  • Loading branch information
kxl4126 committed Jun 29, 2023
1 parent c488f0e commit 7ec3389
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 210 deletions.
8 changes: 4 additions & 4 deletions modules/account-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export { Dot };
import * as Near from '@bitgo/sdk-coin-near';
export { Near };

import * as Bsc from '@bitgo/sdk-coin-bsc';
export { Bsc };
import * as Bnb from '@bitgo/sdk-coin-bsc';
export { Bnb };

import * as Polygon from '@bitgo/sdk-coin-polygon';
export { Polygon };
Expand All @@ -120,8 +120,8 @@ const coinBuilderMap = {
tcelo: Celo.TransactionBuilder,
avaxc: AvaxC.TransactionBuilder,
tavaxc: AvaxC.TransactionBuilder,
bsc: Bsc.TransactionBuilder,
tbsc: Bsc.TransactionBuilder,
bnb: Bnb.TransactionBuilder,
tbnb: Bnb.TransactionBuilder,
avaxp: AvaxP.TransactionBuilderFactory,
tavaxp: AvaxP.TransactionBuilderFactory,
hbar: Hbar.TransactionBuilderFactory,
Expand Down
12 changes: 6 additions & 6 deletions modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
AvaxP,
Bch,
Bld,
Bsc,
BscToken,
Bnb,
BnbToken,
Bsv,
Btc,
Btg,
Expand Down Expand Up @@ -64,7 +64,7 @@ import {
TavaxP,
Tbch,
Tbld,
Tbsc,
Tbnb,
Tbsv,
Tbtc,
Tcelo,
Expand Down Expand Up @@ -114,7 +114,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('bch', Bch.createInstance);
globalCoinFactory.register('bcha', Bcha.createInstance);
globalCoinFactory.register('bld', Bld.createInstance);
globalCoinFactory.register('bsc', Bsc.createInstance);
globalCoinFactory.register('bnb', Bnb.createInstance);
globalCoinFactory.register('bsv', Bsv.createInstance);
globalCoinFactory.register('btc', Btc.createInstance);
globalCoinFactory.register('btg', Btg.createInstance);
Expand Down Expand Up @@ -155,7 +155,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('tbch', Tbch.createInstance);
globalCoinFactory.register('tbcha', Tbcha.createInstance);
globalCoinFactory.register('tbld', Tbld.createInstance);
globalCoinFactory.register('tbsc', Tbsc.createInstance);
globalCoinFactory.register('tbnb', Tbnb.createInstance);
globalCoinFactory.register('tbsv', Tbsv.createInstance);
globalCoinFactory.register('tbtc', Tbtc.createInstance);
globalCoinFactory.register('tcelo', Tcelo.createInstance);
Expand Down Expand Up @@ -212,7 +212,7 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register(name, coinConstructor);
});

BscToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
BnbToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
globalCoinFactory.register(name, coinConstructor);
});

Expand Down
4 changes: 2 additions & 2 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AvaxP, TavaxP } from '@bitgo/sdk-coin-avaxp';
import { Bch, Tbch } from '@bitgo/sdk-coin-bch';
import { Bcha, Tbcha } from '@bitgo/sdk-coin-bcha';
import { Bld, Tbld } from '@bitgo/sdk-coin-bld';
import { Bsc, BscToken, Tbsc } from '@bitgo/sdk-coin-bsc';
import { Bnb, BnbToken, Tbnb } from '@bitgo/sdk-coin-bsc';
import { Bsv, Tbsv } from '@bitgo/sdk-coin-bsv';
import { Btc, Tbtc } from '@bitgo/sdk-coin-btc';
import { Btg } from '@bitgo/sdk-coin-btg';
Expand Down Expand Up @@ -45,7 +45,7 @@ export { Atom, Tatom };
export { AvaxC, AvaxCToken, TavaxC };
export { AvaxP, TavaxP };
export { Bch, Tbch };
export { Bsc, BscToken, Tbsc };
export { Bnb, BnbToken, Tbnb };
export { Bsv, Tbsv };
export { Btc, Tbtc };
export { Btg };
Expand Down
2 changes: 1 addition & 1 deletion modules/bitgo/test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Coins', () => {
AlgoToken: 1,
AvaxCToken: 1,
PolygonToken: 1,
BscToken: 1,
BnbToken: 1,
};
Object.keys(BitGoJS.Coin)
.filter((coinName) => !excludedKeys[coinName])
Expand Down
2 changes: 1 addition & 1 deletion modules/bitgo/test/v2/unit/keychains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ describe('V2 Keychains', function () {
});
});

['tbsc'].forEach((coin) => {
['tbnb'].forEach((coin) => {
it('should create ECDSA TSS Keychains', async function () {
sandbox.stub(ECDSAUtils.EcdsaUtils.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);
const keychains = await bitgo.coin(coin).keychains().createMpc({
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-bsc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Next, you will be able to initialize an instance of "bitgo" through `@bitgo/sdk-

```javascript
import { BitGoAPI } from '@bitgo/sdk-api';
import { Bsc } from '@bitgo/sdk-coin-bsc';
import { Bnb } from '@bitgo/sdk-coin-bsc';

const sdk = new BitGoAPI();

sdk.register('bsc', Bsc.createInstance);
sdk.register('bsc', Bnb.createInstance);
```

## Development
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { AbstractEthLikeCoin } from '@bitgo/abstract-eth';
import { TransactionBuilder as EthTransactionBuilder } from '@bitgo/sdk-coin-eth';
import { TransactionBuilder } from './lib';

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

static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new Bsc(bitgo, staticsCoin);
return new Bnb(bitgo, staticsCoin);
}

protected getTransactionBuilder(): EthTransactionBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ import { CoinNames, EthLikeToken } from '@bitgo/abstract-eth';

export { EthLikeTokenConfig };

export class BscToken extends EthLikeToken {
export class BnbToken extends EthLikeToken {
public readonly tokenConfig: EthLikeTokenConfig;
static coinNames: CoinNames = {
Mainnet: 'bsc',
Testnet: 'tbsc',
Mainnet: 'bnb',
Testnet: 'tbnb',
};
constructor(bitgo: BitGoBase, tokenConfig: EthLikeTokenConfig) {
super(bitgo, tokenConfig, BscToken.coinNames);
super(bitgo, tokenConfig, BnbToken.coinNames);
}
static createTokenConstructor(config: EthLikeTokenConfig): CoinConstructor {
return super.createTokenConstructor(config, BscToken.coinNames);
return super.createTokenConstructor(config, BnbToken.coinNames);
}

static createTokenConstructors(): NamedCoinConstructor[] {
return super.createTokenConstructors(BscToken.coinNames);
return super.createTokenConstructors(BnbToken.coinNames);
}

getFullName(): string {
return 'Bsc Token';
return 'Bnb Token';
}

supportsTss(): boolean {
Expand Down
6 changes: 3 additions & 3 deletions modules/sdk-coin-bsc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './lib';
export * from './bsc';
export * from './tbsc';
export * from './bscToken';
export * from './bnb';
export * from './tbnb';
export * from './bnbToken';
export * from './register';
8 changes: 4 additions & 4 deletions modules/sdk-coin-bsc/src/lib/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const testnetCommon = EthereumCommon.forCustomChain(
'mainnet',
{
name: 'testnet',
networkId: (coins.get('tbsc').network as EthereumNetwork).chainId,
chainId: (coins.get('tbsc').network as EthereumNetwork).chainId,
networkId: (coins.get('tbnb').network as EthereumNetwork).chainId,
chainId: (coins.get('tbnb').network as EthereumNetwork).chainId,
},
'petersburg'
);
Expand All @@ -15,8 +15,8 @@ export const mainnetCommon = EthereumCommon.forCustomChain(
'mainnet',
{
name: 'mainnet',
networkId: (coins.get('bsc').network as EthereumNetwork).chainId,
chainId: (coins.get('bsc').network as EthereumNetwork).chainId,
networkId: (coins.get('bnb').network as EthereumNetwork).chainId,
chainId: (coins.get('bnb').network as EthereumNetwork).chainId,
},
'petersburg'
);
2 changes: 1 addition & 1 deletion modules/sdk-coin-bsc/src/lib/transferBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { TransferBuilder as EthTransferBuilder } from '@bitgo/sdk-coin-eth';
export class TransferBuilder extends EthTransferBuilder {
/** @inheritdoc */
protected getNativeOperationHashPrefix(): string {
return 'BSC';
return 'BNB';
}
}
12 changes: 6 additions & 6 deletions modules/sdk-coin-bsc/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BitGoBase } from '@bitgo/sdk-core';
import { Bsc } from './bsc';
import { BscToken } from './bscToken';
import { Tbsc } from './tbsc';
import { Bnb } from './bnb';
import { BnbToken } from './bnbToken';
import { Tbnb } from './tbnb';

export const register = (sdk: BitGoBase): void => {
sdk.register('bsc', Bsc.createInstance);
sdk.register('tbsc', Tbsc.createInstance);
BscToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register('bnb', Bnb.createInstance);
sdk.register('tbnb', Tbnb.createInstance);
BnbToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';

import { Bsc } from './bsc';
import { Bnb } from './bnb';

export class Tbsc extends Bsc {
export class Tbnb extends Bnb {
protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo, staticsCoin);
}

static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new Tbsc(bitgo, staticsCoin);
return new Tbnb(bitgo, staticsCoin);
}

/** @inheritDoc */
Expand Down
41 changes: 41 additions & 0 deletions modules/sdk-coin-bsc/test/unit/bnb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'should';

import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
import { BitGoAPI } from '@bitgo/sdk-api';

import { Bnb, Tbnb } from '../../src/index';

const bitgo: TestBitGoAPI = TestBitGo.decorate(BitGoAPI, { env: 'test' });

describe('BNB Smart Chain', function () {
before(function () {
bitgo.safeRegister('bnb', Bnb.createInstance);
bitgo.safeRegister('tbnb', Tbnb.createInstance);
bitgo.initializeTestVars();
});

describe('Basic Coin Info', function () {
it('should return the right info for bnb', function () {
const bnb = bitgo.coin('bnb');

bnb.should.be.an.instanceof(Bnb);
bnb.getChain().should.equal('bnb');
bnb.getFamily().should.equal('bnb');
bnb.getFullName().should.equal('BNB Smart Chain');
bnb.getBaseFactor().should.equal(1e18);
bnb.supportsTss().should.equal(true);
});

it('should return the right info for tbnb', function () {
const tbnb = bitgo.coin('tbnb');

tbnb.should.be.an.instanceof(Tbnb);
tbnb.getChain().should.equal('tbnb');
tbnb.getFamily().should.equal('bnb');
tbnb.getFullName().should.equal('Testnet BNB Smart Chain');
tbnb.getBaseFactor().should.equal(1e18);
tbnb.supportsTss().should.equal(true);
tbnb.allowsAccountConsolidations().should.equal(true);
});
});
});
32 changes: 32 additions & 0 deletions modules/sdk-coin-bsc/test/unit/bnbToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'should';

import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
import { BnbToken } from '../../src';
import { BitGoAPI } from '@bitgo/sdk-api';

describe('Bnb Token:', function () {
let bitgo: TestBitGoAPI;
let bnbTokenCoin;
const tokenName = 'tbnb:busd';

before(function () {
bitgo = TestBitGo.decorate(BitGoAPI, { env: 'test' });
BnbToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
bitgo.safeRegister(name, coinConstructor);
});
bitgo.initializeTestVars();
bnbTokenCoin = bitgo.coin(tokenName);
});

it('should return constants', function () {
bnbTokenCoin.getChain().should.equal('tbnb:busd');
bnbTokenCoin.getBaseChain().should.equal('tbnb');
bnbTokenCoin.getFullName().should.equal('Bnb Token');
bnbTokenCoin.getBaseFactor().should.equal(1e18);
bnbTokenCoin.type.should.equal(tokenName);
bnbTokenCoin.name.should.equal('Test BNB USD Token');
bnbTokenCoin.coin.should.equal('tbnb');
bnbTokenCoin.network.should.equal('Testnet');
bnbTokenCoin.decimalPlaces.should.equal(18);
});
});
41 changes: 0 additions & 41 deletions modules/sdk-coin-bsc/test/unit/bsc.ts

This file was deleted.

32 changes: 0 additions & 32 deletions modules/sdk-coin-bsc/test/unit/bscToken.ts

This file was deleted.

Loading

0 comments on commit 7ec3389

Please sign in to comment.