Skip to content

Commit d1a9d62

Browse files
committed
feat(statics): add Go Account (OFC) support for MegaETH tokens
- Add ofcMegaethErc20 factory function with addressCoin='megaeth' - Add tofcMegaethErc20 factory function with addressCoin='tmegaeth' - Update existing OFC tokens to use correct factory functions - Add OFC equivalent for test token (ofctmegaeth:tmt) WIN-8346 TICKET: WIN-8346
1 parent ab68700 commit d1a9d62

2 files changed

Lines changed: 123 additions & 4 deletions

File tree

modules/statics/src/coins/ofcErc20Coins.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OfcCoin, ofcerc20, tofcerc20 } from '../ofc';
1+
import { OfcCoin, ofcerc20, tofcerc20, ofcMegaethErc20, tofcMegaethErc20 } from '../ofc';
22
import { CoinFeature, UnderlyingAsset } from '../base';
33
import { AccountCoin } from '../account';
44

@@ -5197,21 +5197,30 @@ export const tOfcErc20Coins = [
51975197
underlyingAssetForSymbol('tmantle:bgerch')
51985198
),
51995199

5200-
// MegaEth Network tokens
5201-
ofcerc20(
5200+
// MegaEth Network mainnet tokens
5201+
ofcMegaethErc20(
52025202
'65df2f65-bb7a-4485-b725-a5fb2e6cd281',
52035203
'ofcmegaeth:mega',
52045204
'Mega',
52055205
18,
52065206
underlyingAssetForSymbol('megaeth:mega')
52075207
),
5208-
ofcerc20(
5208+
ofcMegaethErc20(
52095209
'7bcafa71-a2f3-4a9e-98e2-4d3f655281f8',
52105210
'ofcmegaeth:weth',
52115211
'Wrapped Ether',
52125212
18,
52135213
underlyingAssetForSymbol('megaeth:weth')
52145214
),
5215+
5216+
// MegaEth Network testnet tokens
5217+
tofcMegaethErc20(
5218+
'c4e8f2a1-9b3d-4e5f-8a6c-7d2e1f0b9c8a',
5219+
'ofctmegaeth:tmt',
5220+
'Test Mintable Token',
5221+
6,
5222+
underlyingAssetForSymbol('tmegaeth:tmt')
5223+
),
52155224
];
52165225

52175226
function underlyingAssetForSymbol(underlyingAssetValue: string): UnderlyingAsset {

modules/statics/src/ofc.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,116 @@ export function tofcPolygonErc20(
11331133
);
11341134
}
11351135

1136+
/**
1137+
* Factory function for ofc megaethErc20 token instances.
1138+
*
1139+
* @param id uuid v4
1140+
* @param name unique identifier of the coin
1141+
* @param fullName Complete human-readable name of the coin
1142+
* @param network Network object for this coin
1143+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
1144+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
1145+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
1146+
* @param prefix? Optional coin prefix. Defaults to empty string
1147+
* @param suffix? Optional coin suffix. Defaults to coin name.
1148+
* @param isToken? Whether or not this account coin is a token of another coin
1149+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
1150+
* @param primaryKeyCurve The elliptic curve for this chain/token
1151+
*/
1152+
export function ofcMegaethErc20(
1153+
id: string,
1154+
name: string,
1155+
fullName: string,
1156+
decimalPlaces: number,
1157+
asset: UnderlyingAsset,
1158+
kind: CoinKind = CoinKind.CRYPTO,
1159+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
1160+
prefix = '',
1161+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
1162+
network: OfcNetwork = Networks.main.ofc,
1163+
isToken = true,
1164+
addressCoin = 'megaeth',
1165+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
1166+
) {
1167+
const filteredFeatures = getFilteredFeatures(suffix);
1168+
if (filteredFeatures.length > 0) {
1169+
features = filteredFeatures;
1170+
}
1171+
return Object.freeze(
1172+
new OfcCoin({
1173+
id,
1174+
name,
1175+
fullName,
1176+
network,
1177+
prefix,
1178+
suffix,
1179+
features,
1180+
decimalPlaces,
1181+
isToken,
1182+
asset,
1183+
kind,
1184+
addressCoin,
1185+
primaryKeyCurve,
1186+
baseUnit: BaseUnit.ETH,
1187+
})
1188+
);
1189+
}
1190+
1191+
/**
1192+
* Factory function for testnet ofc megaethErc20 token instances.
1193+
*
1194+
* @param id uuid v4
1195+
* @param name unique identifier of the coin
1196+
* @param fullName Complete human-readable name of the coin
1197+
* @param network Network object for this coin
1198+
* @param decimalPlaces Number of decimal places this coin supports (divisibility exponent)
1199+
* @param asset Asset which this coin represents. This is the same for both mainnet and testnet variants of a coin.
1200+
* @param kind Differentiates coins which represent fiat assets from those which represent crypto assets
1201+
* @param prefix? Optional coin prefix. Defaults to empty string
1202+
* @param suffix? Optional coin suffix. Defaults to coin name.
1203+
* @param isToken? Whether or not this account coin is a token of another coin
1204+
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `OfcCoin`
1205+
* @param primaryKeyCurve The elliptic curve for this chain/token
1206+
*/
1207+
export function tofcMegaethErc20(
1208+
id: string,
1209+
name: string,
1210+
fullName: string,
1211+
decimalPlaces: number,
1212+
asset: UnderlyingAsset,
1213+
kind: CoinKind = CoinKind.CRYPTO,
1214+
features: CoinFeature[] = OfcCoin.DEFAULT_FEATURES,
1215+
prefix = '',
1216+
suffix: string = name.replace(/^ofc/, '').toUpperCase(),
1217+
network: OfcNetwork = Networks.test.ofc,
1218+
isToken = true,
1219+
addressCoin = 'tmegaeth',
1220+
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
1221+
) {
1222+
const filteredFeatures = getFilteredFeatures(suffix);
1223+
if (filteredFeatures.length > 0) {
1224+
features = filteredFeatures;
1225+
}
1226+
return Object.freeze(
1227+
new OfcCoin({
1228+
id,
1229+
name,
1230+
fullName,
1231+
network,
1232+
prefix,
1233+
suffix,
1234+
features,
1235+
decimalPlaces,
1236+
isToken,
1237+
asset,
1238+
kind,
1239+
addressCoin,
1240+
primaryKeyCurve,
1241+
baseUnit: BaseUnit.ETH,
1242+
})
1243+
);
1244+
}
1245+
11361246
/**
11371247
* Factory function for ofc bsc token instances.
11381248
*

0 commit comments

Comments
 (0)