@fuel-ts/account 0.92.1 → 0.94.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/README.md +9 -29
- package/dist/account.d.ts +15 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts +0 -2
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +0 -2
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +0 -6
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +0 -4
- package/dist/configs.mjs.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +24 -1
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts +14 -1
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/types/connector-metadata.d.ts.map +1 -1
- package/dist/connectors/utils/promises.d.ts.map +1 -1
- package/dist/index.global.js +1645 -985
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1034 -673
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +771 -423
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +15 -9
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +614 -1
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +3 -3
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +19 -47
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource-cache.d.ts +14 -0
- package/dist/providers/resource-cache.d.ts.map +1 -0
- package/dist/providers/transaction-request/blob-transaction-request.d.ts +48 -0
- package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +4 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +5 -2
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +9 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +10 -5
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/call.d.ts +4 -3
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/input.d.ts +6 -1
- package/dist/providers/transaction-summary/input.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +4 -2
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +5 -2
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +6 -0
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +0 -16
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
- package/dist/test-utils/test-asset-id.d.ts +8 -0
- package/dist/test-utils/test-asset-id.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +4 -2
- package/dist/test-utils/test-message.d.ts.map +1 -1
- package/dist/test-utils/wallet-config.d.ts +3 -3
- package/dist/test-utils/wallet-config.d.ts.map +1 -1
- package/dist/test-utils.d.ts +1 -3
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.global.js +43613 -42984
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1560 -1271
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +1282 -994
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +1 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/keystore-wallet.d.ts.map +1 -1
- package/package.json +19 -21
- package/dist/providers/memory-cache.d.ts +0 -11
- package/dist/providers/memory-cache.d.ts.map +0 -1
- package/dist/test-utils/asset-id.d.ts +0 -8
- package/dist/test-utils/asset-id.d.ts.map +0 -1
- package/dist/test-utils/generateTestWallet.d.ts +0 -4
- package/dist/test-utils/generateTestWallet.d.ts.map +0 -1
- package/dist/test-utils/seedTestWallet.d.ts +0 -4
- package/dist/test-utils/seedTestWallet.d.ts.map +0 -1
package/dist/index.js
CHANGED
@@ -62,10 +62,12 @@ __export(src_exports, {
|
|
62
62
|
BLOCKS_PAGE_SIZE_LIMIT: () => BLOCKS_PAGE_SIZE_LIMIT,
|
63
63
|
BaseTransactionRequest: () => BaseTransactionRequest,
|
64
64
|
BaseWalletUnlocked: () => BaseWalletUnlocked,
|
65
|
+
BlobTransactionRequest: () => BlobTransactionRequest,
|
65
66
|
CHAIN_IDS: () => CHAIN_IDS,
|
66
67
|
ChainName: () => ChainName,
|
67
68
|
ChangeOutputCollisionError: () => ChangeOutputCollisionError,
|
68
69
|
CreateTransactionRequest: () => CreateTransactionRequest,
|
70
|
+
DEFAULT_RESOURCE_CACHE_TTL: () => DEFAULT_RESOURCE_CACHE_TTL,
|
69
71
|
Fuel: () => Fuel,
|
70
72
|
FuelConnector: () => FuelConnector,
|
71
73
|
FuelConnectorEventType: () => FuelConnectorEventType,
|
@@ -99,6 +101,7 @@ __export(src_exports, {
|
|
99
101
|
WalletUnlocked: () => WalletUnlocked,
|
100
102
|
addAmountToCoinQuantities: () => addAmountToCoinQuantities,
|
101
103
|
addOperation: () => addOperation,
|
104
|
+
aggregateInputsAmountsByAssetAndOwner: () => aggregateInputsAmountsByAssetAndOwner,
|
102
105
|
assemblePanicError: () => assemblePanicError,
|
103
106
|
assembleReceiptByType: () => assembleReceiptByType,
|
104
107
|
assembleRevertError: () => assembleRevertError,
|
@@ -109,6 +112,7 @@ __export(src_exports, {
|
|
109
112
|
cacheRequestInputsResources: () => cacheRequestInputsResources,
|
110
113
|
cacheRequestInputsResourcesFromOwner: () => cacheRequestInputsResourcesFromOwner,
|
111
114
|
calculateGasFee: () => calculateGasFee,
|
115
|
+
calculateMetadataGasForTxBlob: () => calculateMetadataGasForTxBlob,
|
112
116
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
113
117
|
calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
|
114
118
|
calculateTXFeeForSummary: () => calculateTXFeeForSummary,
|
@@ -167,6 +171,7 @@ __export(src_exports, {
|
|
167
171
|
hasSameAssetId: () => hasSameAssetId,
|
168
172
|
inputify: () => inputify,
|
169
173
|
isCoin: () => isCoin,
|
174
|
+
isInputCoin: () => isInputCoin,
|
170
175
|
isMessage: () => isMessage,
|
171
176
|
isRawCoin: () => isRawCoin,
|
172
177
|
isRawMessage: () => isRawMessage,
|
@@ -174,7 +179,11 @@ __export(src_exports, {
|
|
174
179
|
isRequestInputMessage: () => isRequestInputMessage,
|
175
180
|
isRequestInputResource: () => isRequestInputResource,
|
176
181
|
isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
|
182
|
+
isTransactionTypeBlob: () => isTransactionTypeBlob,
|
183
|
+
isTransactionTypeCreate: () => isTransactionTypeCreate,
|
184
|
+
isTransactionTypeScript: () => isTransactionTypeScript,
|
177
185
|
isType: () => isType,
|
186
|
+
isTypeBlob: () => isTypeBlob,
|
178
187
|
isTypeCreate: () => isTypeCreate,
|
179
188
|
isTypeMint: () => isTypeMint,
|
180
189
|
isTypeScript: () => isTypeScript,
|
@@ -199,10 +208,10 @@ module.exports = __toCommonJS(src_exports);
|
|
199
208
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
200
209
|
var import_address4 = require("@fuel-ts/address");
|
201
210
|
var import_crypto2 = require("@fuel-ts/crypto");
|
202
|
-
var
|
211
|
+
var import_errors17 = require("@fuel-ts/errors");
|
203
212
|
var import_interfaces = require("@fuel-ts/interfaces");
|
204
|
-
var
|
205
|
-
var
|
213
|
+
var import_math21 = require("@fuel-ts/math");
|
214
|
+
var import_utils30 = require("@fuel-ts/utils");
|
206
215
|
var import_ramda4 = require("ramda");
|
207
216
|
|
208
217
|
// src/providers/coin-quantity.ts
|
@@ -242,25 +251,17 @@ var addAmountToCoinQuantities = (params) => {
|
|
242
251
|
|
243
252
|
// src/providers/provider.ts
|
244
253
|
var import_address3 = require("@fuel-ts/address");
|
245
|
-
var
|
246
|
-
var
|
254
|
+
var import_errors15 = require("@fuel-ts/errors");
|
255
|
+
var import_math18 = require("@fuel-ts/math");
|
247
256
|
var import_transactions20 = require("@fuel-ts/transactions");
|
248
|
-
var
|
257
|
+
var import_utils24 = require("@fuel-ts/utils");
|
249
258
|
var import_versions = require("@fuel-ts/versions");
|
250
|
-
var
|
259
|
+
var import_utils25 = require("@noble/curves/abstract/utils");
|
251
260
|
var import_graphql_request = require("graphql-request");
|
252
261
|
var import_ramda3 = require("ramda");
|
253
262
|
|
254
263
|
// src/providers/__generated__/operations.ts
|
255
264
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
256
|
-
var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
257
|
-
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
258
|
-
type: __typename
|
259
|
-
... on SqueezedOutStatus {
|
260
|
-
reason
|
261
|
-
}
|
262
|
-
}
|
263
|
-
`;
|
264
265
|
var SubmittedStatusFragmentDoc = import_graphql_tag.default`
|
265
266
|
fragment SubmittedStatusFragment on SubmittedStatus {
|
266
267
|
type: __typename
|
@@ -317,6 +318,47 @@ var SuccessStatusFragmentDoc = import_graphql_tag.default`
|
|
317
318
|
totalFee
|
318
319
|
}
|
319
320
|
${ReceiptFragmentDoc}`;
|
321
|
+
var MalleableTransactionFieldsFragmentDoc = import_graphql_tag.default`
|
322
|
+
fragment malleableTransactionFieldsFragment on Transaction {
|
323
|
+
receiptsRoot
|
324
|
+
inputs {
|
325
|
+
type: __typename
|
326
|
+
... on InputCoin {
|
327
|
+
txPointer
|
328
|
+
}
|
329
|
+
... on InputContract {
|
330
|
+
txPointer
|
331
|
+
}
|
332
|
+
}
|
333
|
+
outputs {
|
334
|
+
type: __typename
|
335
|
+
... on CoinOutput {
|
336
|
+
to
|
337
|
+
amount
|
338
|
+
assetId
|
339
|
+
}
|
340
|
+
... on ContractOutput {
|
341
|
+
inputIndex
|
342
|
+
balanceRoot
|
343
|
+
stateRoot
|
344
|
+
}
|
345
|
+
... on ChangeOutput {
|
346
|
+
to
|
347
|
+
amount
|
348
|
+
assetId
|
349
|
+
}
|
350
|
+
... on VariableOutput {
|
351
|
+
to
|
352
|
+
amount
|
353
|
+
assetId
|
354
|
+
}
|
355
|
+
... on ContractCreated {
|
356
|
+
contract
|
357
|
+
stateRoot
|
358
|
+
}
|
359
|
+
}
|
360
|
+
}
|
361
|
+
`;
|
320
362
|
var FailureStatusFragmentDoc = import_graphql_tag.default`
|
321
363
|
fragment FailureStatusFragment on FailureStatus {
|
322
364
|
type: __typename
|
@@ -338,6 +380,32 @@ var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
|
|
338
380
|
reason
|
339
381
|
}
|
340
382
|
`;
|
383
|
+
var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
384
|
+
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
385
|
+
... on SubmittedStatus {
|
386
|
+
...SubmittedStatusFragment
|
387
|
+
}
|
388
|
+
... on SuccessStatus {
|
389
|
+
...SuccessStatusFragment
|
390
|
+
transaction {
|
391
|
+
...malleableTransactionFieldsFragment
|
392
|
+
}
|
393
|
+
}
|
394
|
+
... on FailureStatus {
|
395
|
+
...FailureStatusFragment
|
396
|
+
transaction {
|
397
|
+
...malleableTransactionFieldsFragment
|
398
|
+
}
|
399
|
+
}
|
400
|
+
... on SqueezedOutStatus {
|
401
|
+
...SqueezedOutStatusFragment
|
402
|
+
}
|
403
|
+
}
|
404
|
+
${SubmittedStatusFragmentDoc}
|
405
|
+
${SuccessStatusFragmentDoc}
|
406
|
+
${MalleableTransactionFieldsFragmentDoc}
|
407
|
+
${FailureStatusFragmentDoc}
|
408
|
+
${SqueezedOutStatusFragmentDoc}`;
|
341
409
|
var TransactionStatusFragmentDoc = import_graphql_tag.default`
|
342
410
|
fragment transactionStatusFragment on TransactionStatus {
|
343
411
|
... on SubmittedStatus {
|
@@ -678,6 +746,12 @@ var GasCostsFragmentDoc = import_graphql_tag.default`
|
|
678
746
|
alocDependentCost {
|
679
747
|
...DependentCostFragment
|
680
748
|
}
|
749
|
+
bldd {
|
750
|
+
...DependentCostFragment
|
751
|
+
}
|
752
|
+
bsiz {
|
753
|
+
...DependentCostFragment
|
754
|
+
}
|
681
755
|
cfe {
|
682
756
|
...DependentCostFragment
|
683
757
|
}
|
@@ -696,6 +770,9 @@ var GasCostsFragmentDoc = import_graphql_tag.default`
|
|
696
770
|
csiz {
|
697
771
|
...DependentCostFragment
|
698
772
|
}
|
773
|
+
ed19DependentCost {
|
774
|
+
...DependentCostFragment
|
775
|
+
}
|
699
776
|
k256 {
|
700
777
|
...DependentCostFragment
|
701
778
|
}
|
@@ -1227,12 +1304,11 @@ function getSdk(requester) {
|
|
1227
1304
|
var import_errors = require("@fuel-ts/errors");
|
1228
1305
|
var import_graphql = require("graphql");
|
1229
1306
|
var _FuelGraphqlSubscriber = class {
|
1230
|
-
constructor(
|
1231
|
-
this.
|
1307
|
+
constructor(stream) {
|
1308
|
+
this.stream = stream;
|
1232
1309
|
}
|
1233
|
-
|
1234
|
-
|
1235
|
-
const { url, query, variables, fetchFn } = this.options;
|
1310
|
+
static async create(options) {
|
1311
|
+
const { url, query, variables, fetchFn } = options;
|
1236
1312
|
const response = await fetchFn(`${url}-sub`, {
|
1237
1313
|
method: "POST",
|
1238
1314
|
body: JSON.stringify({
|
@@ -1244,14 +1320,11 @@ var _FuelGraphqlSubscriber = class {
|
|
1244
1320
|
Accept: "text/event-stream"
|
1245
1321
|
}
|
1246
1322
|
});
|
1247
|
-
|
1323
|
+
return new _FuelGraphqlSubscriber(response.body.getReader());
|
1248
1324
|
}
|
1249
1325
|
events = [];
|
1250
1326
|
parsingLeftover = "";
|
1251
1327
|
async next() {
|
1252
|
-
if (!this.stream) {
|
1253
|
-
await this.setStream();
|
1254
|
-
}
|
1255
1328
|
while (true) {
|
1256
1329
|
if (this.events.length > 0) {
|
1257
1330
|
const { data, errors } = this.events.shift();
|
@@ -1302,62 +1375,65 @@ var _FuelGraphqlSubscriber = class {
|
|
1302
1375
|
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1303
1376
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1304
1377
|
|
1305
|
-
// src/providers/
|
1378
|
+
// src/providers/resource-cache.ts
|
1306
1379
|
var import_errors2 = require("@fuel-ts/errors");
|
1307
1380
|
var import_utils2 = require("@fuel-ts/utils");
|
1308
|
-
var cache =
|
1309
|
-
var
|
1310
|
-
var MemoryCache = class {
|
1381
|
+
var cache = /* @__PURE__ */ new Map();
|
1382
|
+
var ResourceCache = class {
|
1311
1383
|
ttl;
|
1312
|
-
constructor(
|
1313
|
-
this.ttl =
|
1314
|
-
if (typeof
|
1384
|
+
constructor(ttl) {
|
1385
|
+
this.ttl = ttl;
|
1386
|
+
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1315
1387
|
throw new import_errors2.FuelError(
|
1316
1388
|
import_errors2.ErrorCode.INVALID_TTL,
|
1317
1389
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1318
1390
|
);
|
1319
1391
|
}
|
1320
1392
|
}
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
}
|
1329
|
-
return void 0;
|
1330
|
-
}
|
1331
|
-
set(value) {
|
1332
|
-
const expiresAt = Date.now() + this.ttl;
|
1333
|
-
const key = (0, import_utils2.hexlify)(value);
|
1334
|
-
cache[key] = {
|
1335
|
-
expires: expiresAt,
|
1336
|
-
value
|
1393
|
+
// Add resources to the cache
|
1394
|
+
set(transactionId, resources) {
|
1395
|
+
const currentTime = Date.now();
|
1396
|
+
const existingResources = cache.get(transactionId) || {
|
1397
|
+
utxos: /* @__PURE__ */ new Set(),
|
1398
|
+
messages: /* @__PURE__ */ new Set(),
|
1399
|
+
timestamp: currentTime
|
1337
1400
|
};
|
1338
|
-
|
1401
|
+
resources.utxos.forEach((utxo) => existingResources.utxos.add((0, import_utils2.hexlify)(utxo)));
|
1402
|
+
resources.messages.forEach((message) => existingResources.messages.add((0, import_utils2.hexlify)(message)));
|
1403
|
+
cache.set(transactionId, existingResources);
|
1339
1404
|
}
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
if (data) {
|
1344
|
-
list.push(data);
|
1345
|
-
}
|
1346
|
-
return list;
|
1347
|
-
}, []);
|
1405
|
+
// Remove resources from the cache for a given transaction ID
|
1406
|
+
unset(transactionId) {
|
1407
|
+
cache.delete(transactionId);
|
1348
1408
|
}
|
1409
|
+
// Get all cached resources and remove expired ones
|
1349
1410
|
getActiveData() {
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1411
|
+
const allResources = { utxos: [], messages: [] };
|
1412
|
+
const currentTime = Date.now();
|
1413
|
+
cache.forEach((resource, transactionId) => {
|
1414
|
+
if (currentTime - resource.timestamp < this.ttl) {
|
1415
|
+
allResources.utxos.push(...resource.utxos);
|
1416
|
+
allResources.messages.push(...resource.messages);
|
1417
|
+
} else {
|
1418
|
+
cache.delete(transactionId);
|
1354
1419
|
}
|
1355
|
-
|
1356
|
-
|
1420
|
+
});
|
1421
|
+
return allResources;
|
1422
|
+
}
|
1423
|
+
// Check if a UTXO ID or message nonce is already cached and not expired
|
1424
|
+
isCached(key) {
|
1425
|
+
const currentTime = Date.now();
|
1426
|
+
for (const [transactionId, resourceData] of cache.entries()) {
|
1427
|
+
if (currentTime - resourceData.timestamp > this.ttl) {
|
1428
|
+
cache.delete(transactionId);
|
1429
|
+
} else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
|
1430
|
+
return true;
|
1431
|
+
}
|
1432
|
+
}
|
1433
|
+
return false;
|
1357
1434
|
}
|
1358
|
-
|
1359
|
-
|
1360
|
-
delete cache[key];
|
1435
|
+
clear() {
|
1436
|
+
cache.clear();
|
1361
1437
|
}
|
1362
1438
|
};
|
1363
1439
|
|
@@ -1498,6 +1574,7 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1498
1574
|
var import_address = require("@fuel-ts/address");
|
1499
1575
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1500
1576
|
var import_crypto = require("@fuel-ts/crypto");
|
1577
|
+
var import_errors8 = require("@fuel-ts/errors");
|
1501
1578
|
var import_math8 = require("@fuel-ts/math");
|
1502
1579
|
var import_transactions7 = require("@fuel-ts/transactions");
|
1503
1580
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -1867,6 +1944,15 @@ function calculateMetadataGasForTxScript({
|
|
1867
1944
|
}) {
|
1868
1945
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1869
1946
|
}
|
1947
|
+
function calculateMetadataGasForTxBlob({
|
1948
|
+
gasCosts,
|
1949
|
+
txBytesSize,
|
1950
|
+
witnessBytesSize
|
1951
|
+
}) {
|
1952
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1953
|
+
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
1954
|
+
return txId.add(blobLen);
|
1955
|
+
}
|
1870
1956
|
var calculateGasFee = (params) => {
|
1871
1957
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1872
1958
|
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
@@ -2435,7 +2521,7 @@ var BaseTransactionRequest = class {
|
|
2435
2521
|
* @hidden
|
2436
2522
|
*/
|
2437
2523
|
metadataGas(_gasCosts) {
|
2438
|
-
throw new
|
2524
|
+
throw new import_errors8.FuelError(import_errors8.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2439
2525
|
}
|
2440
2526
|
/**
|
2441
2527
|
* @hidden
|
@@ -2510,6 +2596,7 @@ var BaseTransactionRequest = class {
|
|
2510
2596
|
};
|
2511
2597
|
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
2512
2598
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2599
|
+
return this;
|
2513
2600
|
}
|
2514
2601
|
/**
|
2515
2602
|
* Retrieves an array of CoinQuantity for each coin output present in the transaction.
|
@@ -2556,14 +2643,11 @@ var BaseTransactionRequest = class {
|
|
2556
2643
|
}
|
2557
2644
|
});
|
2558
2645
|
}
|
2646
|
+
byteLength() {
|
2647
|
+
return this.toTransactionBytes().byteLength;
|
2648
|
+
}
|
2559
2649
|
};
|
2560
2650
|
|
2561
|
-
// src/providers/transaction-request/create-transaction-request.ts
|
2562
|
-
var import_configs8 = require("@fuel-ts/address/configs");
|
2563
|
-
var import_math10 = require("@fuel-ts/math");
|
2564
|
-
var import_transactions9 = require("@fuel-ts/transactions");
|
2565
|
-
var import_utils13 = require("@fuel-ts/utils");
|
2566
|
-
|
2567
2651
|
// src/providers/transaction-request/hash-transaction.ts
|
2568
2652
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2569
2653
|
var import_hasher = require("@fuel-ts/hasher");
|
@@ -2635,11 +2719,81 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2635
2719
|
return (0, import_hasher.sha256)(concatenatedData);
|
2636
2720
|
}
|
2637
2721
|
|
2722
|
+
// src/providers/transaction-request/blob-transaction-request.ts
|
2723
|
+
var BlobTransactionRequest = class extends BaseTransactionRequest {
|
2724
|
+
static from(obj) {
|
2725
|
+
if (obj instanceof this) {
|
2726
|
+
return obj;
|
2727
|
+
}
|
2728
|
+
return new this(obj);
|
2729
|
+
}
|
2730
|
+
/** Type of the transaction */
|
2731
|
+
type = import_transactions7.TransactionType.Blob;
|
2732
|
+
/** Blob ID */
|
2733
|
+
blobId;
|
2734
|
+
/** Witness index of contract bytecode to create */
|
2735
|
+
witnessIndex;
|
2736
|
+
/**
|
2737
|
+
* Creates an instance `BlobTransactionRequest`.
|
2738
|
+
*
|
2739
|
+
* @param blobTransactionRequestLike - The initial values for the instance
|
2740
|
+
*/
|
2741
|
+
constructor({ witnessIndex, blobId, ...rest }) {
|
2742
|
+
super(rest);
|
2743
|
+
this.blobId = blobId;
|
2744
|
+
this.witnessIndex = witnessIndex ?? 0;
|
2745
|
+
}
|
2746
|
+
/**
|
2747
|
+
* Converts the transaction request to a `TransactionBlob`.
|
2748
|
+
*
|
2749
|
+
* @returns The transaction create object.
|
2750
|
+
*/
|
2751
|
+
toTransaction() {
|
2752
|
+
const baseTransaction = this.getBaseTransaction();
|
2753
|
+
const { witnessIndex, blobId } = this;
|
2754
|
+
return {
|
2755
|
+
type: import_transactions7.TransactionType.Blob,
|
2756
|
+
...baseTransaction,
|
2757
|
+
blobId,
|
2758
|
+
witnessIndex
|
2759
|
+
};
|
2760
|
+
}
|
2761
|
+
/**
|
2762
|
+
* Gets the Transaction Request by hashing the transaction.
|
2763
|
+
*
|
2764
|
+
* @param chainId - The chain ID.
|
2765
|
+
*
|
2766
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
2767
|
+
*/
|
2768
|
+
getTransactionId(chainId) {
|
2769
|
+
return hashTransaction(this, chainId);
|
2770
|
+
}
|
2771
|
+
/**
|
2772
|
+
* Calculates the metadata gas cost for a blob transaction.
|
2773
|
+
*
|
2774
|
+
* @param gasCosts - gas costs passed from the chain.
|
2775
|
+
* @returns metadata gas cost for the blob transaction.
|
2776
|
+
*/
|
2777
|
+
metadataGas(gasCosts) {
|
2778
|
+
return calculateMetadataGasForTxBlob({
|
2779
|
+
gasCosts,
|
2780
|
+
txBytesSize: this.byteSize(),
|
2781
|
+
witnessBytesSize: this.witnesses[this.witnessIndex].length
|
2782
|
+
});
|
2783
|
+
}
|
2784
|
+
};
|
2785
|
+
|
2786
|
+
// src/providers/transaction-request/create-transaction-request.ts
|
2787
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2788
|
+
var import_math10 = require("@fuel-ts/math");
|
2789
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2790
|
+
var import_utils14 = require("@fuel-ts/utils");
|
2791
|
+
|
2638
2792
|
// src/providers/transaction-request/storage-slot.ts
|
2639
|
-
var
|
2793
|
+
var import_utils13 = require("@fuel-ts/utils");
|
2640
2794
|
var getStorageValue = (value) => {
|
2641
2795
|
const v = new Uint8Array(32);
|
2642
|
-
v.set((0,
|
2796
|
+
v.set((0, import_utils13.arrayify)(value));
|
2643
2797
|
return v;
|
2644
2798
|
};
|
2645
2799
|
var storageSlotify = (storageSlot) => {
|
@@ -2653,8 +2807,8 @@ var storageSlotify = (storageSlot) => {
|
|
2653
2807
|
value = storageSlot.value;
|
2654
2808
|
}
|
2655
2809
|
return {
|
2656
|
-
key: (0,
|
2657
|
-
value: (0,
|
2810
|
+
key: (0, import_utils13.hexlify)(key),
|
2811
|
+
value: (0, import_utils13.hexlify)(getStorageValue(value))
|
2658
2812
|
};
|
2659
2813
|
};
|
2660
2814
|
|
@@ -2682,7 +2836,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2682
2836
|
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
2683
2837
|
super(rest);
|
2684
2838
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2685
|
-
this.salt = (0,
|
2839
|
+
this.salt = (0, import_utils14.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2686
2840
|
this.storageSlots = [...storageSlots ?? []];
|
2687
2841
|
}
|
2688
2842
|
/**
|
@@ -2699,7 +2853,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2699
2853
|
...baseTransaction,
|
2700
2854
|
bytecodeWitnessIndex,
|
2701
2855
|
storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
|
2702
|
-
salt: this.salt ? (0,
|
2856
|
+
salt: this.salt ? (0, import_utils14.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2703
2857
|
storageSlots
|
2704
2858
|
};
|
2705
2859
|
}
|
@@ -2738,7 +2892,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2738
2892
|
}
|
2739
2893
|
metadataGas(gasCosts) {
|
2740
2894
|
return calculateMetadataGasForTxCreate({
|
2741
|
-
contractBytesSize: (0, import_math10.bn)((0,
|
2895
|
+
contractBytesSize: (0, import_math10.bn)((0, import_utils14.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2742
2896
|
gasCosts,
|
2743
2897
|
stateRootSize: this.storageSlots.length,
|
2744
2898
|
txBytesSize: this.byteSize()
|
@@ -2752,17 +2906,17 @@ var import_address2 = require("@fuel-ts/address");
|
|
2752
2906
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2753
2907
|
var import_math11 = require("@fuel-ts/math");
|
2754
2908
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2755
|
-
var
|
2909
|
+
var import_utils16 = require("@fuel-ts/utils");
|
2756
2910
|
|
2757
2911
|
// src/providers/transaction-request/scripts.ts
|
2758
|
-
var
|
2912
|
+
var import_utils15 = require("@fuel-ts/utils");
|
2759
2913
|
var returnZeroScript = {
|
2760
2914
|
/*
|
2761
2915
|
Opcode::RET(REG_ZERO)
|
2762
2916
|
Opcode::NOOP
|
2763
2917
|
*/
|
2764
2918
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2765
|
-
bytes: (0,
|
2919
|
+
bytes: (0, import_utils15.arrayify)("0x24000000"),
|
2766
2920
|
encodeScriptData: () => new Uint8Array(0)
|
2767
2921
|
};
|
2768
2922
|
var withdrawScript = {
|
@@ -2776,7 +2930,7 @@ var withdrawScript = {
|
|
2776
2930
|
00000000 00000000 [amount value]
|
2777
2931
|
*/
|
2778
2932
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2779
|
-
bytes: (0,
|
2933
|
+
bytes: (0, import_utils15.arrayify)("0x5040C0105D44C0064C40001124000000"),
|
2780
2934
|
encodeScriptData: () => new Uint8Array(0)
|
2781
2935
|
};
|
2782
2936
|
|
@@ -2805,8 +2959,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2805
2959
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2806
2960
|
super(rest);
|
2807
2961
|
this.gasLimit = (0, import_math11.bn)(gasLimit);
|
2808
|
-
this.script = (0,
|
2809
|
-
this.scriptData = (0,
|
2962
|
+
this.script = (0, import_utils16.arrayify)(script ?? returnZeroScript.bytes);
|
2963
|
+
this.scriptData = (0, import_utils16.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2810
2964
|
this.abis = rest.abis;
|
2811
2965
|
}
|
2812
2966
|
/**
|
@@ -2815,8 +2969,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2815
2969
|
* @returns The transaction script object.
|
2816
2970
|
*/
|
2817
2971
|
toTransaction() {
|
2818
|
-
const script = (0,
|
2819
|
-
const scriptData = (0,
|
2972
|
+
const script = (0, import_utils16.arrayify)(this.script ?? "0x");
|
2973
|
+
const scriptData = (0, import_utils16.arrayify)(this.scriptData ?? "0x");
|
2820
2974
|
return {
|
2821
2975
|
type: import_transactions10.TransactionType.Script,
|
2822
2976
|
scriptGasLimit: this.gasLimit,
|
@@ -2824,8 +2978,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2824
2978
|
scriptLength: (0, import_math11.bn)(script.length),
|
2825
2979
|
scriptDataLength: (0, import_math11.bn)(scriptData.length),
|
2826
2980
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2827
|
-
script: (0,
|
2828
|
-
scriptData: (0,
|
2981
|
+
script: (0, import_utils16.hexlify)(script),
|
2982
|
+
scriptData: (0, import_utils16.hexlify)(scriptData)
|
2829
2983
|
};
|
2830
2984
|
}
|
2831
2985
|
/**
|
@@ -2963,10 +3117,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2963
3117
|
};
|
2964
3118
|
|
2965
3119
|
// src/providers/transaction-request/utils.ts
|
2966
|
-
var
|
3120
|
+
var import_errors10 = require("@fuel-ts/errors");
|
2967
3121
|
var import_transactions11 = require("@fuel-ts/transactions");
|
2968
3122
|
var transactionRequestify = (obj) => {
|
2969
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
3123
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
2970
3124
|
return obj;
|
2971
3125
|
}
|
2972
3126
|
const { type } = obj;
|
@@ -2977,27 +3131,36 @@ var transactionRequestify = (obj) => {
|
|
2977
3131
|
case import_transactions11.TransactionType.Create: {
|
2978
3132
|
return CreateTransactionRequest.from(obj);
|
2979
3133
|
}
|
3134
|
+
case import_transactions11.TransactionType.Blob: {
|
3135
|
+
return BlobTransactionRequest.from(obj);
|
3136
|
+
}
|
2980
3137
|
default: {
|
2981
|
-
throw new
|
3138
|
+
throw new import_errors10.FuelError(
|
3139
|
+
import_errors10.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3140
|
+
`Unsupported transaction type: ${type}.`
|
3141
|
+
);
|
2982
3142
|
}
|
2983
3143
|
}
|
2984
3144
|
};
|
3145
|
+
var isTransactionTypeScript = (request) => request.type === import_transactions11.TransactionType.Script;
|
3146
|
+
var isTransactionTypeCreate = (request) => request.type === import_transactions11.TransactionType.Create;
|
3147
|
+
var isTransactionTypeBlob = (request) => request.type === import_transactions11.TransactionType.Blob;
|
2985
3148
|
|
2986
3149
|
// src/providers/transaction-response/transaction-response.ts
|
2987
|
-
var
|
2988
|
-
var
|
3150
|
+
var import_errors14 = require("@fuel-ts/errors");
|
3151
|
+
var import_math17 = require("@fuel-ts/math");
|
2989
3152
|
var import_transactions19 = require("@fuel-ts/transactions");
|
2990
|
-
var
|
3153
|
+
var import_utils21 = require("@fuel-ts/utils");
|
2991
3154
|
|
2992
3155
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2993
|
-
var
|
3156
|
+
var import_math16 = require("@fuel-ts/math");
|
2994
3157
|
var import_transactions17 = require("@fuel-ts/transactions");
|
2995
|
-
var
|
3158
|
+
var import_utils19 = require("@fuel-ts/utils");
|
2996
3159
|
|
2997
3160
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2998
3161
|
var import_math12 = require("@fuel-ts/math");
|
2999
3162
|
var import_transactions12 = require("@fuel-ts/transactions");
|
3000
|
-
var
|
3163
|
+
var import_utils17 = require("@fuel-ts/utils");
|
3001
3164
|
var calculateTXFeeForSummary = (params) => {
|
3002
3165
|
const {
|
3003
3166
|
gasPrice,
|
@@ -3011,7 +3174,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3011
3174
|
}
|
3012
3175
|
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
3013
3176
|
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
3014
|
-
const transactionBytes = (0,
|
3177
|
+
const transactionBytes = (0, import_utils17.arrayify)(rawPayload);
|
3015
3178
|
const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
|
3016
3179
|
const { type, witnesses, inputs, policies } = transaction;
|
3017
3180
|
let metadataGas = (0, import_math12.bn)(0);
|
@@ -3021,7 +3184,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3021
3184
|
}
|
3022
3185
|
if (type === import_transactions12.TransactionType.Create) {
|
3023
3186
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3024
|
-
const contractBytesSize = (0, import_math12.bn)((0,
|
3187
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils17.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
3025
3188
|
metadataGas = calculateMetadataGasForTxCreate({
|
3026
3189
|
contractBytesSize,
|
3027
3190
|
gasCosts,
|
@@ -3066,8 +3229,8 @@ var calculateTXFeeForSummary = (params) => {
|
|
3066
3229
|
|
3067
3230
|
// src/providers/transaction-summary/operations.ts
|
3068
3231
|
var import_configs10 = require("@fuel-ts/address/configs");
|
3069
|
-
var
|
3070
|
-
var
|
3232
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3233
|
+
var import_math14 = require("@fuel-ts/math");
|
3071
3234
|
var import_transactions15 = require("@fuel-ts/transactions");
|
3072
3235
|
|
3073
3236
|
// src/providers/transaction-summary/call.ts
|
@@ -3104,7 +3267,8 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3104
3267
|
};
|
3105
3268
|
|
3106
3269
|
// src/providers/transaction-summary/input.ts
|
3107
|
-
var
|
3270
|
+
var import_errors11 = require("@fuel-ts/errors");
|
3271
|
+
var import_math13 = require("@fuel-ts/math");
|
3108
3272
|
var import_transactions13 = require("@fuel-ts/transactions");
|
3109
3273
|
function getInputsByTypes(inputs, types) {
|
3110
3274
|
return inputs.filter((i) => types.includes(i.type));
|
@@ -3121,17 +3285,47 @@ function getInputsMessage(inputs) {
|
|
3121
3285
|
function getInputsCoinAndMessage(inputs) {
|
3122
3286
|
return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
|
3123
3287
|
}
|
3288
|
+
function isInputCoin(input) {
|
3289
|
+
return input.type === import_transactions13.InputType.Coin;
|
3290
|
+
}
|
3124
3291
|
function getInputsContract(inputs) {
|
3125
3292
|
return getInputsByType(inputs, import_transactions13.InputType.Contract);
|
3126
3293
|
}
|
3127
|
-
function
|
3294
|
+
function findCoinInput(inputs, assetId) {
|
3128
3295
|
const coinInputs = getInputsCoin(inputs);
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
)
|
3134
|
-
|
3296
|
+
return coinInputs.find((i) => i.assetId === assetId);
|
3297
|
+
}
|
3298
|
+
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetID) {
|
3299
|
+
const aggregated = /* @__PURE__ */ new Map();
|
3300
|
+
getInputsCoinAndMessage(inputs).forEach((input) => {
|
3301
|
+
const assetId = isInputCoin(input) ? input.assetId : baseAssetID;
|
3302
|
+
const owner = isInputCoin(input) ? input.owner : input.recipient;
|
3303
|
+
let ownersMap = aggregated.get(assetId);
|
3304
|
+
if (!ownersMap) {
|
3305
|
+
ownersMap = /* @__PURE__ */ new Map();
|
3306
|
+
aggregated.set(assetId, ownersMap);
|
3307
|
+
}
|
3308
|
+
let ownerBalance = ownersMap.get(owner);
|
3309
|
+
if (!ownerBalance) {
|
3310
|
+
ownerBalance = new import_math13.BN(0);
|
3311
|
+
ownersMap.set(owner, ownerBalance);
|
3312
|
+
}
|
3313
|
+
ownersMap.set(owner, ownerBalance.add(input.amount));
|
3314
|
+
});
|
3315
|
+
return aggregated;
|
3316
|
+
}
|
3317
|
+
function findMessageInput(inputs) {
|
3318
|
+
return getInputsMessage(inputs)?.[0];
|
3319
|
+
}
|
3320
|
+
function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
|
3321
|
+
const coinInput = findCoinInput(inputs, assetId);
|
3322
|
+
if (coinInput) {
|
3323
|
+
return coinInput;
|
3324
|
+
}
|
3325
|
+
if (isBaseAsset) {
|
3326
|
+
return findMessageInput(inputs);
|
3327
|
+
}
|
3328
|
+
return void 0;
|
3135
3329
|
}
|
3136
3330
|
function getInputContractFromIndex(inputs, inputIndex) {
|
3137
3331
|
if (inputIndex == null) {
|
@@ -3142,8 +3336,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3142
3336
|
return void 0;
|
3143
3337
|
}
|
3144
3338
|
if (contractInput.type !== import_transactions13.InputType.Contract) {
|
3145
|
-
throw new
|
3146
|
-
|
3339
|
+
throw new import_errors11.FuelError(
|
3340
|
+
import_errors11.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3147
3341
|
`Contract input should be of type 'contract'.`
|
3148
3342
|
);
|
3149
3343
|
}
|
@@ -3187,6 +3381,7 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
|
3187
3381
|
TransactionTypeName2["Script"] = "Script";
|
3188
3382
|
TransactionTypeName2["Upgrade"] = "Upgrade";
|
3189
3383
|
TransactionTypeName2["Upload"] = "Upload";
|
3384
|
+
TransactionTypeName2["Blob"] = "Blob";
|
3190
3385
|
return TransactionTypeName2;
|
3191
3386
|
})(TransactionTypeName || {});
|
3192
3387
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
@@ -3232,10 +3427,12 @@ function getTransactionTypeName(transactionType) {
|
|
3232
3427
|
return "Create" /* Create */;
|
3233
3428
|
case import_transactions15.TransactionType.Script:
|
3234
3429
|
return "Script" /* Script */;
|
3430
|
+
case import_transactions15.TransactionType.Blob:
|
3431
|
+
return "Blob" /* Blob */;
|
3235
3432
|
default:
|
3236
|
-
throw new
|
3237
|
-
|
3238
|
-
`
|
3433
|
+
throw new import_errors12.FuelError(
|
3434
|
+
import_errors12.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3435
|
+
`Unsupported transaction type: ${transactionType}.`
|
3239
3436
|
);
|
3240
3437
|
}
|
3241
3438
|
}
|
@@ -3258,6 +3455,9 @@ function isTypeUpgrade(transactionType) {
|
|
3258
3455
|
function isTypeUpload(transactionType) {
|
3259
3456
|
return isType(transactionType, "Upload" /* Upload */);
|
3260
3457
|
}
|
3458
|
+
function isTypeBlob(transactionType) {
|
3459
|
+
return isType(transactionType, "Blob" /* Blob */);
|
3460
|
+
}
|
3261
3461
|
function hasSameAssetId(a) {
|
3262
3462
|
return (b) => a.assetId === b.assetId;
|
3263
3463
|
}
|
@@ -3267,41 +3467,51 @@ function getReceiptsCall(receipts) {
|
|
3267
3467
|
function getReceiptsMessageOut(receipts) {
|
3268
3468
|
return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
|
3269
3469
|
}
|
3270
|
-
|
3470
|
+
function mergeAssets(op1, op2) {
|
3271
3471
|
const assets1 = op1.assetsSent || [];
|
3272
3472
|
const assets2 = op2.assetsSent || [];
|
3273
|
-
const
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3473
|
+
const assetMap = /* @__PURE__ */ new Map();
|
3474
|
+
assets1.forEach((asset) => {
|
3475
|
+
assetMap.set(asset.assetId, { ...asset });
|
3476
|
+
});
|
3477
|
+
assets2.forEach((asset) => {
|
3478
|
+
const existingAsset = assetMap.get(asset.assetId);
|
3479
|
+
if (existingAsset) {
|
3480
|
+
existingAsset.amount = (0, import_math14.bn)(existingAsset.amount).add(asset.amount);
|
3481
|
+
} else {
|
3482
|
+
assetMap.set(asset.assetId, { ...asset });
|
3280
3483
|
}
|
3281
|
-
const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
|
3282
|
-
return { ...asset1, amount: mergedAmount };
|
3283
3484
|
});
|
3284
|
-
return
|
3285
|
-
}
|
3485
|
+
return Array.from(assetMap.values());
|
3486
|
+
}
|
3286
3487
|
function isSameOperation(a, b) {
|
3287
3488
|
return a.name === b.name && a.from?.address === b.from?.address && a.to?.address === b.to?.address && a.from?.type === b.from?.type && a.to?.type === b.to?.type;
|
3288
3489
|
}
|
3490
|
+
function mergeAssetsSent(existing, toAdd) {
|
3491
|
+
if (!toAdd.assetsSent?.length) {
|
3492
|
+
return existing.assetsSent;
|
3493
|
+
}
|
3494
|
+
return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
|
3495
|
+
}
|
3496
|
+
function mergeCalls(existing, toAdd) {
|
3497
|
+
if (!toAdd.calls?.length) {
|
3498
|
+
return existing.calls;
|
3499
|
+
}
|
3500
|
+
return [...existing.calls || [], ...toAdd.calls];
|
3501
|
+
}
|
3502
|
+
function mergeOperations(existing, toAdd) {
|
3503
|
+
return {
|
3504
|
+
...existing,
|
3505
|
+
assetsSent: mergeAssetsSent(existing, toAdd),
|
3506
|
+
calls: mergeCalls(existing, toAdd)
|
3507
|
+
};
|
3508
|
+
}
|
3289
3509
|
function addOperation(operations, toAdd) {
|
3290
|
-
const
|
3291
|
-
|
3292
|
-
|
3293
|
-
const existentOperation = { ...allOperations[index] };
|
3294
|
-
if (toAdd.assetsSent?.length) {
|
3295
|
-
existentOperation.assetsSent = existentOperation.assetsSent?.length ? mergeAssets(existentOperation, toAdd) : toAdd.assetsSent;
|
3296
|
-
}
|
3297
|
-
if (toAdd.calls?.length) {
|
3298
|
-
existentOperation.calls = [...existentOperation.calls || [], ...toAdd.calls];
|
3299
|
-
}
|
3300
|
-
allOperations[index] = existentOperation;
|
3301
|
-
} else {
|
3302
|
-
allOperations.push(toAdd);
|
3510
|
+
const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
|
3511
|
+
if (existingIndex === -1) {
|
3512
|
+
return [...operations, toAdd];
|
3303
3513
|
}
|
3304
|
-
return
|
3514
|
+
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
3305
3515
|
}
|
3306
3516
|
function getReceiptsTransferOut(receipts) {
|
3307
3517
|
return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
|
@@ -3314,7 +3524,7 @@ function getWithdrawFromFuelOperations({
|
|
3314
3524
|
const messageOutReceipts = getReceiptsMessageOut(receipts);
|
3315
3525
|
const withdrawFromFuelOperations = messageOutReceipts.reduce(
|
3316
3526
|
(prevWithdrawFromFuelOps, receipt) => {
|
3317
|
-
const input = getInputFromAssetId(inputs, baseAssetId);
|
3527
|
+
const input = getInputFromAssetId(inputs, baseAssetId, true);
|
3318
3528
|
if (input) {
|
3319
3529
|
const inputAddress = getInputAccountAddress(input);
|
3320
3530
|
const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
|
@@ -3343,65 +3553,80 @@ function getWithdrawFromFuelOperations({
|
|
3343
3553
|
);
|
3344
3554
|
return withdrawFromFuelOperations;
|
3345
3555
|
}
|
3556
|
+
function getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs) {
|
3557
|
+
const abi = abiMap?.[contractInput.contractID];
|
3558
|
+
if (!abi) {
|
3559
|
+
return [];
|
3560
|
+
}
|
3561
|
+
return [
|
3562
|
+
getFunctionCall({
|
3563
|
+
abi,
|
3564
|
+
receipt,
|
3565
|
+
rawPayload,
|
3566
|
+
maxInputs
|
3567
|
+
})
|
3568
|
+
];
|
3569
|
+
}
|
3570
|
+
function getAssetsSent(receipt) {
|
3571
|
+
return receipt.amount?.isZero() ? void 0 : [
|
3572
|
+
{
|
3573
|
+
amount: receipt.amount,
|
3574
|
+
assetId: receipt.assetId
|
3575
|
+
}
|
3576
|
+
];
|
3577
|
+
}
|
3578
|
+
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3579
|
+
const assetId = receipt.assetId === import_configs10.ZeroBytes32 ? baseAssetId : receipt.assetId;
|
3580
|
+
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3581
|
+
if (!input) {
|
3582
|
+
return [];
|
3583
|
+
}
|
3584
|
+
const inputAddress = getInputAccountAddress(input);
|
3585
|
+
const calls = getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs);
|
3586
|
+
return [
|
3587
|
+
{
|
3588
|
+
name: "Contract call" /* contractCall */,
|
3589
|
+
from: {
|
3590
|
+
type: 1 /* account */,
|
3591
|
+
address: inputAddress
|
3592
|
+
},
|
3593
|
+
to: {
|
3594
|
+
type: 0 /* contract */,
|
3595
|
+
address: receipt.to
|
3596
|
+
},
|
3597
|
+
assetsSent: getAssetsSent(receipt),
|
3598
|
+
calls
|
3599
|
+
}
|
3600
|
+
];
|
3601
|
+
}
|
3346
3602
|
function getContractCallOperations({
|
3347
3603
|
inputs,
|
3348
3604
|
outputs,
|
3349
3605
|
receipts,
|
3350
3606
|
abiMap,
|
3351
3607
|
rawPayload,
|
3352
|
-
maxInputs
|
3608
|
+
maxInputs,
|
3609
|
+
baseAssetId
|
3353
3610
|
}) {
|
3354
3611
|
const contractCallReceipts = getReceiptsCall(receipts);
|
3355
3612
|
const contractOutputs = getOutputsContract(outputs);
|
3356
|
-
|
3613
|
+
return contractOutputs.flatMap((output) => {
|
3357
3614
|
const contractInput = getInputContractFromIndex(inputs, output.inputIndex);
|
3358
|
-
if (contractInput) {
|
3359
|
-
|
3360
|
-
if (receipt.to === contractInput.contractID) {
|
3361
|
-
const input = getInputFromAssetId(inputs, receipt.assetId);
|
3362
|
-
if (input) {
|
3363
|
-
const inputAddress = getInputAccountAddress(input);
|
3364
|
-
const calls = [];
|
3365
|
-
const abi = abiMap?.[contractInput.contractID];
|
3366
|
-
if (abi) {
|
3367
|
-
calls.push(
|
3368
|
-
getFunctionCall({
|
3369
|
-
abi,
|
3370
|
-
receipt,
|
3371
|
-
rawPayload,
|
3372
|
-
maxInputs
|
3373
|
-
})
|
3374
|
-
);
|
3375
|
-
}
|
3376
|
-
const newContractCallOps = addOperation(prevContractCallOps, {
|
3377
|
-
name: "Contract call" /* contractCall */,
|
3378
|
-
from: {
|
3379
|
-
type: 1 /* account */,
|
3380
|
-
address: inputAddress
|
3381
|
-
},
|
3382
|
-
to: {
|
3383
|
-
type: 0 /* contract */,
|
3384
|
-
address: receipt.to
|
3385
|
-
},
|
3386
|
-
// if no amount is forwarded to the contract, skip showing assetsSent
|
3387
|
-
assetsSent: receipt.amount?.isZero() ? void 0 : [
|
3388
|
-
{
|
3389
|
-
amount: receipt.amount,
|
3390
|
-
assetId: receipt.assetId
|
3391
|
-
}
|
3392
|
-
],
|
3393
|
-
calls
|
3394
|
-
});
|
3395
|
-
return newContractCallOps;
|
3396
|
-
}
|
3397
|
-
}
|
3398
|
-
return prevContractCallOps;
|
3399
|
-
}, prevOutputCallOps);
|
3400
|
-
return newCallOps;
|
3615
|
+
if (!contractInput) {
|
3616
|
+
return [];
|
3401
3617
|
}
|
3402
|
-
return
|
3403
|
-
|
3404
|
-
|
3618
|
+
return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
|
3619
|
+
(receipt) => processCallReceipt(
|
3620
|
+
receipt,
|
3621
|
+
contractInput,
|
3622
|
+
inputs,
|
3623
|
+
abiMap,
|
3624
|
+
rawPayload,
|
3625
|
+
maxInputs,
|
3626
|
+
baseAssetId
|
3627
|
+
)
|
3628
|
+
);
|
3629
|
+
});
|
3405
3630
|
}
|
3406
3631
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
3407
3632
|
const { to: toAddress, assetId, amount } = receipt;
|
@@ -3433,32 +3658,40 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3433
3658
|
function getTransferOperations({
|
3434
3659
|
inputs,
|
3435
3660
|
outputs,
|
3436
|
-
receipts
|
3661
|
+
receipts,
|
3662
|
+
baseAssetId
|
3437
3663
|
}) {
|
3438
3664
|
let operations = [];
|
3439
3665
|
const coinOutputs = getOutputsCoin(outputs);
|
3440
3666
|
const contractInputs = getInputsContract(inputs);
|
3441
3667
|
const changeOutputs = getOutputsChange(outputs);
|
3442
|
-
|
3443
|
-
|
3444
|
-
const
|
3445
|
-
|
3668
|
+
const aggregated = aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId);
|
3669
|
+
coinOutputs.forEach(({ amount, assetId, to }) => {
|
3670
|
+
const txPayers = aggregated.get(assetId) || /* @__PURE__ */ new Map();
|
3671
|
+
let selectedPayer;
|
3672
|
+
let fallbackPayer;
|
3673
|
+
for (const [address, payedAmount] of txPayers) {
|
3674
|
+
if (!fallbackPayer) {
|
3675
|
+
fallbackPayer = address;
|
3676
|
+
}
|
3677
|
+
if (payedAmount.gte(amount)) {
|
3678
|
+
selectedPayer = address;
|
3679
|
+
break;
|
3680
|
+
}
|
3681
|
+
}
|
3682
|
+
selectedPayer = selectedPayer || fallbackPayer;
|
3683
|
+
if (selectedPayer) {
|
3446
3684
|
operations = addOperation(operations, {
|
3447
3685
|
name: "Transfer asset" /* transfer */,
|
3448
3686
|
from: {
|
3449
3687
|
type: 1 /* account */,
|
3450
|
-
address:
|
3688
|
+
address: selectedPayer
|
3451
3689
|
},
|
3452
3690
|
to: {
|
3453
3691
|
type: 1 /* account */,
|
3454
3692
|
address: to
|
3455
3693
|
},
|
3456
|
-
assetsSent: [
|
3457
|
-
{
|
3458
|
-
assetId,
|
3459
|
-
amount
|
3460
|
-
}
|
3461
|
-
]
|
3694
|
+
assetsSent: [{ assetId, amount }]
|
3462
3695
|
});
|
3463
3696
|
}
|
3464
3697
|
});
|
@@ -3531,21 +3764,19 @@ function getOperations({
|
|
3531
3764
|
baseAssetId
|
3532
3765
|
}) {
|
3533
3766
|
if (isTypeCreate(transactionType)) {
|
3534
|
-
return [
|
3535
|
-
...getContractCreatedOperations({ inputs, outputs }),
|
3536
|
-
...getTransferOperations({ inputs, outputs, receipts })
|
3537
|
-
];
|
3767
|
+
return [...getContractCreatedOperations({ inputs, outputs })];
|
3538
3768
|
}
|
3539
3769
|
if (isTypeScript(transactionType)) {
|
3540
3770
|
return [
|
3541
|
-
...getTransferOperations({ inputs, outputs, receipts }),
|
3771
|
+
...getTransferOperations({ inputs, outputs, receipts, baseAssetId }),
|
3542
3772
|
...getContractCallOperations({
|
3543
3773
|
inputs,
|
3544
3774
|
outputs,
|
3545
3775
|
receipts,
|
3546
3776
|
abiMap,
|
3547
3777
|
rawPayload,
|
3548
|
-
maxInputs
|
3778
|
+
maxInputs,
|
3779
|
+
baseAssetId
|
3549
3780
|
}),
|
3550
3781
|
...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
|
3551
3782
|
];
|
@@ -3604,8 +3835,8 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3604
3835
|
};
|
3605
3836
|
|
3606
3837
|
// src/providers/transaction-summary/status.ts
|
3607
|
-
var
|
3608
|
-
var
|
3838
|
+
var import_errors13 = require("@fuel-ts/errors");
|
3839
|
+
var import_math15 = require("@fuel-ts/math");
|
3609
3840
|
var getTransactionStatusName = (gqlStatus) => {
|
3610
3841
|
switch (gqlStatus) {
|
3611
3842
|
case "FailureStatus":
|
@@ -3617,8 +3848,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3617
3848
|
case "SqueezedOutStatus":
|
3618
3849
|
return "squeezedout" /* squeezedout */;
|
3619
3850
|
default:
|
3620
|
-
throw new
|
3621
|
-
|
3851
|
+
throw new import_errors13.FuelError(
|
3852
|
+
import_errors13.ErrorCode.INVALID_TRANSACTION_STATUS,
|
3622
3853
|
`Invalid transaction status: ${gqlStatus}.`
|
3623
3854
|
);
|
3624
3855
|
}
|
@@ -3639,15 +3870,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3639
3870
|
time = gqlTransactionStatus.time;
|
3640
3871
|
blockId = gqlTransactionStatus.block.id;
|
3641
3872
|
isStatusSuccess = true;
|
3642
|
-
totalFee = (0,
|
3643
|
-
totalGas = (0,
|
3873
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3874
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3644
3875
|
break;
|
3645
3876
|
case "FailureStatus":
|
3646
3877
|
time = gqlTransactionStatus.time;
|
3647
3878
|
blockId = gqlTransactionStatus.block.id;
|
3648
3879
|
isStatusFailure = true;
|
3649
|
-
totalFee = (0,
|
3650
|
-
totalGas = (0,
|
3880
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3881
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3651
3882
|
break;
|
3652
3883
|
case "SubmittedStatus":
|
3653
3884
|
time = gqlTransactionStatus.time;
|
@@ -3687,7 +3918,7 @@ function assembleTransactionSummary(params) {
|
|
3687
3918
|
baseAssetId
|
3688
3919
|
} = params;
|
3689
3920
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3690
|
-
const rawPayload = (0,
|
3921
|
+
const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
|
3691
3922
|
const operations = getOperations({
|
3692
3923
|
transactionType: transaction.type,
|
3693
3924
|
inputs: transaction.inputs || [],
|
@@ -3699,7 +3930,7 @@ function assembleTransactionSummary(params) {
|
|
3699
3930
|
baseAssetId
|
3700
3931
|
});
|
3701
3932
|
const typeName = getTransactionTypeName(transaction.type);
|
3702
|
-
const tip = (0,
|
3933
|
+
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3703
3934
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3704
3935
|
const fee = calculateTXFeeForSummary({
|
3705
3936
|
totalFee,
|
@@ -3719,7 +3950,7 @@ function assembleTransactionSummary(params) {
|
|
3719
3950
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3720
3951
|
let date;
|
3721
3952
|
if (time) {
|
3722
|
-
date =
|
3953
|
+
date = import_utils19.DateTime.fromTai64(time);
|
3723
3954
|
}
|
3724
3955
|
const transactionSummary = {
|
3725
3956
|
id,
|
@@ -3739,6 +3970,7 @@ function assembleTransactionSummary(params) {
|
|
3739
3970
|
isTypeScript: isTypeScript(transaction.type),
|
3740
3971
|
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3741
3972
|
isTypeUpload: isTypeUpload(transaction.type),
|
3973
|
+
isTypeBlob: isTypeBlob(transaction.type),
|
3742
3974
|
isStatusFailure,
|
3743
3975
|
isStatusSuccess,
|
3744
3976
|
isStatusPending,
|
@@ -3764,26 +3996,59 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
3764
3996
|
}
|
3765
3997
|
|
3766
3998
|
// src/providers/transaction-response/transaction-response.ts
|
3999
|
+
function mapGqlOutputsToTxOutputs(outputs) {
|
4000
|
+
return outputs.map((o) => {
|
4001
|
+
const obj = "amount" in o ? { ...o, amount: (0, import_math17.bn)(o.amount) } : o;
|
4002
|
+
switch (obj.type) {
|
4003
|
+
case "CoinOutput":
|
4004
|
+
return { ...obj, type: import_transactions19.OutputType.Coin };
|
4005
|
+
case "ContractOutput":
|
4006
|
+
return {
|
4007
|
+
...obj,
|
4008
|
+
type: import_transactions19.OutputType.Contract,
|
4009
|
+
inputIndex: parseInt(obj.inputIndex, 10)
|
4010
|
+
};
|
4011
|
+
case "ChangeOutput":
|
4012
|
+
return {
|
4013
|
+
...obj,
|
4014
|
+
type: import_transactions19.OutputType.Change
|
4015
|
+
};
|
4016
|
+
case "VariableOutput":
|
4017
|
+
return { ...obj, type: import_transactions19.OutputType.Variable };
|
4018
|
+
case "ContractCreated":
|
4019
|
+
return {
|
4020
|
+
...obj,
|
4021
|
+
type: import_transactions19.OutputType.ContractCreated,
|
4022
|
+
contractId: obj.contract
|
4023
|
+
};
|
4024
|
+
default:
|
4025
|
+
return (0, import_utils21.assertUnreachable)(obj);
|
4026
|
+
}
|
4027
|
+
});
|
4028
|
+
}
|
3767
4029
|
var TransactionResponse = class {
|
3768
4030
|
/** Transaction ID */
|
3769
4031
|
id;
|
3770
4032
|
/** Current provider */
|
3771
4033
|
provider;
|
3772
4034
|
/** Gas used on the transaction */
|
3773
|
-
gasUsed = (0,
|
4035
|
+
gasUsed = (0, import_math17.bn)(0);
|
3774
4036
|
/** The graphql Transaction with receipts object. */
|
3775
4037
|
gqlTransaction;
|
4038
|
+
request;
|
4039
|
+
status;
|
3776
4040
|
abis;
|
3777
4041
|
/**
|
3778
4042
|
* Constructor for `TransactionResponse`.
|
3779
4043
|
*
|
3780
|
-
* @param
|
4044
|
+
* @param tx - The transaction ID or TransactionRequest.
|
3781
4045
|
* @param provider - The provider.
|
3782
4046
|
*/
|
3783
|
-
constructor(
|
3784
|
-
this.id =
|
4047
|
+
constructor(tx, provider, abis) {
|
4048
|
+
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
3785
4049
|
this.provider = provider;
|
3786
4050
|
this.abis = abis;
|
4051
|
+
this.request = typeof tx === "string" ? void 0 : tx;
|
3787
4052
|
}
|
3788
4053
|
/**
|
3789
4054
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
@@ -3798,6 +4063,54 @@ var TransactionResponse = class {
|
|
3798
4063
|
await response.fetch();
|
3799
4064
|
return response;
|
3800
4065
|
}
|
4066
|
+
applyMalleableSubscriptionFields(transaction) {
|
4067
|
+
const status = this.status;
|
4068
|
+
if (!status) {
|
4069
|
+
return;
|
4070
|
+
}
|
4071
|
+
const tx = transaction;
|
4072
|
+
if (status.type === "SuccessStatus" || status.type === "FailureStatus") {
|
4073
|
+
tx.inputs = tx.inputs.map((input, idx) => {
|
4074
|
+
if ("txPointer" in input) {
|
4075
|
+
const correspondingInput = status.transaction.inputs?.[idx];
|
4076
|
+
return {
|
4077
|
+
...input,
|
4078
|
+
txPointer: import_transactions19.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
|
4079
|
+
};
|
4080
|
+
}
|
4081
|
+
return input;
|
4082
|
+
});
|
4083
|
+
tx.outputs = mapGqlOutputsToTxOutputs(status.transaction.outputs);
|
4084
|
+
if ("receiptsRoot" in status.transaction) {
|
4085
|
+
tx.receiptsRoot = status.transaction.receiptsRoot;
|
4086
|
+
}
|
4087
|
+
}
|
4088
|
+
}
|
4089
|
+
async getTransaction() {
|
4090
|
+
if (this.request) {
|
4091
|
+
const tx = this.request.toTransaction();
|
4092
|
+
this.applyMalleableSubscriptionFields(tx);
|
4093
|
+
return {
|
4094
|
+
tx,
|
4095
|
+
bytes: this.request.toTransactionBytes()
|
4096
|
+
};
|
4097
|
+
}
|
4098
|
+
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
4099
|
+
return {
|
4100
|
+
tx: this.decodeTransaction(gqlTransaction),
|
4101
|
+
bytes: (0, import_utils21.arrayify)(gqlTransaction.rawPayload)
|
4102
|
+
};
|
4103
|
+
}
|
4104
|
+
getReceipts() {
|
4105
|
+
const status = this.status ?? this.gqlTransaction?.status;
|
4106
|
+
switch (status?.type) {
|
4107
|
+
case "SuccessStatus":
|
4108
|
+
case "FailureStatus":
|
4109
|
+
return status.receipts.map(processGqlReceipt);
|
4110
|
+
default:
|
4111
|
+
return [];
|
4112
|
+
}
|
4113
|
+
}
|
3801
4114
|
/**
|
3802
4115
|
* Fetch the transaction with receipts from the provider.
|
3803
4116
|
*
|
@@ -3808,11 +4121,12 @@ var TransactionResponse = class {
|
|
3808
4121
|
transactionId: this.id
|
3809
4122
|
});
|
3810
4123
|
if (!response.transaction) {
|
3811
|
-
const subscription = this.provider.operations.statusChange({
|
4124
|
+
const subscription = await this.provider.operations.statusChange({
|
3812
4125
|
transactionId: this.id
|
3813
4126
|
});
|
3814
4127
|
for await (const { statusChange } of subscription) {
|
3815
4128
|
if (statusChange) {
|
4129
|
+
this.status = statusChange;
|
3816
4130
|
break;
|
3817
4131
|
}
|
3818
4132
|
}
|
@@ -3829,7 +4143,7 @@ var TransactionResponse = class {
|
|
3829
4143
|
*/
|
3830
4144
|
decodeTransaction(transactionWithReceipts) {
|
3831
4145
|
return new import_transactions19.TransactionCoder().decode(
|
3832
|
-
(0,
|
4146
|
+
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3833
4147
|
0
|
3834
4148
|
)?.[0];
|
3835
4149
|
}
|
@@ -3841,28 +4155,17 @@ var TransactionResponse = class {
|
|
3841
4155
|
* @returns
|
3842
4156
|
*/
|
3843
4157
|
async getTransactionSummary(contractsAbiMap) {
|
3844
|
-
|
3845
|
-
if (!transaction) {
|
3846
|
-
transaction = await this.fetch();
|
3847
|
-
}
|
3848
|
-
const decodedTransaction = this.decodeTransaction(
|
3849
|
-
transaction
|
3850
|
-
);
|
3851
|
-
let txReceipts = [];
|
3852
|
-
if (transaction?.status && "receipts" in transaction.status) {
|
3853
|
-
txReceipts = transaction.status.receipts;
|
3854
|
-
}
|
3855
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
4158
|
+
const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
|
3856
4159
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3857
4160
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3858
4161
|
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3859
4162
|
const baseAssetId = this.provider.getBaseAssetId();
|
3860
4163
|
const transactionSummary = assembleTransactionSummary({
|
3861
4164
|
id: this.id,
|
3862
|
-
receipts,
|
3863
|
-
transaction
|
3864
|
-
transactionBytes
|
3865
|
-
gqlTransactionStatus:
|
4165
|
+
receipts: this.getReceipts(),
|
4166
|
+
transaction,
|
4167
|
+
transactionBytes,
|
4168
|
+
gqlTransactionStatus: this.status ?? this.gqlTransaction?.status,
|
3866
4169
|
gasPerByte,
|
3867
4170
|
gasPriceFactor,
|
3868
4171
|
abiMap: contractsAbiMap,
|
@@ -3879,13 +4182,15 @@ var TransactionResponse = class {
|
|
3879
4182
|
if (status && status !== "SubmittedStatus") {
|
3880
4183
|
return;
|
3881
4184
|
}
|
3882
|
-
const subscription = this.provider.operations.statusChange({
|
4185
|
+
const subscription = await this.provider.operations.statusChange({
|
3883
4186
|
transactionId: this.id
|
3884
4187
|
});
|
3885
4188
|
for await (const { statusChange } of subscription) {
|
4189
|
+
this.status = statusChange;
|
3886
4190
|
if (statusChange.type === "SqueezedOutStatus") {
|
3887
|
-
|
3888
|
-
|
4191
|
+
this.unsetResourceCache();
|
4192
|
+
throw new import_errors14.FuelError(
|
4193
|
+
import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3889
4194
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3890
4195
|
);
|
3891
4196
|
}
|
@@ -3893,7 +4198,6 @@ var TransactionResponse = class {
|
|
3893
4198
|
break;
|
3894
4199
|
}
|
3895
4200
|
}
|
3896
|
-
await this.fetch();
|
3897
4201
|
}
|
3898
4202
|
/**
|
3899
4203
|
* Assembles the result of a transaction by retrieving the transaction summary,
|
@@ -3910,7 +4214,6 @@ var TransactionResponse = class {
|
|
3910
4214
|
async assembleResult(contractsAbiMap) {
|
3911
4215
|
const transactionSummary = await this.getTransactionSummary(contractsAbiMap);
|
3912
4216
|
const transactionResult = {
|
3913
|
-
gqlTransaction: this.gqlTransaction,
|
3914
4217
|
...transactionSummary
|
3915
4218
|
};
|
3916
4219
|
let logs = [];
|
@@ -3922,9 +4225,11 @@ var TransactionResponse = class {
|
|
3922
4225
|
);
|
3923
4226
|
transactionResult.logs = logs;
|
3924
4227
|
}
|
3925
|
-
const {
|
3926
|
-
|
3927
|
-
|
4228
|
+
const { receipts } = transactionResult;
|
4229
|
+
const status = this.status ?? this.gqlTransaction?.status;
|
4230
|
+
if (status?.type === "FailureStatus") {
|
4231
|
+
this.unsetResourceCache();
|
4232
|
+
const { reason } = status;
|
3928
4233
|
throw extractTxError({
|
3929
4234
|
receipts,
|
3930
4235
|
statusReason: reason,
|
@@ -3950,10 +4255,13 @@ var TransactionResponse = class {
|
|
3950
4255
|
async wait(contractsAbiMap) {
|
3951
4256
|
return this.waitForResult(contractsAbiMap);
|
3952
4257
|
}
|
4258
|
+
unsetResourceCache() {
|
4259
|
+
this.provider.cache?.unset(this.id);
|
4260
|
+
}
|
3953
4261
|
};
|
3954
4262
|
|
3955
4263
|
// src/providers/utils/auto-retry-fetch.ts
|
3956
|
-
var
|
4264
|
+
var import_utils23 = require("@fuel-ts/utils");
|
3957
4265
|
function getWaitDelay(options, retryAttemptNum) {
|
3958
4266
|
const duration = options.baseDelay ?? 150;
|
3959
4267
|
switch (options.backoff) {
|
@@ -3983,30 +4291,17 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3983
4291
|
throw error;
|
3984
4292
|
}
|
3985
4293
|
const delay = getWaitDelay(options, retryNum);
|
3986
|
-
await (0,
|
4294
|
+
await (0, import_utils23.sleep)(delay);
|
3987
4295
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3988
4296
|
}
|
3989
4297
|
};
|
3990
4298
|
}
|
3991
4299
|
|
3992
|
-
// src/providers/utils/merge-quantities.ts
|
3993
|
-
var mergeQuantities = (...coinQuantities) => {
|
3994
|
-
const resultMap = {};
|
3995
|
-
function addToMap({ amount, assetId }) {
|
3996
|
-
if (resultMap[assetId]) {
|
3997
|
-
resultMap[assetId] = resultMap[assetId].add(amount);
|
3998
|
-
} else {
|
3999
|
-
resultMap[assetId] = amount;
|
4000
|
-
}
|
4001
|
-
}
|
4002
|
-
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
4003
|
-
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
4004
|
-
};
|
4005
|
-
|
4006
4300
|
// src/providers/provider.ts
|
4007
4301
|
var MAX_RETRIES = 10;
|
4008
4302
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
4009
4303
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
4304
|
+
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
4010
4305
|
var processGqlChain = (chain) => {
|
4011
4306
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
4012
4307
|
const {
|
@@ -4022,47 +4317,47 @@ var processGqlChain = (chain) => {
|
|
4022
4317
|
} = consensusParameters;
|
4023
4318
|
return {
|
4024
4319
|
name,
|
4025
|
-
baseChainHeight: (0,
|
4320
|
+
baseChainHeight: (0, import_math18.bn)(daHeight),
|
4026
4321
|
consensusParameters: {
|
4027
4322
|
version,
|
4028
|
-
chainId: (0,
|
4323
|
+
chainId: (0, import_math18.bn)(chainId),
|
4029
4324
|
baseAssetId,
|
4030
4325
|
feeParameters: {
|
4031
4326
|
version: feeParams.version,
|
4032
|
-
gasPerByte: (0,
|
4033
|
-
gasPriceFactor: (0,
|
4327
|
+
gasPerByte: (0, import_math18.bn)(feeParams.gasPerByte),
|
4328
|
+
gasPriceFactor: (0, import_math18.bn)(feeParams.gasPriceFactor)
|
4034
4329
|
},
|
4035
4330
|
contractParameters: {
|
4036
4331
|
version: contractParams.version,
|
4037
|
-
contractMaxSize: (0,
|
4038
|
-
maxStorageSlots: (0,
|
4332
|
+
contractMaxSize: (0, import_math18.bn)(contractParams.contractMaxSize),
|
4333
|
+
maxStorageSlots: (0, import_math18.bn)(contractParams.maxStorageSlots)
|
4039
4334
|
},
|
4040
4335
|
txParameters: {
|
4041
4336
|
version: txParams.version,
|
4042
|
-
maxInputs: (0,
|
4043
|
-
maxOutputs: (0,
|
4044
|
-
maxWitnesses: (0,
|
4045
|
-
maxGasPerTx: (0,
|
4046
|
-
maxSize: (0,
|
4047
|
-
maxBytecodeSubsections: (0,
|
4337
|
+
maxInputs: (0, import_math18.bn)(txParams.maxInputs),
|
4338
|
+
maxOutputs: (0, import_math18.bn)(txParams.maxOutputs),
|
4339
|
+
maxWitnesses: (0, import_math18.bn)(txParams.maxWitnesses),
|
4340
|
+
maxGasPerTx: (0, import_math18.bn)(txParams.maxGasPerTx),
|
4341
|
+
maxSize: (0, import_math18.bn)(txParams.maxSize),
|
4342
|
+
maxBytecodeSubsections: (0, import_math18.bn)(txParams.maxBytecodeSubsections)
|
4048
4343
|
},
|
4049
4344
|
predicateParameters: {
|
4050
4345
|
version: predicateParams.version,
|
4051
|
-
maxPredicateLength: (0,
|
4052
|
-
maxPredicateDataLength: (0,
|
4053
|
-
maxGasPerPredicate: (0,
|
4054
|
-
maxMessageDataLength: (0,
|
4346
|
+
maxPredicateLength: (0, import_math18.bn)(predicateParams.maxPredicateLength),
|
4347
|
+
maxPredicateDataLength: (0, import_math18.bn)(predicateParams.maxPredicateDataLength),
|
4348
|
+
maxGasPerPredicate: (0, import_math18.bn)(predicateParams.maxGasPerPredicate),
|
4349
|
+
maxMessageDataLength: (0, import_math18.bn)(predicateParams.maxMessageDataLength)
|
4055
4350
|
},
|
4056
4351
|
scriptParameters: {
|
4057
4352
|
version: scriptParams.version,
|
4058
|
-
maxScriptLength: (0,
|
4059
|
-
maxScriptDataLength: (0,
|
4353
|
+
maxScriptLength: (0, import_math18.bn)(scriptParams.maxScriptLength),
|
4354
|
+
maxScriptDataLength: (0, import_math18.bn)(scriptParams.maxScriptDataLength)
|
4060
4355
|
},
|
4061
4356
|
gasCosts
|
4062
4357
|
},
|
4063
4358
|
latestBlock: {
|
4064
4359
|
id: latestBlock.id,
|
4065
|
-
height: (0,
|
4360
|
+
height: (0, import_math18.bn)(latestBlock.height),
|
4066
4361
|
time: latestBlock.header.time,
|
4067
4362
|
transactions: latestBlock.transactions.map((i) => ({
|
4068
4363
|
id: i.id
|
@@ -4089,14 +4384,23 @@ var _Provider = class {
|
|
4089
4384
|
__publicField(this, "cache");
|
4090
4385
|
__publicField(this, "options", {
|
4091
4386
|
timeout: void 0,
|
4092
|
-
|
4387
|
+
resourceCacheTTL: void 0,
|
4093
4388
|
fetch: void 0,
|
4094
4389
|
retryOptions: void 0
|
4095
4390
|
});
|
4096
4391
|
this.options = { ...this.options, ...options };
|
4097
4392
|
this.url = url;
|
4098
4393
|
this.operations = this.createOperations();
|
4099
|
-
|
4394
|
+
const { resourceCacheTTL } = this.options;
|
4395
|
+
if ((0, import_utils24.isDefined)(resourceCacheTTL)) {
|
4396
|
+
if (resourceCacheTTL !== -1) {
|
4397
|
+
this.cache = new ResourceCache(resourceCacheTTL);
|
4398
|
+
} else {
|
4399
|
+
this.cache = void 0;
|
4400
|
+
}
|
4401
|
+
} else {
|
4402
|
+
this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
|
4403
|
+
}
|
4100
4404
|
}
|
4101
4405
|
/** @hidden */
|
4102
4406
|
static clearChainAndNodeCaches() {
|
@@ -4140,8 +4444,8 @@ var _Provider = class {
|
|
4140
4444
|
getChain() {
|
4141
4445
|
const chain = _Provider.chainInfoCache[this.url];
|
4142
4446
|
if (!chain) {
|
4143
|
-
throw new
|
4144
|
-
|
4447
|
+
throw new import_errors15.FuelError(
|
4448
|
+
import_errors15.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4145
4449
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4146
4450
|
);
|
4147
4451
|
}
|
@@ -4155,8 +4459,8 @@ var _Provider = class {
|
|
4155
4459
|
getNode() {
|
4156
4460
|
const node = _Provider.nodeInfoCache[this.url];
|
4157
4461
|
if (!node) {
|
4158
|
-
throw new
|
4159
|
-
|
4462
|
+
throw new import_errors15.FuelError(
|
4463
|
+
import_errors15.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4160
4464
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4161
4465
|
);
|
4162
4466
|
}
|
@@ -4198,9 +4502,9 @@ var _Provider = class {
|
|
4198
4502
|
* @returns A promise that resolves to the Chain and NodeInfo.
|
4199
4503
|
*/
|
4200
4504
|
async fetchChainAndNodeInfo() {
|
4201
|
-
const chain = await this.fetchChain();
|
4202
4505
|
const nodeInfo = await this.fetchNode();
|
4203
4506
|
_Provider.ensureClientVersionIsSupported(nodeInfo);
|
4507
|
+
const chain = await this.fetchChain();
|
4204
4508
|
return {
|
4205
4509
|
chain,
|
4206
4510
|
nodeInfo
|
@@ -4234,8 +4538,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4234
4538
|
if ("response" in response) {
|
4235
4539
|
const graphQlResponse = response.response;
|
4236
4540
|
if (Array.isArray(graphQlResponse?.errors)) {
|
4237
|
-
throw new
|
4238
|
-
|
4541
|
+
throw new import_errors15.FuelError(
|
4542
|
+
import_errors15.FuelError.CODES.INVALID_REQUEST,
|
4239
4543
|
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
4240
4544
|
);
|
4241
4545
|
}
|
@@ -4246,7 +4550,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4246
4550
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
4247
4551
|
const isSubscription = opDefinition?.operation === "subscription";
|
4248
4552
|
if (isSubscription) {
|
4249
|
-
return
|
4553
|
+
return FuelGraphqlSubscriber.create({
|
4250
4554
|
url: this.url,
|
4251
4555
|
query,
|
4252
4556
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
@@ -4275,7 +4579,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4275
4579
|
*/
|
4276
4580
|
async getBlockNumber() {
|
4277
4581
|
const { chain } = await this.operations.getChain();
|
4278
|
-
return (0,
|
4582
|
+
return (0, import_math18.bn)(chain.latestBlock.height, 10);
|
4279
4583
|
}
|
4280
4584
|
/**
|
4281
4585
|
* Returns the node information for the current provider network.
|
@@ -4285,8 +4589,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4285
4589
|
async fetchNode() {
|
4286
4590
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4287
4591
|
const processedNodeInfo = {
|
4288
|
-
maxDepth: (0,
|
4289
|
-
maxTx: (0,
|
4592
|
+
maxDepth: (0, import_math18.bn)(nodeInfo.maxDepth),
|
4593
|
+
maxTx: (0, import_math18.bn)(nodeInfo.maxTx),
|
4290
4594
|
nodeVersion: nodeInfo.nodeVersion,
|
4291
4595
|
utxoValidation: nodeInfo.utxoValidation,
|
4292
4596
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4327,6 +4631,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4327
4631
|
} = this.getChain();
|
4328
4632
|
return baseAssetId;
|
4329
4633
|
}
|
4634
|
+
validateTransaction(tx, consensusParameters) {
|
4635
|
+
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4636
|
+
if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
|
4637
|
+
throw new import_errors15.FuelError(
|
4638
|
+
import_errors15.ErrorCode.MAX_INPUTS_EXCEEDED,
|
4639
|
+
"The transaction exceeds the maximum allowed number of inputs."
|
4640
|
+
);
|
4641
|
+
}
|
4642
|
+
if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
|
4643
|
+
throw new import_errors15.FuelError(
|
4644
|
+
import_errors15.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
4645
|
+
"The transaction exceeds the maximum allowed number of outputs."
|
4646
|
+
);
|
4647
|
+
}
|
4648
|
+
}
|
4330
4649
|
/**
|
4331
4650
|
* Submits a transaction to the chain to be executed.
|
4332
4651
|
*
|
@@ -4338,39 +4657,23 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4338
4657
|
* @returns A promise that resolves to the transaction response object.
|
4339
4658
|
*/
|
4340
4659
|
// #region Provider-sendTransaction
|
4341
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true
|
4660
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
4342
4661
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4343
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
|
4344
4662
|
if (estimateTxDependencies) {
|
4345
4663
|
await this.estimateTxDependencies(transactionRequest);
|
4346
4664
|
}
|
4347
|
-
const
|
4665
|
+
const { consensusParameters } = this.getChain();
|
4666
|
+
this.validateTransaction(transactionRequest, consensusParameters);
|
4667
|
+
const encodedTransaction = (0, import_utils24.hexlify)(transactionRequest.toTransactionBytes());
|
4348
4668
|
let abis;
|
4349
|
-
if (transactionRequest
|
4669
|
+
if (isTransactionTypeScript(transactionRequest)) {
|
4350
4670
|
abis = transactionRequest.abis;
|
4351
4671
|
}
|
4352
|
-
if (awaitExecution) {
|
4353
|
-
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
4354
|
-
for await (const { submitAndAwait } of subscription) {
|
4355
|
-
if (submitAndAwait.type === "SqueezedOutStatus") {
|
4356
|
-
throw new import_errors14.FuelError(
|
4357
|
-
import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
4358
|
-
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
4359
|
-
);
|
4360
|
-
}
|
4361
|
-
if (submitAndAwait.type !== "SubmittedStatus") {
|
4362
|
-
break;
|
4363
|
-
}
|
4364
|
-
}
|
4365
|
-
const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
|
4366
|
-
const response = new TransactionResponse(transactionId2, this, abis);
|
4367
|
-
await response.fetch();
|
4368
|
-
return response;
|
4369
|
-
}
|
4370
4672
|
const {
|
4371
4673
|
submit: { id: transactionId }
|
4372
4674
|
} = await this.operations.submit({ encodedTransaction });
|
4373
|
-
|
4675
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4676
|
+
return new TransactionResponse(transactionRequest, this, abis);
|
4374
4677
|
}
|
4375
4678
|
/**
|
4376
4679
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -4387,7 +4690,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4387
4690
|
if (estimateTxDependencies) {
|
4388
4691
|
return this.estimateTxDependencies(transactionRequest);
|
4389
4692
|
}
|
4390
|
-
const encodedTransaction = (0,
|
4693
|
+
const encodedTransaction = (0, import_utils24.hexlify)(transactionRequest.toTransactionBytes());
|
4391
4694
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4392
4695
|
encodedTransactions: encodedTransaction,
|
4393
4696
|
utxoValidation: utxoValidation || false
|
@@ -4407,13 +4710,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4407
4710
|
async estimatePredicates(transactionRequest) {
|
4408
4711
|
const shouldEstimatePredicates = Boolean(
|
4409
4712
|
transactionRequest.inputs.find(
|
4410
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4713
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils25.equalBytes)((0, import_utils24.arrayify)(input.predicate), (0, import_utils24.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
|
4411
4714
|
)
|
4412
4715
|
);
|
4413
4716
|
if (!shouldEstimatePredicates) {
|
4414
4717
|
return transactionRequest;
|
4415
4718
|
}
|
4416
|
-
const encodedTransaction = (0,
|
4719
|
+
const encodedTransaction = (0, import_utils24.hexlify)(transactionRequest.toTransactionBytes());
|
4417
4720
|
const response = await this.operations.estimatePredicates({
|
4418
4721
|
encodedTransaction
|
4419
4722
|
});
|
@@ -4422,7 +4725,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4422
4725
|
} = response;
|
4423
4726
|
if (inputs) {
|
4424
4727
|
inputs.forEach((input, index) => {
|
4425
|
-
if ("predicateGasUsed" in input && (0,
|
4728
|
+
if ("predicateGasUsed" in input && (0, import_math18.bn)(input.predicateGasUsed).gt(0)) {
|
4426
4729
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4427
4730
|
}
|
4428
4731
|
});
|
@@ -4439,7 +4742,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4439
4742
|
* @returns A promise that resolves to the estimate transaction dependencies.
|
4440
4743
|
*/
|
4441
4744
|
async estimateTxDependencies(transactionRequest) {
|
4442
|
-
if (transactionRequest
|
4745
|
+
if (isTransactionTypeCreate(transactionRequest)) {
|
4443
4746
|
return {
|
4444
4747
|
receipts: [],
|
4445
4748
|
outputVariables: 0,
|
@@ -4454,14 +4757,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4454
4757
|
const {
|
4455
4758
|
dryRun: [{ receipts: rawReceipts, status }]
|
4456
4759
|
} = await this.operations.dryRun({
|
4457
|
-
encodedTransactions: [(0,
|
4760
|
+
encodedTransactions: [(0, import_utils24.hexlify)(transactionRequest.toTransactionBytes())],
|
4458
4761
|
utxoValidation: false
|
4459
4762
|
});
|
4460
4763
|
receipts = rawReceipts.map(processGqlReceipt);
|
4461
4764
|
dryRunStatus = status;
|
4462
4765
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4463
4766
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4464
|
-
if (hasMissingOutputs) {
|
4767
|
+
if (hasMissingOutputs && isTransactionTypeScript(transactionRequest)) {
|
4465
4768
|
outputVariables += missingOutputVariables.length;
|
4466
4769
|
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
4467
4770
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4503,8 +4806,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4503
4806
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4504
4807
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4505
4808
|
allRequests.forEach((req, index) => {
|
4506
|
-
if (req
|
4507
|
-
serializedTransactionsMap.set(index, (0,
|
4809
|
+
if (isTransactionTypeScript(req)) {
|
4810
|
+
serializedTransactionsMap.set(index, (0, import_utils24.hexlify)(req.toTransactionBytes()));
|
4508
4811
|
}
|
4509
4812
|
});
|
4510
4813
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4529,7 +4832,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4529
4832
|
);
|
4530
4833
|
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4531
4834
|
const request = allRequests[requestIdx];
|
4532
|
-
if (hasMissingOutputs && request
|
4835
|
+
if (hasMissingOutputs && isTransactionTypeScript(request)) {
|
4533
4836
|
result.outputVariables += missingOutputVariables.length;
|
4534
4837
|
request.addVariableOutputs(missingOutputVariables.length);
|
4535
4838
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4540,7 +4843,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4540
4843
|
transactionRequest: request
|
4541
4844
|
});
|
4542
4845
|
request.maxFee = maxFee;
|
4543
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4846
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils24.hexlify)(request.toTransactionBytes()));
|
4544
4847
|
nextRoundTransactions.push(requestIdx);
|
4545
4848
|
}
|
4546
4849
|
}
|
@@ -4561,7 +4864,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4561
4864
|
if (estimateTxDependencies) {
|
4562
4865
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4563
4866
|
}
|
4564
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4867
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils24.hexlify)(tx.toTransactionBytes()));
|
4565
4868
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4566
4869
|
encodedTransactions,
|
4567
4870
|
utxoValidation: utxoValidation || false
|
@@ -4587,13 +4890,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4587
4890
|
gasPrice = await this.estimateGasPrice(10);
|
4588
4891
|
}
|
4589
4892
|
const minFee = calculateGasFee({
|
4590
|
-
gasPrice: (0,
|
4893
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4591
4894
|
gas: minGas,
|
4592
4895
|
priceFactor: gasPriceFactor,
|
4593
4896
|
tip: transactionRequest.tip
|
4594
4897
|
}).add(1);
|
4595
|
-
let gasLimit = (0,
|
4596
|
-
if (transactionRequest
|
4898
|
+
let gasLimit = (0, import_math18.bn)(0);
|
4899
|
+
if (isTransactionTypeScript(transactionRequest)) {
|
4597
4900
|
gasLimit = transactionRequest.gasLimit;
|
4598
4901
|
if (transactionRequest.gasLimit.eq(0)) {
|
4599
4902
|
transactionRequest.gasLimit = minGas;
|
@@ -4605,7 +4908,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4605
4908
|
}
|
4606
4909
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4607
4910
|
const maxFee = calculateGasFee({
|
4608
|
-
gasPrice: (0,
|
4911
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4609
4912
|
gas: maxGas,
|
4610
4913
|
priceFactor: gasPriceFactor,
|
4611
4914
|
tip: transactionRequest.tip
|
@@ -4635,7 +4938,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4635
4938
|
if (estimateTxDependencies) {
|
4636
4939
|
return this.estimateTxDependencies(transactionRequest);
|
4637
4940
|
}
|
4638
|
-
const encodedTransactions = [(0,
|
4941
|
+
const encodedTransactions = [(0, import_utils24.hexlify)(transactionRequest.toTransactionBytes())];
|
4639
4942
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4640
4943
|
encodedTransactions,
|
4641
4944
|
utxoValidation: true
|
@@ -4648,6 +4951,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4648
4951
|
return { receipts: callResult[0].receipts };
|
4649
4952
|
}
|
4650
4953
|
/**
|
4954
|
+
* @hidden
|
4955
|
+
*
|
4651
4956
|
* Returns a transaction cost to enable user
|
4652
4957
|
* to set gasLimit and also reserve balance amounts
|
4653
4958
|
* on the transaction.
|
@@ -4657,23 +4962,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4657
4962
|
*
|
4658
4963
|
* @returns A promise that resolves to the transaction cost object.
|
4659
4964
|
*/
|
4660
|
-
async getTransactionCost(transactionRequestLike, {
|
4965
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4661
4966
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4662
|
-
const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
|
4663
|
-
const baseAssetId = this.getBaseAssetId();
|
4664
4967
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4665
|
-
const
|
4666
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4667
|
-
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4968
|
+
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4668
4969
|
if (isScriptTransaction) {
|
4669
|
-
txRequestClone.gasLimit = (0,
|
4670
|
-
}
|
4671
|
-
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4672
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4970
|
+
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4673
4971
|
}
|
4674
4972
|
const signedRequest = (0, import_ramda3.clone)(txRequestClone);
|
4675
4973
|
let addedSignatures = 0;
|
4676
|
-
if (signatureCallback &&
|
4974
|
+
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4677
4975
|
const lengthBefore = signedRequest.witnesses.length;
|
4678
4976
|
await signatureCallback(signedRequest);
|
4679
4977
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
@@ -4687,7 +4985,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4687
4985
|
let dryRunStatus;
|
4688
4986
|
let missingContractIds = [];
|
4689
4987
|
let outputVariables = 0;
|
4690
|
-
let gasUsed = (0,
|
4988
|
+
let gasUsed = (0, import_math18.bn)(0);
|
4691
4989
|
txRequestClone.maxFee = maxFee;
|
4692
4990
|
if (isScriptTransaction) {
|
4693
4991
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4706,7 +5004,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4706
5004
|
}));
|
4707
5005
|
}
|
4708
5006
|
return {
|
4709
|
-
requiredQuantities: allQuantities,
|
4710
5007
|
receipts,
|
4711
5008
|
gasUsed,
|
4712
5009
|
gasPrice,
|
@@ -4722,34 +5019,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4722
5019
|
updateMaxFee
|
4723
5020
|
};
|
4724
5021
|
}
|
4725
|
-
/**
|
4726
|
-
* Get the required quantities and associated resources for a transaction.
|
4727
|
-
*
|
4728
|
-
* @param owner - address to add resources from.
|
4729
|
-
* @param transactionRequestLike - transaction request to populate resources for.
|
4730
|
-
* @param quantitiesToContract - quantities for the contract (optional).
|
4731
|
-
*
|
4732
|
-
* @returns a promise resolving to the required quantities for the transaction.
|
4733
|
-
*/
|
4734
|
-
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4735
|
-
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4736
|
-
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
4737
|
-
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4738
|
-
quantitiesToContract
|
4739
|
-
});
|
4740
|
-
transactionRequest.addResources(
|
4741
|
-
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4742
|
-
);
|
4743
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4744
|
-
quantitiesToContract
|
4745
|
-
});
|
4746
|
-
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4747
|
-
return {
|
4748
|
-
resources,
|
4749
|
-
requiredQuantities,
|
4750
|
-
...txCost
|
4751
|
-
};
|
4752
|
-
}
|
4753
5022
|
/**
|
4754
5023
|
* Returns coins for the given owner.
|
4755
5024
|
*
|
@@ -4768,15 +5037,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4768
5037
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
4769
5038
|
inputArgs: paginationArgs
|
4770
5039
|
}),
|
4771
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
5040
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils24.hexlify)(assetId) }
|
4772
5041
|
});
|
4773
5042
|
const coins = edges.map(({ node }) => ({
|
4774
5043
|
id: node.utxoId,
|
4775
5044
|
assetId: node.assetId,
|
4776
|
-
amount: (0,
|
5045
|
+
amount: (0, import_math18.bn)(node.amount),
|
4777
5046
|
owner: import_address3.Address.fromAddressOrString(node.owner),
|
4778
|
-
blockCreated: (0,
|
4779
|
-
txCreatedIdx: (0,
|
5047
|
+
blockCreated: (0, import_math18.bn)(node.blockCreated),
|
5048
|
+
txCreatedIdx: (0, import_math18.bn)(node.txCreatedIdx)
|
4780
5049
|
}));
|
4781
5050
|
return {
|
4782
5051
|
coins,
|
@@ -4794,19 +5063,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4794
5063
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4795
5064
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4796
5065
|
const excludeInput = {
|
4797
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4798
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
5066
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils24.hexlify)(nonce)) || [],
|
5067
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils24.hexlify)(id)) || []
|
4799
5068
|
};
|
4800
5069
|
if (this.cache) {
|
4801
|
-
const
|
4802
|
-
|
4803
|
-
);
|
4804
|
-
excludeInput.utxos = Array.from(uniqueUtxos);
|
5070
|
+
const cached = this.cache.getActiveData();
|
5071
|
+
excludeInput.messages.push(...cached.messages);
|
5072
|
+
excludeInput.utxos.push(...cached.utxos);
|
4805
5073
|
}
|
4806
5074
|
const coinsQuery = {
|
4807
5075
|
owner: ownerAddress.toB256(),
|
4808
5076
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4809
|
-
assetId: (0,
|
5077
|
+
assetId: (0, import_utils24.hexlify)(assetId),
|
4810
5078
|
amount: amount.toString(10),
|
4811
5079
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4812
5080
|
})),
|
@@ -4817,9 +5085,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4817
5085
|
switch (coin.type) {
|
4818
5086
|
case "MessageCoin":
|
4819
5087
|
return {
|
4820
|
-
amount: (0,
|
5088
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4821
5089
|
assetId: coin.assetId,
|
4822
|
-
daHeight: (0,
|
5090
|
+
daHeight: (0, import_math18.bn)(coin.daHeight),
|
4823
5091
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4824
5092
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4825
5093
|
nonce: coin.nonce
|
@@ -4827,11 +5095,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4827
5095
|
case "Coin":
|
4828
5096
|
return {
|
4829
5097
|
id: coin.utxoId,
|
4830
|
-
amount: (0,
|
5098
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4831
5099
|
assetId: coin.assetId,
|
4832
5100
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4833
|
-
blockCreated: (0,
|
4834
|
-
txCreatedIdx: (0,
|
5101
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
5102
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4835
5103
|
};
|
4836
5104
|
default:
|
4837
5105
|
return null;
|
@@ -4848,13 +5116,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4848
5116
|
async getBlock(idOrHeight) {
|
4849
5117
|
let variables;
|
4850
5118
|
if (typeof idOrHeight === "number") {
|
4851
|
-
variables = { height: (0,
|
5119
|
+
variables = { height: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4852
5120
|
} else if (idOrHeight === "latest") {
|
4853
5121
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4854
5122
|
} else if (idOrHeight.length === 66) {
|
4855
5123
|
variables = { blockId: idOrHeight };
|
4856
5124
|
} else {
|
4857
|
-
variables = { blockId: (0,
|
5125
|
+
variables = { blockId: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4858
5126
|
}
|
4859
5127
|
const { block } = await this.operations.getBlock(variables);
|
4860
5128
|
if (!block) {
|
@@ -4862,7 +5130,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4862
5130
|
}
|
4863
5131
|
return {
|
4864
5132
|
id: block.id,
|
4865
|
-
height: (0,
|
5133
|
+
height: (0, import_math18.bn)(block.height),
|
4866
5134
|
time: block.header.time,
|
4867
5135
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4868
5136
|
};
|
@@ -4884,7 +5152,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4884
5152
|
});
|
4885
5153
|
const blocks = edges.map(({ node: block }) => ({
|
4886
5154
|
id: block.id,
|
4887
|
-
height: (0,
|
5155
|
+
height: (0, import_math18.bn)(block.height),
|
4888
5156
|
time: block.header.time,
|
4889
5157
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4890
5158
|
}));
|
@@ -4899,7 +5167,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4899
5167
|
async getBlockWithTransactions(idOrHeight) {
|
4900
5168
|
let variables;
|
4901
5169
|
if (typeof idOrHeight === "number") {
|
4902
|
-
variables = { blockHeight: (0,
|
5170
|
+
variables = { blockHeight: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4903
5171
|
} else if (idOrHeight === "latest") {
|
4904
5172
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4905
5173
|
} else {
|
@@ -4911,11 +5179,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4911
5179
|
}
|
4912
5180
|
return {
|
4913
5181
|
id: block.id,
|
4914
|
-
height: (0,
|
5182
|
+
height: (0, import_math18.bn)(block.height, 10),
|
4915
5183
|
time: block.header.time,
|
4916
5184
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4917
5185
|
transactions: block.transactions.map(
|
4918
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
5186
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils24.arrayify)(tx.rawPayload), 0)?.[0]
|
4919
5187
|
)
|
4920
5188
|
};
|
4921
5189
|
}
|
@@ -4931,7 +5199,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4931
5199
|
return null;
|
4932
5200
|
}
|
4933
5201
|
return new import_transactions20.TransactionCoder().decode(
|
4934
|
-
(0,
|
5202
|
+
(0, import_utils24.arrayify)(transaction.rawPayload),
|
4935
5203
|
0
|
4936
5204
|
)?.[0];
|
4937
5205
|
}
|
@@ -4946,7 +5214,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4946
5214
|
} = await this.operations.getTransactions(paginationArgs);
|
4947
5215
|
const coder = new import_transactions20.TransactionCoder();
|
4948
5216
|
const transactions = edges.map(
|
4949
|
-
({ node: { rawPayload } }) => coder.decode((0,
|
5217
|
+
({ node: { rawPayload } }) => coder.decode((0, import_utils24.arrayify)(rawPayload), 0)[0]
|
4950
5218
|
);
|
4951
5219
|
return { transactions, pageInfo };
|
4952
5220
|
}
|
@@ -4973,9 +5241,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4973
5241
|
async getContractBalance(contractId, assetId) {
|
4974
5242
|
const { contractBalance } = await this.operations.getContractBalance({
|
4975
5243
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4976
|
-
asset: (0,
|
5244
|
+
asset: (0, import_utils24.hexlify)(assetId)
|
4977
5245
|
});
|
4978
|
-
return (0,
|
5246
|
+
return (0, import_math18.bn)(contractBalance.amount, 10);
|
4979
5247
|
}
|
4980
5248
|
/**
|
4981
5249
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4987,9 +5255,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4987
5255
|
async getBalance(owner, assetId) {
|
4988
5256
|
const { balance } = await this.operations.getBalance({
|
4989
5257
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4990
|
-
assetId: (0,
|
5258
|
+
assetId: (0, import_utils24.hexlify)(assetId)
|
4991
5259
|
});
|
4992
|
-
return (0,
|
5260
|
+
return (0, import_math18.bn)(balance.amount, 10);
|
4993
5261
|
}
|
4994
5262
|
/**
|
4995
5263
|
* Returns balances for the given owner.
|
@@ -5011,7 +5279,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5011
5279
|
});
|
5012
5280
|
const balances = edges.map(({ node }) => ({
|
5013
5281
|
assetId: node.assetId,
|
5014
|
-
amount: (0,
|
5282
|
+
amount: (0, import_math18.bn)(node.amount)
|
5015
5283
|
}));
|
5016
5284
|
return { balances };
|
5017
5285
|
}
|
@@ -5037,15 +5305,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5037
5305
|
sender: node.sender,
|
5038
5306
|
recipient: node.recipient,
|
5039
5307
|
nonce: node.nonce,
|
5040
|
-
amount: (0,
|
5308
|
+
amount: (0, import_math18.bn)(node.amount),
|
5041
5309
|
data: node.data
|
5042
5310
|
}),
|
5043
5311
|
sender: import_address3.Address.fromAddressOrString(node.sender),
|
5044
5312
|
recipient: import_address3.Address.fromAddressOrString(node.recipient),
|
5045
5313
|
nonce: node.nonce,
|
5046
|
-
amount: (0,
|
5314
|
+
amount: (0, import_math18.bn)(node.amount),
|
5047
5315
|
data: import_transactions20.InputMessageCoder.decodeData(node.data),
|
5048
|
-
daHeight: (0,
|
5316
|
+
daHeight: (0, import_math18.bn)(node.daHeight)
|
5049
5317
|
}));
|
5050
5318
|
return {
|
5051
5319
|
messages,
|
@@ -5067,8 +5335,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5067
5335
|
nonce
|
5068
5336
|
};
|
5069
5337
|
if (commitBlockId && commitBlockHeight) {
|
5070
|
-
throw new
|
5071
|
-
|
5338
|
+
throw new import_errors15.FuelError(
|
5339
|
+
import_errors15.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5072
5340
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5073
5341
|
);
|
5074
5342
|
}
|
@@ -5102,19 +5370,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5102
5370
|
} = result.messageProof;
|
5103
5371
|
return {
|
5104
5372
|
messageProof: {
|
5105
|
-
proofIndex: (0,
|
5373
|
+
proofIndex: (0, import_math18.bn)(messageProof.proofIndex),
|
5106
5374
|
proofSet: messageProof.proofSet
|
5107
5375
|
},
|
5108
5376
|
blockProof: {
|
5109
|
-
proofIndex: (0,
|
5377
|
+
proofIndex: (0, import_math18.bn)(blockProof.proofIndex),
|
5110
5378
|
proofSet: blockProof.proofSet
|
5111
5379
|
},
|
5112
5380
|
messageBlockHeader: {
|
5113
5381
|
id: messageBlockHeader.id,
|
5114
|
-
daHeight: (0,
|
5382
|
+
daHeight: (0, import_math18.bn)(messageBlockHeader.daHeight),
|
5115
5383
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
5116
5384
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
5117
|
-
height: (0,
|
5385
|
+
height: (0, import_math18.bn)(messageBlockHeader.height),
|
5118
5386
|
prevRoot: messageBlockHeader.prevRoot,
|
5119
5387
|
time: messageBlockHeader.time,
|
5120
5388
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -5126,10 +5394,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5126
5394
|
},
|
5127
5395
|
commitBlockHeader: {
|
5128
5396
|
id: commitBlockHeader.id,
|
5129
|
-
daHeight: (0,
|
5397
|
+
daHeight: (0, import_math18.bn)(commitBlockHeader.daHeight),
|
5130
5398
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
5131
5399
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
5132
|
-
height: (0,
|
5400
|
+
height: (0, import_math18.bn)(commitBlockHeader.height),
|
5133
5401
|
prevRoot: commitBlockHeader.prevRoot,
|
5134
5402
|
time: commitBlockHeader.time,
|
5135
5403
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -5142,7 +5410,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5142
5410
|
sender: import_address3.Address.fromAddressOrString(sender),
|
5143
5411
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
5144
5412
|
nonce,
|
5145
|
-
amount: (0,
|
5413
|
+
amount: (0, import_math18.bn)(amount),
|
5146
5414
|
data
|
5147
5415
|
};
|
5148
5416
|
}
|
@@ -5153,7 +5421,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5153
5421
|
*/
|
5154
5422
|
async getLatestGasPrice() {
|
5155
5423
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
5156
|
-
return (0,
|
5424
|
+
return (0, import_math18.bn)(latestGasPrice.gasPrice);
|
5157
5425
|
}
|
5158
5426
|
/**
|
5159
5427
|
* Returns the estimate gas price for the given block horizon.
|
@@ -5165,7 +5433,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5165
5433
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
5166
5434
|
blockHorizon: String(blockHorizon)
|
5167
5435
|
});
|
5168
|
-
return (0,
|
5436
|
+
return (0, import_math18.bn)(estimateGasPrice.gasPrice);
|
5169
5437
|
}
|
5170
5438
|
/**
|
5171
5439
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -5186,10 +5454,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5186
5454
|
*/
|
5187
5455
|
async produceBlocks(amount, startTime) {
|
5188
5456
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5189
|
-
blocksToProduce: (0,
|
5190
|
-
startTimestamp: startTime ?
|
5457
|
+
blocksToProduce: (0, import_math18.bn)(amount).toString(10),
|
5458
|
+
startTimestamp: startTime ? import_utils24.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5191
5459
|
});
|
5192
|
-
return (0,
|
5460
|
+
return (0, import_math18.bn)(latestBlockHeight);
|
5193
5461
|
}
|
5194
5462
|
/**
|
5195
5463
|
* Get the transaction response for the given transaction ID.
|
@@ -5236,26 +5504,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5236
5504
|
const { paginationLimit, inputArgs = {} } = params;
|
5237
5505
|
const { first, last, after, before } = inputArgs;
|
5238
5506
|
if (after && before) {
|
5239
|
-
throw new
|
5240
|
-
|
5507
|
+
throw new import_errors15.FuelError(
|
5508
|
+
import_errors15.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5241
5509
|
'Pagination arguments "after" and "before" cannot be used together'
|
5242
5510
|
);
|
5243
5511
|
}
|
5244
5512
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5245
|
-
throw new
|
5246
|
-
|
5513
|
+
throw new import_errors15.FuelError(
|
5514
|
+
import_errors15.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5247
5515
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5248
5516
|
);
|
5249
5517
|
}
|
5250
5518
|
if (first && before) {
|
5251
|
-
throw new
|
5252
|
-
|
5519
|
+
throw new import_errors15.FuelError(
|
5520
|
+
import_errors15.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5253
5521
|
'The use of pagination argument "first" with "before" is not supported'
|
5254
5522
|
);
|
5255
5523
|
}
|
5256
5524
|
if (last && after) {
|
5257
|
-
throw new
|
5258
|
-
|
5525
|
+
throw new import_errors15.FuelError(
|
5526
|
+
import_errors15.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5259
5527
|
'The use of pagination argument "last" with "after" is not supported'
|
5260
5528
|
);
|
5261
5529
|
}
|
@@ -5286,15 +5554,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5286
5554
|
};
|
5287
5555
|
var Provider = _Provider;
|
5288
5556
|
_cacheInputs = new WeakSet();
|
5289
|
-
cacheInputs_fn = function(inputs) {
|
5557
|
+
cacheInputs_fn = function(inputs, transactionId) {
|
5290
5558
|
if (!this.cache) {
|
5291
5559
|
return;
|
5292
5560
|
}
|
5293
|
-
inputs.
|
5294
|
-
|
5295
|
-
|
5296
|
-
|
5297
|
-
|
5561
|
+
const inputsToCache = inputs.reduce(
|
5562
|
+
(acc, input) => {
|
5563
|
+
if (input.type === import_transactions20.InputType.Coin) {
|
5564
|
+
acc.utxos.push(input.id);
|
5565
|
+
} else if (input.type === import_transactions20.InputType.Message) {
|
5566
|
+
acc.messages.push(input.nonce);
|
5567
|
+
}
|
5568
|
+
return acc;
|
5569
|
+
},
|
5570
|
+
{ utxos: [], messages: [] }
|
5571
|
+
);
|
5572
|
+
this.cache.set(transactionId, inputsToCache);
|
5298
5573
|
};
|
5299
5574
|
/** @hidden */
|
5300
5575
|
__publicField(Provider, "chainInfoCache", {});
|
@@ -5302,23 +5577,23 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5302
5577
|
__publicField(Provider, "nodeInfoCache", {});
|
5303
5578
|
|
5304
5579
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5305
|
-
var
|
5306
|
-
var
|
5580
|
+
var import_errors16 = require("@fuel-ts/errors");
|
5581
|
+
var import_math19 = require("@fuel-ts/math");
|
5307
5582
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5308
|
-
var
|
5583
|
+
var import_utils27 = require("@fuel-ts/utils");
|
5309
5584
|
async function getTransactionSummary(params) {
|
5310
5585
|
const { id, provider, abiMap } = params;
|
5311
5586
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
5312
5587
|
transactionId: id
|
5313
5588
|
});
|
5314
5589
|
if (!gqlTransaction) {
|
5315
|
-
throw new
|
5316
|
-
|
5590
|
+
throw new import_errors16.FuelError(
|
5591
|
+
import_errors16.ErrorCode.TRANSACTION_NOT_FOUND,
|
5317
5592
|
`Transaction not found for given id: ${id}.`
|
5318
5593
|
);
|
5319
5594
|
}
|
5320
5595
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5321
|
-
(0,
|
5596
|
+
(0, import_utils27.arrayify)(gqlTransaction.rawPayload),
|
5322
5597
|
0
|
5323
5598
|
);
|
5324
5599
|
let txReceipts = [];
|
@@ -5339,10 +5614,10 @@ async function getTransactionSummary(params) {
|
|
5339
5614
|
id: gqlTransaction.id,
|
5340
5615
|
receipts,
|
5341
5616
|
transaction: decodedTransaction,
|
5342
|
-
transactionBytes: (0,
|
5617
|
+
transactionBytes: (0, import_utils27.arrayify)(gqlTransaction.rawPayload),
|
5343
5618
|
gqlTransactionStatus: gqlTransaction.status,
|
5344
|
-
gasPerByte: (0,
|
5345
|
-
gasPriceFactor: (0,
|
5619
|
+
gasPerByte: (0, import_math19.bn)(gasPerByte),
|
5620
|
+
gasPriceFactor: (0, import_math19.bn)(gasPriceFactor),
|
5346
5621
|
abiMap,
|
5347
5622
|
maxInputs,
|
5348
5623
|
gasCosts,
|
@@ -5351,7 +5626,6 @@ async function getTransactionSummary(params) {
|
|
5351
5626
|
baseAssetId
|
5352
5627
|
});
|
5353
5628
|
return {
|
5354
|
-
gqlTransaction,
|
5355
5629
|
...transactionInfo
|
5356
5630
|
};
|
5357
5631
|
}
|
@@ -5365,6 +5639,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
5365
5639
|
const gasPrice = await provider.getLatestGasPrice();
|
5366
5640
|
const baseAssetId = provider.getBaseAssetId();
|
5367
5641
|
const transactionSummary = assembleTransactionSummary({
|
5642
|
+
id: transactionRequest.getTransactionId(provider.getChainId()),
|
5368
5643
|
receipts,
|
5369
5644
|
transaction,
|
5370
5645
|
transactionBytes,
|
@@ -5395,7 +5670,7 @@ async function getTransactionsSummaries(params) {
|
|
5395
5670
|
const transactions = edges.map((edge) => {
|
5396
5671
|
const { node: gqlTransaction } = edge;
|
5397
5672
|
const { id, rawPayload, status } = gqlTransaction;
|
5398
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5673
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils27.arrayify)(rawPayload), 0);
|
5399
5674
|
let txReceipts = [];
|
5400
5675
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5401
5676
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5405,7 +5680,7 @@ async function getTransactionsSummaries(params) {
|
|
5405
5680
|
id,
|
5406
5681
|
receipts,
|
5407
5682
|
transaction: decodedTransaction,
|
5408
|
-
transactionBytes: (0,
|
5683
|
+
transactionBytes: (0, import_utils27.arrayify)(rawPayload),
|
5409
5684
|
gqlTransactionStatus: status,
|
5410
5685
|
abiMap,
|
5411
5686
|
gasPerByte,
|
@@ -5417,7 +5692,6 @@ async function getTransactionsSummaries(params) {
|
|
5417
5692
|
baseAssetId
|
5418
5693
|
});
|
5419
5694
|
const output = {
|
5420
|
-
gqlTransaction,
|
5421
5695
|
...transactionSummary
|
5422
5696
|
};
|
5423
5697
|
return output;
|
@@ -5553,19 +5827,33 @@ var rawAssets = [
|
|
5553
5827
|
];
|
5554
5828
|
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
5555
5829
|
|
5830
|
+
// src/providers/utils/merge-quantities.ts
|
5831
|
+
var mergeQuantities = (...coinQuantities) => {
|
5832
|
+
const resultMap = {};
|
5833
|
+
function addToMap({ amount, assetId }) {
|
5834
|
+
if (resultMap[assetId]) {
|
5835
|
+
resultMap[assetId] = resultMap[assetId].add(amount);
|
5836
|
+
} else {
|
5837
|
+
resultMap[assetId] = amount;
|
5838
|
+
}
|
5839
|
+
}
|
5840
|
+
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
5841
|
+
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
5842
|
+
};
|
5843
|
+
|
5556
5844
|
// src/utils/formatTransferToContractScriptData.ts
|
5557
5845
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5558
|
-
var
|
5559
|
-
var
|
5846
|
+
var import_math20 = require("@fuel-ts/math");
|
5847
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5560
5848
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5561
5849
|
var formatTransferToContractScriptData = (params) => {
|
5562
5850
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5563
5851
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5564
|
-
const encoded = numberCoder.encode(new
|
5852
|
+
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
5565
5853
|
const scriptData = Uint8Array.from([
|
5566
|
-
...(0,
|
5854
|
+
...(0, import_utils29.arrayify)(hexlifiedContractId),
|
5567
5855
|
...encoded,
|
5568
|
-
...(0,
|
5856
|
+
...(0, import_utils29.arrayify)(assetId)
|
5569
5857
|
]);
|
5570
5858
|
return scriptData;
|
5571
5859
|
};
|
@@ -5590,7 +5878,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
5590
5878
|
};
|
5591
5879
|
|
5592
5880
|
// src/account.ts
|
5593
|
-
var MAX_FUNDING_ATTEMPTS =
|
5881
|
+
var MAX_FUNDING_ATTEMPTS = 5;
|
5594
5882
|
var Account = class extends import_interfaces.AbstractAccount {
|
5595
5883
|
/**
|
5596
5884
|
* The address associated with the account.
|
@@ -5626,7 +5914,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5626
5914
|
*/
|
5627
5915
|
get provider() {
|
5628
5916
|
if (!this._provider) {
|
5629
|
-
throw new
|
5917
|
+
throw new import_errors17.FuelError(import_errors17.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
5630
5918
|
}
|
5631
5919
|
return this._provider;
|
5632
5920
|
}
|
@@ -5703,12 +5991,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5703
5991
|
* @returns A promise that resolves to the funded transaction request.
|
5704
5992
|
*/
|
5705
5993
|
async fund(request, params) {
|
5706
|
-
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5994
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
|
5707
5995
|
const fee = request.maxFee;
|
5708
5996
|
const baseAssetId = this.provider.getBaseAssetId();
|
5709
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
5997
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
|
5710
5998
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5711
|
-
amount: (0,
|
5999
|
+
amount: (0, import_math21.bn)(fee),
|
5712
6000
|
assetId: baseAssetId,
|
5713
6001
|
coinQuantities: requiredQuantities
|
5714
6002
|
});
|
@@ -5716,7 +6004,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5716
6004
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5717
6005
|
quantitiesDict[assetId] = {
|
5718
6006
|
required: amount,
|
5719
|
-
owned: (0,
|
6007
|
+
owned: (0, import_math21.bn)(0)
|
5720
6008
|
};
|
5721
6009
|
});
|
5722
6010
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5751,10 +6039,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5751
6039
|
);
|
5752
6040
|
}
|
5753
6041
|
if (!updateMaxFee) {
|
6042
|
+
needsToBeFunded = false;
|
5754
6043
|
break;
|
5755
6044
|
}
|
5756
6045
|
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5757
|
-
transactionRequest: requestToReestimate2
|
6046
|
+
transactionRequest: requestToReestimate2,
|
6047
|
+
gasPrice
|
5758
6048
|
});
|
5759
6049
|
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5760
6050
|
request.inputs,
|
@@ -5774,6 +6064,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5774
6064
|
}
|
5775
6065
|
fundingAttempts += 1;
|
5776
6066
|
}
|
6067
|
+
if (needsToBeFunded) {
|
6068
|
+
throw new import_errors17.FuelError(
|
6069
|
+
import_errors17.ErrorCode.NOT_ENOUGH_FUNDS,
|
6070
|
+
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6071
|
+
);
|
6072
|
+
}
|
5777
6073
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5778
6074
|
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5779
6075
|
if (addedSignatures) {
|
@@ -5874,9 +6170,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5874
6170
|
* @returns A promise that resolves to the transaction response.
|
5875
6171
|
*/
|
5876
6172
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5877
|
-
if ((0,
|
5878
|
-
throw new
|
5879
|
-
|
6173
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
6174
|
+
throw new import_errors17.FuelError(
|
6175
|
+
import_errors17.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5880
6176
|
"Transfer amount must be a positive number."
|
5881
6177
|
);
|
5882
6178
|
}
|
@@ -5884,7 +6180,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5884
6180
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5885
6181
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5886
6182
|
hexlifiedContractId: contractAddress.toB256(),
|
5887
|
-
amountToTransfer: (0,
|
6183
|
+
amountToTransfer: (0, import_math21.bn)(amount),
|
5888
6184
|
assetId: assetIdToTransfer
|
5889
6185
|
});
|
5890
6186
|
let request = new ScriptTransactionRequest({
|
@@ -5893,9 +6189,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5893
6189
|
scriptData
|
5894
6190
|
});
|
5895
6191
|
request.addContractInputAndOutput(contractAddress);
|
5896
|
-
const txCost = await this.
|
5897
|
-
|
5898
|
-
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
6192
|
+
const txCost = await this.getTransactionCost(request, {
|
6193
|
+
quantities: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5899
6194
|
});
|
5900
6195
|
request = this.validateGasLimitAndMaxFee({
|
5901
6196
|
transactionRequest: request,
|
@@ -5916,22 +6211,22 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5916
6211
|
*/
|
5917
6212
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5918
6213
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5919
|
-
const recipientDataArray = (0,
|
6214
|
+
const recipientDataArray = (0, import_utils30.arrayify)(
|
5920
6215
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5921
6216
|
);
|
5922
|
-
const amountDataArray = (0,
|
5923
|
-
"0x".concat((0,
|
6217
|
+
const amountDataArray = (0, import_utils30.arrayify)(
|
6218
|
+
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5924
6219
|
);
|
5925
6220
|
const script = new Uint8Array([
|
5926
|
-
...(0,
|
6221
|
+
...(0, import_utils30.arrayify)(withdrawScript.bytes),
|
5927
6222
|
...recipientDataArray,
|
5928
6223
|
...amountDataArray
|
5929
6224
|
]);
|
5930
6225
|
const params = { script, ...txParams };
|
5931
6226
|
const baseAssetId = this.provider.getBaseAssetId();
|
5932
6227
|
let request = new ScriptTransactionRequest(params);
|
5933
|
-
const
|
5934
|
-
const txCost = await this.
|
6228
|
+
const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
|
6229
|
+
const txCost = await this.getTransactionCost(request, { quantities });
|
5935
6230
|
request = this.validateGasLimitAndMaxFee({
|
5936
6231
|
transactionRequest: request,
|
5937
6232
|
gasUsed: txCost.gasUsed,
|
@@ -5941,6 +6236,58 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5941
6236
|
await this.fund(request, txCost);
|
5942
6237
|
return this.sendTransaction(request);
|
5943
6238
|
}
|
6239
|
+
/**
|
6240
|
+
* Returns a transaction cost to enable user
|
6241
|
+
* to set gasLimit and also reserve balance amounts
|
6242
|
+
* on the transaction.
|
6243
|
+
*
|
6244
|
+
* @param transactionRequestLike - The transaction request object.
|
6245
|
+
* @param transactionCostParams - The transaction cost parameters (optional).
|
6246
|
+
*
|
6247
|
+
* @returns A promise that resolves to the transaction cost object.
|
6248
|
+
*/
|
6249
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6250
|
+
const txRequestClone = (0, import_ramda4.clone)(transactionRequestify(transactionRequestLike));
|
6251
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
6252
|
+
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6253
|
+
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6254
|
+
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
6255
|
+
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6256
|
+
if ("assetId" in input) {
|
6257
|
+
return input.assetId === assetId;
|
6258
|
+
}
|
6259
|
+
if ("recipient" in input) {
|
6260
|
+
return baseAssetId === assetId;
|
6261
|
+
}
|
6262
|
+
return false;
|
6263
|
+
});
|
6264
|
+
const updateAssetInput = (assetId, quantity) => {
|
6265
|
+
const assetInput = findAssetInput(assetId);
|
6266
|
+
const usedQuantity = quantity;
|
6267
|
+
if (assetInput && "amount" in assetInput) {
|
6268
|
+
assetInput.amount = usedQuantity;
|
6269
|
+
} else {
|
6270
|
+
txRequestClone.addResources(
|
6271
|
+
this.generateFakeResources([
|
6272
|
+
{
|
6273
|
+
amount: quantity,
|
6274
|
+
assetId
|
6275
|
+
}
|
6276
|
+
])
|
6277
|
+
);
|
6278
|
+
}
|
6279
|
+
};
|
6280
|
+
mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
|
6281
|
+
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
6282
|
+
);
|
6283
|
+
const txCost = await this.provider.getTransactionCost(txRequestClone, {
|
6284
|
+
signatureCallback
|
6285
|
+
});
|
6286
|
+
return {
|
6287
|
+
...txCost,
|
6288
|
+
requiredQuantities
|
6289
|
+
};
|
6290
|
+
}
|
5944
6291
|
/**
|
5945
6292
|
* Sign a message from the account via the connector.
|
5946
6293
|
*
|
@@ -5951,7 +6298,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5951
6298
|
*/
|
5952
6299
|
async signMessage(message) {
|
5953
6300
|
if (!this._connector) {
|
5954
|
-
throw new
|
6301
|
+
throw new import_errors17.FuelError(import_errors17.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
5955
6302
|
}
|
5956
6303
|
return this._connector.signMessage(this.address.toString(), message);
|
5957
6304
|
}
|
@@ -5963,8 +6310,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5963
6310
|
*/
|
5964
6311
|
async signTransaction(transactionRequestLike) {
|
5965
6312
|
if (!this._connector) {
|
5966
|
-
throw new
|
5967
|
-
|
6313
|
+
throw new import_errors17.FuelError(
|
6314
|
+
import_errors17.ErrorCode.MISSING_CONNECTOR,
|
5968
6315
|
"A connector is required to sign transactions."
|
5969
6316
|
);
|
5970
6317
|
}
|
@@ -5977,7 +6324,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5977
6324
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
5978
6325
|
* @returns A promise that resolves to the transaction response.
|
5979
6326
|
*/
|
5980
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true
|
6327
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
5981
6328
|
if (this._connector) {
|
5982
6329
|
return this.provider.getTransactionResponse(
|
5983
6330
|
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
|
@@ -5988,7 +6335,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5988
6335
|
await this.provider.estimateTxDependencies(transactionRequest);
|
5989
6336
|
}
|
5990
6337
|
return this.provider.sendTransaction(transactionRequest, {
|
5991
|
-
awaitExecution,
|
5992
6338
|
estimateTxDependencies: false
|
5993
6339
|
});
|
5994
6340
|
}
|
@@ -6014,18 +6360,18 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6014
6360
|
*/
|
6015
6361
|
generateFakeResources(coins) {
|
6016
6362
|
return coins.map((coin) => ({
|
6017
|
-
id: (0,
|
6363
|
+
id: (0, import_utils30.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
6018
6364
|
owner: this.address,
|
6019
|
-
blockCreated: (0,
|
6020
|
-
txCreatedIdx: (0,
|
6365
|
+
blockCreated: (0, import_math21.bn)(1),
|
6366
|
+
txCreatedIdx: (0, import_math21.bn)(1),
|
6021
6367
|
...coin
|
6022
6368
|
}));
|
6023
6369
|
}
|
6024
6370
|
/** @hidden * */
|
6025
6371
|
validateTransferAmount(amount) {
|
6026
|
-
if ((0,
|
6027
|
-
throw new
|
6028
|
-
|
6372
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
6373
|
+
throw new import_errors17.FuelError(
|
6374
|
+
import_errors17.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6029
6375
|
"Transfer amount must be a positive number."
|
6030
6376
|
);
|
6031
6377
|
}
|
@@ -6033,9 +6379,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6033
6379
|
/** @hidden * */
|
6034
6380
|
async estimateAndFundTransaction(transactionRequest, txParams) {
|
6035
6381
|
let request = transactionRequest;
|
6036
|
-
const txCost = await this.
|
6037
|
-
resourcesOwner: this
|
6038
|
-
});
|
6382
|
+
const txCost = await this.getTransactionCost(request);
|
6039
6383
|
request = this.validateGasLimitAndMaxFee({
|
6040
6384
|
transactionRequest: request,
|
6041
6385
|
gasUsed: txCost.gasUsed,
|
@@ -6053,19 +6397,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6053
6397
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
6054
6398
|
}) {
|
6055
6399
|
const request = transactionRequestify(transactionRequest);
|
6056
|
-
if (!(0,
|
6400
|
+
if (!(0, import_utils30.isDefined)(setGasLimit)) {
|
6057
6401
|
request.gasLimit = gasUsed;
|
6058
6402
|
} else if (gasUsed.gt(setGasLimit)) {
|
6059
|
-
throw new
|
6060
|
-
|
6403
|
+
throw new import_errors17.FuelError(
|
6404
|
+
import_errors17.ErrorCode.GAS_LIMIT_TOO_LOW,
|
6061
6405
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6062
6406
|
);
|
6063
6407
|
}
|
6064
|
-
if (!(0,
|
6408
|
+
if (!(0, import_utils30.isDefined)(setMaxFee)) {
|
6065
6409
|
request.maxFee = maxFee;
|
6066
6410
|
} else if (maxFee.gt(setMaxFee)) {
|
6067
|
-
throw new
|
6068
|
-
|
6411
|
+
throw new import_errors17.FuelError(
|
6412
|
+
import_errors17.ErrorCode.MAX_FEE_TOO_LOW,
|
6069
6413
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6070
6414
|
);
|
6071
6415
|
}
|
@@ -6075,14 +6419,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6075
6419
|
|
6076
6420
|
// src/wallet/base-wallet-unlocked.ts
|
6077
6421
|
var import_hasher3 = require("@fuel-ts/hasher");
|
6078
|
-
var
|
6422
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6079
6423
|
|
6080
6424
|
// src/signer/signer.ts
|
6081
6425
|
var import_address5 = require("@fuel-ts/address");
|
6082
6426
|
var import_crypto3 = require("@fuel-ts/crypto");
|
6083
6427
|
var import_hasher2 = require("@fuel-ts/hasher");
|
6084
|
-
var
|
6085
|
-
var
|
6428
|
+
var import_math22 = require("@fuel-ts/math");
|
6429
|
+
var import_utils31 = require("@fuel-ts/utils");
|
6086
6430
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
6087
6431
|
var Signer = class {
|
6088
6432
|
address;
|
@@ -6101,10 +6445,10 @@ var Signer = class {
|
|
6101
6445
|
privateKey = `0x${privateKey}`;
|
6102
6446
|
}
|
6103
6447
|
}
|
6104
|
-
const privateKeyBytes = (0,
|
6105
|
-
this.privateKey = (0,
|
6106
|
-
this.publicKey = (0,
|
6107
|
-
this.compressedPublicKey = (0,
|
6448
|
+
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
6449
|
+
this.privateKey = (0, import_utils31.hexlify)(privateKeyBytes);
|
6450
|
+
this.publicKey = (0, import_utils31.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
6451
|
+
this.compressedPublicKey = (0, import_utils31.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
6108
6452
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
6109
6453
|
}
|
6110
6454
|
/**
|
@@ -6118,11 +6462,11 @@ var Signer = class {
|
|
6118
6462
|
* @returns hashed signature
|
6119
6463
|
*/
|
6120
6464
|
sign(data) {
|
6121
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
6122
|
-
const r = (0,
|
6123
|
-
const s = (0,
|
6465
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils31.arrayify)(data), (0, import_utils31.arrayify)(this.privateKey));
|
6466
|
+
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
6467
|
+
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
6124
6468
|
s[0] |= (signature.recovery || 0) << 7;
|
6125
|
-
return (0,
|
6469
|
+
return (0, import_utils31.hexlify)((0, import_utils31.concat)([r, s]));
|
6126
6470
|
}
|
6127
6471
|
/**
|
6128
6472
|
* Add point on the current elliptic curve
|
@@ -6131,8 +6475,8 @@ var Signer = class {
|
|
6131
6475
|
* @returns compressed point on the curve
|
6132
6476
|
*/
|
6133
6477
|
addPoint(point) {
|
6134
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6135
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6478
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils31.arrayify)(this.compressedPublicKey));
|
6479
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils31.arrayify)(point));
|
6136
6480
|
const result = p0.add(p1);
|
6137
6481
|
return `0x${result.toHex(true)}`;
|
6138
6482
|
}
|
@@ -6144,16 +6488,16 @@ var Signer = class {
|
|
6144
6488
|
* @returns public key from signature from the
|
6145
6489
|
*/
|
6146
6490
|
static recoverPublicKey(data, signature) {
|
6147
|
-
const signedMessageBytes = (0,
|
6491
|
+
const signedMessageBytes = (0, import_utils31.arrayify)(signature);
|
6148
6492
|
const r = signedMessageBytes.slice(0, 32);
|
6149
6493
|
const s = signedMessageBytes.slice(32, 64);
|
6150
6494
|
const recoveryParam = (s[0] & 128) >> 7;
|
6151
6495
|
s[0] &= 127;
|
6152
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
6496
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils31.hexlify)(r)), BigInt((0, import_utils31.hexlify)(s))).addRecoveryBit(
|
6153
6497
|
recoveryParam
|
6154
6498
|
);
|
6155
|
-
const publicKey = sig.recoverPublicKey((0,
|
6156
|
-
return (0,
|
6499
|
+
const publicKey = sig.recoverPublicKey((0, import_utils31.arrayify)(data)).toRawBytes(false).slice(1);
|
6500
|
+
return (0, import_utils31.hexlify)(publicKey);
|
6157
6501
|
}
|
6158
6502
|
/**
|
6159
6503
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -6172,7 +6516,7 @@ var Signer = class {
|
|
6172
6516
|
* @returns random 32-byte hashed
|
6173
6517
|
*/
|
6174
6518
|
static generatePrivateKey(entropy) {
|
6175
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
6519
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils31.concat)([(0, import_crypto3.randomBytes)(32), (0, import_utils31.arrayify)(entropy)])) : (0, import_crypto3.randomBytes)(32);
|
6176
6520
|
}
|
6177
6521
|
/**
|
6178
6522
|
* Extended publicKey from a compact publicKey
|
@@ -6181,17 +6525,16 @@ var Signer = class {
|
|
6181
6525
|
* @returns extended publicKey
|
6182
6526
|
*/
|
6183
6527
|
static extendPublicKey(publicKey) {
|
6184
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6185
|
-
return (0,
|
6528
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils31.arrayify)(publicKey));
|
6529
|
+
return (0, import_utils31.hexlify)(point.toRawBytes(false).slice(1));
|
6186
6530
|
}
|
6187
6531
|
};
|
6188
6532
|
|
6189
6533
|
// src/wallet/keystore-wallet.ts
|
6190
6534
|
var import_address6 = require("@fuel-ts/address");
|
6191
6535
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6192
|
-
var
|
6193
|
-
var
|
6194
|
-
var import_uuid = require("uuid");
|
6536
|
+
var import_errors18 = require("@fuel-ts/errors");
|
6537
|
+
var import_utils32 = require("@fuel-ts/utils");
|
6195
6538
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6196
6539
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6197
6540
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6221,7 +6564,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
6221
6564
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6222
6565
|
const mac = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6223
6566
|
const keystore = {
|
6224
|
-
id: (0,
|
6567
|
+
id: (0, import_crypto4.randomUUID)(),
|
6225
6568
|
version: 3,
|
6226
6569
|
address: removeHexPrefix(ownerAddress.toHexString()),
|
6227
6570
|
crypto: {
|
@@ -6267,13 +6610,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6267
6610
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6268
6611
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6269
6612
|
if (mac !== macHash) {
|
6270
|
-
throw new
|
6271
|
-
|
6613
|
+
throw new import_errors18.FuelError(
|
6614
|
+
import_errors18.ErrorCode.INVALID_PASSWORD,
|
6272
6615
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6273
6616
|
);
|
6274
6617
|
}
|
6275
6618
|
const buffer = await (0, import_crypto4.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6276
|
-
const privateKey = (0,
|
6619
|
+
const privateKey = (0, import_utils32.hexlify)(buffer);
|
6277
6620
|
return privateKey;
|
6278
6621
|
}
|
6279
6622
|
|
@@ -6318,7 +6661,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6318
6661
|
*/
|
6319
6662
|
async signMessage(message) {
|
6320
6663
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6321
|
-
return (0,
|
6664
|
+
return (0, import_utils33.hexlify)(signedMessage);
|
6322
6665
|
}
|
6323
6666
|
/**
|
6324
6667
|
* Signs a transaction with the wallet's private key.
|
@@ -6331,7 +6674,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6331
6674
|
const chainId = this.provider.getChainId();
|
6332
6675
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6333
6676
|
const signature = await this.signer().sign(hashedTransaction);
|
6334
|
-
return (0,
|
6677
|
+
return (0, import_utils33.hexlify)(signature);
|
6335
6678
|
}
|
6336
6679
|
/**
|
6337
6680
|
* Populates a transaction with the witnesses signature.
|
@@ -6350,17 +6693,16 @@ var BaseWalletUnlocked = class extends Account {
|
|
6350
6693
|
*
|
6351
6694
|
* @param transactionRequestLike - The transaction request to send.
|
6352
6695
|
* @param estimateTxDependencies - Whether to estimate the transaction dependencies.
|
6353
|
-
* @param awaitExecution - Whether to wait for the transaction to be executed.
|
6354
6696
|
* @returns A promise that resolves to the TransactionResponse object.
|
6355
6697
|
*/
|
6356
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false
|
6698
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
|
6357
6699
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
6358
6700
|
if (estimateTxDependencies) {
|
6359
6701
|
await this.provider.estimateTxDependencies(transactionRequest);
|
6360
6702
|
}
|
6361
6703
|
return this.provider.sendTransaction(
|
6362
6704
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
6363
|
-
{
|
6705
|
+
{ estimateTxDependencies: false }
|
6364
6706
|
);
|
6365
6707
|
}
|
6366
6708
|
/**
|
@@ -6399,16 +6741,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6399
6741
|
|
6400
6742
|
// src/hdwallet/hdwallet.ts
|
6401
6743
|
var import_crypto6 = require("@fuel-ts/crypto");
|
6402
|
-
var
|
6744
|
+
var import_errors21 = require("@fuel-ts/errors");
|
6403
6745
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6404
|
-
var
|
6405
|
-
var
|
6746
|
+
var import_math23 = require("@fuel-ts/math");
|
6747
|
+
var import_utils37 = require("@fuel-ts/utils");
|
6406
6748
|
|
6407
6749
|
// src/mnemonic/mnemonic.ts
|
6408
6750
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6409
|
-
var
|
6751
|
+
var import_errors20 = require("@fuel-ts/errors");
|
6410
6752
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6411
|
-
var
|
6753
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6412
6754
|
|
6413
6755
|
// src/wordlists/words/english.ts
|
6414
6756
|
var english = [
|
@@ -8469,9 +8811,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8469
8811
|
})(Language || {});
|
8470
8812
|
|
8471
8813
|
// src/mnemonic/utils.ts
|
8472
|
-
var
|
8814
|
+
var import_errors19 = require("@fuel-ts/errors");
|
8473
8815
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8474
|
-
var
|
8816
|
+
var import_utils34 = require("@fuel-ts/utils");
|
8475
8817
|
function getLowerMask(bits) {
|
8476
8818
|
return (1 << bits) - 1;
|
8477
8819
|
}
|
@@ -8506,20 +8848,20 @@ function entropyToMnemonicIndices(entropy) {
|
|
8506
8848
|
}
|
8507
8849
|
}
|
8508
8850
|
const checksumBits = entropy.length / 4;
|
8509
|
-
const checksum = (0,
|
8851
|
+
const checksum = (0, import_utils34.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8510
8852
|
indices[indices.length - 1] <<= checksumBits;
|
8511
8853
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8512
8854
|
return indices;
|
8513
8855
|
}
|
8514
8856
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8515
8857
|
const size = Math.ceil(11 * words.length / 8);
|
8516
|
-
const entropy = (0,
|
8858
|
+
const entropy = (0, import_utils34.arrayify)(new Uint8Array(size));
|
8517
8859
|
let offset = 0;
|
8518
8860
|
for (let i = 0; i < words.length; i += 1) {
|
8519
8861
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8520
8862
|
if (index === -1) {
|
8521
|
-
throw new
|
8522
|
-
|
8863
|
+
throw new import_errors19.FuelError(
|
8864
|
+
import_errors19.ErrorCode.INVALID_MNEMONIC,
|
8523
8865
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8524
8866
|
);
|
8525
8867
|
}
|
@@ -8533,10 +8875,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8533
8875
|
const entropyBits = 32 * words.length / 3;
|
8534
8876
|
const checksumBits = words.length / 3;
|
8535
8877
|
const checksumMask = getUpperMask(checksumBits);
|
8536
|
-
const checksum = (0,
|
8878
|
+
const checksum = (0, import_utils34.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8537
8879
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8538
|
-
throw new
|
8539
|
-
|
8880
|
+
throw new import_errors19.FuelError(
|
8881
|
+
import_errors19.ErrorCode.INVALID_CHECKSUM,
|
8540
8882
|
"Checksum validation failed for the provided mnemonic."
|
8541
8883
|
);
|
8542
8884
|
}
|
@@ -8544,22 +8886,22 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8544
8886
|
}
|
8545
8887
|
|
8546
8888
|
// src/mnemonic/mnemonic.ts
|
8547
|
-
var MasterSecret = (0,
|
8889
|
+
var MasterSecret = (0, import_utils35.toUtf8Bytes)("Bitcoin seed");
|
8548
8890
|
var MainnetPRV = "0x0488ade4";
|
8549
8891
|
var TestnetPRV = "0x04358394";
|
8550
8892
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8551
8893
|
function assertWordList(wordlist) {
|
8552
8894
|
if (wordlist.length !== 2048) {
|
8553
|
-
throw new
|
8554
|
-
|
8895
|
+
throw new import_errors20.FuelError(
|
8896
|
+
import_errors20.ErrorCode.INVALID_WORD_LIST,
|
8555
8897
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8556
8898
|
);
|
8557
8899
|
}
|
8558
8900
|
}
|
8559
8901
|
function assertEntropy(entropy) {
|
8560
8902
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8561
|
-
throw new
|
8562
|
-
|
8903
|
+
throw new import_errors20.FuelError(
|
8904
|
+
import_errors20.ErrorCode.INVALID_ENTROPY,
|
8563
8905
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8564
8906
|
);
|
8565
8907
|
}
|
@@ -8569,7 +8911,7 @@ function assertMnemonic(words) {
|
|
8569
8911
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8570
8912
|
", "
|
8571
8913
|
)}] words, but got ${words.length}.`;
|
8572
|
-
throw new
|
8914
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
8573
8915
|
}
|
8574
8916
|
}
|
8575
8917
|
var Mnemonic = class {
|
@@ -8608,7 +8950,7 @@ var Mnemonic = class {
|
|
8608
8950
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8609
8951
|
const words = getWords(phrase);
|
8610
8952
|
assertMnemonic(words);
|
8611
|
-
return (0,
|
8953
|
+
return (0, import_utils35.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8612
8954
|
}
|
8613
8955
|
/**
|
8614
8956
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8616,7 +8958,7 @@ var Mnemonic = class {
|
|
8616
8958
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8617
8959
|
*/
|
8618
8960
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8619
|
-
const entropyBytes = (0,
|
8961
|
+
const entropyBytes = (0, import_utils35.arrayify)(entropy);
|
8620
8962
|
assertWordList(wordlist);
|
8621
8963
|
assertEntropy(entropyBytes);
|
8622
8964
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8628,8 +8970,8 @@ var Mnemonic = class {
|
|
8628
8970
|
*/
|
8629
8971
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8630
8972
|
assertMnemonic(getWords(phrase));
|
8631
|
-
const phraseBytes = (0,
|
8632
|
-
const salt = (0,
|
8973
|
+
const phraseBytes = (0, import_utils35.toUtf8Bytes)(getPhrase(phrase));
|
8974
|
+
const salt = (0, import_utils35.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8633
8975
|
return (0, import_crypto5.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8634
8976
|
}
|
8635
8977
|
/**
|
@@ -8685,14 +9027,14 @@ var Mnemonic = class {
|
|
8685
9027
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8686
9028
|
*/
|
8687
9029
|
static masterKeysFromSeed(seed) {
|
8688
|
-
const seedArray = (0,
|
9030
|
+
const seedArray = (0, import_utils35.arrayify)(seed);
|
8689
9031
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8690
|
-
throw new
|
8691
|
-
|
9032
|
+
throw new import_errors20.FuelError(
|
9033
|
+
import_errors20.ErrorCode.INVALID_SEED,
|
8692
9034
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8693
9035
|
);
|
8694
9036
|
}
|
8695
|
-
return (0,
|
9037
|
+
return (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", MasterSecret, seedArray));
|
8696
9038
|
}
|
8697
9039
|
/**
|
8698
9040
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8703,22 +9045,22 @@ var Mnemonic = class {
|
|
8703
9045
|
*/
|
8704
9046
|
static seedToExtendedKey(seed, testnet = false) {
|
8705
9047
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8706
|
-
const prefix = (0,
|
9048
|
+
const prefix = (0, import_utils35.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8707
9049
|
const depth = "0x00";
|
8708
9050
|
const fingerprint = "0x00000000";
|
8709
9051
|
const index = "0x00000000";
|
8710
9052
|
const chainCode = masterKey.slice(32);
|
8711
9053
|
const privateKey = masterKey.slice(0, 32);
|
8712
|
-
const extendedKey = (0,
|
9054
|
+
const extendedKey = (0, import_utils35.concat)([
|
8713
9055
|
prefix,
|
8714
9056
|
depth,
|
8715
9057
|
fingerprint,
|
8716
9058
|
index,
|
8717
9059
|
chainCode,
|
8718
|
-
(0,
|
9060
|
+
(0, import_utils35.concat)(["0x00", privateKey])
|
8719
9061
|
]);
|
8720
|
-
const checksum = (0,
|
8721
|
-
return (0,
|
9062
|
+
const checksum = (0, import_utils35.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
9063
|
+
return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([extendedKey, checksum]));
|
8722
9064
|
}
|
8723
9065
|
/**
|
8724
9066
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8733,7 +9075,7 @@ var Mnemonic = class {
|
|
8733
9075
|
* @returns A randomly generated mnemonic
|
8734
9076
|
*/
|
8735
9077
|
static generate(size = 32, extraEntropy = "") {
|
8736
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
9078
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils35.concat)([(0, import_crypto5.randomBytes)(size), (0, import_utils35.arrayify)(extraEntropy)])) : (0, import_crypto5.randomBytes)(size);
|
8737
9079
|
return Mnemonic.entropyToMnemonic(entropy);
|
8738
9080
|
}
|
8739
9081
|
};
|
@@ -8741,12 +9083,12 @@ var mnemonic_default = Mnemonic;
|
|
8741
9083
|
|
8742
9084
|
// src/hdwallet/hdwallet.ts
|
8743
9085
|
var HARDENED_INDEX = 2147483648;
|
8744
|
-
var MainnetPRV2 = (0,
|
8745
|
-
var MainnetPUB = (0,
|
8746
|
-
var TestnetPRV2 = (0,
|
8747
|
-
var TestnetPUB = (0,
|
9086
|
+
var MainnetPRV2 = (0, import_utils37.hexlify)("0x0488ade4");
|
9087
|
+
var MainnetPUB = (0, import_utils37.hexlify)("0x0488b21e");
|
9088
|
+
var TestnetPRV2 = (0, import_utils37.hexlify)("0x04358394");
|
9089
|
+
var TestnetPUB = (0, import_utils37.hexlify)("0x043587cf");
|
8748
9090
|
function base58check(data) {
|
8749
|
-
return (0,
|
9091
|
+
return (0, import_utils37.encodeBase58)((0, import_utils37.concat)([data, (0, import_utils37.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8750
9092
|
}
|
8751
9093
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8752
9094
|
if (isPublic) {
|
@@ -8755,17 +9097,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8755
9097
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8756
9098
|
}
|
8757
9099
|
function isPublicExtendedKey(extendedKey) {
|
8758
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
9100
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils37.hexlify)(extendedKey.slice(0, 4)));
|
8759
9101
|
}
|
8760
9102
|
function isValidExtendedKey(extendedKey) {
|
8761
9103
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8762
|
-
(0,
|
9104
|
+
(0, import_utils37.hexlify)(extendedKey.slice(0, 4))
|
8763
9105
|
);
|
8764
9106
|
}
|
8765
9107
|
function parsePath(path, depth = 0) {
|
8766
9108
|
const components = path.split("/");
|
8767
9109
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
8768
|
-
throw new
|
9110
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
8769
9111
|
}
|
8770
9112
|
if (components[0] === "m") {
|
8771
9113
|
components.shift();
|
@@ -8777,8 +9119,8 @@ function parsePath(path, depth = 0) {
|
|
8777
9119
|
var HDWallet = class {
|
8778
9120
|
depth = 0;
|
8779
9121
|
index = 0;
|
8780
|
-
fingerprint = (0,
|
8781
|
-
parentFingerprint = (0,
|
9122
|
+
fingerprint = (0, import_utils37.hexlify)("0x00000000");
|
9123
|
+
parentFingerprint = (0, import_utils37.hexlify)("0x00000000");
|
8782
9124
|
privateKey;
|
8783
9125
|
publicKey;
|
8784
9126
|
chainCode;
|
@@ -8790,19 +9132,19 @@ var HDWallet = class {
|
|
8790
9132
|
constructor(config) {
|
8791
9133
|
if (config.privateKey) {
|
8792
9134
|
const signer = new Signer(config.privateKey);
|
8793
|
-
this.publicKey = (0,
|
8794
|
-
this.privateKey = (0,
|
9135
|
+
this.publicKey = (0, import_utils37.hexlify)(signer.compressedPublicKey);
|
9136
|
+
this.privateKey = (0, import_utils37.hexlify)(config.privateKey);
|
8795
9137
|
} else {
|
8796
9138
|
if (!config.publicKey) {
|
8797
|
-
throw new
|
8798
|
-
|
9139
|
+
throw new import_errors21.FuelError(
|
9140
|
+
import_errors21.ErrorCode.HD_WALLET_ERROR,
|
8799
9141
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8800
9142
|
);
|
8801
9143
|
}
|
8802
|
-
this.publicKey = (0,
|
9144
|
+
this.publicKey = (0, import_utils37.hexlify)(config.publicKey);
|
8803
9145
|
}
|
8804
9146
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8805
|
-
this.fingerprint = (0,
|
9147
|
+
this.fingerprint = (0, import_utils37.dataSlice)((0, import_crypto6.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8806
9148
|
this.depth = config.depth || this.depth;
|
8807
9149
|
this.index = config.index || this.index;
|
8808
9150
|
this.chainCode = config.chainCode;
|
@@ -8818,28 +9160,28 @@ var HDWallet = class {
|
|
8818
9160
|
* @returns A new instance of HDWallet on the derived index
|
8819
9161
|
*/
|
8820
9162
|
deriveIndex(index) {
|
8821
|
-
const privateKey = this.privateKey && (0,
|
8822
|
-
const publicKey = (0,
|
8823
|
-
const chainCode = (0,
|
9163
|
+
const privateKey = this.privateKey && (0, import_utils37.arrayify)(this.privateKey);
|
9164
|
+
const publicKey = (0, import_utils37.arrayify)(this.publicKey);
|
9165
|
+
const chainCode = (0, import_utils37.arrayify)(this.chainCode);
|
8824
9166
|
const data = new Uint8Array(37);
|
8825
9167
|
if (index & HARDENED_INDEX) {
|
8826
9168
|
if (!privateKey) {
|
8827
|
-
throw new
|
8828
|
-
|
9169
|
+
throw new import_errors21.FuelError(
|
9170
|
+
import_errors21.ErrorCode.HD_WALLET_ERROR,
|
8829
9171
|
"Cannot derive a hardened index without a private Key."
|
8830
9172
|
);
|
8831
9173
|
}
|
8832
9174
|
data.set(privateKey, 1);
|
8833
9175
|
} else {
|
8834
|
-
data.set((0,
|
9176
|
+
data.set((0, import_utils37.arrayify)(this.publicKey));
|
8835
9177
|
}
|
8836
|
-
data.set((0,
|
8837
|
-
const bytes = (0,
|
9178
|
+
data.set((0, import_math23.toBytes)(index, 4), 33);
|
9179
|
+
const bytes = (0, import_utils37.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
|
8838
9180
|
const IL = bytes.slice(0, 32);
|
8839
9181
|
const IR = bytes.slice(32);
|
8840
9182
|
if (privateKey) {
|
8841
9183
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8842
|
-
const ki = (0,
|
9184
|
+
const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8843
9185
|
return new HDWallet({
|
8844
9186
|
privateKey: ki,
|
8845
9187
|
chainCode: IR,
|
@@ -8848,7 +9190,7 @@ var HDWallet = class {
|
|
8848
9190
|
parentFingerprint: this.fingerprint
|
8849
9191
|
});
|
8850
9192
|
}
|
8851
|
-
const signer = new Signer((0,
|
9193
|
+
const signer = new Signer((0, import_utils37.hexlify)(IL));
|
8852
9194
|
const Ki = signer.addPoint(publicKey);
|
8853
9195
|
return new HDWallet({
|
8854
9196
|
publicKey: Ki,
|
@@ -8877,18 +9219,18 @@ var HDWallet = class {
|
|
8877
9219
|
*/
|
8878
9220
|
toExtendedKey(isPublic = false, testnet = false) {
|
8879
9221
|
if (this.depth >= 256) {
|
8880
|
-
throw new
|
8881
|
-
|
9222
|
+
throw new import_errors21.FuelError(
|
9223
|
+
import_errors21.ErrorCode.HD_WALLET_ERROR,
|
8882
9224
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
8883
9225
|
);
|
8884
9226
|
}
|
8885
9227
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8886
|
-
const depth = (0,
|
9228
|
+
const depth = (0, import_utils37.hexlify)(Uint8Array.from([this.depth]));
|
8887
9229
|
const parentFingerprint = this.parentFingerprint;
|
8888
|
-
const index = (0,
|
9230
|
+
const index = (0, import_math23.toHex)(this.index, 4);
|
8889
9231
|
const chainCode = this.chainCode;
|
8890
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8891
|
-
const extendedKey = (0,
|
9232
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils37.concat)(["0x00", this.privateKey]) : this.publicKey;
|
9233
|
+
const extendedKey = (0, import_utils37.arrayify)((0, import_utils37.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8892
9234
|
return base58check(extendedKey);
|
8893
9235
|
}
|
8894
9236
|
/**
|
@@ -8900,34 +9242,34 @@ var HDWallet = class {
|
|
8900
9242
|
static fromSeed(seed) {
|
8901
9243
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8902
9244
|
return new HDWallet({
|
8903
|
-
chainCode: (0,
|
8904
|
-
privateKey: (0,
|
9245
|
+
chainCode: (0, import_utils37.arrayify)(masterKey.slice(32)),
|
9246
|
+
privateKey: (0, import_utils37.arrayify)(masterKey.slice(0, 32))
|
8905
9247
|
});
|
8906
9248
|
}
|
8907
9249
|
static fromExtendedKey(extendedKey) {
|
8908
|
-
const decoded = (0,
|
8909
|
-
const bytes = (0,
|
9250
|
+
const decoded = (0, import_utils37.hexlify)((0, import_math23.toBytes)((0, import_utils37.decodeBase58)(extendedKey)));
|
9251
|
+
const bytes = (0, import_utils37.arrayify)(decoded);
|
8910
9252
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8911
9253
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8912
|
-
throw new
|
9254
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
8913
9255
|
}
|
8914
9256
|
if (!validChecksum) {
|
8915
|
-
throw new
|
9257
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8916
9258
|
}
|
8917
9259
|
const depth = bytes[4];
|
8918
|
-
const parentFingerprint = (0,
|
8919
|
-
const index = parseInt((0,
|
8920
|
-
const chainCode = (0,
|
9260
|
+
const parentFingerprint = (0, import_utils37.hexlify)(bytes.slice(5, 9));
|
9261
|
+
const index = parseInt((0, import_utils37.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
9262
|
+
const chainCode = (0, import_utils37.hexlify)(bytes.slice(13, 45));
|
8921
9263
|
const key = bytes.slice(45, 78);
|
8922
9264
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8923
|
-
throw new
|
8924
|
-
|
9265
|
+
throw new import_errors21.FuelError(
|
9266
|
+
import_errors21.ErrorCode.HD_WALLET_ERROR,
|
8925
9267
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
8926
9268
|
);
|
8927
9269
|
}
|
8928
9270
|
if (isPublicExtendedKey(bytes)) {
|
8929
9271
|
if (key[0] !== 3) {
|
8930
|
-
throw new
|
9272
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
8931
9273
|
}
|
8932
9274
|
return new HDWallet({
|
8933
9275
|
publicKey: key,
|
@@ -8938,7 +9280,7 @@ var HDWallet = class {
|
|
8938
9280
|
});
|
8939
9281
|
}
|
8940
9282
|
if (key[0] !== 0) {
|
8941
|
-
throw new
|
9283
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
8942
9284
|
}
|
8943
9285
|
return new HDWallet({
|
8944
9286
|
privateKey: key.slice(1),
|
@@ -9106,7 +9448,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9106
9448
|
// src/wallet-manager/wallet-manager.ts
|
9107
9449
|
var import_address9 = require("@fuel-ts/address");
|
9108
9450
|
var import_crypto7 = require("@fuel-ts/crypto");
|
9109
|
-
var
|
9451
|
+
var import_errors24 = require("@fuel-ts/errors");
|
9110
9452
|
var import_events = require("events");
|
9111
9453
|
|
9112
9454
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9129,7 +9471,7 @@ var MemoryStorage = class {
|
|
9129
9471
|
|
9130
9472
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9131
9473
|
var import_address7 = require("@fuel-ts/address");
|
9132
|
-
var
|
9474
|
+
var import_errors22 = require("@fuel-ts/errors");
|
9133
9475
|
var _secret;
|
9134
9476
|
var MnemonicVault = class {
|
9135
9477
|
constructor(options) {
|
@@ -9185,8 +9527,8 @@ var MnemonicVault = class {
|
|
9185
9527
|
}
|
9186
9528
|
numberOfAccounts += 1;
|
9187
9529
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9188
|
-
throw new
|
9189
|
-
|
9530
|
+
throw new import_errors22.FuelError(
|
9531
|
+
import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
|
9190
9532
|
`Account with address '${address}' not found in derived wallets.`
|
9191
9533
|
);
|
9192
9534
|
}
|
@@ -9200,7 +9542,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9200
9542
|
|
9201
9543
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9202
9544
|
var import_address8 = require("@fuel-ts/address");
|
9203
|
-
var
|
9545
|
+
var import_errors23 = require("@fuel-ts/errors");
|
9204
9546
|
var _privateKeys;
|
9205
9547
|
var PrivateKeyVault = class {
|
9206
9548
|
/**
|
@@ -9241,8 +9583,8 @@ var PrivateKeyVault = class {
|
|
9241
9583
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9242
9584
|
);
|
9243
9585
|
if (!privateKey) {
|
9244
|
-
throw new
|
9245
|
-
|
9586
|
+
throw new import_errors23.FuelError(
|
9587
|
+
import_errors23.ErrorCode.WALLET_MANAGER_ERROR,
|
9246
9588
|
`No private key found for address '${address}'.`
|
9247
9589
|
);
|
9248
9590
|
}
|
@@ -9266,7 +9608,7 @@ var ERROR_MESSAGES = {
|
|
9266
9608
|
};
|
9267
9609
|
function assert(condition, message) {
|
9268
9610
|
if (!condition) {
|
9269
|
-
throw new
|
9611
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.WALLET_MANAGER_ERROR, message);
|
9270
9612
|
}
|
9271
9613
|
}
|
9272
9614
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9492,25 +9834,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9492
9834
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9493
9835
|
|
9494
9836
|
// src/wallet-manager/types.ts
|
9495
|
-
var
|
9837
|
+
var import_errors25 = require("@fuel-ts/errors");
|
9496
9838
|
var Vault = class {
|
9497
9839
|
constructor(_options) {
|
9498
|
-
throw new
|
9840
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9499
9841
|
}
|
9500
9842
|
serialize() {
|
9501
|
-
throw new
|
9843
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9502
9844
|
}
|
9503
9845
|
getAccounts() {
|
9504
|
-
throw new
|
9846
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9505
9847
|
}
|
9506
9848
|
addAccount() {
|
9507
|
-
throw new
|
9849
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9508
9850
|
}
|
9509
9851
|
exportAccount(_address) {
|
9510
|
-
throw new
|
9852
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9511
9853
|
}
|
9512
9854
|
getWallet(_address) {
|
9513
|
-
throw new
|
9855
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9514
9856
|
}
|
9515
9857
|
};
|
9516
9858
|
__publicField(Vault, "type");
|
@@ -9520,19 +9862,19 @@ var StorageAbstract = class {
|
|
9520
9862
|
// src/predicate/predicate.ts
|
9521
9863
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
9522
9864
|
var import_address10 = require("@fuel-ts/address");
|
9523
|
-
var
|
9524
|
-
var
|
9865
|
+
var import_errors26 = require("@fuel-ts/errors");
|
9866
|
+
var import_utils39 = require("@fuel-ts/utils");
|
9525
9867
|
|
9526
9868
|
// src/predicate/utils/getPredicateRoot.ts
|
9527
9869
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9528
9870
|
var import_merkle = require("@fuel-ts/merkle");
|
9529
|
-
var
|
9871
|
+
var import_utils38 = require("@fuel-ts/utils");
|
9530
9872
|
var getPredicateRoot = (bytecode) => {
|
9531
9873
|
const chunkSize = 16 * 1024;
|
9532
|
-
const bytes = (0,
|
9533
|
-
const chunks = (0,
|
9534
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9535
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9874
|
+
const bytes = (0, import_utils38.arrayify)(bytecode);
|
9875
|
+
const chunks = (0, import_utils38.chunkAndPadBytes)(bytes, chunkSize);
|
9876
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils38.hexlify)(c)));
|
9877
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils38.concat)(["0x4655454C", codeRoot]));
|
9536
9878
|
return predicateRoot;
|
9537
9879
|
};
|
9538
9880
|
|
@@ -9547,14 +9889,14 @@ var Predicate = class extends Account {
|
|
9547
9889
|
* @param bytecode - The bytecode of the predicate.
|
9548
9890
|
* @param abi - The JSON ABI of the predicate.
|
9549
9891
|
* @param provider - The provider used to interact with the blockchain.
|
9550
|
-
* @param
|
9892
|
+
* @param data - The predicate input data (optional).
|
9551
9893
|
* @param configurableConstants - Optional configurable constants for the predicate.
|
9552
9894
|
*/
|
9553
9895
|
constructor({
|
9554
9896
|
bytecode,
|
9555
9897
|
abi,
|
9556
9898
|
provider,
|
9557
|
-
|
9899
|
+
data,
|
9558
9900
|
configurableConstants
|
9559
9901
|
}) {
|
9560
9902
|
const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
|
@@ -9566,8 +9908,8 @@ var Predicate = class extends Account {
|
|
9566
9908
|
super(address, provider);
|
9567
9909
|
this.bytes = predicateBytes;
|
9568
9910
|
this.interface = predicateInterface;
|
9569
|
-
if (
|
9570
|
-
this.predicateData =
|
9911
|
+
if (data !== void 0 && data.length > 0) {
|
9912
|
+
this.predicateData = data;
|
9571
9913
|
}
|
9572
9914
|
}
|
9573
9915
|
/**
|
@@ -9584,8 +9926,8 @@ var Predicate = class extends Account {
|
|
9584
9926
|
}
|
9585
9927
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9586
9928
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9587
|
-
input.predicate = (0,
|
9588
|
-
input.predicateData = (0,
|
9929
|
+
input.predicate = (0, import_utils39.hexlify)(this.bytes);
|
9930
|
+
input.predicateData = (0, import_utils39.hexlify)(this.getPredicateData());
|
9589
9931
|
input.witnessIndex = 0;
|
9590
9932
|
}
|
9591
9933
|
});
|
@@ -9627,13 +9969,13 @@ var Predicate = class extends Account {
|
|
9627
9969
|
* @returns An object containing the new predicate bytes and interface.
|
9628
9970
|
*/
|
9629
9971
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9630
|
-
let predicateBytes = (0,
|
9972
|
+
let predicateBytes = (0, import_utils39.arrayify)(bytes);
|
9631
9973
|
let abiInterface;
|
9632
9974
|
if (jsonAbi) {
|
9633
9975
|
abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
9634
9976
|
if (abiInterface.functions.main === void 0) {
|
9635
|
-
throw new
|
9636
|
-
|
9977
|
+
throw new import_errors26.FuelError(
|
9978
|
+
import_errors26.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
9637
9979
|
'Cannot use ABI without "main" function.'
|
9638
9980
|
);
|
9639
9981
|
}
|
@@ -9665,8 +10007,8 @@ var Predicate = class extends Account {
|
|
9665
10007
|
);
|
9666
10008
|
return resources.map((resource) => ({
|
9667
10009
|
...resource,
|
9668
|
-
predicate: (0,
|
9669
|
-
predicateData: (0,
|
10010
|
+
predicate: (0, import_utils39.hexlify)(this.bytes),
|
10011
|
+
predicateData: (0, import_utils39.hexlify)(this.getPredicateData())
|
9670
10012
|
}));
|
9671
10013
|
}
|
9672
10014
|
/**
|
@@ -9678,8 +10020,8 @@ var Predicate = class extends Account {
|
|
9678
10020
|
generateFakeResources(coins) {
|
9679
10021
|
return super.generateFakeResources(coins).map((coin) => ({
|
9680
10022
|
...coin,
|
9681
|
-
predicate: (0,
|
9682
|
-
predicateData: (0,
|
10023
|
+
predicate: (0, import_utils39.hexlify)(this.bytes),
|
10024
|
+
predicateData: (0, import_utils39.hexlify)(this.getPredicateData())
|
9683
10025
|
}));
|
9684
10026
|
}
|
9685
10027
|
/**
|
@@ -9694,24 +10036,31 @@ var Predicate = class extends Account {
|
|
9694
10036
|
const mutatedBytes = bytes;
|
9695
10037
|
try {
|
9696
10038
|
if (!abiInterface) {
|
9697
|
-
throw new
|
10039
|
+
throw new import_errors26.FuelError(
|
10040
|
+
import_errors26.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
9698
10041
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
9699
10042
|
);
|
9700
10043
|
}
|
9701
10044
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
9702
|
-
throw new
|
10045
|
+
throw new import_errors26.FuelError(
|
10046
|
+
import_errors26.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10047
|
+
"Predicate has no configurable constants to be set"
|
10048
|
+
);
|
9703
10049
|
}
|
9704
10050
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
9705
10051
|
if (!abiInterface?.configurables[key]) {
|
9706
|
-
throw new
|
10052
|
+
throw new import_errors26.FuelError(
|
10053
|
+
import_errors26.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
10054
|
+
`No configurable constant named '${key}' found in the Predicate`
|
10055
|
+
);
|
9707
10056
|
}
|
9708
10057
|
const { offset } = abiInterface.configurables[key];
|
9709
10058
|
const encoded = abiInterface.encodeConfigurable(key, value);
|
9710
10059
|
mutatedBytes.set(encoded, offset);
|
9711
10060
|
});
|
9712
10061
|
} catch (err) {
|
9713
|
-
throw new
|
9714
|
-
|
10062
|
+
throw new import_errors26.FuelError(
|
10063
|
+
import_errors26.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
9715
10064
|
`Error setting configurable constants: ${err.message}.`
|
9716
10065
|
);
|
9717
10066
|
}
|
@@ -9742,9 +10091,10 @@ var Predicate = class extends Account {
|
|
9742
10091
|
};
|
9743
10092
|
|
9744
10093
|
// src/connectors/fuel.ts
|
9745
|
-
var
|
10094
|
+
var import_errors29 = require("@fuel-ts/errors");
|
9746
10095
|
|
9747
10096
|
// src/connectors/fuel-connector.ts
|
10097
|
+
var import_errors27 = require("@fuel-ts/errors");
|
9748
10098
|
var import_events2 = require("events");
|
9749
10099
|
|
9750
10100
|
// src/connectors/types/connector-types.ts
|
@@ -9818,7 +10168,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9818
10168
|
* @returns Always true.
|
9819
10169
|
*/
|
9820
10170
|
async ping() {
|
9821
|
-
throw new
|
10171
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9822
10172
|
}
|
9823
10173
|
/**
|
9824
10174
|
* Should return the current version of the connector
|
@@ -9827,7 +10177,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9827
10177
|
* @returns boolean - connection status.
|
9828
10178
|
*/
|
9829
10179
|
async version() {
|
9830
|
-
throw new
|
10180
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9831
10181
|
}
|
9832
10182
|
/**
|
9833
10183
|
* Should return true if the connector is connected
|
@@ -9836,7 +10186,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9836
10186
|
* @returns The connection status.
|
9837
10187
|
*/
|
9838
10188
|
async isConnected() {
|
9839
|
-
throw new
|
10189
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9840
10190
|
}
|
9841
10191
|
/**
|
9842
10192
|
* Should return all the accounts authorized for the
|
@@ -9845,7 +10195,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9845
10195
|
* @returns The accounts addresses strings
|
9846
10196
|
*/
|
9847
10197
|
async accounts() {
|
9848
|
-
throw new
|
10198
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9849
10199
|
}
|
9850
10200
|
/**
|
9851
10201
|
* Should start the connection process and return
|
@@ -9857,7 +10207,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9857
10207
|
* @returns boolean - connection status.
|
9858
10208
|
*/
|
9859
10209
|
async connect() {
|
9860
|
-
throw new
|
10210
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9861
10211
|
}
|
9862
10212
|
/**
|
9863
10213
|
* Should disconnect the current connection and
|
@@ -9867,7 +10217,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9867
10217
|
* @returns The connection status.
|
9868
10218
|
*/
|
9869
10219
|
async disconnect() {
|
9870
|
-
throw new
|
10220
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9871
10221
|
}
|
9872
10222
|
/**
|
9873
10223
|
* Should start the sign message process and return
|
@@ -9879,7 +10229,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9879
10229
|
* @returns Message signature
|
9880
10230
|
*/
|
9881
10231
|
async signMessage(_address, _message) {
|
9882
|
-
throw new
|
10232
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9883
10233
|
}
|
9884
10234
|
/**
|
9885
10235
|
* Should start the sign transaction process and return
|
@@ -9891,7 +10241,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9891
10241
|
* @returns Transaction signature
|
9892
10242
|
*/
|
9893
10243
|
async signTransaction(_address, _transaction) {
|
9894
|
-
throw new
|
10244
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9895
10245
|
}
|
9896
10246
|
/**
|
9897
10247
|
* Should start the send transaction process and return
|
@@ -9907,7 +10257,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9907
10257
|
* @returns The transaction id
|
9908
10258
|
*/
|
9909
10259
|
async sendTransaction(_address, _transaction) {
|
9910
|
-
throw new
|
10260
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9911
10261
|
}
|
9912
10262
|
/**
|
9913
10263
|
* Should return the current account selected inside the connector, if the account
|
@@ -9918,7 +10268,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9918
10268
|
* @returns The current account selected otherwise null.
|
9919
10269
|
*/
|
9920
10270
|
async currentAccount() {
|
9921
|
-
throw new
|
10271
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9922
10272
|
}
|
9923
10273
|
/**
|
9924
10274
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -9932,7 +10282,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9932
10282
|
* @returns True if the asset was added successfully
|
9933
10283
|
*/
|
9934
10284
|
async addAssets(_assets) {
|
9935
|
-
throw new
|
10285
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9936
10286
|
}
|
9937
10287
|
/**
|
9938
10288
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -9946,7 +10296,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9946
10296
|
* @returns True if the asset was added successfully
|
9947
10297
|
*/
|
9948
10298
|
async addAsset(_asset) {
|
9949
|
-
throw new
|
10299
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9950
10300
|
}
|
9951
10301
|
/**
|
9952
10302
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -9954,7 +10304,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9954
10304
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
9955
10305
|
*/
|
9956
10306
|
async assets() {
|
9957
|
-
throw new
|
10307
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9958
10308
|
}
|
9959
10309
|
/**
|
9960
10310
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -9965,7 +10315,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9965
10315
|
* @returns Return true if the network was added successfully
|
9966
10316
|
*/
|
9967
10317
|
async addNetwork(_networkUrl) {
|
9968
|
-
throw new
|
10318
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9969
10319
|
}
|
9970
10320
|
/**
|
9971
10321
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -9976,7 +10326,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9976
10326
|
* @returns Return true if the network was added successfully
|
9977
10327
|
*/
|
9978
10328
|
async selectNetwork(_network) {
|
9979
|
-
throw new
|
10329
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9980
10330
|
}
|
9981
10331
|
/**
|
9982
10332
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -9984,7 +10334,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9984
10334
|
* @returns Return all the networks added to the connector.
|
9985
10335
|
*/
|
9986
10336
|
async networks() {
|
9987
|
-
throw new
|
10337
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9988
10338
|
}
|
9989
10339
|
/**
|
9990
10340
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -9992,7 +10342,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9992
10342
|
* @returns Return the current network selected inside the connector.
|
9993
10343
|
*/
|
9994
10344
|
async currentNetwork() {
|
9995
|
-
throw new
|
10345
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
9996
10346
|
}
|
9997
10347
|
/**
|
9998
10348
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10002,7 +10352,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10002
10352
|
* @returns Return true if the ABI was added successfully.
|
10003
10353
|
*/
|
10004
10354
|
async addABI(_contractId, _abi) {
|
10005
|
-
throw new
|
10355
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10006
10356
|
}
|
10007
10357
|
/**
|
10008
10358
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10011,7 +10361,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10011
10361
|
* @returns The ABI if it exists, otherwise return null.
|
10012
10362
|
*/
|
10013
10363
|
async getABI(_id) {
|
10014
|
-
throw new
|
10364
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10015
10365
|
}
|
10016
10366
|
/**
|
10017
10367
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10020,7 +10370,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10020
10370
|
* @returns Returns true if the abi exists or false if not.
|
10021
10371
|
*/
|
10022
10372
|
async hasABI(_id) {
|
10023
|
-
throw new
|
10373
|
+
throw new import_errors27.FuelError(import_errors27.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10024
10374
|
}
|
10025
10375
|
/**
|
10026
10376
|
* Event listener for the connector.
|
@@ -10064,6 +10414,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10064
10414
|
}
|
10065
10415
|
|
10066
10416
|
// src/connectors/utils/promises.ts
|
10417
|
+
var import_errors28 = require("@fuel-ts/errors");
|
10067
10418
|
function deferPromise() {
|
10068
10419
|
const defer = {};
|
10069
10420
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10075,7 +10426,7 @@ function deferPromise() {
|
|
10075
10426
|
async function withTimeout(promise, timeout = 1050) {
|
10076
10427
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10077
10428
|
setTimeout(() => {
|
10078
|
-
reject(new
|
10429
|
+
reject(new import_errors28.FuelError(import_errors28.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10079
10430
|
}, timeout);
|
10080
10431
|
});
|
10081
10432
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10162,7 +10513,8 @@ var _Fuel = class extends FuelConnector {
|
|
10162
10513
|
const hasConnector = await this.hasConnector();
|
10163
10514
|
await this.pingConnector();
|
10164
10515
|
if (!this._currentConnector || !hasConnector) {
|
10165
|
-
throw new
|
10516
|
+
throw new import_errors29.FuelError(
|
10517
|
+
import_errors29.ErrorCode.MISSING_CONNECTOR,
|
10166
10518
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10167
10519
|
);
|
10168
10520
|
}
|
@@ -10226,7 +10578,7 @@ var _Fuel = class extends FuelConnector {
|
|
10226
10578
|
cacheTime: PING_CACHE_TIME
|
10227
10579
|
})();
|
10228
10580
|
} catch {
|
10229
|
-
throw new
|
10581
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
|
10230
10582
|
}
|
10231
10583
|
}
|
10232
10584
|
/**
|
@@ -10375,7 +10727,7 @@ var _Fuel = class extends FuelConnector {
|
|
10375
10727
|
const currentNetwork = await this.currentNetwork();
|
10376
10728
|
provider = await Provider.create(currentNetwork.url);
|
10377
10729
|
} else {
|
10378
|
-
throw new
|
10730
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
10379
10731
|
}
|
10380
10732
|
return provider;
|
10381
10733
|
}
|
@@ -10420,10 +10772,12 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10420
10772
|
BLOCKS_PAGE_SIZE_LIMIT,
|
10421
10773
|
BaseTransactionRequest,
|
10422
10774
|
BaseWalletUnlocked,
|
10775
|
+
BlobTransactionRequest,
|
10423
10776
|
CHAIN_IDS,
|
10424
10777
|
ChainName,
|
10425
10778
|
ChangeOutputCollisionError,
|
10426
10779
|
CreateTransactionRequest,
|
10780
|
+
DEFAULT_RESOURCE_CACHE_TTL,
|
10427
10781
|
Fuel,
|
10428
10782
|
FuelConnector,
|
10429
10783
|
FuelConnectorEventType,
|
@@ -10457,6 +10811,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10457
10811
|
WalletUnlocked,
|
10458
10812
|
addAmountToCoinQuantities,
|
10459
10813
|
addOperation,
|
10814
|
+
aggregateInputsAmountsByAssetAndOwner,
|
10460
10815
|
assemblePanicError,
|
10461
10816
|
assembleReceiptByType,
|
10462
10817
|
assembleRevertError,
|
@@ -10467,6 +10822,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10467
10822
|
cacheRequestInputsResources,
|
10468
10823
|
cacheRequestInputsResourcesFromOwner,
|
10469
10824
|
calculateGasFee,
|
10825
|
+
calculateMetadataGasForTxBlob,
|
10470
10826
|
calculateMetadataGasForTxCreate,
|
10471
10827
|
calculateMetadataGasForTxScript,
|
10472
10828
|
calculateTXFeeForSummary,
|
@@ -10525,6 +10881,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10525
10881
|
hasSameAssetId,
|
10526
10882
|
inputify,
|
10527
10883
|
isCoin,
|
10884
|
+
isInputCoin,
|
10528
10885
|
isMessage,
|
10529
10886
|
isRawCoin,
|
10530
10887
|
isRawMessage,
|
@@ -10532,7 +10889,11 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10532
10889
|
isRequestInputMessage,
|
10533
10890
|
isRequestInputResource,
|
10534
10891
|
isRequestInputResourceFromOwner,
|
10892
|
+
isTransactionTypeBlob,
|
10893
|
+
isTransactionTypeCreate,
|
10894
|
+
isTransactionTypeScript,
|
10535
10895
|
isType,
|
10896
|
+
isTypeBlob,
|
10536
10897
|
isTypeCreate,
|
10537
10898
|
isTypeMint,
|
10538
10899
|
isTypeScript,
|