@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/index.global.js
CHANGED
@@ -17990,8 +17990,8 @@
|
|
17990
17990
|
function getBuiltinVersions() {
|
17991
17991
|
return {
|
17992
17992
|
FUEL_CORE: "0.43.1",
|
17993
|
-
FORC: "0.68.
|
17994
|
-
FUELS: "0.101.
|
17993
|
+
FORC: "0.68.7",
|
17994
|
+
FUELS: "0.101.2"
|
17995
17995
|
};
|
17996
17996
|
}
|
17997
17997
|
__name(getBuiltinVersions, "getBuiltinVersions");
|
@@ -21301,7 +21301,8 @@ If you are attempting to transform a hex value, please make sure it is being pas
|
|
21301
21301
|
functions,
|
21302
21302
|
loggedTypes,
|
21303
21303
|
messagesTypes: abi.messagesTypes,
|
21304
|
-
configurables
|
21304
|
+
configurables,
|
21305
|
+
errorCodes: abi.errorCodes
|
21305
21306
|
};
|
21306
21307
|
return transpiled;
|
21307
21308
|
}
|
@@ -28831,6 +28832,7 @@ ${incompatibleNodeVersionMessage}`,
|
|
28831
28832
|
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
28832
28833
|
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
28833
28834
|
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
28835
|
+
var REVERT_WITH_LOG_SIGNAL = "0xffffffffffff0006";
|
28834
28836
|
var PANIC_REASONS = [
|
28835
28837
|
"ArithmeticError",
|
28836
28838
|
"ArithmeticOverflow",
|
@@ -28899,6 +28901,14 @@ ${incompatibleNodeVersionMessage}`,
|
|
28899
28901
|
"WitnessNotFound"
|
28900
28902
|
];
|
28901
28903
|
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
28904
|
+
var SwaySignalErrors = {
|
28905
|
+
FAILED_REQUIRE_SIGNAL,
|
28906
|
+
FAILED_TRANSFER_TO_ADDRESS_SIGNAL,
|
28907
|
+
FAILED_ASSERT_EQ_SIGNAL,
|
28908
|
+
FAILED_ASSERT_SIGNAL,
|
28909
|
+
FAILED_ASSERT_NE_SIGNAL,
|
28910
|
+
REVERT_WITH_LOG_SIGNAL
|
28911
|
+
};
|
28902
28912
|
|
28903
28913
|
// src/providers/utils/serialization.ts
|
28904
28914
|
var deserializeChain = /* @__PURE__ */ __name((chain) => {
|
@@ -29648,58 +29658,97 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
29648
29658
|
});
|
29649
29659
|
}, "assemblePanicError");
|
29650
29660
|
var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
|
29651
|
-
var
|
29661
|
+
var assembleSignalErrorMessage = /* @__PURE__ */ __name((reasonHex, logs, metadata) => {
|
29652
29662
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
29653
|
-
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
29654
29663
|
let reason = "";
|
29655
|
-
|
29656
|
-
|
29657
|
-
|
29658
|
-
|
29659
|
-
|
29660
|
-
|
29661
|
-
|
29662
|
-
|
29663
|
-
|
29664
|
-
}
|
29665
|
-
|
29666
|
-
|
29667
|
-
|
29668
|
-
|
29669
|
-
|
29670
|
-
}
|
29671
|
-
|
29672
|
-
|
29673
|
-
|
29674
|
-
|
29675
|
-
|
29676
|
-
|
29677
|
-
|
29678
|
-
|
29679
|
-
|
29680
|
-
|
29681
|
-
|
29682
|
-
|
29683
|
-
|
29684
|
-
|
29685
|
-
|
29686
|
-
|
29687
|
-
|
29688
|
-
|
29689
|
-
|
29690
|
-
|
29691
|
-
|
29692
|
-
|
29693
|
-
|
29664
|
+
const lastLog = logs[logs.length - 1];
|
29665
|
+
const lastButOneLog = logs[logs.length - 2];
|
29666
|
+
switch (reasonHex) {
|
29667
|
+
case FAILED_REQUIRE_SIGNAL: {
|
29668
|
+
reason = "require";
|
29669
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
29670
|
+
break;
|
29671
|
+
}
|
29672
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
29673
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
29674
|
+
reason = "assert_eq";
|
29675
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
29676
|
+
break;
|
29677
|
+
}
|
29678
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
29679
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
29680
|
+
reason = "assert_ne";
|
29681
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
29682
|
+
break;
|
29683
|
+
}
|
29684
|
+
case FAILED_ASSERT_SIGNAL:
|
29685
|
+
reason = "assert";
|
29686
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
29687
|
+
break;
|
29688
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
29689
|
+
reason = "MissingOutputVariable";
|
29690
|
+
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
29691
|
+
break;
|
29692
|
+
default:
|
29693
|
+
reason = `revert_with_log`;
|
29694
|
+
errorMessage = `The transaction reverted because a "revert_with_log" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
29695
|
+
break;
|
29696
|
+
}
|
29697
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
29698
|
+
...metadata,
|
29699
|
+
reason
|
29700
|
+
});
|
29701
|
+
}, "assembleSignalErrorMessage");
|
29702
|
+
function buildAbiErrorMessage(abiError, logs, metadata, reason) {
|
29703
|
+
const { pos, msg } = abiError;
|
29704
|
+
let errorMessage = "";
|
29705
|
+
const positionMessage = pos ? `
|
29706
|
+
|
29707
|
+
This error originated at ${JSON.stringify(pos, null, 2)}` : "";
|
29708
|
+
if (msg) {
|
29709
|
+
errorMessage = `A sway "panic" expression was invoked with the message: "${msg}".${positionMessage}`;
|
29710
|
+
} else {
|
29711
|
+
const value = logs[logs.length - 1];
|
29712
|
+
errorMessage = `A sway "panic" expression was invoked with the value: ${JSON.stringify(value)}.${positionMessage}`;
|
29713
|
+
}
|
29714
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
29715
|
+
...metadata,
|
29716
|
+
reason
|
29717
|
+
});
|
29718
|
+
}
|
29719
|
+
__name(buildAbiErrorMessage, "buildAbiErrorMessage");
|
29720
|
+
function findErrorInAbis(statusReason, abis = []) {
|
29721
|
+
for (const abi of abis) {
|
29722
|
+
if (abi.errorCodes?.[statusReason]) {
|
29723
|
+
return abi.errorCodes[statusReason];
|
29694
29724
|
}
|
29695
29725
|
}
|
29726
|
+
return void 0;
|
29727
|
+
}
|
29728
|
+
__name(findErrorInAbis, "findErrorInAbis");
|
29729
|
+
var assembleRevertError = /* @__PURE__ */ __name((_receipts, logs, metadata, statusReason, abis) => {
|
29730
|
+
const match = statusReason.match(/Revert\((\d+)\)/);
|
29731
|
+
const reason = match?.[1] ?? statusReason;
|
29732
|
+
const reasonHex = bn(reason).toHex();
|
29733
|
+
if (Object.values(SwaySignalErrors).includes(reasonHex)) {
|
29734
|
+
return assembleSignalErrorMessage(reasonHex, logs, metadata);
|
29735
|
+
}
|
29736
|
+
let abiError;
|
29737
|
+
if (abis) {
|
29738
|
+
const abisArr = [abis.main, ...Object.values(abis.otherContractsAbis)];
|
29739
|
+
abiError = findErrorInAbis(reason, abisArr);
|
29740
|
+
}
|
29741
|
+
if (abiError) {
|
29742
|
+
return buildAbiErrorMessage(abiError, logs, metadata, reason);
|
29743
|
+
}
|
29744
|
+
const errorMessage = `The transaction reverted with reason: ${reason}.`;
|
29696
29745
|
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
29697
29746
|
...metadata,
|
29698
29747
|
reason
|
29699
29748
|
});
|
29700
29749
|
}, "assembleRevertError");
|
29701
29750
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
29702
|
-
const { receipts, statusReason, logs, groupedLogs } = params;
|
29751
|
+
const { receipts, statusReason, logs, groupedLogs, abis } = params;
|
29703
29752
|
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
29704
29753
|
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
29705
29754
|
const metadata = {
|
@@ -29713,7 +29762,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
29713
29762
|
if (isPanic) {
|
29714
29763
|
return assemblePanicError(statusReason, metadata);
|
29715
29764
|
}
|
29716
|
-
return assembleRevertError(receipts, logs, metadata);
|
29765
|
+
return assembleRevertError(receipts, logs, metadata, statusReason, abis);
|
29717
29766
|
}, "extractTxError");
|
29718
29767
|
|
29719
29768
|
// src/providers/utils/merge-quantities.ts
|
@@ -31315,6 +31364,42 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31315
31364
|
return maxFee;
|
31316
31365
|
}, "calculateTXFeeForSummary");
|
31317
31366
|
|
31367
|
+
// src/providers/transaction-summary/call.ts
|
31368
|
+
var getFunctionCall = /* @__PURE__ */ __name(({
|
31369
|
+
abi,
|
31370
|
+
receipt,
|
31371
|
+
offset,
|
31372
|
+
scriptData
|
31373
|
+
}) => {
|
31374
|
+
const [functionSelector, argumentsOffset] = new StdStringCoder().decode(scriptData, offset);
|
31375
|
+
const abiInterface = new Interface(abi);
|
31376
|
+
const functionFragment = abiInterface.getFunction(functionSelector);
|
31377
|
+
const inputs = functionFragment.jsonFn.inputs;
|
31378
|
+
let argumentsProvided;
|
31379
|
+
if (inputs.length) {
|
31380
|
+
const functionArgsBytes = scriptData.slice(argumentsOffset);
|
31381
|
+
const decodedArguments = functionFragment.decodeArguments(functionArgsBytes);
|
31382
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
31383
|
+
const value = decodedArguments?.[index];
|
31384
|
+
const name = input.name;
|
31385
|
+
if (name) {
|
31386
|
+
return {
|
31387
|
+
...prev,
|
31388
|
+
// reparse to remove bn
|
31389
|
+
[name]: JSON.parse(JSON.stringify(value))
|
31390
|
+
};
|
31391
|
+
}
|
31392
|
+
return prev;
|
31393
|
+
}, {});
|
31394
|
+
}
|
31395
|
+
return {
|
31396
|
+
functionSignature: functionFragment.signature,
|
31397
|
+
functionName: functionFragment.name,
|
31398
|
+
argumentsProvided,
|
31399
|
+
...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
|
31400
|
+
};
|
31401
|
+
}, "getFunctionCall");
|
31402
|
+
|
31318
31403
|
// src/providers/transaction-summary/input.ts
|
31319
31404
|
function getInputsByTypes(inputs, types) {
|
31320
31405
|
return inputs.filter((i) => types.includes(i.type));
|
@@ -31644,12 +31729,45 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31644
31729
|
return withdrawFromFuelOperations;
|
31645
31730
|
}
|
31646
31731
|
__name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
|
31647
|
-
function
|
31732
|
+
function findBytesSegmentIndex(whole, segment) {
|
31733
|
+
for (let i = 0; i <= whole.length - segment.length; i++) {
|
31734
|
+
let match = true;
|
31735
|
+
for (let j = 0; j < segment.length; j++) {
|
31736
|
+
if (whole[i + j] !== segment[j]) {
|
31737
|
+
match = false;
|
31738
|
+
break;
|
31739
|
+
}
|
31740
|
+
}
|
31741
|
+
if (match) {
|
31742
|
+
return i;
|
31743
|
+
}
|
31744
|
+
}
|
31745
|
+
return -1;
|
31746
|
+
}
|
31747
|
+
__name(findBytesSegmentIndex, "findBytesSegmentIndex");
|
31748
|
+
function getContractCalls(contractInput, abiMap, receipt, scriptData) {
|
31749
|
+
const calls = [];
|
31648
31750
|
const abi = abiMap?.[contractInput.contractID];
|
31649
|
-
if (!abi) {
|
31650
|
-
return
|
31751
|
+
if (!abi || !scriptData) {
|
31752
|
+
return calls;
|
31753
|
+
}
|
31754
|
+
const bytesSegment = concat([
|
31755
|
+
arrayify(receipt.to),
|
31756
|
+
// Contract ID (32 bytes)
|
31757
|
+
toBytes(receipt.param1.toHex(), 8),
|
31758
|
+
// Function selector offset (8 bytes)
|
31759
|
+
toBytes(receipt.param2.toHex(), 8)
|
31760
|
+
// Function args offset (8 bytes)
|
31761
|
+
]);
|
31762
|
+
const segmentIndex = findBytesSegmentIndex(scriptData, bytesSegment);
|
31763
|
+
const canDecodeFunctionCall = segmentIndex !== -1;
|
31764
|
+
if (!canDecodeFunctionCall) {
|
31765
|
+
return calls;
|
31651
31766
|
}
|
31652
|
-
|
31767
|
+
const offset = segmentIndex + bytesSegment.length;
|
31768
|
+
const call = getFunctionCall({ abi, receipt, offset, scriptData });
|
31769
|
+
calls.push(call);
|
31770
|
+
return calls;
|
31653
31771
|
}
|
31654
31772
|
__name(getContractCalls, "getContractCalls");
|
31655
31773
|
function getAssetsSent(receipt) {
|
@@ -31661,14 +31779,14 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31661
31779
|
];
|
31662
31780
|
}
|
31663
31781
|
__name(getAssetsSent, "getAssetsSent");
|
31664
|
-
function processCallReceipt(receipt, contractInput, inputs, abiMap,
|
31782
|
+
function processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId) {
|
31665
31783
|
const assetId = receipt.assetId === ZeroBytes32 ? baseAssetId : receipt.assetId;
|
31666
31784
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
31667
31785
|
if (!input) {
|
31668
31786
|
return [];
|
31669
31787
|
}
|
31670
31788
|
const inputAddress = getInputAccountAddress(input);
|
31671
|
-
const calls = getContractCalls(contractInput, abiMap, receipt,
|
31789
|
+
const calls = getContractCalls(contractInput, abiMap, receipt, scriptData);
|
31672
31790
|
return [
|
31673
31791
|
{
|
31674
31792
|
name: "Contract call" /* contractCall */,
|
@@ -31693,7 +31811,6 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31693
31811
|
receipts,
|
31694
31812
|
abiMap,
|
31695
31813
|
rawPayload,
|
31696
|
-
maxInputs,
|
31697
31814
|
baseAssetId
|
31698
31815
|
}) {
|
31699
31816
|
const contractCallReceipts = getReceiptsCall(receipts);
|
@@ -31703,16 +31820,15 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
31703
31820
|
if (!contractInput) {
|
31704
31821
|
return [];
|
31705
31822
|
}
|
31823
|
+
let scriptData;
|
31824
|
+
if (rawPayload) {
|
31825
|
+
const [transaction] = new TransactionCoder().decode(arrayify(rawPayload), 0);
|
31826
|
+
if (transaction.type === TransactionType.Script) {
|
31827
|
+
scriptData = arrayify(transaction.scriptData);
|
31828
|
+
}
|
31829
|
+
}
|
31706
31830
|
return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
|
31707
|
-
(receipt) => processCallReceipt(
|
31708
|
-
receipt,
|
31709
|
-
contractInput,
|
31710
|
-
inputs,
|
31711
|
-
abiMap,
|
31712
|
-
rawPayload,
|
31713
|
-
maxInputs,
|
31714
|
-
baseAssetId
|
31715
|
-
)
|
31831
|
+
(receipt) => processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId)
|
31716
31832
|
);
|
31717
31833
|
});
|
31718
31834
|
}
|
@@ -32477,6 +32593,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
32477
32593
|
...transactionSummary
|
32478
32594
|
};
|
32479
32595
|
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
32596
|
+
let abis;
|
32480
32597
|
if (this.abis) {
|
32481
32598
|
({ logs, groupedLogs } = getAllDecodedLogs({
|
32482
32599
|
receipts: transactionSummary.receipts,
|
@@ -32485,6 +32602,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
32485
32602
|
}));
|
32486
32603
|
transactionResult.logs = logs;
|
32487
32604
|
transactionResult.groupedLogs = groupedLogs;
|
32605
|
+
abis = this.abis;
|
32488
32606
|
}
|
32489
32607
|
const { receipts } = transactionResult;
|
32490
32608
|
const status = this.getTransactionStatus();
|
@@ -32494,7 +32612,8 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
32494
32612
|
receipts,
|
32495
32613
|
statusReason: reason,
|
32496
32614
|
logs,
|
32497
|
-
groupedLogs
|
32615
|
+
groupedLogs,
|
32616
|
+
abis
|
32498
32617
|
});
|
32499
32618
|
}
|
32500
32619
|
return transactionResult;
|
@@ -34370,18 +34489,21 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
34370
34489
|
extractDryRunError(transactionRequest, receipts, reason) {
|
34371
34490
|
let logs = [];
|
34372
34491
|
let groupedLogs = {};
|
34492
|
+
let abis;
|
34373
34493
|
if (transactionRequest.type === TransactionType.Script && transactionRequest.abis) {
|
34374
34494
|
({ logs, groupedLogs } = getAllDecodedLogs({
|
34375
34495
|
receipts,
|
34376
34496
|
mainAbi: transactionRequest.abis.main,
|
34377
34497
|
externalAbis: transactionRequest.abis.otherContractsAbis
|
34378
34498
|
}));
|
34499
|
+
abis = transactionRequest.abis;
|
34379
34500
|
}
|
34380
34501
|
return extractTxError({
|
34381
34502
|
logs,
|
34382
34503
|
groupedLogs,
|
34383
34504
|
receipts,
|
34384
|
-
statusReason: reason
|
34505
|
+
statusReason: reason,
|
34506
|
+
abis
|
34385
34507
|
});
|
34386
34508
|
}
|
34387
34509
|
/**
|