|
| 1 | +import { AccountCoin, AccountConstructorOptions } from './account'; |
| 2 | +import { BaseUnit, CoinFeature, KeyCurve, UnderlyingAsset } from './base'; |
| 3 | +import { EVM_FEATURES } from './coinFeatures'; |
| 4 | +import { AccountNetwork } from './networks'; |
| 5 | + |
| 6 | +export interface HypeEvmConstructorOptions extends AccountConstructorOptions { |
| 7 | + tokenId: number; |
| 8 | + systemAddress: string; |
| 9 | +} |
| 10 | + |
| 11 | +export class HypeEvm extends AccountCoin { |
| 12 | + public static readonly DEFAULT_FEATURES = [ |
| 13 | + ...EVM_FEATURES, |
| 14 | + CoinFeature.SHARED_EVM_SIGNING, |
| 15 | + CoinFeature.SHARED_EVM_SDK, |
| 16 | + CoinFeature.EVM_COMPATIBLE_IMS, |
| 17 | + CoinFeature.EVM_COMPATIBLE_UI, |
| 18 | + CoinFeature.EVM_NON_BITGO_RECOVERY, |
| 19 | + CoinFeature.EVM_UNSIGNED_SWEEP_RECOVERY, |
| 20 | + CoinFeature.SUPPORTS_ERC20, |
| 21 | + CoinFeature.STAKING, |
| 22 | + ]; |
| 23 | + |
| 24 | + public tokenId: number; |
| 25 | + public systemAddress: string; |
| 26 | + |
| 27 | + constructor(options: HypeEvmConstructorOptions) { |
| 28 | + super({ |
| 29 | + ...options, |
| 30 | + }); |
| 31 | + |
| 32 | + this.tokenId = options.tokenId; |
| 33 | + this.systemAddress = options.systemAddress; |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +/** |
| 38 | + * Factory function for hypeEvm coin instances |
| 39 | + * |
| 40 | + * @param id uuid v4 |
| 41 | + * @param name unique identifier of the coin |
| 42 | + * @param fullName Complete human-readable name of the coin |
| 43 | + * @param network Network object for this coin |
| 44 | + * @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin. |
| 45 | + * @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined for EVM like coins |
| 46 | + * @param prefix? Optional coin prefix. Defaults to empty string |
| 47 | + * @param suffix? Optional coin suffix. Defaults to coin name. |
| 48 | + * @param primaryKeyCurve The elliptic curve for this chain/token |
| 49 | + */ |
| 50 | +export function hypeEvm( |
| 51 | + id: string, |
| 52 | + name: string, |
| 53 | + fullName: string, |
| 54 | + network: AccountNetwork, |
| 55 | + decimalPlaces: number, |
| 56 | + asset: UnderlyingAsset, |
| 57 | + baseUnit: BaseUnit, |
| 58 | + tokenId: number, |
| 59 | + systemAddress: string, |
| 60 | + features: CoinFeature[] = HypeEvm.DEFAULT_FEATURES, |
| 61 | + prefix = '', |
| 62 | + suffix: string = name.toUpperCase(), |
| 63 | + primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1 |
| 64 | +) { |
| 65 | + return Object.freeze( |
| 66 | + new HypeEvm({ |
| 67 | + id, |
| 68 | + name, |
| 69 | + fullName, |
| 70 | + network, |
| 71 | + decimalPlaces, |
| 72 | + asset, |
| 73 | + baseUnit, |
| 74 | + features, |
| 75 | + prefix, |
| 76 | + suffix, |
| 77 | + primaryKeyCurve, |
| 78 | + isToken: false, |
| 79 | + tokenId, |
| 80 | + systemAddress, |
| 81 | + }) |
| 82 | + ); |
| 83 | +} |
0 commit comments