@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.mjs
CHANGED
@@ -710,7 +710,7 @@ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
|
710
710
|
import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
|
711
711
|
import { bn as bn21 } from "@fuel-ts/math";
|
712
712
|
import { InputType as InputType8, OutputType as OutputType9 } from "@fuel-ts/transactions";
|
713
|
-
import { arrayify as
|
713
|
+
import { arrayify as arrayify17, hexlify as hexlify18, isDefined as isDefined4 } from "@fuel-ts/utils";
|
714
714
|
import { clone as clone9 } from "ramda";
|
715
715
|
|
716
716
|
// src/providers/coin-quantity.ts
|
@@ -751,8 +751,8 @@ var addAmountToCoinQuantities = /* @__PURE__ */ __name((params) => {
|
|
751
751
|
import { Address as Address2, isB256 } from "@fuel-ts/address";
|
752
752
|
import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
|
753
753
|
import { bn as bn18 } from "@fuel-ts/math";
|
754
|
-
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as
|
755
|
-
import { arrayify as
|
754
|
+
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder7, TransactionType as TransactionType11 } from "@fuel-ts/transactions";
|
755
|
+
import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined3, sleep as sleep2 } from "@fuel-ts/utils";
|
756
756
|
import { checkFuelCoreVersionCompatibility, versions } from "@fuel-ts/versions";
|
757
757
|
import { GraphQLClient } from "graphql-request";
|
758
758
|
import gql2 from "graphql-tag";
|
@@ -3262,7 +3262,8 @@ import {
|
|
3262
3262
|
FAILED_ASSERT_SIGNAL,
|
3263
3263
|
FAILED_TRANSFER_TO_ADDRESS_SIGNAL as FAILED_TRANSFER_TO_ADDRESS_SIGNAL2,
|
3264
3264
|
PANIC_REASONS,
|
3265
|
-
PANIC_DOC_URL
|
3265
|
+
PANIC_DOC_URL,
|
3266
|
+
SwaySignalErrors
|
3266
3267
|
} from "@fuel-ts/transactions/configs";
|
3267
3268
|
var assemblePanicError = /* @__PURE__ */ __name((statusReason, metadata) => {
|
3268
3269
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
@@ -3279,58 +3280,97 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
3279
3280
|
});
|
3280
3281
|
}, "assemblePanicError");
|
3281
3282
|
var stringify = /* @__PURE__ */ __name((obj) => JSON.stringify(obj, null, 2), "stringify");
|
3282
|
-
var
|
3283
|
+
var assembleSignalErrorMessage = /* @__PURE__ */ __name((reasonHex, logs, metadata) => {
|
3283
3284
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
3284
|
-
const revertReceipt = receipts.find(({ type }) => type === ReceiptType4.Revert);
|
3285
3285
|
let reason = "";
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3290
|
-
|
3291
|
-
|
3292
|
-
|
3293
|
-
|
3294
|
-
|
3295
|
-
}
|
3296
|
-
|
3297
|
-
|
3298
|
-
|
3299
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
3300
|
-
break;
|
3301
|
-
}
|
3302
|
-
case FAILED_ASSERT_NE_SIGNAL: {
|
3303
|
-
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
3304
|
-
reason = "assert_ne";
|
3305
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
3306
|
-
break;
|
3307
|
-
}
|
3308
|
-
case FAILED_ASSERT_SIGNAL:
|
3309
|
-
reason = "assert";
|
3310
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
3311
|
-
break;
|
3312
|
-
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
3313
|
-
reason = "MissingOutputVariable";
|
3314
|
-
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
3315
|
-
break;
|
3316
|
-
default:
|
3317
|
-
throw new FuelError8(
|
3318
|
-
ErrorCode8.UNKNOWN,
|
3319
|
-
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
3320
|
-
{
|
3321
|
-
...metadata,
|
3322
|
-
reason: "unknown"
|
3323
|
-
}
|
3324
|
-
);
|
3286
|
+
const lastLog = logs[logs.length - 1];
|
3287
|
+
const lastButOneLog = logs[logs.length - 2];
|
3288
|
+
switch (reasonHex) {
|
3289
|
+
case FAILED_REQUIRE_SIGNAL: {
|
3290
|
+
reason = "require";
|
3291
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
3292
|
+
break;
|
3293
|
+
}
|
3294
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
3295
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
3296
|
+
reason = "assert_eq";
|
3297
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
3298
|
+
break;
|
3325
3299
|
}
|
3300
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
3301
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
3302
|
+
reason = "assert_ne";
|
3303
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
3304
|
+
break;
|
3305
|
+
}
|
3306
|
+
case FAILED_ASSERT_SIGNAL:
|
3307
|
+
reason = "assert";
|
3308
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
3309
|
+
break;
|
3310
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
3311
|
+
reason = "MissingOutputVariable";
|
3312
|
+
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
3313
|
+
break;
|
3314
|
+
default:
|
3315
|
+
reason = `revert_with_log`;
|
3316
|
+
errorMessage = `The transaction reverted because a "revert_with_log" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
|
3317
|
+
break;
|
3318
|
+
}
|
3319
|
+
return new FuelError8(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
3320
|
+
...metadata,
|
3321
|
+
reason
|
3322
|
+
});
|
3323
|
+
}, "assembleSignalErrorMessage");
|
3324
|
+
function buildAbiErrorMessage(abiError, logs, metadata, reason) {
|
3325
|
+
const { pos, msg } = abiError;
|
3326
|
+
let errorMessage = "";
|
3327
|
+
const positionMessage = pos ? `
|
3328
|
+
|
3329
|
+
This error originated at ${JSON.stringify(pos, null, 2)}` : "";
|
3330
|
+
if (msg) {
|
3331
|
+
errorMessage = `A sway "panic" expression was invoked with the message: "${msg}".${positionMessage}`;
|
3332
|
+
} else {
|
3333
|
+
const value = logs[logs.length - 1];
|
3334
|
+
errorMessage = `A sway "panic" expression was invoked with the value: ${JSON.stringify(value)}.${positionMessage}`;
|
3326
3335
|
}
|
3327
3336
|
return new FuelError8(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
3328
3337
|
...metadata,
|
3329
3338
|
reason
|
3330
3339
|
});
|
3340
|
+
}
|
3341
|
+
__name(buildAbiErrorMessage, "buildAbiErrorMessage");
|
3342
|
+
function findErrorInAbis(statusReason, abis = []) {
|
3343
|
+
for (const abi of abis) {
|
3344
|
+
if (abi.errorCodes?.[statusReason]) {
|
3345
|
+
return abi.errorCodes[statusReason];
|
3346
|
+
}
|
3347
|
+
}
|
3348
|
+
return void 0;
|
3349
|
+
}
|
3350
|
+
__name(findErrorInAbis, "findErrorInAbis");
|
3351
|
+
var assembleRevertError = /* @__PURE__ */ __name((_receipts, logs, metadata, statusReason, abis) => {
|
3352
|
+
const match = statusReason.match(/Revert\((\d+)\)/);
|
3353
|
+
const reason = match?.[1] ?? statusReason;
|
3354
|
+
const reasonHex = bn7(reason).toHex();
|
3355
|
+
if (Object.values(SwaySignalErrors).includes(reasonHex)) {
|
3356
|
+
return assembleSignalErrorMessage(reasonHex, logs, metadata);
|
3357
|
+
}
|
3358
|
+
let abiError;
|
3359
|
+
if (abis) {
|
3360
|
+
const abisArr = [abis.main, ...Object.values(abis.otherContractsAbis)];
|
3361
|
+
abiError = findErrorInAbis(reason, abisArr);
|
3362
|
+
}
|
3363
|
+
if (abiError) {
|
3364
|
+
return buildAbiErrorMessage(abiError, logs, metadata, reason);
|
3365
|
+
}
|
3366
|
+
const errorMessage = `The transaction reverted with reason: ${reason}.`;
|
3367
|
+
return new FuelError8(ErrorCode8.SCRIPT_REVERTED, errorMessage, {
|
3368
|
+
...metadata,
|
3369
|
+
reason
|
3370
|
+
});
|
3331
3371
|
}, "assembleRevertError");
|
3332
3372
|
var extractTxError = /* @__PURE__ */ __name((params) => {
|
3333
|
-
const { receipts, statusReason, logs, groupedLogs } = params;
|
3373
|
+
const { receipts, statusReason, logs, groupedLogs, abis } = params;
|
3334
3374
|
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
3335
3375
|
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
3336
3376
|
const metadata = {
|
@@ -3344,7 +3384,7 @@ var extractTxError = /* @__PURE__ */ __name((params) => {
|
|
3344
3384
|
if (isPanic) {
|
3345
3385
|
return assemblePanicError(statusReason, metadata);
|
3346
3386
|
}
|
3347
|
-
return assembleRevertError(receipts, logs, metadata);
|
3387
|
+
return assembleRevertError(receipts, logs, metadata, statusReason, abis);
|
3348
3388
|
}, "extractTxError");
|
3349
3389
|
|
3350
3390
|
// src/providers/utils/merge-quantities.ts
|
@@ -4932,12 +4972,12 @@ var ResourceCache = class {
|
|
4932
4972
|
// src/providers/transaction-response/transaction-response.ts
|
4933
4973
|
import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
|
4934
4974
|
import { bn as bn17 } from "@fuel-ts/math";
|
4935
|
-
import { TransactionCoder as
|
4936
|
-
import { arrayify as
|
4975
|
+
import { TransactionCoder as TransactionCoder6, TxPointerCoder } from "@fuel-ts/transactions";
|
4976
|
+
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4937
4977
|
|
4938
4978
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
4939
4979
|
import { bn as bn16 } from "@fuel-ts/math";
|
4940
|
-
import { PolicyType as PolicyType3, TransactionCoder as
|
4980
|
+
import { PolicyType as PolicyType3, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
4941
4981
|
import { DateTime, hexlify as hexlify16 } from "@fuel-ts/utils";
|
4942
4982
|
|
4943
4983
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
@@ -5009,8 +5049,47 @@ var calculateTXFeeForSummary = /* @__PURE__ */ __name((params) => {
|
|
5009
5049
|
// src/providers/transaction-summary/operations.ts
|
5010
5050
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
5011
5051
|
import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
|
5012
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
5013
|
-
import { ReceiptType as ReceiptType5, TransactionType as TransactionType10 } from "@fuel-ts/transactions";
|
5052
|
+
import { bn as bn14, toBytes } from "@fuel-ts/math";
|
5053
|
+
import { ReceiptType as ReceiptType5, TransactionCoder as TransactionCoder4, TransactionType as TransactionType10 } from "@fuel-ts/transactions";
|
5054
|
+
import { arrayify as arrayify11, concat as concat3 } from "@fuel-ts/utils";
|
5055
|
+
|
5056
|
+
// src/providers/transaction-summary/call.ts
|
5057
|
+
import { StdStringCoder } from "@fuel-ts/abi-coder";
|
5058
|
+
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
5059
|
+
var getFunctionCall = /* @__PURE__ */ __name(({
|
5060
|
+
abi,
|
5061
|
+
receipt,
|
5062
|
+
offset,
|
5063
|
+
scriptData
|
5064
|
+
}) => {
|
5065
|
+
const [functionSelector, argumentsOffset] = new StdStringCoder().decode(scriptData, offset);
|
5066
|
+
const abiInterface = new Interface2(abi);
|
5067
|
+
const functionFragment = abiInterface.getFunction(functionSelector);
|
5068
|
+
const inputs = functionFragment.jsonFn.inputs;
|
5069
|
+
let argumentsProvided;
|
5070
|
+
if (inputs.length) {
|
5071
|
+
const functionArgsBytes = scriptData.slice(argumentsOffset);
|
5072
|
+
const decodedArguments = functionFragment.decodeArguments(functionArgsBytes);
|
5073
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
5074
|
+
const value = decodedArguments?.[index];
|
5075
|
+
const name = input.name;
|
5076
|
+
if (name) {
|
5077
|
+
return {
|
5078
|
+
...prev,
|
5079
|
+
// reparse to remove bn
|
5080
|
+
[name]: JSON.parse(JSON.stringify(value))
|
5081
|
+
};
|
5082
|
+
}
|
5083
|
+
return prev;
|
5084
|
+
}, {});
|
5085
|
+
}
|
5086
|
+
return {
|
5087
|
+
functionSignature: functionFragment.signature,
|
5088
|
+
functionName: functionFragment.name,
|
5089
|
+
argumentsProvided,
|
5090
|
+
...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
|
5091
|
+
};
|
5092
|
+
}, "getFunctionCall");
|
5014
5093
|
|
5015
5094
|
// src/providers/transaction-summary/input.ts
|
5016
5095
|
import { ErrorCode as ErrorCode12, FuelError as FuelError14 } from "@fuel-ts/errors";
|
@@ -5345,12 +5424,45 @@ function getWithdrawFromFuelOperations({
|
|
5345
5424
|
return withdrawFromFuelOperations;
|
5346
5425
|
}
|
5347
5426
|
__name(getWithdrawFromFuelOperations, "getWithdrawFromFuelOperations");
|
5348
|
-
function
|
5349
|
-
|
5350
|
-
|
5351
|
-
|
5427
|
+
function findBytesSegmentIndex(whole, segment) {
|
5428
|
+
for (let i = 0; i <= whole.length - segment.length; i++) {
|
5429
|
+
let match = true;
|
5430
|
+
for (let j = 0; j < segment.length; j++) {
|
5431
|
+
if (whole[i + j] !== segment[j]) {
|
5432
|
+
match = false;
|
5433
|
+
break;
|
5434
|
+
}
|
5435
|
+
}
|
5436
|
+
if (match) {
|
5437
|
+
return i;
|
5438
|
+
}
|
5352
5439
|
}
|
5353
|
-
return
|
5440
|
+
return -1;
|
5441
|
+
}
|
5442
|
+
__name(findBytesSegmentIndex, "findBytesSegmentIndex");
|
5443
|
+
function getContractCalls(contractInput, abiMap, receipt, scriptData) {
|
5444
|
+
const calls = [];
|
5445
|
+
const abi = abiMap?.[contractInput.contractID];
|
5446
|
+
if (!abi || !scriptData) {
|
5447
|
+
return calls;
|
5448
|
+
}
|
5449
|
+
const bytesSegment = concat3([
|
5450
|
+
arrayify11(receipt.to),
|
5451
|
+
// Contract ID (32 bytes)
|
5452
|
+
toBytes(receipt.param1.toHex(), 8),
|
5453
|
+
// Function selector offset (8 bytes)
|
5454
|
+
toBytes(receipt.param2.toHex(), 8)
|
5455
|
+
// Function args offset (8 bytes)
|
5456
|
+
]);
|
5457
|
+
const segmentIndex = findBytesSegmentIndex(scriptData, bytesSegment);
|
5458
|
+
const canDecodeFunctionCall = segmentIndex !== -1;
|
5459
|
+
if (!canDecodeFunctionCall) {
|
5460
|
+
return calls;
|
5461
|
+
}
|
5462
|
+
const offset = segmentIndex + bytesSegment.length;
|
5463
|
+
const call = getFunctionCall({ abi, receipt, offset, scriptData });
|
5464
|
+
calls.push(call);
|
5465
|
+
return calls;
|
5354
5466
|
}
|
5355
5467
|
__name(getContractCalls, "getContractCalls");
|
5356
5468
|
function getAssetsSent(receipt) {
|
@@ -5362,14 +5474,14 @@ function getAssetsSent(receipt) {
|
|
5362
5474
|
];
|
5363
5475
|
}
|
5364
5476
|
__name(getAssetsSent, "getAssetsSent");
|
5365
|
-
function processCallReceipt(receipt, contractInput, inputs, abiMap,
|
5477
|
+
function processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId) {
|
5366
5478
|
const assetId = receipt.assetId === ZeroBytes329 ? baseAssetId : receipt.assetId;
|
5367
5479
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
5368
5480
|
if (!input) {
|
5369
5481
|
return [];
|
5370
5482
|
}
|
5371
5483
|
const inputAddress = getInputAccountAddress(input);
|
5372
|
-
const calls = getContractCalls(contractInput, abiMap, receipt,
|
5484
|
+
const calls = getContractCalls(contractInput, abiMap, receipt, scriptData);
|
5373
5485
|
return [
|
5374
5486
|
{
|
5375
5487
|
name: "Contract call" /* contractCall */,
|
@@ -5394,7 +5506,6 @@ function getContractCallOperations({
|
|
5394
5506
|
receipts,
|
5395
5507
|
abiMap,
|
5396
5508
|
rawPayload,
|
5397
|
-
maxInputs,
|
5398
5509
|
baseAssetId
|
5399
5510
|
}) {
|
5400
5511
|
const contractCallReceipts = getReceiptsCall(receipts);
|
@@ -5404,16 +5515,15 @@ function getContractCallOperations({
|
|
5404
5515
|
if (!contractInput) {
|
5405
5516
|
return [];
|
5406
5517
|
}
|
5518
|
+
let scriptData;
|
5519
|
+
if (rawPayload) {
|
5520
|
+
const [transaction] = new TransactionCoder4().decode(arrayify11(rawPayload), 0);
|
5521
|
+
if (transaction.type === TransactionType10.Script) {
|
5522
|
+
scriptData = arrayify11(transaction.scriptData);
|
5523
|
+
}
|
5524
|
+
}
|
5407
5525
|
return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
|
5408
|
-
(receipt) => processCallReceipt(
|
5409
|
-
receipt,
|
5410
|
-
contractInput,
|
5411
|
-
inputs,
|
5412
|
-
abiMap,
|
5413
|
-
rawPayload,
|
5414
|
-
maxInputs,
|
5415
|
-
baseAssetId
|
5416
|
-
)
|
5526
|
+
(receipt) => processCallReceipt(receipt, contractInput, inputs, abiMap, scriptData, baseAssetId)
|
5417
5527
|
);
|
5418
5528
|
});
|
5419
5529
|
}
|
@@ -5830,7 +5940,7 @@ function assemblePreConfirmationTransactionSummary(params) {
|
|
5830
5940
|
type = getTransactionTypeName(transaction.type);
|
5831
5941
|
tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
5832
5942
|
if (receipts) {
|
5833
|
-
const rawPayload = hexlify16(new
|
5943
|
+
const rawPayload = hexlify16(new TransactionCoder5().encode(transaction));
|
5834
5944
|
operations = getOperations({
|
5835
5945
|
transactionType: transaction.type,
|
5836
5946
|
inputs: transaction.inputs || [],
|
@@ -5876,7 +5986,7 @@ function assemblePreConfirmationTransactionSummary(params) {
|
|
5876
5986
|
__name(assemblePreConfirmationTransactionSummary, "assemblePreConfirmationTransactionSummary");
|
5877
5987
|
|
5878
5988
|
// src/providers/transaction-response/getAllDecodedLogs.ts
|
5879
|
-
import { Interface as
|
5989
|
+
import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
|
5880
5990
|
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
5881
5991
|
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
5882
5992
|
function getAllDecodedLogs(opts) {
|
@@ -5896,7 +6006,7 @@ function getAllDecodedLogs(opts) {
|
|
5896
6006
|
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
5897
6007
|
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
5898
6008
|
if (isDecodable) {
|
5899
|
-
const interfaceToUse = isLogFromMainAbi ? new
|
6009
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface3(mainAbi) : new Interface3(externalAbis[receipt.id]);
|
5900
6010
|
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
5901
6011
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
5902
6012
|
logs.push(decodedLog);
|
@@ -5996,8 +6106,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
5996
6106
|
}
|
5997
6107
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
5998
6108
|
const { rawPayload } = gqlTransaction;
|
5999
|
-
const bytes =
|
6000
|
-
const [tx] = new
|
6109
|
+
const bytes = arrayify12(rawPayload);
|
6110
|
+
const [tx] = new TransactionCoder6().decode(bytes, 0);
|
6001
6111
|
return {
|
6002
6112
|
tx,
|
6003
6113
|
bytes
|
@@ -6184,6 +6294,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
6184
6294
|
...transactionSummary
|
6185
6295
|
};
|
6186
6296
|
let { logs, groupedLogs } = { logs: [], groupedLogs: {} };
|
6297
|
+
let abis;
|
6187
6298
|
if (this.abis) {
|
6188
6299
|
({ logs, groupedLogs } = getAllDecodedLogs({
|
6189
6300
|
receipts: transactionSummary.receipts,
|
@@ -6192,6 +6303,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
6192
6303
|
}));
|
6193
6304
|
transactionResult.logs = logs;
|
6194
6305
|
transactionResult.groupedLogs = groupedLogs;
|
6306
|
+
abis = this.abis;
|
6195
6307
|
}
|
6196
6308
|
const { receipts } = transactionResult;
|
6197
6309
|
const status = this.getTransactionStatus();
|
@@ -6201,7 +6313,8 @@ var TransactionResponse = class _TransactionResponse {
|
|
6201
6313
|
receipts,
|
6202
6314
|
statusReason: reason,
|
6203
6315
|
logs,
|
6204
|
-
groupedLogs
|
6316
|
+
groupedLogs,
|
6317
|
+
abis
|
6205
6318
|
});
|
6206
6319
|
}
|
6207
6320
|
return transactionResult;
|
@@ -6263,7 +6376,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
6263
6376
|
};
|
6264
6377
|
|
6265
6378
|
// src/providers/transaction-response/getDecodedLogs.ts
|
6266
|
-
import { Interface as
|
6379
|
+
import { Interface as Interface4, BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
6267
6380
|
import { ZeroBytes32 as ZeroBytes3211 } from "@fuel-ts/address/configs";
|
6268
6381
|
import { ReceiptType as ReceiptType8 } from "@fuel-ts/transactions";
|
6269
6382
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
@@ -6279,7 +6392,7 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
|
6279
6392
|
const isLogFromMainAbi = receipt.id === ZeroBytes3211 || mainContract === receipt.id;
|
6280
6393
|
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
6281
6394
|
if (isDecodable) {
|
6282
|
-
const interfaceToUse = isLogFromMainAbi ? new
|
6395
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface4(mainAbi) : new Interface4(externalAbis[receipt.id]);
|
6283
6396
|
const data = receipt.type === ReceiptType8.Log ? new BigNumberCoder2("u64").encode(receipt.ra) : receipt.data;
|
6284
6397
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
6285
6398
|
logs.push(decodedLog);
|
@@ -7666,7 +7779,7 @@ var Provider = class _Provider {
|
|
7666
7779
|
},
|
7667
7780
|
transactionIds: block.transactions.map((tx) => tx.id),
|
7668
7781
|
transactions: block.transactions.map(
|
7669
|
-
(tx) => new
|
7782
|
+
(tx) => new TransactionCoder7().decode(arrayify13(tx.rawPayload), 0)?.[0]
|
7670
7783
|
)
|
7671
7784
|
};
|
7672
7785
|
}
|
@@ -7682,8 +7795,8 @@ var Provider = class _Provider {
|
|
7682
7795
|
return null;
|
7683
7796
|
}
|
7684
7797
|
try {
|
7685
|
-
return new
|
7686
|
-
|
7798
|
+
return new TransactionCoder7().decode(
|
7799
|
+
arrayify13(transaction.rawPayload),
|
7687
7800
|
0
|
7688
7801
|
)?.[0];
|
7689
7802
|
} catch (error) {
|
@@ -7708,10 +7821,10 @@ var Provider = class _Provider {
|
|
7708
7821
|
paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
|
7709
7822
|
})
|
7710
7823
|
});
|
7711
|
-
const coder = new
|
7824
|
+
const coder = new TransactionCoder7();
|
7712
7825
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
7713
7826
|
try {
|
7714
|
-
return coder.decode(
|
7827
|
+
return coder.decode(arrayify13(rawPayload), 0)[0];
|
7715
7828
|
} catch (error) {
|
7716
7829
|
if (error instanceof FuelError19 && error.code === ErrorCode17.UNSUPPORTED_TRANSACTION_TYPE) {
|
7717
7830
|
console.warn("Unsupported transaction type encountered");
|
@@ -8082,18 +8195,21 @@ var Provider = class _Provider {
|
|
8082
8195
|
extractDryRunError(transactionRequest, receipts, reason) {
|
8083
8196
|
let logs = [];
|
8084
8197
|
let groupedLogs = {};
|
8198
|
+
let abis;
|
8085
8199
|
if (transactionRequest.type === TransactionType11.Script && transactionRequest.abis) {
|
8086
8200
|
({ logs, groupedLogs } = getAllDecodedLogs({
|
8087
8201
|
receipts,
|
8088
8202
|
mainAbi: transactionRequest.abis.main,
|
8089
8203
|
externalAbis: transactionRequest.abis.otherContractsAbis
|
8090
8204
|
}));
|
8205
|
+
abis = transactionRequest.abis;
|
8091
8206
|
}
|
8092
8207
|
return extractTxError({
|
8093
8208
|
logs,
|
8094
8209
|
groupedLogs,
|
8095
8210
|
receipts,
|
8096
|
-
statusReason: reason
|
8211
|
+
statusReason: reason,
|
8212
|
+
abis
|
8097
8213
|
});
|
8098
8214
|
}
|
8099
8215
|
/**
|
@@ -8164,8 +8280,8 @@ var Provider = class _Provider {
|
|
8164
8280
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
8165
8281
|
import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
|
8166
8282
|
import { bn as bn19 } from "@fuel-ts/math";
|
8167
|
-
import { TransactionCoder as
|
8168
|
-
import { arrayify as
|
8283
|
+
import { TransactionCoder as TransactionCoder8 } from "@fuel-ts/transactions";
|
8284
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
8169
8285
|
async function getTransactionSummary(params) {
|
8170
8286
|
const { id, provider, abiMap } = params;
|
8171
8287
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -8177,8 +8293,8 @@ async function getTransactionSummary(params) {
|
|
8177
8293
|
`Transaction not found for given id: ${id}.`
|
8178
8294
|
);
|
8179
8295
|
}
|
8180
|
-
const [decodedTransaction] = new
|
8181
|
-
|
8296
|
+
const [decodedTransaction] = new TransactionCoder8().decode(
|
8297
|
+
arrayify14(gqlTransaction.rawPayload),
|
8182
8298
|
0
|
8183
8299
|
);
|
8184
8300
|
let txReceipts = [];
|
@@ -8200,7 +8316,7 @@ async function getTransactionSummary(params) {
|
|
8200
8316
|
id: gqlTransaction.id,
|
8201
8317
|
receipts,
|
8202
8318
|
transaction: decodedTransaction,
|
8203
|
-
transactionBytes:
|
8319
|
+
transactionBytes: arrayify14(gqlTransaction.rawPayload),
|
8204
8320
|
gqlTransactionStatus: gqlTransaction.status,
|
8205
8321
|
gasPerByte: bn19(gasPerByte),
|
8206
8322
|
gasPriceFactor: bn19(gasPriceFactor),
|
@@ -8266,7 +8382,7 @@ async function getTransactionsSummaries(params) {
|
|
8266
8382
|
const transactions = edges.map((edge) => {
|
8267
8383
|
const { node: gqlTransaction } = edge;
|
8268
8384
|
const { id, rawPayload, status } = gqlTransaction;
|
8269
|
-
const [decodedTransaction] = new
|
8385
|
+
const [decodedTransaction] = new TransactionCoder8().decode(arrayify14(rawPayload), 0);
|
8270
8386
|
let txReceipts = [];
|
8271
8387
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
8272
8388
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -8276,7 +8392,7 @@ async function getTransactionsSummaries(params) {
|
|
8276
8392
|
id,
|
8277
8393
|
receipts,
|
8278
8394
|
transaction: decodedTransaction,
|
8279
|
-
transactionBytes:
|
8395
|
+
transactionBytes: arrayify14(rawPayload),
|
8280
8396
|
gqlTransactionStatus: status,
|
8281
8397
|
abiMap,
|
8282
8398
|
gasPerByte,
|
@@ -8301,8 +8417,8 @@ __name(getTransactionsSummaries, "getTransactionsSummaries");
|
|
8301
8417
|
|
8302
8418
|
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
8303
8419
|
import { bn as bn20 } from "@fuel-ts/math";
|
8304
|
-
import { TransactionCoder as
|
8305
|
-
import { arrayify as
|
8420
|
+
import { TransactionCoder as TransactionCoder9 } from "@fuel-ts/transactions";
|
8421
|
+
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
8306
8422
|
var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) => {
|
8307
8423
|
const { provider, transactionSummary } = opts;
|
8308
8424
|
const { id, transactionBytes, gasPrice, receipts } = transactionSummary;
|
@@ -8314,8 +8430,8 @@ var assembleTransactionSummaryFromJson = /* @__PURE__ */ __name(async (opts) =>
|
|
8314
8430
|
gasCosts
|
8315
8431
|
}
|
8316
8432
|
} = await provider.getChain();
|
8317
|
-
const deserializedTransactionBytes =
|
8318
|
-
const [transaction] = new
|
8433
|
+
const deserializedTransactionBytes = arrayify15(transactionBytes);
|
8434
|
+
const [transaction] = new TransactionCoder9().decode(deserializedTransactionBytes, 0);
|
8319
8435
|
return assembleTransactionSummary({
|
8320
8436
|
id,
|
8321
8437
|
transaction,
|
@@ -8379,15 +8495,15 @@ var AbstractAccount = class {
|
|
8379
8495
|
// src/utils/formatTransferToContractScriptData.ts
|
8380
8496
|
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder3, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
8381
8497
|
import { Address as Address3 } from "@fuel-ts/address";
|
8382
|
-
import { arrayify as
|
8498
|
+
import { arrayify as arrayify16, concat as concat4 } from "@fuel-ts/utils";
|
8383
8499
|
import * as asm from "@fuels/vm-asm";
|
8384
8500
|
var formatTransferToContractScriptData = /* @__PURE__ */ __name((transferParams) => {
|
8385
8501
|
const numberCoder = new BigNumberCoder3("u64");
|
8386
8502
|
return transferParams.reduce((acc, transferParam) => {
|
8387
8503
|
const { assetId, amount, contractId } = transferParam;
|
8388
8504
|
const encoded = numberCoder.encode(amount);
|
8389
|
-
const scriptData =
|
8390
|
-
return
|
8505
|
+
const scriptData = concat4([new Address3(contractId).toBytes(), encoded, arrayify16(assetId)]);
|
8506
|
+
return concat4([acc, scriptData]);
|
8391
8507
|
}, new Uint8Array());
|
8392
8508
|
}, "formatTransferToContractScriptData");
|
8393
8509
|
var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferParams) => {
|
@@ -8396,7 +8512,7 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
|
|
8396
8512
|
let script = new Uint8Array();
|
8397
8513
|
transferParams.forEach((_, i) => {
|
8398
8514
|
const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
|
8399
|
-
script =
|
8515
|
+
script = concat4([
|
8400
8516
|
script,
|
8401
8517
|
// Load ScriptData into register 0x10.
|
8402
8518
|
asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
|
@@ -8412,7 +8528,7 @@ var assembleTransferToContractScript = /* @__PURE__ */ __name(async (transferPar
|
|
8412
8528
|
asm.tr(17, 19, 20).to_bytes()
|
8413
8529
|
]);
|
8414
8530
|
});
|
8415
|
-
script =
|
8531
|
+
script = concat4([script, asm.ret(1).to_bytes()]);
|
8416
8532
|
return { script, scriptData };
|
8417
8533
|
}, "assembleTransferToContractScript");
|
8418
8534
|
|
@@ -8800,14 +8916,14 @@ var Account = class extends AbstractAccount {
|
|
8800
8916
|
*/
|
8801
8917
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
8802
8918
|
const recipientAddress = new Address4(recipient);
|
8803
|
-
const recipientDataArray =
|
8919
|
+
const recipientDataArray = arrayify17(
|
8804
8920
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
8805
8921
|
);
|
8806
|
-
const amountDataArray =
|
8922
|
+
const amountDataArray = arrayify17(
|
8807
8923
|
"0x".concat(bn21(amount).toHex().substring(2).padStart(16, "0"))
|
8808
8924
|
);
|
8809
8925
|
const script = new Uint8Array([
|
8810
|
-
...
|
8926
|
+
...arrayify17(withdrawScript.bytes),
|
8811
8927
|
...recipientDataArray,
|
8812
8928
|
...amountDataArray
|
8813
8929
|
]);
|
@@ -9225,8 +9341,8 @@ import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
|
9225
9341
|
import { Address as Address5 } from "@fuel-ts/address";
|
9226
9342
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
9227
9343
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
9228
|
-
import { toBytes } from "@fuel-ts/math";
|
9229
|
-
import { hexlify as hexlify19, concat as
|
9344
|
+
import { toBytes as toBytes2 } from "@fuel-ts/math";
|
9345
|
+
import { hexlify as hexlify19, concat as concat5, arrayify as arrayify18 } from "@fuel-ts/utils";
|
9230
9346
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
9231
9347
|
var Signer = class _Signer {
|
9232
9348
|
static {
|
@@ -9248,7 +9364,7 @@ var Signer = class _Signer {
|
|
9248
9364
|
privateKey = `0x${privateKey}`;
|
9249
9365
|
}
|
9250
9366
|
}
|
9251
|
-
const privateKeyBytes =
|
9367
|
+
const privateKeyBytes = toBytes2(privateKey, 32);
|
9252
9368
|
this.privateKey = hexlify19(privateKeyBytes);
|
9253
9369
|
this.publicKey = hexlify19(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
9254
9370
|
this.compressedPublicKey = hexlify19(secp256k1.getPublicKey(privateKeyBytes, true));
|
@@ -9265,11 +9381,11 @@ var Signer = class _Signer {
|
|
9265
9381
|
* @returns hashed signature
|
9266
9382
|
*/
|
9267
9383
|
sign(data) {
|
9268
|
-
const signature = secp256k1.sign(
|
9269
|
-
const r =
|
9270
|
-
const s =
|
9384
|
+
const signature = secp256k1.sign(arrayify18(data), arrayify18(this.privateKey));
|
9385
|
+
const r = toBytes2(`0x${signature.r.toString(16)}`, 32);
|
9386
|
+
const s = toBytes2(`0x${signature.s.toString(16)}`, 32);
|
9271
9387
|
s[0] |= (signature.recovery || 0) << 7;
|
9272
|
-
return hexlify19(
|
9388
|
+
return hexlify19(concat5([r, s]));
|
9273
9389
|
}
|
9274
9390
|
/**
|
9275
9391
|
* Add point on the current elliptic curve
|
@@ -9278,8 +9394,8 @@ var Signer = class _Signer {
|
|
9278
9394
|
* @returns compressed point on the curve
|
9279
9395
|
*/
|
9280
9396
|
addPoint(point) {
|
9281
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
9282
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
9397
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify18(this.compressedPublicKey));
|
9398
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify18(point));
|
9283
9399
|
const result = p0.add(p1);
|
9284
9400
|
return `0x${result.toHex(true)}`;
|
9285
9401
|
}
|
@@ -9291,7 +9407,7 @@ var Signer = class _Signer {
|
|
9291
9407
|
* @returns public key from signature from the
|
9292
9408
|
*/
|
9293
9409
|
static recoverPublicKey(data, signature) {
|
9294
|
-
const signedMessageBytes =
|
9410
|
+
const signedMessageBytes = arrayify18(signature);
|
9295
9411
|
const r = signedMessageBytes.slice(0, 32);
|
9296
9412
|
const s = signedMessageBytes.slice(32, 64);
|
9297
9413
|
const recoveryParam = (s[0] & 128) >> 7;
|
@@ -9299,7 +9415,7 @@ var Signer = class _Signer {
|
|
9299
9415
|
const sig = new secp256k1.Signature(BigInt(hexlify19(r)), BigInt(hexlify19(s))).addRecoveryBit(
|
9300
9416
|
recoveryParam
|
9301
9417
|
);
|
9302
|
-
const publicKey = sig.recoverPublicKey(
|
9418
|
+
const publicKey = sig.recoverPublicKey(arrayify18(data)).toRawBytes(false).slice(1);
|
9303
9419
|
return hexlify19(publicKey);
|
9304
9420
|
}
|
9305
9421
|
/**
|
@@ -9319,7 +9435,7 @@ var Signer = class _Signer {
|
|
9319
9435
|
* @returns random 32-byte hashed
|
9320
9436
|
*/
|
9321
9437
|
static generatePrivateKey(entropy) {
|
9322
|
-
return entropy ? hash2(
|
9438
|
+
return entropy ? hash2(concat5([randomBytes3(32), arrayify18(entropy)])) : randomBytes3(32);
|
9323
9439
|
}
|
9324
9440
|
/**
|
9325
9441
|
* Extended publicKey from a compact publicKey
|
@@ -9328,7 +9444,7 @@ var Signer = class _Signer {
|
|
9328
9444
|
* @returns extended publicKey
|
9329
9445
|
*/
|
9330
9446
|
static extendPublicKey(publicKey) {
|
9331
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
9447
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify18(publicKey));
|
9332
9448
|
return hexlify19(point.toRawBytes(false).slice(1));
|
9333
9449
|
}
|
9334
9450
|
};
|
@@ -9565,14 +9681,14 @@ var BaseWalletUnlocked = class extends Account {
|
|
9565
9681
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
9566
9682
|
import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
|
9567
9683
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
9568
|
-
import { bn as bn22, toBytes as
|
9569
|
-
import { arrayify as
|
9684
|
+
import { bn as bn22, toBytes as toBytes3, toHex } from "@fuel-ts/math";
|
9685
|
+
import { arrayify as arrayify21, hexlify as hexlify23, concat as concat7, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
9570
9686
|
|
9571
9687
|
// src/mnemonic/mnemonic.ts
|
9572
9688
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
9573
9689
|
import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9574
9690
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
9575
|
-
import { arrayify as
|
9691
|
+
import { arrayify as arrayify20, hexlify as hexlify22, concat as concat6, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
9576
9692
|
|
9577
9693
|
// src/wordlists/words/english.ts
|
9578
9694
|
var english = [
|
@@ -11635,7 +11751,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
11635
11751
|
// src/mnemonic/utils.ts
|
11636
11752
|
import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
|
11637
11753
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
11638
|
-
import { arrayify as
|
11754
|
+
import { arrayify as arrayify19 } from "@fuel-ts/utils";
|
11639
11755
|
function getLowerMask(bits) {
|
11640
11756
|
return (1 << bits) - 1;
|
11641
11757
|
}
|
@@ -11674,7 +11790,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
11674
11790
|
}
|
11675
11791
|
}
|
11676
11792
|
const checksumBits = entropy.length / 4;
|
11677
|
-
const checksum =
|
11793
|
+
const checksum = arrayify19(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
11678
11794
|
indices[indices.length - 1] <<= checksumBits;
|
11679
11795
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
11680
11796
|
return indices;
|
@@ -11682,7 +11798,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
11682
11798
|
__name(entropyToMnemonicIndices, "entropyToMnemonicIndices");
|
11683
11799
|
function mnemonicWordsToEntropy(words, wordlist) {
|
11684
11800
|
const size = Math.ceil(11 * words.length / 8);
|
11685
|
-
const entropy =
|
11801
|
+
const entropy = arrayify19(new Uint8Array(size));
|
11686
11802
|
let offset = 0;
|
11687
11803
|
for (let i = 0; i < words.length; i += 1) {
|
11688
11804
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -11702,7 +11818,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
11702
11818
|
const entropyBits = 32 * words.length / 3;
|
11703
11819
|
const checksumBits = words.length / 3;
|
11704
11820
|
const checksumMask = getUpperMask(checksumBits);
|
11705
|
-
const checksum =
|
11821
|
+
const checksum = arrayify19(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
11706
11822
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
11707
11823
|
throw new FuelError23(
|
11708
11824
|
ErrorCode21.INVALID_CHECKSUM,
|
@@ -11792,7 +11908,7 @@ var Mnemonic = class _Mnemonic {
|
|
11792
11908
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
11793
11909
|
*/
|
11794
11910
|
static entropyToMnemonic(entropy, wordlist = english) {
|
11795
|
-
const entropyBytes =
|
11911
|
+
const entropyBytes = arrayify20(entropy);
|
11796
11912
|
assertWordList(wordlist);
|
11797
11913
|
assertEntropy(entropyBytes);
|
11798
11914
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -11861,14 +11977,14 @@ var Mnemonic = class _Mnemonic {
|
|
11861
11977
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
11862
11978
|
*/
|
11863
11979
|
static masterKeysFromSeed(seed) {
|
11864
|
-
const seedArray =
|
11980
|
+
const seedArray = arrayify20(seed);
|
11865
11981
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
11866
11982
|
throw new FuelError24(
|
11867
11983
|
ErrorCode22.INVALID_SEED,
|
11868
11984
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
11869
11985
|
);
|
11870
11986
|
}
|
11871
|
-
return
|
11987
|
+
return arrayify20(computeHmac("sha512", MasterSecret, seedArray));
|
11872
11988
|
}
|
11873
11989
|
/**
|
11874
11990
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -11879,22 +11995,22 @@ var Mnemonic = class _Mnemonic {
|
|
11879
11995
|
*/
|
11880
11996
|
static seedToExtendedKey(seed, testnet = false) {
|
11881
11997
|
const masterKey = _Mnemonic.masterKeysFromSeed(seed);
|
11882
|
-
const prefix =
|
11998
|
+
const prefix = arrayify20(testnet ? TestnetPRV : MainnetPRV);
|
11883
11999
|
const depth = "0x00";
|
11884
12000
|
const fingerprint = "0x00000000";
|
11885
12001
|
const index = "0x00000000";
|
11886
12002
|
const chainCode = masterKey.slice(32);
|
11887
12003
|
const privateKey = masterKey.slice(0, 32);
|
11888
|
-
const extendedKey =
|
12004
|
+
const extendedKey = concat6([
|
11889
12005
|
prefix,
|
11890
12006
|
depth,
|
11891
12007
|
fingerprint,
|
11892
12008
|
index,
|
11893
12009
|
chainCode,
|
11894
|
-
|
12010
|
+
concat6(["0x00", privateKey])
|
11895
12011
|
]);
|
11896
12012
|
const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
|
11897
|
-
return encodeBase58(
|
12013
|
+
return encodeBase58(concat6([extendedKey, checksum]));
|
11898
12014
|
}
|
11899
12015
|
/**
|
11900
12016
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -11909,7 +12025,7 @@ var Mnemonic = class _Mnemonic {
|
|
11909
12025
|
* @returns A randomly generated mnemonic
|
11910
12026
|
*/
|
11911
12027
|
static generate(size = 32, extraEntropy = "") {
|
11912
|
-
const entropy = extraEntropy ? sha2563(
|
12028
|
+
const entropy = extraEntropy ? sha2563(concat6([randomBytes5(size), arrayify20(extraEntropy)])) : randomBytes5(size);
|
11913
12029
|
return _Mnemonic.entropyToMnemonic(entropy);
|
11914
12030
|
}
|
11915
12031
|
};
|
@@ -11922,7 +12038,7 @@ var MainnetPUB = hexlify23("0x0488b21e");
|
|
11922
12038
|
var TestnetPRV2 = hexlify23("0x04358394");
|
11923
12039
|
var TestnetPUB = hexlify23("0x043587cf");
|
11924
12040
|
function base58check(data) {
|
11925
|
-
return encodeBase582(
|
12041
|
+
return encodeBase582(concat7([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
11926
12042
|
}
|
11927
12043
|
__name(base58check, "base58check");
|
11928
12044
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
@@ -12002,9 +12118,9 @@ var HDWallet = class _HDWallet {
|
|
12002
12118
|
* @returns A new instance of HDWallet on the derived index
|
12003
12119
|
*/
|
12004
12120
|
deriveIndex(index) {
|
12005
|
-
const privateKey = this.privateKey &&
|
12006
|
-
const publicKey =
|
12007
|
-
const chainCode =
|
12121
|
+
const privateKey = this.privateKey && arrayify21(this.privateKey);
|
12122
|
+
const publicKey = arrayify21(this.publicKey);
|
12123
|
+
const chainCode = arrayify21(this.chainCode);
|
12008
12124
|
const data = new Uint8Array(37);
|
12009
12125
|
if (index & HARDENED_INDEX) {
|
12010
12126
|
if (!privateKey) {
|
@@ -12015,10 +12131,10 @@ var HDWallet = class _HDWallet {
|
|
12015
12131
|
}
|
12016
12132
|
data.set(privateKey, 1);
|
12017
12133
|
} else {
|
12018
|
-
data.set(
|
12134
|
+
data.set(arrayify21(this.publicKey));
|
12019
12135
|
}
|
12020
|
-
data.set(
|
12021
|
-
const bytes =
|
12136
|
+
data.set(toBytes3(index, 4), 33);
|
12137
|
+
const bytes = arrayify21(computeHmac2("sha512", chainCode, data));
|
12022
12138
|
const IL = bytes.slice(0, 32);
|
12023
12139
|
const IR = bytes.slice(32);
|
12024
12140
|
if (privateKey) {
|
@@ -12071,8 +12187,8 @@ var HDWallet = class _HDWallet {
|
|
12071
12187
|
const parentFingerprint = this.parentFingerprint;
|
12072
12188
|
const index = toHex(this.index, 4);
|
12073
12189
|
const chainCode = this.chainCode;
|
12074
|
-
const key = this.privateKey != null && !isPublic ?
|
12075
|
-
const extendedKey =
|
12190
|
+
const key = this.privateKey != null && !isPublic ? concat7(["0x00", this.privateKey]) : this.publicKey;
|
12191
|
+
const extendedKey = arrayify21(concat7([prefix, depth, parentFingerprint, index, chainCode, key]));
|
12076
12192
|
return base58check(extendedKey);
|
12077
12193
|
}
|
12078
12194
|
/**
|
@@ -12084,13 +12200,13 @@ var HDWallet = class _HDWallet {
|
|
12084
12200
|
static fromSeed(seed) {
|
12085
12201
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
12086
12202
|
return new _HDWallet({
|
12087
|
-
chainCode:
|
12088
|
-
privateKey:
|
12203
|
+
chainCode: arrayify21(masterKey.slice(32)),
|
12204
|
+
privateKey: arrayify21(masterKey.slice(0, 32))
|
12089
12205
|
});
|
12090
12206
|
}
|
12091
12207
|
static fromExtendedKey(extendedKey) {
|
12092
|
-
const decoded = hexlify23(
|
12093
|
-
const bytes =
|
12208
|
+
const decoded = hexlify23(toBytes3(decodeBase58(extendedKey)));
|
12209
|
+
const bytes = arrayify21(decoded);
|
12094
12210
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
12095
12211
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
12096
12212
|
throw new FuelError25(ErrorCode23.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -12717,19 +12833,19 @@ var StorageAbstract = class {
|
|
12717
12833
|
};
|
12718
12834
|
|
12719
12835
|
// src/predicate/predicate.ts
|
12720
|
-
import { Interface as
|
12836
|
+
import { Interface as Interface5 } from "@fuel-ts/abi-coder";
|
12721
12837
|
import { Address as Address10 } from "@fuel-ts/address";
|
12722
12838
|
import { ErrorCode as ErrorCode29, FuelError as FuelError31 } from "@fuel-ts/errors";
|
12723
|
-
import { arrayify as
|
12839
|
+
import { arrayify as arrayify24, hexlify as hexlify25 } from "@fuel-ts/utils";
|
12724
12840
|
|
12725
12841
|
// src/utils/deployScriptOrPredicate.ts
|
12726
12842
|
import { FuelError as FuelError30, ErrorCode as ErrorCode28 } from "@fuel-ts/errors";
|
12727
|
-
import { arrayify as
|
12843
|
+
import { arrayify as arrayify22 } from "@fuel-ts/utils";
|
12728
12844
|
|
12729
12845
|
// src/utils/predicate-script-loader-instructions.ts
|
12730
12846
|
import { BigNumberCoder as BigNumberCoder4 } from "@fuel-ts/abi-coder";
|
12731
12847
|
import { sha256 as sha2565 } from "@fuel-ts/hasher";
|
12732
|
-
import { concat as
|
12848
|
+
import { concat as concat8 } from "@fuel-ts/utils";
|
12733
12849
|
import * as asm2 from "@fuels/vm-asm";
|
12734
12850
|
var BLOB_ID_SIZE = 32;
|
12735
12851
|
var REG_ADDRESS_OF_DATA_AFTER_CODE = 16;
|
@@ -12855,7 +12971,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
12855
12971
|
...dataSectionLenBytes
|
12856
12972
|
]);
|
12857
12973
|
return {
|
12858
|
-
loaderBytecode:
|
12974
|
+
loaderBytecode: concat8([loaderBytecode2, configurableSection]),
|
12859
12975
|
blobOffset: loaderBytecode2.length
|
12860
12976
|
};
|
12861
12977
|
}
|
@@ -12899,8 +13015,8 @@ async function deployScriptOrPredicate({
|
|
12899
13015
|
abi,
|
12900
13016
|
loaderInstanceCallback
|
12901
13017
|
}) {
|
12902
|
-
const blobId = getBytecodeId(
|
12903
|
-
const configurableOffset = getBytecodeConfigurableOffset(
|
13018
|
+
const blobId = getBytecodeId(arrayify22(bytecode));
|
13019
|
+
const configurableOffset = getBytecodeConfigurableOffset(arrayify22(bytecode));
|
12904
13020
|
const byteCodeWithoutConfigurableSection = bytecode.slice(0, configurableOffset);
|
12905
13021
|
const blobTxRequest = new BlobTransactionRequest({
|
12906
13022
|
blobId,
|
@@ -12908,8 +13024,8 @@ async function deployScriptOrPredicate({
|
|
12908
13024
|
witnesses: [byteCodeWithoutConfigurableSection]
|
12909
13025
|
});
|
12910
13026
|
const { loaderBytecode, blobOffset } = getPredicateScriptLoaderInstructions(
|
12911
|
-
|
12912
|
-
|
13027
|
+
arrayify22(bytecode),
|
13028
|
+
arrayify22(blobId)
|
12913
13029
|
);
|
12914
13030
|
const newConfigurableOffsetDiff = byteCodeWithoutConfigurableSection.length - (blobOffset || 0);
|
12915
13031
|
const newAbi = adjustConfigurableOffsets(abi, newConfigurableOffsetDiff);
|
@@ -12944,13 +13060,13 @@ __name(deployScriptOrPredicate, "deployScriptOrPredicate");
|
|
12944
13060
|
// src/predicate/utils/getPredicateRoot.ts
|
12945
13061
|
import { hash as hash3 } from "@fuel-ts/hasher";
|
12946
13062
|
import { calcRoot } from "@fuel-ts/merkle";
|
12947
|
-
import { chunkAndPadBytes, hexlify as hexlify24, concat as
|
13063
|
+
import { chunkAndPadBytes, hexlify as hexlify24, concat as concat9, arrayify as arrayify23 } from "@fuel-ts/utils";
|
12948
13064
|
var getPredicateRoot = /* @__PURE__ */ __name((bytecode) => {
|
12949
13065
|
const chunkSize = 16 * 1024;
|
12950
|
-
const bytes =
|
13066
|
+
const bytes = arrayify23(bytecode);
|
12951
13067
|
const chunks = chunkAndPadBytes(bytes, chunkSize);
|
12952
13068
|
const codeRoot = calcRoot(chunks.map((c) => hexlify24(c)));
|
12953
|
-
const predicateRoot = hash3(
|
13069
|
+
const predicateRoot = hash3(concat9(["0x4655454C", codeRoot]));
|
12954
13070
|
return predicateRoot;
|
12955
13071
|
}, "getPredicateRoot");
|
12956
13072
|
|
@@ -12987,7 +13103,7 @@ var Predicate = class _Predicate extends Account {
|
|
12987
13103
|
);
|
12988
13104
|
const address = new Address10(getPredicateRoot(predicateBytes));
|
12989
13105
|
super(address, provider);
|
12990
|
-
this.initialBytecode =
|
13106
|
+
this.initialBytecode = arrayify24(bytecode);
|
12991
13107
|
this.bytes = predicateBytes;
|
12992
13108
|
this.interface = predicateInterface;
|
12993
13109
|
this.configurableConstants = configurableConstants;
|
@@ -13079,8 +13195,8 @@ var Predicate = class _Predicate extends Account {
|
|
13079
13195
|
* @returns An object containing the new predicate bytes and interface.
|
13080
13196
|
*/
|
13081
13197
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
13082
|
-
let predicateBytes =
|
13083
|
-
const abiInterface = new
|
13198
|
+
let predicateBytes = arrayify24(bytes);
|
13199
|
+
const abiInterface = new Interface5(jsonAbi);
|
13084
13200
|
if (abiInterface.functions.main === void 0) {
|
13085
13201
|
throw new FuelError31(
|
13086
13202
|
ErrorCode29.ABI_MAIN_METHOD_MISSING,
|
@@ -13974,6 +14090,7 @@ export {
|
|
13974
14090
|
assemblePreConfirmationTransactionSummary,
|
13975
14091
|
assembleReceiptByType,
|
13976
14092
|
assembleRevertError,
|
14093
|
+
assembleSignalErrorMessage,
|
13977
14094
|
assembleTransactionSummary,
|
13978
14095
|
assembleTransactionSummaryFromJson,
|
13979
14096
|
assets,
|