Skip to content

Commit 702fe75

Browse files
committed
feat: added canton coin to statics
Ticket: COIN-5851
1 parent 14ff70e commit 702fe75

File tree

7 files changed

+131
-2
lines changed

7 files changed

+131
-2
lines changed

modules/bitgo/test/browser/browser.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ describe('Coins', () => {
5858
HashToken: 1,
5959
FlrToken: 1,
6060
JettonToken: 1,
61-
Canton: 1,
62-
TCanton: 1,
6361
};
6462
Object.keys(BitGoJS.Coin)
6563
.filter((coinName) => !excludedKeys[coinName])

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
import { ada } from './ada';
5353
import { avaxp } from './avaxp';
5454
import { BaseUnit, CoinFeature, KeyCurve, UnderlyingAsset } from './base';
55+
import { canton } from './canton';
5556
import { erc20Coins } from './coins/erc20Coins';
5657
import { avaxTokens } from './coins/avaxTokens';
5758
import { bscTokens } from './coins/bscTokens';
@@ -76,6 +77,7 @@ import {
7677
BERA_BGT_FEATURES,
7778
BERA_FEATURES,
7879
BSC_FEATURES,
80+
CANTON_FEATURES,
7981
CELO_FEATURES,
8082
COREDAO_FEATURES,
8183
COREUM_FEATURES,
@@ -2086,6 +2088,28 @@ export const allCoinsAndTokens = [
20862088
CoinFeature.EVM_COMPATIBLE_WP,
20872089
]
20882090
),
2091+
canton(
2092+
'07385320-5a4f-48e9-97a5-86d4be9f24b0',
2093+
'canton',
2094+
'Canton Coin',
2095+
Networks.main.canton,
2096+
UnderlyingAsset.CANTON,
2097+
CANTON_FEATURES,
2098+
'',
2099+
'CANTON',
2100+
KeyCurve.Ed25519
2101+
),
2102+
canton(
2103+
'f5d7f76b-fc5a-4da8-b1d0-a86ad0fd269e',
2104+
'tcanton',
2105+
'Testnet Canton Coin',
2106+
Networks.test.canton,
2107+
UnderlyingAsset.CANTON,
2108+
CANTON_FEATURES,
2109+
'',
2110+
'TCANTON',
2111+
KeyCurve.Ed25519
2112+
),
20892113
gasTankAccount(
20902114
'98071460-1488-4edd-857f-0899bc5eee4f',
20912115
'vet',

modules/statics/src/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export enum CoinFamily {
3939
BSV = 'bsv',
4040
BTC = 'btc',
4141
BTG = 'btg',
42+
CANTON = 'canton',
4243
CELO = 'celo',
4344
COREDAO = 'coredao',
4445
COREUM = 'coreum',
@@ -510,6 +511,7 @@ export enum UnderlyingAsset {
510511
BSV = 'bsv',
511512
BTC = 'btc',
512513
BTG = 'btg',
514+
CANTON = 'canton',
513515
DASH = 'dash',
514516
DOT = 'dot',
515517
CELO = 'celo', // Celo main coin
@@ -3276,6 +3278,7 @@ export enum BaseUnit {
32763278
VET = 'wei',
32773279
TCRONOS = 'basetcro',
32783280
TASI = 'atestfet',
3281+
CANTON = 'canton',
32793282
}
32803283

32813284
export interface BaseCoinConstructorOptions {

modules/statics/src/canton.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { BaseCoin, BaseUnit, CoinFeature, CoinKind, KeyCurve, UnderlyingAsset } from './base';
2+
import { CantonNetwork } from './networks';
3+
4+
export interface CantonConstructorOptions {
5+
id: string;
6+
fullName: string;
7+
name: string;
8+
network: CantonNetwork;
9+
features: CoinFeature[];
10+
asset: UnderlyingAsset;
11+
prefix?: string;
12+
suffix?: string;
13+
primaryKeyCurve: KeyCurve;
14+
}
15+
16+
export class Canton extends BaseCoin {
17+
public readonly network: CantonNetwork;
18+
19+
constructor(options: CantonConstructorOptions) {
20+
super({
21+
...options,
22+
kind: CoinKind.CRYPTO,
23+
isToken: false,
24+
decimalPlaces: 10,
25+
baseUnit: BaseUnit.CANTON,
26+
});
27+
this.network = options.network;
28+
}
29+
30+
protected disallowedFeatures(): Set<CoinFeature> {
31+
return new Set([CoinFeature.ACCOUNT_MODEL]);
32+
}
33+
34+
protected requiredFeatures(): Set<CoinFeature> {
35+
return new Set([CoinFeature.UNSPENT_MODEL]);
36+
}
37+
}
38+
39+
/**
40+
* Factory function for canton coin instances
41+
*
42+
* @param {String} id unique identifier (uuid v4)
43+
* @param {String} name unique identifier of the coin
44+
* @param {String} fullName complete human-readable name of the coin
45+
* @param {CantonNetwork} network network object for this coin
46+
* @param {UnderlyingAsset} asset asset which this coin represents. This is the same for both mainNet and testNet variants of a coin.
47+
* @param {CoinFeature[]} features features of this coin. Defaults to the CANTON_DEFAULT_FEATURES defined in `account`
48+
* @param {String} prefix optional coin prefix. Defaults to empty string
49+
* @param {String} suffix optional coin suffix. Defaults to coin name.
50+
* @param {KeyCurve} primaryKeyCurve the elliptic curve for this chain/token
51+
*/
52+
export function canton(
53+
id: string,
54+
name: string,
55+
fullName: string,
56+
network: CantonNetwork,
57+
asset: UnderlyingAsset,
58+
features: CoinFeature[],
59+
prefix = '',
60+
suffix: string = name.toUpperCase(),
61+
primaryKeyCurve: KeyCurve = KeyCurve.Ed25519
62+
): Readonly<Canton> {
63+
return Object.freeze(
64+
new Canton({
65+
id,
66+
name,
67+
fullName,
68+
network,
69+
prefix,
70+
suffix,
71+
features,
72+
asset,
73+
primaryKeyCurve,
74+
})
75+
);
76+
}

modules/statics/src/coinFeatures.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,15 @@ export const IOTA_FEATURES = [
660660
CoinFeature.ENTERPRISE_PAYS_FEES,
661661
CoinFeature.TSS_ENTERPRISE_PAYS_FEES,
662662
];
663+
664+
export const CANTON_DEFAULT_FEATURES = [
665+
CoinFeature.UNSPENT_MODEL,
666+
CoinFeature.TRANSACTION_DATA,
667+
CoinFeature.REQUIRES_BIG_NUMBER,
668+
CoinFeature.CUSTODY_BITGO_TRUST,
669+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
670+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
671+
CoinFeature.CUSTODY_BITGO_INDIA,
672+
];
673+
674+
export const CANTON_FEATURES = [...CANTON_DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD];

modules/statics/src/networks.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,18 @@ class PlumeTestnet extends Testnet implements EthereumNetwork {
19861986
nativeCoinOperationHashPrefix = '98867';
19871987
}
19881988

1989+
class Canton extends Mainnet implements BaseNetwork {
1990+
name = 'Canton';
1991+
family = CoinFamily.CANTON;
1992+
explorerUrl = '';
1993+
}
1994+
1995+
class CantonTestnet extends Testnet implements BaseNetwork {
1996+
name = 'CantonTestnet';
1997+
family = CoinFamily.CANTON;
1998+
explorerUrl = '';
1999+
}
2000+
19892001
export const Networks = {
19902002
main: {
19912003
ada: Object.freeze(new Ada()),
@@ -2006,6 +2018,7 @@ export const Networks = {
20062018
bera: Object.freeze(new Berachain()),
20072019
bld: Object.freeze(new Bld()),
20082020
bsc: Object.freeze(new BinanceSmartChain()),
2021+
canton: Object.freeze(new Canton()),
20092022
casper: Object.freeze(new Casper()),
20102023
celo: Object.freeze(new Celo()),
20112024
coredao: Object.freeze(new Coredao()),
@@ -2105,6 +2118,7 @@ export const Networks = {
21052118
bera: Object.freeze(new BerachainTestnet()),
21062119
bld: Object.freeze(new BldTestnet()),
21072120
bsc: Object.freeze(new BinanceSmartChainTestnet()),
2121+
canton: Object.freeze(new CantonTestnet()),
21082122
casper: Object.freeze(new CasperTestnet()),
21092123
coredao: Object.freeze(new CoredaoTestnet()),
21102124
celo: Object.freeze(new CeloTestnet()),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const expectedColdFeatures = {
6565
'baseeth',
6666
'bld',
6767
'bsc',
68+
'canton',
6869
'coredao',
6970
'coreum',
7071
'cronos',
@@ -120,6 +121,7 @@ export const expectedColdFeatures = {
120121
'tbaseeth',
121122
'tbld',
122123
'tbsc',
124+
'tcanton',
123125
'tcoredao',
124126
'tcoreum',
125127
'tcronos',

0 commit comments

Comments
 (0)