@cityofzion/bs-neo3 1.16.2 → 1.16.4

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.
Files changed (43) hide show
  1. package/dist/BSNeo3.d.ts +39 -30
  2. package/dist/BSNeo3.js +102 -54
  3. package/dist/constants/BSNeo3Constants.d.ts +12 -17
  4. package/dist/constants/BSNeo3Constants.js +221 -37
  5. package/dist/helpers/BSNeo3Helper.d.ts +5 -6
  6. package/dist/helpers/BSNeo3Helper.js +9 -8
  7. package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.d.ts +6 -0
  8. package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.js +26 -0
  9. package/dist/helpers/BSNeo3NeonJsSingletonHelper.d.ts +7 -0
  10. package/dist/helpers/BSNeo3NeonJsSingletonHelper.js +26 -0
  11. package/dist/index.d.ts +3 -2
  12. package/dist/index.js +3 -2
  13. package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +13 -12
  14. package/dist/services/blockchain-data/DoraBDSNeo3.js +130 -140
  15. package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +13 -19
  16. package/dist/services/blockchain-data/RpcBDSNeo3.js +28 -62
  17. package/dist/services/chaim-data/RpcCDSNeo3.d.ts +7 -0
  18. package/dist/services/chaim-data/RpcCDSNeo3.js +27 -0
  19. package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +6 -7
  20. package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +4 -19
  21. package/dist/services/explorer/DoraESNeo3.d.ts +5 -5
  22. package/dist/services/explorer/DoraESNeo3.js +19 -22
  23. package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +10 -10
  24. package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +28 -38
  25. package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +10 -9
  26. package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +26 -25
  27. package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +7 -11
  28. package/dist/services/nft-data/GhostMarketNDSNeo3.js +41 -79
  29. package/dist/services/vote/DoraVoteServiceNeo3.d.ts +8 -29
  30. package/dist/services/vote/DoraVoteServiceNeo3.js +81 -21
  31. package/dist/types.d.ts +84 -0
  32. package/dist/types.js +18 -0
  33. package/package.json +25 -25
  34. package/dist/assets/tokens/mainnet.json +0 -194
  35. package/dist/assets/tokens/native.json +0 -14
  36. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.d.ts +0 -34
  37. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.js +0 -102
  38. package/dist/interfaces.d.ts +0 -41
  39. package/dist/interfaces.js +0 -2
  40. package/dist/services/nft-data/RpcNDSNeo3.d.ts +0 -9
  41. package/dist/services/nft-data/RpcNDSNeo3.js +0 -59
  42. package/dist/services/vote/RpcVoteServiceNeo3.d.ts +0 -10
  43. package/dist/services/vote/RpcVoteServiceNeo3.js +0 -88
@@ -8,17 +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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
11
16
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
17
  if (kind === "m") throw new TypeError("Private method is not writable");
13
18
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
19
  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
20
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
21
  };
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
- };
22
22
  var __rest = (this && this.__rest) || function (s, e) {
23
23
  var t = {};
24
24
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -30,76 +30,69 @@ var __rest = (this && this.__rest) || function (s, e) {
30
30
  }
31
31
  return t;
32
32
  };
33
- var _DoraBDSNeo3_instances, _DoraBDSNeo3_supportedNep11Standards, _DoraBDSNeo3_nftDataService, _DoraBDSNeo3_explorerService, _DoraBDSNeo3_neo3NeoXBridgeService, _DoraBDSNeo3_validateAddress, _DoraBDSNeo3_validateFullTransactionsByAddressParams, _DoraBDSNeo3_validateGetFullTransactionsByAddressParams, _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications;
33
+ var _DoraBDSNeo3_instances, _a, _DoraBDSNeo3_apiInstance, _DoraBDSNeo3_api_get, _DoraBDSNeo3_convertByteStringToAddress, _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications;
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.DoraBDSNeo3 = exports.DoraNeoRest = void 0;
35
+ exports.DoraBDSNeo3 = void 0;
36
36
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
37
37
  const dora_ts_1 = require("@cityofzion/dora-ts");
