@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/test-utils.mjs
CHANGED
@@ -20,6 +20,7 @@ var __privateMethod = (obj, member, method) => {
|
|
20
20
|
|
21
21
|
// src/wallet/base-wallet-unlocked.ts
|
22
22
|
import { hashMessage } from "@fuel-ts/hasher";
|
23
|
+
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
23
24
|
|
24
25
|
// src/account.ts
|
25
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
@@ -27,12 +28,12 @@ import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
|
27
28
|
import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
|
28
29
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
30
|
import { bn as bn16 } from "@fuel-ts/math";
|
30
|
-
import {
|
31
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
31
32
|
|
32
33
|
// src/providers/coin-quantity.ts
|
33
34
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
34
35
|
import { bn } from "@fuel-ts/math";
|
35
|
-
import { hexlify } from "
|
36
|
+
import { hexlify } from "@fuel-ts/utils";
|
36
37
|
var coinQuantityfy = (coinQuantityLike) => {
|
37
38
|
let assetId;
|
38
39
|
let amount;
|
@@ -75,10 +76,10 @@ import {
|
|
75
76
|
InputMessageCoder,
|
76
77
|
TransactionCoder as TransactionCoder5
|
77
78
|
} from "@fuel-ts/transactions";
|
78
|
-
import { arrayify } from "@fuel-ts/utils";
|
79
|
+
import { arrayify as arrayify11, hexlify as hexlify12 } from "@fuel-ts/utils";
|
79
80
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
80
81
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
81
|
-
import {
|
82
|
+
import { Network } from "ethers";
|
82
83
|
import { GraphQLClient } from "graphql-request";
|
83
84
|
import { clone as clone3 } from "ramda";
|
84
85
|
|
@@ -951,7 +952,7 @@ async function* fuelGraphQLSubscriber({
|
|
951
952
|
|
952
953
|
// src/providers/memory-cache.ts
|
953
954
|
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
954
|
-
import { hexlify as hexlify2 } from "
|
955
|
+
import { hexlify as hexlify2 } from "@fuel-ts/utils";
|
955
956
|
var cache = {};
|
956
957
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
957
958
|
var MemoryCache = class {
|
@@ -1013,23 +1014,23 @@ import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
|
1013
1014
|
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1014
1015
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1015
1016
|
import { InputType } from "@fuel-ts/transactions";
|
1016
|
-
import {
|
1017
|
+
import { arrayify, hexlify as hexlify3 } from "@fuel-ts/utils";
|
1017
1018
|
var inputify = (value) => {
|
1018
1019
|
const { type } = value;
|
1019
1020
|
switch (value.type) {
|
1020
1021
|
case InputType.Coin: {
|
1021
|
-
const predicate =
|
1022
|
-
const predicateData =
|
1022
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
1023
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
1023
1024
|
return {
|
1024
1025
|
type: InputType.Coin,
|
1025
|
-
txID: hexlify3(
|
1026
|
-
outputIndex:
|
1026
|
+
txID: hexlify3(arrayify(value.id).slice(0, 32)),
|
1027
|
+
outputIndex: arrayify(value.id)[32],
|
1027
1028
|
owner: hexlify3(value.owner),
|
1028
1029
|
amount: bn2(value.amount),
|
1029
1030
|
assetId: hexlify3(value.assetId),
|
1030
1031
|
txPointer: {
|
1031
|
-
blockHeight: toNumber(
|
1032
|
-
txIndex: toNumber(
|
1032
|
+
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1033
|
+
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1033
1034
|
},
|
1034
1035
|
witnessIndex: value.witnessIndex,
|
1035
1036
|
maturity: value.maturity ?? 0,
|
@@ -1048,16 +1049,16 @@ var inputify = (value) => {
|
|
1048
1049
|
balanceRoot: ZeroBytes32,
|
1049
1050
|
stateRoot: ZeroBytes32,
|
1050
1051
|
txPointer: {
|
1051
|
-
blockHeight: toNumber(
|
1052
|
-
txIndex: toNumber(
|
1052
|
+
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1053
|
+
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1053
1054
|
},
|
1054
1055
|
contractID: hexlify3(value.contractId)
|
1055
1056
|
};
|
1056
1057
|
}
|
1057
1058
|
case InputType.Message: {
|
1058
|
-
const predicate =
|
1059
|
-
const predicateData =
|
1060
|
-
const data =
|
1059
|
+
const predicate = arrayify(value.predicate ?? "0x");
|
1060
|
+
const predicateData = arrayify(value.predicateData ?? "0x");
|
1061
|
+
const data = arrayify(value.data ?? "0x");
|
1061
1062
|
return {
|
1062
1063
|
type: InputType.Message,
|
1063
1064
|
sender: hexlify3(value.sender),
|
@@ -1088,7 +1089,7 @@ import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
|
1088
1089
|
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1089
1090
|
import { bn as bn3 } from "@fuel-ts/math";
|
1090
1091
|
import { OutputType } from "@fuel-ts/transactions";
|
1091
|
-
import { hexlify as hexlify4 } from "
|
1092
|
+
import { hexlify as hexlify4 } from "@fuel-ts/utils";
|
1092
1093
|
var outputify = (value) => {
|
1093
1094
|
const { type } = value;
|
1094
1095
|
switch (type) {
|
@@ -1151,7 +1152,7 @@ import {
|
|
1151
1152
|
OutputType as OutputType2,
|
1152
1153
|
TransactionType
|
1153
1154
|
} from "@fuel-ts/transactions";
|
1154
|
-
import { concat, hexlify as hexlify7 } from "
|
1155
|
+
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1155
1156
|
|
1156
1157
|
// src/providers/resource.ts
|
1157
1158
|
var isCoin = (resource) => "id" in resource;
|
@@ -1167,7 +1168,7 @@ import {
|
|
1167
1168
|
ReceiptType
|
1168
1169
|
} from "@fuel-ts/transactions";
|
1169
1170
|
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
1170
|
-
import {
|
1171
|
+
import { arrayify as arrayify2 } from "@fuel-ts/utils";
|
1171
1172
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1172
1173
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1173
1174
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1311,7 +1312,7 @@ function assembleReceiptByType(receipt) {
|
|
1311
1312
|
const recipient = hexOrZero(receipt.recipient);
|
1312
1313
|
const nonce = hexOrZero(receipt.nonce);
|
1313
1314
|
const amount = bn4(receipt.amount);
|
1314
|
-
const data = receipt.data ?
|
1315
|
+
const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
|
1315
1316
|
const digest = hexOrZero(receipt.digest);
|
1316
1317
|
const messageId = ReceiptMessageOutCoder.getMessageId({
|
1317
1318
|
sender,
|
@@ -1373,7 +1374,7 @@ import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1373
1374
|
// src/providers/utils/gas.ts
|
1374
1375
|
import { bn as bn5 } from "@fuel-ts/math";
|
1375
1376
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1376
|
-
import {
|
1377
|
+
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1377
1378
|
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1378
1379
|
var getGasUsedFromReceipts = (receipts) => {
|
1379
1380
|
const scriptResult = receipts.filter(
|
@@ -1398,9 +1399,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
1398
1399
|
const totalGas = inputs.reduce((total, input) => {
|
1399
1400
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1400
1401
|
return total.add(
|
1401
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
1402
|
-
resolveGasDependentCosts(getBytesCopy3(input.predicate).length, gasCosts.contractRoot)
|
1403
|
-
).add(bn5(input.predicateGasUsed))
|
1402
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1404
1403
|
);
|
1405
1404
|
}
|
1406
1405
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -1449,7 +1448,7 @@ function calculateMetadataGasForTxScript({
|
|
1449
1448
|
}
|
1450
1449
|
|
1451
1450
|
// src/providers/utils/json.ts
|
1452
|
-
import { hexlify as hexlify5 } from "
|
1451
|
+
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
1453
1452
|
import { clone } from "ramda";
|
1454
1453
|
function normalize(object) {
|
1455
1454
|
Object.keys(object).forEach((key) => {
|
@@ -1502,9 +1501,9 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1502
1501
|
};
|
1503
1502
|
|
1504
1503
|
// src/providers/transaction-request/witness.ts
|
1505
|
-
import {
|
1504
|
+
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1506
1505
|
var witnessify = (value) => {
|
1507
|
-
const data =
|
1506
|
+
const data = arrayify4(value);
|
1508
1507
|
return {
|
1509
1508
|
data: hexlify6(data),
|
1510
1509
|
dataLength: data.length
|
@@ -2006,14 +2005,15 @@ var BaseTransactionRequest = class {
|
|
2006
2005
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2007
2006
|
import { bn as bn8 } from "@fuel-ts/math";
|
2008
2007
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2009
|
-
import {
|
2008
|
+
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2010
2009
|
|
2011
2010
|
// src/providers/transaction-request/hash-transaction.ts
|
2012
2011
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2013
2012
|
import { uint64ToBytesBE } from "@fuel-ts/hasher";
|
2014
2013
|
import { bn as bn7 } from "@fuel-ts/math";
|
2015
2014
|
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2016
|
-
import { concat as concat2
|
2015
|
+
import { concat as concat2 } from "@fuel-ts/utils";
|
2016
|
+
import { sha256 } from "ethers";
|
2017
2017
|
import { clone as clone2 } from "ramda";
|
2018
2018
|
function hashTransaction(transactionRequest, chainId) {
|
2019
2019
|
const transaction = transactionRequest.toTransaction();
|
@@ -2080,10 +2080,10 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2080
2080
|
}
|
2081
2081
|
|
2082
2082
|
// src/providers/transaction-request/storage-slot.ts
|
2083
|
-
import {
|
2083
|
+
import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
|
2084
2084
|
var getStorageValue = (value) => {
|
2085
2085
|
const v = new Uint8Array(32);
|
2086
|
-
v.set(
|
2086
|
+
v.set(arrayify5(value));
|
2087
2087
|
return v;
|
2088
2088
|
};
|
2089
2089
|
var storageSlotify = (storageSlot) => {
|
@@ -2188,7 +2188,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2188
2188
|
}
|
2189
2189
|
metadataGas(gasCosts) {
|
2190
2190
|
return calculateMetadataGasForTxCreate({
|
2191
|
-
contractBytesSize: bn8(
|
2191
|
+
contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2192
2192
|
gasCosts,
|
2193
2193
|
stateRootSize: this.storageSlots.length,
|
2194
2194
|
txBytesSize: this.byteSize()
|
@@ -2202,17 +2202,17 @@ import { addressify as addressify2 } from "@fuel-ts/address";
|
|
2202
2202
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2203
2203
|
import { bn as bn9 } from "@fuel-ts/math";
|
2204
2204
|
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2205
|
-
import {
|
2205
|
+
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2206
2206
|
|
2207
2207
|
// src/providers/transaction-request/scripts.ts
|
2208
|
-
import {
|
2208
|
+
import { arrayify as arrayify7 } from "@fuel-ts/utils";
|
2209
2209
|
var returnZeroScript = {
|
2210
2210
|
/*
|
2211
2211
|
Opcode::RET(REG_ZERO)
|
2212
2212
|
Opcode::NOOP
|
2213
2213
|
*/
|
2214
2214
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2215
|
-
bytes:
|
2215
|
+
bytes: arrayify7("0x24000000"),
|
2216
2216
|
encodeScriptData: () => new Uint8Array(0)
|
2217
2217
|
};
|
2218
2218
|
var withdrawScript = {
|
@@ -2226,7 +2226,7 @@ var withdrawScript = {
|
|
2226
2226
|
00000000 00000000 [amount value]
|
2227
2227
|
*/
|
2228
2228
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2229
|
-
bytes:
|
2229
|
+
bytes: arrayify7("0x5040C0105D44C0064C40001124000000"),
|
2230
2230
|
encodeScriptData: () => new Uint8Array(0)
|
2231
2231
|
};
|
2232
2232
|
|
@@ -2254,8 +2254,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2254
2254
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2255
2255
|
super(rest);
|
2256
2256
|
this.gasLimit = bn9(gasLimit);
|
2257
|
-
this.script =
|
2258
|
-
this.scriptData =
|
2257
|
+
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2258
|
+
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2259
2259
|
}
|
2260
2260
|
/**
|
2261
2261
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2263,8 +2263,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2263
2263
|
* @returns The transaction script object.
|
2264
2264
|
*/
|
2265
2265
|
toTransaction() {
|
2266
|
-
const script =
|
2267
|
-
const scriptData =
|
2266
|
+
const script = arrayify8(this.script ?? "0x");
|
2267
|
+
const scriptData = arrayify8(this.scriptData ?? "0x");
|
2268
2268
|
return {
|
2269
2269
|
type: TransactionType4.Script,
|
2270
2270
|
scriptGasLimit: this.gasLimit,
|
@@ -2424,15 +2424,15 @@ var transactionRequestify = (obj) => {
|
|
2424
2424
|
import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
|
2425
2425
|
import { bn as bn13 } from "@fuel-ts/math";
|
2426
2426
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2427
|
-
import {
|
2427
|
+
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2428
2428
|
|
2429
2429
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2430
|
-
import { hexlify as hexlify11 } from "
|
2430
|
+
import { hexlify as hexlify11 } from "@fuel-ts/utils";
|
2431
2431
|
|
2432
2432
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2433
2433
|
import { bn as bn10 } from "@fuel-ts/math";
|
2434
2434
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2435
|
-
import {
|
2435
|
+
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2436
2436
|
var calculateTransactionFee = (params) => {
|
2437
2437
|
const {
|
2438
2438
|
gasUsed,
|
@@ -2441,7 +2441,7 @@ var calculateTransactionFee = (params) => {
|
|
2441
2441
|
} = params;
|
2442
2442
|
const gasPerByte = bn10(feeParams.gasPerByte);
|
2443
2443
|
const gasPriceFactor = bn10(feeParams.gasPriceFactor);
|
2444
|
-
const transactionBytes =
|
2444
|
+
const transactionBytes = arrayify9(rawPayload);
|
2445
2445
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2446
2446
|
if (transaction.type === TransactionType6.Mint) {
|
2447
2447
|
return {
|
@@ -2456,7 +2456,7 @@ var calculateTransactionFee = (params) => {
|
|
2456
2456
|
let gasLimit = bn10(0);
|
2457
2457
|
if (type === TransactionType6.Create) {
|
2458
2458
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2459
|
-
const contractBytesSize = bn10(
|
2459
|
+
const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2460
2460
|
metadataGas = calculateMetadataGasForTxCreate({
|
2461
2461
|
contractBytesSize,
|
2462
2462
|
gasCosts,
|
@@ -3215,7 +3215,7 @@ var TransactionResponse = class {
|
|
3215
3215
|
*/
|
3216
3216
|
decodeTransaction(transactionWithReceipts) {
|
3217
3217
|
return new TransactionCoder4().decode(
|
3218
|
-
|
3218
|
+
arrayify10(transactionWithReceipts.rawPayload),
|
3219
3219
|
0
|
3220
3220
|
)?.[0];
|
3221
3221
|
}
|
@@ -3241,7 +3241,7 @@ var TransactionResponse = class {
|
|
3241
3241
|
id: this.id,
|
3242
3242
|
receipts,
|
3243
3243
|
transaction: decodedTransaction,
|
3244
|
-
transactionBytes:
|
3244
|
+
transactionBytes: arrayify10(transaction.rawPayload),
|
3245
3245
|
gqlTransactionStatus: transaction.status,
|
3246
3246
|
gasPerByte,
|
3247
3247
|
gasPriceFactor,
|
@@ -3685,7 +3685,7 @@ var _Provider = class {
|
|
3685
3685
|
async estimatePredicates(transactionRequest) {
|
3686
3686
|
const shouldEstimatePredicates = Boolean(
|
3687
3687
|
transactionRequest.inputs.find(
|
3688
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(
|
3688
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN(input.predicateGasUsed).isZero()
|
3689
3689
|
)
|
3690
3690
|
);
|
3691
3691
|
if (!shouldEstimatePredicates) {
|
@@ -4008,7 +4008,7 @@ var _Provider = class {
|
|
4008
4008
|
time: block.header.time,
|
4009
4009
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4010
4010
|
transactions: block.transactions.map(
|
4011
|
-
(tx) => new TransactionCoder5().decode(
|
4011
|
+
(tx) => new TransactionCoder5().decode(arrayify11(tx.rawPayload), 0)?.[0]
|
4012
4012
|
)
|
4013
4013
|
};
|
4014
4014
|
}
|
@@ -4024,7 +4024,7 @@ var _Provider = class {
|
|
4024
4024
|
return null;
|
4025
4025
|
}
|
4026
4026
|
return new TransactionCoder5().decode(
|
4027
|
-
|
4027
|
+
arrayify11(transaction.rawPayload),
|
4028
4028
|
0
|
4029
4029
|
)?.[0];
|
4030
4030
|
}
|
@@ -4254,7 +4254,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4254
4254
|
import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
|
4255
4255
|
import { bn as bn15 } from "@fuel-ts/math";
|
4256
4256
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4257
|
-
import {
|
4257
|
+
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4258
4258
|
|
4259
4259
|
// src/providers/chains.ts
|
4260
4260
|
var CHAIN_IDS = {
|
@@ -4304,16 +4304,16 @@ var assets = [
|
|
4304
4304
|
// src/utils/formatTransferToContractScriptData.ts
|
4305
4305
|
import { U64Coder as U64Coder2 } from "@fuel-ts/abi-coder";
|
4306
4306
|
import { BN as BN2 } from "@fuel-ts/math";
|
4307
|
+
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
4307
4308
|
import * as asm from "@fuels/vm-asm";
|
4308
|
-
import { getBytesCopy as getBytesCopy13 } from "ethers";
|
4309
4309
|
var formatTransferToContractScriptData = (params) => {
|
4310
4310
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4311
4311
|
const numberCoder = new U64Coder2();
|
4312
4312
|
const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
|
4313
4313
|
const scriptData = Uint8Array.from([
|
4314
|
-
...
|
4314
|
+
...arrayify13(hexlifiedContractId),
|
4315
4315
|
...encoded,
|
4316
|
-
...
|
4316
|
+
...arrayify13(assetId)
|
4317
4317
|
]);
|
4318
4318
|
return scriptData;
|
4319
4319
|
};
|
@@ -4641,14 +4641,14 @@ var Account = class extends AbstractAccount {
|
|
4641
4641
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4642
4642
|
const { minGasPrice } = this.provider.getGasConfig();
|
4643
4643
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
4644
|
-
const recipientDataArray =
|
4644
|
+
const recipientDataArray = arrayify14(
|
4645
4645
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4646
4646
|
);
|
4647
|
-
const amountDataArray =
|
4647
|
+
const amountDataArray = arrayify14(
|
4648
4648
|
"0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
|
4649
4649
|
);
|
4650
4650
|
const script = new Uint8Array([
|
4651
|
-
...
|
4651
|
+
...arrayify14(withdrawScript.bytes),
|
4652
4652
|
...recipientDataArray,
|
4653
4653
|
...amountDataArray
|
4654
4654
|
]);
|
@@ -4735,8 +4735,8 @@ import { Address as Address4 } from "@fuel-ts/address";
|
|
4735
4735
|
import { randomBytes } from "@fuel-ts/crypto";
|
4736
4736
|
import { hash } from "@fuel-ts/hasher";
|
4737
4737
|
import { toBytes } from "@fuel-ts/math";
|
4738
|
+
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
4738
4739
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
4739
|
-
import { hexlify as hexlify13, concat as concat3, getBytesCopy as getBytesCopy15 } from "ethers";
|
4740
4740
|
var Signer = class {
|
4741
4741
|
address;
|
4742
4742
|
publicKey;
|
@@ -4771,11 +4771,11 @@ var Signer = class {
|
|
4771
4771
|
* @returns hashed signature
|
4772
4772
|
*/
|
4773
4773
|
sign(data) {
|
4774
|
-
const signature = secp256k1.sign(
|
4774
|
+
const signature = secp256k1.sign(arrayify15(data), arrayify15(this.privateKey));
|
4775
4775
|
const r = toBytes(`0x${signature.r.toString(16)}`, 32);
|
4776
4776
|
const s = toBytes(`0x${signature.s.toString(16)}`, 32);
|
4777
4777
|
s[0] |= (signature.recovery || 0) << 7;
|
4778
|
-
return concat3([r, s]);
|
4778
|
+
return hexlify13(concat3([r, s]));
|
4779
4779
|
}
|
4780
4780
|
/**
|
4781
4781
|
* Add point on the current elliptic curve
|
@@ -4784,8 +4784,8 @@ var Signer = class {
|
|
4784
4784
|
* @returns compressed point on the curve
|
4785
4785
|
*/
|
4786
4786
|
addPoint(point) {
|
4787
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
4788
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
4787
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify15(this.compressedPublicKey));
|
4788
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify15(point));
|
4789
4789
|
const result = p0.add(p1);
|
4790
4790
|
return `0x${result.toHex(true)}`;
|
4791
4791
|
}
|
@@ -4797,7 +4797,7 @@ var Signer = class {
|
|
4797
4797
|
* @returns public key from signature from the
|
4798
4798
|
*/
|
4799
4799
|
static recoverPublicKey(data, signature) {
|
4800
|
-
const signedMessageBytes =
|
4800
|
+
const signedMessageBytes = arrayify15(signature);
|
4801
4801
|
const r = signedMessageBytes.slice(0, 32);
|
4802
4802
|
const s = signedMessageBytes.slice(32, 64);
|
4803
4803
|
const recoveryParam = (s[0] & 128) >> 7;
|
@@ -4805,7 +4805,7 @@ var Signer = class {
|
|
4805
4805
|
const sig = new secp256k1.Signature(BigInt(hexlify13(r)), BigInt(hexlify13(s))).addRecoveryBit(
|
4806
4806
|
recoveryParam
|
4807
4807
|
);
|
4808
|
-
const publicKey = sig.recoverPublicKey(
|
4808
|
+
const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
|
4809
4809
|
return hexlify13(publicKey);
|
4810
4810
|
}
|
4811
4811
|
/**
|
@@ -4825,7 +4825,7 @@ var Signer = class {
|
|
4825
4825
|
* @returns random 32-byte hashed
|
4826
4826
|
*/
|
4827
4827
|
static generatePrivateKey(entropy) {
|
4828
|
-
return entropy ? hash(concat3([randomBytes(32),
|
4828
|
+
return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
|
4829
4829
|
}
|
4830
4830
|
/**
|
4831
4831
|
* Extended publicKey from a compact publicKey
|
@@ -4834,7 +4834,7 @@ var Signer = class {
|
|
4834
4834
|
* @returns extended publicKey
|
4835
4835
|
*/
|
4836
4836
|
static extendPublicKey(publicKey) {
|
4837
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
4837
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
|
4838
4838
|
return hexlify13(point.toRawBytes(false).slice(1));
|
4839
4839
|
}
|
4840
4840
|
};
|
@@ -4851,7 +4851,7 @@ import {
|
|
4851
4851
|
encryptJsonWalletData
|
4852
4852
|
} from "@fuel-ts/crypto";
|
4853
4853
|
import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
|
4854
|
-
import { hexlify as hexlify14 } from "
|
4854
|
+
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
4855
4855
|
import { v4 as uuidv4 } from "uuid";
|
4856
4856
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
4857
4857
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -4979,7 +4979,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
4979
4979
|
*/
|
4980
4980
|
async signMessage(message) {
|
4981
4981
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
4982
|
-
return signedMessage;
|
4982
|
+
return hexlify15(signedMessage);
|
4983
4983
|
}
|
4984
4984
|
/**
|
4985
4985
|
* Signs a transaction with the wallet's private key.
|
@@ -4992,7 +4992,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
4992
4992
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
4993
4993
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
4994
4994
|
const signature = await this.signer().sign(hashedTransaction);
|
4995
|
-
return signature;
|
4995
|
+
return hexlify15(signature);
|
4996
4996
|
}
|
4997
4997
|
/**
|
4998
4998
|
* Populates a transaction with the witnesses signature.
|
@@ -5053,32 +5053,22 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5053
5053
|
// src/hdwallet/hdwallet.ts
|
5054
5054
|
import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5055
5055
|
import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5056
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5056
5057
|
import {
|
5057
5058
|
toBeHex,
|
5058
5059
|
dataSlice as dataSlice2,
|
5059
|
-
hexlify as hexlify16,
|
5060
5060
|
encodeBase58 as encodeBase582,
|
5061
5061
|
decodeBase58,
|
5062
5062
|
sha256 as sha2564,
|
5063
5063
|
computeHmac as computeHmac2,
|
5064
|
-
ripemd160
|
5065
|
-
getBytesCopy as getBytesCopy18,
|
5066
|
-
concat as concat5
|
5064
|
+
ripemd160
|
5067
5065
|
} from "ethers";
|
5068
5066
|
|
5069
5067
|
// src/mnemonic/mnemonic.ts
|
5070
5068
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
5071
5069
|
import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
|
5072
|
-
import {
|
5073
|
-
|
5074
|
-
hexlify as hexlify15,
|
5075
|
-
dataSlice,
|
5076
|
-
pbkdf2,
|
5077
|
-
sha256 as sha2563,
|
5078
|
-
computeHmac,
|
5079
|
-
encodeBase58,
|
5080
|
-
getBytesCopy as getBytesCopy17
|
5081
|
-
} from "ethers";
|
5070
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5071
|
+
import { dataSlice, pbkdf2, sha256 as sha2563, computeHmac, encodeBase58 } from "ethers";
|
5082
5072
|
|
5083
5073
|
// src/wordlists/words/english.ts
|
5084
5074
|
var english = [
|
@@ -7134,7 +7124,8 @@ var english = [
|
|
7134
7124
|
|
7135
7125
|
// src/mnemonic/utils.ts
|
7136
7126
|
import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
|
7137
|
-
import {
|
7127
|
+
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7128
|
+
import { sha256 as sha2562 } from "ethers";
|
7138
7129
|
function toUtf8Bytes(stri) {
|
7139
7130
|
const str = stri.normalize("NFKD");
|
7140
7131
|
const result = [];
|
@@ -7201,14 +7192,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7201
7192
|
}
|
7202
7193
|
}
|
7203
7194
|
const checksumBits = entropy.length / 4;
|
7204
|
-
const checksum =
|
7195
|
+
const checksum = arrayify16(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
7205
7196
|
indices[indices.length - 1] <<= checksumBits;
|
7206
7197
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7207
7198
|
return indices;
|
7208
7199
|
}
|
7209
7200
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7210
7201
|
const size = Math.ceil(11 * words.length / 8);
|
7211
|
-
const entropy =
|
7202
|
+
const entropy = arrayify16(new Uint8Array(size));
|
7212
7203
|
let offset = 0;
|
7213
7204
|
for (let i = 0; i < words.length; i += 1) {
|
7214
7205
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7228,7 +7219,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7228
7219
|
const entropyBits = 32 * words.length / 3;
|
7229
7220
|
const checksumBits = words.length / 3;
|
7230
7221
|
const checksumMask = getUpperMask(checksumBits);
|
7231
|
-
const checksum =
|
7222
|
+
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7232
7223
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7233
7224
|
throw new FuelError16(
|
7234
7225
|
ErrorCode15.INVALID_CHECKSUM,
|
@@ -7303,7 +7294,7 @@ var Mnemonic = class {
|
|
7303
7294
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7304
7295
|
const words = getWords(phrase);
|
7305
7296
|
assertMnemonic(words);
|
7306
|
-
return
|
7297
|
+
return hexlify16(mnemonicWordsToEntropy(words, wordlist));
|
7307
7298
|
}
|
7308
7299
|
/**
|
7309
7300
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7311,7 +7302,7 @@ var Mnemonic = class {
|
|
7311
7302
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7312
7303
|
*/
|
7313
7304
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7314
|
-
const entropyBytes =
|
7305
|
+
const entropyBytes = arrayify17(entropy);
|
7315
7306
|
assertWordList(wordlist);
|
7316
7307
|
assertEntropy(entropyBytes);
|
7317
7308
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7380,14 +7371,14 @@ var Mnemonic = class {
|
|
7380
7371
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7381
7372
|
*/
|
7382
7373
|
static masterKeysFromSeed(seed) {
|
7383
|
-
const seedArray =
|
7374
|
+
const seedArray = arrayify17(seed);
|
7384
7375
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7385
7376
|
throw new FuelError17(
|
7386
7377
|
ErrorCode16.INVALID_SEED,
|
7387
7378
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7388
7379
|
);
|
7389
7380
|
}
|
7390
|
-
return
|
7381
|
+
return arrayify17(computeHmac("sha512", MasterSecret, seedArray));
|
7391
7382
|
}
|
7392
7383
|
/**
|
7393
7384
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7398,7 +7389,7 @@ var Mnemonic = class {
|
|
7398
7389
|
*/
|
7399
7390
|
static seedToExtendedKey(seed, testnet = false) {
|
7400
7391
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7401
|
-
const prefix =
|
7392
|
+
const prefix = arrayify17(testnet ? TestnetPRV : MainnetPRV);
|
7402
7393
|
const depth = "0x00";
|
7403
7394
|
const fingerprint = "0x00000000";
|
7404
7395
|
const index = "0x00000000";
|
@@ -7428,7 +7419,7 @@ var Mnemonic = class {
|
|
7428
7419
|
* @returns A randomly generated mnemonic
|
7429
7420
|
*/
|
7430
7421
|
static generate(size = 32, extraEntropy = "") {
|
7431
|
-
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size),
|
7422
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
|
7432
7423
|
return Mnemonic.entropyToMnemonic(entropy);
|
7433
7424
|
}
|
7434
7425
|
};
|
@@ -7436,10 +7427,10 @@ var mnemonic_default = Mnemonic;
|
|
7436
7427
|
|
7437
7428
|
// src/hdwallet/hdwallet.ts
|
7438
7429
|
var HARDENED_INDEX = 2147483648;
|
7439
|
-
var MainnetPRV2 =
|
7440
|
-
var MainnetPUB =
|
7441
|
-
var TestnetPRV2 =
|
7442
|
-
var TestnetPUB =
|
7430
|
+
var MainnetPRV2 = hexlify17("0x0488ade4");
|
7431
|
+
var MainnetPUB = hexlify17("0x0488b21e");
|
7432
|
+
var TestnetPRV2 = hexlify17("0x04358394");
|
7433
|
+
var TestnetPUB = hexlify17("0x043587cf");
|
7443
7434
|
function base58check(data) {
|
7444
7435
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
7445
7436
|
}
|
@@ -7450,11 +7441,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7450
7441
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7451
7442
|
}
|
7452
7443
|
function isPublicExtendedKey(extendedKey) {
|
7453
|
-
return [MainnetPUB, TestnetPUB].includes(
|
7444
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify17(extendedKey.slice(0, 4)));
|
7454
7445
|
}
|
7455
7446
|
function isValidExtendedKey(extendedKey) {
|
7456
7447
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7457
|
-
|
7448
|
+
hexlify17(extendedKey.slice(0, 4))
|
7458
7449
|
);
|
7459
7450
|
}
|
7460
7451
|
function parsePath(path2, depth = 0) {
|
@@ -7472,8 +7463,8 @@ function parsePath(path2, depth = 0) {
|
|
7472
7463
|
var HDWallet = class {
|
7473
7464
|
depth = 0;
|
7474
7465
|
index = 0;
|
7475
|
-
fingerprint =
|
7476
|
-
parentFingerprint =
|
7466
|
+
fingerprint = hexlify17("0x00000000");
|
7467
|
+
parentFingerprint = hexlify17("0x00000000");
|
7477
7468
|
privateKey;
|
7478
7469
|
publicKey;
|
7479
7470
|
chainCode;
|
@@ -7485,8 +7476,8 @@ var HDWallet = class {
|
|
7485
7476
|
constructor(config) {
|
7486
7477
|
if (config.privateKey) {
|
7487
7478
|
const signer = new Signer(config.privateKey);
|
7488
|
-
this.publicKey =
|
7489
|
-
this.privateKey =
|
7479
|
+
this.publicKey = hexlify17(signer.compressedPublicKey);
|
7480
|
+
this.privateKey = hexlify17(config.privateKey);
|
7490
7481
|
} else {
|
7491
7482
|
if (!config.publicKey) {
|
7492
7483
|
throw new FuelError18(
|
@@ -7494,7 +7485,7 @@ var HDWallet = class {
|
|
7494
7485
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7495
7486
|
);
|
7496
7487
|
}
|
7497
|
-
this.publicKey =
|
7488
|
+
this.publicKey = hexlify17(config.publicKey);
|
7498
7489
|
}
|
7499
7490
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7500
7491
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -7513,9 +7504,9 @@ var HDWallet = class {
|
|
7513
7504
|
* @returns A new instance of HDWallet on the derived index
|
7514
7505
|
*/
|
7515
7506
|
deriveIndex(index) {
|
7516
|
-
const privateKey = this.privateKey &&
|
7517
|
-
const publicKey =
|
7518
|
-
const chainCode =
|
7507
|
+
const privateKey = this.privateKey && arrayify18(this.privateKey);
|
7508
|
+
const publicKey = arrayify18(this.publicKey);
|
7509
|
+
const chainCode = arrayify18(this.chainCode);
|
7519
7510
|
const data = new Uint8Array(37);
|
7520
7511
|
if (index & HARDENED_INDEX) {
|
7521
7512
|
if (!privateKey) {
|
@@ -7526,10 +7517,10 @@ var HDWallet = class {
|
|
7526
7517
|
}
|
7527
7518
|
data.set(privateKey, 1);
|
7528
7519
|
} else {
|
7529
|
-
data.set(
|
7520
|
+
data.set(arrayify18(this.publicKey));
|
7530
7521
|
}
|
7531
7522
|
data.set(toBytes2(index, 4), 33);
|
7532
|
-
const bytes =
|
7523
|
+
const bytes = arrayify18(computeHmac2("sha512", chainCode, data));
|
7533
7524
|
const IL = bytes.slice(0, 32);
|
7534
7525
|
const IR = bytes.slice(32);
|
7535
7526
|
if (privateKey) {
|
@@ -7543,7 +7534,7 @@ var HDWallet = class {
|
|
7543
7534
|
parentFingerprint: this.fingerprint
|
7544
7535
|
});
|
7545
7536
|
}
|
7546
|
-
const signer = new Signer(
|
7537
|
+
const signer = new Signer(hexlify17(IL));
|
7547
7538
|
const Ki = signer.addPoint(publicKey);
|
7548
7539
|
return new HDWallet({
|
7549
7540
|
publicKey: Ki,
|
@@ -7578,14 +7569,12 @@ var HDWallet = class {
|
|
7578
7569
|
);
|
7579
7570
|
}
|
7580
7571
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7581
|
-
const depth =
|
7572
|
+
const depth = hexlify17(Uint8Array.from([this.depth]));
|
7582
7573
|
const parentFingerprint = this.parentFingerprint;
|
7583
7574
|
const index = toHex(this.index, 4);
|
7584
7575
|
const chainCode = this.chainCode;
|
7585
7576
|
const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
|
7586
|
-
const extendedKey =
|
7587
|
-
concat5([prefix, depth, parentFingerprint, index, chainCode, key])
|
7588
|
-
);
|
7577
|
+
const extendedKey = arrayify18(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7589
7578
|
return base58check(extendedKey);
|
7590
7579
|
}
|
7591
7580
|
/**
|
@@ -7597,13 +7586,13 @@ var HDWallet = class {
|
|
7597
7586
|
static fromSeed(seed) {
|
7598
7587
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7599
7588
|
return new HDWallet({
|
7600
|
-
chainCode:
|
7601
|
-
privateKey:
|
7589
|
+
chainCode: arrayify18(masterKey.slice(32)),
|
7590
|
+
privateKey: arrayify18(masterKey.slice(0, 32))
|
7602
7591
|
});
|
7603
7592
|
}
|
7604
7593
|
static fromExtendedKey(extendedKey) {
|
7605
7594
|
const decoded = toBeHex(decodeBase58(extendedKey));
|
7606
|
-
const bytes =
|
7595
|
+
const bytes = arrayify18(decoded);
|
7607
7596
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7608
7597
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7609
7598
|
throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7612,9 +7601,9 @@ var HDWallet = class {
|
|
7612
7601
|
throw new FuelError18(ErrorCode17.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7613
7602
|
}
|
7614
7603
|
const depth = bytes[4];
|
7615
|
-
const parentFingerprint =
|
7616
|
-
const index = parseInt(
|
7617
|
-
const chainCode =
|
7604
|
+
const parentFingerprint = hexlify17(bytes.slice(5, 9));
|
7605
|
+
const index = parseInt(hexlify17(bytes.slice(9, 13)).substring(2), 16);
|
7606
|
+
const chainCode = hexlify17(bytes.slice(13, 45));
|
7618
7607
|
const key = bytes.slice(45, 78);
|
7619
7608
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7620
7609
|
throw new FuelError18(
|
@@ -7830,11 +7819,10 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7830
7819
|
// src/test-utils/launchNode.ts
|
7831
7820
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
7832
7821
|
import { toHex as toHex2 } from "@fuel-ts/math";
|
7833
|
-
import { defaultChainConfig, defaultConsensusKey } from "@fuel-ts/utils";
|
7822
|
+
import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
7834
7823
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
7835
7824
|
import { spawn } from "child_process";
|
7836
7825
|
import { randomUUID } from "crypto";
|
7837
|
-
import { hexlify as hexlify17 } from "ethers";
|
7838
7826
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
7839
7827
|
import os from "os";
|
7840
7828
|
import path from "path";
|
@@ -7919,7 +7907,7 @@ var launchNode = async ({
|
|
7919
7907
|
if (!process.env.GENESIS_SECRET) {
|
7920
7908
|
const pk = Signer.generatePrivateKey();
|
7921
7909
|
const signer = new Signer(pk);
|
7922
|
-
process.env.GENESIS_SECRET =
|
7910
|
+
process.env.GENESIS_SECRET = hexlify18(pk);
|
7923
7911
|
chainConfig = {
|
7924
7912
|
...defaultChainConfig,
|
7925
7913
|
initial_state: {
|