@fuel-ts/account 0.0.0-rc-1895-20240401111027 → 0.0.0-rc-1832-20240402063902
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 +80 -149
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +468 -541
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -318
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils.global.js +80 -149
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +434 -501
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +213 -288
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/utils/extract-tx-error.d.ts +0 -30
- package/dist/providers/utils/extract-tx-error.d.ts.map +0 -1
package/dist/index.global.js
CHANGED
@@ -31918,9 +31918,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31918
31918
|
__privateAdd2(this, _getPaddedData);
|
31919
31919
|
}
|
31920
31920
|
encode(value) {
|
31921
|
-
if (!Array.isArray(value)) {
|
31922
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
31923
|
-
}
|
31924
31921
|
const parts = [];
|
31925
31922
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
31926
31923
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -31947,7 +31944,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31947
31944
|
};
|
31948
31945
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
31949
31946
|
getPaddedData_fn = function(value) {
|
31950
|
-
const
|
31947
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
31948
|
+
const data = [Uint8Array.from(bytes3)];
|
31951
31949
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
31952
31950
|
if (paddingLength) {
|
31953
31951
|
data.push(new Uint8Array(paddingLength));
|
@@ -32040,7 +32038,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32040
32038
|
return { None: [] };
|
32041
32039
|
}
|
32042
32040
|
decode(data, offset) {
|
32043
|
-
if (data.length < this.encodedLength
|
32041
|
+
if (data.length < this.encodedLength) {
|
32044
32042
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
32045
32043
|
}
|
32046
32044
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -32623,11 +32621,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32623
32621
|
super("struct", "struct Bytes", WORD_SIZE);
|
32624
32622
|
}
|
32625
32623
|
encode(value) {
|
32626
|
-
|
32627
|
-
|
32628
|
-
}
|
32629
|
-
const bytes3 = new Uint8Array(value);
|
32630
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32624
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
32625
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
|
32631
32626
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32632
32627
|
}
|
32633
32628
|
decode(data, offset) {
|
@@ -32758,6 +32753,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32758
32753
|
return [toNumber2(bytes3), offset + this.length];
|
32759
32754
|
}
|
32760
32755
|
};
|
32756
|
+
var OptionCoder2 = class extends EnumCoder2 {
|
32757
|
+
encode(value) {
|
32758
|
+
const result = super.encode(this.toSwayOption(value));
|
32759
|
+
return result;
|
32760
|
+
}
|
32761
|
+
toSwayOption(input) {
|
32762
|
+
if (input !== void 0) {
|
32763
|
+
return { Some: input };
|
32764
|
+
}
|
32765
|
+
return { None: [] };
|
32766
|
+
}
|
32767
|
+
decode(data, offset) {
|
32768
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
32769
|
+
return [this.toOption(decoded), newOffset];
|
32770
|
+
}
|
32771
|
+
toOption(output3) {
|
32772
|
+
if (output3 && "Some" in output3) {
|
32773
|
+
return output3.Some;
|
32774
|
+
}
|
32775
|
+
return void 0;
|
32776
|
+
}
|
32777
|
+
};
|
32761
32778
|
var RawSliceCoder2 = class extends Coder {
|
32762
32779
|
constructor() {
|
32763
32780
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -32811,6 +32828,30 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32811
32828
|
}
|
32812
32829
|
};
|
32813
32830
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
32831
|
+
var StrSliceCoder = class extends Coder {
|
32832
|
+
constructor() {
|
32833
|
+
super("strSlice", "str", WORD_SIZE);
|
32834
|
+
}
|
32835
|
+
encode(value) {
|
32836
|
+
const bytes3 = toUtf8Bytes(value);
|
32837
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32838
|
+
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32839
|
+
}
|
32840
|
+
decode(data, offset) {
|
32841
|
+
if (data.length < this.encodedLength) {
|
32842
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
32843
|
+
}
|
32844
|
+
const offsetAndLength = offset + WORD_SIZE;
|
32845
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
32846
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32847
|
+
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
32848
|
+
if (bytes3.length !== length) {
|
32849
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
32850
|
+
}
|
32851
|
+
return [toUtf8String(bytes3), offsetAndLength + length];
|
32852
|
+
}
|
32853
|
+
};
|
32854
|
+
__publicField4(StrSliceCoder, "memorySize", 1);
|
32814
32855
|
var StringCoder2 = class extends Coder {
|
32815
32856
|
constructor(length) {
|
32816
32857
|
super("string", `str[${length}]`, length);
|
@@ -32849,7 +32890,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32849
32890
|
Object.keys(this.coders).map((fieldName) => {
|
32850
32891
|
const fieldCoder = this.coders[fieldName];
|
32851
32892
|
const fieldValue = value[fieldName];
|
32852
|
-
if (!(fieldCoder instanceof
|
32893
|
+
if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
|
32853
32894
|
throw new FuelError(
|
32854
32895
|
ErrorCode.ENCODE_ERROR,
|
32855
32896
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -32957,6 +32998,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32957
32998
|
return new ByteCoder2();
|
32958
32999
|
case STD_STRING_CODER_TYPE:
|
32959
33000
|
return new StdStringCoder2();
|
33001
|
+
case STR_SLICE_CODER_TYPE:
|
33002
|
+
return new StrSliceCoder();
|
32960
33003
|
default:
|
32961
33004
|
break;
|
32962
33005
|
}
|
@@ -33001,7 +33044,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33001
33044
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
33002
33045
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
33003
33046
|
if (isOptionEnum) {
|
33004
|
-
return new
|
33047
|
+
return new OptionCoder2(enumMatch.name, coders);
|
33005
33048
|
}
|
33006
33049
|
return new EnumCoder2(enumMatch.name, coders);
|
33007
33050
|
}
|
@@ -33012,12 +33055,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33012
33055
|
);
|
33013
33056
|
return new TupleCoder2(coders);
|
33014
33057
|
}
|
33015
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
33016
|
-
throw new FuelError(
|
33017
|
-
ErrorCode.INVALID_DATA,
|
33018
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
33019
|
-
);
|
33020
|
-
}
|
33021
33058
|
throw new FuelError(
|
33022
33059
|
ErrorCode.CODER_NOT_FOUND,
|
33023
33060
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -33053,6 +33090,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33053
33090
|
var FunctionFragment = class {
|
33054
33091
|
signature;
|
33055
33092
|
selector;
|
33093
|
+
selectorBytes;
|
33094
|
+
encoding;
|
33056
33095
|
name;
|
33057
33096
|
jsonFn;
|
33058
33097
|
attributes;
|
@@ -33065,6 +33104,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33065
33104
|
this.name = name;
|
33066
33105
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33067
33106
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
33107
|
+
this.selectorBytes = new StdStringCoder2().encode(name);
|
33108
|
+
this.encoding = this.jsonAbi.encoding;
|
33068
33109
|
this.isInputDataPointer = this.#isInputDataPointer();
|
33069
33110
|
this.outputMetadata = {
|
33070
33111
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -33118,11 +33159,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33118
33159
|
}
|
33119
33160
|
const coders = nonEmptyInputs.map(
|
33120
33161
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
33121
|
-
isRightPadded: nonEmptyInputs.length > 1
|
33162
|
+
isRightPadded: nonEmptyInputs.length > 1,
|
33163
|
+
encoding: this.encoding
|
33122
33164
|
})
|
33123
33165
|
);
|
33124
|
-
|
33125
|
-
|
33166
|
+
if (this.encoding === ENCODING_V1) {
|
33167
|
+
return new TupleCoder2(coders).encode(shallowCopyValues);
|
33168
|
+
}
|
33169
|
+
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
33126
33170
|
return unpackDynamicData(results, offset, results.byteLength);
|
33127
33171
|
}
|
33128
33172
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -33169,7 +33213,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33169
33213
|
}
|
33170
33214
|
const result = nonEmptyInputs.reduce(
|
33171
33215
|
(obj, input) => {
|
33172
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
33216
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
|
33173
33217
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
33174
33218
|
return {
|
33175
33219
|
decoded: [...obj.decoded, decodedValue],
|
@@ -33189,7 +33233,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33189
33233
|
return [void 0, 0];
|
33190
33234
|
}
|
33191
33235
|
const bytes3 = arrayify(data);
|
33192
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
33236
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
|
33237
|
+
encoding: this.encoding
|
33238
|
+
});
|
33193
33239
|
return coder.decode(bytes3, 0);
|
33194
33240
|
}
|
33195
33241
|
};
|
@@ -33257,7 +33303,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33257
33303
|
}
|
33258
33304
|
);
|
33259
33305
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33260
|
-
isRightPadded: true
|
33306
|
+
isRightPadded: true,
|
33307
|
+
encoding: this.jsonAbi.encoding
|
33261
33308
|
});
|
33262
33309
|
}
|
33263
33310
|
getTypeById(typeId) {
|
@@ -38962,60 +39009,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38962
39009
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
38963
39010
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
38964
39011
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
38965
|
-
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
38966
39012
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
38967
|
-
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
38968
|
-
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
38969
|
-
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
38970
|
-
var PANIC_REASONS = [
|
38971
|
-
"UnknownPanicReason",
|
38972
|
-
"Revert",
|
38973
|
-
"OutOfGas",
|
38974
|
-
"TransactionValidity",
|
38975
|
-
"MemoryOverflow",
|
38976
|
-
"ArithmeticOverflow",
|
38977
|
-
"ContractNotFound",
|
38978
|
-
"MemoryOwnership",
|
38979
|
-
"NotEnoughBalance",
|
38980
|
-
"ExpectedInternalContext",
|
38981
|
-
"AssetIdNotFound",
|
38982
|
-
"InputNotFound",
|
38983
|
-
"OutputNotFound",
|
38984
|
-
"WitnessNotFound",
|
38985
|
-
"TransactionMaturity",
|
38986
|
-
"InvalidMetadataIdentifier",
|
38987
|
-
"MalformedCallStructure",
|
38988
|
-
"ReservedRegisterNotWritable",
|
38989
|
-
"InvalidFlags",
|
38990
|
-
"InvalidImmediateValue",
|
38991
|
-
"ExpectedCoinInput",
|
38992
|
-
"EcalError",
|
38993
|
-
"MemoryWriteOverlap",
|
38994
|
-
"ContractNotInInputs",
|
38995
|
-
"InternalBalanceOverflow",
|
38996
|
-
"ContractMaxSize",
|
38997
|
-
"ExpectedUnallocatedStack",
|
38998
|
-
"MaxStaticContractsReached",
|
38999
|
-
"TransferAmountCannotBeZero",
|
39000
|
-
"ExpectedOutputVariable",
|
39001
|
-
"ExpectedParentInternalContext",
|
39002
|
-
"PredicateReturnedNonOne",
|
39003
|
-
"ContractIdAlreadyDeployed",
|
39004
|
-
"ContractMismatch",
|
39005
|
-
"MessageDataTooLong",
|
39006
|
-
"ArithmeticError",
|
39007
|
-
"ContractInstructionNotAllowed",
|
39008
|
-
"TransferZeroCoins",
|
39009
|
-
"InvalidInstruction",
|
39010
|
-
"MemoryNotExecutable",
|
39011
|
-
"PolicyIsNotSet",
|
39012
|
-
"PolicyNotFound",
|
39013
|
-
"TooManyReceipts",
|
39014
|
-
"BalanceOverflow",
|
39015
|
-
"InvalidBlockHeight",
|
39016
|
-
"TooManySlots"
|
39017
|
-
];
|
39018
|
-
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
39019
39013
|
|
39020
39014
|
// src/providers/utils/receipts.ts
|
39021
39015
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -39389,64 +39383,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39389
39383
|
});
|
39390
39384
|
}
|
39391
39385
|
|
39392
|
-
// src/providers/utils/extract-tx-error.ts
|
39393
|
-
var assemblePanicError = (status) => {
|
39394
|
-
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
39395
|
-
if (PANIC_REASONS.includes(status.reason)) {
|
39396
|
-
errorMessage = `${errorMessage}
|
39397
|
-
|
39398
|
-
You can read more about this error at:
|
39399
|
-
|
39400
|
-
${PANIC_DOC_URL}#variant.${status.reason}`;
|
39401
|
-
}
|
39402
|
-
return errorMessage;
|
39403
|
-
};
|
39404
|
-
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
39405
|
-
var assembleRevertError = (receipts, logs) => {
|
39406
|
-
let errorMessage = "The transaction reverted with an unknown reason.";
|
39407
|
-
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
39408
|
-
if (revertReceipt) {
|
39409
|
-
const reasonHex = bn(revertReceipt.val).toHex();
|
39410
|
-
switch (reasonHex) {
|
39411
|
-
case FAILED_REQUIRE_SIGNAL: {
|
39412
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
39413
|
-
break;
|
39414
|
-
}
|
39415
|
-
case FAILED_ASSERT_EQ_SIGNAL: {
|
39416
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
39417
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
39418
|
-
break;
|
39419
|
-
}
|
39420
|
-
case FAILED_ASSERT_NE_SIGNAL: {
|
39421
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
39422
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
39423
|
-
break;
|
39424
|
-
}
|
39425
|
-
case FAILED_ASSERT_SIGNAL:
|
39426
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
39427
|
-
break;
|
39428
|
-
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
39429
|
-
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
39430
|
-
break;
|
39431
|
-
default:
|
39432
|
-
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
39433
|
-
}
|
39434
|
-
}
|
39435
|
-
return errorMessage;
|
39436
|
-
};
|
39437
|
-
var extractTxError = (params) => {
|
39438
|
-
const { receipts, status, logs } = params;
|
39439
|
-
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
39440
|
-
let err = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
39441
|
-
err += `
|
39442
|
-
|
39443
|
-
logs: ${JSON.stringify(logs, null, 2)}`;
|
39444
|
-
err += `
|
39445
|
-
|
39446
|
-
receipts: ${JSON.stringify(receipts, null, 2)}`;
|
39447
|
-
return new FuelError(ErrorCode.SCRIPT_REVERTED, err);
|
39448
|
-
};
|
39449
|
-
|
39450
39386
|
// src/providers/transaction-request/errors.ts
|
39451
39387
|
var ChangeOutputCollisionError = class extends Error {
|
39452
39388
|
name = "ChangeOutputCollisionError";
|
@@ -41263,26 +41199,14 @@ receipts: ${JSON.stringify(receipts, null, 2)}`;
|
|
41263
41199
|
gqlTransaction: this.gqlTransaction,
|
41264
41200
|
...transactionSummary
|
41265
41201
|
};
|
41266
|
-
let logs = [];
|
41267
41202
|
if (this.abis) {
|
41268
|
-
logs = getDecodedLogs(
|
41203
|
+
const logs = getDecodedLogs(
|
41269
41204
|
transactionSummary.receipts,
|
41270
41205
|
this.abis.main,
|
41271
41206
|
this.abis.otherContractsAbis
|
41272
41207
|
);
|
41273
41208
|
transactionResult.logs = logs;
|
41274
41209
|
}
|
41275
|
-
if (transactionResult.isStatusFailure) {
|
41276
|
-
const {
|
41277
|
-
receipts,
|
41278
|
-
gqlTransaction: { status }
|
41279
|
-
} = transactionResult;
|
41280
|
-
throw extractTxError({
|
41281
|
-
receipts,
|
41282
|
-
status,
|
41283
|
-
logs
|
41284
|
-
});
|
41285
|
-
}
|
41286
41210
|
return transactionResult;
|
41287
41211
|
}
|
41288
41212
|
/**
|
@@ -41291,7 +41215,14 @@ receipts: ${JSON.stringify(receipts, null, 2)}`;
|
|
41291
41215
|
* @param contractsAbiMap - The contracts ABI map.
|
41292
41216
|
*/
|
41293
41217
|
async wait(contractsAbiMap) {
|
41294
|
-
|
41218
|
+
const result = await this.waitForResult(contractsAbiMap);
|
41219
|
+
if (result.isStatusFailure) {
|
41220
|
+
throw new FuelError(
|
41221
|
+
ErrorCode.TRANSACTION_FAILED,
|
41222
|
+
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
41223
|
+
);
|
41224
|
+
}
|
41225
|
+
return result;
|
41295
41226
|
}
|
41296
41227
|
};
|
41297
41228
|
|