@tetherto/wdk-wallet-evm-erc-4337 1.0.0-beta.17 → 1.0.0-beta.18
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetherto/wdk-wallet-evm-erc-4337",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.18",
|
|
4
4
|
"description": "A simple package to manage BIP-32 wallets for evm blockchains, which implement the erc-4337 standard and its account abstraction features",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wdk",
|
|
@@ -593,16 +593,29 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
593
593
|
}
|
|
594
594
|
|
|
595
595
|
/**
|
|
596
|
-
* Returns the chain id.
|
|
596
|
+
* Returns the chain id, asserting the provider is on the configured network.
|
|
597
|
+
*
|
|
598
|
+
* The value is read once from the provider (`eth_chainId`), checked against
|
|
599
|
+
* `config.chainId`, and cached. Every UserOperation is built and signed against
|
|
600
|
+
* this value, so a provider reporting a different chain than the one the
|
|
601
|
+
* application configured must fail here rather than produce a signature for the
|
|
602
|
+
* wrong network.
|
|
597
603
|
*
|
|
598
604
|
* @protected
|
|
599
605
|
* @returns {Promise<bigint>} - The chain id.
|
|
606
|
+
* @throws {ConfigurationError} If the provider's chain id does not match `config.chainId`.
|
|
600
607
|
*/
|
|
601
608
|
async _getChainId () {
|
|
602
609
|
if (!this._chainId) {
|
|
603
|
-
const chainId = await this._provider.request({ method: 'eth_chainId' })
|
|
610
|
+
const chainId = BigInt(await this._provider.request({ method: 'eth_chainId' }))
|
|
611
|
+
|
|
612
|
+
if (this._config.chainId !== undefined && chainId !== BigInt(this._config.chainId)) {
|
|
613
|
+
throw new ConfigurationError(
|
|
614
|
+
`Provider is on chain ${chainId} but the wallet is configured for chain ${this._config.chainId}`
|
|
615
|
+
)
|
|
616
|
+
}
|
|
604
617
|
|
|
605
|
-
this._chainId =
|
|
618
|
+
this._chainId = chainId
|
|
606
619
|
}
|
|
607
620
|
|
|
608
621
|
return this._chainId
|
|
@@ -717,8 +730,8 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
717
730
|
* @returns {Promise<BuiltUserOperation>} The built operation, signing context, and (in token mode) the paymaster quote.
|
|
718
731
|
*/
|
|
719
732
|
async _buildUserOperation (calls, config, txOverrides = {}) {
|
|
720
|
-
const smartAccount = await this._getSmartAccount(config)
|
|
721
733
|
const chainId = await this._getChainId()
|
|
734
|
+
const smartAccount = await this._getSmartAccount(config)
|
|
722
735
|
|
|
723
736
|
const mode = WalletAccountReadOnlyEvmErc4337._resolvePaymasterMode(config)
|
|
724
737
|
const provider = mode !== PaymasterMode.NATIVE
|