@dynamic-labs/ethereum 0.18.0-RC.2 → 0.18.0-RC.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 +295 -0
- package/package.json +9 -7
- package/src/ethProviderHelper.cjs +11 -0
- package/src/ethProviderHelper.d.ts +2 -0
- package/src/ethProviderHelper.js +11 -0
- package/src/index.cjs +6 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -2
- package/src/injected/BackpackEvm.cjs +25 -0
- package/src/injected/BackpackEvm.d.ts +5 -0
- package/src/injected/BackpackEvm.js +21 -0
- package/src/injected/Rabby.cjs +15 -0
- package/src/injected/Rabby.d.ts +5 -0
- package/src/injected/Rabby.js +11 -0
- package/src/injected/index.cjs +6 -0
- package/src/injected/index.d.ts +2 -0
- package/src/injected/index.js +6 -0
- package/src/types.d.ts +3 -2
- package/src/utils/isString.d.ts +1 -0
- package/src/utils/last.d.ts +1 -0
- package/src/utils/parseIntSafe.cjs +22 -0
- package/src/utils/parseIntSafe.d.ts +1 -0
- package/src/utils/parseIntSafe.js +18 -0
- package/src/walletConnect/client/client.cjs +2 -2
- package/src/walletConnect/client/client.d.ts +1 -1
- package/src/walletConnect/client/client.js +2 -2
- package/src/walletConnect/fetchWalletConnectWallets.cjs +2 -0
- package/src/walletConnect/fetchWalletConnectWallets.js +2 -0
- package/src/walletConnect/walletConnect.cjs +12 -2
- package/src/walletConnect/walletConnect.d.ts +18 -1
- package/src/walletConnect/walletConnect.js +12 -2
- package/src/walletConnect/walletConnectV2.cjs +206 -59
- package/src/walletConnect/walletConnectV2.d.ts +25 -2
- package/src/walletConnect/walletConnectV2.js +205 -59
package/src/injected/index.d.ts
CHANGED
package/src/injected/index.js
CHANGED
|
@@ -23,6 +23,10 @@ export { UnknownInjectedWallet } from './UnknownInjectedWallet.js';
|
|
|
23
23
|
import { Zerion } from './Zerion.js';
|
|
24
24
|
export { Zerion } from './Zerion.js';
|
|
25
25
|
import { Superb } from './Superb.js';
|
|
26
|
+
import { Rabby } from './Rabby.js';
|
|
27
|
+
export { Rabby } from './Rabby.js';
|
|
28
|
+
import { BackpackEvm } from './BackpackEvm.js';
|
|
29
|
+
export { BackpackEvm } from './BackpackEvm.js';
|
|
26
30
|
|
|
27
31
|
const injectedWallets = [
|
|
28
32
|
BloctoInjected,
|
|
@@ -38,6 +42,8 @@ const injectedWallets = [
|
|
|
38
42
|
UnknownInjectedWallet,
|
|
39
43
|
Zerion,
|
|
40
44
|
Superb,
|
|
45
|
+
Rabby,
|
|
46
|
+
BackpackEvm,
|
|
41
47
|
];
|
|
42
48
|
|
|
43
49
|
export { injectedWallets };
|
package/src/types.d.ts
CHANGED
|
@@ -7,16 +7,17 @@ declare global {
|
|
|
7
7
|
ethereum?: IEthereum;
|
|
8
8
|
phantom?: IWindowPhantom;
|
|
9
9
|
zerionWallet?: IEthereum;
|
|
10
|
+
coinbaseWalletExtension?: IEthereum;
|
|
10
11
|
superb?: IEthereum;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
export type IEthereum = {
|
|
14
15
|
[key in ProviderFlag]: boolean;
|
|
15
16
|
} & {
|
|
16
|
-
providers
|
|
17
|
+
providers?: object[];
|
|
17
18
|
request: <T extends string>(params: {
|
|
18
19
|
method: T;
|
|
19
20
|
} | object) => Promise<T extends 'eth_requestAccounts' ? [string] : object>;
|
|
20
21
|
};
|
|
21
|
-
export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion' | 'isPhantom' | 'isSuperb';
|
|
22
|
+
export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion' | 'isPhantom' | 'isSuperb' | 'isRabby' | 'isBackpack';
|
|
22
23
|
export type EthProviderCondition = ProviderCondition<ProviderFlag>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isString: (value: unknown) => value is string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const last: <T = unknown>(array: T[]) => T | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
|
+
|
|
7
|
+
const parseIntSafe = (value, radix = 10) => {
|
|
8
|
+
try {
|
|
9
|
+
const int = parseInt(String(value), radix);
|
|
10
|
+
if (isNaN(int)) {
|
|
11
|
+
walletConnectorCore.logger.error(`Error parsing ${value}`);
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return int;
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
walletConnectorCore.logger.error(`Error parsing ${value} to int: ${e}`);
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.parseIntSafe = parseIntSafe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseIntSafe: (value: string | number, radix?: number) => number | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
|
|
3
|
+
const parseIntSafe = (value, radix = 10) => {
|
|
4
|
+
try {
|
|
5
|
+
const int = parseInt(String(value), radix);
|
|
6
|
+
if (isNaN(int)) {
|
|
7
|
+
logger.error(`Error parsing ${value}`);
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
return int;
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
logger.error(`Error parsing ${value} to int: ${e}`);
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { parseIntSafe };
|
|
@@ -12,12 +12,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
12
12
|
|
|
13
13
|
var Client__default = /*#__PURE__*/_interopDefaultLegacy(Client);
|
|
14
14
|
|
|
15
|
-
const initClient = (name, settings) => {
|
|
15
|
+
const initClient = (name, bridge, settings) => {
|
|
16
16
|
const storageId = `walletconnect-${name}`;
|
|
17
17
|
const session = localStorage.getItem(storageId);
|
|
18
18
|
const clientArgs = session
|
|
19
19
|
? { session: JSON.parse(session), storageId }
|
|
20
|
-
: { bridge
|
|
20
|
+
: { bridge, storageId };
|
|
21
21
|
return new Client__default["default"](Object.assign(Object.assign({}, clientArgs), settings));
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -2,7 +2,7 @@ import Client from '@walletconnect/client';
|
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
5
|
-
export declare const initClient: (name: string, settings?: any) => Client;
|
|
5
|
+
export declare const initClient: (name: string, bridge: string, settings?: any) => Client;
|
|
6
6
|
/**
|
|
7
7
|
* Attach event handlers to WalletConnect events.
|
|
8
8
|
*/
|
|
@@ -4,12 +4,12 @@ import { Contract, ethers } from 'ethers';
|
|
|
4
4
|
import { isSameAddress, logger, performPlatformSpecificConnectionMethod, getDeepLink } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { isMobile } from '@dynamic-labs/utils';
|
|
6
6
|
|
|
7
|
-
const initClient = (name, settings) => {
|
|
7
|
+
const initClient = (name, bridge, settings) => {
|
|
8
8
|
const storageId = `walletconnect-${name}`;
|
|
9
9
|
const session = localStorage.getItem(storageId);
|
|
10
10
|
const clientArgs = session
|
|
11
11
|
? { session: JSON.parse(session), storageId }
|
|
12
|
-
: { bridge
|
|
12
|
+
: { bridge, storageId };
|
|
13
13
|
return new Client(Object.assign(Object.assign({}, clientArgs), settings));
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
@@ -18,20 +18,24 @@ var WalletConnectProvider__default = /*#__PURE__*/_interopDefaultLegacy(WalletCo
|
|
|
18
18
|
|
|
19
19
|
class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
20
20
|
constructor(_a) {
|
|
21
|
-
var { walletName } = _a, props = _tslib.__rest(_a, ["walletName"]);
|
|
21
|
+
var { walletConnectV1Bridge, walletName } = _a, props = _tslib.__rest(_a, ["walletConnectV1Bridge", "walletName"]);
|
|
22
22
|
super(props);
|
|
23
23
|
this.supportedChains = ['EVM', 'ETH'];
|
|
24
24
|
this.connectedChain = 'EVM';
|
|
25
|
+
this.bridge = 'https://bridge.walletconnect.org';
|
|
25
26
|
this.canConnectViaQrCode = true;
|
|
26
27
|
this.isWalletConnect = true;
|
|
27
28
|
this.switchNetworkOnlyFromWallet = false;
|
|
28
29
|
this.name = walletName;
|
|
30
|
+
if (walletConnectV1Bridge) {
|
|
31
|
+
this.bridge = walletConnectV1Bridge;
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
getClient() {
|
|
31
35
|
if (this.client) {
|
|
32
36
|
return this.client;
|
|
33
37
|
}
|
|
34
|
-
this.client = client.initClient(walletConnectorCore.normalizeWalletName(this.name), this.clientOptions);
|
|
38
|
+
this.client = client.initClient(walletConnectorCore.normalizeWalletName(this.name), this.bridge, this.clientOptions);
|
|
35
39
|
return this.client;
|
|
36
40
|
}
|
|
37
41
|
supportsNetworkSwitching() {
|
|
@@ -135,6 +139,12 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
135
139
|
return client.accounts;
|
|
136
140
|
});
|
|
137
141
|
}
|
|
142
|
+
getSession() {
|
|
143
|
+
var _a;
|
|
144
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
return (_a = this.client) === null || _a === void 0 ? void 0 : _a.session;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
138
148
|
}
|
|
139
149
|
|
|
140
150
|
exports.WalletConnect = WalletConnect;
|
|
@@ -3,19 +3,34 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
import { Chain, FetchPublicAddressOpts, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
5
5
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
6
|
+
type ConnectorSession = {
|
|
7
|
+
connected: boolean;
|
|
8
|
+
accounts: string[];
|
|
9
|
+
chainId: number;
|
|
10
|
+
bridge: string;
|
|
11
|
+
key: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
clientMeta: any;
|
|
14
|
+
peerId: string;
|
|
15
|
+
peerMeta: any;
|
|
16
|
+
handshakeId: number;
|
|
17
|
+
handshakeTopic: string;
|
|
18
|
+
};
|
|
6
19
|
export type WalletConnectOpts = EthWalletConnectorOpts & {
|
|
20
|
+
walletConnectV1Bridge: string;
|
|
7
21
|
walletName: string;
|
|
8
22
|
};
|
|
9
23
|
export declare class WalletConnect extends EthWalletConnector {
|
|
10
24
|
supportedChains: Chain[];
|
|
11
25
|
connectedChain: Chain;
|
|
12
26
|
name: string;
|
|
27
|
+
bridge: string;
|
|
13
28
|
canConnectViaQrCode: boolean;
|
|
14
29
|
isWalletConnect: boolean;
|
|
15
30
|
switchNetworkOnlyFromWallet: boolean;
|
|
16
31
|
client?: Client;
|
|
17
32
|
clientOptions?: any;
|
|
18
|
-
constructor({ walletName, ...props }: WalletConnectOpts);
|
|
33
|
+
constructor({ walletConnectV1Bridge, walletName, ...props }: WalletConnectOpts);
|
|
19
34
|
getClient(): Client;
|
|
20
35
|
supportsNetworkSwitching(): boolean;
|
|
21
36
|
setupEventListeners(listeners: WalletEventListeners): void;
|
|
@@ -30,4 +45,6 @@ export declare class WalletConnect extends EthWalletConnector {
|
|
|
30
45
|
provider: ethers.providers.Web3Provider;
|
|
31
46
|
}): Promise<void>;
|
|
32
47
|
getConnectedAccounts(): Promise<string[]>;
|
|
48
|
+
getSession(): Promise<ConnectorSession | undefined>;
|
|
33
49
|
}
|
|
50
|
+
export {};
|
|
@@ -10,20 +10,24 @@ import { initClient, setupWalletConnectEventListeners, teardownWalletConnectEven
|
|
|
10
10
|
|
|
11
11
|
class WalletConnect extends EthWalletConnector {
|
|
12
12
|
constructor(_a) {
|
|
13
|
-
var { walletName } = _a, props = __rest(_a, ["walletName"]);
|
|
13
|
+
var { walletConnectV1Bridge, walletName } = _a, props = __rest(_a, ["walletConnectV1Bridge", "walletName"]);
|
|
14
14
|
super(props);
|
|
15
15
|
this.supportedChains = ['EVM', 'ETH'];
|
|
16
16
|
this.connectedChain = 'EVM';
|
|
17
|
+
this.bridge = 'https://bridge.walletconnect.org';
|
|
17
18
|
this.canConnectViaQrCode = true;
|
|
18
19
|
this.isWalletConnect = true;
|
|
19
20
|
this.switchNetworkOnlyFromWallet = false;
|
|
20
21
|
this.name = walletName;
|
|
22
|
+
if (walletConnectV1Bridge) {
|
|
23
|
+
this.bridge = walletConnectV1Bridge;
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
getClient() {
|
|
23
27
|
if (this.client) {
|
|
24
28
|
return this.client;
|
|
25
29
|
}
|
|
26
|
-
this.client = initClient(normalizeWalletName(this.name), this.clientOptions);
|
|
30
|
+
this.client = initClient(normalizeWalletName(this.name), this.bridge, this.clientOptions);
|
|
27
31
|
return this.client;
|
|
28
32
|
}
|
|
29
33
|
supportsNetworkSwitching() {
|
|
@@ -127,6 +131,12 @@ class WalletConnect extends EthWalletConnector {
|
|
|
127
131
|
return client.accounts;
|
|
128
132
|
});
|
|
129
133
|
}
|
|
134
|
+
getSession() {
|
|
135
|
+
var _a;
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
return (_a = this.client) === null || _a === void 0 ? void 0 : _a.session;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
export { WalletConnect };
|