@cityofzion/bs-neo-legacy 1.12.1 → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,18 @@ export declare class BSNeoLegacyConstants {
8
8
  hash: string;
9
9
  decimals: number;
10
10
  }[];
11
+ static GAS_ASSET: {
12
+ symbol: string;
13
+ name: string;
14
+ hash: string;
15
+ decimals: number;
16
+ };
17
+ static NEO_ASSET: {
18
+ symbol: string;
19
+ name: string;
20
+ hash: string;
21
+ decimals: number;
22
+ };
11
23
  static RPC_LIST_BY_NETWORK_ID: Record<BSNeoLegacyNetworkId, string[]>;
12
24
  static LEGACY_NETWORK_BY_NETWORK_ID: Record<BSNeoLegacyNetworkId, string>;
13
25
  static MAINNET_NETWORK_IDS: BSNeoLegacyNetworkId[];
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.BSNeoLegacyConstants = void 0;
8
8
  const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
9
9
  const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
10
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
10
11
  class BSNeoLegacyConstants {
11
12
  }
12
13
  exports.BSNeoLegacyConstants = BSNeoLegacyConstants;
@@ -14,7 +15,9 @@ _a = BSNeoLegacyConstants;
14
15
  BSNeoLegacyConstants.EXTRA_TOKENS_BY_NETWORK_ID = {
15
16
  mainnet: mainnet_json_1.default,
16
17
  };