38
- const neon_js_1 = require("@cityofzion/neon-js");
39
- const BSNeo3Constants_1 = require("../../constants/BSNeo3Constants");
40
- const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
41
38
  const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
42
- exports.DoraNeoRest = new dora_ts_1.api.NeoRESTApi({
43
- doraUrl: blockchain_service_1.BSCommonConstants.DORA_URL,
44
- endpoint: '/api/v2/neo3',
45
- });
39
+ const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
40
+ const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
46
41
  class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
47
- constructor(network, feeToken, claimToken, tokens, nftDataService, explorerService, tokenService, neo3NeoXBridgeService) {
48
- super(network, feeToken, claimToken, tokens, tokenService);
42
+ static getClient() {
43
+ return new dora_ts_1.api.NeoRESTApi({ doraUrl: blockchain_service_1.BSCommonConstants.DORA_URL, endpoint: '/api/v2/neo3' });
44
+ }
45
+ constructor(service) {
46
+ super(service);
49
47
  _DoraBDSNeo3_instances.add(this);
50
- _DoraBDSNeo3_supportedNep11Standards.set(this, ['nep11', 'nep-11']);
51
- _DoraBDSNeo3_nftDataService.set(this, void 0);
52
- _DoraBDSNeo3_explorerService.set(this, void 0);
53
- _DoraBDSNeo3_neo3NeoXBridgeService.set(this, void 0);
54
- __classPrivateFieldSet(this, _DoraBDSNeo3_nftDataService, nftDataService, "f");
55
- __classPrivateFieldSet(this, _DoraBDSNeo3_explorerService, explorerService, "f");
56
- __classPrivateFieldSet(this, _DoraBDSNeo3_neo3NeoXBridgeService, neo3NeoXBridgeService, "f");
48
+ _DoraBDSNeo3_apiInstance.set(this, void 0);
57
49
  }
58
50
  getTransaction(hash) {
59
51
  const _super = Object.create(null, {
60
52
  getTransaction: { get: () => super.getTransaction }
61
53
  });
62
- var _a, _b;
63
54
  return __awaiter(this, void 0, void 0, function* () {
64
- if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
55
+ var _b, _c;
56
+ if (BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(this._service.network)) {
65
57
  return yield _super.getTransaction.call(this, hash);
66
58
  }
67
59
  try {
68
- const data = yield exports.DoraNeoRest.transaction(hash, this._network.id);
69
- const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_a = data.sysfee) !== null && _a !== void 0 ? _a : 0);
70
- const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_b = data.netfee) !== null && _b !== void 0 ? _b : 0);
60
+ const data = yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).transaction(hash, this._service.network.id);
61
+ const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_b = data.sysfee) !== null && _b !== void 0 ? _b : 0);
62
+ const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_c = data.netfee) !== null && _c !== void 0 ? _c : 0);
71
63
  const totalFee = systemFeeNumber.plus(networkFeeNumber);
72
64
  return {
73
65
  block: data.block,
74
66
  time: Number(data.time),
75
67
  hash: data.hash,
76
- fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._feeToken.decimals }),
68
+ fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._service.feeToken.decimals }),
77
69
  notifications: [],
78
70
  transfers: [],
79
71
  type: 'default', // It's not possible to set the correct type because we don't have notifications here
80
72
  };
81
73
  }
82
- catch (_c) {
74
+ catch (_d) {
83
75
  throw new Error(`Transaction not found: ${hash}`);
84
76
  }
85
77
  });
86
78
  }
