@fuel-ts/account 0.74.0 → 0.75.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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +2 -1
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/fuel.d.ts +1 -2
- package/dist/connectors/fuel.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +0 -8
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/events.d.ts +2 -36
- package/dist/connectors/types/events.d.ts.map +1 -1
- package/dist/connectors/types/index.d.ts +0 -2
- package/dist/connectors/types/index.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.global.js +1358 -1074
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +569 -426
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +486 -362
- 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/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/assets/index.d.ts +4 -0
- package/dist/providers/assets/index.d.ts.map +1 -0
- package/dist/providers/assets/types.d.ts +36 -0
- package/dist/providers/assets/types.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +4 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -0
- package/dist/providers/assets/utils/network.d.ts +33 -0
- package/dist/providers/assets/utils/network.d.ts.map +1 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/providers/assets/utils/url.d.ts +2 -0
- package/dist/providers/assets/utils/url.d.ts.map +1 -0
- package/dist/providers/chains.d.ts +11 -0
- package/dist/providers/chains.d.ts.map +1 -0
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +13 -3
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/memory-cache.d.ts +1 -1
- package/dist/providers/memory-cache.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +17 -7
- 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/hash-transaction.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 +1 -2
- package/dist/providers/transaction-request/script-transaction-request.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 +2 -10
- package/dist/providers/transaction-request/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-summary/operations.d.ts +0 -2
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/output.d.ts +2 -2
- package/dist/providers/transaction-summary/output.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +0 -1
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/gas.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.map +1 -1
- package/dist/test-utils.global.js +4010 -3792
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +462 -402
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +384 -336
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +4 -4
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +1 -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/package.json +16 -16
- package/dist/connectors/types/asset.d.ts +0 -2
- package/dist/connectors/types/asset.d.ts.map +0 -1
- package/dist/connectors/types/constants.d.ts +0 -7
- package/dist/connectors/types/constants.d.ts.map +0 -1
- package/dist/connectors/types/message.d.ts +0 -15
- package/dist/connectors/types/message.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
@@ -33,12 +33,12 @@ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
|
33
33
|
import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
|
34
34
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
35
35
|
import { bn as bn16 } from "@fuel-ts/math";
|
36
|
-
import {
|
36
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
37
37
|
|
38
38
|
// src/providers/coin-quantity.ts
|
39
39
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
40
40
|
import { bn } from "@fuel-ts/math";
|
41
|
-
import { hexlify } from "
|
41
|
+
import { hexlify } from "@fuel-ts/utils";
|
42
42
|
var coinQuantityfy = (coinQuantityLike) => {
|
43
43
|
let assetId;
|
44
44
|
let amount;
|
@@ -74,15 +74,17 @@ var addAmountToAsset = (params) => {
|
|
74
74
|
// src/providers/provider.ts
|
75
75
|
import { Address as Address2 } from "@fuel-ts/address";
|
76
76
|
import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
|
77
|
-
import { bn as bn14, max } from "@fuel-ts/math";
|
77
|
+
import { BN, bn as bn14, max } from "@fuel-ts/math";
|
78
78
|
import {
|
79
79
|
InputType as InputType6,
|
80
80
|
TransactionType as TransactionType8,
|
81
81
|
InputMessageCoder,
|
82
82
|
TransactionCoder as TransactionCoder5
|
83
83
|
} from "@fuel-ts/transactions";
|
84
|
+
import { arrayify as arrayify11, hexlify as hexlify12 } from "@fuel-ts/utils";
|
84
85
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
85
|
-
import {
|
86
|
+
import { equalBytes } from "@noble/curves/abstract/utils";
|
87
|
+
import { Network } from "ethers";
|
86
88
|
import { GraphQLClient } from "graphql-request";
|
87
89
|
import { clone as clone3 } from "ramda";
|
88
90
|
|
@@ -891,71 +893,67 @@ function getSdk(requester) {
|
|
891
893
|
// src/providers/fuel-graphql-subscriber.ts
|
892
894
|
import { FuelError } from "@fuel-ts/errors";
|
893
895
|
import { print } from "graphql";
|
894
|
-
var
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
this.readableStreamController.enqueue(
|
911
|
-
new FuelError(
|
912
|
-
FuelError.CODES.INVALID_REQUEST,
|
913
|
-
errors.map((err) => err.message).join("\n\n")
|
914
|
-
)
|
915
|
-
);
|
916
|
-
} else {
|
917
|
-
this.readableStreamController.enqueue(data);
|
918
|
-
}
|
919
|
-
}
|
896
|
+
var _FuelGraphqlSubscriber = class {
|
897
|
+
constructor(options) {
|
898
|
+
this.options = options;
|
899
|
+
}
|
900
|
+
stream;
|
901
|
+
async setStream() {
|
902
|
+
const { url, query, variables, fetchFn } = this.options;
|
903
|
+
const response = await fetchFn(`${url}-sub`, {
|
904
|
+
method: "POST",
|
905
|
+
body: JSON.stringify({
|
906
|
+
query: print(query),
|
907
|
+
variables
|
908
|
+
}),
|
909
|
+
headers: {
|
910
|
+
"Content-Type": "application/json",
|
911
|
+
Accept: "text/event-stream"
|
920
912
|
}
|
921
913
|
});
|
914
|
+
this.stream = response.body.getReader();
|
922
915
|
}
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
async function* fuelGraphQLSubscriber({
|
927
|
-
url,
|
928
|
-
variables,
|
929
|
-
query,
|
930
|
-
fetchFn
|
931
|
-
}) {
|
932
|
-
const response = await fetchFn(`${url}-sub`, {
|
933
|
-
method: "POST",
|
934
|
-
body: JSON.stringify({
|
935
|
-
query: print(query),
|
936
|
-
variables
|
937
|
-
}),
|
938
|
-
headers: {
|
939
|
-
"Content-Type": "application/json",
|
940
|
-
Accept: "text/event-stream"
|
941
|
-
}
|
942
|
-
});
|
943
|
-
const subscriptionStreamReader = response.body.pipeThrough(new FuelSubscriptionStream()).getReader();
|
944
|
-
while (true) {
|
945
|
-
const { value, done } = await subscriptionStreamReader.read();
|
946
|
-
if (value instanceof FuelError) {
|
947
|
-
throw value;
|
916
|
+
async next() {
|
917
|
+
if (!this.stream) {
|
918
|
+
await this.setStream();
|
948
919
|
}
|
949
|
-
|
950
|
-
|
951
|
-
|
920
|
+
while (true) {
|
921
|
+
const { value, done } = await this.stream.read();
|
922
|
+
if (done) {
|
923
|
+
return { value, done };
|
924
|
+
}
|
925
|
+
const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
|
926
|
+
if (!text.startsWith("data:")) {
|
927
|
+
continue;
|
928
|
+
}
|
929
|
+
const { data, errors } = JSON.parse(text.split("data:")[1]);
|
930
|
+
if (Array.isArray(errors)) {
|
931
|
+
throw new FuelError(
|
932
|
+
FuelError.CODES.INVALID_REQUEST,
|
933
|
+
errors.map((err) => err.message).join("\n\n")
|
934
|
+
);
|
935
|
+
}
|
936
|
+
return { value: data, done: false };
|
952
937
|
}
|
953
938
|
}
|
954
|
-
|
939
|
+
/**
|
940
|
+
* Gets called when `break` is called in a `for-await-of` loop.
|
941
|
+
*/
|
942
|
+
async return() {
|
943
|
+
await this.stream.cancel();
|
944
|
+
this.stream.releaseLock();
|
945
|
+
return { done: true, value: void 0 };
|
946
|
+
}
|
947
|
+
[Symbol.asyncIterator]() {
|
948
|
+
return this;
|
949
|
+
}
|
950
|
+
};
|
951
|
+
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
952
|
+
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
955
953
|
|
956
954
|
// src/providers/memory-cache.ts
|
957
955
|
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
958
|
-
import { hexlify as hexlify2 } from "
|
956
|
+
import { hexlify as hexlify2 } from "@fuel-ts/utils";
|
959
957
|
var cache = {};
|
960
958
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
961
959
|
var MemoryCache = class {
|
@@ -1017,23 +1015,23 @@ import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
|
1017
1015
|
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1018
1016
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1019
1017
|
import { InputType } from "@fuel-ts/transactions";
|
1020
|
-
import {
|
1018
|
+
import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
|
1021
1019
|
var inputify = (value) => {
|
1022
1020
|
const { type } = value;
|
1023
1021
|
switch (value.type) {
|
1024
1022
|
case InputType.Coin: {
|
1025
|
-
const predicate =
|
1026
|
-
const predicateData =
|
1023
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
1024
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
1027
1025
|
return {
|
1028
1026
|
type: InputType.Coin,
|
1029
|
-
txID: hexlify3(
|
1030
|
-
outputIndex:
|
1027
|
+
txID: hexlify3(arrayify(value.id).slice(0, 32)),
|
1028
|
+
outputIndex: arrayify(value.id)[32],
|
1031
1029
|
owner: hexlify3(value.owner),
|
1032
1030
|
amount: bn2(value.amount),
|
1033
1031
|
assetId: hexlify3(value.assetId),
|
1034
1032
|
txPointer: {
|
1035
|
-
blockHeight: toNumber(
|
1036
|
-
txIndex: toNumber(
|
1033
|
+
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1034
|
+
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1037
1035
|
},
|
1038
1036
|
witnessIndex: value.witnessIndex,
|
1039
1037
|
maturity: value.maturity ?? 0,
|
@@ -1052,16 +1050,16 @@ var inputify = (value) => {
|
|
1052
1050
|
balanceRoot: ZeroBytes32,
|
1053
1051
|
stateRoot: ZeroBytes32,
|
1054
1052
|
txPointer: {
|
1055
|
-
blockHeight: toNumber(
|
1056
|
-
txIndex: toNumber(
|
1053
|
+
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1054
|
+
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1057
1055
|
},
|
1058
1056
|
contractID: hexlify3(value.contractId)
|
1059
1057
|
};
|
1060
1058
|
}
|
1061
1059
|
case InputType.Message: {
|
1062
|
-
const predicate =
|
1063
|
-
const predicateData =
|
1064
|
-
const data =
|
1060
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
1061
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
1062
|
+
const data = arrayify(value.data ?? "0x");
|
1065
1063
|
return {
|
1066
1064
|
type: InputType.Message,
|
1067
1065
|
sender: hexlify3(value.sender),
|
@@ -1092,7 +1090,7 @@ import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
|
1092
1090
|
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1093
1091
|
import { bn as bn3 } from "@fuel-ts/math";
|
1094
1092
|
import { OutputType } from "@fuel-ts/transactions";
|
1095
|
-
import { hexlify as hexlify4 } from "
|
1093
|
+
import { hexlify as hexlify4 } from "@fuel-ts/utils";
|
1096
1094
|
var outputify = (value) => {
|
1097
1095
|
const { type } = value;
|
1098
1096
|
switch (type) {
|
@@ -1155,7 +1153,7 @@ import {
|
|
1155
1153
|
OutputType as OutputType2,
|
1156
1154
|
TransactionType
|
1157
1155
|
} from "@fuel-ts/transactions";
|
1158
|
-
import { concat,
|
1156
|
+
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1159
1157
|
|
1160
1158
|
// src/providers/resource.ts
|
1161
1159
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1174,7 +1172,7 @@ import {
|
|
1174
1172
|
ReceiptType
|
1175
1173
|
} from "@fuel-ts/transactions";
|
1176
1174
|
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
1177
|
-
import {
|
1175
|
+
import { arrayify as arrayify2 } from "@fuel-ts/utils";
|
1178
1176
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1179
1177
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1180
1178
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1318,7 +1316,7 @@ function assembleReceiptByType(receipt) {
|
|
1318
1316
|
const recipient = hexOrZero(receipt.recipient);
|
1319
1317
|
const nonce = hexOrZero(receipt.nonce);
|
1320
1318
|
const amount = bn4(receipt.amount);
|
1321
|
-
const data = receipt.data ?
|
1319
|
+
const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
|
1322
1320
|
const digest = hexOrZero(receipt.digest);
|
1323
1321
|
const messageId = ReceiptMessageOutCoder.getMessageId({
|
1324
1322
|
sender,
|
@@ -1439,7 +1437,7 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1439
1437
|
// src/providers/utils/gas.ts
|
1440
1438
|
import { bn as bn5 } from "@fuel-ts/math";
|
1441
1439
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1442
|
-
import {
|
1440
|
+
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1443
1441
|
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1444
1442
|
var getGasUsedFromReceipts = (receipts) => {
|
1445
1443
|
const scriptResult = receipts.filter(
|
@@ -1464,9 +1462,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
1464
1462
|
const totalGas = inputs.reduce((total, input) => {
|
1465
1463
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1466
1464
|
return total.add(
|
1467
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
1468
|
-
resolveGasDependentCosts(getBytesCopy3(input.predicate).length, gasCosts.contractRoot)
|
1469
|
-
).add(bn5(input.predicateGasUsed))
|
1465
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1470
1466
|
);
|
1471
1467
|
}
|
1472
1468
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -1515,7 +1511,7 @@ function calculateMetadataGasForTxScript({
|
|
1515
1511
|
}
|
1516
1512
|
|
1517
1513
|
// src/providers/utils/json.ts
|
1518
|
-
import { hexlify as hexlify5 } from "
|
1514
|
+
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
1519
1515
|
import { clone } from "ramda";
|
1520
1516
|
function normalize(object) {
|
1521
1517
|
Object.keys(object).forEach((key) => {
|
@@ -1581,9 +1577,9 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1581
1577
|
};
|
1582
1578
|
|
1583
1579
|
// src/providers/transaction-request/witness.ts
|
1584
|
-
import {
|
1580
|
+
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1585
1581
|
var witnessify = (value) => {
|
1586
|
-
const data =
|
1582
|
+
const data = arrayify4(value);
|
1587
1583
|
return {
|
1588
1584
|
data: hexlify6(data),
|
1589
1585
|
dataLength: data.length
|
@@ -2055,19 +2051,27 @@ var BaseTransactionRequest = class {
|
|
2055
2051
|
toJSON() {
|
2056
2052
|
return normalizeJSON(this);
|
2057
2053
|
}
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2054
|
+
updatePredicateInputs(inputs) {
|
2055
|
+
this.inputs.forEach((i) => {
|
2056
|
+
let correspondingInput;
|
2057
|
+
switch (i.type) {
|
2058
|
+
case InputType2.Coin:
|
2059
|
+
correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
|
2060
|
+
break;
|
2061
|
+
case InputType2.Message:
|
2062
|
+
correspondingInput = inputs.find(
|
2063
|
+
(x) => x.type === InputType2.Message && x.sender === i.sender
|
2064
|
+
);
|
2065
|
+
break;
|
2066
|
+
default:
|
2067
|
+
return;
|
2068
|
+
}
|
2069
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
|
2070
|
+
i.predicate = correspondingInput.predicate;
|
2071
|
+
i.predicateData = correspondingInput.predicateData;
|
2072
|
+
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2073
|
+
}
|
2074
|
+
});
|
2071
2075
|
}
|
2072
2076
|
};
|
2073
2077
|
|
@@ -2075,14 +2079,15 @@ var BaseTransactionRequest = class {
|
|
2075
2079
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2076
2080
|
import { bn as bn8 } from "@fuel-ts/math";
|
2077
2081
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2078
|
-
import {
|
2082
|
+
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2079
2083
|
|
2080
2084
|
// src/providers/transaction-request/hash-transaction.ts
|
2081
2085
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2082
2086
|
import { uint64ToBytesBE } from "@fuel-ts/hasher";
|
2083
2087
|
import { bn as bn7 } from "@fuel-ts/math";
|
2084
2088
|
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2085
|
-
import { concat as concat2
|
2089
|
+
import { concat as concat2 } from "@fuel-ts/utils";
|
2090
|
+
import { sha256 } from "ethers";
|
2086
2091
|
import { clone as clone2 } from "ramda";
|
2087
2092
|
function hashTransaction(transactionRequest, chainId) {
|
2088
2093
|
const transaction = transactionRequest.toTransaction();
|
@@ -2149,10 +2154,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2149
2154
|
}
|
2150
2155
|
|
2151
2156
|
// src/providers/transaction-request/storage-slot.ts
|
2152
|
-
import {
|
2157
|
+
import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
|
2153
2158
|
var getStorageValue = (value) => {
|
2154
2159
|
const v = new Uint8Array(32);
|
2155
|
-
v.set(
|
2160
|
+
v.set(arrayify5(value));
|
2156
2161
|
return v;
|
2157
2162
|
};
|
2158
2163
|
var storageSlotify = (storageSlot) => {
|
@@ -2257,7 +2262,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2257
2262
|
}
|
2258
2263
|
metadataGas(gasCosts) {
|
2259
2264
|
return calculateMetadataGasForTxCreate({
|
2260
|
-
contractBytesSize: bn8(
|
2265
|
+
contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2261
2266
|
gasCosts,
|
2262
2267
|
stateRootSize: this.storageSlots.length,
|
2263
2268
|
txBytesSize: this.byteSize()
|
@@ -2271,17 +2276,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
|
|
2271
2276
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2272
2277
|
import { bn as bn9 } from "@fuel-ts/math";
|
2273
2278
|
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2274
|
-
import {
|
2279
|
+
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2275
2280
|
|
2276
2281
|
// src/providers/transaction-request/scripts.ts
|
2277
|
-
import {
|
2282
|
+
import { arrayify as arrayify7 } from "@fuel-ts/utils";
|
2278
2283
|
var returnZeroScript = {
|
2279
2284
|
/*
|
2280
2285
|
Opcode::RET(REG_ZERO)
|
2281
2286
|
Opcode::NOOP
|
2282
2287
|
*/
|
2283
2288
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2284
|
-
bytes:
|
2289
|
+
bytes: arrayify7("0x24000000"),
|
2285
2290
|
encodeScriptData: () => new Uint8Array(0)
|
2286
2291
|
};
|
2287
2292
|
var withdrawScript = {
|
@@ -2295,7 +2300,7 @@ var withdrawScript = {
|
|
2295
2300
|
00000000 00000000 [amount value]
|
2296
2301
|
*/
|
2297
2302
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2298
|
-
bytes:
|
2303
|
+
bytes: arrayify7("0x5040C0105D44C0064C40001124000000"),
|
2299
2304
|
encodeScriptData: () => new Uint8Array(0)
|
2300
2305
|
};
|
2301
2306
|
|
@@ -2323,8 +2328,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2323
2328
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2324
2329
|
super(rest);
|
2325
2330
|
this.gasLimit = bn9(gasLimit);
|
2326
|
-
this.script =
|
2327
|
-
this.scriptData =
|
2331
|
+
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2332
|
+
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2328
2333
|
}
|
2329
2334
|
/**
|
2330
2335
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2332,8 +2337,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2332
2337
|
* @returns The transaction script object.
|
2333
2338
|
*/
|
2334
2339
|
toTransaction() {
|
2335
|
-
const script =
|
2336
|
-
const scriptData =
|
2340
|
+
const script = arrayify8(this.script ?? "0x");
|
2341
|
+
const scriptData = arrayify8(this.scriptData ?? "0x");
|
2337
2342
|
return {
|
2338
2343
|
type: TransactionType4.Script,
|
2339
2344
|
scriptGasLimit: this.gasLimit,
|
@@ -2493,15 +2498,15 @@ var transactionRequestify = (obj) => {
|
|
2493
2498
|
import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
|
2494
2499
|
import { bn as bn13 } from "@fuel-ts/math";
|
2495
2500
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2496
|
-
import {
|
2501
|
+
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2497
2502
|
|
2498
2503
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2499
|
-
import { hexlify as hexlify11 } from "
|
2504
|
+
import { hexlify as hexlify11 } from "@fuel-ts/utils";
|
2500
2505
|
|
2501
2506
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2502
2507
|
import { bn as bn10 } from "@fuel-ts/math";
|
2503
2508
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2504
|
-
import {
|
2509
|
+
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2505
2510
|
var calculateTransactionFee = (params) => {
|
2506
2511
|
const {
|
2507
2512
|
gasUsed,
|
@@ -2510,7 +2515,7 @@ var calculateTransactionFee = (params) => {
|
|
2510
2515
|
} = params;
|
2511
2516
|
const gasPerByte = bn10(feeParams.gasPerByte);
|
2512
2517
|
const gasPriceFactor = bn10(feeParams.gasPriceFactor);
|
2513
|
-
const transactionBytes =
|
2518
|
+
const transactionBytes = arrayify9(rawPayload);
|
2514
2519
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2515
2520
|
if (transaction.type === TransactionType6.Mint) {
|
2516
2521
|
return {
|
@@ -2525,7 +2530,7 @@ var calculateTransactionFee = (params) => {
|
|
2525
2530
|
let gasLimit = bn10(0);
|
2526
2531
|
if (type === TransactionType6.Create) {
|
2527
2532
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2528
|
-
const contractBytesSize = bn10(
|
2533
|
+
const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2529
2534
|
metadataGas = calculateMetadataGasForTxCreate({
|
2530
2535
|
contractBytesSize,
|
2531
2536
|
gasCosts,
|
@@ -2580,6 +2585,7 @@ var fromTai64ToDate = (tai64Timestamp) => {
|
|
2580
2585
|
var fromDateToTai64 = (date) => TAI64.fromUnix(Math.floor(date.getTime() / 1e3)).toString(10);
|
2581
2586
|
|
2582
2587
|
// src/providers/transaction-summary/operations.ts
|
2588
|
+
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2583
2589
|
import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2584
2590
|
import { bn as bn12 } from "@fuel-ts/math";
|
2585
2591
|
import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
@@ -2724,7 +2730,6 @@ var OperationName = /* @__PURE__ */ ((OperationName2) => {
|
|
2724
2730
|
OperationName2["contractCreated"] = "Contract created";
|
2725
2731
|
OperationName2["transfer"] = "Transfer asset";
|
2726
2732
|
OperationName2["contractCall"] = "Contract call";
|
2727
|
-
OperationName2["contractTransfer"] = "Contract transfer";
|
2728
2733
|
OperationName2["receive"] = "Receive asset";
|
2729
2734
|
OperationName2["mint"] = "Mint asset";
|
2730
2735
|
OperationName2["predicatecall"] = "Predicate call";
|
@@ -2824,33 +2829,6 @@ function addOperation(operations, toAdd) {
|
|
2824
2829
|
function getReceiptsTransferOut(receipts) {
|
2825
2830
|
return getReceiptsByType(receipts, ReceiptType3.TransferOut);
|
2826
2831
|
}
|
2827
|
-
function getContractTransferOperations({ receipts }) {
|
2828
|
-
const transferOutReceipts = getReceiptsTransferOut(receipts);
|
2829
|
-
const contractTransferOperations = transferOutReceipts.reduce(
|
2830
|
-
(prevContractTransferOps, receipt) => {
|
2831
|
-
const newContractTransferOps = addOperation(prevContractTransferOps, {
|
2832
|
-
name: "Contract transfer" /* contractTransfer */,
|
2833
|
-
from: {
|
2834
|
-
type: 0 /* contract */,
|
2835
|
-
address: receipt.from
|
2836
|
-
},
|
2837
|
-
to: {
|
2838
|
-
type: 1 /* account */,
|
2839
|
-
address: receipt.to
|
2840
|
-
},
|
2841
|
-
assetsSent: [
|
2842
|
-
{
|
2843
|
-
amount: receipt.amount,
|
2844
|
-
assetId: receipt.assetId
|
2845
|
-
}
|
2846
|
-
]
|
2847
|
-
});
|
2848
|
-
return newContractTransferOps;
|
2849
|
-
},
|
2850
|
-
[]
|
2851
|
-
);
|
2852
|
-
return contractTransferOperations;
|
2853
|
-
}
|
2854
2832
|
function getWithdrawFromFuelOperations({
|
2855
2833
|
inputs,
|
2856
2834
|
receipts
|
@@ -2948,70 +2926,77 @@ function getContractCallOperations({
|
|
2948
2926
|
}, []);
|
2949
2927
|
return contractCallOperations;
|
2950
2928
|
}
|
2929
|
+
function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
|
2930
|
+
const { to: toAddress, assetId, amount } = receipt;
|
2931
|
+
let { from: fromAddress } = receipt;
|
2932
|
+
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
2933
|
+
if (ZeroBytes328 === fromAddress) {
|
2934
|
+
const change = changeOutputs.find((output) => output.assetId === assetId);
|
2935
|
+
fromAddress = change?.to || fromAddress;
|
2936
|
+
}
|
2937
|
+
const fromType = contractInputs.some((input) => input.contractID === fromAddress) ? 0 /* contract */ : 1 /* account */;
|
2938
|
+
return {
|
2939
|
+
name: "Transfer asset" /* transfer */,
|
2940
|
+
from: {
|
2941
|
+
type: fromType,
|
2942
|
+
address: fromAddress
|
2943
|
+
},
|
2944
|
+
to: {
|
2945
|
+
type: toType,
|
2946
|
+
address: toAddress
|
2947
|
+
},
|
2948
|
+
assetsSent: [
|
2949
|
+
{
|
2950
|
+
assetId: assetId.toString(),
|
2951
|
+
amount
|
2952
|
+
}
|
2953
|
+
]
|
2954
|
+
};
|
2955
|
+
}
|
2951
2956
|
function getTransferOperations({
|
2952
2957
|
inputs,
|
2953
2958
|
outputs,
|
2954
2959
|
receipts
|
2955
2960
|
}) {
|
2961
|
+
let operations = [];
|
2956
2962
|
const coinOutputs = getOutputsCoin(outputs);
|
2957
|
-
const
|
2963
|
+
const contractInputs = getInputsContract(inputs);
|
2964
|
+
const changeOutputs = getOutputsChange(outputs);
|
2965
|
+
coinOutputs.forEach((output) => {
|
2966
|
+
const { amount, assetId, to } = output;
|
2967
|
+
const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
|
2968
|
+
if (changeOutput) {
|
2969
|
+
operations = addOperation(operations, {
|
2970
|
+
name: "Transfer asset" /* transfer */,
|
2971
|
+
from: {
|
2972
|
+
type: 1 /* account */,
|
2973
|
+
address: changeOutput.to
|
2974
|
+
},
|
2975
|
+
to: {
|
2976
|
+
type: 1 /* account */,
|
2977
|
+
address: to
|
2978
|
+
},
|
2979
|
+
assetsSent: [
|
2980
|
+
{
|
2981
|
+
assetId,
|
2982
|
+
amount
|
2983
|
+
}
|
2984
|
+
]
|
2985
|
+
});
|
2986
|
+
}
|
2987
|
+
});
|
2988
|
+
const transferReceipts = getReceiptsByType(
|
2958
2989
|
receipts,
|
2959
2990
|
ReceiptType3.Transfer
|
2960
2991
|
);
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
const inputAddress = getInputAccountAddress(utxo);
|
2970
|
-
operations = addOperation(operations, {
|
2971
|
-
name: "Transfer asset" /* transfer */,
|
2972
|
-
from: {
|
2973
|
-
type: 1 /* account */,
|
2974
|
-
address: inputAddress
|
2975
|
-
},
|
2976
|
-
to: {
|
2977
|
-
type: 0 /* contract */,
|
2978
|
-
address: contractInput.contractID
|
2979
|
-
},
|
2980
|
-
assetsSent: [
|
2981
|
-
{
|
2982
|
-
assetId: assetId.toString(),
|
2983
|
-
amount: transferReceipt.amount
|
2984
|
-
}
|
2985
|
-
]
|
2986
|
-
});
|
2987
|
-
}
|
2988
|
-
});
|
2989
|
-
} else {
|
2990
|
-
coinOutputs.forEach((output) => {
|
2991
|
-
const input = getInputFromAssetId(inputs, output.assetId);
|
2992
|
-
if (input) {
|
2993
|
-
const inputAddress = getInputAccountAddress(input);
|
2994
|
-
const operationToAdd = {
|
2995
|
-
name: "Transfer asset" /* transfer */,
|
2996
|
-
from: {
|
2997
|
-
type: 1 /* account */,
|
2998
|
-
address: inputAddress
|
2999
|
-
},
|
3000
|
-
to: {
|
3001
|
-
type: 1 /* account */,
|
3002
|
-
address: output.to.toString()
|
3003
|
-
},
|
3004
|
-
assetsSent: [
|
3005
|
-
{
|
3006
|
-
assetId: output.assetId.toString(),
|
3007
|
-
amount: output.amount
|
3008
|
-
}
|
3009
|
-
]
|
3010
|
-
};
|
3011
|
-
operations = addOperation(operations, operationToAdd);
|
3012
|
-
}
|
3013
|
-
});
|
3014
|
-
}
|
2992
|
+
const transferOutReceipts = getReceiptsByType(
|
2993
|
+
receipts,
|
2994
|
+
ReceiptType3.TransferOut
|
2995
|
+
);
|
2996
|
+
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
2997
|
+
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
2998
|
+
operations = addOperation(operations, operation);
|
2999
|
+
});
|
3015
3000
|
return operations;
|
3016
3001
|
}
|
3017
3002
|
function getPayProducerOperations(outputs) {
|
@@ -3084,7 +3069,6 @@ function getOperations({
|
|
3084
3069
|
rawPayload,
|
3085
3070
|
maxInputs
|
3086
3071
|
}),
|
3087
|
-
...getContractTransferOperations({ receipts }),
|
3088
3072
|
...getWithdrawFromFuelOperations({ inputs, receipts })
|
3089
3073
|
];
|
3090
3074
|
}
|
@@ -3330,7 +3314,7 @@ var TransactionResponse = class {
|
|
3330
3314
|
*/
|
3331
3315
|
decodeTransaction(transactionWithReceipts) {
|
3332
3316
|
return new TransactionCoder4().decode(
|
3333
|
-
|
3317
|
+
arrayify10(transactionWithReceipts.rawPayload),
|
3334
3318
|
0
|
3335
3319
|
)?.[0];
|
3336
3320
|
}
|
@@ -3356,7 +3340,7 @@ var TransactionResponse = class {
|
|
3356
3340
|
id: this.id,
|
3357
3341
|
receipts,
|
3358
3342
|
transaction: decodedTransaction,
|
3359
|
-
transactionBytes:
|
3343
|
+
transactionBytes: arrayify10(transaction.rawPayload),
|
3360
3344
|
gqlTransactionStatus: transaction.status,
|
3361
3345
|
gasPerByte,
|
3362
3346
|
gasPriceFactor,
|
@@ -3657,7 +3641,7 @@ var _Provider = class {
|
|
3657
3641
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
3658
3642
|
const isSubscription = opDefinition?.operation === "subscription";
|
3659
3643
|
if (isSubscription) {
|
3660
|
-
return
|
3644
|
+
return new FuelGraphqlSubscriber({
|
3661
3645
|
url: this.url,
|
3662
3646
|
query,
|
3663
3647
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
@@ -3790,7 +3774,7 @@ var _Provider = class {
|
|
3790
3774
|
async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
3791
3775
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3792
3776
|
if (estimateTxDependencies) {
|
3793
|
-
|
3777
|
+
return this.estimateTxDependencies(transactionRequest);
|
3794
3778
|
}
|
3795
3779
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3796
3780
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
@@ -3809,6 +3793,14 @@ var _Provider = class {
|
|
3809
3793
|
* @returns A promise that resolves to the estimated transaction request object.
|
3810
3794
|
*/
|
3811
3795
|
async estimatePredicates(transactionRequest) {
|
3796
|
+
const shouldEstimatePredicates = Boolean(
|
3797
|
+
transactionRequest.inputs.find(
|
3798
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN(input.predicateGasUsed).isZero()
|
3799
|
+
)
|
3800
|
+
);
|
3801
|
+
if (!shouldEstimatePredicates) {
|
3802
|
+
return transactionRequest;
|
3803
|
+
}
|
3812
3804
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3813
3805
|
const response = await this.operations.estimatePredicates({
|
3814
3806
|
encodedTransaction
|
@@ -3839,34 +3831,41 @@ var _Provider = class {
|
|
3839
3831
|
* @returns A promise.
|
3840
3832
|
*/
|
3841
3833
|
async estimateTxDependencies(transactionRequest) {
|
3842
|
-
let missingOutputVariableCount = 0;
|
3843
|
-
let missingOutputContractIdsCount = 0;
|
3844
|
-
let tries = 0;
|
3845
3834
|
if (transactionRequest.type === TransactionType8.Create) {
|
3846
|
-
return
|
3847
|
-
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3835
|
+
return {
|
3836
|
+
receipts: [],
|
3837
|
+
outputVariables: 0,
|
3838
|
+
missingContractIds: []
|
3839
|
+
};
|
3851
3840
|
}
|
3852
|
-
|
3841
|
+
await this.estimatePredicates(transactionRequest);
|
3842
|
+
let receipts = [];
|
3843
|
+
const missingContractIds = [];
|
3844
|
+
let outputVariables = 0;
|
3845
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3853
3846
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3854
|
-
encodedTransaction: hexlify12(
|
3847
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
3855
3848
|
utxoValidation: false
|
3856
3849
|
});
|
3857
|
-
|
3850
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3858
3851
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3859
|
-
|
3860
|
-
|
3861
|
-
|
3862
|
-
|
3852
|
+
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3853
|
+
if (hasMissingOutputs) {
|
3854
|
+
outputVariables += missingOutputVariables.length;
|
3855
|
+
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
3856
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
3857
|
+
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3858
|
+
missingContractIds.push(contractId);
|
3859
|
+
});
|
3860
|
+
} else {
|
3861
|
+
break;
|
3863
3862
|
}
|
3864
|
-
txRequest.addVariableOutputs(missingOutputVariableCount);
|
3865
|
-
missingOutputContractIds.forEach(
|
3866
|
-
({ contractId }) => txRequest.addContractInputAndOutput(Address2.fromString(contractId))
|
3867
|
-
);
|
3868
|
-
tries += 1;
|
3869
3863
|
}
|
3864
|
+
return {
|
3865
|
+
receipts,
|
3866
|
+
outputVariables,
|
3867
|
+
missingContractIds
|
3868
|
+
};
|
3870
3869
|
}
|
3871
3870
|
/**
|
3872
3871
|
* Executes a signed transaction without applying the states changes
|
@@ -3881,7 +3880,7 @@ var _Provider = class {
|
|
3881
3880
|
async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
3882
3881
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3883
3882
|
if (estimateTxDependencies) {
|
3884
|
-
|
3883
|
+
return this.estimateTxDependencies(transactionRequest);
|
3885
3884
|
}
|
3886
3885
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3887
3886
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
@@ -3913,35 +3912,37 @@ var _Provider = class {
|
|
3913
3912
|
estimatePredicates = true,
|
3914
3913
|
resourcesOwner
|
3915
3914
|
} = {}) {
|
3916
|
-
const
|
3915
|
+
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3917
3916
|
const chainInfo = this.getChain();
|
3918
3917
|
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3919
|
-
const gasPrice = max(
|
3920
|
-
const isScriptTransaction =
|
3921
|
-
|
3918
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
3919
|
+
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
3920
|
+
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3921
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3922
|
+
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
3923
|
+
if (estimatePredicates) {
|
3922
3924
|
if (isScriptTransaction) {
|
3923
|
-
|
3925
|
+
txRequestClone.gasLimit = bn14(0);
|
3924
3926
|
}
|
3925
|
-
|
3927
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3928
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3929
|
+
}
|
3930
|
+
await this.estimatePredicates(txRequestClone);
|
3926
3931
|
}
|
3927
|
-
const minGas =
|
3928
|
-
const maxGas =
|
3929
|
-
const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
|
3930
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3931
|
-
transactionRequest.fundWithFakeUtxos(allQuantities, resourcesOwner);
|
3932
|
-
let gasUsed = minGas;
|
3932
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
3933
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
3933
3934
|
let receipts = [];
|
3934
|
-
|
3935
|
-
|
3936
|
-
|
3937
|
-
|
3938
|
-
|
3939
|
-
|
3935
|
+
let missingContractIds = [];
|
3936
|
+
let outputVariables = 0;
|
3937
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
3938
|
+
txRequestClone.gasPrice = bn14(0);
|
3939
|
+
txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
3940
|
+
const result = await this.estimateTxDependencies(txRequestClone);
|
3940
3941
|
receipts = result.receipts;
|
3941
|
-
|
3942
|
-
|
3943
|
-
gasUsed = minGas;
|
3942
|
+
outputVariables = result.outputVariables;
|
3943
|
+
missingContractIds = result.missingContractIds;
|
3944
3944
|
}
|
3945
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
3945
3946
|
const usedFee = calculatePriceWithFactor(
|
3946
3947
|
gasUsed,
|
3947
3948
|
gasPrice,
|
@@ -3959,7 +3960,10 @@ var _Provider = class {
|
|
3959
3960
|
maxGas,
|
3960
3961
|
usedFee,
|
3961
3962
|
minFee,
|
3962
|
-
maxFee
|
3963
|
+
maxFee,
|
3964
|
+
estimatedInputs: txRequestClone.inputs,
|
3965
|
+
outputVariables,
|
3966
|
+
missingContractIds
|
3963
3967
|
};
|
3964
3968
|
}
|
3965
3969
|
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
@@ -4127,7 +4131,7 @@ var _Provider = class {
|
|
4127
4131
|
time: block.header.time,
|
4128
4132
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4129
4133
|
transactions: block.transactions.map(
|
4130
|
-
(tx) => new TransactionCoder5().decode(
|
4134
|
+
(tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
|
4131
4135
|
)
|
4132
4136
|
};
|
4133
4137
|
}
|
@@ -4143,7 +4147,7 @@ var _Provider = class {
|
|
4143
4147
|
return null;
|
4144
4148
|
}
|
4145
4149
|
return new TransactionCoder5().decode(
|
4146
|
-
|
4150
|
+
arrayify11(transaction.rawPayload),
|
4147
4151
|
0
|
4148
4152
|
)?.[0];
|
4149
4153
|
}
|
@@ -4373,7 +4377,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4373
4377
|
import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
|
4374
4378
|
import { bn as bn15 } from "@fuel-ts/math";
|
4375
4379
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4376
|
-
import {
|
4380
|
+
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4377
4381
|
async function getTransactionSummary(params) {
|
4378
4382
|
const { id, provider, abiMap } = params;
|
4379
4383
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -4386,7 +4390,7 @@ async function getTransactionSummary(params) {
|
|
4386
4390
|
);
|
4387
4391
|
}
|
4388
4392
|
const [decodedTransaction] = new TransactionCoder6().decode(
|
4389
|
-
|
4393
|
+
arrayify12(gqlTransaction.rawPayload),
|
4390
4394
|
0
|
4391
4395
|
);
|
4392
4396
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -4397,7 +4401,7 @@ async function getTransactionSummary(params) {
|
|
4397
4401
|
id: gqlTransaction.id,
|
4398
4402
|
receipts,
|
4399
4403
|
transaction: decodedTransaction,
|
4400
|
-
transactionBytes:
|
4404
|
+
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4401
4405
|
gqlTransactionStatus: gqlTransaction.status,
|
4402
4406
|
gasPerByte: bn15(gasPerByte),
|
4403
4407
|
gasPriceFactor: bn15(gasPriceFactor),
|
@@ -4439,13 +4443,13 @@ async function getTransactionsSummaries(params) {
|
|
4439
4443
|
const transactions = edges.map((edge) => {
|
4440
4444
|
const { node: gqlTransaction } = edge;
|
4441
4445
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4442
|
-
const [decodedTransaction] = new TransactionCoder6().decode(
|
4446
|
+
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4443
4447
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4444
4448
|
const transactionSummary = assembleTransactionSummary({
|
4445
4449
|
id,
|
4446
4450
|
receipts,
|
4447
4451
|
transaction: decodedTransaction,
|
4448
|
-
transactionBytes:
|
4452
|
+
transactionBytes: arrayify12(rawPayload),
|
4449
4453
|
gqlTransactionStatus: status,
|
4450
4454
|
abiMap,
|
4451
4455
|
gasPerByte,
|
@@ -4465,19 +4469,140 @@ async function getTransactionsSummaries(params) {
|
|
4465
4469
|
};
|
4466
4470
|
}
|
4467
4471
|
|
4472
|
+
// src/providers/chains.ts
|
4473
|
+
var CHAIN_IDS = {
|
4474
|
+
eth: {
|
4475
|
+
sepolia: 11155111,
|
4476
|
+
foundry: 31337
|
4477
|
+
},
|
4478
|
+
fuel: {
|
4479
|
+
beta5: 0,
|
4480
|
+
devnet: 10
|
4481
|
+
}
|
4482
|
+
};
|
4483
|
+
|
4484
|
+
// src/providers/assets/utils/network.ts
|
4485
|
+
var getDefaultChainId = (networkType) => {
|
4486
|
+
if (networkType === "ethereum") {
|
4487
|
+
return CHAIN_IDS.eth.sepolia;
|
4488
|
+
}
|
4489
|
+
if (networkType === "fuel") {
|
4490
|
+
return CHAIN_IDS.fuel.beta5;
|
4491
|
+
}
|
4492
|
+
return void 0;
|
4493
|
+
};
|
4494
|
+
var getAssetNetwork = ({
|
4495
|
+
asset,
|
4496
|
+
chainId,
|
4497
|
+
networkType
|
4498
|
+
}) => {
|
4499
|
+
const network = asset.networks.find(
|
4500
|
+
(item) => item.chainId === chainId && item.type === networkType
|
4501
|
+
);
|
4502
|
+
return network;
|
4503
|
+
};
|
4504
|
+
var getAssetWithNetwork = ({
|
4505
|
+
asset,
|
4506
|
+
chainId,
|
4507
|
+
networkType
|
4508
|
+
}) => {
|
4509
|
+
const { networks: _, ...assetRest } = asset;
|
4510
|
+
const chainIdToUse = chainId ?? getDefaultChainId(networkType);
|
4511
|
+
if (chainIdToUse === void 0) {
|
4512
|
+
return void 0;
|
4513
|
+
}
|
4514
|
+
const assetNetwork = getAssetNetwork({
|
4515
|
+
asset,
|
4516
|
+
chainId: chainIdToUse,
|
4517
|
+
networkType
|
4518
|
+
});
|
4519
|
+
if (!assetNetwork) {
|
4520
|
+
return void 0;
|
4521
|
+
}
|
4522
|
+
return {
|
4523
|
+
...assetRest,
|
4524
|
+
...assetNetwork
|
4525
|
+
};
|
4526
|
+
};
|
4527
|
+
var getAssetEth = (asset, chainId) => getAssetWithNetwork({
|
4528
|
+
asset,
|
4529
|
+
networkType: "ethereum",
|
4530
|
+
chainId
|
4531
|
+
});
|
4532
|
+
var getAssetFuel = (asset, chainId) => getAssetWithNetwork({
|
4533
|
+
asset,
|
4534
|
+
networkType: "fuel",
|
4535
|
+
chainId
|
4536
|
+
});
|
4537
|
+
|
4538
|
+
// src/providers/assets/utils/url.ts
|
4539
|
+
var DELIMITER_PATH = "/";
|
4540
|
+
var trimRegex = /^\/|\/$/g;
|
4541
|
+
var trimPath = (path = "") => path.replace(trimRegex, "");
|
4542
|
+
function urlJoin(baseUrl, ...paths) {
|
4543
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4544
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4545
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4546
|
+
if (rootPath && hasBaseUrl) {
|
4547
|
+
allPaths.unshift("");
|
4548
|
+
}
|
4549
|
+
return allPaths.join(DELIMITER_PATH);
|
4550
|
+
}
|
4551
|
+
|
4552
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4553
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4554
|
+
return assets2.map((asset) => ({
|
4555
|
+
...asset,
|
4556
|
+
icon: urlJoin(basePath, asset.icon)
|
4557
|
+
}));
|
4558
|
+
}
|
4559
|
+
|
4560
|
+
// src/providers/assets/index.ts
|
4561
|
+
var assets = [
|
4562
|
+
{
|
4563
|
+
name: "Ethereum",
|
4564
|
+
symbol: "ETH",
|
4565
|
+
icon: "eth.svg",
|
4566
|
+
networks: [
|
4567
|
+
{
|
4568
|
+
type: "ethereum",
|
4569
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
4570
|
+
decimals: 18
|
4571
|
+
},
|
4572
|
+
{
|
4573
|
+
type: "ethereum",
|
4574
|
+
chainId: CHAIN_IDS.eth.foundry,
|
4575
|
+
decimals: 18
|
4576
|
+
},
|
4577
|
+
{
|
4578
|
+
type: "fuel",
|
4579
|
+
chainId: CHAIN_IDS.fuel.beta5,
|
4580
|
+
decimals: 9,
|
4581
|
+
assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
4582
|
+
},
|
4583
|
+
{
|
4584
|
+
type: "fuel",
|
4585
|
+
chainId: CHAIN_IDS.fuel.devnet,
|
4586
|
+
decimals: 9,
|
4587
|
+
assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
4588
|
+
}
|
4589
|
+
]
|
4590
|
+
}
|
4591
|
+
];
|
4592
|
+
|
4468
4593
|
// src/utils/formatTransferToContractScriptData.ts
|
4469
4594
|
import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
|
4470
|
-
import { BN } from "@fuel-ts/math";
|
4595
|
+
import { BN as BN2 } from "@fuel-ts/math";
|
4596
|
+
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
4471
4597
|
import * as asm from "@fuels/vm-asm";
|
4472
|
-
import { getBytesCopy as getBytesCopy14 } from "ethers";
|
4473
4598
|
var formatTransferToContractScriptData = (params) => {
|
4474
4599
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4475
4600
|
const numberCoder = new U64Coder2();
|
4476
|
-
const encoded = numberCoder.encode(new
|
4601
|
+
const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
|
4477
4602
|
const scriptData = Uint8Array.from([
|
4478
|
-
...
|
4603
|
+
...arrayify13(hexlifiedContractId),
|
4479
4604
|
...encoded,
|
4480
|
-
...
|
4605
|
+
...arrayify13(assetId)
|
4481
4606
|
]);
|
4482
4607
|
return scriptData;
|
4483
4608
|
};
|
@@ -4727,7 +4852,10 @@ var Account = class extends AbstractAccount {
|
|
4727
4852
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4728
4853
|
const request = new ScriptTransactionRequest(params);
|
4729
4854
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4730
|
-
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request
|
4855
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4856
|
+
estimateTxDependencies: true,
|
4857
|
+
resourcesOwner: this
|
4858
|
+
});
|
4731
4859
|
request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
|
4732
4860
|
request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
|
4733
4861
|
this.validateGas({
|
@@ -4737,6 +4865,7 @@ var Account = class extends AbstractAccount {
|
|
4737
4865
|
minGasPrice
|
4738
4866
|
});
|
4739
4867
|
await this.fund(request, requiredQuantities, maxFee);
|
4868
|
+
request.updatePredicateInputs(estimatedInputs);
|
4740
4869
|
return request;
|
4741
4870
|
}
|
4742
4871
|
/**
|
@@ -4750,7 +4879,7 @@ var Account = class extends AbstractAccount {
|
|
4750
4879
|
*/
|
4751
4880
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4752
4881
|
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
4753
|
-
return this.sendTransaction(request);
|
4882
|
+
return this.sendTransaction(request, { estimateTxDependencies: false });
|
4754
4883
|
}
|
4755
4884
|
/**
|
4756
4885
|
* Transfers coins to a contract address.
|
@@ -4801,14 +4930,14 @@ var Account = class extends AbstractAccount {
|
|
4801
4930
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4802
4931
|
const { minGasPrice } = this.provider.getGasConfig();
|
4803
4932
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
4804
|
-
const recipientDataArray =
|
4933
|
+
const recipientDataArray = arrayify14(
|
4805
4934
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4806
4935
|
);
|
4807
|
-
const amountDataArray =
|
4936
|
+
const amountDataArray = arrayify14(
|
4808
4937
|
"0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
|
4809
4938
|
);
|
4810
4939
|
const script = new Uint8Array([
|
4811
|
-
...
|
4940
|
+
...arrayify14(withdrawScript.bytes),
|
4812
4941
|
...recipientDataArray,
|
4813
4942
|
...amountDataArray
|
4814
4943
|
]);
|
@@ -4841,16 +4970,18 @@ var Account = class extends AbstractAccount {
|
|
4841
4970
|
* @param transactionRequestLike - The transaction request to be sent.
|
4842
4971
|
* @returns A promise that resolves to the transaction response.
|
4843
4972
|
*/
|
4844
|
-
async sendTransaction(transactionRequestLike,
|
4973
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
4845
4974
|
if (this._connector) {
|
4846
4975
|
return this.provider.getTransactionResponse(
|
4847
4976
|
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
|
4848
4977
|
);
|
4849
4978
|
}
|
4850
4979
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4851
|
-
|
4980
|
+
if (estimateTxDependencies) {
|
4981
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
4982
|
+
}
|
4852
4983
|
return this.provider.sendTransaction(transactionRequest, {
|
4853
|
-
|
4984
|
+
awaitExecution,
|
4854
4985
|
estimateTxDependencies: false
|
4855
4986
|
});
|
4856
4987
|
}
|
@@ -4860,9 +4991,11 @@ var Account = class extends AbstractAccount {
|
|
4860
4991
|
* @param transactionRequestLike - The transaction request to be simulated.
|
4861
4992
|
* @returns A promise that resolves to the call result.
|
4862
4993
|
*/
|
4863
|
-
async simulateTransaction(transactionRequestLike) {
|
4994
|
+
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
4864
4995
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4865
|
-
|
4996
|
+
if (estimateTxDependencies) {
|
4997
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
4998
|
+
}
|
4866
4999
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
4867
5000
|
}
|
4868
5001
|
validateGas({
|
@@ -4888,14 +5021,15 @@ var Account = class extends AbstractAccount {
|
|
4888
5021
|
|
4889
5022
|
// src/wallet/base-wallet-unlocked.ts
|
4890
5023
|
import { hashMessage } from "@fuel-ts/hasher";
|
5024
|
+
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
4891
5025
|
|
4892
5026
|
// src/signer/signer.ts
|
4893
5027
|
import { Address as Address4 } from "@fuel-ts/address";
|
4894
5028
|
import { randomBytes } from "@fuel-ts/crypto";
|
4895
5029
|
import { hash } from "@fuel-ts/hasher";
|
4896
5030
|
import { toBytes } from "@fuel-ts/math";
|
5031
|
+
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
4897
5032
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
4898
|
-
import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy16 } from "ethers";
|
4899
5033
|
var Signer = class {
|
4900
5034
|
address;
|
4901
5035
|
publicKey;
|
@@ -4930,11 +5064,11 @@ var Signer = class {
|
|
4930
5064
|
* @returns hashed signature
|
4931
5065
|
*/
|
4932
5066
|
sign(data) {
|
4933
|
-
const signature = secp256k1.sign(
|
5067
|
+
const signature = secp256k1.sign(arrayify15(data), arrayify15(this.privateKey));
|
4934
5068
|
const r = toBytes(`0x${signature.r.toString(16)}`, 32);
|
4935
5069
|
const s = toBytes(`0x${signature.s.toString(16)}`, 32);
|
4936
5070
|
s[0] |= (signature.recovery || 0) << 7;
|
4937
|
-
return concat3([r, s]);
|
5071
|
+
return hexlify13(concat3([r, s]));
|
4938
5072
|
}
|
4939
5073
|
/**
|
4940
5074
|
* Add point on the current elliptic curve
|
@@ -4943,8 +5077,8 @@ var Signer = class {
|
|
4943
5077
|
* @returns compressed point on the curve
|
4944
5078
|
*/
|
4945
5079
|
addPoint(point) {
|
4946
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
4947
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
5080
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify15(this.compressedPublicKey));
|
5081
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify15(point));
|
4948
5082
|
const result = p0.add(p1);
|
4949
5083
|
return `0x${result.toHex(true)}`;
|
4950
5084
|
}
|
@@ -4956,7 +5090,7 @@ var Signer = class {
|
|
4956
5090
|
* @returns public key from signature from the
|
4957
5091
|
*/
|
4958
5092
|
static recoverPublicKey(data, signature) {
|
4959
|
-
const signedMessageBytes =
|
5093
|
+
const signedMessageBytes = arrayify15(signature);
|
4960
5094
|
const r = signedMessageBytes.slice(0, 32);
|
4961
5095
|
const s = signedMessageBytes.slice(32, 64);
|
4962
5096
|
const recoveryParam = (s[0] & 128) >> 7;
|
@@ -4964,7 +5098,7 @@ var Signer = class {
|
|
4964
5098
|
const sig = new secp256k1.Signature(BigInt(hexlify13(r)), BigInt(hexlify13(s))).addRecoveryBit(
|
4965
5099
|
recoveryParam
|
4966
5100
|
);
|
4967
|
-
const publicKey = sig.recoverPublicKey(
|
5101
|
+
const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
|
4968
5102
|
return hexlify13(publicKey);
|
4969
5103
|
}
|
4970
5104
|
/**
|
@@ -4984,7 +5118,7 @@ var Signer = class {
|
|
4984
5118
|
* @returns random 32-byte hashed
|
4985
5119
|
*/
|
4986
5120
|
static generatePrivateKey(entropy) {
|
4987
|
-
return entropy ? hash(concat3([randomBytes(32),
|
5121
|
+
return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
|
4988
5122
|
}
|
4989
5123
|
/**
|
4990
5124
|
* Extended publicKey from a compact publicKey
|
@@ -4993,7 +5127,7 @@ var Signer = class {
|
|
4993
5127
|
* @returns extended publicKey
|
4994
5128
|
*/
|
4995
5129
|
static extendPublicKey(publicKey) {
|
4996
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
5130
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
|
4997
5131
|
return hexlify13(point.toRawBytes(false).slice(1));
|
4998
5132
|
}
|
4999
5133
|
};
|
@@ -5010,7 +5144,7 @@ import {
|
|
5010
5144
|
encryptJsonWalletData
|
5011
5145
|
} from "@fuel-ts/crypto";
|
5012
5146
|
import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
|
5013
|
-
import { hexlify as hexlify14 } from "
|
5147
|
+
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
5014
5148
|
import { v4 as uuidv4 } from "uuid";
|
5015
5149
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5016
5150
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5138,7 +5272,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5138
5272
|
*/
|
5139
5273
|
async signMessage(message) {
|
5140
5274
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
5141
|
-
return signedMessage;
|
5275
|
+
return hexlify15(signedMessage);
|
5142
5276
|
}
|
5143
5277
|
/**
|
5144
5278
|
* Signs a transaction with the wallet's private key.
|
@@ -5151,7 +5285,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5151
5285
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5152
5286
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5153
5287
|
const signature = await this.signer().sign(hashedTransaction);
|
5154
|
-
return signature;
|
5288
|
+
return hexlify15(signature);
|
5155
5289
|
}
|
5156
5290
|
/**
|
5157
5291
|
* Populates a transaction with the witnesses signature.
|
@@ -5171,12 +5305,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
5171
5305
|
* @param transactionRequestLike - The transaction request to send.
|
5172
5306
|
* @returns A promise that resolves to the TransactionResponse object.
|
5173
5307
|
*/
|
5174
|
-
async sendTransaction(transactionRequestLike,
|
5308
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5175
5309
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5176
|
-
|
5310
|
+
if (estimateTxDependencies) {
|
5311
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
5312
|
+
}
|
5177
5313
|
return this.provider.sendTransaction(
|
5178
5314
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
5179
|
-
{
|
5315
|
+
{ awaitExecution, estimateTxDependencies: false }
|
5180
5316
|
);
|
5181
5317
|
}
|
5182
5318
|
/**
|
@@ -5185,9 +5321,11 @@ var BaseWalletUnlocked = class extends Account {
|
|
5185
5321
|
* @param transactionRequestLike - The transaction request to simulate.
|
5186
5322
|
* @returns A promise that resolves to the CallResult object.
|
5187
5323
|
*/
|
5188
|
-
async simulateTransaction(transactionRequestLike) {
|
5324
|
+
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
5189
5325
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5190
|
-
|
5326
|
+
if (estimateTxDependencies) {
|
5327
|
+
await this.provider.estimateTxDependencies(transactionRequest);
|
5328
|
+
}
|
5191
5329
|
return this.provider.call(
|
5192
5330
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
5193
5331
|
{
|
@@ -5208,32 +5346,22 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5208
5346
|
// src/hdwallet/hdwallet.ts
|
5209
5347
|
import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5210
5348
|
import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5349
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5211
5350
|
import {
|
5212
5351
|
toBeHex,
|
5213
5352
|
dataSlice as dataSlice2,
|
5214
|
-
hexlify as hexlify16,
|
5215
5353
|
encodeBase58 as encodeBase582,
|
5216
5354
|
decodeBase58,
|
5217
5355
|
sha256 as sha2564,
|
5218
5356
|
computeHmac as computeHmac2,
|
5219
|
-
ripemd160
|
5220
|
-
getBytesCopy as getBytesCopy19,
|
5221
|
-
concat as concat5
|
5357
|
+
ripemd160
|
5222
5358
|
} from "ethers";
|
5223
5359
|
|
5224
5360
|
// src/mnemonic/mnemonic.ts
|
5225
5361
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
5226
5362
|
import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
|
5227
|
-
import {
|
5228
|
-
|
5229
|
-
hexlify as hexlify15,
|
5230
|
-
dataSlice,
|
5231
|
-
pbkdf2,
|
5232
|
-
sha256 as sha2563,
|
5233
|
-
computeHmac,
|
5234
|
-
encodeBase58,
|
5235
|
-
getBytesCopy as getBytesCopy18
|
5236
|
-
} from "ethers";
|
5363
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5364
|
+
import { dataSlice, pbkdf2, sha256 as sha2563, computeHmac, encodeBase58 } from "ethers";
|
5237
5365
|
|
5238
5366
|
// src/wordlists/words/english.ts
|
5239
5367
|
var english = [
|
@@ -7295,7 +7423,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7295
7423
|
|
7296
7424
|
// src/mnemonic/utils.ts
|
7297
7425
|
import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
|
7298
|
-
import {
|
7426
|
+
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7427
|
+
import { sha256 as sha2562 } from "ethers";
|
7299
7428
|
function toUtf8Bytes(stri) {
|
7300
7429
|
const str = stri.normalize("NFKD");
|
7301
7430
|
const result = [];
|
@@ -7362,14 +7491,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7362
7491
|
}
|
7363
7492
|
}
|
7364
7493
|
const checksumBits = entropy.length / 4;
|
7365
|
-
const checksum =
|
7494
|
+
const checksum = arrayify16(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
7366
7495
|
indices[indices.length - 1] <<= checksumBits;
|
7367
7496
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7368
7497
|
return indices;
|
7369
7498
|
}
|
7370
7499
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7371
7500
|
const size = Math.ceil(11 * words.length / 8);
|
7372
|
-
const entropy =
|
7501
|
+
const entropy = arrayify16(new Uint8Array(size));
|
7373
7502
|
let offset = 0;
|
7374
7503
|
for (let i = 0; i < words.length; i += 1) {
|
7375
7504
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7389,7 +7518,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7389
7518
|
const entropyBits = 32 * words.length / 3;
|
7390
7519
|
const checksumBits = words.length / 3;
|
7391
7520
|
const checksumMask = getUpperMask(checksumBits);
|
7392
|
-
const checksum =
|
7521
|
+
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7393
7522
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7394
7523
|
throw new FuelError16(
|
7395
7524
|
ErrorCode15.INVALID_CHECKSUM,
|
@@ -7464,7 +7593,7 @@ var Mnemonic = class {
|
|
7464
7593
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7465
7594
|
const words = getWords(phrase);
|
7466
7595
|
assertMnemonic(words);
|
7467
|
-
return
|
7596
|
+
return hexlify16(mnemonicWordsToEntropy(words, wordlist));
|
7468
7597
|
}
|
7469
7598
|
/**
|
7470
7599
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7472,7 +7601,7 @@ var Mnemonic = class {
|
|
7472
7601
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7473
7602
|
*/
|
7474
7603
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7475
|
-
const entropyBytes =
|
7604
|
+
const entropyBytes = arrayify17(entropy);
|
7476
7605
|
assertWordList(wordlist);
|
7477
7606
|
assertEntropy(entropyBytes);
|
7478
7607
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7541,14 +7670,14 @@ var Mnemonic = class {
|
|
7541
7670
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7542
7671
|
*/
|
7543
7672
|
static masterKeysFromSeed(seed) {
|
7544
|
-
const seedArray =
|
7673
|
+
const seedArray = arrayify17(seed);
|
7545
7674
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7546
7675
|
throw new FuelError17(
|
7547
7676
|
ErrorCode16.INVALID_SEED,
|
7548
7677
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7549
7678
|
);
|
7550
7679
|
}
|
7551
|
-
return
|
7680
|
+
return arrayify17(computeHmac("sha512", MasterSecret, seedArray));
|
7552
7681
|
}
|
7553
7682
|
/**
|
7554
7683
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7559,7 +7688,7 @@ var Mnemonic = class {
|
|
7559
7688
|
*/
|
7560
7689
|
static seedToExtendedKey(seed, testnet = false) {
|
7561
7690
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7562
|
-
const prefix =
|
7691
|
+
const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
|
7563
7692
|
const depth = "0x00";
|
7564
7693
|
const fingerprint = "0x00000000";
|
7565
7694
|
const index = "0x00000000";
|
@@ -7589,7 +7718,7 @@ var Mnemonic = class {
|
|
7589
7718
|
* @returns A randomly generated mnemonic
|
7590
7719
|
*/
|
7591
7720
|
static generate(size = 32, extraEntropy = "") {
|
7592
|
-
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size),
|
7721
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
|
7593
7722
|
return Mnemonic.entropyToMnemonic(entropy);
|
7594
7723
|
}
|
7595
7724
|
};
|
@@ -7597,10 +7726,10 @@ var mnemonic_default = Mnemonic;
|
|
7597
7726
|
|
7598
7727
|
// src/hdwallet/hdwallet.ts
|
7599
7728
|
var HARDENED_INDEX = 2147483648;
|
7600
|
-
var MainnetPRV2 =
|
7601
|
-
var MainnetPUB =
|
7602
|
-
var TestnetPRV2 =
|
7603
|
-
var TestnetPUB =
|
7729
|
+
var MainnetPRV2 = hexlify17("0x0488ade4");
|
7730
|
+
var MainnetPUB = hexlify17("0x0488b21e");
|
7731
|
+
var TestnetPRV2 = hexlify17("0x04358394");
|
7732
|
+
var TestnetPUB = hexlify17("0x043587cf");
|
7604
7733
|
function base58check(data) {
|
7605
7734
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
7606
7735
|
}
|
@@ -7611,11 +7740,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7611
7740
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7612
7741
|
}
|
7613
7742
|
function isPublicExtendedKey(extendedKey) {
|
7614
|
-
return [MainnetPUB, TestnetPUB].includes(
|
7743
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify17(extendedKey.slice(0, 4)));
|
7615
7744
|
}
|
7616
7745
|
function isValidExtendedKey(extendedKey) {
|
7617
7746
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7618
|
-
|
7747
|
+
hexlify17(extendedKey.slice(0, 4))
|
7619
7748
|
);
|
7620
7749
|
}
|
7621
7750
|
function parsePath(path, depth = 0) {
|
@@ -7633,8 +7762,8 @@ function parsePath(path, depth = 0) {
|
|
7633
7762
|
var HDWallet = class {
|
7634
7763
|
depth = 0;
|
7635
7764
|
index = 0;
|
7636
|
-
fingerprint =
|
7637
|
-
parentFingerprint =
|
7765
|
+
fingerprint = hexlify17("0x00000000");
|
7766
|
+
parentFingerprint = hexlify17("0x00000000");
|
7638
7767
|
privateKey;
|
7639
7768
|
publicKey;
|
7640
7769
|
chainCode;
|
@@ -7646,8 +7775,8 @@ var HDWallet = class {
|
|
7646
7775
|
constructor(config) {
|
7647
7776
|
if (config.privateKey) {
|
7648
7777
|
const signer = new Signer(config.privateKey);
|
7649
|
-
this.publicKey =
|
7650
|
-
this.privateKey =
|
7778
|
+
this.publicKey = hexlify17(signer.compressedPublicKey);
|
7779
|
+
this.privateKey = hexlify17(config.privateKey);
|
7651
7780
|
} else {
|
7652
7781
|
if (!config.publicKey) {
|
7653
7782
|
throw new FuelError18(
|
@@ -7655,7 +7784,7 @@ var HDWallet = class {
|
|
7655
7784
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7656
7785
|
);
|
7657
7786
|
}
|
7658
|
-
this.publicKey =
|
7787
|
+
this.publicKey = hexlify17(config.publicKey);
|
7659
7788
|
}
|
7660
7789
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7661
7790
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -7674,9 +7803,9 @@ var HDWallet = class {
|
|
7674
7803
|
* @returns A new instance of HDWallet on the derived index
|
7675
7804
|
*/
|
7676
7805
|
deriveIndex(index) {
|
7677
|
-
const privateKey = this.privateKey &&
|
7678
|
-
const publicKey =
|
7679
|
-
const chainCode =
|
7806
|
+
const privateKey = this.privateKey && arrayify18(this.privateKey);
|
7807
|
+
const publicKey = arrayify18(this.publicKey);
|
7808
|
+
const chainCode = arrayify18(this.chainCode);
|
7680
7809
|
const data = new Uint8Array(37);
|
7681
7810
|
if (index & HARDENED_INDEX) {
|
7682
7811
|
if (!privateKey) {
|
@@ -7687,10 +7816,10 @@ var HDWallet = class {
|
|
7687
7816
|
}
|
7688
7817
|
data.set(privateKey, 1);
|
7689
7818
|
} else {
|
7690
|
-
data.set(
|
7819
|
+
data.set(arrayify18(this.publicKey));
|
7691
7820
|
}
|
7692
7821
|
data.set(toBytes2(index, 4), 33);
|
7693
|
-
const bytes =
|
7822
|
+
const bytes = arrayify18(computeHmac2("sha512", chainCode, data));
|
7694
7823
|
const IL = bytes.slice(0, 32);
|
7695
7824
|
const IR = bytes.slice(32);
|
7696
7825
|
if (privateKey) {
|
@@ -7704,7 +7833,7 @@ var HDWallet = class {
|
|
7704
7833
|
parentFingerprint: this.fingerprint
|
7705
7834
|
});
|
7706
7835
|
}
|
7707
|
-
const signer = new Signer(
|
7836
|
+
const signer = new Signer(hexlify17(IL));
|
7708
7837
|
const Ki = signer.addPoint(publicKey);
|
7709
7838
|
return new HDWallet({
|
7710
7839
|
publicKey: Ki,
|
@@ -7739,14 +7868,12 @@ var HDWallet = class {
|
|
7739
7868
|
);
|
7740
7869
|
}
|
7741
7870
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7742
|
-
const depth =
|
7871
|
+
const depth = hexlify17(Uint8Array.from([this.depth]));
|
7743
7872
|
const parentFingerprint = this.parentFingerprint;
|
7744
7873
|
const index = toHex(this.index, 4);
|
7745
7874
|
const chainCode = this.chainCode;
|
7746
7875
|
const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
|
7747
|
-
const extendedKey =
|
7748
|
-
concat5([prefix, depth, parentFingerprint, index, chainCode, key])
|
7749
|
-
);
|
7876
|
+
const extendedKey = arrayify18(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7750
7877
|
return base58check(extendedKey);
|
7751
7878
|
}
|
7752
7879
|
/**
|
@@ -7758,13 +7885,13 @@ var HDWallet = class {
|
|
7758
7885
|
static fromSeed(seed) {
|
7759
7886
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7760
7887
|
return new HDWallet({
|
7761
|
-
chainCode:
|
7762
|
-
privateKey:
|
7888
|
+
chainCode: arrayify18(masterKey.slice(32)),
|
7889
|
+
privateKey: arrayify18(masterKey.slice(0, 32))
|
7763
7890
|
});
|
7764
7891
|
}
|
7765
7892
|
static fromExtendedKey(extendedKey) {
|
7766
7893
|
const decoded = toBeHex(decodeBase58(extendedKey));
|
7767
|
-
const bytes =
|
7894
|
+
const bytes = arrayify18(decoded);
|
7768
7895
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7769
7896
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7770
7897
|
throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7773,9 +7900,9 @@ var HDWallet = class {
|
|
7773
7900
|
throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7774
7901
|
}
|
7775
7902
|
const depth = bytes[4];
|
7776
|
-
const parentFingerprint =
|
7777
|
-
const index = parseInt(
|
7778
|
-
const chainCode =
|
7903
|
+
const parentFingerprint = hexlify17(bytes.slice(5, 9));
|
7904
|
+
const index = parseInt(hexlify17(bytes.slice(9, 13)).substring(2), 16);
|
7905
|
+
const chainCode = hexlify17(bytes.slice(13, 45));
|
7779
7906
|
const key = bytes.slice(45, 78);
|
7780
7907
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7781
7908
|
throw new FuelError18(
|
@@ -8387,18 +8514,17 @@ import { Address as Address9 } from "@fuel-ts/address";
|
|
8387
8514
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8388
8515
|
import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
|
8389
8516
|
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8390
|
-
import {
|
8517
|
+
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8391
8518
|
|
8392
8519
|
// src/predicate/utils/getPredicateRoot.ts
|
8393
8520
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
8394
8521
|
import { calcRoot } from "@fuel-ts/merkle";
|
8395
|
-
import { chunkAndPadBytes } from "@fuel-ts/utils";
|
8396
|
-
import { hexlify as hexlify17, concat as concat6, getBytesCopy as getBytesCopy20 } from "ethers";
|
8522
|
+
import { chunkAndPadBytes, hexlify as hexlify18, concat as concat6, arrayify as arrayify19 } from "@fuel-ts/utils";
|
8397
8523
|
var getPredicateRoot = (bytecode) => {
|
8398
8524
|
const chunkSize = 16 * 1024;
|
8399
|
-
const bytes =
|
8525
|
+
const bytes = arrayify19(bytecode);
|
8400
8526
|
const chunks = chunkAndPadBytes(bytes, chunkSize);
|
8401
|
-
const codeRoot = calcRoot(chunks.map((c) =>
|
8527
|
+
const codeRoot = calcRoot(chunks.map((c) => hexlify18(c)));
|
8402
8528
|
const predicateRoot = hash2(concat6(["0x4655454C", codeRoot]));
|
8403
8529
|
return predicateRoot;
|
8404
8530
|
};
|
@@ -8438,7 +8564,7 @@ var Predicate = class extends Account {
|
|
8438
8564
|
const request = transactionRequestify(transactionRequestLike);
|
8439
8565
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8440
8566
|
request.inputs?.forEach((input) => {
|
8441
|
-
if (input.type === InputType7.Coin &&
|
8567
|
+
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8442
8568
|
input.predicate = this.bytes;
|
8443
8569
|
input.predicateData = this.getPredicateData(policies.length);
|
8444
8570
|
}
|
@@ -8509,7 +8635,7 @@ var Predicate = class extends Account {
|
|
8509
8635
|
* @returns An object containing the new predicate bytes and interface.
|
8510
8636
|
*/
|
8511
8637
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8512
|
-
let predicateBytes =
|
8638
|
+
let predicateBytes = arrayify20(bytes);
|
8513
8639
|
let abiInterface;
|
8514
8640
|
if (jsonAbi) {
|
8515
8641
|
abiInterface = new Interface3(jsonAbi);
|
@@ -8569,6 +8695,9 @@ var Predicate = class extends Account {
|
|
8569
8695
|
}
|
8570
8696
|
};
|
8571
8697
|
|
8698
|
+
// src/connectors/fuel.ts
|
8699
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8700
|
+
|
8572
8701
|
// src/connectors/fuel-connector.ts
|
8573
8702
|
import { EventEmitter as EventEmitter2 } from "events";
|
8574
8703
|
|
@@ -8609,17 +8738,6 @@ var FuelConnectorEventTypes = /* @__PURE__ */ ((FuelConnectorEventTypes2) => {
|
|
8609
8738
|
})(FuelConnectorEventTypes || {});
|
8610
8739
|
var FuelConnectorEventType = "FuelConnector";
|
8611
8740
|
|
8612
|
-
// src/connectors/types/data-type.ts
|
8613
|
-
var MessageTypes = /* @__PURE__ */ ((MessageTypes2) => {
|
8614
|
-
MessageTypes2["ping"] = "ping";
|
8615
|
-
MessageTypes2["uiEvent"] = "uiEvent";
|
8616
|
-
MessageTypes2["event"] = "event";
|
8617
|
-
MessageTypes2["request"] = "request";
|
8618
|
-
MessageTypes2["response"] = "response";
|
8619
|
-
MessageTypes2["removeConnection"] = "removeConnection";
|
8620
|
-
return MessageTypes2;
|
8621
|
-
})(MessageTypes || {});
|
8622
|
-
|
8623
8741
|
// src/connectors/types/local-storage.ts
|
8624
8742
|
var LocalStorage = class {
|
8625
8743
|
storage;
|
@@ -8908,6 +9026,7 @@ async function withTimeout(promise, timeout = 1050) {
|
|
8908
9026
|
// src/connectors/fuel.ts
|
8909
9027
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
8910
9028
|
var PING_CACHE_TIME = 5e3;
|
9029
|
+
var { warn } = console;
|
8911
9030
|
var _Fuel = class extends FuelConnector {
|
8912
9031
|
_storage = null;
|
8913
9032
|
_connectors = [];
|
@@ -9176,14 +9295,12 @@ var _Fuel = class extends FuelConnector {
|
|
9176
9295
|
* Return a Fuel Provider instance with extends features to work with
|
9177
9296
|
* connectors.
|
9178
9297
|
*
|
9179
|
-
* @deprecated
|
9298
|
+
* @deprecated getProvider is deprecated and is going to be removed in the future, use getWallet instead.
|
9180
9299
|
*/
|
9181
9300
|
async getProvider(providerOrNetwork) {
|
9182
|
-
|
9183
|
-
|
9184
|
-
|
9185
|
-
);
|
9186
|
-
}
|
9301
|
+
warn(
|
9302
|
+
"getProvider is deprecated and is going to be removed in the future, use getWallet instead."
|
9303
|
+
);
|
9187
9304
|
return this._getProvider(providerOrNetwork);
|
9188
9305
|
}
|
9189
9306
|
/**
|
@@ -9200,7 +9317,7 @@ var _Fuel = class extends FuelConnector {
|
|
9200
9317
|
const currentNetwork = await this.currentNetwork();
|
9201
9318
|
provider = await Provider.create(currentNetwork.url);
|
9202
9319
|
} else {
|
9203
|
-
throw new
|
9320
|
+
throw new FuelError24(ErrorCode23.INVALID_PROVIDER, "Provider is not valid.");
|
9204
9321
|
}
|
9205
9322
|
return provider;
|
9206
9323
|
}
|
@@ -9243,6 +9360,7 @@ export {
|
|
9243
9360
|
AddressType,
|
9244
9361
|
BaseTransactionRequest,
|
9245
9362
|
BaseWalletUnlocked,
|
9363
|
+
CHAIN_IDS,
|
9246
9364
|
ChainName,
|
9247
9365
|
ChangeOutputCollisionError,
|
9248
9366
|
CreateTransactionRequest,
|
@@ -9256,7 +9374,6 @@ export {
|
|
9256
9374
|
LocalStorage,
|
9257
9375
|
MNEMONIC_SIZES,
|
9258
9376
|
MemoryStorage,
|
9259
|
-
MessageTypes,
|
9260
9377
|
mnemonic_default as Mnemonic,
|
9261
9378
|
MnemonicVault,
|
9262
9379
|
NoWitnessAtIndexError,
|
@@ -9281,6 +9398,7 @@ export {
|
|
9281
9398
|
addOperation,
|
9282
9399
|
assembleReceiptByType,
|
9283
9400
|
assembleTransactionSummary,
|
9401
|
+
assets,
|
9284
9402
|
buildBlockExplorerUrl,
|
9285
9403
|
cacheFor,
|
9286
9404
|
calculateMetadataGasForTxCreate,
|
@@ -9298,10 +9416,14 @@ export {
|
|
9298
9416
|
fromTai64ToUnix,
|
9299
9417
|
fromUnixToTai64,
|
9300
9418
|
gasUsedByInputs,
|
9419
|
+
getAssetEth,
|
9420
|
+
getAssetFuel,
|
9421
|
+
getAssetNetwork,
|
9422
|
+
getAssetWithNetwork,
|
9301
9423
|
getContractCallOperations,
|
9302
9424
|
getContractCreatedOperations,
|
9303
|
-
getContractTransferOperations,
|
9304
9425
|
getDecodedLogs,
|
9426
|
+
getDefaultChainId,
|
9305
9427
|
getGasUsedFromReceipts,
|
9306
9428
|
getInputAccountAddress,
|
9307
9429
|
getInputContractFromIndex,
|
@@ -9350,9 +9472,11 @@ export {
|
|
9350
9472
|
processGqlReceipt,
|
9351
9473
|
processGraphqlStatus,
|
9352
9474
|
resolveGasDependentCosts,
|
9475
|
+
resolveIconPaths,
|
9353
9476
|
returnZeroScript,
|
9354
9477
|
sleep,
|
9355
9478
|
transactionRequestify,
|
9479
|
+
urlJoin,
|
9356
9480
|
withTimeout,
|
9357
9481
|
withdrawScript
|
9358
9482
|
};
|