17
- BSNeoLegacyConstants.NATIVE_ASSETS = native_json_1.default;
18
+ BSNeoLegacyConstants.NATIVE_ASSETS = blockchain_service_1.BSTokenHelper.normalizeToken(native_json_1.default);
19
+ BSNeoLegacyConstants.GAS_ASSET = _a.NATIVE_ASSETS.find(blockchain_service_1.BSTokenHelper.predicateBySymbol('GAS'));
20
+ BSNeoLegacyConstants.NEO_ASSET = _a.NATIVE_ASSETS.find(blockchain_service_1.BSTokenHelper.predicateBySymbol('NEO'));
18
21
  BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID = {
19
22
  mainnet: [
20
23
  'https://mainnet1.neo2.coz.io:443',
@@ -57,6 +60,7 @@ BSNeoLegacyConstants.TESTNET_NETWORKS = [
57
60
  ];
58
61
  BSNeoLegacyConstants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
59
62
  BSNeoLegacyConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
63
+ // If tou change this, make sure to update the tests accordingly
60
64
  BSNeoLegacyConstants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
61
65
  BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS = 'AaT27thuyPaqERPwERhk7QhfKrbj4xoyAV';
62
66
  BSNeoLegacyConstants.MIGRATION_COZ_FEE = 0.01; // 1%
@@ -16,7 +16,6 @@ export declare class BSNeoLegacyHelper {
16
16
  }[];
17
17
  static getRpcList(network: Network<BSNeoLegacyNetworkId>): string[];
18
18
  static isMainnet(network: Network<BSNeoLegacyNetworkId>): boolean;
19
- static normalizeHash(hash: string): string;
20
19
  static waitForMigration(params: WaitForMigrationParams): Promise<{
21
20
  isTransactionConfirmed: boolean;
22
21
  isNeo3TransactionConfirmed: boolean;
@@ -26,7 +26,7 @@ class BSNeoLegacyHelper {
26
26
  static getTokens(network) {
27
27
  var _a;
28
28
  const extraTokens = (_a = BSNeoLegacyConstants_1.BSNeoLegacyConstants.EXTRA_TOKENS_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
29
- return [...extraTokens, ...native_json_1.default];
29
+ return blockchain_service_1.BSTokenHelper.normalizeToken([...extraTokens, ...native_json_1.default]);
30
30
  }
31
31
  static getRpcList(network) {
32
32
  var _a;
@@ -35,9 +35,6 @@ class BSNeoLegacyHelper {
35
35
  static isMainnet(network) {
36
36
  return BSNeoLegacyConstants_1.BSNeoLegacyConstants.MAINNET_NETWORK_IDS.includes(network.id);
37
37
  }
38
- static normalizeHash(hash) {
39
- return (0, blockchain_service_1.normalizeHash)(hash, { lowercase: false });
40
- }
41
38
  static waitForMigration(params) {
42
39
  return __awaiter(this, void 0, void 0, function* () {
43
40
  const { neo3Address, neo3Service, transactionHash, neoLegacyService } = params;
@@ -49,7 +46,7 @@ class BSNeoLegacyHelper {
49
46
  };
50
47
  let transactionResponse;
51
48
  for (let i = 0; i < MAX_ATTEMPTS; i++) {
52
- yield (0, blockchain_service_1.wait)(30000);
49
+ yield blockchain_service_1.BSUtilsHelper.wait(30000);
53
50
  try {
54
51
  transactionResponse = yield neoLegacyService.blockchainDataService.getTransaction(transactionHash);
55
52
  response.isTransactionConfirmed = true;
@@ -62,7 +59,7 @@ class BSNeoLegacyHelper {
62
59
  if (!response.isTransactionConfirmed)
63
60
  return response;
64
61
  for (let i = 0; i < NEO3_MAX_ATTEMPTS; i++) {
65
- yield (0, blockchain_service_1.wait)(60000);
62
+ yield blockchain_service_1.BSUtilsHelper.wait(60000);
66
63
  try {
67
64
  const neo3Response = yield neo3Service.blockchainDataService.getTransactionsByAddress({
68
65
  address: neo3Address,
@@ -21,23 +21,11 @@ export type CalculateNeoLegacyMigrationAmountsResponse = {
21
21
  export declare class BSNeoLegacy<BSName extends string = string> implements BlockchainService<BSName, BSNeoLegacyNetworkId>, BSClaimable<BSName>, BSWithExplorerService, BSWithLedger<BSName> {
22
22
  #private;
23
23
  NATIVE_ASSETS: {
24
- hash: string;
25
- symbol: string;
26
- name: string;
27
- decimals: number;
28
- }[];
29
- GAS_ASSET: {
30
- hash: string;
31
24
  symbol: string;
32
25
  name: string;
33
- decimals: number;
34
- };
35
- NEO_ASSET: {
36
26
  hash: string;
37
- symbol: string;
38
- name: string;
39
27
  decimals: number;
40
- };
28
+ }[];
41
29
  readonly name: BSName;
42
30
  readonly bip44DerivationPath: string;
43
31
  nativeTokens: Token[];
@@ -39,9 +39,7 @@ const NeonJsLedgerServiceNeoLegacy_1 = require("./ledger/NeonJsLedgerServiceNeoL
39
39
  class BSNeoLegacy {
40
40
  constructor(name, network, getLedgerTransport) {
41
41
  _BSNeoLegacy_instances.add(this);
42
- this.NATIVE_ASSETS = BSNeoLegacyConstants_1.BSNeoLegacyConstants.NATIVE_ASSETS.map(asset => (Object.assign(Object.assign({}, asset), { hash: (0, blockchain_service_1.normalizeHash)(asset.hash) })));
43
- this.GAS_ASSET = this.NATIVE_ASSETS.find(({ symbol }) => symbol === 'GAS');
44
- this.NEO_ASSET = this.NATIVE_ASSETS.find(({ symbol }) => symbol === 'NEO');
42
+ this.NATIVE_ASSETS = BSNeoLegacyConstants_1.BSNeoLegacyConstants.NATIVE_ASSETS;
45
43
  network = network !== null && network !== void 0 ? network : BSNeoLegacyConstants_1.BSNeoLegacyConstants.DEFAULT_NETWORK;
46
44
  this.name = name;
47
45
  this.legacyNetwork = BSNeoLegacyConstants_1.BSNeoLegacyConstants.LEGACY_NETWORK_BY_NETWORK_ID[network.id];
@@ -119,13 +117,13 @@ class BSNeoLegacy {
119
117
  const nep5ScriptBuilder = new neon_js_1.sc.ScriptBuilder();
120
118
  const concatIntents = [...intents, ...(tipIntent ? [tipIntent] : [])];
121
119
  for (const intent of concatIntents) {
122
- const tokenHashFixed = BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(intent.tokenHash);
123
- const nativeAsset = this.NATIVE_ASSETS.find(({ hash }) => hash === tokenHashFixed);
120
+ const normalizeTokenHash = blockchain_service_1.BSTokenHelper.normalizeHash(intent.tokenHash);
121
+ const nativeAsset = this.NATIVE_ASSETS.find(blockchain_service_1.BSTokenHelper.predicateByHash(normalizeTokenHash));
124
122
  if (nativeAsset) {
125
123
  nativeIntents.push(...neon_js_1.api.makeIntent({ [nativeAsset.symbol]: Number(intent.amount) }, intent.receiverAddress));
126
124
  continue;
127
125
  }
128
- nep5ScriptBuilder.emitAppCall(tokenHashFixed, 'transfer', [
126
+ nep5ScriptBuilder.emitAppCall(normalizeTokenHash, 'transfer', [
129
127
  neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(neonJsAccount.address)),
130
128
  neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(intent.receiverAddress)),
131
129
  neon_js_1.sc.ContractParam.integer(new neon_js_1.u.Fixed8(intent.amount)
@@ -169,9 +167,9 @@ class BSNeoLegacy {
169
167
  const provider = new neon_js_1.api.neoCli.instance(this.network.url);
170
168
  const intents = [];
171
169
  if (neoLegacyMigrationAmounts.gasBalance)
172
- intents.push(...neon_js_1.api.makeIntent({ [this.GAS_ASSET.symbol]: Number(neoLegacyMigrationAmounts.gasBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
170
+ intents.push(...neon_js_1.api.makeIntent({ [BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.symbol]: Number(neoLegacyMigrationAmounts.gasBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
173
171
  if (neoLegacyMigrationAmounts.neoBalance)
174
- intents.push(...neon_js_1.api.makeIntent({ [this.NEO_ASSET.symbol]: Number(neoLegacyMigrationAmounts.neoBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
172
+ intents.push(...neon_js_1.api.makeIntent({ [BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.symbol]: Number(neoLegacyMigrationAmounts.neoBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
175
173
  return yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_sendTransfer).call(this, {
176
174
  url: this.network.url,
177
175
  api: provider,
@@ -215,26 +213,32 @@ class BSNeoLegacy {
215
213
  const gasAmountNumberLessCozFee = gasAmountNumberLessAllNep17TransfersFee - cozFee;
216
214
  const allGasFeeNumberThatUserWillPay = cozFee + BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE * 2;
217
215
  const allGasAmountNumberThatUserWillReceive = gasAmountNumberLessCozFee + BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE;
218
- response.gasMigrationTotalFees = (0, blockchain_service_1.formatNumber)(allGasFeeNumberThatUserWillPay, this.GAS_ASSET.decimals);
219
- response.gasMigrationReceiveAmount = (0, blockchain_service_1.formatNumber)(allGasAmountNumberThatUserWillReceive, this.GAS_ASSET.decimals);
216
+ response.gasMigrationTotalFees = blockchain_service_1.BSBigNumberHelper.format(allGasFeeNumberThatUserWillPay, {
217
+ decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.decimals,
218
+ });
219
+ response.gasMigrationReceiveAmount = blockchain_service_1.BSBigNumberHelper.format(allGasAmountNumberThatUserWillReceive, {
220
+ decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.decimals,
221
+ });
220
222
  }
221
223
  if (neoLegacyMigrationAmounts.neoBalance && neoLegacyMigrationAmounts.hasEnoughNeoBalance) {
222
224
  const neoMigrationAmountNumber = Number(neoLegacyMigrationAmounts.neoBalance.amount);
223
- response.neoMigrationTotalFees = (0, blockchain_service_1.formatNumber)(Math.ceil(neoMigrationAmountNumber * BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_FEE), this.NEO_ASSET.decimals);
224
- response.neoMigrationReceiveAmount = (0, blockchain_service_1.formatNumber)(neoMigrationAmountNumber - Number(response.neoMigrationTotalFees), this.NEO_ASSET.decimals);
225
+ response.neoMigrationTotalFees = blockchain_service_1.BSBigNumberHelper.format(Math.ceil(neoMigrationAmountNumber * BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_FEE), { decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.decimals });
226
+ response.neoMigrationReceiveAmount = blockchain_service_1.BSBigNumberHelper.format(neoMigrationAmountNumber - Number(response.neoMigrationTotalFees), { decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.decimals });
225
227
  }
226
228
  return response;
227
229
  }
228
230
  calculateNeoLegacyMigrationAmounts(balance) {
229
- const gasBalance = balance.find(({ token }) => (0, blockchain_service_1.normalizeHash)(token.hash) === this.GAS_ASSET.hash);
230
- const neoBalance = balance.find(({ token }) => (0, blockchain_service_1.normalizeHash)(token.hash) === this.NEO_ASSET.hash);
231
+ const gasBalance = balance.find(({ token }) => blockchain_service_1.BSTokenHelper.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET)(token));
232
+ const neoBalance = balance.find(({ token }) => blockchain_service_1.BSTokenHelper.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET)(token));
231
233
  let hasEnoughGasBalance = false;
232
234
  let hasEnoughNeoBalance = false;
233
235
  if (gasBalance) {
234
- hasEnoughGasBalance = Number(gasBalance.amount) >= BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_MIN_GAS;
236
+ const gasBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(gasBalance.amount);
237
+ hasEnoughGasBalance = gasBalanceNumber.isGreaterThanOrEqualTo(BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_MIN_GAS);
235
238
  }
236
239
  if (neoBalance) {
237
- hasEnoughNeoBalance = Number(neoBalance.amount) >= BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_MIN_NEO;
240
+ const neoBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(neoBalance.amount);
241
+ hasEnoughNeoBalance = neoBalanceNumber.isGreaterThanOrEqualTo(BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_MIN_NEO);
238
242
  }
239
243
  return {
240
244
  gasBalance,
@@ -140,7 +140,8 @@ class DoraBDSNeoLegacy {
140
140
  const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getAddressTemplateUrl();
141
141
  const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getTxTemplateUrl();
142
142
  const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getContractTemplateUrl();
143
- const itemPromises = items.map((item) => __awaiter(this, void 0, void 0, function* () {
143
+ const itemPromises = items.map((_d) => __awaiter(this, void 0, void 0, function* () {
144
+ var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
144
145
  const txId = item.transactionID;
145
146
  const newItem = {
146
147
  txId,
@@ -149,22 +150,28 @@ class DoraBDSNeoLegacy {
149
150
  date: item.date,
150
151
  invocationCount: item.invocationCount,
151
152
  notificationCount: item.notificationCount,
152
- networkFeeAmount: (0, blockchain_service_1.formatNumber)(item.networkFeeAmount, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
153
- systemFeeAmount: (0, blockchain_service_1.formatNumber)(item.systemFeeAmount, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
153
+ networkFeeAmount: networkFeeAmount
154
+ ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals })
155
+ : undefined,
156
+ systemFeeAmount: systemFeeAmount
157
+ ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals })
158
+ : undefined,
154
159
  events: [],
155
160
  };
156
161
  const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
157
- var _d, _e, _f, _g;
162
+ var _e, _f, _g, _h;
158
163
  const { contractHash: hash, amount, from, to } = event;
159
164
  const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
160
- const standard = (_f = (_e = (_d = event.supportedStandards) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.toLowerCase()) !== null && _f !== void 0 ? _f : '';
165
+ const standard = (_g = (_f = (_e = event.supportedStandards) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.toLowerCase()) !== null && _g !== void 0 ? _g : '';
161
166
  const isNep5 = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_supportedNep5Standards, "f").includes(standard);
162
167
  const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
163
168
  const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
164
169
  const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
165
170
  const assetEvent = {
166
171
  eventType: 'token',
167
- amount: (0, blockchain_service_1.formatNumber)(amount, (_g = token === null || token === void 0 ? void 0 : token.decimals) !== null && _g !== void 0 ? _g : event.tokenDecimals),
172
+ amount: amount
173
+ ? blockchain_service_1.BSBigNumberHelper.format(amount, { decimals: (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals })
174
+ : undefined,
168
175
  methodName: event.methodName,
169
176
  from: from !== null && from !== void 0 ? from : undefined,
170
177
  fromUrl,
@@ -209,22 +216,23 @@ class DoraBDSNeoLegacy {
209
216
  }
210
217
  getTokenInfo(tokenHash) {
211
218
  return __awaiter(this, void 0, void 0, function* () {
212
- const localToken = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(token => BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(token.hash) === BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(tokenHash));
213
- if (localToken)
214
- return localToken;
215
- if (__classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").has(tokenHash)) {
216
- return __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").get(tokenHash);
219
+ const cachedToken = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").get(tokenHash);
220
+ if (cachedToken) {
221
+ return cachedToken;
217
222
  }
218
- const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
219
- if (!data || 'error' in data)
220
- throw new Error(`Token ${tokenHash} not found`);
221
- const token = {
222
- decimals: Number(data.decimals),
223
- symbol: data.symbol,
224
- hash: data.scripthash,
225
- name: data.name,
226
- };
227
- __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, token);
223
+ let token = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokens, "f").find(blockchain_service_1.BSTokenHelper.predicateByHash(tokenHash));
224
+ if (!token) {
225
+ const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
226
+ if (!data || 'error' in data)
227
+ throw new Error(`Token ${tokenHash} not found`);
228
+ token = {
229
+ decimals: Number(data.decimals),
230
+ symbol: data.symbol,
231
+ hash: data.scripthash,
232
+ name: data.name,
233
+ };
234
+ }
235
+ __classPrivateFieldGet(this, _DoraBDSNeoLegacy_tokenCache, "f").set(tokenHash, blockchain_service_1.BSTokenHelper.normalizeToken(token));
228
236
  return token;
229
237
  });
230
238
  }
@@ -232,21 +240,20 @@ class DoraBDSNeoLegacy {
232
240
  return __awaiter(this, void 0, void 0, function* () {
233
241
  const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
234
242
  const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {
235
- const hash = BSNeoLegacyHelper_1.BSNeoLegacyHelper.normalizeHash(balance.asset);
236
- let token = {
237
- hash,
243
+ let token = blockchain_service_1.BSTokenHelper.normalizeToken({
244
+ hash: balance.asset,
238
245
  name: balance.asset_name,
239
246
  symbol: balance.symbol,
240
247
  decimals: 8,
241
- };
248
+ });
242
249
  try {
243
- token = yield this.getTokenInfo(hash);
250
+ token = yield this.getTokenInfo(balance.asset);
244
251
  }
245
252
  catch (_a) {
246
253
  // Empty block
247
254
  }
248
255
  return {
249
- amount: Number(balance.balance).toFixed(token.decimals),
256
+ amount: blockchain_service_1.BSBigNumberHelper.format(balance.balance, { decimals: token.decimals }),
250
257
  token,
251
258
  };
252
259
  }));
@@ -24,12 +24,12 @@ class NeoTubeESNeoLegacy {
24
24
  buildTransactionUrl(hash) {
25
25
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_network, "f")))
26
26
  throw new Error('NeoTube is only available on mainnet');
27
- return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/transaction/${(0, blockchain_service_1.denormalizeHash)(hash)}`;
27
+ return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/transaction/${blockchain_service_1.BSTokenHelper.normalizeHash(hash)}`;
28
28
  }
29
29
  buildContractUrl(contractHash) {
30
30
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_network, "f")))
31
31
  throw new Error('NeoTube is only available on mainnet');
32
- return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/asset/${contractHash}/page/1`;
32
+ return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/asset/${blockchain_service_1.BSTokenHelper.normalizeHash(contractHash)}/page/1`;
33
33
  }
34
34
  buildNftUrl(_params) {
35
35
  throw new Error('NeoTube does not support nft');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "1.12.1",
3
+ "version": "1.12.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -14,8 +14,8 @@
14
14
  "@ledgerhq/hw-transport": "~6.30.5",
15
15
  "axios": "1.8.2",
16
16
  "date-fns": "~4.1.0",
17
- "@cityofzion/blockchain-service": "1.18.1",
18
- "@cityofzion/bs-asteroid-sdk": "0.9.1"
17
+ "@cityofzion/bs-asteroid-sdk": "0.9.1",
18
+ "@cityofzion/blockchain-service": "1.19.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/jest": "29.5.3",