@dynamic-labs/ethereum 2.1.0-alpha.2 → 2.1.0-alpha.20
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 +168 -0
- package/package.json +10 -10
- package/src/EthWalletConnector.d.ts +2785 -5
- package/src/coinbase/coinbase.cjs +40 -73
- package/src/coinbase/coinbase.d.ts +2807 -292
- package/src/coinbase/coinbase.js +41 -74
- package/src/coinbase/helpers.cjs +29 -0
- package/src/coinbase/helpers.d.ts +3 -0
- package/src/coinbase/helpers.js +25 -0
- package/src/coinbase/types.d.ts +21 -0
- package/src/injected/fetchInjectedWalletConnectors.cjs +0 -3
- package/src/injected/fetchInjectedWalletConnectors.js +0 -3
- package/src/walletConnect/walletConnect.d.ts +6883 -17
- package/src/coinbase/client/client.cjs +0 -73
- package/src/coinbase/client/client.d.ts +0 -7
- package/src/coinbase/client/client.js +0 -66
- package/src/coinbase/client/index.d.ts +0 -2
- package/src/coinbase/client/types.d.ts +0 -17
- package/src/injected/Zerion.cjs +0 -39
- package/src/injected/Zerion.d.ts +0 -10
- package/src/injected/Zerion.js +0 -35
package/src/coinbase/coinbase.js
CHANGED
|
@@ -1,103 +1,70 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __rest, __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
-
import { createWalletClient, custom } from 'viem';
|
|
4
|
-
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { toHex, toBytes, createWalletClient, custom } from 'viem';
|
|
5
4
|
import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
6
|
-
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
7
5
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
8
|
-
import {
|
|
6
|
+
import { getCoinbaseProvider } from './helpers.js';
|
|
9
7
|
|
|
10
8
|
class Coinbase extends EthWalletConnector {
|
|
11
9
|
constructor(_a) {
|
|
12
|
-
var { appName, appLogoUrl, evmNetworks } = _a, props = __rest(_a, ["appName", "appLogoUrl", "evmNetworks"]);
|
|
10
|
+
var { appName, appLogoUrl, evmNetworks, coinbaseWalletPreference } = _a, props = __rest(_a, ["appName", "appLogoUrl", "evmNetworks", "coinbaseWalletPreference"]);
|
|
13
11
|
super(Object.assign({ evmNetworks }, props));
|
|
14
12
|
this.name = 'Coinbase';
|
|
15
13
|
this.overrideKey = 'coinbase';
|
|
16
14
|
this.supportedChains = ['EVM', 'ETH'];
|
|
17
15
|
this.connectedChain = 'EVM';
|
|
18
|
-
this.canConnectViaQrCode =
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.ethProviderHelper = new EthProviderHelper(wallet, this);
|
|
28
|
-
}
|
|
29
|
-
setupEventListeners() {
|
|
30
|
-
var _a, _b, _c;
|
|
31
|
-
if (!this.isInstalledOnBrowser()) {
|
|
32
|
-
this.setupCoinbaseProviderEventListeners();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider();
|
|
36
|
-
if (!provider) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const setupResponse = (_c = (_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b._setupEventListeners) === null || _c === void 0 ? void 0 : _c.call(_b, this);
|
|
40
|
-
if (!(setupResponse === null || setupResponse === void 0 ? void 0 : setupResponse.tearDownEventListeners))
|
|
41
|
-
return;
|
|
42
|
-
this.teardownEventListeners = setupResponse.tearDownEventListeners;
|
|
43
|
-
}
|
|
44
|
-
getWalletClient(chainId) {
|
|
45
|
-
var _a;
|
|
46
|
-
if (this.isInstalledOnBrowser()) {
|
|
47
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
48
|
-
}
|
|
49
|
-
return createWalletClient({
|
|
50
|
-
transport: custom(getCoinbaseClient({
|
|
51
|
-
opts: this.coinbaseProviderOpts,
|
|
52
|
-
}).provider),
|
|
16
|
+
this.canConnectViaQrCode = false;
|
|
17
|
+
this.canConnectViaCustodialService = true;
|
|
18
|
+
this.coinbaseProvider = getCoinbaseProvider({
|
|
19
|
+
opts: {
|
|
20
|
+
appLogoUrl: appLogoUrl,
|
|
21
|
+
appName: appName,
|
|
22
|
+
evmNetworks: evmNetworks,
|
|
23
|
+
walletPreference: coinbaseWalletPreference,
|
|
24
|
+
},
|
|
53
25
|
});
|
|
54
26
|
}
|
|
55
|
-
|
|
56
|
-
var _a;
|
|
57
|
-
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
58
|
-
}
|
|
59
|
-
getAddress(opts) {
|
|
27
|
+
getAddress() {
|
|
60
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return getAddress(this.coinbaseProviderOpts, opts);
|
|
29
|
+
const [address] = yield this.coinbaseProvider.request({
|
|
30
|
+
method: 'eth_requestAccounts',
|
|
31
|
+
});
|
|
32
|
+
return address;
|
|
66
33
|
});
|
|
67
34
|
}
|
|
68
35
|
signMessage(messageToSign) {
|
|
69
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
37
|
+
const [address] = yield this.coinbaseProvider.request({
|
|
38
|
+
method: 'eth_requestAccounts',
|
|
39
|
+
});
|
|
40
|
+
try {
|
|
41
|
+
return yield this.coinbaseProvider.request({
|
|
42
|
+
method: 'personal_sign',
|
|
43
|
+
params: [toHex(toBytes(messageToSign)), address.toLowerCase()],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return undefined;
|
|
73
48
|
}
|
|
74
|
-
return signMessage(this.coinbaseProviderOpts, messageToSign);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
endSession() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
if (this.isInstalledOnBrowser())
|
|
80
|
-
return;
|
|
81
|
-
killCoinbaseSession();
|
|
82
49
|
});
|
|
83
50
|
}
|
|
84
|
-
|
|
85
|
-
const { provider } = getCoinbaseClient({
|
|
86
|
-
opts: this.coinbaseProviderOpts,
|
|
87
|
-
});
|
|
88
|
-
if (!provider) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
51
|
+
setupEventListeners() {
|
|
91
52
|
const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers(this);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
this.coinbaseProvider.on('accountsChanged', handleAccountChange);
|
|
54
|
+
this.coinbaseProvider.on('chainChanged', handleChainChange);
|
|
55
|
+
this.coinbaseProvider.on('disconnect', handleDisconnect);
|
|
95
56
|
this.teardownEventListeners = () => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
57
|
+
this.coinbaseProvider.removeListener('accountsChanged', handleAccountChange);
|
|
58
|
+
this.coinbaseProvider.removeListener('chainChanged', handleChainChange);
|
|
59
|
+
this.coinbaseProvider.removeListener('disconnect', handleDisconnect);
|
|
99
60
|
};
|
|
100
61
|
}
|
|
62
|
+
getWalletClient() {
|
|
63
|
+
return createWalletClient({
|
|
64
|
+
// add account and chain
|
|
65
|
+
transport: custom(this.coinbaseProvider),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
101
68
|
}
|
|
102
69
|
|
|
103
70
|
export { Coinbase };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletSdk = require('@coinbase/wallet-sdk');
|
|
7
|
+
|
|
8
|
+
// storing a reference to the coinbase provider because the provider methods work better when
|
|
9
|
+
// they are called on the same instance
|
|
10
|
+
let coinbaseProvider;
|
|
11
|
+
const getCoinbaseProvider = ({ opts: { appLogoUrl, appName, walletPreference } = {}, }) => {
|
|
12
|
+
if (!coinbaseProvider) {
|
|
13
|
+
const coinbaseSdk = new walletSdk.CoinbaseWalletSDK({
|
|
14
|
+
appChainIds: [
|
|
15
|
+
// hard code to work on base sepolia for now
|
|
16
|
+
84532,
|
|
17
|
+
// ...evmNetworks?.map((network) => Number(network.chainId)),
|
|
18
|
+
],
|
|
19
|
+
appLogoUrl,
|
|
20
|
+
appName,
|
|
21
|
+
});
|
|
22
|
+
coinbaseProvider = coinbaseSdk.makeWeb3Provider({
|
|
23
|
+
options: walletPreference !== null && walletPreference !== void 0 ? walletPreference : 'all',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return coinbaseProvider;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.getCoinbaseProvider = getCoinbaseProvider;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { CoinbaseWalletSDK } from '@coinbase/wallet-sdk';
|
|
3
|
+
|
|
4
|
+
// storing a reference to the coinbase provider because the provider methods work better when
|
|
5
|
+
// they are called on the same instance
|
|
6
|
+
let coinbaseProvider;
|
|
7
|
+
const getCoinbaseProvider = ({ opts: { appLogoUrl, appName, walletPreference } = {}, }) => {
|
|
8
|
+
if (!coinbaseProvider) {
|
|
9
|
+
const coinbaseSdk = new CoinbaseWalletSDK({
|
|
10
|
+
appChainIds: [
|
|
11
|
+
// hard code to work on base sepolia for now
|
|
12
|
+
84532,
|
|
13
|
+
// ...evmNetworks?.map((network) => Number(network.chainId)),
|
|
14
|
+
],
|
|
15
|
+
appLogoUrl,
|
|
16
|
+
appName,
|
|
17
|
+
});
|
|
18
|
+
coinbaseProvider = coinbaseSdk.makeWeb3Provider({
|
|
19
|
+
options: walletPreference !== null && walletPreference !== void 0 ? walletPreference : 'all',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return coinbaseProvider;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { getCoinbaseProvider };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ProviderInterface } from '@coinbase/wallet-sdk';
|
|
2
|
+
import { type CoinbaseWalletPreference, type GenericNetwork } from '@dynamic-labs/types';
|
|
3
|
+
import { type EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
4
|
+
export type GetCoinbaseProviderOpts = {
|
|
5
|
+
appLogoUrl?: string;
|
|
6
|
+
appName?: string;
|
|
7
|
+
evmNetworks?: GenericNetwork[];
|
|
8
|
+
walletPreference?: CoinbaseWalletPreference;
|
|
9
|
+
};
|
|
10
|
+
export type CoinbaseProviderHandlerOpts = {
|
|
11
|
+
onDisconnect(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type GetCoinbaseProvider = (args: {
|
|
14
|
+
handlers?: CoinbaseProviderHandlerOpts;
|
|
15
|
+
opts?: GetCoinbaseProviderOpts;
|
|
16
|
+
}) => ProviderInterface;
|
|
17
|
+
export type CoinbaseOpts = EthWalletConnectorOpts & {
|
|
18
|
+
appLogoUrl?: string;
|
|
19
|
+
appName?: string;
|
|
20
|
+
coinbaseWalletPreference?: CoinbaseWalletPreference;
|
|
21
|
+
};
|
|
@@ -8,18 +8,15 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
8
8
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
9
9
|
var PhantomEvm = require('./PhantomEvm.cjs');
|
|
10
10
|
var ExodusEvm = require('./ExodusEvm.cjs');
|
|
11
|
-
var Zerion = require('./Zerion.cjs');
|
|
12
11
|
|
|
13
12
|
const injectedWalletOverrides = [
|
|
14
13
|
PhantomEvm.PhantomEvm,
|
|
15
14
|
ExodusEvm.ExodusEvm,
|
|
16
|
-
Zerion.Zerion,
|
|
17
15
|
];
|
|
18
16
|
const filteredInjectedWalletKeysOverrides = [
|
|
19
17
|
'phantomevm',
|
|
20
18
|
'coinbase',
|
|
21
19
|
'exodusevm',
|
|
22
|
-
'zerion',
|
|
23
20
|
];
|
|
24
21
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
25
22
|
var _a;
|
|
@@ -4,18 +4,15 @@ import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
|
4
4
|
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
5
5
|
import { PhantomEvm } from './PhantomEvm.js';
|
|
6
6
|
import { ExodusEvm } from './ExodusEvm.js';
|
|
7
|
-
import { Zerion } from './Zerion.js';
|
|
8
7
|
|
|
9
8
|
const injectedWalletOverrides = [
|
|
10
9
|
PhantomEvm,
|
|
11
10
|
ExodusEvm,
|
|
12
|
-
Zerion,
|
|
13
11
|
];
|
|
14
12
|
const filteredInjectedWalletKeysOverrides = [
|
|
15
13
|
'phantomevm',
|
|
16
14
|
'coinbase',
|
|
17
15
|
'exodusevm',
|
|
18
|
-
'zerion',
|
|
19
16
|
];
|
|
20
17
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
21
18
|
var _a;
|