87
- getTransactionsByAddress({ address, nextPageParams = 1, }) {
79
+ getTransactionsByAddress(_b) {
88
80
  const _super = Object.create(null, {
89
81
  getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
90
82
  });
91
- return __awaiter(this, void 0, void 0, function* () {
92
- if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
83
+ return __awaiter(this, arguments, void 0, function* ({ address, nextPageParams = 1, }) {
84
+ if (BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(this._service.network)) {
93
85
  return yield _super.getTransactionsByAddress.call(this, { address, nextPageParams });
94
86
  }
95
- const data = yield exports.DoraNeoRest.addressTXFull(address, nextPageParams, this._network.id);
87
+ const data = yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).addressTXFull(address, nextPageParams, this._service.network.id);
88
+ const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
96
89
  const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
97
- var _a, _b, _c;
90
+ var _b, _c, _d;
98
91
  const transferPromises = [];
99
- const notifications = (_a = item.notifications) !== null && _a !== void 0 ? _a : [];
92
+ const notifications = (_b = item.notifications) !== null && _b !== void 0 ? _b : [];
100
93
  item.notifications.forEach(({ contract: contractHash, state, event_name: eventName }) => {
101
- var _a;
102
- const properties = (Array.isArray(state) ? state : (_a = state === null || state === void 0 ? void 0 : state.value) !== null && _a !== void 0 ? _a : []);
94
+ var _b;
95
+ const properties = (Array.isArray(state) ? state : ((_b = state === null || state === void 0 ? void 0 : state.value) !== null && _b !== void 0 ? _b : []));
103
96
  if (eventName !== 'Transfer' || (properties.length !== 3 && properties.length !== 4))
104
97
  return;
105
98
  const promise = () => __awaiter(this, void 0, void 0, function* () {
@@ -107,13 +100,13 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
107
100
  const isAsset = properties.length === 3;
108
101
  const from = properties[0].value;
109
102
  const to = properties[1].value;
110
- const convertedFrom = from ? this.convertByteStringToAddress(from) : 'Mint';
111
- const convertedTo = to ? this.convertByteStringToAddress(to) : 'Burn';
103
+ const convertedFrom = from ? __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_convertByteStringToAddress).call(this, from) : 'Mint';
104
+ const convertedTo = to ? __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_convertByteStringToAddress).call(this, to) : 'Burn';
112
105
  if (isAsset) {
113
106
  const token = yield this.getTokenInfo(contractHash);
114
107
  const amount = properties[2].value;
115
108
  return {
116
- amount: amount ? neon_js_1.u.BigInteger.fromNumber(amount).toDecimal((_b = token.decimals) !== null && _b !== void 0 ? _b : 0) : '0',
109
+ amount: amount ? u.BigInteger.fromNumber(amount).toDecimal((_b = token.decimals) !== null && _b !== void 0 ? _b : 0) : '0',
117
110
  from: convertedFrom,
118
111
  to: convertedTo,
119
112
  contractHash,
@@ -132,14 +125,14 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
132
125
  transferPromises.push(promise());
133
126
  });
134
127
  const transfers = yield Promise.all(transferPromises);
135
- const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_b = item.sysfee) !== null && _b !== void 0 ? _b : 0);
136
- const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_c = item.netfee) !== null && _c !== void 0 ? _c : 0);
128
+ const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_c = item.sysfee) !== null && _c !== void 0 ? _c : 0);
129
+ const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_d = item.netfee) !== null && _d !== void 0 ? _d : 0);
137
130
  const totalFee = systemFeeNumber.plus(networkFeeNumber);
138
131
  let transaction = {
139
132
  block: item.block,
140
133
  time: Number(item.time),
141
134
  hash: item.hash,
142
- fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._feeToken.decimals }),
135
+ fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._service.feeToken.decimals }),
143
136
  transfers,
144
137
  notifications: notifications.map(notification => ({
145
138
  eventName: notification.event_name,
@@ -161,27 +154,27 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
161
154
  };
162
155
  });
163
156
  }
