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