@cityofzion/bs-neox 1.2.5 → 1.3.1
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 +3 -2
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.js +179 -15
- 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 -1
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +10 -11
- package/package.json +4 -4
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,10 +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
|
+
#private;
|
|
5
6
|
static BASE_URL_BY_CHAIN_ID: Partial<Record<BSNeoXNetworkId, string>>;
|
|
6
7
|
static getClient(network: Network<BSNeoXNetworkId>): import("axios").AxiosInstance;
|
|
7
|
-
constructor(network: Network<BSNeoXNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService);
|
|
8
|
+
constructor(network: Network<BSNeoXNetworkId>, nftDataService: NftDataService, explorerService: ExplorerService, tokenService: TokenService, neo3NeoXBridgeService: INeo3NeoXBridgeService);
|
|
8
9
|
maxTimeToConfirmTransactionInMs: number;
|
|
9
10
|
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
10
11
|
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
11
22
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
23
|
var t = {};
|
|
13
24
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -22,6 +33,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
33
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
35
|
};
|
|
36
|
+
var _BlockscoutBDSNeoX_instances, _BlockscoutBDSNeoX_nftDataService, _BlockscoutBDSNeoX_explorerService, _BlockscoutBDSNeoX_neo3NeoXBridgeService, _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction;
|
|
25
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
38
|
exports.BlockscoutBDSNeoX = void 0;
|
|
27
39
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -30,6 +42,9 @@ const ethers_1 = require("ethers");
|
|
|
30
42
|
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
31
43
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
32
44
|
const BSNeoXConstants_1 = require("../../constants/BSNeoXConstants");
|
|
45
|
+
const bridge_1 = require("../../assets/abis/bridge");
|
|
46
|
+
const Neo3NeoXBridgeService_1 = require("../neo3neoXBridge/Neo3NeoXBridgeService");
|
|
47
|
+
const neon_js_1 = require("@cityofzion/neon-js");
|
|
33
48
|
class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
34
49
|
static getClient(network) {
|
|
35
50
|
const baseURL = BlockscoutBDSNeoX.BASE_URL_BY_CHAIN_ID[network.id];
|
|
@@ -40,11 +55,19 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
40
55
|
baseURL,
|
|
41
56
|
});
|
|
42
57
|
}
|
|
43
|
-
constructor(network, nftDataService, explorerService) {
|
|
44
|
-
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
|
+
_BlockscoutBDSNeoX_instances.add(this);
|
|
61
|
+
_BlockscoutBDSNeoX_nftDataService.set(this, void 0);
|
|
62
|
+
_BlockscoutBDSNeoX_explorerService.set(this, void 0);
|
|
63
|
+
_BlockscoutBDSNeoX_neo3NeoXBridgeService.set(this, void 0);
|
|
45
64
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
65
|
+
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_nftDataService, nftDataService, "f");
|
|
66
|
+
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_explorerService, explorerService, "f");
|
|
67
|
+
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_neo3NeoXBridgeService, neo3NeoXBridgeService, "f");
|
|
46
68
|
}
|
|
47
69
|
getTransaction(txid) {
|
|
70
|
+
var _a;
|
|
48
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
72
|
const client = BlockscoutBDSNeoX.getClient(this._network);
|
|
50
73
|
const { data } = yield client.get(`/transactions/${txid}`);
|
|
@@ -52,13 +75,14 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
52
75
|
throw new Error('Transaction not found');
|
|
53
76
|
}
|
|
54
77
|
const nativeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
78
|
+
const to = (_a = data.to) === null || _a === void 0 ? void 0 : _a.hash;
|
|
55
79
|
const transfers = [];
|
|
56
80
|
const hasNativeTokenBeingTransferred = data.value !== '0';
|
|
57
81
|
if (hasNativeTokenBeingTransferred) {
|
|
58
82
|
transfers.push({
|
|
59
83
|
amount: ethers_1.ethers.utils.formatUnits(data.value, nativeToken.decimals),
|
|
60
84
|
from: data.from.hash,
|
|
61
|
-
to
|
|
85
|
+
to,
|
|
62
86
|
type: 'token',
|
|
63
87
|
contractHash: nativeToken.hash,
|
|
64
88
|
token: nativeToken,
|
|
@@ -74,7 +98,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
74
98
|
to: tokenTransfer.to.hash,
|
|
75
99
|
type: 'token',
|
|
76
100
|
contractHash: tokenTransfer.token.address,
|
|
77
|
-
token:
|
|
101
|
+
token: this._tokenService.normalizeToken({
|
|
78
102
|
symbol: tokenTransfer.token.symbol,
|
|
79
103
|
name: tokenTransfer.token.name,
|
|
80
104
|
hash: tokenTransfer.token.address,
|
|
@@ -85,23 +109,30 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
85
109
|
}
|
|
86
110
|
if (tokenTransfer.token.type === 'ERC-721') {
|
|
87
111
|
transfers.push({
|
|
88
|
-
|
|
112
|
+
tokenHash: tokenTransfer.total.token_id,
|
|
89
113
|
from: tokenTransfer.from.hash,
|
|
90
114
|
to: tokenTransfer.to.hash,
|
|
91
115
|
type: 'nft',
|
|
92
|
-
|
|
116
|
+
collectionHash: tokenTransfer.token.address,
|
|
93
117
|
});
|
|
94
118
|
}
|
|
95
119
|
}
|
|
96
120
|
}
|
|
97
|
-
|
|
121
|
+
let transaction = {
|
|
98
122
|
block: data.block,
|
|
99
123
|
hash: data.hash,
|
|
100
124
|
fee: ethers_1.ethers.utils.formatUnits(data.fee.value, nativeToken.decimals),
|
|
101
125
|
time: new Date(data.timestamp).getTime() / 1000,
|
|
102
126
|
notifications: [],
|
|
103
127
|
transfers,
|
|
128
|
+
type: 'default',
|
|
104
129
|
};
|
|
130
|
+
if (to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH) {
|
|
131
|
+
const [bridgeNeo3NeoXData] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, data));
|
|
132
|
+
if (bridgeNeo3NeoXData)
|
|
133
|
+
transaction = Object.assign(Object.assign({}, transaction), { type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData });
|
|
134
|
+
}
|
|
135
|
+
return transaction;
|
|
105
136
|
});
|
|
106
137
|
}
|
|
107
138
|
getTransactionsByAddress(params) {
|
|
@@ -118,13 +149,15 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
118
149
|
const nativeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
119
150
|
const transactions = [];
|
|
120
151
|
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
var _a;
|
|
121
153
|
const transfers = [];
|
|
154
|
+
const to = (_a = item.to) === null || _a === void 0 ? void 0 : _a.hash;
|
|
122
155
|
const hasNativeTokenBeingTransferred = item.value !== '0';
|
|
123
156
|
if (hasNativeTokenBeingTransferred) {
|
|
124
157
|
transfers.push({
|
|
125
158
|
amount: ethers_1.ethers.utils.formatUnits(item.value, nativeToken.decimals),
|
|
126
159
|
from: item.from.hash,
|
|
127
|
-
to
|
|
160
|
+
to,
|
|
128
161
|
type: 'token',
|
|
129
162
|
contractHash: nativeToken.hash,
|
|
130
163
|
token: nativeToken,
|
|
@@ -153,14 +186,21 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
153
186
|
/* empty */
|
|
154
187
|
}
|
|
155
188
|
}
|
|
156
|
-
|
|
189
|
+
let transaction = {
|
|
157
190
|
block: item.block,
|
|
158
191
|
hash: item.hash,
|
|
159
192
|
fee: ethers_1.ethers.utils.formatUnits(item.fee.value, nativeToken.decimals),
|
|
160
193
|
time: new Date(item.timestamp).getTime() / 1000,
|
|
161
194
|
notifications: [],
|
|
162
195
|
transfers,
|
|
163
|
-
|
|
196
|
+
type: 'default',
|
|
197
|
+
};
|
|
198
|
+
if (to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH) {
|
|
199
|
+
const [bridgeNeo3NeoXData] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, item));
|
|
200
|
+
if (bridgeNeo3NeoXData)
|
|
201
|
+
transaction = Object.assign(Object.assign({}, transaction), { type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData });
|
|
202
|
+
}
|
|
203
|
+
transactions.push(transaction);
|
|
164
204
|
}));
|
|
165
205
|
yield Promise.allSettled(promises);
|
|
166
206
|
return {
|
|
@@ -170,10 +210,11 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
170
210
|
});
|
|
171
211
|
}
|
|
172
212
|
getFullTransactionsByAddress(_a) {
|
|
173
|
-
var _b;
|
|
213
|
+
var _b, _c;
|
|
174
214
|
var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
|
|
175
215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
216
|
this._validateGetFullTransactionsByAddressParams(params);
|
|
217
|
+
const data = [];
|
|
177
218
|
const response = yield dora_ts_1.api.NeoXREST.getFullTransactionsByAddress({
|
|
178
219
|
address: params.address,
|
|
179
220
|
timestampFrom: params.dateFrom,
|
|
@@ -182,7 +223,103 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
182
223
|
cursor: nextCursor,
|
|
183
224
|
pageLimit: (_b = params.pageSize) !== null && _b !== void 0 ? _b : 50,
|
|
184
225
|
});
|
|
185
|
-
|
|
226
|
+
const items = (_c = response.data) !== null && _c !== void 0 ? _c : [];
|
|
227
|
+
const nativeToken = bs_ethereum_1.BSEthereumHelper.getNativeAsset(this._network);
|
|
228
|
+
const client = BlockscoutBDSNeoX.getClient(this._network);
|
|
229
|
+
const addressTemplateUrl = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_explorerService, "f").getAddressTemplateUrl();
|
|
230
|
+
const txTemplateUrl = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_explorerService, "f").getTxTemplateUrl();
|
|
231
|
+
const nftTemplateUrl = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_explorerService, "f").getNftTemplateUrl();
|
|
232
|
+
const contractTemplateUrl = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_explorerService, "f").getContractTemplateUrl();
|
|
233
|
+
const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
|
|
235
|
+
const txId = item.transactionID;
|
|
236
|
+
let newItem = {
|
|
237
|
+
txId,
|
|
238
|
+
txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
|
|
239
|
+
block: item.block,
|
|
240
|
+
date: item.date,
|
|
241
|
+
invocationCount: item.invocationCount,
|
|
242
|
+
notificationCount: item.notificationCount,
|
|
243
|
+
networkFeeAmount: networkFeeAmount
|
|
244
|
+
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: nativeToken.decimals })
|
|
245
|
+
: undefined,
|
|
246
|
+
systemFeeAmount: systemFeeAmount
|
|
247
|
+
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: nativeToken.decimals })
|
|
248
|
+
: undefined,
|
|
249
|
+
events: [],
|
|
250
|
+
type: 'default',
|
|
251
|
+
};
|
|
252
|
+
const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
var _e, _f, _g, _h, _j, _k, _l;
|
|
254
|
+
let nftEvent;
|
|
255
|
+
let assetEvent;
|
|
256
|
+
const { methodName, tokenID: tokenHash, contractHash } = event;
|
|
257
|
+
const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
|
|
258
|
+
const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
|
|
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 : '';
|
|
260
|
+
const isErc1155 = this._supportedErc1155Standards.includes(standard);
|
|
261
|
+
const isErc721 = this._supportedErc721Standards.includes(standard);
|
|
262
|
+
const isErc20 = this._supportedErc20Standards.includes(standard);
|
|
263
|
+
const isNft = (isErc1155 || isErc721) && !!tokenHash;
|
|
264
|
+
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
265
|
+
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
266
|
+
const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
|
|
267
|
+
if (isNft) {
|
|
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;
|
|
272
|
+
nftEvent = {
|
|
273
|
+
eventType: 'nft',
|
|
274
|
+
amount: undefined,
|
|
275
|
+
methodName,
|
|
276
|
+
from,
|
|
277
|
+
fromUrl,
|
|
278
|
+
to,
|
|
279
|
+
toUrl,
|
|
280
|
+
collectionHash: contractHash,
|
|
281
|
+
collectionHashUrl: contractHashUrl,
|
|
282
|
+
tokenHash,
|
|
283
|
+
tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
|
|
284
|
+
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
285
|
+
nftUrl,
|
|
286
|
+
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
287
|
+
collectionName: (_k = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _k === void 0 ? void 0 : _k.name,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
292
|
+
assetEvent = {
|
|
293
|
+
eventType: 'token',
|
|
294
|
+
amount: event.amount
|
|
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 })
|
|
296
|
+
: undefined,
|
|
297
|
+
methodName,
|
|
298
|
+
from,
|
|
299
|
+
fromUrl,
|
|
300
|
+
to,
|
|
301
|
+
toUrl,
|
|
302
|
+
contractHash,
|
|
303
|
+
contractHashUrl,
|
|
304
|
+
token: token !== null && token !== void 0 ? token : undefined,
|
|
305
|
+
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
if (newItem.type === 'default' && to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH) {
|
|
309
|
+
const [data] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
const response = yield client.get(`/transactions/${txId}`);
|
|
311
|
+
return __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, response.data);
|
|
312
|
+
}));
|
|
313
|
+
if (data)
|
|
314
|
+
newItem = Object.assign(Object.assign({}, newItem), { type: 'bridgeNeo3NeoX', data });
|
|
315
|
+
}
|
|
316
|
+
newItem.events.splice(eventIndex, 0, isNft ? nftEvent : assetEvent);
|
|
317
|
+
}));
|
|
318
|
+
yield Promise.allSettled(eventPromises);
|
|
319
|
+
data.splice(index, 0, newItem);
|
|
320
|
+
}));
|
|
321
|
+
yield Promise.allSettled(itemPromises);
|
|
322
|
+
return { nextCursor: response.nextCursor, data };
|
|
186
323
|
});
|
|
187
324
|
}
|
|
188
325
|
exportFullTransactionsByAddress(params) {
|
|
@@ -231,7 +368,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
231
368
|
}
|
|
232
369
|
getTokenInfo(tokenHash) {
|
|
233
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
const normalizedHash =
|
|
371
|
+
const normalizedHash = this._tokenService.normalizeHash(tokenHash);
|
|
235
372
|
const nativeAsset = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
236
373
|
if (nativeAsset.hash === normalizedHash) {
|
|
237
374
|
return nativeAsset;
|
|
@@ -248,7 +385,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
248
385
|
if (data.type !== 'ERC-20') {
|
|
249
386
|
throw new Error('Token is not an ERC-20 token');
|
|
250
387
|
}
|
|
251
|
-
const token =
|
|
388
|
+
const token = this._tokenService.normalizeToken({
|
|
252
389
|
decimals: data.decimals ? parseInt(data.decimals) : bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
253
390
|
hash: tokenHash,
|
|
254
391
|
name: data.name,
|
|
@@ -281,7 +418,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
281
418
|
if (balance.token.type !== 'ERC-20') {
|
|
282
419
|
return;
|
|
283
420
|
}
|
|
284
|
-
const token =
|
|
421
|
+
const token = this._tokenService.normalizeToken({
|
|
285
422
|
decimals: balance.token.decimals ? parseInt(balance.token.decimals) : bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
286
423
|
hash: balance.token.address,
|
|
287
424
|
name: balance.token.symbol,
|
|
@@ -311,6 +448,33 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
311
448
|
}
|
|
312
449
|
}
|
|
313
450
|
exports.BlockscoutBDSNeoX = BlockscoutBDSNeoX;
|
|
451
|
+
_BlockscoutBDSNeoX_nftDataService = new WeakMap(), _BlockscoutBDSNeoX_explorerService = new WeakMap(), _BlockscoutBDSNeoX_neo3NeoXBridgeService = new WeakMap(), _BlockscoutBDSNeoX_instances = new WeakSet(), _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction = function _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction(blockscoutTransaction) {
|
|
452
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
453
|
+
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
454
|
+
const input = BridgeInterface.parseTransaction({ data: blockscoutTransaction.raw_input });
|
|
455
|
+
const to = input.args._to;
|
|
456
|
+
const receiverAddress = neon_js_1.wallet.getAddressFromScriptHash(to.startsWith('0x') ? to.slice(2) : to);
|
|
457
|
+
if (input.name === 'withdrawNative') {
|
|
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(ethers_1.ethers.utils.formatUnits(blockscoutTransaction.value, token.decimals), {
|
|
462
|
+
decimals: token.decimals,
|
|
463
|
+
});
|
|
464
|
+
return { amount, token, receiverAddress };
|
|
465
|
+
}
|
|
466
|
+
if (input.name === 'withdrawToken') {
|
|
467
|
+
const token = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_neo3NeoXBridgeService, "f").tokens.find(this._tokenService.predicateByHash(BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN));
|
|
468
|
+
if (!token)
|
|
469
|
+
return undefined;
|
|
470
|
+
const amount = blockchain_service_1.BSBigNumberHelper.format(ethers_1.ethers.utils.formatUnits(input.args._amount, token.decimals), {
|
|
471
|
+
decimals: token.decimals,
|
|
472
|
+
});
|
|
473
|
+
return { amount, token, receiverAddress };
|
|
474
|
+
}
|
|
475
|
+
return undefined;
|
|
476
|
+
});
|
|
477
|
+
};
|
|
314
478
|
BlockscoutBDSNeoX.BASE_URL_BY_CHAIN_ID = {
|
|
315
479
|
'47763': `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/neox/mainnet`,
|
|
316
480
|
'12227332': 'https://dora-stage.coz.io/api/neox/testnet',
|
|
@@ -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
|
});
|
|
@@ -2,7 +2,7 @@ import { INeo3NeoXBridgeService, TBridgeToken, TNeo3NeoXBridgeServiceBridgeParam
|
|
|
2
2
|
import { BSNeoX } from '../../BSNeoX';
|
|
3
3
|
export declare class Neo3NeoXBridgeService<BSName extends string> implements INeo3NeoXBridgeService<BSName> {
|
|
4
4
|
#private;
|
|
5
|
-
readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
5
|
+
static readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
6
6
|
readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
7
7
|
tokens: TBridgeToken<BSName>[];
|
|
8
8
|
constructor(service: BSNeoX<BSName>);
|
|
@@ -37,7 +37,6 @@ const BSNeoXHelper_1 = require("../../helpers/BSNeoXHelper");
|
|
|
37
37
|
class Neo3NeoXBridgeService {
|
|
38
38
|
constructor(service) {
|
|
39
39
|
_Neo3NeoXBridgeService_instances.add(this);
|
|
40
|
-
this.BRIDGE_SCRIPT_HASH = '0x1212000000000000000000000000000000000004';
|
|
41
40
|
this.BRIDGE_BASE_CONFIRMATION_URL = 'https://xexplorer.neo.org:8877/api/v1/transactions/deposits';
|
|
42
41
|
_Neo3NeoXBridgeService_service.set(this, void 0);
|
|
43
42
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeService_service, service, "f");
|
|
@@ -50,8 +49,8 @@ class Neo3NeoXBridgeService {
|
|
|
50
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
50
|
try {
|
|
52
51
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url);
|
|
53
|
-
const bridgeContract = new ethers_1.ethers.Contract(
|
|
54
|
-
const isNativeToken =
|
|
52
|
+
const bridgeContract = new ethers_1.ethers.Contract(Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI, provider);
|
|
53
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
55
54
|
const response = isNativeToken
|
|
56
55
|
? yield bridgeContract.nativeBridge()
|
|
57
56
|
: yield bridgeContract.tokenBridges(token.hash);
|
|
@@ -75,7 +74,7 @@ class Neo3NeoXBridgeService {
|
|
|
75
74
|
getApprovalFee(params) {
|
|
76
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
76
|
try {
|
|
78
|
-
const isNativeToken =
|
|
77
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
79
78
|
if (isNativeToken) {
|
|
80
79
|
throw new blockchain_service_1.BSError('No allowance fee for native token', 'NO_ALLOWANCE_FEE');
|
|
81
80
|
}
|
|
@@ -103,10 +102,10 @@ class Neo3NeoXBridgeService {
|
|
|
103
102
|
throw new blockchain_service_1.BSError('Bridging to Neo3 is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
104
103
|
const { account } = params;
|
|
105
104
|
const signer = yield __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").generateSigner(account);
|
|
106
|
-
const bridgeContract = new ethers_1.ethers.Contract(
|
|
105
|
+
const bridgeContract = new ethers_1.ethers.Contract(Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI);
|
|
107
106
|
const to = '0x' + neon_js_1.wallet.getScriptHashFromAddress(params.receiverAddress);
|
|
108
107
|
const bridgeFee = ethers_1.ethers.utils.parseUnits(params.bridgeFee, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals);
|
|
109
|
-
const isNativeToken =
|
|
108
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
110
109
|
let bridgeTransactionParam = {
|
|
111
110
|
type: 2,
|
|
112
111
|
};
|
|
@@ -153,7 +152,7 @@ class Neo3NeoXBridgeService {
|
|
|
153
152
|
}
|
|
154
153
|
try {
|
|
155
154
|
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
156
|
-
const isNativeToken =
|
|
155
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
157
156
|
let nonce;
|
|
158
157
|
if (isNativeToken) {
|
|
159
158
|
const item = data.items[0];
|
|
@@ -180,7 +179,7 @@ class Neo3NeoXBridgeService {
|
|
|
180
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
180
|
try {
|
|
182
181
|
let url;
|
|
183
|
-
const isNativeToken =
|
|
182
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
184
183
|
if (isNativeToken) {
|
|
185
184
|
url = `${this.BRIDGE_BASE_CONFIRMATION_URL}/${params.nonce}`;
|
|
186
185
|
}
|
|
@@ -204,7 +203,7 @@ _Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances
|
|
|
204
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
205
204
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url);
|
|
206
205
|
const erc20Contract = new ethers_1.ethers.Contract(params.token.hash, bs_ethereum_1.ERC20_ABI, provider);
|
|
207
|
-
const allowance = yield erc20Contract.allowance(params.account.address,
|
|
206
|
+
const allowance = yield erc20Contract.allowance(params.account.address, Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH);
|
|
208
207
|
const allowanceNumber = blockchain_service_1.BSBigNumberHelper.fromDecimals(allowance.toString(), BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN.decimals);
|
|
209
208
|
// We are using 0 as the decimals because the NEO token in Neo3 has 0 decimals
|
|
210
209
|
const fixedAmount = blockchain_service_1.BSBigNumberHelper.format(params.amount, { decimals: 0 });
|
|
@@ -212,7 +211,7 @@ _Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances
|
|
|
212
211
|
return null;
|
|
213
212
|
}
|
|
214
213
|
const amount = ethers_1.ethers.utils.parseUnits(fixedAmount, params.token.decimals);
|
|
215
|
-
|
|
216
|
-
return populatedApproveTransaction;
|
|
214
|
+
return yield erc20Contract.populateTransaction.approve(Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH, amount);
|
|
217
215
|
});
|
|
218
216
|
};
|
|
217
|
+
Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH = '0x1212000000000000000000000000000000000004';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
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.
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"eslint": "^8.48.0",
|
|
30
30
|
"jest": "29.6.2",
|
|
31
31
|
"ts-jest": "29.1.1",
|
|
32
|
-
"ts-node": "10.9.
|
|
32
|
+
"ts-node": "~10.9.2",
|
|
33
33
|
"typescript": "4.9.5"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|