Skip to content

Commit a147441

Browse files
authored
Merge pull request #6931 from BitGo/WIN-7162-add-ada-fingerprint
feat(sdk-coin-ada): Add fingerprint as the contract address
2 parents 8c46f24 + 65f2080 commit a147441

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

modules/sdk-coin-ada/src/adaToken.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ export class AdaToken extends Ada {
5050
return this.tokenConfig.decimalPlaces;
5151
}
5252

53-
get uniqueAssetId() {
54-
return this.tokenConfig.uniqueAssetId;
55-
}
56-
5753
getChain() {
5854
return this.tokenConfig.type;
5955
}
@@ -85,4 +81,8 @@ export class AdaToken extends Ada {
8581
transactionDataAllowed() {
8682
return false;
8783
}
84+
85+
get contractAddress() {
86+
return this.tokenConfig.contractAddress;
87+
}
8888
}

modules/statics/src/account.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ export interface CosmosTokenConstructorOptions extends AccountConstructorOptions
169169
}
170170

171171
export interface AdaTokenConstructorOptions extends AccountConstructorOptions {
172-
uniqueAssetId: string;
173172
policyId: string;
174173
assetName: string;
174+
contractAddress: string;
175175
}
176176
export interface ContractAddress extends String {
177177
__contractaddress_phantom__: never;
@@ -703,17 +703,17 @@ export class PolyxCoin extends AccountCoinToken {
703703
}
704704

705705
export class AdaToken extends AccountCoinToken {
706-
public uniqueAssetId: string;
707706
public policyId: string;
708707
public assetName: string;
708+
public contractAddress: string;
709709
constructor(options: AdaTokenConstructorOptions) {
710710
super({
711711
...options,
712712
});
713713

714-
this.uniqueAssetId = options.uniqueAssetId;
715714
this.policyId = options.policyId;
716715
this.assetName = options.assetName;
716+
this.contractAddress = options.contractAddress;
717717
}
718718
}
719719

@@ -1876,6 +1876,7 @@ export function tsolToken(
18761876
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
18771877
* @param policyId Policy Id
18781878
* @param assetName Asset name -> Policy ID + Asset name is the unique identifier
1879+
* @param contractAddress Fingerprint of this token
18791880
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
18801881
* @param prefix? Optional token prefix. Defaults to empty string
18811882
* @param suffix? Optional token suffix. Defaults to token name.
@@ -1890,15 +1891,14 @@ export function adaToken(
18901891
decimalPlaces: number,
18911892
policyId: string,
18921893
assetName: string,
1893-
encodedAssetName: string,
1894+
contractAddress: string,
18941895
asset: UnderlyingAsset,
18951896
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.REQUIRES_RESERVE],
18961897
prefix = '',
18971898
suffix: string = name.toUpperCase(),
18981899
network: AccountNetwork = Networks.main.ada,
18991900
primaryKeyCurve: KeyCurve = KeyCurve.Ed25519
19001901
) {
1901-
const uniqueAssetId = `${policyId}${encodedAssetName}`;
19021902
return Object.freeze(
19031903
new AdaToken({
19041904
id,
@@ -1911,11 +1911,11 @@ export function adaToken(
19111911
suffix,
19121912
features,
19131913
decimalPlaces,
1914+
contractAddress,
19141915
asset,
19151916
isToken: true,
19161917
primaryKeyCurve,
19171918
baseUnit: BaseUnit.ADA,
1918-
uniqueAssetId,
19191919
})
19201920
);
19211921
}
@@ -1929,6 +1929,7 @@ export function adaToken(
19291929
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
19301930
* @param policyId Policy Id
19311931
* @param assetName Asset name -> Policy ID + Asset name is the unique identifier
1932+
* @param contractAddress Fingerprint of this token
19321933
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
19331934
* @param prefix? Optional token prefix. Defaults to empty string
19341935
* @param suffix? Optional token suffix. Defaults to token name.
@@ -1942,7 +1943,7 @@ export function tadaToken(
19421943
decimalPlaces: number,
19431944
policyId: string,
19441945
assetName: string,
1945-
encodedAssetName: string,
1946+
contractAddress: string,
19461947
asset: UnderlyingAsset,
19471948
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.REQUIRES_RESERVE],
19481949
network: AccountNetwork = Networks.test.ada,
@@ -1956,7 +1957,7 @@ export function tadaToken(
19561957
decimalPlaces,
19571958
policyId,
19581959
assetName,
1959-
encodedAssetName,
1960+
contractAddress,
19601961
asset,
19611962
features,
19621963
prefix,

modules/statics/src/coins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ export function createToken(token: AmsTokenConfig): Readonly<BaseCoin> | undefin
258258
case 'ada':
259259
return initializer(
260260
...commonArgs.slice(0, 4), // id, name, fullName, decimalPlaces
261-
token.uniqueAssetId,
262261
token.assetName,
263262
token.policyId,
263+
token.contractAddress,
264264
...commonArgs.slice(4) // asset, features, prefix, suffix, network, primaryKeyCurve
265265
);
266266
default:

modules/statics/src/coins/adaTokens.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export const adaTokens = [
88
'a7678172-84b3-4c7e-ac46-9875d23a1cb7',
99
'tada:water',
1010
'Test ADA Token',
11-
6,
11+
0, // Tokens are not divisible - https://cardano-ledger.readthedocs.io/en/latest/explanations/token-bundles.html
1212
'2533cca6eb42076e144e9f2772c390dece9fce173bc38c72294b3924',
1313
'WATER',
14-
'5741544552',
14+
'asset1n69xf60d0760xvn8v2ffd5frvsm0cl2r8hfjf6',
1515
UnderlyingAsset['tada:water'],
1616
ADA_TOKEN_FEATURES,
1717
Networks.test.ada

modules/statics/src/tokenConfig.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export type SolTokenConfig = BaseNetworkConfig & {
7070
export type AdaTokenConfig = BaseNetworkConfig & {
7171
policyId: string;
7272
assetName: string;
73-
uniqueAssetId: string;
73+
contractAddress: string;
7474
};
7575

7676
export type AlgoTokenConfig = BaseNetworkConfig & {
@@ -386,7 +386,6 @@ export interface AmsTokenConfig {
386386
programId?: string;
387387
addressCoin?: string;
388388
assetName?: string;
389-
uniqueAssetId?: string;
390389
policyId?: string;
391390
}
392391

@@ -791,7 +790,7 @@ function getAdaTokenConfig(coin: AdaToken): AdaTokenConfig {
791790
policyId: coin.policyId,
792791
assetName: coin.assetName,
793792
decimalPlaces: coin.decimalPlaces,
794-
uniqueAssetId: coin.uniqueAssetId,
793+
contractAddress: coin.contractAddress,
795794
};
796795
}
797796
const getFormattedAdaTokens = (customCoinMap = coins) =>

0 commit comments

Comments
 (0)