@cityofzion/bs-neo3 1.16.3 → 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.
- package/dist/BSNeo3.d.ts +39 -30
- package/dist/BSNeo3.js +102 -54
- package/dist/constants/BSNeo3Constants.d.ts +12 -17
- package/dist/constants/BSNeo3Constants.js +221 -37
- package/dist/helpers/BSNeo3Helper.d.ts +5 -6
- package/dist/helpers/BSNeo3Helper.js +9 -8
- package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.d.ts +6 -0
- package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.js +26 -0
- package/dist/helpers/BSNeo3NeonJsSingletonHelper.d.ts +7 -0
- package/dist/helpers/BSNeo3NeonJsSingletonHelper.js +26 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +13 -12
- package/dist/services/blockchain-data/DoraBDSNeo3.js +130 -140
- package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +13 -19
- package/dist/services/blockchain-data/RpcBDSNeo3.js +28 -62
- package/dist/services/chaim-data/RpcCDSNeo3.d.ts +7 -0
- package/dist/services/chaim-data/RpcCDSNeo3.js +27 -0
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +6 -7
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +4 -19
- package/dist/services/explorer/DoraESNeo3.d.ts +5 -5
- package/dist/services/explorer/DoraESNeo3.js +19 -22
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +10 -10
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +28 -38
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +10 -9
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +26 -25
- package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +7 -11
- package/dist/services/nft-data/GhostMarketNDSNeo3.js +41 -79
- package/dist/services/vote/DoraVoteServiceNeo3.d.ts +8 -29
- package/dist/services/vote/DoraVoteServiceNeo3.js +81 -21
- package/dist/types.d.ts +84 -0
- package/dist/types.js +18 -0
- package/package.json +25 -25
- package/dist/assets/tokens/mainnet.json +0 -194
- package/dist/assets/tokens/native.json +0 -14
- package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.d.ts +0 -34
- package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.js +0 -102
- package/dist/interfaces.d.ts +0 -41
- package/dist/interfaces.js +0 -2
- package/dist/services/nft-data/RpcNDSNeo3.d.ts +0 -9
- package/dist/services/nft-data/RpcNDSNeo3.js +0 -59
- package/dist/services/vote/RpcVoteServiceNeo3.d.ts +0 -10
- 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,
|
|
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 =
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
69
|
-
const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((
|
|
70
|
-
const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((
|
|
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.
|
|
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 (
|
|
74
|
+
catch (_d) {
|
|
83
75
|
throw new Error(`Transaction not found: ${hash}`);
|
|
84
76
|
}
|
|
85
77
|
});
|
|
86
78
|
}
|
|
87
|
-
getTransactionsByAddress(
|
|
79
|
+
getTransactionsByAddress(_b) {
|
|
88
80
|
const _super = Object.create(null, {
|
|
89
81
|
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
90
82
|
});
|
|
91
|
-
return __awaiter(this,
|
|
92
|
-
if (BSNeo3Helper_1.BSNeo3Helper.
|
|
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
|
|
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
|
|
90
|
+
var _b, _c, _d;
|
|
98
91
|
const transferPromises = [];
|
|
99
|
-
const notifications = (
|
|
92
|
+
const notifications = (_b = item.notifications) !== null && _b !== void 0 ? _b : [];
|
|
100
93
|
item.notifications.forEach(({ contract: contractHash, state, event_name: eventName }) => {
|
|
101
|
-
var
|
|
102
|
-
const properties = (Array.isArray(state) ? state : (
|
|
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.
|
|
111
|
-
const convertedTo = to ? this.
|
|
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 ?
|
|
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((
|
|
136
|
-
const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((
|
|
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.
|
|
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(
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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.
|
|
166
|
+
network: this._service.network.id,
|
|
175
167
|
cursor: nextCursor,
|
|
176
|
-
pageLimit: (
|
|
168
|
+
pageLimit: (_c = params.pageSize) !== null && _c !== void 0 ? _c : 50,
|
|
177
169
|
});
|
|
178
|
-
const items = (
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
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.
|
|
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.
|
|
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
|
|
196
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
204
197
|
const { methodName, tokenID: tokenHash, contractHash, contractName } = event;
|
|
205
|
-
const from = (
|
|
206
|
-
const to = (
|
|
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 = (
|
|
211
|
-
const isNft =
|
|
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(() =>
|
|
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
|
-
|
|
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: (
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
amount: event.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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(() =>
|
|
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
|
-
|
|
275
|
-
return yield
|
|
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.
|
|
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
|
-
|
|
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
|
|
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: (
|
|
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 (
|
|
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.
|
|
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.
|
|
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
|
|
321
|
-
token = this.
|
|
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 (
|
|
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.
|
|
331
|
+
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(this._service.network)) {
|
|
342
332
|
return yield _super.getBalance.call(this, address);
|
|
343
333
|
}
|
|
344
|
-
const response = yield
|
|
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 (
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
|
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 = (
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
export declare class RpcBDSNeo3 implements
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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<
|
|
18
|
-
getBalance(address: string): Promise<
|
|
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
|
}
|