@dynamic-labs/ethereum-core 4.0.0-alpha.5 → 4.0.0-alpha.51

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +468 -0
  2. package/package.cjs +8 -0
  3. package/package.js +4 -0
  4. package/package.json +11 -18
  5. package/src/connector/{EthWalletConnector.cjs → EthereumWalletConnector.cjs} +37 -22
  6. package/src/connector/EthereumWalletConnector.d.ts +7714 -0
  7. package/src/connector/{EthWalletConnector.js → EthereumWalletConnector.js} +38 -23
  8. package/src/connector/createConnector/createConnector.cjs +103 -0
  9. package/src/connector/createConnector/createConnector.d.ts +23 -0
  10. package/src/connector/createConnector/createConnector.js +99 -0
  11. package/src/connector/createConnector/index.d.ts +1 -0
  12. package/src/connector/index.d.ts +2 -1
  13. package/src/connector/isEthWalletConnector/isEthWalletConnector.d.ts +2 -2
  14. package/src/index.cjs +7 -3
  15. package/src/index.js +6 -1
  16. package/src/rpc/RpcProvidersEthereum/RpcProvidersEthereum.cjs +2 -7
  17. package/src/rpc/RpcProvidersEthereum/RpcProvidersEthereum.js +2 -7
  18. package/src/rpc/evmProvidersSelector/evmProvidersSelector.cjs +0 -1
  19. package/src/rpc/evmProvidersSelector/evmProvidersSelector.d.ts +1 -1
  20. package/src/rpc/evmProvidersSelector/evmProvidersSelector.js +0 -1
  21. package/src/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.cjs +4 -3
  22. package/src/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.d.ts +1 -1
  23. package/src/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.js +4 -3
  24. package/src/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.d.ts +223 -1
  25. package/src/utils/viem/interceptTransport/interceptTransport.cjs +3 -0
  26. package/src/utils/viem/interceptTransport/interceptTransport.js +3 -0
  27. package/src/wallet/EthereumWallet.cjs +20 -1
  28. package/src/wallet/EthereumWallet.d.ts +12 -2
  29. package/src/wallet/EthereumWallet.js +21 -2
  30. package/src/connector/EthWalletConnector.d.ts +0 -3090
@@ -8,5 +8,227 @@ type Props = {
8
8
  walletUiUtils: WalletUiUtils<InternalWalletConnector>;
9
9
  provider: PublicClient<Transport, Chain>;
10
10
  };
