@fuel-ts/account 0.76.3 → 0.78.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 +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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +906 -1340
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +151 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +211 -121
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +16 -15
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +9 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/index.d.ts +1 -0
- package/dist/providers/assets/index.d.ts.map +1 -1
- package/dist/providers/assets/types.d.ts +5 -5
- package/dist/providers/assets/types.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts +4 -4
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +25 -15
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/hash-transaction.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/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/test-utils.global.js +871 -1314
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +118 -32
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +159 -81
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.js
CHANGED
@@ -112,7 +112,7 @@ var import_transactions17 = require("@fuel-ts/transactions");
|
|
112
112
|
var import_utils22 = require("@fuel-ts/utils");
|
113
113
|
var import_versions = require("@fuel-ts/versions");
|
114
114
|
var import_utils23 = require("@noble/curves/abstract/utils");
|
115
|
-
var
|
115
|
+
var import_ethers = require("ethers");
|
116
116
|
var import_graphql_request = require("graphql-request");
|
117
117
|
var import_ramda3 = require("ramda");
|
118
118
|
|
@@ -177,6 +177,9 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
177
177
|
time
|
178
178
|
reason
|
179
179
|
}
|
180
|
+
... on SqueezedOutStatus {
|
181
|
+
reason
|
182
|
+
}
|
180
183
|
}
|
181
184
|
`;
|
182
185
|
var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
@@ -954,7 +957,16 @@ var _FuelGraphqlSubscriber = class {
|
|
954
957
|
if (!text.startsWith("data:")) {
|
955
958
|
continue;
|
956
959
|
}
|
957
|
-
|
960
|
+
let data;
|
961
|
+
let errors;
|
962
|
+
try {
|
963
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
964
|
+
} catch (e) {
|
965
|
+
throw new import_errors.FuelError(
|
966
|
+
import_errors.ErrorCode.STREAM_PARSING_ERROR,
|
967
|
+
`Error while parsing stream data response: ${text}`
|
968
|
+
);
|
969
|
+
}
|
958
970
|
if (Array.isArray(errors)) {
|
959
971
|
throw new import_errors.FuelError(
|
960
972
|
import_errors.FuelError.CODES.INVALID_REQUEST,
|
@@ -1634,13 +1646,27 @@ var BaseTransactionRequest = class {
|
|
1634
1646
|
this.outputs.push(output);
|
1635
1647
|
return this.outputs.length - 1;
|
1636
1648
|
}
|
1649
|
+
/**
|
1650
|
+
* @hidden
|
1651
|
+
*
|
1652
|
+
* Pushes a witness to the list and returns the index
|
1653
|
+
*
|
1654
|
+
* @param signature - The signature to add to the witness.
|
1655
|
+
* @returns The index of the created witness.
|
1656
|
+
*/
|
1657
|
+
addWitness(signature) {
|
1658
|
+
this.witnesses.push(signature);
|
1659
|
+
return this.witnesses.length - 1;
|
1660
|
+
}
|
1637
1661
|
/**
|
1638
1662
|
* @hidden
|
1639
1663
|
*
|
1640
1664
|
* Creates an empty witness without any side effects and returns the index
|
1665
|
+
*
|
1666
|
+
* @returns The index of the created witness.
|
1641
1667
|
*/
|
1642
|
-
|
1643
|
-
this.
|
1668
|
+
addEmptyWitness() {
|
1669
|
+
this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1644
1670
|
return this.witnesses.length - 1;
|
1645
1671
|
}
|
1646
1672
|
/**
|
@@ -1669,6 +1695,21 @@ var BaseTransactionRequest = class {
|
|
1669
1695
|
}
|
1670
1696
|
this.witnesses[index] = witness;
|
1671
1697
|
}
|
1698
|
+
/**
|
1699
|
+
* Helper function to add an external signature to the transaction.
|
1700
|
+
*
|
1701
|
+
* @param account - The account/s to sign to the transaction.
|
1702
|
+
* @returns The transaction with the signature witness added.
|
1703
|
+
*/
|
1704
|
+
async addAccountWitnesses(account) {
|
1705
|
+
const accounts = Array.isArray(account) ? account : [account];
|
1706
|
+
await Promise.all(
|
1707
|
+
accounts.map(async (acc) => {
|
1708
|
+
this.addWitness(await acc.signTransaction(this));
|
1709
|
+
})
|
1710
|
+
);
|
1711
|
+
return this;
|
1712
|
+
}
|
1672
1713
|
/**
|
1673
1714
|
* Gets the coin inputs for a transaction.
|
1674
1715
|
*
|
@@ -1734,7 +1775,7 @@ var BaseTransactionRequest = class {
|
|
1734
1775
|
} else {
|
1735
1776
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
1736
1777
|
if (typeof witnessIndex !== "number") {
|
1737
|
-
witnessIndex = this.
|
1778
|
+
witnessIndex = this.addEmptyWitness();
|
1738
1779
|
}
|
1739
1780
|
}
|
1740
1781
|
const input = {
|
@@ -1746,7 +1787,7 @@ var BaseTransactionRequest = class {
|
|
1746
1787
|
txPointer: "0x00000000000000000000000000000000",
|
1747
1788
|
witnessIndex,
|
1748
1789
|
predicate: predicate?.bytes,
|
1749
|
-
predicateData: predicate?.
|
1790
|
+
predicateData: predicate?.predicateDataBytes
|
1750
1791
|
};
|
1751
1792
|
this.pushInput(input);
|
1752
1793
|
this.addChangeOutput(owner, assetId);
|
@@ -1768,7 +1809,7 @@ var BaseTransactionRequest = class {
|
|
1768
1809
|
} else {
|
1769
1810
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
1770
1811
|
if (typeof witnessIndex !== "number") {
|
1771
|
-
witnessIndex = this.
|
1812
|
+
witnessIndex = this.addEmptyWitness();
|
1772
1813
|
}
|
1773
1814
|
}
|
1774
1815
|
const input = {
|
@@ -1779,7 +1820,7 @@ var BaseTransactionRequest = class {
|
|
1779
1820
|
amount,
|
1780
1821
|
witnessIndex,
|
1781
1822
|
predicate: predicate?.bytes,
|
1782
|
-
predicateData: predicate?.
|
1823
|
+
predicateData: predicate?.predicateDataBytes
|
1783
1824
|
};
|
1784
1825
|
this.pushInput(input);
|
1785
1826
|
this.addChangeOutput(recipient, assetId);
|
@@ -2026,7 +2067,6 @@ var import_hasher = require("@fuel-ts/hasher");
|
|
2026
2067
|
var import_math7 = require("@fuel-ts/math");
|
2027
2068
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2028
2069
|
var import_utils11 = require("@fuel-ts/utils");
|
2029
|
-
var import_ethers = require("ethers");
|
2030
2070
|
var import_ramda2 = require("ramda");
|
2031
2071
|
function hashTransaction(transactionRequest, chainId) {
|
2032
2072
|
const transaction = transactionRequest.toTransaction();
|
@@ -2089,7 +2129,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2089
2129
|
transaction.witnesses = [];
|
2090
2130
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2091
2131
|
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
|
2092
|
-
return (0,
|
2132
|
+
return (0, import_hasher.sha256)(concatenatedData);
|
2093
2133
|
}
|
2094
2134
|
|
2095
2135
|
// src/providers/transaction-request/storage-slot.ts
|
@@ -3243,6 +3283,12 @@ var TransactionResponse = class {
|
|
3243
3283
|
transactionId: this.id
|
3244
3284
|
});
|
3245
3285
|
for await (const { statusChange } of subscription) {
|
3286
|
+
if (statusChange.type === "SqueezedOutStatus") {
|
3287
|
+
throw new import_errors12.FuelError(
|
3288
|
+
import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3289
|
+
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3290
|
+
);
|
3291
|
+
}
|
3246
3292
|
if (statusChange.type !== "SubmittedStatus") {
|
3247
3293
|
break;
|
3248
3294
|
}
|
@@ -3407,14 +3453,15 @@ var _Provider = class {
|
|
3407
3453
|
}
|
3408
3454
|
static getFetchFn(options) {
|
3409
3455
|
const { retryOptions, timeout } = options;
|
3410
|
-
return autoRetryFetch((...args) => {
|
3411
|
-
if (options.fetch) {
|
3412
|
-
return options.fetch(...args);
|
3413
|
-
}
|
3456
|
+
return autoRetryFetch(async (...args) => {
|
3414
3457
|
const url = args[0];
|
3415
3458
|
const request = args[1];
|
3416
3459
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
3417
|
-
|
3460
|
+
let fullRequest = { ...request, signal };
|
3461
|
+
if (options.requestMiddleware) {
|
3462
|
+
fullRequest = await options.requestMiddleware(fullRequest);
|
3463
|
+
}
|
3464
|
+
return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
|
3418
3465
|
}, retryOptions);
|
3419
3466
|
}
|
3420
3467
|
/**
|
@@ -3548,7 +3595,7 @@ var _Provider = class {
|
|
3548
3595
|
name,
|
3549
3596
|
consensusParameters: { chainId }
|
3550
3597
|
} = await this.getChain();
|
3551
|
-
const network = new
|
3598
|
+
const network = new import_ethers.Network(name, chainId.toNumber());
|
3552
3599
|
return Promise.resolve(network);
|
3553
3600
|
}
|
3554
3601
|
/**
|
@@ -3620,6 +3667,12 @@ var _Provider = class {
|
|
3620
3667
|
if (awaitExecution) {
|
3621
3668
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3622
3669
|
for await (const { submitAndAwait } of subscription) {
|
3670
|
+
if (submitAndAwait.type === "SqueezedOutStatus") {
|
3671
|
+
throw new import_errors13.FuelError(
|
3672
|
+
import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3673
|
+
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
3674
|
+
);
|
3675
|
+
}
|
3623
3676
|
if (submitAndAwait.type !== "SubmittedStatus") {
|
3624
3677
|
break;
|
3625
3678
|
}
|
@@ -3783,7 +3836,8 @@ var _Provider = class {
|
|
3783
3836
|
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
3784
3837
|
estimateTxDependencies = true,
|
3785
3838
|
estimatePredicates = true,
|
3786
|
-
resourcesOwner
|
3839
|
+
resourcesOwner,
|
3840
|
+
signatureCallback
|
3787
3841
|
} = {}) {
|
3788
3842
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3789
3843
|
const chainInfo = this.getChain();
|
@@ -3802,6 +3856,9 @@ var _Provider = class {
|
|
3802
3856
|
}
|
3803
3857
|
await this.estimatePredicates(txRequestClone);
|
3804
3858
|
}
|
3859
|
+
if (signatureCallback && isScriptTransaction) {
|
3860
|
+
await signatureCallback(txRequestClone);
|
3861
|
+
}
|
3805
3862
|
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
3806
3863
|
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
3807
3864
|
let receipts = [];
|
@@ -4585,6 +4642,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4585
4642
|
* @returns A promise that resolves to the transaction response.
|
4586
4643
|
*/
|
4587
4644
|
async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4645
|
+
if ((0, import_math17.bn)(amount).lte(0)) {
|
4646
|
+
throw new import_errors15.FuelError(
|
4647
|
+
import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4648
|
+
"Transfer amount must be a positive number."
|
4649
|
+
);
|
4650
|
+
}
|
4588
4651
|
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
4589
4652
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
4590
4653
|
}
|
@@ -4598,6 +4661,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4598
4661
|
* @returns A promise that resolves to the transaction response.
|
4599
4662
|
*/
|
4600
4663
|
async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
|
4664
|
+
if ((0, import_math17.bn)(amount).lte(0)) {
|
4665
|
+
throw new import_errors15.FuelError(
|
4666
|
+
import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4667
|
+
"Transfer amount must be a positive number."
|
4668
|
+
);
|
4669
|
+
}
|
4601
4670
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4602
4671
|
const { minGasPrice } = this.provider.getGasConfig();
|
4603
4672
|
const params = { gasPrice: minGasPrice, ...txParams };
|
@@ -4671,6 +4740,21 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4671
4740
|
}
|
4672
4741
|
return this._connector.signMessage(this.address.toString(), message);
|
4673
4742
|
}
|
4743
|
+
/**
|
4744
|
+
* Signs a transaction with the wallet's private key.
|
4745
|
+
*
|
4746
|
+
* @param transactionRequestLike - The transaction request to sign.
|
4747
|
+
* @returns A promise that resolves to the signature of the transaction.
|
4748
|
+
*/
|
4749
|
+
async signTransaction(transactionRequestLike) {
|
4750
|
+
if (!this._connector) {
|
4751
|
+
throw new import_errors15.FuelError(
|
4752
|
+
import_errors15.ErrorCode.MISSING_CONNECTOR,
|
4753
|
+
"A connector is required to sign transactions."
|
4754
|
+
);
|
4755
|
+
}
|
4756
|
+
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
4757
|
+
}
|
4674
4758
|
/**
|
4675
4759
|
* Sends a transaction to the network.
|
4676
4760
|
*
|
@@ -4977,7 +5061,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
4977
5061
|
*/
|
4978
5062
|
async signTransaction(transactionRequestLike) {
|
4979
5063
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
4980
|
-
const chainId = this.provider.
|
5064
|
+
const chainId = this.provider.getChainId();
|
4981
5065
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
4982
5066
|
const signature = await this.signer().sign(hashedTransaction);
|
4983
5067
|
return (0, import_utils30.hexlify)(signature);
|
@@ -5040,15 +5124,17 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5040
5124
|
|
5041
5125
|
// src/hdwallet/hdwallet.ts
|
5042
5126
|
var import_errors19 = require("@fuel-ts/errors");
|
5127
|
+
var import_hasher6 = require("@fuel-ts/hasher");
|
5043
5128
|
var import_math19 = require("@fuel-ts/math");
|
5044
5129
|
var import_utils34 = require("@fuel-ts/utils");
|
5045
|
-
var
|
5130
|
+
var import_ethers3 = require("ethers");
|
5046
5131
|
|
5047
5132
|
// src/mnemonic/mnemonic.ts
|
5048
5133
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5049
5134
|
var import_errors18 = require("@fuel-ts/errors");
|
5135
|
+
var import_hasher5 = require("@fuel-ts/hasher");
|
5050
5136
|
var import_utils32 = require("@fuel-ts/utils");
|
5051
|
-
var
|
5137
|
+
var import_ethers2 = require("ethers");
|
5052
5138
|
|
5053
5139
|
// src/wordlists/words/english.ts
|
5054
5140
|
var english = [
|
@@ -7104,8 +7190,8 @@ var english = [
|
|
7104
7190
|
|
7105
7191
|
// src/mnemonic/utils.ts
|
7106
7192
|
var import_errors17 = require("@fuel-ts/errors");
|
7193
|
+
var import_hasher4 = require("@fuel-ts/hasher");
|
7107
7194
|
var import_utils31 = require("@fuel-ts/utils");
|
7108
|
-
var import_ethers3 = require("ethers");
|
7109
7195
|
function toUtf8Bytes(stri) {
|
7110
7196
|
const str = stri.normalize("NFKD");
|
7111
7197
|
const result = [];
|
@@ -7172,7 +7258,7 @@ function entropyToMnemonicIndices(entropy) {
|
|
7172
7258
|
}
|
7173
7259
|
}
|
7174
7260
|
const checksumBits = entropy.length / 4;
|
7175
|
-
const checksum = (0, import_utils31.arrayify)((0,
|
7261
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7176
7262
|
indices[indices.length - 1] <<= checksumBits;
|
7177
7263
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7178
7264
|
return indices;
|
@@ -7199,7 +7285,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7199
7285
|
const entropyBits = 32 * words.length / 3;
|
7200
7286
|
const checksumBits = words.length / 3;
|
7201
7287
|
const checksumMask = getUpperMask(checksumBits);
|
7202
|
-
const checksum = (0, import_utils31.arrayify)((0,
|
7288
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7203
7289
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7204
7290
|
throw new import_errors17.FuelError(
|
7205
7291
|
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
@@ -7296,7 +7382,7 @@ var Mnemonic = class {
|
|
7296
7382
|
assertMnemonic(getWords(phrase));
|
7297
7383
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7298
7384
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7299
|
-
return (0,
|
7385
|
+
return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7300
7386
|
}
|
7301
7387
|
/**
|
7302
7388
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7358,7 +7444,7 @@ var Mnemonic = class {
|
|
7358
7444
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7359
7445
|
);
|
7360
7446
|
}
|
7361
|
-
return (0, import_utils32.arrayify)((0,
|
7447
|
+
return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7362
7448
|
}
|
7363
7449
|
/**
|
7364
7450
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7383,8 +7469,8 @@ var Mnemonic = class {
|
|
7383
7469
|
chainCode,
|
7384
7470
|
(0, import_utils32.concat)(["0x00", privateKey])
|
7385
7471
|
]);
|
7386
|
-
const checksum = (0,
|
7387
|
-
return (0,
|
7472
|
+
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7473
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7388
7474
|
}
|
7389
7475
|
/**
|
7390
7476
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7399,7 +7485,7 @@ var Mnemonic = class {
|
|
7399
7485
|
* @returns A randomly generated mnemonic
|
7400
7486
|
*/
|
7401
7487
|
static generate(size = 32, extraEntropy = "") {
|
7402
|
-
const entropy = extraEntropy ? (0,
|
7488
|
+
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);
|
7403
7489
|
return Mnemonic.entropyToMnemonic(entropy);
|
7404
7490
|
}
|
7405
7491
|
};
|
@@ -7412,7 +7498,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
|
7412
7498
|
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7413
7499
|
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7414
7500
|
function base58check(data) {
|
7415
|
-
return (0,
|
7501
|
+
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)]));
|
7416
7502
|
}
|
7417
7503
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7418
7504
|
if (isPublic) {
|
@@ -7468,7 +7554,7 @@ var HDWallet = class {
|
|
7468
7554
|
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7469
7555
|
}
|
7470
7556
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7471
|
-
this.fingerprint = (0,
|
7557
|
+
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
7472
7558
|
this.depth = config.depth || this.depth;
|
7473
7559
|
this.index = config.index || this.index;
|
7474
7560
|
this.chainCode = config.chainCode;
|
@@ -7500,7 +7586,7 @@ var HDWallet = class {
|
|
7500
7586
|
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7501
7587
|
}
|
7502
7588
|
data.set((0, import_math19.toBytes)(index, 4), 33);
|
7503
|
-
const bytes = (0, import_utils34.arrayify)((0,
|
7589
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
7504
7590
|
const IL = bytes.slice(0, 32);
|
7505
7591
|
const IR = bytes.slice(32);
|
7506
7592
|
if (privateKey) {
|
@@ -7571,7 +7657,7 @@ var HDWallet = class {
|
|
7571
7657
|
});
|
7572
7658
|
}
|
7573
7659
|
static fromExtendedKey(extendedKey) {
|
7574
|
-
const decoded = (0,
|
7660
|
+
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
7575
7661
|
const bytes = (0, import_utils34.arrayify)(decoded);
|
7576
7662
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7577
7663
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|