-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathcantonToken.ts
More file actions
69 lines (54 loc) · 1.78 KB
/
cantonToken.ts
File metadata and controls
69 lines (54 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core';
import { coins, CantonTokenConfig, NetworkType, tokens } from '@bitgo/statics';
import { Canton } from './canton';
export class CantonToken extends Canton {
public readonly tokenConfig: CantonTokenConfig;
constructor(bitgo: BitGoBase, tokenConfig: CantonTokenConfig) {
const staticsCoin = tokenConfig.network === NetworkType.MAINNET ? coins.get('canton') : coins.get('tcanton');
super(bitgo, staticsCoin);
this.tokenConfig = tokenConfig;
}
static createTokenConstructor(config: CantonTokenConfig): CoinConstructor {
return (bitgo: BitGoBase) => new CantonToken(bitgo, config);
}
static createTokenConstructors(
tokenConfig: CantonTokenConfig[] = [...tokens.bitcoin.canton.tokens, ...tokens.testnet.canton.tokens]
): NamedCoinConstructor[] {
const tokensCtors: NamedCoinConstructor[] = [];
for (const token of tokenConfig) {
const tokenConstructor = CantonToken.createTokenConstructor(token);
tokensCtors.push({ name: token.type, coinConstructor: tokenConstructor });
}
return tokensCtors;
}
get name(): string {
return this.tokenConfig.name;
}
get coin(): string {
return this.tokenConfig.coin;
}
get baseUrl(): string {
return this.tokenConfig.baseUrl;
}
get admin(): string {
return this.tokenConfig.admin;
}
get assetName(): string {
return this.tokenConfig.assetName;
}
get decimalPlaces(): number {
return this.tokenConfig.decimalPlaces;
}
getChain(): string {
return this.tokenConfig.type;
}
getBaseChain(): string {
return this.coin;
}
getFullName(): string {
return 'Canton Token';
}
getBaseFactor(): number {
return Math.pow(10, this.tokenConfig.decimalPlaces);
}
}