164
- getFullTransactionsByAddress(_a) {
165
- var _b, _c;
166
- var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
157
+ getFullTransactionsByAddress(_b) {
167
158
  return __awaiter(this, void 0, void 0, function* () {
168
- __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateGetFullTransactionsByAddressParams).call(this, params);
169
- const data = [];
170
- const response = yield exports.DoraNeoRest.getFullTransactionsByAddress({
159
+ var _c, _d;
160
+ var { nextCursor } = _b, params = __rest(_b, ["nextCursor"]);
161
+ blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign({ service: this._service, supportedNetworksIds: _a.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS }, params));
162
+ const response = yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).getFullTransactionsByAddress({
171
163
  address: params.address,
172
164
  timestampFrom: params.dateFrom,
173
165
  timestampTo: params.dateTo,
174
- network: this._network.id,
166
+ network: this._service.network.id,
175
167
  cursor: nextCursor,
176
- pageLimit: (_b = params.pageSize) !== null && _b !== void 0 ? _b : 50,
168
+ pageLimit: (_c = params.pageSize) !== null && _c !== void 0 ? _c : 50,
177
169
  });
178
- const items = (_c = response.data) !== null && _c !== void 0 ? _c : [];
179
- const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getAddressTemplateUrl();
180
- const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getTxTemplateUrl();
181
- const nftTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getNftTemplateUrl();
182
- const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getContractTemplateUrl();
183
- const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
184
- var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
170
+ const items = (_d = response.data) !== null && _d !== void 0 ? _d : [];
171
+ const data = [];
172
+ const addressTemplateUrl = this._service.explorerService.getAddressTemplateUrl();
173
+ const txTemplateUrl = this._service.explorerService.getTxTemplateUrl();
174
+ const nftTemplateUrl = this._service.explorerService.getNftTemplateUrl();
175
+ const contractTemplateUrl = this._service.explorerService.getContractTemplateUrl();
176
+ const itemPromises = items.map((_b, index) => __awaiter(this, void 0, void 0, function* () {
177
+ var { networkFeeAmount, systemFeeAmount } = _b, item = __rest(_b, ["networkFeeAmount", "systemFeeAmount"]);
185
178
  const txId = item.transactionID;
186
179
  let newItem = {
187
180
  txId,
@@ -191,30 +184,30 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
191
184
  invocationCount: item.invocationCount,
192
185
  notificationCount: item.notificationCount,
193
186
  networkFeeAmount: networkFeeAmount
194
- ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: this._feeToken.decimals })
187
+ ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: this._service.feeToken.decimals })
195
188
  : undefined,
196
189
  systemFeeAmount: systemFeeAmount
197
- ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: this._feeToken.decimals })
190
+ ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: this._service.feeToken.decimals })
198
191
  : undefined,
199
192
  events: [],
200
193
  type: 'default',
201
194
  };
202
195
  const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
203
- var _e, _f, _g, _h, _j, _k, _l;
196
+ var _b, _c, _d, _e, _f, _g, _h;
204
197
  const { methodName, tokenID: tokenHash, contractHash, contractName } = event;
205
- const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
206
- const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
198
+ const from = (_b = event.from) !== null && _b !== void 0 ? _b : undefined;
199
+ const to = (_c = event.to) !== null && _c !== void 0 ? _c : undefined;
207
200
  const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
208
201
  const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
209
202
  const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
210
- 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 : '';
211
- const isNft = __classPrivateFieldGet(this, _DoraBDSNeo3_supportedNep11Standards, "f").includes(standard) && !!tokenHash;
203
+ const standard = (_f = (_e = (_d = event.supportedStandards) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.toLowerCase()) !== null && _f !== void 0 ? _f : '';
204
+ const isNft = _a.SUPPORTED_NEP11_STANDARDS.includes(standard) && !!tokenHash;
212
205
  if (isNft) {
213
- const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraBDSNeo3_nftDataService, "f").getNft({ collectionHash: contractHash, tokenHash }));
206
+ const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this._service.nftDataService.getNft({ collectionHash: contractHash, tokenHash }));
214
207
  const nftUrl = contractHash
