Skip to content

Commit eca6c0e

Browse files
committed
feat: added canton coin to statics
Ticket: COIN-5851
1 parent a974bb1 commit eca6c0e

File tree

8 files changed

+118
-2
lines changed

8 files changed

+118
-2
lines changed

modules/sdk-coin-canton/src/canton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class Canton extends BaseCoin {
104104

105105
/** @inheritDoc */
106106
auditDecryptedKey({ multiSigType, prv, publicKey }: AuditDecryptedKeyParams): void {
107-
if (multiSigType !== 'tss') {
107+
if (multiSigType !== multisigTypes.tss) {
108108
throw new Error('Unsupported multiSigType');
109109
}
110110
auditEddsaPrivateKey(prv, publicKey ?? '');

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 20 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,24 @@ 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+
KeyCurve.Ed25519
2099+
),
2100+
canton(
2101+
'f5d7f76b-fc5a-4da8-b1d0-a86ad0fd269e',
2102+
'tcanton',
2103+
'Testnet Canton Coin',
2104+
Networks.test.canton,
2105+
UnderlyingAsset.CANTON,
2106+
CANTON_FEATURES,
2107+
KeyCurve.Ed25519
2108+
),
20892109
gasTankAccount(
20902110
'98071460-1488-4edd-857f-0899bc5eee4f',
20912111
'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
@@ -3288,6 +3290,7 @@ export enum BaseUnit {
32883290
VET = 'wei',
32893291
TCRONOS = 'basetcro',
32903292
TASI = 'atestfet',
3293+
CANTON = 'canton',
32913294
}
32923295

32933296
export interface BaseCoinConstructorOptions {

modules/statics/src/canton.ts

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

modules/statics/src/coinFeatures.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,12 @@ export const IOTA_FEATURES = [
660660
CoinFeature.ENTERPRISE_PAYS_FEES,
661661
CoinFeature.TSS_ENTERPRISE_PAYS_FEES,
662662
];
663+
664+
// TODO: https://bitgoinc.atlassian.net/browse/COIN-5870
665+
export const CANTON_FEATURES = [
666+
CoinFeature.UNSPENT_MODEL,
667+
CoinFeature.TRANSACTION_DATA,
668+
CoinFeature.REQUIRES_BIG_NUMBER,
669+
CoinFeature.TSS,
670+
CoinFeature.TSS_COLD,
671+
];

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/coins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
reducedAmsTokenConfig,
3636
reducedTokenConfigForAllChains,
3737
} from './resources/amsTokenConfig';
38-
import { Networks } from '../../src/networks';
3938

4039
interface DuplicateCoinObject {
4140
name: string;
@@ -86,6 +85,7 @@ const custodyFeatures: Record<string, { features: CoinFeature[] }> = {
8685
],
8786
},
8887
btg: { features: [CoinFeature.CUSTODY_BITGO_GERMANY, CoinFeature.CUSTODY_BITGO_FRANKFURT] },
88+
canton: { features: [CoinFeature.CUSTODY_BITGO_TRUST] },
8989
cspr: {
9090
features: [
9191
CoinFeature.CUSTODY_BITGO_GERMANY,

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)