Skip to content

Commit 2ba82d6

Browse files
committed
feat(sdk-core): add aed and sgd
TICKET: FIAT-176 Add United Arab Emirates Dirham and Singapore Dollar
1 parent c5f1072 commit 2ba82d6

File tree

10 files changed

+277
-5
lines changed

10 files changed

+277
-5
lines changed

modules/bitgo/src/v2/coinFactory.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ import {
4949
EthLikeCoin,
5050
Flr,
5151
TethLikeCoin,
52+
FiatAED,
5253
FiatEur,
5354
FiatGBP,
55+
FiatSGD,
5456
FiatUsd,
5557
Gteth,
5658
Hash,
@@ -111,8 +113,10 @@ import {
111113
Teth,
112114
Teth2,
113115
Tflr,
116+
TfiatAED,
114117
TfiatEur,
115118
TfiatGBP,
119+
TfiatSGD,
116120
TfiatUsd,
117121
Thash,
118122
Thbar,
@@ -190,8 +194,10 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
190194
globalCoinFactory.register('ethw', Ethw.createInstance);
191195
globalCoinFactory.register('baseeth', EthLikeCoin.createInstance);
192196
globalCoinFactory.register('tbaseeth', TethLikeCoin.createInstance);
197+
globalCoinFactory.register('fiataed', FiatAED.createInstance);
193198
globalCoinFactory.register('fiateur', FiatEur.createInstance);
194199
globalCoinFactory.register('fiatgbp', FiatGBP.createInstance);
200+
globalCoinFactory.register('fiatsgd', FiatSGD.createInstance);
195201
globalCoinFactory.register('fiatusd', FiatUsd.createInstance);
196202
globalCoinFactory.register('flr', Flr.createInstance);
197203
globalCoinFactory.register('gteth', Gteth.createInstance);
@@ -249,8 +255,10 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
249255
globalCoinFactory.register('tetc', Tetc.createInstance);
250256
globalCoinFactory.register('teth', Teth.createInstance);
251257
globalCoinFactory.register('teth2', Teth2.createInstance);
258+
globalCoinFactory.register('tfiataed', TfiatAED.createInstance);
252259
globalCoinFactory.register('tfiateur', TfiatEur.createInstance);
253260
globalCoinFactory.register('tfiatgbp', TfiatGBP.createInstance);
261+
globalCoinFactory.register('tfiatsgd', TfiatSGD.createInstance);
254262
globalCoinFactory.register('tfiatusd', TfiatUsd.createInstance);
255263
globalCoinFactory.register('tflr', Tflr.createInstance);
256264
globalCoinFactory.register('thash', Thash.createInstance);

modules/bitgo/src/v2/coins/index.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,35 @@ export { Wemix, Twemix };
125125
export { Zketh, Tzketh, ZkethToken };
126126

127127
import { coins } from '@bitgo/sdk-core';
128-
const { Ofc, OfcToken, Susd, FiatUsd, FiatEur, FiatGBP, Tsusd, TfiatUsd, TfiatEur, TfiatGBP } = coins;
129-
export { FiatEur, FiatGBP, FiatUsd, Ofc, OfcToken, Susd, TfiatEur, TfiatGBP, TfiatUsd, Tsusd };
128+
const {
129+
Ofc,
130+
OfcToken,
131+
Susd,
132+
FiatUsd,
133+
FiatEur,
134+
FiatGBP,
135+
FiatAED,
136+
FiatSGD,
137+
Tsusd,
138+
TfiatUsd,
139+
TfiatEur,
140+
TfiatGBP,
141+
TfiatAED,
142+
TfiatSGD,
143+
} = coins;
144+
export {
145+
FiatAED,
146+
FiatEur,
147+
FiatGBP,
148+
FiatSGD,
149+
FiatUsd,
150+
Ofc,
151+
OfcToken,
152+
Susd,
153+
TfiatAED,
154+
TfiatEur,
155+
TfiatGBP,
156+
TfiatSGD,
157+
TfiatUsd,
158+
Tsusd,
159+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @prettier
3+
*/
4+
import {
5+
BaseCoin,
6+
BitGoBase,
7+
KeyPair,
8+
MethodNotImplementedError,
9+
ParsedTransaction,
10+
ParseTransactionOptions,
11+
SignedTransaction,
12+
SignTransactionOptions,
13+
VerifyAddressOptions,
14+
VerifyTransactionOptions,
15+
} from '../';
16+
17+
export class FiatAED extends BaseCoin {
18+
static createInstance(bitgo: BitGoBase): BaseCoin {
19+
return new FiatAED(bitgo);
20+
}
21+
22+
/**
23+
* Returns the factor between the base unit and its smallest subdivison
24+
* @return {number}
25+
*/
26+
getBaseFactor() {
27+
return 1e2;
28+
}
29+
30+
getChain() {
31+
return 'fiataed';
32+
}
33+
34+
getFamily() {
35+
return 'fiat';
36+
}
37+
38+
getFullName() {
39+
return 'United Arab Emirates Dirham';
40+
}
41+
42+
/**
43+
* Return whether the given m of n wallet signers/ key amounts are valid for the coin
44+
*/
45+
isValidMofNSetup({ m, n }: { m: number; n: number }) {
46+
return m === 0 && n === 0;
47+
}
48+
49+
isValidAddress(address: string): boolean {
50+
throw new MethodNotImplementedError();
51+
}
52+
53+
generateKeyPair(seed?: Buffer): KeyPair {
54+
throw new MethodNotImplementedError();
55+
}
56+
57+
isValidPub(pub: string): boolean {
58+
throw new MethodNotImplementedError();
59+
}
60+
61+
async parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
62+
return {};
63+
}
64+
65+
async isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
66+
throw new MethodNotImplementedError();
67+
}
68+
69+
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
70+
return true;
71+
}
72+
73+
async signTransaction(params: SignTransactionOptions = {}): Promise<SignedTransaction> {
74+
throw new MethodNotImplementedError();
75+
}
76+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @prettier
3+
*/
4+
import {
5+
BaseCoin,
6+
BitGoBase,
7+
KeyPair,
8+
MethodNotImplementedError,
9+
ParsedTransaction,
10+
ParseTransactionOptions,
11+
SignedTransaction,
12+
SignTransactionOptions,
13+
VerifyAddressOptions,
14+
VerifyTransactionOptions,
15+
} from '..';
16+
17+
export class FiatSGD extends BaseCoin {
18+
static createInstance(bitgo: BitGoBase): BaseCoin {
19+
return new FiatSGD(bitgo);
20+
}
21+
22+
/**
23+
* Returns the factor between the base unit and its smallest subdivison
24+
* @return {number}
25+
*/
26+
getBaseFactor() {
27+
return 1e2;
28+
}
29+
30+
getChain() {
31+
return 'fiatsgd';
32+
}
33+
34+
getFamily() {
35+
return 'fiat';
36+
}
37+
38+
getFullName() {
39+
return 'Singapore Dollar';
40+
}
41+
42+
/**
43+
* Return whether the given m of n wallet signers/ key amounts are valid for the coin
44+
*/
45+
isValidMofNSetup({ m, n }: { m: number; n: number }) {
46+
return m === 0 && n === 0;
47+
}
48+
49+
isValidAddress(address: string): boolean {
50+
throw new MethodNotImplementedError();
51+
}
52+
53+
generateKeyPair(seed?: Buffer): KeyPair {
54+
throw new MethodNotImplementedError();
55+
}
56+
57+
isValidPub(pub: string): boolean {
58+
throw new MethodNotImplementedError();
59+
}
60+
61+
async parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
62+
return {};
63+
}
64+
65+
async isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
66+
throw new MethodNotImplementedError();
67+
}
68+
69+
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
70+
return true;
71+
}
72+
73+
async signTransaction(params: SignTransactionOptions = {}): Promise<SignedTransaction> {
74+
throw new MethodNotImplementedError();
75+
}
76+
}

