Skip to content

Commit

Permalink
Merge pull request #5541 from BitGo/WIN-4540-alter-tokenAddress-for-sol
Browse files Browse the repository at this point in the history
chore(sdk-coin-sol): use contractAddress to form tokenAddress
  • Loading branch information
rakeshgsharma authored Feb 17, 2025
2 parents eceb874 + e2db18c commit cc37428
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modules/sdk-coin-sol/src/solToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class SolToken extends Sol {
return this.tokenConfig.decimalPlaces;
}

get contractAddress() {
return this.tokenConfig.tokenAddress;
}

getChain() {
return this.tokenConfig.type;
}
Expand Down
31 changes: 31 additions & 0 deletions modules/sdk-coin-sol/test/unit/solToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'should';
import { BitGoAPI } from '@bitgo/sdk-api';
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
import { SolToken } from '../../src';

describe('SOL Token:', function () {
let bitgo: TestBitGoAPI;
let solTokenCoin;
const tokenName = 'sol:spx';

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

it('should return constants', function () {
solTokenCoin.getChain().should.equal(tokenName);
solTokenCoin.getBaseChain().should.equal('sol');
solTokenCoin.getBaseFactor().should.equal(1e8);
solTokenCoin.getFullName().should.equal('Solana Token');
solTokenCoin.coin.should.equal('sol');
solTokenCoin.decimalPlaces.should.equal(8);
solTokenCoin.network.should.equal('Mainnet');
solTokenCoin.tokenAddress.should.equal('J3NKxxXZcnNiMjKw9hYb2K4LUxgwB6t1FtPtQVsv3KFr');
solTokenCoin.contractAddress.should.equal('J3NKxxXZcnNiMjKw9hYb2K4LUxgwB6t1FtPtQVsv3KFr');
});
});
2 changes: 1 addition & 1 deletion modules/statics/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class SolCoin extends AccountCoinToken {
...options,
});

this.tokenAddress = options.tokenAddress;
this.tokenAddress = options.contractAddress;
this.contractAddress = options.contractAddress;
}
}
Expand Down
2 changes: 2 additions & 0 deletions modules/statics/src/tokenConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type StellarTokenConfig = BaseNetworkConfig;

export type SolTokenConfig = BaseNetworkConfig & {
tokenAddress: string;
contractAddress: string;
};

export type AdaTokenConfig = BaseNetworkConfig & {
Expand Down Expand Up @@ -434,6 +435,7 @@ const formattedSolTokens = coins.reduce((acc: SolTokenConfig[], coin) => {
name: coin.fullName,
tokenAddress: coin.tokenAddress,
decimalPlaces: coin.decimalPlaces,
contractAddress: coin.contractAddress,
});
}
return acc;
Expand Down

0 comments on commit cc37428

Please sign in to comment.