@dynamic-labs/ethereum 2.1.0-alpha.2 → 2.1.0-alpha.21
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 +170 -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
|
@@ -5,103 +5,70 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var viem = require('viem');
|
|
8
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
|
-
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
11
9
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
12
|
-
var
|
|
10
|
+
var helpers = require('./helpers.cjs');
|
|
13
11
|
|
|
14
12
|
class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
15
13
|
constructor(_a) {
|
|
16
|
-
var { appName, appLogoUrl, evmNetworks } = _a, props = _tslib.__rest(_a, ["appName", "appLogoUrl", "evmNetworks"]);
|
|
14
|
+
var { appName, appLogoUrl, evmNetworks, coinbaseWalletPreference } = _a, props = _tslib.__rest(_a, ["appName", "appLogoUrl", "evmNetworks", "coinbaseWalletPreference"]);
|
|
17
15
|
super(Object.assign({ evmNetworks }, props));
|
|
18
16
|
this.name = 'Coinbase';
|
|
19
17
|
this.overrideKey = 'coinbase';
|
|
20
18
|
this.supportedChains = ['EVM', 'ETH'];
|
|
21
19
|
this.connectedChain = 'EVM';
|
|
22
|
-
this.canConnectViaQrCode =
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(wallet, this);
|
|
32
|
-
}
|
|
33
|
-
setupEventListeners() {
|
|
34
|
-
var _a, _b, _c;
|
|
35
|
-
if (!this.isInstalledOnBrowser()) {
|
|
36
|
-
this.setupCoinbaseProviderEventListeners();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider();
|
|
40
|
-
if (!provider) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const setupResponse = (_c = (_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b._setupEventListeners) === null || _c === void 0 ? void 0 : _c.call(_b, this);
|
|
44
|
-
if (!(setupResponse === null || setupResponse === void 0 ? void 0 : setupResponse.tearDownEventListeners))
|
|
45
|
-
return;
|
|
46
|
-
this.teardownEventListeners = setupResponse.tearDownEventListeners;
|
|
47
|
-
}
|
|
48
|
-
getWalletClient(chainId) {
|
|
49
|
-
var _a;
|
|
50
|
-
if (this.isInstalledOnBrowser()) {
|
|
51
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
52
|
-
}
|
|
53
|
-
return viem.createWalletClient({
|
|
54
|
-
transport: viem.custom(client.getCoinbaseClient({
|
|
55
|
-
opts: this.coinbaseProviderOpts,
|
|
56
|
-
}).provider),
|
|
20
|
+
this.canConnectViaQrCode = false;
|
|
21
|
+
this.canConnectViaCustodialService = true;
|
|
22
|
+
this.coinbaseProvider = helpers.getCoinbaseProvider({
|
|
23
|
+
opts: {
|
|
24
|
+
appLogoUrl: appLogoUrl,
|
|
25
|
+
appName: appName,
|
|
26
|
+
evmNetworks: evmNetworks,
|
|
27
|
+
walletPreference: coinbaseWalletPreference,
|
|
28
|
+
},
|
|
57
29
|
});
|
|
58
30
|
}
|
|
59
|
-
|
|
60
|
-
var _a;
|
|
61
|
-
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
62
|
-
}
|
|
63
|
-
getAddress(opts) {
|
|
31
|
+
getAddress() {
|
|
64
32
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return client.getAddress(this.coinbaseProviderOpts, opts);
|
|
33
|
+
const [address] = yield this.coinbaseProvider.request({
|
|
34
|
+
method: 'eth_requestAccounts',
|
|
35
|
+
});
|
|
36
|
+
return address;
|
|
70
37
|
});
|
|
71
38
|
}
|
|
72
39
|
signMessage(messageToSign) {
|
|
73
40
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
41
|
+
const [address] = yield this.coinbaseProvider.request({
|
|
42
|
+
method: 'eth_requestAccounts',
|
|
43
|
+
});
|
|
44
|
+
try {
|
|
45
|
+
return yield this.coinbaseProvider.request({
|
|
46
|
+
method: 'personal_sign',
|
|
47
|
+
params: [viem.toHex(viem.toBytes(messageToSign)), address.toLowerCase()],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return undefined;
|
|
77
52
|
}
|
|
78
|
-
return client.signMessage(this.coinbaseProviderOpts, messageToSign);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
endSession() {
|
|
82
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
if (this.isInstalledOnBrowser())
|
|
84
|
-
return;
|
|
85
|
-
client.killCoinbaseSession();
|
|
86
53
|
});
|
|
87
54
|
}
|
|
88
|
-
|
|
89
|
-
const { provider } = client.getCoinbaseClient({
|
|
90
|
-
opts: this.coinbaseProviderOpts,
|
|
91
|
-
});
|
|
92
|
-
if (!provider) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
55
|
+
setupEventListeners() {
|
|
95
56
|
const { handleAccountChange, handleChainChange, handleDisconnect } = walletConnectorCore.eventListenerHandlers(this);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
57
|
+
this.coinbaseProvider.on('accountsChanged', handleAccountChange);
|
|
58
|
+
this.coinbaseProvider.on('chainChanged', handleChainChange);
|
|
59
|
+
this.coinbaseProvider.on('disconnect', handleDisconnect);
|
|
99
60
|
this.teardownEventListeners = () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
61
|
+
this.coinbaseProvider.removeListener('accountsChanged', handleAccountChange);
|
|
62
|
+
this.coinbaseProvider.removeListener('chainChanged', handleChainChange);
|
|
63
|
+
this.coinbaseProvider.removeListener('disconnect', handleDisconnect);
|
|
103
64
|
};
|
|
104
65
|
}
|
|
66
|
+
getWalletClient() {
|
|
67
|
+
return viem.createWalletClient({
|
|
68
|
+
// add account and chain
|
|
69
|
+
transport: viem.custom(this.coinbaseProvider),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
105
72
|
}
|
|
106
73
|
|
|
107
74
|
exports.Coinbase = Coinbase;
|