@fuel-ts/account 0.97.2 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts +20 -17
- package/dist/account.d.ts.map +1 -1
- package/dist/assets/asset-api.d.ts +69 -0
- package/dist/assets/asset-api.d.ts.map +1 -0
- package/dist/assets/assets.d.ts.map +1 -0
- package/dist/{providers/assets → assets}/index.d.ts +1 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/types.d.ts.map +1 -0
- package/dist/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
- package/dist/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
- package/dist/assets/utils/index.d.ts.map +1 -0
- package/dist/{providers/assets → assets}/utils/network.d.ts +6 -6
- package/dist/assets/utils/network.d.ts.map +1 -0
- package/dist/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/assets/utils/url.d.ts.map +1 -0
- package/dist/configs.d.ts +2 -2
- 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 +5 -5
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts +3 -3
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +8 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/events.d.ts +1 -1
- package/dist/connectors/types/events.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +17174 -15376
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6602 -6428
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6613 -6450
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +28 -175
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +3 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +1 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/message.d.ts +8 -7
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +65 -42
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/errors.d.ts +3 -3
- package/dist/providers/transaction-request/errors.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +26 -4
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/output.d.ts +1 -1
- package/dist/providers/transaction-request/output.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +13 -3
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/scripts.d.ts +1 -1
- package/dist/providers/transaction-request/scripts.d.ts.map +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +7 -0
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/upload-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/witness.d.ts +1 -1
- package/dist/providers/transaction-request/witness.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +0 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/input.d.ts +1 -1
- package/dist/providers/transaction-summary/status.d.ts +9 -2
- package/dist/providers/transaction-summary/status.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +1 -21
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts +5 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +1 -1
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
- package/dist/test-utils/test-message.d.ts +6 -6
- package/dist/test-utils/test-message.d.ts.map +1 -1
- package/dist/test-utils/wallet-config.d.ts +2 -1
- package/dist/test-utils/wallet-config.d.ts.map +1 -1
- package/dist/test-utils.global.js +3096 -1963
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +498 -1011
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +453 -966
- package/dist/test-utils.mjs.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts +36 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/keystore-wallet.d.ts +2 -2
- package/dist/wallet/keystore-wallet.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +3 -2
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallets.d.ts +1 -1
- package/dist/wallet/wallets.d.ts.map +1 -1
- package/dist/wallet-manager/types.d.ts +4 -4
- package/dist/wallet-manager/types.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +6 -5
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +6 -5
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +3 -3
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +28 -30
- package/dist/providers/assets/assets.d.ts.map +0 -1
- package/dist/providers/assets/index.d.ts.map +0 -1
- package/dist/providers/assets/types.d.ts.map +0 -1
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +0 -2
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +0 -1
- package/dist/providers/assets/utils/index.d.ts.map +0 -1
- package/dist/providers/assets/utils/network.d.ts.map +0 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +0 -1
- package/dist/providers/assets/utils/url.d.ts.map +0 -1
- /package/dist/{providers/assets → assets}/assets.d.ts +0 -0
- /package/dist/{providers/assets → assets}/types.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/index.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/resolveIconPaths.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/url.d.ts +0 -0
package/dist/test-utils.mjs
CHANGED
@@ -55,7 +55,7 @@ var Signer = class {
|
|
55
55
|
this.privateKey = hexlify(privateKeyBytes);
|
56
56
|
this.publicKey = hexlify(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
57
57
|
this.compressedPublicKey = hexlify(secp256k1.getPublicKey(privateKeyBytes, true));
|
58
|
-
this.address = Address
|
58
|
+
this.address = new Address(this.publicKey);
|
59
59
|
}
|
60
60
|
/**
|
61
61
|
* Sign data using the Signer instance
|
@@ -113,7 +113,7 @@ var Signer = class {
|
|
113
113
|
* @returns Address from signature
|
114
114
|
*/
|
115
115
|
static recoverAddress(data, signature) {
|
116
|
-
return Address
|
116
|
+
return new Address(Signer.recoverPublicKey(data, signature));
|
117
117
|
}
|
118
118
|
/**
|
119
119
|
* Generate a random privateKey
|
@@ -220,7 +220,8 @@ var launchNode = async ({
|
|
220
220
|
loggingEnabled = true,
|
221
221
|
basePath,
|
222
222
|
snapshotConfig = defaultSnapshotConfigs,
|
223
|
-
includeInitialState = false
|
223
|
+
includeInitialState = false,
|
224
|
+
killProcessOnExit = false
|
224
225
|
} = {}) => (
|
225
226
|
// eslint-disable-next-line no-async-promise-executor
|
226
227
|
new Promise(async (resolve, reject) => {
|
@@ -297,14 +298,14 @@ var launchNode = async ({
|
|
297
298
|
console.log(chunk.toString());
|
298
299
|
});
|
299
300
|
}
|
300
|
-
const
|
301
|
+
const removeChildListeners = () => {
|
301
302
|
child.stderr.removeAllListeners();
|
303
|
+
};
|
304
|
+
const removeTempDir = () => {
|
302
305
|
if (existsSync(tempDir)) {
|
303
306
|
rmSync(tempDir, { recursive: true });
|
304
307
|
}
|
305
308
|
};
|
306
|
-
child.on("error", removeSideffects);
|
307
|
-
child.on("exit", removeSideffects);
|
308
309
|
const childState = {
|
309
310
|
isDead: false
|
310
311
|
};
|
@@ -313,7 +314,7 @@ var launchNode = async ({
|
|
313
314
|
return;
|
314
315
|
}
|
315
316
|
childState.isDead = true;
|
316
|
-
|
317
|
+
removeChildListeners();
|
317
318
|
if (child.pid !== void 0) {
|
318
319
|
try {
|
319
320
|
process.kill(-child.pid);
|
@@ -332,6 +333,7 @@ var launchNode = async ({
|
|
332
333
|
} else {
|
333
334
|
console.error("No PID available for the child process, unable to kill launched node");
|
334
335
|
}
|
336
|
+
removeTempDir();
|
335
337
|
};
|
336
338
|
child.stderr.on("data", (chunk) => {
|
337
339
|
const text = typeof chunk === "string" ? chunk : chunk.toString();
|
@@ -360,7 +362,18 @@ var launchNode = async ({
|
|
360
362
|
process.on("SIGUSR2", cleanup);
|
361
363
|
process.on("beforeExit", cleanup);
|
362
364
|
process.on("uncaughtException", cleanup);
|
363
|
-
child.on("
|
365
|
+
child.on("exit", (code, _signal) => {
|
366
|
+
removeChildListeners();
|
367
|
+
removeTempDir();
|
368
|
+
if (killProcessOnExit) {
|
369
|
+
process.exit(code);
|
370
|
+
}
|
371
|
+
});
|
372
|
+
child.on("error", (err) => {
|
373
|
+
removeChildListeners();
|
374
|
+
removeTempDir();
|
375
|
+
reject(err);
|
376
|
+
});
|
364
377
|
})
|
365
378
|
);
|
366
379
|
|
@@ -405,7 +418,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
405
418
|
|
406
419
|
// src/providers/provider.ts
|
407
420
|
import { Address as Address3 } from "@fuel-ts/address";
|
408
|
-
import { ErrorCode as
|
421
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
409
422
|
import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
|
410
423
|
import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
411
424
|
import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
@@ -1160,9 +1173,6 @@ var GetBalancesDocument = gql`
|
|
1160
1173
|
first: $first
|
1161
1174
|
last: $last
|
1162
1175
|
) {
|
1163
|
-
pageInfo {
|
1164
|
-
...pageInfoFragment
|
1165
|
-
}
|
1166
1176
|
edges {
|
1167
1177
|
node {
|
1168
1178
|
assetId
|
@@ -1171,7 +1181,7 @@ var GetBalancesDocument = gql`
|
|
1171
1181
|
}
|
1172
1182
|
}
|
1173
1183
|
}
|
1174
|
-
|
1184
|
+
`;
|
1175
1185
|
var GetMessagesDocument = gql`
|
1176
1186
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
1177
1187
|
messages(
|
@@ -1193,6 +1203,13 @@ var GetMessagesDocument = gql`
|
|
1193
1203
|
}
|
1194
1204
|
${PageInfoFragmentDoc}
|
1195
1205
|
${GetMessageFragmentDoc}`;
|
1206
|
+
var DaCompressedBlockDocument = gql`
|
1207
|
+
query daCompressedBlock($height: U32!) {
|
1208
|
+
daCompressedBlock(height: $height) {
|
1209
|
+
bytes
|
1210
|
+
}
|
1211
|
+
}
|
1212
|
+
`;
|
1196
1213
|
var GetMessageProofDocument = gql`
|
1197
1214
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1198
1215
|
messageProof(
|
@@ -1276,13 +1293,6 @@ var GetConsensusParametersVersionDocument = gql`
|
|
1276
1293
|
}
|
1277
1294
|
}
|
1278
1295
|
`;
|
1279
|
-
var SubmitAndAwaitDocument = gql`
|
1280
|
-
subscription submitAndAwait($encodedTransaction: HexString!) {
|
1281
|
-
submitAndAwait(tx: $encodedTransaction) {
|
1282
|
-
...transactionStatusSubscriptionFragment
|
1283
|
-
}
|
1284
|
-
}
|
1285
|
-
${TransactionStatusSubscriptionFragmentDoc}`;
|
1286
1296
|
var SubmitAndAwaitStatusDocument = gql`
|
1287
1297
|
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1288
1298
|
submitAndAwaitStatus(tx: $encodedTransaction) {
|
@@ -1371,6 +1381,9 @@ function getSdk(requester) {
|
|
1371
1381
|
getMessages(variables, options) {
|
1372
1382
|
return requester(GetMessagesDocument, variables, options);
|
1373
1383
|
},
|
1384
|
+
daCompressedBlock(variables, options) {
|
1385
|
+
return requester(DaCompressedBlockDocument, variables, options);
|
1386
|
+
},
|
1374
1387
|
getMessageProof(variables, options) {
|
1375
1388
|
return requester(GetMessageProofDocument, variables, options);
|
1376
1389
|
},
|
@@ -1398,9 +1411,6 @@ function getSdk(requester) {
|
|
1398
1411
|
getConsensusParametersVersion(variables, options) {
|
1399
1412
|
return requester(GetConsensusParametersVersionDocument, variables, options);
|
1400
1413
|
},
|
1401
|
-
submitAndAwait(variables, options) {
|
1402
|
-
return requester(SubmitAndAwaitDocument, variables, options);
|
1403
|
-
},
|
1404
1414
|
submitAndAwaitStatus(variables, options) {
|
1405
1415
|
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1406
1416
|
},
|
@@ -1411,8 +1421,60 @@ function getSdk(requester) {
|
|
1411
1421
|
}
|
1412
1422
|
|
1413
1423
|
// src/providers/fuel-graphql-subscriber.ts
|
1414
|
-
import { ErrorCode, FuelError as
|
1424
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1415
1425
|
import { print } from "graphql";
|
1426
|
+
|
1427
|
+
// src/providers/utils/handle-gql-error-message.ts
|
1428
|
+
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
1429
|
+
var mapGqlErrorMessage = (error) => {
|
1430
|
+
switch (error.message) {
|
1431
|
+
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
1432
|
+
return new FuelError2(
|
1433
|
+
ErrorCode.NOT_ENOUGH_FUNDS,
|
1434
|
+
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
1435
|
+
{},
|
1436
|
+
error
|
1437
|
+
);
|
1438
|
+
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
1439
|
+
return new FuelError2(
|
1440
|
+
ErrorCode.MAX_COINS_REACHED,
|
1441
|
+
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
1442
|
+
{},
|
1443
|
+
error
|
1444
|
+
);
|
1445
|
+
default:
|
1446
|
+
return new FuelError2(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1447
|
+
}
|
1448
|
+
};
|
1449
|
+
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1450
|
+
if (!incompatibleNodeVersionMessage) {
|
1451
|
+
return error;
|
1452
|
+
}
|
1453
|
+
return new FuelError2(
|
1454
|
+
error.code,
|
1455
|
+
`${error.message}
|
1456
|
+
|
1457
|
+
${incompatibleNodeVersionMessage}`,
|
1458
|
+
error.metadata,
|
1459
|
+
error.rawError
|
1460
|
+
);
|
1461
|
+
};
|
1462
|
+
var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
|
1463
|
+
if (!Array.isArray(errors)) {
|
1464
|
+
return;
|
1465
|
+
}
|
1466
|
+
const mappedErrors = errors.map(mapGqlErrorMessage);
|
1467
|
+
if (mappedErrors.length === 1) {
|
1468
|
+
throw mapGqlErrorWithIncompatibleNodeVersion(mappedErrors[0], incompatibleNodeVersionMessage);
|
1469
|
+
}
|
1470
|
+
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1471
|
+
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1472
|
+
new FuelError2(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1473
|
+
incompatibleNodeVersionMessage
|
1474
|
+
);
|
1475
|
+
};
|
1476
|
+
|
1477
|
+
// src/providers/fuel-graphql-subscriber.ts
|
1416
1478
|
var _FuelGraphqlSubscriber = class {
|
1417
1479
|
constructor(stream) {
|
1418
1480
|
this.stream = stream;
|
@@ -1440,12 +1502,7 @@ var _FuelGraphqlSubscriber = class {
|
|
1440
1502
|
while (true) {
|
1441
1503
|
if (this.events.length > 0) {
|
1442
1504
|
const { data, errors } = this.events.shift();
|
1443
|
-
|
1444
|
-
throw new FuelError2(
|
1445
|
-
FuelError2.CODES.INVALID_REQUEST,
|
1446
|
-
errors.map((err) => err.message).join("\n\n")
|
1447
|
-
);
|
1448
|
-
}
|
1505
|
+
assertGqlResponseHasNoErrors(errors, _FuelGraphqlSubscriber.incompatibleNodeVersionMessage);
|
1449
1506
|
return { value: data, done: false };
|
1450
1507
|
}
|
1451
1508
|
const { value, done } = await this.stream.read();
|
@@ -1463,8 +1520,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1463
1520
|
try {
|
1464
1521
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1465
1522
|
} catch (e) {
|
1466
|
-
throw new
|
1467
|
-
|
1523
|
+
throw new FuelError3(
|
1524
|
+
ErrorCode2.STREAM_PARSING_ERROR,
|
1468
1525
|
`Error while parsing stream data response: ${text}`
|
1469
1526
|
);
|
1470
1527
|
}
|
@@ -1483,10 +1540,11 @@ var _FuelGraphqlSubscriber = class {
|
|
1483
1540
|
}
|
1484
1541
|
};
|
1485
1542
|
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1543
|
+
__publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
1486
1544
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1487
1545
|
|
1488
1546
|
// src/providers/resource-cache.ts
|
1489
|
-
import { ErrorCode as
|
1547
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1490
1548
|
import { hexlify as hexlify4 } from "@fuel-ts/utils";
|
1491
1549
|
var cache = /* @__PURE__ */ new Map();
|
1492
1550
|
var ResourceCache = class {
|
@@ -1494,8 +1552,8 @@ var ResourceCache = class {
|
|
1494
1552
|
constructor(ttl) {
|
1495
1553
|
this.ttl = ttl;
|
1496
1554
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1497
|
-
throw new
|
1498
|
-
|
1555
|
+
throw new FuelError4(
|
1556
|
+
ErrorCode3.INVALID_TTL,
|
1499
1557
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1500
1558
|
);
|
1501
1559
|
}
|
@@ -1550,7 +1608,7 @@ var ResourceCache = class {
|
|
1550
1608
|
// src/providers/transaction-request/input.ts
|
1551
1609
|
import { BYTES_32 as BYTES_322, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1552
1610
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1553
|
-
import { ErrorCode as
|
1611
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1554
1612
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1555
1613
|
import { InputType } from "@fuel-ts/transactions";
|
1556
1614
|
import { arrayify as arrayify2, hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1614,8 +1672,8 @@ var inputify = (value) => {
|
|
1614
1672
|
};
|
1615
1673
|
}
|
1616
1674
|
default: {
|
1617
|
-
throw new
|
1618
|
-
|
1675
|
+
throw new FuelError5(
|
1676
|
+
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
1619
1677
|
`Invalid transaction input type: ${type}.`
|
1620
1678
|
);
|
1621
1679
|
}
|
@@ -1624,7 +1682,7 @@ var inputify = (value) => {
|
|
1624
1682
|
|
1625
1683
|
// src/providers/transaction-request/output.ts
|
1626
1684
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
1627
|
-
import { ErrorCode as
|
1685
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1628
1686
|
import { bn as bn3 } from "@fuel-ts/math";
|
1629
1687
|
import { OutputType } from "@fuel-ts/transactions";
|
1630
1688
|
import { hexlify as hexlify6 } from "@fuel-ts/utils";
|
@@ -1671,8 +1729,8 @@ var outputify = (value) => {
|
|
1671
1729
|
};
|
1672
1730
|
}
|
1673
1731
|
default: {
|
1674
|
-
throw new
|
1675
|
-
|
1732
|
+
throw new FuelError6(
|
1733
|
+
ErrorCode5.INVALID_TRANSACTION_INPUT,
|
1676
1734
|
`Invalid transaction output type: ${type}.`
|
1677
1735
|
);
|
1678
1736
|
}
|
@@ -1684,13 +1742,13 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1684
1742
|
import { Address as Address2, addressify } from "@fuel-ts/address";
|
1685
1743
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1686
1744
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
1687
|
-
import { FuelError as
|
1745
|
+
import { FuelError as FuelError11 } from "@fuel-ts/errors";
|
1688
1746
|
import { bn as bn8 } from "@fuel-ts/math";
|
1689
1747
|
import {
|
1690
1748
|
PolicyType,
|
1691
1749
|
TransactionCoder,
|
1692
1750
|
InputType as InputType3,
|
1693
|
-
OutputType as
|
1751
|
+
OutputType as OutputType3,
|
1694
1752
|
TransactionType
|
1695
1753
|
} from "@fuel-ts/transactions";
|
1696
1754
|
import { concat as concat2, hexlify as hexlify10, isDefined } from "@fuel-ts/utils";
|
@@ -1703,7 +1761,7 @@ var isCoin = (resource) => "id" in resource;
|
|
1703
1761
|
|
1704
1762
|
// src/providers/utils/receipts.ts
|
1705
1763
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1706
|
-
import { ErrorCode as
|
1764
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1707
1765
|
import { bn as bn4 } from "@fuel-ts/math";
|
1708
1766
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1709
1767
|
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
@@ -1734,7 +1792,6 @@ function assembleReceiptByType(receipt) {
|
|
1734
1792
|
const callReceipt = {
|
1735
1793
|
type: ReceiptType.Call,
|
1736
1794
|
id,
|
1737
|
-
from: id,
|
1738
1795
|
to: hexOrZero(receipt?.to),
|
1739
1796
|
amount: bn4(receipt.amount),
|
1740
1797
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1802,10 +1859,6 @@ function assembleReceiptByType(receipt) {
|
|
1802
1859
|
rb,
|
1803
1860
|
rc,
|
1804
1861
|
rd,
|
1805
|
-
val0: ra,
|
1806
|
-
val1: rb,
|
1807
|
-
val2: rc,
|
1808
|
-
val3: rd,
|
1809
1862
|
pc: bn4(receipt.pc),
|
1810
1863
|
is: bn4(receipt.is)
|
1811
1864
|
};
|
@@ -1819,8 +1872,6 @@ function assembleReceiptByType(receipt) {
|
|
1819
1872
|
id: hexOrZero(receipt.id || receipt.contractId),
|
1820
1873
|
ra,
|
1821
1874
|
rb,
|
1822
|
-
val0: ra,
|
1823
|
-
val1: rb,
|
1824
1875
|
ptr: bn4(receipt.ptr),
|
1825
1876
|
len: bn4(receipt.len),
|
1826
1877
|
digest: hexOrZero(receipt.digest),
|
@@ -1835,7 +1886,6 @@ function assembleReceiptByType(receipt) {
|
|
1835
1886
|
const transferReceipt = {
|
1836
1887
|
type: ReceiptType.Transfer,
|
1837
1888
|
id,
|
1838
|
-
from: id,
|
1839
1889
|
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1840
1890
|
amount: bn4(receipt.amount),
|
1841
1891
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1849,7 +1899,6 @@ function assembleReceiptByType(receipt) {
|
|
1849
1899
|
const transferOutReceipt = {
|
1850
1900
|
type: ReceiptType.TransferOut,
|
1851
1901
|
id,
|
1852
|
-
from: id,
|
1853
1902
|
to: hexOrZero(receipt.toAddress || receipt.to),
|
1854
1903
|
amount: bn4(receipt.amount),
|
1855
1904
|
assetId: hexOrZero(receipt.assetId),
|
@@ -1925,12 +1974,12 @@ function assembleReceiptByType(receipt) {
|
|
1925
1974
|
return burnReceipt;
|
1926
1975
|
}
|
1927
1976
|
default:
|
1928
|
-
throw new
|
1977
|
+
throw new FuelError7(ErrorCode6.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
1929
1978
|
}
|
1930
1979
|
}
|
1931
1980
|
|
1932
1981
|
// src/providers/utils/block-explorer.ts
|
1933
|
-
import { ErrorCode as
|
1982
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError8 } from "@fuel-ts/errors";
|
1934
1983
|
|
1935
1984
|
// src/providers/utils/gas.ts
|
1936
1985
|
import { bn as bn5 } from "@fuel-ts/math";
|
@@ -2102,7 +2151,7 @@ function normalizeJSON(root) {
|
|
2102
2151
|
}
|
2103
2152
|
|
2104
2153
|
// src/providers/utils/extract-tx-error.ts
|
2105
|
-
import { ErrorCode as
|
2154
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2106
2155
|
import { bn as bn6 } from "@fuel-ts/math";
|
2107
2156
|
import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
|
2108
2157
|
import {
|
@@ -2123,7 +2172,7 @@ You can read more about this error at:
|
|
2123
2172
|
|
2124
2173
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
2125
2174
|
}
|
2126
|
-
return new
|
2175
|
+
return new FuelError9(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
2127
2176
|
...metadata,
|
2128
2177
|
reason: statusReason
|
2129
2178
|
});
|
@@ -2164,8 +2213,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2164
2213
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
2165
2214
|
break;
|
2166
2215
|
default:
|
2167
|
-
throw new
|
2168
|
-
|
2216
|
+
throw new FuelError9(
|
2217
|
+
ErrorCode8.UNKNOWN,
|
2169
2218
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2170
2219
|
{
|
2171
2220
|
...metadata,
|
@@ -2174,7 +2223,7 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2174
2223
|
);
|
2175
2224
|
}
|
2176
2225
|
}
|
2177
|
-
return new
|
2226
|
+
return new FuelError9(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
2178
2227
|
...metadata,
|
2179
2228
|
reason
|
2180
2229
|
});
|
@@ -2207,8 +2256,9 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2207
2256
|
};
|
2208
2257
|
|
2209
2258
|
// src/providers/transaction-request/helpers.ts
|
2259
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2210
2260
|
import { bn as bn7 } from "@fuel-ts/math";
|
2211
|
-
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
2261
|
+
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2212
2262
|
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
2213
2263
|
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
2214
2264
|
var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
|
@@ -2239,6 +2289,32 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
|
2239
2289
|
messages: []
|
2240
2290
|
}
|
2241
2291
|
);
|
2292
|
+
var getBurnableAssetCount = (baseAssetId, transactionRequest) => {
|
2293
|
+
const { inputs, outputs } = transactionRequest;
|
2294
|
+
const coinInputs = new Set(inputs.filter(isRequestInputCoin).map((input) => input.assetId));
|
2295
|
+
if (inputs.some((i) => isRequestInputMessage(i) && bn7(i.amount).gt(0))) {
|
2296
|
+
coinInputs.add(baseAssetId);
|
2297
|
+
}
|
2298
|
+
const changeOutputs = new Set(
|
2299
|
+
outputs.filter((output) => output.type === OutputType2.Change).map((output) => output.assetId)
|
2300
|
+
);
|
2301
|
+
const difference = new Set([...coinInputs].filter((x) => !changeOutputs.has(x)));
|
2302
|
+
return difference.size;
|
2303
|
+
};
|
2304
|
+
var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAssetBurn = false) => {
|
2305
|
+
if (enableAssetBurn === true) {
|
2306
|
+
return;
|
2307
|
+
}
|
2308
|
+
if (getBurnableAssetCount(baseAssetId, transactionRequest) <= 0) {
|
2309
|
+
return;
|
2310
|
+
}
|
2311
|
+
const message = [
|
2312
|
+
"Asset burn detected.",
|
2313
|
+
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2314
|
+
"Or enable asset burn, upon sending the transaction."
|
2315
|
+
].join("\n");
|
2316
|
+
throw new FuelError10(ErrorCode9.ASSET_BURN_DETECTED, message);
|
2317
|
+
};
|
2242
2318
|
|
2243
2319
|
// src/providers/transaction-request/witness.ts
|
2244
2320
|
import { arrayify as arrayify5, hexlify as hexlify9 } from "@fuel-ts/utils";
|
@@ -2388,7 +2464,7 @@ var BaseTransactionRequest = class {
|
|
2388
2464
|
* @param signature - The signature to update the witness with.
|
2389
2465
|
*/
|
2390
2466
|
updateWitnessByOwner(address, signature) {
|
2391
|
-
const ownerAddress = Address2
|
2467
|
+
const ownerAddress = new Address2(address);
|
2392
2468
|
const witnessIndex = this.getCoinInputWitnessIndexByOwner(ownerAddress);
|
2393
2469
|
if (typeof witnessIndex === "number") {
|
2394
2470
|
this.updateWitness(witnessIndex, signature);
|
@@ -2439,7 +2515,7 @@ var BaseTransactionRequest = class {
|
|
2439
2515
|
*/
|
2440
2516
|
getCoinOutputs() {
|
2441
2517
|
return this.outputs.filter(
|
2442
|
-
(output) => output.type ===
|
2518
|
+
(output) => output.type === OutputType3.Coin
|
2443
2519
|
);
|
2444
2520
|
}
|
2445
2521
|
/**
|
@@ -2449,7 +2525,7 @@ var BaseTransactionRequest = class {
|
|
2449
2525
|
*/
|
2450
2526
|
getChangeOutputs() {
|
2451
2527
|
return this.outputs.filter(
|
2452
|
-
(output) => output.type ===
|
2528
|
+
(output) => output.type === OutputType3.Change
|
2453
2529
|
);
|
2454
2530
|
}
|
2455
2531
|
/**
|
@@ -2570,7 +2646,7 @@ var BaseTransactionRequest = class {
|
|
2570
2646
|
*/
|
2571
2647
|
addCoinOutput(to, amount, assetId) {
|
2572
2648
|
this.pushOutput({
|
2573
|
-
type:
|
2649
|
+
type: OutputType3.Coin,
|
2574
2650
|
to: addressify(to).toB256(),
|
2575
2651
|
amount,
|
2576
2652
|
assetId
|
@@ -2586,7 +2662,7 @@ var BaseTransactionRequest = class {
|
|
2586
2662
|
addCoinOutputs(to, quantities) {
|
2587
2663
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
2588
2664
|
this.pushOutput({
|
2589
|
-
type:
|
2665
|
+
type: OutputType3.Coin,
|
2590
2666
|
to: addressify(to).toB256(),
|
2591
2667
|
amount: quantity.amount,
|
2592
2668
|
assetId: quantity.assetId
|
@@ -2606,7 +2682,7 @@ var BaseTransactionRequest = class {
|
|
2606
2682
|
);
|
2607
2683
|
if (!changeOutput) {
|
2608
2684
|
this.pushOutput({
|
2609
|
-
type:
|
2685
|
+
type: OutputType3.Change,
|
2610
2686
|
to: addressify(to).toB256(),
|
2611
2687
|
assetId
|
2612
2688
|
});
|
@@ -2622,7 +2698,7 @@ var BaseTransactionRequest = class {
|
|
2622
2698
|
* @hidden
|
2623
2699
|
*/
|
2624
2700
|
metadataGas(_gasCosts) {
|
2625
|
-
throw new
|
2701
|
+
throw new FuelError11(FuelError11.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2626
2702
|
}
|
2627
2703
|
/**
|
2628
2704
|
* @hidden
|
@@ -2739,7 +2815,7 @@ var BaseTransactionRequest = class {
|
|
2739
2815
|
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2740
2816
|
const owner = getRequestInputResourceOwner(i);
|
2741
2817
|
const correspondingInput = inputsToExtractGasUsed.find(
|
2742
|
-
(x) => isRequestInputResourceFromOwner(x, Address2
|
2818
|
+
(x) => isRequestInputResourceFromOwner(x, new Address2(String(owner)))
|
2743
2819
|
);
|
2744
2820
|
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2745
2821
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2758,7 +2834,7 @@ import { clone as clone3 } from "ramda";
|
|
2758
2834
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2759
2835
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2760
2836
|
import { bn as bn9 } from "@fuel-ts/math";
|
2761
|
-
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as
|
2837
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType4, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2762
2838
|
import { concat as concat3 } from "@fuel-ts/utils";
|
2763
2839
|
import { clone as clone2 } from "ramda";
|
2764
2840
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2799,16 +2875,16 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2799
2875
|
transaction.outputs = transaction.outputs.map((output) => {
|
2800
2876
|
const outputClone = clone2(output);
|
2801
2877
|
switch (outputClone.type) {
|
2802
|
-
case
|
2878
|
+
case OutputType4.Contract: {
|
2803
2879
|
outputClone.balanceRoot = ZeroBytes325;
|
2804
2880
|
outputClone.stateRoot = ZeroBytes325;
|
2805
2881
|
return outputClone;
|
2806
2882
|
}
|
2807
|
-
case
|
2883
|
+
case OutputType4.Change: {
|
2808
2884
|
outputClone.amount = bn9(0);
|
2809
2885
|
return outputClone;
|
2810
2886
|
}
|
2811
|
-
case
|
2887
|
+
case OutputType4.Variable: {
|
2812
2888
|
outputClone.to = ZeroBytes325;
|
2813
2889
|
outputClone.amount = bn9(0);
|
2814
2890
|
outputClone.assetId = ZeroBytes325;
|
@@ -2889,7 +2965,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
|
|
2889
2965
|
// src/providers/transaction-request/create-transaction-request.ts
|
2890
2966
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2891
2967
|
import { bn as bn10 } from "@fuel-ts/math";
|
2892
|
-
import { TransactionType as TransactionType3, OutputType as
|
2968
|
+
import { TransactionType as TransactionType3, OutputType as OutputType5 } from "@fuel-ts/transactions";
|
2893
2969
|
import { arrayify as arrayify7, hexlify as hexlify12 } from "@fuel-ts/utils";
|
2894
2970
|
import { clone as clone4 } from "ramda";
|
2895
2971
|
|
@@ -2965,7 +3041,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2965
3041
|
*/
|
2966
3042
|
getContractCreatedOutputs() {
|
2967
3043
|
return this.outputs.filter(
|
2968
|
-
(output) => output.type ===
|
3044
|
+
(output) => output.type === OutputType5.ContractCreated
|
2969
3045
|
);
|
2970
3046
|
}
|
2971
3047
|
/**
|
@@ -2986,7 +3062,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2986
3062
|
*/
|
2987
3063
|
addContractCreatedOutput(contractId, stateRoot) {
|
2988
3064
|
this.pushOutput({
|
2989
|
-
type:
|
3065
|
+
type: OutputType5.ContractCreated,
|
2990
3066
|
contractId,
|
2991
3067
|
stateRoot
|
2992
3068
|
});
|
@@ -3006,7 +3082,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
3006
3082
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
3007
3083
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
3008
3084
|
import { bn as bn11 } from "@fuel-ts/math";
|
3009
|
-
import { InputType as InputType5, OutputType as
|
3085
|
+
import { InputType as InputType5, OutputType as OutputType6, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
3010
3086
|
import { arrayify as arrayify9, hexlify as hexlify13 } from "@fuel-ts/utils";
|
3011
3087
|
import { clone as clone5 } from "ramda";
|
3012
3088
|
|
@@ -3062,6 +3138,20 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3062
3138
|
this.scriptData = arrayify9(scriptData ?? returnZeroScript.encodeScriptData());
|
3063
3139
|
this.abis = rest.abis;
|
3064
3140
|
}
|
3141
|
+
/**
|
3142
|
+
* Helper function to estimate and fund the transaction request with a specified account.
|
3143
|
+
*
|
3144
|
+
* @param account - The account to fund the transaction.
|
3145
|
+
* @param params - The parameters for the transaction cost.
|
3146
|
+
* @returns The current instance of the `ScriptTransactionRequest` funded.
|
3147
|
+
*/
|
3148
|
+
async estimateAndFund(account, { signatureCallback, quantities = [] } = {}) {
|
3149
|
+
const txCost = await account.getTransactionCost(this, { signatureCallback, quantities });
|
3150
|
+
this.maxFee = txCost.maxFee;
|
3151
|
+
this.gasLimit = txCost.gasUsed;
|
3152
|
+
await account.fund(this, txCost);
|
3153
|
+
return this;
|
3154
|
+
}
|
3065
3155
|
/**
|
3066
3156
|
* Converts the transaction request to a `TransactionScript`.
|
3067
3157
|
*
|
@@ -3098,7 +3188,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3098
3188
|
*/
|
3099
3189
|
getContractOutputs() {
|
3100
3190
|
return this.outputs.filter(
|
3101
|
-
(output) => output.type ===
|
3191
|
+
(output) => output.type === OutputType6.Contract
|
3102
3192
|
);
|
3103
3193
|
}
|
3104
3194
|
/**
|
@@ -3108,7 +3198,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3108
3198
|
*/
|
3109
3199
|
getVariableOutputs() {
|
3110
3200
|
return this.outputs.filter(
|
3111
|
-
(output) => output.type ===
|
3201
|
+
(output) => output.type === OutputType6.Variable
|
3112
3202
|
);
|
3113
3203
|
}
|
3114
3204
|
/**
|
@@ -3131,7 +3221,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3131
3221
|
let outputsNumber = numberOfVariables;
|
3132
3222
|
while (outputsNumber) {
|
3133
3223
|
this.pushOutput({
|
3134
|
-
type:
|
3224
|
+
type: OutputType6.Variable
|
3135
3225
|
});
|
3136
3226
|
outputsNumber -= 1;
|
3137
3227
|
}
|
@@ -3180,7 +3270,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3180
3270
|
txPointer: "0x00000000000000000000000000000000"
|
3181
3271
|
});
|
3182
3272
|
this.pushOutput({
|
3183
|
-
type:
|
3273
|
+
type: OutputType6.Contract,
|
3184
3274
|
inputIndex
|
3185
3275
|
});
|
3186
3276
|
return this;
|
@@ -3216,7 +3306,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3216
3306
|
};
|
3217
3307
|
|
3218
3308
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3219
|
-
import { FuelError as
|
3309
|
+
import { FuelError as FuelError12 } from "@fuel-ts/errors";
|
3220
3310
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
3221
3311
|
import {
|
3222
3312
|
TransactionType as TransactionType5,
|
@@ -3323,7 +3413,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3323
3413
|
}
|
3324
3414
|
};
|
3325
3415
|
} else {
|
3326
|
-
throw new
|
3416
|
+
throw new FuelError12(FuelError12.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3327
3417
|
}
|
3328
3418
|
return {
|
3329
3419
|
type: TransactionType5.Upgrade,
|
@@ -3365,7 +3455,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3365
3455
|
txBytesSize
|
3366
3456
|
});
|
3367
3457
|
}
|
3368
|
-
throw new
|
3458
|
+
throw new FuelError12(FuelError12.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3369
3459
|
}
|
3370
3460
|
};
|
3371
3461
|
|
@@ -3476,7 +3566,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
3476
3566
|
};
|
3477
3567
|
|
3478
3568
|
// src/providers/transaction-request/utils.ts
|
3479
|
-
import { ErrorCode as
|
3569
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3480
3570
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3481
3571
|
var transactionRequestify = (obj) => {
|
3482
3572
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3500,8 +3590,8 @@ var transactionRequestify = (obj) => {
|
|
3500
3590
|
return UploadTransactionRequest.from(obj);
|
3501
3591
|
}
|
3502
3592
|
default: {
|
3503
|
-
throw new
|
3504
|
-
|
3593
|
+
throw new FuelError13(
|
3594
|
+
ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
|
3505
3595
|
`Unsupported transaction type: ${type}.`
|
3506
3596
|
);
|
3507
3597
|
}
|
@@ -3511,9 +3601,9 @@ var isTransactionTypeScript = (request) => request.type === TransactionType7.Scr
|
|
3511
3601
|
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3512
3602
|
|
3513
3603
|
// src/providers/transaction-response/transaction-response.ts
|
3514
|
-
import { ErrorCode as
|
3604
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
|
3515
3605
|
import { bn as bn16 } from "@fuel-ts/math";
|
3516
|
-
import { OutputType as
|
3606
|
+
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3517
3607
|
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
3518
3608
|
|
3519
3609
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
@@ -3530,12 +3620,8 @@ var calculateTXFeeForSummary = (params) => {
|
|
3530
3620
|
gasPrice,
|
3531
3621
|
rawPayload,
|
3532
3622
|
tip,
|
3533
|
-
totalFee,
|
3534
3623
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
3535
3624
|
} = params;
|
3536
|
-
if (totalFee) {
|
3537
|
-
return totalFee;
|
3538
|
-
}
|
3539
3625
|
const gasPerByte = bn12(feeParams.gasPerByte);
|
3540
3626
|
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
3541
3627
|
const transactionBytes = arrayify11(rawPayload);
|
@@ -3593,7 +3679,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3593
3679
|
|
3594
3680
|
// src/providers/transaction-summary/operations.ts
|
3595
3681
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3596
|
-
import { ErrorCode as
|
3682
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3597
3683
|
import { bn as bn13 } from "@fuel-ts/math";
|
3598
3684
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3599
3685
|
|
@@ -3631,7 +3717,7 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3631
3717
|
};
|
3632
3718
|
|
3633
3719
|
// src/providers/transaction-summary/input.ts
|
3634
|
-
import { ErrorCode as
|
3720
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
|
3635
3721
|
import { BN } from "@fuel-ts/math";
|
3636
3722
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3637
3723
|
function getInputsByTypes(inputs, types) {
|
@@ -3659,10 +3745,10 @@ function findCoinInput(inputs, assetId) {
|
|
3659
3745
|
const coinInputs = getInputsCoin(inputs);
|
3660
3746
|
return coinInputs.find((i) => i.assetId === assetId);
|
3661
3747
|
}
|
3662
|
-
function aggregateInputsAmountsByAssetAndOwner(inputs,
|
3748
|
+
function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId) {
|
3663
3749
|
const aggregated = /* @__PURE__ */ new Map();
|
3664
3750
|
getInputsCoinAndMessage(inputs).forEach((input) => {
|
3665
|
-
const assetId = isInputCoin(input) ? input.assetId :
|
3751
|
+
const assetId = isInputCoin(input) ? input.assetId : baseAssetId;
|
3666
3752
|
const owner = isInputCoin(input) ? input.owner : input.recipient;
|
3667
3753
|
let ownersMap = aggregated.get(assetId);
|
3668
3754
|
if (!ownersMap) {
|
@@ -3700,8 +3786,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3700
3786
|
return void 0;
|
3701
3787
|
}
|
3702
3788
|
if (contractInput.type !== InputType6.Contract) {
|
3703
|
-
throw new
|
3704
|
-
|
3789
|
+
throw new FuelError14(
|
3790
|
+
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
3705
3791
|
`Contract input should be of type 'contract'.`
|
3706
3792
|
);
|
3707
3793
|
}
|
@@ -3718,21 +3804,21 @@ function getInputAccountAddress(input) {
|
|
3718
3804
|
}
|
3719
3805
|
|
3720
3806
|
// src/providers/transaction-summary/output.ts
|
3721
|
-
import { OutputType as
|
3807
|
+
import { OutputType as OutputType7 } from "@fuel-ts/transactions";
|
3722
3808
|
function getOutputsByType(outputs, type) {
|
3723
3809
|
return outputs.filter((o) => o.type === type);
|
3724
3810
|
}
|
3725
3811
|
function getOutputsContractCreated(outputs) {
|
3726
|
-
return getOutputsByType(outputs,
|
3812
|
+
return getOutputsByType(outputs, OutputType7.ContractCreated);
|
3727
3813
|
}
|
3728
3814
|
function getOutputsCoin(outputs) {
|
3729
|
-
return getOutputsByType(outputs,
|
3815
|
+
return getOutputsByType(outputs, OutputType7.Coin);
|
3730
3816
|
}
|
3731
3817
|
function getOutputsChange(outputs) {
|
3732
|
-
return getOutputsByType(outputs,
|
3818
|
+
return getOutputsByType(outputs, OutputType7.Change);
|
3733
3819
|
}
|
3734
3820
|
function getOutputsContract(outputs) {
|
3735
|
-
return getOutputsByType(outputs,
|
3821
|
+
return getOutputsByType(outputs, OutputType7.Contract);
|
3736
3822
|
}
|
3737
3823
|
|
3738
3824
|
// src/providers/transaction-summary/operations.ts
|
@@ -3754,8 +3840,8 @@ function getTransactionTypeName(transactionType) {
|
|
3754
3840
|
case TransactionType9.Upload:
|
3755
3841
|
return "Upload" /* Upload */;
|
3756
3842
|
default:
|
3757
|
-
throw new
|
3758
|
-
|
3843
|
+
throw new FuelError15(
|
3844
|
+
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
3759
3845
|
`Unsupported transaction type: ${transactionType}.`
|
3760
3846
|
);
|
3761
3847
|
}
|
@@ -3948,7 +4034,7 @@ function getContractCallOperations({
|
|
3948
4034
|
}
|
3949
4035
|
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
3950
4036
|
const { to: toAddress, assetId, amount } = receipt;
|
3951
|
-
let {
|
4037
|
+
let { id: fromAddress } = receipt;
|
3952
4038
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3953
4039
|
if (ZeroBytes329 === fromAddress) {
|
3954
4040
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
@@ -4135,7 +4221,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4135
4221
|
};
|
4136
4222
|
|
4137
4223
|
// src/providers/transaction-summary/status.ts
|
4138
|
-
import { ErrorCode as
|
4224
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4139
4225
|
import { bn as bn14 } from "@fuel-ts/math";
|
4140
4226
|
var getTransactionStatusName = (gqlStatus) => {
|
4141
4227
|
switch (gqlStatus) {
|
@@ -4148,8 +4234,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4148
4234
|
case "SqueezedOutStatus":
|
4149
4235
|
return "squeezedout" /* squeezedout */;
|
4150
4236
|
default:
|
4151
|
-
throw new
|
4152
|
-
|
4237
|
+
throw new FuelError16(
|
4238
|
+
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
4153
4239
|
`Invalid transaction status: ${gqlStatus}.`
|
4154
4240
|
);
|
4155
4241
|
}
|
@@ -4199,6 +4285,7 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
4199
4285
|
};
|
4200
4286
|
return processedGraphqlStatus;
|
4201
4287
|
};
|
4288
|
+
var getTotalFeeFromStatus = (status) => status && "totalFee" in status ? bn14(status.totalFee) : void 0;
|
4202
4289
|
|
4203
4290
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
4204
4291
|
function assembleTransactionSummary(params) {
|
@@ -4232,8 +4319,7 @@ function assembleTransactionSummary(params) {
|
|
4232
4319
|
const typeName = getTransactionTypeName(transaction.type);
|
4233
4320
|
const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
4234
4321
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
4235
|
-
const fee = calculateTXFeeForSummary({
|
4236
|
-
totalFee,
|
4322
|
+
const fee = totalFee ?? calculateTXFeeForSummary({
|
4237
4323
|
gasPrice,
|
4238
4324
|
rawPayload,
|
4239
4325
|
tip,
|
@@ -4287,8 +4373,8 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
4287
4373
|
return receipts.reduce((logs, receipt) => {
|
4288
4374
|
if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
|
4289
4375
|
const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
|
4290
|
-
const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.
|
4291
|
-
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.
|
4376
|
+
const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4377
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4292
4378
|
logs.push(decodedLog);
|
4293
4379
|
}
|
4294
4380
|
return logs;
|
@@ -4301,24 +4387,24 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4301
4387
|
const obj = "amount" in o ? { ...o, amount: bn16(o.amount) } : o;
|
4302
4388
|
switch (obj.type) {
|
4303
4389
|
case "CoinOutput":
|
4304
|
-
return { ...obj, type:
|
4390
|
+
return { ...obj, type: OutputType8.Coin };
|
4305
4391
|
case "ContractOutput":
|
4306
4392
|
return {
|
4307
4393
|
...obj,
|
4308
|
-
type:
|
4394
|
+
type: OutputType8.Contract,
|
4309
4395
|
inputIndex: parseInt(obj.inputIndex, 10)
|
4310
4396
|
};
|
4311
4397
|
case "ChangeOutput":
|
4312
4398
|
return {
|
4313
4399
|
...obj,
|
4314
|
-
type:
|
4400
|
+
type: OutputType8.Change
|
4315
4401
|
};
|
4316
4402
|
case "VariableOutput":
|
4317
|
-
return { ...obj, type:
|
4403
|
+
return { ...obj, type: OutputType8.Variable };
|
4318
4404
|
case "ContractCreated":
|
4319
4405
|
return {
|
4320
4406
|
...obj,
|
4321
|
-
type:
|
4407
|
+
type: OutputType8.ContractCreated,
|
4322
4408
|
contractId: obj.contract
|
4323
4409
|
};
|
4324
4410
|
default:
|
@@ -4333,12 +4419,13 @@ var TransactionResponse = class {
|
|
4333
4419
|
* @param tx - The transaction ID or TransactionRequest.
|
4334
4420
|
* @param provider - The provider.
|
4335
4421
|
*/
|
4336
|
-
constructor(tx, provider, abis, submitTxSubscription) {
|
4422
|
+
constructor(tx, provider, chainId, abis, submitTxSubscription) {
|
4337
4423
|
this.submitTxSubscription = submitTxSubscription;
|
4338
|
-
this.id = typeof tx === "string" ? tx : tx.getTransactionId(
|
4424
|
+
this.id = typeof tx === "string" ? tx : tx.getTransactionId(chainId);
|
4339
4425
|
this.provider = provider;
|
4340
4426
|
this.abis = abis;
|
4341
4427
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4428
|
+
this.waitForResult = this.waitForResult.bind(this);
|
4342
4429
|
}
|
4343
4430
|
/** Transaction ID */
|
4344
4431
|
id;
|
@@ -4360,7 +4447,8 @@ var TransactionResponse = class {
|
|
4360
4447
|
* @param provider - The provider.
|
4361
4448
|
*/
|
4362
4449
|
static async create(id, provider, abis) {
|
4363
|
-
const
|
4450
|
+
const chainId = await provider.getChainId();
|
4451
|
+
const response = new TransactionResponse(id, provider, chainId, abis);
|
4364
4452
|
await response.fetch();
|
4365
4453
|
return response;
|
4366
4454
|
}
|
@@ -4457,10 +4545,11 @@ var TransactionResponse = class {
|
|
4457
4545
|
*/
|
4458
4546
|
async getTransactionSummary(contractsAbiMap) {
|
4459
4547
|
const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
|
4460
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
4461
|
-
const
|
4462
|
-
const
|
4463
|
-
const
|
4548
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await this.provider.getGasConfig();
|
4549
|
+
const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status);
|
4550
|
+
const gasPrice = totalFee ? bn16(0) : await this.provider.getLatestGasPrice();
|
4551
|
+
const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs;
|
4552
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
4464
4553
|
const transactionSummary = assembleTransactionSummary({
|
4465
4554
|
id: this.id,
|
4466
4555
|
receipts: this.getReceipts(),
|
@@ -4491,8 +4580,8 @@ var TransactionResponse = class {
|
|
4491
4580
|
this.status = statusChange;
|
4492
4581
|
if (statusChange.type === "SqueezedOutStatus") {
|
4493
4582
|
this.unsetResourceCache();
|
4494
|
-
throw new
|
4495
|
-
|
4583
|
+
throw new FuelError17(
|
4584
|
+
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
4496
4585
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4497
4586
|
);
|
4498
4587
|
}
|
@@ -4599,55 +4688,32 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4599
4688
|
};
|
4600
4689
|
}
|
4601
4690
|
|
4602
|
-
// src/providers/utils/handle-gql-error-message.ts
|
4603
|
-
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4604
|
-
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4605
|
-
switch (errorMessage) {
|
4606
|
-
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4607
|
-
throw new FuelError16(
|
4608
|
-
ErrorCode13.NOT_ENOUGH_FUNDS,
|
4609
|
-
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4610
|
-
{},
|
4611
|
-
rawError
|
4612
|
-
);
|
4613
|
-
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
4614
|
-
throw new FuelError16(
|
4615
|
-
ErrorCode13.MAX_COINS_REACHED,
|
4616
|
-
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
4617
|
-
{},
|
4618
|
-
rawError
|
4619
|
-
);
|
4620
|
-
default:
|
4621
|
-
throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
|
4622
|
-
}
|
4623
|
-
};
|
4624
|
-
|
4625
4691
|
// src/providers/utils/validate-pagination-args.ts
|
4626
|
-
import { FuelError as
|
4692
|
+
import { FuelError as FuelError18, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
4627
4693
|
var validatePaginationArgs = (params) => {
|
4628
4694
|
const { paginationLimit, inputArgs = {} } = params;
|
4629
4695
|
const { first, last, after, before } = inputArgs;
|
4630
4696
|
if (after && before) {
|
4631
|
-
throw new
|
4632
|
-
|
4697
|
+
throw new FuelError18(
|
4698
|
+
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4633
4699
|
'Pagination arguments "after" and "before" cannot be used together'
|
4634
4700
|
);
|
4635
4701
|
}
|
4636
4702
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
4637
|
-
throw new
|
4638
|
-
|
4703
|
+
throw new FuelError18(
|
4704
|
+
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4639
4705
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
4640
4706
|
);
|
4641
4707
|
}
|
4642
4708
|
if (first && before) {
|
4643
|
-
throw new
|
4644
|
-
|
4709
|
+
throw new FuelError18(
|
4710
|
+
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4645
4711
|
'The use of pagination argument "first" with "before" is not supported'
|
4646
4712
|
);
|
4647
4713
|
}
|
4648
4714
|
if (last && after) {
|
4649
|
-
throw new
|
4650
|
-
|
4715
|
+
throw new FuelError18(
|
4716
|
+
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4651
4717
|
'The use of pagination argument "last" with "after" is not supported'
|
4652
4718
|
);
|
4653
4719
|
}
|
@@ -4801,7 +4867,7 @@ var _Provider = class {
|
|
4801
4867
|
try {
|
4802
4868
|
parsedUrl = new URL(url);
|
4803
4869
|
} catch (error) {
|
4804
|
-
throw new
|
4870
|
+
throw new FuelError19(FuelError19.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4805
4871
|
}
|
4806
4872
|
const username = parsedUrl.username;
|
4807
4873
|
const password = parsedUrl.password;
|
@@ -4816,58 +4882,40 @@ var _Provider = class {
|
|
4816
4882
|
};
|
4817
4883
|
}
|
4818
4884
|
/**
|
4819
|
-
*
|
4820
|
-
*
|
4821
|
-
* @param url - GraphQL endpoint of the Fuel node
|
4822
|
-
* @param options - Additional options for the provider
|
4823
|
-
*
|
4824
|
-
* @returns A promise that resolves to a Provider instance.
|
4885
|
+
* Initialize Provider async stuff
|
4825
4886
|
*/
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
4829
|
-
return provider;
|
4887
|
+
async init() {
|
4888
|
+
await this.fetchChainAndNodeInfo();
|
4889
|
+
return this;
|
4830
4890
|
}
|
4831
4891
|
/**
|
4832
|
-
* Returns the
|
4892
|
+
* Returns the `chainInfo` for the current network.
|
4833
4893
|
*
|
4834
4894
|
* @returns the chain information configuration.
|
4835
4895
|
*/
|
4836
|
-
getChain() {
|
4837
|
-
|
4838
|
-
|
4839
|
-
throw new FuelError18(
|
4840
|
-
ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
|
4841
|
-
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4842
|
-
);
|
4843
|
-
}
|
4844
|
-
return chain;
|
4896
|
+
async getChain() {
|
4897
|
+
await this.init();
|
4898
|
+
return _Provider.chainInfoCache[this.urlWithoutAuth];
|
4845
4899
|
}
|
4846
4900
|
/**
|
4847
|
-
* Returns the
|
4901
|
+
* Returns the `nodeInfo` for the current network.
|
4848
4902
|
*
|
4849
4903
|
* @returns the node information configuration.
|
4850
4904
|
*/
|
4851
|
-
getNode() {
|
4852
|
-
|
4853
|
-
|
4854
|
-
throw new FuelError18(
|
4855
|
-
ErrorCode15.NODE_INFO_CACHE_EMPTY,
|
4856
|
-
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4857
|
-
);
|
4858
|
-
}
|
4859
|
-
return node;
|
4905
|
+
async getNode() {
|
4906
|
+
await this.init();
|
4907
|
+
return _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4860
4908
|
}
|
4861
4909
|
/**
|
4862
4910
|
* Returns some helpful parameters related to gas fees.
|
4863
4911
|
*/
|
4864
|
-
getGasConfig() {
|
4912
|
+
async getGasConfig() {
|
4865
4913
|
const {
|
4866
4914
|
txParameters: { maxGasPerTx },
|
4867
4915
|
predicateParameters: { maxGasPerPredicate },
|
4868
4916
|
feeParameters: { gasPriceFactor, gasPerByte },
|
4869
4917
|
gasCosts
|
4870
|
-
} = this.getChain().consensusParameters;
|
4918
|
+
} = (await this.getChain()).consensusParameters;
|
4871
4919
|
return {
|
4872
4920
|
maxGasPerTx,
|
4873
4921
|
maxGasPerPredicate,
|
@@ -4889,7 +4937,7 @@ var _Provider = class {
|
|
4889
4937
|
this.options = options ?? this.options;
|
4890
4938
|
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4891
4939
|
this.operations = this.createOperations();
|
4892
|
-
await this.
|
4940
|
+
await this.init();
|
4893
4941
|
}
|
4894
4942
|
/**
|
4895
4943
|
* Return the chain and node information.
|
@@ -4900,11 +4948,12 @@ var _Provider = class {
|
|
4900
4948
|
let nodeInfo;
|
4901
4949
|
let chain;
|
4902
4950
|
try {
|
4903
|
-
|
4904
|
-
|
4951
|
+
nodeInfo = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4952
|
+
chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4953
|
+
const noCache = !nodeInfo || !chain;
|
4954
|
+
if (ignoreCache || noCache) {
|
4955
|
+
throw new Error(`Jumps to the catch block and re-fetch`);
|
4905
4956
|
}
|
4906
|
-
nodeInfo = this.getNode();
|
4907
|
-
chain = this.getChain();
|
4908
4957
|
} catch (_err) {
|
4909
4958
|
const data = await this.operations.getChainAndNodeInfo();
|
4910
4959
|
nodeInfo = {
|
@@ -4914,7 +4963,7 @@ var _Provider = class {
|
|
4914
4963
|
utxoValidation: data.nodeInfo.utxoValidation,
|
4915
4964
|
vmBacktrace: data.nodeInfo.vmBacktrace
|
4916
4965
|
};
|
4917
|
-
_Provider.
|
4966
|
+
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
4918
4967
|
chain = processGqlChain(data.chain);
|
4919
4968
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
4920
4969
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
@@ -4928,15 +4977,15 @@ var _Provider = class {
|
|
4928
4977
|
/**
|
4929
4978
|
* @hidden
|
4930
4979
|
*/
|
4931
|
-
static
|
4980
|
+
static setIncompatibleNodeVersionMessage(nodeInfo) {
|
4932
4981
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
4933
4982
|
if (!isMajorSupported || !isMinorSupported) {
|
4934
|
-
|
4935
|
-
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}
|
4936
|
-
|
4937
|
-
Things may not work as expected
|
4938
|
-
|
4939
|
-
|
4983
|
+
_Provider.incompatibleNodeVersionMessage = [
|
4984
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}.`,
|
4985
|
+
`The TS SDK currently supports fuel-core version ${supportedVersion}.`,
|
4986
|
+
`Things may not work as expected.`
|
4987
|
+
].join("\n");
|
4988
|
+
FuelGraphqlSubscriber.incompatibleNodeVersionMessage = _Provider.incompatibleNodeVersionMessage;
|
4940
4989
|
}
|
4941
4990
|
}
|
4942
4991
|
/**
|
@@ -4952,11 +5001,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4952
5001
|
responseMiddleware: (response) => {
|
4953
5002
|
if ("response" in response) {
|
4954
5003
|
const graphQlResponse = response.response;
|
4955
|
-
|
4956
|
-
|
4957
|
-
|
4958
|
-
|
4959
|
-
}
|
5004
|
+
assertGqlResponseHasNoErrors(
|
5005
|
+
graphQlResponse.errors,
|
5006
|
+
_Provider.incompatibleNodeVersionMessage
|
5007
|
+
);
|
4960
5008
|
}
|
4961
5009
|
}
|
4962
5010
|
});
|
@@ -5051,10 +5099,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5051
5099
|
*
|
5052
5100
|
* @returns A promise that resolves to the chain ID number.
|
5053
5101
|
*/
|
5054
|
-
getChainId() {
|
5102
|
+
async getChainId() {
|
5055
5103
|
const {
|
5056
5104
|
consensusParameters: { chainId }
|
5057
|
-
} = this.getChain();
|
5105
|
+
} = await this.getChain();
|
5058
5106
|
return chainId.toNumber();
|
5059
5107
|
}
|
5060
5108
|
/**
|
@@ -5062,30 +5110,31 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5062
5110
|
*
|
5063
5111
|
* @returns the base asset ID.
|
5064
5112
|
*/
|
5065
|
-
getBaseAssetId() {
|
5113
|
+
async getBaseAssetId() {
|
5114
|
+
const all = await this.getChain();
|
5066
5115
|
const {
|
5067
5116
|
consensusParameters: { baseAssetId }
|
5068
|
-
} =
|
5117
|
+
} = all;
|
5069
5118
|
return baseAssetId;
|
5070
5119
|
}
|
5071
5120
|
/**
|
5072
5121
|
* @hidden
|
5073
5122
|
*/
|
5074
|
-
validateTransaction(tx) {
|
5123
|
+
async validateTransaction(tx) {
|
5075
5124
|
const {
|
5076
5125
|
consensusParameters: {
|
5077
5126
|
txParameters: { maxInputs, maxOutputs }
|
5078
5127
|
}
|
5079
|
-
} = this.getChain();
|
5128
|
+
} = await this.getChain();
|
5080
5129
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
5081
|
-
throw new
|
5082
|
-
|
5130
|
+
throw new FuelError19(
|
5131
|
+
ErrorCode16.MAX_INPUTS_EXCEEDED,
|
5083
5132
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5084
5133
|
);
|
5085
5134
|
}
|
5086
5135
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
5087
|
-
throw new
|
5088
|
-
|
5136
|
+
throw new FuelError19(
|
5137
|
+
ErrorCode16.MAX_OUTPUTS_EXCEEDED,
|
5089
5138
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5090
5139
|
);
|
5091
5140
|
}
|
@@ -5100,20 +5149,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5100
5149
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
5101
5150
|
* @returns A promise that resolves to the transaction response object.
|
5102
5151
|
*/
|
5103
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
5152
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, enableAssetBurn } = {}) {
|
5104
5153
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5154
|
+
validateTransactionForAssetBurn(
|
5155
|
+
await this.getBaseAssetId(),
|
5156
|
+
transactionRequest,
|
5157
|
+
enableAssetBurn
|
5158
|
+
);
|
5105
5159
|
if (estimateTxDependencies) {
|
5106
5160
|
await this.estimateTxDependencies(transactionRequest);
|
5107
5161
|
}
|
5108
|
-
this.validateTransaction(transactionRequest);
|
5162
|
+
await this.validateTransaction(transactionRequest);
|
5109
5163
|
const encodedTransaction = hexlify17(transactionRequest.toTransactionBytes());
|
5110
5164
|
let abis;
|
5111
5165
|
if (isTransactionTypeScript(transactionRequest)) {
|
5112
5166
|
abis = transactionRequest.abis;
|
5113
5167
|
}
|
5114
5168
|
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
5115
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
5116
|
-
|
5169
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(await this.getChainId()));
|
5170
|
+
const chainId = await this.getChainId();
|
5171
|
+
return new TransactionResponse(transactionRequest, this, chainId, abis, subscription);
|
5117
5172
|
}
|
5118
5173
|
/**
|
5119
5174
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -5179,9 +5234,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5179
5234
|
* `addVariableOutputs` is called on the transaction.
|
5180
5235
|
*
|
5181
5236
|
* @param transactionRequest - The transaction request object.
|
5237
|
+
* @param gasPrice - The gas price to use for the transaction, if not provided it will be fetched.
|
5182
5238
|
* @returns A promise that resolves to the estimate transaction dependencies.
|
5183
5239
|
*/
|
5184
|
-
async estimateTxDependencies(transactionRequest) {
|
5240
|
+
async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
|
5185
5241
|
if (isTransactionTypeCreate(transactionRequest)) {
|
5186
5242
|
return {
|
5187
5243
|
receipts: [],
|
@@ -5193,14 +5249,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5193
5249
|
const missingContractIds = [];
|
5194
5250
|
let outputVariables = 0;
|
5195
5251
|
let dryRunStatus;
|
5196
|
-
this.validateTransaction(transactionRequest);
|
5252
|
+
await this.validateTransaction(transactionRequest);
|
5253
|
+
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5197
5254
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5198
5255
|
const {
|
5199
5256
|
dryRun: [{ receipts: rawReceipts, status }]
|
5200
5257
|
} = await this.operations.dryRun({
|
5201
5258
|
encodedTransactions: [hexlify17(transactionRequest.toTransactionBytes())],
|
5202
5259
|
utxoValidation: false,
|
5203
|
-
gasPrice:
|
5260
|
+
gasPrice: gasPrice.toString()
|
5204
5261
|
});
|
5205
5262
|
receipts = rawReceipts.map(processGqlReceipt);
|
5206
5263
|
dryRunStatus = status;
|
@@ -5210,12 +5267,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5210
5267
|
outputVariables += missingOutputVariables.length;
|
5211
5268
|
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
5212
5269
|
missingOutputContractIds.forEach(({ contractId }) => {
|
5213
|
-
transactionRequest.addContractInputAndOutput(Address3
|
5270
|
+
transactionRequest.addContractInputAndOutput(new Address3(contractId));
|
5214
5271
|
missingContractIds.push(contractId);
|
5215
5272
|
});
|
5216
5273
|
const { maxFee } = await this.estimateTxGasAndFee({
|
5217
5274
|
transactionRequest,
|
5218
|
-
gasPrice
|
5275
|
+
gasPrice
|
5219
5276
|
});
|
5220
5277
|
transactionRequest.maxFee = maxFee;
|
5221
5278
|
} else {
|
@@ -5279,7 +5336,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5279
5336
|
result.outputVariables += missingOutputVariables.length;
|
5280
5337
|
request.addVariableOutputs(missingOutputVariables.length);
|
5281
5338
|
missingOutputContractIds.forEach(({ contractId }) => {
|
5282
|
-
request.addContractInputAndOutput(Address3
|
5339
|
+
request.addContractInputAndOutput(new Address3(contractId));
|
5283
5340
|
result.missingContractIds.push(contractId);
|
5284
5341
|
});
|
5285
5342
|
const { maxFee } = await this.estimateTxGasAndFee({
|
@@ -5324,7 +5381,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5324
5381
|
if (diff < 6e4) {
|
5325
5382
|
return;
|
5326
5383
|
}
|
5327
|
-
|
5384
|
+
if (!_Provider.chainInfoCache?.[this.urlWithoutAuth]) {
|
5385
|
+
await this.fetchChainAndNodeInfo(true);
|
5386
|
+
return;
|
5387
|
+
}
|
5388
|
+
const chainInfo = _Provider.chainInfoCache[this.urlWithoutAuth];
|
5328
5389
|
const {
|
5329
5390
|
consensusParameters: { version: previous }
|
5330
5391
|
} = chainInfo;
|
@@ -5341,15 +5402,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5341
5402
|
}
|
5342
5403
|
/**
|
5343
5404
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
5344
|
-
* @param
|
5405
|
+
* @param params - The parameters for estimating the transaction gas and fee.
|
5345
5406
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
5346
5407
|
*/
|
5347
5408
|
async estimateTxGasAndFee(params) {
|
5348
|
-
const { transactionRequest } = params;
|
5349
|
-
let
|
5409
|
+
const { transactionRequest, gasPrice: gasPriceParam } = params;
|
5410
|
+
let gasPrice = gasPriceParam;
|
5350
5411
|
await this.autoRefetchConfigs();
|
5351
|
-
const chainInfo = this.getChain();
|
5352
|
-
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
5412
|
+
const chainInfo = await this.getChain();
|
5413
|
+
const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
|
5353
5414
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
5354
5415
|
if (!isDefined2(gasPrice)) {
|
5355
5416
|
gasPrice = await this.estimateGasPrice(10);
|
@@ -5427,7 +5488,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5427
5488
|
*
|
5428
5489
|
* @returns A promise that resolves to the transaction cost object.
|
5429
5490
|
*/
|
5430
|
-
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5491
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, gasPrice: gasPriceParam } = {}) {
|
5431
5492
|
const txRequestClone = clone8(transactionRequestify(transactionRequestLike));
|
5432
5493
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5433
5494
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
@@ -5443,8 +5504,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5443
5504
|
}
|
5444
5505
|
await this.estimatePredicates(signedRequest);
|
5445
5506
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
5446
|
-
|
5447
|
-
|
5507
|
+
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5508
|
+
let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
|
5509
|
+
// Fetches and returns a gas price
|
5510
|
+
transactionRequest: signedRequest,
|
5511
|
+
gasPrice
|
5448
5512
|
});
|
5449
5513
|
let receipts = [];
|
5450
5514
|
let dryRunStatus;
|
@@ -5457,15 +5521,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5457
5521
|
if (signatureCallback) {
|
5458
5522
|
await signatureCallback(txRequestClone);
|
5459
5523
|
}
|
5460
|
-
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
5524
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
5461
5525
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
5462
5526
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
5463
5527
|
}
|
5464
|
-
const { maxGasPerTx } = this.getGasConfig();
|
5528
|
+
const { maxGasPerTx } = await this.getGasConfig();
|
5465
5529
|
const pristineGasUsed = getGasUsedFromReceipts(receipts);
|
5466
5530
|
gasUsed = bn17(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
|
5467
5531
|
txRequestClone.gasLimit = gasUsed;
|
5468
|
-
({ maxFee, maxGas, minFee, minGas
|
5532
|
+
({ maxFee, maxGas, minFee, minGas } = await this.estimateTxGasAndFee({
|
5469
5533
|
transactionRequest: txRequestClone,
|
5470
5534
|
gasPrice
|
5471
5535
|
}));
|
@@ -5496,7 +5560,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5496
5560
|
* @returns A promise that resolves to the coins.
|
5497
5561
|
*/
|
5498
5562
|
async getCoins(owner, assetId, paginationArgs) {
|
5499
|
-
const ownerAddress = Address3
|
5563
|
+
const ownerAddress = new Address3(owner);
|
5500
5564
|
const {
|
5501
5565
|
coins: { edges, pageInfo }
|
5502
5566
|
} = await this.operations.getCoins({
|
@@ -5528,7 +5592,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5528
5592
|
* @returns A promise that resolves to the resources.
|
5529
5593
|
*/
|
5530
5594
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5531
|
-
const ownerAddress = Address3
|
5595
|
+
const ownerAddress = new Address3(owner);
|
5532
5596
|
const excludeInput = {
|
5533
5597
|
messages: excludedIds?.messages?.map((nonce) => hexlify17(nonce)) || [],
|
5534
5598
|
utxos: excludedIds?.utxos?.map((id) => hexlify17(id)) || []
|
@@ -5555,8 +5619,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5555
5619
|
amount: bn17(coin.amount),
|
5556
5620
|
assetId: coin.assetId,
|
5557
5621
|
daHeight: bn17(coin.daHeight),
|
5558
|
-
sender: Address3
|
5559
|
-
recipient: Address3
|
5622
|
+
sender: new Address3(coin.sender),
|
5623
|
+
recipient: new Address3(coin.recipient),
|
5560
5624
|
nonce: coin.nonce
|
5561
5625
|
};
|
5562
5626
|
case "Coin":
|
@@ -5718,7 +5782,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5718
5782
|
0
|
5719
5783
|
)?.[0];
|
5720
5784
|
} catch (error) {
|
5721
|
-
if (error instanceof
|
5785
|
+
if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
5722
5786
|
console.warn("Unsupported transaction type encountered");
|
5723
5787
|
return null;
|
5724
5788
|
}
|
@@ -5744,7 +5808,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5744
5808
|
try {
|
5745
5809
|
return coder.decode(arrayify13(rawPayload), 0)[0];
|
5746
5810
|
} catch (error) {
|
5747
|
-
if (error instanceof
|
5811
|
+
if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
5748
5812
|
console.warn("Unsupported transaction type encountered");
|
5749
5813
|
return null;
|
5750
5814
|
}
|
@@ -5753,6 +5817,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5753
5817
|
}).filter((tx) => tx !== null);
|
5754
5818
|
return { transactions, pageInfo };
|
5755
5819
|
}
|
5820
|
+
/**
|
5821
|
+
* Fetches a compressed block at the specified height.
|
5822
|
+
*
|
5823
|
+
* @param height - The height of the block to fetch.
|
5824
|
+
* @returns The compressed block if available, otherwise `null`.
|
5825
|
+
*/
|
5826
|
+
async daCompressedBlock(height) {
|
5827
|
+
const { daCompressedBlock } = await this.operations.daCompressedBlock({
|
5828
|
+
height
|
5829
|
+
});
|
5830
|
+
if (!daCompressedBlock) {
|
5831
|
+
return null;
|
5832
|
+
}
|
5833
|
+
return daCompressedBlock;
|
5834
|
+
}
|
5756
5835
|
/**
|
5757
5836
|
* Get deployed contract with the given ID.
|
5758
5837
|
*
|
@@ -5775,7 +5854,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5775
5854
|
*/
|
5776
5855
|
async getContractBalance(contractId, assetId) {
|
5777
5856
|
const { contractBalance } = await this.operations.getContractBalance({
|
5778
|
-
contract: Address3
|
5857
|
+
contract: new Address3(contractId).toB256(),
|
5779
5858
|
asset: hexlify17(assetId)
|
5780
5859
|
});
|
5781
5860
|
return bn17(contractBalance.amount, 10);
|
@@ -5789,7 +5868,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5789
5868
|
*/
|
5790
5869
|
async getBalance(owner, assetId) {
|
5791
5870
|
const { balance } = await this.operations.getBalance({
|
5792
|
-
owner: Address3
|
5871
|
+
owner: new Address3(owner).toB256(),
|
5793
5872
|
assetId: hexlify17(assetId)
|
5794
5873
|
});
|
5795
5874
|
return bn17(balance.amount, 10);
|
@@ -5810,7 +5889,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5810
5889
|
* but the current Fuel-Core implementation does not support pagination yet.
|
5811
5890
|
*/
|
5812
5891
|
first: 1e4,
|
5813
|
-
filter: { owner: Address3
|
5892
|
+
filter: { owner: new Address3(owner).toB256() }
|
5814
5893
|
});
|
5815
5894
|
const balances = edges.map(({ node }) => ({
|
5816
5895
|
assetId: node.assetId,
|
@@ -5833,7 +5912,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5833
5912
|
inputArgs: paginationArgs,
|
5834
5913
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
|
5835
5914
|
}),
|
5836
|
-
owner: Address3
|
5915
|
+
owner: new Address3(address).toB256()
|
5837
5916
|
});
|
5838
5917
|
const messages = edges.map(({ node }) => ({
|
5839
5918
|
messageId: InputMessageCoder2.getMessageId({
|
@@ -5843,8 +5922,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5843
5922
|
amount: bn17(node.amount),
|
5844
5923
|
data: node.data
|
5845
5924
|
}),
|
5846
|
-
sender: Address3
|
5847
|
-
recipient: Address3
|
5925
|
+
sender: new Address3(node.sender),
|
5926
|
+
recipient: new Address3(node.recipient),
|
5848
5927
|
nonce: node.nonce,
|
5849
5928
|
amount: bn17(node.amount),
|
5850
5929
|
data: InputMessageCoder2.decodeData(node.data),
|
@@ -5870,8 +5949,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5870
5949
|
nonce
|
5871
5950
|
};
|
5872
5951
|
if (commitBlockId && commitBlockHeight) {
|
5873
|
-
throw new
|
5874
|
-
|
5952
|
+
throw new FuelError19(
|
5953
|
+
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
5875
5954
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5876
5955
|
);
|
5877
5956
|
}
|
@@ -5942,8 +6021,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5942
6021
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
5943
6022
|
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
5944
6023
|
},
|
5945
|
-
sender: Address3
|
5946
|
-
recipient: Address3
|
6024
|
+
sender: new Address3(sender),
|
6025
|
+
recipient: new Address3(recipient),
|
5947
6026
|
nonce,
|
5948
6027
|
amount: bn17(amount),
|
5949
6028
|
data
|
@@ -6034,9 +6113,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6034
6113
|
* @param transactionId - The transaction ID to get the response for.
|
6035
6114
|
* @returns A promise that resolves to the transaction response.
|
6036
6115
|
*/
|
6037
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
6038
6116
|
async getTransactionResponse(transactionId) {
|
6039
|
-
|
6117
|
+
const chainId = await this.getChainId();
|
6118
|
+
return new TransactionResponse(transactionId, this, chainId);
|
6040
6119
|
}
|
6041
6120
|
/**
|
6042
6121
|
* Returns Message for given nonce.
|
@@ -6057,8 +6136,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6057
6136
|
amount: bn17(rawMessage.amount),
|
6058
6137
|
data: rawMessage.data
|
6059
6138
|
}),
|
6060
|
-
sender: Address3
|
6061
|
-
recipient: Address3
|
6139
|
+
sender: new Address3(rawMessage.sender),
|
6140
|
+
recipient: new Address3(rawMessage.recipient),
|
6062
6141
|
nonce,
|
6063
6142
|
amount: bn17(rawMessage.amount),
|
6064
6143
|
data: InputMessageCoder2.decodeData(rawMessage.data),
|
@@ -6124,617 +6203,15 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
6124
6203
|
__publicField(Provider, "chainInfoCache", {});
|
6125
6204
|
/** @hidden */
|
6126
6205
|
__publicField(Provider, "nodeInfoCache", {});
|
6206
|
+
/** @hidden */
|
6207
|
+
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6127
6208
|
|
6128
6209
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6129
|
-
import { ErrorCode as
|
6210
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6130
6211
|
import { bn as bn18 } from "@fuel-ts/math";
|
6131
6212
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
6132
6213
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
6133
6214
|
|
6134
|
-
// src/providers/chains.ts
|
6135
|
-
var CHAIN_IDS = {
|
6136
|
-
eth: {
|
6137
|
-
mainnet: 1,
|
6138
|
-
sepolia: 11155111,
|
6139
|
-
foundry: 31337
|
6140
|
-
},
|
6141
|
-
fuel: {
|
6142
|
-
devnet: 0,
|
6143
|
-
testnet: 0,
|
6144
|
-
mainnet: 9889
|
6145
|
-
}
|
6146
|
-
};
|
6147
|
-
|
6148
|
-
// src/providers/assets/utils/url.ts
|
6149
|
-
var DELIMITER_PATH = "/";
|
6150
|
-
var trimRegex = /^\/|\/$/g;
|
6151
|
-
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
6152
|
-
function urlJoin(baseUrl, ...paths) {
|
6153
|
-
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
6154
|
-
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
6155
|
-
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
6156
|
-
if (rootPath && hasBaseUrl) {
|
6157
|
-
allPaths.unshift("");
|
6158
|
-
}
|
6159
|
-
return allPaths.join(DELIMITER_PATH);
|
6160
|
-
}
|
6161
|
-
|
6162
|
-
// src/providers/assets/utils/resolveIconPaths.ts
|
6163
|
-
function resolveIconPaths(assets2, basePath = "./") {
|
6164
|
-
return assets2.map((asset) => ({
|
6165
|
-
...asset,
|
6166
|
-
icon: urlJoin(basePath, asset.icon)
|
6167
|
-
}));
|
6168
|
-
}
|
6169
|
-
|
6170
|
-
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
6171
|
-
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
6172
|
-
|
6173
|
-
// src/providers/assets/assets.ts
|
6174
|
-
var rawAssets = [
|
6175
|
-
{
|
6176
|
-
name: "Ethereum",
|
6177
|
-
symbol: "ETH",
|
6178
|
-
icon: "eth.svg",
|
6179
|
-
networks: [
|
6180
|
-
{
|
6181
|
-
type: "ethereum",
|
6182
|
-
chainId: CHAIN_IDS.eth.sepolia,
|
6183
|
-
decimals: 18
|
6184
|
-
},
|
6185
|
-
{
|
6186
|
-
type: "ethereum",
|
6187
|
-
chainId: CHAIN_IDS.eth.foundry,
|
6188
|
-
decimals: 18
|
6189
|
-
},
|
6190
|
-
{
|
6191
|
-
type: "ethereum",
|
6192
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6193
|
-
decimals: 18
|
6194
|
-
},
|
6195
|
-
{
|
6196
|
-
type: "fuel",
|
6197
|
-
chainId: CHAIN_IDS.fuel.devnet,
|
6198
|
-
decimals: 9,
|
6199
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6200
|
-
},
|
6201
|
-
{
|
6202
|
-
type: "fuel",
|
6203
|
-
chainId: CHAIN_IDS.fuel.testnet,
|
6204
|
-
decimals: 9,
|
6205
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6206
|
-
},
|
6207
|
-
{
|
6208
|
-
type: "fuel",
|
6209
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6210
|
-
decimals: 9,
|
6211
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6212
|
-
}
|
6213
|
-
]
|
6214
|
-
},
|
6215
|
-
{
|
6216
|
-
name: "WETH",
|
6217
|
-
symbol: "WETH",
|
6218
|
-
icon: "weth.svg",
|
6219
|
-
networks: [
|
6220
|
-
{
|
6221
|
-
type: "ethereum",
|
6222
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6223
|
-
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6224
|
-
decimals: 18
|
6225
|
-
},
|
6226
|
-
{
|
6227
|
-
type: "fuel",
|
6228
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6229
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6230
|
-
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6231
|
-
decimals: 9
|
6232
|
-
}
|
6233
|
-
]
|
6234
|
-
},
|
6235
|
-
{
|
6236
|
-
name: "weETH",
|
6237
|
-
symbol: "weETH",
|
6238
|
-
icon: "weETH.webp",
|
6239
|
-
networks: [
|
6240
|
-
{
|
6241
|
-
type: "ethereum",
|
6242
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6243
|
-
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6244
|
-
decimals: 18
|
6245
|
-
},
|
6246
|
-
{
|
6247
|
-
type: "fuel",
|
6248
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6249
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6250
|
-
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6251
|
-
decimals: 9
|
6252
|
-
}
|
6253
|
-
]
|
6254
|
-
},
|
6255
|
-
{
|
6256
|
-
name: "rsETH",
|
6257
|
-
symbol: "rsETH",
|
6258
|
-
icon: "rsETH.webp",
|
6259
|
-
networks: [
|
6260
|
-
{
|
6261
|
-
type: "ethereum",
|
6262
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6263
|
-
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6264
|
-
decimals: 18
|
6265
|
-
},
|
6266
|
-
{
|
6267
|
-
type: "fuel",
|
6268
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6269
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6270
|
-
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6271
|
-
decimals: 9
|
6272
|
-
}
|
6273
|
-
]
|
6274
|
-
},
|
6275
|
-
{
|
6276
|
-
name: "rETH",
|
6277
|
-
symbol: "rETH",
|
6278
|
-
icon: "reth.svg",
|
6279
|
-
networks: [
|
6280
|
-
{
|
6281
|
-
type: "ethereum",
|
6282
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6283
|
-
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6284
|
-
decimals: 18
|
6285
|
-
},
|
6286
|
-
{
|
6287
|
-
type: "fuel",
|
6288
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6289
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6290
|
-
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6291
|
-
decimals: 9
|
6292
|
-
}
|
6293
|
-
]
|
6294
|
-
},
|
6295
|
-
{
|
6296
|
-
name: "wbETH",
|
6297
|
-
symbol: "wbETH",
|
6298
|
-
icon: "wbeth.png",
|
6299
|
-
networks: [
|
6300
|
-
{
|
6301
|
-
type: "ethereum",
|
6302
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6303
|
-
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6304
|
-
decimals: 18
|
6305
|
-
},
|
6306
|
-
{
|
6307
|
-
type: "fuel",
|
6308
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6309
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6310
|
-
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6311
|
-
decimals: 9
|
6312
|
-
}
|
6313
|
-
]
|
6314
|
-
},
|
6315
|
-
{
|
6316
|
-
name: "rstETH",
|
6317
|
-
symbol: "rstETH",
|
6318
|
-
icon: "rstETH.webp",
|
6319
|
-
networks: [
|
6320
|
-
{
|
6321
|
-
type: "ethereum",
|
6322
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6323
|
-
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6324
|
-
decimals: 18
|
6325
|
-
},
|
6326
|
-
{
|
6327
|
-
type: "fuel",
|
6328
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6329
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6330
|
-
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6331
|
-
decimals: 9
|
6332
|
-
}
|
6333
|
-
]
|
6334
|
-
},
|
6335
|
-
{
|
6336
|
-
name: "amphrETH",
|
6337
|
-
symbol: "amphrETH",
|
6338
|
-
icon: "amphrETH.png",
|
6339
|
-
networks: [
|
6340
|
-
{
|
6341
|
-
type: "ethereum",
|
6342
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6343
|
-
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6344
|
-
decimals: 18
|
6345
|
-
},
|
6346
|
-
{
|
6347
|
-
type: "fuel",
|
6348
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6349
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6350
|
-
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6351
|
-
decimals: 9
|
6352
|
-
}
|
6353
|
-
]
|
6354
|
-
},
|
6355
|
-
{
|
6356
|
-
name: "Manta mBTC",
|
6357
|
-
symbol: "Manta mBTC",
|
6358
|
-
icon: "manta-mbtc.svg",
|
6359
|
-
networks: [
|
6360
|
-
{
|
6361
|
-
type: "ethereum",
|
6362
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6363
|
-
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6364
|
-
decimals: 18
|
6365
|
-
},
|
6366
|
-
{
|
6367
|
-
type: "fuel",
|
6368
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6369
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6370
|
-
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6371
|
-
decimals: 9
|
6372
|
-
}
|
6373
|
-
]
|
6374
|
-
},
|
6375
|
-
{
|
6376
|
-
name: "Manta mETH",
|
6377
|
-
symbol: "Manta mETH",
|
6378
|
-
icon: "manta-meth.svg",
|
6379
|
-
networks: [
|
6380
|
-
{
|
6381
|
-
type: "ethereum",
|
6382
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6383
|
-
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6384
|
-
decimals: 18
|
6385
|
-
},
|
6386
|
-
{
|
6387
|
-
type: "fuel",
|
6388
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6389
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6390
|
-
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6391
|
-
decimals: 9
|
6392
|
-
}
|
6393
|
-
]
|
6394
|
-
},
|
6395
|
-
{
|
6396
|
-
name: "Manta mUSD",
|
6397
|
-
symbol: "Manta mUSD",
|
6398
|
-
icon: "manta-musd.svg",
|
6399
|
-
networks: [
|
6400
|
-
{
|
6401
|
-
type: "ethereum",
|
6402
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6403
|
-
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6404
|
-
decimals: 18
|
6405
|
-
},
|
6406
|
-
{
|
6407
|
-
type: "fuel",
|
6408
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6409
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6410
|
-
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6411
|
-
decimals: 9
|
6412
|
-
}
|
6413
|
-
]
|
6414
|
-
},
|
6415
|
-
{
|
6416
|
-
name: "pumpBTC",
|
6417
|
-
symbol: "pumpBTC",
|
6418
|
-
icon: "pumpbtc.webp",
|
6419
|
-
networks: [
|
6420
|
-
{
|
6421
|
-
type: "ethereum",
|
6422
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6423
|
-
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6424
|
-
decimals: 8
|
6425
|
-
},
|
6426
|
-
{
|
6427
|
-
type: "fuel",
|
6428
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6429
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6430
|
-
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6431
|
-
decimals: 8
|
6432
|
-
}
|
6433
|
-
]
|
6434
|
-
},
|
6435
|
-
{
|
6436
|
-
name: "FBTC",
|
6437
|
-
symbol: "FBTC",
|
6438
|
-
icon: "fbtc.svg",
|
6439
|
-
networks: [
|
6440
|
-
{
|
6441
|
-
type: "ethereum",
|
6442
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6443
|
-
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6444
|
-
decimals: 8
|
6445
|
-
},
|
6446
|
-
{
|
6447
|
-
type: "fuel",
|
6448
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6449
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6450
|
-
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6451
|
-
decimals: 8
|
6452
|
-
}
|
6453
|
-
]
|
6454
|
-
},
|
6455
|
-
{
|
6456
|
-
name: "SolvBTC",
|
6457
|
-
symbol: "SolvBTC",
|
6458
|
-
icon: "solvBTC.webp",
|
6459
|
-
networks: [
|
6460
|
-
{
|
6461
|
-
type: "ethereum",
|
6462
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6463
|
-
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6464
|
-
decimals: 18
|
6465
|
-
},
|
6466
|
-
{
|
6467
|
-
type: "fuel",
|
6468
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6469
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6470
|
-
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6471
|
-
decimals: 9
|
6472
|
-
}
|
6473
|
-
]
|
6474
|
-
},
|
6475
|
-
{
|
6476
|
-
name: "SolvBTC.BBN",
|
6477
|
-
symbol: "SolvBTC.BBN",
|
6478
|
-
icon: "SolvBTC.BBN.png",
|
6479
|
-
networks: [
|
6480
|
-
{
|
6481
|
-
type: "ethereum",
|
6482
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6483
|
-
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6484
|
-
decimals: 18
|
6485
|
-
},
|
6486
|
-
{
|
6487
|
-
type: "fuel",
|
6488
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6489
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6490
|
-
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6491
|
-
decimals: 9
|
6492
|
-
}
|
6493
|
-
]
|
6494
|
-
},
|
6495
|
-
{
|
6496
|
-
name: "Mantle mETH",
|
6497
|
-
symbol: "Mantle mETH",
|
6498
|
-
icon: "mantle-meth.svg",
|
6499
|
-
networks: [
|
6500
|
-
{
|
6501
|
-
type: "ethereum",
|
6502
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6503
|
-
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6504
|
-
decimals: 18
|
6505
|
-
},
|
6506
|
-
{
|
6507
|
-
type: "fuel",
|
6508
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6509
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6510
|
-
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6511
|
-
decimals: 9
|
6512
|
-
}
|
6513
|
-
]
|
6514
|
-
},
|
6515
|
-
{
|
6516
|
-
name: "sDAI",
|
6517
|
-
symbol: "sDAI",
|
6518
|
-
icon: "sdai.svg",
|
6519
|
-
networks: [
|
6520
|
-
{
|
6521
|
-
type: "ethereum",
|
6522
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6523
|
-
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6524
|
-
decimals: 18
|
6525
|
-
},
|
6526
|
-
{
|
6527
|
-
type: "fuel",
|
6528
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6529
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6530
|
-
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6531
|
-
decimals: 9
|
6532
|
-
}
|
6533
|
-
]
|
6534
|
-
},
|
6535
|
-
{
|
6536
|
-
name: "USDT",
|
6537
|
-
symbol: "USDT",
|
6538
|
-
icon: "usdt.svg",
|
6539
|
-
networks: [
|
6540
|
-
{
|
6541
|
-
type: "ethereum",
|
6542
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6543
|
-
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6544
|
-
decimals: 6
|
6545
|
-
},
|
6546
|
-
{
|
6547
|
-
type: "fuel",
|
6548
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6549
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6550
|
-
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6551
|
-
decimals: 6
|
6552
|
-
}
|
6553
|
-
]
|
6554
|
-
},
|
6555
|
-
{
|
6556
|
-
name: "USDC",
|
6557
|
-
symbol: "USDC",
|
6558
|
-
icon: "usdc.svg",
|
6559
|
-
networks: [
|
6560
|
-
{
|
6561
|
-
type: "ethereum",
|
6562
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6563
|
-
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6564
|
-
decimals: 6
|
6565
|
-
},
|
6566
|
-
{
|
6567
|
-
type: "fuel",
|
6568
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6569
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6570
|
-
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6571
|
-
decimals: 6
|
6572
|
-
}
|
6573
|
-
]
|
6574
|
-
},
|
6575
|
-
{
|
6576
|
-
name: "USDe",
|
6577
|
-
symbol: "USDe",
|
6578
|
-
icon: "USDe.svg",
|
6579
|
-
networks: [
|
6580
|
-
{
|
6581
|
-
type: "ethereum",
|
6582
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6583
|
-
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6584
|
-
decimals: 18
|
6585
|
-
},
|
6586
|
-
{
|
6587
|
-
type: "fuel",
|
6588
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6589
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6590
|
-
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6591
|
-
decimals: 9
|
6592
|
-
}
|
6593
|
-
]
|
6594
|
-
},
|
6595
|
-
{
|
6596
|
-
name: "sUSDe",
|
6597
|
-
symbol: "sUSDe",
|
6598
|
-
icon: "sUSDe.webp",
|
6599
|
-
networks: [
|
6600
|
-
{
|
6601
|
-
type: "ethereum",
|
6602
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6603
|
-
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6604
|
-
decimals: 18
|
6605
|
-
},
|
6606
|
-
{
|
6607
|
-
type: "fuel",
|
6608
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6609
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6610
|
-
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6611
|
-
decimals: 9
|
6612
|
-
}
|
6613
|
-
]
|
6614
|
-
},
|
6615
|
-
{
|
6616
|
-
name: "rsUSDe",
|
6617
|
-
symbol: "rsUSDe",
|
6618
|
-
icon: "rsUSDe.svg",
|
6619
|
-
networks: [
|
6620
|
-
{
|
6621
|
-
type: "ethereum",
|
6622
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6623
|
-
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6624
|
-
decimals: 18
|
6625
|
-
},
|
6626
|
-
{
|
6627
|
-
type: "fuel",
|
6628
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6629
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6630
|
-
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6631
|
-
decimals: 9
|
6632
|
-
}
|
6633
|
-
]
|
6634
|
-
},
|
6635
|
-
{
|
6636
|
-
name: "wstETH",
|
6637
|
-
symbol: "wstETH",
|
6638
|
-
icon: "wsteth.svg",
|
6639
|
-
networks: [
|
6640
|
-
{
|
6641
|
-
type: "ethereum",
|
6642
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6643
|
-
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6644
|
-
decimals: 18
|
6645
|
-
},
|
6646
|
-
{
|
6647
|
-
type: "fuel",
|
6648
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6649
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6650
|
-
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6651
|
-
decimals: 9
|
6652
|
-
}
|
6653
|
-
]
|
6654
|
-
},
|
6655
|
-
{
|
6656
|
-
name: "ezETH",
|
6657
|
-
symbol: "ezETH",
|
6658
|
-
icon: "ezeth.webp",
|
6659
|
-
networks: [
|
6660
|
-
{
|
6661
|
-
type: "ethereum",
|
6662
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6663
|
-
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6664
|
-
decimals: 18
|
6665
|
-
},
|
6666
|
-
{
|
6667
|
-
type: "fuel",
|
6668
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6669
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6670
|
-
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6671
|
-
decimals: 9
|
6672
|
-
}
|
6673
|
-
]
|
6674
|
-
},
|
6675
|
-
{
|
6676
|
-
name: "pzETH",
|
6677
|
-
symbol: "pzETH",
|
6678
|
-
icon: "pzETH.webp",
|
6679
|
-
networks: [
|
6680
|
-
{
|
6681
|
-
type: "ethereum",
|
6682
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6683
|
-
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6684
|
-
decimals: 18
|
6685
|
-
},
|
6686
|
-
{
|
6687
|
-
type: "fuel",
|
6688
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6689
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6690
|
-
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6691
|
-
decimals: 9
|
6692
|
-
}
|
6693
|
-
]
|
6694
|
-
},
|
6695
|
-
{
|
6696
|
-
name: "Re7LRT",
|
6697
|
-
symbol: "Re7LRT",
|
6698
|
-
icon: "Re7LRT.png",
|
6699
|
-
networks: [
|
6700
|
-
{
|
6701
|
-
type: "ethereum",
|
6702
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6703
|
-
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6704
|
-
decimals: 18
|
6705
|
-
},
|
6706
|
-
{
|
6707
|
-
type: "fuel",
|
6708
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6709
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6710
|
-
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6711
|
-
decimals: 9
|
6712
|
-
}
|
6713
|
-
]
|
6714
|
-
},
|
6715
|
-
{
|
6716
|
-
name: "steakLRT",
|
6717
|
-
symbol: "steakLRT",
|
6718
|
-
icon: "steakLRT.png",
|
6719
|
-
networks: [
|
6720
|
-
{
|
6721
|
-
type: "ethereum",
|
6722
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6723
|
-
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6724
|
-
decimals: 18
|
6725
|
-
},
|
6726
|
-
{
|
6727
|
-
type: "fuel",
|
6728
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6729
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6730
|
-
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6731
|
-
decimals: 9
|
6732
|
-
}
|
6733
|
-
]
|
6734
|
-
}
|
6735
|
-
];
|
6736
|
-
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
6737
|
-
|
6738
6215
|
// src/test-utils/test-asset-id.ts
|
6739
6216
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6740
6217
|
import { hexlify as hexlify18 } from "@fuel-ts/utils";
|
@@ -6760,7 +6237,8 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6760
6237
|
|
6761
6238
|
// src/test-utils/wallet-config.ts
|
6762
6239
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6763
|
-
import { FuelError as
|
6240
|
+
import { FuelError as FuelError26 } from "@fuel-ts/errors";
|
6241
|
+
import { bn as bn21 } from "@fuel-ts/math";
|
6764
6242
|
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
|
6765
6243
|
|
6766
6244
|
// src/wallet/base-wallet-unlocked.ts
|
@@ -6771,8 +6249,7 @@ import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
|
6771
6249
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6772
6250
|
import { Address as Address5 } from "@fuel-ts/address";
|
6773
6251
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6774
|
-
import { ErrorCode as
|
6775
|
-
import { AbstractAccount } from "@fuel-ts/interfaces";
|
6252
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6776
6253
|
import { bn as bn19 } from "@fuel-ts/math";
|
6777
6254
|
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
6778
6255
|
import { arrayify as arrayify16, hexlify as hexlify19, isDefined as isDefined3 } from "@fuel-ts/utils";
|
@@ -6792,6 +6269,10 @@ var mergeQuantities = (...coinQuantities) => {
|
|
6792
6269
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
6793
6270
|
};
|
6794
6271
|
|
6272
|
+
// src/types.ts
|
6273
|
+
var AbstractAccount = class {
|
6274
|
+
};
|
6275
|
+
|
6795
6276
|
// src/utils/formatTransferToContractScriptData.ts
|
6796
6277
|
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
6797
6278
|
import { Address as Address4 } from "@fuel-ts/address";
|
@@ -6802,11 +6283,7 @@ var formatTransferToContractScriptData = (transferParams) => {
|
|
6802
6283
|
return transferParams.reduce((acc, transferParam) => {
|
6803
6284
|
const { assetId, amount, contractId } = transferParam;
|
6804
6285
|
const encoded = numberCoder.encode(amount);
|
6805
|
-
const scriptData = concat4([
|
6806
|
-
Address4.fromAddressOrString(contractId).toBytes(),
|
6807
|
-
encoded,
|
6808
|
-
arrayify15(assetId)
|
6809
|
-
]);
|
6286
|
+
const scriptData = concat4([new Address4(contractId).toBytes(), encoded, arrayify15(assetId)]);
|
6810
6287
|
return concat4([acc, scriptData]);
|
6811
6288
|
}, new Uint8Array());
|
6812
6289
|
};
|
@@ -6862,7 +6339,7 @@ var Account = class extends AbstractAccount {
|
|
6862
6339
|
super();
|
6863
6340
|
this._provider = provider;
|
6864
6341
|
this._connector = connector;
|
6865
|
-
this.address = Address5
|
6342
|
+
this.address = new Address5(address);
|
6866
6343
|
}
|
6867
6344
|
/**
|
6868
6345
|
* The provider used to interact with the network.
|
@@ -6873,7 +6350,7 @@ var Account = class extends AbstractAccount {
|
|
6873
6350
|
*/
|
6874
6351
|
get provider() {
|
6875
6352
|
if (!this._provider) {
|
6876
|
-
throw new
|
6353
|
+
throw new FuelError21(ErrorCode18.MISSING_PROVIDER, "Provider not set");
|
6877
6354
|
}
|
6878
6355
|
return this._provider;
|
6879
6356
|
}
|
@@ -6929,7 +6406,7 @@ var Account = class extends AbstractAccount {
|
|
6929
6406
|
* @returns A promise that resolves to the balance amount.
|
6930
6407
|
*/
|
6931
6408
|
async getBalance(assetId) {
|
6932
|
-
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
6409
|
+
const assetIdToFetch = assetId ?? await this.provider.getBaseAssetId();
|
6933
6410
|
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
6934
6411
|
return amount;
|
6935
6412
|
}
|
@@ -6952,7 +6429,7 @@ var Account = class extends AbstractAccount {
|
|
6952
6429
|
async fund(request, params) {
|
6953
6430
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
|
6954
6431
|
const fee = request.maxFee;
|
6955
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
6432
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
6956
6433
|
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
6957
6434
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
6958
6435
|
amount: bn19(fee),
|
@@ -7024,12 +6501,12 @@ var Account = class extends AbstractAccount {
|
|
7024
6501
|
fundingAttempts += 1;
|
7025
6502
|
}
|
7026
6503
|
if (needsToBeFunded) {
|
7027
|
-
throw new
|
7028
|
-
|
6504
|
+
throw new FuelError21(
|
6505
|
+
ErrorCode18.NOT_ENOUGH_FUNDS,
|
7029
6506
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
7030
6507
|
);
|
7031
6508
|
}
|
7032
|
-
this.provider.validateTransaction(request);
|
6509
|
+
await this.provider.validateTransaction(request);
|
7033
6510
|
request.updatePredicateGasUsed(estimatedPredicates);
|
7034
6511
|
const requestToReestimate = clone9(request);
|
7035
6512
|
if (addedSignatures) {
|
@@ -7056,7 +6533,11 @@ var Account = class extends AbstractAccount {
|
|
7056
6533
|
*/
|
7057
6534
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
7058
6535
|
let request = new ScriptTransactionRequest(txParams);
|
7059
|
-
request = this.addTransfer(request, {
|
6536
|
+
request = this.addTransfer(request, {
|
6537
|
+
destination,
|
6538
|
+
amount,
|
6539
|
+
assetId: assetId || await this.provider.getBaseAssetId()
|
6540
|
+
});
|
7060
6541
|
request = await this.estimateAndFundTransaction(request, txParams);
|
7061
6542
|
return request;
|
7062
6543
|
}
|
@@ -7096,11 +6577,7 @@ var Account = class extends AbstractAccount {
|
|
7096
6577
|
addTransfer(request, transferParams) {
|
7097
6578
|
const { destination, amount, assetId } = transferParams;
|
7098
6579
|
this.validateTransferAmount(amount);
|
7099
|
-
request.addCoinOutput(
|
7100
|
-
Address5.fromAddressOrString(destination),
|
7101
|
-
amount,
|
7102
|
-
assetId ?? this.provider.getBaseAssetId()
|
7103
|
-
);
|
6580
|
+
request.addCoinOutput(new Address5(destination), amount, assetId);
|
7104
6581
|
return request;
|
7105
6582
|
}
|
7106
6583
|
/**
|
@@ -7111,12 +6588,11 @@ var Account = class extends AbstractAccount {
|
|
7111
6588
|
* @returns The updated script transaction request.
|
7112
6589
|
*/
|
7113
6590
|
addBatchTransfer(request, transferParams) {
|
7114
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
7115
6591
|
transferParams.forEach(({ destination, amount, assetId }) => {
|
7116
6592
|
this.addTransfer(request, {
|
7117
6593
|
destination,
|
7118
6594
|
amount,
|
7119
|
-
assetId
|
6595
|
+
assetId
|
7120
6596
|
});
|
7121
6597
|
});
|
7122
6598
|
return request;
|
@@ -7138,13 +6614,14 @@ var Account = class extends AbstractAccount {
|
|
7138
6614
|
...txParams
|
7139
6615
|
});
|
7140
6616
|
const quantities = [];
|
6617
|
+
const defaultAssetId = await this.provider.getBaseAssetId();
|
7141
6618
|
const transferParams = contractTransferParams.map((transferParam) => {
|
7142
6619
|
const amount = bn19(transferParam.amount);
|
7143
|
-
const contractAddress = Address5
|
7144
|
-
const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) :
|
6620
|
+
const contractAddress = new Address5(transferParam.contractId);
|
6621
|
+
const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) : defaultAssetId;
|
7145
6622
|
if (amount.lte(0)) {
|
7146
|
-
throw new
|
7147
|
-
|
6623
|
+
throw new FuelError21(
|
6624
|
+
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7148
6625
|
"Transfer amount must be a positive number."
|
7149
6626
|
);
|
7150
6627
|
}
|
@@ -7171,7 +6648,7 @@ var Account = class extends AbstractAccount {
|
|
7171
6648
|
* @returns A promise that resolves to the transaction response.
|
7172
6649
|
*/
|
7173
6650
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
7174
|
-
const recipientAddress = Address5
|
6651
|
+
const recipientAddress = new Address5(recipient);
|
7175
6652
|
const recipientDataArray = arrayify16(
|
7176
6653
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
7177
6654
|
);
|
@@ -7184,7 +6661,7 @@ var Account = class extends AbstractAccount {
|
|
7184
6661
|
...amountDataArray
|
7185
6662
|
]);
|
7186
6663
|
const params = { script, ...txParams };
|
7187
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
6664
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
7188
6665
|
let request = new ScriptTransactionRequest(params);
|
7189
6666
|
const quantities = [{ amount: bn19(amount), assetId: baseAssetId }];
|
7190
6667
|
const txCost = await this.getTransactionCost(request, { quantities });
|
@@ -7207,9 +6684,9 @@ var Account = class extends AbstractAccount {
|
|
7207
6684
|
*
|
7208
6685
|
* @returns A promise that resolves to the transaction cost object.
|
7209
6686
|
*/
|
7210
|
-
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6687
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [], gasPrice } = {}) {
|
7211
6688
|
const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
|
7212
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
6689
|
+
const baseAssetId = await this.provider.getBaseAssetId();
|
7213
6690
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7214
6691
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7215
6692
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
|
@@ -7242,7 +6719,8 @@ var Account = class extends AbstractAccount {
|
|
7242
6719
|
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
7243
6720
|
);
|
7244
6721
|
const txCost = await this.provider.getTransactionCost(txRequestClone, {
|
7245
|
-
signatureCallback
|
6722
|
+
signatureCallback,
|
6723
|
+
gasPrice
|
7246
6724
|
});
|
7247
6725
|
return {
|
7248
6726
|
...txCost,
|
@@ -7259,7 +6737,7 @@ var Account = class extends AbstractAccount {
|
|
7259
6737
|
*/
|
7260
6738
|
async signMessage(message) {
|
7261
6739
|
if (!this._connector) {
|
7262
|
-
throw new
|
6740
|
+
throw new FuelError21(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7263
6741
|
}
|
7264
6742
|
return this._connector.signMessage(this.address.toString(), message);
|
7265
6743
|
}
|
@@ -7271,8 +6749,8 @@ var Account = class extends AbstractAccount {
|
|
7271
6749
|
*/
|
7272
6750
|
async signTransaction(transactionRequestLike) {
|
7273
6751
|
if (!this._connector) {
|
7274
|
-
throw new
|
7275
|
-
|
6752
|
+
throw new FuelError21(
|
6753
|
+
ErrorCode18.MISSING_CONNECTOR,
|
7276
6754
|
"A connector is required to sign transactions."
|
7277
6755
|
);
|
7278
6756
|
}
|
@@ -7285,10 +6763,13 @@ var Account = class extends AbstractAccount {
|
|
7285
6763
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
7286
6764
|
* @returns A promise that resolves to the transaction response.
|
7287
6765
|
*/
|
7288
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
6766
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, onBeforeSend, skipCustomFee = false } = {}) {
|
7289
6767
|
if (this._connector) {
|
7290
6768
|
return this.provider.getTransactionResponse(
|
7291
|
-
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike
|
6769
|
+
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, {
|
6770
|
+
onBeforeSend,
|
6771
|
+
skipCustomFee
|
6772
|
+
})
|
7292
6773
|
);
|
7293
6774
|
}
|
7294
6775
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
@@ -7331,8 +6812,8 @@ var Account = class extends AbstractAccount {
|
|
7331
6812
|
/** @hidden * */
|
7332
6813
|
validateTransferAmount(amount) {
|
7333
6814
|
if (bn19(amount).lte(0)) {
|
7334
|
-
throw new
|
7335
|
-
|
6815
|
+
throw new FuelError21(
|
6816
|
+
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7336
6817
|
"Transfer amount must be a positive number."
|
7337
6818
|
);
|
7338
6819
|
}
|
@@ -7361,16 +6842,16 @@ var Account = class extends AbstractAccount {
|
|
7361
6842
|
if (!isDefined3(setGasLimit)) {
|
7362
6843
|
request.gasLimit = gasUsed;
|
7363
6844
|
} else if (gasUsed.gt(setGasLimit)) {
|
7364
|
-
throw new
|
7365
|
-
|
6845
|
+
throw new FuelError21(
|
6846
|
+
ErrorCode18.GAS_LIMIT_TOO_LOW,
|
7366
6847
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7367
6848
|
);
|
7368
6849
|
}
|
7369
6850
|
if (!isDefined3(setMaxFee)) {
|
7370
6851
|
request.maxFee = maxFee;
|
7371
6852
|
} else if (maxFee.gt(setMaxFee)) {
|
7372
|
-
throw new
|
7373
|
-
|
6853
|
+
throw new FuelError21(
|
6854
|
+
ErrorCode18.MAX_FEE_TOO_LOW,
|
7374
6855
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7375
6856
|
);
|
7376
6857
|
}
|
@@ -7390,7 +6871,7 @@ import {
|
|
7390
6871
|
encryptJsonWalletData,
|
7391
6872
|
randomUUID as randomUUID2
|
7392
6873
|
} from "@fuel-ts/crypto";
|
7393
|
-
import { ErrorCode as
|
6874
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
7394
6875
|
import { hexlify as hexlify20 } from "@fuel-ts/utils";
|
7395
6876
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7396
6877
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -7405,7 +6886,7 @@ var removeHexPrefix = (hexString) => {
|
|
7405
6886
|
};
|
7406
6887
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
7407
6888
|
const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
|
7408
|
-
const ownerAddress = Address6
|
6889
|
+
const ownerAddress = new Address6(address);
|
7409
6890
|
const salt = randomBytes6(DEFAULT_KEY_SIZE);
|
7410
6891
|
const key = scrypt({
|
7411
6892
|
password: bufferFromString(password),
|
@@ -7467,8 +6948,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7467
6948
|
const macHashUint8Array = keccak256(data);
|
7468
6949
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
7469
6950
|
if (mac !== macHash) {
|
7470
|
-
throw new
|
7471
|
-
|
6951
|
+
throw new FuelError22(
|
6952
|
+
ErrorCode19.INVALID_PASSWORD,
|
7472
6953
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7473
6954
|
);
|
7474
6955
|
}
|
@@ -7528,7 +7009,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7528
7009
|
*/
|
7529
7010
|
async signTransaction(transactionRequestLike) {
|
7530
7011
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
7531
|
-
const chainId = this.provider.getChainId();
|
7012
|
+
const chainId = await this.provider.getChainId();
|
7532
7013
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
7533
7014
|
const signature = await this.signer().sign(hashedTransaction);
|
7534
7015
|
return hexlify21(signature);
|
@@ -7552,14 +7033,19 @@ var BaseWalletUnlocked = class extends Account {
|
|
7552
7033
|
* @param estimateTxDependencies - Whether to estimate the transaction dependencies.
|
7553
7034
|
* @returns A promise that resolves to the TransactionResponse object.
|
7554
7035
|
*/
|
7555
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
|
7036
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, enableAssetBurn } = {}) {
|
7556
7037
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
7038
|
+
validateTransactionForAssetBurn(
|
7039
|
+
await this.provider.getBaseAssetId(),
|
7040
|
+
transactionRequest,
|
7041
|
+
enableAssetBurn
|
7042
|
+
);
|
7557
7043
|
if (estimateTxDependencies) {
|
7558
7044
|
await this.provider.estimateTxDependencies(transactionRequest);
|
7559
7045
|
}
|
7560
7046
|
return this.provider.sendTransaction(
|
7561
7047
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
7562
|
-
{ estimateTxDependencies: false }
|
7048
|
+
{ estimateTxDependencies: false, enableAssetBurn }
|
7563
7049
|
);
|
7564
7050
|
}
|
7565
7051
|
/**
|
@@ -7598,14 +7084,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7598
7084
|
|
7599
7085
|
// src/hdwallet/hdwallet.ts
|
7600
7086
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7601
|
-
import { ErrorCode as
|
7087
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError25 } from "@fuel-ts/errors";
|
7602
7088
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7603
7089
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
7604
7090
|
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7605
7091
|
|
7606
7092
|
// src/mnemonic/mnemonic.ts
|
7607
7093
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7608
|
-
import { ErrorCode as
|
7094
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
|
7609
7095
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7610
7096
|
import { arrayify as arrayify18, hexlify as hexlify22, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7611
7097
|
|
@@ -9662,7 +9148,7 @@ var english = [
|
|
9662
9148
|
];
|
9663
9149
|
|
9664
9150
|
// src/mnemonic/utils.ts
|
9665
|
-
import { ErrorCode as
|
9151
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9666
9152
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9667
9153
|
import { arrayify as arrayify17 } from "@fuel-ts/utils";
|
9668
9154
|
function getLowerMask(bits) {
|
@@ -9711,8 +9197,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9711
9197
|
for (let i = 0; i < words.length; i += 1) {
|
9712
9198
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9713
9199
|
if (index === -1) {
|
9714
|
-
throw new
|
9715
|
-
|
9200
|
+
throw new FuelError23(
|
9201
|
+
ErrorCode20.INVALID_MNEMONIC,
|
9716
9202
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9717
9203
|
);
|
9718
9204
|
}
|
@@ -9728,8 +9214,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9728
9214
|
const checksumMask = getUpperMask(checksumBits);
|
9729
9215
|
const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9730
9216
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9731
|
-
throw new
|
9732
|
-
|
9217
|
+
throw new FuelError23(
|
9218
|
+
ErrorCode20.INVALID_CHECKSUM,
|
9733
9219
|
"Checksum validation failed for the provided mnemonic."
|
9734
9220
|
);
|
9735
9221
|
}
|
@@ -9743,16 +9229,16 @@ var TestnetPRV = "0x04358394";
|
|
9743
9229
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9744
9230
|
function assertWordList(wordlist) {
|
9745
9231
|
if (wordlist.length !== 2048) {
|
9746
|
-
throw new
|
9747
|
-
|
9232
|
+
throw new FuelError24(
|
9233
|
+
ErrorCode21.INVALID_WORD_LIST,
|
9748
9234
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9749
9235
|
);
|
9750
9236
|
}
|
9751
9237
|
}
|
9752
9238
|
function assertEntropy(entropy) {
|
9753
9239
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9754
|
-
throw new
|
9755
|
-
|
9240
|
+
throw new FuelError24(
|
9241
|
+
ErrorCode21.INVALID_ENTROPY,
|
9756
9242
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9757
9243
|
);
|
9758
9244
|
}
|
@@ -9762,7 +9248,7 @@ function assertMnemonic(words) {
|
|
9762
9248
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9763
9249
|
", "
|
9764
9250
|
)}] words, but got ${words.length}.`;
|
9765
|
-
throw new
|
9251
|
+
throw new FuelError24(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
9766
9252
|
}
|
9767
9253
|
}
|
9768
9254
|
var Mnemonic = class {
|
@@ -9880,8 +9366,8 @@ var Mnemonic = class {
|
|
9880
9366
|
static masterKeysFromSeed(seed) {
|
9881
9367
|
const seedArray = arrayify18(seed);
|
9882
9368
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9883
|
-
throw new
|
9884
|
-
|
9369
|
+
throw new FuelError24(
|
9370
|
+
ErrorCode21.INVALID_SEED,
|
9885
9371
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9886
9372
|
);
|
9887
9373
|
}
|
@@ -9958,7 +9444,7 @@ function isValidExtendedKey(extendedKey) {
|
|
9958
9444
|
function parsePath(path2, depth = 0) {
|
9959
9445
|
const components = path2.split("/");
|
9960
9446
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9961
|
-
throw new
|
9447
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9962
9448
|
}
|
9963
9449
|
if (components[0] === "m") {
|
9964
9450
|
components.shift();
|
@@ -9987,8 +9473,8 @@ var HDWallet = class {
|
|
9987
9473
|
this.privateKey = hexlify23(config.privateKey);
|
9988
9474
|
} else {
|
9989
9475
|
if (!config.publicKey) {
|
9990
|
-
throw new
|
9991
|
-
|
9476
|
+
throw new FuelError25(
|
9477
|
+
ErrorCode22.HD_WALLET_ERROR,
|
9992
9478
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9993
9479
|
);
|
9994
9480
|
}
|
@@ -10017,8 +9503,8 @@ var HDWallet = class {
|
|
10017
9503
|
const data = new Uint8Array(37);
|
10018
9504
|
if (index & HARDENED_INDEX) {
|
10019
9505
|
if (!privateKey) {
|
10020
|
-
throw new
|
10021
|
-
|
9506
|
+
throw new FuelError25(
|
9507
|
+
ErrorCode22.HD_WALLET_ERROR,
|
10022
9508
|
"Cannot derive a hardened index without a private Key."
|
10023
9509
|
);
|
10024
9510
|
}
|
@@ -10070,8 +9556,8 @@ var HDWallet = class {
|
|
10070
9556
|
*/
|
10071
9557
|
toExtendedKey(isPublic = false, testnet = false) {
|
10072
9558
|
if (this.depth >= 256) {
|
10073
|
-
throw new
|
10074
|
-
|
9559
|
+
throw new FuelError25(
|
9560
|
+
ErrorCode22.HD_WALLET_ERROR,
|
10075
9561
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10076
9562
|
);
|
10077
9563
|
}
|
@@ -10102,10 +9588,10 @@ var HDWallet = class {
|
|
10102
9588
|
const bytes = arrayify19(decoded);
|
10103
9589
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10104
9590
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10105
|
-
throw new
|
9591
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10106
9592
|
}
|
10107
9593
|
if (!validChecksum) {
|
10108
|
-
throw new
|
9594
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10109
9595
|
}
|
10110
9596
|
const depth = bytes[4];
|
10111
9597
|
const parentFingerprint = hexlify23(bytes.slice(5, 9));
|
@@ -10113,14 +9599,14 @@ var HDWallet = class {
|
|
10113
9599
|
const chainCode = hexlify23(bytes.slice(13, 45));
|
10114
9600
|
const key = bytes.slice(45, 78);
|
10115
9601
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10116
|
-
throw new
|
10117
|
-
|
9602
|
+
throw new FuelError25(
|
9603
|
+
ErrorCode22.HD_WALLET_ERROR,
|
10118
9604
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10119
9605
|
);
|
10120
9606
|
}
|
10121
9607
|
if (isPublicExtendedKey(bytes)) {
|
10122
9608
|
if (key[0] !== 3) {
|
10123
|
-
throw new
|
9609
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
10124
9610
|
}
|
10125
9611
|
return new HDWallet({
|
10126
9612
|
publicKey: key,
|
@@ -10131,7 +9617,7 @@ var HDWallet = class {
|
|
10131
9617
|
});
|
10132
9618
|
}
|
10133
9619
|
if (key[0] !== 0) {
|
10134
|
-
throw new
|
9620
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
10135
9621
|
}
|
10136
9622
|
return new HDWallet({
|
10137
9623
|
privateKey: key.slice(1),
|
@@ -10311,14 +9797,14 @@ var WalletsConfig = class {
|
|
10311
9797
|
constructor(baseAssetId, config) {
|
10312
9798
|
WalletsConfig.validate(config);
|
10313
9799
|
this.options = config;
|
10314
|
-
const { assets
|
9800
|
+
const { assets, coinsPerAsset, amountPerCoin, messages } = this.options;
|
10315
9801
|
this.wallets = this.generateWallets();
|
10316
9802
|
this.initialState = {
|
10317
9803
|
messages: WalletsConfig.createMessages(this.wallets, messages),
|
10318
9804
|
coins: WalletsConfig.createCoins(
|
10319
9805
|
this.wallets,
|
10320
9806
|
baseAssetId,
|
10321
|
-
|
9807
|
+
assets,
|
10322
9808
|
coinsPerAsset,
|
10323
9809
|
amountPerCoin
|
10324
9810
|
)
|
@@ -10343,19 +9829,19 @@ var WalletsConfig = class {
|
|
10343
9829
|
/**
|
10344
9830
|
* Create coins for the wallets in the format that the chain expects.
|
10345
9831
|
*/
|
10346
|
-
static createCoins(wallets, baseAssetId,
|
9832
|
+
static createCoins(wallets, baseAssetId, assets, coinsPerAsset, amountPerCoin) {
|
10347
9833
|
const coins = [];
|
10348
9834
|
let assetIds = [baseAssetId];
|
10349
|
-
if (Array.isArray(
|
10350
|
-
assetIds = assetIds.concat(
|
9835
|
+
if (Array.isArray(assets)) {
|
9836
|
+
assetIds = assetIds.concat(assets.map((a) => a.value));
|
10351
9837
|
} else {
|
10352
|
-
assetIds = assetIds.concat(TestAssetId.random(
|
9838
|
+
assetIds = assetIds.concat(TestAssetId.random(assets - 1).map((a) => a.value));
|
10353
9839
|
}
|
10354
9840
|
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
10355
9841
|
assetIds.forEach((assetId) => {
|
10356
9842
|
for (let index = 0; index < coinsPerAsset; index++) {
|
10357
9843
|
coins.push({
|
10358
|
-
amount: amountPerCoin,
|
9844
|
+
amount: bn21(amountPerCoin).toString(),
|
10359
9845
|
asset_id: assetId,
|
10360
9846
|
owner: walletAddress,
|
10361
9847
|
tx_pointer_block_height: 0,
|
@@ -10370,31 +9856,31 @@ var WalletsConfig = class {
|
|
10370
9856
|
}
|
10371
9857
|
static validate({
|
10372
9858
|
count: wallets,
|
10373
|
-
assets
|
9859
|
+
assets,
|
10374
9860
|
coinsPerAsset,
|
10375
9861
|
amountPerCoin
|
10376
9862
|
}) {
|
10377
9863
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
10378
|
-
throw new
|
10379
|
-
|
9864
|
+
throw new FuelError26(
|
9865
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10380
9866
|
"Number of wallets must be greater than zero."
|
10381
9867
|
);
|
10382
9868
|
}
|
10383
|
-
if (Array.isArray(
|
10384
|
-
throw new
|
10385
|
-
|
9869
|
+
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
9870
|
+
throw new FuelError26(
|
9871
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10386
9872
|
"Number of assets per wallet must be greater than zero."
|
10387
9873
|
);
|
10388
9874
|
}
|
10389
9875
|
if (coinsPerAsset <= 0) {
|
10390
|
-
throw new
|
10391
|
-
|
9876
|
+
throw new FuelError26(
|
9877
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10392
9878
|
"Number of coins per asset must be greater than zero."
|
10393
9879
|
);
|
10394
9880
|
}
|
10395
|
-
if (amountPerCoin
|
10396
|
-
throw new
|
10397
|
-
|
9881
|
+
if (bn21(amountPerCoin).lt(0)) {
|
9882
|
+
throw new FuelError26(
|
9883
|
+
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10398
9884
|
"Amount per coin must be greater than or equal to zero."
|
10399
9885
|
);
|
10400
9886
|
}
|
@@ -10447,7 +9933,8 @@ async function setupTestProviderAndWallets({
|
|
10447
9933
|
}
|
10448
9934
|
let provider;
|
10449
9935
|
try {
|
10450
|
-
provider =
|
9936
|
+
provider = new Provider(url, providerOptions);
|
9937
|
+
await provider.init();
|
10451
9938
|
} catch (err) {
|
10452
9939
|
cleanup();
|
10453
9940
|
throw err;
|
@@ -10467,7 +9954,7 @@ async function setupTestProviderAndWallets({
|
|
10467
9954
|
// src/test-utils/test-message.ts
|
10468
9955
|
import { Address as Address7 } from "@fuel-ts/address";
|
10469
9956
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
10470
|
-
import { bn as
|
9957
|
+
import { bn as bn22 } from "@fuel-ts/math";
|
10471
9958
|
import { hexlify as hexlify25 } from "@fuel-ts/utils";
|
10472
9959
|
var TestMessage = class {
|
10473
9960
|
sender;
|
@@ -10504,7 +9991,7 @@ var TestMessage = class {
|
|
10504
9991
|
sender: this.sender.toB256(),
|
10505
9992
|
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
10506
9993
|
nonce: this.nonce,
|
10507
|
-
amount:
|
9994
|
+
amount: bn22(this.amount).toNumber(),
|
10508
9995
|
data,
|
10509
9996
|
da_height: this.da_height
|
10510
9997
|
};
|