@dynamic-labs/ethereum-aa-core 4.14.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Dynamic Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @dynamic-labs/ethereum-aa-core
2
+
3
+ Core package for Ethereum Account Abstraction utilities and types.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @dynamic-labs/ethereum-aa-core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { AccountAbstractionBaseConnector } from '@dynamic-labs/ethereum-aa-core';
15
+ ```
16
+
17
+ ## License
18
+
19
+ MIT
package/package.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var version = "4.14.0";
7
+
8
+ exports.version = version;
package/package.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ var version = "4.14.0";
3
+
4
+ export { version };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@dynamic-labs/ethereum-aa-core",
3
+ "version": "4.14.0",
4
+ "description": "Core package for Ethereum Account Abstraction utilities and types",
5
+ "author": "Dynamic Labs, Inc.",
6
+ "license": "MIT",
7
+ "main": "./src/index.cjs",
8
+ "module": "./src/index.js",
9
+ "types": "./src/index.d.ts",
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./src/index.d.ts",
14
+ "import": "./src/index.js",
15
+ "require": "./src/index.cjs"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "homepage": "https://www.dynamic.xyz/",
20
+ "dependencies": {
21
+ "@dynamic-labs/sdk-api-core": "0.0.658",
22
+ "@dynamic-labs/assert-package-version": "4.14.0",
23
+ "@dynamic-labs/ethereum-core": "4.14.0",
24
+ "@dynamic-labs/types": "4.14.0",
25
+ "@dynamic-labs/utils": "4.14.0",
26
+ "@dynamic-labs/wallet-book": "4.14.0",
27
+ "@dynamic-labs/wallet-connector-core": "4.14.0"
28
+ },
29
+ "peerDependencies": {
30
+ "viem": "^2.21.60"
31
+ }
32
+ }
@@ -0,0 +1,92 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var viem = require('viem');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
+ var utils = require('@dynamic-labs/utils');
9
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
10
+
11
+ class AccountAbstractionBaseConnector extends walletConnectorCore.WalletConnectorBase {
12
+ constructor(opts) {
13
+ super({ walletBook: opts.walletBook });
14
+ this._isGasSponsorshipDisabled = false;
15
+ this.evmNetworks = [];
16
+ this.ChainWallet = ethereumCore.EthereumWallet;
17
+ this.isEmbeddedWallet = true;
18
+ this.connectedChain = 'EVM';
19
+ this.supportedChains = ['ETH', 'EVM'];
20
+ this._walletUiUtils = opts.walletUiUtils;
21
+ this.evmNetworks = opts.evmNetworks;
22
+ }
23
+ /**
24
+ * Gets the EOA connector associated with this account abstraction wallet
25
+ * @deprecated Use getEOAConnector with a specific smart contract wallet address instead
26
+ */
27
+ getEOAConnector() {
28
+ return this.eoaConnector;
29
+ }
30
+ /**
31
+ * Disables gas sponsorship for the next transaction
32
+ */
33
+ disableGasSponsorshipOnce() {
34
+ this._isGasSponsorshipDisabled = true;
35
+ }
36
+ /**
37
+ * Protected method to check if gas sponsorship is disabled
38
+ */
39
+ isGasSponsorshipDisabled() {
40
+ return this._isGasSponsorshipDisabled;
41
+ }
42
+ /**
43
+ * Gets the enabled networks
44
+ */
45
+ getEnabledNetworks() {
46
+ return this.evmNetworks;
47
+ }
48
+ /**
49
+ * Gets the signer for the current wallet
50
+ */
51
+ async getSigner() {
52
+ return this.getWalletClient();
53
+ }
54
+ /**
55
+ * Gets the balance for an address
56
+ */
57
+ async getBalance(address) {
58
+ const publicClient = await this.getPublicClient();
59
+ if (!publicClient) {
60
+ throw new utils.DynamicError('No public client available');
61
+ }
62
+ const balance = await publicClient.getBalance({ address });
63
+ return viem.formatEther(balance);
64
+ }
65
+ /**
66
+ * Validates that the expected wallet is active
67
+ */
68
+ async validateActiveWallet(expectedAddress) {
69
+ const currentAddress = await this.getAddress();
70
+ if (currentAddress?.toLowerCase() !== expectedAddress.toLowerCase()) {
71
+ throw new utils.DynamicError('Invalid active wallet');
72
+ }
73
+ }
74
+ async createUiTransaction(from) {
75
+ await this.validateActiveWallet(from);
76
+ const walletClient = this.getWalletClient();
77
+ const publicClient = await this.getPublicClient();
78
+ if (!publicClient || !walletClient) {
79
+ throw new utils.DynamicError('No public client available');
80
+ }
81
+ return ethereumCore.createViemUiTransaction({
82
+ from,
83
+ publicClient: publicClient,
84
+ walletClient: walletClient,
85
+ });
86
+ }
87
+ async getBlockExplorerUrlsForCurrentNetwork() {
88
+ return this.eoaConnector?.getBlockExplorerUrlsForCurrentNetwork() ?? [];
89
+ }
90
+ }
91
+
92
+ exports.AccountAbstractionBaseConnector = AccountAbstractionBaseConnector;
@@ -0,0 +1,65 @@
1
+ import { Chain, InternalWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
2
+ import { EthereumWallet } from '@dynamic-labs/ethereum-core';
3
+ import { IUITransaction, WalletUiUtils, GenericNetwork } from '@dynamic-labs/types';
4
+ import { SmartWalletProperties } from '@dynamic-labs/sdk-api-core';
5
+ import { AccountAbstractionConnectorProps } from '../types';
6
+ export declare abstract class AccountAbstractionBaseConnector extends WalletConnectorBase<typeof EthereumWallet> {
7
+ abstract eoaConnector: InternalWalletConnector | undefined;
8
+ abstract eoaAddress: string | undefined;
9
+ protected _walletUiUtils: WalletUiUtils<InternalWalletConnector>;
10
+ private _isGasSponsorshipDisabled;
11
+ protected evmNetworks: GenericNetwork[];
12
+ ChainWallet: typeof EthereumWallet;
13
+ isEmbeddedWallet: boolean;
14
+ connectedChain: Chain;
15
+ supportedChains: Chain[];
16
+ constructor(opts: AccountAbstractionConnectorProps);
17
+ /**
18
+ * Gets the EOA connector associated with this account abstraction wallet
19
+ * @deprecated Use getEOAConnector with a specific smart contract wallet address instead
20
+ */
21
+ getEOAConnector(): InternalWalletConnector | undefined;
22
+ /**
23
+ * Disables gas sponsorship for the next transaction
24
+ */
25
+ disableGasSponsorshipOnce(): void;
26
+ /**
27
+ * Protected method to check if gas sponsorship is disabled
28
+ */
29
+ protected isGasSponsorshipDisabled(): boolean;
30
+ /**
31
+ * Gets the enabled networks
32
+ */
33
+ getEnabledNetworks(): GenericNetwork[];
34
+ /**
35
+ * Gets the signer for the current wallet
36
+ */
37
+ getSigner(): Promise<unknown>;
38
+ /**
39
+ * Gets the balance for an address
40
+ */
41
+ getBalance(address: string): Promise<string | undefined>;
42
+ /**
43
+ * Validates that the expected wallet is active
44
+ */
45
+ validateActiveWallet(expectedAddress: string): Promise<void>;
46
+ abstract canSponsorTransactionGas(transaction: {
47
+ from: string;
48
+ to?: string;
49
+ value?: bigint;
50
+ data?: string;
51
+ }): Promise<boolean>;
52
+ createUiTransaction(from: string): Promise<IUITransaction>;
53
+ getBlockExplorerUrlsForCurrentNetwork(): Promise<string[]>;
54
+ abstract getAccountAbstractionProvider<T>({ withSponsorship, }: {
55
+ withSponsorship: boolean;
56
+ }): Promise<T>;
57
+ abstract initialize(params: {
58
+ smartWalletAddress: string;
59
+ eoaAddress: string;
60
+ eoaConnector: InternalWalletConnector;
61
+ properties?: SmartWalletProperties;
62
+ shouldSetEoaConnector?: boolean;
63
+ }): Promise<void>;
64
+ }
65
+ //# sourceMappingURL=AccountAbstractionBaseConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAbstractionBaseConnector.d.ts","sourceRoot":"","sources":["../../../../../packages/ethereum-aa-core/src/connector/AccountAbstractionBaseConnector.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAEL,cAAc,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,8BAAsB,+BAAgC,SAAQ,mBAAmB,CAC/E,OAAO,cAAc,CACtB;IACC,QAAQ,CAAC,YAAY,EAAE,uBAAuB,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC,SAAS,CAAC,cAAc,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACjE,OAAO,CAAC,yBAAyB,CAAS;IAC1C,SAAS,CA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B,CAAC,EAAE,OAAO,CAAC;KACjC,GAAG,OAAO,CAAC,IAAI,CAAC;CAClB"}
@@ -0,0 +1,88 @@
1
+ 'use client'
2
+ import { formatEther } from 'viem';
3
+ import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
4
+ import { DynamicError } from '@dynamic-labs/utils';
5
+ import { EthereumWallet, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
6
+
7
+ class AccountAbstractionBaseConnector extends WalletConnectorBase {
8
+ constructor(opts) {
9
+ super({ walletBook: opts.walletBook });
10
+ this._isGasSponsorshipDisabled = false;
11
+ this.evmNetworks = [];
12
+ this.ChainWallet = EthereumWallet;
13
+ this.isEmbeddedWallet = true;
14
+ this.connectedChain = 'EVM';
15
+ this.supportedChains = ['ETH', 'EVM'];
16
+ this._walletUiUtils = opts.walletUiUtils;
17
+ this.evmNetworks = opts.evmNetworks;
18
+ }
19
+ /**
20
+ * Gets the EOA connector associated with this account abstraction wallet
21
+ * @deprecated Use getEOAConnector with a specific smart contract wallet address instead
22
+ */
23
+ getEOAConnector() {
24
+ return this.eoaConnector;
25
+ }
26
+ /**
27
+ * Disables gas sponsorship for the next transaction
28
+ */
29
+ disableGasSponsorshipOnce() {
30
+ this._isGasSponsorshipDisabled = true;
31
+ }
32
+ /**
33
+ * Protected method to check if gas sponsorship is disabled
34
+ */
35
+ isGasSponsorshipDisabled() {
36
+ return this._isGasSponsorshipDisabled;
37
+ }
38
+ /**
39
+ * Gets the enabled networks
40
+ */
41
+ getEnabledNetworks() {
42
+ return this.evmNetworks;
43
+ }
44
+ /**
45
+ * Gets the signer for the current wallet
46
+ */
47
+ async getSigner() {
48
+ return this.getWalletClient();
49
+ }
50
+ /**
51
+ * Gets the balance for an address
52
+ */
53
+ async getBalance(address) {
54
+ const publicClient = await this.getPublicClient();
55
+ if (!publicClient) {
56
+ throw new DynamicError('No public client available');
57
+ }
58
+ const balance = await publicClient.getBalance({ address });
59
+ return formatEther(balance);
60
+ }
61
+ /**
62
+ * Validates that the expected wallet is active
63
+ */
64
+ async validateActiveWallet(expectedAddress) {
65
+ const currentAddress = await this.getAddress();
66
+ if (currentAddress?.toLowerCase() !== expectedAddress.toLowerCase()) {
67
+ throw new DynamicError('Invalid active wallet');
68
+ }
69
+ }
70
+ async createUiTransaction(from) {
71
+ await this.validateActiveWallet(from);
72
+ const walletClient = this.getWalletClient();
73
+ const publicClient = await this.getPublicClient();
74
+ if (!publicClient || !walletClient) {
75
+ throw new DynamicError('No public client available');
76
+ }
77
+ return createViemUiTransaction({
78
+ from,
79
+ publicClient: publicClient,
80
+ walletClient: walletClient,
81
+ });
82
+ }
83
+ async getBlockExplorerUrlsForCurrentNetwork() {
84
+ return this.eoaConnector?.getBlockExplorerUrlsForCurrentNetwork() ?? [];
85
+ }
86
+ }
87
+
88
+ export { AccountAbstractionBaseConnector };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AccountAbstractionBaseConnector.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAbstractionBaseConnector.spec.d.ts","sourceRoot":"","sources":["../../../../../packages/ethereum-aa-core/src/connector/AccountAbstractionBaseConnector.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { AccountAbstractionBaseConnector } from './AccountAbstractionBaseConnector';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ethereum-aa-core/src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC"}
package/src/index.cjs ADDED
@@ -0,0 +1,12 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var assertPackageVersion = require('@dynamic-labs/assert-package-version');
7
+ var _package = require('../package.cjs');
8
+ var AccountAbstractionBaseConnector = require('./connector/AccountAbstractionBaseConnector.cjs');
9
+
10
+ assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-aa-core', _package.version);
11
+
12
+ exports.AccountAbstractionBaseConnector = AccountAbstractionBaseConnector.AccountAbstractionBaseConnector;
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './connector';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/ethereum-aa-core/src/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ 'use client'
2
+ import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
3
+ import { version } from '../package.js';
4
+ export { AccountAbstractionBaseConnector } from './connector/AccountAbstractionBaseConnector.js';
5
+
6
+ assertPackageVersion('@dynamic-labs/ethereum-aa-core', version);
@@ -0,0 +1,9 @@
1
+ import { GenericNetwork, WalletUiUtils } from '@dynamic-labs/types';
2
+ import { WalletBookSchema } from '@dynamic-labs/wallet-book';
3
+ import { InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
4
+ export type AccountAbstractionConnectorProps = {
5
+ walletUiUtils: WalletUiUtils<InternalWalletConnector>;
6
+ walletBook: WalletBookSchema;
7
+ evmNetworks: GenericNetwork[];
8
+ };
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ethereum-aa-core/src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACtD,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B,CAAC"}