11
- export declare const createAccountWithUiConfirmation: ({ address, account, provider, walletConnector, walletUiUtils, }: Props) => LocalAccount;
11
+ export declare const createAccountWithUiConfirmation: ({ address, account, provider, walletConnector, walletUiUtils, }: Props) => {
12
+ address: `0x${string}`;
13
+ nonceManager?: import("viem").NonceManager | undefined;
14
+ sign?: ((parameters: {
15
+ hash: `0x${string}`;
16
+ }) => Promise<`0x${string}`>) | undefined;
17
+ experimental_signAuthorization?: ((parameters: import("viem/experimental").Authorization) => Promise<import("viem/accounts").SignAuthorizationReturnType>) | undefined;
18
+ signMessage: ({ message }: {
19
+ message: import("viem").SignableMessage;
20
+ }) => Promise<`0x${string}`>;
21
+ signTransaction: <serializer extends import("viem").SerializeTransactionFn<import("viem").TransactionSerializable> = import("viem").SerializeTransactionFn<import("viem").TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
22
+ serializer?: serializer | undefined;
23
+ } | undefined) => Promise<import("viem").IsNarrowable<import("viem").TransactionSerialized<import("viem").GetTransactionType<transaction>>, `0x${string}`> extends true ? import("viem").TransactionSerialized<import("viem").GetTransactionType<transaction>> : `0x${string}`>;
24
+ signTypedData: <const typedData extends Record<string, unknown> | {
25
+ [x: string]: readonly import("viem").TypedDataParameter[];
26
+ [x: `string[${string}]`]: undefined;
27
+ [x: `function[${string}]`]: undefined;
28
+ [x: `address[${string}]`]: undefined;
29
+ [x: `bool[${string}]`]: undefined;
30
+ [x: `bytes[${string}]`]: undefined;
31
+ [x: `bytes1[${string}]`]: undefined;
32
+ [x: `bytes32[${string}]`]: undefined;
33
+ [x: `bytes31[${string}]`]: undefined;
34
+ [x: `bytes30[${string}]`]: undefined;
35
+ [x: `bytes29[${string}]`]: undefined;
36
+ [x: `bytes28[${string}]`]: undefined;
37
+ [x: `bytes27[${string}]`]: undefined;
38
+ [x: `bytes26[${string}]`]: undefined;
39
+ [x: `bytes25[${string}]`]: undefined;
40
+ [x: `bytes24[${string}]`]: undefined;
41
+ [x: `bytes23[${string}]`]: undefined;
42
+ [x: `bytes22[${string}]`]: undefined;
43
+ [x: `bytes21[${string}]`]: undefined;
44
+ [x: `bytes20[${string}]`]: undefined;
45
+ [x: `bytes19[${string}]`]: undefined;
46
+ [x: `bytes2[${string}]`]: undefined;
47
+ [x: `bytes18[${string}]`]: undefined;
48
+ [x: `bytes17[${string}]`]: undefined;
49
+ [x: `bytes16[${string}]`]: undefined;
50
+ [x: `bytes15[${string}]`]: undefined;
51
+ [x: `bytes14[${string}]`]: undefined;
52
+ [x: `bytes13[${string}]`]: undefined;
53
+ [x: `bytes12[${string}]`]: undefined;
54
+ [x: `bytes11[${string}]`]: undefined;
55
+ [x: `bytes10[${string}]`]: undefined;
56
+ [x: `bytes9[${string}]`]: undefined;
57
+ [x: `bytes8[${string}]`]: undefined;
58
+ [x: `bytes7[${string}]`]: undefined;
59
+ [x: `bytes6[${string}]`]: undefined;
60
+ [x: `bytes5[${string}]`]: undefined;
61
+ [x: `bytes4[${string}]`]: undefined;
62
+ [x: `bytes3[${string}]`]: undefined;
63
+ [x: `int[${string}]`]: undefined;
64
+ [x: `int40[${string}]`]: undefined;
65
+ [x: `int32[${string}]`]: undefined;
66
+ [x: `int24[${string}]`]: undefined;
67
+ [x: `int16[${string}]`]: undefined;
68
+ [x: `int8[${string}]`]: undefined;
69
+ [x: `int48[${string}]`]: undefined;
70
+ [x: `int56[${string}]`]: undefined;
71
+ [x: `int64[${string}]`]: undefined;
72
+ [x: `int72[${string}]`]: undefined;
73
+ [x: `int80[${string}]`]: undefined;
74
+ [x: `int88[${string}]`]: undefined;
75
+ [x: `int96[${string}]`]: undefined;
76
+ [x: `int104[${string}]`]: undefined;
77
+ [x: `int112[${string}]`]: undefined;
78
+ [x: `int120[${string}]`]: undefined;
79
+ [x: `int128[${string}]`]: undefined;
80
+ [x: `int136[${string}]`]: undefined;
81
+ [x: `int144[${string}]`]: undefined;
82
+ [x: `int152[${string}]`]: undefined;
83
+ [x: `int160[${string}]`]: undefined;
84
+ [x: `int168[${string}]`]: undefined;
85
+ [x: `int176[${string}]`]: undefined;
86
+ [x: `int184[${string}]`]: undefined;
87
+ [x: `int192[${string}]`]: undefined;
88
+ [x: `int200[${string}]`]: undefined;
89
+ [x: `int208[${string}]`]: undefined;
90
+ [x: `int216[${string}]`]: undefined;
91
+ [x: `int224[${string}]`]: undefined;
92
+ [x: `int232[${string}]`]: undefined;
93
+ [x: `int240[${string}]`]: undefined;
94
+ [x: `int248[${string}]`]: undefined;
95
+ [x: `int256[${string}]`]: undefined;
96
+ [x: `uint[${string}]`]: undefined;
97
+ [x: `uint40[${string}]`]: undefined;
98
+ [x: `uint32[${string}]`]: undefined;
99
+ [x: `uint24[${string}]`]: undefined;
100
+ [x: `uint16[${string}]`]: undefined;
101
+ [x: `uint8[${string}]`]: undefined;
102
+ [x: `uint48[${string}]`]: undefined;
103
+ [x: `uint56[${string}]`]: undefined;
104
+ [x: `uint64[${string}]`]: undefined;
105
+ [x: `uint72[${string}]`]: undefined;
106
+ [x: `uint80[${string}]`]: undefined;
107
+ [x: `uint88[${string}]`]: undefined;
108
+ [x: `uint96[${string}]`]: undefined;
109
+ [x: `uint104[${string}]`]: undefined;
110
+ [x: `uint112[${string}]`]: undefined;
111
+ [x: `uint120[${string}]`]: undefined;
112
+ [x: `uint128[${string}]`]: undefined;
113
+ [x: `uint136[${string}]`]: undefined;
114
+ [x: `uint144[${string}]`]: undefined;
115
+ [x: `uint152[${string}]`]: undefined;
116
+ [x: `uint160[${string}]`]: undefined;
117
+ [x: `uint168[${string}]`]: undefined;
118
+ [x: `uint176[${string}]`]: undefined;
119
+ [x: `uint184[${string}]`]: undefined;
120
+ [x: `uint192[${string}]`]: undefined;
121
+ [x: `uint200[${string}]`]: undefined;
122
+ [x: `uint208[${string}]`]: undefined;
123
+ [x: `uint216[${string}]`]: undefined;
124
+ [x: `uint224[${string}]`]: undefined;
125
+ [x: `uint232[${string}]`]: undefined;
126
+ [x: `uint240[${string}]`]: undefined;
127
+ [x: `uint248[${string}]`]: undefined;
128
+ [x: `uint256[${string}]`]: undefined;
129
+ string?: undefined;
130
+ address?: undefined;
131
+ bool?: undefined;
132
+ bytes?: undefined;
133
+ bytes1?: undefined;
134
+ bytes32?: undefined;
135
+ bytes31?: undefined;
136
+ bytes30?: undefined;
137
+ bytes29?: undefined;
138
+ bytes28?: undefined;
139
+ bytes27?: undefined;
140
+ bytes26?: undefined;
141
+ bytes25?: undefined;
142
+ bytes24?: undefined;
143
+ bytes23?: undefined;
144
+ bytes22?: undefined;
145
+ bytes21?: undefined;
146
+ bytes20?: undefined;
147
+ bytes19?: undefined;
148
+ bytes2?: undefined;
149
+ bytes18?: undefined;
150
+ bytes17?: undefined;
151
+ bytes16?: undefined;
152
+ bytes15?: undefined;
153
+ bytes14?: undefined;
154
+ bytes13?: undefined;
155
+ bytes12?: undefined;
156
+ bytes11?: undefined;
157
+ bytes10?: undefined;
158
+ bytes9?: undefined;
159
+ bytes8?: undefined;
160
+ bytes7?: undefined;
161
+ bytes6?: undefined;
162
+ bytes5?: undefined;
163
+ bytes4?: undefined;
164
+ bytes3?: undefined;
165
+ int40?: undefined;
166
+ int32?: undefined;
167
+ int24?: undefined;
168
+ int16?: undefined;
169
+ int8?: undefined;
170
+ int48?: undefined;
171
+ int56?: undefined;
172
+ int64?: undefined;
173
+ int72?: undefined;
174
+ int80?: undefined;
175
+ int88?: undefined;
176
+ int96?: undefined;
177
+ int104?: undefined;
178
+ int112?: undefined;
179
+ int120?: undefined;
180
+ int128?: undefined;
181
+ int136?: undefined;
182
+ int144?: undefined;
183
+ int152?: undefined;
184
+ int160?: undefined;
185
+ int168?: undefined;
186
+ int176?: undefined;
187
+ int184?: undefined;
188
+ int192?: undefined;
189
+ int200?: undefined;
190
+ int208?: undefined;
191
+ int216?: undefined;
192
+ int224?: undefined;
193
+ int232?: undefined;
194
+ int240?: undefined;
195
+ int248?: undefined;
196
+ int256?: undefined;
197
+ uint40?: undefined;
198
+ uint32?: undefined;
199
+ uint24?: undefined;
200
+ uint16?: undefined;
201
+ uint8?: undefined;
202
+ uint48?: undefined;
203
+ uint56?: undefined;
204
+ uint64?: undefined;
205
+ uint72?: undefined;
206
+ uint80?: undefined;
207
+ uint88?: undefined;
208
+ uint96?: undefined;
209
+ uint104?: undefined;
210
+ uint112?: undefined;
211
+ uint120?: undefined;
212
+ uint128?: undefined;
213
+ uint136?: undefined;
214
+ uint144?: undefined;
215
+ uint152?: undefined;
216
+ uint160?: undefined;
217
+ uint168?: undefined;
218
+ uint176?: undefined;
219
+ uint184?: undefined;
220
+ uint192?: undefined;
221
+ uint200?: undefined;
222
+ uint208?: undefined;
223
+ uint216?: undefined;
224
+ uint224?: undefined;
225
+ uint232?: undefined;
226
+ uint240?: undefined;
227
+ uint248?: undefined;
228
+ uint256?: undefined;
229
+ }, primaryType extends "EIP712Domain" | keyof typedData = keyof typedData>(parameters: import("viem").TypedDataDefinition<typedData, primaryType>) => Promise<`0x${string}`>;
230
+ publicKey: `0x${string}`;
231
+ source: string;
232
+ type: "local";
233
+ };
12
234
  export {};
