Skip to content

Commit 830f2ac

Browse files
authored
Merge pull request #8012 from BitGo/FIAT-1195
feat: add INR
2 parents 9c021b1 + 3873880 commit 830f2ac

10 files changed

Lines changed: 136 additions & 0 deletions

File tree

modules/bitgo/src/v2/coinFactory.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import {
9494
FiatAED,
9595
FiatEur,
9696
FiatGBP,
97+
FiatINR,
9798
FiatSGD,
9899
FiatUsd,
99100
Gteth,
@@ -173,6 +174,7 @@ import {
173174
TfiatAED,
174175
TfiatEur,
175176
TfiatGBP,
177+
TfiatINR,
176178
TfiatSGD,
177179
TfiatUsd,
178180
Thash,
@@ -275,6 +277,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
275277
coinFactory.register('fiataed', FiatAED.createInstance);
276278
coinFactory.register('fiateur', FiatEur.createInstance);
277279
coinFactory.register('fiatgbp', FiatGBP.createInstance);
280+
coinFactory.register('fiatinr', FiatINR.createInstance);
278281
coinFactory.register('fiatsgd', FiatSGD.createInstance);
279282
coinFactory.register('fiatusd', FiatUsd.createInstance);
280283
coinFactory.register('flr', Flr.createInstance);
@@ -346,6 +349,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
346349
coinFactory.register('tfiataed', TfiatAED.createInstance);
347350
coinFactory.register('tfiateur', TfiatEur.createInstance);
348351
coinFactory.register('tfiatgbp', TfiatGBP.createInstance);
352+
coinFactory.register('tfiatinr', TfiatINR.createInstance);
349353
coinFactory.register('tfiatsgd', TfiatSGD.createInstance);
350354
coinFactory.register('tfiatusd', TfiatUsd.createInstance);
351355
coinFactory.register('tflr', Tflr.createInstance);
@@ -695,6 +699,8 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine
695699
return FiatEur.createInstance;
696700
case 'fiatgbp':
697701
return FiatGBP.createInstance;
702+
case 'fiatinr':
703+
return FiatINR.createInstance;
698704
case 'fiatsgd':
699705
return FiatSGD.createInstance;
700706
case 'fiatusd':
@@ -837,6 +843,8 @@ export function getCoinConstructor(coinName: string): CoinConstructor | undefine
837843
return TfiatEur.createInstance;
838844
case 'tfiatgbp':
839845
return TfiatGBP.createInstance;
846+
case 'tfiatinr':
847+
return TfiatINR.createInstance;
840848
case 'tfiatsgd':
841849
return TfiatSGD.createInstance;
842850
case 'tfiatusd':

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,22 @@ const {
162162
FiatUsd,
163163
FiatEur,
164164
FiatGBP,
165+
FiatINR,
165166
FiatAED,
166167
FiatSGD,
167168
Tsusd,
168169
TfiatUsd,
169170
TfiatEur,
170171
TfiatGBP,
172+
TfiatINR,
171173
TfiatAED,
172174
TfiatSGD,
173175
} = coins;
174176
export {
175177
FiatAED,
176178
FiatEur,
177179
FiatGBP,
180+
FiatINR,
178181
FiatSGD,
179182
FiatUsd,
180183
Ofc,
@@ -183,6 +186,7 @@ export {
183186
TfiatAED,
184187
TfiatEur,
185188
TfiatGBP,
189+
TfiatINR,
186190
TfiatSGD,
187191
TfiatUsd,
188192
Tsusd,

modules/bitgo/test/v2/unit/coins/ofcToken.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ describe('OFC:', function () {
4040
tgbp.getBaseFactor().should.equal(PRECISION_2);
4141
});
4242

43+
it('test fiat constants for OFCTINR', function () {
44+
const tgbp = bitgo.coin('ofctinr');
45+
tgbp.getChain().should.equal('ofctinr');
46+
tgbp.getFullName().should.equal('Test Indian Rupee');
47+
tgbp.getBaseFactor().should.equal(PRECISION_2);
48+
});
49+
4350
it('test crypto coins for ofctbtc', function () {
4451
const tbtc = bitgo.coin('ofctbtc');
4552
tbtc.getChain().should.equal('ofctbtc');
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* @prettier
3+
*/
4+
import {
5+
AuditDecryptedKeyParams,
6+
BaseCoin,
7+
BitGoBase,
8+
KeyPair,
9+
MethodNotImplementedError,
10+
ParsedTransaction,
11+
ParseTransactionOptions,
12+
SignedTransaction,
13+
SignTransactionOptions,
14+
VerifyAddressOptions,
15+
VerifyTransactionOptions,
16+
} from '../';
17+
18+
export class FiatINR extends BaseCoin {
19+
static createInstance(bitgo: BitGoBase): BaseCoin {
20+
return new FiatINR(bitgo);
21+
}
22+
23+
/**
24+
* Returns the factor between the base unit and its smallest subdivison
25+
* @return {number}
26+
*/
27+
getBaseFactor() {
28+
return 1e2;
29+
}
30+
31+
getChain() {
32+
return 'fiatinr';
33+
}
34+
35+
getFamily() {
36+
return 'fiat';
37+
}
38+
39+
getFullName() {
40+
return 'Indian Rupee';
41+
}
42+
43+
/**
44+
* Return whether the given m of n wallet signers/ key amounts are valid for the coin
45+
*/
46+
isValidMofNSetup({ m, n }: { m: number; n: number }) {
47+
return m === 0 && n === 0;
48+
}
49+
50+
isValidAddress(address: string): boolean {
51+
throw new MethodNotImplementedError();
52+
}
53+
54+
generateKeyPair(seed?: Buffer): KeyPair {
55+
throw new MethodNotImplementedError();
56+
}
57+
58+
isValidPub(pub: string): boolean {
59+
throw new MethodNotImplementedError();
60+
}
61+
62+
async parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
63+
return {};
64+
}
65+
66+
async isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
67+
throw new MethodNotImplementedError();
68+
}
69+
70+
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
71+
return true;
72+
}
73+
74+
async signTransaction(params: SignTransactionOptions = {}): Promise<SignedTransaction> {
75+
throw new MethodNotImplementedError();
76+
}
77+
78+
/** @inheritDoc */
79+
auditDecryptedKey(params: AuditDecryptedKeyParams): void {
80+
throw new MethodNotImplementedError();
81+
}
82+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export * from './fiateur';
66
export * from './tfiateur';
77
export * from './fiatgbp';
88
export * from './tfiatgbp';
9+
export * from './fiatinr';
10+
export * from './tfiatinr';
911
export * from './fiatusd';
1012
export * from './tfiatusd';
1113
export * from './ofc';
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 { FiatINR } from './fiatinr';
6+
7+
export class TfiatINR extends FiatINR {
8+
static createInstance(bitgo: BitGoBase): BaseCoin {
9+
return new TfiatINR(bitgo);
10+
}
11+
12+
getChain() {
13+
return 'tfiatinr';
14+
}
15+
16+
getFullName() {
17+
return 'Testnet Indian Rupee';
18+
}
19+
}

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6159,6 +6159,15 @@ export const allCoinsAndTokens = [
61596159
2,
61606160
UnderlyingAsset.GBP
61616161
),
6162+
fiat('4d8c6e0e-08c4-4767-9e3b-8bc5bb78c5b5', 'fiatinr', 'Indian Rupee', Networks.main.fiat, 2, UnderlyingAsset.INR),
6163+
fiat(
6164+
'5455f07e-0b96-4e8e-a651-d68f1f13d9ce',
6165+
'tfiatinr',
6166+
'Testnet Indian Rupee',
6167+
Networks.test.fiat,
6168+
2,
6169+
UnderlyingAsset.INR
6170+
),
61626171
fiat(
61636172
'414d69c3-8da1-460a-add3-ef26453fc76c',
61646173
'fiataed',

modules/statics/src/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,7 @@ export enum UnderlyingAsset {
35583558
AED = 'aed',
35593559
EUR = 'eur',
35603560
GBP = 'gbp',
3561+
INR = 'inr',
35613562
SGD = 'sgd',
35623563
USD = 'usd',
35633564
}

modules/statics/src/coins/ofcCoins.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const ofcCoins = [
5454
ofc('837f0cab-cad1-4510-a8e4-f2c60e1a8760', 'ofcusd', 'USD', 2, UnderlyingAsset.USD, CoinKind.FIAT),
5555
ofc('798f2a7c-23fd-4e16-9fe5-6bf47ca438a0', 'ofceur', 'Euro', 2, UnderlyingAsset.EUR, CoinKind.FIAT),
5656
ofc('f37bbb72-adfe-4d06-90dc-afd0aa34aadd', 'ofcgbp', 'Pound Sterling', 2, UnderlyingAsset.GBP, CoinKind.FIAT),
57+
ofc('5d6ec3ce-b06f-4233-ad8c-27860e2d3cf9', 'ofcinr', 'Indian Rupee', 2, UnderlyingAsset.INR, CoinKind.FIAT),
5758
ofc('60778b32-3497-4e45-895a-3f0bd3a2f475', 'ofcsgd', 'Singapore Dollar', 2, UnderlyingAsset.SGD, CoinKind.FIAT),
5859
ofc(
5960
'fe742061-8838-4b32-ab64-d328ca587feb',
@@ -517,6 +518,7 @@ export const ofcCoins = [
517518
UnderlyingAsset.GBP,
518519
CoinKind.FIAT
519520
),
521+
tofc('874e72f2-dab0-4d99-825c-f94c94cece65', 'ofctinr', 'Test Indian Rupee', 2, UnderlyingAsset.INR, CoinKind.FIAT),
520522
tofc('e5e9dedb-4d72-4a44-a84c-32f46d275bdc', 'ofctcspr', 'Test Casper', 9, UnderlyingAsset.CSPR, CoinKind.CRYPTO),
521523
tofc('b84e3f27-e521-4093-9616-fc92ba352cd9', 'ofctnear', 'Test Near', 24, UnderlyingAsset.NEAR, CoinKind.CRYPTO),
522524
tofc('457d1c4e-5bf7-442a-90c9-dfd590f30925', 'ofctbtc', 'Test Bitcoin', 8, UnderlyingAsset.BTC, CoinKind.CRYPTO),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export const expectedColdFeatures = {
219219
'fiataed',
220220
'fiateur',
221221
'fiatgbp',
222+
'fiatinr',
222223
'fiatsgd',
223224
'fiatusd',
224225
'lnbtc',
@@ -228,6 +229,7 @@ export const expectedColdFeatures = {
228229
'tfiataed',
229230
'tfiateur',
230231
'tfiatgbp',
232+
'tfiatinr',
231233
'tfiatsgd',
232234
'tfiatusd',
233235
'tlnbtc',

0 commit comments

Comments
 (0)