@fuel-ts/account 0.97.2 → 0.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts +19 -16
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +4 -4
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts +3 -3
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +8 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +2922 -1249
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +333 -279
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +358 -309
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +0 -169
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +3 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +8 -7
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +27 -34
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/errors.d.ts +3 -3
- package/dist/providers/transaction-request/errors.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +26 -4
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/output.d.ts +1 -1
- package/dist/providers/transaction-request/output.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +13 -3
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/scripts.d.ts +1 -1
- package/dist/providers/transaction-request/scripts.d.ts.map +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +7 -0
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/upload-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/witness.d.ts +1 -1
- package/dist/providers/transaction-request/witness.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +0 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.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 +1 -1
- package/dist/providers/transaction-summary/status.d.ts +9 -2
- package/dist/providers/transaction-summary/status.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +1 -21
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +1 -1
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -1
- 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-message.d.ts +6 -6
- package/dist/test-utils/test-message.d.ts.map +1 -1
- package/dist/test-utils.global.js +2908 -1240
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +258 -219
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +287 -248
- package/dist/test-utils.mjs.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/keystore-wallet.d.ts +2 -2
- package/dist/wallet/keystore-wallet.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +3 -2
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallets.d.ts +1 -1
- package/dist/wallet/wallets.d.ts.map +1 -1
- package/dist/wallet-manager/types.d.ts +4 -4
- package/dist/wallet-manager/types.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +5 -5
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +5 -5
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +3 -3
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +28 -29
package/dist/index.js
CHANGED
@@ -57,6 +57,8 @@ var __privateMethod = (obj, member, method) => {
|
|
57
57
|
// src/index.ts
|
58
58
|
var src_exports = {};
|
59
59
|
__export(src_exports, {
|
60
|
+
AbstractAccount: () => AbstractAccount,
|
61
|
+
AbstractScriptRequest: () => AbstractScriptRequest,
|
60
62
|
Account: () => Account,
|
61
63
|
AddressType: () => AddressType,
|
62
64
|
BLOCKS_PAGE_SIZE_LIMIT: () => BLOCKS_PAGE_SIZE_LIMIT,
|
@@ -138,6 +140,7 @@ __export(src_exports, {
|
|
138
140
|
getAssetFuel: () => getAssetFuel,
|
139
141
|
getAssetNetwork: () => getAssetNetwork,
|
140
142
|
getAssetWithNetwork: () => getAssetWithNetwork,
|
143
|
+
getBurnableAssetCount: () => getBurnableAssetCount,
|
141
144
|
getContractCallOperations: () => getContractCallOperations,
|
142
145
|
getContractCreatedOperations: () => getContractCreatedOperations,
|
143
146
|
getDecodedLogs: () => getDecodedLogs,
|
@@ -169,6 +172,7 @@ __export(src_exports, {
|
|
169
172
|
getReceiptsTransferOut: () => getReceiptsTransferOut,
|
170
173
|
getReceiptsWithMissingData: () => getReceiptsWithMissingData,
|
171
174
|
getRequestInputResourceOwner: () => getRequestInputResourceOwner,
|
175
|
+
getTotalFeeFromStatus: () => getTotalFeeFromStatus,
|
172
176
|
getTransactionStatusName: () => getTransactionStatusName,
|
173
177
|
getTransactionSummary: () => getTransactionSummary,
|
174
178
|
getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
|
@@ -212,6 +216,7 @@ __export(src_exports, {
|
|
212
216
|
returnZeroScript: () => returnZeroScript,
|
213
217
|
transactionRequestify: () => transactionRequestify,
|
214
218
|
urlJoin: () => urlJoin,
|
219
|
+
validateTransactionForAssetBurn: () => validateTransactionForAssetBurn,
|
215
220
|
withTimeout: () => withTimeout,
|
216
221
|
withdrawScript: () => withdrawScript
|
217
222
|
});
|
@@ -221,8 +226,7 @@ module.exports = __toCommonJS(src_exports);
|
|
221
226
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
222
227
|
var import_address5 = require("@fuel-ts/address");
|
223
228
|
var import_crypto2 = require("@fuel-ts/crypto");
|
224
|
-
var
|
225
|
-
var import_interfaces = require("@fuel-ts/interfaces");
|
229
|
+
var import_errors21 = require("@fuel-ts/errors");
|
226
230
|
var import_math20 = require("@fuel-ts/math");
|
227
231
|
var import_transactions24 = require("@fuel-ts/transactions");
|
228
232
|
var import_utils34 = require("@fuel-ts/utils");
|
@@ -265,7 +269,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
265
269
|
|
266
270
|
// src/providers/provider.ts
|
267
271
|
var import_address3 = require("@fuel-ts/address");
|
268
|
-
var
|
272
|
+
var import_errors19 = require("@fuel-ts/errors");
|
269
273
|
var import_math18 = require("@fuel-ts/math");
|
270
274
|
var import_transactions22 = require("@fuel-ts/transactions");
|
271
275
|
var import_utils28 = require("@fuel-ts/utils");
|
@@ -1136,13 +1140,6 @@ var GetConsensusParametersVersionDocument = import_graphql_tag.default`
|
|
1136
1140
|
}
|
1137
1141
|
}
|
1138
1142
|
`;
|
1139
|
-
var SubmitAndAwaitDocument = import_graphql_tag.default`
|
1140
|
-
subscription submitAndAwait($encodedTransaction: HexString!) {
|
1141
|
-
submitAndAwait(tx: $encodedTransaction) {
|
1142
|
-
...transactionStatusSubscriptionFragment
|
1143
|
-
}
|
1144
|
-
}
|
1145
|
-
${TransactionStatusSubscriptionFragmentDoc}`;
|
1146
1143
|
var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
|
1147
1144
|
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1148
1145
|
submitAndAwaitStatus(tx: $encodedTransaction) {
|
@@ -1258,9 +1255,6 @@ function getSdk(requester) {
|
|
1258
1255
|
getConsensusParametersVersion(variables, options) {
|
1259
1256
|
return requester(GetConsensusParametersVersionDocument, variables, options);
|
1260
1257
|
},
|
1261
|
-
submitAndAwait(variables, options) {
|
1262
|
-
return requester(SubmitAndAwaitDocument, variables, options);
|
1263
|
-
},
|
1264
1258
|
submitAndAwaitStatus(variables, options) {
|
1265
1259
|
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1266
1260
|
},
|
@@ -1544,7 +1538,7 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1544
1538
|
var import_address = require("@fuel-ts/address");
|
1545
1539
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1546
1540
|
var import_crypto = require("@fuel-ts/crypto");
|
1547
|
-
var
|
1541
|
+
var import_errors9 = require("@fuel-ts/errors");
|
1548
1542
|
var import_math8 = require("@fuel-ts/math");
|
1549
1543
|
var import_transactions7 = require("@fuel-ts/transactions");
|
1550
1544
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -1591,7 +1585,6 @@ function assembleReceiptByType(receipt) {
|
|
1591
1585
|
const callReceipt = {
|
1592
1586
|
type: import_transactions3.ReceiptType.Call,
|
1593
1587
|
id,
|
1594
|
-
from: id,
|
1595
1588
|
to: hexOrZero(receipt?.to),
|
1596
1589
|
amount: (0, import_math4.bn)(receipt.amount),
|
1597
1590
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1659,10 +1652,6 @@ function assembleReceiptByType(receipt) {
|
|
1659
1652
|
rb,
|
1660
1653
|
rc,
|
1661
1654
|
rd,
|
1662
|
-
val0: ra,
|
1663
|
-
val1: rb,
|
1664
|
-
val2: rc,
|
1665
|
-
val3: rd,
|
1666
1655
|
pc: (0, import_math4.bn)(receipt.pc),
|
1667
1656
|
is: (0, import_math4.bn)(receipt.is)
|
1668
1657
|
};
|
@@ -1676,8 +1665,6 @@ function assembleReceiptByType(receipt) {
|
|
1676
1665
|
id: hexOrZero(receipt.id || receipt.contractId),
|
1677
1666
|
ra,
|
1678
1667
|
rb,
|
1679
|
-
val0: ra,
|
1680
|
-
val1: rb,
|
1681
1668
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
1682
1669
|
len: (0, import_math4.bn)(receipt.len),
|
1683
1670
|
digest: hexOrZero(receipt.digest),
|
@@ -1692,7 +1679,6 @@ function assembleReceiptByType(receipt) {
|
|
1692
1679
|
const transferReceipt = {
|
1693
1680
|
type: import_transactions3.ReceiptType.Transfer,
|
1694
1681
|
id,
|
1695
|
-
from: id,
|
1696
1682
|
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1697
1683
|
amount: (0, import_math4.bn)(receipt.amount),
|
1698
1684
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1706,7 +1692,6 @@ function assembleReceiptByType(receipt) {
|
|
1706
1692
|
const transferOutReceipt = {
|
1707
1693
|
type: import_transactions3.ReceiptType.TransferOut,
|
1708
1694
|
id,
|
1709
|
-
from: id,
|
1710
1695
|
to: hexOrZero(receipt.toAddress || receipt.to),
|
1711
1696
|
amount: (0, import_math4.bn)(receipt.amount),
|
1712
1697
|
assetId: hexOrZero(receipt.assetId),
|
@@ -2127,6 +2112,7 @@ var NoWitnessByOwnerError = class extends Error {
|
|
2127
2112
|
};
|
2128
2113
|
|
2129
2114
|
// src/providers/transaction-request/helpers.ts
|
2115
|
+
var import_errors8 = require("@fuel-ts/errors");
|
2130
2116
|
var import_math7 = require("@fuel-ts/math");
|
2131
2117
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2132
2118
|
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
@@ -2173,6 +2159,32 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
|
2173
2159
|
messages: []
|
2174
2160
|
}
|
2175
2161
|
);
|
2162
|
+
var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
2163
|
+
const { inputs, outputs } = transactionRequest;
|
2164
|
+
const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
|
2165
|
+
if (inputs.some((i) => isRequestInputMessage(i) && (0, import_math7.bn)(i.amount).gt(0))) {
|
2166
|
+
coinInputs.add(baseAssetId);
|
2167
|
+
}
|
2168
|
+
const changeOutputs = new Set(
|
2169
|
+
outputs.filter((output) => output.type === import_transactions6.OutputType.Change).map((output) => output.assetId)
|
2170
|
+
);
|
2171
|
+
const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
|
2172
|
+
return difference.size;
|
2173
|
+
};
|
2174
|
+
var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
2175
|
+
if (enableAssetBurn === true) {
|
2176
|
+
return;
|
2177
|
+
}
|
2178
|
+
if (getBurnableAssetCount(baseAssetId, transactionRequest) <= 0) {
|
2179
|
+
return;
|
2180
|
+
}
|
2181
|
+
const message = [
|
2182
|
+
"Asset burn detected.",
|
2183
|
+
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2184
|
+
"Or enable asset burn, upon sending the transaction."
|
2185
|
+
].join("\n");
|
2186
|
+
throw new import_errors8.FuelError(import_errors8.ErrorCode.ASSET_BURN_DETECTED, message);
|
2187
|
+
};
|
2176
2188
|
|
2177
2189
|
// src/providers/transaction-request/witness.ts
|
2178
2190
|
var import_utils8 = require("@fuel-ts/utils");
|
@@ -2556,7 +2568,7 @@ var BaseTransactionRequest = class {
|
|
2556
2568
|
* @hidden
|
2557
2569
|
*/
|
2558
2570
|
metadataGas(_gasCosts) {
|
2559
|
-
throw new
|
2571
|
+
throw new import_errors9.FuelError(import_errors9.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2560
2572
|
}
|
2561
2573
|
/**
|
2562
2574
|
* @hidden
|
@@ -2996,6 +3008,20 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2996
3008
|
this.scriptData = (0, import_utils16.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2997
3009
|
this.abis = rest.abis;
|
2998
3010
|
}
|
3011
|
+
/**
|
3012
|
+
* Helper function to estimate and fund the transaction request with a specified account.
|
3013
|
+
*
|
3014
|
+
* @param account - The account to fund the transaction.
|
3015
|
+
* @param params - The parameters for the transaction cost.
|
3016
|
+
* @returns The current instance of the `ScriptTransactionRequest` funded.
|
3017
|
+
*/
|
3018
|
+
async estimateAndFund(account, { signatureCallback, quantities = [] } = {}) {
|
3019
|
+
const txCost = await account.getTransactionCost(this, { signatureCallback, quantities });
|
3020
|
+
this.maxFee = txCost.maxFee;
|
3021
|
+
this.gasLimit = txCost.gasUsed;
|
3022
|
+
await account.fund(this, txCost);
|
3023
|
+
return this;
|
3024
|
+
}
|
2999
3025
|
/**
|
3000
3026
|
* Converts the transaction request to a `TransactionScript`.
|
3001
3027
|
*
|
@@ -3150,7 +3176,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3150
3176
|
};
|
3151
3177
|
|
3152
3178
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3153
|
-
var
|
3179
|
+
var import_errors11 = require("@fuel-ts/errors");
|
3154
3180
|
var import_hasher2 = require("@fuel-ts/hasher");
|
3155
3181
|
var import_transactions11 = require("@fuel-ts/transactions");
|
3156
3182
|
var import_utils17 = require("@fuel-ts/utils");
|
@@ -3254,7 +3280,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3254
3280
|
}
|
3255
3281
|
};
|
3256
3282
|
} else {
|
3257
|
-
throw new
|
3283
|
+
throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3258
3284
|
}
|
3259
3285
|
return {
|
3260
3286
|
type: import_transactions11.TransactionType.Upgrade,
|
@@ -3296,7 +3322,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3296
3322
|
txBytesSize
|
3297
3323
|
});
|
3298
3324
|
}
|
3299
|
-
throw new
|
3325
|
+
throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3300
3326
|
}
|
3301
3327
|
};
|
3302
3328
|
|
@@ -3406,8 +3432,12 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
3406
3432
|
}
|
3407
3433
|
};
|
3408
3434
|
|
3435
|
+
// src/providers/transaction-request/types.ts
|
3436
|
+
var AbstractScriptRequest = class {
|
3437
|
+
};
|
3438
|
+
|
3409
3439
|
// src/providers/transaction-request/utils.ts
|
3410
|
-
var
|
3440
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3411
3441
|
var import_transactions13 = require("@fuel-ts/transactions");
|
3412
3442
|
var transactionRequestify = (obj) => {
|
3413
3443
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3431,8 +3461,8 @@ var transactionRequestify = (obj) => {
|
|
3431
3461
|
return UploadTransactionRequest.from(obj);
|
3432
3462
|
}
|
3433
3463
|
default: {
|
3434
|
-
throw new
|
3435
|
-
|
3464
|
+
throw new import_errors12.FuelError(
|
3465
|
+
import_errors12.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3436
3466
|
`Unsupported transaction type: ${type}.`
|
3437
3467
|
);
|
3438
3468
|
}
|
@@ -3445,7 +3475,7 @@ var isTransactionTypeUpgrade = (request) => request.type === import_transactions
|
|
3445
3475
|
var isTransactionTypeUpload = (request) => request.type === import_transactions13.TransactionType.Upload;
|
3446
3476
|
|
3447
3477
|
// src/providers/transaction-response/transaction-response.ts
|
3448
|
-
var
|
3478
|
+
var import_errors16 = require("@fuel-ts/errors");
|
3449
3479
|
var import_math17 = require("@fuel-ts/math");
|
3450
3480
|
var import_transactions21 = require("@fuel-ts/transactions");
|
3451
3481
|
var import_utils25 = require("@fuel-ts/utils");
|
@@ -3464,12 +3494,8 @@ var calculateTXFeeForSummary = (params) => {
|
|
3464
3494
|
gasPrice,
|
3465
3495
|
rawPayload,
|
3466
3496
|
tip,
|
3467
|
-
totalFee,
|
3468
3497
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
3469
3498
|
} = params;
|
3470
|
-
if (totalFee) {
|
3471
|
-
return totalFee;
|
3472
|
-
}
|
3473
3499
|
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
3474
3500
|
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
3475
3501
|
const transactionBytes = (0, import_utils21.arrayify)(rawPayload);
|
@@ -3527,7 +3553,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3527
3553
|
|
3528
3554
|
// src/providers/transaction-summary/operations.ts
|
3529
3555
|
var import_configs11 = require("@fuel-ts/address/configs");
|
3530
|
-
var
|
3556
|
+
var import_errors14 = require("@fuel-ts/errors");
|
3531
3557
|
var import_math14 = require("@fuel-ts/math");
|
3532
3558
|
var import_transactions17 = require("@fuel-ts/transactions");
|
3533
3559
|
|
@@ -3565,7 +3591,7 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3565
3591
|
};
|
3566
3592
|
|
3567
3593
|
// src/providers/transaction-summary/input.ts
|
3568
|
-
var
|
3594
|
+
var import_errors13 = require("@fuel-ts/errors");
|
3569
3595
|
var import_math13 = require("@fuel-ts/math");
|
3570
3596
|
var import_transactions15 = require("@fuel-ts/transactions");
|
3571
3597
|
function getInputsByTypes(inputs, types) {
|
@@ -3593,10 +3619,10 @@ function findCoinInput(inputs, assetId) {
|
|
3593
3619
|
const coinInputs = getInputsCoin(inputs);
|
3594
3620
|
return coinInputs.find((i) => i.assetId === assetId);
|
3595
3621
|
}
|
3596
|
-
function aggregateInputsAmountsByAssetAndOwner(inputs,
|
3622
|
+
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
3597
3623
|
const aggregated = /* @__PURE__ */ new Map();
|
3598
3624
|
getInputsCoinAndMessage(inputs).forEach((input) => {
|
3599
|
-
const assetId = isInputCoin(input) ? input.assetId :
|
3625
|
+
const assetId = isInputCoin(input) ? input.assetId : baseAssetId;
|
3600
3626
|
const owner = isInputCoin(input) ? input.owner : input.recipient;
|
3601
3627
|
let ownersMap = aggregated.get(assetId);
|
3602
3628
|
if (!ownersMap) {
|
@@ -3634,8 +3660,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3634
3660
|
return void 0;
|
3635
3661
|
}
|
3636
3662
|
if (contractInput.type !== import_transactions15.InputType.Contract) {
|
3637
|
-
throw new
|
3638
|
-
|
3663
|
+
throw new import_errors13.FuelError(
|
3664
|
+
import_errors13.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3639
3665
|
`Contract input should be of type 'contract'.`
|
3640
3666
|
);
|
3641
3667
|
}
|
@@ -3695,10 +3721,6 @@ var OperationName = /* @__PURE__ */ ((OperationName2) => {
|
|
3695
3721
|
OperationName2["transfer"] = "Transfer asset";
|
3696
3722
|
OperationName2["contractCall"] = "Contract call";
|
3697
3723
|
OperationName2["receive"] = "Receive asset";
|
3698
|
-
OperationName2["mint"] = "Mint asset";
|
3699
|
-
OperationName2["predicatecall"] = "Predicate call";
|
3700
|
-
OperationName2["script"] = "Script";
|
3701
|
-
OperationName2["sent"] = "Sent asset";
|
3702
3724
|
OperationName2["withdrawFromFuel"] = "Withdraw from Fuel";
|
3703
3725
|
return OperationName2;
|
3704
3726
|
})(OperationName || {});
|
@@ -3732,8 +3754,8 @@ function getTransactionTypeName(transactionType) {
|
|
3732
3754
|
case import_transactions17.TransactionType.Upload:
|
3733
3755
|
return "Upload" /* Upload */;
|
3734
3756
|
default:
|
3735
|
-
throw new
|
3736
|
-
|
3757
|
+
throw new import_errors14.FuelError(
|
3758
|
+
import_errors14.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3737
3759
|
`Unsupported transaction type: ${transactionType}.`
|
3738
3760
|
);
|
3739
3761
|
}
|
@@ -3932,7 +3954,7 @@ function getContractCallOperations({
|
|
3932
3954
|
}
|
3933
3955
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
3934
3956
|
const { to: toAddress, assetId, amount } = receipt;
|
3935
|
-
let {
|
3957
|
+
let { id: fromAddress } = receipt;
|
3936
3958
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3937
3959
|
if (import_configs11.ZeroBytes32 === fromAddress) {
|
3938
3960
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
@@ -4119,7 +4141,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4119
4141
|
};
|
4120
4142
|
|
4121
4143
|
// src/providers/transaction-summary/status.ts
|
4122
|
-
var
|
4144
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4123
4145
|
var import_math15 = require("@fuel-ts/math");
|
4124
4146
|
var getTransactionStatusName = (gqlStatus) => {
|
4125
4147
|
switch (gqlStatus) {
|
@@ -4132,8 +4154,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4132
4154
|
case "SqueezedOutStatus":
|
4133
4155
|
return "squeezedout" /* squeezedout */;
|
4134
4156
|
default:
|
4135
|
-
throw new
|
4136
|
-
|
4157
|
+
throw new import_errors15.FuelError(
|
4158
|
+
import_errors15.ErrorCode.INVALID_TRANSACTION_STATUS,
|
4137
4159
|
`Invalid transaction status: ${gqlStatus}.`
|
4138
4160
|
);
|
4139
4161
|
}
|
@@ -4183,6 +4205,7 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
4183
4205
|
};
|
4184
4206
|
return processedGraphqlStatus;
|
4185
4207
|
};
|
4208
|
+
var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? (0, import_math15.bn)(status.totalFee) : void 0;
|
4186
4209
|
|
4187
4210
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
4188
4211
|
function assembleTransactionSummary(params) {
|
@@ -4216,8 +4239,7 @@ function assembleTransactionSummary(params) {
|
|
4216
4239
|
const typeName = getTransactionTypeName(transaction.type);
|
4217
4240
|
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions19.PolicyType.Tip)?.data);
|
4218
4241
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
4219
|
-
const fee = calculateTXFeeForSummary({
|
4220
|
-
totalFee,
|
4242
|
+
const fee = totalFee ?? calculateTXFeeForSummary({
|
4221
4243
|
gasPrice,
|
4222
4244
|
rawPayload,
|
4223
4245
|
tip,
|
@@ -4271,8 +4293,8 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
4271
4293
|
return receipts.reduce((logs, receipt) => {
|
4272
4294
|
if (receipt.type === import_transactions20.ReceiptType.LogData || receipt.type === import_transactions20.ReceiptType.Log) {
|
4273
4295
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
4274
|
-
const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.
|
4275
|
-
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.
|
4296
|
+
const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4297
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4276
4298
|
logs.push(decodedLog);
|
4277
4299
|
}
|
4278
4300
|
return logs;
|
@@ -4317,9 +4339,9 @@ var TransactionResponse = class {
|
|
4317
4339
|
* @param tx - The transaction ID or TransactionRequest.
|
4318
4340
|
* @param provider - The provider.
|
4319
4341
|
*/
|
4320
|
-
constructor(tx, provider, abis, submitTxSubscription) {
|
4342
|
+
constructor(tx, provider, chainId, abis, submitTxSubscription) {
|
4321
4343
|
this.submitTxSubscription = submitTxSubscription;
|
4322
|
-
this.id = typeof tx === "string" ? tx : tx.getTransactionId(
|
4344
|
+
this.id = typeof tx === "string" ? tx : tx.getTransactionId(chainId);
|
4323
4345
|
this.provider = provider;
|
4324
4346
|
this.abis = abis;
|
4325
4347
|
this.request = typeof tx === "string" ? void 0 : tx;
|
@@ -4344,7 +4366,8 @@ var TransactionResponse = class {
|
|
4344
4366
|
* @param provider - The provider.
|
4345
4367
|
*/
|
4346
4368
|
static async create(id, provider, abis) {
|
4347
|
-
const
|
4369
|
+
const chainId = await provider.getChainId();
|
4370
|
+
const response = new TransactionResponse(id, provider, chainId, abis);
|
4348
4371
|
await response.fetch();
|
4349
4372
|
return response;
|
4350
4373
|
}
|
@@ -4441,10 +4464,11 @@ var TransactionResponse = class {
|
|
4441
4464
|
*/
|
4442
4465
|
async getTransactionSummary(contractsAbiMap) {
|
4443
4466
|
const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
|
4444
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
4445
|
-
const
|
4446
|
-
const
|
4447
|
-
const
|
4467
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await this.provider.getGasConfig();
|
4468
|
+
const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status);
|
4469
|
+
const gasPrice = totalFee ? (0, import_math17.bn)(0) : await this.provider.getLatestGasPrice();
|
4470
|
+
const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs;
|
4471
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
4448
4472
|
const transactionSummary = assembleTransactionSummary({
|
4449
4473
|
id: this.id,
|
4450
4474
|
receipts: this.getReceipts(),
|
@@ -4475,8 +4499,8 @@ var TransactionResponse = class {
|
|
4475
4499
|
this.status = statusChange;
|
4476
4500
|
if (statusChange.type === "SqueezedOutStatus") {
|
4477
4501
|
this.unsetResourceCache();
|
4478
|
-
throw new
|
4479
|
-
|
4502
|
+
throw new import_errors16.FuelError(
|
4503
|
+
import_errors16.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
4480
4504
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4481
4505
|
);
|
4482
4506
|
}
|
@@ -4584,54 +4608,54 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4584
4608
|
}
|
4585
4609
|
|
4586
4610
|
// src/providers/utils/handle-gql-error-message.ts
|
4587
|
-
var
|
4611
|
+
var import_errors17 = require("@fuel-ts/errors");
|
4588
4612
|
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4589
4613
|
switch (errorMessage) {
|
4590
4614
|
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4591
|
-
throw new
|
4592
|
-
|
4615
|
+
throw new import_errors17.FuelError(
|
4616
|
+
import_errors17.ErrorCode.NOT_ENOUGH_FUNDS,
|
4593
4617
|
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4594
4618
|
{},
|
4595
4619
|
rawError
|
4596
4620
|
);
|
4597
4621
|
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
4598
|
-
throw new
|
4599
|
-
|
4622
|
+
throw new import_errors17.FuelError(
|
4623
|
+
import_errors17.ErrorCode.MAX_COINS_REACHED,
|
4600
4624
|
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
4601
4625
|
{},
|
4602
4626
|
rawError
|
4603
4627
|
);
|
4604
4628
|
default:
|
4605
|
-
throw new
|
4629
|
+
throw new import_errors17.FuelError(import_errors17.ErrorCode.INVALID_REQUEST, errorMessage);
|
4606
4630
|
}
|
4607
4631
|
};
|
4608
4632
|
|
4609
4633
|
// src/providers/utils/validate-pagination-args.ts
|
4610
|
-
var
|
4634
|
+
var import_errors18 = require("@fuel-ts/errors");
|
4611
4635
|
var validatePaginationArgs = (params) => {
|
4612
4636
|
const { paginationLimit, inputArgs = {} } = params;
|
4613
4637
|
const { first, last, after, before } = inputArgs;
|
4614
4638
|
if (after && before) {
|
4615
|
-
throw new
|
4616
|
-
|
4639
|
+
throw new import_errors18.FuelError(
|
4640
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4617
4641
|
'Pagination arguments "after" and "before" cannot be used together'
|
4618
4642
|
);
|
4619
4643
|
}
|
4620
4644
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
4621
|
-
throw new
|
4622
|
-
|
4645
|
+
throw new import_errors18.FuelError(
|
4646
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4623
4647
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
4624
4648
|
);
|
4625
4649
|
}
|
4626
4650
|
if (first && before) {
|
4627
|
-
throw new
|
4628
|
-
|
4651
|
+
throw new import_errors18.FuelError(
|
4652
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4629
4653
|
'The use of pagination argument "first" with "before" is not supported'
|
4630
4654
|
);
|
4631
4655
|
}
|
4632
4656
|
if (last && after) {
|
4633
|
-
throw new
|
4634
|
-
|
4657
|
+
throw new import_errors18.FuelError(
|
4658
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4635
4659
|
'The use of pagination argument "last" with "after" is not supported'
|
4636
4660
|
);
|
4637
4661
|
}
|
@@ -4785,7 +4809,7 @@ var _Provider = class {
|
|
4785
4809
|
try {
|
4786
4810
|
parsedUrl = new URL(url);
|
4787
4811
|
} catch (error) {
|
4788
|
-
throw new
|
4812
|
+
throw new import_errors19.FuelError(import_errors19.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4789
4813
|
}
|
4790
4814
|
const username = parsedUrl.username;
|
4791
4815
|
const password = parsedUrl.password;
|
@@ -4800,58 +4824,40 @@ var _Provider = class {
|
|
4800
4824
|
};
|
4801
4825
|
}
|
4802
4826
|
/**
|
4803
|
-
*
|
4804
|
-
*
|
4805
|
-
* @param url - GraphQL endpoint of the Fuel node
|
4806
|
-
* @param options - Additional options for the provider
|
4807
|
-
*
|
4808
|
-
* @returns A promise that resolves to a Provider instance.
|
4827
|
+
* Initialize Provider async stuff
|
4809
4828
|
*/
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
return provider;
|
4829
|
+
async init() {
|
4830
|
+
await this.fetchChainAndNodeInfo();
|
4831
|
+
return this;
|
4814
4832
|
}
|
4815
4833
|
/**
|
4816
|
-
* Returns the
|
4834
|
+
* Returns the `chainInfo` for the current network.
|
4817
4835
|
*
|
4818
4836
|
* @returns the chain information configuration.
|
4819
4837
|
*/
|
4820
|
-
getChain() {
|
4821
|
-
|
4822
|
-
|
4823
|
-
throw new import_errors18.FuelError(
|
4824
|
-
import_errors18.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4825
|
-
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4826
|
-
);
|
4827
|
-
}
|
4828
|
-
return chain;
|
4838
|
+
async getChain() {
|
4839
|
+
await this.init();
|
4840
|
+
return _Provider.chainInfoCache[this.urlWithoutAuth];
|
4829
4841
|
}
|
4830
4842
|
/**
|
4831
|
-
* Returns the
|
4843
|
+
* Returns the `nodeInfo` for the current network.
|
4832
4844
|
*
|
4833
4845
|
* @returns the node information configuration.
|
4834
4846
|
*/
|
4835
|
-
getNode() {
|
4836
|
-
|
4837
|
-
|
4838
|
-
throw new import_errors18.FuelError(
|
4839
|
-
import_errors18.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4840
|
-
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4841
|
-
);
|
4842
|
-
}
|
4843
|
-
return node;
|
4847
|
+
async getNode() {
|
4848
|
+
await this.init();
|
4849
|
+
return _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4844
4850
|
}
|
4845
4851
|
/**
|
4846
4852
|
* Returns some helpful parameters related to gas fees.
|
4847
4853
|
*/
|
4848
|
-
getGasConfig() {
|
4854
|
+
async getGasConfig() {
|
4849
4855
|
const {
|
4850
4856
|
txParameters: { maxGasPerTx },
|
4851
4857
|
predicateParameters: { maxGasPerPredicate },
|
4852
4858
|
feeParameters: { gasPriceFactor, gasPerByte },
|
4853
4859
|
gasCosts
|
4854
|
-
} = this.getChain().consensusParameters;
|
4860
|
+
} = (await this.getChain()).consensusParameters;
|
4855
4861
|
return {
|
4856
4862
|
maxGasPerTx,
|
4857
4863
|
maxGasPerPredicate,
|
@@ -4873,7 +4879,7 @@ var _Provider = class {
|
|
4873
4879
|
this.options = options ?? this.options;
|
4874
4880
|
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4875
4881
|
this.operations = this.createOperations();
|
4876
|
-
await this.
|
4882
|
+
await this.init();
|
4877
4883
|
}
|
4878
4884
|
/**
|
4879
4885
|
* Return the chain and node information.
|
@@ -4884,11 +4890,12 @@ var _Provider = class {
|
|
4884
4890
|
let nodeInfo;
|
4885
4891
|
let chain;
|
4886
4892
|
try {
|
4887
|
-
|
4888
|
-
|
4893
|
+
nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4894
|
+
chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4895
|
+
const noCache = !nodeInfo || !chain;
|
4896
|
+
if (ignoreCache || noCache) {
|
4897
|
+
throw new Error(`Jumps to the catch block and re-fetch`);
|
4889
4898
|
}
|
4890
|
-
nodeInfo = this.getNode();
|
4891
|
-
chain = this.getChain();
|
4892
4899
|
} catch (_err) {
|
4893
4900
|
const data = await this.operations.getChainAndNodeInfo();
|
4894
4901
|
nodeInfo = {
|
@@ -5035,10 +5042,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5035
5042
|
*
|
5036
5043
|
* @returns A promise that resolves to the chain ID number.
|
5037
5044
|
*/
|
5038
|
-
getChainId() {
|
5045
|
+
async getChainId() {
|
5039
5046
|
const {
|
5040
5047
|
consensusParameters: { chainId }
|
5041
|
-
} = this.getChain();
|
5048
|
+
} = await this.getChain();
|
5042
5049
|
return chainId.toNumber();
|
5043
5050
|
}
|
5044
5051
|
/**
|
@@ -5046,30 +5053,31 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5046
5053
|
*
|
5047
5054
|
* @returns the base asset ID.
|
5048
5055
|
*/
|
5049
|
-
getBaseAssetId() {
|
5056
|
+
async getBaseAssetId() {
|
5057
|
+
const all = await this.getChain();
|
5050
5058
|
const {
|
5051
5059
|
consensusParameters: { baseAssetId }
|
5052
|
-
} =
|
5060
|
+
} = all;
|
5053
5061
|
return baseAssetId;
|
5054
5062
|
}
|
5055
5063
|
/**
|
5056
5064
|
* @hidden
|
5057
5065
|
*/
|
5058
|
-
validateTransaction(tx) {
|
5066
|
+
async validateTransaction(tx) {
|
5059
5067
|
const {
|
5060
5068
|
consensusParameters: {
|
5061
5069
|
txParameters: { maxInputs, maxOutputs }
|
5062
5070
|
}
|
5063
|
-
} = this.getChain();
|
5071
|
+
} = await this.getChain();
|
5064
5072
|
if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
|
5065
|
-
throw new
|
5066
|
-
|
5073
|
+
throw new import_errors19.FuelError(
|
5074
|
+
import_errors19.ErrorCode.MAX_INPUTS_EXCEEDED,
|
5067
5075
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5068
5076
|
);
|
5069
5077
|
}
|
5070
5078
|
if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
|
5071
|
-
throw new
|
5072
|
-
|
5079
|
+
throw new import_errors19.FuelError(
|
5080
|
+
import_errors19.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
5073
5081
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5074
5082
|
);
|
5075
5083
|
}
|
@@ -5084,20 +5092,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5084
5092
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
5085
5093
|
* @returns A promise that resolves to the transaction response object.
|
5086
5094
|
*/
|
5087
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
5095
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, enableAssetBurn } = {}) {
|
5088
5096
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5097
|
+
validateTransactionForAssetBurn(
|
5098
|
+
await this.getBaseAssetId(),
|
5099
|
+
transactionRequest,
|
5100
|
+
enableAssetBurn
|
5101
|
+
);
|
5089
5102
|
if (estimateTxDependencies) {
|
5090
5103
|
await this.estimateTxDependencies(transactionRequest);
|
5091
5104
|
}
|
5092
|
-
this.validateTransaction(transactionRequest);
|
5105
|
+
await this.validateTransaction(transactionRequest);
|
5093
5106
|
const encodedTransaction = (0, import_utils28.hexlify)(transactionRequest.toTransactionBytes());
|
5094
5107
|
let abis;
|
5095
5108
|
if (isTransactionTypeScript(transactionRequest)) {
|
5096
5109
|
abis = transactionRequest.abis;
|
5097
5110
|
}
|
5098
5111
|
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
5099
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
5100
|
-
|
5112
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(await this.getChainId()));
|
5113
|
+
const chainId = await this.getChainId();
|
5114
|
+
return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
|
5101
5115
|
}
|
5102
5116
|
/**
|
5103
5117
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -5177,7 +5191,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5177
5191
|
const missingContractIds = [];
|
5178
5192
|
let outputVariables = 0;
|
5179
5193
|
let dryRunStatus;
|
5180
|
-
this.validateTransaction(transactionRequest);
|
5194
|
+
await this.validateTransaction(transactionRequest);
|
5181
5195
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5182
5196
|
const {
|
5183
5197
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -5308,7 +5322,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5308
5322
|
if (diff < 6e4) {
|
5309
5323
|
return;
|
5310
5324
|
}
|
5311
|
-
|
5325
|
+
if (!_Provider.chainInfoCache?.[this.urlWithoutAuth]) {
|
5326
|
+
await this.fetchChainAndNodeInfo(true);
|
5327
|
+
return;
|
5328
|
+
}
|
5329
|
+
const chainInfo = _Provider.chainInfoCache[this.urlWithoutAuth];
|
5312
5330
|
const {
|
5313
5331
|
consensusParameters: { version: previous }
|
5314
5332
|
} = chainInfo;
|
@@ -5332,8 +5350,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5332
5350
|
const { transactionRequest } = params;
|
5333
5351
|
let { gasPrice } = params;
|
5334
5352
|
await this.autoRefetchConfigs();
|
5335
|
-
const chainInfo = this.getChain();
|
5336
|
-
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
5353
|
+
const chainInfo = await this.getChain();
|
5354
|
+
const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
|
5337
5355
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
5338
5356
|
if (!(0, import_utils28.isDefined)(gasPrice)) {
|
5339
5357
|
gasPrice = await this.estimateGasPrice(10);
|
@@ -5445,7 +5463,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5445
5463
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
5446
5464
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
5447
5465
|
}
|
5448
|
-
const { maxGasPerTx } = this.getGasConfig();
|
5466
|
+
const { maxGasPerTx } = await this.getGasConfig();
|
5449
5467
|
const pristineGasUsed = getGasUsedFromReceipts(receipts);
|
5450
5468
|
gasUsed = (0, import_math18.bn)(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
|
5451
5469
|
txRequestClone.gasLimit = gasUsed;
|
@@ -5702,7 +5720,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5702
5720
|
0
|
5703
5721
|
)?.[0];
|
5704
5722
|
} catch (error) {
|
5705
|
-
if (error instanceof
|
5723
|
+
if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5706
5724
|
console.warn("Unsupported transaction type encountered");
|
5707
5725
|
return null;
|
5708
5726
|
}
|
@@ -5728,7 +5746,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5728
5746
|
try {
|
5729
5747
|
return coder.decode((0, import_utils28.arrayify)(rawPayload), 0)[0];
|
5730
5748
|
} catch (error) {
|
5731
|
-
if (error instanceof
|
5749
|
+
if (error instanceof import_errors19.FuelError && error.code === import_errors19.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5732
5750
|
console.warn("Unsupported transaction type encountered");
|
5733
5751
|
return null;
|
5734
5752
|
}
|
@@ -5854,8 +5872,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5854
5872
|
nonce
|
5855
5873
|
};
|
5856
5874
|
if (commitBlockId && commitBlockHeight) {
|
5857
|
-
throw new
|
5858
|
-
|
5875
|
+
throw new import_errors19.FuelError(
|
5876
|
+
import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5859
5877
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5860
5878
|
);
|
5861
5879
|
}
|
@@ -6018,9 +6036,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6018
6036
|
* @param transactionId - The transaction ID to get the response for.
|
6019
6037
|
* @returns A promise that resolves to the transaction response.
|
6020
6038
|
*/
|
6021
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
6022
6039
|
async getTransactionResponse(transactionId) {
|
6023
|
-
|
6040
|
+
const chainId = await this.getChainId();
|
6041
|
+
return new TransactionResponse(transactionId, this, chainId);
|
6024
6042
|
}
|
6025
6043
|
/**
|
6026
6044
|
* Returns Message for given nonce.
|
@@ -6110,7 +6128,7 @@ __publicField(Provider, "chainInfoCache", {});
|
|
6110
6128
|
__publicField(Provider, "nodeInfoCache", {});
|
6111
6129
|
|
6112
6130
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6113
|
-
var
|
6131
|
+
var import_errors20 = require("@fuel-ts/errors");
|
6114
6132
|
var import_math19 = require("@fuel-ts/math");
|
6115
6133
|
var import_transactions23 = require("@fuel-ts/transactions");
|
6116
6134
|
var import_utils31 = require("@fuel-ts/utils");
|
@@ -6120,8 +6138,8 @@ async function getTransactionSummary(params) {
|
|
6120
6138
|
transactionId: id
|
6121
6139
|
});
|
6122
6140
|
if (!gqlTransaction) {
|
6123
|
-
throw new
|
6124
|
-
|
6141
|
+
throw new import_errors20.FuelError(
|
6142
|
+
import_errors20.ErrorCode.TRANSACTION_NOT_FOUND,
|
6125
6143
|
`Transaction not found for given id: ${id}.`
|
6126
6144
|
);
|
6127
6145
|
}
|
@@ -6140,9 +6158,10 @@ async function getTransactionSummary(params) {
|
|
6140
6158
|
txParameters: { maxInputs, maxGasPerTx },
|
6141
6159
|
gasCosts
|
6142
6160
|
}
|
6143
|
-
} = provider.getChain();
|
6144
|
-
const
|
6145
|
-
const
|
6161
|
+
} = await provider.getChain();
|
6162
|
+
const totalFee = getTotalFeeFromStatus(gqlTransaction.status);
|
6163
|
+
const gasPrice = totalFee ? (0, import_math19.bn)(0) : await provider.getLatestGasPrice();
|
6164
|
+
const baseAssetId = await provider.getBaseAssetId();
|
6146
6165
|
const transactionInfo = assembleTransactionSummary({
|
6147
6166
|
id: gqlTransaction.id,
|
6148
6167
|
receipts,
|
@@ -6165,14 +6184,14 @@ async function getTransactionSummary(params) {
|
|
6165
6184
|
async function getTransactionSummaryFromRequest(params) {
|
6166
6185
|
const { provider, transactionRequest, abiMap } = params;
|
6167
6186
|
const { receipts } = await provider.dryRun(transactionRequest);
|
6168
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
6169
|
-
const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
|
6187
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await provider.getGasConfig();
|
6188
|
+
const maxInputs = (await provider.getChain()).consensusParameters.txParameters.maxInputs;
|
6170
6189
|
const transaction = transactionRequest.toTransaction();
|
6171
6190
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
6172
6191
|
const gasPrice = await provider.getLatestGasPrice();
|
6173
|
-
const baseAssetId = provider.getBaseAssetId();
|
6192
|
+
const baseAssetId = await provider.getBaseAssetId();
|
6174
6193
|
const transactionSummary = assembleTransactionSummary({
|
6175
|
-
id: transactionRequest.getTransactionId(provider.getChainId()),
|
6194
|
+
id: transactionRequest.getTransactionId(await provider.getChainId()),
|
6176
6195
|
receipts,
|
6177
6196
|
transaction,
|
6178
6197
|
transactionBytes,
|
@@ -6205,9 +6224,9 @@ async function getTransactionsSummaries(params) {
|
|
6205
6224
|
txParameters: { maxInputs, maxGasPerTx },
|
6206
6225
|
gasCosts
|
6207
6226
|
}
|
6208
|
-
} = provider.getChain();
|
6227
|
+
} = await provider.getChain();
|
6209
6228
|
const gasPrice = await provider.getLatestGasPrice();
|
6210
|
-
const baseAssetId = provider.getBaseAssetId();
|
6229
|
+
const baseAssetId = await provider.getBaseAssetId();
|
6211
6230
|
const transactions = edges.map((edge) => {
|
6212
6231
|
const { node: gqlTransaction } = edge;
|
6213
6232
|
const { id, rawPayload, status } = gqlTransaction;
|
@@ -6915,6 +6934,10 @@ var mergeQuantities = (...coinQuantities) => {
|
|
6915
6934
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
6916
6935
|
};
|
6917
6936
|
|
6937
|
+
// src/types.ts
|
6938
|
+
var AbstractAccount = class {
|
6939
|
+
};
|
6940
|
+
|
6918
6941
|
// src/utils/formatTransferToContractScriptData.ts
|
6919
6942
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
6920
6943
|
var import_address4 = require("@fuel-ts/address");
|
@@ -6961,7 +6984,7 @@ var assembleTransferToContractScript = async (transferParams) => {
|
|
6961
6984
|
|
6962
6985
|
// src/account.ts
|
6963
6986
|
var MAX_FUNDING_ATTEMPTS = 5;
|
6964
|
-
var Account = class extends
|
6987
|
+
var Account = class extends AbstractAccount {
|
6965
6988
|
/**
|
6966
6989
|
* The address associated with the account.
|
6967
6990
|
*/
|
@@ -6996,7 +7019,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6996
7019
|
*/
|
6997
7020
|
get provider() {
|
6998
7021
|
if (!this._provider) {
|
6999
|
-
throw new
|
7022
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
7000
7023
|
}
|
7001
7024
|
return this._provider;
|
7002
7025
|
}
|
@@ -7052,7 +7075,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7052
7075
|
* @returns A promise that resolves to the balance amount.
|
7053
7076
|
*/
|
7054
7077
|
async getBalance(assetId) {
|
7055
|
-
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
7078
|
+
const assetIdToFetch = assetId ?? await this.provider.getBaseAssetId();
|
7056
7079
|
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
7057
7080
|
return amount;
|
7058
7081
|
}
|
@@ -7075,7 +7098,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7075
7098
|
async fund(request, params) {
|
7076
7099
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
|
7077
7100
|
const fee = request.maxFee;
|
7078
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
7101
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
7079
7102
|
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
7080
7103
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
7081
7104
|
amount: (0, import_math20.bn)(fee),
|
@@ -7147,12 +7170,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7147
7170
|
fundingAttempts += 1;
|
7148
7171
|
}
|
7149
7172
|
if (needsToBeFunded) {
|
7150
|
-
throw new
|
7151
|
-
|
7173
|
+
throw new import_errors21.FuelError(
|
7174
|
+
import_errors21.ErrorCode.NOT_ENOUGH_FUNDS,
|
7152
7175
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
7153
7176
|
);
|
7154
7177
|
}
|
7155
|
-
this.provider.validateTransaction(request);
|
7178
|
+
await this.provider.validateTransaction(request);
|
7156
7179
|
request.updatePredicateGasUsed(estimatedPredicates);
|
7157
7180
|
const requestToReestimate = (0, import_ramda9.clone)(request);
|
7158
7181
|
if (addedSignatures) {
|
@@ -7179,7 +7202,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7179
7202
|
*/
|
7180
7203
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
7181
7204
|
let request = new ScriptTransactionRequest(txParams);
|
7182
|
-
request = this.addTransfer(request, {
|
7205
|
+
request = this.addTransfer(request, {
|
7206
|
+
destination,
|
7207
|
+
amount,
|
7208
|
+
assetId: assetId || await this.provider.getBaseAssetId()
|
7209
|
+
});
|
7183
7210
|
request = await this.estimateAndFundTransaction(request, txParams);
|
7184
7211
|
return request;
|
7185
7212
|
}
|
@@ -7219,11 +7246,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7219
7246
|
addTransfer(request, transferParams) {
|
7220
7247
|
const { destination, amount, assetId } = transferParams;
|
7221
7248
|
this.validateTransferAmount(amount);
|
7222
|
-
request.addCoinOutput(
|
7223
|
-
import_address5.Address.fromAddressOrString(destination),
|
7224
|
-
amount,
|
7225
|
-
assetId ?? this.provider.getBaseAssetId()
|
7226
|
-
);
|
7249
|
+
request.addCoinOutput(import_address5.Address.fromAddressOrString(destination), amount, assetId);
|
7227
7250
|
return request;
|
7228
7251
|
}
|
7229
7252
|
/**
|
@@ -7234,12 +7257,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7234
7257
|
* @returns The updated script transaction request.
|
7235
7258
|
*/
|
7236
7259
|
addBatchTransfer(request, transferParams) {
|
7237
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
7238
7260
|
transferParams.forEach(({ destination, amount, assetId }) => {
|
7239
7261
|
this.addTransfer(request, {
|
7240
7262
|
destination,
|
7241
7263
|
amount,
|
7242
|
-
assetId
|
7264
|
+
assetId
|
7243
7265
|
});
|
7244
7266
|
});
|
7245
7267
|
return request;
|
@@ -7261,13 +7283,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7261
7283
|
...txParams
|
7262
7284
|
});
|
7263
7285
|
const quantities = [];
|
7286
|
+
const defaultAssetId = await this.provider.getBaseAssetId();
|
7264
7287
|
const transferParams = contractTransferParams.map((transferParam) => {
|
7265
7288
|
const amount = (0, import_math20.bn)(transferParam.amount);
|
7266
7289
|
const contractAddress = import_address5.Address.fromAddressOrString(transferParam.contractId);
|
7267
|
-
const assetId = transferParam.assetId ? (0, import_utils34.hexlify)(transferParam.assetId) :
|
7290
|
+
const assetId = transferParam.assetId ? (0, import_utils34.hexlify)(transferParam.assetId) : defaultAssetId;
|
7268
7291
|
if (amount.lte(0)) {
|
7269
|
-
throw new
|
7270
|
-
|
7292
|
+
throw new import_errors21.FuelError(
|
7293
|
+
import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7271
7294
|
"Transfer amount must be a positive number."
|
7272
7295
|
);
|
7273
7296
|
}
|
@@ -7307,7 +7330,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7307
7330
|
...amountDataArray
|
7308
7331
|
]);
|
7309
7332
|
const params = { script, ...txParams };
|
7310
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
7333
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
7311
7334
|
let request = new ScriptTransactionRequest(params);
|
7312
7335
|
const quantities = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
7313
7336
|
const txCost = await this.getTransactionCost(request, { quantities });
|
@@ -7332,7 +7355,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7332
7355
|
*/
|
7333
7356
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
7334
7357
|
const txRequestClone = (0, import_ramda9.clone)(transactionRequestify(transactionRequestLike));
|
7335
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
7358
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
7336
7359
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7337
7360
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7338
7361
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math20.bn)("100000000000000000") }];
|
@@ -7382,7 +7405,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7382
7405
|
*/
|
7383
7406
|
async signMessage(message) {
|
7384
7407
|
if (!this._connector) {
|
7385
|
-
throw new
|
7408
|
+
throw new import_errors21.FuelError(import_errors21.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7386
7409
|
}
|
7387
7410
|
return this._connector.signMessage(this.address.toString(), message);
|
7388
7411
|
}
|
@@ -7394,8 +7417,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7394
7417
|
*/
|
7395
7418
|
async signTransaction(transactionRequestLike) {
|
7396
7419
|
if (!this._connector) {
|
7397
|
-
throw new
|
7398
|
-
|
7420
|
+
throw new import_errors21.FuelError(
|
7421
|
+
import_errors21.ErrorCode.MISSING_CONNECTOR,
|
7399
7422
|
"A connector is required to sign transactions."
|
7400
7423
|
);
|
7401
7424
|
}
|
@@ -7408,10 +7431,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7408
7431
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
7409
7432
|
* @returns A promise that resolves to the transaction response.
|
7410
7433
|
*/
|
7411
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
7434
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
|
7412
7435
|
if (this._connector) {
|
7413
7436
|
return this.provider.getTransactionResponse(
|
7414
|
-
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike
|
7437
|
+
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
|
7438
|
+
onBeforeSend,
|
7439
|
+
skipCustomFee
|
7440
|
+
})
|
7415
7441
|
);
|
7416
7442
|
}
|
7417
7443
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
@@ -7454,8 +7480,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7454
7480
|
/** @hidden * */
|
7455
7481
|
validateTransferAmount(amount) {
|
7456
7482
|
if ((0, import_math20.bn)(amount).lte(0)) {
|
7457
|
-
throw new
|
7458
|
-
|
7483
|
+
throw new import_errors21.FuelError(
|
7484
|
+
import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
7459
7485
|
"Transfer amount must be a positive number."
|
7460
7486
|
);
|
7461
7487
|
}
|
@@ -7484,16 +7510,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
7484
7510
|
if (!(0, import_utils34.isDefined)(setGasLimit)) {
|
7485
7511
|
request.gasLimit = gasUsed;
|
7486
7512
|
} else if (gasUsed.gt(setGasLimit)) {
|
7487
|
-
throw new
|
7488
|
-
|
7513
|
+
throw new import_errors21.FuelError(
|
7514
|
+
import_errors21.ErrorCode.GAS_LIMIT_TOO_LOW,
|
7489
7515
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7490
7516
|
);
|
7491
7517
|
}
|
7492
7518
|
if (!(0, import_utils34.isDefined)(setMaxFee)) {
|
7493
7519
|
request.maxFee = maxFee;
|
7494
7520
|
} else if (maxFee.gt(setMaxFee)) {
|
7495
|
-
throw new
|
7496
|
-
|
7521
|
+
throw new import_errors21.FuelError(
|
7522
|
+
import_errors21.ErrorCode.MAX_FEE_TOO_LOW,
|
7497
7523
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7498
7524
|
);
|
7499
7525
|
}
|
@@ -7617,7 +7643,7 @@ var Signer = class {
|
|
7617
7643
|
// src/wallet/keystore-wallet.ts
|
7618
7644
|
var import_address7 = require("@fuel-ts/address");
|
7619
7645
|
var import_crypto4 = require("@fuel-ts/crypto");
|
7620
|
-
var
|
7646
|
+
var import_errors22 = require("@fuel-ts/errors");
|
7621
7647
|
var import_utils36 = require("@fuel-ts/utils");
|
7622
7648
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7623
7649
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7694,8 +7720,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7694
7720
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
7695
7721
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
7696
7722
|
if (mac !== macHash) {
|
7697
|
-
throw new
|
7698
|
-
|
7723
|
+
throw new import_errors22.FuelError(
|
7724
|
+
import_errors22.ErrorCode.INVALID_PASSWORD,
|
7699
7725
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7700
7726
|
);
|
7701
7727
|
}
|
@@ -7755,7 +7781,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7755
7781
|
*/
|
7756
7782
|
async signTransaction(transactionRequestLike) {
|
7757
7783
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
7758
|
-
const chainId = this.provider.getChainId();
|
7784
|
+
const chainId = await this.provider.getChainId();
|
7759
7785
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
7760
7786
|
const signature = await this.signer().sign(hashedTransaction);
|
7761
7787
|
return (0, import_utils37.hexlify)(signature);
|
@@ -7779,14 +7805,19 @@ var BaseWalletUnlocked = class extends Account {
|
|
7779
7805
|
* @param estimateTxDependencies - Whether to estimate the transaction dependencies.
|
7780
7806
|
* @returns A promise that resolves to the TransactionResponse object.
|
7781
7807
|
*/
|
7782
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
|
7808
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, enableAssetBurn } = {}) {
|
7783
7809
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
7810
|
+
validateTransactionForAssetBurn(
|
7811
|
+
await this.provider.getBaseAssetId(),
|
7812
|
+
transactionRequest,
|
7813
|
+
enableAssetBurn
|
7814
|
+
);
|
7784
7815
|
if (estimateTxDependencies) {
|
7785
7816
|
await this.provider.estimateTxDependencies(transactionRequest);
|
7786
7817
|
}
|
7787
7818
|
return this.provider.sendTransaction(
|
7788
7819
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
7789
|
-
{ estimateTxDependencies: false }
|
7820
|
+
{ estimateTxDependencies: false, enableAssetBurn }
|
7790
7821
|
);
|
7791
7822
|
}
|
7792
7823
|
/**
|
@@ -7825,14 +7856,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7825
7856
|
|
7826
7857
|
// src/hdwallet/hdwallet.ts
|
7827
7858
|
var import_crypto6 = require("@fuel-ts/crypto");
|
7828
|
-
var
|
7859
|
+
var import_errors25 = require("@fuel-ts/errors");
|
7829
7860
|
var import_hasher7 = require("@fuel-ts/hasher");
|
7830
7861
|
var import_math22 = require("@fuel-ts/math");
|
7831
7862
|
var import_utils41 = require("@fuel-ts/utils");
|
7832
7863
|
|
7833
7864
|
// src/mnemonic/mnemonic.ts
|
7834
7865
|
var import_crypto5 = require("@fuel-ts/crypto");
|
7835
|
-
var
|
7866
|
+
var import_errors24 = require("@fuel-ts/errors");
|
7836
7867
|
var import_hasher6 = require("@fuel-ts/hasher");
|
7837
7868
|
var import_utils39 = require("@fuel-ts/utils");
|
7838
7869
|
|
@@ -9895,7 +9926,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
9895
9926
|
})(Language || {});
|
9896
9927
|
|
9897
9928
|
// src/mnemonic/utils.ts
|
9898
|
-
var
|
9929
|
+
var import_errors23 = require("@fuel-ts/errors");
|
9899
9930
|
var import_hasher5 = require("@fuel-ts/hasher");
|
9900
9931
|
var import_utils38 = require("@fuel-ts/utils");
|
9901
9932
|
function getLowerMask(bits) {
|
@@ -9944,8 +9975,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9944
9975
|
for (let i = 0; i < words.length; i += 1) {
|
9945
9976
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9946
9977
|
if (index === -1) {
|
9947
|
-
throw new
|
9948
|
-
|
9978
|
+
throw new import_errors23.FuelError(
|
9979
|
+
import_errors23.ErrorCode.INVALID_MNEMONIC,
|
9949
9980
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9950
9981
|
);
|
9951
9982
|
}
|
@@ -9961,8 +9992,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9961
9992
|
const checksumMask = getUpperMask(checksumBits);
|
9962
9993
|
const checksum = (0, import_utils38.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9963
9994
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9964
|
-
throw new
|
9965
|
-
|
9995
|
+
throw new import_errors23.FuelError(
|
9996
|
+
import_errors23.ErrorCode.INVALID_CHECKSUM,
|
9966
9997
|
"Checksum validation failed for the provided mnemonic."
|
9967
9998
|
);
|
9968
9999
|
}
|
@@ -9976,16 +10007,16 @@ var TestnetPRV = "0x04358394";
|
|
9976
10007
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9977
10008
|
function assertWordList(wordlist) {
|
9978
10009
|
if (wordlist.length !== 2048) {
|
9979
|
-
throw new
|
9980
|
-
|
10010
|
+
throw new import_errors24.FuelError(
|
10011
|
+
import_errors24.ErrorCode.INVALID_WORD_LIST,
|
9981
10012
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9982
10013
|
);
|
9983
10014
|
}
|
9984
10015
|
}
|
9985
10016
|
function assertEntropy(entropy) {
|
9986
10017
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9987
|
-
throw new
|
9988
|
-
|
10018
|
+
throw new import_errors24.FuelError(
|
10019
|
+
import_errors24.ErrorCode.INVALID_ENTROPY,
|
9989
10020
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9990
10021
|
);
|
9991
10022
|
}
|
@@ -9995,7 +10026,7 @@ function assertMnemonic(words) {
|
|
9995
10026
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9996
10027
|
", "
|
9997
10028
|
)}] words, but got ${words.length}.`;
|
9998
|
-
throw new
|
10029
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
9999
10030
|
}
|
10000
10031
|
}
|
10001
10032
|
var Mnemonic = class {
|
@@ -10113,8 +10144,8 @@ var Mnemonic = class {
|
|
10113
10144
|
static masterKeysFromSeed(seed) {
|
10114
10145
|
const seedArray = (0, import_utils39.arrayify)(seed);
|
10115
10146
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
10116
|
-
throw new
|
10117
|
-
|
10147
|
+
throw new import_errors24.FuelError(
|
10148
|
+
import_errors24.ErrorCode.INVALID_SEED,
|
10118
10149
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
10119
10150
|
);
|
10120
10151
|
}
|
@@ -10191,7 +10222,7 @@ function isValidExtendedKey(extendedKey) {
|
|
10191
10222
|
function parsePath(path, depth = 0) {
|
10192
10223
|
const components = path.split("/");
|
10193
10224
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
10194
|
-
throw new
|
10225
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
10195
10226
|
}
|
10196
10227
|
if (components[0] === "m") {
|
10197
10228
|
components.shift();
|
@@ -10220,8 +10251,8 @@ var HDWallet = class {
|
|
10220
10251
|
this.privateKey = (0, import_utils41.hexlify)(config.privateKey);
|
10221
10252
|
} else {
|
10222
10253
|
if (!config.publicKey) {
|
10223
|
-
throw new
|
10224
|
-
|
10254
|
+
throw new import_errors25.FuelError(
|
10255
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
10225
10256
|
"Both public and private Key cannot be missing. At least one should be provided."
|
10226
10257
|
);
|
10227
10258
|
}
|
@@ -10250,8 +10281,8 @@ var HDWallet = class {
|
|
10250
10281
|
const data = new Uint8Array(37);
|
10251
10282
|
if (index & HARDENED_INDEX) {
|
10252
10283
|
if (!privateKey) {
|
10253
|
-
throw new
|
10254
|
-
|
10284
|
+
throw new import_errors25.FuelError(
|
10285
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
10255
10286
|
"Cannot derive a hardened index without a private Key."
|
10256
10287
|
);
|
10257
10288
|
}
|
@@ -10303,8 +10334,8 @@ var HDWallet = class {
|
|
10303
10334
|
*/
|
10304
10335
|
toExtendedKey(isPublic = false, testnet = false) {
|
10305
10336
|
if (this.depth >= 256) {
|
10306
|
-
throw new
|
10307
|
-
|
10337
|
+
throw new import_errors25.FuelError(
|
10338
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
10308
10339
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10309
10340
|
);
|
10310
10341
|
}
|
@@ -10335,10 +10366,10 @@ var HDWallet = class {
|
|
10335
10366
|
const bytes = (0, import_utils41.arrayify)(decoded);
|
10336
10367
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10337
10368
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10338
|
-
throw new
|
10369
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10339
10370
|
}
|
10340
10371
|
if (!validChecksum) {
|
10341
|
-
throw new
|
10372
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10342
10373
|
}
|
10343
10374
|
const depth = bytes[4];
|
10344
10375
|
const parentFingerprint = (0, import_utils41.hexlify)(bytes.slice(5, 9));
|
@@ -10346,14 +10377,14 @@ var HDWallet = class {
|
|
10346
10377
|
const chainCode = (0, import_utils41.hexlify)(bytes.slice(13, 45));
|
10347
10378
|
const key = bytes.slice(45, 78);
|
10348
10379
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10349
|
-
throw new
|
10350
|
-
|
10380
|
+
throw new import_errors25.FuelError(
|
10381
|
+
import_errors25.ErrorCode.HD_WALLET_ERROR,
|
10351
10382
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10352
10383
|
);
|
10353
10384
|
}
|
10354
10385
|
if (isPublicExtendedKey(bytes)) {
|
10355
10386
|
if (key[0] !== 3) {
|
10356
|
-
throw new
|
10387
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
10357
10388
|
}
|
10358
10389
|
return new HDWallet({
|
10359
10390
|
publicKey: key,
|
@@ -10364,7 +10395,7 @@ var HDWallet = class {
|
|
10364
10395
|
});
|
10365
10396
|
}
|
10366
10397
|
if (key[0] !== 0) {
|
10367
|
-
throw new
|
10398
|
+
throw new import_errors25.FuelError(import_errors25.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
10368
10399
|
}
|
10369
10400
|
return new HDWallet({
|
10370
10401
|
privateKey: key.slice(1),
|
@@ -10532,7 +10563,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
10532
10563
|
// src/wallet-manager/wallet-manager.ts
|
10533
10564
|
var import_address10 = require("@fuel-ts/address");
|
10534
10565
|
var import_crypto7 = require("@fuel-ts/crypto");
|
10535
|
-
var
|
10566
|
+
var import_errors28 = require("@fuel-ts/errors");
|
10536
10567
|
var import_events = require("events");
|
10537
10568
|
|
10538
10569
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -10555,7 +10586,7 @@ var MemoryStorage = class {
|
|
10555
10586
|
|
10556
10587
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
10557
10588
|
var import_address8 = require("@fuel-ts/address");
|
10558
|
-
var
|
10589
|
+
var import_errors26 = require("@fuel-ts/errors");
|
10559
10590
|
var _secret;
|
10560
10591
|
var MnemonicVault = class {
|
10561
10592
|
constructor(options) {
|
@@ -10611,8 +10642,8 @@ var MnemonicVault = class {
|
|
10611
10642
|
}
|
10612
10643
|
numberOfAccounts += 1;
|
10613
10644
|
} while (numberOfAccounts < this.numberOfAccounts);
|
10614
|
-
throw new
|
10615
|
-
|
10645
|
+
throw new import_errors26.FuelError(
|
10646
|
+
import_errors26.ErrorCode.WALLET_MANAGER_ERROR,
|
10616
10647
|
`Account with address '${address}' not found in derived wallets.`
|
10617
10648
|
);
|
10618
10649
|
}
|
@@ -10626,7 +10657,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
10626
10657
|
|
10627
10658
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
10628
10659
|
var import_address9 = require("@fuel-ts/address");
|
10629
|
-
var
|
10660
|
+
var import_errors27 = require("@fuel-ts/errors");
|
10630
10661
|
var _privateKeys;
|
10631
10662
|
var PrivateKeyVault = class {
|
10632
10663
|
/**
|
@@ -10667,8 +10698,8 @@ var PrivateKeyVault = class {
|
|
10667
10698
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
10668
10699
|
);
|
10669
10700
|
if (!privateKey) {
|
10670
|
-
throw new
|
10671
|
-
|
10701
|
+
throw new import_errors27.FuelError(
|
10702
|
+
import_errors27.ErrorCode.WALLET_MANAGER_ERROR,
|
10672
10703
|
`No private key found for address '${address}'.`
|
10673
10704
|
);
|
10674
10705
|
}
|
@@ -10692,7 +10723,7 @@ var ERROR_MESSAGES = {
|
|
10692
10723
|
};
|
10693
10724
|
function assert(condition, message) {
|
10694
10725
|
if (!condition) {
|
10695
|
-
throw new
|
10726
|
+
throw new import_errors28.FuelError(import_errors28.ErrorCode.WALLET_MANAGER_ERROR, message);
|
10696
10727
|
}
|
10697
10728
|
}
|
10698
10729
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -10918,25 +10949,25 @@ deserializeVaults_fn = function(vaults) {
|
|
10918
10949
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
10919
10950
|
|
10920
10951
|
// src/wallet-manager/types.ts
|
10921
|
-
var
|
10952
|
+
var import_errors29 = require("@fuel-ts/errors");
|
10922
10953
|
var Vault = class {
|
10923
10954
|
constructor(_options) {
|
10924
|
-
throw new
|
10955
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10925
10956
|
}
|
10926
10957
|
serialize() {
|
10927
|
-
throw new
|
10958
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10928
10959
|
}
|
10929
10960
|
getAccounts() {
|
10930
|
-
throw new
|
10961
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10931
10962
|
}
|
10932
10963
|
addAccount() {
|
10933
|
-
throw new
|
10964
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10934
10965
|
}
|
10935
10966
|
exportAccount(_address) {
|
10936
|
-
throw new
|
10967
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10937
10968
|
}
|
10938
10969
|
getWallet(_address) {
|
10939
|
-
throw new
|
10970
|
+
throw new import_errors29.FuelError(import_errors29.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10940
10971
|
}
|
10941
10972
|
};
|
10942
10973
|
__publicField(Vault, "type");
|
@@ -10946,11 +10977,11 @@ var StorageAbstract = class {
|
|
10946
10977
|
// src/predicate/predicate.ts
|
10947
10978
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
10948
10979
|
var import_address11 = require("@fuel-ts/address");
|
10949
|
-
var
|
10980
|
+
var import_errors31 = require("@fuel-ts/errors");
|
10950
10981
|
var import_utils45 = require("@fuel-ts/utils");
|
10951
10982
|
|
10952
10983
|
// src/utils/deployScriptOrPredicate.ts
|
10953
|
-
var
|
10984
|
+
var import_errors30 = require("@fuel-ts/errors");
|
10954
10985
|
var import_hasher8 = require("@fuel-ts/hasher");
|
10955
10986
|
var import_math23 = require("@fuel-ts/math");
|
10956
10987
|
var import_utils43 = require("@fuel-ts/utils");
|
@@ -11085,7 +11116,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11085
11116
|
// src/utils/deployScriptOrPredicate.ts
|
11086
11117
|
async function fundBlobTx(deployer, blobTxRequest) {
|
11087
11118
|
let totalCost = (0, import_math23.bn)(0);
|
11088
|
-
const chainInfo = deployer.provider.getChain();
|
11119
|
+
const chainInfo = await deployer.provider.getChain();
|
11089
11120
|
const gasPrice = await deployer.provider.estimateGasPrice(10);
|
11090
11121
|
const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;
|
11091
11122
|
const minGas = blobTxRequest.calculateMinGas(chainInfo);
|
@@ -11097,7 +11128,7 @@ async function fundBlobTx(deployer, blobTxRequest) {
|
|
11097
11128
|
}).add(1);
|
11098
11129
|
totalCost = totalCost.add(minFee);
|
11099
11130
|
if (totalCost.gt(await deployer.getBalance())) {
|
11100
|
-
throw new
|
11131
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
|
11101
11132
|
}
|
11102
11133
|
const txCost = await deployer.getTransactionCost(blobTxRequest);
|
11103
11134
|
blobTxRequest.maxFee = txCost.maxFee;
|
@@ -11148,7 +11179,7 @@ async function deployScriptOrPredicate({
|
|
11148
11179
|
throw new Error();
|
11149
11180
|
}
|
11150
11181
|
} catch (err) {
|
11151
|
-
throw new
|
11182
|
+
throw new import_errors30.FuelError(import_errors30.ErrorCode.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
|
11152
11183
|
}
|
11153
11184
|
return loaderInstance;
|
11154
11185
|
};
|
@@ -11176,6 +11207,8 @@ var Predicate = class extends Account {
|
|
11176
11207
|
bytes;
|
11177
11208
|
predicateData = [];
|
11178
11209
|
interface;
|
11210
|
+
initialBytecode;
|
11211
|
+
configurableConstants;
|
11179
11212
|
/**
|
11180
11213
|
* Creates an instance of the Predicate class.
|
11181
11214
|
*
|
@@ -11199,8 +11232,10 @@ var Predicate = class extends Account {
|
|
11199
11232
|
);
|
11200
11233
|
const address = import_address11.Address.fromB256(getPredicateRoot(predicateBytes));
|
11201
11234
|
super(address, provider);
|
11235
|
+
this.initialBytecode = (0, import_utils45.arrayify)(bytecode);
|
11202
11236
|
this.bytes = predicateBytes;
|
11203
11237
|
this.interface = predicateInterface;
|
11238
|
+
this.configurableConstants = configurableConstants;
|
11204
11239
|
if (data !== void 0 && data.length > 0) {
|
11205
11240
|
this.predicateData = data;
|
11206
11241
|
}
|
@@ -11253,6 +11288,20 @@ var Predicate = class extends Account {
|
|
11253
11288
|
const mainFn = this.interface?.functions.main;
|
11254
11289
|
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
11255
11290
|
}
|
11291
|
+
/**
|
11292
|
+
* Creates a new Predicate instance from an existing Predicate instance.
|
11293
|
+
* @param overrides - The data and configurable constants to override.
|
11294
|
+
* @returns A new Predicate instance with the same bytecode, ABI and provider but with the ability to set the data and configurable constants.
|
11295
|
+
*/
|
11296
|
+
toNewInstance(overrides = {}) {
|
11297
|
+
return new Predicate({
|
11298
|
+
bytecode: this.initialBytecode,
|
11299
|
+
abi: this.interface.jsonAbi,
|
11300
|
+
provider: this.provider,
|
11301
|
+
data: overrides.data ?? this.predicateData,
|
11302
|
+
configurableConstants: overrides.configurableConstants ?? this.configurableConstants
|
11303
|
+
});
|
11304
|
+
}
|
11256
11305
|
/**
|
11257
11306
|
* Processes the predicate data and returns the altered bytecode and interface.
|
11258
11307
|
*
|
@@ -11265,8 +11314,8 @@ var Predicate = class extends Account {
|
|
11265
11314
|
let predicateBytes = (0, import_utils45.arrayify)(bytes);
|
11266
11315
|
const abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
11267
11316
|
if (abiInterface.functions.main === void 0) {
|
11268
|
-
throw new
|
11269
|
-
|
11317
|
+
throw new import_errors31.FuelError(
|
11318
|
+
import_errors31.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
11270
11319
|
'Cannot use ABI without "main" function.'
|
11271
11320
|
);
|
11272
11321
|
}
|
@@ -11326,15 +11375,15 @@ var Predicate = class extends Account {
|
|
11326
11375
|
const mutatedBytes = bytes;
|
11327
11376
|
try {
|
11328
11377
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
11329
|
-
throw new
|
11330
|
-
|
11378
|
+
throw new import_errors31.FuelError(
|
11379
|
+
import_errors31.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
11331
11380
|
"Predicate has no configurable constants to be set"
|
11332
11381
|
);
|
11333
11382
|
}
|
11334
11383
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
11335
11384
|
if (!abiInterface?.configurables[key]) {
|
11336
|
-
throw new
|
11337
|
-
|
11385
|
+
throw new import_errors31.FuelError(
|
11386
|
+
import_errors31.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
11338
11387
|
`No configurable constant named '${key}' found in the Predicate`
|
11339
11388
|
);
|
11340
11389
|
}
|
@@ -11343,8 +11392,8 @@ var Predicate = class extends Account {
|
|
11343
11392
|
mutatedBytes.set(encoded, offset);
|
11344
11393
|
});
|
11345
11394
|
} catch (err) {
|
11346
|
-
throw new
|
11347
|
-
|
11395
|
+
throw new import_errors31.FuelError(
|
11396
|
+
import_errors31.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
11348
11397
|
`Error setting configurable constants: ${err.message}.`
|
11349
11398
|
);
|
11350
11399
|
}
|
@@ -11397,10 +11446,10 @@ var Predicate = class extends Account {
|
|
11397
11446
|
};
|
11398
11447
|
|
11399
11448
|
// src/connectors/fuel.ts
|
11400
|
-
var
|
11449
|
+
var import_errors34 = require("@fuel-ts/errors");
|
11401
11450
|
|
11402
11451
|
// src/connectors/fuel-connector.ts
|
11403
|
-
var
|
11452
|
+
var import_errors32 = require("@fuel-ts/errors");
|
11404
11453
|
var import_events2 = require("events");
|
11405
11454
|
|
11406
11455
|
// src/connectors/types/connector-types.ts
|
@@ -11475,7 +11524,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11475
11524
|
* @returns Always true.
|
11476
11525
|
*/
|
11477
11526
|
async ping() {
|
11478
|
-
throw new
|
11527
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11479
11528
|
}
|
11480
11529
|
/**
|
11481
11530
|
* Should return the current version of the connector
|
@@ -11484,7 +11533,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11484
11533
|
* @returns boolean - connection status.
|
11485
11534
|
*/
|
11486
11535
|
async version() {
|
11487
|
-
throw new
|
11536
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11488
11537
|
}
|
11489
11538
|
/**
|
11490
11539
|
* Should return true if the connector is connected
|
@@ -11493,7 +11542,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11493
11542
|
* @returns The connection status.
|
11494
11543
|
*/
|
11495
11544
|
async isConnected() {
|
11496
|
-
throw new
|
11545
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11497
11546
|
}
|
11498
11547
|
/**
|
11499
11548
|
* Should return all the accounts authorized for the
|
@@ -11502,7 +11551,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11502
11551
|
* @returns The accounts addresses strings
|
11503
11552
|
*/
|
11504
11553
|
async accounts() {
|
11505
|
-
throw new
|
11554
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11506
11555
|
}
|
11507
11556
|
/**
|
11508
11557
|
* Should start the connection process and return
|
@@ -11514,7 +11563,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11514
11563
|
* @returns boolean - connection status.
|
11515
11564
|
*/
|
11516
11565
|
async connect() {
|
11517
|
-
throw new
|
11566
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11518
11567
|
}
|
11519
11568
|
/**
|
11520
11569
|
* Should disconnect the current connection and
|
@@ -11524,7 +11573,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11524
11573
|
* @returns The connection status.
|
11525
11574
|
*/
|
11526
11575
|
async disconnect() {
|
11527
|
-
throw new
|
11576
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11528
11577
|
}
|
11529
11578
|
/**
|
11530
11579
|
* Should start the sign message process and return
|
@@ -11536,7 +11585,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11536
11585
|
* @returns Message signature
|
11537
11586
|
*/
|
11538
11587
|
async signMessage(_address, _message) {
|
11539
|
-
throw new
|
11588
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11540
11589
|
}
|
11541
11590
|
/**
|
11542
11591
|
* Should start the sign transaction process and return
|
@@ -11548,7 +11597,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11548
11597
|
* @returns Transaction signature
|
11549
11598
|
*/
|
11550
11599
|
async signTransaction(_address, _transaction) {
|
11551
|
-
throw new
|
11600
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11552
11601
|
}
|
11553
11602
|
/**
|
11554
11603
|
* Should start the send transaction process and return
|
@@ -11560,11 +11609,11 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11560
11609
|
*
|
11561
11610
|
* @param address - The address to sign the transaction
|
11562
11611
|
* @param transaction - The transaction to send
|
11563
|
-
*
|
11612
|
+
* @param params - Optional parameters to send the transaction
|
11564
11613
|
* @returns The transaction id
|
11565
11614
|
*/
|
11566
|
-
async sendTransaction(_address, _transaction) {
|
11567
|
-
throw new
|
11615
|
+
async sendTransaction(_address, _transaction, _params) {
|
11616
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11568
11617
|
}
|
11569
11618
|
/**
|
11570
11619
|
* Should return the current account selected inside the connector, if the account
|
@@ -11575,7 +11624,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11575
11624
|
* @returns The current account selected otherwise null.
|
11576
11625
|
*/
|
11577
11626
|
async currentAccount() {
|
11578
|
-
throw new
|
11627
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11579
11628
|
}
|
11580
11629
|
/**
|
11581
11630
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -11589,7 +11638,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11589
11638
|
* @returns True if the asset was added successfully
|
11590
11639
|
*/
|
11591
11640
|
async addAssets(_assets) {
|
11592
|
-
throw new
|
11641
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11593
11642
|
}
|
11594
11643
|
/**
|
11595
11644
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -11603,7 +11652,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11603
11652
|
* @returns True if the asset was added successfully
|
11604
11653
|
*/
|
11605
11654
|
async addAsset(_asset) {
|
11606
|
-
throw new
|
11655
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11607
11656
|
}
|
11608
11657
|
/**
|
11609
11658
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -11611,7 +11660,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11611
11660
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
11612
11661
|
*/
|
11613
11662
|
async assets() {
|
11614
|
-
throw new
|
11663
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11615
11664
|
}
|
11616
11665
|
/**
|
11617
11666
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -11622,7 +11671,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11622
11671
|
* @returns Return true if the network was added successfully
|
11623
11672
|
*/
|
11624
11673
|
async addNetwork(_networkUrl) {
|
11625
|
-
throw new
|
11674
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11626
11675
|
}
|
11627
11676
|
/**
|
11628
11677
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -11633,7 +11682,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11633
11682
|
* @returns Return true if the network was added successfully
|
11634
11683
|
*/
|
11635
11684
|
async selectNetwork(_network) {
|
11636
|
-
throw new
|
11685
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11637
11686
|
}
|
11638
11687
|
/**
|
11639
11688
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -11641,7 +11690,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11641
11690
|
* @returns Return all the networks added to the connector.
|
11642
11691
|
*/
|
11643
11692
|
async networks() {
|
11644
|
-
throw new
|
11693
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11645
11694
|
}
|
11646
11695
|
/**
|
11647
11696
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -11649,7 +11698,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11649
11698
|
* @returns Return the current network selected inside the connector.
|
11650
11699
|
*/
|
11651
11700
|
async currentNetwork() {
|
11652
|
-
throw new
|
11701
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11653
11702
|
}
|
11654
11703
|
/**
|
11655
11704
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -11659,7 +11708,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11659
11708
|
* @returns Return true if the ABI was added successfully.
|
11660
11709
|
*/
|
11661
11710
|
async addABI(_contractId, _abi) {
|
11662
|
-
throw new
|
11711
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11663
11712
|
}
|
11664
11713
|
/**
|
11665
11714
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -11668,7 +11717,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11668
11717
|
* @returns The ABI if it exists, otherwise return null.
|
11669
11718
|
*/
|
11670
11719
|
async getABI(_id) {
|
11671
|
-
throw new
|
11720
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11672
11721
|
}
|
11673
11722
|
/**
|
11674
11723
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -11677,7 +11726,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
11677
11726
|
* @returns Returns true if the abi exists or false if not.
|
11678
11727
|
*/
|
11679
11728
|
async hasABI(_id) {
|
11680
|
-
throw new
|
11729
|
+
throw new import_errors32.FuelError(import_errors32.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11681
11730
|
}
|
11682
11731
|
/**
|
11683
11732
|
* Event listener for the connector.
|
@@ -11721,7 +11770,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
11721
11770
|
}
|
11722
11771
|
|
11723
11772
|
// src/connectors/utils/promises.ts
|
11724
|
-
var
|
11773
|
+
var import_errors33 = require("@fuel-ts/errors");
|
11725
11774
|
function deferPromise() {
|
11726
11775
|
const defer = {};
|
11727
11776
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -11733,7 +11782,7 @@ function deferPromise() {
|
|
11733
11782
|
async function withTimeout(promise, timeout = 1050) {
|
11734
11783
|
const timeoutPromise = new Promise((resolve, reject) => {
|
11735
11784
|
setTimeout(() => {
|
11736
|
-
reject(new
|
11785
|
+
reject(new import_errors33.FuelError(import_errors33.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
11737
11786
|
}, timeout);
|
11738
11787
|
});
|
11739
11788
|
return Promise.race([timeoutPromise, promise]);
|
@@ -11768,7 +11817,7 @@ var _Fuel = class extends FuelConnector {
|
|
11768
11817
|
this._targetUnsubscribe = this.setupConnectorListener();
|
11769
11818
|
await connectResponse;
|
11770
11819
|
} catch (error) {
|
11771
|
-
throw new
|
11820
|
+
throw new import_errors34.FuelError(import_errors34.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
11772
11821
|
}
|
11773
11822
|
}
|
11774
11823
|
async init() {
|
@@ -11834,8 +11883,8 @@ var _Fuel = class extends FuelConnector {
|
|
11834
11883
|
const hasConnector = await this.hasConnector();
|
11835
11884
|
await this.pingConnector();
|
11836
11885
|
if (!this._currentConnector || !hasConnector) {
|
11837
|
-
throw new
|
11838
|
-
|
11886
|
+
throw new import_errors34.FuelError(
|
11887
|
+
import_errors34.ErrorCode.MISSING_CONNECTOR,
|
11839
11888
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
11840
11889
|
);
|
11841
11890
|
}
|
@@ -11899,7 +11948,7 @@ var _Fuel = class extends FuelConnector {
|
|
11899
11948
|
cacheTime: PING_CACHE_TIME
|
11900
11949
|
})();
|
11901
11950
|
} catch {
|
11902
|
-
throw new
|
11951
|
+
throw new import_errors34.FuelError(import_errors34.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
|
11903
11952
|
}
|
11904
11953
|
}
|
11905
11954
|
/**
|
@@ -12043,12 +12092,12 @@ var _Fuel = class extends FuelConnector {
|
|
12043
12092
|
if (providerOrNetwork && "getTransactionResponse" in providerOrNetwork) {
|
12044
12093
|
provider = providerOrNetwork;
|
12045
12094
|
} else if (providerOrNetwork && "chainId" in providerOrNetwork && "url" in providerOrNetwork) {
|
12046
|
-
provider =
|
12095
|
+
provider = new Provider(providerOrNetwork.url);
|
12047
12096
|
} else if (!providerOrNetwork) {
|
12048
12097
|
const currentNetwork = await this.currentNetwork();
|
12049
|
-
provider =
|
12098
|
+
provider = new Provider(currentNetwork.url);
|
12050
12099
|
} else {
|
12051
|
-
throw new
|
12100
|
+
throw new import_errors34.FuelError(import_errors34.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
12052
12101
|
}
|
12053
12102
|
return provider;
|
12054
12103
|
}
|
@@ -12088,6 +12137,8 @@ __publicField(Fuel, "STORAGE_KEY", "fuel-current-connector");
|
|
12088
12137
|
__publicField(Fuel, "defaultConfig", {});
|
12089
12138
|
// Annotate the CommonJS export names for ESM import in node:
|
12090
12139
|
0 && (module.exports = {
|
12140
|
+
AbstractAccount,
|
12141
|
+
AbstractScriptRequest,
|
12091
12142
|
Account,
|
12092
12143
|
AddressType,
|
12093
12144
|
BLOCKS_PAGE_SIZE_LIMIT,
|
@@ -12169,6 +12220,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
12169
12220
|
getAssetFuel,
|
12170
12221
|
getAssetNetwork,
|
12171
12222
|
getAssetWithNetwork,
|
12223
|
+
getBurnableAssetCount,
|
12172
12224
|
getContractCallOperations,
|
12173
12225
|
getContractCreatedOperations,
|
12174
12226
|
getDecodedLogs,
|
@@ -12200,6 +12252,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
12200
12252
|
getReceiptsTransferOut,
|
12201
12253
|
getReceiptsWithMissingData,
|
12202
12254
|
getRequestInputResourceOwner,
|
12255
|
+
getTotalFeeFromStatus,
|
12203
12256
|
getTransactionStatusName,
|
12204
12257
|
getTransactionSummary,
|
12205
12258
|
getTransactionSummaryFromRequest,
|
@@ -12243,6 +12296,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
12243
12296
|
returnZeroScript,
|
12244
12297
|
transactionRequestify,
|
12245
12298
|
urlJoin,
|
12299
|
+
validateTransactionForAssetBurn,
|
12246
12300
|
withTimeout,
|
12247
12301
|
withdrawScript
|
12248
12302
|
});
|