215
208
  ? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{collectionHash}', contractHash).replace('{tokenHash}', tokenHash)
216
209
  : undefined;
217
- const nftEvent = {
210
+ newItem.events.splice(eventIndex, 0, {
218
211
  eventType: 'nft',
219
212
  amount: undefined,
220
213
  methodName,
@@ -229,32 +222,29 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
229
222
  nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
230
223
  nftUrl,
231
224
  name: nft === null || nft === void 0 ? void 0 : nft.name,
232
- collectionName: (_k = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _k === void 0 ? void 0 : _k.name,
233
- };
234
- newItem.events.splice(eventIndex, 0, nftEvent);
225
+ collectionName: (_g = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _g === void 0 ? void 0 : _g.name,
226
+ });
235
227
  return;
236
228
  }
237
- else {
238
- const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
239
- const assetEvent = {
240
- eventType: 'token',
241
- amount: event.amount
242
- ? 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 })
243
- : undefined,
244
- methodName,
245
- from,
246
- fromUrl,
247
- to,
248
- toUrl,
249
- contractHash,
250
- contractHashUrl,
251
- token: token !== null && token !== void 0 ? token : undefined,
252
- tokenType: 'nep-17',
253
- };
254
- newItem.events.splice(eventIndex, 0, assetEvent);
255
- }
229
+ const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
230
+ newItem.events.splice(eventIndex, 0, {
231
+ eventType: 'token',
232
+ amount: event.amount
233
+ ? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals })
234
+ : undefined,
235
+ methodName,
236
+ from,
237
+ fromUrl,
238
+ to,
239
+ toUrl,
240
+ contractHash,
241
+ contractHashUrl,
242
+ token: token !== null && token !== void 0 ? token : undefined,
243
+ tokenType: 'nep-17',
244
+ });
245
+ // Verify if the event is a bridgeNeo3NeoX event
256
246
  if (newItem.type === 'default' && contractName === 'NeoXBridge') {
257
- const [log] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => exports.DoraNeoRest.log(txId, this._network.id));
247
+ const [log] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).log(txId, this._service.network.id));
258
248
  if (!!log && log.vmstate === 'HALT') {
259
249
  const data = __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications).call(this, log.notifications || []);
260
250
  if (data)
@@ -271,12 +261,12 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
271
261
  }
272
262
  exportFullTransactionsByAddress(params) {
273
263
  return __awaiter(this, void 0, void 0, function* () {
274
- __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateFullTransactionsByAddressParams).call(this, params);
275
- return yield exports.DoraNeoRest.exportFullTransactionsByAddress({
264
+ blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign({ service: this._service, supportedNetworksIds: _a.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS }, params));
265
+ return yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).exportFullTransactionsByAddress({
276
266
  address: params.address,
277
267
  timestampFrom: params.dateFrom,
278
268
  timestampTo: params.dateTo,
279
- network: this._network.id,
269
+ network: this._service.network.id,
280
270
  });
281
271
  });
282
272
  }
@@ -284,20 +274,20 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
284
274
  const _super = Object.create(null, {
285
275
  getContract: { get: () => super.getContract }
286
276
  });
287
- var _a, _b;
288
277
  return __awaiter(this, void 0, void 0, function* () {
289
- if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
278
+ var _b, _c;
279
+ if (BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(this._service.network)) {
290
280
  return yield _super.getContract.call(this, contractHash);
291
281
  }
292
282
  try {
293
- const data = yield exports.DoraNeoRest.contract(contractHash, this._network.id);
283
+ const data = yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).contract(contractHash, this._service.network.id);
294
284
  return {
295
285
  hash: data.hash,
296
- methods: (_b = (_a = data.manifest.abi) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [],
286
+ methods: (_c = (_b = data.manifest.abi) === null || _b === void 0 ? void 0 : _b.methods) !== null && _c !== void 0 ? _c : [],
297
287
  name: data.manifest.name,
298
288
  };
299
289
  }
300
- catch (_c) {
290
+ catch (_d) {
301
291
  throw new Error(`Contract not found: ${contractHash}`);
302
292
  }
303
293
  });
@@ -307,7 +297,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
307
297
  getTokenInfo: { get: () => super.getTokenInfo }
308
298
  });
