@fuel-ts/account 0.0.0-rc-1962-20240328175938 → 0.0.0-rc-1895-20240329092733
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/index.global.js +125 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +541 -468
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -240
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +30 -0
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils.global.js +125 -9
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +501 -434
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +288 -213
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transaction-response.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-response/transaction-response.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"transaction-response.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-response/transaction-response.ts"],"names":[],"mapp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,gBAAgB,GAAG,IAAI,EACjD,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;YAgClC,mBAAmB;IAyBjC;;;;OAIG;IACG,aAAa,CAAC,gBAAgB,GAAG,IAAI,EACzC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAsC/C;;;;OAIG;IACG,IAAI,CAAC,gBAAgB,GAAG,IAAI,EAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAGhD"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { FuelError } from '@fuel-ts/errors';
|
2
|
+
import type { GqlTransactionStatusFragmentFragment } from '../__generated__/operations';
|
3
|
+
import type { TransactionResultReceipt } from '../transaction-response';
|
4
|
+
import type { FailureStatus } from '../transaction-summary';
|
5
|
+
/**
|
6
|
+
* Assembles an error message for a panic status.
|
7
|
+
* @param status - The transaction failure status.
|
8
|
+
* @returns The error message.
|
9
|
+
*/
|
10
|
+
export declare const assemblePanicError: (status: FailureStatus) => string;
|
11
|
+
/**
|
12
|
+
* Assembles an error message for a revert status.
|
13
|
+
* @param receipts - The transaction result processed receipts.
|
14
|
+
* @param logs - The transaction decoded logs.
|
15
|
+
* @returns The error message.
|
16
|
+
*/
|
17
|
+
export declare const assembleRevertError: (receipts: Array<TransactionResultReceipt>, logs: Array<unknown>) => string;
|
18
|
+
interface IExtractTxError {
|
19
|
+
receipts: Array<TransactionResultReceipt>;
|
20
|
+
status?: GqlTransactionStatusFragmentFragment | null;
|
21
|
+
logs: Array<unknown>;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Extracts the transaction error and returns a FuelError object.
|
25
|
+
* @param IExtractTxError - The parameters for extracting the error.
|
26
|
+
* @returns The FuelError object.
|
27
|
+
*/
|
28
|
+
export declare const extractTxError: (params: IExtractTxError) => FuelError;
|
29
|
+
export {};
|
30
|
+
//# sourceMappingURL=extract-tx-error.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extract-tx-error.d.ts","sourceRoot":"","sources":["../../../src/providers/utils/extract-tx-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAcvD,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,aAAa,WAQvD,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM,wBAAwB,CAAC,QACnC,MAAM,OAAO,CAAC,WA+CrB,CAAC;AAEF,UAAU,eAAe;IACvB,QAAQ,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,oCAAoC,GAAG,IAAI,CAAC;IACrD,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,WAAY,eAAe,KAAG,SAcxD,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
|
@@ -42424,7 +42424,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42424
42424
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42425
42425
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42426
42426
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42427
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42427
42428
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42429
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42430
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42431
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42432
|
+
var PANIC_REASONS = [
|
42433
|
+
"UnknownPanicReason",
|
42434
|
+
"Revert",
|
42435
|
+
"OutOfGas",
|
42436
|
+
"TransactionValidity",
|
42437
|
+
"MemoryOverflow",
|
42438
|
+
"ArithmeticOverflow",
|
42439
|
+
"ContractNotFound",
|
42440
|
+
"MemoryOwnership",
|
42441
|
+
"NotEnoughBalance",
|
42442
|
+
"ExpectedInternalContext",
|
42443
|
+
"AssetIdNotFound",
|
42444
|
+
"InputNotFound",
|
42445
|
+
"OutputNotFound",
|
42446
|
+
"WitnessNotFound",
|
42447
|
+
"TransactionMaturity",
|
42448
|
+
"InvalidMetadataIdentifier",
|
42449
|
+
"MalformedCallStructure",
|
42450
|
+
"ReservedRegisterNotWritable",
|
42451
|
+
"InvalidFlags",
|
42452
|
+
"InvalidImmediateValue",
|
42453
|
+
"ExpectedCoinInput",
|
42454
|
+
"EcalError",
|
42455
|
+
"MemoryWriteOverlap",
|
42456
|
+
"ContractNotInInputs",
|
42457
|
+
"InternalBalanceOverflow",
|
42458
|
+
"ContractMaxSize",
|
42459
|
+
"ExpectedUnallocatedStack",
|
42460
|
+
"MaxStaticContractsReached",
|
42461
|
+
"TransferAmountCannotBeZero",
|
42462
|
+
"ExpectedOutputVariable",
|
42463
|
+
"ExpectedParentInternalContext",
|
42464
|
+
"PredicateReturnedNonOne",
|
42465
|
+
"ContractIdAlreadyDeployed",
|
42466
|
+
"ContractMismatch",
|
42467
|
+
"MessageDataTooLong",
|
42468
|
+
"ArithmeticError",
|
42469
|
+
"ContractInstructionNotAllowed",
|
42470
|
+
"TransferZeroCoins",
|
42471
|
+
"InvalidInstruction",
|
42472
|
+
"MemoryNotExecutable",
|
42473
|
+
"PolicyIsNotSet",
|
42474
|
+
"PolicyNotFound",
|
42475
|
+
"TooManyReceipts",
|
42476
|
+
"BalanceOverflow",
|
42477
|
+
"InvalidBlockHeight",
|
42478
|
+
"TooManySlots"
|
42479
|
+
];
|
42480
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42428
42481
|
|
42429
42482
|
// src/providers/utils/receipts.ts
|
42430
42483
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42737,6 +42790,64 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42737
42790
|
});
|
42738
42791
|
}
|
42739
42792
|
|
42793
|
+
// src/providers/utils/extract-tx-error.ts
|
42794
|
+
var assemblePanicError = (status) => {
|
42795
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42796
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
42797
|
+
errorMessage = `${errorMessage}
|
42798
|
+
|
42799
|
+
You can read more about this error at:
|
42800
|
+
|
42801
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42802
|
+
}
|
42803
|
+
return errorMessage;
|
42804
|
+
};
|
42805
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42806
|
+
var assembleRevertError = (receipts, logs) => {
|
42807
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
42808
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42809
|
+
if (revertReceipt) {
|
42810
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
42811
|
+
switch (reasonHex) {
|
42812
|
+
case FAILED_REQUIRE_SIGNAL: {
|
42813
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42814
|
+
break;
|
42815
|
+
}
|
42816
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
42817
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42818
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42819
|
+
break;
|
42820
|
+
}
|
42821
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
42822
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42823
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42824
|
+
break;
|
42825
|
+
}
|
42826
|
+
case FAILED_ASSERT_SIGNAL:
|
42827
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42828
|
+
break;
|
42829
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42830
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42831
|
+
break;
|
42832
|
+
default:
|
42833
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42834
|
+
}
|
42835
|
+
}
|
42836
|
+
return errorMessage;
|
42837
|
+
};
|
42838
|
+
var extractTxError = (params) => {
|
42839
|
+
const { receipts, status, logs } = params;
|
42840
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42841
|
+
let err = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42842
|
+
err += `
|
42843
|
+
|
42844
|
+
logs: ${JSON.stringify(logs, null, 2)}`;
|
42845
|
+
err += `
|
42846
|
+
|
42847
|
+
receipts: ${JSON.stringify(receipts, null, 2)}`;
|
42848
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, err);
|
42849
|
+
};
|
42850
|
+
|
42740
42851
|
// src/providers/transaction-request/errors.ts
|
42741
42852
|
var NoWitnessAtIndexError = class extends Error {
|
42742
42853
|
constructor(index) {
|
@@ -44494,14 +44605,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44494
44605
|
gqlTransaction: this.gqlTransaction,
|
44495
44606
|
...transactionSummary
|
44496
44607
|
};
|
44608
|
+
let logs = [];
|
44497
44609
|
if (this.abis) {
|
44498
|
-
|
44610
|
+
logs = getDecodedLogs(
|
44499
44611
|
transactionSummary.receipts,
|
44500
44612
|
this.abis.main,
|
44501
44613
|
this.abis.otherContractsAbis
|
44502
44614
|
);
|
44503
44615
|
transactionResult.logs = logs;
|
44504
44616
|
}
|
44617
|
+
if (transactionResult.isStatusFailure) {
|
44618
|
+
const {
|
44619
|
+
receipts,
|
44620
|
+
gqlTransaction: { status }
|
44621
|
+
} = transactionResult;
|
44622
|
+
throw extractTxError({
|
44623
|
+
receipts,
|
44624
|
+
status,
|
44625
|
+
logs
|
44626
|
+
});
|
44627
|
+
}
|
44505
44628
|
return transactionResult;
|
44506
44629
|
}
|
44507
44630
|
/**
|
@@ -44510,14 +44633,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44510
44633
|
* @param contractsAbiMap - The contracts ABI map.
|
44511
44634
|
*/
|
44512
44635
|
async wait(contractsAbiMap) {
|
44513
|
-
|
44514
|
-
if (result.isStatusFailure) {
|
44515
|
-
throw new FuelError(
|
44516
|
-
ErrorCode.TRANSACTION_FAILED,
|
44517
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44518
|
-
);
|
44519
|
-
}
|
44520
|
-
return result;
|
44636
|
+
return this.waitForResult(contractsAbiMap);
|
44521
44637
|
}
|
44522
44638
|
};
|
44523
44639
|
|