@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.
- package/CHANGELOG.md +468 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +11 -18
- package/src/connector/{EthWalletConnector.cjs → EthereumWalletConnector.cjs} +37 -22
- package/src/connector/EthereumWalletConnector.d.ts +7714 -0
- package/src/connector/{EthWalletConnector.js → EthereumWalletConnector.js} +38 -23
- package/src/connector/createConnector/createConnector.cjs +103 -0
- package/src/connector/createConnector/createConnector.d.ts +23 -0
- package/src/connector/createConnector/createConnector.js +99 -0
- package/src/connector/createConnector/index.d.ts +1 -0
- package/src/connector/index.d.ts +2 -1
- package/src/connector/isEthWalletConnector/isEthWalletConnector.d.ts +2 -2
- package/src/index.cjs +7 -3
- package/src/index.js +6 -1
- package/src/rpc/RpcProvidersEthereum/RpcProvidersEthereum.cjs +2 -7
- package/src/rpc/RpcProvidersEthereum/RpcProvidersEthereum.js +2 -7
- package/src/rpc/evmProvidersSelector/evmProvidersSelector.cjs +0 -1
- package/src/rpc/evmProvidersSelector/evmProvidersSelector.d.ts +1 -1
- package/src/rpc/evmProvidersSelector/evmProvidersSelector.js +0 -1
- package/src/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.cjs +4 -3
- package/src/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.d.ts +1 -1
- package/src/utils/viem/ViemRpcUiTransaction/ViemRpcUiTransaction.js +4 -3
- package/src/utils/viem/createAccountWithUiConfirmation/createAccountWithUiConfirmation.d.ts +223 -1
- package/src/utils/viem/interceptTransport/interceptTransport.cjs +3 -0
- package/src/utils/viem/interceptTransport/interceptTransport.js +3 -0
- package/src/wallet/EthereumWallet.cjs +20 -1
- package/src/wallet/EthereumWallet.d.ts +12 -2
- package/src/wallet/EthereumWallet.js +21 -2
- package/src/connector/EthWalletConnector.d.ts +0 -3090
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { getAddress, formatEther } from 'viem';
|
|
4
4
|
import { toAccount } from 'viem/accounts';
|
|
5
|
-
import { parseEvmNetworks, retryableFn, FALLBACK_UNDEFINED, DynamicError, UserRejectedRequestError } from '@dynamic-labs/utils';
|
|
5
|
+
import { parseEvmNetworks, retryableFn, FALLBACK_UNDEFINED, DynamicError, UserRejectedRequestError, isMobile } from '@dynamic-labs/utils';
|
|
6
6
|
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import '../utils/logger.js';
|
|
8
8
|
import '../utils/viem/estimateL1Fee/opStack/estimateL1Fee.js';
|
|
@@ -13,7 +13,25 @@ import { findEvmNetwork } from '../utils/findEvmNetwork/findEvmNetwork.js';
|
|
|
13
13
|
import { getNameservice } from '../utils/getNameservice/getNameservice.js';
|
|
14
14
|
import { EthereumWallet } from '../wallet/EthereumWallet.js';
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class EthereumWalletConnector extends WalletConnectorBase {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
var _a;
|
|
19
|
+
super(props);
|
|
20
|
+
this.supportedChains = ['EVM', 'ETH'];
|
|
21
|
+
this.connectedChain = 'EVM';
|
|
22
|
+
this.ChainWallet = EthereumWallet;
|
|
23
|
+
this.evmNetworkRpcMap = () => this.evmNetworks.reduce((acc, network) => {
|
|
24
|
+
var _a;
|
|
25
|
+
[acc[network.chainId]] = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a.length)
|
|
26
|
+
? network.privateCustomerRpcUrls
|
|
27
|
+
: network.rpcUrls;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
this.walletUiUtils = props.walletUiUtils;
|
|
31
|
+
this.evmNetworks = parseEvmNetworks(props.evmNetworks);
|
|
32
|
+
this.chainRpcProviders = props.chainRpcProviders;
|
|
33
|
+
(_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerEvmProviders();
|
|
34
|
+
}
|
|
17
35
|
getPublicClient() {
|
|
18
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
37
|
var _a, _b;
|
|
@@ -33,21 +51,6 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
33
51
|
return (_b = this.chainRpcProviders.getEvmProviderByChainId(providers, networkId)) === null || _b === void 0 ? void 0 : _b.provider;
|
|
34
52
|
});
|
|
35
53
|
}
|
|
36
|
-
constructor(props) {
|
|
37
|
-
var _a;
|
|
38
|
-
super(props);
|
|
39
|
-
this.ChainWallet = EthereumWallet;
|
|
40
|
-
this.evmNetworkRpcMap = () => this.evmNetworks.reduce((acc, network) => {
|
|
41
|
-
var _a;
|
|
42
|
-
[acc[network.chainId]] = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a.length)
|
|
43
|
-
? network.privateCustomerRpcUrls
|
|
44
|
-
: network.rpcUrls;
|
|
45
|
-
return acc;
|
|
46
|
-
}, {});
|
|
47
|
-
this.evmNetworks = parseEvmNetworks(props.evmNetworks);
|
|
48
|
-
this.chainRpcProviders = props.chainRpcProviders;
|
|
49
|
-
(_a = this.chainRpcProviders) === null || _a === void 0 ? void 0 : _a.registerEvmProviders();
|
|
50
|
-
}
|
|
51
54
|
getNetwork() {
|
|
52
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
56
|
const provider = this.getWalletClient();
|
|
@@ -179,7 +182,7 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
179
182
|
}
|
|
180
183
|
providerSwitchNetwork(_a) {
|
|
181
184
|
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
182
|
-
var _b, _c, _d, _e;
|
|
185
|
+
var _b, _c, _d, _e, _f;
|
|
183
186
|
const { chainId } = network;
|
|
184
187
|
const currentNetworkId = yield this.getNetwork();
|
|
185
188
|
if (currentNetworkId && currentNetworkId === chainId) {
|
|
@@ -200,16 +203,19 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
205
|
catch (error) {
|
|
206
|
+
if ((_b = error.details) === null || _b === void 0 ? void 0 : _b.includes('"wallet_switchEthereumChain" not implemented')) {
|
|
207
|
+
throw new DynamicError('Network switching is not available at this time. The user should manually switch network in their wallet');
|
|
208
|
+
}
|
|
203
209
|
// we need to check for unrecognized chain error first because it also contains 'rejected' in message
|
|
204
210
|
if (error.code === 4902 ||
|
|
205
|
-
((
|
|
211
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Unrecognized chain')) ||
|
|
206
212
|
// https://github.com/MetaMask/metamask-mobile/issues/3312#issuecomment-1065923294
|
|
207
|
-
((
|
|
213
|
+
((_e = (_d = error.data) === null || _d === void 0 ? void 0 : _d.orginalError) === null || _e === void 0 ? void 0 : _e.code) === 4902) {
|
|
208
214
|
// error code indicates the chain has not been added yet
|
|
209
215
|
// https://docs.metamask.io/guide/rpc-api.html#usage-with-wallet-switchethereumchain
|
|
210
216
|
return this.providerAddNetwork({ network, provider });
|
|
211
217
|
}
|
|
212
|
-
else if (((
|
|
218
|
+
else if (((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('rejected')) ||
|
|
213
219
|
(typeof error === 'string' && error.includes('rejected'))) {
|
|
214
220
|
throw new DynamicError("User rejected the wallet's request to switch network");
|
|
215
221
|
}
|
|
@@ -223,7 +229,16 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
223
229
|
return __awaiter(this, arguments, void 0, function* ({ network, provider, }) {
|
|
224
230
|
var _b;
|
|
225
231
|
try {
|
|
226
|
-
|
|
232
|
+
if (isMobile()) {
|
|
233
|
+
yield this.walletUiUtils.addNetwork({
|
|
234
|
+
handler: () => provider.addChain({ chain: getOrMapViemChain(network) }),
|
|
235
|
+
network,
|
|
236
|
+
walletConnector: this,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
yield provider.addChain({ chain: getOrMapViemChain(network) });
|
|
241
|
+
}
|
|
227
242
|
}
|
|
228
243
|
catch (error) {
|
|
229
244
|
if (((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('rejected')) ||
|
|
@@ -279,4 +294,4 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
279
294
|
}
|
|
280
295
|
}
|
|
281
296
|
|
|
282
|
-
export {
|
|
297
|
+
export { EthereumWalletConnector };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var EthereumWalletConnector = require('../EthereumWalletConnector.cjs');
|
|
8
|
+
|
|
9
|
+
const createConnector = (customConnectorFn) => (props) => {
|
|
10
|
+
const delegate = customConnectorFn(props);
|
|
11
|
+
return [
|
|
12
|
+
class extends EthereumWalletConnector.EthereumWalletConnector {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(Object.assign(Object.assign({}, props), { metadata: delegate.metadata }));
|
|
15
|
+
this.name = delegate.metadata.name;
|
|
16
|
+
this.overrideKey = `${delegate.metadata.name}evm`;
|
|
17
|
+
}
|
|
18
|
+
connect() {
|
|
19
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield delegate.connect();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
endSession() {
|
|
24
|
+
const _super = Object.create(null, {
|
|
25
|
+
endSession: { get: () => super.endSession }
|
|
26
|
+
});
|
|
27
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (delegate.disconnect) {
|
|
29
|
+
yield delegate.disconnect();
|
|
30
|
+
}
|
|
31
|
+
return _super.endSession.call(this);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
getAddress() {
|
|
35
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return delegate.getAddress();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getConnectedAccounts() {
|
|
40
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return delegate.getConnectedAccounts();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getNetwork() {
|
|
45
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return delegate.getNetwork();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getPublicClient() {
|
|
50
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return delegate.getPublicClient();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getWalletClient(chainId) {
|
|
55
|
+
return delegate.getWalletClient(chainId);
|
|
56
|
+
}
|
|
57
|
+
isInstalledOnBrowser() {
|
|
58
|
+
return delegate.isInstalledOnBrowser();
|
|
59
|
+
}
|
|
60
|
+
signMessage(messageToSign) {
|
|
61
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return delegate.signMessage(messageToSign);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
filter() {
|
|
66
|
+
if (delegate.filter) {
|
|
67
|
+
return delegate.filter();
|
|
68
|
+
}
|
|
69
|
+
return super.filter();
|
|
70
|
+
}
|
|
71
|
+
init() {
|
|
72
|
+
const _super = Object.create(null, {
|
|
73
|
+
init: { get: () => super.init }
|
|
74
|
+
});
|
|
75
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (delegate.init) {
|
|
77
|
+
return delegate.init();
|
|
78
|
+
}
|
|
79
|
+
return _super.init.call(this);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
supportsNetworkSwitching() {
|
|
83
|
+
if (delegate.supportsNetworkSwitching) {
|
|
84
|
+
return delegate.supportsNetworkSwitching();
|
|
85
|
+
}
|
|
86
|
+
return super.supportsNetworkSwitching();
|
|
87
|
+
}
|
|
88
|
+
switchNetwork(_a) {
|
|
89
|
+
const _super = Object.create(null, {
|
|
90
|
+
switchNetwork: { get: () => super.switchNetwork }
|
|
91
|
+
});
|
|
92
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ networkName, networkChainId, }) {
|
|
93
|
+
if (delegate.switchNetwork) {
|
|
94
|
+
return delegate.switchNetwork({ networkChainId, networkName });
|
|
95
|
+
}
|
|
96
|
+
return _super.switchNetwork.call(this, { networkChainId, networkName });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.createConnector = createConnector;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WalletClient, Transport, Chain, Account, PublicClient } from 'viem';
|
|
2
|
+
import { WalletConnectorsMethod, WalletMetadata } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
type CustomConnectorDelegate = {
|
|
4
|
+
metadata: WalletMetadata;
|
|
5
|
+
connect: () => Promise<void>;
|
|
6
|
+
disconnect: () => Promise<void>;
|
|
7
|
+
getAddress: () => Promise<string>;
|
|
8
|
+
getConnectedAccounts: () => Promise<string[]>;
|
|
9
|
+
getNetwork: () => Promise<number | undefined>;
|
|
10
|
+
getPublicClient: () => Promise<void | PublicClient<Transport, Chain> | undefined>;
|
|
11
|
+
getWalletClient: (chainId?: string) => WalletClient<Transport, Chain, Account> | undefined;
|
|
12
|
+
isInstalledOnBrowser: () => boolean;
|
|
13
|
+
signMessage: (messageToSign: string) => Promise<string>;
|
|
14
|
+
filter?: () => boolean;
|
|
15
|
+
init?: () => Promise<void>;
|
|
16
|
+
supportsNetworkSwitching?: () => boolean;
|
|
17
|
+
switchNetwork?: (props: {
|
|
18
|
+
networkName?: string;
|
|
19
|
+
networkChainId?: number;
|
|
20
|
+
}) => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export declare const createConnector: (customConnectorFn: (props: any) => CustomConnectorDelegate) => WalletConnectorsMethod;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { EthereumWalletConnector } from '../EthereumWalletConnector.js';
|
|
4
|
+
|
|
5
|
+
const createConnector = (customConnectorFn) => (props) => {
|
|
6
|
+
const delegate = customConnectorFn(props);
|
|
7
|
+
return [
|
|
8
|
+
class extends EthereumWalletConnector {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(Object.assign(Object.assign({}, props), { metadata: delegate.metadata }));
|
|
11
|
+
this.name = delegate.metadata.name;
|
|
12
|
+
this.overrideKey = `${delegate.metadata.name}evm`;
|
|
13
|
+
}
|
|
14
|
+
connect() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
yield delegate.connect();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
endSession() {
|
|
20
|
+
const _super = Object.create(null, {
|
|
21
|
+
endSession: { get: () => super.endSession }
|
|
22
|
+
});
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (delegate.disconnect) {
|
|
25
|
+
yield delegate.disconnect();
|
|
26
|
+
}
|
|
27
|
+
return _super.endSession.call(this);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getAddress() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return delegate.getAddress();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
getConnectedAccounts() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
return delegate.getConnectedAccounts();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getNetwork() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
return delegate.getNetwork();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getPublicClient() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return delegate.getPublicClient();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getWalletClient(chainId) {
|
|
51
|
+
return delegate.getWalletClient(chainId);
|
|
52
|
+
}
|
|
53
|
+
isInstalledOnBrowser() {
|
|
54
|
+
return delegate.isInstalledOnBrowser();
|
|
55
|
+
}
|
|
56
|
+
signMessage(messageToSign) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return delegate.signMessage(messageToSign);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
filter() {
|
|
62
|
+
if (delegate.filter) {
|
|
63
|
+
return delegate.filter();
|
|
64
|
+
}
|
|
65
|
+
return super.filter();
|
|
66
|
+
}
|
|
67
|
+
init() {
|
|
68
|
+
const _super = Object.create(null, {
|
|
69
|
+
init: { get: () => super.init }
|
|
70
|
+
});
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
if (delegate.init) {
|
|
73
|
+
return delegate.init();
|
|
74
|
+
}
|
|
75
|
+
return _super.init.call(this);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
supportsNetworkSwitching() {
|
|
79
|
+
if (delegate.supportsNetworkSwitching) {
|
|
80
|
+
return delegate.supportsNetworkSwitching();
|
|
81
|
+
}
|
|
82
|
+
return super.supportsNetworkSwitching();
|
|
83
|
+
}
|
|
84
|
+
switchNetwork(_a) {
|
|
85
|
+
const _super = Object.create(null, {
|
|
86
|
+
switchNetwork: { get: () => super.switchNetwork }
|
|
87
|
+
});
|
|
88
|
+
return __awaiter(this, arguments, void 0, function* ({ networkName, networkChainId, }) {
|
|
89
|
+
if (delegate.switchNetwork) {
|
|
90
|
+
return delegate.switchNetwork({ networkChainId, networkName });
|
|
91
|
+
}
|
|
92
|
+
return _super.switchNetwork.call(this, { networkChainId, networkName });
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export { createConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createConnector';
|
package/src/connector/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import {
|
|
3
|
-
export declare const isEthWalletConnector: (connector: WalletConnector |
|
|
2
|
+
import { EthereumWalletConnector } from '../';
|
|
3
|
+
export declare const isEthWalletConnector: (connector: WalletConnector | EthereumWalletConnector) => connector is EthereumWalletConnector;
|
package/src/index.cjs
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
|
+
var _package = require('../package.cjs');
|
|
8
|
+
var EthereumWalletConnector = require('./connector/EthereumWalletConnector.cjs');
|
|
7
9
|
var isEthWalletConnector = require('./connector/isEthWalletConnector/isEthWalletConnector.cjs');
|
|
10
|
+
var createConnector = require('./connector/createConnector/createConnector.cjs');
|
|
8
11
|
require('./rpc/RpcProvidersEthereum/RpcProvidersEthereum.cjs');
|
|
9
12
|
var rpcProviders = require('@dynamic-labs/rpc-providers');
|
|
10
13
|
var evmProvidersSelector = require('./rpc/evmProvidersSelector/evmProvidersSelector.cjs');
|
|
@@ -25,10 +28,11 @@ var validateAddressFormat = require('./utils/validateAddressFormat/validateAddre
|
|
|
25
28
|
var EthereumWallet = require('./wallet/EthereumWallet.cjs');
|
|
26
29
|
var isEthereumWallet = require('./wallet/isEthereumWallet/isEthereumWallet.cjs');
|
|
27
30
|
|
|
31
|
+
assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-core', _package.version);
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
exports.EthWalletConnector = EthWalletConnector.EthWalletConnector;
|
|
33
|
+
exports.EthereumWalletConnector = EthereumWalletConnector.EthereumWalletConnector;
|
|
31
34
|
exports.isEthWalletConnector = isEthWalletConnector.isEthWalletConnector;
|
|
35
|
+
exports.createConnector = createConnector.createConnector;
|
|
32
36
|
exports.evmProvidersSelector = evmProvidersSelector.evmProvidersSelector;
|
|
33
37
|
exports.ViemRpcUiTransaction = ViemRpcUiTransaction.ViemRpcUiTransaction;
|
|
34
38
|
exports.ViemUiTransaction = ViemUiTransaction.ViemUiTransaction;
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
2
|
+
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
|
+
import { version } from '../package.js';
|
|
4
|
+
export { EthereumWalletConnector } from './connector/EthereumWalletConnector.js';
|
|
3
5
|
export { isEthWalletConnector } from './connector/isEthWalletConnector/isEthWalletConnector.js';
|
|
6
|
+
export { createConnector } from './connector/createConnector/createConnector.js';
|
|
4
7
|
import './rpc/RpcProvidersEthereum/RpcProvidersEthereum.js';
|
|
5
8
|
export * from '@dynamic-labs/rpc-providers';
|
|
6
9
|
export { evmProvidersSelector } from './rpc/evmProvidersSelector/evmProvidersSelector.js';
|
|
@@ -20,3 +23,5 @@ export { getNameservice } from './utils/getNameservice/getNameservice.js';
|
|
|
20
23
|
export { validateAddressFormat } from './utils/validateAddressFormat/validateAddressFormat.js';
|
|
21
24
|
export { EthereumWallet } from './wallet/EthereumWallet.js';
|
|
22
25
|
export { isEthereumWallet } from './wallet/isEthereumWallet/isEthereumWallet.js';
|
|
26
|
+
|
|
27
|
+
assertPackageVersion('@dynamic-labs/ethereum-core', version);
|
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
var rpcProviders = require('@dynamic-labs/rpc-providers');
|
|
6
6
|
var utils = require('@dynamic-labs/utils');
|
|
7
|
-
require('../../../_virtual/_tslib.cjs');
|
|
8
|
-
require('../../utils/logger.cjs');
|
|
9
|
-
require('../../utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs');
|
|
10
|
-
require('../../utils/viem/chainsMap/chainsMap.cjs');
|
|
11
|
-
require('viem/accounts');
|
|
12
7
|
var getOrMapViemChain = require('../../utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
|
|
13
8
|
|
|
14
9
|
rpcProviders.ChainRpcProviders.getEvmProviderByChainId = (rpcProviders, chainId) => {
|
|
@@ -19,8 +14,8 @@ rpcProviders.ChainRpcProviders.getEvmProviderByChainId = (rpcProviders, chainId)
|
|
|
19
14
|
rpcProviders.ChainRpcProviders.registerEvmProviders = () => {
|
|
20
15
|
rpcProviders.ChainRpcProviders.registerChainProviders(rpcProviders.ProviderChain.EVM, (config) => {
|
|
21
16
|
const rpcProviders = {};
|
|
22
|
-
if (config === null || config === void 0 ? void 0 : config
|
|
23
|
-
rpcProviders.evm = utils.parseEvmNetworks(config
|
|
17
|
+
if (config === null || config === void 0 ? void 0 : config['evm']) {
|
|
18
|
+
rpcProviders.evm = utils.parseEvmNetworks(config['evm']).map((network) => {
|
|
24
19
|
var _a;
|
|
25
20
|
const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
|
|
26
21
|
const provider = viem.createPublicClient({
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
import { createPublicClient, http } from 'viem';
|
|
3
3
|
import { ChainRpcProviders, ProviderChain } from '@dynamic-labs/rpc-providers';
|
|
4
4
|
import { parseEvmNetworks } from '@dynamic-labs/utils';
|
|
5
|
-
import '../../../_virtual/_tslib.js';
|
|
6
|
-
import '../../utils/logger.js';
|
|
7
|
-
import '../../utils/viem/estimateL1Fee/opStack/estimateL1Fee.js';
|
|
8
|
-
import '../../utils/viem/chainsMap/chainsMap.js';
|
|
9
|
-
import 'viem/accounts';
|
|
10
5
|
import { getOrMapViemChain } from '../../utils/viem/getOrMapViemChain/getOrMapViemChain.js';
|
|
11
6
|
|
|
12
7
|
ChainRpcProviders.getEvmProviderByChainId = (rpcProviders, chainId) => {
|
|
@@ -17,8 +12,8 @@ ChainRpcProviders.getEvmProviderByChainId = (rpcProviders, chainId) => {
|
|
|
17
12
|
ChainRpcProviders.registerEvmProviders = () => {
|
|
18
13
|
ChainRpcProviders.registerChainProviders(ProviderChain.EVM, (config) => {
|
|
19
14
|
const rpcProviders = {};
|
|
20
|
-
if (config === null || config === void 0 ? void 0 : config
|
|
21
|
-
rpcProviders.evm = parseEvmNetworks(config
|
|
15
|
+
if (config === null || config === void 0 ? void 0 : config['evm']) {
|
|
16
|
+
rpcProviders.evm = parseEvmNetworks(config['evm']).map((network) => {
|
|
22
17
|
var _a;
|
|
23
18
|
const rpcUrl = ((_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || network.rpcUrls[0];
|
|
24
19
|
const provider = createPublicClient({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EvmRpcProvider, RpcProvidersSelector } from '
|
|
1
|
+
import { EvmRpcProvider, RpcProvidersSelector } from '@dynamic-labs/rpc-providers';
|
|
2
2
|
export type EvmRpcProviderMethods = {
|
|
3
3
|
defaultProvider: EvmRpcProvider | undefined;
|
|
4
4
|
providers: EvmRpcProvider[] | undefined;
|
|
@@ -35,7 +35,7 @@ class ViemRpcUiTransaction extends Eip1559FeeFeed.Eip1559FeeFeed {
|
|
|
35
35
|
return this.transaction.to || undefined;
|
|
36
36
|
}
|
|
37
37
|
get from() {
|
|
38
|
-
return this.transaction.from;
|
|
38
|
+
return this.transaction.from || '';
|
|
39
39
|
}
|
|
40
40
|
get value() {
|
|
41
41
|
const { value } = this.transaction;
|
|
@@ -62,10 +62,11 @@ class ViemRpcUiTransaction extends Eip1559FeeFeed.Eip1559FeeFeed {
|
|
|
62
62
|
estimateGas() {
|
|
63
63
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
-
const _a = this.transaction, transaction = _tslib.__rest(_a, ["from"]);
|
|
65
|
+
const _a = this.transaction, { from } = _a, transaction = _tslib.__rest(_a, ["from"]);
|
|
66
|
+
const transactionWithFrom = Object.assign(Object.assign({}, transaction), { from });
|
|
66
67
|
const hexResult = (yield this.publicClient.transport.request({
|
|
67
68
|
method: 'eth_estimateGas',
|
|
68
|
-
params: [
|
|
69
|
+
params: [transactionWithFrom],
|
|
69
70
|
}));
|
|
70
71
|
return viem.hexToBigInt(hexResult);
|
|
71
72
|
});
|
|
@@ -23,7 +23,7 @@ export declare class ViemRpcUiTransaction extends Eip1559FeeFeed implements IUIT
|
|
|
23
23
|
parse: (input: string) => bigint;
|
|
24
24
|
format: (value: bigint, { precision }?: import("@dynamic-labs/types").IUITransactionFormatOptions) => string;
|
|
25
25
|
get to(): `0x${string}` | undefined;
|
|
26
|
-
get from(): `0x${string}
|
|
26
|
+
get from(): `0x${string}` | "";
|
|
27
27
|
get value(): bigint | undefined;
|
|
28
28
|
get data(): `0x${string}` | undefined;
|
|
29
29
|
submit(): Promise<string>;
|
|
@@ -31,7 +31,7 @@ class ViemRpcUiTransaction extends Eip1559FeeFeed {
|
|
|
31
31
|
return this.transaction.to || undefined;
|
|
32
32
|
}
|
|
33
33
|
get from() {
|
|
34
|
-
return this.transaction.from;
|
|
34
|
+
return this.transaction.from || '';
|
|
35
35
|
}
|
|
36
36
|
get value() {
|
|
37
37
|
const { value } = this.transaction;
|
|
@@ -58,10 +58,11 @@ class ViemRpcUiTransaction extends Eip1559FeeFeed {
|
|
|
58
58
|
estimateGas() {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
|
-
const _a = this.transaction, transaction = __rest(_a, ["from"]);
|
|
61
|
+
const _a = this.transaction, { from } = _a, transaction = __rest(_a, ["from"]);
|
|
62
|
+
const transactionWithFrom = Object.assign(Object.assign({}, transaction), { from });
|
|
62
63
|
const hexResult = (yield this.publicClient.transport.request({
|
|
63
64
|
method: 'eth_estimateGas',
|
|
64
|
-
params: [
|
|
65
|
+
params: [transactionWithFrom],
|
|
65
66
|
}));
|
|
66
67
|
return hexToBigInt(hexResult);
|
|
67
68
|
});
|