309
299
  return __awaiter(this, void 0, void 0, function* () {
310
- if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
300
+ if (BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(this._service.network)) {
311
301
  return yield _super.getTokenInfo.call(this, tokenHash);
312
302
  }
313
303
  try {
@@ -315,10 +305,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
315
305
  if (cachedToken) {
316
306
  return cachedToken;
317
307
  }
318
- let token = this._tokens.find(currentToken => this._tokenService.predicateByHash(tokenHash, currentToken));
308
+ let token = this._service.tokens.find(token => this._service.tokenService.predicateByHash(tokenHash, token));
319
309
  if (!token) {
320
- const { decimals, symbol, name, scripthash } = yield exports.DoraNeoRest.asset(tokenHash, this._network.id);
321
- token = this._tokenService.normalizeToken({
310
+ const { decimals, symbol, name, scripthash } = yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).asset(tokenHash, this._service.network.id);
311
+ token = this._service.tokenService.normalizeToken({
322
312
  decimals: Number(decimals),
323
313
  symbol,
324
314
  name,
@@ -328,7 +318,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
328
318
  this._tokenCache.set(tokenHash, token);
329
319
  return token;
330
320
  }
331
- catch (_a) {
321
+ catch (_b) {
332
322
  throw new Error(`Token not found: ${tokenHash}`);
333
323
  }
334
324
  });
@@ -338,10 +328,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
338
328
  getBalance: { get: () => super.getBalance }
339
329
  });
340
330
  return __awaiter(this, void 0, void 0, function* () {
341
- if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
331
+ if (BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(this._service.network)) {
342
332
  return yield _super.getBalance.call(this, address);
343
333
  }
344
- const response = yield exports.DoraNeoRest.balance(address, this._network.id);
334
+ const response = yield __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).balance(address, this._service.network.id);
345
335
  const promises = response.map((balance) => __awaiter(this, void 0, void 0, function* () {
346
336
  try {
347
337
  const token = yield this.getTokenInfo(balance.asset);
@@ -350,7 +340,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
350
340
  token,
351
341
  };
352
342
  }
353
- catch (_a) {
343
+ catch (_b) {
354
344
  // Empty block
355
345
  }
356
346
  }));
@@ -358,49 +348,49 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
358
348
  return balances.filter(balance => balance !== undefined);
359
349
  });
360
350
  }
361
- convertByteStringToAddress(byteString) {
362
- const account = new neon_js_1.wallet.Account(neon_js_1.u.reverseHex(neon_js_1.u.HexString.fromBase64(byteString).toString()));
363
- return account.address;
364
- }
365
351
  }
366
352
  exports.DoraBDSNeo3 = DoraBDSNeo3;
