@dynamic-labs/wallet-connector-core 4.0.0-alpha.3 → 4.0.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 +261 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +9 -16
- package/src/{lib/wallets/Wallet → Wallet}/Wallet.cjs +3 -5
- package/src/{lib/wallets/Wallet → Wallet}/Wallet.d.ts +1 -1
- package/src/{lib/wallets/Wallet → Wallet}/Wallet.js +3 -5
- package/src/{lib → WalletBookSingleton}/WalletBookSingleton.cjs +3 -0
- package/src/{lib → WalletBookSingleton}/WalletBookSingleton.d.ts +1 -0
- package/src/{lib → WalletBookSingleton}/WalletBookSingleton.js +3 -0
- package/src/WalletBookSingleton/index.d.ts +1 -0
- package/src/{lib/WalletConnector.cjs → WalletConnectorBase/WalletConnectorBase.cjs} +18 -29
- package/src/{lib/WalletConnector.d.ts → WalletConnectorBase/WalletConnectorBase.d.ts} +13 -44
- package/src/{lib/WalletConnector.js → WalletConnectorBase/WalletConnectorBase.js} +19 -28
- package/src/WalletConnectorBase/index.d.ts +2 -0
- package/src/WalletConnectorBase/types.cjs +33 -0
- package/src/WalletConnectorBase/types.d.ts +54 -0
- package/src/WalletConnectorBase/types.js +28 -0
- package/src/events/index.d.ts +1 -0
- package/src/events/walletConnectorEvents.cjs +14 -0
- package/src/events/walletConnectorEvents.d.ts +26 -0
- package/src/events/walletConnectorEvents.js +6 -0
- package/src/index.cjs +20 -7
- package/src/index.d.ts +7 -4
- package/src/index.js +12 -2
- package/src/{lib → interfaces}/IAccountAbstractionWalletConnector.d.ts +11 -2
- package/src/{lib → interfaces}/IBitcoinWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ICoinbaseMPCWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IEmailWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IHardwareWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IPasskeyWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/IPhantomRedirectConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ISMSWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ISendBalanceWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ISessionKeyCompatibleWalletConnector.d.ts +1 -1
- package/src/{lib → interfaces}/ITurnkeyWalletConnector.d.ts +1 -1
- package/src/interfaces/ITurnkeyWalletConnectorStamper.d.ts +35 -0
- package/src/{lib → interfaces}/IWalletConnectConnector.d.ts +1 -1
- package/src/{lib → interfaces}/index.d.ts +7 -10
- package/src/types.d.ts +50 -0
- package/src/utils/eventListenerHandlers.d.ts +1 -1
- package/src/utils/getChainInfo/getChainInfo.cjs +4 -4
- package/src/utils/getChainInfo/getChainInfo.d.ts +2 -2
- package/src/utils/getChainInfo/getChainInfo.js +4 -4
- package/src/utils/getWalletConnectorByKey.d.ts +1 -1
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.cjs +16 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/getDeepLinks.js +12 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDeepLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.cjs +36 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/getDownloadLinks.js +32 -0
- package/src/utils/getWalletMetadataFromWalletBook/getDownloadLinks/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.cjs +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/getIconUrl.js +11 -0
- package/src/utils/getWalletMetadataFromWalletBook/getIconUrl/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.cjs +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/getValidHexColor.js +11 -0
- package/src/utils/getWalletMetadataFromWalletBook/getValidHexColor/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.cjs +19 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.d.ts +3 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/getWalletLimitations.js +15 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletLimitations/index.d.ts +1 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.cjs +42 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.d.ts +10 -0
- package/src/utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.js +38 -0
- package/src/utils/getWalletMetadataFromWalletBook/index.d.ts +1 -0
- package/src/utils/index.d.ts +3 -0
- package/src/utils/isAccountAbstractionConnector/isAccountAbstractionConnector.d.ts +1 -1
- package/src/utils/isBitcoinConnector/isBitcoinConnector.d.ts +1 -1
- package/src/utils/isBloctoConnector/isBloctoConnector.d.ts +1 -1
- package/src/utils/isCoinbaseMpcWalletConnector/isCoinbaseMpcWalletConnector.d.ts +1 -1
- package/src/utils/isConnectorEventSupported/index.d.ts +1 -0
- package/src/utils/isConnectorEventSupported/isConnectorEventSupported.cjs +11 -0
- package/src/utils/isConnectorEventSupported/isConnectorEventSupported.d.ts +3 -0
- package/src/utils/isConnectorEventSupported/isConnectorEventSupported.js +7 -0
- package/src/utils/isConnectorMethodSupported/isConnectorMethodSupported.cjs +2 -5
- package/src/utils/isConnectorMethodSupported/isConnectorMethodSupported.d.ts +3 -3
- package/src/utils/isConnectorMethodSupported/isConnectorMethodSupported.js +2 -5
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +1 -1
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +1 -1
- package/src/utils/isEmbeddedConnector/isEmbeddedConnector.d.ts +1 -1
- package/src/utils/isHardwareWalletConnector/isHardwareWalletConnector.d.ts +1 -1
- package/src/utils/isMagicConnector/isMagicConnector.d.ts +1 -1
- package/src/utils/isPasskeyWalletConnector/isPasskeyWalletConnector.d.ts +1 -1
- package/src/utils/isPhantomRedirectConnector/isPhantomRedirectConnector.d.ts +1 -1
- package/src/utils/isSendBalanceWalletConnector/isSendBalanceWalletConnector.d.ts +2 -2
- package/src/utils/isSessionKeyCompatible/isSessionKeyCompatibleWallet/isSessionKeyCompatibleWallet.d.ts +1 -1
- package/src/utils/isSessionKeyCompatible/isSessionKeyCompatibleWalletConnector/isSessionKeyCompatibleWalletConnector.d.ts +2 -2
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +1 -1
- package/src/utils/isTurnkeyWalletConnector/isTurnkeyWalletConnector.d.ts +1 -1
- package/src/utils/isWalletConnectConnector/isWalletConnectConnector.d.ts +1 -1
- package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.d.ts +1 -1
- package/src/lib/ITurnkeyWalletConnectorStamper.d.ts +0 -18
- package/src/lib/WalletConnectorExtension.d.ts +0 -7
- package/src/lib/types.d.ts +0 -8
- package/src/lib/wallets/index.d.ts +0 -1
- /package/src/{lib/wallets/Wallet → Wallet}/index.d.ts +0 -0
- /package/src/{lib → interfaces}/IEmailOTPWalletConnector.d.ts +0 -0
|
@@ -1,44 +1,21 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __classPrivateFieldGet, __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
|
-
import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
4
|
import { WalletAddressMismatchError } from '@dynamic-labs/utils';
|
|
5
|
+
import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
6
|
+
import { walletConnectorEvents } from '../events/walletConnectorEvents.js';
|
|
6
7
|
import { logger } from '../utils/logger.js';
|
|
7
8
|
import { isSameAddress } from '../utils/isSameAddress/isSameAddress.js';
|
|
8
9
|
import { getMobileExperience } from '../utils/getMobileExperience/getMobileExperience.js';
|
|
10
|
+
import { getWalletMetadataFromWalletBook } from '../utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.js';
|
|
9
11
|
import { isConnectorMethodSupported } from '../utils/isConnectorMethodSupported/isConnectorMethodSupported.js';
|
|
10
|
-
import { WalletBookSingleton } from '
|
|
12
|
+
import { WalletBookSingleton } from '../WalletBookSingleton/WalletBookSingleton.js';
|
|
11
13
|
|
|
12
14
|
/* eslint-disable @typescript-eslint/triple-slash-reference */
|
|
13
15
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
14
16
|
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
15
17
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
16
18
|
var _WalletConnectorBase_registeredExtensions;
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
18
|
-
const Chains = [
|
|
19
|
-
'ETH',
|
|
20
|
-
'FLOW',
|
|
21
|
-
'SOL',
|
|
22
|
-
'EVM',
|
|
23
|
-
'ALGO',
|
|
24
|
-
'STARK',
|
|
25
|
-
'ATOM',
|
|
26
|
-
'COSMOS',
|
|
27
|
-
'BTC',
|
|
28
|
-
];
|
|
29
|
-
const socialProviders = [
|
|
30
|
-
'google',
|
|
31
|
-
'facebook',
|
|
32
|
-
'apple',
|
|
33
|
-
'github',
|
|
34
|
-
'bitbucket',
|
|
35
|
-
'gitlab',
|
|
36
|
-
'linkedin',
|
|
37
|
-
'twitter',
|
|
38
|
-
'discord',
|
|
39
|
-
'twitch',
|
|
40
|
-
'microsoft',
|
|
41
|
-
];
|
|
42
19
|
class WalletConnectorBase extends EventEmitter {
|
|
43
20
|
createWallet(props) {
|
|
44
21
|
const wallet = new this.ChainWallet(props);
|
|
@@ -118,6 +95,10 @@ class WalletConnectorBase extends EventEmitter {
|
|
|
118
95
|
this.isInitialized = true;
|
|
119
96
|
this.constructorProps = props;
|
|
120
97
|
this._walletBookInstance = WalletBookSingleton.getOrCreate(props.walletBook);
|
|
98
|
+
this._metadata = props.metadata;
|
|
99
|
+
this.walletConnectorEventsEmitter =
|
|
100
|
+
this.constructorProps.walletConnectorEventsEmitter ||
|
|
101
|
+
walletConnectorEvents;
|
|
121
102
|
if (this.walletBook === undefined) {
|
|
122
103
|
throw new Error('WalletConnectorBase was not called with super(props) and is missing wallet-book');
|
|
123
104
|
}
|
|
@@ -299,6 +280,16 @@ class WalletConnectorBase extends EventEmitter {
|
|
|
299
280
|
get key() {
|
|
300
281
|
return this.overrideKey || this.name.replace(/\W/g, '').toLowerCase();
|
|
301
282
|
}
|
|
283
|
+
get metadata() {
|
|
284
|
+
var _a;
|
|
285
|
+
if (!this._metadata) {
|
|
286
|
+
this._metadata = getWalletMetadataFromWalletBook({
|
|
287
|
+
walletBook: this.walletBook,
|
|
288
|
+
walletKey: this.key,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return (_a = this._metadata) !== null && _a !== void 0 ? _a : { icon: '', id: this.key, name: this.name };
|
|
292
|
+
}
|
|
302
293
|
/**
|
|
303
294
|
* Whether the wallet connector should fall back to a different wallet connector
|
|
304
295
|
* This is called after the object is instantiated, so it can't be a static property
|
|
@@ -450,4 +441,4 @@ class WalletConnectorBase extends EventEmitter {
|
|
|
450
441
|
}
|
|
451
442
|
_WalletConnectorBase_registeredExtensions = new WeakMap();
|
|
452
443
|
|
|
453
|
-
export {
|
|
444
|
+
export { WalletConnectorBase };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const Chains = [
|
|
7
|
+
'ETH',
|
|
8
|
+
'FLOW',
|
|
9
|
+
'SOL',
|
|
10
|
+
'EVM',
|
|
11
|
+
'ALGO',
|
|
12
|
+
'STARK',
|
|
13
|
+
'ATOM',
|
|
14
|
+
'COSMOS',
|
|
15
|
+
'BTC',
|
|
16
|
+
'ECLIPSE',
|
|
17
|
+
];
|
|
18
|
+
const socialProviders = [
|
|
19
|
+
'google',
|
|
20
|
+
'facebook',
|
|
21
|
+
'apple',
|
|
22
|
+
'github',
|
|
23
|
+
'bitbucket',
|
|
24
|
+
'gitlab',
|
|
25
|
+
'linkedin',
|
|
26
|
+
'twitter',
|
|
27
|
+
'discord',
|
|
28
|
+
'twitch',
|
|
29
|
+
'microsoft',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
exports.Chains = Chains;
|
|
33
|
+
exports.socialProviders = socialProviders;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { WalletConnectorCore } from '../types';
|
|
3
|
+
export declare const Chains: readonly ["ETH", "FLOW", "SOL", "EVM", "ALGO", "STARK", "ATOM", "COSMOS", "BTC", "ECLIPSE"];
|
|
4
|
+
export type Chain = typeof Chains[number];
|
|
5
|
+
export declare const socialProviders: readonly ["google", "facebook", "apple", "github", "bitbucket", "gitlab", "linkedin", "twitter", "discord", "twitch", "microsoft"];
|
|
6
|
+
export type SocialProvider = typeof socialProviders[number];
|
|
7
|
+
export type PayloadParams = {
|
|
8
|
+
params: {
|
|
9
|
+
accounts: string[];
|
|
10
|
+
chainId: number;
|
|
11
|
+
message: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
export type GetAddressOpts = {
|
|
15
|
+
chainId?: string;
|
|
16
|
+
onConnect?(payload: PayloadParams): void;
|
|
17
|
+
onDesktopUri?(uri: string): void;
|
|
18
|
+
onDisplayUri?(uri: string): void;
|
|
19
|
+
};
|
|
20
|
+
export type NameServiceData = {
|
|
21
|
+
avatar?: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
};
|
|
24
|
+
export type InternalWalletConnector = WalletConnectorCore.WalletConnector;
|
|
25
|
+
export type WalletConnector = Pick<InternalWalletConnector, 'canConnectViaCustodialService' | 'canConnectViaQrCode' | 'canConnectViaSocial' | 'chainRpcProviders' | 'connect' | 'connectedChain' | 'createWallet' | 'constructorProps' | 'endSession' | 'getAddress' | 'getAdditionalAddresses' | 'getConnectedAccounts' | 'getDeepLink' | 'getMobileOrInstalledWallet' | 'getNetwork' | 'getSession' | 'initEventListener' | 'isAvailable' | 'isEmbeddedWallet' | 'isInitialized' | 'isInstalledOnBrowser' | 'isTestnet' | 'isWalletConnect' | 'key' | 'metadata' | 'name' | 'parseAddress' | 'proveOwnership' | 'providerResources' | 'supportedChains' | 'supportsNetworkSwitching' | 'switchNetwork' | 'switchNetworkOnlyFromWallet' | 'teardownEventListeners'> & EventEmitter<WalletConnectorEventTypes>;
|
|
26
|
+
export interface WalletConnectorConstructor {
|
|
27
|
+
new (props?: any): InternalWalletConnector;
|
|
28
|
+
}
|
|
29
|
+
export type WalletConnectorsMethod = (props?: any) => WalletConnectorConstructor[];
|
|
30
|
+
export type WalletConnectorEventTypes = {
|
|
31
|
+
chainChange: (props: {
|
|
32
|
+
chain: string;
|
|
33
|
+
}) => void;
|
|
34
|
+
accountChange: (props: {
|
|
35
|
+
accounts: string[];
|
|
36
|
+
}) => void;
|
|
37
|
+
disconnect: () => void;
|
|
38
|
+
};
|
|
39
|
+
export interface WalletConnectorExtension {
|
|
40
|
+
extend(connector: InternalWalletConnector, settings?: {
|
|
41
|
+
walletConnectDappProjectId?: string;
|
|
42
|
+
}): void;
|
|
43
|
+
name: string;
|
|
44
|
+
}
|
|
45
|
+
export type ChainChangeEventHandler = (chainId: string | number) => Promise<void>;
|
|
46
|
+
export type DisconnectEventHandler = (error?: {
|
|
47
|
+
code: number;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
export type ChainInfo = {
|
|
50
|
+
blockchainName: string;
|
|
51
|
+
displayName: string;
|
|
52
|
+
name: string;
|
|
53
|
+
symbol: Chain;
|
|
54
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const Chains = [
|
|
3
|
+
'ETH',
|
|
4
|
+
'FLOW',
|
|
5
|
+
'SOL',
|
|
6
|
+
'EVM',
|
|
7
|
+
'ALGO',
|
|
8
|
+
'STARK',
|
|
9
|
+
'ATOM',
|
|
10
|
+
'COSMOS',
|
|
11
|
+
'BTC',
|
|
12
|
+
'ECLIPSE',
|
|
13
|
+
];
|
|
14
|
+
const socialProviders = [
|
|
15
|
+
'google',
|
|
16
|
+
'facebook',
|
|
17
|
+
'apple',
|
|
18
|
+
'github',
|
|
19
|
+
'bitbucket',
|
|
20
|
+
'gitlab',
|
|
21
|
+
'linkedin',
|
|
22
|
+
'twitter',
|
|
23
|
+
'discord',
|
|
24
|
+
'twitch',
|
|
25
|
+
'microsoft',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export { Chains, socialProviders };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './walletConnectorEvents';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var EventEmitter = require('eventemitter3');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
11
|
+
|
|
12
|
+
const walletConnectorEvents = new EventEmitter__default["default"]();
|
|
13
|
+
|
|
14
|
+
exports.walletConnectorEvents = walletConnectorEvents;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { InternalWalletConnector } from '../WalletConnectorBase';
|
|
3
|
+
type AutoConnectEventProps = {
|
|
4
|
+
connector: InternalWalletConnector;
|
|
5
|
+
};
|
|
6
|
+
type ProviderReadyEventProps = {
|
|
7
|
+
connector: InternalWalletConnector;
|
|
8
|
+
};
|
|
9
|
+
export type WalletConnectorEvents = {
|
|
10
|
+
/**
|
|
11
|
+
* This is useful for when we want to auto-connect/login with a wallet
|
|
12
|
+
* without the user having to select it from the list, as long as
|
|
13
|
+
* the wallet is already connected to the dapp
|
|
14
|
+
*
|
|
15
|
+
* For example, we can auto-connect to a Safe wallet from a a Safe App
|
|
16
|
+
*/
|
|
17
|
+
autoConnect: (props: AutoConnectEventProps) => void;
|
|
18
|
+
/**
|
|
19
|
+
* This is useful for when we want to know when the wallet provider
|
|
20
|
+
* is ready to be used
|
|
21
|
+
*/
|
|
22
|
+
providerReady: (props: ProviderReadyEventProps) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const walletConnectorEvents: EventEmitter<WalletConnectorEvents, any>;
|
|
25
|
+
export type WalletConnectorEventEmitter = typeof walletConnectorEvents;
|
|
26
|
+
export {};
|
package/src/index.cjs
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
|
+
var _package = require('../package.cjs');
|
|
8
|
+
var walletConnectorEvents = require('./events/walletConnectorEvents.cjs');
|
|
8
9
|
var logger = require('./utils/logger.cjs');
|
|
9
10
|
var ProviderLookup = require('./utils/ProviderLookup/ProviderLookup.cjs');
|
|
10
11
|
var getChainInfo = require('./utils/getChainInfo/getChainInfo.cjs');
|
|
@@ -35,13 +36,17 @@ var isSendBalanceWalletConnector = require('./utils/isSendBalanceWalletConnector
|
|
|
35
36
|
var isSessionKeyCompatibleWallet = require('./utils/isSessionKeyCompatible/isSessionKeyCompatibleWallet/isSessionKeyCompatibleWallet.cjs');
|
|
36
37
|
var isSessionKeyCompatibleWalletConnector = require('./utils/isSessionKeyCompatible/isSessionKeyCompatibleWalletConnector/isSessionKeyCompatibleWalletConnector.cjs');
|
|
37
38
|
var getMobileExperience = require('./utils/getMobileExperience/getMobileExperience.cjs');
|
|
39
|
+
var getWalletMetadataFromWalletBook = require('./utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.cjs');
|
|
40
|
+
var isConnectorMethodSupported = require('./utils/isConnectorMethodSupported/isConnectorMethodSupported.cjs');
|
|
41
|
+
var isConnectorEventSupported = require('./utils/isConnectorEventSupported/isConnectorEventSupported.cjs');
|
|
42
|
+
var Wallet = require('./Wallet/Wallet.cjs');
|
|
43
|
+
var WalletConnectorBase = require('./WalletConnectorBase/WalletConnectorBase.cjs');
|
|
44
|
+
var types = require('./WalletConnectorBase/types.cjs');
|
|
45
|
+
var WalletBookSingleton = require('./WalletBookSingleton/WalletBookSingleton.cjs');
|
|
38
46
|
|
|
47
|
+
assertPackageVersion.assertPackageVersion('@dynamic-labs/wallet-connector-core', _package.version);
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
exports.Chains = WalletConnector.Chains;
|
|
42
|
-
exports.WalletConnectorBase = WalletConnector.WalletConnectorBase;
|
|
43
|
-
exports.socialProviders = WalletConnector.socialProviders;
|
|
44
|
-
exports.Wallet = Wallet.Wallet;
|
|
49
|
+
exports.walletConnectorEvents = walletConnectorEvents.walletConnectorEvents;
|
|
45
50
|
exports.logger = logger.logger;
|
|
46
51
|
exports.ProviderLookup = ProviderLookup.ProviderLookup;
|
|
47
52
|
exports.getChainInfo = getChainInfo.getChainInfo;
|
|
@@ -76,3 +81,11 @@ exports.isSendBalanceWalletConnector = isSendBalanceWalletConnector.isSendBalanc
|
|
|
76
81
|
exports.isSessionKeyCompatibleWallet = isSessionKeyCompatibleWallet.isSessionKeyCompatibleWallet;
|
|
77
82
|
exports.isSessionKeyCompatibleWalletConnector = isSessionKeyCompatibleWalletConnector.isSessionKeyCompatibleWalletConnector;
|
|
78
83
|
exports.getMobileExperience = getMobileExperience.getMobileExperience;
|
|
84
|
+
exports.getWalletMetadataFromWalletBook = getWalletMetadataFromWalletBook.getWalletMetadataFromWalletBook;
|
|
85
|
+
exports.isConnectorMethodSupported = isConnectorMethodSupported.isConnectorMethodSupported;
|
|
86
|
+
exports.isConnectorEventSupported = isConnectorEventSupported.isConnectorEventSupported;
|
|
87
|
+
exports.Wallet = Wallet.Wallet;
|
|
88
|
+
exports.WalletConnectorBase = WalletConnectorBase.WalletConnectorBase;
|
|
89
|
+
exports.Chains = types.Chains;
|
|
90
|
+
exports.socialProviders = types.socialProviders;
|
|
91
|
+
exports.WalletBookSingleton = WalletBookSingleton.WalletBookSingleton;
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type
|
|
3
|
-
export type { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler, } from './types';
|
|
4
|
-
export {
|
|
1
|
+
export { walletConnectorEvents } from './events';
|
|
2
|
+
export { type Attestation, type AuthenticatorRecoveryHandler, type AuthenticatorType, type BitcoinSignPsbtRequest, type BitcoinSignPsbtRequestSignature, type BitcoinSignPsbtResponse, type ExportHandler, type ExtendedPrivateKey, type IAccountAbstractionWalletConnector, type IBitcoinWalletConnector, type ICoinbaseMPCWalletConnector, type IEmailOTPWalletConnector, type IEmailWalletConnector, type IHardwareWalletConnector, type IPasskeyWalletConnector, type IPhantomRedirectConnector, type IPhantomRedirectConnectorWithEvents, type ISendBalanceWalletConnector, type ISessionKeyCompatibleWalletConnector, type ISMSWalletConnector, type ITurnkeyWalletConnector, type ITurnkeyWalletConnectorStamper, type IWalletConnectConnector, type RawPrivateKey, type RecoveryEmailParams, type RecoveryWebAuthnAttestation, type SignAllTransactionsListener, type SignAndSendTransactionListener, type SignMessageListener, type SignTransactionListener, type WebAuthnAttestation, } from './interfaces';
|
|
3
|
+
export type { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler, WalletConnectorCore, WalletMetadata, WalletDeepLinks, WalletDownloadLinks, WalletLimitations, } from './types';
|
|
4
|
+
export { addHexPrefix, bufferToHex, eventListenerHandlers, getChainInfo, getChainInfoWithOverrides, getDeepLink, getMobileExperience, getRpcUrlForChain, getWalletConnectorByKey, isAccountAbstractionConnector, isBitcoinConnector, isBloctoConnector, isCoinbaseMpcWalletConnector, isEmailOTPWalletConnector, isEmailWalletConnector, isEmbeddedConnector, isHardwareWalletConnector, isHex, isMagicConnector, isPasskeyWalletConnector, isPhantomRedirectConnector, isSameAddress, isSendBalanceWalletConnector, isSessionKeyCompatibleWallet, isSessionKeyCompatibleWalletConnector, isSocialWalletConnector, isTurnkeyWalletConnector, isWalletConnectConnector, isConnectorMethodSupported, isConnectorEventSupported, getWalletMetadataFromWalletBook, logger, performPlatformSpecificConnectionMethod, ProviderLookup, setChainInfoOverrides, shouldLowercaseAddress, utf8ToHex, type ChainDisplayOverrides, type DeepLinkVariant, type ProviderCondition, } from './utils';
|
|
5
|
+
export { Wallet, type WalletConstructor, type WalletProps } from './Wallet';
|
|
6
|
+
export { Chains, socialProviders, WalletConnectorBase, type Chain, type ChainInfo, type GetAddressOpts, type InternalWalletConnector, type NameServiceData, type PayloadParams, type SocialProvider, type WalletConnector, type WalletConnectorConstructor, type WalletConnectorEventTypes, type WalletConnectorExtension, type WalletConnectorsMethod, } from './WalletConnectorBase';
|
|
7
|
+
export { WalletBookSingleton } from './WalletBookSingleton';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
|
+
import { version } from '../package.js';
|
|
4
|
+
export { walletConnectorEvents } from './events/walletConnectorEvents.js';
|
|
4
5
|
export { logger } from './utils/logger.js';
|
|
5
6
|
export { ProviderLookup } from './utils/ProviderLookup/ProviderLookup.js';
|
|
6
7
|
export { getChainInfo, getChainInfoWithOverrides, setChainInfoOverrides } from './utils/getChainInfo/getChainInfo.js';
|
|
@@ -31,3 +32,12 @@ export { isSendBalanceWalletConnector } from './utils/isSendBalanceWalletConnect
|
|
|
31
32
|
export { isSessionKeyCompatibleWallet } from './utils/isSessionKeyCompatible/isSessionKeyCompatibleWallet/isSessionKeyCompatibleWallet.js';
|
|
32
33
|
export { isSessionKeyCompatibleWalletConnector } from './utils/isSessionKeyCompatible/isSessionKeyCompatibleWalletConnector/isSessionKeyCompatibleWalletConnector.js';
|
|
33
34
|
export { getMobileExperience } from './utils/getMobileExperience/getMobileExperience.js';
|
|
35
|
+
export { getWalletMetadataFromWalletBook } from './utils/getWalletMetadataFromWalletBook/getWalletMetadataFromWalletBook.js';
|
|
36
|
+
export { isConnectorMethodSupported } from './utils/isConnectorMethodSupported/isConnectorMethodSupported.js';
|
|
37
|
+
export { isConnectorEventSupported } from './utils/isConnectorEventSupported/isConnectorEventSupported.js';
|
|
38
|
+
export { Wallet } from './Wallet/Wallet.js';
|
|
39
|
+
export { WalletConnectorBase } from './WalletConnectorBase/WalletConnectorBase.js';
|
|
40
|
+
export { Chains, socialProviders } from './WalletConnectorBase/types.js';
|
|
41
|
+
export { WalletBookSingleton } from './WalletBookSingleton/WalletBookSingleton.js';
|
|
42
|
+
|
|
43
|
+
assertPackageVersion('@dynamic-labs/wallet-connector-core', version);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IUITransaction } from '@dynamic-labs/types';
|
|
2
|
-
import {
|
|
2
|
+
import { EcdsaValidatorOptions, ProviderEntryPointVersionEnum, ProviderKernelVersionEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { WalletConnector, WalletConnectorBase } from '../WalletConnectorBase';
|
|
3
4
|
type GetAccountAbstractionProviderProps = {
|
|
4
5
|
withSponsorship?: boolean;
|
|
5
6
|
};
|
|
@@ -8,11 +9,19 @@ export interface IAccountAbstractionWalletConnector extends WalletConnectorBase
|
|
|
8
9
|
disableGasSponsorshipOnce(): void;
|
|
9
10
|
getAccountAbstractionProvider<T>(props?: GetAccountAbstractionProviderProps): T;
|
|
10
11
|
getAccountAbstractionProvider(props?: GetAccountAbstractionProviderProps): unknown;
|
|
11
|
-
setEoaConnector(connector: WalletConnectorBase): Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* @deprecated You should get the EOA connector by passing the SCW wallet to getEOAConnector,
|
|
14
14
|
* from the useSmartWallet hook
|
|
15
15
|
*/
|
|
16
16
|
getEOAConnector(): WalletConnector | undefined;
|
|
17
|
+
registerEoa({ smartWalletAddress, eoaAddress, eoaConnector, shouldSetEoaConnector, ecdsaProviderType, entryPointVersion, kernelVersion, }: {
|
|
18
|
+
smartWalletAddress: string;
|
|
19
|
+
eoaAddress: string;
|
|
20
|
+
eoaConnector: WalletConnectorBase;
|
|
21
|
+
shouldSetEoaConnector?: boolean;
|
|
22
|
+
ecdsaProviderType?: EcdsaValidatorOptions;
|
|
23
|
+
entryPointVersion?: ProviderEntryPointVersionEnum;
|
|
24
|
+
kernelVersion?: ProviderKernelVersionEnum;
|
|
25
|
+
}): Promise<void>;
|
|
17
26
|
}
|
|
18
27
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletConnectorBase } from '
|
|
1
|
+
import { WalletConnectorBase } from '../WalletConnectorBase';
|
|
2
2
|
export interface ISMSWalletConnector extends WalletConnectorBase {
|
|
3
3
|
get phone(): string | undefined | null;
|
|
4
4
|
setPhone(phone: ISMSWalletConnector['phone']): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransactionReceipt, IUITransaction } from '@dynamic-labs/types';
|
|
2
|
-
import { WalletConnectorBase } from '
|
|
2
|
+
import { WalletConnectorBase } from '../WalletConnectorBase';
|
|
3
3
|
export interface ISendBalanceWalletConnector extends WalletConnectorBase {
|
|
4
4
|
createUiTransaction(from: string): Promise<IUITransaction>;
|
|
5
5
|
confirmTransactionStatus?(txHash: string): Promise<TransactionReceipt>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JwtVerifiedCredential, TurnkeyWalletProperties } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
import { WalletConnectorBase } from '
|
|
2
|
+
import { WalletConnectorBase } from '../WalletConnectorBase';
|
|
3
3
|
type JwtVerifiedCredentialWithSmartWalletRef = JwtVerifiedCredential & {
|
|
4
4
|
smartWalletRefId?: string;
|
|
5
5
|
smartWalletRefAddress?: string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WalletConnectorBase } from '../WalletConnectorBase';
|
|
2
|
+
export interface ITurnkeyWalletConnectorStamper extends WalletConnectorBase {
|
|
3
|
+
stampCreateWalletAccountRequest: ({ request, }: {
|
|
4
|
+
request: {
|
|
5
|
+
type: string;
|
|
6
|
+
timestampMs: string;
|
|
7
|
+
organizationId: string;
|
|
8
|
+
parameters: any;
|
|
9
|
+
};
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
body: string;
|
|
12
|
+
url: string;
|
|
13
|
+
stamp: {
|
|
14
|
+
stampHeaderName: string;
|
|
15
|
+
stampHeaderValue: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
stampDeleteSubOrganizationRequest: ({ request, }: {
|
|
19
|
+
request: {
|
|
20
|
+
type: string;
|
|
21
|
+
timestampMs: string;
|
|
22
|
+
organizationId: string;
|
|
23
|
+
parameters: {
|
|
24
|
+
deleteWithoutExport?: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
body: string;
|
|
29
|
+
url: string;
|
|
30
|
+
stamp: {
|
|
31
|
+
stampHeaderName: string;
|
|
32
|
+
stampHeaderValue: string;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
export * from './IEmailOTPWalletConnector';
|
|
2
|
-
export * from './IEmailWalletConnector';
|
|
3
|
-
export * from './WalletConnector';
|
|
4
|
-
export * from './types';
|
|
5
|
-
export * from './IPasskeyWalletConnector';
|
|
6
|
-
export * from './ITurnkeyWalletConnector';
|
|
7
|
-
export * from './ITurnkeyWalletConnectorStamper';
|
|
8
1
|
export * from './IAccountAbstractionWalletConnector';
|
|
9
2
|
export * from './IBitcoinWalletConnector';
|
|
3
|
+
export * from './ICoinbaseMPCWalletConnector';
|
|
4
|
+
export * from './IEmailOTPWalletConnector';
|
|
5
|
+
export * from './IEmailWalletConnector';
|
|
10
6
|
export * from './IHardwareWalletConnector';
|
|
7
|
+
export * from './IPasskeyWalletConnector';
|
|
11
8
|
export * from './IPhantomRedirectConnector';
|
|
12
|
-
export * from './ICoinbaseMPCWalletConnector';
|
|
13
|
-
export * from './IWalletConnectConnector';
|
|
14
9
|
export * from './ISendBalanceWalletConnector';
|
|
15
10
|
export * from './ISessionKeyCompatibleWalletConnector';
|
|
16
11
|
export * from './ISMSWalletConnector';
|
|
17
|
-
export * from './
|
|
12
|
+
export * from './ITurnkeyWalletConnector';
|
|
13
|
+
export * from './ITurnkeyWalletConnectorStamper';
|
|
14
|
+
export * from './IWalletConnectConnector';
|
package/src/types.d.ts
CHANGED
|
@@ -3,3 +3,53 @@ export type ChainChangeEventHandler = (chainId: string | number) => Promise<void
|
|
|
3
3
|
export type DisconnectEventHandler = (error?: {
|
|
4
4
|
code: number;
|
|
5
5
|
}) => Promise<void>;
|
|
6
|
+
export type WalletEvent = 'accountChanged' | 'chainChanged';
|
|
7
|
+
export type WalletMethod = 'getConnectedAccounts';
|
|
8
|
+
export type WalletLimitations = {
|
|
9
|
+
browserExtension?: {
|
|
10
|
+
unsupportedEvents?: WalletEvent[];
|
|
11
|
+
unsupportedMethods?: WalletMethod[];
|
|
12
|
+
};
|
|
13
|
+
mobile?: {
|
|
14
|
+
unsupportedEvents?: WalletEvent[];
|
|
15
|
+
unsupportedMethods?: WalletMethod[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type WalletDownloadLinks = {
|
|
19
|
+
chromeId?: string;
|
|
20
|
+
edgeId?: string;
|
|
21
|
+
firefoxId?: string;
|
|
22
|
+
operaId?: string;
|
|
23
|
+
safariId?: string;
|
|
24
|
+
androidId?: string;
|
|
25
|
+
iosId?: string;
|
|
26
|
+
};
|
|
27
|
+
export type WalletDeepLinks = {
|
|
28
|
+
native?: string;
|
|
29
|
+
universal?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @property id - A key that can be used to identify the wallet/connector, based on the wallet name
|
|
33
|
+
* @property name - The wallet name
|
|
34
|
+
* @property icon - The url or data for the wallet icon
|
|
35
|
+
* @property brandColor - The hex valye for the wallet brand color
|
|
36
|
+
* @property groupKey - Key used to group wallets together, for example, by chain
|
|
37
|
+
* @property inAppBrowserUrl - The url to open the wallet in the in-app browser
|
|
38
|
+
* @property deepLinks - The mobile deep links of the wallet
|
|
39
|
+
* @property downloadLinks - The ids to download the wallet in the different browsers and mobile stores
|
|
40
|
+
* @property walletLimitations - The limitations of the wallet in regards to methods and events
|
|
41
|
+
* @property rdns - The wallet rdns if it supports EIP-6963
|
|
42
|
+
*/
|
|
43
|
+
export type WalletMetadata = {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
icon: string;
|
|
47
|
+
brandColor?: `#${string}`;
|
|
48
|
+
groupKey?: string;
|
|
49
|
+
inAppBrowserUrl?: string;
|
|
50
|
+
deepLinks?: WalletDeepLinks;
|
|
51
|
+
downloadLinks?: WalletDownloadLinks;
|
|
52
|
+
walletLimitations?: WalletLimitations;
|
|
53
|
+
rdns?: string;
|
|
54
|
+
};
|
|
55
|
+
export declare namespace WalletConnectorCore { }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletConnector } from '
|
|
1
|
+
import { WalletConnector } from '..';
|
|
2
2
|
import { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler } from '../types';
|
|
3
3
|
export declare const eventListenerHandlers: (walletConnector: WalletConnector) => {
|
|
4
4
|
handleAccountChange: AccountChangeEventHandler;
|
|
@@ -47,10 +47,10 @@ const chainsInfo = [
|
|
|
47
47
|
symbol: 'COSMOS',
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
blockchainName: '
|
|
51
|
-
displayName: '
|
|
52
|
-
name: '
|
|
53
|
-
symbol: '
|
|
50
|
+
blockchainName: 'Eclipse',
|
|
51
|
+
displayName: 'Eclipse',
|
|
52
|
+
name: 'eclipse',
|
|
53
|
+
symbol: 'ECLIPSE',
|
|
54
54
|
},
|
|
55
55
|
];
|
|
56
56
|
const chainOverrides = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChainInfo } from '
|
|
2
|
-
export type ChainName = 'algorand' | 'bitcoin' | 'evm' | 'flow' | 'solana' | 'starknet' | 'cosmos';
|
|
1
|
+
import { ChainInfo } from '../..';
|
|
2
|
+
export type ChainName = 'algorand' | 'eclipse' | 'bitcoin' | 'evm' | 'flow' | 'solana' | 'starknet' | 'cosmos';
|
|
3
3
|
export type ChainDisplayOverrides = Partial<Record<ChainName, {
|
|
4
4
|
displayName?: string;
|
|
5
5
|
}>>;
|
|
@@ -43,10 +43,10 @@ const chainsInfo = [
|
|
|
43
43
|
symbol: 'COSMOS',
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
blockchainName: '
|
|
47
|
-
displayName: '
|
|
48
|
-
name: '
|
|
49
|
-
symbol: '
|
|
46
|
+
blockchainName: 'Eclipse',
|
|
47
|
+
displayName: 'Eclipse',
|
|
48
|
+
name: 'eclipse',
|
|
49
|
+
symbol: 'ECLIPSE',
|
|
50
50
|
},
|
|
51
51
|
];
|
|
52
52
|
const chainOverrides = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { InternalWalletConnector } from '
|
|
1
|
+
import { InternalWalletConnector } from '..';
|
|
2
2
|
export declare const getWalletConnectorByKey: (wallets: InternalWalletConnector[], key: string) => InternalWalletConnector | null;
|