@dynamic-labs/ethereum 2.1.0-alpha.3 → 2.1.0-alpha.31
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 +263 -0
- package/package.json +11 -11
- package/src/EthWalletConnector.cjs +5 -1
- package/src/EthWalletConnector.d.ts +2786 -6
- package/src/EthWalletConnector.js +5 -1
- package/src/coinbase/coinbase.cjs +57 -71
- package/src/coinbase/coinbase.d.ts +6893 -291
- package/src/coinbase/coinbase.js +58 -72
- package/src/coinbase/helpers.cjs +35 -0
- package/src/coinbase/helpers.d.ts +3 -0
- package/src/coinbase/helpers.js +31 -0
- package/src/coinbase/types.d.ts +21 -0
- package/src/index.cjs +3 -0
- package/src/index.js +3 -0
- package/src/injected/PhantomEvm.cjs +1 -1
- package/src/injected/PhantomEvm.js +1 -1
- package/src/injected/UnknownInjected.cjs +21 -0
- package/src/injected/UnknownInjected.d.ts +8 -0
- package/src/injected/UnknownInjected.js +17 -0
- package/src/injected/fetchInjectedWalletConnectors.cjs +0 -3
- package/src/injected/fetchInjectedWalletConnectors.js +0 -3
- package/src/injected/index.d.ts +1 -0
- 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
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
-
var walletSdk = require('@coinbase/wallet-sdk');
|
|
8
|
-
var viem = require('viem');
|
|
9
|
-
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
var constants = require('../../constants.cjs');
|
|
11
|
-
|
|
12
|
-
const jsonRpcUrl = `https://mainnet.infura.io/v3/${constants.INFURA_ID}`;
|
|
13
|
-
const chainId = 1;
|
|
14
|
-
// storing a reference to the coinbase sdk so that we can call getQrUrl on it when we need a fresh qr code
|
|
15
|
-
let coinbaseSdk;
|
|
16
|
-
// storing a reference to the coinbase provider because the provider methods work better when
|
|
17
|
-
// they are called on the same instance
|
|
18
|
-
let coinbaseProvider;
|
|
19
|
-
const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
if (!coinbaseProvider) {
|
|
22
|
-
coinbaseSdk = new walletSdk.CoinbaseWalletSDK({
|
|
23
|
-
appLogoUrl,
|
|
24
|
-
appName,
|
|
25
|
-
enableMobileWalletLink: true,
|
|
26
|
-
headlessMode: true,
|
|
27
|
-
reloadOnDisconnect: false,
|
|
28
|
-
});
|
|
29
|
-
const network = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.find((network) => network.chainId === chainId);
|
|
30
|
-
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
31
|
-
((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
32
|
-
jsonRpcUrl;
|
|
33
|
-
coinbaseProvider = coinbaseSdk.makeWeb3Provider(rpcUrl, chainId);
|
|
34
|
-
}
|
|
35
|
-
return { provider: coinbaseProvider, sdk: coinbaseSdk };
|
|
36
|
-
};
|
|
37
|
-
const killCoinbaseSession = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
yield (coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.close());
|
|
39
|
-
});
|
|
40
|
-
const getAddress = (coinbaseProviderOpts, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
-
var _a;
|
|
42
|
-
const { provider, sdk } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
43
|
-
const qrUrl = sdk.getQrUrl();
|
|
44
|
-
if (!qrUrl) {
|
|
45
|
-
throw new utils.DynamicError('no qr url available');
|
|
46
|
-
}
|
|
47
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _a === void 0 ? void 0 : _a.call(opts, qrUrl);
|
|
48
|
-
const [address] = yield provider.request({
|
|
49
|
-
method: 'eth_requestAccounts',
|
|
50
|
-
});
|
|
51
|
-
return address;
|
|
52
|
-
});
|
|
53
|
-
const signMessage = (coinbaseProviderOpts, messageToSign) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
const { provider } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
55
|
-
const [address] = yield provider.request({
|
|
56
|
-
method: 'eth_requestAccounts',
|
|
57
|
-
});
|
|
58
|
-
try {
|
|
59
|
-
return yield provider.request({
|
|
60
|
-
method: 'personal_sign',
|
|
61
|
-
params: [viem.toHex(viem.toBytes(messageToSign)), address.toLowerCase()],
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
yield provider.close();
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
exports.getAddress = getAddress;
|
|
71
|
-
exports.getCoinbaseClient = getCoinbaseClient;
|
|
72
|
-
exports.killCoinbaseSession = killCoinbaseSession;
|
|
73
|
-
exports.signMessage = signMessage;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { GetAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import { GetCoinbaseClient, GetCoinbaseProviderOpts } from './types';
|
|
3
|
-
export declare const clearClientVariables: () => void;
|
|
4
|
-
export declare const getCoinbaseClient: GetCoinbaseClient;
|
|
5
|
-
export declare const killCoinbaseSession: () => Promise<void>;
|
|
6
|
-
export declare const getAddress: (coinbaseProviderOpts: GetCoinbaseProviderOpts, opts?: GetAddressOpts) => Promise<string | undefined>;
|
|
7
|
-
export declare const signMessage: (coinbaseProviderOpts: GetCoinbaseProviderOpts, messageToSign: string) => Promise<string | undefined>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import { CoinbaseWalletSDK } from '@coinbase/wallet-sdk';
|
|
4
|
-
import { toHex, toBytes } from 'viem';
|
|
5
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
|
-
import { INFURA_ID } from '../../constants.js';
|
|
7
|
-
|
|
8
|
-
const jsonRpcUrl = `https://mainnet.infura.io/v3/${INFURA_ID}`;
|
|
9
|
-
const chainId = 1;
|
|
10
|
-
// storing a reference to the coinbase sdk so that we can call getQrUrl on it when we need a fresh qr code
|
|
11
|
-
let coinbaseSdk;
|
|
12
|
-
// storing a reference to the coinbase provider because the provider methods work better when
|
|
13
|
-
// they are called on the same instance
|
|
14
|
-
let coinbaseProvider;
|
|
15
|
-
const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
if (!coinbaseProvider) {
|
|
18
|
-
coinbaseSdk = new CoinbaseWalletSDK({
|
|
19
|
-
appLogoUrl,
|
|
20
|
-
appName,
|
|
21
|
-
enableMobileWalletLink: true,
|
|
22
|
-
headlessMode: true,
|
|
23
|
-
reloadOnDisconnect: false,
|
|
24
|
-
});
|
|
25
|
-
const network = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.find((network) => network.chainId === chainId);
|
|
26
|
-
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
27
|
-
((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
28
|
-
jsonRpcUrl;
|
|
29
|
-
coinbaseProvider = coinbaseSdk.makeWeb3Provider(rpcUrl, chainId);
|
|
30
|
-
}
|
|
31
|
-
return { provider: coinbaseProvider, sdk: coinbaseSdk };
|
|
32
|
-
};
|
|
33
|
-
const killCoinbaseSession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
yield (coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.close());
|
|
35
|
-
});
|
|
36
|
-
const getAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
var _a;
|
|
38
|
-
const { provider, sdk } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
39
|
-
const qrUrl = sdk.getQrUrl();
|
|
40
|
-
if (!qrUrl) {
|
|
41
|
-
throw new DynamicError('no qr url available');
|
|
42
|
-
}
|
|
43
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _a === void 0 ? void 0 : _a.call(opts, qrUrl);
|
|
44
|
-
const [address] = yield provider.request({
|
|
45
|
-
method: 'eth_requestAccounts',
|
|
46
|
-
});
|
|
47
|
-
return address;
|
|
48
|
-
});
|
|
49
|
-
const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
const { provider } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
51
|
-
const [address] = yield provider.request({
|
|
52
|
-
method: 'eth_requestAccounts',
|
|
53
|
-
});
|
|
54
|
-
try {
|
|
55
|
-
return yield provider.request({
|
|
56
|
-
method: 'personal_sign',
|
|
57
|
-
params: [toHex(toBytes(messageToSign)), address.toLowerCase()],
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
yield provider.close();
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export { getAddress, getCoinbaseClient, killCoinbaseSession, signMessage };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import CoinbaseWalletSDK, { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
2
|
-
import { GenericNetwork } from '@dynamic-labs/types';
|
|
3
|
-
export type GetCoinbaseProviderOpts = {
|
|
4
|
-
appLogoUrl?: string;
|
|
5
|
-
appName?: string;
|
|
6
|
-
evmNetworks?: GenericNetwork[];
|
|
7
|
-
};
|
|
8
|
-
export type CoinbaseProviderHandlerOpts = {
|
|
9
|
-
onDisconnect(): Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
export type GetCoinbaseClient = (args: {
|
|
12
|
-
handlers?: CoinbaseProviderHandlerOpts;
|
|
13
|
-
opts?: GetCoinbaseProviderOpts;
|
|
14
|
-
}) => {
|
|
15
|
-
provider: CoinbaseWalletProvider;
|
|
16
|
-
sdk: CoinbaseWalletSDK;
|
|
17
|
-
};
|
package/src/injected/Zerion.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
7
|
-
|
|
8
|
-
// on desktop, we use EIP-6963 to connect to the wallet so the injectedConfig
|
|
9
|
-
// is not needed.
|
|
10
|
-
const zerionWalletBookConfig = {
|
|
11
|
-
eip6963Config: {
|
|
12
|
-
rdns: 'io.zerion.wallet',
|
|
13
|
-
},
|
|
14
|
-
filterFromWalletConnect: true,
|
|
15
|
-
injectedConfig: [
|
|
16
|
-
{
|
|
17
|
-
chain: 'evm',
|
|
18
|
-
// adds isMetaMask flag to the wallet connector so that the window provider works
|
|
19
|
-
// in the zerion in-app browser.
|
|
20
|
-
extensionLocators: [{ flag: 'isMetaMask', value: true }],
|
|
21
|
-
windowLocations: ['zerionWallet', 'zerionwallet.ethereum'],
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
name: 'Zerion',
|
|
25
|
-
};
|
|
26
|
-
class Zerion extends InjectedWalletBase {
|
|
27
|
-
constructor(props) {
|
|
28
|
-
super(props);
|
|
29
|
-
this.name = 'Zerion';
|
|
30
|
-
this.overrideKey = 'zerion';
|
|
31
|
-
this.wallet = zerionWalletBookConfig;
|
|
32
|
-
}
|
|
33
|
-
isInstalledOnBrowser() {
|
|
34
|
-
var _a;
|
|
35
|
-
return Boolean(window.zerionWallet || ((_a = window.zerionwallet) === null || _a === void 0 ? void 0 : _a.ethereum));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.Zerion = Zerion;
|
package/src/injected/Zerion.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
-
import { EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
3
|
-
import InjectedWalletBase from './InjectedWalletBase';
|
|
4
|
-
export declare class Zerion extends InjectedWalletBase {
|
|
5
|
-
name: string;
|
|
6
|
-
overrideKey: string;
|
|
7
|
-
wallet: WalletSchema;
|
|
8
|
-
constructor(props: EthWalletConnectorOpts);
|
|
9
|
-
isInstalledOnBrowser(): boolean;
|
|
10
|
-
}
|
package/src/injected/Zerion.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
3
|
-
|
|
4
|
-
// on desktop, we use EIP-6963 to connect to the wallet so the injectedConfig
|
|
5
|
-
// is not needed.
|
|
6
|
-
const zerionWalletBookConfig = {
|
|
7
|
-
eip6963Config: {
|
|
8
|
-
rdns: 'io.zerion.wallet',
|
|
9
|
-
},
|
|
10
|
-
filterFromWalletConnect: true,
|
|
11
|
-
injectedConfig: [
|
|
12
|
-
{
|
|
13
|
-
chain: 'evm',
|
|
14
|
-
// adds isMetaMask flag to the wallet connector so that the window provider works
|
|
15
|
-
// in the zerion in-app browser.
|
|
16
|
-
extensionLocators: [{ flag: 'isMetaMask', value: true }],
|
|
17
|
-
windowLocations: ['zerionWallet', 'zerionwallet.ethereum'],
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
name: 'Zerion',
|
|
21
|
-
};
|
|
22
|
-
class Zerion extends InjectedWalletBase {
|
|
23
|
-
constructor(props) {
|
|
24
|
-
super(props);
|
|
25
|
-
this.name = 'Zerion';
|
|
26
|
-
this.overrideKey = 'zerion';
|
|
27
|
-
this.wallet = zerionWalletBookConfig;
|
|
28
|
-
}
|
|
29
|
-
isInstalledOnBrowser() {
|
|
30
|
-
var _a;
|
|
31
|
-
return Boolean(window.zerionWallet || ((_a = window.zerionwallet) === null || _a === void 0 ? void 0 : _a.ethereum));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { Zerion };
|