Skip to content

Commit 2782706

Browse files
authored
Merge pull request #6830 from BitGo/WIN-6446-ada-token-support
feat(sdk-coin-ada): add support for tokens
2 parents 04231a2 + 4fadc03 commit 2782706

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

modules/statics/src/account.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,17 +1864,18 @@ export function tsolToken(
18641864
}
18651865

18661866
/**
1867-
* Factory function for ada token instances.
1867+
* Factory function for prod cardano token instances.
18681868
*
18691869
* @param id uuid v4
1870-
* @param name unique identifier of the token
1870+
* @param name Name of the token
18711871
* @param fullName Complete human-readable name of the token
18721872
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
1873-
* @param tokenSymbol Token symbol of this token
1873+
* @param policyId Policy Id
1874+
* @param assetName Asset name -> Policy ID + Asset name is the unique identifier
18741875
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
18751876
* @param prefix? Optional token prefix. Defaults to empty string
18761877
* @param suffix? Optional token suffix. Defaults to token name.
1877-
* @param network? Optional token network. Defaults to Cardano main network.
1878+
* @param network? Optional token network. Defaults to the testnet Cardano network.
18781879
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES and REQUIRES_RESERVE defined in `AccountCoin`
18791880
* @param primaryKeyCurve The elliptic curve for this chain/token
18801881
*/
@@ -1916,10 +1917,11 @@ export function adaToken(
19161917
* Factory function for testnet cardano token instances.
19171918
*
19181919
* @param id uuid v4
1919-
* @param name unique identifier of the token
1920+
* @param name Name of the token
19201921
* @param fullName Complete human-readable name of the token
19211922
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
1922-
* @param tokenSymbol Token symbol of this token i.e: AUSD
1923+
* @param policyId Policy Id
1924+
* @param assetName Asset name -> Policy ID + Asset name is the unique identifier
19231925
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
19241926
* @param prefix? Optional token prefix. Defaults to empty string
19251927
* @param suffix? Optional token suffix. Defaults to token name.
@@ -1935,9 +1937,9 @@ export function tadaToken(
19351937
assetName: string,
19361938
asset: UnderlyingAsset,
19371939
features: CoinFeature[] = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.REQUIRES_RESERVE],
1940+
network: AccountNetwork = Networks.test.ada,
19381941
prefix = '',
1939-
suffix: string = name.toUpperCase(),
1940-
network: AccountNetwork = Networks.test.ada
1942+
suffix: string = name.toUpperCase()
19411943
) {
19421944
return adaToken(id, name, fullName, decimalPlaces, policyId, assetName, asset, features, prefix, suffix, network);
19431945
}

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import {
126126
} from './coinFeatures';
127127
import { botTokens } from './coins/botTokens';
128128
import { botOfcTokens } from './coins/botOfcTokens';
129+
import { adaTokens } from './coins/adaTokens';
129130

130131
export const allCoinsAndTokens = [
131132
...lightningCoins,
@@ -141,6 +142,7 @@ export const allCoinsAndTokens = [
141142
...cosmosTokens,
142143
...botTokens,
143144
...botOfcTokens,
145+
...adaTokens,
144146
avaxp(
145147
'5436386e-9e4d-4d82-92df-59d9720d1738',
146148
'avaxp',

modules/statics/src/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,6 +3022,9 @@ export enum UnderlyingAsset {
30223022
'eth:neiro2' = 'eth:neiro2',
30233023
'eth:sign' = 'eth:sign',
30243024

3025+
// ADA testnet tokens
3026+
'tada:water' = 'tada:water',
3027+
30253028
// fiats
30263029
AED = 'aed',
30273030
EUR = 'eur',

modules/statics/src/coinFeatures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export const HTETH_TOKEN_FEATURES = [
168168
CoinFeature.EIP1559,
169169
CoinFeature.WALLET_CONNECT_DEFI,
170170
];
171-
export const ADA_FEATURES = [...Ada.DEFAULT_FEATURES, CoinFeature.BULK_TRANSACTION];
171+
export const ADA_FEATURES = [...Ada.DEFAULT_FEATURES, CoinFeature.BULK_TRANSACTION, CoinFeature.SUPPORTS_TOKENS];
172172
export const ADA_FEATURES_WITH_FRANKFURT = [...ADA_FEATURES, CoinFeature.CUSTODY_BITGO_FRANKFURT];
173173
export const DOT_FEATURES = [
174174
...ACCOUNT_COIN_DEFAULT_FEATURES,

modules/statics/src/coins.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
vetNFTCollection,
2525
vetToken,
2626
xrpToken,
27+
adaToken,
2728
} from './account';
2829
import { ofcToken } from './ofc';
2930
import { BaseCoin } from './base';
@@ -63,6 +64,7 @@ export function createToken(token: AmsTokenConfig): Readonly<BaseCoin> | undefin
6364
xlm: stellarToken,
6465
xrp: xrpToken,
6566
ofc: ofcToken,
67+
ada: adaToken,
6668
};
6769

6870
//return the BaseCoin from default coin map if present
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { tadaToken, AccountCoin } from '../account';
2+
import { UnderlyingAsset } from '../base';
3+
import { Networks } from '../networks';
4+
5+
export const adaTokens = [
6+
tadaToken(
7+
'a7678172-84b3-4c7e-ac46-9875d23a1cb7',
8+
'tada:water',
9+
'Test ADA Token',
10+
6,
11+
'2533cca6eb42076e144e9f2772c390dece9fce173bc38c72294b3924',
12+
'WATER',
13+
UnderlyingAsset['tada:water'],
14+
AccountCoin.DEFAULT_FEATURES,
15+
Networks.test.ada
16+
),
17+
];

0 commit comments

Comments
 (0)