Skip to content

prototype #5990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
32 changes: 31 additions & 1 deletion modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import {
InvalidIdError,
MissingRequiredCoinFeatureError,
} from './errors';
import { BaseNetwork } from './networks';
import { BaseNetwork, Networks } from './networks';
import { coins } from './coins';
import { OfcCoin } from './ofc';
import { v4 as uuidV4 } from 'uuid';

export enum CoinKind {
CRYPTO = 'crypto',
Expand Down Expand Up @@ -2708,6 +2711,11 @@ export abstract class BaseCoin {
*/
public readonly primaryKeyCurve: KeyCurve;

/**
* Off-chain equivalent of this asset.
*/
public readonly ofcCoin?: Readonly<BaseCoin>;

/**
* Set of features which are required by a coin subclass
* @return {Set<CoinFeature>}
Expand Down Expand Up @@ -2784,5 +2792,27 @@ export abstract class BaseCoin {
this.asset = options.asset;
this.network = options.network;
this.primaryKeyCurve = options.primaryKeyCurve;
this.ofcCoin =
coins.get(`ofc${this.name}`) ??
Object.freeze(
new OfcCoin({
id: uuidV4({
rng: () => Buffer.from(options.id, 'utf-8'),
}),
name: `ofc${options.name}`,
fullName: options.fullName,
network: Networks.test.ofc /* TODO: Networks.main.ofc if mainnet */,
prefix: '',
suffix: options.name.toUpperCase(),
features: [...OfcCoin.DEFAULT_FEATURES, CoinFeature.TSS_ENTERPRISE_PAYS_FEES],
decimalPlaces: options.decimalPlaces,
isToken: options.isToken,
asset: options.asset,
kind: options.kind,
primaryKeyCurve: options.primaryKeyCurve,
baseUnit: BaseUnit.OFC,
addressCoin: options.isToken ? options.name : undefined,
})
);
}
}
Loading