Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ import {
EthLikeCoin,
Flr,
TethLikeCoin,
FiatAED,
FiatEur,
FiatGBP,
FiatSGD,
FiatUsd,
Gteth,
Hash,
Expand Down Expand Up @@ -111,8 +113,10 @@ import {
Teth,
Teth2,
Tflr,
TfiatAED,
TfiatEur,
TfiatGBP,
TfiatSGD,
TfiatUsd,
Thash,
Thbar,
Expand Down Expand Up @@ -190,8 +194,10 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('ethw', Ethw.createInstance);
globalCoinFactory.register('baseeth', EthLikeCoin.createInstance);
globalCoinFactory.register('tbaseeth', TethLikeCoin.createInstance);
globalCoinFactory.register('fiataed', FiatAED.createInstance);
globalCoinFactory.register('fiateur', FiatEur.createInstance);
globalCoinFactory.register('fiatgbp', FiatGBP.createInstance);
globalCoinFactory.register('fiatsgd', FiatSGD.createInstance);
globalCoinFactory.register('fiatusd', FiatUsd.createInstance);
globalCoinFactory.register('flr', Flr.createInstance);
globalCoinFactory.register('gteth', Gteth.createInstance);
Expand Down Expand Up @@ -249,8 +255,10 @@ function registerCoinConstructors(globalCoinFactory: CoinFactory): void {
globalCoinFactory.register('tetc', Tetc.createInstance);
globalCoinFactory.register('teth', Teth.createInstance);
globalCoinFactory.register('teth2', Teth2.createInstance);
globalCoinFactory.register('tfiataed', TfiatAED.createInstance);
globalCoinFactory.register('tfiateur', TfiatEur.createInstance);
globalCoinFactory.register('tfiatgbp', TfiatGBP.createInstance);
globalCoinFactory.register('tfiatsgd', TfiatSGD.createInstance);
globalCoinFactory.register('tfiatusd', TfiatUsd.createInstance);
globalCoinFactory.register('tflr', Tflr.createInstance);
globalCoinFactory.register('thash', Thash.createInstance);
Expand Down
34 changes: 32 additions & 2 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,35 @@ export { Wemix, Twemix };
export { Zketh, Tzketh, ZkethToken };

import { coins } from '@bitgo/sdk-core';
const { Ofc, OfcToken, Susd, FiatUsd, FiatEur, FiatGBP, Tsusd, TfiatUsd, TfiatEur, TfiatGBP } = coins;
export { FiatEur, FiatGBP, FiatUsd, Ofc, OfcToken, Susd, TfiatEur, TfiatGBP, TfiatUsd, Tsusd };
const {
Ofc,
OfcToken,
Susd,
FiatUsd,
FiatEur,
FiatGBP,
FiatAED,
FiatSGD,
Tsusd,
TfiatUsd,
TfiatEur,
TfiatGBP,
TfiatAED,
TfiatSGD,
} = coins;
export {
FiatAED,
FiatEur,
FiatGBP,
FiatSGD,
FiatUsd,
Ofc,
OfcToken,
Susd,
TfiatAED,
TfiatEur,
TfiatGBP,
TfiatSGD,
TfiatUsd,
Tsusd,
};
76 changes: 76 additions & 0 deletions modules/sdk-core/src/coins/fiataed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @prettier
*/
import {
BaseCoin,
BitGoBase,
KeyPair,
MethodNotImplementedError,
ParsedTransaction,
ParseTransactionOptions,
SignedTransaction,
SignTransactionOptions,
VerifyAddressOptions,
VerifyTransactionOptions,
} from '../';

export class FiatAED extends BaseCoin {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easier to just create a new package for the fiat coins, abstract-fiat? And then each of these fiat coins can extend a common FiatBaseCoin class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably yes. I will create a ticket and look into this. We will be adding a lot more fiats in the future, but these two (and eur and gbp) are the only ones we will need for H1

static createInstance(bitgo: BitGoBase): BaseCoin {
return new FiatAED(bitgo);
}

/**
* Returns the factor between the base unit and its smallest subdivison
* @return {number}
*/
getBaseFactor() {
return 1e2;
}

getChain() {
return 'fiataed';
}

getFamily() {
return 'fiat';
}

getFullName() {
return 'United Arab Emirates Dirham';
}

/**
* Return whether the given m of n wallet signers/ key amounts are valid for the coin
*/
isValidMofNSetup({ m, n }: { m: number; n: number }) {
return m === 0 && n === 0;
}

isValidAddress(address: string): boolean {
throw new MethodNotImplementedError();
}

generateKeyPair(seed?: Buffer): KeyPair {
throw new MethodNotImplementedError();
}

isValidPub(pub: string): boolean {
throw new MethodNotImplementedError();
}

async parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
return {};
}

async isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
throw new MethodNotImplementedError();
}

async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
return true;
}

async signTransaction(params: SignTransactionOptions = {}): Promise<SignedTransaction> {
throw new MethodNotImplementedError();
}
}
76 changes: 76 additions & 0 deletions modules/sdk-core/src/coins/fiatsgd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @prettier
*/
import {
BaseCoin,
BitGoBase,
KeyPair,
MethodNotImplementedError,
ParsedTransaction,
ParseTransactionOptions,
SignedTransaction,
SignTransactionOptions,
VerifyAddressOptions,
VerifyTransactionOptions,
} from '..';