@@ -33,6 +33,9 @@ const interceptTransport = ({ getAccounts, onPersonalSign, onSendTransaction, on
33
33
  error.walk() instanceof utils.UserRejectedTransactionError) {
34
34
  throw new viem.UserRejectedRequestError(error.walk());
35
35
  }
36
+ if (error instanceof utils.UserRejectedTransactionError) {
37
+ throw new viem.UserRejectedRequestError(error);
38
+ }
36
39
  if (error instanceof utils.UserRejectedRequestError) {
37
40
  throw new viem.UserRejectedRequestError(error);
38
41
  }
@@ -29,6 +29,9 @@ const interceptTransport = ({ getAccounts, onPersonalSign, onSendTransaction, on
29
29
  error.walk() instanceof UserRejectedTransactionError) {
30
30
  throw new UserRejectedRequestError$1(error.walk());
31
31
  }
32
+ if (error instanceof UserRejectedTransactionError) {
33
+ throw new UserRejectedRequestError$1(error);
34
+ }
32
35
  if (error instanceof UserRejectedRequestError) {
33
36
  throw new UserRejectedRequestError$1(error);
34
37
  }
@@ -12,9 +12,28 @@ require('../utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs');
12
12
  require('../utils/viem/chainsMap/chainsMap.cjs');
13
13
  var interceptTransport = require('../utils/viem/interceptTransport/interceptTransport.cjs');
14
14
  require('viem/accounts');
15
- require('viem/chains');
15
+ var getOrMapViemChain = require('../utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
16
16
 
17
17
  class EthereumWallet extends walletConnectorCore.Wallet {
18
+ /**
19
+ * Sends the native balance of the wallet to the given address.
20
+ * @param amount - The amount of balance to send (in ETH).
21
+ * @param toAddress - The address to send the balance to.
22
+ * @returns The transaction hash of the sent transaction.
23
+ */
24
+ sendBalance(_a) {
25
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
26
+ const provider = yield this.getWalletClient();
27
+ const transaction = {
28
+ account: this.address,
29
+ chain: getOrMapViemChain.getChain(yield provider.getChainId()),
30
+ to: toAddress,
31
+ value: amount ? viem.parseEther(amount) : undefined,
32
+ };
33
+ const transactionHash = yield provider.sendTransaction(transaction);
34
+ return transactionHash;
35
+ });
36
+ }
18
37
  /**
19
38
  * Retrieves the public client.
20
39
  * @returns A promise that resolves to the public client,
@@ -1,7 +1,17 @@
1
1
  import { Account, Chain, PublicClient, Transport, WalletClient } from 'viem';
2
2
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
3
- import { EthWalletConnector } from '../connector';
4
- export declare class EthereumWallet extends Wallet<EthWalletConnector> {
3
+ import { EthereumWalletConnector } from '../connector';
4
+ export declare class EthereumWallet extends Wallet<EthereumWalletConnector> {
5
+ /**
6
+ * Sends the native balance of the wallet to the given address.
7
+ * @param amount - The amount of balance to send (in ETH).
8
+ * @param toAddress - The address to send the balance to.
9
+ * @returns The transaction hash of the sent transaction.
10
+ */
11
+ sendBalance({ amount, toAddress, }: {
12
+ amount: string;
13
+ toAddress: string;
14
+ }): Promise<`0x${string}`>;
5
15
  /**
6
16
  * Retrieves the public client.
7
17
  * @returns A promise that resolves to the public client,
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { createWalletClient, custom } from 'viem';
3
+ import { parseEther, createWalletClient, custom } from 'viem';
4
4
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
5
5
  import '@dynamic-labs/utils';
6
6
  import '../utils/logger.js';
@@ -8,9 +8,28 @@ import '../utils/viem/estimateL1Fee/opStack/estimateL1Fee.js';
8
8
  import '../utils/viem/chainsMap/chainsMap.js';
9
9
  import { interceptTransport } from '../utils/viem/interceptTransport/interceptTransport.js';
10
10
  import 'viem/accounts';
11
- import 'viem/chains';
11
+ import { getChain } from '../utils/viem/getOrMapViemChain/getOrMapViemChain.js';
12
12
 
13
13
  class EthereumWallet extends Wallet {
14
+ /**
15
+ * Sends the native balance of the wallet to the given address.
16
+ * @param amount - The amount of balance to send (in ETH).
17
+ * @param toAddress - The address to send the balance to.
18
+ * @returns The transaction hash of the sent transaction.
19
+ */
20
+ sendBalance(_a) {
21
+ return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
22
+ const provider = yield this.getWalletClient();
23
+ const transaction = {
24
+ account: this.address,
25
+ chain: getChain(yield provider.getChainId()),
26
+ to: toAddress,
27
+ value: amount ? parseEther(amount) : undefined,
28
+ };
29
+ const transactionHash = yield provider.sendTransaction(transaction);
30
+ return transactionHash;
31
+ });
32
+ }
14
33
  /**
15
34
  * Retrieves the public client.
16
35
  * @returns A promise that resolves to the public client,