@fuel-ts/account 0.89.2 → 0.91.0
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 +8 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts +3 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +4 -2
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +10 -4
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +7 -3
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +3228 -2762
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +246 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +150 -81
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +8 -0
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +711 -505
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/chains.d.ts +1 -1
- package/dist/providers/provider.d.ts +12 -2
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +2 -8
- package/dist/providers/utils/extract-tx-error.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 +8 -0
- package/dist/test-utils/asset-id.d.ts.map +1 -0
- package/dist/test-utils/launchNode.d.ts +10 -5
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +34 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +29 -0
- package/dist/test-utils/test-message.d.ts.map +1 -0
- package/dist/test-utils/wallet-config.d.ts +55 -0
- package/dist/test-utils/wallet-config.d.ts.map +1 -0
- package/dist/test-utils.d.ts +8 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.global.js +2277 -1467
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +546 -234
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +452 -144
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +1 -1
- package/package.json +26 -25
- package/dist/providers/utils/sleep.d.ts +0 -3
- package/dist/providers/utils/sleep.d.ts.map +0 -1
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
@@ -28,11 +28,13 @@ var __privateMethod = (obj, member, method) => {
|
|
28
28
|
};
|
29
29
|
|
30
30
|
// src/account.ts
|
31
|
+
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
31
32
|
import { Address as Address3 } from "@fuel-ts/address";
|
33
|
+
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
32
34
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
33
35
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
34
36
|
import { bn as bn19 } from "@fuel-ts/math";
|
35
|
-
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
37
|
+
import { arrayify as arrayify14, hexlify as hexlify13, isDefined as isDefined2 } from "@fuel-ts/utils";
|
36
38
|
import { clone as clone4 } from "ramda";
|
37
39
|
|
38
40
|
// src/providers/coin-quantity.ts
|
@@ -307,6 +309,7 @@ var MessageProofFragmentDoc = gql`
|
|
307
309
|
proofIndex
|
308
310
|
}
|
309
311
|
messageBlockHeader {
|
312
|
+
version
|
310
313
|
id
|
311
314
|
daHeight
|
312
315
|
consensusParametersVersion
|
@@ -322,6 +325,7 @@ var MessageProofFragmentDoc = gql`
|
|
322
325
|
applicationHash
|
323
326
|
}
|
324
327
|
commitBlockHeader {
|
328
|
+
version
|
325
329
|
id
|
326
330
|
daHeight
|
327
331
|
consensusParametersVersion
|
@@ -508,6 +512,15 @@ var GasCostsFragmentDoc = gql`
|
|
508
512
|
wqmm
|
509
513
|
xor
|
510
514
|
xori
|
515
|
+
alocDependentCost {
|
516
|
+
...DependentCostFragment
|
517
|
+
}
|
518
|
+
cfe {
|
519
|
+
...DependentCostFragment
|
520
|
+
}
|
521
|
+
cfeiDependentCost {
|
522
|
+
...DependentCostFragment
|
523
|
+
}
|
511
524
|
call {
|
512
525
|
...DependentCostFragment
|
513
526
|
}
|
@@ -692,9 +705,13 @@ var GetTransactionsDocument = gql`
|
|
692
705
|
...transactionFragment
|
693
706
|
}
|
694
707
|
}
|
708
|
+
pageInfo {
|
709
|
+
...pageInfoFragment
|
710
|
+
}
|
695
711
|
}
|
696
712
|
}
|
697
|
-
${TransactionFragmentDoc}
|
713
|
+
${TransactionFragmentDoc}
|
714
|
+
${PageInfoFragmentDoc}`;
|
698
715
|
var GetTransactionsByOwnerDocument = gql`
|
699
716
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
700
717
|
transactionsByOwner(
|
@@ -886,8 +903,12 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
886
903
|
}
|
887
904
|
${RelayedTransactionStatusFragmentDoc}`;
|
888
905
|
var DryRunDocument = gql`
|
889
|
-
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
890
|
-
dryRun(
|
906
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
|
907
|
+
dryRun(
|
908
|
+
txs: $encodedTransactions
|
909
|
+
utxoValidation: $utxoValidation
|
910
|
+
gasPrice: $gasPrice
|
911
|
+
) {
|
891
912
|
...dryRunTransactionExecutionStatusFragment
|
892
913
|
}
|
893
914
|
}
|
@@ -1714,15 +1735,6 @@ function normalizeJSON(root) {
|
|
1714
1735
|
return normalize(clone(root));
|
1715
1736
|
}
|
1716
1737
|
|
1717
|
-
// src/providers/utils/sleep.ts
|
1718
|
-
function sleep(time) {
|
1719
|
-
return new Promise((resolve) => {
|
1720
|
-
setTimeout(() => {
|
1721
|
-
resolve(true);
|
1722
|
-
}, time);
|
1723
|
-
});
|
1724
|
-
}
|
1725
|
-
|
1726
1738
|
// src/providers/utils/extract-tx-error.ts
|
1727
1739
|
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1728
1740
|
import { bn as bn6 } from "@fuel-ts/math";
|
@@ -1736,7 +1748,7 @@ import {
|
|
1736
1748
|
PANIC_REASONS,
|
1737
1749
|
PANIC_DOC_URL
|
1738
1750
|
} from "@fuel-ts/transactions/configs";
|
1739
|
-
var assemblePanicError = (statusReason) => {
|
1751
|
+
var assemblePanicError = (statusReason, metadata) => {
|
1740
1752
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
1741
1753
|
if (PANIC_REASONS.includes(statusReason)) {
|
1742
1754
|
errorMessage = `${errorMessage}
|
@@ -1745,10 +1757,13 @@ You can read more about this error at:
|
|
1745
1757
|
|
1746
1758
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
1747
1759
|
}
|
1748
|
-
return
|
1760
|
+
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
1761
|
+
...metadata,
|
1762
|
+
reason: statusReason
|
1763
|
+
});
|
1749
1764
|
};
|
1750
1765
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1751
|
-
var assembleRevertError = (receipts, logs) => {
|
1766
|
+
var assembleRevertError = (receipts, logs, metadata) => {
|
1752
1767
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
1753
1768
|
const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
|
1754
1769
|
let reason = "";
|
@@ -1781,25 +1796,36 @@ var assembleRevertError = (receipts, logs) => {
|
|
1781
1796
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1782
1797
|
break;
|
1783
1798
|
default:
|
1784
|
-
|
1785
|
-
|
1799
|
+
throw new FuelError7(
|
1800
|
+
ErrorCode7.UNKNOWN,
|
1801
|
+
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
1802
|
+
{
|
1803
|
+
...metadata,
|
1804
|
+
reason: "unknown"
|
1805
|
+
}
|
1806
|
+
);
|
1786
1807
|
}
|
1787
1808
|
}
|
1788
|
-
return
|
1809
|
+
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
1810
|
+
...metadata,
|
1811
|
+
reason
|
1812
|
+
});
|
1789
1813
|
};
|
1790
1814
|
var extractTxError = (params) => {
|
1791
1815
|
const { receipts, statusReason, logs } = params;
|
1792
1816
|
const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
|
1793
1817
|
const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
|
1794
|
-
const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
|
1795
1818
|
const metadata = {
|
1796
1819
|
logs,
|
1797
1820
|
receipts,
|
1798
1821
|
panic: isPanic,
|
1799
1822
|
revert: isRevert,
|
1800
|
-
reason
|
1823
|
+
reason: ""
|
1801
1824
|
};
|
1802
|
-
|
1825
|
+
if (isPanic) {
|
1826
|
+
return assemblePanicError(statusReason, metadata);
|
1827
|
+
}
|
1828
|
+
return assembleRevertError(receipts, logs, metadata);
|
1803
1829
|
};
|
1804
1830
|
|
1805
1831
|
// src/providers/transaction-request/errors.ts
|
@@ -3752,6 +3778,7 @@ var TransactionResponse = class {
|
|
3752
3778
|
};
|
3753
3779
|
|
3754
3780
|
// src/providers/utils/auto-retry-fetch.ts
|
3781
|
+
import { sleep } from "@fuel-ts/utils";
|
3755
3782
|
function getWaitDelay(options, retryAttemptNum) {
|
3756
3783
|
const duration = options.baseDelay ?? 150;
|
3757
3784
|
switch (options.backoff) {
|
@@ -4178,7 +4205,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4178
4205
|
* @param sendTransactionParams - The provider call parameters (optional).
|
4179
4206
|
* @returns A promise that resolves to the call result object.
|
4180
4207
|
*/
|
4181
|
-
async
|
4208
|
+
async dryRun(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4182
4209
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4183
4210
|
if (estimateTxDependencies) {
|
4184
4211
|
return this.estimateTxDependencies(transactionRequest);
|
@@ -4717,6 +4744,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4717
4744
|
0
|
4718
4745
|
)?.[0];
|
4719
4746
|
}
|
4747
|
+
/**
|
4748
|
+
* Retrieves transactions based on the provided pagination arguments.
|
4749
|
+
* @param paginationArgs - The pagination arguments for retrieving transactions.
|
4750
|
+
* @returns A promise that resolves to an object containing the retrieved transactions and pagination information.
|
4751
|
+
*/
|
4752
|
+
async getTransactions(paginationArgs) {
|
4753
|
+
const {
|
4754
|
+
transactions: { edges, pageInfo }
|
4755
|
+
} = await this.operations.getTransactions(paginationArgs);
|
4756
|
+
const coder = new TransactionCoder5();
|
4757
|
+
const transactions = edges.map(
|
4758
|
+
({ node: { rawPayload } }) => coder.decode(arrayify11(rawPayload), 0)[0]
|
4759
|
+
);
|
4760
|
+
return { transactions, pageInfo };
|
4761
|
+
}
|
4720
4762
|
/**
|
4721
4763
|
* Get deployed contract with the given ID.
|
4722
4764
|
*
|
@@ -5077,7 +5119,7 @@ async function getTransactionSummary(params) {
|
|
5077
5119
|
}
|
5078
5120
|
async function getTransactionSummaryFromRequest(params) {
|
5079
5121
|
const { provider, transactionRequest, abiMap } = params;
|
5080
|
-
const { receipts } = await provider.
|
5122
|
+
const { receipts } = await provider.dryRun(transactionRequest);
|
5081
5123
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
5082
5124
|
const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
|
5083
5125
|
const transaction = transactionRequest.toTransaction();
|
@@ -5155,8 +5197,8 @@ var CHAIN_IDS = {
|
|
5155
5197
|
foundry: 31337
|
5156
5198
|
},
|
5157
5199
|
fuel: {
|
5158
|
-
|
5159
|
-
|
5200
|
+
devnet: 0,
|
5201
|
+
testnet: 0
|
5160
5202
|
}
|
5161
5203
|
};
|
5162
5204
|
|
@@ -5166,7 +5208,7 @@ var getDefaultChainId = (networkType) => {
|
|
5166
5208
|
return CHAIN_IDS.eth.sepolia;
|
5167
5209
|
}
|
5168
5210
|
if (networkType === "fuel") {
|
5169
|
-
return CHAIN_IDS.fuel.
|
5211
|
+
return CHAIN_IDS.fuel.testnet;
|
5170
5212
|
}
|
5171
5213
|
return void 0;
|
5172
5214
|
};
|
@@ -5258,15 +5300,15 @@ var rawAssets = [
|
|
5258
5300
|
},
|
5259
5301
|
{
|
5260
5302
|
type: "fuel",
|
5261
|
-
chainId: CHAIN_IDS.fuel.
|
5303
|
+
chainId: CHAIN_IDS.fuel.devnet,
|
5262
5304
|
decimals: 9,
|
5263
|
-
assetId: "
|
5305
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
5264
5306
|
},
|
5265
5307
|
{
|
5266
5308
|
type: "fuel",
|
5267
|
-
chainId: CHAIN_IDS.fuel.
|
5309
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
5268
5310
|
decimals: 9,
|
5269
|
-
assetId: "
|
5311
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
5270
5312
|
}
|
5271
5313
|
]
|
5272
5314
|
}
|
@@ -5780,6 +5822,21 @@ var Account = class extends AbstractAccount {
|
|
5780
5822
|
}
|
5781
5823
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5782
5824
|
}
|
5825
|
+
/**
|
5826
|
+
* Generates an array of fake resources based on the provided coins.
|
5827
|
+
*
|
5828
|
+
* @param coins - An array of `FakeResources` objects representing the coins.
|
5829
|
+
* @returns An array of `Resource` objects with generated properties.
|
5830
|
+
*/
|
5831
|
+
generateFakeResources(coins) {
|
5832
|
+
return coins.map((coin) => ({
|
5833
|
+
id: hexlify13(randomBytes2(UTXO_ID_LEN3)),
|
5834
|
+
owner: this.address,
|
5835
|
+
blockCreated: bn19(1),
|
5836
|
+
txCreatedIdx: bn19(1),
|
5837
|
+
...coin
|
5838
|
+
}));
|
5839
|
+
}
|
5783
5840
|
/** @hidden * */
|
5784
5841
|
validateTransferAmount(amount) {
|
5785
5842
|
if (bn19(amount).lte(0)) {
|
@@ -5834,14 +5891,14 @@ var Account = class extends AbstractAccount {
|
|
5834
5891
|
|
5835
5892
|
// src/wallet/base-wallet-unlocked.ts
|
5836
5893
|
import { hashMessage } from "@fuel-ts/hasher";
|
5837
|
-
import { hexlify as
|
5894
|
+
import { hexlify as hexlify16 } from "@fuel-ts/utils";
|
5838
5895
|
|
5839
5896
|
// src/signer/signer.ts
|
5840
5897
|
import { Address as Address4 } from "@fuel-ts/address";
|
5841
|
-
import { randomBytes as
|
5898
|
+
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
5842
5899
|
import { hash } from "@fuel-ts/hasher";
|
5843
5900
|
import { toBytes } from "@fuel-ts/math";
|
5844
|
-
import { hexlify as
|
5901
|
+
import { hexlify as hexlify14, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
5845
5902
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
5846
5903
|
var Signer = class {
|
5847
5904
|
address;
|
@@ -5861,9 +5918,9 @@ var Signer = class {
|
|
5861
5918
|
}
|
5862
5919
|
}
|
5863
5920
|
const privateKeyBytes = toBytes(privateKey, 32);
|
5864
|
-
this.privateKey =
|
5865
|
-
this.publicKey =
|
5866
|
-
this.compressedPublicKey =
|
5921
|
+
this.privateKey = hexlify14(privateKeyBytes);
|
5922
|
+
this.publicKey = hexlify14(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5923
|
+
this.compressedPublicKey = hexlify14(secp256k1.getPublicKey(privateKeyBytes, true));
|
5867
5924
|
this.address = Address4.fromPublicKey(this.publicKey);
|
5868
5925
|
}
|
5869
5926
|
/**
|
@@ -5881,7 +5938,7 @@ var Signer = class {
|
|
5881
5938
|
const r = toBytes(`0x${signature.r.toString(16)}`, 32);
|
5882
5939
|
const s = toBytes(`0x${signature.s.toString(16)}`, 32);
|
5883
5940
|
s[0] |= (signature.recovery || 0) << 7;
|
5884
|
-
return
|
5941
|
+
return hexlify14(concat3([r, s]));
|
5885
5942
|
}
|
5886
5943
|
/**
|
5887
5944
|
* Add point on the current elliptic curve
|
@@ -5908,11 +5965,11 @@ var Signer = class {
|
|
5908
5965
|
const s = signedMessageBytes.slice(32, 64);
|
5909
5966
|
const recoveryParam = (s[0] & 128) >> 7;
|
5910
5967
|
s[0] &= 127;
|
5911
|
-
const sig = new secp256k1.Signature(BigInt(
|
5968
|
+
const sig = new secp256k1.Signature(BigInt(hexlify14(r)), BigInt(hexlify14(s))).addRecoveryBit(
|
5912
5969
|
recoveryParam
|
5913
5970
|
);
|
5914
5971
|
const publicKey = sig.recoverPublicKey(arrayify15(data)).toRawBytes(false).slice(1);
|
5915
|
-
return
|
5972
|
+
return hexlify14(publicKey);
|
5916
5973
|
}
|
5917
5974
|
/**
|
5918
5975
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5931,7 +5988,7 @@ var Signer = class {
|
|
5931
5988
|
* @returns random 32-byte hashed
|
5932
5989
|
*/
|
5933
5990
|
static generatePrivateKey(entropy) {
|
5934
|
-
return entropy ? hash(concat3([
|
5991
|
+
return entropy ? hash(concat3([randomBytes3(32), arrayify15(entropy)])) : randomBytes3(32);
|
5935
5992
|
}
|
5936
5993
|
/**
|
5937
5994
|
* Extended publicKey from a compact publicKey
|
@@ -5941,7 +5998,7 @@ var Signer = class {
|
|
5941
5998
|
*/
|
5942
5999
|
static extendPublicKey(publicKey) {
|
5943
6000
|
const point = secp256k1.ProjectivePoint.fromHex(arrayify15(publicKey));
|
5944
|
-
return
|
6001
|
+
return hexlify14(point.toRawBytes(false).slice(1));
|
5945
6002
|
}
|
5946
6003
|
};
|
5947
6004
|
|
@@ -5950,14 +6007,14 @@ import { Address as Address5 } from "@fuel-ts/address";
|
|
5950
6007
|
import {
|
5951
6008
|
bufferFromString,
|
5952
6009
|
keccak256,
|
5953
|
-
randomBytes as
|
6010
|
+
randomBytes as randomBytes4,
|
5954
6011
|
scrypt,
|
5955
6012
|
stringFromBuffer,
|
5956
6013
|
decryptJsonWalletData,
|
5957
6014
|
encryptJsonWalletData
|
5958
6015
|
} from "@fuel-ts/crypto";
|
5959
6016
|
import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
|
5960
|
-
import { hexlify as
|
6017
|
+
import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
5961
6018
|
import { v4 as uuidv4 } from "uuid";
|
5962
6019
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5963
6020
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5973,7 +6030,7 @@ var removeHexPrefix = (hexString) => {
|
|
5973
6030
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
5974
6031
|
const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
|
5975
6032
|
const ownerAddress = Address5.fromAddressOrString(address);
|
5976
|
-
const salt =
|
6033
|
+
const salt = randomBytes4(DEFAULT_KEY_SIZE);
|
5977
6034
|
const key = scrypt({
|
5978
6035
|
password: bufferFromString(password),
|
5979
6036
|
salt,
|
@@ -5982,7 +6039,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
5982
6039
|
r: DEFAULT_KDF_PARAMS_R,
|
5983
6040
|
p: DEFAULT_KDF_PARAMS_P
|
5984
6041
|
});
|
5985
|
-
const iv =
|
6042
|
+
const iv = randomBytes4(DEFAULT_IV_SIZE);
|
5986
6043
|
const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
|
5987
6044
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
5988
6045
|
const macHashUint8Array = keccak256(data);
|
@@ -6040,7 +6097,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6040
6097
|
);
|
6041
6098
|
}
|
6042
6099
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
6043
|
-
const privateKey =
|
6100
|
+
const privateKey = hexlify15(buffer);
|
6044
6101
|
return privateKey;
|
6045
6102
|
}
|
6046
6103
|
|
@@ -6085,7 +6142,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6085
6142
|
*/
|
6086
6143
|
async signMessage(message) {
|
6087
6144
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
6088
|
-
return
|
6145
|
+
return hexlify16(signedMessage);
|
6089
6146
|
}
|
6090
6147
|
/**
|
6091
6148
|
* Signs a transaction with the wallet's private key.
|
@@ -6098,7 +6155,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6098
6155
|
const chainId = this.provider.getChainId();
|
6099
6156
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6100
6157
|
const signature = await this.signer().sign(hashedTransaction);
|
6101
|
-
return
|
6158
|
+
return hexlify16(signature);
|
6102
6159
|
}
|
6103
6160
|
/**
|
6104
6161
|
* Populates a transaction with the witnesses signature.
|
@@ -6131,7 +6188,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6131
6188
|
);
|
6132
6189
|
}
|
6133
6190
|
/**
|
6134
|
-
* Populates the witness signature for a transaction and sends a call to the network using `provider.
|
6191
|
+
* Populates the witness signature for a transaction and sends a call to the network using `provider.dryRun`.
|
6135
6192
|
*
|
6136
6193
|
* @param transactionRequestLike - The transaction request to simulate.
|
6137
6194
|
* @returns A promise that resolves to the CallResult object.
|
@@ -6141,7 +6198,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6141
6198
|
if (estimateTxDependencies) {
|
6142
6199
|
await this.provider.estimateTxDependencies(transactionRequest);
|
6143
6200
|
}
|
6144
|
-
return this.provider.
|
6201
|
+
return this.provider.dryRun(
|
6145
6202
|
await this.populateTransactionWitnessesSignature(transactionRequest),
|
6146
6203
|
{
|
6147
6204
|
utxoValidation: true,
|
@@ -6169,13 +6226,13 @@ import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
|
6169
6226
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
6170
6227
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6171
6228
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6172
|
-
import { arrayify as arrayify18, hexlify as
|
6229
|
+
import { arrayify as arrayify18, hexlify as hexlify18, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6173
6230
|
|
6174
6231
|
// src/mnemonic/mnemonic.ts
|
6175
|
-
import { randomBytes as
|
6232
|
+
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6176
6233
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
6177
6234
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6178
|
-
import { arrayify as arrayify17, hexlify as
|
6235
|
+
import { arrayify as arrayify17, hexlify as hexlify17, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6179
6236
|
|
6180
6237
|
// src/wordlists/words/english.ts
|
6181
6238
|
var english = [
|
@@ -8375,7 +8432,7 @@ var Mnemonic = class {
|
|
8375
8432
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8376
8433
|
const words = getWords(phrase);
|
8377
8434
|
assertMnemonic(words);
|
8378
|
-
return
|
8435
|
+
return hexlify17(mnemonicWordsToEntropy(words, wordlist));
|
8379
8436
|
}
|
8380
8437
|
/**
|
8381
8438
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8500,7 +8557,7 @@ var Mnemonic = class {
|
|
8500
8557
|
* @returns A randomly generated mnemonic
|
8501
8558
|
*/
|
8502
8559
|
static generate(size = 32, extraEntropy = "") {
|
8503
|
-
const entropy = extraEntropy ? sha2563(concat4([
|
8560
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes5(size), arrayify17(extraEntropy)])) : randomBytes5(size);
|
8504
8561
|
return Mnemonic.entropyToMnemonic(entropy);
|
8505
8562
|
}
|
8506
8563
|
};
|
@@ -8508,10 +8565,10 @@ var mnemonic_default = Mnemonic;
|
|
8508
8565
|
|
8509
8566
|
// src/hdwallet/hdwallet.ts
|
8510
8567
|
var HARDENED_INDEX = 2147483648;
|
8511
|
-
var MainnetPRV2 =
|
8512
|
-
var MainnetPUB =
|
8513
|
-
var TestnetPRV2 =
|
8514
|
-
var TestnetPUB =
|
8568
|
+
var MainnetPRV2 = hexlify18("0x0488ade4");
|
8569
|
+
var MainnetPUB = hexlify18("0x0488b21e");
|
8570
|
+
var TestnetPRV2 = hexlify18("0x04358394");
|
8571
|
+
var TestnetPUB = hexlify18("0x043587cf");
|
8515
8572
|
function base58check(data) {
|
8516
8573
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
8517
8574
|
}
|
@@ -8522,11 +8579,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8522
8579
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8523
8580
|
}
|
8524
8581
|
function isPublicExtendedKey(extendedKey) {
|
8525
|
-
return [MainnetPUB, TestnetPUB].includes(
|
8582
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify18(extendedKey.slice(0, 4)));
|
8526
8583
|
}
|
8527
8584
|
function isValidExtendedKey(extendedKey) {
|
8528
8585
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8529
|
-
|
8586
|
+
hexlify18(extendedKey.slice(0, 4))
|
8530
8587
|
);
|
8531
8588
|
}
|
8532
8589
|
function parsePath(path, depth = 0) {
|
@@ -8544,8 +8601,8 @@ function parsePath(path, depth = 0) {
|
|
8544
8601
|
var HDWallet = class {
|
8545
8602
|
depth = 0;
|
8546
8603
|
index = 0;
|
8547
|
-
fingerprint =
|
8548
|
-
parentFingerprint =
|
8604
|
+
fingerprint = hexlify18("0x00000000");
|
8605
|
+
parentFingerprint = hexlify18("0x00000000");
|
8549
8606
|
privateKey;
|
8550
8607
|
publicKey;
|
8551
8608
|
chainCode;
|
@@ -8557,8 +8614,8 @@ var HDWallet = class {
|
|
8557
8614
|
constructor(config) {
|
8558
8615
|
if (config.privateKey) {
|
8559
8616
|
const signer = new Signer(config.privateKey);
|
8560
|
-
this.publicKey =
|
8561
|
-
this.privateKey =
|
8617
|
+
this.publicKey = hexlify18(signer.compressedPublicKey);
|
8618
|
+
this.privateKey = hexlify18(config.privateKey);
|
8562
8619
|
} else {
|
8563
8620
|
if (!config.publicKey) {
|
8564
8621
|
throw new FuelError19(
|
@@ -8566,7 +8623,7 @@ var HDWallet = class {
|
|
8566
8623
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8567
8624
|
);
|
8568
8625
|
}
|
8569
|
-
this.publicKey =
|
8626
|
+
this.publicKey = hexlify18(config.publicKey);
|
8570
8627
|
}
|
8571
8628
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8572
8629
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -8615,7 +8672,7 @@ var HDWallet = class {
|
|
8615
8672
|
parentFingerprint: this.fingerprint
|
8616
8673
|
});
|
8617
8674
|
}
|
8618
|
-
const signer = new Signer(
|
8675
|
+
const signer = new Signer(hexlify18(IL));
|
8619
8676
|
const Ki = signer.addPoint(publicKey);
|
8620
8677
|
return new HDWallet({
|
8621
8678
|
publicKey: Ki,
|
@@ -8650,7 +8707,7 @@ var HDWallet = class {
|
|
8650
8707
|
);
|
8651
8708
|
}
|
8652
8709
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8653
|
-
const depth =
|
8710
|
+
const depth = hexlify18(Uint8Array.from([this.depth]));
|
8654
8711
|
const parentFingerprint = this.parentFingerprint;
|
8655
8712
|
const index = toHex(this.index, 4);
|
8656
8713
|
const chainCode = this.chainCode;
|
@@ -8672,7 +8729,7 @@ var HDWallet = class {
|
|
8672
8729
|
});
|
8673
8730
|
}
|
8674
8731
|
static fromExtendedKey(extendedKey) {
|
8675
|
-
const decoded =
|
8732
|
+
const decoded = hexlify18(toBytes2(decodeBase58(extendedKey)));
|
8676
8733
|
const bytes = arrayify18(decoded);
|
8677
8734
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8678
8735
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8682,9 +8739,9 @@ var HDWallet = class {
|
|
8682
8739
|
throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8683
8740
|
}
|
8684
8741
|
const depth = bytes[4];
|
8685
|
-
const parentFingerprint =
|
8686
|
-
const index = parseInt(
|
8687
|
-
const chainCode =
|
8742
|
+
const parentFingerprint = hexlify18(bytes.slice(5, 9));
|
8743
|
+
const index = parseInt(hexlify18(bytes.slice(9, 13)).substring(2), 16);
|
8744
|
+
const chainCode = hexlify18(bytes.slice(13, 45));
|
8688
8745
|
const key = bytes.slice(45, 78);
|
8689
8746
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8690
8747
|
throw new FuelError19(
|
@@ -9288,17 +9345,17 @@ var StorageAbstract = class {
|
|
9288
9345
|
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9289
9346
|
import { Address as Address9 } from "@fuel-ts/address";
|
9290
9347
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9291
|
-
import { arrayify as arrayify20, hexlify as
|
9348
|
+
import { arrayify as arrayify20, hexlify as hexlify20 } from "@fuel-ts/utils";
|
9292
9349
|
|
9293
9350
|
// src/predicate/utils/getPredicateRoot.ts
|
9294
9351
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
9295
9352
|
import { calcRoot } from "@fuel-ts/merkle";
|
9296
|
-
import { chunkAndPadBytes, hexlify as
|
9353
|
+
import { chunkAndPadBytes, hexlify as hexlify19, concat as concat6, arrayify as arrayify19 } from "@fuel-ts/utils";
|
9297
9354
|
var getPredicateRoot = (bytecode) => {
|
9298
9355
|
const chunkSize = 16 * 1024;
|
9299
9356
|
const bytes = arrayify19(bytecode);
|
9300
9357
|
const chunks = chunkAndPadBytes(bytes, chunkSize);
|
9301
|
-
const codeRoot = calcRoot(chunks.map((c) =>
|
9358
|
+
const codeRoot = calcRoot(chunks.map((c) => hexlify19(c)));
|
9302
9359
|
const predicateRoot = hash2(concat6(["0x4655454C", codeRoot]));
|
9303
9360
|
return predicateRoot;
|
9304
9361
|
};
|
@@ -9351,8 +9408,8 @@ var Predicate = class extends Account {
|
|
9351
9408
|
}
|
9352
9409
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9353
9410
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9354
|
-
input.predicate =
|
9355
|
-
input.predicateData =
|
9411
|
+
input.predicate = hexlify20(this.bytes);
|
9412
|
+
input.predicateData = hexlify20(this.getPredicateData());
|
9356
9413
|
input.witnessIndex = 0;
|
9357
9414
|
}
|
9358
9415
|
});
|
@@ -9432,8 +9489,21 @@ var Predicate = class extends Account {
|
|
9432
9489
|
);
|
9433
9490
|
return resources.map((resource) => ({
|
9434
9491
|
...resource,
|
9435
|
-
predicate:
|
9436
|
-
predicateData:
|
9492
|
+
predicate: hexlify20(this.bytes),
|
9493
|
+
predicateData: hexlify20(this.getPredicateData())
|
9494
|
+
}));
|
9495
|
+
}
|
9496
|
+
/**
|
9497
|
+
* Generates an array of fake resources based on the provided coins.
|
9498
|
+
*
|
9499
|
+
* @param coins - An array of `FakeResources` objects representing the coins.
|
9500
|
+
* @returns An array of `Resource` objects with generated properties.
|
9501
|
+
*/
|
9502
|
+
generateFakeResources(coins) {
|
9503
|
+
return super.generateFakeResources(coins).map((coin) => ({
|
9504
|
+
...coin,
|
9505
|
+
predicate: hexlify20(this.bytes),
|
9506
|
+
predicateData: hexlify20(this.getPredicateData())
|
9437
9507
|
}));
|
9438
9508
|
}
|
9439
9509
|
/**
|
@@ -10297,7 +10367,6 @@ export {
|
|
10297
10367
|
resolveGasDependentCosts,
|
10298
10368
|
resolveIconPaths,
|
10299
10369
|
returnZeroScript,
|
10300
|
-
sleep,
|
10301
10370
|
transactionRequestify,
|
10302
10371
|
urlJoin,
|
10303
10372
|
withTimeout,
|