Skip to content

Commit d89deb9

Browse files
authored
Merge pull request #5714 from BitGo/COIN-3364
fix(sdk-coin-stx): adding contractId instead of contractAddress & contractName for SIP10 tokens
2 parents 3691db2 + 68d4db7 commit d89deb9

File tree

3 files changed

+14
-39
lines changed

3 files changed

+14
-39
lines changed

modules/sdk-coin-stx/src/sip10Token.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@ export class Sip10Token extends Stx {
3636
return this.tokenConfig.network;
3737
}
3838

39-
get tokenContractAddress(): string {
40-
return this.tokenConfig.tokenContractAddress;
41-
}
42-
43-
get contractName(): string {
44-
return this.tokenConfig.contractName;
39+
get assetId(): string {
40+
return this.tokenConfig.assetId;
4541
}
4642

4743
get decimalPlaces(): number {

modules/statics/src/account.ts

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ export interface FiatCoinConstructorOptions extends AccountConstructorOptions {
131131
}
132132

133133
export interface Sip10TokenConstructorOptions extends AccountConstructorOptions {
134-
contractAddress: string;
135-
contractName: string;
134+
assetId: string;
136135
}
137136

138137
export interface ContractAddress extends String {
@@ -531,15 +530,13 @@ export class FiatCoin extends BaseCoin {
531530
* the contractName on the chain.
532531
*/
533532
export class Sip10Token extends AccountCoinToken {
534-
public contractAddress: string;
535-
public contractName: string;
533+
public assetId: string;
536534
constructor(options: Sip10TokenConstructorOptions) {
537535
super({
538536
...options,
539537
});
540538

541-
this.contractAddress = options.contractAddress;
542-
this.contractName = options.contractName;
539+
this.assetId = options.assetId;
543540
}
544541
}
545542

@@ -2612,8 +2609,7 @@ export function fiat(
26122609
* @param name unique identifier of the token
26132610
* @param fullName Complete human-readable name of the token
26142611
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
2615-
* @param contractName Contract name of this token
2616-
* @param contractAddress Contract address of this token
2612+
* @param assetId A unique identifier for a token, which is in the form of contractAddress.contractName::tokenName
26172613
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
26182614
* @param prefix? Optional token prefix. Defaults to empty string
26192615
* @param suffix? Optional token suffix. Defaults to token name.
@@ -2626,8 +2622,7 @@ export function sip10Token(
26262622
name: string,
26272623
fullName: string,
26282624
decimalPlaces: number,
2629-
contractName: string,
2630-
contractAddress: string,
2625+
assetId: string,
26312626
asset: UnderlyingAsset,
26322627
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
26332628
prefix = '',
@@ -2641,8 +2636,7 @@ export function sip10Token(
26412636
name,
26422637
fullName,
26432638
network,
2644-
contractName,
2645-
contractAddress,
2639+
assetId,
26462640
prefix,
26472641
suffix,
26482642
features,
@@ -2662,8 +2656,7 @@ export function sip10Token(
26622656
* @param name unique identifier of the token
26632657
* @param fullName Complete human-readable name of the token
26642658
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
2665-
* @param contractName Contract name of this token
2666-
* @param contractAddress Contract address of this token
2659+
* @param assetId A unique identifier for a token, which is in the form of contractAddress.contractName::tokenName
26672660
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
26682661
* @param prefix? Optional token prefix. Defaults to empty string
26692662
* @param suffix? Optional token suffix. Defaults to token name.
@@ -2675,25 +2668,12 @@ export function tsip10Token(
26752668
name: string,
26762669
fullName: string,
26772670
decimalPlaces: number,
2678-
contractName: string,
2679-
contractAddress: string,
2671+
assetId: string,
26802672
asset: UnderlyingAsset,
26812673
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
26822674
prefix = '',
26832675
suffix: string = name.toUpperCase(),
26842676
network: AccountNetwork = Networks.test.stx
26852677
) {
2686-
return sip10Token(
2687-
id,
2688-
name,
2689-
fullName,
2690-
decimalPlaces,
2691-
contractName,
2692-
contractAddress,
2693-
asset,
2694-
features,
2695-
prefix,
2696-
suffix,
2697-
network
2698-
);
2678+
return sip10Token(id, name, fullName, decimalPlaces, assetId, asset, features, prefix, suffix, network);
26992679
}

modules/statics/src/tokenConfig.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export type AptTokenConfig = BaseNetworkConfig & {
9696
assetId: string;
9797
};
9898

99-
export type Sip10TokenConfig = BaseContractAddressConfig & {
100-
contractName: string;
99+
export type Sip10TokenConfig = BaseNetworkConfig & {
100+
assetId: string;
101101
};
102102

103103
export interface Tokens {
@@ -566,8 +566,7 @@ const formattedSip10Tokens = coins.reduce((acc: Sip10TokenConfig[], coin) => {
566566
coin: coin.network.type === NetworkType.MAINNET ? 'stx' : 'tstx',
567567
network: coin.network.type === NetworkType.MAINNET ? 'Mainnet' : 'Testnet',
568568
name: coin.fullName,
569-
contractName: coin.contractName,
570-
tokenContractAddress: coin.contractAddress.toString().toLowerCase(),
569+
assetId: coin.assetId,
571570
decimalPlaces: coin.decimalPlaces,
572571
});
573572
}

0 commit comments

Comments
 (0)