@cityofzion/bs-neo-legacy 1.10.9 → 1.11.0
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/constants/BSNeoLegacyConstants.d.ts +2 -0
- package/dist/constants/BSNeoLegacyConstants.js +2 -0
- package/dist/services/BSNeoLegacy.d.ts +1 -1
- package/dist/services/BSNeoLegacy.js +71 -49
- package/dist/services/blockchain-data/DoraBDSNeoLegacy.d.ts +3 -2
- package/dist/services/blockchain-data/DoraBDSNeoLegacy.js +86 -5
- package/dist/services/explorer/NeoTubeESNeoLegacy.d.ts +2 -0
- package/dist/services/explorer/NeoTubeESNeoLegacy.js +8 -0
- package/package.json +5 -3
|
@@ -24,4 +24,6 @@ export declare class BSNeoLegacyConstants {
|
|
|
24
24
|
static readonly MIGRATION_MIN_GAS = 0.1;
|
|
25
25
|
static readonly MIGRATION_MIN_NEO = 2;
|
|
26
26
|
static readonly MIGRATION_COZ_NEO3_ADDRESS = "NLMsicDapULKFDmAzTsbhwrZjYZ83j53Ty";
|
|
27
|
+
static MAX_TRANSACTION_SIZE_WITHOUT_FEE: number;
|
|
28
|
+
static FEE_APPLIED_TO_PLAYABLE_TRANSACTION: number;
|
|
27
29
|
}
|
|
@@ -64,3 +64,5 @@ BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE = 0.0112143;
|
|
|
64
64
|
BSNeoLegacyConstants.MIGRATION_MIN_GAS = 0.1;
|
|
65
65
|
BSNeoLegacyConstants.MIGRATION_MIN_NEO = 2;
|
|
66
66
|
BSNeoLegacyConstants.MIGRATION_COZ_NEO3_ADDRESS = 'NLMsicDapULKFDmAzTsbhwrZjYZ83j53Ty';
|
|
67
|
+
BSNeoLegacyConstants.MAX_TRANSACTION_SIZE_WITHOUT_FEE = 1024;
|
|
68
|
+
BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION = 0.001;
|
|
@@ -63,7 +63,7 @@ export declare class BSNeoLegacy<BSName extends string = string> implements Bloc
|
|
|
63
63
|
decrypt(encryptedKey: string, password: string): Promise<Account<BSName>>;
|
|
64
64
|
encrypt(key: string, password: string): Promise<string>;
|
|
65
65
|
transfer({ intents, senderAccount, tipIntent, ...params }: TransferParam<BSName>): Promise<string[]>;
|
|
66
|
-
claim(account: Account): Promise<string>;
|
|
66
|
+
claim(account: Account<BSName>): Promise<string>;
|
|
67
67
|
migrate({ account, neo3Address, neoLegacyMigrationAmounts }: MigrateParams<BSName>): Promise<string>;
|
|
68
68
|
/**
|
|
69
69
|
* Reference: https://github.com/CityOfZion/legacy-n3-swap-service/blob/master/policy/policy.go
|
|
@@ -24,7 +24,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
}
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
|
-
var _BSNeoLegacy_instances, _BSNeoLegacy_generateSigningCallback, _BSNeoLegacy_setTokens;
|
|
27
|
+
var _BSNeoLegacy_instances, _BSNeoLegacy_generateSigningCallback, _BSNeoLegacy_setTokens, _BSNeoLegacy_hasTransactionMoreThanMaxSize, _BSNeoLegacy_signTransfer, _BSNeoLegacy_sendTransfer, _BSNeoLegacy_signClaim, _BSNeoLegacy_sendClaim;
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.BSNeoLegacy = void 0;
|
|
30
30
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -51,7 +51,7 @@ class BSNeoLegacy {
|
|
|
51
51
|
}
|
|
52
52
|
testNetwork(network) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const blockchainDataServiceClone = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens);
|
|
54
|
+
const blockchainDataServiceClone = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService);
|
|
55
55
|
yield blockchainDataServiceClone.getBlockHeight();
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -60,9 +60,9 @@ class BSNeoLegacy {
|
|
|
60
60
|
throw new Error('Custom network is not supported');
|
|
61
61
|
__classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_setTokens).call(this, network);
|
|
62
62
|
this.network = network;
|
|
63
|
-
this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens);
|
|
64
|
-
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network);
|
|
65
63
|
this.explorerService = new NeoTubeESNeoLegacy_1.NeoTubeESNeoLegacy(network);
|
|
64
|
+
this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken, this.tokens, this.explorerService);
|
|
65
|
+
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network);
|
|
66
66
|
}
|
|
67
67
|
validateAddress(address) {
|
|
68
68
|
return neon_js_1.wallet.isAddress(address);
|
|
@@ -134,54 +134,27 @@ class BSNeoLegacy {
|
|
|
134
134
|
.toString()),
|
|
135
135
|
]);
|
|
136
136
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
response = yield neon_js_1.api.doInvoke({
|
|
150
|
-
intents: nativeIntents.length > 0 ? nativeIntents : undefined,
|
|
151
|
-
account: neonJsAccount,
|
|
152
|
-
api: apiProvider,
|
|
153
|
-
script: nep5ScriptBuilder.str,
|
|
154
|
-
url: this.network.url,
|
|
155
|
-
fees: priorityFee,
|
|
156
|
-
signingFunction: signingCallback,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
if (!response.tx)
|
|
160
|
-
throw new Error('Failed to send transaction');
|
|
161
|
-
return intents.map(() => response.tx.hash);
|
|
137
|
+
const hash = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_sendTransfer).call(this, {
|
|
138
|
+
account: neonJsAccount,
|
|
139
|
+
api: apiProvider,
|
|
140
|
+
url: this.network.url,
|
|
141
|
+
intents: nativeIntents.length > 0 ? nativeIntents : undefined,
|
|
142
|
+
signingFunction: signingCallback,
|
|
143
|
+
fees: priorityFee,
|
|
144
|
+
}, nep5ScriptBuilder);
|
|
145
|
+
return intents.map(() => hash);
|
|
162
146
|
});
|
|
163
147
|
}
|
|
164
148
|
claim(account) {
|
|
165
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const
|
|
167
|
-
const balances = yield this.blockchainDataService.getBalance(account.address);
|
|
168
|
-
const neoBalance = balances.find(balance => balance.token.symbol === 'NEO');
|
|
169
|
-
if (!neoBalance)
|
|
170
|
-
throw new Error('It is necessary to have NEO to claim');
|
|
171
|
-
const unclaimed = yield this.blockchainDataService.getUnclaimed(account.address);
|
|
172
|
-
if (Number(unclaimed) <= 0)
|
|
173
|
-
throw new Error(`Doesn't have gas to claim`);
|
|
150
|
+
const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_generateSigningCallback).call(this, account);
|
|
174
151
|
const apiProvider = new neon_js_1.api.neoCli.instance(this.legacyNetwork);
|
|
175
|
-
|
|
176
|
-
const response = yield neon_js_1.api.claimGas({
|
|
177
|
-
claims,
|
|
152
|
+
return yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_sendClaim).call(this, {
|
|
178
153
|
api: apiProvider,
|
|
179
|
-
account:
|
|
154
|
+
account: neonJsAccount,
|
|
180
155
|
url: this.network.url,
|
|
156
|
+
signingFunction: signingCallback,
|
|
181
157
|
});
|
|
182
|
-
if (!response.tx)
|
|
183
|
-
throw new Error('Failed to claim');
|
|
184
|
-
return response.tx.hash;
|
|
185
158
|
});
|
|
186
159
|
}
|
|
187
160
|
migrate({ account, neo3Address, neoLegacyMigrationAmounts }) {
|
|
@@ -199,12 +172,11 @@ class BSNeoLegacy {
|
|
|
199
172
|
intents.push(...neon_js_1.api.makeIntent({ [this.GAS_ASSET.symbol]: Number(neoLegacyMigrationAmounts.gasBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
|
|
200
173
|
if (neoLegacyMigrationAmounts.neoBalance)
|
|
201
174
|
intents.push(...neon_js_1.api.makeIntent({ [this.NEO_ASSET.symbol]: Number(neoLegacyMigrationAmounts.neoBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
|
|
202
|
-
|
|
175
|
+
return yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_sendTransfer).call(this, {
|
|
203
176
|
url: this.network.url,
|
|
204
177
|
api: provider,
|
|
205
178
|
account: neonJsAccount,
|
|
206
179
|
intents,
|
|
207
|
-
fees: 0,
|
|
208
180
|
signingFunction: signingCallback,
|
|
209
181
|
override: {
|
|
210
182
|
attributes: [
|
|
@@ -219,9 +191,6 @@ class BSNeoLegacy {
|
|
|
219
191
|
],
|
|
220
192
|
},
|
|
221
193
|
});
|
|
222
|
-
if (!response.tx)
|
|
223
|
-
throw new Error('Migration failed on send');
|
|
224
|
-
return response.tx.hash;
|
|
225
194
|
});
|
|
226
195
|
}
|
|
227
196
|
/**
|
|
@@ -292,6 +261,7 @@ _BSNeoLegacy_instances = new WeakSet(), _BSNeoLegacy_generateSigningCallback = f
|
|
|
292
261
|
}
|
|
293
262
|
return {
|
|
294
263
|
neonJsAccount,
|
|
264
|
+
signingCallback: neon_js_1.api.signWithPrivateKey(neonJsAccount.privateKey),
|
|
295
265
|
};
|
|
296
266
|
});
|
|
297
267
|
}, _BSNeoLegacy_setTokens = function _BSNeoLegacy_setTokens(network) {
|
|
@@ -301,4 +271,56 @@ _BSNeoLegacy_instances = new WeakSet(), _BSNeoLegacy_generateSigningCallback = f
|
|
|
301
271
|
this.feeToken = tokens.find(token => token.symbol === 'GAS');
|
|
302
272
|
this.burnToken = tokens.find(token => token.symbol === 'NEO');
|
|
303
273
|
this.claimToken = tokens.find(token => token.symbol === 'GAS');
|
|
274
|
+
}, _BSNeoLegacy_hasTransactionMoreThanMaxSize = function _BSNeoLegacy_hasTransactionMoreThanMaxSize(config) {
|
|
275
|
+
if (!config.fees || config.fees < BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION) {
|
|
276
|
+
const serializedTransaction = config.tx.serialize(true);
|
|
277
|
+
const transactionSize = serializedTransaction.length / 2;
|
|
278
|
+
if (transactionSize > BSNeoLegacyConstants_1.BSNeoLegacyConstants.MAX_TRANSACTION_SIZE_WITHOUT_FEE) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}, _BSNeoLegacy_signTransfer = function _BSNeoLegacy_signTransfer(config, nep5ScriptBuilder) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
if (!nep5ScriptBuilder || nep5ScriptBuilder.isEmpty()) {
|
|
286
|
+
config = yield neon_js_1.api.createContractTx(config);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
config.script = nep5ScriptBuilder.str;
|
|
290
|
+
config = yield neon_js_1.api.createInvocationTx(config);
|
|
291
|
+
}
|
|
292
|
+
config = yield neon_js_1.api.modifyTransactionForEmptyTransaction(config);
|
|
293
|
+
config = yield neon_js_1.api.addAttributeIfExecutingAsSmartContract(config);
|
|
294
|
+
config = yield neon_js_1.api.signTx(config);
|
|
295
|
+
config = yield neon_js_1.api.addSignatureIfExecutingAsSmartContract(config);
|
|
296
|
+
return config;
|
|
297
|
+
});
|
|
298
|
+
}, _BSNeoLegacy_sendTransfer = function _BSNeoLegacy_sendTransfer(config, nep5ScriptBuilder) {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
const sharedConfig = yield neon_js_1.api.fillBalance(config);
|
|
301
|
+
let signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signTransfer).call(this, Object.assign({}, sharedConfig), nep5ScriptBuilder);
|
|
302
|
+
if (__classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_hasTransactionMoreThanMaxSize).call(this, signedConfig)) {
|
|
303
|
+
signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signTransfer).call(this, Object.assign(Object.assign({}, sharedConfig), { fees: BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION }), nep5ScriptBuilder);
|
|
304
|
+
}
|
|
305
|
+
signedConfig = yield neon_js_1.api.sendTx(signedConfig);
|
|
306
|
+
return signedConfig.response.txid;
|
|
307
|
+
});
|
|
308
|
+
}, _BSNeoLegacy_signClaim = function _BSNeoLegacy_signClaim(config) {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
config = yield neon_js_1.api.createClaimTx(config);
|
|
311
|
+
config = yield neon_js_1.api.addAttributeIfExecutingAsSmartContract(config);
|
|
312
|
+
config = yield neon_js_1.api.signTx(config);
|
|
313
|
+
config = yield neon_js_1.api.addSignatureIfExecutingAsSmartContract(config);
|
|
314
|
+
return config;
|
|
315
|
+
});
|
|
316
|
+
}, _BSNeoLegacy_sendClaim = function _BSNeoLegacy_sendClaim(config) {
|
|
317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
const sharedConfig = yield neon_js_1.api.fillClaims(config);
|
|
319
|
+
let signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signClaim).call(this, Object.assign({}, sharedConfig));
|
|
320
|
+
if (__classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_hasTransactionMoreThanMaxSize).call(this, signedConfig)) {
|
|
321
|
+
signedConfig = yield __classPrivateFieldGet(this, _BSNeoLegacy_instances, "m", _BSNeoLegacy_signClaim).call(this, Object.assign(Object.assign({}, sharedConfig), { fees: BSNeoLegacyConstants_1.BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION }));
|
|
322
|
+
}
|
|
323
|
+
signedConfig = yield neon_js_1.api.sendTx(signedConfig);
|
|
324
|
+
return signedConfig.response.txid;
|
|
325
|
+
});
|
|
304
326
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { BalanceResponse, BlockchainDataService, ContractResponse,
|
|
1
|
+
import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExplorerService, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeoLegacyNetworkId } from '../../constants/BSNeoLegacyConstants';
|
|
3
3
|
export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
|
|
4
4
|
#private;
|
|
5
5
|
maxTimeToConfirmTransactionInMs: number;
|
|
6
|
-
constructor(network: Network<BSNeoLegacyNetworkId>, feeToken: Token, claimToken: Token, tokens: Token[]);
|
|
6
|
+
constructor(network: Network<BSNeoLegacyNetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], explorerService: ExplorerService);
|
|
7
7
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
8
8
|
getTransactionsByAddress({ address, nextPageParams, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
9
|
+
getFullTransactionsByAddress(params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
9
10
|
getContract(contractHash: string): Promise<ContractResponse>;
|
|
10
11
|
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
11
12
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
@@ -19,24 +19,40 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
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
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25
|
+
t[p] = s[p];
|
|
26
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
27
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
29
|
+
t[p[i]] = s[p[i]];
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
var _DoraBDSNeoLegacy_instances, _DoraBDSNeoLegacy_supportedNep5Standards, _DoraBDSNeoLegacy_network, _DoraBDSNeoLegacy_claimToken, _DoraBDSNeoLegacy_feeToken, _DoraBDSNeoLegacy_tokens, _DoraBDSNeoLegacy_tokenCache, _DoraBDSNeoLegacy_explorerService, _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams;
|
|
23
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
35
|
exports.DoraBDSNeoLegacy = void 0;
|
|
36
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
25
37
|
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
26
38
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
27
39
|
const BSNeoLegacyHelper_1 = require("../../helpers/BSNeoLegacyHelper");
|
|
28
40
|
class DoraBDSNeoLegacy {
|
|
29
|
-
constructor(network, feeToken, claimToken, tokens) {
|
|
41
|
+
constructor(network, feeToken, claimToken, tokens, explorerService) {
|
|
42
|
+
_DoraBDSNeoLegacy_instances.add(this);
|
|
43
|
+
_DoraBDSNeoLegacy_supportedNep5Standards.set(this, ['nep5', 'nep-5']);
|
|
30
44
|
_DoraBDSNeoLegacy_network.set(this, void 0);
|
|
31
45
|
_DoraBDSNeoLegacy_claimToken.set(this, void 0);
|
|
32
46
|
_DoraBDSNeoLegacy_feeToken.set(this, void 0);
|
|
33
47
|
_DoraBDSNeoLegacy_tokens.set(this, void 0);
|
|
34
48
|
_DoraBDSNeoLegacy_tokenCache.set(this, new Map());
|
|
49
|
+
_DoraBDSNeoLegacy_explorerService.set(this, void 0);
|
|
35
50
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
|
|
36
51
|
__classPrivateFieldSet(this, _DoraBDSNeoLegacy_network, network, "f");
|
|
37
52
|
__classPrivateFieldSet(this, _DoraBDSNeoLegacy_claimToken, claimToken, "f");
|
|
38
53
|
__classPrivateFieldSet(this, _DoraBDSNeoLegacy_feeToken, feeToken, "f");
|
|
39
54
|
__classPrivateFieldSet(this, _DoraBDSNeoLegacy_tokens, tokens, "f");
|
|
55
|
+
__classPrivateFieldSet(this, _DoraBDSNeoLegacy_explorerService, explorerService, "f");
|
|
40
56
|
}
|
|
41
57
|
getTransaction(hash) {
|
|
42
58
|
var _a, _b, _c;
|
|
@@ -106,6 +122,66 @@ class DoraBDSNeoLegacy {
|
|
|
106
122
|
};
|
|
107
123
|
});
|
|
108
124
|
}
|
|
125
|
+
getFullTransactionsByAddress(params) {
|
|
126
|
+
var _a;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
__classPrivateFieldGet(this, _DoraBDSNeoLegacy_instances, "m", _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams).call(this, params);
|
|
129
|
+
const data = [];
|
|
130
|
+
const _b = yield dora_ts_1.api.NeoLegacyREST.getFullTransactionsByAddress({
|
|
131
|
+
address: params.address,
|
|
132
|
+
timestampFrom: params.dateFrom,
|
|
133
|
+
timestampTo: params.dateTo,
|
|
134
|
+
network: 'mainnet',
|
|
135
|
+
cursor: params.nextCursor,
|
|
136
|
+
}), { nextCursor } = _b, response = __rest(_b, ["nextCursor"]);
|
|
137
|
+
const items = (_a = response.data) !== null && _a !== void 0 ? _a : [];
|
|
138
|
+
const addressTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getAddressTemplateUrl();
|
|
139
|
+
const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getTxTemplateUrl();
|
|
140
|
+
const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_explorerService, "f").getContractTemplateUrl();
|
|
141
|
+
const itemPromises = items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
const txId = item.transactionID;
|
|
143
|
+
const newItem = {
|
|
144
|
+
txId,
|
|
145
|
+
txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
|
|
146
|
+
block: item.block,
|
|
147
|
+
date: item.date,
|
|
148
|
+
invocationCount: item.invocationCount,
|
|
149
|
+
notificationCount: item.notificationCount,
|
|
150
|
+
networkFeeAmount: (0, blockchain_service_1.formatNumber)(item.networkFeeAmount, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
|
|
151
|
+
systemFeeAmount: (0, blockchain_service_1.formatNumber)(item.systemFeeAmount, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_feeToken, "f").decimals),
|
|
152
|
+
events: [],
|
|
153
|
+
};
|
|
154
|
+
const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
var _c, _d, _e, _f;
|
|
156
|
+
const { contractHash: hash, amount, from, to } = event;
|
|
157
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
|
|
158
|
+
const standard = (_e = (_d = (_c = event.supportedStandards) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) !== null && _e !== void 0 ? _e : '';
|
|
159
|
+
const isNep5 = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_supportedNep5Standards, "f").includes(standard);
|
|
160
|
+
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
161
|
+
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
162
|
+
const hashUrl = hash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', hash) : undefined;
|
|
163
|
+
const assetEvent = {
|
|
164
|
+
eventType: 'token',
|
|
165
|
+
amount: (0, blockchain_service_1.formatNumber)(amount, (_f = token === null || token === void 0 ? void 0 : token.decimals) !== null && _f !== void 0 ? _f : event.tokenDecimals),
|
|
166
|
+
methodName: event.methodName,
|
|
167
|
+
from: from || 'Burn',
|
|
168
|
+
fromUrl,
|
|
169
|
+
to: to || 'Mint',
|
|
170
|
+
toUrl,
|
|
171
|
+
hash,
|
|
172
|
+
hashUrl,
|
|
173
|
+
token: token !== null && token !== void 0 ? token : undefined,
|
|
174
|
+
tokenType: isNep5 ? 'nep-5' : 'generic',
|
|
175
|
+
};
|
|
176
|
+
newItem.events.push(assetEvent);
|
|
177
|
+
}));
|
|
178
|
+
yield Promise.allSettled(eventPromises);
|
|
179
|
+
data.push(newItem);
|
|
180
|
+
}));
|
|
181
|
+
yield Promise.allSettled(itemPromises);
|
|
182
|
+
return { nextCursor, data };
|
|
183
|
+
});
|
|
184
|
+
}
|
|
109
185
|
getContract(contractHash) {
|
|
110
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
187
|
const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
|
|
@@ -161,8 +237,7 @@ class DoraBDSNeoLegacy {
|
|
|
161
237
|
token,
|
|
162
238
|
};
|
|
163
239
|
}));
|
|
164
|
-
|
|
165
|
-
return result;
|
|
240
|
+
return yield Promise.all(promises);
|
|
166
241
|
});
|
|
167
242
|
}
|
|
168
243
|
getUnclaimed(address) {
|
|
@@ -206,4 +281,10 @@ class DoraBDSNeoLegacy {
|
|
|
206
281
|
}
|
|
207
282
|
}
|
|
208
283
|
exports.DoraBDSNeoLegacy = DoraBDSNeoLegacy;
|
|
209
|
-
_DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokens = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap()
|
|
284
|
+
_DoraBDSNeoLegacy_supportedNep5Standards = new WeakMap(), _DoraBDSNeoLegacy_network = new WeakMap(), _DoraBDSNeoLegacy_claimToken = new WeakMap(), _DoraBDSNeoLegacy_feeToken = new WeakMap(), _DoraBDSNeoLegacy_tokens = new WeakMap(), _DoraBDSNeoLegacy_tokenCache = new WeakMap(), _DoraBDSNeoLegacy_explorerService = new WeakMap(), _DoraBDSNeoLegacy_instances = new WeakSet(), _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams = function _DoraBDSNeoLegacy_validateFullTransactionsByAddressParams(params) {
|
|
285
|
+
if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f")))
|
|
286
|
+
throw new Error('Only Mainnet is supported');
|
|
287
|
+
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
|
|
288
|
+
if (!neon_js_1.wallet.isAddress(params.address))
|
|
289
|
+
throw new Error('Invalid address param');
|
|
290
|
+
};
|
|
@@ -8,4 +8,6 @@ export declare class NeoTubeESNeoLegacy implements ExplorerService {
|
|
|
8
8
|
buildNftUrl(_params: BuildNftUrlParams): string;
|
|
9
9
|
getAddressTemplateUrl(): string | undefined;
|
|
10
10
|
getTxTemplateUrl(): string | undefined;
|
|
11
|
+
getNftTemplateUrl(): undefined;
|
|
12
|
+
getContractTemplateUrl(): string | undefined;
|
|
11
13
|
}
|
|
@@ -44,6 +44,14 @@ class NeoTubeESNeoLegacy {
|
|
|
44
44
|
return undefined;
|
|
45
45
|
return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/transaction/{txId}`;
|
|
46
46
|
}
|
|
47
|
+
getNftTemplateUrl() {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
getContractTemplateUrl() {
|
|
51
|
+
if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnet(__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_network, "f")))
|
|
52
|
+
return undefined;
|
|
53
|
+
return `${__classPrivateFieldGet(this, _NeoTubeESNeoLegacy_BASE_URL, "f")}/asset/{hash}/page/1`;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
exports.NeoTubeESNeoLegacy = NeoTubeESNeoLegacy;
|
|
49
57
|
_NeoTubeESNeoLegacy_BASE_URL = new WeakMap(), _NeoTubeESNeoLegacy_network = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo-legacy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Coz",
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"/dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@cityofzion/dora-ts": "0.0
|
|
12
|
+
"@cityofzion/dora-ts": "0.4.0",
|
|
13
13
|
"@cityofzion/neon-js": "4.8.3",
|
|
14
14
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
15
|
-
"
|
|
15
|
+
"axios": "1.8.2",
|
|
16
|
+
"date-fns": "~4.1.0",
|
|
17
|
+
"@cityofzion/blockchain-service": "1.17.1",
|
|
16
18
|
"@cityofzion/bs-asteroid-sdk": "0.9.1"
|
|
17
19
|
},
|
|
18
20
|
"devDependencies": {
|