@fuel-ts/account 0.0.0-rc-1815-20240322115843 → 0.0.0-rc-1356-20240322130951
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 +0 -7
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +0 -10
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/index.global.js +12 -70
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +107 -173
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -71
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +1 -20
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils/asset-id.d.ts +9 -0
- package/dist/test-utils/asset-id.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +4 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +8 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +28 -0
- package/dist/test-utils/test-message.d.ts.map +1 -0
- package/dist/test-utils/wallet-config.d.ts +49 -0
- package/dist/test-utils/wallet-config.d.ts.map +1 -0
- package/dist/test-utils.global.js +328 -70
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +332 -164
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +235 -71
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -16
- package/dist/providers/utils/sleep.d.ts +0 -3
- package/dist/providers/utils/sleep.d.ts.map +0 -1
package/dist/index.js
CHANGED
@@ -171,7 +171,6 @@ __export(src_exports, {
|
|
171
171
|
resolveGasDependentCosts: () => resolveGasDependentCosts,
|
172
172
|
resolveIconPaths: () => resolveIconPaths,
|
173
173
|
returnZeroScript: () => returnZeroScript,
|
174
|
-
sleep: () => sleep,
|
175
174
|
transactionRequestify: () => transactionRequestify,
|
176
175
|
urlJoin: () => urlJoin,
|
177
176
|
withTimeout: () => withTimeout,
|
@@ -185,7 +184,7 @@ var import_configs11 = require("@fuel-ts/address/configs");
|
|
185
184
|
var import_errors15 = require("@fuel-ts/errors");
|
186
185
|
var import_interfaces = require("@fuel-ts/interfaces");
|
187
186
|
var import_math17 = require("@fuel-ts/math");
|
188
|
-
var
|
187
|
+
var import_utils28 = require("@fuel-ts/utils");
|
189
188
|
|
190
189
|
// src/providers/coin-quantity.ts
|
191
190
|
var import_configs = require("@fuel-ts/address/configs");
|
@@ -228,9 +227,9 @@ var import_address3 = require("@fuel-ts/address");
|
|
228
227
|
var import_errors13 = require("@fuel-ts/errors");
|
229
228
|
var import_math14 = require("@fuel-ts/math");
|
230
229
|
var import_transactions17 = require("@fuel-ts/transactions");
|
231
|
-
var
|
230
|
+
var import_utils23 = require("@fuel-ts/utils");
|
232
231
|
var import_versions = require("@fuel-ts/versions");
|
233
|
-
var
|
232
|
+
var import_utils24 = require("@noble/curves/abstract/utils");
|
234
233
|
var import_ethers = require("ethers");
|
235
234
|
var import_graphql_request = require("graphql-request");
|
236
235
|
var import_ramda3 = require("ramda");
|
@@ -1689,15 +1688,6 @@ function normalizeJSON(root) {
|
|
1689
1688
|
return normalize((0, import_ramda.clone)(root));
|
1690
1689
|
}
|
1691
1690
|
|
1692
|
-
// src/providers/utils/sleep.ts
|
1693
|
-
function sleep(time) {
|
1694
|
-
return new Promise((resolve) => {
|
1695
|
-
setTimeout(() => {
|
1696
|
-
resolve(true);
|
1697
|
-
}, time);
|
1698
|
-
});
|
1699
|
-
}
|
1700
|
-
|
1701
1691
|
// src/providers/transaction-request/errors.ts
|
1702
1692
|
var ChangeOutputCollisionError = class extends Error {
|
1703
1693
|
name = "ChangeOutputCollisionError";
|
@@ -1839,27 +1829,13 @@ var BaseTransactionRequest = class {
|
|
1839
1829
|
this.outputs.push(output);
|
1840
1830
|
return this.outputs.length - 1;
|
1841
1831
|
}
|
1842
|
-
/**
|
1843
|
-
* @hidden
|
1844
|
-
*
|
1845
|
-
* Pushes a witness to the list and returns the index
|
1846
|
-
*
|
1847
|
-
* @param signature - The signature to add to the witness.
|
1848
|
-
* @returns The index of the created witness.
|
1849
|
-
*/
|
1850
|
-
addWitness(signature) {
|
1851
|
-
this.witnesses.push(signature);
|
1852
|
-
return this.witnesses.length - 1;
|
1853
|
-
}
|
1854
1832
|
/**
|
1855
1833
|
* @hidden
|
1856
1834
|
*
|
1857
1835
|
* Creates an empty witness without any side effects and returns the index
|
1858
|
-
*
|
1859
|
-
* @returns The index of the created witness.
|
1860
1836
|
*/
|
1861
|
-
|
1862
|
-
this.
|
1837
|
+
createWitness() {
|
1838
|
+
this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1863
1839
|
return this.witnesses.length - 1;
|
1864
1840
|
}
|
1865
1841
|
/**
|
@@ -1888,21 +1864,6 @@ var BaseTransactionRequest = class {
|
|
1888
1864
|
}
|
1889
1865
|
this.witnesses[index] = witness;
|
1890
1866
|
}
|
1891
|
-
/**
|
1892
|
-
* Helper function to add an external signature to the transaction.
|
1893
|
-
*
|
1894
|
-
* @param account - The account/s to sign to the transaction.
|
1895
|
-
* @returns The transaction with the signature witness added.
|
1896
|
-
*/
|
1897
|
-
async addAccountWitnesses(account) {
|
1898
|
-
const accounts = Array.isArray(account) ? account : [account];
|
1899
|
-
await Promise.all(
|
1900
|
-
accounts.map(async (acc) => {
|
1901
|
-
this.addWitness(await acc.signTransaction(this));
|
1902
|
-
})
|
1903
|
-
);
|
1904
|
-
return this;
|
1905
|
-
}
|
1906
1867
|
/**
|
1907
1868
|
* Gets the coin inputs for a transaction.
|
1908
1869
|
*
|
@@ -1968,7 +1929,7 @@ var BaseTransactionRequest = class {
|
|
1968
1929
|
} else {
|
1969
1930
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
1970
1931
|
if (typeof witnessIndex !== "number") {
|
1971
|
-
witnessIndex = this.
|
1932
|
+
witnessIndex = this.createWitness();
|
1972
1933
|
}
|
1973
1934
|
}
|
1974
1935
|
const input = {
|
@@ -2002,7 +1963,7 @@ var BaseTransactionRequest = class {
|
|
2002
1963
|
} else {
|
2003
1964
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
2004
1965
|
if (typeof witnessIndex !== "number") {
|
2005
|
-
witnessIndex = this.
|
1966
|
+
witnessIndex = this.createWitness();
|
2006
1967
|
}
|
2007
1968
|
}
|
2008
1969
|
const input = {
|
@@ -3584,6 +3545,7 @@ function getDecodedLogs(receipts, abiInterface) {
|
|
3584
3545
|
}
|
3585
3546
|
|
3586
3547
|
// src/providers/utils/auto-retry-fetch.ts
|
3548
|
+
var import_utils22 = require("@fuel-ts/utils");
|
3587
3549
|
function getWaitDelay(options, retryAttemptNum) {
|
3588
3550
|
const duration = options.baseDelay ?? 150;
|
3589
3551
|
switch (options.backoff) {
|
@@ -3613,7 +3575,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3613
3575
|
throw error;
|
3614
3576
|
}
|
3615
3577
|
const delay = getWaitDelay(options, retryNum);
|
3616
|
-
await sleep(delay);
|
3578
|
+
await (0, import_utils22.sleep)(delay);
|
3617
3579
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3618
3580
|
}
|
3619
3581
|
};
|
@@ -3916,7 +3878,7 @@ var _Provider = class {
|
|
3916
3878
|
if (estimateTxDependencies) {
|
3917
3879
|
await this.estimateTxDependencies(transactionRequest);
|
3918
3880
|
}
|
3919
|
-
const encodedTransaction = (0,
|
3881
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3920
3882
|
if (awaitExecution) {
|
3921
3883
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3922
3884
|
for await (const { submitAndAwait } of subscription) {
|
@@ -3955,7 +3917,7 @@ var _Provider = class {
|
|
3955
3917
|
if (estimateTxDependencies) {
|
3956
3918
|
return this.estimateTxDependencies(transactionRequest);
|
3957
3919
|
}
|
3958
|
-
const encodedTransaction = (0,
|
3920
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3959
3921
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3960
3922
|
encodedTransaction,
|
3961
3923
|
utxoValidation: utxoValidation || false
|
@@ -3974,13 +3936,13 @@ var _Provider = class {
|
|
3974
3936
|
async estimatePredicates(transactionRequest) {
|
3975
3937
|
const shouldEstimatePredicates = Boolean(
|
3976
3938
|
transactionRequest.inputs.find(
|
3977
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3939
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
|
3978
3940
|
)
|
3979
3941
|
);
|
3980
3942
|
if (!shouldEstimatePredicates) {
|
3981
3943
|
return transactionRequest;
|
3982
3944
|
}
|
3983
|
-
const encodedTransaction = (0,
|
3945
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3984
3946
|
const response = await this.operations.estimatePredicates({
|
3985
3947
|
encodedTransaction
|
3986
3948
|
});
|
@@ -4023,7 +3985,7 @@ var _Provider = class {
|
|
4023
3985
|
let outputVariables = 0;
|
4024
3986
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4025
3987
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4026
|
-
encodedTransaction: (0,
|
3988
|
+
encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
|
4027
3989
|
utxoValidation: false
|
4028
3990
|
});
|
4029
3991
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -4061,7 +4023,7 @@ var _Provider = class {
|
|
4061
4023
|
if (estimateTxDependencies) {
|
4062
4024
|
return this.estimateTxDependencies(transactionRequest);
|
4063
4025
|
}
|
4064
|
-
const encodedTransaction = (0,
|
4026
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4065
4027
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4066
4028
|
encodedTransaction,
|
4067
4029
|
utxoValidation: true
|
@@ -4171,7 +4133,7 @@ var _Provider = class {
|
|
4171
4133
|
const result = await this.operations.getCoins({
|
4172
4134
|
first: 10,
|
4173
4135
|
...paginationArgs,
|
4174
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4136
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4175
4137
|
});
|
4176
4138
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4177
4139
|
return coins.map((coin) => ({
|
@@ -4195,19 +4157,19 @@ var _Provider = class {
|
|
4195
4157
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4196
4158
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4197
4159
|
const excludeInput = {
|
4198
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4199
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4160
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4161
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
4200
4162
|
};
|
4201
4163
|
if (this.cache) {
|
4202
4164
|
const uniqueUtxos = new Set(
|
4203
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4165
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
4204
4166
|
);
|
4205
4167
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4206
4168
|
}
|
4207
4169
|
const coinsQuery = {
|
4208
4170
|
owner: ownerAddress.toB256(),
|
4209
4171
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4210
|
-
assetId: (0,
|
4172
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
4211
4173
|
amount: amount.toString(10),
|
4212
4174
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4213
4175
|
})),
|
@@ -4310,7 +4272,7 @@ var _Provider = class {
|
|
4310
4272
|
time: block.header.time,
|
4311
4273
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4312
4274
|
transactions: block.transactions.map(
|
4313
|
-
(tx) => new import_transactions17.TransactionCoder().decode((0,
|
4275
|
+
(tx) => new import_transactions17.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4314
4276
|
)
|
4315
4277
|
};
|
4316
4278
|
}
|
@@ -4326,7 +4288,7 @@ var _Provider = class {
|
|
4326
4288
|
return null;
|
4327
4289
|
}
|
4328
4290
|
return new import_transactions17.TransactionCoder().decode(
|
4329
|
-
(0,
|
4291
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4330
4292
|
0
|
4331
4293
|
)?.[0];
|
4332
4294
|
}
|
@@ -4353,7 +4315,7 @@ var _Provider = class {
|
|
4353
4315
|
async getContractBalance(contractId, assetId) {
|
4354
4316
|
const { contractBalance } = await this.operations.getContractBalance({
|
4355
4317
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4356
|
-
asset: (0,
|
4318
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4357
4319
|
});
|
4358
4320
|
return (0, import_math14.bn)(contractBalance.amount, 10);
|
4359
4321
|
}
|
@@ -4367,7 +4329,7 @@ var _Provider = class {
|
|
4367
4329
|
async getBalance(owner, assetId) {
|
4368
4330
|
const { balance } = await this.operations.getBalance({
|
4369
4331
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4370
|
-
assetId: (0,
|
4332
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4371
4333
|
});
|
4372
4334
|
return (0, import_math14.bn)(balance.amount, 10);
|
4373
4335
|
}
|
@@ -4528,7 +4490,7 @@ var _Provider = class {
|
|
4528
4490
|
async produceBlocks(amount, startTime) {
|
4529
4491
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4530
4492
|
blocksToProduce: (0, import_math14.bn)(amount).toString(10),
|
4531
|
-
startTimestamp: startTime ?
|
4493
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4532
4494
|
});
|
4533
4495
|
return (0, import_math14.bn)(latestBlockHeight);
|
4534
4496
|
}
|
@@ -4556,7 +4518,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4556
4518
|
var import_errors14 = require("@fuel-ts/errors");
|
4557
4519
|
var import_math15 = require("@fuel-ts/math");
|
4558
4520
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4559
|
-
var
|
4521
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4560
4522
|
async function getTransactionSummary(params) {
|
4561
4523
|
const { id, provider, abiMap } = params;
|
4562
4524
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -4569,7 +4531,7 @@ async function getTransactionSummary(params) {
|
|
4569
4531
|
);
|
4570
4532
|
}
|
4571
4533
|
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
|
4572
|
-
(0,
|
4534
|
+
(0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
4573
4535
|
0
|
4574
4536
|
);
|
4575
4537
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -4580,7 +4542,7 @@ async function getTransactionSummary(params) {
|
|
4580
4542
|
id: gqlTransaction.id,
|
4581
4543
|
receipts,
|
4582
4544
|
transaction: decodedTransaction,
|
4583
|
-
transactionBytes: (0,
|
4545
|
+
transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
4584
4546
|
gqlTransactionStatus: gqlTransaction.status,
|
4585
4547
|
gasPerByte: (0, import_math15.bn)(gasPerByte),
|
4586
4548
|
gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
|
@@ -4622,13 +4584,13 @@ async function getTransactionsSummaries(params) {
|
|
4622
4584
|
const transactions = edges.map((edge) => {
|
4623
4585
|
const { node: gqlTransaction } = edge;
|
4624
4586
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4625
|
-
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0,
|
4587
|
+
const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
|
4626
4588
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4627
4589
|
const transactionSummary = assembleTransactionSummary({
|
4628
4590
|
id,
|
4629
4591
|
receipts,
|
4630
4592
|
transaction: decodedTransaction,
|
4631
|
-
transactionBytes: (0,
|
4593
|
+
transactionBytes: (0, import_utils26.arrayify)(rawPayload),
|
4632
4594
|
gqlTransactionStatus: status,
|
4633
4595
|
abiMap,
|
4634
4596
|
gasPerByte,
|
@@ -4772,16 +4734,16 @@ var assets = [
|
|
4772
4734
|
// src/utils/formatTransferToContractScriptData.ts
|
4773
4735
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4774
4736
|
var import_math16 = require("@fuel-ts/math");
|
4775
|
-
var
|
4737
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4776
4738
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4777
4739
|
var formatTransferToContractScriptData = (params) => {
|
4778
4740
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4779
4741
|
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4780
4742
|
const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
|
4781
4743
|
const scriptData = Uint8Array.from([
|
4782
|
-
...(0,
|
4744
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4783
4745
|
...encoded,
|
4784
|
-
...(0,
|
4746
|
+
...(0, import_utils27.arrayify)(assetId)
|
4785
4747
|
]);
|
4786
4748
|
return scriptData;
|
4787
4749
|
};
|
@@ -5121,14 +5083,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5121
5083
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5122
5084
|
const { minGasPrice } = this.provider.getGasConfig();
|
5123
5085
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5124
|
-
const recipientDataArray = (0,
|
5086
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5125
5087
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5126
5088
|
);
|
5127
|
-
const amountDataArray = (0,
|
5089
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5128
5090
|
"0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5129
5091
|
);
|
5130
5092
|
const script = new Uint8Array([
|
5131
|
-
...(0,
|
5093
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5132
5094
|
...recipientDataArray,
|
5133
5095
|
...amountDataArray
|
5134
5096
|
]);
|
@@ -5155,21 +5117,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5155
5117
|
}
|
5156
5118
|
return this._connector.signMessage(this.address.toString(), message);
|
5157
5119
|
}
|
5158
|
-
/**
|
5159
|
-
* Signs a transaction with the wallet's private key.
|
5160
|
-
*
|
5161
|
-
* @param transactionRequestLike - The transaction request to sign.
|
5162
|
-
* @returns A promise that resolves to the signature of the transaction.
|
5163
|
-
*/
|
5164
|
-
async signTransaction(transactionRequestLike) {
|
5165
|
-
if (!this._connector) {
|
5166
|
-
throw new import_errors15.FuelError(
|
5167
|
-
import_errors15.ErrorCode.MISSING_CONNECTOR,
|
5168
|
-
"A connector is required to sign transactions."
|
5169
|
-
);
|
5170
|
-
}
|
5171
|
-
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
5172
|
-
}
|
5173
5120
|
/**
|
5174
5121
|
* Sends a transaction to the network.
|
5175
5122
|
*
|
@@ -5227,14 +5174,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5227
5174
|
|
5228
5175
|
// src/wallet/base-wallet-unlocked.ts
|
5229
5176
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5230
|
-
var
|
5177
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5231
5178
|
|
5232
5179
|
// src/signer/signer.ts
|
5233
5180
|
var import_address5 = require("@fuel-ts/address");
|
5234
5181
|
var import_crypto = require("@fuel-ts/crypto");
|
5235
5182
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5236
5183
|
var import_math18 = require("@fuel-ts/math");
|
5237
|
-
var
|
5184
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5238
5185
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5239
5186
|
var Signer = class {
|
5240
5187
|
address;
|
@@ -5254,9 +5201,9 @@ var Signer = class {
|
|
5254
5201
|
}
|
5255
5202
|
}
|
5256
5203
|
const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
|
5257
|
-
this.privateKey = (0,
|
5258
|
-
this.publicKey = (0,
|
5259
|
-
this.compressedPublicKey = (0,
|
5204
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5205
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5206
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5260
5207
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5261
5208
|
}
|
5262
5209
|
/**
|
@@ -5270,11 +5217,11 @@ var Signer = class {
|
|
5270
5217
|
* @returns hashed signature
|
5271
5218
|
*/
|
5272
5219
|
sign(data) {
|
5273
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5220
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5274
5221
|
const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5275
5222
|
const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5276
5223
|
s[0] |= (signature.recovery || 0) << 7;
|
5277
|
-
return (0,
|
5224
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5278
5225
|
}
|
5279
5226
|
/**
|
5280
5227
|
* Add point on the current elliptic curve
|
@@ -5283,8 +5230,8 @@ var Signer = class {
|
|
5283
5230
|
* @returns compressed point on the curve
|
5284
5231
|
*/
|
5285
5232
|
addPoint(point) {
|
5286
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5287
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5233
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5234
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5288
5235
|
const result = p0.add(p1);
|
5289
5236
|
return `0x${result.toHex(true)}`;
|
5290
5237
|
}
|
@@ -5296,16 +5243,16 @@ var Signer = class {
|
|
5296
5243
|
* @returns public key from signature from the
|
5297
5244
|
*/
|
5298
5245
|
static recoverPublicKey(data, signature) {
|
5299
|
-
const signedMessageBytes = (0,
|
5246
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5300
5247
|
const r = signedMessageBytes.slice(0, 32);
|
5301
5248
|
const s = signedMessageBytes.slice(32, 64);
|
5302
5249
|
const recoveryParam = (s[0] & 128) >> 7;
|
5303
5250
|
s[0] &= 127;
|
5304
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5251
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5305
5252
|
recoveryParam
|
5306
5253
|
);
|
5307
|
-
const publicKey = sig.recoverPublicKey((0,
|
5308
|
-
return (0,
|
5254
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5255
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5309
5256
|
}
|
5310
5257
|
/**
|
5311
5258
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5324,7 +5271,7 @@ var Signer = class {
|
|
5324
5271
|
* @returns random 32-byte hashed
|
5325
5272
|
*/
|
5326
5273
|
static generatePrivateKey(entropy) {
|
5327
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5274
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5328
5275
|
}
|
5329
5276
|
/**
|
5330
5277
|
* Extended publicKey from a compact publicKey
|
@@ -5333,8 +5280,8 @@ var Signer = class {
|
|
5333
5280
|
* @returns extended publicKey
|
5334
5281
|
*/
|
5335
5282
|
static extendPublicKey(publicKey) {
|
5336
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5337
|
-
return (0,
|
5283
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5284
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5338
5285
|
}
|
5339
5286
|
};
|
5340
5287
|
|
@@ -5342,7 +5289,7 @@ var Signer = class {
|
|
5342
5289
|
var import_address6 = require("@fuel-ts/address");
|
5343
5290
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5344
5291
|
var import_errors16 = require("@fuel-ts/errors");
|
5345
|
-
var
|
5292
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5346
5293
|
var import_uuid = require("uuid");
|
5347
5294
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5348
5295
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5425,7 +5372,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5425
5372
|
);
|
5426
5373
|
}
|
5427
5374
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5428
|
-
const privateKey = (0,
|
5375
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5429
5376
|
return privateKey;
|
5430
5377
|
}
|
5431
5378
|
|
@@ -5470,7 +5417,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5470
5417
|
*/
|
5471
5418
|
async signMessage(message) {
|
5472
5419
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5473
|
-
return (0,
|
5420
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5474
5421
|
}
|
5475
5422
|
/**
|
5476
5423
|
* Signs a transaction with the wallet's private key.
|
@@ -5480,10 +5427,10 @@ var BaseWalletUnlocked = class extends Account {
|
|
5480
5427
|
*/
|
5481
5428
|
async signTransaction(transactionRequestLike) {
|
5482
5429
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5483
|
-
const chainId = this.provider.
|
5430
|
+
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
5484
5431
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5485
5432
|
const signature = await this.signer().sign(hashedTransaction);
|
5486
|
-
return (0,
|
5433
|
+
return (0, import_utils31.hexlify)(signature);
|
5487
5434
|
}
|
5488
5435
|
/**
|
5489
5436
|
* Populates a transaction with the witnesses signature.
|
@@ -5545,14 +5492,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5545
5492
|
var import_errors19 = require("@fuel-ts/errors");
|
5546
5493
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5547
5494
|
var import_math19 = require("@fuel-ts/math");
|
5548
|
-
var
|
5495
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5549
5496
|
var import_ethers3 = require("ethers");
|
5550
5497
|
|
5551
5498
|
// src/mnemonic/mnemonic.ts
|
5552
5499
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5553
5500
|
var import_errors18 = require("@fuel-ts/errors");
|
5554
5501
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5555
|
-
var
|
5502
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5556
5503
|
var import_ethers2 = require("ethers");
|
5557
5504
|
|
5558
5505
|
// src/wordlists/words/english.ts
|
@@ -7616,7 +7563,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7616
7563
|
// src/mnemonic/utils.ts
|
7617
7564
|
var import_errors17 = require("@fuel-ts/errors");
|
7618
7565
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7619
|
-
var
|
7566
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7620
7567
|
function toUtf8Bytes(stri) {
|
7621
7568
|
const str = stri.normalize("NFKD");
|
7622
7569
|
const result = [];
|
@@ -7683,14 +7630,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7683
7630
|
}
|
7684
7631
|
}
|
7685
7632
|
const checksumBits = entropy.length / 4;
|
7686
|
-
const checksum = (0,
|
7633
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7687
7634
|
indices[indices.length - 1] <<= checksumBits;
|
7688
7635
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7689
7636
|
return indices;
|
7690
7637
|
}
|
7691
7638
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7692
7639
|
const size = Math.ceil(11 * words.length / 8);
|
7693
|
-
const entropy = (0,
|
7640
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7694
7641
|
let offset = 0;
|
7695
7642
|
for (let i = 0; i < words.length; i += 1) {
|
7696
7643
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7710,7 +7657,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7710
7657
|
const entropyBits = 32 * words.length / 3;
|
7711
7658
|
const checksumBits = words.length / 3;
|
7712
7659
|
const checksumMask = getUpperMask(checksumBits);
|
7713
|
-
const checksum = (0,
|
7660
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7714
7661
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7715
7662
|
throw new import_errors17.FuelError(
|
7716
7663
|
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
@@ -7785,7 +7732,7 @@ var Mnemonic = class {
|
|
7785
7732
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7786
7733
|
const words = getWords(phrase);
|
7787
7734
|
assertMnemonic(words);
|
7788
|
-
return (0,
|
7735
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7789
7736
|
}
|
7790
7737
|
/**
|
7791
7738
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7793,7 +7740,7 @@ var Mnemonic = class {
|
|
7793
7740
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7794
7741
|
*/
|
7795
7742
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7796
|
-
const entropyBytes = (0,
|
7743
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7797
7744
|
assertWordList(wordlist);
|
7798
7745
|
assertEntropy(entropyBytes);
|
7799
7746
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7862,14 +7809,14 @@ var Mnemonic = class {
|
|
7862
7809
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7863
7810
|
*/
|
7864
7811
|
static masterKeysFromSeed(seed) {
|
7865
|
-
const seedArray = (0,
|
7812
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7866
7813
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7867
7814
|
throw new import_errors18.FuelError(
|
7868
7815
|
import_errors18.ErrorCode.INVALID_SEED,
|
7869
7816
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7870
7817
|
);
|
7871
7818
|
}
|
7872
|
-
return (0,
|
7819
|
+
return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7873
7820
|
}
|
7874
7821
|
/**
|
7875
7822
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7880,22 +7827,22 @@ var Mnemonic = class {
|
|
7880
7827
|
*/
|
7881
7828
|
static seedToExtendedKey(seed, testnet = false) {
|
7882
7829
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7883
|
-
const prefix = (0,
|
7830
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7884
7831
|
const depth = "0x00";
|
7885
7832
|
const fingerprint = "0x00000000";
|
7886
7833
|
const index = "0x00000000";
|
7887
7834
|
const chainCode = masterKey.slice(32);
|
7888
7835
|
const privateKey = masterKey.slice(0, 32);
|
7889
|
-
const extendedKey = (0,
|
7836
|
+
const extendedKey = (0, import_utils33.concat)([
|
7890
7837
|
prefix,
|
7891
7838
|
depth,
|
7892
7839
|
fingerprint,
|
7893
7840
|
index,
|
7894
7841
|
chainCode,
|
7895
|
-
(0,
|
7842
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7896
7843
|
]);
|
7897
7844
|
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7898
|
-
return (0, import_ethers2.encodeBase58)((0,
|
7845
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7899
7846
|
}
|
7900
7847
|
/**
|
7901
7848
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7910,7 +7857,7 @@ var Mnemonic = class {
|
|
7910
7857
|
* @returns A randomly generated mnemonic
|
7911
7858
|
*/
|
7912
7859
|
static generate(size = 32, extraEntropy = "") {
|
7913
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7860
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7914
7861
|
return Mnemonic.entropyToMnemonic(entropy);
|
7915
7862
|
}
|
7916
7863
|
};
|
@@ -7918,12 +7865,12 @@ var mnemonic_default = Mnemonic;
|
|
7918
7865
|
|
7919
7866
|
// src/hdwallet/hdwallet.ts
|
7920
7867
|
var HARDENED_INDEX = 2147483648;
|
7921
|
-
var MainnetPRV2 = (0,
|
7922
|
-
var MainnetPUB = (0,
|
7923
|
-
var TestnetPRV2 = (0,
|
7924
|
-
var TestnetPUB = (0,
|
7868
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
7869
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
7870
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
7871
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7925
7872
|
function base58check(data) {
|
7926
|
-
return (0, import_ethers3.encodeBase58)((0,
|
7873
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7927
7874
|
}
|
7928
7875
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7929
7876
|
if (isPublic) {
|
@@ -7932,11 +7879,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7932
7879
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7933
7880
|
}
|
7934
7881
|
function isPublicExtendedKey(extendedKey) {
|
7935
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7882
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
7936
7883
|
}
|
7937
7884
|
function isValidExtendedKey(extendedKey) {
|
7938
7885
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7939
|
-
(0,
|
7886
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
7940
7887
|
);
|
7941
7888
|
}
|
7942
7889
|
function parsePath(path, depth = 0) {
|
@@ -7954,8 +7901,8 @@ function parsePath(path, depth = 0) {
|
|
7954
7901
|
var HDWallet = class {
|
7955
7902
|
depth = 0;
|
7956
7903
|
index = 0;
|
7957
|
-
fingerprint = (0,
|
7958
|
-
parentFingerprint = (0,
|
7904
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7905
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7959
7906
|
privateKey;
|
7960
7907
|
publicKey;
|
7961
7908
|
chainCode;
|
@@ -7967,8 +7914,8 @@ var HDWallet = class {
|
|
7967
7914
|
constructor(config) {
|
7968
7915
|
if (config.privateKey) {
|
7969
7916
|
const signer = new Signer(config.privateKey);
|
7970
|
-
this.publicKey = (0,
|
7971
|
-
this.privateKey = (0,
|
7917
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
7918
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
7972
7919
|
} else {
|
7973
7920
|
if (!config.publicKey) {
|
7974
7921
|
throw new import_errors19.FuelError(
|
@@ -7976,7 +7923,7 @@ var HDWallet = class {
|
|
7976
7923
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7977
7924
|
);
|
7978
7925
|
}
|
7979
|
-
this.publicKey = (0,
|
7926
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7980
7927
|
}
|
7981
7928
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7982
7929
|
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -7995,9 +7942,9 @@ var HDWallet = class {
|
|
7995
7942
|
* @returns A new instance of HDWallet on the derived index
|
7996
7943
|
*/
|
7997
7944
|
deriveIndex(index) {
|
7998
|
-
const privateKey = this.privateKey && (0,
|
7999
|
-
const publicKey = (0,
|
8000
|
-
const chainCode = (0,
|
7945
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
7946
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
7947
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8001
7948
|
const data = new Uint8Array(37);
|
8002
7949
|
if (index & HARDENED_INDEX) {
|
8003
7950
|
if (!privateKey) {
|
@@ -8008,10 +7955,10 @@ var HDWallet = class {
|
|
8008
7955
|
}
|
8009
7956
|
data.set(privateKey, 1);
|
8010
7957
|
} else {
|
8011
|
-
data.set((0,
|
7958
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8012
7959
|
}
|
8013
7960
|
data.set((0, import_math19.toBytes)(index, 4), 33);
|
8014
|
-
const bytes = (0,
|
7961
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
8015
7962
|
const IL = bytes.slice(0, 32);
|
8016
7963
|
const IR = bytes.slice(32);
|
8017
7964
|
if (privateKey) {
|
@@ -8025,7 +7972,7 @@ var HDWallet = class {
|
|
8025
7972
|
parentFingerprint: this.fingerprint
|
8026
7973
|
});
|
8027
7974
|
}
|
8028
|
-
const signer = new Signer((0,
|
7975
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8029
7976
|
const Ki = signer.addPoint(publicKey);
|
8030
7977
|
return new HDWallet({
|
8031
7978
|
publicKey: Ki,
|
@@ -8060,12 +8007,12 @@ var HDWallet = class {
|
|
8060
8007
|
);
|
8061
8008
|
}
|
8062
8009
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8063
|
-
const depth = (0,
|
8010
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8064
8011
|
const parentFingerprint = this.parentFingerprint;
|
8065
8012
|
const index = (0, import_math19.toHex)(this.index, 4);
|
8066
8013
|
const chainCode = this.chainCode;
|
8067
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8068
|
-
const extendedKey = (0,
|
8014
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8015
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8069
8016
|
return base58check(extendedKey);
|
8070
8017
|
}
|
8071
8018
|
/**
|
@@ -8077,13 +8024,13 @@ var HDWallet = class {
|
|
8077
8024
|
static fromSeed(seed) {
|
8078
8025
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8079
8026
|
return new HDWallet({
|
8080
|
-
chainCode: (0,
|
8081
|
-
privateKey: (0,
|
8027
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8028
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8082
8029
|
});
|
8083
8030
|
}
|
8084
8031
|
static fromExtendedKey(extendedKey) {
|
8085
8032
|
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
8086
|
-
const bytes = (0,
|
8033
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8087
8034
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8088
8035
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8089
8036
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8092,9 +8039,9 @@ var HDWallet = class {
|
|
8092
8039
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8093
8040
|
}
|
8094
8041
|
const depth = bytes[4];
|
8095
|
-
const parentFingerprint = (0,
|
8096
|
-
const index = parseInt((0,
|
8097
|
-
const chainCode = (0,
|
8042
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8043
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8044
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8098
8045
|
const key = bytes.slice(45, 78);
|
8099
8046
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8100
8047
|
throw new import_errors19.FuelError(
|
@@ -8700,18 +8647,18 @@ var import_address10 = require("@fuel-ts/address");
|
|
8700
8647
|
var import_configs12 = require("@fuel-ts/address/configs");
|
8701
8648
|
var import_errors24 = require("@fuel-ts/errors");
|
8702
8649
|
var import_transactions19 = require("@fuel-ts/transactions");
|
8703
|
-
var
|
8650
|
+
var import_utils37 = require("@fuel-ts/utils");
|
8704
8651
|
|
8705
8652
|
// src/predicate/utils/getPredicateRoot.ts
|
8706
8653
|
var import_hasher7 = require("@fuel-ts/hasher");
|
8707
8654
|
var import_merkle = require("@fuel-ts/merkle");
|
8708
|
-
var
|
8655
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8709
8656
|
var getPredicateRoot = (bytecode) => {
|
8710
8657
|
const chunkSize = 16 * 1024;
|
8711
|
-
const bytes = (0,
|
8712
|
-
const chunks = (0,
|
8713
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
8714
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
8658
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
8659
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
8660
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
8661
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
8715
8662
|
return predicateRoot;
|
8716
8663
|
};
|
8717
8664
|
|
@@ -8760,7 +8707,7 @@ var Predicate = class extends Account {
|
|
8760
8707
|
const request = transactionRequestify(transactionRequestLike);
|
8761
8708
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8762
8709
|
request.inputs?.forEach((input) => {
|
8763
|
-
if (input.type === import_transactions19.InputType.Coin && (0,
|
8710
|
+
if (input.type === import_transactions19.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
|
8764
8711
|
input.predicate = this.bytes;
|
8765
8712
|
input.predicateData = this.getPredicateData(policies.length);
|
8766
8713
|
}
|
@@ -8821,7 +8768,7 @@ var Predicate = class extends Account {
|
|
8821
8768
|
* @returns An object containing the new predicate bytes and interface.
|
8822
8769
|
*/
|
8823
8770
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8824
|
-
let predicateBytes = (0,
|
8771
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
8825
8772
|
let abiInterface;
|
8826
8773
|
if (jsonAbi) {
|
8827
8774
|
abiInterface = new import_abi_coder5.Interface(jsonAbi);
|
@@ -9021,18 +8968,6 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
9021
8968
|
async signMessage(_address, _message) {
|
9022
8969
|
throw new Error("Method not implemented.");
|
9023
8970
|
}
|
9024
|
-
/**
|
9025
|
-
* Should start the sign transaction process and return
|
9026
|
-
* the signed transaction.
|
9027
|
-
*
|
9028
|
-
* @param address - The address to sign the transaction
|
9029
|
-
* @param transaction - The transaction to sign
|
9030
|
-
*
|
9031
|
-
* @returns Transaction signature
|
9032
|
-
*/
|
9033
|
-
async signTransaction(_address, _transaction) {
|
9034
|
-
throw new Error("Method not implemented.");
|
9035
|
-
}
|
9036
8971
|
/**
|
9037
8972
|
* Should start the send transaction process and return
|
9038
8973
|
* the transaction id submitted to the network.
|
@@ -9669,7 +9604,6 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9669
9604
|
resolveGasDependentCosts,
|
9670
9605
|
resolveIconPaths,
|
9671
9606
|
returnZeroScript,
|
9672
|
-
sleep,
|
9673
9607
|
transactionRequestify,
|
9674
9608
|
urlJoin,
|
9675
9609
|
withTimeout,
|