@fuel-ts/account 0.94.4 → 0.94.6
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/configs.d.ts +6 -0
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +3 -4
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +7 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/local-storage.d.ts +0 -1
- package/dist/connectors/types/local-storage.d.ts.map +1 -1
- package/dist/index.global.js +1659 -1135
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1329 -416
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1271 -367
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +169 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/assets.d.ts +1 -1
- package/dist/providers/assets/assets.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
- package/dist/providers/chains.d.ts +2 -0
- package/dist/providers/chains.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +0 -2
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +17 -4
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +2 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +8 -2
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +87 -0
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/upload-transaction-request.d.ts +82 -0
- package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/utils.d.ts +6 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +3 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/input.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/output.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +16 -0
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts.map +1 -1
- package/dist/test-utils.global.js +1653 -1131
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1238 -341
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +1195 -300
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +0 -1
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +18 -17
package/dist/index.js
CHANGED
@@ -94,6 +94,8 @@ __export(src_exports, {
|
|
94
94
|
TransactionStatus: () => TransactionStatus,
|
95
95
|
TransactionType: () => import_transactions7.TransactionType,
|
96
96
|
TransactionTypeName: () => TransactionTypeName,
|
97
|
+
UpgradeTransactionRequest: () => UpgradeTransactionRequest,
|
98
|
+
UploadTransactionRequest: () => UploadTransactionRequest,
|
97
99
|
Vault: () => Vault,
|
98
100
|
Wallet: () => Wallet,
|
99
101
|
WalletLocked: () => WalletLocked,
|
@@ -115,6 +117,9 @@ __export(src_exports, {
|
|
115
117
|
calculateMetadataGasForTxBlob: () => calculateMetadataGasForTxBlob,
|
116
118
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
117
119
|
calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
|
120
|
+
calculateMetadataGasForTxUpgrade: () => calculateMetadataGasForTxUpgrade,
|
121
|
+
calculateMetadataGasForTxUpload: () => calculateMetadataGasForTxUpload,
|
122
|
+
calculateMinGasForTxUpload: () => calculateMinGasForTxUpload,
|
118
123
|
calculateTXFeeForSummary: () => calculateTXFeeForSummary,
|
119
124
|
coinQuantityfy: () => coinQuantityfy,
|
120
125
|
deferPromise: () => deferPromise,
|
@@ -185,6 +190,8 @@ __export(src_exports, {
|
|
185
190
|
isTransactionTypeBlob: () => isTransactionTypeBlob,
|
186
191
|
isTransactionTypeCreate: () => isTransactionTypeCreate,
|
187
192
|
isTransactionTypeScript: () => isTransactionTypeScript,
|
193
|
+
isTransactionTypeUpgrade: () => isTransactionTypeUpgrade,
|
194
|
+
isTransactionTypeUpload: () => isTransactionTypeUpload,
|
188
195
|
isType: () => isType,
|
189
196
|
isTypeBlob: () => isTypeBlob,
|
190
197
|
isTypeCreate: () => isTypeCreate,
|
@@ -211,12 +218,12 @@ module.exports = __toCommonJS(src_exports);
|
|
211
218
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
212
219
|
var import_address4 = require("@fuel-ts/address");
|
213
220
|
var import_crypto2 = require("@fuel-ts/crypto");
|
214
|
-
var
|
221
|
+
var import_errors19 = require("@fuel-ts/errors");
|
215
222
|
var import_interfaces = require("@fuel-ts/interfaces");
|
216
223
|
var import_math21 = require("@fuel-ts/math");
|
217
|
-
var
|
218
|
-
var
|
219
|
-
var
|
224
|
+
var import_transactions24 = require("@fuel-ts/transactions");
|
225
|
+
var import_utils34 = require("@fuel-ts/utils");
|
226
|
+
var import_ramda9 = require("ramda");
|
220
227
|
|
221
228
|
// src/providers/coin-quantity.ts
|
222
229
|
var import_math = require("@fuel-ts/math");
|
@@ -255,15 +262,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
255
262
|
|
256
263
|
// src/providers/provider.ts
|
257
264
|
var import_address3 = require("@fuel-ts/address");
|
258
|
-
var
|
265
|
+
var import_errors17 = require("@fuel-ts/errors");
|
259
266
|
var import_math18 = require("@fuel-ts/math");
|
260
|
-
var
|
261
|
-
var
|
267
|
+
var import_transactions22 = require("@fuel-ts/transactions");
|
268
|
+
var import_utils28 = require("@fuel-ts/utils");
|
262
269
|
var import_versions = require("@fuel-ts/versions");
|
263
|
-
var
|
270
|
+
var import_utils29 = require("@noble/curves/abstract/utils");
|
264
271
|
var import_graphql_request = require("graphql-request");
|
265
272
|
var import_graphql_tag2 = __toESM(require("graphql-tag"));
|
266
|
-
var
|
273
|
+
var import_ramda8 = require("ramda");
|
267
274
|
|
268
275
|
// src/providers/__generated__/operations.ts
|
269
276
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
@@ -1211,6 +1218,13 @@ var SubmitAndAwaitDocument = import_graphql_tag.default`
|
|
1211
1218
|
}
|
1212
1219
|
}
|
1213
1220
|
${TransactionStatusSubscriptionFragmentDoc}`;
|
1221
|
+
var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
|
1222
|
+
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1223
|
+
submitAndAwaitStatus(tx: $encodedTransaction) {
|
1224
|
+
...transactionStatusSubscriptionFragment
|
1225
|
+
}
|
1226
|
+
}
|
1227
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1214
1228
|
var StatusChangeDocument = import_graphql_tag.default`
|
1215
1229
|
subscription statusChange($transactionId: TransactionId!) {
|
1216
1230
|
statusChange(id: $transactionId) {
|
@@ -1307,6 +1321,9 @@ function getSdk(requester) {
|
|
1307
1321
|
submitAndAwait(variables, options) {
|
1308
1322
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1309
1323
|
},
|
1324
|
+
submitAndAwaitStatus(variables, options) {
|
1325
|
+
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1326
|
+
},
|
1310
1327
|
statusChange(variables, options) {
|
1311
1328
|
return requester(StatusChangeDocument, variables, options);
|
1312
1329
|
}
|
@@ -1333,7 +1350,9 @@ var _FuelGraphqlSubscriber = class {
|
|
1333
1350
|
Accept: "text/event-stream"
|
1334
1351
|
}
|
1335
1352
|
});
|
1336
|
-
|
1353
|
+
const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
|
1354
|
+
await new _FuelGraphqlSubscriber(errorReader).next();
|
1355
|
+
return new _FuelGraphqlSubscriber(resultReader);
|
1337
1356
|
}
|
1338
1357
|
events = [];
|
1339
1358
|
parsingLeftover = "";
|
@@ -1376,10 +1395,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1376
1395
|
/**
|
1377
1396
|
* Gets called when `break` is called in a `for-await-of` loop.
|
1378
1397
|
*/
|
1379
|
-
|
1380
|
-
|
1381
|
-
this.stream.releaseLock();
|
1382
|
-
return { done: true, value: void 0 };
|
1398
|
+
return() {
|
1399
|
+
return Promise.resolve({ done: true, value: void 0 });
|
1383
1400
|
}
|
1384
1401
|
[Symbol.asyncIterator]() {
|
1385
1402
|
return this;
|
@@ -1753,12 +1770,12 @@ function assembleReceiptByType(receipt) {
|
|
1753
1770
|
const amount = (0, import_math4.bn)(receipt.amount);
|
1754
1771
|
const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
|
1755
1772
|
const digest = hexOrZero(receipt.digest);
|
1756
|
-
const messageId = import_transactions3.
|
1773
|
+
const messageId = import_transactions3.InputMessageCoder.getMessageId({
|
1757
1774
|
sender,
|
1758
1775
|
recipient,
|
1759
1776
|
nonce,
|
1760
1777
|
amount,
|
1761
|
-
data
|
1778
|
+
data: (0, import_utils5.hexlify)(data)
|
1762
1779
|
});
|
1763
1780
|
const receiptMessageOut = {
|
1764
1781
|
type: import_transactions3.ReceiptType.MessageOut,
|
@@ -1775,7 +1792,7 @@ function assembleReceiptByType(receipt) {
|
|
1775
1792
|
case "MINT" /* Mint */: {
|
1776
1793
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1777
1794
|
const subId = hexOrZero(receipt.subId);
|
1778
|
-
const assetId = import_transactions3.
|
1795
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1779
1796
|
const mintReceipt = {
|
1780
1797
|
type: import_transactions3.ReceiptType.Mint,
|
1781
1798
|
subId,
|
@@ -1790,7 +1807,7 @@ function assembleReceiptByType(receipt) {
|
|
1790
1807
|
case "BURN" /* Burn */: {
|
1791
1808
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1792
1809
|
const subId = hexOrZero(receipt.subId);
|
1793
|
-
const assetId = import_transactions3.
|
1810
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1794
1811
|
const burnReceipt = {
|
1795
1812
|
type: import_transactions3.ReceiptType.Burn,
|
1796
1813
|
subId,
|
@@ -1809,7 +1826,7 @@ function assembleReceiptByType(receipt) {
|
|
1809
1826
|
|
1810
1827
|
// src/providers/utils/block-explorer.ts
|
1811
1828
|
var import_errors6 = require("@fuel-ts/errors");
|
1812
|
-
var DEFAULT_BLOCK_EXPLORER_URL = "https://
|
1829
|
+
var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
|
1813
1830
|
var getPathFromInput = (key, value) => {
|
1814
1831
|
const pathMap = {
|
1815
1832
|
address: `address`,
|
@@ -1969,6 +1986,39 @@ function calculateMetadataGasForTxBlob({
|
|
1969
1986
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
1970
1987
|
return txId.add(blobLen);
|
1971
1988
|
}
|
1989
|
+
function calculateMetadataGasForTxUpgrade({
|
1990
|
+
gasCosts,
|
1991
|
+
txBytesSize,
|
1992
|
+
consensusSize
|
1993
|
+
}) {
|
1994
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1995
|
+
if (consensusSize) {
|
1996
|
+
const consensusLen = resolveGasDependentCosts(consensusSize, gasCosts.s256);
|
1997
|
+
txId.add(consensusLen);
|
1998
|
+
}
|
1999
|
+
return txId;
|
2000
|
+
}
|
2001
|
+
function calculateMetadataGasForTxUpload({
|
2002
|
+
gasCosts,
|
2003
|
+
txBytesSize,
|
2004
|
+
subsectionSize,
|
2005
|
+
subsectionsSize
|
2006
|
+
}) {
|
2007
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2008
|
+
const subsectionLen = resolveGasDependentCosts(subsectionSize, gasCosts.s256);
|
2009
|
+
txId.add(subsectionLen);
|
2010
|
+
const subsectionsLen = resolveGasDependentCosts(subsectionsSize, gasCosts.stateRoot);
|
2011
|
+
txId.add(subsectionsLen);
|
2012
|
+
return txId;
|
2013
|
+
}
|
2014
|
+
function calculateMinGasForTxUpload({
|
2015
|
+
gasCosts,
|
2016
|
+
baseMinGas,
|
2017
|
+
subsectionSize
|
2018
|
+
}) {
|
2019
|
+
const additionalStoragePerByte = (0, import_math5.bn)(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2020
|
+
return (0, import_math5.bn)(baseMinGas).add(additionalStoragePerByte);
|
2021
|
+
}
|
1972
2022
|
var calculateGasFee = (params) => {
|
1973
2023
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1974
2024
|
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
@@ -3137,51 +3187,316 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3137
3187
|
}
|
3138
3188
|
};
|
3139
3189
|
|
3140
|
-
// src/providers/transaction-request/
|
3190
|
+
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3141
3191
|
var import_errors10 = require("@fuel-ts/errors");
|
3192
|
+
var import_hasher2 = require("@fuel-ts/hasher");
|
3142
3193
|
var import_transactions11 = require("@fuel-ts/transactions");
|
3194
|
+
var import_utils17 = require("@fuel-ts/utils");
|
3195
|
+
var import_ramda6 = require("ramda");
|
3196
|
+
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
3197
|
+
static from(obj) {
|
3198
|
+
if (obj instanceof UpgradeTransactionRequest) {
|
3199
|
+
return obj;
|
3200
|
+
}
|
3201
|
+
return new this((0, import_ramda6.clone)(obj));
|
3202
|
+
}
|
3203
|
+
/** The type of transaction */
|
3204
|
+
type = import_transactions11.TransactionType.Upgrade;
|
3205
|
+
/** The upgrade purpose */
|
3206
|
+
upgradePurpose;
|
3207
|
+
/** Witness index of consensus */
|
3208
|
+
bytecodeWitnessIndex;
|
3209
|
+
/**
|
3210
|
+
* Creates an instance `UpgradeTransactionRequest`.
|
3211
|
+
*
|
3212
|
+
* @param upgradeTransactionRequestLike - The initial values for the instance
|
3213
|
+
*/
|
3214
|
+
constructor({
|
3215
|
+
upgradePurpose,
|
3216
|
+
bytecodeWitnessIndex,
|
3217
|
+
...rest
|
3218
|
+
} = {}) {
|
3219
|
+
super(rest);
|
3220
|
+
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
3221
|
+
this.upgradePurpose = upgradePurpose ?? {
|
3222
|
+
type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
|
3223
|
+
checksum: "0x"
|
3224
|
+
};
|
3225
|
+
}
|
3226
|
+
/**
|
3227
|
+
* Adds a consensus parameters upgrade purpose.
|
3228
|
+
*
|
3229
|
+
* @param consensus - The consensus bytecode.
|
3230
|
+
*
|
3231
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3232
|
+
*/
|
3233
|
+
addConsensusParametersUpgradePurpose(consensus) {
|
3234
|
+
this.bytecodeWitnessIndex = this.addWitness(consensus);
|
3235
|
+
this.upgradePurpose = {
|
3236
|
+
type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
|
3237
|
+
checksum: (0, import_hasher2.hash)(consensus)
|
3238
|
+
};
|
3239
|
+
return this;
|
3240
|
+
}
|
3241
|
+
/**
|
3242
|
+
* Adds a state transition upgrade purpose.
|
3243
|
+
*
|
3244
|
+
* @param bytecodeRoot - The Merkle root of the state transition.
|
3245
|
+
*
|
3246
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3247
|
+
*/
|
3248
|
+
addStateTransitionUpgradePurpose(bytecodeRoot) {
|
3249
|
+
this.upgradePurpose = {
|
3250
|
+
type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
|
3251
|
+
data: (0, import_utils17.hexlify)(bytecodeRoot)
|
3252
|
+
};
|
3253
|
+
return this;
|
3254
|
+
}
|
3255
|
+
/**
|
3256
|
+
* Adds an upgrade purpose.
|
3257
|
+
*
|
3258
|
+
* @param type - The upgrade purpose type.
|
3259
|
+
* @param data - The bytecode or merkle root of upgrade purpose
|
3260
|
+
*
|
3261
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3262
|
+
*/
|
3263
|
+
addUpgradePurpose(type, data) {
|
3264
|
+
if (type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
|
3265
|
+
this.addConsensusParametersUpgradePurpose(data);
|
3266
|
+
}
|
3267
|
+
if (type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
|
3268
|
+
this.addStateTransitionUpgradePurpose(data);
|
3269
|
+
}
|
3270
|
+
return this;
|
3271
|
+
}
|
3272
|
+
/**
|
3273
|
+
* Converts the transaction request to a `TransactionUpgrade`.
|
3274
|
+
*
|
3275
|
+
* @returns The transaction create object.
|
3276
|
+
*/
|
3277
|
+
toTransaction() {
|
3278
|
+
let upgradePurpose;
|
3279
|
+
if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
|
3280
|
+
upgradePurpose = {
|
3281
|
+
type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
|
3282
|
+
data: {
|
3283
|
+
witnessIndex: this.bytecodeWitnessIndex,
|
3284
|
+
checksum: this.upgradePurpose.checksum
|
3285
|
+
}
|
3286
|
+
};
|
3287
|
+
} else if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
|
3288
|
+
upgradePurpose = {
|
3289
|
+
type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
|
3290
|
+
data: {
|
3291
|
+
bytecodeRoot: (0, import_utils17.hexlify)(this.upgradePurpose.data)
|
3292
|
+
}
|
3293
|
+
};
|
3294
|
+
} else {
|
3295
|
+
throw new import_errors10.FuelError(import_errors10.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3296
|
+
}
|
3297
|
+
return {
|
3298
|
+
type: import_transactions11.TransactionType.Upgrade,
|
3299
|
+
...super.getBaseTransaction(),
|
3300
|
+
upgradePurpose
|
3301
|
+
};
|
3302
|
+
}
|
3303
|
+
/**
|
3304
|
+
* Gets the Transaction ID by hashing the transaction
|
3305
|
+
*
|
3306
|
+
* @param chainId - The chain ID.
|
3307
|
+
*
|
3308
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3309
|
+
*/
|
3310
|
+
getTransactionId(chainId) {
|
3311
|
+
return hashTransaction(this, chainId);
|
3312
|
+
}
|
3313
|
+
/**
|
3314
|
+
* Calculates the metadata gas cost for an upgrade transaction.
|
3315
|
+
*
|
3316
|
+
* @param gasCosts - gas costs passed from the chain.
|
3317
|
+
*
|
3318
|
+
* @returns metadata gas cost for the upgrade transaction.
|
3319
|
+
*/
|
3320
|
+
metadataGas(gasCosts) {
|
3321
|
+
const txBytesSize = this.byteSize();
|
3322
|
+
if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
|
3323
|
+
const witnessIndex = this.bytecodeWitnessIndex;
|
3324
|
+
const consensusSize = this.witnesses[witnessIndex].length;
|
3325
|
+
return calculateMetadataGasForTxUpgrade({
|
3326
|
+
gasCosts,
|
3327
|
+
txBytesSize,
|
3328
|
+
consensusSize
|
3329
|
+
});
|
3330
|
+
}
|
3331
|
+
if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
|
3332
|
+
return calculateMetadataGasForTxUpgrade({
|
3333
|
+
gasCosts,
|
3334
|
+
txBytesSize
|
3335
|
+
});
|
3336
|
+
}
|
3337
|
+
throw new import_errors10.FuelError(import_errors10.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3338
|
+
}
|
3339
|
+
};
|
3340
|
+
|
3341
|
+
// src/providers/transaction-request/upload-transaction-request.ts
|
3342
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
3343
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
3344
|
+
var import_utils19 = require("@fuel-ts/utils");
|
3345
|
+
var import_ramda7 = require("ramda");
|
3346
|
+
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
3347
|
+
static from(obj) {
|
3348
|
+
if (obj instanceof UploadTransactionRequest) {
|
3349
|
+
return obj;
|
3350
|
+
}
|
3351
|
+
return new this((0, import_ramda7.clone)(obj));
|
3352
|
+
}
|
3353
|
+
/** Type of the transaction */
|
3354
|
+
type = import_transactions12.TransactionType.Upload;
|
3355
|
+
/** The witness index of the subsection of the bytecode. */
|
3356
|
+
witnessIndex;
|
3357
|
+
/** The subsection data. */
|
3358
|
+
subsection;
|
3359
|
+
/**
|
3360
|
+
* Creates an instance `UploadTransactionRequest`.
|
3361
|
+
*
|
3362
|
+
* @param uploadTransactionRequestLike - The initial values for the instance
|
3363
|
+
*/
|
3364
|
+
constructor({ witnessIndex, subsection, ...rest } = {}) {
|
3365
|
+
super(rest);
|
3366
|
+
this.witnessIndex = witnessIndex ?? 0;
|
3367
|
+
this.subsection = subsection ?? {
|
3368
|
+
proofSet: [],
|
3369
|
+
root: import_configs10.ZeroBytes32,
|
3370
|
+
subsectionIndex: 0,
|
3371
|
+
subsectionsNumber: 0
|
3372
|
+
};
|
3373
|
+
}
|
3374
|
+
/**
|
3375
|
+
* Adds the subsection.
|
3376
|
+
*
|
3377
|
+
* @param subsection - The subsection data.
|
3378
|
+
*/
|
3379
|
+
addSubsection(subsection) {
|
3380
|
+
const { subsection: subsectionBytecode, ...rest } = subsection;
|
3381
|
+
this.subsection = rest;
|
3382
|
+
this.witnessIndex = this.addWitness(subsectionBytecode);
|
3383
|
+
}
|
3384
|
+
/**
|
3385
|
+
* Gets the Transaction Request by hashing the transaction.
|
3386
|
+
*
|
3387
|
+
* @param chainId - The chain ID.
|
3388
|
+
*
|
3389
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3390
|
+
*/
|
3391
|
+
getTransactionId(chainId) {
|
3392
|
+
return hashTransaction(this, chainId);
|
3393
|
+
}
|
3394
|
+
/**
|
3395
|
+
* Converts the transaction request to a `TransactionUpload`.
|
3396
|
+
*
|
3397
|
+
* @returns The transaction create object.
|
3398
|
+
*/
|
3399
|
+
toTransaction() {
|
3400
|
+
const baseTransaction = this.getBaseTransaction();
|
3401
|
+
const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
|
3402
|
+
return {
|
3403
|
+
type: import_transactions12.TransactionType.Upload,
|
3404
|
+
...baseTransaction,
|
3405
|
+
subsectionIndex,
|
3406
|
+
subsectionsNumber,
|
3407
|
+
root: (0, import_utils19.hexlify)(root),
|
3408
|
+
proofSet: proofSet.map(import_utils19.hexlify),
|
3409
|
+
witnessIndex: this.witnessIndex,
|
3410
|
+
proofSetCount: proofSet.length
|
3411
|
+
};
|
3412
|
+
}
|
3413
|
+
/**
|
3414
|
+
* Calculates the metadata gas cost for an upload transaction.
|
3415
|
+
*
|
3416
|
+
* @param gasCosts - gas costs passed from the chain.
|
3417
|
+
*
|
3418
|
+
* @returns metadata gas cost for the upload transaction.
|
3419
|
+
*/
|
3420
|
+
metadataGas(gasCosts) {
|
3421
|
+
return calculateMetadataGasForTxUpload({
|
3422
|
+
gasCosts,
|
3423
|
+
txBytesSize: this.byteSize(),
|
3424
|
+
subsectionSize: (0, import_utils19.arrayify)(this.witnesses[this.witnessIndex]).length,
|
3425
|
+
subsectionsSize: this.subsection.subsectionsNumber
|
3426
|
+
});
|
3427
|
+
}
|
3428
|
+
/**
|
3429
|
+
* Calculates the minimum gas for an upload transaction.
|
3430
|
+
*
|
3431
|
+
* @param chainInfo - The chain information.
|
3432
|
+
*
|
3433
|
+
* @returns the minimum gas for the upload transaction
|
3434
|
+
*/
|
3435
|
+
calculateMinGas(chainInfo) {
|
3436
|
+
const minGas = super.calculateMinGas(chainInfo);
|
3437
|
+
const { gasCosts } = chainInfo.consensusParameters;
|
3438
|
+
const bytecode = this.witnesses[this.witnessIndex] ?? import_configs10.ZeroBytes32;
|
3439
|
+
return calculateMinGasForTxUpload({
|
3440
|
+
gasCosts,
|
3441
|
+
baseMinGas: minGas.toNumber(),
|
3442
|
+
subsectionSize: (0, import_utils19.arrayify)(bytecode).length
|
3443
|
+
});
|
3444
|
+
}
|
3445
|
+
};
|
3446
|
+
|
3447
|
+
// src/providers/transaction-request/utils.ts
|
3448
|
+
var import_errors11 = require("@fuel-ts/errors");
|
3449
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
3143
3450
|
var transactionRequestify = (obj) => {
|
3144
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
3451
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
3145
3452
|
return obj;
|
3146
3453
|
}
|
3147
3454
|
const { type } = obj;
|
3148
3455
|
switch (obj.type) {
|
3149
|
-
case
|
3456
|
+
case import_transactions13.TransactionType.Script: {
|
3150
3457
|
return ScriptTransactionRequest.from(obj);
|
3151
3458
|
}
|
3152
|
-
case
|
3459
|
+
case import_transactions13.TransactionType.Create: {
|
3153
3460
|
return CreateTransactionRequest.from(obj);
|
3154
3461
|
}
|
3155
|
-
case
|
3462
|
+
case import_transactions13.TransactionType.Blob: {
|
3156
3463
|
return BlobTransactionRequest.from(obj);
|
3157
3464
|
}
|
3465
|
+
case import_transactions13.TransactionType.Upgrade: {
|
3466
|
+
return UpgradeTransactionRequest.from(obj);
|
3467
|
+
}
|
3468
|
+
case import_transactions13.TransactionType.Upload: {
|
3469
|
+
return UploadTransactionRequest.from(obj);
|
3470
|
+
}
|
3158
3471
|
default: {
|
3159
|
-
throw new
|
3160
|
-
|
3472
|
+
throw new import_errors11.FuelError(
|
3473
|
+
import_errors11.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3161
3474
|
`Unsupported transaction type: ${type}.`
|
3162
3475
|
);
|
3163
3476
|
}
|
3164
3477
|
}
|
3165
3478
|
};
|
3166
|
-
var isTransactionTypeScript = (request) => request.type ===
|
3167
|
-
var isTransactionTypeCreate = (request) => request.type ===
|
3168
|
-
var isTransactionTypeBlob = (request) => request.type ===
|
3479
|
+
var isTransactionTypeScript = (request) => request.type === import_transactions13.TransactionType.Script;
|
3480
|
+
var isTransactionTypeCreate = (request) => request.type === import_transactions13.TransactionType.Create;
|
3481
|
+
var isTransactionTypeBlob = (request) => request.type === import_transactions13.TransactionType.Blob;
|
3482
|
+
var isTransactionTypeUpgrade = (request) => request.type === import_transactions13.TransactionType.Upgrade;
|
3483
|
+
var isTransactionTypeUpload = (request) => request.type === import_transactions13.TransactionType.Upload;
|
3169
3484
|
|
3170
3485
|
// src/providers/transaction-response/transaction-response.ts
|
3171
|
-
var
|
3486
|
+
var import_errors15 = require("@fuel-ts/errors");
|
3172
3487
|
var import_math17 = require("@fuel-ts/math");
|
3173
|
-
var
|
3174
|
-
var
|
3488
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
3489
|
+
var import_utils25 = require("@fuel-ts/utils");
|
3175
3490
|
|
3176
3491
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3177
3492
|
var import_math16 = require("@fuel-ts/math");
|
3178
|
-
var
|
3179
|
-
var
|
3493
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
3494
|
+
var import_utils23 = require("@fuel-ts/utils");
|
3180
3495
|
|
3181
3496
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3182
3497
|
var import_math12 = require("@fuel-ts/math");
|
3183
|
-
var
|
3184
|
-
var
|
3498
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
3499
|
+
var import_utils21 = require("@fuel-ts/utils");
|
3185
3500
|
var calculateTXFeeForSummary = (params) => {
|
3186
3501
|
const {
|
3187
3502
|
gasPrice,
|
@@ -3195,17 +3510,17 @@ var calculateTXFeeForSummary = (params) => {
|
|
3195
3510
|
}
|
3196
3511
|
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
3197
3512
|
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
3198
|
-
const transactionBytes = (0,
|
3199
|
-
const [transaction] = new
|
3513
|
+
const transactionBytes = (0, import_utils21.arrayify)(rawPayload);
|
3514
|
+
const [transaction] = new import_transactions14.TransactionCoder().decode(transactionBytes, 0);
|
3200
3515
|
const { type, witnesses, inputs, policies } = transaction;
|
3201
3516
|
let metadataGas = (0, import_math12.bn)(0);
|
3202
3517
|
let gasLimit = (0, import_math12.bn)(0);
|
3203
|
-
if (type !==
|
3518
|
+
if (type !== import_transactions14.TransactionType.Create && type !== import_transactions14.TransactionType.Script) {
|
3204
3519
|
return (0, import_math12.bn)(0);
|
3205
3520
|
}
|
3206
|
-
if (type ===
|
3521
|
+
if (type === import_transactions14.TransactionType.Create) {
|
3207
3522
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3208
|
-
const contractBytesSize = (0, import_math12.bn)((0,
|
3523
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils21.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
3209
3524
|
metadataGas = calculateMetadataGasForTxCreate({
|
3210
3525
|
contractBytesSize,
|
3211
3526
|
gasCosts,
|
@@ -3229,7 +3544,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3229
3544
|
metadataGas,
|
3230
3545
|
txBytesSize: transactionBytes.length
|
3231
3546
|
});
|
3232
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
3547
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions14.PolicyType.WitnessLimit)?.data;
|
3233
3548
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
3234
3549
|
const maxGas = getMaxGas({
|
3235
3550
|
gasPerByte,
|
@@ -3249,10 +3564,10 @@ var calculateTXFeeForSummary = (params) => {
|
|
3249
3564
|
};
|
3250
3565
|
|
3251
3566
|
// src/providers/transaction-summary/operations.ts
|
3252
|
-
var
|
3253
|
-
var
|
3567
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
3568
|
+
var import_errors13 = require("@fuel-ts/errors");
|
3254
3569
|
var import_math14 = require("@fuel-ts/math");
|
3255
|
-
var
|
3570
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
3256
3571
|
|
3257
3572
|
// src/providers/transaction-summary/call.ts
|
3258
3573
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
@@ -3288,9 +3603,9 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3288
3603
|
};
|
3289
3604
|
|
3290
3605
|
// src/providers/transaction-summary/input.ts
|
3291
|
-
var
|
3606
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3292
3607
|
var import_math13 = require("@fuel-ts/math");
|
3293
|
-
var
|
3608
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
3294
3609
|
function getInputsByTypes(inputs, types) {
|
3295
3610
|
return inputs.filter((i) => types.includes(i.type));
|
3296
3611
|
}
|
@@ -3298,19 +3613,19 @@ function getInputsByType(inputs, type) {
|
|
3298
3613
|
return inputs.filter((i) => i.type === type);
|
3299
3614
|
}
|
3300
3615
|
function getInputsCoin(inputs) {
|
3301
|
-
return getInputsByType(inputs,
|
3616
|
+
return getInputsByType(inputs, import_transactions15.InputType.Coin);
|
3302
3617
|
}
|
3303
3618
|
function getInputsMessage(inputs) {
|
3304
|
-
return getInputsByType(inputs,
|
3619
|
+
return getInputsByType(inputs, import_transactions15.InputType.Message);
|
3305
3620
|
}
|
3306
3621
|
function getInputsCoinAndMessage(inputs) {
|
3307
|
-
return getInputsByTypes(inputs, [
|
3622
|
+
return getInputsByTypes(inputs, [import_transactions15.InputType.Coin, import_transactions15.InputType.Message]);
|
3308
3623
|
}
|
3309
3624
|
function isInputCoin(input) {
|
3310
|
-
return input.type ===
|
3625
|
+
return input.type === import_transactions15.InputType.Coin;
|
3311
3626
|
}
|
3312
3627
|
function getInputsContract(inputs) {
|
3313
|
-
return getInputsByType(inputs,
|
3628
|
+
return getInputsByType(inputs, import_transactions15.InputType.Contract);
|
3314
3629
|
}
|
3315
3630
|
function findCoinInput(inputs, assetId) {
|
3316
3631
|
const coinInputs = getInputsCoin(inputs);
|
@@ -3356,43 +3671,43 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3356
3671
|
if (!contractInput) {
|
3357
3672
|
return void 0;
|
3358
3673
|
}
|
3359
|
-
if (contractInput.type !==
|
3360
|
-
throw new
|
3361
|
-
|
3674
|
+
if (contractInput.type !== import_transactions15.InputType.Contract) {
|
3675
|
+
throw new import_errors12.FuelError(
|
3676
|
+
import_errors12.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3362
3677
|
`Contract input should be of type 'contract'.`
|
3363
3678
|
);
|
3364
3679
|
}
|
3365
3680
|
return contractInput;
|
3366
3681
|
}
|
3367
3682
|
function getInputAccountAddress(input) {
|
3368
|
-
if (input.type ===
|
3683
|
+
if (input.type === import_transactions15.InputType.Coin) {
|
3369
3684
|
return input.owner.toString();
|
3370
3685
|
}
|
3371
|
-
if (input.type ===
|
3686
|
+
if (input.type === import_transactions15.InputType.Message) {
|
3372
3687
|
return input.recipient.toString();
|
3373
3688
|
}
|
3374
3689
|
return "";
|
3375
3690
|
}
|
3376
3691
|
|
3377
3692
|
// src/providers/transaction-summary/output.ts
|
3378
|
-
var
|
3693
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3379
3694
|
function getOutputsByType(outputs, type) {
|
3380
3695
|
return outputs.filter((o) => o.type === type);
|
3381
3696
|
}
|
3382
3697
|
function getOutputsContractCreated(outputs) {
|
3383
|
-
return getOutputsByType(outputs,
|
3698
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.ContractCreated);
|
3384
3699
|
}
|
3385
3700
|
function getOutputsCoin(outputs) {
|
3386
|
-
return getOutputsByType(outputs,
|
3701
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Coin);
|
3387
3702
|
}
|
3388
3703
|
function getOutputsChange(outputs) {
|
3389
|
-
return getOutputsByType(outputs,
|
3704
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Change);
|
3390
3705
|
}
|
3391
3706
|
function getOutputsContract(outputs) {
|
3392
|
-
return getOutputsByType(outputs,
|
3707
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Contract);
|
3393
3708
|
}
|
3394
3709
|
function getOutputsVariable(outputs) {
|
3395
|
-
return getOutputsByType(outputs,
|
3710
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Variable);
|
3396
3711
|
}
|
3397
3712
|
|
3398
3713
|
// src/providers/transaction-summary/types.ts
|
@@ -3442,17 +3757,21 @@ function getReceiptsByType(receipts, type) {
|
|
3442
3757
|
}
|
3443
3758
|
function getTransactionTypeName(transactionType) {
|
3444
3759
|
switch (transactionType) {
|
3445
|
-
case
|
3760
|
+
case import_transactions17.TransactionType.Mint:
|
3446
3761
|
return "Mint" /* Mint */;
|
3447
|
-
case
|
3762
|
+
case import_transactions17.TransactionType.Create:
|
3448
3763
|
return "Create" /* Create */;
|
3449
|
-
case
|
3764
|
+
case import_transactions17.TransactionType.Script:
|
3450
3765
|
return "Script" /* Script */;
|
3451
|
-
case
|
3766
|
+
case import_transactions17.TransactionType.Blob:
|
3452
3767
|
return "Blob" /* Blob */;
|
3768
|
+
case import_transactions17.TransactionType.Upgrade:
|
3769
|
+
return "Upgrade" /* Upgrade */;
|
3770
|
+
case import_transactions17.TransactionType.Upload:
|
3771
|
+
return "Upload" /* Upload */;
|
3453
3772
|
default:
|
3454
|
-
throw new
|
3455
|
-
|
3773
|
+
throw new import_errors13.FuelError(
|
3774
|
+
import_errors13.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3456
3775
|
`Unsupported transaction type: ${transactionType}.`
|
3457
3776
|
);
|
3458
3777
|
}
|
@@ -3483,10 +3802,10 @@ function hasSameAssetId(a) {
|
|
3483
3802
|
return (b) => a.assetId === b.assetId;
|
3484
3803
|
}
|
3485
3804
|
function getReceiptsCall(receipts) {
|
3486
|
-
return getReceiptsByType(receipts,
|
3805
|
+
return getReceiptsByType(receipts, import_transactions17.ReceiptType.Call);
|
3487
3806
|
}
|
3488
3807
|
function getReceiptsMessageOut(receipts) {
|
3489
|
-
return getReceiptsByType(receipts,
|
3808
|
+
return getReceiptsByType(receipts, import_transactions17.ReceiptType.MessageOut);
|
3490
3809
|
}
|
3491
3810
|
function mergeAssets(op1, op2) {
|
3492
3811
|
const assets1 = op1.assetsSent || [];
|
@@ -3535,7 +3854,7 @@ function addOperation(operations, toAdd) {
|
|
3535
3854
|
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
3536
3855
|
}
|
3537
3856
|
function getReceiptsTransferOut(receipts) {
|
3538
|
-
return getReceiptsByType(receipts,
|
3857
|
+
return getReceiptsByType(receipts, import_transactions17.ReceiptType.TransferOut);
|
3539
3858
|
}
|
3540
3859
|
function getWithdrawFromFuelOperations({
|
3541
3860
|
inputs,
|
@@ -3597,7 +3916,7 @@ function getAssetsSent(receipt) {
|
|
3597
3916
|
];
|
3598
3917
|
}
|
3599
3918
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3600
|
-
const assetId = receipt.assetId ===
|
3919
|
+
const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
|
3601
3920
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3602
3921
|
if (!input) {
|
3603
3922
|
return [];
|
@@ -3653,7 +3972,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3653
3972
|
const { to: toAddress, assetId, amount } = receipt;
|
3654
3973
|
let { from: fromAddress } = receipt;
|
3655
3974
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3656
|
-
if (
|
3975
|
+
if (import_configs11.ZeroBytes32 === fromAddress) {
|
3657
3976
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3658
3977
|
fromAddress = change?.to || fromAddress;
|
3659
3978
|
}
|
@@ -3718,11 +4037,11 @@ function getTransferOperations({
|
|
3718
4037
|
});
|
3719
4038
|
const transferReceipts = getReceiptsByType(
|
3720
4039
|
receipts,
|
3721
|
-
|
4040
|
+
import_transactions17.ReceiptType.Transfer
|
3722
4041
|
);
|
3723
4042
|
const transferOutReceipts = getReceiptsByType(
|
3724
4043
|
receipts,
|
3725
|
-
|
4044
|
+
import_transactions17.ReceiptType.TransferOut
|
3726
4045
|
);
|
3727
4046
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3728
4047
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3806,17 +4125,17 @@ function getOperations({
|
|
3806
4125
|
}
|
3807
4126
|
|
3808
4127
|
// src/providers/transaction-summary/receipt.ts
|
3809
|
-
var
|
4128
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
3810
4129
|
var processGqlReceipt = (gqlReceipt) => {
|
3811
4130
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3812
4131
|
switch (receipt.type) {
|
3813
|
-
case
|
4132
|
+
case import_transactions18.ReceiptType.ReturnData: {
|
3814
4133
|
return {
|
3815
4134
|
...receipt,
|
3816
4135
|
data: gqlReceipt.data || "0x"
|
3817
4136
|
};
|
3818
4137
|
}
|
3819
|
-
case
|
4138
|
+
case import_transactions18.ReceiptType.LogData: {
|
3820
4139
|
return {
|
3821
4140
|
...receipt,
|
3822
4141
|
data: gqlReceipt.data || "0x"
|
@@ -3829,7 +4148,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3829
4148
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3830
4149
|
const mintedAssets = [];
|
3831
4150
|
receipts.forEach((receipt) => {
|
3832
|
-
if (receipt.type ===
|
4151
|
+
if (receipt.type === import_transactions18.ReceiptType.Mint) {
|
3833
4152
|
mintedAssets.push({
|
3834
4153
|
subId: receipt.subId,
|
3835
4154
|
contractId: receipt.contractId,
|
@@ -3843,7 +4162,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3843
4162
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3844
4163
|
const burnedAssets = [];
|
3845
4164
|
receipts.forEach((receipt) => {
|
3846
|
-
if (receipt.type ===
|
4165
|
+
if (receipt.type === import_transactions18.ReceiptType.Burn) {
|
3847
4166
|
burnedAssets.push({
|
3848
4167
|
subId: receipt.subId,
|
3849
4168
|
contractId: receipt.contractId,
|
@@ -3856,7 +4175,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3856
4175
|
};
|
3857
4176
|
|
3858
4177
|
// src/providers/transaction-summary/status.ts
|
3859
|
-
var
|
4178
|
+
var import_errors14 = require("@fuel-ts/errors");
|
3860
4179
|
var import_math15 = require("@fuel-ts/math");
|
3861
4180
|
var getTransactionStatusName = (gqlStatus) => {
|
3862
4181
|
switch (gqlStatus) {
|
@@ -3869,8 +4188,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3869
4188
|
case "SqueezedOutStatus":
|
3870
4189
|
return "squeezedout" /* squeezedout */;
|
3871
4190
|
default:
|
3872
|
-
throw new
|
3873
|
-
|
4191
|
+
throw new import_errors14.FuelError(
|
4192
|
+
import_errors14.ErrorCode.INVALID_TRANSACTION_STATUS,
|
3874
4193
|
`Invalid transaction status: ${gqlStatus}.`
|
3875
4194
|
);
|
3876
4195
|
}
|
@@ -3939,7 +4258,7 @@ function assembleTransactionSummary(params) {
|
|
3939
4258
|
baseAssetId
|
3940
4259
|
} = params;
|
3941
4260
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3942
|
-
const rawPayload = (0,
|
4261
|
+
const rawPayload = (0, import_utils23.hexlify)(transactionBytes);
|
3943
4262
|
const operations = getOperations({
|
3944
4263
|
transactionType: transaction.type,
|
3945
4264
|
inputs: transaction.inputs || [],
|
@@ -3951,7 +4270,7 @@ function assembleTransactionSummary(params) {
|
|
3951
4270
|
baseAssetId
|
3952
4271
|
});
|
3953
4272
|
const typeName = getTransactionTypeName(transaction.type);
|
3954
|
-
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type ===
|
4273
|
+
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions19.PolicyType.Tip)?.data);
|
3955
4274
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3956
4275
|
const fee = calculateTXFeeForSummary({
|
3957
4276
|
totalFee,
|
@@ -3971,7 +4290,7 @@ function assembleTransactionSummary(params) {
|
|
3971
4290
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3972
4291
|
let date;
|
3973
4292
|
if (time) {
|
3974
|
-
date =
|
4293
|
+
date = import_utils23.DateTime.fromTai64(time);
|
3975
4294
|
}
|
3976
4295
|
const transactionSummary = {
|
3977
4296
|
id,
|
@@ -4003,12 +4322,12 @@ function assembleTransactionSummary(params) {
|
|
4003
4322
|
|
4004
4323
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4005
4324
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
4006
|
-
var
|
4325
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
4007
4326
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
4008
4327
|
return receipts.reduce((logs, receipt) => {
|
4009
|
-
if (receipt.type ===
|
4328
|
+
if (receipt.type === import_transactions20.ReceiptType.LogData || receipt.type === import_transactions20.ReceiptType.Log) {
|
4010
4329
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
4011
|
-
const data = receipt.type ===
|
4330
|
+
const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
4012
4331
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
|
4013
4332
|
logs.push(decodedLog);
|
4014
4333
|
}
|
@@ -4022,55 +4341,56 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4022
4341
|
const obj = "amount" in o ? { ...o, amount: (0, import_math17.bn)(o.amount) } : o;
|
4023
4342
|
switch (obj.type) {
|
4024
4343
|
case "CoinOutput":
|
4025
|
-
return { ...obj, type:
|
4344
|
+
return { ...obj, type: import_transactions21.OutputType.Coin };
|
4026
4345
|
case "ContractOutput":
|
4027
4346
|
return {
|
4028
4347
|
...obj,
|
4029
|
-
type:
|
4348
|
+
type: import_transactions21.OutputType.Contract,
|
4030
4349
|
inputIndex: parseInt(obj.inputIndex, 10)
|
4031
4350
|
};
|
4032
4351
|
case "ChangeOutput":
|
4033
4352
|
return {
|
4034
4353
|
...obj,
|
4035
|
-
type:
|
4354
|
+
type: import_transactions21.OutputType.Change
|
4036
4355
|
};
|
4037
4356
|
case "VariableOutput":
|
4038
|
-
return { ...obj, type:
|
4357
|
+
return { ...obj, type: import_transactions21.OutputType.Variable };
|
4039
4358
|
case "ContractCreated":
|
4040
4359
|
return {
|
4041
4360
|
...obj,
|
4042
|
-
type:
|
4361
|
+
type: import_transactions21.OutputType.ContractCreated,
|
4043
4362
|
contractId: obj.contract
|
4044
4363
|
};
|
4045
4364
|
default:
|
4046
|
-
return (0,
|
4365
|
+
return (0, import_utils25.assertUnreachable)(obj);
|
4047
4366
|
}
|
4048
4367
|
});
|
4049
4368
|
}
|
4050
4369
|
var TransactionResponse = class {
|
4051
|
-
/** Transaction ID */
|
4052
|
-
id;
|
4053
|
-
/** Current provider */
|
4054
|
-
provider;
|
4055
|
-
/** Gas used on the transaction */
|
4056
|
-
gasUsed = (0, import_math17.bn)(0);
|
4057
|
-
/** The graphql Transaction with receipts object. */
|
4058
|
-
gqlTransaction;
|
4059
|
-
request;
|
4060
|
-
status;
|
4061
|
-
abis;
|
4062
4370
|
/**
|
4063
4371
|
* Constructor for `TransactionResponse`.
|
4064
4372
|
*
|
4065
4373
|
* @param tx - The transaction ID or TransactionRequest.
|
4066
4374
|
* @param provider - The provider.
|
4067
4375
|
*/
|
4068
|
-
constructor(tx, provider, abis) {
|
4376
|
+
constructor(tx, provider, abis, submitTxSubscription) {
|
4377
|
+
this.submitTxSubscription = submitTxSubscription;
|
4069
4378
|
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
4070
4379
|
this.provider = provider;
|
4071
4380
|
this.abis = abis;
|
4072
4381
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4073
4382
|
}
|
4383
|
+
/** Transaction ID */
|
4384
|
+
id;
|
4385
|
+
/** Current provider */
|
4386
|
+
provider;
|
4387
|
+
/** Gas used on the transaction */
|
4388
|
+
gasUsed = (0, import_math17.bn)(0);
|
4389
|
+
/** The graphql Transaction with receipts object. */
|
4390
|
+
gqlTransaction;
|
4391
|
+
request;
|
4392
|
+
status;
|
4393
|
+
abis;
|
4074
4394
|
/**
|
4075
4395
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
4076
4396
|
* an instance of `TransactionResponse` and wait for the transaction to be fetched
|
@@ -4096,7 +4416,7 @@ var TransactionResponse = class {
|
|
4096
4416
|
const correspondingInput = status.transaction.inputs?.[idx];
|
4097
4417
|
return {
|
4098
4418
|
...input,
|
4099
|
-
txPointer:
|
4419
|
+
txPointer: import_transactions21.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
|
4100
4420
|
};
|
4101
4421
|
}
|
4102
4422
|
return input;
|
@@ -4119,7 +4439,7 @@ var TransactionResponse = class {
|
|
4119
4439
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
4120
4440
|
return {
|
4121
4441
|
tx: this.decodeTransaction(gqlTransaction),
|
4122
|
-
bytes: (0,
|
4442
|
+
bytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload)
|
4123
4443
|
};
|
4124
4444
|
}
|
4125
4445
|
getReceipts() {
|
@@ -4163,8 +4483,8 @@ var TransactionResponse = class {
|
|
4163
4483
|
* @returns The decoded transaction.
|
4164
4484
|
*/
|
4165
4485
|
decodeTransaction(transactionWithReceipts) {
|
4166
|
-
return new
|
4167
|
-
(0,
|
4486
|
+
return new import_transactions21.TransactionCoder().decode(
|
4487
|
+
(0, import_utils25.arrayify)(transactionWithReceipts.rawPayload),
|
4168
4488
|
0
|
4169
4489
|
)?.[0];
|
4170
4490
|
}
|
@@ -4203,15 +4523,16 @@ var TransactionResponse = class {
|
|
4203
4523
|
if (status && status !== "SubmittedStatus") {
|
4204
4524
|
return;
|
4205
4525
|
}
|
4206
|
-
const subscription = await this.provider.operations.statusChange({
|
4526
|
+
const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
|
4207
4527
|
transactionId: this.id
|
4208
4528
|
});
|
4209
|
-
for await (const
|
4529
|
+
for await (const sub of subscription) {
|
4530
|
+
const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
|
4210
4531
|
this.status = statusChange;
|
4211
4532
|
if (statusChange.type === "SqueezedOutStatus") {
|
4212
4533
|
this.unsetResourceCache();
|
4213
|
-
throw new
|
4214
|
-
|
4534
|
+
throw new import_errors15.FuelError(
|
4535
|
+
import_errors15.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
4215
4536
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4216
4537
|
);
|
4217
4538
|
}
|
@@ -4282,7 +4603,7 @@ var TransactionResponse = class {
|
|
4282
4603
|
};
|
4283
4604
|
|
4284
4605
|
// src/providers/utils/auto-retry-fetch.ts
|
4285
|
-
var
|
4606
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4286
4607
|
function getWaitDelay(options, retryAttemptNum) {
|
4287
4608
|
const duration = options.baseDelay ?? 150;
|
4288
4609
|
switch (options.backoff) {
|
@@ -4312,25 +4633,25 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4312
4633
|
throw error;
|
4313
4634
|
}
|
4314
4635
|
const delay = getWaitDelay(options, retryNum);
|
4315
|
-
await (0,
|
4636
|
+
await (0, import_utils27.sleep)(delay);
|
4316
4637
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
4317
4638
|
}
|
4318
4639
|
};
|
4319
4640
|
}
|
4320
4641
|
|
4321
4642
|
// src/providers/utils/handle-gql-error-message.ts
|
4322
|
-
var
|
4643
|
+
var import_errors16 = require("@fuel-ts/errors");
|
4323
4644
|
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4324
4645
|
switch (errorMessage) {
|
4325
4646
|
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4326
|
-
throw new
|
4327
|
-
|
4647
|
+
throw new import_errors16.FuelError(
|
4648
|
+
import_errors16.ErrorCode.NOT_ENOUGH_FUNDS,
|
4328
4649
|
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4329
4650
|
{},
|
4330
4651
|
rawError
|
4331
4652
|
);
|
4332
4653
|
default:
|
4333
|
-
throw new
|
4654
|
+
throw new import_errors16.FuelError(import_errors16.ErrorCode.INVALID_REQUEST, errorMessage);
|
4334
4655
|
}
|
4335
4656
|
};
|
4336
4657
|
|
@@ -4412,24 +4733,34 @@ var _Provider = class {
|
|
4412
4733
|
* @hidden
|
4413
4734
|
*/
|
4414
4735
|
constructor(url, options = {}) {
|
4415
|
-
this.url = url;
|
4416
4736
|
/**
|
4417
4737
|
* @hidden
|
4418
4738
|
*/
|
4419
4739
|
__privateAdd(this, _cacheInputs);
|
4420
4740
|
__publicField(this, "operations");
|
4421
4741
|
__publicField(this, "cache");
|
4742
|
+
/** @hidden */
|
4743
|
+
__publicField(this, "url");
|
4744
|
+
/** @hidden */
|
4745
|
+
__publicField(this, "urlWithoutAuth");
|
4422
4746
|
__publicField(this, "options", {
|
4423
4747
|
timeout: void 0,
|
4424
4748
|
resourceCacheTTL: void 0,
|
4425
4749
|
fetch: void 0,
|
4426
|
-
retryOptions: void 0
|
4750
|
+
retryOptions: void 0,
|
4751
|
+
headers: void 0
|
4427
4752
|
});
|
4753
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4754
|
+
this.url = rawUrl;
|
4755
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4428
4756
|
this.options = { ...this.options, ...options };
|
4429
4757
|
this.url = url;
|
4758
|
+
if (headers) {
|
4759
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4760
|
+
}
|
4430
4761
|
this.operations = this.createOperations();
|
4431
4762
|
const { resourceCacheTTL } = this.options;
|
4432
|
-
if ((0,
|
4763
|
+
if ((0, import_utils28.isDefined)(resourceCacheTTL)) {
|
4433
4764
|
if (resourceCacheTTL !== -1) {
|
4434
4765
|
this.cache = new ResourceCache(resourceCacheTTL);
|
4435
4766
|
} else {
|
@@ -4448,12 +4779,16 @@ var _Provider = class {
|
|
4448
4779
|
* @hidden
|
4449
4780
|
*/
|
4450
4781
|
static getFetchFn(options) {
|
4451
|
-
const { retryOptions, timeout } = options;
|
4782
|
+
const { retryOptions, timeout, headers } = options;
|
4452
4783
|
return autoRetryFetch(async (...args) => {
|
4453
4784
|
const url = args[0];
|
4454
4785
|
const request = args[1];
|
4455
4786
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
4456
|
-
let fullRequest = {
|
4787
|
+
let fullRequest = {
|
4788
|
+
...request,
|
4789
|
+
signal,
|
4790
|
+
headers: { ...request?.headers, ...headers }
|
4791
|
+
};
|
4457
4792
|
if (options.requestMiddleware) {
|
4458
4793
|
fullRequest = await options.requestMiddleware(fullRequest);
|
4459
4794
|
}
|
@@ -4461,15 +4796,23 @@ var _Provider = class {
|
|
4461
4796
|
}, retryOptions);
|
4462
4797
|
}
|
4463
4798
|
static extractBasicAuth(url) {
|
4464
|
-
|
4799
|
+
let parsedUrl;
|
4800
|
+
try {
|
4801
|
+
parsedUrl = new URL(url);
|
4802
|
+
} catch (error) {
|
4803
|
+
throw new import_errors17.FuelError(import_errors17.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4804
|
+
}
|
4465
4805
|
const username = parsedUrl.username;
|
4466
4806
|
const password = parsedUrl.password;
|
4467
|
-
const
|
4807
|
+
const urlWithoutAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4468
4808
|
if (!(username && password)) {
|
4469
|
-
return { url,
|
4809
|
+
return { url, urlWithoutAuth: url, headers: void 0 };
|
4470
4810
|
}
|
4471
|
-
|
4472
|
-
|
4811
|
+
return {
|
4812
|
+
url,
|
4813
|
+
urlWithoutAuth,
|
4814
|
+
headers: { Authorization: `Basic ${btoa(`${username}:${password}`)}` }
|
4815
|
+
};
|
4473
4816
|
}
|
4474
4817
|
/**
|
4475
4818
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
@@ -4480,17 +4823,7 @@ var _Provider = class {
|
|
4480
4823
|
* @returns A promise that resolves to a Provider instance.
|
4481
4824
|
*/
|
4482
4825
|
static async create(url, options = {}) {
|
4483
|
-
const
|
4484
|
-
const provider = new _Provider(urlToUse, {
|
4485
|
-
...options,
|
4486
|
-
requestMiddleware: async (request) => {
|
4487
|
-
if (auth) {
|
4488
|
-
request.headers ??= {};
|
4489
|
-
request.headers.Authorization = auth;
|
4490
|
-
}
|
4491
|
-
return options.requestMiddleware?.(request) ?? request;
|
4492
|
-
}
|
4493
|
-
});
|
4826
|
+
const provider = new _Provider(url, options);
|
4494
4827
|
await provider.fetchChainAndNodeInfo();
|
4495
4828
|
return provider;
|
4496
4829
|
}
|
@@ -4500,10 +4833,10 @@ var _Provider = class {
|
|
4500
4833
|
* @returns the chain information configuration.
|
4501
4834
|
*/
|
4502
4835
|
getChain() {
|
4503
|
-
const chain = _Provider.chainInfoCache[this.
|
4836
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4504
4837
|
if (!chain) {
|
4505
|
-
throw new
|
4506
|
-
|
4838
|
+
throw new import_errors17.FuelError(
|
4839
|
+
import_errors17.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4507
4840
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4508
4841
|
);
|
4509
4842
|
}
|
@@ -4515,10 +4848,10 @@ var _Provider = class {
|
|
4515
4848
|
* @returns the node information configuration.
|
4516
4849
|
*/
|
4517
4850
|
getNode() {
|
4518
|
-
const node = _Provider.nodeInfoCache[this.
|
4851
|
+
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4519
4852
|
if (!node) {
|
4520
|
-
throw new
|
4521
|
-
|
4853
|
+
throw new import_errors17.FuelError(
|
4854
|
+
import_errors17.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4522
4855
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4523
4856
|
);
|
4524
4857
|
}
|
@@ -4549,8 +4882,11 @@ var _Provider = class {
|
|
4549
4882
|
* @param options - Additional options for the provider.
|
4550
4883
|
*/
|
4551
4884
|
async connect(url, options) {
|
4552
|
-
|
4885
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4886
|
+
this.url = rawUrl;
|
4887
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4553
4888
|
this.options = options ?? this.options;
|
4889
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4554
4890
|
this.operations = this.createOperations();
|
4555
4891
|
await this.fetchChainAndNodeInfo();
|
4556
4892
|
}
|
@@ -4590,7 +4926,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4590
4926
|
*/
|
4591
4927
|
createOperations() {
|
4592
4928
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4593
|
-
const gqlClient = new import_graphql_request.GraphQLClient(this.
|
4929
|
+
const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
|
4594
4930
|
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4595
4931
|
responseMiddleware: (response) => {
|
4596
4932
|
if ("response" in response) {
|
@@ -4608,7 +4944,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4608
4944
|
const isSubscription = opDefinition?.operation === "subscription";
|
4609
4945
|
if (isSubscription) {
|
4610
4946
|
return FuelGraphqlSubscriber.create({
|
4611
|
-
url: this.
|
4947
|
+
url: this.urlWithoutAuth,
|
4612
4948
|
query,
|
4613
4949
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4614
4950
|
variables: vars
|
@@ -4671,7 +5007,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4671
5007
|
utxoValidation: nodeInfo.utxoValidation,
|
4672
5008
|
vmBacktrace: nodeInfo.vmBacktrace
|
4673
5009
|
};
|
4674
|
-
_Provider.nodeInfoCache[this.
|
5010
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
4675
5011
|
return processedNodeInfo;
|
4676
5012
|
}
|
4677
5013
|
/**
|
@@ -4682,7 +5018,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4682
5018
|
async fetchChain() {
|
4683
5019
|
const { chain } = await this.operations.getChain();
|
4684
5020
|
const processedChain = processGqlChain(chain);
|
4685
|
-
_Provider.chainInfoCache[this.
|
5021
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
4686
5022
|
return processedChain;
|
4687
5023
|
}
|
4688
5024
|
/**
|
@@ -4710,14 +5046,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4710
5046
|
validateTransaction(tx, consensusParameters) {
|
4711
5047
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4712
5048
|
if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
|
4713
|
-
throw new
|
4714
|
-
|
5049
|
+
throw new import_errors17.FuelError(
|
5050
|
+
import_errors17.ErrorCode.MAX_INPUTS_EXCEEDED,
|
4715
5051
|
"The transaction exceeds the maximum allowed number of inputs."
|
4716
5052
|
);
|
4717
5053
|
}
|
4718
5054
|
if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
|
4719
|
-
throw new
|
4720
|
-
|
5055
|
+
throw new import_errors17.FuelError(
|
5056
|
+
import_errors17.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
4721
5057
|
"The transaction exceeds the maximum allowed number of outputs."
|
4722
5058
|
);
|
4723
5059
|
}
|
@@ -4739,16 +5075,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4739
5075
|
}
|
4740
5076
|
const { consensusParameters } = this.getChain();
|
4741
5077
|
this.validateTransaction(transactionRequest, consensusParameters);
|
4742
|
-
const encodedTransaction = (0,
|
5078
|
+
const encodedTransaction = (0, import_utils28.hexlify)(transactionRequest.toTransactionBytes());
|
4743
5079
|
let abis;
|
4744
5080
|
if (isTransactionTypeScript(transactionRequest)) {
|
4745
5081
|
abis = transactionRequest.abis;
|
4746
5082
|
}
|
4747
|
-
const {
|
4748
|
-
|
4749
|
-
|
4750
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4751
|
-
return new TransactionResponse(transactionRequest, this, abis);
|
5083
|
+
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
5084
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
5085
|
+
return new TransactionResponse(transactionRequest, this, abis, subscription);
|
4752
5086
|
}
|
4753
5087
|
/**
|
4754
5088
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -4765,7 +5099,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4765
5099
|
if (estimateTxDependencies) {
|
4766
5100
|
return this.estimateTxDependencies(transactionRequest);
|
4767
5101
|
}
|
4768
|
-
const encodedTransaction = (0,
|
5102
|
+
const encodedTransaction = (0, import_utils28.hexlify)(transactionRequest.toTransactionBytes());
|
4769
5103
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4770
5104
|
encodedTransactions: encodedTransaction,
|
4771
5105
|
utxoValidation: utxoValidation || false
|
@@ -4785,13 +5119,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4785
5119
|
async estimatePredicates(transactionRequest) {
|
4786
5120
|
const shouldEstimatePredicates = Boolean(
|
4787
5121
|
transactionRequest.inputs.find(
|
4788
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
5122
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils29.equalBytes)((0, import_utils28.arrayify)(input.predicate), (0, import_utils28.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
|
4789
5123
|
)
|
4790
5124
|
);
|
4791
5125
|
if (!shouldEstimatePredicates) {
|
4792
5126
|
return transactionRequest;
|
4793
5127
|
}
|
4794
|
-
const encodedTransaction = (0,
|
5128
|
+
const encodedTransaction = (0, import_utils28.hexlify)(transactionRequest.toTransactionBytes());
|
4795
5129
|
const response = await this.operations.estimatePredicates({
|
4796
5130
|
encodedTransaction
|
4797
5131
|
});
|
@@ -4832,7 +5166,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4832
5166
|
const {
|
4833
5167
|
dryRun: [{ receipts: rawReceipts, status }]
|
4834
5168
|
} = await this.operations.dryRun({
|
4835
|
-
encodedTransactions: [(0,
|
5169
|
+
encodedTransactions: [(0, import_utils28.hexlify)(transactionRequest.toTransactionBytes())],
|
4836
5170
|
utxoValidation: false
|
4837
5171
|
});
|
4838
5172
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4878,11 +5212,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4878
5212
|
missingContractIds: [],
|
4879
5213
|
dryRunStatus: void 0
|
4880
5214
|
}));
|
4881
|
-
const allRequests = (0,
|
5215
|
+
const allRequests = (0, import_ramda8.clone)(transactionRequests);
|
4882
5216
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4883
5217
|
allRequests.forEach((req, index) => {
|
4884
5218
|
if (isTransactionTypeScript(req)) {
|
4885
|
-
serializedTransactionsMap.set(index, (0,
|
5219
|
+
serializedTransactionsMap.set(index, (0, import_utils28.hexlify)(req.toTransactionBytes()));
|
4886
5220
|
}
|
4887
5221
|
});
|
4888
5222
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4918,7 +5252,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4918
5252
|
transactionRequest: request
|
4919
5253
|
});
|
4920
5254
|
request.maxFee = maxFee;
|
4921
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
5255
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils28.hexlify)(request.toTransactionBytes()));
|
4922
5256
|
nextRoundTransactions.push(requestIdx);
|
4923
5257
|
}
|
4924
5258
|
}
|
@@ -4939,7 +5273,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4939
5273
|
if (estimateTxDependencies) {
|
4940
5274
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4941
5275
|
}
|
4942
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
5276
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils28.hexlify)(tx.toTransactionBytes()));
|
4943
5277
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4944
5278
|
encodedTransactions,
|
4945
5279
|
utxoValidation: utxoValidation || false
|
@@ -5013,7 +5347,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5013
5347
|
if (estimateTxDependencies) {
|
5014
5348
|
return this.estimateTxDependencies(transactionRequest);
|
5015
5349
|
}
|
5016
|
-
const encodedTransactions = [(0,
|
5350
|
+
const encodedTransactions = [(0, import_utils28.hexlify)(transactionRequest.toTransactionBytes())];
|
5017
5351
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5018
5352
|
encodedTransactions,
|
5019
5353
|
utxoValidation: true
|
@@ -5038,13 +5372,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5038
5372
|
* @returns A promise that resolves to the transaction cost object.
|
5039
5373
|
*/
|
5040
5374
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5041
|
-
const txRequestClone = (0,
|
5375
|
+
const txRequestClone = (0, import_ramda8.clone)(transactionRequestify(transactionRequestLike));
|
5042
5376
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5043
5377
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
5044
5378
|
if (isScriptTransaction) {
|
5045
5379
|
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
5046
5380
|
}
|
5047
|
-
const signedRequest = (0,
|
5381
|
+
const signedRequest = (0, import_ramda8.clone)(txRequestClone);
|
5048
5382
|
let addedSignatures = 0;
|
5049
5383
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
5050
5384
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5112,7 +5446,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5112
5446
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5113
5447
|
inputArgs: paginationArgs
|
5114
5448
|
}),
|
5115
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
5449
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils28.hexlify)(assetId) }
|
5116
5450
|
});
|
5117
5451
|
const coins = edges.map(({ node }) => ({
|
5118
5452
|
id: node.utxoId,
|
@@ -5138,8 +5472,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5138
5472
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5139
5473
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
5140
5474
|
const excludeInput = {
|
5141
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
5142
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
5475
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils28.hexlify)(nonce)) || [],
|
5476
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils28.hexlify)(id)) || []
|
5143
5477
|
};
|
5144
5478
|
if (this.cache) {
|
5145
5479
|
const cached = this.cache.getActiveData();
|
@@ -5149,7 +5483,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5149
5483
|
const coinsQuery = {
|
5150
5484
|
owner: ownerAddress.toB256(),
|
5151
5485
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
5152
|
-
assetId: (0,
|
5486
|
+
assetId: (0, import_utils28.hexlify)(assetId),
|
5153
5487
|
amount: amount.toString(10),
|
5154
5488
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
5155
5489
|
})),
|
@@ -5304,7 +5638,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5304
5638
|
},
|
5305
5639
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5306
5640
|
transactions: block.transactions.map(
|
5307
|
-
(tx) => new
|
5641
|
+
(tx) => new import_transactions22.TransactionCoder().decode((0, import_utils28.arrayify)(tx.rawPayload), 0)?.[0]
|
5308
5642
|
)
|
5309
5643
|
};
|
5310
5644
|
}
|
@@ -5320,12 +5654,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5320
5654
|
return null;
|
5321
5655
|
}
|
5322
5656
|
try {
|
5323
|
-
return new
|
5324
|
-
(0,
|
5657
|
+
return new import_transactions22.TransactionCoder().decode(
|
5658
|
+
(0, import_utils28.arrayify)(transaction.rawPayload),
|
5325
5659
|
0
|
5326
5660
|
)?.[0];
|
5327
5661
|
} catch (error) {
|
5328
|
-
if (error instanceof
|
5662
|
+
if (error instanceof import_errors17.FuelError && error.code === import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5329
5663
|
console.warn("Unsupported transaction type encountered");
|
5330
5664
|
return null;
|
5331
5665
|
}
|
@@ -5341,12 +5675,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5341
5675
|
const {
|
5342
5676
|
transactions: { edges, pageInfo }
|
5343
5677
|
} = await this.operations.getTransactions(paginationArgs);
|
5344
|
-
const coder = new
|
5678
|
+
const coder = new import_transactions22.TransactionCoder();
|
5345
5679
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5346
5680
|
try {
|
5347
|
-
return coder.decode((0,
|
5681
|
+
return coder.decode((0, import_utils28.arrayify)(rawPayload), 0)[0];
|
5348
5682
|
} catch (error) {
|
5349
|
-
if (error instanceof
|
5683
|
+
if (error instanceof import_errors17.FuelError && error.code === import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5350
5684
|
console.warn("Unsupported transaction type encountered");
|
5351
5685
|
return null;
|
5352
5686
|
}
|
@@ -5378,7 +5712,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5378
5712
|
async getContractBalance(contractId, assetId) {
|
5379
5713
|
const { contractBalance } = await this.operations.getContractBalance({
|
5380
5714
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
5381
|
-
asset: (0,
|
5715
|
+
asset: (0, import_utils28.hexlify)(assetId)
|
5382
5716
|
});
|
5383
5717
|
return (0, import_math18.bn)(contractBalance.amount, 10);
|
5384
5718
|
}
|
@@ -5392,7 +5726,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5392
5726
|
async getBalance(owner, assetId) {
|
5393
5727
|
const { balance } = await this.operations.getBalance({
|
5394
5728
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
5395
|
-
assetId: (0,
|
5729
|
+
assetId: (0, import_utils28.hexlify)(assetId)
|
5396
5730
|
});
|
5397
5731
|
return (0, import_math18.bn)(balance.amount, 10);
|
5398
5732
|
}
|
@@ -5438,7 +5772,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5438
5772
|
owner: import_address3.Address.fromAddressOrString(address).toB256()
|
5439
5773
|
});
|
5440
5774
|
const messages = edges.map(({ node }) => ({
|
5441
|
-
messageId:
|
5775
|
+
messageId: import_transactions22.InputMessageCoder.getMessageId({
|
5442
5776
|
sender: node.sender,
|
5443
5777
|
recipient: node.recipient,
|
5444
5778
|
nonce: node.nonce,
|
@@ -5449,7 +5783,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5449
5783
|
recipient: import_address3.Address.fromAddressOrString(node.recipient),
|
5450
5784
|
nonce: node.nonce,
|
5451
5785
|
amount: (0, import_math18.bn)(node.amount),
|
5452
|
-
data:
|
5786
|
+
data: import_transactions22.InputMessageCoder.decodeData(node.data),
|
5453
5787
|
daHeight: (0, import_math18.bn)(node.daHeight)
|
5454
5788
|
}));
|
5455
5789
|
return {
|
@@ -5472,8 +5806,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5472
5806
|
nonce
|
5473
5807
|
};
|
5474
5808
|
if (commitBlockId && commitBlockHeight) {
|
5475
|
-
throw new
|
5476
|
-
|
5809
|
+
throw new import_errors17.FuelError(
|
5810
|
+
import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5477
5811
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5478
5812
|
);
|
5479
5813
|
}
|
@@ -5592,7 +5926,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5592
5926
|
async produceBlocks(amount, startTime) {
|
5593
5927
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5594
5928
|
blocksToProduce: (0, import_math18.bn)(amount).toString(10),
|
5595
|
-
startTimestamp: startTime ?
|
5929
|
+
startTimestamp: startTime ? import_utils28.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5596
5930
|
});
|
5597
5931
|
return (0, import_math18.bn)(latestBlockHeight);
|
5598
5932
|
}
|
@@ -5618,7 +5952,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5618
5952
|
return null;
|
5619
5953
|
}
|
5620
5954
|
const message = {
|
5621
|
-
messageId:
|
5955
|
+
messageId: import_transactions22.InputMessageCoder.getMessageId({
|
5622
5956
|
sender: rawMessage.sender,
|
5623
5957
|
recipient: rawMessage.recipient,
|
5624
5958
|
nonce: rawMessage.nonce,
|
@@ -5629,7 +5963,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5629
5963
|
recipient: import_address3.Address.fromAddressOrString(rawMessage.recipient),
|
5630
5964
|
nonce: rawMessage.nonce,
|
5631
5965
|
amount: (0, import_math18.bn)(rawMessage.amount),
|
5632
|
-
data:
|
5966
|
+
data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
|
5633
5967
|
daHeight: (0, import_math18.bn)(rawMessage.daHeight)
|
5634
5968
|
};
|
5635
5969
|
return message;
|
@@ -5656,26 +5990,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5656
5990
|
const { paginationLimit, inputArgs = {} } = params;
|
5657
5991
|
const { first, last, after, before } = inputArgs;
|
5658
5992
|
if (after && before) {
|
5659
|
-
throw new
|
5660
|
-
|
5993
|
+
throw new import_errors17.FuelError(
|
5994
|
+
import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5661
5995
|
'Pagination arguments "after" and "before" cannot be used together'
|
5662
5996
|
);
|
5663
5997
|
}
|
5664
5998
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5665
|
-
throw new
|
5666
|
-
|
5999
|
+
throw new import_errors17.FuelError(
|
6000
|
+
import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5667
6001
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5668
6002
|
);
|
5669
6003
|
}
|
5670
6004
|
if (first && before) {
|
5671
|
-
throw new
|
5672
|
-
|
6005
|
+
throw new import_errors17.FuelError(
|
6006
|
+
import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5673
6007
|
'The use of pagination argument "first" with "before" is not supported'
|
5674
6008
|
);
|
5675
6009
|
}
|
5676
6010
|
if (last && after) {
|
5677
|
-
throw new
|
5678
|
-
|
6011
|
+
throw new import_errors17.FuelError(
|
6012
|
+
import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5679
6013
|
'The use of pagination argument "last" with "after" is not supported'
|
5680
6014
|
);
|
5681
6015
|
}
|
@@ -5712,9 +6046,9 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
5712
6046
|
}
|
5713
6047
|
const inputsToCache = inputs.reduce(
|
5714
6048
|
(acc, input) => {
|
5715
|
-
if (input.type ===
|
6049
|
+
if (input.type === import_transactions22.InputType.Coin) {
|
5716
6050
|
acc.utxos.push(input.id);
|
5717
|
-
} else if (input.type ===
|
6051
|
+
} else if (input.type === import_transactions22.InputType.Message) {
|
5718
6052
|
acc.messages.push(input.nonce);
|
5719
6053
|
}
|
5720
6054
|
return acc;
|
@@ -5729,23 +6063,23 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5729
6063
|
__publicField(Provider, "nodeInfoCache", {});
|
5730
6064
|
|
5731
6065
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5732
|
-
var
|
6066
|
+
var import_errors18 = require("@fuel-ts/errors");
|
5733
6067
|
var import_math19 = require("@fuel-ts/math");
|
5734
|
-
var
|
5735
|
-
var
|
6068
|
+
var import_transactions23 = require("@fuel-ts/transactions");
|
6069
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5736
6070
|
async function getTransactionSummary(params) {
|
5737
6071
|
const { id, provider, abiMap } = params;
|
5738
6072
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
5739
6073
|
transactionId: id
|
5740
6074
|
});
|
5741
6075
|
if (!gqlTransaction) {
|
5742
|
-
throw new
|
5743
|
-
|
6076
|
+
throw new import_errors18.FuelError(
|
6077
|
+
import_errors18.ErrorCode.TRANSACTION_NOT_FOUND,
|
5744
6078
|
`Transaction not found for given id: ${id}.`
|
5745
6079
|
);
|
5746
6080
|
}
|
5747
|
-
const [decodedTransaction] = new
|
5748
|
-
(0,
|
6081
|
+
const [decodedTransaction] = new import_transactions23.TransactionCoder().decode(
|
6082
|
+
(0, import_utils31.arrayify)(gqlTransaction.rawPayload),
|
5749
6083
|
0
|
5750
6084
|
);
|
5751
6085
|
let txReceipts = [];
|
@@ -5766,7 +6100,7 @@ async function getTransactionSummary(params) {
|
|
5766
6100
|
id: gqlTransaction.id,
|
5767
6101
|
receipts,
|
5768
6102
|
transaction: decodedTransaction,
|
5769
|
-
transactionBytes: (0,
|
6103
|
+
transactionBytes: (0, import_utils31.arrayify)(gqlTransaction.rawPayload),
|
5770
6104
|
gqlTransactionStatus: gqlTransaction.status,
|
5771
6105
|
gasPerByte: (0, import_math19.bn)(gasPerByte),
|
5772
6106
|
gasPriceFactor: (0, import_math19.bn)(gasPriceFactor),
|
@@ -5822,7 +6156,7 @@ async function getTransactionsSummaries(params) {
|
|
5822
6156
|
const transactions = edges.map((edge) => {
|
5823
6157
|
const { node: gqlTransaction } = edge;
|
5824
6158
|
const { id, rawPayload, status } = gqlTransaction;
|
5825
|
-
const [decodedTransaction] = new
|
6159
|
+
const [decodedTransaction] = new import_transactions23.TransactionCoder().decode((0, import_utils31.arrayify)(rawPayload), 0);
|
5826
6160
|
let txReceipts = [];
|
5827
6161
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5828
6162
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5832,7 +6166,7 @@ async function getTransactionsSummaries(params) {
|
|
5832
6166
|
id,
|
5833
6167
|
receipts,
|
5834
6168
|
transaction: decodedTransaction,
|
5835
|
-
transactionBytes: (0,
|
6169
|
+
transactionBytes: (0, import_utils31.arrayify)(rawPayload),
|
5836
6170
|
gqlTransactionStatus: status,
|
5837
6171
|
abiMap,
|
5838
6172
|
gasPerByte,
|
@@ -5857,12 +6191,14 @@ async function getTransactionsSummaries(params) {
|
|
5857
6191
|
// src/providers/chains.ts
|
5858
6192
|
var CHAIN_IDS = {
|
5859
6193
|
eth: {
|
6194
|
+
mainnet: 1,
|
5860
6195
|
sepolia: 11155111,
|
5861
6196
|
foundry: 31337
|
5862
6197
|
},
|
5863
6198
|
fuel: {
|
5864
6199
|
devnet: 0,
|
5865
|
-
testnet: 0
|
6200
|
+
testnet: 0,
|
6201
|
+
mainnet: 9889
|
5866
6202
|
}
|
5867
6203
|
};
|
5868
6204
|
|
@@ -5962,6 +6298,11 @@ var rawAssets = [
|
|
5962
6298
|
chainId: CHAIN_IDS.eth.foundry,
|
5963
6299
|
decimals: 18
|
5964
6300
|
},
|
6301
|
+
{
|
6302
|
+
type: "ethereum",
|
6303
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6304
|
+
decimals: 18
|
6305
|
+
},
|
5965
6306
|
{
|
5966
6307
|
type: "fuel",
|
5967
6308
|
chainId: CHAIN_IDS.fuel.devnet,
|
@@ -5973,6 +6314,571 @@ var rawAssets = [
|
|
5973
6314
|
chainId: CHAIN_IDS.fuel.testnet,
|
5974
6315
|
decimals: 9,
|
5975
6316
|
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6317
|
+
},
|
6318
|
+
{
|
6319
|
+
type: "fuel",
|
6320
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6321
|
+
decimals: 9,
|
6322
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6323
|
+
}
|
6324
|
+
]
|
6325
|
+
},
|
6326
|
+
{
|
6327
|
+
name: "WETH",
|
6328
|
+
symbol: "WETH",
|
6329
|
+
icon: "weth.svg",
|
6330
|
+
networks: [
|
6331
|
+
{
|
6332
|
+
type: "ethereum",
|
6333
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6334
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6335
|
+
decimals: 18
|
6336
|
+
},
|
6337
|
+
{
|
6338
|
+
type: "fuel",
|
6339
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6340
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6341
|
+
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6342
|
+
decimals: 18
|
6343
|
+
}
|
6344
|
+
]
|
6345
|
+
},
|
6346
|
+
{
|
6347
|
+
name: "weETH",
|
6348
|
+
symbol: "weETH",
|
6349
|
+
icon: "weETH.webp",
|
6350
|
+
networks: [
|
6351
|
+
{
|
6352
|
+
type: "ethereum",
|
6353
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6354
|
+
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6355
|
+
decimals: 18
|
6356
|
+
},
|
6357
|
+
{
|
6358
|
+
type: "fuel",
|
6359
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6360
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6361
|
+
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6362
|
+
decimals: 18
|
6363
|
+
}
|
6364
|
+
]
|
6365
|
+
},
|
6366
|
+
{
|
6367
|
+
name: "rsETH",
|
6368
|
+
symbol: "rsETH",
|
6369
|
+
icon: "rsETH.webp",
|
6370
|
+
networks: [
|
6371
|
+
{
|
6372
|
+
type: "ethereum",
|
6373
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6374
|
+
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6375
|
+
decimals: 18
|
6376
|
+
},
|
6377
|
+
{
|
6378
|
+
type: "fuel",
|
6379
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6380
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6381
|
+
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6382
|
+
decimals: 18
|
6383
|
+
}
|
6384
|
+
]
|
6385
|
+
},
|
6386
|
+
{
|
6387
|
+
name: "rETH",
|
6388
|
+
symbol: "rETH",
|
6389
|
+
icon: "reth.svg",
|
6390
|
+
networks: [
|
6391
|
+
{
|
6392
|
+
type: "ethereum",
|
6393
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6394
|
+
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6395
|
+
decimals: 18
|
6396
|
+
},
|
6397
|
+
{
|
6398
|
+
type: "fuel",
|
6399
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6400
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6401
|
+
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6402
|
+
decimals: 18
|
6403
|
+
}
|
6404
|
+
]
|
6405
|
+
},
|
6406
|
+
{
|
6407
|
+
name: "wbETH",
|
6408
|
+
symbol: "wbETH",
|
6409
|
+
icon: "wbeth.png",
|
6410
|
+
networks: [
|
6411
|
+
{
|
6412
|
+
type: "ethereum",
|
6413
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6414
|
+
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6415
|
+
decimals: 18
|
6416
|
+
},
|
6417
|
+
{
|
6418
|
+
type: "fuel",
|
6419
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6420
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6421
|
+
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6422
|
+
decimals: 18
|
6423
|
+
}
|
6424
|
+
]
|
6425
|
+
},
|
6426
|
+
{
|
6427
|
+
name: "rstETH",
|
6428
|
+
symbol: "rstETH",
|
6429
|
+
icon: "rstETH.webp",
|
6430
|
+
networks: [
|
6431
|
+
{
|
6432
|
+
type: "ethereum",
|
6433
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6434
|
+
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6435
|
+
decimals: 18
|
6436
|
+
},
|
6437
|
+
{
|
6438
|
+
type: "fuel",
|
6439
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6440
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6441
|
+
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6442
|
+
decimals: 18
|
6443
|
+
}
|
6444
|
+
]
|
6445
|
+
},
|
6446
|
+
{
|
6447
|
+
name: "amphrETH",
|
6448
|
+
symbol: "amphrETH",
|
6449
|
+
icon: "amphrETH.png",
|
6450
|
+
networks: [
|
6451
|
+
{
|
6452
|
+
type: "ethereum",
|
6453
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6454
|
+
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6455
|
+
decimals: 18
|
6456
|
+
},
|
6457
|
+
{
|
6458
|
+
type: "fuel",
|
6459
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6460
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6461
|
+
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6462
|
+
decimals: 18
|
6463
|
+
}
|
6464
|
+
]
|
6465
|
+
},
|
6466
|
+
{
|
6467
|
+
name: "Manta mBTC",
|
6468
|
+
symbol: "Manta mBTC",
|
6469
|
+
icon: "manta-mbtc.svg",
|
6470
|
+
networks: [
|
6471
|
+
{
|
6472
|
+
type: "ethereum",
|
6473
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6474
|
+
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6475
|
+
decimals: 18
|
6476
|
+
},
|
6477
|
+
{
|
6478
|
+
type: "fuel",
|
6479
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6480
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6481
|
+
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6482
|
+
decimals: 18
|
6483
|
+
}
|
6484
|
+
]
|
6485
|
+
},
|
6486
|
+
{
|
6487
|
+
name: "Manta mETH",
|
6488
|
+
symbol: "Manta mETH",
|
6489
|
+
icon: "manta-meth.svg",
|
6490
|
+
networks: [
|
6491
|
+
{
|
6492
|
+
type: "ethereum",
|
6493
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6494
|
+
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6495
|
+
decimals: 18
|
6496
|
+
},
|
6497
|
+
{
|
6498
|
+
type: "fuel",
|
6499
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6500
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6501
|
+
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6502
|
+
decimals: 18
|
6503
|
+
}
|
6504
|
+
]
|
6505
|
+
},
|
6506
|
+
{
|
6507
|
+
name: "Manta mUSD",
|
6508
|
+
symbol: "Manta mUSD",
|
6509
|
+
icon: "manta-musd.svg",
|
6510
|
+
networks: [
|
6511
|
+
{
|
6512
|
+
type: "ethereum",
|
6513
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6514
|
+
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6515
|
+
decimals: 18
|
6516
|
+
},
|
6517
|
+
{
|
6518
|
+
type: "fuel",
|
6519
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6520
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6521
|
+
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6522
|
+
decimals: 18
|
6523
|
+
}
|
6524
|
+
]
|
6525
|
+
},
|
6526
|
+
{
|
6527
|
+
name: "pumpBTC",
|
6528
|
+
symbol: "pumpBTC",
|
6529
|
+
icon: "pumpbtc.webp",
|
6530
|
+
networks: [
|
6531
|
+
{
|
6532
|
+
type: "ethereum",
|
6533
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6534
|
+
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6535
|
+
decimals: 8
|
6536
|
+
},
|
6537
|
+
{
|
6538
|
+
type: "fuel",
|
6539
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6540
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6541
|
+
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6542
|
+
decimals: 8
|
6543
|
+
}
|
6544
|
+
]
|
6545
|
+
},
|
6546
|
+
{
|
6547
|
+
name: "FBTC",
|
6548
|
+
symbol: "FBTC",
|
6549
|
+
icon: "fbtc.svg",
|
6550
|
+
networks: [
|
6551
|
+
{
|
6552
|
+
type: "ethereum",
|
6553
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6554
|
+
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6555
|
+
decimals: 8
|
6556
|
+
},
|
6557
|
+
{
|
6558
|
+
type: "fuel",
|
6559
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6560
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6561
|
+
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6562
|
+
decimals: 8
|
6563
|
+
}
|
6564
|
+
]
|
6565
|
+
},
|
6566
|
+
{
|
6567
|
+
name: "SolvBTC",
|
6568
|
+
symbol: "SolvBTC",
|
6569
|
+
icon: "solvBTC.webp",
|
6570
|
+
networks: [
|
6571
|
+
{
|
6572
|
+
type: "ethereum",
|
6573
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6574
|
+
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6575
|
+
decimals: 18
|
6576
|
+
},
|
6577
|
+
{
|
6578
|
+
type: "fuel",
|
6579
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6580
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6581
|
+
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6582
|
+
decimals: 18
|
6583
|
+
}
|
6584
|
+
]
|
6585
|
+
},
|
6586
|
+
{
|
6587
|
+
name: "SolvBTC.BBN",
|
6588
|
+
symbol: "SolvBTC.BBN",
|
6589
|
+
icon: "SolvBTC.BBN.png",
|
6590
|
+
networks: [
|
6591
|
+
{
|
6592
|
+
type: "ethereum",
|
6593
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6594
|
+
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6595
|
+
decimals: 18
|
6596
|
+
},
|
6597
|
+
{
|
6598
|
+
type: "fuel",
|
6599
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6600
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6601
|
+
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6602
|
+
decimals: 18
|
6603
|
+
}
|
6604
|
+
]
|
6605
|
+
},
|
6606
|
+
{
|
6607
|
+
name: "Mantle mETH",
|
6608
|
+
symbol: "Mantle mETH",
|
6609
|
+
icon: "mantle-meth.svg",
|
6610
|
+
networks: [
|
6611
|
+
{
|
6612
|
+
type: "ethereum",
|
6613
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6614
|
+
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6615
|
+
decimals: 18
|
6616
|
+
},
|
6617
|
+
{
|
6618
|
+
type: "fuel",
|
6619
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6620
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6621
|
+
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6622
|
+
decimals: 18
|
6623
|
+
}
|
6624
|
+
]
|
6625
|
+
},
|
6626
|
+
{
|
6627
|
+
name: "sDAI",
|
6628
|
+
symbol: "sDAI",
|
6629
|
+
icon: "sdai.svg",
|
6630
|
+
networks: [
|
6631
|
+
{
|
6632
|
+
type: "ethereum",
|
6633
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6634
|
+
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6635
|
+
decimals: 18
|
6636
|
+
},
|
6637
|
+
{
|
6638
|
+
type: "fuel",
|
6639
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6640
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6641
|
+
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6642
|
+
decimals: 18
|
6643
|
+
}
|
6644
|
+
]
|
6645
|
+
},
|
6646
|
+
{
|
6647
|
+
name: "USDT",
|
6648
|
+
symbol: "USDT",
|
6649
|
+
icon: "usdt.svg",
|
6650
|
+
networks: [
|
6651
|
+
{
|
6652
|
+
type: "ethereum",
|
6653
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6654
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6655
|
+
decimals: 6
|
6656
|
+
},
|
6657
|
+
{
|
6658
|
+
type: "fuel",
|
6659
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6660
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6661
|
+
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6662
|
+
decimals: 6
|
6663
|
+
}
|
6664
|
+
]
|
6665
|
+
},
|
6666
|
+
{
|
6667
|
+
name: "USDC",
|
6668
|
+
symbol: "USDC",
|
6669
|
+
icon: "usdc.svg",
|
6670
|
+
networks: [
|
6671
|
+
{
|
6672
|
+
type: "ethereum",
|
6673
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6674
|
+
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6675
|
+
decimals: 6
|
6676
|
+
},
|
6677
|
+
{
|
6678
|
+
type: "fuel",
|
6679
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6680
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6681
|
+
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6682
|
+
decimals: 6
|
6683
|
+
}
|
6684
|
+
]
|
6685
|
+
},
|
6686
|
+
{
|
6687
|
+
name: "USDe",
|
6688
|
+
symbol: "USDe",
|
6689
|
+
icon: "USDe.svg",
|
6690
|
+
networks: [
|
6691
|
+
{
|
6692
|
+
type: "ethereum",
|
6693
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6694
|
+
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6695
|
+
decimals: 18
|
6696
|
+
},
|
6697
|
+
{
|
6698
|
+
type: "ethereum",
|
6699
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6700
|
+
address: "0xc6387efad0f184a90b34f397c3d6fd63135ef790",
|
6701
|
+
decimals: 18
|
6702
|
+
},
|
6703
|
+
{
|
6704
|
+
type: "fuel",
|
6705
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6706
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6707
|
+
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6708
|
+
decimals: 18
|
6709
|
+
},
|
6710
|
+
{
|
6711
|
+
type: "fuel",
|
6712
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6713
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6714
|
+
assetId: "0xf5c6d72d0f2c782fa47d8e228c198a08654e9fc66ca60ad85902b1d09046a7ab",
|
6715
|
+
decimals: 18
|
6716
|
+
}
|
6717
|
+
]
|
6718
|
+
},
|
6719
|
+
{
|
6720
|
+
name: "sUSDe",
|
6721
|
+
symbol: "sUSDe",
|
6722
|
+
icon: "sUSDe.webp",
|
6723
|
+
networks: [
|
6724
|
+
{
|
6725
|
+
type: "ethereum",
|
6726
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6727
|
+
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6728
|
+
decimals: 18
|
6729
|
+
},
|
6730
|
+
{
|
6731
|
+
type: "ethereum",
|
6732
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6733
|
+
address: "0xb8f4f4eafc1d2a3c0a4d519bbf1114c311cc9b1b",
|
6734
|
+
decimals: 18
|
6735
|
+
},
|
6736
|
+
{
|
6737
|
+
type: "fuel",
|
6738
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6739
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6740
|
+
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6741
|
+
decimals: 18
|
6742
|
+
},
|
6743
|
+
{
|
6744
|
+
type: "fuel",
|
6745
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6746
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6747
|
+
assetId: "0xa86e37d385c08beddbb02c8260f9ec535d484c8ea908fc19d4e6dc8d5141fb2e",
|
6748
|
+
decimals: 18
|
6749
|
+
}
|
6750
|
+
]
|
6751
|
+
},
|
6752
|
+
{
|
6753
|
+
name: "rsUSDe",
|
6754
|
+
symbol: "rsUSDe",
|
6755
|
+
icon: "rsUSDe.svg",
|
6756
|
+
networks: [
|
6757
|
+
{
|
6758
|
+
type: "ethereum",
|
6759
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6760
|
+
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6761
|
+
decimals: 18
|
6762
|
+
},
|
6763
|
+
{
|
6764
|
+
type: "fuel",
|
6765
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6766
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6767
|
+
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6768
|
+
decimals: 18
|
6769
|
+
}
|
6770
|
+
]
|
6771
|
+
},
|
6772
|
+
{
|
6773
|
+
name: "wstETH",
|
6774
|
+
symbol: "wstETH",
|
6775
|
+
icon: "wsteth.svg",
|
6776
|
+
networks: [
|
6777
|
+
{
|
6778
|
+
type: "ethereum",
|
6779
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6780
|
+
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6781
|
+
decimals: 18
|
6782
|
+
},
|
6783
|
+
{
|
6784
|
+
type: "ethereum",
|
6785
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6786
|
+
address: "0xB82381A3fBD3FaFA77B3a7bE693342618240067b",
|
6787
|
+
decimals: 18
|
6788
|
+
},
|
6789
|
+
{
|
6790
|
+
type: "fuel",
|
6791
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6792
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6793
|
+
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6794
|
+
decimals: 18
|
6795
|
+
},
|
6796
|
+
{
|
6797
|
+
type: "fuel",
|
6798
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6799
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6800
|
+
assetId: "0x4c467e3fd4f32179e1aad3b92ebbdaa6ff6aeda5b8da5f8e64e96405eb52a7f5",
|
6801
|
+
decimals: 18
|
6802
|
+
}
|
6803
|
+
]
|
6804
|
+
},
|
6805
|
+
{
|
6806
|
+
name: "ezETH",
|
6807
|
+
symbol: "ezETH",
|
6808
|
+
icon: "ezeth.webp",
|
6809
|
+
networks: [
|
6810
|
+
{
|
6811
|
+
type: "ethereum",
|
6812
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6813
|
+
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6814
|
+
decimals: 18
|
6815
|
+
},
|
6816
|
+
{
|
6817
|
+
type: "fuel",
|
6818
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6819
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6820
|
+
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6821
|
+
decimals: 18
|
6822
|
+
}
|
6823
|
+
]
|
6824
|
+
},
|
6825
|
+
{
|
6826
|
+
name: "pzETH",
|
6827
|
+
symbol: "pzETH",
|
6828
|
+
icon: "pzETH.webp",
|
6829
|
+
networks: [
|
6830
|
+
{
|
6831
|
+
type: "ethereum",
|
6832
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6833
|
+
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6834
|
+
decimals: 18
|
6835
|
+
},
|
6836
|
+
{
|
6837
|
+
type: "fuel",
|
6838
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6839
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6840
|
+
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6841
|
+
decimals: 18
|
6842
|
+
}
|
6843
|
+
]
|
6844
|
+
},
|
6845
|
+
{
|
6846
|
+
name: "Re7LRT",
|
6847
|
+
symbol: "Re7LRT",
|
6848
|
+
icon: "Re7LRT.png",
|
6849
|
+
networks: [
|
6850
|
+
{
|
6851
|
+
type: "ethereum",
|
6852
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6853
|
+
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6854
|
+
decimals: 18
|
6855
|
+
},
|
6856
|
+
{
|
6857
|
+
type: "fuel",
|
6858
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6859
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6860
|
+
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6861
|
+
decimals: 18
|
6862
|
+
}
|
6863
|
+
]
|
6864
|
+
},
|
6865
|
+
{
|
6866
|
+
name: "steakLRT",
|
6867
|
+
symbol: "steakLRT",
|
6868
|
+
icon: "steakLRT.png",
|
6869
|
+
networks: [
|
6870
|
+
{
|
6871
|
+
type: "ethereum",
|
6872
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6873
|
+
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6874
|
+
decimals: 18
|
6875
|
+
},
|
6876
|
+
{
|
6877
|
+
type: "fuel",
|
6878
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6879
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6880
|
+
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6881
|
+
decimals: 18
|
5976
6882
|
}
|
5977
6883
|
]
|
5978
6884
|
}
|
@@ -5996,16 +6902,16 @@ var mergeQuantities = (...coinQuantities) => {
|
|
5996
6902
|
// src/utils/formatTransferToContractScriptData.ts
|
5997
6903
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5998
6904
|
var import_math20 = require("@fuel-ts/math");
|
5999
|
-
var
|
6905
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6000
6906
|
var asm = __toESM(require("@fuels/vm-asm"));
|
6001
6907
|
var formatTransferToContractScriptData = (params) => {
|
6002
6908
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
6003
6909
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
6004
6910
|
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
6005
6911
|
const scriptData = Uint8Array.from([
|
6006
|
-
...(0,
|
6912
|
+
...(0, import_utils33.arrayify)(hexlifiedContractId),
|
6007
6913
|
...encoded,
|
6008
|
-
...(0,
|
6914
|
+
...(0, import_utils33.arrayify)(assetId)
|
6009
6915
|
]);
|
6010
6916
|
return scriptData;
|
6011
6917
|
};
|
@@ -6066,7 +6972,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6066
6972
|
*/
|
6067
6973
|
get provider() {
|
6068
6974
|
if (!this._provider) {
|
6069
|
-
throw new
|
6975
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
6070
6976
|
}
|
6071
6977
|
return this._provider;
|
6072
6978
|
}
|
@@ -6184,7 +7090,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6184
7090
|
);
|
6185
7091
|
request.addResources(resources);
|
6186
7092
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6187
|
-
const requestToReestimate2 = (0,
|
7093
|
+
const requestToReestimate2 = (0, import_ramda9.clone)(request);
|
6188
7094
|
if (addedSignatures) {
|
6189
7095
|
Array.from({ length: addedSignatures }).forEach(
|
6190
7096
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6217,13 +7123,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6217
7123
|
fundingAttempts += 1;
|
6218
7124
|
}
|
6219
7125
|
if (needsToBeFunded) {
|
6220
|
-
throw new
|
6221
|
-
|
7126
|
+
throw new import_errors19.FuelError(
|
7127
|
+
import_errors19.ErrorCode.NOT_ENOUGH_FUNDS,
|
6222
7128
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6223
7129
|
);
|
6224
7130
|
}
|
6225
7131
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6226
|
-
const requestToReestimate = (0,
|
7132
|
+
const requestToReestimate = (0, import_ramda9.clone)(request);
|
6227
7133
|
if (addedSignatures) {
|
6228
7134
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6229
7135
|
}
|
@@ -6323,8 +7229,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6323
7229
|
*/
|
6324
7230
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6325
7231
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6326
|
-
throw new
|
6327
|
-
|
7232
|
+
throw new import_errors19.FuelError(
|
7233
|
+
import_errors19.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6328
7234
|
"Transfer amount must be a positive number."
|
6329
7235
|
);
|
6330
7236
|
}
|
@@ -6363,14 +7269,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6363
7269
|
*/
|
6364
7270
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
6365
7271
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
6366
|
-
const recipientDataArray = (0,
|
7272
|
+
const recipientDataArray = (0, import_utils34.arrayify)(
|
6367
7273
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
6368
7274
|
);
|
6369
|
-
const amountDataArray = (0,
|
7275
|
+
const amountDataArray = (0, import_utils34.arrayify)(
|
6370
7276
|
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
6371
7277
|
);
|
6372
7278
|
const script = new Uint8Array([
|
6373
|
-
...(0,
|
7279
|
+
...(0, import_utils34.arrayify)(withdrawScript.bytes),
|
6374
7280
|
...recipientDataArray,
|
6375
7281
|
...amountDataArray
|
6376
7282
|
]);
|
@@ -6399,13 +7305,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6399
7305
|
* @returns A promise that resolves to the transaction cost object.
|
6400
7306
|
*/
|
6401
7307
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6402
|
-
const txRequestClone = (0,
|
7308
|
+
const txRequestClone = (0, import_ramda9.clone)(transactionRequestify(transactionRequestLike));
|
6403
7309
|
const baseAssetId = this.provider.getBaseAssetId();
|
6404
7310
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6405
7311
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6406
7312
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
|
6407
7313
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6408
|
-
if (input.type ===
|
7314
|
+
if (input.type === import_transactions24.InputType.Coin) {
|
6409
7315
|
return input.assetId === assetId;
|
6410
7316
|
}
|
6411
7317
|
if (isRequestInputMessageWithoutData(input)) {
|
@@ -6450,7 +7356,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6450
7356
|
*/
|
6451
7357
|
async signMessage(message) {
|
6452
7358
|
if (!this._connector) {
|
6453
|
-
throw new
|
7359
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6454
7360
|
}
|
6455
7361
|
return this._connector.signMessage(this.address.toString(), message);
|
6456
7362
|
}
|
@@ -6462,8 +7368,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6462
7368
|
*/
|
6463
7369
|
async signTransaction(transactionRequestLike) {
|
6464
7370
|
if (!this._connector) {
|
6465
|
-
throw new
|
6466
|
-
|
7371
|
+
throw new import_errors19.FuelError(
|
7372
|
+
import_errors19.ErrorCode.MISSING_CONNECTOR,
|
6467
7373
|
"A connector is required to sign transactions."
|
6468
7374
|
);
|
6469
7375
|
}
|
@@ -6512,7 +7418,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6512
7418
|
*/
|
6513
7419
|
generateFakeResources(coins) {
|
6514
7420
|
return coins.map((coin) => ({
|
6515
|
-
id: (0,
|
7421
|
+
id: (0, import_utils34.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
6516
7422
|
owner: this.address,
|
6517
7423
|
blockCreated: (0, import_math21.bn)(1),
|
6518
7424
|
txCreatedIdx: (0, import_math21.bn)(1),
|
@@ -6522,8 +7428,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6522
7428
|
/** @hidden * */
|
6523
7429
|
validateTransferAmount(amount) {
|
6524
7430
|
if ((0, import_math21.bn)(amount).lte(0)) {
|
6525
|
-
throw new
|
6526
|
-
|
7431
|
+
throw new import_errors19.FuelError(
|
7432
|
+
import_errors19.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6527
7433
|
"Transfer amount must be a positive number."
|
6528
7434
|
);
|
6529
7435
|
}
|
@@ -6549,19 +7455,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6549
7455
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
6550
7456
|
}) {
|
6551
7457
|
const request = transactionRequestify(transactionRequest);
|
6552
|
-
if (!(0,
|
7458
|
+
if (!(0, import_utils34.isDefined)(setGasLimit)) {
|
6553
7459
|
request.gasLimit = gasUsed;
|
6554
7460
|
} else if (gasUsed.gt(setGasLimit)) {
|
6555
|
-
throw new
|
6556
|
-
|
7461
|
+
throw new import_errors19.FuelError(
|
7462
|
+
import_errors19.ErrorCode.GAS_LIMIT_TOO_LOW,
|
6557
7463
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6558
7464
|
);
|
6559
7465
|
}
|
6560
|
-
if (!(0,
|
7466
|
+
if (!(0, import_utils34.isDefined)(setMaxFee)) {
|
6561
7467
|
request.maxFee = maxFee;
|
6562
7468
|
} else if (maxFee.gt(setMaxFee)) {
|
6563
|
-
throw new
|
6564
|
-
|
7469
|
+
throw new import_errors19.FuelError(
|
7470
|
+
import_errors19.ErrorCode.MAX_FEE_TOO_LOW,
|
6565
7471
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6566
7472
|
);
|
6567
7473
|
}
|
@@ -6570,15 +7476,15 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6570
7476
|
};
|
6571
7477
|
|
6572
7478
|
// src/wallet/base-wallet-unlocked.ts
|
6573
|
-
var
|
6574
|
-
var
|
7479
|
+
var import_hasher4 = require("@fuel-ts/hasher");
|
7480
|
+
var import_utils37 = require("@fuel-ts/utils");
|
6575
7481
|
|
6576
7482
|
// src/signer/signer.ts
|
6577
7483
|
var import_address5 = require("@fuel-ts/address");
|
6578
7484
|
var import_crypto3 = require("@fuel-ts/crypto");
|
6579
|
-
var
|
7485
|
+
var import_hasher3 = require("@fuel-ts/hasher");
|
6580
7486
|
var import_math22 = require("@fuel-ts/math");
|
6581
|
-
var
|
7487
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6582
7488
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
6583
7489
|
var Signer = class {
|
6584
7490
|
address;
|
@@ -6598,9 +7504,9 @@ var Signer = class {
|
|
6598
7504
|
}
|
6599
7505
|
}
|
6600
7506
|
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
6601
|
-
this.privateKey = (0,
|
6602
|
-
this.publicKey = (0,
|
6603
|
-
this.compressedPublicKey = (0,
|
7507
|
+
this.privateKey = (0, import_utils35.hexlify)(privateKeyBytes);
|
7508
|
+
this.publicKey = (0, import_utils35.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
7509
|
+
this.compressedPublicKey = (0, import_utils35.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
6604
7510
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
6605
7511
|
}
|
6606
7512
|
/**
|
@@ -6614,11 +7520,11 @@ var Signer = class {
|
|
6614
7520
|
* @returns hashed signature
|
6615
7521
|
*/
|
6616
7522
|
sign(data) {
|
6617
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
7523
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils35.arrayify)(data), (0, import_utils35.arrayify)(this.privateKey));
|
6618
7524
|
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
6619
7525
|
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
6620
7526
|
s[0] |= (signature.recovery || 0) << 7;
|
6621
|
-
return (0,
|
7527
|
+
return (0, import_utils35.hexlify)((0, import_utils35.concat)([r, s]));
|
6622
7528
|
}
|
6623
7529
|
/**
|
6624
7530
|
* Add point on the current elliptic curve
|
@@ -6627,8 +7533,8 @@ var Signer = class {
|
|
6627
7533
|
* @returns compressed point on the curve
|
6628
7534
|
*/
|
6629
7535
|
addPoint(point) {
|
6630
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6631
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
7536
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils35.arrayify)(this.compressedPublicKey));
|
7537
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils35.arrayify)(point));
|
6632
7538
|
const result = p0.add(p1);
|
6633
7539
|
return `0x${result.toHex(true)}`;
|
6634
7540
|
}
|
@@ -6640,16 +7546,16 @@ var Signer = class {
|
|
6640
7546
|
* @returns public key from signature from the
|
6641
7547
|
*/
|
6642
7548
|
static recoverPublicKey(data, signature) {
|
6643
|
-
const signedMessageBytes = (0,
|
7549
|
+
const signedMessageBytes = (0, import_utils35.arrayify)(signature);
|
6644
7550
|
const r = signedMessageBytes.slice(0, 32);
|
6645
7551
|
const s = signedMessageBytes.slice(32, 64);
|
6646
7552
|
const recoveryParam = (s[0] & 128) >> 7;
|
6647
7553
|
s[0] &= 127;
|
6648
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
7554
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils35.hexlify)(r)), BigInt((0, import_utils35.hexlify)(s))).addRecoveryBit(
|
6649
7555
|
recoveryParam
|
6650
7556
|
);
|
6651
|
-
const publicKey = sig.recoverPublicKey((0,
|
6652
|
-
return (0,
|
7557
|
+
const publicKey = sig.recoverPublicKey((0, import_utils35.arrayify)(data)).toRawBytes(false).slice(1);
|
7558
|
+
return (0, import_utils35.hexlify)(publicKey);
|
6653
7559
|
}
|
6654
7560
|
/**
|
6655
7561
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -6668,7 +7574,7 @@ var Signer = class {
|
|
6668
7574
|
* @returns random 32-byte hashed
|
6669
7575
|
*/
|
6670
7576
|
static generatePrivateKey(entropy) {
|
6671
|
-
return entropy ? (0,
|
7577
|
+
return entropy ? (0, import_hasher3.hash)((0, import_utils35.concat)([(0, import_crypto3.randomBytes)(32), (0, import_utils35.arrayify)(entropy)])) : (0, import_crypto3.randomBytes)(32);
|
6672
7578
|
}
|
6673
7579
|
/**
|
6674
7580
|
* Extended publicKey from a compact publicKey
|
@@ -6677,16 +7583,16 @@ var Signer = class {
|
|
6677
7583
|
* @returns extended publicKey
|
6678
7584
|
*/
|
6679
7585
|
static extendPublicKey(publicKey) {
|
6680
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
6681
|
-
return (0,
|
7586
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils35.arrayify)(publicKey));
|
7587
|
+
return (0, import_utils35.hexlify)(point.toRawBytes(false).slice(1));
|
6682
7588
|
}
|
6683
7589
|
};
|
6684
7590
|
|
6685
7591
|
// src/wallet/keystore-wallet.ts
|
6686
7592
|
var import_address6 = require("@fuel-ts/address");
|
6687
7593
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6688
|
-
var
|
6689
|
-
var
|
7594
|
+
var import_errors20 = require("@fuel-ts/errors");
|
7595
|
+
var import_utils36 = require("@fuel-ts/utils");
|
6690
7596
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6691
7597
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6692
7598
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6762,13 +7668,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6762
7668
|
const macHashUint8Array = (0, import_crypto4.keccak256)(data);
|
6763
7669
|
const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
|
6764
7670
|
if (mac !== macHash) {
|
6765
|
-
throw new
|
6766
|
-
|
7671
|
+
throw new import_errors20.FuelError(
|
7672
|
+
import_errors20.ErrorCode.INVALID_PASSWORD,
|
6767
7673
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6768
7674
|
);
|
6769
7675
|
}
|
6770
7676
|
const buffer = await (0, import_crypto4.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6771
|
-
const privateKey = (0,
|
7677
|
+
const privateKey = (0, import_utils36.hexlify)(buffer);
|
6772
7678
|
return privateKey;
|
6773
7679
|
}
|
6774
7680
|
|
@@ -6812,8 +7718,8 @@ var BaseWalletUnlocked = class extends Account {
|
|
6812
7718
|
* @returns A promise that resolves to the signature as a ECDSA 64 bytes string.
|
6813
7719
|
*/
|
6814
7720
|
async signMessage(message) {
|
6815
|
-
const signedMessage = await this.signer().sign((0,
|
6816
|
-
return (0,
|
7721
|
+
const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
|
7722
|
+
return (0, import_utils37.hexlify)(signedMessage);
|
6817
7723
|
}
|
6818
7724
|
/**
|
6819
7725
|
* Signs a transaction with the wallet's private key.
|
@@ -6826,7 +7732,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6826
7732
|
const chainId = this.provider.getChainId();
|
6827
7733
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6828
7734
|
const signature = await this.signer().sign(hashedTransaction);
|
6829
|
-
return (0,
|
7735
|
+
return (0, import_utils37.hexlify)(signature);
|
6830
7736
|
}
|
6831
7737
|
/**
|
6832
7738
|
* Populates a transaction with the witnesses signature.
|
@@ -6893,16 +7799,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6893
7799
|
|
6894
7800
|
// src/hdwallet/hdwallet.ts
|
6895
7801
|
var import_crypto6 = require("@fuel-ts/crypto");
|
6896
|
-
var
|
6897
|
-
var
|
7802
|
+
var import_errors23 = require("@fuel-ts/errors");
|
7803
|
+
var import_hasher7 = require("@fuel-ts/hasher");
|
6898
7804
|
var import_math23 = require("@fuel-ts/math");
|
6899
|
-
var
|
7805
|
+
var import_utils41 = require("@fuel-ts/utils");
|
6900
7806
|
|
6901
7807
|
// src/mnemonic/mnemonic.ts
|
6902
7808
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6903
|
-
var
|
6904
|
-
var
|
6905
|
-
var
|
7809
|
+
var import_errors22 = require("@fuel-ts/errors");
|
7810
|
+
var import_hasher6 = require("@fuel-ts/hasher");
|
7811
|
+
var import_utils39 = require("@fuel-ts/utils");
|
6906
7812
|
|
6907
7813
|
// src/wordlists/words/english.ts
|
6908
7814
|
var english = [
|
@@ -8963,9 +9869,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8963
9869
|
})(Language || {});
|
8964
9870
|
|
8965
9871
|
// src/mnemonic/utils.ts
|
8966
|
-
var
|
8967
|
-
var
|
8968
|
-
var
|
9872
|
+
var import_errors21 = require("@fuel-ts/errors");
|
9873
|
+
var import_hasher5 = require("@fuel-ts/hasher");
|
9874
|
+
var import_utils38 = require("@fuel-ts/utils");
|
8969
9875
|
function getLowerMask(bits) {
|
8970
9876
|
return (1 << bits) - 1;
|
8971
9877
|
}
|
@@ -9000,20 +9906,20 @@ function entropyToMnemonicIndices(entropy) {
|
|
9000
9906
|
}
|
9001
9907
|
}
|
9002
9908
|
const checksumBits = entropy.length / 4;
|
9003
|
-
const checksum = (0,
|
9909
|
+
const checksum = (0, import_utils38.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
9004
9910
|
indices[indices.length - 1] <<= checksumBits;
|
9005
9911
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
9006
9912
|
return indices;
|
9007
9913
|
}
|
9008
9914
|
function mnemonicWordsToEntropy(words, wordlist) {
|
9009
9915
|
const size = Math.ceil(11 * words.length / 8);
|
9010
|
-
const entropy = (0,
|
9916
|
+
const entropy = (0, import_utils38.arrayify)(new Uint8Array(size));
|
9011
9917
|
let offset = 0;
|
9012
9918
|
for (let i = 0; i < words.length; i += 1) {
|
9013
9919
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9014
9920
|
if (index === -1) {
|
9015
|
-
throw new
|
9016
|
-
|
9921
|
+
throw new import_errors21.FuelError(
|
9922
|
+
import_errors21.ErrorCode.INVALID_MNEMONIC,
|
9017
9923
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9018
9924
|
);
|
9019
9925
|
}
|
@@ -9027,10 +9933,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9027
9933
|
const entropyBits = 32 * words.length / 3;
|
9028
9934
|
const checksumBits = words.length / 3;
|
9029
9935
|
const checksumMask = getUpperMask(checksumBits);
|
9030
|
-
const checksum = (0,
|
9936
|
+
const checksum = (0, import_utils38.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9031
9937
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9032
|
-
throw new
|
9033
|
-
|
9938
|
+
throw new import_errors21.FuelError(
|
9939
|
+
import_errors21.ErrorCode.INVALID_CHECKSUM,
|
9034
9940
|
"Checksum validation failed for the provided mnemonic."
|
9035
9941
|
);
|
9036
9942
|
}
|
@@ -9038,22 +9944,22 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9038
9944
|
}
|
9039
9945
|
|
9040
9946
|
// src/mnemonic/mnemonic.ts
|
9041
|
-
var MasterSecret = (0,
|
9947
|
+
var MasterSecret = (0, import_utils39.toUtf8Bytes)("Bitcoin seed");
|
9042
9948
|
var MainnetPRV = "0x0488ade4";
|
9043
9949
|
var TestnetPRV = "0x04358394";
|
9044
9950
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9045
9951
|
function assertWordList(wordlist) {
|
9046
9952
|
if (wordlist.length !== 2048) {
|
9047
|
-
throw new
|
9048
|
-
|
9953
|
+
throw new import_errors22.FuelError(
|
9954
|
+
import_errors22.ErrorCode.INVALID_WORD_LIST,
|
9049
9955
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9050
9956
|
);
|
9051
9957
|
}
|
9052
9958
|
}
|
9053
9959
|
function assertEntropy(entropy) {
|
9054
9960
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9055
|
-
throw new
|
9056
|
-
|
9961
|
+
throw new import_errors22.FuelError(
|
9962
|
+
import_errors22.ErrorCode.INVALID_ENTROPY,
|
9057
9963
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9058
9964
|
);
|
9059
9965
|
}
|
@@ -9063,7 +9969,7 @@ function assertMnemonic(words) {
|
|
9063
9969
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9064
9970
|
", "
|
9065
9971
|
)}] words, but got ${words.length}.`;
|
9066
|
-
throw new
|
9972
|
+
throw new import_errors22.FuelError(import_errors22.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
9067
9973
|
}
|
9068
9974
|
}
|
9069
9975
|
var Mnemonic = class {
|
@@ -9102,7 +10008,7 @@ var Mnemonic = class {
|
|
9102
10008
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
9103
10009
|
const words = getWords(phrase);
|
9104
10010
|
assertMnemonic(words);
|
9105
|
-
return (0,
|
10011
|
+
return (0, import_utils39.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
9106
10012
|
}
|
9107
10013
|
/**
|
9108
10014
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -9110,7 +10016,7 @@ var Mnemonic = class {
|
|
9110
10016
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9111
10017
|
*/
|
9112
10018
|
static entropyToMnemonic(entropy, wordlist = english) {
|
9113
|
-
const entropyBytes = (0,
|
10019
|
+
const entropyBytes = (0, import_utils39.arrayify)(entropy);
|
9114
10020
|
assertWordList(wordlist);
|
9115
10021
|
assertEntropy(entropyBytes);
|
9116
10022
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -9122,8 +10028,8 @@ var Mnemonic = class {
|
|
9122
10028
|
*/
|
9123
10029
|
static mnemonicToSeed(phrase, passphrase = "") {
|
9124
10030
|
assertMnemonic(getWords(phrase));
|
9125
|
-
const phraseBytes = (0,
|
9126
|
-
const salt = (0,
|
10031
|
+
const phraseBytes = (0, import_utils39.toUtf8Bytes)(getPhrase(phrase));
|
10032
|
+
const salt = (0, import_utils39.toUtf8Bytes)(`mnemonic${passphrase}`);
|
9127
10033
|
return (0, import_crypto5.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
9128
10034
|
}
|
9129
10035
|
/**
|
@@ -9179,14 +10085,14 @@ var Mnemonic = class {
|
|
9179
10085
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9180
10086
|
*/
|
9181
10087
|
static masterKeysFromSeed(seed) {
|
9182
|
-
const seedArray = (0,
|
10088
|
+
const seedArray = (0, import_utils39.arrayify)(seed);
|
9183
10089
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9184
|
-
throw new
|
9185
|
-
|
10090
|
+
throw new import_errors22.FuelError(
|
10091
|
+
import_errors22.ErrorCode.INVALID_SEED,
|
9186
10092
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9187
10093
|
);
|
9188
10094
|
}
|
9189
|
-
return (0,
|
10095
|
+
return (0, import_utils39.arrayify)((0, import_crypto5.computeHmac)("sha512", MasterSecret, seedArray));
|
9190
10096
|
}
|
9191
10097
|
/**
|
9192
10098
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -9197,22 +10103,22 @@ var Mnemonic = class {
|
|
9197
10103
|
*/
|
9198
10104
|
static seedToExtendedKey(seed, testnet = false) {
|
9199
10105
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
9200
|
-
const prefix = (0,
|
10106
|
+
const prefix = (0, import_utils39.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
9201
10107
|
const depth = "0x00";
|
9202
10108
|
const fingerprint = "0x00000000";
|
9203
10109
|
const index = "0x00000000";
|
9204
10110
|
const chainCode = masterKey.slice(32);
|
9205
10111
|
const privateKey = masterKey.slice(0, 32);
|
9206
|
-
const extendedKey = (0,
|
10112
|
+
const extendedKey = (0, import_utils39.concat)([
|
9207
10113
|
prefix,
|
9208
10114
|
depth,
|
9209
10115
|
fingerprint,
|
9210
10116
|
index,
|
9211
10117
|
chainCode,
|
9212
|
-
(0,
|
10118
|
+
(0, import_utils39.concat)(["0x00", privateKey])
|
9213
10119
|
]);
|
9214
|
-
const checksum = (0,
|
9215
|
-
return (0,
|
10120
|
+
const checksum = (0, import_utils39.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
|
10121
|
+
return (0, import_utils39.encodeBase58)((0, import_utils39.concat)([extendedKey, checksum]));
|
9216
10122
|
}
|
9217
10123
|
/**
|
9218
10124
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -9227,7 +10133,7 @@ var Mnemonic = class {
|
|
9227
10133
|
* @returns A randomly generated mnemonic
|
9228
10134
|
*/
|
9229
10135
|
static generate(size = 32, extraEntropy = "") {
|
9230
|
-
const entropy = extraEntropy ? (0,
|
10136
|
+
const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils39.concat)([(0, import_crypto5.randomBytes)(size), (0, import_utils39.arrayify)(extraEntropy)])) : (0, import_crypto5.randomBytes)(size);
|
9231
10137
|
return Mnemonic.entropyToMnemonic(entropy);
|
9232
10138
|
}
|
9233
10139
|
};
|
@@ -9235,12 +10141,12 @@ var mnemonic_default = Mnemonic;
|
|
9235
10141
|
|
9236
10142
|
// src/hdwallet/hdwallet.ts
|
9237
10143
|
var HARDENED_INDEX = 2147483648;
|
9238
|
-
var MainnetPRV2 = (0,
|
9239
|
-
var MainnetPUB = (0,
|
9240
|
-
var TestnetPRV2 = (0,
|
9241
|
-
var TestnetPUB = (0,
|
10144
|
+
var MainnetPRV2 = (0, import_utils41.hexlify)("0x0488ade4");
|
10145
|
+
var MainnetPUB = (0, import_utils41.hexlify)("0x0488b21e");
|
10146
|
+
var TestnetPRV2 = (0, import_utils41.hexlify)("0x04358394");
|
10147
|
+
var TestnetPUB = (0, import_utils41.hexlify)("0x043587cf");
|
9242
10148
|
function base58check(data) {
|
9243
|
-
return (0,
|
10149
|
+
return (0, import_utils41.encodeBase58)((0, import_utils41.concat)([data, (0, import_utils41.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
|
9244
10150
|
}
|
9245
10151
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
9246
10152
|
if (isPublic) {
|
@@ -9249,17 +10155,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9249
10155
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9250
10156
|
}
|
9251
10157
|
function isPublicExtendedKey(extendedKey) {
|
9252
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
10158
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils41.hexlify)(extendedKey.slice(0, 4)));
|
9253
10159
|
}
|
9254
10160
|
function isValidExtendedKey(extendedKey) {
|
9255
10161
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9256
|
-
(0,
|
10162
|
+
(0, import_utils41.hexlify)(extendedKey.slice(0, 4))
|
9257
10163
|
);
|
9258
10164
|
}
|
9259
10165
|
function parsePath(path, depth = 0) {
|
9260
10166
|
const components = path.split("/");
|
9261
10167
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9262
|
-
throw new
|
10168
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
9263
10169
|
}
|
9264
10170
|
if (components[0] === "m") {
|
9265
10171
|
components.shift();
|
@@ -9271,8 +10177,8 @@ function parsePath(path, depth = 0) {
|
|
9271
10177
|
var HDWallet = class {
|
9272
10178
|
depth = 0;
|
9273
10179
|
index = 0;
|
9274
|
-
fingerprint = (0,
|
9275
|
-
parentFingerprint = (0,
|
10180
|
+
fingerprint = (0, import_utils41.hexlify)("0x00000000");
|
10181
|
+
parentFingerprint = (0, import_utils41.hexlify)("0x00000000");
|
9276
10182
|
privateKey;
|
9277
10183
|
publicKey;
|
9278
10184
|
chainCode;
|
@@ -9284,19 +10190,19 @@ var HDWallet = class {
|
|
9284
10190
|
constructor(config) {
|
9285
10191
|
if (config.privateKey) {
|
9286
10192
|
const signer = new Signer(config.privateKey);
|
9287
|
-
this.publicKey = (0,
|
9288
|
-
this.privateKey = (0,
|
10193
|
+
this.publicKey = (0, import_utils41.hexlify)(signer.compressedPublicKey);
|
10194
|
+
this.privateKey = (0, import_utils41.hexlify)(config.privateKey);
|
9289
10195
|
} else {
|
9290
10196
|
if (!config.publicKey) {
|
9291
|
-
throw new
|
9292
|
-
|
10197
|
+
throw new import_errors23.FuelError(
|
10198
|
+
import_errors23.ErrorCode.HD_WALLET_ERROR,
|
9293
10199
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9294
10200
|
);
|
9295
10201
|
}
|
9296
|
-
this.publicKey = (0,
|
10202
|
+
this.publicKey = (0, import_utils41.hexlify)(config.publicKey);
|
9297
10203
|
}
|
9298
10204
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
9299
|
-
this.fingerprint = (0,
|
10205
|
+
this.fingerprint = (0, import_utils41.dataSlice)((0, import_crypto6.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
|
9300
10206
|
this.depth = config.depth || this.depth;
|
9301
10207
|
this.index = config.index || this.index;
|
9302
10208
|
this.chainCode = config.chainCode;
|
@@ -9312,23 +10218,23 @@ var HDWallet = class {
|
|
9312
10218
|
* @returns A new instance of HDWallet on the derived index
|
9313
10219
|
*/
|
9314
10220
|
deriveIndex(index) {
|
9315
|
-
const privateKey = this.privateKey && (0,
|
9316
|
-
const publicKey = (0,
|
9317
|
-
const chainCode = (0,
|
10221
|
+
const privateKey = this.privateKey && (0, import_utils41.arrayify)(this.privateKey);
|
10222
|
+
const publicKey = (0, import_utils41.arrayify)(this.publicKey);
|
10223
|
+
const chainCode = (0, import_utils41.arrayify)(this.chainCode);
|
9318
10224
|
const data = new Uint8Array(37);
|
9319
10225
|
if (index & HARDENED_INDEX) {
|
9320
10226
|
if (!privateKey) {
|
9321
|
-
throw new
|
9322
|
-
|
10227
|
+
throw new import_errors23.FuelError(
|
10228
|
+
import_errors23.ErrorCode.HD_WALLET_ERROR,
|
9323
10229
|
"Cannot derive a hardened index without a private Key."
|
9324
10230
|
);
|
9325
10231
|
}
|
9326
10232
|
data.set(privateKey, 1);
|
9327
10233
|
} else {
|
9328
|
-
data.set((0,
|
10234
|
+
data.set((0, import_utils41.arrayify)(this.publicKey));
|
9329
10235
|
}
|
9330
10236
|
data.set((0, import_math23.toBytes)(index, 4), 33);
|
9331
|
-
const bytes = (0,
|
10237
|
+
const bytes = (0, import_utils41.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
|
9332
10238
|
const IL = bytes.slice(0, 32);
|
9333
10239
|
const IR = bytes.slice(32);
|
9334
10240
|
if (privateKey) {
|
@@ -9342,7 +10248,7 @@ var HDWallet = class {
|
|
9342
10248
|
parentFingerprint: this.fingerprint
|
9343
10249
|
});
|
9344
10250
|
}
|
9345
|
-
const signer = new Signer((0,
|
10251
|
+
const signer = new Signer((0, import_utils41.hexlify)(IL));
|
9346
10252
|
const Ki = signer.addPoint(publicKey);
|
9347
10253
|
return new HDWallet({
|
9348
10254
|
publicKey: Ki,
|
@@ -9371,18 +10277,18 @@ var HDWallet = class {
|
|
9371
10277
|
*/
|
9372
10278
|
toExtendedKey(isPublic = false, testnet = false) {
|
9373
10279
|
if (this.depth >= 256) {
|
9374
|
-
throw new
|
9375
|
-
|
10280
|
+
throw new import_errors23.FuelError(
|
10281
|
+
import_errors23.ErrorCode.HD_WALLET_ERROR,
|
9376
10282
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9377
10283
|
);
|
9378
10284
|
}
|
9379
10285
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9380
|
-
const depth = (0,
|
10286
|
+
const depth = (0, import_utils41.hexlify)(Uint8Array.from([this.depth]));
|
9381
10287
|
const parentFingerprint = this.parentFingerprint;
|
9382
10288
|
const index = (0, import_math23.toHex)(this.index, 4);
|
9383
10289
|
const chainCode = this.chainCode;
|
9384
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
9385
|
-
const extendedKey = (0,
|
10290
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils41.concat)(["0x00", this.privateKey]) : this.publicKey;
|
10291
|
+
const extendedKey = (0, import_utils41.arrayify)((0, import_utils41.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9386
10292
|
return base58check(extendedKey);
|
9387
10293
|
}
|
9388
10294
|
/**
|
@@ -9394,34 +10300,34 @@ var HDWallet = class {
|
|
9394
10300
|
static fromSeed(seed) {
|
9395
10301
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9396
10302
|
return new HDWallet({
|
9397
|
-
chainCode: (0,
|
9398
|
-
privateKey: (0,
|
10303
|
+
chainCode: (0, import_utils41.arrayify)(masterKey.slice(32)),
|
10304
|
+
privateKey: (0, import_utils41.arrayify)(masterKey.slice(0, 32))
|
9399
10305
|
});
|
9400
10306
|
}
|
9401
10307
|
static fromExtendedKey(extendedKey) {
|
9402
|
-
const decoded = (0,
|
9403
|
-
const bytes = (0,
|
10308
|
+
const decoded = (0, import_utils41.hexlify)((0, import_math23.toBytes)((0, import_utils41.decodeBase58)(extendedKey)));
|
10309
|
+
const bytes = (0, import_utils41.arrayify)(decoded);
|
9404
10310
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9405
10311
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9406
|
-
throw new
|
10312
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9407
10313
|
}
|
9408
10314
|
if (!validChecksum) {
|
9409
|
-
throw new
|
10315
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9410
10316
|
}
|
9411
10317
|
const depth = bytes[4];
|
9412
|
-
const parentFingerprint = (0,
|
9413
|
-
const index = parseInt((0,
|
9414
|
-
const chainCode = (0,
|
10318
|
+
const parentFingerprint = (0, import_utils41.hexlify)(bytes.slice(5, 9));
|
10319
|
+
const index = parseInt((0, import_utils41.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
10320
|
+
const chainCode = (0, import_utils41.hexlify)(bytes.slice(13, 45));
|
9415
10321
|
const key = bytes.slice(45, 78);
|
9416
10322
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9417
|
-
throw new
|
9418
|
-
|
10323
|
+
throw new import_errors23.FuelError(
|
10324
|
+
import_errors23.ErrorCode.HD_WALLET_ERROR,
|
9419
10325
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9420
10326
|
);
|
9421
10327
|
}
|
9422
10328
|
if (isPublicExtendedKey(bytes)) {
|
9423
10329
|
if (key[0] !== 3) {
|
9424
|
-
throw new
|
10330
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
9425
10331
|
}
|
9426
10332
|
return new HDWallet({
|
9427
10333
|
publicKey: key,
|
@@ -9432,7 +10338,7 @@ var HDWallet = class {
|
|
9432
10338
|
});
|
9433
10339
|
}
|
9434
10340
|
if (key[0] !== 0) {
|
9435
|
-
throw new
|
10341
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
9436
10342
|
}
|
9437
10343
|
return new HDWallet({
|
9438
10344
|
privateKey: key.slice(1),
|
@@ -9600,7 +10506,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9600
10506
|
// src/wallet-manager/wallet-manager.ts
|
9601
10507
|
var import_address9 = require("@fuel-ts/address");
|
9602
10508
|
var import_crypto7 = require("@fuel-ts/crypto");
|
9603
|
-
var
|
10509
|
+
var import_errors26 = require("@fuel-ts/errors");
|
9604
10510
|
var import_events = require("events");
|
9605
10511
|
|
9606
10512
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9623,7 +10529,7 @@ var MemoryStorage = class {
|
|
9623
10529
|
|
9624
10530
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9625
10531
|
var import_address7 = require("@fuel-ts/address");
|
9626
|
-
var
|
10532
|
+
var import_errors24 = require("@fuel-ts/errors");
|
9627
10533
|
var _secret;
|
9628
10534
|
var MnemonicVault = class {
|
9629
10535
|
constructor(options) {
|
@@ -9679,8 +10585,8 @@ var MnemonicVault = class {
|
|
9679
10585
|
}
|
9680
10586
|
numberOfAccounts += 1;
|
9681
10587
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9682
|
-
throw new
|
9683
|
-
|
10588
|
+
throw new import_errors24.FuelError(
|
10589
|
+
import_errors24.ErrorCode.WALLET_MANAGER_ERROR,
|
9684
10590
|
`Account with address '${address}' not found in derived wallets.`
|
9685
10591
|
);
|
9686
10592
|
}
|
@@ -9694,7 +10600,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9694
10600
|
|
9695
10601
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9696
10602
|
var import_address8 = require("@fuel-ts/address");
|
9697
|
-
var
|
10603
|
+
var import_errors25 = require("@fuel-ts/errors");
|
9698
10604
|
var _privateKeys;
|
9699
10605
|
var PrivateKeyVault = class {
|
9700
10606
|
/**
|
@@ -9735,8 +10641,8 @@ var PrivateKeyVault = class {
|
|
9735
10641
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9736
10642
|
);
|
9737
10643
|
if (!privateKey) {
|
9738
|
-
throw new
|
9739
|
-
|
10644
|
+
throw new import_errors25.FuelError(
|
10645
|
+
import_errors25.ErrorCode.WALLET_MANAGER_ERROR,
|
9740
10646
|
`No private key found for address '${address}'.`
|
9741
10647
|
);
|
9742
10648
|
}
|
@@ -9760,7 +10666,7 @@ var ERROR_MESSAGES = {
|
|
9760
10666
|
};
|
9761
10667
|
function assert(condition, message) {
|
9762
10668
|
if (!condition) {
|
9763
|
-
throw new
|
10669
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.WALLET_MANAGER_ERROR, message);
|
9764
10670
|
}
|
9765
10671
|
}
|
9766
10672
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9986,25 +10892,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9986
10892
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9987
10893
|
|
9988
10894
|
// src/wallet-manager/types.ts
|
9989
|
-
var
|
10895
|
+
var import_errors27 = require("@fuel-ts/errors");
|
9990
10896
|
var Vault = class {
|
9991
10897
|
constructor(_options) {
|
9992
|
-
throw new
|
10898
|
+
throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9993
10899
|
}
|
9994
10900
|
serialize() {
|
9995
|
-
throw new
|
10901
|
+
throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9996
10902
|
}
|
9997
10903
|
getAccounts() {
|
9998
|
-
throw new
|
10904
|
+
throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
9999
10905
|
}
|
10000
10906
|
addAccount() {
|
10001
|
-
throw new
|
10907
|
+
throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10002
10908
|
}
|
10003
10909
|
exportAccount(_address) {
|
10004
|
-
throw new
|
10910
|
+
throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10005
10911
|
}
|
10006
10912
|
getWallet(_address) {
|
10007
|
-
throw new
|
10913
|
+
throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
10008
10914
|
}
|
10009
10915
|
};
|
10010
10916
|
__publicField(Vault, "type");
|
@@ -10014,19 +10920,19 @@ var StorageAbstract = class {
|
|
10014
10920
|
// src/predicate/predicate.ts
|
10015
10921
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
10016
10922
|
var import_address10 = require("@fuel-ts/address");
|
10017
|
-
var
|
10018
|
-
var
|
10923
|
+
var import_errors28 = require("@fuel-ts/errors");
|
10924
|
+
var import_utils43 = require("@fuel-ts/utils");
|
10019
10925
|
|
10020
10926
|
// src/predicate/utils/getPredicateRoot.ts
|
10021
|
-
var
|
10927
|
+
var import_hasher8 = require("@fuel-ts/hasher");
|
10022
10928
|
var import_merkle = require("@fuel-ts/merkle");
|
10023
|
-
var
|
10929
|
+
var import_utils42 = require("@fuel-ts/utils");
|
10024
10930
|
var getPredicateRoot = (bytecode) => {
|
10025
10931
|
const chunkSize = 16 * 1024;
|
10026
|
-
const bytes = (0,
|
10027
|
-
const chunks = (0,
|
10028
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
10029
|
-
const predicateRoot = (0,
|
10932
|
+
const bytes = (0, import_utils42.arrayify)(bytecode);
|
10933
|
+
const chunks = (0, import_utils42.chunkAndPadBytes)(bytes, chunkSize);
|
10934
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils42.hexlify)(c)));
|
10935
|
+
const predicateRoot = (0, import_hasher8.hash)((0, import_utils42.concat)(["0x4655454C", codeRoot]));
|
10030
10936
|
return predicateRoot;
|
10031
10937
|
};
|
10032
10938
|
|
@@ -10078,8 +10984,8 @@ var Predicate = class extends Account {
|
|
10078
10984
|
}
|
10079
10985
|
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
10080
10986
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
10081
|
-
input.predicate = (0,
|
10082
|
-
input.predicateData = (0,
|
10987
|
+
input.predicate = (0, import_utils43.hexlify)(this.bytes);
|
10988
|
+
input.predicateData = (0, import_utils43.hexlify)(this.getPredicateData());
|
10083
10989
|
input.witnessIndex = 0;
|
10084
10990
|
}
|
10085
10991
|
});
|
@@ -10121,13 +11027,13 @@ var Predicate = class extends Account {
|
|
10121
11027
|
* @returns An object containing the new predicate bytes and interface.
|
10122
11028
|
*/
|
10123
11029
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
10124
|
-
let predicateBytes = (0,
|
11030
|
+
let predicateBytes = (0, import_utils43.arrayify)(bytes);
|
10125
11031
|
let abiInterface;
|
10126
11032
|
if (jsonAbi) {
|
10127
11033
|
abiInterface = new import_abi_coder8.Interface(jsonAbi);
|
10128
11034
|
if (abiInterface.functions.main === void 0) {
|
10129
|
-
throw new
|
10130
|
-
|
11035
|
+
throw new import_errors28.FuelError(
|
11036
|
+
import_errors28.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
10131
11037
|
'Cannot use ABI without "main" function.'
|
10132
11038
|
);
|
10133
11039
|
}
|
@@ -10159,8 +11065,8 @@ var Predicate = class extends Account {
|
|
10159
11065
|
);
|
10160
11066
|
return resources.map((resource) => ({
|
10161
11067
|
...resource,
|
10162
|
-
predicate: (0,
|
10163
|
-
predicateData: (0,
|
11068
|
+
predicate: (0, import_utils43.hexlify)(this.bytes),
|
11069
|
+
predicateData: (0, import_utils43.hexlify)(this.getPredicateData())
|
10164
11070
|
}));
|
10165
11071
|
}
|
10166
11072
|
/**
|
@@ -10172,8 +11078,8 @@ var Predicate = class extends Account {
|
|
10172
11078
|
generateFakeResources(coins) {
|
10173
11079
|
return super.generateFakeResources(coins).map((coin) => ({
|
10174
11080
|
...coin,
|
10175
|
-
predicate: (0,
|
10176
|
-
predicateData: (0,
|
11081
|
+
predicate: (0, import_utils43.hexlify)(this.bytes),
|
11082
|
+
predicateData: (0, import_utils43.hexlify)(this.getPredicateData())
|
10177
11083
|
}));
|
10178
11084
|
}
|
10179
11085
|
/**
|
@@ -10188,21 +11094,21 @@ var Predicate = class extends Account {
|
|
10188
11094
|
const mutatedBytes = bytes;
|
10189
11095
|
try {
|
10190
11096
|
if (!abiInterface) {
|
10191
|
-
throw new
|
10192
|
-
|
11097
|
+
throw new import_errors28.FuelError(
|
11098
|
+
import_errors28.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10193
11099
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
10194
11100
|
);
|
10195
11101
|
}
|
10196
11102
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
10197
|
-
throw new
|
10198
|
-
|
11103
|
+
throw new import_errors28.FuelError(
|
11104
|
+
import_errors28.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10199
11105
|
"Predicate has no configurable constants to be set"
|
10200
11106
|
);
|
10201
11107
|
}
|
10202
11108
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
10203
11109
|
if (!abiInterface?.configurables[key]) {
|
10204
|
-
throw new
|
10205
|
-
|
11110
|
+
throw new import_errors28.FuelError(
|
11111
|
+
import_errors28.ErrorCode.CONFIGURABLE_NOT_FOUND,
|
10206
11112
|
`No configurable constant named '${key}' found in the Predicate`
|
10207
11113
|
);
|
10208
11114
|
}
|
@@ -10211,8 +11117,8 @@ var Predicate = class extends Account {
|
|
10211
11117
|
mutatedBytes.set(encoded, offset);
|
10212
11118
|
});
|
10213
11119
|
} catch (err) {
|
10214
|
-
throw new
|
10215
|
-
|
11120
|
+
throw new import_errors28.FuelError(
|
11121
|
+
import_errors28.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
10216
11122
|
`Error setting configurable constants: ${err.message}.`
|
10217
11123
|
);
|
10218
11124
|
}
|
@@ -10243,10 +11149,10 @@ var Predicate = class extends Account {
|
|
10243
11149
|
};
|
10244
11150
|
|
10245
11151
|
// src/connectors/fuel.ts
|
10246
|
-
var
|
11152
|
+
var import_errors31 = require("@fuel-ts/errors");
|
10247
11153
|
|
10248
11154
|
// src/connectors/fuel-connector.ts
|
10249
|
-
var
|
11155
|
+
var import_errors29 = require("@fuel-ts/errors");
|
10250
11156
|
var import_events2 = require("events");
|
10251
11157
|
|
10252
11158
|
// src/connectors/types/connector-types.ts
|
@@ -10320,7 +11226,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10320
11226
|
* @returns Always true.
|
10321
11227
|
*/
|
10322
11228
|
async ping() {
|
10323
|
-
throw new
|
11229
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10324
11230
|
}
|
10325
11231
|
/**
|
10326
11232
|
* Should return the current version of the connector
|
@@ -10329,7 +11235,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10329
11235
|
* @returns boolean - connection status.
|
10330
11236
|
*/
|
10331
11237
|
async version() {
|
10332
|
-
throw new
|
11238
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10333
11239
|
}
|
10334
11240
|
/**
|
10335
11241
|
* Should return true if the connector is connected
|
@@ -10338,7 +11244,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10338
11244
|
* @returns The connection status.
|
10339
11245
|
*/
|
10340
11246
|
async isConnected() {
|
10341
|
-
throw new
|
11247
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10342
11248
|
}
|
10343
11249
|
/**
|
10344
11250
|
* Should return all the accounts authorized for the
|
@@ -10347,7 +11253,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10347
11253
|
* @returns The accounts addresses strings
|
10348
11254
|
*/
|
10349
11255
|
async accounts() {
|
10350
|
-
throw new
|
11256
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10351
11257
|
}
|
10352
11258
|
/**
|
10353
11259
|
* Should start the connection process and return
|
@@ -10359,7 +11265,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10359
11265
|
* @returns boolean - connection status.
|
10360
11266
|
*/
|
10361
11267
|
async connect() {
|
10362
|
-
throw new
|
11268
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10363
11269
|
}
|
10364
11270
|
/**
|
10365
11271
|
* Should disconnect the current connection and
|
@@ -10369,7 +11275,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10369
11275
|
* @returns The connection status.
|
10370
11276
|
*/
|
10371
11277
|
async disconnect() {
|
10372
|
-
throw new
|
11278
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10373
11279
|
}
|
10374
11280
|
/**
|
10375
11281
|
* Should start the sign message process and return
|
@@ -10381,7 +11287,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10381
11287
|
* @returns Message signature
|
10382
11288
|
*/
|
10383
11289
|
async signMessage(_address, _message) {
|
10384
|
-
throw new
|
11290
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10385
11291
|
}
|
10386
11292
|
/**
|
10387
11293
|
* Should start the sign transaction process and return
|
@@ -10393,7 +11299,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10393
11299
|
* @returns Transaction signature
|
10394
11300
|
*/
|
10395
11301
|
async signTransaction(_address, _transaction) {
|
10396
|
-
throw new
|
11302
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10397
11303
|
}
|
10398
11304
|
/**
|
10399
11305
|
* Should start the send transaction process and return
|
@@ -10409,7 +11315,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10409
11315
|
* @returns The transaction id
|
10410
11316
|
*/
|
10411
11317
|
async sendTransaction(_address, _transaction) {
|
10412
|
-
throw new
|
11318
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10413
11319
|
}
|
10414
11320
|
/**
|
10415
11321
|
* Should return the current account selected inside the connector, if the account
|
@@ -10420,7 +11326,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10420
11326
|
* @returns The current account selected otherwise null.
|
10421
11327
|
*/
|
10422
11328
|
async currentAccount() {
|
10423
|
-
throw new
|
11329
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10424
11330
|
}
|
10425
11331
|
/**
|
10426
11332
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10434,7 +11340,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10434
11340
|
* @returns True if the asset was added successfully
|
10435
11341
|
*/
|
10436
11342
|
async addAssets(_assets) {
|
10437
|
-
throw new
|
11343
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10438
11344
|
}
|
10439
11345
|
/**
|
10440
11346
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10448,7 +11354,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10448
11354
|
* @returns True if the asset was added successfully
|
10449
11355
|
*/
|
10450
11356
|
async addAsset(_asset) {
|
10451
|
-
throw new
|
11357
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10452
11358
|
}
|
10453
11359
|
/**
|
10454
11360
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10456,7 +11362,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10456
11362
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10457
11363
|
*/
|
10458
11364
|
async assets() {
|
10459
|
-
throw new
|
11365
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10460
11366
|
}
|
10461
11367
|
/**
|
10462
11368
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10467,7 +11373,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10467
11373
|
* @returns Return true if the network was added successfully
|
10468
11374
|
*/
|
10469
11375
|
async addNetwork(_networkUrl) {
|
10470
|
-
throw new
|
11376
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10471
11377
|
}
|
10472
11378
|
/**
|
10473
11379
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10478,7 +11384,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10478
11384
|
* @returns Return true if the network was added successfully
|
10479
11385
|
*/
|
10480
11386
|
async selectNetwork(_network) {
|
10481
|
-
throw new
|
11387
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10482
11388
|
}
|
10483
11389
|
/**
|
10484
11390
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10486,7 +11392,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10486
11392
|
* @returns Return all the networks added to the connector.
|
10487
11393
|
*/
|
10488
11394
|
async networks() {
|
10489
|
-
throw new
|
11395
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10490
11396
|
}
|
10491
11397
|
/**
|
10492
11398
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10494,7 +11400,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10494
11400
|
* @returns Return the current network selected inside the connector.
|
10495
11401
|
*/
|
10496
11402
|
async currentNetwork() {
|
10497
|
-
throw new
|
11403
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10498
11404
|
}
|
10499
11405
|
/**
|
10500
11406
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10504,7 +11410,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10504
11410
|
* @returns Return true if the ABI was added successfully.
|
10505
11411
|
*/
|
10506
11412
|
async addABI(_contractId, _abi) {
|
10507
|
-
throw new
|
11413
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10508
11414
|
}
|
10509
11415
|
/**
|
10510
11416
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10513,7 +11419,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10513
11419
|
* @returns The ABI if it exists, otherwise return null.
|
10514
11420
|
*/
|
10515
11421
|
async getABI(_id) {
|
10516
|
-
throw new
|
11422
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10517
11423
|
}
|
10518
11424
|
/**
|
10519
11425
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10522,7 +11428,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
10522
11428
|
* @returns Returns true if the abi exists or false if not.
|
10523
11429
|
*/
|
10524
11430
|
async hasABI(_id) {
|
10525
|
-
throw new
|
11431
|
+
throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10526
11432
|
}
|
10527
11433
|
/**
|
10528
11434
|
* Event listener for the connector.
|
@@ -10566,7 +11472,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10566
11472
|
}
|
10567
11473
|
|
10568
11474
|
// src/connectors/utils/promises.ts
|
10569
|
-
var
|
11475
|
+
var import_errors30 = require("@fuel-ts/errors");
|
10570
11476
|
function deferPromise() {
|
10571
11477
|
const defer = {};
|
10572
11478
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10578,7 +11484,7 @@ function deferPromise() {
|
|
10578
11484
|
async function withTimeout(promise, timeout = 1050) {
|
10579
11485
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10580
11486
|
setTimeout(() => {
|
10581
|
-
reject(new
|
11487
|
+
reject(new import_errors30.FuelError(import_errors30.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10582
11488
|
}, timeout);
|
10583
11489
|
});
|
10584
11490
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10612,7 +11518,7 @@ var _Fuel = class extends FuelConnector {
|
|
10612
11518
|
await this.setDefaultConnector();
|
10613
11519
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10614
11520
|
} catch (error) {
|
10615
|
-
throw new
|
11521
|
+
throw new import_errors31.FuelError(import_errors31.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10616
11522
|
}
|
10617
11523
|
}
|
10618
11524
|
async init() {
|
@@ -10678,8 +11584,8 @@ var _Fuel = class extends FuelConnector {
|
|
10678
11584
|
const hasConnector = await this.hasConnector();
|
10679
11585
|
await this.pingConnector();
|
10680
11586
|
if (!this._currentConnector || !hasConnector) {
|
10681
|
-
throw new
|
10682
|
-
|
11587
|
+
throw new import_errors31.FuelError(
|
11588
|
+
import_errors31.ErrorCode.MISSING_CONNECTOR,
|
10683
11589
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10684
11590
|
);
|
10685
11591
|
}
|
@@ -10743,7 +11649,7 @@ var _Fuel = class extends FuelConnector {
|
|
10743
11649
|
cacheTime: PING_CACHE_TIME
|
10744
11650
|
})();
|
10745
11651
|
} catch {
|
10746
|
-
throw new
|
11652
|
+
throw new import_errors31.FuelError(import_errors31.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
|
10747
11653
|
}
|
10748
11654
|
}
|
10749
11655
|
/**
|
@@ -10892,7 +11798,7 @@ var _Fuel = class extends FuelConnector {
|
|
10892
11798
|
const currentNetwork = await this.currentNetwork();
|
10893
11799
|
provider = await Provider.create(currentNetwork.url);
|
10894
11800
|
} else {
|
10895
|
-
throw new
|
11801
|
+
throw new import_errors31.FuelError(import_errors31.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
10896
11802
|
}
|
10897
11803
|
return provider;
|
10898
11804
|
}
|
@@ -10969,6 +11875,8 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10969
11875
|
TransactionStatus,
|
10970
11876
|
TransactionType,
|
10971
11877
|
TransactionTypeName,
|
11878
|
+
UpgradeTransactionRequest,
|
11879
|
+
UploadTransactionRequest,
|
10972
11880
|
Vault,
|
10973
11881
|
Wallet,
|
10974
11882
|
WalletLocked,
|
@@ -10990,6 +11898,9 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10990
11898
|
calculateMetadataGasForTxBlob,
|
10991
11899
|
calculateMetadataGasForTxCreate,
|
10992
11900
|
calculateMetadataGasForTxScript,
|
11901
|
+
calculateMetadataGasForTxUpgrade,
|
11902
|
+
calculateMetadataGasForTxUpload,
|
11903
|
+
calculateMinGasForTxUpload,
|
10993
11904
|
calculateTXFeeForSummary,
|
10994
11905
|
coinQuantityfy,
|
10995
11906
|
deferPromise,
|
@@ -11060,6 +11971,8 @@ __publicField(Fuel, "defaultConfig", {});
|
|
11060
11971
|
isTransactionTypeBlob,
|
11061
11972
|
isTransactionTypeCreate,
|
11062
11973
|
isTransactionTypeScript,
|
11974
|
+
isTransactionTypeUpgrade,
|
11975
|
+
isTransactionTypeUpload,
|
11063
11976
|
isType,
|
11064
11977
|
isTypeBlob,
|
11065
11978
|
isTypeCreate,
|