367
- _DoraBDSNeo3_supportedNep11Standards = new WeakMap(), _DoraBDSNeo3_nftDataService = new WeakMap(), _DoraBDSNeo3_explorerService = new WeakMap(), _DoraBDSNeo3_neo3NeoXBridgeService = new WeakMap(), _DoraBDSNeo3_instances = new WeakSet(), _DoraBDSNeo3_validateAddress = function _DoraBDSNeo3_validateAddress(address) {
368
- return neon_js_1.wallet.isAddress(address, 53);
369
- }, _DoraBDSNeo3_validateFullTransactionsByAddressParams = function _DoraBDSNeo3_validateFullTransactionsByAddressParams(params) {
370
- if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network))
371
- throw new Error('Only Mainnet and Testnet are supported');
372
- blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
373
- if (!__classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateAddress).call(this, params.address))
374
- throw new Error('Invalid address param');
375
- }, _DoraBDSNeo3_validateGetFullTransactionsByAddressParams = function _DoraBDSNeo3_validateGetFullTransactionsByAddressParams(_a) {
376
- var { pageSize } = _a, params = __rest(_a, ["pageSize"]);
377
- if (typeof pageSize === 'number' && (isNaN(pageSize) || pageSize < 1 || pageSize > 500))
378
- throw new Error('Page size should be between 1 and 500');
379
- __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateFullTransactionsByAddressParams).call(this, params);
353
+ _a = DoraBDSNeo3, _DoraBDSNeo3_apiInstance = new WeakMap(), _DoraBDSNeo3_instances = new WeakSet(), _DoraBDSNeo3_api_get = function _DoraBDSNeo3_api_get() {
354
+ if (!__classPrivateFieldGet(this, _DoraBDSNeo3_apiInstance, "f")) {
355
+ __classPrivateFieldSet(this, _DoraBDSNeo3_apiInstance, _a.getClient(), "f");
356
+ }
357
+ return __classPrivateFieldGet(this, _DoraBDSNeo3_apiInstance, "f");
358
+ }, _DoraBDSNeo3_convertByteStringToAddress = function _DoraBDSNeo3_convertByteStringToAddress(byteString) {
359
+ const { wallet, u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
360
+ const account = new wallet.Account(u.reverseHex(u.HexString.fromBase64(byteString).toString()));
361
+ return account.address;
380
362
  }, _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications = function _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications(notifications) {
381
- var _a, _b, _c;
363
+ var _b, _c, _d, _e, _f;
382
364
  const gasNotification = notifications.find(({ event_name }) => event_name === 'NativeDeposit');
383
365
  const isNativeToken = !!gasNotification;
384
366
  const neoNotification = !isNativeToken
385
367
  ? notifications.find(({ event_name }) => event_name === 'TokenDeposit')
386
368
  : undefined;
387
369
  const notification = isNativeToken ? gasNotification : neoNotification;
388
- const notificationStateValue = (_a = notification === null || notification === void 0 ? void 0 : notification.state) === null || _a === void 0 ? void 0 : _a.value;
370
+ const notificationStateValue = (_b = notification === null || notification === void 0 ? void 0 : notification.state) === null || _b === void 0 ? void 0 : _b.value;
389
371
  if (!notificationStateValue)
390
372
  return undefined;
391
- const decimals = isNativeToken ? BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.decimals : BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.decimals;
392
- const amountIndex = isNativeToken ? 2 : 4;
393
- const amountWithDecimals = ((_b = notificationStateValue === null || notificationStateValue === void 0 ? void 0 : notificationStateValue[amountIndex]) === null || _b === void 0 ? void 0 : _b.value) || 0;
394
- const amount = blockchain_service_1.BSBigNumberHelper.format(neon_js_1.u.BigInteger.fromNumber(amountWithDecimals).toDecimal(decimals), {
395
- decimals,
396
- });
397
- const receiverAddressIndex = isNativeToken ? 1 : 3;
398
- const byteStringReceiverAddress = ((_c = notificationStateValue === null || notificationStateValue === void 0 ? void 0 : notificationStateValue[receiverAddressIndex]) === null || _c === void 0 ? void 0 : _c.value) || '';
399
- if (!byteStringReceiverAddress)
400
- return undefined;
401
- const receiverAddress = `0x${neon_js_1.u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`;
402
- const token = __classPrivateFieldGet(this, _DoraBDSNeo3_neo3NeoXBridgeService, "f").tokens.find(currentToken => this._tokenService.predicateByHash(isNativeToken ? BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN : BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN, currentToken));
403
- if (!token)
373
+ let token;
374
+ let amountInDecimals;
375
+ let byteStringReceiverAddress;
376
+ if (isNativeToken) {
377
+ token = this._service.neo3NeoXBridgeService.gasToken;
378
+ amountInDecimals = (_c = notificationStateValue[2]) === null || _c === void 0 ? void 0 : _c.value;
379
+ byteStringReceiverAddress = (_d = notificationStateValue[1]) === null || _d === void 0 ? void 0 : _d.value;
380
+ }
381
+ else {
382
+ token = this._service.neo3NeoXBridgeService.neoToken;
383
+ amountInDecimals = (_e = notificationStateValue[4]) === null || _e === void 0 ? void 0 : _e.value;
384
+ byteStringReceiverAddress = (_f = notificationStateValue[3]) === null || _f === void 0 ? void 0 : _f.value;
385
+ }
386
+ if (!token || !amountInDecimals || !byteStringReceiverAddress)
404
387
  return undefined;
405
- return { amount, token, receiverAddress };
388
+ const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
389
+ return {
390
+ amount: blockchain_service_1.BSBigNumberHelper.toNumber(blockchain_service_1.BSBigNumberHelper.fromDecimals(amountInDecimals, token.decimals)),
391
+ token,
392
+ receiverAddress: `0x${u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`,
393
+ };
406
394
  };
395
+ DoraBDSNeo3.SUPPORTED_NEP11_STANDARDS = ['nep11', 'nep-11'];
396
+ DoraBDSNeo3.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS = ['mainnet', 'testnet'];
@@ -1,22 +1,16 @@
1
- import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TokenService, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
3
- export declare class RpcBDSNeo3 implements BlockchainDataService, BDSClaimable {
4
- readonly _tokenCache: Map<string, Token>;
5
- readonly _feeToken: Token;
6
- readonly _claimToken: Token;
7
- readonly _network: Network<BSNeo3NetworkId>;
8
- readonly _tokens: Token[];
9
- readonly _tokenService: TokenService;
10
- maxTimeToConfirmTransactionInMs: number;
11
- constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], tokenService: TokenService);
12
- getTransaction(hash: string): Promise<TransactionResponse>;
13
- getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
14
- getFullTransactionsByAddress(_params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
15
- exportFullTransactionsByAddress(_params: ExportTransactionsByAddressParams): Promise<string>;
1
+ import { TBalanceResponse, ContractResponse, TExportTransactionsByAddressParams, TFullTransactionsByAddressParams, TFullTransactionsByAddressResponse, IBlockchainDataService, TBSToken, TTransactionResponse, TTransactionsByAddressParams, TTransactionsByAddressResponse } from '@cityofzion/blockchain-service';
2
+ import { IBSNeo3 } from '../../types';
3
+ export declare class RpcBDSNeo3<N extends string> implements IBlockchainDataService {
4
+ readonly maxTimeToConfirmTransactionInMs: number;
5
+ readonly _tokenCache: Map<string, TBSToken>;
6
+ readonly _service: IBSNeo3<N>;
7
+ constructor(service: IBSNeo3<N>);
8
+ getTransaction(hash: string): Promise<TTransactionResponse>;
9
+ getTransactionsByAddress(_params: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
10
+ getFullTransactionsByAddress(_params: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
11
+ exportFullTransactionsByAddress(_params: TExportTransactionsByAddressParams): Promise<string>;
16
12
  getContract(contractHash: string): Promise<ContractResponse>;
17
- getTokenInfo(tokenHash: string): Promise<Token>;
18
- getBalance(address: string): Promise<BalanceResponse[]>;
13
+ getTokenInfo(tokenHash: string): Promise<TBSToken>;
14
+ getBalance(address: string): Promise<TBalanceResponse[]>;
19
15
  getBlockHeight(): Promise<number>;
20
- getUnclaimed(address: string): Promise<string>;
21
- getRpcList(): Promise<RpcResponse[]>;
22
16
  }