@dynamic-labs/ethereum 4.0.0-alpha.48 → 4.0.0-alpha.49
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 +29 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/ethProviderHelper.cjs +4 -1
- package/src/ethProviderHelper.js +4 -1
- package/src/index.cjs +6 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/metaMask/MetaMaskConnector.cjs +3 -4
- package/src/metaMask/MetaMaskConnector.d.ts +1 -1
- package/src/metaMask/MetaMaskConnector.js +3 -4
- package/src/utils/createInjectedConnector/createInjectedConnector.cjs +93 -0
- package/src/utils/createInjectedConnector/createInjectedConnector.d.ts +16 -0
- package/src/utils/createInjectedConnector/createInjectedConnector.js +89 -0
- package/src/utils/createInjectedConnector/index.d.ts +1 -0
- package/src/utils/normalizeRpcError/index.d.ts +1 -0
- package/src/utils/normalizeRpcError/normalizeRpcError.cjs +20 -0
- package/src/utils/normalizeRpcError/normalizeRpcError.d.ts +5 -0
- package/src/utils/normalizeRpcError/normalizeRpcError.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.49](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.48...v4.0.0-alpha.49) (2024-12-27)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* change openFunding to openExternalFunding (#7684)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* aa blockaid simulations ([#7583](https://github.com/dynamic-labs/dynamic-auth/issues/7583)) ([6436220](https://github.com/dynamic-labs/dynamic-auth/commit/64362204d2c96291a37bf281d62531d6f2384fdf))
|
|
12
|
+
* add ethereum createConnector function ([#7607](https://github.com/dynamic-labs/dynamic-auth/issues/7607)) ([f306537](https://github.com/dynamic-labs/dynamic-auth/commit/f3065372f3c5dfc8bf26173dc722576e614af5e1))
|
|
13
|
+
* add fundWithExternalWallet method to useFunding ([#7688](https://github.com/dynamic-labs/dynamic-auth/issues/7688)) ([d48b1d2](https://github.com/dynamic-labs/dynamic-auth/commit/d48b1d2568ba928b322a4d81b6386e775ae4aa98))
|
|
14
|
+
* change openFunding to openExternalFunding ([#7684](https://github.com/dynamic-labs/dynamic-auth/issues/7684)) ([8efb9cb](https://github.com/dynamic-labs/dynamic-auth/commit/8efb9cb9ca3d7e2273c14e18f7be5892e50b8e12))
|
|
15
|
+
* connect global wallet in ethereum ([#7619](https://github.com/dynamic-labs/dynamic-auth/issues/7619)) ([fdb7f00](https://github.com/dynamic-labs/dynamic-auth/commit/fdb7f00c33f7da3ac95ae13ac674caa64b453cae))
|
|
16
|
+
* create wallet groups dynamically based on wallet options ([#7662](https://github.com/dynamic-labs/dynamic-auth/issues/7662)) ([981affc](https://github.com/dynamic-labs/dynamic-auth/commit/981affce5518f6532d960fe4e879e9cf40a66ce7))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **ethereum:** normalize user reject error from injected wallets ([#7702](https://github.com/dynamic-labs/dynamic-auth/issues/7702)) ([ce456a8](https://github.com/dynamic-labs/dynamic-auth/commit/ce456a8592197b07857baf32bb1b38867ffb37fe))
|
|
22
|
+
* fetch nonce when authenticating a user that connected in connect-only mode ([#7689](https://github.com/dynamic-labs/dynamic-auth/issues/7689)) ([f048bb9](https://github.com/dynamic-labs/dynamic-auth/commit/f048bb96b6cb5ae603966b2813f900a082cd158f))
|
|
23
|
+
* filter out wallets for the current network when using external wallet funding ([#7694](https://github.com/dynamic-labs/dynamic-auth/issues/7694)) ([65db665](https://github.com/dynamic-labs/dynamic-auth/commit/65db6652a934561e7d07379a65d2baa8f7813d8e))
|
|
24
|
+
* remove toaccount from signmessage and signtypeddata for zerodev ([#7650](https://github.com/dynamic-labs/dynamic-auth/issues/7650)) ([626e849](https://github.com/dynamic-labs/dynamic-auth/commit/626e849a4af3af51d60b42dd2787edb05126744b))
|
|
25
|
+
* save nonce to storage ([#7698](https://github.com/dynamic-labs/dynamic-auth/issues/7698)) ([93dc65b](https://github.com/dynamic-labs/dynamic-auth/commit/93dc65b7f78040367b85420c1374f3cafbfb598b))
|
|
26
|
+
* **sdk-react-core:** add timeout when getting connected accounts ([#7697](https://github.com/dynamic-labs/dynamic-auth/issues/7697)) ([9a4bd7c](https://github.com/dynamic-labs/dynamic-auth/commit/9a4bd7c02795205ec98d8d71aba75b51b9bbee7c))
|
|
27
|
+
* update auth token from new source ([#7666](https://github.com/dynamic-labs/dynamic-auth/issues/7666)) ([61798de](https://github.com/dynamic-labs/dynamic-auth/commit/61798de26d759db9064f5f84118540346a44ab50))
|
|
28
|
+
* update extension update_url endpoint ([#7655](https://github.com/dynamic-labs/dynamic-auth/issues/7655)) ([46cff3a](https://github.com/dynamic-labs/dynamic-auth/commit/46cff3a80c9efee659a764df47f927ed5a117079))
|
|
29
|
+
* zerodev confirmation UI closes properly ([#7664](https://github.com/dynamic-labs/dynamic-auth/issues/7664)) ([a78aded](https://github.com/dynamic-labs/dynamic-auth/commit/a78adedc054d09134198d22812aa5cab7bbff548))
|
|
30
|
+
|
|
2
31
|
## [4.0.0-alpha.48](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.47...v4.0.0-alpha.48) (2024-12-17)
|
|
3
32
|
|
|
4
33
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.49",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"eventemitter3": "5.0.1",
|
|
25
25
|
"buffer": "6.0.3",
|
|
26
26
|
"@metamask/sdk": "0.30.1",
|
|
27
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/embedded-wallet-evm": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/ethereum-core": "4.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
32
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
33
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
27
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.49",
|
|
28
|
+
"@dynamic-labs/embedded-wallet-evm": "4.0.0-alpha.49",
|
|
29
|
+
"@dynamic-labs/ethereum-core": "4.0.0-alpha.49",
|
|
30
|
+
"@dynamic-labs/logger": "4.0.0-alpha.49",
|
|
31
|
+
"@dynamic-labs/types": "4.0.0-alpha.49",
|
|
32
|
+
"@dynamic-labs/utils": "4.0.0-alpha.49",
|
|
33
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.49",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.49"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"viem": "^2.7.12"
|
|
@@ -9,6 +9,7 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
9
9
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
10
10
|
var utils = require('@dynamic-labs/utils');
|
|
11
11
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
12
|
+
var normalizeRpcError = require('./utils/normalizeRpcError/normalizeRpcError.cjs');
|
|
12
13
|
|
|
13
14
|
class EthProviderHelper {
|
|
14
15
|
constructor(connector) {
|
|
@@ -87,7 +88,9 @@ class EthProviderHelper {
|
|
|
87
88
|
return viem.createWalletClient({
|
|
88
89
|
account: this.connector.getActiveAccount(),
|
|
89
90
|
chain: chainId ? ethereumCore.chainsMap[chainId] : this.connector.getActiveChain(),
|
|
90
|
-
transport: viem.custom(
|
|
91
|
+
transport: viem.custom({
|
|
92
|
+
request: (args) => provider.request(args).catch(normalizeRpcError.normalizeRpcError),
|
|
93
|
+
}),
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
getAddress() {
|
package/src/ethProviderHelper.js
CHANGED
|
@@ -5,6 +5,7 @@ import { ProviderLookup, logger, eventListenerHandlers } from '@dynamic-labs/wal
|
|
|
5
5
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
6
6
|
import { getProvidersFromWindow, Eip6963ProviderSingleton } from '@dynamic-labs/utils';
|
|
7
7
|
import { chainsMap } from '@dynamic-labs/ethereum-core';
|
|
8
|
+
import { normalizeRpcError } from './utils/normalizeRpcError/normalizeRpcError.js';
|
|
8
9
|
|
|
9
10
|
class EthProviderHelper {
|
|
10
11
|
constructor(connector) {
|
|
@@ -83,7 +84,9 @@ class EthProviderHelper {
|
|
|
83
84
|
return createWalletClient({
|
|
84
85
|
account: this.connector.getActiveAccount(),
|
|
85
86
|
chain: chainId ? chainsMap[chainId] : this.connector.getActiveChain(),
|
|
86
|
-
transport: custom(
|
|
87
|
+
transport: custom({
|
|
88
|
+
request: (args) => provider.request(args).catch(normalizeRpcError),
|
|
89
|
+
}),
|
|
87
90
|
});
|
|
88
91
|
}
|
|
89
92
|
getAddress() {
|
package/src/index.cjs
CHANGED
|
@@ -19,6 +19,7 @@ var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
|
19
19
|
var MetaMaskConnector = require('./metaMask/MetaMaskConnector.cjs');
|
|
20
20
|
var ethProviderHelper = require('./ethProviderHelper.cjs');
|
|
21
21
|
var constants = require('./constants.cjs');
|
|
22
|
+
var createInjectedConnector = require('./utils/createInjectedConnector/createInjectedConnector.cjs');
|
|
22
23
|
|
|
23
24
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum', _package.version);
|
|
24
25
|
const EthereumWalletConnectors = (props) => [
|
|
@@ -42,10 +43,15 @@ Object.defineProperty(exports, 'EthereumWalletConnector', {
|
|
|
42
43
|
enumerable: true,
|
|
43
44
|
get: function () { return ethereumCore.EthereumWalletConnector; }
|
|
44
45
|
});
|
|
46
|
+
Object.defineProperty(exports, 'createConnector', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return ethereumCore.createConnector; }
|
|
49
|
+
});
|
|
45
50
|
Object.defineProperty(exports, 'isEthereumWallet', {
|
|
46
51
|
enumerable: true,
|
|
47
52
|
get: function () { return ethereumCore.isEthereumWallet; }
|
|
48
53
|
});
|
|
49
54
|
exports.EthProviderHelper = ethProviderHelper.EthProviderHelper;
|
|
50
55
|
exports.INFURA_ID = constants.INFURA_ID;
|
|
56
|
+
exports.createInjectedConnector = createInjectedConnector.createInjectedConnector;
|
|
51
57
|
exports.EthereumWalletConnectors = EthereumWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from './injected';
|
|
|
5
5
|
export * from './ethProviderHelper';
|
|
6
6
|
export * from './constants';
|
|
7
7
|
export * from './types';
|
|
8
|
+
export { createInjectedConnector } from './utils/createInjectedConnector';
|
|
8
9
|
export declare const EthereumWalletConnectors: (props: any) => WalletConnectorConstructor[];
|
|
9
|
-
export { isEthereumWallet, EthereumWalletConnector, } from '@dynamic-labs/ethereum-core';
|
|
10
|
+
export { isEthereumWallet, EthereumWalletConnector, createConnector, } from '@dynamic-labs/ethereum-core';
|
package/src/index.js
CHANGED
|
@@ -13,10 +13,11 @@ export { InjectedWalletBase as EthereumInjectedConnector } from './injected/Inje
|
|
|
13
13
|
import './walletConnect/walletConnect.js';
|
|
14
14
|
import { fetchWalletConnectWallets, getWalletConnectConnector } from './walletConnect/fetchWalletConnectWallets.js';
|
|
15
15
|
import { Coinbase } from './coinbase/coinbase.js';
|
|
16
|
-
export { EthereumWalletConnector, isEthereumWallet } from '@dynamic-labs/ethereum-core';
|
|
16
|
+
export { EthereumWalletConnector, createConnector, isEthereumWallet } from '@dynamic-labs/ethereum-core';
|
|
17
17
|
import { MetaMaskConnector } from './metaMask/MetaMaskConnector.js';
|
|
18
18
|
export { EthProviderHelper } from './ethProviderHelper.js';
|
|
19
19
|
export { INFURA_ID } from './constants.js';
|
|
20
|
+
export { createInjectedConnector } from './utils/createInjectedConnector/createInjectedConnector.js';
|
|
20
21
|
|
|
21
22
|
assertPackageVersion('@dynamic-labs/ethereum', version);
|
|
22
23
|
const EthereumWalletConnectors = (props) => [
|
|
@@ -193,7 +193,7 @@ class MetaMaskConnector extends InjectedWalletBase.InjectedWalletBase {
|
|
|
193
193
|
return accounts;
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
-
signMessage(messageToSign
|
|
196
|
+
signMessage(messageToSign) {
|
|
197
197
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
198
198
|
yield this.metaMaskSDK.sdkInitPromise;
|
|
199
199
|
/**
|
|
@@ -209,11 +209,10 @@ class MetaMaskConnector extends InjectedWalletBase.InjectedWalletBase {
|
|
|
209
209
|
return undefined;
|
|
210
210
|
}
|
|
211
211
|
const [selectedAddress] = yield this.getConnectedAccounts();
|
|
212
|
-
|
|
213
|
-
if (!effectiveAddress) {
|
|
212
|
+
if (!selectedAddress) {
|
|
214
213
|
return undefined;
|
|
215
214
|
}
|
|
216
|
-
const walletClient = this.getWalletClientForAddress(
|
|
215
|
+
const walletClient = this.getWalletClientForAddress(selectedAddress);
|
|
217
216
|
if (!walletClient)
|
|
218
217
|
return undefined;
|
|
219
218
|
const signature = yield walletClient.signMessage({
|
|
@@ -26,7 +26,7 @@ export declare class MetaMaskConnector extends InjectedWalletBase implements IWa
|
|
|
26
26
|
getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
|
|
27
27
|
private getConnectedAccountsSafely;
|
|
28
28
|
getConnectedAccounts(): Promise<string[]>;
|
|
29
|
-
signMessage(messageToSign: string
|
|
29
|
+
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
30
30
|
chooseAccountsToConnect(): Promise<never[]>;
|
|
31
31
|
getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
|
|
32
32
|
get rdns(): string;
|
|
@@ -189,7 +189,7 @@ class MetaMaskConnector extends InjectedWalletBase {
|
|
|
189
189
|
return accounts;
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
signMessage(messageToSign
|
|
192
|
+
signMessage(messageToSign) {
|
|
193
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
194
|
yield this.metaMaskSDK.sdkInitPromise;
|
|
195
195
|
/**
|
|
@@ -205,11 +205,10 @@ class MetaMaskConnector extends InjectedWalletBase {
|
|
|
205
205
|
return undefined;
|
|
206
206
|
}
|
|
207
207
|
const [selectedAddress] = yield this.getConnectedAccounts();
|
|
208
|
-
|
|
209
|
-
if (!effectiveAddress) {
|
|
208
|
+
if (!selectedAddress) {
|
|
210
209
|
return undefined;
|
|
211
210
|
}
|
|
212
|
-
const walletClient = this.getWalletClientForAddress(
|
|
211
|
+
const walletClient = this.getWalletClientForAddress(selectedAddress);
|
|
213
212
|
if (!walletClient)
|
|
214
213
|
return undefined;
|
|
215
214
|
const signature = yield walletClient.signMessage({
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
require('@dynamic-labs/utils');
|
|
8
|
+
var InjectedWalletBase = require('../../injected/InjectedWalletBase.cjs');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('../logger.cjs');
|
|
11
|
+
|
|
12
|
+
const createInjectedConnector = (customConnectorFn) => (props) => {
|
|
13
|
+
const delegate = customConnectorFn(props);
|
|
14
|
+
return [
|
|
15
|
+
class extends InjectedWalletBase.InjectedWalletBase {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(Object.assign(Object.assign({}, props), { metadata: delegate.metadata }));
|
|
18
|
+
this.name = delegate.metadata.name;
|
|
19
|
+
}
|
|
20
|
+
init() {
|
|
21
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return delegate.init();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
findProvider() {
|
|
26
|
+
return delegate.findProvider();
|
|
27
|
+
}
|
|
28
|
+
signMessage(messageToSign) {
|
|
29
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return delegate.signMessage(messageToSign);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
connect() {
|
|
34
|
+
const _super = Object.create(null, {
|
|
35
|
+
connect: { get: () => super.connect }
|
|
36
|
+
});
|
|
37
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (delegate.connect) {
|
|
39
|
+
return delegate.connect();
|
|
40
|
+
}
|
|
41
|
+
return _super.connect.call(this);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
endSession() {
|
|
45
|
+
const _super = Object.create(null, {
|
|
46
|
+
endSession: { get: () => super.endSession }
|
|
47
|
+
});
|
|
48
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (delegate.disconnect) {
|
|
50
|
+
yield delegate.disconnect();
|
|
51
|
+
}
|
|
52
|
+
return _super.endSession.call(this);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getAddress() {
|
|
56
|
+
const _super = Object.create(null, {
|
|
57
|
+
getAddress: { get: () => super.getAddress }
|
|
58
|
+
});
|
|
59
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
if (delegate.getAddress) {
|
|
61
|
+
return delegate.getAddress();
|
|
62
|
+
}
|
|
63
|
+
return _super.getAddress.call(this);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getConnectedAccounts() {
|
|
67
|
+
const _super = Object.create(null, {
|
|
68
|
+
getConnectedAccounts: { get: () => super.getConnectedAccounts }
|
|
69
|
+
});
|
|
70
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
if (delegate.getConnectedAccounts) {
|
|
72
|
+
return delegate.getConnectedAccounts();
|
|
73
|
+
}
|
|
74
|
+
return _super.getConnectedAccounts.call(this);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
filter() {
|
|
78
|
+
if (delegate.filter) {
|
|
79
|
+
return delegate.filter();
|
|
80
|
+
}
|
|
81
|
+
return super.filter();
|
|
82
|
+
}
|
|
83
|
+
supportsNetworkSwitching() {
|
|
84
|
+
if (delegate.supportsNetworkSwitching) {
|
|
85
|
+
return delegate.supportsNetworkSwitching();
|
|
86
|
+
}
|
|
87
|
+
return super.supportsNetworkSwitching();
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
exports.createInjectedConnector = createInjectedConnector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WalletConnectorsMethod, WalletMetadata } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { IEthereum } from '../../types';
|
|
3
|
+
type CustomConnectorDelegate = {
|
|
4
|
+
metadata: WalletMetadata;
|
|
5
|
+
init: () => Promise<void>;
|
|
6
|
+
findProvider: () => IEthereum | undefined;
|
|
7
|
+
signMessage: (messageToSign: string) => Promise<string>;
|
|
8
|
+
connect?: () => Promise<void>;
|
|
9
|
+
disconnect?: () => Promise<void>;
|
|
10
|
+
filter?: () => boolean;
|
|
11
|
+
getAddress?: () => Promise<string>;
|
|
12
|
+
getConnectedAccounts?: () => Promise<string[]>;
|
|
13
|
+
supportsNetworkSwitching?: () => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const createInjectedConnector: (customConnectorFn: (props: any) => CustomConnectorDelegate) => WalletConnectorsMethod;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import '@dynamic-labs/utils';
|
|
4
|
+
import { InjectedWalletBase } from '../../injected/InjectedWalletBase.js';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import '../logger.js';
|
|
7
|
+
|
|
8
|
+
const createInjectedConnector = (customConnectorFn) => (props) => {
|
|
9
|
+
const delegate = customConnectorFn(props);
|
|
10
|
+
return [
|
|
11
|
+
class extends InjectedWalletBase {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(Object.assign(Object.assign({}, props), { metadata: delegate.metadata }));
|
|
14
|
+
this.name = delegate.metadata.name;
|
|
15
|
+
}
|
|
16
|
+
init() {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
return delegate.init();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
findProvider() {
|
|
22
|
+
return delegate.findProvider();
|
|
23
|
+
}
|
|
24
|
+
signMessage(messageToSign) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return delegate.signMessage(messageToSign);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
connect() {
|
|
30
|
+
const _super = Object.create(null, {
|
|
31
|
+
connect: { get: () => super.connect }
|
|
32
|
+
});
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
if (delegate.connect) {
|
|
35
|
+
return delegate.connect();
|
|
36
|
+
}
|
|
37
|
+
return _super.connect.call(this);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
endSession() {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
endSession: { get: () => super.endSession }
|
|
43
|
+
});
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (delegate.disconnect) {
|
|
46
|
+
yield delegate.disconnect();
|
|
47
|
+
}
|
|
48
|
+
return _super.endSession.call(this);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getAddress() {
|
|
52
|
+
const _super = Object.create(null, {
|
|
53
|
+
getAddress: { get: () => super.getAddress }
|
|
54
|
+
});
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (delegate.getAddress) {
|
|
57
|
+
return delegate.getAddress();
|
|
58
|
+
}
|
|
59
|
+
return _super.getAddress.call(this);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getConnectedAccounts() {
|
|
63
|
+
const _super = Object.create(null, {
|
|
64
|
+
getConnectedAccounts: { get: () => super.getConnectedAccounts }
|
|
65
|
+
});
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (delegate.getConnectedAccounts) {
|
|
68
|
+
return delegate.getConnectedAccounts();
|
|
69
|
+
}
|
|
70
|
+
return _super.getConnectedAccounts.call(this);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
filter() {
|
|
74
|
+
if (delegate.filter) {
|
|
75
|
+
return delegate.filter();
|
|
76
|
+
}
|
|
77
|
+
return super.filter();
|
|
78
|
+
}
|
|
79
|
+
supportsNetworkSwitching() {
|
|
80
|
+
if (delegate.supportsNetworkSwitching) {
|
|
81
|
+
return delegate.supportsNetworkSwitching();
|
|
82
|
+
}
|
|
83
|
+
return super.supportsNetworkSwitching();
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { createInjectedConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createInjectedConnector';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { normalizeRpcError } from './normalizeRpcError';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var viem = require('viem');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Some wallets may not reject some operations following the EIP-1193 standard.
|
|
10
|
+
* This function normalizes the errors to follow the EIP-1193 standard.
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
const normalizeRpcError = (err) => {
|
|
14
|
+
if (err.code === undefined && err.message === 'Request rejected') {
|
|
15
|
+
throw new viem.UserRejectedRequestError(err);
|
|
16
|
+
}
|
|
17
|
+
throw err;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.normalizeRpcError = normalizeRpcError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { UserRejectedRequestError } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Some wallets may not reject some operations following the EIP-1193 standard.
|
|
6
|
+
* This function normalizes the errors to follow the EIP-1193 standard.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
const normalizeRpcError = (err) => {
|
|
10
|
+
if (err.code === undefined && err.message === 'Request rejected') {
|
|
11
|
+
throw new UserRejectedRequestError(err);
|
|
12
|
+
}
|
|
13
|
+
throw err;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { normalizeRpcError };
|