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 3e13938
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 166 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,
bsc: Bnb.TransactionBuilder,
tbsc: 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/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
6 changes: 3 additions & 3 deletions modules/sdk-coin-bsc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ npm i @bitgo/sdk-api @bitgo/sdk-coin-bsc
Next, you will be able to initialize an instance of "bitgo" through `@bitgo/sdk-api` instead of `bitgo`.

```javascript
import { BitGoAPI } from '@bitgo/sdk-api';
import { Bsc } from '@bitgo/sdk-coin-bsc';
import {BitGoAPI} from '@bitgo/sdk-api';
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
44 changes: 22 additions & 22 deletions modules/sdk-coin-bsc/test/unit/bsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ import 'should';
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
import { BitGoAPI } from '@bitgo/sdk-api';

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

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

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

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

bsc.should.be.an.instanceof(Bsc);
bsc.getChain().should.equal('bsc');
bsc.getFamily().should.equal('bsc');
bsc.getFullName().should.equal('Binance Smart Chain');
bsc.getBaseFactor().should.equal(1e18);
bsc.supportsTss().should.equal(true);
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 tbsc', function () {
const tbsc = bitgo.coin('tbsc');
it('should return the right info for tbnb', function () {
const tbnb = bitgo.coin('tbnb');

tbsc.should.be.an.instanceof(Tbsc);
tbsc.getChain().should.equal('tbsc');
tbsc.getFamily().should.equal('bsc');
tbsc.getFullName().should.equal('Testnet Binance Smart Chain');
tbsc.getBaseFactor().should.equal(1e18);
tbsc.supportsTss().should.equal(true);
tbsc.allowsAccountConsolidations().should.equal(true);
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);
});
});
});
30 changes: 15 additions & 15 deletions modules/sdk-coin-bsc/test/unit/bscToken.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import 'should';

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

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

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

it('should return constants', function () {
bscTokenCoin.getChain().should.equal('tbsc:busd');
bscTokenCoin.getBaseChain().should.equal('tbsc');
bscTokenCoin.getFullName().should.equal('Bsc Token');
bscTokenCoin.getBaseFactor().should.equal(1e18);
bscTokenCoin.type.should.equal(tokenName);
bscTokenCoin.name.should.equal('Test Binance USD Token');
bscTokenCoin.coin.should.equal('tbsc');
bscTokenCoin.network.should.equal('Testnet');
bscTokenCoin.decimalPlaces.should.equal(18);
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);
});
});
4 changes: 2 additions & 2 deletions modules/sdk-coin-bsc/test/unit/transactionBuilder/send.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getBuilder } from '../getBuilder';
import should from 'should';

describe('BSC Transfer Builder', () => {
describe('BNB Transfer Builder', () => {
describe('Build from TxHex', function () {
it('Should successfully build from txHex', async function () {
const txBuilder = getBuilder('tbsc');
const txBuilder = getBuilder('tbnb');
const txHex =
'0xf8ad82026d85059f73c1808303d09094f5caa5e3e93afbc21bd19ef4f2691a37121f791780b844fb90b32000000000000000000000000090a4693ee469ac4f04bb9bb8ccf955e6cf4cf875000000000000000000000000000000000000000000000000000000000000000181e5a08d37159dab62ce1f450cab33c932603505952e351f5da8da70023cdc9275be57a034be4eac6c2d636c6f1f0762ab0390fc8aa2fc541a968c911f8ef05a3422f44f';
txBuilder.from(txHex);
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-core/src/bitgo/utils/mpcUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export abstract class MpcUtils {
recipients: intentRecipients,
};

if (baseCoin.getFamily() === 'eth' || baseCoin.getFamily() === 'polygon' || baseCoin.getFamily() === 'bsc') {
if (baseCoin.getFamily() === 'eth' || baseCoin.getFamily() === 'polygon' || baseCoin.getFamily() === 'bnb') {
switch (params.intentType) {
case 'payment':
case 'transferToken':
Expand Down
Loading

0 comments on commit 3e13938

Please sign in to comment.