@cityofzion/bs-neox 1.3.0 → 1.3.2
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/BSNeoX.js +4 -3
- package/dist/constants/BSNeoXConstants.d.ts +1 -0
- package/dist/constants/BSNeoXConstants.js +9 -3
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.d.ts +2 -2
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.js +35 -29
- package/dist/services/exchange-data/FlamingoForthewinEDSNeoX.d.ts +2 -2
- package/dist/services/exchange-data/FlamingoForthewinEDSNeoX.js +2 -2
- package/dist/services/explorer/BlockscoutESNeoX.d.ts +2 -2
- package/dist/services/explorer/BlockscoutESNeoX.js +2 -2
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +1 -0
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +6 -5
- package/package.json +3 -3
package/dist/BSNeoX.js
CHANGED
|
@@ -18,11 +18,12 @@ class BSNeoX extends bs_ethereum_1.BSEthereum {
|
|
|
18
18
|
}
|
|
19
19
|
setNetwork(network) {
|
|
20
20
|
this.network = network;
|
|
21
|
+
this.tokenService = new bs_ethereum_1.TokenServiceEthereum();
|
|
21
22
|
this.nftDataService = new GhostMarketNDSNeoX_1.GhostMarketNDSNeoX(network);
|
|
22
|
-
this.explorerService = new BlockscoutESNeoX_1.BlockscoutESNeoX(network);
|
|
23
|
-
this.exchangeDataService = new FlamingoForthewinEDSNeoX_1.FlamingoForthewinEDSNeoX(network);
|
|
24
|
-
this.blockchainDataService = new BlockscoutBDSNeoX_1.BlockscoutBDSNeoX(network, this.nftDataService, this.explorerService);
|
|
23
|
+
this.explorerService = new BlockscoutESNeoX_1.BlockscoutESNeoX(network, this.tokenService);
|
|
24
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeoX_1.FlamingoForthewinEDSNeoX(network, this.tokenService);
|
|
25
25
|
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
26
|
+
this.blockchainDataService = new BlockscoutBDSNeoX_1.BlockscoutBDSNeoX(network, this.nftDataService, this.explorerService, this.tokenService, this.neo3NeoXBridgeService);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
exports.BSNeoX = BSNeoX;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Network, NetworkId, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
export type BSNeoXNetworkId = NetworkId<'47763' | '12227332'>;
|
|
3
3
|
export declare class BSNeoXConstants {
|
|
4
|
+
#private;
|
|
4
5
|
static NATIVE_ASSET: Token;
|
|
5
6
|
static NEO_TOKEN: Token;
|
|
6
7
|
static RPC_LIST_BY_NETWORK_ID: Record<BSNeoXNetworkId, string[]>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _a, _BSNeoXConstants_tokenService;
|
|
3
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
9
|
exports.BSNeoXConstants = void 0;
|
|
5
10
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
@@ -7,13 +12,14 @@ class BSNeoXConstants {
|
|
|
7
12
|
}
|
|
8
13
|
exports.BSNeoXConstants = BSNeoXConstants;
|
|
9
14
|
_a = BSNeoXConstants;
|
|
10
|
-
|
|
15
|
+
_BSNeoXConstants_tokenService = { value: new bs_ethereum_1.TokenServiceEthereum() };
|
|
16
|
+
BSNeoXConstants.NATIVE_ASSET = __classPrivateFieldGet(_a, _a, "f", _BSNeoXConstants_tokenService).normalizeToken({
|
|
11
17
|
symbol: 'GAS',
|
|
12
18
|
name: 'GAS',
|
|
13
19
|
decimals: 18,
|
|
14
20
|
hash: '0x',
|
|
15
21
|
});
|
|
16
|
-
BSNeoXConstants.NEO_TOKEN =
|
|
22
|
+
BSNeoXConstants.NEO_TOKEN = __classPrivateFieldGet(_a, _a, "f", _BSNeoXConstants_tokenService).normalizeToken({
|
|
17
23
|
name: 'NEO',
|
|
18
24
|
symbol: 'NEO',
|
|
19
25
|
decimals: 18,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, ExplorerService, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, ContractResponse, ExplorerService, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, INeo3NeoXBridgeService, Network, NftDataService, Token, TokenService, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { DoraBDSEthereum } from '@cityofzion/bs-ethereum';
|
|
3
3
|
import { BSNeoXNetworkId } from '../../constants/BSNeoXConstants';
|
|
4
4
|
export declare class BlockscoutBDSNeoX extends DoraBDSEthereum<BSNeoXNetworkId> {
|
|
5
5
|
#private;
|
|
6
6
|
static BASE_URL_BY_CHAIN_ID: Partial<Record<BSNeoXNetworkId, string>>;
|
|
7
7
|
static getClient(network: Network<BSNeoXNetworkId>): import("axios").AxiosInstance;
|
|
8
|
-
constructor(network: Network<BSNeoXNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService);
|
|
8
|
+
constructor(network: Network<BSNeoXNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService, tokenService: TokenService, neo3NeoXBridgeService: INeo3NeoXBridgeService);
|
|
9
9
|
maxTimeToConfirmTransactionInMs: number;
|
|
10
10
|
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
11
11
|
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
@@ -33,7 +33,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
33
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
35
|
};
|
|
36
|
-
var _BlockscoutBDSNeoX_instances, _BlockscoutBDSNeoX_nftDataService, _BlockscoutBDSNeoX_explorerService, _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction;
|
|
36
|
+
var _BlockscoutBDSNeoX_instances, _BlockscoutBDSNeoX_nftDataService, _BlockscoutBDSNeoX_explorerService, _BlockscoutBDSNeoX_neo3NeoXBridgeService, _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.BlockscoutBDSNeoX = void 0;
|
|
39
39
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -55,14 +55,16 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
55
55
|
baseURL,
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
constructor(network, nftDataService, explorerService) {
|
|
59
|
-
super(network, BSNeoXConstants_1.BSNeoXConstants.ALL_NETWORK_IDS);
|
|
58
|
+
constructor(network, nftDataService, explorerService, tokenService, neo3NeoXBridgeService) {
|
|
59
|
+
super(network, BSNeoXConstants_1.BSNeoXConstants.ALL_NETWORK_IDS, tokenService);
|
|
60
60
|
_BlockscoutBDSNeoX_instances.add(this);
|
|
61
61
|
_BlockscoutBDSNeoX_nftDataService.set(this, void 0);
|
|
62
62
|
_BlockscoutBDSNeoX_explorerService.set(this, void 0);
|
|
63
|
+
_BlockscoutBDSNeoX_neo3NeoXBridgeService.set(this, void 0);
|
|
63
64
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
64
65
|
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_nftDataService, nftDataService, "f");
|
|
65
66
|
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_explorerService, explorerService, "f");
|
|
67
|
+
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_neo3NeoXBridgeService, neo3NeoXBridgeService, "f");
|
|
66
68
|
}
|
|
67
69
|
getTransaction(txid) {
|
|
68
70
|
var _a;
|
|
@@ -96,7 +98,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
96
98
|
to: tokenTransfer.to.hash,
|
|
97
99
|
type: 'token',
|
|
98
100
|
contractHash: tokenTransfer.token.address,
|
|
99
|
-
token:
|
|
101
|
+
token: this._tokenService.normalizeToken({
|
|
100
102
|
symbol: tokenTransfer.token.symbol,
|
|
101
103
|
name: tokenTransfer.token.name,
|
|
102
104
|
hash: tokenTransfer.token.address,
|
|
@@ -107,11 +109,11 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
107
109
|
}
|
|
108
110
|
if (tokenTransfer.token.type === 'ERC-721') {
|
|
109
111
|
transfers.push({
|
|
110
|
-
|
|
112
|
+
tokenHash: tokenTransfer.total.token_id,
|
|
111
113
|
from: tokenTransfer.from.hash,
|
|
112
114
|
to: tokenTransfer.to.hash,
|
|
113
115
|
type: 'nft',
|
|
114
|
-
|
|
116
|
+
collectionHash: tokenTransfer.token.address,
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
}
|
|
@@ -248,23 +250,25 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
248
250
|
type: 'default',
|
|
249
251
|
};
|
|
250
252
|
const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
var _e, _f, _g, _h, _j, _k;
|
|
253
|
+
var _e, _f, _g, _h, _j, _k, _l;
|
|
252
254
|
let nftEvent;
|
|
253
255
|
let assetEvent;
|
|
254
|
-
const { methodName, tokenID:
|
|
256
|
+
const { methodName, tokenID: tokenHash, contractHash } = event;
|
|
255
257
|
const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
|
|
256
258
|
const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
|
|
257
259
|
const standard = (_j = (_h = (_g = event.supportedStandards) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.toLowerCase()) !== null && _j !== void 0 ? _j : '';
|
|
258
260
|
const isErc1155 = this._supportedErc1155Standards.includes(standard);
|
|
259
261
|
const isErc721 = this._supportedErc721Standards.includes(standard);
|
|
260
262
|
const isErc20 = this._supportedErc20Standards.includes(standard);
|
|
261
|
-
const isNft = (isErc1155 || isErc721) && !!
|
|
263
|
+
const isNft = (isErc1155 || isErc721) && !!tokenHash;
|
|
262
264
|
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
263
265
|
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
264
|
-
const
|
|
266
|
+
const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
|
|
265
267
|
if (isNft) {
|
|
266
|
-
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _BlockscoutBDSNeoX_nftDataService, "f").getNft({
|
|
267
|
-
const nftUrl =
|
|
268
|
+
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _BlockscoutBDSNeoX_nftDataService, "f").getNft({ collectionHash: contractHash, tokenHash }));
|
|
269
|
+
const nftUrl = contractHash
|
|
270
|
+
? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{collectionHash}', contractHash).replace('{tokenHash}', tokenHash)
|
|
271
|
+
: undefined;
|
|
268
272
|
nftEvent = {
|
|
269
273
|
eventType: 'nft',
|
|
270
274
|
amount: undefined,
|
|
@@ -273,30 +277,30 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
273
277
|
fromUrl,
|
|
274
278
|
to,
|
|
275
279
|
toUrl,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
collectionHash: contractHash,
|
|
281
|
+
collectionHashUrl: contractHashUrl,
|
|
282
|
+
tokenHash,
|
|
279
283
|
tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
|
|
280
284
|
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
281
285
|
nftUrl,
|
|
282
286
|
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
283
|
-
collectionName: nft === null || nft === void 0 ? void 0 : nft.
|
|
287
|
+
collectionName: (_k = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _k === void 0 ? void 0 : _k.name,
|
|
284
288
|
};
|
|
285
289
|
}
|
|
286
290
|
else {
|
|
287
|
-
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(
|
|
291
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
288
292
|
assetEvent = {
|
|
289
293
|
eventType: 'token',
|
|
290
294
|
amount: event.amount
|
|
291
|
-
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (
|
|
295
|
+
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_l = token === null || token === void 0 ? void 0 : token.decimals) !== null && _l !== void 0 ? _l : event.tokenDecimals })
|
|
292
296
|
: undefined,
|
|
293
297
|
methodName,
|
|
294
298
|
from,
|
|
295
299
|
fromUrl,
|
|
296
300
|
to,
|
|
297
301
|
toUrl,
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
contractHash,
|
|
303
|
+
contractHashUrl,
|
|
300
304
|
token: token !== null && token !== void 0 ? token : undefined,
|
|
301
305
|
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
302
306
|
};
|
|
@@ -364,7 +368,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
364
368
|
}
|
|
365
369
|
getTokenInfo(tokenHash) {
|
|
366
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
-
const normalizedHash =
|
|
371
|
+
const normalizedHash = this._tokenService.normalizeHash(tokenHash);
|
|
368
372
|
const nativeAsset = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
369
373
|
if (nativeAsset.hash === normalizedHash) {
|
|
370
374
|
return nativeAsset;
|
|
@@ -381,7 +385,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
381
385
|
if (data.type !== 'ERC-20') {
|
|
382
386
|
throw new Error('Token is not an ERC-20 token');
|
|
383
387
|
}
|
|
384
|
-
const token =
|
|
388
|
+
const token = this._tokenService.normalizeToken({
|
|
385
389
|
decimals: data.decimals ? parseInt(data.decimals) : bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
386
390
|
hash: tokenHash,
|
|
387
391
|
name: data.name,
|
|
@@ -414,7 +418,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
414
418
|
if (balance.token.type !== 'ERC-20') {
|
|
415
419
|
return;
|
|
416
420
|
}
|
|
417
|
-
const token =
|
|
421
|
+
const token = this._tokenService.normalizeToken({
|
|
418
422
|
decimals: balance.token.decimals ? parseInt(balance.token.decimals) : bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
419
423
|
hash: balance.token.address,
|
|
420
424
|
name: balance.token.symbol,
|
|
@@ -444,21 +448,23 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
444
448
|
}
|
|
445
449
|
}
|
|
446
450
|
exports.BlockscoutBDSNeoX = BlockscoutBDSNeoX;
|
|
447
|
-
_BlockscoutBDSNeoX_nftDataService = new WeakMap(), _BlockscoutBDSNeoX_explorerService = new WeakMap(), _BlockscoutBDSNeoX_instances = new WeakSet(), _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction = function _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction(blockscoutTransaction) {
|
|
451
|
+
_BlockscoutBDSNeoX_nftDataService = new WeakMap(), _BlockscoutBDSNeoX_explorerService = new WeakMap(), _BlockscoutBDSNeoX_neo3NeoXBridgeService = new WeakMap(), _BlockscoutBDSNeoX_instances = new WeakSet(), _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction = function _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction(blockscoutTransaction) {
|
|
448
452
|
return __awaiter(this, void 0, void 0, function* () {
|
|
449
453
|
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
450
454
|
const input = BridgeInterface.parseTransaction({ data: blockscoutTransaction.raw_input });
|
|
451
455
|
const to = input.args._to;
|
|
452
456
|
const receiverAddress = neon_js_1.wallet.getAddressFromScriptHash(to.startsWith('0x') ? to.slice(2) : to);
|
|
453
457
|
if (input.name === 'withdrawNative') {
|
|
454
|
-
const token = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
});
|
|
458
|
+
const token = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_neo3NeoXBridgeService, "f").tokens.find(this._tokenService.predicateByHash(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET));
|
|
459
|
+
if (!token)
|
|
460
|
+
return undefined;
|
|
461
|
+
const amount = blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromNumber(ethers_1.ethers.utils.formatUnits(blockscoutTransaction.value, token.decimals)).minus(Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_FEE), { decimals: token.decimals });
|
|
458
462
|
return { amount, token, receiverAddress };
|
|
459
463
|
}
|
|
460
464
|
if (input.name === 'withdrawToken') {
|
|
461
|
-
const token = BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN;
|
|
465
|
+
const token = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_neo3NeoXBridgeService, "f").tokens.find(this._tokenService.predicateByHash(BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN));
|
|
466
|
+
if (!token)
|
|
467
|
+
return undefined;
|
|
462
468
|
const amount = blockchain_service_1.BSBigNumberHelper.format(ethers_1.ethers.utils.formatUnits(input.args._amount, token.decimals), {
|
|
463
469
|
decimals: token.decimals,
|
|
464
470
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesResponse, TokenService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeoXNetworkId } from '../../constants/BSNeoXConstants';
|
|
3
3
|
export declare class FlamingoForthewinEDSNeoX extends FlamingoForthewinEDS implements ExchangeDataService {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(network: Network<BSNeoXNetworkId
|
|
5
|
+
constructor(network: Network<BSNeoXNetworkId>, tokenService: TokenService);
|
|
6
6
|
getTokenPrices({ tokens }: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
7
7
|
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<import("@cityofzion/blockchain-service").TokenPricesHistoryResponse[]>;
|
|
8
8
|
}
|
|
@@ -25,8 +25,8 @@ exports.FlamingoForthewinEDSNeoX = void 0;
|
|
|
25
25
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
26
|
const BSNeoXConstants_1 = require("../../constants/BSNeoXConstants");
|
|
27
27
|
class FlamingoForthewinEDSNeoX extends blockchain_service_1.FlamingoForthewinEDS {
|
|
28
|
-
constructor(network) {
|
|
29
|
-
super();
|
|
28
|
+
constructor(network, tokenService) {
|
|
29
|
+
super(tokenService);
|
|
30
30
|
_FlamingoForthewinEDSNeoX_instances.add(this);
|
|
31
31
|
_FlamingoForthewinEDSNeoX_network.set(this, void 0);
|
|
32
32
|
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeoX_network, network, "f");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Network } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { Network, TokenService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BlockscoutESEthereum } from '@cityofzion/bs-ethereum';
|
|
3
3
|
import { BSNeoXNetworkId } from '../../constants/BSNeoXConstants';
|
|
4
4
|
export declare class BlockscoutESNeoX extends BlockscoutESEthereum<BSNeoXNetworkId> {
|
|
5
|
-
constructor(network: Network<BSNeoXNetworkId
|
|
5
|
+
constructor(network: Network<BSNeoXNetworkId>, tokenService: TokenService);
|
|
6
6
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BlockscoutESNeoX = void 0;
|
|
4
4
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
5
5
|
class BlockscoutESNeoX extends bs_ethereum_1.BlockscoutESEthereum {
|
|
6
|
-
constructor(network) {
|
|
7
|
-
super(network, {
|
|
6
|
+
constructor(network, tokenService) {
|
|
7
|
+
super(network, tokenService, {
|
|
8
8
|
'47763': 'https://xexplorer.neo.org',
|
|
9
9
|
'12227332': 'https://xt4scan.ngd.network',
|
|
10
10
|
});
|
|
@@ -3,6 +3,7 @@ import { BSNeoX } from '../../BSNeoX';
|
|
|
3
3
|
export declare class Neo3NeoXBridgeService<BSName extends string> implements INeo3NeoXBridgeService<BSName> {
|
|
4
4
|
#private;
|
|
5
5
|
static readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
6
|
+
static readonly BRIDGE_FEE = 0.1;
|
|
6
7
|
readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
7
8
|
tokens: TBridgeToken<BSName>[];
|
|
8
9
|
constructor(service: BSNeoX<BSName>);
|
|
@@ -50,7 +50,7 @@ class Neo3NeoXBridgeService {
|
|
|
50
50
|
try {
|
|
51
51
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url);
|
|
52
52
|
const bridgeContract = new ethers_1.ethers.Contract(Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI, provider);
|
|
53
|
-
const isNativeToken =
|
|
53
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
54
54
|
const response = isNativeToken
|
|
55
55
|
? yield bridgeContract.nativeBridge()
|
|
56
56
|
: yield bridgeContract.tokenBridges(token.hash);
|
|
@@ -74,7 +74,7 @@ class Neo3NeoXBridgeService {
|
|
|
74
74
|
getApprovalFee(params) {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
76
|
try {
|
|
77
|
-
const isNativeToken =
|
|
77
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
78
78
|
if (isNativeToken) {
|
|
79
79
|
throw new blockchain_service_1.BSError('No allowance fee for native token', 'NO_ALLOWANCE_FEE');
|
|
80
80
|
}
|
|
@@ -105,7 +105,7 @@ class Neo3NeoXBridgeService {
|
|
|
105
105
|
const bridgeContract = new ethers_1.ethers.Contract(Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI);
|
|
106
106
|
const to = '0x' + neon_js_1.wallet.getScriptHashFromAddress(params.receiverAddress);
|
|
107
107
|
const bridgeFee = ethers_1.ethers.utils.parseUnits(params.bridgeFee, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals);
|
|
108
|
-
const isNativeToken =
|
|
108
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
109
109
|
let bridgeTransactionParam = {
|
|
110
110
|
type: 2,
|
|
111
111
|
};
|
|
@@ -152,7 +152,7 @@ class Neo3NeoXBridgeService {
|
|
|
152
152
|
}
|
|
153
153
|
try {
|
|
154
154
|
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
155
|
-
const isNativeToken =
|
|
155
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
156
156
|
let nonce;
|
|
157
157
|
if (isNativeToken) {
|
|
158
158
|
const item = data.items[0];
|
|
@@ -179,7 +179,7 @@ class Neo3NeoXBridgeService {
|
|
|
179
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
180
|
try {
|
|
181
181
|
let url;
|
|
182
|
-
const isNativeToken =
|
|
182
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
183
183
|
if (isNativeToken) {
|
|
184
184
|
url = `${this.BRIDGE_BASE_CONFIRMATION_URL}/${params.nonce}`;
|
|
185
185
|
}
|
|
@@ -215,3 +215,4 @@ _Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances
|
|
|
215
215
|
});
|
|
216
216
|
};
|
|
217
217
|
Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH = '0x1212000000000000000000000000000000000004';
|
|
218
|
+
Neo3NeoXBridgeService.BRIDGE_FEE = 0.1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neox",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"axios": "1.8.2",
|
|
17
17
|
"ethers": "5.7.2",
|
|
18
18
|
"date-fns": "~4.1.0",
|
|
19
|
-
"@cityofzion/blockchain-service": "1.
|
|
20
|
-
"@cityofzion/bs-ethereum": "2.13.
|
|
19
|
+
"@cityofzion/blockchain-service": "1.21.0",
|
|
20
|
+
"@cityofzion/bs-ethereum": "2.13.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@ledgerhq/hw-transport-node-hid": "~6.29.9",
|