@cityofzion/bs-neo-legacy 1.12.5 → 1.12.7

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.
@@ -24,7 +24,7 @@ var __rest = (this && this.__rest) || function (s, e) {
24
24
  }
25
25
  return t;
26
26
  };
27
- var _BSNeoLegacy_instances, _BSNeoLegacy_generateSigningCallback, _BSNeoLegacy_setTokens, _BSNeoLegacy_hasTransactionMoreThanMaxSize, _BSNeoLegacy_signTransfer, _BSNeoLegacy_sendTransfer, _BSNeoLegacy_signClaim, _BSNeoLegacy_sendClaim;
27
+ var _BSNeoLegacy_instances, _BSNeoLegacy_generateSigningCallback, _BSNeoLegacy_setTokens, _BSNeoLegacy_hasTransactionMoreThanMaxSize, _BSNeoLegacy_getRequiredTransactionFeeConfig, _BSNeoLegacy_signTransfer, _BSNeoLegacy_sendTransfer, _BSNeoLegacy_signClaim, _BSNeoLegacy_sendClaim;
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.BSNeoLegacy = void 0;
30
30
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
@@ -160,15 +160,16 @@ class BSNeoLegacy {
160
160
  if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(this.network)) {
161
161
  throw new Error('Must use Mainnet network');
162
162
  }
163
- if (!neoLegacyMigrationAmounts.hasEnoughGasBalance && !neoLegacyMigrationAmounts.hasEnoughNeoBalance) {
163
+ if ((!neoLegacyMigrationAmounts.hasEnoughGasBalance && !neoLegacyMigrationAmounts.hasEnoughNeoBalance) ||
164
+ (!neoLegacyMigrationAmounts.gasBalance && !neoLegacyMigrationAmounts.neoBalance)) {
164
165
  throw new Error('Must have at least 0.1 GAS or 2 NEO');
165
166
  }
166
167
  const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_generateSigningCallback).call(this, account);
167
168
  const provider = new neon_js_1.api.neoCli.instance(this.network.url);
168
169
  const intents = [];
169
- if (neoLegacyMigrationAmounts.gasBalance)
170
+ if (neoLegacyMigrationAmounts.hasEnoughGasBalance && neoLegacyMigrationAmounts.gasBalance)
170
171
  intents.push(...neon_js_1.api.makeIntent({ [BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.symbol]: Number(neoLegacyMigrationAmounts.gasBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
171
- if (neoLegacyMigrationAmounts.neoBalance)
172
+ if (neoLegacyMigrationAmounts.hasEnoughNeoBalance && neoLegacyMigrationAmounts.neoBalance)
172
173
  intents.push(...neon_js_1.api.makeIntent({ [BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.symbol]: Number(neoLegacyMigrationAmounts.neoBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
173
174
  return yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_sendTransfer).call(this, {
174
175
  url: this.network.url,
@@ -284,6 +285,14 @@ _BSNeoLegacy_instances = new WeakSet(), _BSNeoLegacy_generateSigningCallback = f
284
285
  }
285
286
  }
286
287
  return false;
288
+ }, _BSNeoLegacy_getRequiredTransactionFeeConfig = function _BSNeoLegacy_getRequiredTransactionFeeConfig(config) {
289
+ var _a, _b, _c;
290
+ config.fees = BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION;
291
+ const gasIntent = (_c = (_b = (_a = config.intents) === null || _a === void 0 ? void 0 : _a.filter((intent) => blockchain_service_1.BSTokenHelper.normalizeHash(intent.assetId) === BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.hash)) === null || _b === void 0 ? void 0 : _b.sort((a, b) => { var _a; return (_a = b.value.comparedTo(a.value)) !== null && _a !== void 0 ? _a : 0; })) === null || _c === void 0 ? void 0 : _c[0];
292
+ if (gasIntent === null || gasIntent === void 0 ? void 0 : gasIntent.value) {
293
+ gasIntent.value = gasIntent.value.sub(BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION);
294
+ }
295
+ return config;
287
296
  }, _BSNeoLegacy_signTransfer = function _BSNeoLegacy_signTransfer(config, nep5ScriptBuilder) {
288
297
  return __awaiter(this, void 0, void 0, function* () {
289
298
  if (!nep5ScriptBuilder || nep5ScriptBuilder.isEmpty()) {
@@ -304,7 +313,7 @@ _BSNeoLegacy_instances = new WeakSet(), _BSNeoLegacy_generateSigningCallback = f
304
313
  const sharedConfig = yield neon_js_1.api.fillBalance(config);
305
314
  let signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signTransfer).call(this, Object.assign({}, sharedConfig), nep5ScriptBuilder);
306
315
  if (__classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_hasTransactionMoreThanMaxSize).call(this, signedConfig)) {
307
- signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signTransfer).call(this, Object.assign(Object.assign({}, sharedConfig), { fees: BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION }), nep5ScriptBuilder);
316
+ signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signTransfer).call(this, __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_getRequiredTransactionFeeConfig).call(this, sharedConfig), nep5ScriptBuilder);
308
317
  }
309
318
  signedConfig = yield neon_js_1.api.sendTx(signedConfig);
310
319
  return signedConfig.response.txid;
@@ -322,7 +331,7 @@ _BSNeoLegacy_instances = new WeakSet(), _BSNeoLegacy_generateSigningCallback = f
322
331
  const sharedConfig = yield neon_js_1.api.fillClaims(config);
323
332
  let signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signClaim).call(this, Object.assign({}, sharedConfig));
324
333
  if (__classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_hasTransactionMoreThanMaxSize).call(this, signedConfig)) {
325
- signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signClaim).call(this, Object.assign(Object.assign({}, sharedConfig), { fees: BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION }));
334
+ signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signClaim).call(this, __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_getRequiredTransactionFeeConfig).call(this, sharedConfig));
326
335
  }
327
336
  signedConfig = yield neon_js_1.api.sendTx(signedConfig);
328
337
  return signedConfig.response.txid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "1.12.5",
3
+ "version": "1.12.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -14,7 +14,7 @@
14
14
  "@ledgerhq/hw-transport": "~6.31.8",
15
15
  "axios": "~1.8.2",
16
16
  "date-fns": "~4.1.0",
17
- "@cityofzion/blockchain-service": "1.19.2",
17
+ "@cityofzion/blockchain-service": "1.19.3",
18
18
  "@cityofzion/bs-asteroid-sdk": "0.9.1"
19
19
  },
20
20
  "devDependencies": {
@@ -25,8 +25,8 @@
25
25
  "dotenv": "16.3.1",
26
26
  "eslint": "^8.48.0",
27
27
  "jest": "29.6.2",
28
- "ts-jest": "29.1.1",
29
- "ts-node": "10.9.1",
28
+ "ts-jest": "~29.4.0",
29
+ "ts-node": "~10.9.2",
30
30
  "typescript": "4.9.5"
31
31
  },
32
32
  "scripts": {