Skip to content

Commit 612ae7d

Browse files
mohd-kashifmanojkumar138
authored andcommitted
feat(statics): add Kaspa to statics and environments
- Add KaspaCoin class and kaspa() factory function in statics/src/kaspa.ts - Add CoinFamily.KASPA, UnderlyingAsset.KASPA, BaseUnit.KASPA (sompi) to base.ts - Add KaspaMainnet + KaspaTestnet network classes and Networks entries in networks.ts - Add kaspa/tkaspa coin entries with UUIDs to allCoinsAndTokens.ts - Export KaspaCoin from statics/src/index.ts - Add kaspa/tkaspa to expectedColdFeatures.ts (justTSS — ECDSA TSS support) - Add kaspaNodeUrl to EnvironmentTemplate interface and mainnet/testnet bases in environments.ts Jira: CECHO-388
1 parent 863f1fe commit 612ae7d

7 files changed

Lines changed: 118 additions & 0 deletions

File tree

modules/sdk-core/src/bitgo/environments.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ interface EnvironmentTemplate {
7777
sgbExplorerBaseUrl?: string;
7878
sgbExplorerApiToken?: string;
7979
icpNodeUrl: string;
80+
kaspaNodeUrl: string;
8081
hyperLiquidNodeUrl: string;
8182
wemixExplorerBaseUrl?: string;
8283
wemixExplorerApiToken?: string;
@@ -358,6 +359,7 @@ const mainnetBase: EnvironmentTemplate = {
358359
},
359360
},
360361
icpNodeUrl: 'https://ic0.app',
362+
kaspaNodeUrl: 'https://api.kaspa.org',
361363
hyperLiquidNodeUrl: 'https://api.hyperliquid.xyz',
362364
worldExplorerBaseUrl: 'https://worldscan.org/',
363365
somniaExplorerBaseUrl: 'https://mainnet.somnia.w3us.site/',
@@ -436,6 +438,7 @@ const testnetBase: EnvironmentTemplate = {
436438
xdcExplorerBaseUrl: 'https://api.etherscan.io/v2',
437439
sgbExplorerBaseUrl: 'https://coston-explorer.flare.network',
438440
icpNodeUrl: 'https://ic0.app',
441+
kaspaNodeUrl: 'https://api-tn10.kaspa.org',
439442
hyperLiquidNodeUrl: 'https://api.hyperliquid-testnet.xyz',
440443
monExplorerBaseUrl: 'https://api.etherscan.io/v2',
441444
worldExplorerBaseUrl: 'https://sepolia.worldscan.org/',

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { polyxTokens } from './coins/polyxTokens';
7676
import { cantonTokens } from './coins/cantonTokens';
7777
import { flrp } from './flrp';
7878
import { hypeEvm } from './hypeevm';
79+
import { kaspa } from './kaspa';
7980
import {
8081
ACCOUNT_COIN_DEFAULT_FEATURES_EXCLUDE_SINGAPORE_AND_MENA_FZE,
8182
ADA_FEATURES,
@@ -187,6 +188,8 @@ export const allCoinsAndTokens = [
187188
Networks.test.flrP,
188189
UnderlyingAsset.FLRP
189190
),
191+
kaspa('3eebd6e4-b30a-4b37-819d-1e189372b5c9', 'kaspa', 'Kaspa', Networks.main.kaspa, UnderlyingAsset.KASPA),
192+
kaspa('96b7ccfb-6130-43b2-a324-783f86752b94', 'tkaspa', 'Testnet Kaspa', Networks.test.kaspa, UnderlyingAsset.KASPA),
190193
ada(
191194
'fd4d125e-f14f-414b-bd17-6cb1393265f0',
192195
'ada',

modules/statics/src/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export enum CoinFamily {
8080
ISLM = 'islm',
8181
JOVAYETH = 'jovayeth',
8282
KAIA = 'kaia',
83+
KASPA = 'kaspa',
8384
KAVACOSMOS = 'kavacosmos',
8485
KAVAEVM = 'kavaevm',
8586
LNBTC = 'lnbtc',
@@ -1323,6 +1324,7 @@ export enum UnderlyingAsset {
13231324
KARATE = 'karate',
13241325
KARMA = 'karma',
13251326
KAS = 'kas',
1327+
KASPA = 'kaspa',
13261328
KCASH = 'kcash',
13271329
KCS = 'kcs',
13281330
KEEP = 'keep',
@@ -3853,6 +3855,7 @@ export enum BaseUnit {
38533855
TCRONOS = 'basetcro',
38543856
TASI = 'atestfet',
38553857
CANTON = 'canton',
3858+
KASPA = 'sompi',
38563859
USDC = 'usdc',
38573860
}
38583861

modules/statics/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * from './coins';
33
export * from './networks';
44
export * from './errors';
55
export * from './tokenConfig';
6+
export { KaspaCoin } from './kaspa';
67
export { OfcCoin } from './ofc';
78
export { UtxoCoin } from './utxo';
89
export { LightningCoin } from './lightning';

modules/statics/src/kaspa.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { BaseCoin, BaseUnit, CoinFeature, CoinKind, KeyCurve, UnderlyingAsset } from './base';
2+
import { KaspaMainnet, KaspaTestnet } from './networks';
3+
4+
export interface KaspaConstructorOptions {
5+
id: string;
6+
fullName: string;
7+
name: string;
8+
network: KaspaMainnet | KaspaTestnet;
9+
features: CoinFeature[];
10+
asset: UnderlyingAsset;
11+
prefix?: string;
12+
suffix?: string;
13+
primaryKeyCurve: KeyCurve;
14+
}
15+
16+
export class KaspaCoin extends BaseCoin {
17+
public static readonly DEFAULT_FEATURES = [
18+
CoinFeature.UNSPENT_MODEL,
19+
CoinFeature.TSS,
20+
CoinFeature.TSS_COLD,
21+
CoinFeature.CUSTODY,
22+
CoinFeature.CUSTODY_BITGO_TRUST,
23+
CoinFeature.CUSTODY_BITGO_INDIA,
24+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
25+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
26+
CoinFeature.CUSTODY_BITGO_GERMANY,
27+
CoinFeature.CUSTODY_BITGO_FRANKFURT,
28+
];
29+
30+
public readonly network: KaspaMainnet | KaspaTestnet;
31+
32+
constructor(options: KaspaConstructorOptions) {
33+
super({
34+
...options,
35+
kind: CoinKind.CRYPTO,
36+
isToken: false,
37+
decimalPlaces: 8,
38+
baseUnit: BaseUnit.KASPA,
39+
});
40+
41+
this.network = options.network;
42+
}
43+
44+
protected disallowedFeatures(): Set<CoinFeature> {
45+
return new Set([CoinFeature.ACCOUNT_MODEL]);
46+
}
47+
48+
protected requiredFeatures(): Set<CoinFeature> {
49+
return new Set([CoinFeature.UNSPENT_MODEL]);
50+
}
51+
}
52+
53+
/**
54+
* Factory function for Kaspa coin instances.
55+
*
56+
* @param id uuid v4
57+
* @param name unique identifier of the coin
58+
* @param fullName Complete human-readable name of the coin
59+
* @param network Network object for this coin
60+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
61+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `KaspaCoin`
62+
* @param prefix? Optional coin prefix. Defaults to empty string
63+
* @param suffix? Optional coin suffix. Defaults to coin name.
64+
* @param primaryKeyCurve The elliptic curve for this chain/token
65+
*/
66+
export function kaspa(
67+
id: string,
68+
name: string,
69+
fullName: string,
70+
network: KaspaMainnet | KaspaTestnet,
71+
asset: UnderlyingAsset,
72+
features: CoinFeature[] = KaspaCoin.DEFAULT_FEATURES,
73+
prefix = '',
74+
suffix: string = name.toUpperCase(),
75+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
76+
) {
77+
return Object.freeze(
78+
new KaspaCoin({
79+
id,
80+
name,
81+
fullName,
82+
network,
83+
prefix,
84+
suffix,
85+
features,
86+
asset,
87+
primaryKeyCurve,
88+
})
89+
);
90+
}

modules/statics/src/networks.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,20 @@ class IcpTestnet extends Testnet implements AccountNetwork {
268268
accountExplorerUrl = 'https://dashboard.internetcomputer.org/account/';
269269
}
270270

271+
export class KaspaMainnet extends Mainnet implements AccountNetwork {
272+
name = 'Kaspa';
273+
family = CoinFamily.KASPA;
274+
explorerUrl = 'https://explorer.kaspa.org/txs/';
275+
accountExplorerUrl = 'https://explorer.kaspa.org/addresses/';
276+
}
277+
278+
export class KaspaTestnet extends Testnet implements AccountNetwork {
279+
name = 'Testnet Kaspa';
280+
family = CoinFamily.KASPA;
281+
explorerUrl = 'https://explorer-tn10.kaspa.org/txs/';
282+
accountExplorerUrl = 'https://explorer-tn10.kaspa.org/addresses/';
283+
}
284+
271285
class Arbitrum extends Mainnet implements EthereumNetwork {
272286
name = 'Arbitrum';
273287
family = CoinFamily.ARBETH;
@@ -2762,6 +2776,7 @@ export const Networks = {
27622776
islm: Object.freeze(new Islm()),
27632777
jovayeth: Object.freeze(new JovayETH()),
27642778
kaia: Object.freeze(new Kaia()),
2779+
kaspa: Object.freeze(new KaspaMainnet()),
27652780
kavacosmos: Object.freeze(new KavaCosmos()),
27662781
kavaevm: Object.freeze(new KavaEVM()),
27672782
lnbtc: Object.freeze(new LightningBitcoin()),
@@ -2888,6 +2903,7 @@ export const Networks = {
28882903
irys: Object.freeze(new IrysTestnet()),
28892904
islm: Object.freeze(new IslmTestnet()),
28902905
jovayeth: Object.freeze(new JovayETHTestnet()),
2906+
kaspa: Object.freeze(new KaspaTestnet()),
28912907
kavacosmos: Object.freeze(new KavaCosmosTestnet()),
28922908
kavaevm: Object.freeze(new KavaEVMTestnet()),
28932909
kovan: Object.freeze(new Kovan()),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const expectedColdFeatures = {
112112
'injective',
113113
'jovayeth',
114114
'kaia',
115+
'kaspa',
115116
'kavacosmos',
116117
'megaeth',
117118
'mantle',
@@ -205,6 +206,7 @@ export const expectedColdFeatures = {
205206
'tinjective',
206207
'tiota',
207208
'tkaia',
209+
'tkaspa',
208210
'tkavacosmos',
209211
'tmantle',
210212
'tmantra',

0 commit comments

Comments
 (0)