modules/sdk-core/src/coins/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export * from './fiataed';
2+
export * from './tfiataed';
3+
export * from './fiatsgd';
4+
export * from './tfiatsgd';
15
export * from './fiateur';
26
export * from './tfiateur';
37
export * from './fiatgbp';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @prettier
3+
*/
4+
import { BaseCoin, BitGoBase } from '../';
5+
import { FiatAED } from './fiataed';
6+
7+
export class TfiatAED extends FiatAED {
8+
static createInstance(bitgo: BitGoBase): BaseCoin {
9+
return new TfiatAED(bitgo);
10+
}
11+
12+
getChain() {
13+
return 'tfiataed';
14+
}
15+
16+
getFullName() {
17+
return 'Testnet United Arab Emirates Dirham';
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @prettier
3+
*/
4+
import { BaseCoin, BitGoBase } from '../';
5+
import { FiatSGD } from './fiatsgd';
6+
7+
export class TfiatSGD extends FiatSGD {
8+
static createInstance(bitgo: BitGoBase): BaseCoin {
9+
return new TfiatSGD(bitgo);
10+
}
11+
12+
getChain() {
13+
return 'tfiatsgd';
14+
}
15+
16+
getFullName() {
17+
return 'Testnet Singapore Dollar';
18+
}
19+
}

modules/statics/src/base.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,11 @@ export enum UnderlyingAsset {
381381
ETC = 'etc',
382382
EOS = 'eos',
383383
ERD = 'erd',
384-
EUR = 'eur',
385384
EURCVV0 = 'eurcvv0',
386385
EURCV = 'eurcv',
387386
EUROC = 'euroc',
388387
EURR = 'eurr',
389388
FLR = 'flr',
390-
GBP = 'gbp',
391389
GTC = 'gtc',
392390
HASH = 'hash', // Provenance
393391
HBAR = 'hbar', // Hedera main coin
@@ -411,7 +409,6 @@ export enum UnderlyingAsset {
411409
TIA = 'tia', // Celestia
412410
TON = 'ton',
413411
TRX = 'trx',
414-
USD = 'usd',
415412
WEMIX = 'wemix',
416413
XLM = 'xlm',
417414
XDC = 'xdc',
@@ -2505,6 +2502,13 @@ export enum UnderlyingAsset {
25052502
// Sip10 testnet tokens
25062503
'tstx:tsip6dp' = 'tstx:tsip6dp',
25072504
'tstx:tsip8dp' = 'tstx:tsip8dp',
2505+
2506+
// fiats
2507+
AED = 'aed',
2508+
EUR = 'eur',
2509+
GBP = 'gbp',
2510+
SGD = 'sgd',
2511+
USD = 'usd',
25082512
}
25092513

25102514
/**

modules/statics/src/coins.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,4 +2793,36 @@ export const coins = CoinMap.fromCoins([
27932793
2,
27942794
UnderlyingAsset.GBP
27952795
),
2796+
fiat(
2797+
'414d69c3-8da1-460a-add3-ef26453fc76c',
2798+
'fiataed',
2799+
'United Arab Emirates Dirham',
2800+
Networks.main.fiat,
2801+
2,
2802+
UnderlyingAsset.AED
2803+
),
2804+
fiat(
2805+
'47f21e91-c2e0-4aaf-a0c8-e8bb3126688c',
2806+
'tfiataed',
2807+
'Testnet United Arab Emirates Dirham',
2808+
Networks.test.fiat,
2809+
2,
2810+
UnderlyingAsset.AED
2811+
),
2812+
fiat(
2813+
'd5f087f0-acc8-4cc3-aaff-dd7f183099db',
2814+
'fiatsgd',
2815+
'Singapore Dollar',
2816+
Networks.main.fiat,
2817+
2,
2818+
UnderlyingAsset.SGD
2819+
),
2820+
fiat(
2821+
'61c863bc-9e22-457c-b6f2-dcab35f32ff6',
2822+
'tfiatsgd',
2823+
'Testnet Singapore Dollar',
2824+
Networks.test.fiat,
2825+
2,
2826+
UnderlyingAsset.SGD
2827+
),
27962828
]);

modules/statics/test/unit/fixtures/expectedColdFeatures.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,20 @@ export const expectedColdFeatures = {
121121
neither: [
122122
'baseeth',
123123
'ethw',
124+
'fiataed',
124125
'fiateur',
125126
'fiatgbp',
127+
'fiatsgd',
126128
'fiatusd',
127129
'lnbtc',
128130
'susd',
129131
'tbaseeth',
130132
'tbtg',
131133
'teth',
134+
'tfiataed',
132135
'tfiateur',
133136
'tfiatgbp',
137+
'tfiatsgd',
134138
'tfiatusd',
135139
'tlnbtc',
136140
'tsusd',

0 commit comments

Comments
 (0)