Skip to content

Commit d74cc3b

Browse files
feat(statics): added flare p statics
TICKET: WIN-6328
1 parent 91b7731 commit d74cc3b

File tree

7 files changed

+204
-2
lines changed

7 files changed

+204
-2
lines changed

modules/bitgo/test/v2/unit/keychains.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ describe('V2 Keychains', function () {
9898
n.asset !== UnderlyingAsset.IP && // Story Chain
9999
n.asset !== UnderlyingAsset.BASEETH &&
100100
n.asset !== UnderlyingAsset.SOMI &&
101+
n.asset !== UnderlyingAsset.FLRP &&
101102
coinFamilyValues.includes(n.name)
102103
);
103104

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import { sip10Tokens } from './coins/sip10Tokens';
6161
import { nep141Tokens } from './coins/nep141Tokens';
6262
import { vetTokens } from './coins/vetTokens';
6363
import { cosmosTokens } from './coins/cosmosTokens';
64+
import { flrp } from './flrp';
6465
import {
6566
ADA_FEATURES_WITH_FRANKFURT,
6667
ALGO_FEATURES,
@@ -149,6 +150,14 @@ export const allCoinsAndTokens = [
149150
Networks.test.avalancheP,
150151
UnderlyingAsset.AVAXP
151152
),
153+
flrp('84749ce6-a3ca-4270-9970-4e21cca026ca', 'flrp', 'Flare P-Chain', Networks.main.flrP, UnderlyingAsset.FLRP),
154+
flrp(
155+
'e8a58db3-eedd-423c-89ae-817dfb6c6249',
156+
'tflrp',
157+
'Testnet Flare P-Chain',
158+
Networks.test.flrP,
159+
UnderlyingAsset.FLRP
160+
),
152161
ada(
153162
'fd4d125e-f14f-414b-bd17-6cb1393265f0',
154163
'ada',

modules/statics/src/base.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export enum CoinFamily {
5555
FETCHAI = 'fetchai',
5656
FIAT = 'fiat',
5757
FLR = 'flr',
58+
FLRP = 'flrp',
5859
HASH = 'hash', // Provenance
5960
HBAR = 'hbar',
6061
ICP = 'icp',
@@ -518,6 +519,7 @@ export enum UnderlyingAsset {
518519
EURR = 'eurr',
519520
FETCHAI = 'fetchai',
520521
FLR = 'flr',
522+
FLRP = 'flrp',
521523
GTC = 'gtc',
522524
HASH = 'hash', // Provenance
523525
HBAR = 'hbar', // Hedera main coin

modules/statics/src/flrp.ts

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

modules/statics/src/networks.ts

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
// FlareNetwork interface for Flare-family chains
2+
export interface FlareNetwork {
3+
name: string;
4+
family: CoinFamily;
5+
explorerUrl: string;
6+
accountExplorerUrl: string;
7+
chainId?: number;
8+
nativeCoinOperationHashPrefix?: string;
9+
batcherContractAddress?: string;
10+
forwarderFactoryAddress?: string;
11+
forwarderImplementationAddress?: string;
12+
blockchainID?: string;
13+
cChainBlockchainID?: string;
14+
avaxAssetID?: string;
15+
networkID?: number;
16+
hrp?: string;
17+
alias?: string;
18+
vm?: string;
19+
txFee?: string;
20+
maxImportFee?: string;
21+
createSubnetTx?: string;
22+
createChainTx?: string;
23+
creationTxFee?: string;
24+
minConsumption?: string;
25+
maxConsumption?: string;
26+
maxSupply?: string;
27+
minStake?: string;
28+
minStakeDuration?: string;
29+
maxStakeDuration?: string;
30+
minDelegationStake?: string;
31+
minDelegationFee?: string;
32+
}
33+
134
import { CoinFamily } from './base';
235

336
export enum NetworkType {
@@ -1678,7 +1711,61 @@ class Somi extends Mainnet implements EthereumNetwork {
16781711
batcherContractAddress = '0x3e1e5d78e44f15593b3b61ed278f12c27f0ff33e';
16791712
}
16801713

1681-
class Flare extends Mainnet implements EthereumNetwork {
1714+
export class FlareP extends Mainnet implements FlareNetwork {
1715+
name = 'FlareP';
1716+
family = CoinFamily.FLRP;
1717+
explorerUrl = 'https://flarescan.com/blockchain/pvm/transactions/';
1718+
accountExplorerUrl = 'https://flarescan.com/blockchain/pvm/address/';
1719+
blockchainID = '11111111111111111111111111111111LpoYY';
1720+
cChainBlockchainID = '2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5';
1721+
avaxAssetID = ''; // This is not applicable to our chain, so just any string that passes validation will suffice
1722+
networkID = 14;
1723+
hrp = 'flare'; //The Human-Readable Part for Bech32 addresses on the network (e.g., avax for Mainnet). It's the prefix before the 1 in an address.
1724+
alias = 'P';
1725+
vm = 'platformvm';
1726+
txFee = '1000000'; // defaults
1727+
maxImportFee = '10000000'; // defaults
1728+
createSubnetTx = '100000000'; // defaults
1729+
createChainTx = '100000000'; // defaults
1730+
creationTxFee = '10000000'; // defaults
1731+
minConsumption = '0.1';
1732+
maxConsumption = '0.12';
1733+
maxSupply = '103688266974000000000'; // 103B tokens
1734+
minStake = '1000000000000000'; // 1M FLR
1735+
minStakeDuration = '5256000'; // 2 months
1736+
maxStakeDuration = '31536000'; // 1 year
1737+
minDelegationStake = '50000000000000'; // 50000 FLR
1738+
minDelegationFee = '0';
1739+
}
1740+
1741+
export class FlarePTestnet extends Testnet implements FlareNetwork {
1742+
name = 'FlarePTestnet';
1743+
family = CoinFamily.FLRP;
1744+
explorerUrl = 'https://coston2.testnet.flarescan.com/blockchain/pvm/transactions';
1745+
accountExplorerUrl = 'https://coston2.testnet.flarescan.com/blockchain/pvm/address/';
1746+
blockchainID = '11111111111111111111111111111111LpoYY';
1747+
cChainBlockchainID = 'vE8M98mEQH6wk56sStD1ML8HApTgSqfJZLk9gQ3Fsd4i6m3Bi';
1748+
avaxAssetID = ''; // This is not applicable to our chain, so just any string that passes validation will suffice
1749+
networkID = 114;
1750+
hrp = 'costwo'; //The Human-Readable Part for Bech32 addresses on the network (e.g., avax for Mainnet). It's the prefix before the 1 in an address.
1751+
alias = 'P';
1752+
vm = 'platformvm';
1753+
txFee = '1000000'; // defaults
1754+
maxImportFee = '10000000'; // defaults
1755+
createSubnetTx = '100000000'; // defaults
1756+
createChainTx = '100000000'; // defaults
1757+
creationTxFee = '10000000'; // defaults
1758+
minConsumption = '0.1';
1759+
maxConsumption = '0.12';
1760+
maxSupply = '79000000000000000000000'; // 79 trillion tokens
1761+
minStake = '1000000000000000'; // 1M FLR
1762+
minStakeDuration = '5256000'; // 2 months
1763+
maxStakeDuration = '31536000'; // 1 year
1764+
minDelegationStake = '50000000000000'; // 50000 FLR
1765+
minDelegationFee = '0';
1766+
}
1767+
1768+
export class Flare extends Mainnet implements FlareNetwork, EthereumNetwork {
16821769
name = 'Flarechain';
16831770
family = CoinFamily.FLR;
16841771
explorerUrl = 'https://flare-explorer.flare.network/tx/';
@@ -1689,7 +1776,8 @@ class Flare extends Mainnet implements EthereumNetwork {
16891776
forwarderFactoryAddress = '0x37996e762fa8b671869740c79eb33f625b3bf92a';
16901777
forwarderImplementationAddress = '0xd5fe1c1f216b775dfd30638fa7164d41321ef79b';
16911778
}
1692-
class FlareTestnet extends Testnet implements EthereumNetwork {
1779+
1780+
export class FlareTestnet extends Testnet implements FlareNetwork, EthereumNetwork {
16931781
name = 'FlarechainTestnet';
16941782
family = CoinFamily.FLR;
16951783
explorerUrl = 'https://coston2-explorer.flare.network/tx/';
@@ -1831,6 +1919,7 @@ export const Networks = {
18311919
fiat: Object.freeze(new Fiat()),
18321920
fetchai: Object.freeze(new FetchAi()),
18331921
flr: Object.freeze(new Flare()),
1922+
flrP: Object.freeze(new FlareP()),
18341923
hash: Object.freeze(new Hash()),
18351924
hedera: Object.freeze(new Hedera()),
18361925
icp: Object.freeze(new Icp()),
@@ -1919,6 +2008,7 @@ export const Networks = {
19192008
fiat: Object.freeze(new FiatTestnet()),
19202009
fetchai: Object.freeze(new FetchAiTestnet()),
19212010
flr: Object.freeze(new FlareTestnet()),
2011+
flrP: Object.freeze(new FlarePTestnet()),
19222012
mon: Object.freeze(new MonadTestnet()),
19232013
pyrmont: Object.freeze(new Pyrmont()),
19242014
ethereumClassicTestnet: Object.freeze(new EthereumClassicTestnet()),

modules/statics/test/unit/coins.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,10 @@ coins.forEach((coin, coinName) => {
863863
it(`should return true for CUSTODY_BITGO_INDIA ${coin.family} coin feature`, () => {
864864
coin.features.includes(CoinFeature.CUSTODY_BITGO_INDIA).should.eql(true);
865865
});
866+
} else if (coin.family === CoinFamily.FLRP) {
867+
it('does not require custody', () => {
868+
coin.features.includes(CoinFeature.CUSTODY).should.eql(false);
869+
});
866870
} else if (coin.features.includes(CoinFeature.GENERIC_TOKEN)) {
867871
it(`should return false for all custody ${coin.family} coin feature`, () => {
868872
coin.features.includes(CoinFeature.CUSTODY).should.eql(false);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const expectedColdFeatures = {
1515
'doge',
1616
'eos',
1717
'etc',
18+
'flrp',
1819
'hbar',
1920
'ltc',
2021
'rbtc',
@@ -35,6 +36,7 @@ export const expectedColdFeatures = {
3536
'tdoge',
3637
'teos',
3738
'tetc',
39+
'tflrp',
3840
'thbar',
3941
'tltc',
4042
'trbtc',

0 commit comments

Comments
 (0)