@cityofzion/bs-multichain 1.0.4 → 1.0.6
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.
|
@@ -171,7 +171,11 @@ class Neo3NeoXBridgeOrchestrator {
|
|
|
171
171
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: constants.bridgeFee }, "a", _Neo3NeoXBridgeOrchestrator_bridgeFee_set);
|
|
172
172
|
const bridgeMaxAmountBn = blockchain_service_1.BSBigNumberHelper.fromNumber(constants.bridgeMaxAmount);
|
|
173
173
|
const tokenBalanceAmountBn = blockchain_service_1.BSBigNumberHelper.fromNumber((_a = tokenToUseBalance === null || tokenToUseBalance === void 0 ? void 0 : tokenToUseBalance.amount) !== null && _a !== void 0 ? _a : 0);
|
|
174
|
-
const
|
|
174
|
+
const isFeeToken = blockchain_service_1.BSTokenHelper.predicateByHash(this.fromService.feeToken)(__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value);
|
|
175
|
+
const maxTokenBalanceAmountBn = isFeeToken
|
|
176
|
+
? tokenBalanceAmountBn.minus(constants.bridgeFee)
|
|
177
|
+
: tokenBalanceAmountBn;
|
|
178
|
+
const max = Math.max(0, Math.min(bridgeMaxAmountBn.toNumber(), maxTokenBalanceAmountBn.toNumber()));
|
|
175
179
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: blockchain_service_1.BSBigNumberHelper.format(max, { decimals: __classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value.decimals }) }, "a", _Neo3NeoXBridgeOrchestrator_amountToUseMax_set);
|
|
176
180
|
}
|
|
177
181
|
catch (error) {
|
|
@@ -192,8 +196,8 @@ class Neo3NeoXBridgeOrchestrator {
|
|
|
192
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
193
197
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: amount }, "a", _Neo3NeoXBridgeOrchestrator_amountToUse_set);
|
|
194
198
|
if (!amount) {
|
|
195
|
-
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { valid: null, loading: false }, "a", _Neo3NeoXBridgeOrchestrator_amountToUse_set);
|
|
196
|
-
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: null, loading: false }, "a", _Neo3NeoXBridgeOrchestrator_amountToReceive_set);
|
|
199
|
+
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { valid: null, loading: false, error: null }, "a", _Neo3NeoXBridgeOrchestrator_amountToUse_set);
|
|
200
|
+
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: null, loading: false, error: null }, "a", _Neo3NeoXBridgeOrchestrator_amountToReceive_set);
|
|
197
201
|
return;
|
|
198
202
|
}
|
|
199
203
|
if (__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_amountToUseTimeout, "f") !== null)
|
|
@@ -239,7 +243,7 @@ class Neo3NeoXBridgeOrchestrator {
|
|
|
239
243
|
if (newBridgeFee.plus(isFeeToken ? amountToUseBn : 0).isGreaterThan((_b = (_a = __classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_feeTokenBalance, "f")) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0)) {
|
|
240
244
|
throw new blockchain_service_1.BSError('You do not have enough fee token balance to cover the bridge fee', 'INSUFFICIENT_FEE_TOKEN_BALANCE');
|
|
241
245
|
}
|
|
242
|
-
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { valid: true }, "a", _Neo3NeoXBridgeOrchestrator_amountToUse_set);
|
|
246
|
+
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { valid: true, error: null }, "a", _Neo3NeoXBridgeOrchestrator_amountToUse_set);
|
|
243
247
|
}
|
|
244
248
|
catch (error) {
|
|
245
249
|
const treatedError = __classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "m", _Neo3NeoXBridgeOrchestrator_treatError).call(this, error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-multichain",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"eslint": "^8.48.0",
|
|
21
21
|
"jest": "29.6.2",
|
|
22
22
|
"ts-jest": "29.1.1",
|
|
23
|
-
"ts-node": "10.9.
|
|
23
|
+
"ts-node": "~10.9.2",
|
|
24
24
|
"typescript": "4.9.5",
|
|
25
25
|
"typed-emitter": "~2.1.0",
|
|
26
26
|
"@types/lodash": "~4.17.12",
|