@cityofzion/bs-multichain 1.0.7 → 1.0.8
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.
package/dist/BSAggregator.js
CHANGED
|
@@ -36,13 +36,13 @@ class BSAggregator {
|
|
|
36
36
|
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateAddress(address));
|
|
37
37
|
}
|
|
38
38
|
validateTextAllBlockchains(text) {
|
|
39
|
-
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => [bs.validateAddress(text), bs.validateEncrypted(text), bs.validateKey(text)].some(it => it === true));
|
|
39
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => [bs.validateAddress(text), (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(text), bs.validateKey(text)].some(it => it === true));
|
|
40
40
|
}
|
|
41
41
|
validateKeyAllBlockchains(wif) {
|
|
42
42
|
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateKey(wif));
|
|
43
43
|
}
|
|
44
44
|
validateEncryptedAllBlockchains(keyOrJson) {
|
|
45
|
-
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => bs.validateEncrypted(keyOrJson));
|
|
45
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").some(bs => (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(keyOrJson));
|
|
46
46
|
}
|
|
47
47
|
getBlockchainNameByAddress(address) {
|
|
48
48
|
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").filter(bs => bs.validateAddress(address)).map(bs => bs.name);
|
|
@@ -51,7 +51,9 @@ class BSAggregator {
|
|
|
51
51
|
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").filter(bs => bs.validateKey(wif)).map(bs => bs.name);
|
|
52
52
|
}
|
|
53
53
|
getBlockchainNameByEncrypted(keyOrJson) {
|
|
54
|
-
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f")
|
|
54
|
+
return __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f")
|
|
55
|
+
.filter(bs => (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(keyOrJson))
|
|
56
|
+
.map(bs => bs.name);
|
|
55
57
|
}
|
|
56
58
|
generateAccountsFromMnemonic(mnemonic, untilIndexByBlockchainService) {
|
|
57
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -87,9 +87,9 @@ class Neo3NeoXBridgeOrchestrator {
|
|
|
87
87
|
if (!__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_availableTokensToUse_get).value)
|
|
88
88
|
throw new blockchain_service_1.BSError('No available tokens to use', 'NO_AVAILABLE_TOKENS');
|
|
89
89
|
if (token) {
|
|
90
|
-
if (__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value &&
|
|
90
|
+
if (__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value && this.fromService.tokenService.predicate(__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value)(token))
|
|
91
91
|
return;
|
|
92
|
-
if (!__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_availableTokensToUse_get).value.some(
|
|
92
|
+
if (!__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_availableTokensToUse_get).value.some(this.fromService.tokenService.predicate(token)))
|
|
93
93
|
throw new blockchain_service_1.BSError('You are trying to use a token that is not available', 'TOKEN_NOT_AVAILABLE');
|
|
94
94
|
tokenToReceive = this.toService.neo3NeoXBridgeService.tokens.find(item => token.multichainId === item.multichainId);
|
|
95
95
|
if (!tokenToReceive)
|
|
@@ -150,13 +150,13 @@ class Neo3NeoXBridgeOrchestrator {
|
|
|
150
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
151
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_balances, balances, "f");
|
|
152
152
|
const tokenToUseBalance = __classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value && balances
|
|
153
|
-
? balances === null || balances === void 0 ? void 0 : balances.find(item =>
|
|
153
|
+
? balances === null || balances === void 0 ? void 0 : balances.find(item => this.fromService.tokenService.predicateByHash(__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value)(item.token))
|
|
154
154
|
: null;
|
|
155
155
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, {
|
|
156
156
|
value: tokenToUseBalance,
|
|
157
157
|
}, "a", _Neo3NeoXBridgeOrchestrator_tokenToUseBalance_set);
|
|
158
158
|
const feeTokenBalance = balances
|
|
159
|
-
? balances === null || balances === void 0 ? void 0 : balances.find(item =>
|
|
159
|
+
? balances === null || balances === void 0 ? void 0 : balances.find(item => this.fromService.tokenService.predicateByHash(this.fromService.feeToken)(item.token))
|
|
160
160
|
: null;
|
|
161
161
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_feeTokenBalance, feeTokenBalance, "f");
|
|
162
162
|
if (tokenToUseBalance === null || !__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value) {
|
|
@@ -171,7 +171,7 @@ 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 isFeeToken =
|
|
174
|
+
const isFeeToken = this.fromService.tokenService.predicateByHash(this.fromService.feeToken)(__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value);
|
|
175
175
|
const maxTokenBalanceAmountBn = isFeeToken
|
|
176
176
|
? tokenBalanceAmountBn.minus(constants.bridgeFee)
|
|
177
177
|
: tokenBalanceAmountBn;
|
|
@@ -239,7 +239,7 @@ class Neo3NeoXBridgeOrchestrator {
|
|
|
239
239
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, {
|
|
240
240
|
value: blockchain_service_1.BSBigNumberHelper.format(newBridgeFee, { decimals: this.fromService.feeToken.decimals }),
|
|
241
241
|
}, "a", _Neo3NeoXBridgeOrchestrator_bridgeFee_set);
|
|
242
|
-
const isFeeToken =
|
|
242
|
+
const isFeeToken = this.fromService.tokenService.predicateByHash(this.fromService.feeToken)(__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value);
|
|
243
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)) {
|
|
244
244
|
throw new blockchain_service_1.BSError('You do not have enough fee token balance to cover the bridge fee', 'INSUFFICIENT_FEE_TOKEN_BALANCE');
|
|
245
245
|
}
|
|
@@ -217,14 +217,14 @@ _SimpleSwapApi_tickersBySimpleSwapBlockchain = new WeakMap(), _SimpleSwapApi_axi
|
|
|
217
217
|
let blockchainService;
|
|
218
218
|
let decimals;
|
|
219
219
|
let hash = (_a = currency.contractAddress) !== null && _a !== void 0 ? _a : undefined;
|
|
220
|
-
const normalizedHash = hash ? blockchain_service_1.BSTokenHelper.normalizeHash(hash) : '';
|
|
221
220
|
const lowerCaseSymbol = symbol.toLowerCase();
|
|
222
221
|
const tickers = __classPrivateFieldGet(this, _SimpleSwapApi_tickersBySimpleSwapBlockchain, "f")[simpleSwapBlockchain];
|
|
223
222
|
if (chainsByServiceNameEntry) {
|
|
224
223
|
blockchain = chainsByServiceNameEntry[0];
|
|
225
224
|
blockchainService = options.blockchainServicesByName[blockchain];
|
|
225
|
+
const normalizedHash = hash && blockchainService ? blockchainService.tokenService.normalizeHash(hash) : '';
|
|
226
226
|
const token = blockchainService.tokens.find(item => {
|
|
227
|
-
if (normalizedHash &&
|
|
227
|
+
if (normalizedHash && blockchainService && blockchainService.tokenService.predicateByHash(item)(normalizedHash))
|
|
228
228
|
return true;
|
|
229
229
|
const currentLowerCaseSymbol = item.symbol.toLowerCase();
|
|
230
230
|
if (!normalizedHash)
|
|
@@ -87,20 +87,8 @@ class SimpleSwapOrchestrator {
|
|
|
87
87
|
simpleSwapCurrency = (_a = __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_availableTokensToUse_get).value.find(item => item.id === token.id)) !== null && _a !== void 0 ? _a : null;
|
|
88
88
|
if (!simpleSwapCurrency)
|
|
89
89
|
throw new Error('You are trying to use a token that is not available');
|
|
90
|
-
}
|
|
91
|
-
if (simpleSwapCurrency && simpleSwapCurrency.decimals === undefined) {
|
|
92
90
|
if (!(simpleSwapCurrency === null || simpleSwapCurrency === void 0 ? void 0 : simpleSwapCurrency.blockchain) || !simpleSwapCurrency.hash)
|
|
93
91
|
throw new Error('Token is not valid');
|
|
94
|
-
let decimals = 6;
|
|
95
|
-
try {
|
|
96
|
-
const service = __classPrivateFieldGet(this, _SimpleSwapOrchestrator_blockchainServicesByName, "f")[simpleSwapCurrency.blockchain];
|
|
97
|
-
const tokenInfo = yield service.blockchainDataService.getTokenInfo(simpleSwapCurrency.hash);
|
|
98
|
-
decimals = tokenInfo.decimals;
|
|
99
|
-
}
|
|
100
|
-
catch (_c) {
|
|
101
|
-
/* empty */
|
|
102
|
-
}
|
|
103
|
-
simpleSwapCurrency.decimals = decimals;
|
|
104
92
|
}
|
|
105
93
|
__classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { loading: false, value: simpleSwapCurrency }, "a", _SimpleSwapOrchestrator_tokenToUse_set);
|
|
106
94
|
if (((_b = __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_accountToUse_get).value) === null || _b === void 0 ? void 0 : _b.blockchain) !== (simpleSwapCurrency === null || simpleSwapCurrency === void 0 ? void 0 : simpleSwapCurrency.blockchain)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-multichain",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"axios": "~1.8.2",
|
|
14
14
|
"lodash": "~4.17.21",
|
|
15
|
-
"@cityofzion/blockchain-service": "1.
|
|
15
|
+
"@cityofzion/blockchain-service": "1.21.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/jest": "29.5.3",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@types/node": "~22.8.6",
|
|
28
28
|
"@typescript-eslint/eslint-plugin": "~8.12.2",
|
|
29
29
|
"@typescript-eslint/parser": "~8.12.2",
|
|
30
|
-
"@cityofzion/bs-
|
|
31
|
-
"@cityofzion/bs-
|
|
32
|
-
"@cityofzion/bs-
|
|
33
|
-
"@cityofzion/bs-
|
|
30
|
+
"@cityofzion/bs-neo-legacy": "1.13.1",
|
|
31
|
+
"@cityofzion/bs-ethereum": "2.13.1",
|
|
32
|
+
"@cityofzion/bs-neox": "1.3.1",
|
|
33
|
+
"@cityofzion/bs-neo3": "1.16.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsc --project tsconfig.build.json",
|