export class FiatSGD extends BaseCoin {
static createInstance(bitgo: BitGoBase): BaseCoin {
return new FiatSGD(bitgo);
}

/**
* Returns the factor between the base unit and its smallest subdivison
* @return {number}
*/
getBaseFactor() {
return 1e2;
}

getChain() {
return 'fiatsgd';
}

getFamily() {
return 'fiat';
}

getFullName() {
return 'Singapore Dollar';
}

/**
* Return whether the given m of n wallet signers/ key amounts are valid for the coin
*/
isValidMofNSetup({ m, n }: { m: number; n: number }) {
return m === 0 && n === 0;
}

isValidAddress(address: string): boolean {
throw new MethodNotImplementedError();
}

generateKeyPair(seed?: Buffer): KeyPair {
throw new MethodNotImplementedError();
}

isValidPub(pub: string): boolean {
throw new MethodNotImplementedError();
}

async parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
return {};
}

async isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
throw new MethodNotImplementedError();
}

async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
return true;
}

async signTransaction(params: SignTransactionOptions = {}): Promise<SignedTransaction> {
throw new MethodNotImplementedError();
}
}
4 changes: 4 additions & 0 deletions modules/sdk-core/src/coins/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export * from './fiataed';
export * from './tfiataed';
export * from './fiatsgd';
export * from './tfiatsgd';
export * from './fiateur';
export * from './tfiateur';
export * from './fiatgbp';
Expand Down
19 changes: 19 additions & 0 deletions modules/sdk-core/src/coins/tfiataed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @prettier
*/
import { BaseCoin, BitGoBase } from '../';
import { FiatAED } from './fiataed';

export class TfiatAED extends FiatAED {
static createInstance(bitgo: BitGoBase): BaseCoin {
return new TfiatAED(bitgo);
}

getChain() {
return 'tfiataed';
}

getFullName() {
return 'Testnet United Arab Emirates Dirham';
}
}
19 changes: 19 additions & 0 deletions modules/sdk-core/src/coins/tfiatsgd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @prettier
*/
import { BaseCoin, BitGoBase } from '../';
import { FiatSGD } from './fiatsgd';

export class TfiatSGD extends FiatSGD {
static createInstance(bitgo: BitGoBase): BaseCoin {
return new TfiatSGD(bitgo);
}

getChain() {
return 'tfiatsgd';
}

getFullName() {
return 'Testnet Singapore Dollar';
}
}
10 changes: 7 additions & 3 deletions modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,11 @@ export enum UnderlyingAsset {
ETC = 'etc',
EOS = 'eos',
ERD = 'erd',
EUR = 'eur',
EURCVV0 = 'eurcvv0',
EURCV = 'eurcv',
EUROC = 'euroc',
EURR = 'eurr',
FLR = 'flr',
GBP = 'gbp',
GTC = 'gtc',
HASH = 'hash', // Provenance
HBAR = 'hbar', // Hedera main coin
Expand All @@ -411,7 +409,6 @@ export enum UnderlyingAsset {
TIA = 'tia', // Celestia
TON = 'ton',
TRX = 'trx',
USD = 'usd',
WEMIX = 'wemix',
XLM = 'xlm',
XDC = 'xdc',
Expand Down Expand Up @@ -2505,6 +2502,13 @@ export enum UnderlyingAsset {
// Sip10 testnet tokens
'tstx:tsip6dp' = 'tstx:tsip6dp',
'tstx:tsip8dp' = 'tstx:tsip8dp',

// fiats
AED = 'aed',
EUR = 'eur',
GBP = 'gbp',
SGD = 'sgd',
USD = 'usd',
}

/**
Expand Down
32 changes: 32 additions & 0 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2793,4 +2793,36 @@ export const coins = CoinMap.fromCoins([
2,
UnderlyingAsset.GBP
),
fiat(
'414d69c3-8da1-460a-add3-ef26453fc76c',
'fiataed',
'United Arab Emirates Dirham',
Networks.main.fiat,
2,
UnderlyingAsset.AED
),
fiat(
'47f21e91-c2e0-4aaf-a0c8-e8bb3126688c',
'tfiataed',
'Testnet United Arab Emirates Dirham',
Networks.test.fiat,
2,
UnderlyingAsset.AED
),
fiat(
'd5f087f0-acc8-4cc3-aaff-dd7f183099db',
'fiatsgd',
'Singapore Dollar',
Networks.main.fiat,
2,
UnderlyingAsset.SGD
),
fiat(
'61c863bc-9e22-457c-b6f2-dcab35f32ff6',
'tfiatsgd',
'Testnet Singapore Dollar',
Networks.test.fiat,
2,
UnderlyingAsset.SGD
),
]);
4 changes: 4 additions & 0 deletions modules/statics/test/unit/fixtures/expectedColdFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,20 @@ export const expectedColdFeatures = {
neither: [
'baseeth',
'ethw',
'fiataed',
'fiateur',
'fiatgbp',
'fiatsgd',
'fiatusd',
'lnbtc',
'susd',
'tbaseeth',
'tbtg',
'teth',
'tfiataed',
'tfiateur',
'tfiatgbp',
'tfiatsgd',
'tfiatusd',
'tlnbtc',
'tsusd',
Expand Down