@fuel-ts/account 0.0.0-pr-1784-20240221124858 → 0.0.0-pr-1788-20240222085506
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/account.d.ts +1 -2
- package/dist/account.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +183 -183
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +188 -188
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -132
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/memory-cache.d.ts +1 -1
- package/dist/providers/memory-cache.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +1 -2
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/output.d.ts +1 -1
- package/dist/providers/transaction-request/output.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/witness.d.ts +1 -1
- package/dist/providers/transaction-request/witness.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +1 -1
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +2888 -2888
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +183 -183
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +112 -124
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/wallet.d.ts +1 -2
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallets.d.ts +1 -1
- package/dist/wallet/wallets.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.mjs
CHANGED
@@ -33,12 +33,12 @@ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
|
33
33
|
import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
|
34
34
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
35
35
|
import { bn as bn16 } from "@fuel-ts/math";
|
36
|
-
import {
|
36
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
37
37
|
|
38
38
|
// src/providers/coin-quantity.ts
|
39
39
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
40
40
|
import { bn } from "@fuel-ts/math";
|
41
|
-
import { hexlify } from "
|
41
|
+
import { hexlify } from "@fuel-ts/utils";
|
42
42
|
var coinQuantityfy = (coinQuantityLike) => {
|
43
43
|
let assetId;
|
44
44
|
let amount;
|
@@ -81,10 +81,10 @@ import {
|
|
81
81
|
InputMessageCoder,
|
82
82
|
TransactionCoder as TransactionCoder5
|
83
83
|
} from "@fuel-ts/transactions";
|
84
|
-
import { arrayify } from "@fuel-ts/utils";
|
84
|
+
import { arrayify as arrayify11, hexlify as hexlify12 } from "@fuel-ts/utils";
|
85
85
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
86
86
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
87
|
-
import {
|
87
|
+
import { Network } from "ethers";
|
88
88
|
import { GraphQLClient } from "graphql-request";
|
89
89
|
import { clone as clone3 } from "ramda";
|
90
90
|
|
@@ -957,7 +957,7 @@ async function* fuelGraphQLSubscriber({
|
|
957
957
|
|
958
958
|
// src/providers/memory-cache.ts
|
959
959
|
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
960
|
-
import { hexlify as hexlify2 } from "
|
960
|
+
import { hexlify as hexlify2 } from "@fuel-ts/utils";
|
961
961
|
var cache = {};
|
962
962
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
963
963
|
var MemoryCache = class {
|
@@ -1019,23 +1019,23 @@ import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
|
1019
1019
|
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1020
1020
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1021
1021
|
import { InputType } from "@fuel-ts/transactions";
|
1022
|
-
import {
|
1022
|
+
import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
|
1023
1023
|
var inputify = (value) => {
|
1024
1024
|
const { type } = value;
|
1025
1025
|
switch (value.type) {
|
1026
1026
|
case InputType.Coin: {
|
1027
|
-
const predicate =
|
1028
|
-
const predicateData =
|
1027
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
1028
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
1029
1029
|
return {
|
1030
1030
|
type: InputType.Coin,
|
1031
|
-
txID: hexlify3(
|
1032
|
-
outputIndex:
|
1031
|
+
txID: hexlify3(arrayify(value.id).slice(0, 32)),
|
1032
|
+
outputIndex: arrayify(value.id)[32],
|
1033
1033
|
owner: hexlify3(value.owner),
|
1034
1034
|
amount: bn2(value.amount),
|
1035
1035
|
assetId: hexlify3(value.assetId),
|
1036
1036
|
txPointer: {
|
1037
|
-
blockHeight: toNumber(
|
1038
|
-
txIndex: toNumber(
|
1037
|
+
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1038
|
+
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1039
1039
|
},
|
1040
1040
|
witnessIndex: value.witnessIndex,
|
1041
1041
|
maturity: value.maturity ?? 0,
|
@@ -1054,16 +1054,16 @@ var inputify = (value) => {
|
|
1054
1054
|
balanceRoot: ZeroBytes32,
|
1055
1055
|
stateRoot: ZeroBytes32,
|
1056
1056
|
txPointer: {
|
1057
|
-
blockHeight: toNumber(
|
1058
|
-
txIndex: toNumber(
|
1057
|
+
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1058
|
+
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1059
1059
|
},
|
1060
1060
|
contractID: hexlify3(value.contractId)
|
1061
1061
|
};
|
1062
1062
|
}
|
1063
1063
|
case InputType.Message: {
|
1064
|
-
const predicate =
|
1065
|
-
const predicateData =
|
1066
|
-
const data =
|
1064
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
1065
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
1066
|
+
const data = arrayify(value.data ?? "0x");
|
1067
1067
|
return {
|
1068
1068
|
type: InputType.Message,
|
1069
1069
|
sender: hexlify3(value.sender),
|
@@ -1094,7 +1094,7 @@ import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
|
1094
1094
|
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1095
1095
|
import { bn as bn3 } from "@fuel-ts/math";
|
1096
1096
|
import { OutputType } from "@fuel-ts/transactions";
|
1097
|
-
import { hexlify as hexlify4 } from "
|
1097
|
+
import { hexlify as hexlify4 } from "@fuel-ts/utils";
|
1098
1098
|
var outputify = (value) => {
|
1099
1099
|
const { type } = value;
|
1100
1100
|
switch (type) {
|
@@ -1157,7 +1157,7 @@ import {
|
|
1157
1157
|
OutputType as OutputType2,
|
1158
1158
|
TransactionType
|
1159
1159
|
} from "@fuel-ts/transactions";
|
1160
|
-
import { concat, hexlify as hexlify7 } from "
|
1160
|
+
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1161
1161
|
|
1162
1162
|
// src/providers/resource.ts
|
1163
1163
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1176,7 +1176,7 @@ import {
|
|
1176
1176
|
ReceiptType
|
1177
1177
|
} from "@fuel-ts/transactions";
|
1178
1178
|
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
1179
|
-
import {
|
1179
|
+
import { arrayify as arrayify2 } from "@fuel-ts/utils";
|
1180
1180
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1181
1181
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1182
1182
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1320,7 +1320,7 @@ function assembleReceiptByType(receipt) {
|
|
1320
1320
|
const recipient = hexOrZero(receipt.recipient);
|
1321
1321
|
const nonce = hexOrZero(receipt.nonce);
|
1322
1322
|
const amount = bn4(receipt.amount);
|
1323
|
-
const data = receipt.data ?
|
1323
|
+
const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
|
1324
1324
|
const digest = hexOrZero(receipt.digest);
|
1325
1325
|
const messageId = ReceiptMessageOutCoder.getMessageId({
|
1326
1326
|
sender,
|
@@ -1441,7 +1441,7 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1441
1441
|
// src/providers/utils/gas.ts
|
1442
1442
|
import { bn as bn5 } from "@fuel-ts/math";
|
1443
1443
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1444
|
-
import {
|
1444
|
+
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1445
1445
|
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1446
1446
|
var getGasUsedFromReceipts = (receipts) => {
|
1447
1447
|
const scriptResult = receipts.filter(
|
@@ -1466,9 +1466,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
1466
1466
|
const totalGas = inputs.reduce((total, input) => {
|
1467
1467
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1468
1468
|
return total.add(
|
1469
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
1470
|
-
resolveGasDependentCosts(getBytesCopy3(input.predicate).length, gasCosts.contractRoot)
|
1471
|
-
).add(bn5(input.predicateGasUsed))
|
1469
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1472
1470
|
);
|
1473
1471
|
}
|
1474
1472
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -1517,7 +1515,7 @@ function calculateMetadataGasForTxScript({
|
|
1517
1515
|
}
|
1518
1516
|
|
1519
1517
|
// src/providers/utils/json.ts
|
1520
|
-
import { hexlify as hexlify5 } from "
|
1518
|
+
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
1521
1519
|
import { clone } from "ramda";
|
1522
1520
|
function normalize(object) {
|
1523
1521
|
Object.keys(object).forEach((key) => {
|
@@ -1583,9 +1581,9 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1583
1581
|
};
|
1584
1582
|
|
1585
1583
|
// src/providers/transaction-request/witness.ts
|
1586
|
-
import {
|
1584
|
+
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1587
1585
|
var witnessify = (value) => {
|
1588
|
-
const data =
|
1586
|
+
const data = arrayify4(value);
|
1589
1587
|
return {
|
1590
1588
|
data: hexlify6(data),
|
1591
1589
|
dataLength: data.length
|
@@ -2087,14 +2085,15 @@ var BaseTransactionRequest = class {
|
|
2087
2085
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2088
2086
|
import { bn as bn8 } from "@fuel-ts/math";
|
2089
2087
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2090
|
-
import {
|
2088
|
+
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2091
2089
|
|
2092
2090
|
// src/providers/transaction-request/hash-transaction.ts
|
2093
2091
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2094
2092
|
import { uint64ToBytesBE } from "@fuel-ts/hasher";
|
2095
2093
|
import { bn as bn7 } from "@fuel-ts/math";
|
2096
2094
|
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2097
|
-
import { concat as concat2
|
2095
|
+
import { concat as concat2 } from "@fuel-ts/utils";
|
2096
|
+
import { sha256 } from "ethers";
|
2098
2097
|
import { clone as clone2 } from "ramda";
|
2099
2098
|
function hashTransaction(transactionRequest, chainId) {
|
2100
2099
|
const transaction = transactionRequest.toTransaction();
|
@@ -2161,10 +2160,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2161
2160
|
}
|
2162
2161
|
|
2163
2162
|
// src/providers/transaction-request/storage-slot.ts
|
2164
|
-
import {
|
2163
|
+
import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
|
2165
2164
|
var getStorageValue = (value) => {
|
2166
2165
|
const v = new Uint8Array(32);
|
2167
|
-
v.set(
|
2166
|
+
v.set(arrayify5(value));
|
2168
2167
|
return v;
|
2169
2168
|
};
|
2170
2169
|
var storageSlotify = (storageSlot) => {
|
@@ -2269,7 +2268,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2269
2268
|
}
|
2270
2269
|
metadataGas(gasCosts) {
|
2271
2270
|
return calculateMetadataGasForTxCreate({
|
2272
|
-
contractBytesSize: bn8(
|
2271
|
+
contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2273
2272
|
gasCosts,
|
2274
2273
|
stateRootSize: this.storageSlots.length,
|
2275
2274
|
txBytesSize: this.byteSize()
|
@@ -2283,17 +2282,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
|
|
2283
2282
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2284
2283
|
import { bn as bn9 } from "@fuel-ts/math";
|
2285
2284
|
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2286
|
-
import {
|
2285
|
+
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2287
2286
|
|
2288
2287
|
// src/providers/transaction-request/scripts.ts
|
2289
|
-
import {
|
2288
|
+
import { arrayify as arrayify7 } from "@fuel-ts/utils";
|
2290
2289
|
var returnZeroScript = {
|
2291
2290
|
/*
|
2292
2291
|
Opcode::RET(REG_ZERO)
|
2293
2292
|
Opcode::NOOP
|
2294
2293
|
*/
|
2295
2294
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2296
|
-
bytes:
|
2295
|
+
bytes: arrayify7("0x24000000"),
|
2297
2296
|
encodeScriptData: () => new Uint8Array(0)
|
2298
2297
|
};
|
2299
2298
|
var withdrawScript = {
|
@@ -2307,7 +2306,7 @@ var withdrawScript = {
|
|
2307
2306
|
00000000 00000000 [amount value]
|
2308
2307
|
*/
|
2309
2308
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2310
|
-
bytes:
|
2309
|
+
bytes: arrayify7("0x5040C0105D44C0064C40001124000000"),
|
2311
2310
|
encodeScriptData: () => new Uint8Array(0)
|
2312
2311
|
};
|
2313
2312
|
|
@@ -2335,8 +2334,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2335
2334
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2336
2335
|
super(rest);
|
2337
2336
|
this.gasLimit = bn9(gasLimit);
|
2338
|
-
this.script =
|
2339
|
-
this.scriptData =
|
2337
|
+
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2338
|
+
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2340
2339
|
}
|
2341
2340
|
/**
|
2342
2341
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2344,8 +2343,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2344
2343
|
* @returns The transaction script object.
|
2345
2344
|
*/
|
2346
2345
|
toTransaction() {
|
2347
|
-
const script =
|
2348
|
-
const scriptData =
|
2346
|
+
const script = arrayify8(this.script ?? "0x");
|
2347
|
+
const scriptData = arrayify8(this.scriptData ?? "0x");
|
2349
2348
|
return {
|
2350
2349
|
type: TransactionType4.Script,
|
2351
2350
|
scriptGasLimit: this.gasLimit,
|
@@ -2505,15 +2504,15 @@ var transactionRequestify = (obj) => {
|
|
2505
2504
|
import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
|
2506
2505
|
import { bn as bn13 } from "@fuel-ts/math";
|
2507
2506
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2508
|
-
import {
|
2507
|
+
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2509
2508
|
|
2510
2509
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2511
|
-
import { hexlify as hexlify11 } from "
|
2510
|
+
import { hexlify as hexlify11 } from "@fuel-ts/utils";
|
2512
2511
|
|
2513
2512
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2514
2513
|
import { bn as bn10 } from "@fuel-ts/math";
|
2515
2514
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2516
|
-
import {
|
2515
|
+
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2517
2516
|
var calculateTransactionFee = (params) => {
|
2518
2517
|
const {
|
2519
2518
|
gasUsed,
|
@@ -2522,7 +2521,7 @@ var calculateTransactionFee = (params) => {
|
|
2522
2521
|
} = params;
|
2523
2522
|
const gasPerByte = bn10(feeParams.gasPerByte);
|
2524
2523
|
const gasPriceFactor = bn10(feeParams.gasPriceFactor);
|
2525
|
-
const transactionBytes =
|
2524
|
+
const transactionBytes = arrayify9(rawPayload);
|
2526
2525
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2527
2526
|
if (transaction.type === TransactionType6.Mint) {
|
2528
2527
|
return {
|
@@ -2537,7 +2536,7 @@ var calculateTransactionFee = (params) => {
|
|
2537
2536
|
let gasLimit = bn10(0);
|
2538
2537
|
if (type === TransactionType6.Create) {
|
2539
2538
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2540
|
-
const contractBytesSize = bn10(
|
2539
|
+
const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2541
2540
|
metadataGas = calculateMetadataGasForTxCreate({
|
2542
2541
|
contractBytesSize,
|
2543
2542
|
gasCosts,
|
@@ -3342,7 +3341,7 @@ var TransactionResponse = class {
|
|
3342
3341
|
*/
|
3343
3342
|
decodeTransaction(transactionWithReceipts) {
|
3344
3343
|
return new TransactionCoder4().decode(
|
3345
|
-
|
3344
|
+
arrayify10(transactionWithReceipts.rawPayload),
|
3346
3345
|
0
|
3347
3346
|
)?.[0];
|
3348
3347
|
}
|
@@ -3368,7 +3367,7 @@ var TransactionResponse = class {
|
|
3368
3367
|
id: this.id,
|
3369
3368
|
receipts,
|
3370
3369
|
transaction: decodedTransaction,
|
3371
|
-
transactionBytes:
|
3370
|
+
transactionBytes: arrayify10(transaction.rawPayload),
|
3372
3371
|
gqlTransactionStatus: transaction.status,
|
3373
3372
|
gasPerByte,
|
3374
3373
|
gasPriceFactor,
|
@@ -3823,7 +3822,7 @@ var _Provider = class {
|
|
3823
3822
|
async estimatePredicates(transactionRequest) {
|
3824
3823
|
const shouldEstimatePredicates = Boolean(
|
3825
3824
|
transactionRequest.inputs.find(
|
3826
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(
|
3825
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN(input.predicateGasUsed).isZero()
|
3827
3826
|
)
|
3828
3827
|
);
|
3829
3828
|
if (!shouldEstimatePredicates) {
|
@@ -4146,7 +4145,7 @@ var _Provider = class {
|
|
4146
4145
|
time: block.header.time,
|
4147
4146
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4148
4147
|
transactions: block.transactions.map(
|
4149
|
-
(tx) => new TransactionCoder5().decode(
|
4148
|
+
(tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
|
4150
4149
|
)
|
4151
4150
|
};
|
4152
4151
|
}
|
@@ -4162,7 +4161,7 @@ var _Provider = class {
|
|
4162
4161
|
return null;
|
4163
4162
|
}
|
4164
4163
|
return new TransactionCoder5().decode(
|
4165
|
-
|
4164
|
+
arrayify11(transaction.rawPayload),
|
4166
4165
|
0
|
4167
4166
|
)?.[0];
|
4168
4167
|
}
|
@@ -4392,7 +4391,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4392
4391
|
import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
|
4393
4392
|
import { bn as bn15 } from "@fuel-ts/math";
|
4394
4393
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4395
|
-
import {
|
4394
|
+
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4396
4395
|
async function getTransactionSummary(params) {
|
4397
4396
|
const { id, provider, abiMap } = params;
|
4398
4397
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -4405,7 +4404,7 @@ async function getTransactionSummary(params) {
|
|
4405
4404
|
);
|
4406
4405
|
}
|
4407
4406
|
const [decodedTransaction] = new TransactionCoder6().decode(
|
4408
|
-
|
4407
|
+
arrayify12(gqlTransaction.rawPayload),
|
4409
4408
|
0
|
4410
4409
|
);
|
4411
4410
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -4416,7 +4415,7 @@ async function getTransactionSummary(params) {
|
|
4416
4415
|
id: gqlTransaction.id,
|
4417
4416
|
receipts,
|
4418
4417
|
transaction: decodedTransaction,
|
4419
|
-
transactionBytes:
|
4418
|
+
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4420
4419
|
gqlTransactionStatus: gqlTransaction.status,
|
4421
4420
|
gasPerByte: bn15(gasPerByte),
|
4422
4421
|
gasPriceFactor: bn15(gasPriceFactor),
|
@@ -4458,13 +4457,13 @@ async function getTransactionsSummaries(params) {
|
|
4458
4457
|
const transactions = edges.map((edge) => {
|
4459
4458
|
const { node: gqlTransaction } = edge;
|
4460
4459
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4461
|
-
const [decodedTransaction] = new TransactionCoder6().decode(
|
4460
|
+
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4462
4461
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4463
4462
|
const transactionSummary = assembleTransactionSummary({
|
4464
4463
|
id,
|
4465
4464
|
receipts,
|
4466
4465
|
transaction: decodedTransaction,
|
4467
|
-
transactionBytes:
|
4466
|
+
transactionBytes: arrayify12(rawPayload),
|
4468
4467
|
gqlTransactionStatus: status,
|
4469
4468
|
abiMap,
|
4470
4469
|
gasPerByte,
|
@@ -4608,16 +4607,16 @@ var assets = [
|
|
4608
4607
|
// src/utils/formatTransferToContractScriptData.ts
|
4609
4608
|
import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
|
4610
4609
|
import { BN as BN2 } from "@fuel-ts/math";
|
4610
|
+
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
4611
4611
|
import * as asm from "@fuels/vm-asm";
|
4612
|
-
import { getBytesCopy as getBytesCopy13 } from "ethers";
|
4613
4612
|
var formatTransferToContractScriptData = (params) => {
|
4614
4613
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4615
4614
|
const numberCoder = new U64Coder2();
|
4616
4615
|
const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
|
4617
4616
|
const scriptData = Uint8Array.from([
|
4618
|
-
...
|
4617
|
+
...arrayify13(hexlifiedContractId),
|
4619
4618
|
...encoded,
|
4620
|
-
...
|
4619
|
+
...arrayify13(assetId)
|
4621
4620
|
]);
|
4622
4621
|
return scriptData;
|
4623
4622
|
};
|
@@ -4945,14 +4944,14 @@ var Account = class extends AbstractAccount {
|
|
4945
4944
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4946
4945
|
const { minGasPrice } = this.provider.getGasConfig();
|
4947
4946
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
4948
|
-
const recipientDataArray =
|
4947
|
+
const recipientDataArray = arrayify14(
|
4949
4948
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4950
4949
|
);
|
4951
|
-
const amountDataArray =
|
4950
|
+
const amountDataArray = arrayify14(
|
4952
4951
|
"0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
|
4953
4952
|
);
|
4954
4953
|
const script = new Uint8Array([
|
4955
|
-
...
|
4954
|
+
...arrayify14(withdrawScript.bytes),
|
4956
4955
|
...recipientDataArray,
|
4957
4956
|
...amountDataArray
|
4958
4957
|
]);
|
@@ -5036,14 +5035,15 @@ var Account = class extends AbstractAccount {
|
|
5036
5035
|
|
5037
5036
|
// src/wallet/base-wallet-unlocked.ts
|
5038
5037
|
import { hashMessage } from "@fuel-ts/hasher";
|
5038
|
+
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
5039
5039
|
|
5040
5040
|
// src/signer/signer.ts
|
5041
5041
|
import { Address as Address4 } from "@fuel-ts/address";
|
5042
5042
|
import { randomBytes } from "@fuel-ts/crypto";
|
5043
5043
|
import { hash } from "@fuel-ts/hasher";
|
5044
5044
|
import { toBytes } from "@fuel-ts/math";
|
5045
|
+
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
5045
5046
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
5046
|
-
import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy15 } from "ethers";
|
5047
5047
|
var Signer = class {
|
5048
5048
|
address;
|
5049
5049
|
publicKey;
|
@@ -5078,11 +5078,11 @@ var Signer = class {
|
|
5078
5078
|
* @returns hashed signature
|
5079
5079
|
*/
|
5080
5080
|
sign(data) {
|
5081
|
-
const signature = secp256k1.sign(
|
5081
|
+
const signature = secp256k1.sign(arrayify15(data), arrayify15(this.privateKey));
|
5082
5082
|
const r = toBytes(`0x${signature.r.toString(16)}`, 32);
|
5083
5083
|
const s = toBytes(`0x${signature.s.toString(16)}`, 32);
|
5084
5084
|
s[0] |= (signature.recovery || 0) << 7;
|
5085
|
-
return concat3([r, s]);
|
5085
|
+
return hexlify13(concat3([r, s]));
|
5086
5086
|
}
|
5087
5087
|
/**
|
5088
5088
|
* Add point on the current elliptic curve
|
@@ -5091,8 +5091,8 @@ var Signer = class {
|
|
5091
5091
|
* @returns compressed point on the curve
|
5092
5092
|
*/
|
5093
5093
|
addPoint(point) {
|
5094
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
5095
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
5094
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify15(this.compressedPublicKey));
|
5095
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify15(point));
|
5096
5096
|
const result = p0.add(p1);
|
5097
5097
|
return `0x${result.toHex(true)}`;
|
5098
5098
|
}
|
@@ -5104,7 +5104,7 @@ var Signer = class {
|
|
5104
5104
|
* @returns public key from signature from the
|
5105
5105
|
*/
|
5106
5106
|
static recoverPublicKey(data, signature) {
|
5107
|
-
const signedMessageBytes =
|
5107
|
+
const signedMessageBytes = arrayify15(signature);
|
5108
5108
|
const r = signedMessageBytes.slice(0, 32);
|
5109
5109
|
const s = signedMessageBytes.slice(32, 64);
|
5110
5110
|
const recoveryParam = (s[0] & 128) >> 7;
|
@@ -5112,7 +5112,7 @@ var Signer = class {
|
|
5112
5112
|
const sig = new secp256k1.Signature(BigInt(hexlify13(r)), BigInt(hexlify13(s))).addRecoveryBit(
|
5113
5113
|
recoveryParam
|
5114
5114
|
);
|
5115
|
-
const publicKey = sig.recoverPublicKey(
|
5115
|
+
const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
|
5116
5116
|
return hexlify13(publicKey);
|
5117
5117
|
}
|
5118
5118
|
/**
|
@@ -5132,7 +5132,7 @@ var Signer = class {
|
|
5132
5132
|
* @returns random 32-byte hashed
|
5133
5133
|
*/
|
5134
5134
|
static generatePrivateKey(entropy) {
|
5135
|
-
return entropy ? hash(concat3([randomBytes(32),
|
5135
|
+
return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
|
5136
5136
|
}
|
5137
5137
|
/**
|
5138
5138
|
* Extended publicKey from a compact publicKey
|
@@ -5141,7 +5141,7 @@ var Signer = class {
|
|
5141
5141
|
* @returns extended publicKey
|
5142
5142
|
*/
|
5143
5143
|
static extendPublicKey(publicKey) {
|
5144
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
5144
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
|
5145
5145
|
return hexlify13(point.toRawBytes(false).slice(1));
|
5146
5146
|
}
|
5147
5147
|
};
|
@@ -5158,7 +5158,7 @@ import {
|
|
5158
5158
|
encryptJsonWalletData
|
5159
5159
|
} from "@fuel-ts/crypto";
|
5160
5160
|
import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
|
5161
|
-
import { hexlify as hexlify14 } from "
|
5161
|
+
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
5162
5162
|
import { v4 as uuidv4 } from "uuid";
|
5163
5163
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5164
5164
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5286,7 +5286,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5286
5286
|
*/
|
5287
5287
|
async signMessage(message) {
|
5288
5288
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
5289
|
-
return signedMessage;
|
5289
|
+
return hexlify15(signedMessage);
|
5290
5290
|
}
|
5291
5291
|
/**
|
5292
5292
|
* Signs a transaction with the wallet's private key.
|
@@ -5299,7 +5299,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5299
5299
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5300
5300
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5301
5301
|
const signature = await this.signer().sign(hashedTransaction);
|
5302
|
-
return signature;
|
5302
|
+
return hexlify15(signature);
|
5303
5303
|
}
|
5304
5304
|
/**
|
5305
5305
|
* Populates a transaction with the witnesses signature.
|
@@ -5360,32 +5360,22 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5360
5360
|
// src/hdwallet/hdwallet.ts
|
5361
5361
|
import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5362
5362
|
import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5363
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5363
5364
|
import {
|
5364
5365
|
toBeHex,
|
5365
5366
|
dataSlice as dataSlice2,
|
5366
|
-
hexlify as hexlify16,
|
5367
5367
|
encodeBase58 as encodeBase582,
|
5368
5368
|
decodeBase58,
|
5369
5369
|
sha256 as sha2564,
|
5370
5370
|
computeHmac as computeHmac2,
|
5371
|
-
ripemd160
|
5372
|
-
getBytesCopy as getBytesCopy18,
|
5373
|
-
concat as concat5
|
5371
|
+
ripemd160
|
5374
5372
|
} from "ethers";
|
5375
5373
|
|
5376
5374
|
// src/mnemonic/mnemonic.ts
|
5377
5375
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
5378
5376
|
import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
|
5379
|
-
import {
|
5380
|
-
|
5381
|
-
hexlify as hexlify15,
|
5382
|
-
dataSlice,
|
5383
|
-
pbkdf2,
|
5384
|
-
sha256 as sha2563,
|
5385
|
-
computeHmac,
|
5386
|
-
encodeBase58,
|
5387
|
-
getBytesCopy as getBytesCopy17
|
5388
|
-
} from "ethers";
|
5377
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5378
|
+
import { dataSlice, pbkdf2, sha256 as sha2563, computeHmac, encodeBase58 } from "ethers";
|
5389
5379
|
|
5390
5380
|
// src/wordlists/words/english.ts
|
5391
5381
|
var english = [
|
@@ -7447,7 +7437,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7447
7437
|
|
7448
7438
|
// src/mnemonic/utils.ts
|
7449
7439
|
import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
|
7450
|
-
import {
|
7440
|
+
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7441
|
+
import { sha256 as sha2562 } from "ethers";
|
7451
7442
|
function toUtf8Bytes(stri) {
|
7452
7443
|
const str = stri.normalize("NFKD");
|
7453
7444
|
const result = [];
|
@@ -7514,14 +7505,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7514
7505
|
}
|
7515
7506
|
}
|
7516
7507
|
const checksumBits = entropy.length / 4;
|
7517
|
-
const checksum =
|
7508
|
+
const checksum = arrayify16(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
7518
7509
|
indices[indices.length - 1] <<= checksumBits;
|
7519
7510
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7520
7511
|
return indices;
|
7521
7512
|
}
|
7522
7513
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7523
7514
|
const size = Math.ceil(11 * words.length / 8);
|
7524
|
-
const entropy =
|
7515
|
+
const entropy = arrayify16(new Uint8Array(size));
|
7525
7516
|
let offset = 0;
|
7526
7517
|
for (let i = 0; i < words.length; i += 1) {
|
7527
7518
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7541,7 +7532,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7541
7532
|
const entropyBits = 32 * words.length / 3;
|
7542
7533
|
const checksumBits = words.length / 3;
|
7543
7534
|
const checksumMask = getUpperMask(checksumBits);
|
7544
|
-
const checksum =
|
7535
|
+
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7545
7536
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7546
7537
|
throw new FuelError16(
|
7547
7538
|
ErrorCode15.INVALID_CHECKSUM,
|
@@ -7616,7 +7607,7 @@ var Mnemonic = class {
|
|
7616
7607
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7617
7608
|
const words = getWords(phrase);
|
7618
7609
|
assertMnemonic(words);
|
7619
|
-
return
|
7610
|
+
return hexlify16(mnemonicWordsToEntropy(words, wordlist));
|
7620
7611
|
}
|
7621
7612
|
/**
|
7622
7613
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7624,7 +7615,7 @@ var Mnemonic = class {
|
|
7624
7615
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7625
7616
|
*/
|
7626
7617
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7627
|
-
const entropyBytes =
|
7618
|
+
const entropyBytes = arrayify17(entropy);
|
7628
7619
|
assertWordList(wordlist);
|
7629
7620
|
assertEntropy(entropyBytes);
|
7630
7621
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7693,14 +7684,14 @@ var Mnemonic = class {
|
|
7693
7684
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7694
7685
|
*/
|
7695
7686
|
static masterKeysFromSeed(seed) {
|
7696
|
-
const seedArray =
|
7687
|
+
const seedArray = arrayify17(seed);
|
7697
7688
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7698
7689
|
throw new FuelError17(
|
7699
7690
|
ErrorCode16.INVALID_SEED,
|
7700
7691
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7701
7692
|
);
|
7702
7693
|
}
|
7703
|
-
return
|
7694
|
+
return arrayify17(computeHmac("sha512", MasterSecret, seedArray));
|
7704
7695
|
}
|
7705
7696
|
/**
|
7706
7697
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7711,7 +7702,7 @@ var Mnemonic = class {
|
|
7711
7702
|
*/
|
7712
7703
|
static seedToExtendedKey(seed, testnet = false) {
|
7713
7704
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7714
|
-
const prefix =
|
7705
|
+
const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
|
7715
7706
|
const depth = "0x00";
|
7716
7707
|
const fingerprint = "0x00000000";
|
7717
7708
|
const index = "0x00000000";
|
@@ -7741,7 +7732,7 @@ var Mnemonic = class {
|
|
7741
7732
|
* @returns A randomly generated mnemonic
|
7742
7733
|
*/
|
7743
7734
|
static generate(size = 32, extraEntropy = "") {
|
7744
|
-
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size),
|
7735
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
|
7745
7736
|
return Mnemonic.entropyToMnemonic(entropy);
|
7746
7737
|
}
|
7747
7738
|
};
|
@@ -7749,10 +7740,10 @@ var mnemonic_default = Mnemonic;
|
|
7749
7740
|
|
7750
7741
|
// src/hdwallet/hdwallet.ts
|
7751
7742
|
var HARDENED_INDEX = 2147483648;
|
7752
|
-
var MainnetPRV2 =
|
7753
|
-
var MainnetPUB =
|
7754
|
-
var TestnetPRV2 =
|
7755
|
-
var TestnetPUB =
|
7743
|
+
var MainnetPRV2 = hexlify17("0x0488ade4");
|
7744
|
+
var MainnetPUB = hexlify17("0x0488b21e");
|
7745
|
+
var TestnetPRV2 = hexlify17("0x04358394");
|
7746
|
+
var TestnetPUB = hexlify17("0x043587cf");
|
7756
7747
|
function base58check(data) {
|
7757
7748
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
7758
7749
|
}
|
@@ -7763,11 +7754,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7763
7754
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7764
7755
|
}
|
7765
7756
|
function isPublicExtendedKey(extendedKey) {
|
7766
|
-
return [MainnetPUB, TestnetPUB].includes(
|
7757
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify17(extendedKey.slice(0, 4)));
|
7767
7758
|
}
|
7768
7759
|
function isValidExtendedKey(extendedKey) {
|
7769
7760
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7770
|
-
|
7761
|
+
hexlify17(extendedKey.slice(0, 4))
|
7771
7762
|
);
|
7772
7763
|
}
|
7773
7764
|
function parsePath(path, depth = 0) {
|
@@ -7785,8 +7776,8 @@ function parsePath(path, depth = 0) {
|
|
7785
7776
|
var HDWallet = class {
|
7786
7777
|
depth = 0;
|
7787
7778
|
index = 0;
|
7788
|
-
fingerprint =
|
7789
|
-
parentFingerprint =
|
7779
|
+
fingerprint = hexlify17("0x00000000");
|
7780
|
+
parentFingerprint = hexlify17("0x00000000");
|
7790
7781
|
privateKey;
|
7791
7782
|
publicKey;
|
7792
7783
|
chainCode;
|
@@ -7798,8 +7789,8 @@ var HDWallet = class {
|
|
7798
7789
|
constructor(config) {
|
7799
7790
|
if (config.privateKey) {
|
7800
7791
|
const signer = new Signer(config.privateKey);
|
7801
|
-
this.publicKey =
|
7802
|
-
this.privateKey =
|
7792
|
+
this.publicKey = hexlify17(signer.compressedPublicKey);
|
7793
|
+
this.privateKey = hexlify17(config.privateKey);
|
7803
7794
|
} else {
|
7804
7795
|
if (!config.publicKey) {
|
7805
7796
|
throw new FuelError18(
|
@@ -7807,7 +7798,7 @@ var HDWallet = class {
|
|
7807
7798
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7808
7799
|
);
|
7809
7800
|
}
|
7810
|
-
this.publicKey =
|
7801
|
+
this.publicKey = hexlify17(config.publicKey);
|
7811
7802
|
}
|
7812
7803
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7813
7804
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -7826,9 +7817,9 @@ var HDWallet = class {
|
|
7826
7817
|
* @returns A new instance of HDWallet on the derived index
|
7827
7818
|
*/
|
7828
7819
|
deriveIndex(index) {
|
7829
|
-
const privateKey = this.privateKey &&
|
7830
|
-
const publicKey =
|
7831
|
-
const chainCode =
|
7820
|
+
const privateKey = this.privateKey && arrayify18(this.privateKey);
|
7821
|
+
const publicKey = arrayify18(this.publicKey);
|
7822
|
+
const chainCode = arrayify18(this.chainCode);
|
7832
7823
|
const data = new Uint8Array(37);
|
7833
7824
|
if (index & HARDENED_INDEX) {
|
7834
7825
|
if (!privateKey) {
|
@@ -7839,10 +7830,10 @@ var HDWallet = class {
|
|
7839
7830
|
}
|
7840
7831
|
data.set(privateKey, 1);
|
7841
7832
|
} else {
|
7842
|
-
data.set(
|
7833
|
+
data.set(arrayify18(this.publicKey));
|
7843
7834
|
}
|
7844
7835
|
data.set(toBytes2(index, 4), 33);
|
7845
|
-
const bytes =
|
7836
|
+
const bytes = arrayify18(computeHmac2("sha512", chainCode, data));
|
7846
7837
|
const IL = bytes.slice(0, 32);
|
7847
7838
|
const IR = bytes.slice(32);
|
7848
7839
|
if (privateKey) {
|
@@ -7856,7 +7847,7 @@ var HDWallet = class {
|
|
7856
7847
|
parentFingerprint: this.fingerprint
|
7857
7848
|
});
|
7858
7849
|
}
|
7859
|
-
const signer = new Signer(
|
7850
|
+
const signer = new Signer(hexlify17(IL));
|
7860
7851
|
const Ki = signer.addPoint(publicKey);
|
7861
7852
|
return new HDWallet({
|
7862
7853
|
publicKey: Ki,
|
@@ -7891,14 +7882,12 @@ var HDWallet = class {
|
|
7891
7882
|
);
|
7892
7883
|
}
|
7893
7884
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7894
|
-
const depth =
|
7885
|
+
const depth = hexlify17(Uint8Array.from([this.depth]));
|
7895
7886
|
const parentFingerprint = this.parentFingerprint;
|
7896
7887
|
const index = toHex(this.index, 4);
|
7897
7888
|
const chainCode = this.chainCode;
|
7898
7889
|
const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
|
7899
|
-
const extendedKey =
|
7900
|
-
concat5([prefix, depth, parentFingerprint, index, chainCode, key])
|
7901
|
-
);
|
7890
|
+
const extendedKey = arrayify18(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7902
7891
|
return base58check(extendedKey);
|
7903
7892
|
}
|
7904
7893
|
/**
|
@@ -7910,13 +7899,13 @@ var HDWallet = class {
|
|
7910
7899
|
static fromSeed(seed) {
|
7911
7900
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7912
7901
|
return new HDWallet({
|
7913
|
-
chainCode:
|
7914
|
-
privateKey:
|
7902
|
+
chainCode: arrayify18(masterKey.slice(32)),
|
7903
|
+
privateKey: arrayify18(masterKey.slice(0, 32))
|
7915
7904
|
});
|
7916
7905
|
}
|
7917
7906
|
static fromExtendedKey(extendedKey) {
|
7918
7907
|
const decoded = toBeHex(decodeBase58(extendedKey));
|
7919
|
-
const bytes =
|
7908
|
+
const bytes = arrayify18(decoded);
|
7920
7909
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7921
7910
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7922
7911
|
throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7925,9 +7914,9 @@ var HDWallet = class {
|
|
7925
7914
|
throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7926
7915
|
}
|
7927
7916
|
const depth = bytes[4];
|
7928
|
-
const parentFingerprint =
|
7929
|
-
const index = parseInt(
|
7930
|
-
const chainCode =
|
7917
|
+
const parentFingerprint = hexlify17(bytes.slice(5, 9));
|
7918
|
+
const index = parseInt(hexlify17(bytes.slice(9, 13)).substring(2), 16);
|
7919
|
+
const chainCode = hexlify17(bytes.slice(13, 45));
|
7931
7920
|
const key = bytes.slice(45, 78);
|
7932
7921
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7933
7922
|
throw new FuelError18(
|
@@ -8539,18 +8528,17 @@ import { Address as Address9 } from "@fuel-ts/address";
|
|
8539
8528
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8540
8529
|
import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
|
8541
8530
|
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8542
|
-
import {
|
8531
|
+
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8543
8532
|
|
8544
8533
|
// src/predicate/utils/getPredicateRoot.ts
|
8545
8534
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
8546
8535
|
import { calcRoot } from "@fuel-ts/merkle";
|
8547
|
-
import { chunkAndPadBytes } from "@fuel-ts/utils";
|
8548
|
-
import { hexlify as hexlify17, concat as concat6, getBytesCopy as getBytesCopy19 } from "ethers";
|
8536
|
+
import { chunkAndPadBytes, hexlify as hexlify18, concat as concat6, arrayify as arrayify19 } from "@fuel-ts/utils";
|
8549
8537
|
var getPredicateRoot = (bytecode) => {
|
8550
8538
|
const chunkSize = 16 * 1024;
|
8551
|
-
const bytes =
|
8539
|
+
const bytes = arrayify19(bytecode);
|
8552
8540
|
const chunks = chunkAndPadBytes(bytes, chunkSize);
|
8553
|
-
const codeRoot = calcRoot(chunks.map((c) =>
|
8541
|
+
const codeRoot = calcRoot(chunks.map((c) => hexlify18(c)));
|
8554
8542
|
const predicateRoot = hash2(concat6(["0x4655454C", codeRoot]));
|
8555
8543
|
return predicateRoot;
|
8556
8544
|
};
|
@@ -8590,7 +8578,7 @@ var Predicate = class extends Account {
|
|
8590
8578
|
const request = transactionRequestify(transactionRequestLike);
|
8591
8579
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8592
8580
|
request.inputs?.forEach((input) => {
|
8593
|
-
if (input.type === InputType7.Coin &&
|
8581
|
+
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8594
8582
|
input.predicate = this.bytes;
|
8595
8583
|
input.predicateData = this.getPredicateData(policies.length);
|
8596
8584
|
}
|
@@ -8661,7 +8649,7 @@ var Predicate = class extends Account {
|
|
8661
8649
|
* @returns An object containing the new predicate bytes and interface.
|
8662
8650
|
*/
|
8663
8651
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8664
|
-
let predicateBytes =
|
8652
|
+
let predicateBytes = arrayify20(bytes);
|
8665
8653
|
let abiInterface;
|
8666
8654
|
if (jsonAbi) {
|
8667
8655
|
abiInterface = new Interface3(jsonAbi);
|