@fuel-ts/account 0.101.1 → 0.101.2
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/index.global.js +186 -64
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +342 -225
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -158
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/call.d.ts +4 -7
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +1 -1
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +10 -1
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/test-utils.global.js +186 -64
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +302 -187
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +238 -122
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/test-utils.mjs
CHANGED
@@ -408,8 +408,8 @@ var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
|
408
408
|
import { Address as Address3, isB256 } from "@fuel-ts/address";
|
409
409
|
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
410
410
|
import { bn as bn18 } from "@fuel-ts/math";
|
411
|
-
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as
|
412
|
-
import { arrayify as
|
411
|
+
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder7, TransactionType as TransactionType11 } from "@fuel-ts/transactions";
|
412
|
+
import { arrayify as arrayify14, hexlify as hexlify19, DateTime as DateTime2, isDefined as isDefined3, sleep as sleep2 } from "@fuel-ts/utils";
|
413
413
|
import { checkFuelCoreVersionCompatibility, versions } from "@fuel-ts/versions";
|
414
414
|
import { GraphQLClient } from "graphql-request";
|
415
415
|
import gql2 from "graphql-tag";
|
@@ -2856,7 +2856,8 @@ import {
|
|
2856
2856
|
FAILED_ASSERT_SIGNAL,
|
2857
2857
|
FAILED_TRANSFER_TO_ADDRESS_SIGNAL as FAILED_TRANSFER_TO_ADDRESS_SIGNAL2,
|
2858
2858
|
PANIC_REASONS,
|
2859
|
-
PANIC_DOC_URL
|
2859
|
+
PANIC_DOC_URL,
|
2860
|
+
SwaySignalErrors
|
2860
2861
|
} from "@fuel-ts/transactions/configs";
|
2861
2862
|
var assemblePanicError = /* @__PURE__ */ __name((statusReason, metadata) => {
|
2862
2863
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
@@ -2873,58 +2874,97 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
2873
2874
|
});
|
2874
2875
|
}, "assemblePanicError");
|
2875
2876
|
var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
|
2876
|
-
var
|
2877
|
+
var assembleSignalErrorMessage = /* @__PURE__ */ __name((reasonHex, logs, metadata) => {
|
2877
2878
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2878
|
-
const revertReceipt = receipts.find(({ type }) => type === ReceiptType4.Revert);
|
2879
2879
|
let reason = "";
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
2885
|
-
|
2886
|
-
|
2887
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
2888
|
-
break;
|
2889
|
-
}
|
2890
|
-
case FAILED_ASSERT_EQ_SIGNAL: {
|
2891
|
-
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2892
|
-
reason = "assert_eq";
|
2893
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
2894
|
-
break;
|
2895
|
-
}
|
2896
|
-
case FAILED_ASSERT_NE_SIGNAL: {
|
2897
|
-
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2898
|
-
reason = "assert_ne";
|
2899
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
2900
|
-
break;
|
2901
|
-
}
|
2902
|
-
case FAILED_ASSERT_SIGNAL:
|
2903
|
-
reason = "assert";
|
2904
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
2905
|
-
break;
|
2906
|
-
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
2907
|
-
reason = "MissingOutputVariable";
|
2908
|
-
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2909
|
-
break;
|
2910
|
-
default:
|
2911
|
-
throw new FuelError9(
|
2912
|
-
ErrorCode8.UNKNOWN,
|
2913
|
-
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2914
|
-
{
|
2915
|
-
...metadata,
|
2916
|
-
reason: "unknown"
|
2917
|
-
}
|
2918
|
-
);
|
2880
|
+
const lastLog = logs[logs.length - 1];
|
2881
|
+
const lastButOneLog = logs[logs.length - 2];
|
2882
|
+
switch (reasonHex) {
|
2883
|
+
case FAILED_REQUIRE_SIGNAL: {
|
2884
|
+
reason = "require";
|
2885
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
2886
|
+
break;
|
2919
2887
|
}
|
2888
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
2889
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2890
|
+
reason = "assert_eq";
|
2891
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
2892
|
+
break;
|
2893
|
+
}
|
2894
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
2895
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2896
|
+
reason = "assert_ne";
|
2897
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
2898
|
+
break;
|
2899
|
+
}
|
2900
|
+
case FAILED_ASSERT_SIGNAL:
|
2901
|
+
reason = "assert";
|
2902
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
2903
|
+
break;
|
2904
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
2905
|
+
reason = "MissingOutputVariable";
|
2906
|
+
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2907
|
+
break;
|
2908
|
+
default:
|
2909
|
+
reason = `revert_with_log`;
|
2910
|
+
errorMessage = `The transaction reverted because a "revert_with_log" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
2911
|
+
break;
|
2912
|
+
}
|
2913
|
+
return new FuelError9(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
2914
|
+
...metadata,
|
2915
|
+
reason
|
2916
|
+
});
|
2917
|
+
}, "assembleSignalErrorMessage");
|
2918
|
+
function buildAbiErrorMessage(abiError, logs, metadata, reason) {
|
2919
|
+
const { pos, msg } = abiError;
|
2920
|
+
let errorMessage = "";
|
2921
|
+
const positionMessage = pos ? `
|
2922
|
+
|
2923
|
+
This error originated at ${JSON.stringify(pos, null, 2)}` : "";
|
2924
|
+
if (msg) {
|
2925
|
+
errorMessage = `A sway "panic" expression was invoked with the message: "${msg}".${positionMessage}`;
|
2926
|
+
} else {
|
2927
|
+
const value = logs[logs.length - 1];
|
2928
|
+
errorMessage = `A sway "panic" expression was invoked with the value: ${JSON.stringify(value)}.${positionMessage}`;
|
2920
2929
|
}
|
2921
2930
|
return new FuelError9(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
2922
2931
|
...metadata,
|
2923
2932
|
reason
|
2924
2933
|
});
|
2934
|
+
}
|
2935
|
+
__name(buildAbiErrorMessage, "buildAbiErrorMessage");
|
2936
|
+
function findErrorInAbis(statusReason, abis = []) {
|
2937
|
+
for (const abi of abis) {
|
2938
|
+
if (abi.errorCodes?.[statusReason]) {
|
2939
|
+
return abi.errorCodes[statusReason];
|
2940
|
+
}
|
2941
|
+
}
|
2942
|
+
return void 0;
|
2943
|
+
}
|
2944
|
+
__name(findErrorInAbis, "findErrorInAbis");
|
2945
|
+
var assembleRevertError = /* @__PURE__ */ __name((_receipts, logs, metadata, statusReason, abis) => {
|
2946
|
+
const match = statusReason.match(/Revert\((\d+)\)/);
|
2947
|
+
const reason = match?.[1] ?? statusReason;
|
2948
|
+
const reasonHex = bn7(reason).toHex();
|
2949
|
+
if (Object.values(SwaySignalErrors).includes(reasonHex)) {
|
2950
|
+
return assembleSignalErrorMessage(reasonHex, logs, metadata);
|
2951
|
+
}
|
2952
|
+
let abiError;
|
2953
|
+
if (abis) {
|
2954
|
+
const abisArr = [abis.main, ...Object.values(abis.otherContractsAbis)];
|
2955
|
+
abiError = findErrorInAbis(reason, abisArr);
|
2956
|
+
}
|
2957
|
+
if (abiError) {
|
2958
|
+
return buildAbiErrorMessage(abiError, logs, metadata, reason);
|
2959
|
+
}
|
2960
|
+
const errorMessage = `The transaction reverted with reason: ${reason}.`;
|
2961
|
+
return new FuelError9(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
2962
|
+
...metadata,
|
2963
|
+
reason
|
2964
|
+
});
|
2925
2965
|
}, "assembleRevertError");
|
2926
2966
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
2927
|
-
const { receipts, statusReason, logs, groupedLogs } = params;
|
2967
|
+
const { receipts, statusReason, logs, groupedLogs, abis } = params;
|
2928
2968
|
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2929
2969
|
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
2930
2970
|
const metadata = {
|
@@ -2938,7 +2978,7 @@ var extractTxError = /* @__PURE__ */ __name((params) => {
|
|
2938
2978
|
if (isPanic) {
|
2939
2979
|
return assemblePanicError(statusReason, metadata);
|
2940
2980
|
}
|
2941
|
-
return assembleRevertError(receipts, logs, metadata);
|
2981
|
+
return assembleRevertError(receipts, logs, metadata, statusReason, abis);
|
2942
2982
|
}, "extractTxError");
|
2943
2983
|
|
2944
2984
|
// src/providers/utils/merge-quantities.ts
|
@@ -4484,12 +4524,12 @@ var ResourceCache = class {
|
|
4484
4524
|
// src/providers/transaction-response/transaction-response.ts
|
4485
4525
|
import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
|
4486
4526
|
import { bn as bn17 } from "@fuel-ts/math";
|
4487
|
-
import { TransactionCoder as
|
4488
|
-
import { arrayify as
|
4527
|
+
import { TransactionCoder as TransactionCoder6, TxPointerCoder } from "@fuel-ts/transactions";
|
4528
|
+
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
4489
4529
|
|
4490
4530
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
4491
4531
|
import { bn as bn16 } from "@fuel-ts/math";
|
4492
|
-
import { PolicyType as PolicyType3, TransactionCoder as
|
4532
|
+
import { PolicyType as PolicyType3, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
4493
4533
|
import { DateTime, hexlify as hexlify18 } from "@fuel-ts/utils";
|
4494
4534
|
|
4495
4535
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
@@ -4561,8 +4601,47 @@ var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
|
4561
4601
|
// src/providers/transaction-summary/operations.ts
|
4562
4602
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
4563
4603
|
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4564
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
4565
|
-
import { ReceiptType as ReceiptType5, TransactionType as TransactionType10 } from "@fuel-ts/transactions";
|
4604
|
+
import { bn as bn14, toBytes as toBytes2 } from "@fuel-ts/math";
|
4605
|
+
import { ReceiptType as ReceiptType5, TransactionCoder as TransactionCoder4, TransactionType as TransactionType10 } from "@fuel-ts/transactions";
|
4606
|
+
import { arrayify as arrayify12, concat as concat4 } from "@fuel-ts/utils";
|
4607
|
+
|
4608
|
+
// src/providers/transaction-summary/call.ts
|
4609
|
+
import { StdStringCoder } from "@fuel-ts/abi-coder";
|
4610
|
+
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
4611
|
+
var getFunctionCall = /* @__PURE__ */ __name(({
|
4612
|
+
abi,
|
4613
|
+
receipt,
|
4614
|
+
offset,
|
4615
|
+
scriptData
|
4616
|
+
}) => {
|
4617
|
+
const [functionSelector, argumentsOffset] = new StdStringCoder().decode(scriptData, offset);
|
4618
|
+
const abiInterface = new Interface2(abi);
|
4619
|
+
const functionFragment = abiInterface.getFunction(functionSelector);
|
4620
|
+
const inputs = functionFragment.jsonFn.inputs;
|
4621
|
+
let argumentsProvided;
|
4622
|
+
if (inputs.length) {
|
4623
|
+
const functionArgsBytes = scriptData.slice(argumentsOffset);
|
4624
|
+
const decodedArguments = functionFragment.decodeArguments(functionArgsBytes);
|
4625
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
4626
|
+
const value = decodedArguments?.[index];
|
4627
|
+
const name = input.name;
|
4628
|
+
if (name) {
|
4629
|
+
return {
|
4630
|
+
...prev,
|
4631
|
+
// reparse to remove bn
|
4632
|
+
[name]: JSON.parse(JSON.stringify(value))
|
4633
|
+
};
|
4634
|
+
}
|
4635
|
+
return prev;
|
4636
|
+
}, {});
|
4637
|
+
}
|
4638
|
+
return {
|
4639
|
+
functionSignature: functionFragment.signature,
|
4640
|
+
functionName: functionFragment.name,
|
4641
|
+
argumentsProvided,
|
4642
|
+
...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
|
4643
|
+
};
|
4644
|
+
}, "getFunctionCall");
|
4566
4645
|
|
4567
4646
|
// src/providers/transaction-summary/input.ts
|
4568
4647
|
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
@@ -4846,12 +4925,45 @@ function getWithdrawFromFuelOperations({
|
|
4846
4925
|
return withdrawFromFuelOperations;
|
4847
4926
|
}
|
4848
4927
|
__name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
|
4849
|
-
function
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4928
|
+
function findBytesSegmentIndex(whole, segment) {
|
4929
|
+
for (let i = 0; i <= whole.length - segment.length; i++) {
|
4930
|
+
let match = true;
|
4931
|
+
for (let j = 0; j < segment.length; j++) {
|
4932
|
+
if (whole[i + j] !== segment[j]) {
|
4933
|
+
match = false;
|
4934
|
+
break;
|
4935
|
+
}
|
4936
|
+
}
|
4937
|
+
if (match) {
|
4938
|
+
return i;
|
4939
|
+
}
|
4853
4940
|
}
|
4854
|
-
return
|
4941
|
+
return -1;
|
4942
|
+
}
|
4943
|
+
__name(findBytesSegmentIndex, "findBytesSegmentIndex");
|
4944
|
+
function getContractCalls(contractInput, abiMap, receipt, scriptData) {
|
4945
|
+
const calls = [];
|
4946
|
+
const abi = abiMap?.[contractInput.contractID];
|
4947
|
+
if (!abi || !scriptData) {
|
4948
|
+
return calls;
|
4949
|
+
}
|
4950
|
+
const bytesSegment = concat4([
|
4951
|
+
arrayify12(receipt.to),
|
4952
|
+
// Contract ID (32 bytes)
|
4953
|
+
toBytes2(receipt.param1.toHex(), 8),
|
4954
|
+
// Function selector offset (8 bytes)
|
4955
|
+
toBytes2(receipt.param2.toHex(), 8)
|
4956
|
+
// Function args offset (8 bytes)
|
4957
|
+
]);
|
4958
|
+
const segmentIndex = findBytesSegmentIndex(scriptData, bytesSegment);
|
4959
|
+
const canDecodeFunctionCall = segmentIndex !== -1;
|
4960
|
+
if (!canDecodeFunctionCall) {
|
4961
|
+
return calls;
|
4962
|
+
}
|
4963
|
+
const offset = segmentIndex + bytesSegment.length;
|
4964
|
+
const call = getFunctionCall({ abi, receipt, offset, scriptData });
|
4965
|
+
calls.push(call);
|
4966
|
+
return calls;
|
4855
4967
|
}
|
4856
4968
|
__name(getContractCalls, "getContractCalls");
|
4857
4969
|
function getAssetsSent(receipt) {
|
@@ -4863,14 +4975,14 @@ function getAssetsSent(receipt) {
|
|
4863
4975
|
];
|
4864
4976
|
}
|
4865
4977
|
__name(getAssetsSent, "getAssetsSent");
|
4866
|
-
function processCallReceipt(receipt, contractInput, inputs, abiMap,
|
4978
|
+
function processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId) {
|
4867
4979
|
const assetId = receipt.assetId === ZeroBytes329 ? baseAssetId : receipt.assetId;
|
4868
4980
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
4869
4981
|
if (!input) {
|
4870
4982
|
return [];
|
4871
4983
|
}
|
4872
4984
|
const inputAddress = getInputAccountAddress(input);
|
4873
|
-
const calls = getContractCalls(contractInput, abiMap, receipt,
|
4985
|
+
const calls = getContractCalls(contractInput, abiMap, receipt, scriptData);
|
4874
4986
|
return [
|
4875
4987
|
{
|
4876
4988
|
name: "Contract call" /* contractCall */,
|
@@ -4895,7 +5007,6 @@ function getContractCallOperations({
|
|
4895
5007
|
receipts,
|
4896
5008
|
abiMap,
|
4897
5009
|
rawPayload,
|
4898
|
-
maxInputs,
|
4899
5010
|
baseAssetId
|
4900
5011
|
}) {
|
4901
5012
|
const contractCallReceipts = getReceiptsCall(receipts);
|
@@ -4905,16 +5016,15 @@ function getContractCallOperations({
|
|
4905
5016
|
if (!contractInput) {
|
4906
5017
|
return [];
|
4907
5018
|
}
|
5019
|
+
let scriptData;
|
5020
|
+
if (rawPayload) {
|
5021
|
+
const [transaction] = new TransactionCoder4().decode(arrayify12(rawPayload), 0);
|
5022
|
+
if (transaction.type === TransactionType10.Script) {
|
5023
|
+
scriptData = arrayify12(transaction.scriptData);
|
5024
|
+
}
|
5025
|
+
}
|
4908
5026
|
return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
|
4909
|
-
(receipt) => processCallReceipt(
|
4910
|
-
receipt,
|
4911
|
-
contractInput,
|
4912
|
-
inputs,
|
4913
|
-
abiMap,
|
4914
|
-
rawPayload,
|
4915
|
-
maxInputs,
|
4916
|
-
baseAssetId
|
4917
|
-
)
|
5027
|
+
(receipt) => processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId)
|
4918
5028
|
);
|
4919
5029
|
});
|
4920
5030
|
}
|
@@ -5330,7 +5440,7 @@ function assemblePreConfirmationTransactionSummary(params) {
|
|
5330
5440
|
type = getTransactionTypeName(transaction.type);
|
5331
5441
|
tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
5332
5442
|
if (receipts) {
|
5333
|
-
const rawPayload = hexlify18(new
|
5443
|
+
const rawPayload = hexlify18(new TransactionCoder5().encode(transaction));
|
5334
5444
|
operations = getOperations({
|
5335
5445
|
transactionType: transaction.type,
|
5336
5446
|
inputs: transaction.inputs || [],
|
@@ -5376,7 +5486,7 @@ function assemblePreConfirmationTransactionSummary(params) {
|
|
5376
5486
|
__name(assemblePreConfirmationTransactionSummary, "assemblePreConfirmationTransactionSummary");
|
5377
5487
|
|
5378
5488
|
// src/providers/transaction-response/getAllDecodedLogs.ts
|
5379
|
-
import { Interface as
|
5489
|
+
import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
|
5380
5490
|
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
5381
5491
|
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
5382
5492
|
function getAllDecodedLogs(opts) {
|
@@ -5396,7 +5506,7 @@ function getAllDecodedLogs(opts) {
|
|
5396
5506
|
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
5397
5507
|
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
5398
5508
|
if (isDecodable) {
|
5399
|
-
const interfaceToUse = isLogFromMainAbi ? new
|
5509
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface3(mainAbi) : new Interface3(externalAbis[receipt.id]);
|
5400
5510
|
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
5401
5511
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
5402
5512
|
logs.push(decodedLog);
|
@@ -5496,8 +5606,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
5496
5606
|
}
|
5497
5607
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
5498
5608
|
const { rawPayload } = gqlTransaction;
|
5499
|
-
const bytes =
|
5500
|
-
const [tx] = new
|
5609
|
+
const bytes = arrayify13(rawPayload);
|
5610
|
+
const [tx] = new TransactionCoder6().decode(bytes, 0);
|
5501
5611
|
return {
|
5502
5612
|
tx,
|
5503
5613
|
bytes
|
@@ -5684,6 +5794,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
5684
5794
|
...transactionSummary
|
5685
5795
|
};
|
5686
5796
|
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
5797
|
+
let abis;
|
5687
5798
|
if (this.abis) {
|
5688
5799
|
({ logs, groupedLogs } = getAllDecodedLogs({
|
5689
5800
|
receipts: transactionSummary.receipts,
|
@@ -5692,6 +5803,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
5692
5803
|
}));
|
5693
5804
|
transactionResult.logs = logs;
|
5694
5805
|
transactionResult.groupedLogs = groupedLogs;
|
5806
|
+
abis = this.abis;
|
5695
5807
|
}
|
5696
5808
|
const { receipts } = transactionResult;
|
5697
5809
|
const status = this.getTransactionStatus();
|
@@ -5701,7 +5813,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
5701
5813
|
receipts,
|
5702
5814
|
statusReason: reason,
|
5703
5815
|
logs,
|
5704
|
-
groupedLogs
|
5816
|
+
groupedLogs,
|
5817
|
+
abis
|
5705
5818
|
});
|
5706
5819
|
}
|
5707
5820
|
return transactionResult;
|
@@ -5763,7 +5876,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
5763
5876
|
};
|
5764
5877
|
|
5765
5878
|
// src/providers/transaction-response/getDecodedLogs.ts
|
5766
|
-
import { Interface as
|
5879
|
+
import { Interface as Interface4, BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5767
5880
|
import { ZeroBytes32 as ZeroBytes3211 } from "@fuel-ts/address/configs";
|
5768
5881
|
import { ReceiptType as ReceiptType8 } from "@fuel-ts/transactions";
|
5769
5882
|
|
@@ -7143,7 +7256,7 @@ var Provider = class _Provider {
|
|
7143
7256
|
},
|
7144
7257
|
transactionIds: block.transactions.map((tx) => tx.id),
|
7145
7258
|
transactions: block.transactions.map(
|
7146
|
-
(tx) => new
|
7259
|
+
(tx) => new TransactionCoder7().decode(arrayify14(tx.rawPayload), 0)?.[0]
|
7147
7260
|
)
|
7148
7261
|
};
|
7149
7262
|
}
|
@@ -7159,8 +7272,8 @@ var Provider = class _Provider {
|
|
7159
7272
|
return null;
|
7160
7273
|
}
|
7161
7274
|
try {
|
7162
|
-
return new
|
7163
|
-
|
7275
|
+
return new TransactionCoder7().decode(
|
7276
|
+
arrayify14(transaction.rawPayload),
|
7164
7277
|
0
|
7165
7278
|
)?.[0];
|
7166
7279
|
} catch (error) {
|
@@ -7185,10 +7298,10 @@ var Provider = class _Provider {
|
|
7185
7298
|
paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
|
7186
7299
|
})
|
7187
7300
|
});
|
7188
|
-
const coder = new
|
7301
|
+
const coder = new TransactionCoder7();
|
7189
7302
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
7190
7303
|
try {
|
7191
|
-
return coder.decode(
|
7304
|
+
return coder.decode(arrayify14(rawPayload), 0)[0];
|
7192
7305
|
} catch (error) {
|
7193
7306
|
if (error instanceof FuelError20 && error.code === ErrorCode17.UNSUPPORTED_TRANSACTION_TYPE) {
|
7194
7307
|
console.warn("Unsupported transaction type encountered");
|
@@ -7559,18 +7672,21 @@ var Provider = class _Provider {
|
|
7559
7672
|
extractDryRunError(transactionRequest, receipts, reason) {
|
7560
7673
|
let logs = [];
|
7561
7674
|
let groupedLogs = {};
|
7675
|
+
let abis;
|
7562
7676
|
if (transactionRequest.type === TransactionType11.Script && transactionRequest.abis) {
|
7563
7677
|
({ logs, groupedLogs } = getAllDecodedLogs({
|
7564
7678
|
receipts,
|
7565
7679
|
mainAbi: transactionRequest.abis.main,
|
7566
7680
|
externalAbis: transactionRequest.abis.otherContractsAbis
|
7567
7681
|
}));
|
7682
|
+
abis = transactionRequest.abis;
|
7568
7683
|
}
|
7569
7684
|
return extractTxError({
|
7570
7685
|
logs,
|
7571
7686
|
groupedLogs,
|
7572
7687
|
receipts,
|
7573
|
-
statusReason: reason
|
7688
|
+
statusReason: reason,
|
7689
|
+
abis
|
7574
7690
|
});
|
7575
7691
|
}
|
7576
7692
|
/**
|
@@ -7641,13 +7757,13 @@ var Provider = class _Provider {
|
|
7641
7757
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
7642
7758
|
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
7643
7759
|
import { bn as bn19 } from "@fuel-ts/math";
|
7644
|
-
import { TransactionCoder as
|
7645
|
-
import { arrayify as
|
7760
|
+
import { TransactionCoder as TransactionCoder8 } from "@fuel-ts/transactions";
|
7761
|
+
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
7646
7762
|
|
7647
7763
|
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
7648
7764
|
import { bn as bn20 } from "@fuel-ts/math";
|
7649
|
-
import { TransactionCoder as
|
7650
|
-
import { arrayify as
|
7765
|
+
import { TransactionCoder as TransactionCoder9 } from "@fuel-ts/transactions";
|
7766
|
+
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7651
7767
|
|
7652
7768
|
// src/test-utils/test-asset-id.ts
|
7653
7769
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
@@ -7691,7 +7807,7 @@ import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
|
7691
7807
|
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
7692
7808
|
import { bn as bn21 } from "@fuel-ts/math";
|
7693
7809
|
import { InputType as InputType8, OutputType as OutputType9 } from "@fuel-ts/transactions";
|
7694
|
-
import { arrayify as
|
7810
|
+
import { arrayify as arrayify18, hexlify as hexlify21, isDefined as isDefined4 } from "@fuel-ts/utils";
|
7695
7811
|
import { clone as clone9 } from "ramda";
|
7696
7812
|
|
7697
7813
|
// src/types.ts
|
@@ -7704,15 +7820,15 @@ var AbstractAccount = class {
|
|
7704
7820
|
// src/utils/formatTransferToContractScriptData.ts
|
7705
7821
|
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder3, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
7706
7822
|
import { Address as Address4 } from "@fuel-ts/address";
|
7707
|
-
import { arrayify as
|
7823
|
+
import { arrayify as arrayify17, concat as concat5 } from "@fuel-ts/utils";
|
7708
7824
|
import * as asm from "@fuels/vm-asm";
|
7709
7825
|
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
7710
7826
|
const numberCoder = new BigNumberCoder3("u64");
|
7711
7827
|
return transferParams.reduce((acc, transferParam) => {
|
7712
7828
|
const { assetId, amount, contractId } = transferParam;
|
7713
7829
|
const encoded = numberCoder.encode(amount);
|
7714
|
-
const scriptData =
|
7715
|
-
return
|
7830
|
+
const scriptData = concat5([new Address4(contractId).toBytes(), encoded, arrayify17(assetId)]);
|
7831
|
+
return concat5([acc, scriptData]);
|
7716
7832
|
}, new Uint8Array());
|
7717
7833
|
}, "formatTransferToContractScriptData");
|
7718
7834
|
var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
|
@@ -7721,7 +7837,7 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
|
|
7721
7837
|
let script = new Uint8Array();
|
7722
7838
|
transferParams.forEach((_, i) => {
|
7723
7839
|
const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
|
7724
|
-
script =
|
7840
|
+
script = concat5([
|
7725
7841
|
script,
|
7726
7842
|
// Load ScriptData into register 0x10.
|
7727
7843
|
asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
|
@@ -7737,7 +7853,7 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
|
|
7737
7853
|
asm.tr(17, 19, 20).to_bytes()
|
7738
7854
|
]);
|
7739
7855
|
});
|
7740
|
-
script =
|
7856
|
+
script = concat5([script, asm.ret(1).to_bytes()]);
|
7741
7857
|
return { script, scriptData };
|
7742
7858
|
}, "assembleTransferToContractScript");
|
7743
7859
|
|
@@ -8125,14 +8241,14 @@ var Account = class extends AbstractAccount {
|
|
8125
8241
|
*/
|
8126
8242
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
8127
8243
|
const recipientAddress = new Address5(recipient);
|
8128
|
-
const recipientDataArray =
|
8244
|
+
const recipientDataArray = arrayify18(
|
8129
8245
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
8130
8246
|
);
|
8131
|
-
const amountDataArray =
|
8247
|
+
const amountDataArray = arrayify18(
|
8132
8248
|
"0x".concat(bn21(amount).toHex().substring(2).padStart(16, "0"))
|
8133
8249
|
);
|
8134
8250
|
const script = new Uint8Array([
|
8135
|
-
...
|
8251
|
+
...arrayify18(withdrawScript.bytes),
|
8136
8252
|
...recipientDataArray,
|
8137
8253
|
...amountDataArray
|
8138
8254
|
]);
|
@@ -8774,14 +8890,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
8774
8890
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
8775
8891
|
import { ErrorCode as ErrorCode23, FuelError as FuelError26 } from "@fuel-ts/errors";
|
8776
8892
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
8777
|
-
import { bn as bn22, toBytes as
|
8778
|
-
import { arrayify as
|
8893
|
+
import { bn as bn22, toBytes as toBytes3, toHex } from "@fuel-ts/math";
|
8894
|
+
import { arrayify as arrayify21, hexlify as hexlify25, concat as concat7, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
8779
8895
|
|
8780
8896
|
// src/mnemonic/mnemonic.ts
|
8781
8897
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
8782
8898
|
import { ErrorCode as ErrorCode22, FuelError as FuelError25 } from "@fuel-ts/errors";
|
8783
8899
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
8784
|
-
import { arrayify as
|
8900
|
+
import { arrayify as arrayify20, hexlify as hexlify24, concat as concat6, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
8785
8901
|
|
8786
8902
|
// src/wordlists/words/english.ts
|
8787
8903
|
var english = [
|
@@ -10838,7 +10954,7 @@ var english = [
|
|
10838
10954
|
// src/mnemonic/utils.ts
|
10839
10955
|
import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
|
10840
10956
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
10841
|
-
import { arrayify as
|
10957
|
+
import { arrayify as arrayify19 } from "@fuel-ts/utils";
|
10842
10958
|
function getLowerMask(bits) {
|
10843
10959
|
return (1 << bits) - 1;
|
10844
10960
|
}
|
@@ -10877,7 +10993,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
10877
10993
|
}
|
10878
10994
|
}
|
10879
10995
|
const checksumBits = entropy.length / 4;
|
10880
|
-
const checksum =
|
10996
|
+
const checksum = arrayify19(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
10881
10997
|
indices[indices.length - 1] <<= checksumBits;
|
10882
10998
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
10883
10999
|
return indices;
|
@@ -10885,7 +11001,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
10885
11001
|
__name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
|
10886
11002
|
function mnemonicWordsToEntropy(words, wordlist) {
|
10887
11003
|
const size = Math.ceil(11 * words.length / 8);
|
10888
|
-
const entropy =
|
11004
|
+
const entropy = arrayify19(new Uint8Array(size));
|
10889
11005
|
let offset = 0;
|
10890
11006
|
for (let i = 0; i < words.length; i += 1) {
|
10891
11007
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -10905,7 +11021,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
10905
11021
|
const entropyBits = 32 * words.length / 3;
|
10906
11022
|
const checksumBits = words.length / 3;
|
10907
11023
|
const checksumMask = getUpperMask(checksumBits);
|
10908
|
-
const checksum =
|
11024
|
+
const checksum = arrayify19(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
10909
11025
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
10910
11026
|
throw new FuelError24(
|
10911
11027
|
ErrorCode21.INVALID_CHECKSUM,
|
@@ -10995,7 +11111,7 @@ var Mnemonic = class _Mnemonic {
|
|
10995
11111
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
10996
11112
|
*/
|
10997
11113
|
static entropyToMnemonic(entropy, wordlist = english) {
|
10998
|
-
const entropyBytes =
|
11114
|
+
const entropyBytes = arrayify20(entropy);
|
10999
11115
|
assertWordList(wordlist);
|
11000
11116
|
assertEntropy(entropyBytes);
|
11001
11117
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -11064,14 +11180,14 @@ var Mnemonic = class _Mnemonic {
|
|
11064
11180
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
11065
11181
|
*/
|
11066
11182
|
static masterKeysFromSeed(seed) {
|
11067
|
-
const seedArray =
|
11183
|
+
const seedArray = arrayify20(seed);
|
11068
11184
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
11069
11185
|
throw new FuelError25(
|
11070
11186
|
ErrorCode22.INVALID_SEED,
|
11071
11187
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
11072
11188
|
);
|
11073
11189
|
}
|
11074
|
-
return
|
11190
|
+
return arrayify20(computeHmac("sha512", MasterSecret, seedArray));
|
11075
11191
|
}
|
11076
11192
|
/**
|
11077
11193
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -11082,22 +11198,22 @@ var Mnemonic = class _Mnemonic {
|
|
11082
11198
|
*/
|
11083
11199
|
static seedToExtendedKey(seed, testnet = false) {
|
11084
11200
|
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
11085
|
-
const prefix =
|
11201
|
+
const prefix = arrayify20(testnet ? TestnetPRV : MainnetPRV);
|
11086
11202
|
const depth = "0x00";
|
11087
11203
|
const fingerprint = "0x00000000";
|
11088
11204
|
const index = "0x00000000";
|
11089
11205
|
const chainCode = masterKey.slice(32);
|
11090
11206
|
const privateKey = masterKey.slice(0, 32);
|
11091
|
-
const extendedKey =
|
11207
|
+
const extendedKey = concat6([
|
11092
11208
|
prefix,
|
11093
11209
|
depth,
|
11094
11210
|
fingerprint,
|
11095
11211
|
index,
|
11096
11212
|
chainCode,
|
11097
|
-
|
11213
|
+
concat6(["0x00", privateKey])
|
11098
11214
|
]);
|
11099
11215
|
const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
|
11100
|
-
return encodeBase58(
|
11216
|
+
return encodeBase58(concat6([extendedKey, checksum]));
|
11101
11217
|
}
|
11102
11218
|
/**
|
11103
11219
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -11112,7 +11228,7 @@ var Mnemonic = class _Mnemonic {
|
|
11112
11228
|
* @returns A randomly generated mnemonic
|
11113
11229
|
*/
|
11114
11230
|
static generate(size = 32, extraEntropy = "") {
|
11115
|
-
const entropy = extraEntropy ? sha2563(
|
11231
|
+
const entropy = extraEntropy ? sha2563(concat6([randomBytes7(size), arrayify20(extraEntropy)])) : randomBytes7(size);
|
11116
11232
|
return _Mnemonic.entropyToMnemonic(entropy);
|
11117
11233
|
}
|
11118
11234
|
};
|
@@ -11125,7 +11241,7 @@ var MainnetPUB = hexlify25("0x0488b21e");
|
|
11125
11241
|
var TestnetPRV2 = hexlify25("0x04358394");
|
11126
11242
|
var TestnetPUB = hexlify25("0x043587cf");
|
11127
11243
|
function base58check(data) {
|
11128
|
-
return encodeBase582(
|
11244
|
+
return encodeBase582(concat7([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
11129
11245
|
}
|
11130
11246
|
__name(base58check, "base58check");
|
11131
11247
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
@@ -11205,9 +11321,9 @@ var HDWallet = class _HDWallet {
|
|
11205
11321
|
* @returns A new instance of HDWallet on the derived index
|
11206
11322
|
*/
|
11207
11323
|
deriveIndex(index) {
|
11208
|
-
const privateKey = this.privateKey &&
|
11209
|
-
const publicKey =
|
11210
|
-
const chainCode =
|
11324
|
+
const privateKey = this.privateKey && arrayify21(this.privateKey);
|
11325
|
+
const publicKey = arrayify21(this.publicKey);
|
11326
|
+
const chainCode = arrayify21(this.chainCode);
|
11211
11327
|
const data = new Uint8Array(37);
|
11212
11328
|
if (index & HARDENED_INDEX) {
|
11213
11329
|
if (!privateKey) {
|
@@ -11218,10 +11334,10 @@ var HDWallet = class _HDWallet {
|
|
11218
11334
|
}
|
11219
11335
|
data.set(privateKey, 1);
|
11220
11336
|
} else {
|
11221
|
-
data.set(
|
11337
|
+
data.set(arrayify21(this.publicKey));
|
11222
11338
|
}
|
11223
|
-
data.set(
|
11224
|
-
const bytes =
|
11339
|
+
data.set(toBytes3(index, 4), 33);
|
11340
|
+
const bytes = arrayify21(computeHmac2("sha512", chainCode, data));
|
11225
11341
|
const IL = bytes.slice(0, 32);
|
11226
11342
|
const IR = bytes.slice(32);
|
11227
11343
|
if (privateKey) {
|
@@ -11274,8 +11390,8 @@ var HDWallet = class _HDWallet {
|
|
11274
11390
|
const parentFingerprint = this.parentFingerprint;
|
11275
11391
|
const index = toHex(this.index, 4);
|
11276
11392
|
const chainCode = this.chainCode;
|
11277
|
-
const key = this.privateKey != null && !isPublic ?
|
11278
|
-
const extendedKey =
|
11393
|
+
const key = this.privateKey != null && !isPublic ? concat7(["0x00", this.privateKey]) : this.publicKey;
|
11394
|
+
const extendedKey = arrayify21(concat7([prefix, depth, parentFingerprint, index, chainCode, key]));
|
11279
11395
|
return base58check(extendedKey);
|
11280
11396
|
}
|
11281
11397
|
/**
|
@@ -11287,13 +11403,13 @@ var HDWallet = class _HDWallet {
|
|
11287
11403
|
static fromSeed(seed) {
|
11288
11404
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
11289
11405
|
return new _HDWallet({
|
11290
|
-
chainCode:
|
11291
|
-
privateKey:
|
11406
|
+
chainCode: arrayify21(masterKey.slice(32)),
|
11407
|
+
privateKey: arrayify21(masterKey.slice(0, 32))
|
11292
11408
|
});
|
11293
11409
|
}
|
11294
11410
|
static fromExtendedKey(extendedKey) {
|
11295
|
-
const decoded = hexlify25(
|
11296
|
-
const bytes =
|
11411
|
+
const decoded = hexlify25(toBytes3(decodeBase58(extendedKey)));
|
11412
|
+
const bytes = arrayify21(decoded);
|
11297
11413
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
11298
11414
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
11299
11415
|
throw new FuelError26(ErrorCode23.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|