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
2 changes: 1 addition & 1 deletion modules/sdk-coin-canton/src/canton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class Canton extends BaseCoin {

/** @inheritDoc */
auditDecryptedKey({ multiSigType, prv, publicKey }: AuditDecryptedKeyParams): void {
if (multiSigType !== 'tss') {
if (multiSigType !== multisigTypes.tss) {
throw new Error('Unsupported multiSigType');
}
auditEddsaPrivateKey(prv, publicKey ?? '');
Expand Down
20 changes: 20 additions & 0 deletions modules/statics/src/allCoinsAndTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
import { ada } from './ada';
import { avaxp } from './avaxp';
import { BaseUnit, CoinFeature, KeyCurve, UnderlyingAsset } from './base';
import { canton } from './canton';
import { erc20Coins } from './coins/erc20Coins';
import { avaxTokens } from './coins/avaxTokens';
import { bscTokens } from './coins/bscTokens';
Expand All @@ -76,6 +77,7 @@ import {
BERA_BGT_FEATURES,
BERA_FEATURES,
BSC_FEATURES,
CANTON_FEATURES,
CELO_FEATURES,
COREDAO_FEATURES,
COREUM_FEATURES,
Expand Down Expand Up @@ -2084,6 +2086,24 @@ export const allCoinsAndTokens = [
CoinFeature.EVM_COMPATIBLE_WP,
]
),
canton(
'07385320-5a4f-48e9-97a5-86d4be9f24b0',
'canton',
'Canton Coin',
Networks.main.canton,
UnderlyingAsset.CANTON,
CANTON_FEATURES,
KeyCurve.Ed25519
),
canton(
'f5d7f76b-fc5a-4da8-b1d0-a86ad0fd269e',
'tcanton',
'Testnet Canton Coin',
Networks.test.canton,
UnderlyingAsset.CANTON,
CANTON_FEATURES,
KeyCurve.Ed25519
),
gasTankAccount(
'98071460-1488-4edd-857f-0899bc5eee4f',
'vet',
Expand Down
3 changes: 3 additions & 0 deletions modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum CoinFamily {
BSV = 'bsv',
BTC = 'btc',
BTG = 'btg',
CANTON = 'canton',
CELO = 'celo',
COREDAO = 'coredao',
COREUM = 'coreum',
Expand Down Expand Up @@ -510,6 +511,7 @@ export enum UnderlyingAsset {
BSV = 'bsv',
BTC = 'btc',
BTG = 'btg',
CANTON = 'canton',
DASH = 'dash',
DOT = 'dot',
CELO = 'celo', // Celo main coin
Expand Down Expand Up @@ -3288,6 +3290,7 @@ export enum BaseUnit {
VET = 'wei',
TCRONOS = 'basetcro',
TASI = 'atestfet',
CANTON = 'canton',
}

export interface BaseCoinConstructorOptions {
Expand Down
68 changes: 68 additions & 0 deletions modules/statics/src/canton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { BaseCoin, BaseUnit, CoinFeature, CoinKind, KeyCurve, UnderlyingAsset } from './base';
import { BaseNetwork } from './networks';

export interface CantonConstructorOptions {
id: string;
fullName: string;
name: string;
network: BaseNetwork;
features: CoinFeature[];
asset: UnderlyingAsset;
primaryKeyCurve: KeyCurve;
}

export class Canton extends BaseCoin {
public readonly network: BaseNetwork;

constructor(options: CantonConstructorOptions) {
super({
...options,
kind: CoinKind.CRYPTO,
isToken: false,
decimalPlaces: 10,
baseUnit: BaseUnit.CANTON,
});
this.network = options.network;
}

protected disallowedFeatures(): Set<CoinFeature> {
return new Set([CoinFeature.ACCOUNT_MODEL]);
}

protected requiredFeatures(): Set<CoinFeature> {
return new Set([CoinFeature.UNSPENT_MODEL]);
}
}

/**
* Factory function for canton coin instances
*
* @param {String} id unique identifier (uuid v4)
* @param {String} name unique identifier of the coin
* @param {String} fullName complete human-readable name of the coin
* @param {BaseNetwork} network network object for this coin
* @param {UnderlyingAsset} asset asset which this coin represents. This is the same for both mainNet and testNet variants of a coin.
* @param {CoinFeature[]} features features of this coin. Defaults to the CANTON_DEFAULT_FEATURES defined in `account`
* @param {KeyCurve} primaryKeyCurve the elliptic curve for this chain/token
*/
export function canton(
id: string,
name: string,
fullName: string,
network: BaseNetwork,
asset: UnderlyingAsset,
features: CoinFeature[],
primaryKeyCurve: KeyCurve = KeyCurve.Ed25519
): Readonly<Canton> {
return Object.freeze(
new Canton({
id,
name,
fullName,
network,
features,
asset,
primaryKeyCurve,
})
);
}
9 changes: 9 additions & 0 deletions modules/statics/src/coinFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,3 +660,12 @@ export const IOTA_FEATURES = [
CoinFeature.ENTERPRISE_PAYS_FEES,
CoinFeature.TSS_ENTERPRISE_PAYS_FEES,
];

// TODO: https://bitgoinc.atlassian.net/browse/COIN-5870
export const CANTON_FEATURES = [
CoinFeature.UNSPENT_MODEL,
CoinFeature.TRANSACTION_DATA,
CoinFeature.REQUIRES_BIG_NUMBER,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
];
14 changes: 14 additions & 0 deletions modules/statics/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,18 @@ class PlumeTestnet extends Testnet implements EthereumNetwork {
nativeCoinOperationHashPrefix = '98867';
}

class Canton extends Mainnet implements BaseNetwork {
name = 'Canton';
family = CoinFamily.CANTON;
explorerUrl = '';
}

class CantonTestnet extends Testnet implements BaseNetwork {
name = 'CantonTestnet';
family = CoinFamily.CANTON;
explorerUrl = '';
}

export const Networks = {
main: {
ada: Object.freeze(new Ada()),
Expand All @@ -2006,6 +2018,7 @@ export const Networks = {
bera: Object.freeze(new Berachain()),
bld: Object.freeze(new Bld()),
bsc: Object.freeze(new BinanceSmartChain()),
canton: Object.freeze(new Canton()),
casper: Object.freeze(new Casper()),
celo: Object.freeze(new Celo()),
coredao: Object.freeze(new Coredao()),
Expand Down Expand Up @@ -2105,6 +2118,7 @@ export const Networks = {
bera: Object.freeze(new BerachainTestnet()),
bld: Object.freeze(new BldTestnet()),
bsc: Object.freeze(new BinanceSmartChainTestnet()),
canton: Object.freeze(new CantonTestnet()),
casper: Object.freeze(new CasperTestnet()),
coredao: Object.freeze(new CoredaoTestnet()),
celo: Object.freeze(new CeloTestnet()),
Expand Down
2 changes: 1 addition & 1 deletion modules/statics/test/unit/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
reducedAmsTokenConfig,
reducedTokenConfigForAllChains,
} from './resources/amsTokenConfig';
import { Networks } from '../../src/networks';

interface DuplicateCoinObject {
name: string;
Expand Down Expand Up @@ -884,6 +883,7 @@ coins.forEach((coin, coinName) => {
const coinSupportsCustody =
coin.family !== CoinFamily.LNBTC &&
coin.family !== CoinFamily.CELO &&
coin.family !== CoinFamily.CANTON &&
coin.name !== 'ofccelo' &&
coin.name !== 'ofctcelo';
coin.features.includes(CoinFeature.CUSTODY).should.eql(coinSupportsCustody);
Expand Down
2 changes: 2 additions & 0 deletions modules/statics/test/unit/fixtures/expectedColdFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const expectedColdFeatures = {
'baseeth',
'bld',
'bsc',
'canton',
'coredao',
'coreum',
'cronos',
Expand Down Expand Up @@ -120,6 +121,7 @@ export const expectedColdFeatures = {
'tbaseeth',
'tbld',
'tbsc',
'tcanton',
'tcoredao',
'tcoreum',
'tcronos',
Expand Down