@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.js
CHANGED
@@ -58,6 +58,7 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
58
58
|
|
59
59
|
// src/wallet/base-wallet-unlocked.ts
|
60
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
61
|
+
var import_utils30 = require("@fuel-ts/utils");
|
61
62
|
|
62
63
|
// src/account.ts
|
63
64
|
var import_address4 = require("@fuel-ts/address");
|
@@ -65,12 +66,12 @@ var import_configs10 = require("@fuel-ts/address/configs");
|
|
65
66
|
var import_errors15 = require("@fuel-ts/errors");
|
66
67
|
var import_interfaces = require("@fuel-ts/interfaces");
|
67
68
|
var import_math17 = require("@fuel-ts/math");
|
68
|
-
var
|
69
|
+
var import_utils27 = require("@fuel-ts/utils");
|
69
70
|
|
70
71
|
// src/providers/coin-quantity.ts
|
71
72
|
var import_configs = require("@fuel-ts/address/configs");
|
72
73
|
var import_math = require("@fuel-ts/math");
|
73
|
-
var
|
74
|
+
var import_utils = require("@fuel-ts/utils");
|
74
75
|
var coinQuantityfy = (coinQuantityLike) => {
|
75
76
|
let assetId;
|
76
77
|
let amount;
|
@@ -86,7 +87,7 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
86
87
|
}
|
87
88
|
const bnAmount = (0, import_math.bn)(amount);
|
88
89
|
return {
|
89
|
-
assetId: (0,
|
90
|
+
assetId: (0, import_utils.hexlify)(assetId),
|
90
91
|
amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
|
91
92
|
max: max2 ? (0, import_math.bn)(max2) : void 0
|
92
93
|
};
|
@@ -108,10 +109,10 @@ var import_address3 = require("@fuel-ts/address");
|
|
108
109
|
var import_errors13 = require("@fuel-ts/errors");
|
109
110
|
var import_math14 = require("@fuel-ts/math");
|
110
111
|
var import_transactions17 = require("@fuel-ts/transactions");
|
111
|
-
var
|
112
|
+
var import_utils22 = require("@fuel-ts/utils");
|
112
113
|
var import_versions = require("@fuel-ts/versions");
|
113
|
-
var
|
114
|
-
var
|
114
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
115
|
+
var import_ethers2 = require("ethers");
|
115
116
|
var import_graphql_request = require("graphql-request");
|
116
117
|
var import_ramda3 = require("ramda");
|
117
118
|
|
@@ -984,7 +985,7 @@ async function* fuelGraphQLSubscriber({
|
|
984
985
|
|
985
986
|
// src/providers/memory-cache.ts
|
986
987
|
var import_errors2 = require("@fuel-ts/errors");
|
987
|
-
var
|
988
|
+
var import_utils2 = require("@fuel-ts/utils");
|
988
989
|
var cache = {};
|
989
990
|
var DEFAULT_TTL_IN_MS = 30 * 1e3;
|
990
991
|
var MemoryCache = class {
|
@@ -999,7 +1000,7 @@ var MemoryCache = class {
|
|
999
1000
|
}
|
1000
1001
|
}
|
1001
1002
|
get(value, isAutoExpiring = true) {
|
1002
|
-
const key = (0,
|
1003
|
+
const key = (0, import_utils2.hexlify)(value);
|
1003
1004
|
if (cache[key]) {
|
1004
1005
|
if (!isAutoExpiring || cache[key].expires > Date.now()) {
|
1005
1006
|
return cache[key].value;
|
@@ -1010,7 +1011,7 @@ var MemoryCache = class {
|
|
1010
1011
|
}
|
1011
1012
|
set(value) {
|
1012
1013
|
const expiresAt = Date.now() + this.ttl;
|
1013
|
-
const key = (0,
|
1014
|
+
const key = (0, import_utils2.hexlify)(value);
|
1014
1015
|
cache[key] = {
|
1015
1016
|
expires: expiresAt,
|
1016
1017
|
value
|
@@ -1036,7 +1037,7 @@ var MemoryCache = class {
|
|
1036
1037
|
}, []);
|
1037
1038
|
}
|
1038
1039
|
del(value) {
|
1039
|
-
const key = (0,
|
1040
|
+
const key = (0, import_utils2.hexlify)(value);
|
1040
1041
|
delete cache[key];
|
1041
1042
|
}
|
1042
1043
|
};
|
@@ -1046,31 +1047,31 @@ var import_configs2 = require("@fuel-ts/address/configs");
|
|
1046
1047
|
var import_errors3 = require("@fuel-ts/errors");
|
1047
1048
|
var import_math2 = require("@fuel-ts/math");
|
1048
1049
|
var import_transactions = require("@fuel-ts/transactions");
|
1049
|
-
var
|
1050
|
+
var import_utils3 = require("@fuel-ts/utils");
|
1050
1051
|
var inputify = (value) => {
|
1051
1052
|
const { type } = value;
|
1052
1053
|
switch (value.type) {
|
1053
1054
|
case import_transactions.InputType.Coin: {
|
1054
|
-
const predicate = (0,
|
1055
|
-
const predicateData = (0,
|
1055
|
+
const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
|
1056
|
+
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1056
1057
|
return {
|
1057
1058
|
type: import_transactions.InputType.Coin,
|
1058
|
-
txID: (0,
|
1059
|
-
outputIndex: (0,
|
1060
|
-
owner: (0,
|
1059
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1060
|
+
outputIndex: (0, import_utils3.arrayify)(value.id)[32],
|
1061
|
+
owner: (0, import_utils3.hexlify)(value.owner),
|
1061
1062
|
amount: (0, import_math2.bn)(value.amount),
|
1062
|
-
assetId: (0,
|
1063
|
+
assetId: (0, import_utils3.hexlify)(value.assetId),
|
1063
1064
|
txPointer: {
|
1064
|
-
blockHeight: (0, import_math2.toNumber)((0,
|
1065
|
-
txIndex: (0, import_math2.toNumber)((0,
|
1065
|
+
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1066
|
+
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1066
1067
|
},
|
1067
1068
|
witnessIndex: value.witnessIndex,
|
1068
1069
|
maturity: value.maturity ?? 0,
|
1069
1070
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1070
1071
|
predicateLength: predicate.length,
|
1071
1072
|
predicateDataLength: predicateData.length,
|
1072
|
-
predicate: (0,
|
1073
|
-
predicateData: (0,
|
1073
|
+
predicate: (0, import_utils3.hexlify)(predicate),
|
1074
|
+
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1074
1075
|
};
|
1075
1076
|
}
|
1076
1077
|
case import_transactions.InputType.Contract: {
|
@@ -1081,29 +1082,29 @@ var inputify = (value) => {
|
|
1081
1082
|
balanceRoot: import_configs2.ZeroBytes32,
|
1082
1083
|
stateRoot: import_configs2.ZeroBytes32,
|
1083
1084
|
txPointer: {
|
1084
|
-
blockHeight: (0, import_math2.toNumber)((0,
|
1085
|
-
txIndex: (0, import_math2.toNumber)((0,
|
1085
|
+
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1086
|
+
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1086
1087
|
},
|
1087
|
-
contractID: (0,
|
1088
|
+
contractID: (0, import_utils3.hexlify)(value.contractId)
|
1088
1089
|
};
|
1089
1090
|
}
|
1090
1091
|
case import_transactions.InputType.Message: {
|
1091
|
-
const predicate = (0,
|
1092
|
-
const predicateData = (0,
|
1093
|
-
const data = (0,
|
1092
|
+
const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
|
1093
|
+
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1094
|
+
const data = (0, import_utils3.arrayify)(value.data ?? "0x");
|
1094
1095
|
return {
|
1095
1096
|
type: import_transactions.InputType.Message,
|
1096
|
-
sender: (0,
|
1097
|
-
recipient: (0,
|
1097
|
+
sender: (0, import_utils3.hexlify)(value.sender),
|
1098
|
+
recipient: (0, import_utils3.hexlify)(value.recipient),
|
1098
1099
|
amount: (0, import_math2.bn)(value.amount),
|
1099
|
-
nonce: (0,
|
1100
|
+
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1100
1101
|
witnessIndex: value.witnessIndex,
|
1101
1102
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1102
1103
|
predicateLength: predicate.length,
|
1103
1104
|
predicateDataLength: predicateData.length,
|
1104
|
-
predicate: (0,
|
1105
|
-
predicateData: (0,
|
1106
|
-
data: (0,
|
1105
|
+
predicate: (0, import_utils3.hexlify)(predicate),
|
1106
|
+
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1107
|
+
data: (0, import_utils3.hexlify)(data),
|
1107
1108
|
dataLength: data.length
|
1108
1109
|
};
|
1109
1110
|
}
|
@@ -1121,16 +1122,16 @@ var import_configs3 = require("@fuel-ts/address/configs");
|
|
1121
1122
|
var import_errors4 = require("@fuel-ts/errors");
|
1122
1123
|
var import_math3 = require("@fuel-ts/math");
|
1123
1124
|
var import_transactions2 = require("@fuel-ts/transactions");
|
1124
|
-
var
|
1125
|
+
var import_utils4 = require("@fuel-ts/utils");
|
1125
1126
|
var outputify = (value) => {
|
1126
1127
|
const { type } = value;
|
1127
1128
|
switch (type) {
|
1128
1129
|
case import_transactions2.OutputType.Coin: {
|
1129
1130
|
return {
|
1130
1131
|
type: import_transactions2.OutputType.Coin,
|
1131
|
-
to: (0,
|
1132
|
+
to: (0, import_utils4.hexlify)(value.to),
|
1132
1133
|
amount: (0, import_math3.bn)(value.amount),
|
1133
|
-
assetId: (0,
|
1134
|
+
assetId: (0, import_utils4.hexlify)(value.assetId)
|
1134
1135
|
};
|
1135
1136
|
}
|
1136
1137
|
case import_transactions2.OutputType.Contract: {
|
@@ -1144,9 +1145,9 @@ var outputify = (value) => {
|
|
1144
1145
|
case import_transactions2.OutputType.Change: {
|
1145
1146
|
return {
|
1146
1147
|
type: import_transactions2.OutputType.Change,
|
1147
|
-
to: (0,
|
1148
|
+
to: (0, import_utils4.hexlify)(value.to),
|
1148
1149
|
amount: (0, import_math3.bn)(0),
|
1149
|
-
assetId: (0,
|
1150
|
+
assetId: (0, import_utils4.hexlify)(value.assetId)
|
1150
1151
|
};
|
1151
1152
|
}
|
1152
1153
|
case import_transactions2.OutputType.Variable: {
|
@@ -1160,8 +1161,8 @@ var outputify = (value) => {
|
|
1160
1161
|
case import_transactions2.OutputType.ContractCreated: {
|
1161
1162
|
return {
|
1162
1163
|
type: import_transactions2.OutputType.ContractCreated,
|
1163
|
-
contractId: (0,
|
1164
|
-
stateRoot: (0,
|
1164
|
+
contractId: (0, import_utils4.hexlify)(value.contractId),
|
1165
|
+
stateRoot: (0, import_utils4.hexlify)(value.stateRoot)
|
1165
1166
|
};
|
1166
1167
|
}
|
1167
1168
|
default: {
|
@@ -1178,7 +1179,7 @@ var import_address = require("@fuel-ts/address");
|
|
1178
1179
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1179
1180
|
var import_math6 = require("@fuel-ts/math");
|
1180
1181
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1181
|
-
var
|
1182
|
+
var import_utils9 = require("@fuel-ts/utils");
|
1182
1183
|
|
1183
1184
|
// src/providers/resource.ts
|
1184
1185
|
var isCoin = (resource) => "id" in resource;
|
@@ -1189,7 +1190,7 @@ var import_errors5 = require("@fuel-ts/errors");
|
|
1189
1190
|
var import_math4 = require("@fuel-ts/math");
|
1190
1191
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1191
1192
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1192
|
-
var
|
1193
|
+
var import_utils5 = require("@fuel-ts/utils");
|
1193
1194
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1194
1195
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1195
1196
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1333,7 +1334,7 @@ function assembleReceiptByType(receipt) {
|
|
1333
1334
|
const recipient = hexOrZero(receipt.recipient);
|
1334
1335
|
const nonce = hexOrZero(receipt.nonce);
|
1335
1336
|
const amount = (0, import_math4.bn)(receipt.amount);
|
1336
|
-
const data = receipt.data ? (0,
|
1337
|
+
const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
|
1337
1338
|
const digest = hexOrZero(receipt.digest);
|
1338
1339
|
const messageId = import_transactions3.ReceiptMessageOutCoder.getMessageId({
|
1339
1340
|
sender,
|
@@ -1395,7 +1396,7 @@ var import_errors6 = require("@fuel-ts/errors");
|
|
1395
1396
|
// src/providers/utils/gas.ts
|
1396
1397
|
var import_math5 = require("@fuel-ts/math");
|
1397
1398
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1398
|
-
var
|
1399
|
+
var import_utils6 = require("@fuel-ts/utils");
|
1399
1400
|
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1400
1401
|
var getGasUsedFromReceipts = (receipts) => {
|
1401
1402
|
const scriptResult = receipts.filter(
|
@@ -1420,9 +1421,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
|
1420
1421
|
const totalGas = inputs.reduce((total, input) => {
|
1421
1422
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1422
1423
|
return total.add(
|
1423
|
-
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
|
1424
|
-
resolveGasDependentCosts((0, import_ethers6.getBytesCopy)(input.predicate).length, gasCosts.contractRoot)
|
1425
|
-
).add((0, import_math5.bn)(input.predicateGasUsed))
|
1424
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1426
1425
|
);
|
1427
1426
|
}
|
1428
1427
|
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
@@ -1471,13 +1470,13 @@ function calculateMetadataGasForTxScript({
|
|
1471
1470
|
}
|
1472
1471
|
|
1473
1472
|
// src/providers/utils/json.ts
|
1474
|
-
var
|
1473
|
+
var import_utils7 = require("@fuel-ts/utils");
|
1475
1474
|
var import_ramda = require("ramda");
|
1476
1475
|
function normalize(object) {
|
1477
1476
|
Object.keys(object).forEach((key) => {
|
1478
1477
|
switch (object[key]?.constructor.name) {
|
1479
1478
|
case "Uint8Array":
|
1480
|
-
object[key] = (0,
|
1479
|
+
object[key] = (0, import_utils7.hexlify)(object[key]);
|
1481
1480
|
break;
|
1482
1481
|
case "Array":
|
1483
1482
|
object[key] = normalize(object[key]);
|
@@ -1524,11 +1523,11 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1524
1523
|
};
|
1525
1524
|
|
1526
1525
|
// src/providers/transaction-request/witness.ts
|
1527
|
-
var
|
1526
|
+
var import_utils8 = require("@fuel-ts/utils");
|
1528
1527
|
var witnessify = (value) => {
|
1529
|
-
const data = (0,
|
1528
|
+
const data = (0, import_utils8.arrayify)(value);
|
1530
1529
|
return {
|
1531
|
-
data: (0,
|
1530
|
+
data: (0, import_utils8.hexlify)(data),
|
1532
1531
|
dataLength: data.length
|
1533
1532
|
};
|
1534
1533
|
};
|
@@ -1648,7 +1647,7 @@ var BaseTransactionRequest = class {
|
|
1648
1647
|
* Creates an empty witness without any side effects and returns the index
|
1649
1648
|
*/
|
1650
1649
|
createWitness() {
|
1651
|
-
this.witnesses.push((0,
|
1650
|
+
this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1652
1651
|
return this.witnesses.length - 1;
|
1653
1652
|
}
|
1654
1653
|
/**
|
@@ -1717,9 +1716,9 @@ var BaseTransactionRequest = class {
|
|
1717
1716
|
const found = this.inputs.find((input) => {
|
1718
1717
|
switch (input.type) {
|
1719
1718
|
case import_transactions5.InputType.Coin:
|
1720
|
-
return (0,
|
1719
|
+
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1721
1720
|
case import_transactions5.InputType.Message:
|
1722
|
-
return (0,
|
1721
|
+
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1723
1722
|
default:
|
1724
1723
|
return false;
|
1725
1724
|
}
|
@@ -1885,7 +1884,7 @@ var BaseTransactionRequest = class {
|
|
1885
1884
|
*/
|
1886
1885
|
addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
|
1887
1886
|
const changeOutput = this.getChangeOutputs().find(
|
1888
|
-
(output) => (0,
|
1887
|
+
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
1889
1888
|
);
|
1890
1889
|
if (!changeOutput) {
|
1891
1890
|
this.pushOutput({
|
@@ -2028,14 +2027,15 @@ var BaseTransactionRequest = class {
|
|
2028
2027
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2029
2028
|
var import_math8 = require("@fuel-ts/math");
|
2030
2029
|
var import_transactions7 = require("@fuel-ts/transactions");
|
2031
|
-
var
|
2030
|
+
var import_utils13 = require("@fuel-ts/utils");
|
2032
2031
|
|
2033
2032
|
// src/providers/transaction-request/hash-transaction.ts
|
2034
2033
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2035
2034
|
var import_hasher = require("@fuel-ts/hasher");
|
2036
2035
|
var import_math7 = require("@fuel-ts/math");
|
2037
2036
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2038
|
-
var
|
2037
|
+
var import_utils11 = require("@fuel-ts/utils");
|
2038
|
+
var import_ethers = require("ethers");
|
2039
2039
|
var import_ramda2 = require("ramda");
|
2040
2040
|
function hashTransaction(transactionRequest, chainId) {
|
2041
2041
|
const transaction = transactionRequest.toTransaction();
|
@@ -2097,15 +2097,15 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2097
2097
|
transaction.witnessesCount = 0;
|
2098
2098
|
transaction.witnesses = [];
|
2099
2099
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2100
|
-
const concatenatedData = (0,
|
2101
|
-
return (0,
|
2100
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
|
2101
|
+
return (0, import_ethers.sha256)(concatenatedData);
|
2102
2102
|
}
|
2103
2103
|
|
2104
2104
|
// src/providers/transaction-request/storage-slot.ts
|
2105
|
-
var
|
2105
|
+
var import_utils12 = require("@fuel-ts/utils");
|
2106
2106
|
var getStorageValue = (value) => {
|
2107
2107
|
const v = new Uint8Array(32);
|
2108
|
-
v.set((0,
|
2108
|
+
v.set((0, import_utils12.arrayify)(value));
|
2109
2109
|
return v;
|
2110
2110
|
};
|
2111
2111
|
var storageSlotify = (storageSlot) => {
|
@@ -2119,8 +2119,8 @@ var storageSlotify = (storageSlot) => {
|
|
2119
2119
|
value = storageSlot.value;
|
2120
2120
|
}
|
2121
2121
|
return {
|
2122
|
-
key: (0,
|
2123
|
-
value: (0,
|
2122
|
+
key: (0, import_utils12.hexlify)(key),
|
2123
|
+
value: (0, import_utils12.hexlify)(getStorageValue(value))
|
2124
2124
|
};
|
2125
2125
|
};
|
2126
2126
|
|
@@ -2153,7 +2153,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2153
2153
|
} = {}) {
|
2154
2154
|
super(rest);
|
2155
2155
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2156
|
-
this.salt = (0,
|
2156
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
|
2157
2157
|
this.storageSlots = [...storageSlots ?? []];
|
2158
2158
|
}
|
2159
2159
|
/**
|
@@ -2171,7 +2171,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2171
2171
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2172
2172
|
bytecodeWitnessIndex,
|
2173
2173
|
storageSlotsCount: storageSlots.length,
|
2174
|
-
salt: this.salt ? (0,
|
2174
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2175
2175
|
storageSlots
|
2176
2176
|
};
|
2177
2177
|
}
|
@@ -2210,7 +2210,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2210
2210
|
}
|
2211
2211
|
metadataGas(gasCosts) {
|
2212
2212
|
return calculateMetadataGasForTxCreate({
|
2213
|
-
contractBytesSize: (0, import_math8.bn)((0,
|
2213
|
+
contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2214
2214
|
gasCosts,
|
2215
2215
|
stateRootSize: this.storageSlots.length,
|
2216
2216
|
txBytesSize: this.byteSize()
|
@@ -2224,17 +2224,17 @@ var import_address2 = require("@fuel-ts/address");
|
|
2224
2224
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2225
2225
|
var import_math9 = require("@fuel-ts/math");
|
2226
2226
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2227
|
-
var
|
2227
|
+
var import_utils15 = require("@fuel-ts/utils");
|
2228
2228
|
|
2229
2229
|
// src/providers/transaction-request/scripts.ts
|
2230
|
-
var
|
2230
|
+
var import_utils14 = require("@fuel-ts/utils");
|
2231
2231
|
var returnZeroScript = {
|
2232
2232
|
/*
|
2233
2233
|
Opcode::RET(REG_ZERO)
|
2234
2234
|
Opcode::NOOP
|
2235
2235
|
*/
|
2236
2236
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2237
|
-
bytes: (0,
|
2237
|
+
bytes: (0, import_utils14.arrayify)("0x24000000"),
|
2238
2238
|
encodeScriptData: () => new Uint8Array(0)
|
2239
2239
|
};
|
2240
2240
|
var withdrawScript = {
|
@@ -2248,7 +2248,7 @@ var withdrawScript = {
|
|
2248
2248
|
00000000 00000000 [amount value]
|
2249
2249
|
*/
|
2250
2250
|
// TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
|
2251
|
-
bytes: (0,
|
2251
|
+
bytes: (0, import_utils14.arrayify)("0x5040C0105D44C0064C40001124000000"),
|
2252
2252
|
encodeScriptData: () => new Uint8Array(0)
|
2253
2253
|
};
|
2254
2254
|
|
@@ -2276,8 +2276,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2276
2276
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2277
2277
|
super(rest);
|
2278
2278
|
this.gasLimit = (0, import_math9.bn)(gasLimit);
|
2279
|
-
this.script = (0,
|
2280
|
-
this.scriptData = (0,
|
2279
|
+
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2280
|
+
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2281
2281
|
}
|
2282
2282
|
/**
|
2283
2283
|
* Converts the transaction request to a `TransactionScript`.
|
@@ -2285,8 +2285,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2285
2285
|
* @returns The transaction script object.
|
2286
2286
|
*/
|
2287
2287
|
toTransaction() {
|
2288
|
-
const script = (0,
|
2289
|
-
const scriptData = (0,
|
2288
|
+
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2289
|
+
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2290
2290
|
return {
|
2291
2291
|
type: import_transactions8.TransactionType.Script,
|
2292
2292
|
scriptGasLimit: this.gasLimit,
|
@@ -2294,8 +2294,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2294
2294
|
scriptLength: script.length,
|
2295
2295
|
scriptDataLength: scriptData.length,
|
2296
2296
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2297
|
-
script: (0,
|
2298
|
-
scriptData: (0,
|
2297
|
+
script: (0, import_utils15.hexlify)(script),
|
2298
|
+
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2299
2299
|
};
|
2300
2300
|
}
|
2301
2301
|
/**
|
@@ -2446,15 +2446,15 @@ var transactionRequestify = (obj) => {
|
|
2446
2446
|
var import_errors12 = require("@fuel-ts/errors");
|
2447
2447
|
var import_math13 = require("@fuel-ts/math");
|
2448
2448
|
var import_transactions15 = require("@fuel-ts/transactions");
|
2449
|
-
var
|
2449
|
+
var import_utils21 = require("@fuel-ts/utils");
|
2450
2450
|
|
2451
2451
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2452
|
-
var
|
2452
|
+
var import_utils19 = require("@fuel-ts/utils");
|
2453
2453
|
|
2454
2454
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2455
2455
|
var import_math10 = require("@fuel-ts/math");
|
2456
2456
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2457
|
-
var
|
2457
|
+
var import_utils16 = require("@fuel-ts/utils");
|
2458
2458
|
var calculateTransactionFee = (params) => {
|
2459
2459
|
const {
|
2460
2460
|
gasUsed,
|
@@ -2463,7 +2463,7 @@ var calculateTransactionFee = (params) => {
|
|
2463
2463
|
} = params;
|
2464
2464
|
const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
|
2465
2465
|
const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
|
2466
|
-
const transactionBytes = (0,
|
2466
|
+
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2467
2467
|
const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
|
2468
2468
|
if (transaction.type === import_transactions10.TransactionType.Mint) {
|
2469
2469
|
return {
|
@@ -2478,7 +2478,7 @@ var calculateTransactionFee = (params) => {
|
|
2478
2478
|
let gasLimit = (0, import_math10.bn)(0);
|
2479
2479
|
if (type === import_transactions10.TransactionType.Create) {
|
2480
2480
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2481
|
-
const contractBytesSize = (0, import_math10.bn)((0,
|
2481
|
+
const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2482
2482
|
metadataGas = calculateMetadataGasForTxCreate({
|
2483
2483
|
contractBytesSize,
|
2484
2484
|
gasCosts,
|
@@ -3120,7 +3120,7 @@ function assembleTransactionSummary(params) {
|
|
3120
3120
|
gasCosts
|
3121
3121
|
} = params;
|
3122
3122
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3123
|
-
const rawPayload = (0,
|
3123
|
+
const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
|
3124
3124
|
const operations = getOperations({
|
3125
3125
|
transactionType: transaction.type,
|
3126
3126
|
inputs: transaction.inputs || [],
|
@@ -3237,7 +3237,7 @@ var TransactionResponse = class {
|
|
3237
3237
|
*/
|
3238
3238
|
decodeTransaction(transactionWithReceipts) {
|
3239
3239
|
return new import_transactions15.TransactionCoder().decode(
|
3240
|
-
(0,
|
3240
|
+
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3241
3241
|
0
|
3242
3242
|
)?.[0];
|
3243
3243
|
}
|
@@ -3263,7 +3263,7 @@ var TransactionResponse = class {
|
|
3263
3263
|
id: this.id,
|
3264
3264
|
receipts,
|
3265
3265
|
transaction: decodedTransaction,
|
3266
|
-
transactionBytes: (0,
|
3266
|
+
transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
|
3267
3267
|
gqlTransactionStatus: transaction.status,
|
3268
3268
|
gasPerByte,
|
3269
3269
|
gasPriceFactor,
|
@@ -3587,7 +3587,7 @@ var _Provider = class {
|
|
3587
3587
|
name,
|
3588
3588
|
consensusParameters: { chainId }
|
3589
3589
|
} = await this.getChain();
|
3590
|
-
const network = new
|
3590
|
+
const network = new import_ethers2.Network(name, chainId.toNumber());
|
3591
3591
|
return Promise.resolve(network);
|
3592
3592
|
}
|
3593
3593
|
/**
|
@@ -3655,7 +3655,7 @@ var _Provider = class {
|
|
3655
3655
|
if (estimateTxDependencies) {
|
3656
3656
|
await this.estimateTxDependencies(transactionRequest);
|
3657
3657
|
}
|
3658
|
-
const encodedTransaction = (0,
|
3658
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3659
3659
|
if (awaitExecution) {
|
3660
3660
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3661
3661
|
for await (const { submitAndAwait } of subscription) {
|
@@ -3688,7 +3688,7 @@ var _Provider = class {
|
|
3688
3688
|
if (estimateTxDependencies) {
|
3689
3689
|
return this.estimateTxDependencies(transactionRequest);
|
3690
3690
|
}
|
3691
|
-
const encodedTransaction = (0,
|
3691
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3692
3692
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3693
3693
|
encodedTransaction,
|
3694
3694
|
utxoValidation: utxoValidation || false
|
@@ -3707,13 +3707,13 @@ var _Provider = class {
|
|
3707
3707
|
async estimatePredicates(transactionRequest) {
|
3708
3708
|
const shouldEstimatePredicates = Boolean(
|
3709
3709
|
transactionRequest.inputs.find(
|
3710
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3710
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
|
3711
3711
|
)
|
3712
3712
|
);
|
3713
3713
|
if (!shouldEstimatePredicates) {
|
3714
3714
|
return transactionRequest;
|
3715
3715
|
}
|
3716
|
-
const encodedTransaction = (0,
|
3716
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3717
3717
|
const response = await this.operations.estimatePredicates({
|
3718
3718
|
encodedTransaction
|
3719
3719
|
});
|
@@ -3752,7 +3752,7 @@ var _Provider = class {
|
|
3752
3752
|
let receipts = [];
|
3753
3753
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3754
3754
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3755
|
-
encodedTransaction: (0,
|
3755
|
+
encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
|
3756
3756
|
utxoValidation: false
|
3757
3757
|
});
|
3758
3758
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -3786,7 +3786,7 @@ var _Provider = class {
|
|
3786
3786
|
if (estimateTxDependencies) {
|
3787
3787
|
return this.estimateTxDependencies(transactionRequest);
|
3788
3788
|
}
|
3789
|
-
const encodedTransaction = (0,
|
3789
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3790
3790
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3791
3791
|
encodedTransaction,
|
3792
3792
|
utxoValidation: true
|
@@ -3891,7 +3891,7 @@ var _Provider = class {
|
|
3891
3891
|
const result = await this.operations.getCoins({
|
3892
3892
|
first: 10,
|
3893
3893
|
...paginationArgs,
|
3894
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
3894
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
3895
3895
|
});
|
3896
3896
|
const coins = result.coins.edges.map((edge) => edge.node);
|
3897
3897
|
return coins.map((coin) => ({
|
@@ -3915,19 +3915,19 @@ var _Provider = class {
|
|
3915
3915
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
3916
3916
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
3917
3917
|
const excludeInput = {
|
3918
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
3919
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
3918
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
3919
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
3920
3920
|
};
|
3921
3921
|
if (this.cache) {
|
3922
3922
|
const uniqueUtxos = new Set(
|
3923
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
3923
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
3924
3924
|
);
|
3925
3925
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
3926
3926
|
}
|
3927
3927
|
const coinsQuery = {
|
3928
3928
|
owner: ownerAddress.toB256(),
|
3929
3929
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
3930
|
-
assetId: (0,
|
3930
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
3931
3931
|
amount: amount.toString(10),
|
3932
3932
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
3933
3933
|
})),
|
@@ -4030,7 +4030,7 @@ var _Provider = class {
|
|
4030
4030
|
time: block.header.time,
|
4031
4031
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4032
4032
|
transactions: block.transactions.map(
|
4033
|
-
(tx) => new import_transactions17.TransactionCoder().decode((0,
|
4033
|
+
(tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4034
4034
|
)
|
4035
4035
|
};
|
4036
4036
|
}
|
@@ -4046,7 +4046,7 @@ var _Provider = class {
|
|
4046
4046
|
return null;
|
4047
4047
|
}
|
4048
4048
|
return new import_transactions17.TransactionCoder().decode(
|
4049
|
-
(0,
|
4049
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4050
4050
|
0
|
4051
4051
|
)?.[0];
|
4052
4052
|
}
|
@@ -4073,7 +4073,7 @@ var _Provider = class {
|
|
4073
4073
|
async getContractBalance(contractId, assetId) {
|
4074
4074
|
const { contractBalance } = await this.operations.getContractBalance({
|
4075
4075
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4076
|
-
asset: (0,
|
4076
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4077
4077
|
});
|
4078
4078
|
return (0, import_math14.bn)(contractBalance.amount, 10);
|
4079
4079
|
}
|
@@ -4087,7 +4087,7 @@ var _Provider = class {
|
|
4087
4087
|
async getBalance(owner, assetId) {
|
4088
4088
|
const { balance } = await this.operations.getBalance({
|
4089
4089
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4090
|
-
assetId: (0,
|
4090
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4091
4091
|
});
|
4092
4092
|
return (0, import_math14.bn)(balance.amount, 10);
|
4093
4093
|
}
|
@@ -4276,7 +4276,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4276
4276
|
var import_errors14 = require("@fuel-ts/errors");
|
4277
4277
|
var import_math15 = require("@fuel-ts/math");
|
4278
4278
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4279
|
-
var
|
4279
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4280
4280
|
|
4281
4281
|
// src/providers/chains.ts
|
4282
4282
|
var CHAIN_IDS = {
|
@@ -4326,16 +4326,16 @@ var assets = [
|
|
4326
4326
|
// src/utils/formatTransferToContractScriptData.ts
|
4327
4327
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4328
4328
|
var import_math16 = require("@fuel-ts/math");
|
4329
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4329
4330
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4330
|
-
var import_ethers20 = require("ethers");
|
4331
4331
|
var formatTransferToContractScriptData = (params) => {
|
4332
4332
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4333
4333
|
const numberCoder = new import_abi_coder4.U64Coder();
|
4334
4334
|
const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
|
4335
4335
|
const scriptData = Uint8Array.from([
|
4336
|
-
...(0,
|
4336
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4337
4337
|
...encoded,
|
4338
|
-
...(0,
|
4338
|
+
...(0, import_utils26.arrayify)(assetId)
|
4339
4339
|
]);
|
4340
4340
|
return scriptData;
|
4341
4341
|
};
|
@@ -4663,14 +4663,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4663
4663
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4664
4664
|
const { minGasPrice } = this.provider.getGasConfig();
|
4665
4665
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4666
|
-
const recipientDataArray = (0,
|
4666
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
4667
4667
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4668
4668
|
);
|
4669
|
-
const amountDataArray = (0,
|
4669
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
4670
4670
|
"0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4671
4671
|
);
|
4672
4672
|
const script = new Uint8Array([
|
4673
|
-
...(0,
|
4673
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
4674
4674
|
...recipientDataArray,
|
4675
4675
|
...amountDataArray
|
4676
4676
|
]);
|
@@ -4757,8 +4757,8 @@ var import_address5 = require("@fuel-ts/address");
|
|
4757
4757
|
var import_crypto = require("@fuel-ts/crypto");
|
4758
4758
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4759
4759
|
var import_math18 = require("@fuel-ts/math");
|
4760
|
+
var import_utils28 = require("@fuel-ts/utils");
|
4760
4761
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
4761
|
-
var import_ethers22 = require("ethers");
|
4762
4762
|
var Signer = class {
|
4763
4763
|
address;
|
4764
4764
|
publicKey;
|
@@ -4777,9 +4777,9 @@ var Signer = class {
|
|
4777
4777
|
}
|
4778
4778
|
}
|
4779
4779
|
const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
|
4780
|
-
this.privateKey = (0,
|
4781
|
-
this.publicKey = (0,
|
4782
|
-
this.compressedPublicKey = (0,
|
4780
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
4781
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
4782
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
4783
4783
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
4784
4784
|
}
|
4785
4785
|
/**
|
@@ -4793,11 +4793,11 @@ var Signer = class {
|
|
4793
4793
|
* @returns hashed signature
|
4794
4794
|
*/
|
4795
4795
|
sign(data) {
|
4796
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
4796
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
4797
4797
|
const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
4798
4798
|
const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
4799
4799
|
s[0] |= (signature.recovery || 0) << 7;
|
4800
|
-
return (0,
|
4800
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
4801
4801
|
}
|
4802
4802
|
/**
|
4803
4803
|
* Add point on the current elliptic curve
|
@@ -4806,8 +4806,8 @@ var Signer = class {
|
|
4806
4806
|
* @returns compressed point on the curve
|
4807
4807
|
*/
|
4808
4808
|
addPoint(point) {
|
4809
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4810
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4809
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
4810
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
4811
4811
|
const result = p0.add(p1);
|
4812
4812
|
return `0x${result.toHex(true)}`;
|
4813
4813
|
}
|
@@ -4819,16 +4819,16 @@ var Signer = class {
|
|
4819
4819
|
* @returns public key from signature from the
|
4820
4820
|
*/
|
4821
4821
|
static recoverPublicKey(data, signature) {
|
4822
|
-
const signedMessageBytes = (0,
|
4822
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
4823
4823
|
const r = signedMessageBytes.slice(0, 32);
|
4824
4824
|
const s = signedMessageBytes.slice(32, 64);
|
4825
4825
|
const recoveryParam = (s[0] & 128) >> 7;
|
4826
4826
|
s[0] &= 127;
|
4827
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
4827
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
4828
4828
|
recoveryParam
|
4829
4829
|
);
|
4830
|
-
const publicKey = sig.recoverPublicKey((0,
|
4831
|
-
return (0,
|
4830
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
4831
|
+
return (0, import_utils28.hexlify)(publicKey);
|
4832
4832
|
}
|
4833
4833
|
/**
|
4834
4834
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -4847,7 +4847,7 @@ var Signer = class {
|
|
4847
4847
|
* @returns random 32-byte hashed
|
4848
4848
|
*/
|
4849
4849
|
static generatePrivateKey(entropy) {
|
4850
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
4850
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
4851
4851
|
}
|
4852
4852
|
/**
|
4853
4853
|
* Extended publicKey from a compact publicKey
|
@@ -4856,8 +4856,8 @@ var Signer = class {
|
|
4856
4856
|
* @returns extended publicKey
|
4857
4857
|
*/
|
4858
4858
|
static extendPublicKey(publicKey) {
|
4859
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4860
|
-
return (0,
|
4859
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
4860
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
4861
4861
|
}
|
4862
4862
|
};
|
4863
4863
|
|
@@ -4865,7 +4865,7 @@ var Signer = class {
|
|
4865
4865
|
var import_address6 = require("@fuel-ts/address");
|
4866
4866
|
var import_crypto2 = require("@fuel-ts/crypto");
|
4867
4867
|
var import_errors16 = require("@fuel-ts/errors");
|
4868
|
-
var
|
4868
|
+
var import_utils29 = require("@fuel-ts/utils");
|
4869
4869
|
var import_uuid = require("uuid");
|
4870
4870
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
4871
4871
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -4948,7 +4948,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
4948
4948
|
);
|
4949
4949
|
}
|
4950
4950
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
4951
|
-
const privateKey = (0,
|
4951
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
4952
4952
|
return privateKey;
|
4953
4953
|
}
|
4954
4954
|
|
@@ -4993,7 +4993,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
4993
4993
|
*/
|
4994
4994
|
async signMessage(message) {
|
4995
4995
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
4996
|
-
return signedMessage;
|
4996
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
4997
4997
|
}
|
4998
4998
|
/**
|
4999
4999
|
* Signs a transaction with the wallet's private key.
|
@@ -5006,7 +5006,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5006
5006
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5007
5007
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5008
5008
|
const signature = await this.signer().sign(hashedTransaction);
|
5009
|
-
return signature;
|
5009
|
+
return (0, import_utils30.hexlify)(signature);
|
5010
5010
|
}
|
5011
5011
|
/**
|
5012
5012
|
* Populates a transaction with the witnesses signature.
|
@@ -5067,12 +5067,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5067
5067
|
// src/hdwallet/hdwallet.ts
|
5068
5068
|
var import_errors19 = require("@fuel-ts/errors");
|
5069
5069
|
var import_math19 = require("@fuel-ts/math");
|
5070
|
-
var
|
5070
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5071
|
+
var import_ethers5 = require("ethers");
|
5071
5072
|
|
5072
5073
|
// src/mnemonic/mnemonic.ts
|
5073
5074
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5074
5075
|
var import_errors18 = require("@fuel-ts/errors");
|
5075
|
-
var
|
5076
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5077
|
+
var import_ethers4 = require("ethers");
|
5076
5078
|
|
5077
5079
|
// src/wordlists/words/english.ts
|
5078
5080
|
var english = [
|
@@ -7128,7 +7130,8 @@ var english = [
|
|
7128
7130
|
|
7129
7131
|
// src/mnemonic/utils.ts
|
7130
7132
|
var import_errors17 = require("@fuel-ts/errors");
|
7131
|
-
var
|
7133
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7134
|
+
var import_ethers3 = require("ethers");
|
7132
7135
|
function toUtf8Bytes(stri) {
|
7133
7136
|
const str = stri.normalize("NFKD");
|
7134
7137
|
const result = [];
|
@@ -7195,14 +7198,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7195
7198
|
}
|
7196
7199
|
}
|
7197
7200
|
const checksumBits = entropy.length / 4;
|
7198
|
-
const checksum = (0,
|
7201
|
+
const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7199
7202
|
indices[indices.length - 1] <<= checksumBits;
|
7200
7203
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7201
7204
|
return indices;
|
7202
7205
|
}
|
7203
7206
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7204
7207
|
const size = Math.ceil(11 * words.length / 8);
|
7205
|
-
const entropy = (0,
|
7208
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7206
7209
|
let offset = 0;
|
7207
7210
|
for (let i = 0; i < words.length; i += 1) {
|
7208
7211
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7222,7 +7225,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7222
7225
|
const entropyBits = 32 * words.length / 3;
|
7223
7226
|
const checksumBits = words.length / 3;
|
7224
7227
|
const checksumMask = getUpperMask(checksumBits);
|
7225
|
-
const checksum = (0,
|
7228
|
+
const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7226
7229
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7227
7230
|
throw new import_errors17.FuelError(
|
7228
7231
|
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
@@ -7297,7 +7300,7 @@ var Mnemonic = class {
|
|
7297
7300
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7298
7301
|
const words = getWords(phrase);
|
7299
7302
|
assertMnemonic(words);
|
7300
|
-
return (0,
|
7303
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7301
7304
|
}
|
7302
7305
|
/**
|
7303
7306
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7305,7 +7308,7 @@ var Mnemonic = class {
|
|
7305
7308
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7306
7309
|
*/
|
7307
7310
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7308
|
-
const entropyBytes = (0,
|
7311
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7309
7312
|
assertWordList(wordlist);
|
7310
7313
|
assertEntropy(entropyBytes);
|
7311
7314
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7319,7 +7322,7 @@ var Mnemonic = class {
|
|
7319
7322
|
assertMnemonic(getWords(phrase));
|
7320
7323
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7321
7324
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7322
|
-
return (0,
|
7325
|
+
return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7323
7326
|
}
|
7324
7327
|
/**
|
7325
7328
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7374,14 +7377,14 @@ var Mnemonic = class {
|
|
7374
7377
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7375
7378
|
*/
|
7376
7379
|
static masterKeysFromSeed(seed) {
|
7377
|
-
const seedArray = (0,
|
7380
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7378
7381
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7379
7382
|
throw new import_errors18.FuelError(
|
7380
7383
|
import_errors18.ErrorCode.INVALID_SEED,
|
7381
7384
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7382
7385
|
);
|
7383
7386
|
}
|
7384
|
-
return (0,
|
7387
|
+
return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
|
7385
7388
|
}
|
7386
7389
|
/**
|
7387
7390
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7392,22 +7395,22 @@ var Mnemonic = class {
|
|
7392
7395
|
*/
|
7393
7396
|
static seedToExtendedKey(seed, testnet = false) {
|
7394
7397
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7395
|
-
const prefix = (0,
|
7398
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7396
7399
|
const depth = "0x00";
|
7397
7400
|
const fingerprint = "0x00000000";
|
7398
7401
|
const index = "0x00000000";
|
7399
7402
|
const chainCode = masterKey.slice(32);
|
7400
7403
|
const privateKey = masterKey.slice(0, 32);
|
7401
|
-
const extendedKey = (0,
|
7404
|
+
const extendedKey = (0, import_utils32.concat)([
|
7402
7405
|
prefix,
|
7403
7406
|
depth,
|
7404
7407
|
fingerprint,
|
7405
7408
|
index,
|
7406
7409
|
chainCode,
|
7407
|
-
(0,
|
7410
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
7408
7411
|
]);
|
7409
|
-
const checksum = (0,
|
7410
|
-
return (0,
|
7412
|
+
const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
|
7413
|
+
return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7411
7414
|
}
|
7412
7415
|
/**
|
7413
7416
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7422,7 +7425,7 @@ var Mnemonic = class {
|
|
7422
7425
|
* @returns A randomly generated mnemonic
|
7423
7426
|
*/
|
7424
7427
|
static generate(size = 32, extraEntropy = "") {
|
7425
|
-
const entropy = extraEntropy ? (0,
|
7428
|
+
const entropy = extraEntropy ? (0, import_ethers4.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7426
7429
|
return Mnemonic.entropyToMnemonic(entropy);
|
7427
7430
|
}
|
7428
7431
|
};
|
@@ -7430,12 +7433,12 @@ var mnemonic_default = Mnemonic;
|
|
7430
7433
|
|
7431
7434
|
// src/hdwallet/hdwallet.ts
|
7432
7435
|
var HARDENED_INDEX = 2147483648;
|
7433
|
-
var MainnetPRV2 = (0,
|
7434
|
-
var MainnetPUB = (0,
|
7435
|
-
var TestnetPRV2 = (0,
|
7436
|
-
var TestnetPUB = (0,
|
7436
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
7437
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
7438
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7439
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7437
7440
|
function base58check(data) {
|
7438
|
-
return (0,
|
7441
|
+
return (0, import_ethers5.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers5.dataSlice)((0, import_ethers5.sha256)((0, import_ethers5.sha256)(data)), 0, 4)]));
|
7439
7442
|
}
|
7440
7443
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7441
7444
|
if (isPublic) {
|
@@ -7444,11 +7447,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7444
7447
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7445
7448
|
}
|
7446
7449
|
function isPublicExtendedKey(extendedKey) {
|
7447
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7450
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
7448
7451
|
}
|
7449
7452
|
function isValidExtendedKey(extendedKey) {
|
7450
7453
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7451
|
-
(0,
|
7454
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
7452
7455
|
);
|
7453
7456
|
}
|
7454
7457
|
function parsePath(path2, depth = 0) {
|
@@ -7466,8 +7469,8 @@ function parsePath(path2, depth = 0) {
|
|
7466
7469
|
var HDWallet = class {
|
7467
7470
|
depth = 0;
|
7468
7471
|
index = 0;
|
7469
|
-
fingerprint = (0,
|
7470
|
-
parentFingerprint = (0,
|
7472
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7473
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7471
7474
|
privateKey;
|
7472
7475
|
publicKey;
|
7473
7476
|
chainCode;
|
@@ -7479,8 +7482,8 @@ var HDWallet = class {
|
|
7479
7482
|
constructor(config) {
|
7480
7483
|
if (config.privateKey) {
|
7481
7484
|
const signer = new Signer(config.privateKey);
|
7482
|
-
this.publicKey = (0,
|
7483
|
-
this.privateKey = (0,
|
7485
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
7486
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
7484
7487
|
} else {
|
7485
7488
|
if (!config.publicKey) {
|
7486
7489
|
throw new import_errors19.FuelError(
|
@@ -7488,10 +7491,10 @@ var HDWallet = class {
|
|
7488
7491
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7489
7492
|
);
|
7490
7493
|
}
|
7491
|
-
this.publicKey = (0,
|
7494
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7492
7495
|
}
|
7493
7496
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7494
|
-
this.fingerprint = (0,
|
7497
|
+
this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
|
7495
7498
|
this.depth = config.depth || this.depth;
|
7496
7499
|
this.index = config.index || this.index;
|
7497
7500
|
this.chainCode = config.chainCode;
|
@@ -7507,9 +7510,9 @@ var HDWallet = class {
|
|
7507
7510
|
* @returns A new instance of HDWallet on the derived index
|
7508
7511
|
*/
|
7509
7512
|
deriveIndex(index) {
|
7510
|
-
const privateKey = this.privateKey && (0,
|
7511
|
-
const publicKey = (0,
|
7512
|
-
const chainCode = (0,
|
7513
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
7514
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
7515
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
7513
7516
|
const data = new Uint8Array(37);
|
7514
7517
|
if (index & HARDENED_INDEX) {
|
7515
7518
|
if (!privateKey) {
|
@@ -7520,10 +7523,10 @@ var HDWallet = class {
|
|
7520
7523
|
}
|
7521
7524
|
data.set(privateKey, 1);
|
7522
7525
|
} else {
|
7523
|
-
data.set((0,
|
7526
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7524
7527
|
}
|
7525
7528
|
data.set((0, import_math19.toBytes)(index, 4), 33);
|
7526
|
-
const bytes = (0,
|
7529
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
|
7527
7530
|
const IL = bytes.slice(0, 32);
|
7528
7531
|
const IR = bytes.slice(32);
|
7529
7532
|
if (privateKey) {
|
@@ -7537,7 +7540,7 @@ var HDWallet = class {
|
|
7537
7540
|
parentFingerprint: this.fingerprint
|
7538
7541
|
});
|
7539
7542
|
}
|
7540
|
-
const signer = new Signer((0,
|
7543
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
7541
7544
|
const Ki = signer.addPoint(publicKey);
|
7542
7545
|
return new HDWallet({
|
7543
7546
|
publicKey: Ki,
|
@@ -7572,14 +7575,12 @@ var HDWallet = class {
|
|
7572
7575
|
);
|
7573
7576
|
}
|
7574
7577
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7575
|
-
const depth = (0,
|
7578
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
7576
7579
|
const parentFingerprint = this.parentFingerprint;
|
7577
7580
|
const index = (0, import_math19.toHex)(this.index, 4);
|
7578
7581
|
const chainCode = this.chainCode;
|
7579
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7580
|
-
const extendedKey = (0,
|
7581
|
-
(0, import_ethers26.concat)([prefix, depth, parentFingerprint, index, chainCode, key])
|
7582
|
-
);
|
7582
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7583
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7583
7584
|
return base58check(extendedKey);
|
7584
7585
|
}
|
7585
7586
|
/**
|
@@ -7591,13 +7592,13 @@ var HDWallet = class {
|
|
7591
7592
|
static fromSeed(seed) {
|
7592
7593
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7593
7594
|
return new HDWallet({
|
7594
|
-
chainCode: (0,
|
7595
|
-
privateKey: (0,
|
7595
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
7596
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
7596
7597
|
});
|
7597
7598
|
}
|
7598
7599
|
static fromExtendedKey(extendedKey) {
|
7599
|
-
const decoded = (0,
|
7600
|
-
const bytes = (0,
|
7600
|
+
const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
|
7601
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
7601
7602
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7602
7603
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7603
7604
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7606,9 +7607,9 @@ var HDWallet = class {
|
|
7606
7607
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7607
7608
|
}
|
7608
7609
|
const depth = bytes[4];
|
7609
|
-
const parentFingerprint = (0,
|
7610
|
-
const index = parseInt((0,
|
7611
|
-
const chainCode = (0,
|
7610
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
7611
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
7612
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
7612
7613
|
const key = bytes.slice(45, 78);
|
7613
7614
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7614
7615
|
throw new import_errors19.FuelError(
|
@@ -7824,11 +7825,10 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7824
7825
|
// src/test-utils/launchNode.ts
|
7825
7826
|
var import_configs11 = require("@fuel-ts/address/configs");
|
7826
7827
|
var import_math20 = require("@fuel-ts/math");
|
7827
|
-
var
|
7828
|
+
var import_utils35 = require("@fuel-ts/utils");
|
7828
7829
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
7829
7830
|
var import_child_process = require("child_process");
|
7830
7831
|
var import_crypto5 = require("crypto");
|
7831
|
-
var import_ethers27 = require("ethers");
|
7832
7832
|
var import_fs = require("fs");
|
7833
7833
|
var import_os = __toESM(require("os"));
|
7834
7834
|
var import_path = __toESM(require("path"));
|
@@ -7883,7 +7883,7 @@ var launchNode = async ({
|
|
7883
7883
|
"--poa-instant"
|
7884
7884
|
]);
|
7885
7885
|
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
7886
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
7886
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
|
7887
7887
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
7888
7888
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
7889
7889
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -7909,17 +7909,17 @@ var launchNode = async ({
|
|
7909
7909
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
7910
7910
|
}
|
7911
7911
|
const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
7912
|
-
let chainConfig =
|
7912
|
+
let chainConfig = import_utils35.defaultChainConfig;
|
7913
7913
|
if (!process.env.GENESIS_SECRET) {
|
7914
7914
|
const pk = Signer.generatePrivateKey();
|
7915
7915
|
const signer = new Signer(pk);
|
7916
|
-
process.env.GENESIS_SECRET = (0,
|
7916
|
+
process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
|
7917
7917
|
chainConfig = {
|
7918
|
-
...
|
7918
|
+
...import_utils35.defaultChainConfig,
|
7919
7919
|
initial_state: {
|
7920
|
-
...
|
7920
|
+
...import_utils35.defaultChainConfig.initial_state,
|
7921
7921
|
coins: [
|
7922
|
-
...
|
7922
|
+
...import_utils35.defaultChainConfig.initial_state.coins,
|
7923
7923
|
{
|
7924
7924
|
owner: signer.address.toHexString(),
|
7925
7925
|
amount: (0, import_math20.toHex)(1e9),
|