@dynamic-labs-sdk/evm 0.26.4 → 0.26.7
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/dist/{addEIP6963Extension-CfBmjqa4.esm.js → addEIP6963Extension-D87VJZkC.esm.js} +7 -4
- package/dist/addEIP6963Extension-D87VJZkC.esm.js.map +1 -0
- package/dist/addEIP6963Extension-J6SledVr.native.esm.js +27 -0
- package/dist/addEIP6963Extension-J6SledVr.native.esm.js.map +1 -0
- package/dist/{addEIP6963Extension-DGVzF8C0.cjs → addEIP6963Extension-ltl4AoMZ.cjs} +7 -4
- package/dist/addEIP6963Extension-ltl4AoMZ.cjs.map +1 -0
- package/dist/{addWaasEvmExtension-ZDMVoJgn.esm.js → addWaasEvmExtension-B22FwR23.esm.js} +3 -3
- package/dist/{addWaasEvmExtension-ZDMVoJgn.esm.js.map → addWaasEvmExtension-B22FwR23.esm.js.map} +1 -1
- package/dist/addWaasEvmExtension-BV00iC4G.native.esm.js +199 -0
- package/dist/addWaasEvmExtension-BV00iC4G.native.esm.js.map +1 -0
- package/dist/{addWaasEvmExtension-DioTPQDy.cjs → addWaasEvmExtension-CYNMrWQ4.cjs} +3 -3
- package/dist/{addWaasEvmExtension-DioTPQDy.cjs.map → addWaasEvmExtension-CYNMrWQ4.cjs.map} +1 -1
- package/dist/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.d.ts +24 -0
- package/dist/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.d.ts.map +1 -0
- package/dist/baseAccount/addBaseAccountEvmExtension/index.d.ts +2 -0
- package/dist/baseAccount/addBaseAccountEvmExtension/index.d.ts.map +1 -0
- package/dist/baseAccount/baseAccount.types.d.ts +27 -0
- package/dist/baseAccount/baseAccount.types.d.ts.map +1 -0
- package/dist/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.d.ts +22 -0
- package/dist/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.d.ts.map +1 -0
- package/dist/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.d.ts +19 -0
- package/dist/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.d.ts.map +1 -0
- package/dist/baseAccount.cjs +141 -0
- package/dist/baseAccount.cjs.map +1 -0
- package/dist/baseAccount.esm.js +141 -0
- package/dist/baseAccount.esm.js.map +1 -0
- package/dist/baseAccount.native.esm.js +142 -0
- package/dist/baseAccount.native.esm.js.map +1 -0
- package/dist/{createWalletClientForWalletAccount-BWVeSZ_9.cjs → createWalletClientForWalletAccount-CBDDVIYV.cjs} +2 -2
- package/dist/{createWalletClientForWalletAccount-BWVeSZ_9.cjs.map → createWalletClientForWalletAccount-CBDDVIYV.cjs.map} +1 -1
- package/dist/{createWalletClientForWalletAccount-BJZgwgJs.esm.js → createWalletClientForWalletAccount-CC2j8qwa.esm.js} +2 -2
- package/dist/{createWalletClientForWalletAccount-BJZgwgJs.esm.js.map → createWalletClientForWalletAccount-CC2j8qwa.esm.js.map} +1 -1
- package/dist/createWalletClientForWalletAccount-V4CfRjd4.native.esm.js +100 -0
- package/dist/createWalletClientForWalletAccount-V4CfRjd4.native.esm.js.map +1 -0
- package/dist/{createWalletProviderFromEIP1193Provider-BGp3OZ3r.esm.js → createWalletProviderFromEIP1193Provider-CfTnRCB0.esm.js} +2 -2
- package/dist/{createWalletProviderFromEIP1193Provider-BGp3OZ3r.esm.js.map → createWalletProviderFromEIP1193Provider-CfTnRCB0.esm.js.map} +1 -1
- package/dist/{createWalletProviderFromEIP1193Provider-DTVSazmC.cjs → createWalletProviderFromEIP1193Provider-D9gxu6Ay.cjs} +2 -2
- package/dist/{createWalletProviderFromEIP1193Provider-DTVSazmC.cjs.map → createWalletProviderFromEIP1193Provider-D9gxu6Ay.cjs.map} +1 -1
- package/dist/createWalletProviderFromEIP1193Provider-RVjz6Jte.native.esm.js +179 -0
- package/dist/createWalletProviderFromEIP1193Provider-RVjz6Jte.native.esm.js.map +1 -0
- package/dist/eip6963/addEIP6963Extension/addEIP6963Extension.constants.d.ts +2 -0
- package/dist/eip6963/addEIP6963Extension/addEIP6963Extension.constants.d.ts.map +1 -0
- package/dist/eip6963/addEIP6963Extension/addEIP6963Extension.d.ts +3 -3
- package/dist/eip6963/addEIP6963Extension/addEIP6963Extension.d.ts.map +1 -1
- package/dist/eip6963/addEIP6963Extension/addEIP6963Extension.types.d.ts +12 -0
- package/dist/eip6963/addEIP6963Extension/addEIP6963Extension.types.d.ts.map +1 -0
- package/dist/eip6963.cjs +4 -4
- package/dist/eip6963.esm.js +4 -4
- package/dist/eip6963.native.esm.js +10 -0
- package/dist/eip6963.native.esm.js.map +1 -0
- package/dist/evmTransferAmount-B__79nVn.native.esm.js +289 -0
- package/dist/evmTransferAmount-B__79nVn.native.esm.js.map +1 -0
- package/dist/{evmTransferAmount-Cou9zelD.cjs → evmTransferAmount-D5IgMelW.cjs} +2 -2
- package/dist/{evmTransferAmount-Cou9zelD.cjs.map → evmTransferAmount-D5IgMelW.cjs.map} +1 -1
- package/dist/{evmTransferAmount-DljmCxNA.esm.js → evmTransferAmount-jBe-KpYe.esm.js} +2 -2
- package/dist/{evmTransferAmount-DljmCxNA.esm.js.map → evmTransferAmount-jBe-KpYe.esm.js.map} +1 -1
- package/dist/exports/baseAccount.d.ts +3 -0
- package/dist/exports/baseAccount.d.ts.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.esm.js +5 -5
- package/dist/index.native.esm.js +167 -0
- package/dist/index.native.esm.js.map +1 -0
- package/dist/package-CAxC7ycE.native.esm.js +7 -0
- package/dist/package-CAxC7ycE.native.esm.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/getEvmNetworkIds/getEvmNetworkIds.d.ts +12 -0
- package/dist/utils/getEvmNetworkIds/getEvmNetworkIds.d.ts.map +1 -0
- package/dist/viem.cjs +1 -1
- package/dist/viem.esm.js +1 -1
- package/dist/viem.native.esm.js +10 -0
- package/dist/viem.native.esm.js.map +1 -0
- package/dist/waas.cjs +3 -3
- package/dist/waas.esm.js +3 -3
- package/dist/waas.native.esm.js +12 -0
- package/dist/waas.native.esm.js.map +1 -0
- package/dist/walletConnect.cjs +2 -2
- package/dist/walletConnect.esm.js +2 -2
- package/dist/walletConnect.native.esm.js +330 -0
- package/dist/walletConnect.native.esm.js.map +1 -0
- package/dist/windowInjected.cjs +3 -3
- package/dist/windowInjected.esm.js +3 -3
- package/dist/windowInjected.native.esm.js +154 -0
- package/dist/windowInjected.native.esm.js.map +1 -0
- package/package.json +17 -6
- package/dist/addEIP6963Extension-CfBmjqa4.esm.js.map +0 -1
- package/dist/addEIP6963Extension-DGVzF8C0.cjs.map +0 -1
package/dist/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DynamicClient } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { EvmWalletProvider } from '../../EvmWalletProvider.types';
|
|
3
|
+
import type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';
|
|
4
|
+
/**
|
|
5
|
+
* Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally
|
|
6
|
+
* by `addBaseAccountEvmExtension`; not part of the public API.
|
|
7
|
+
*
|
|
8
|
+
* The underlying `@base-org/account` SDK is constructed lazily on the first
|
|
9
|
+
* EIP-1193 call. This avoids reading `client.projectSettings` (via
|
|
10
|
+
* `getEvmNetworkIds`) at extension-registration time — which would throw if
|
|
11
|
+
* the extension is added before `initializeClient` resolves project settings.
|
|
12
|
+
*
|
|
13
|
+
* Classification matches dynamic-auth's mapping for the popup-SDK flow:
|
|
14
|
+
* `WalletProviderEnum.CustodialService`. The browser-extension path is owned
|
|
15
|
+
* by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Optional Base Account preference.
|
|
18
|
+
* @param client - The Dynamic client whose metadata + networks drive the SDK.
|
|
19
|
+
* @not-instrumented
|
|
20
|
+
*/
|
|
21
|
+
export declare const createBaseAccountEvmWalletProvider: ({ preference }: AddBaseAccountEvmExtensionOptions, client: DynamicClient) => EvmWalletProvider;
|
|
22
|
+
//# sourceMappingURL=createBaseAccountEvmWalletProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBaseAccountEvmWalletProvider.d.ts","sourceRoot":"","sources":["../../../src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAU9E;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kCAAkC,mBAC7B,iCAAiC,UACzC,aAAa,KACpB,iBA+CF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DynamicClient } from '@dynamic-labs-sdk/client';
|
|
2
|
+
type BaseAccountAppMetadata = {
|
|
3
|
+
appLogoUrl: string | undefined;
|
|
4
|
+
appName: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Reads the customer-supplied app name and logo from the Dynamic client.
|
|
8
|
+
* Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`
|
|
9
|
+
* — preferring `core.metadata` (set on the client) over project-settings fallbacks.
|
|
10
|
+
*
|
|
11
|
+
* Used by the Base Account EVM extension so callers do not have to repeat
|
|
12
|
+
* values they already passed to `createDynamicClient`.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The Dynamic client whose configuration drives the result.
|
|
15
|
+
* @not-instrumented
|
|
16
|
+
*/
|
|
17
|
+
export declare const getBaseAccountAppMetadata: (client: DynamicClient) => BaseAccountAppMetadata;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=getBaseAccountAppMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBaseAccountAppMetadata.d.ts","sourceRoot":"","sources":["../../../../src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,WAC5B,aAAa,KACpB,sBASF,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
const require_createWalletClientForWalletAccount = require('./createWalletClientForWalletAccount-CBDDVIYV.cjs');
|
|
2
|
+
const require_evmTransferAmount = require('./evmTransferAmount-D5IgMelW.cjs');
|
|
3
|
+
const require_createWalletProviderFromEIP1193Provider = require('./createWalletProviderFromEIP1193Provider-D9gxu6Ay.cjs');
|
|
4
|
+
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
5
|
+
let _dynamic_labs_sdk_client_core = require("@dynamic-labs-sdk/client/core");
|
|
6
|
+
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
7
|
+
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
8
|
+
let _base_org_account = require("@base-org/account");
|
|
9
|
+
|
|
10
|
+
//#region src/utils/getEvmNetworkIds/getEvmNetworkIds.ts
|
|
11
|
+
/**
|
|
12
|
+
* Returns the numeric IDs of the EVM networks configured on the Dynamic
|
|
13
|
+
* client. Generic helper available to any EVM extension that needs to
|
|
14
|
+
* advertise the configured chain set to a third-party SDK (e.g. Base
|
|
15
|
+
* Account, WalletConnect).
|
|
16
|
+
*
|
|
17
|
+
* @param client - The Dynamic client whose project settings drive the result.
|
|
18
|
+
* @not-instrumented
|
|
19
|
+
*/
|
|
20
|
+
const getEvmNetworkIds = (client) => (0, _dynamic_labs_sdk_client.getNetworksData)(client).reduce((networkIds, network) => {
|
|
21
|
+
if (network.chain !== "EVM") return networkIds;
|
|
22
|
+
const networkId = Number.parseInt(network.networkId, 10);
|
|
23
|
+
if (!Number.isFinite(networkId)) return networkIds;
|
|
24
|
+
networkIds.push(networkId);
|
|
25
|
+
return networkIds;
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts
|
|
30
|
+
/**
|
|
31
|
+
* Reads the customer-supplied app name and logo from the Dynamic client.
|
|
32
|
+
* Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`
|
|
33
|
+
* — preferring `core.metadata` (set on the client) over project-settings fallbacks.
|
|
34
|
+
*
|
|
35
|
+
* Used by the Base Account EVM extension so callers do not have to repeat
|
|
36
|
+
* values they already passed to `createDynamicClient`.
|
|
37
|
+
*
|
|
38
|
+
* @param client - The Dynamic client whose configuration drives the result.
|
|
39
|
+
* @not-instrumented
|
|
40
|
+
*/
|
|
41
|
+
const getBaseAccountAppMetadata = (client) => {
|
|
42
|
+
const core = (0, _dynamic_labs_sdk_client_core.getCore)(client);
|
|
43
|
+
const generalSettings = client.projectSettings?.general;
|
|
44
|
+
return {
|
|
45
|
+
appLogoUrl: core.metadata?.iconUrl ?? generalSettings?.appLogo ?? void 0,
|
|
46
|
+
appName: core.metadata?.name ?? generalSettings?.displayName ?? ""
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts
|
|
52
|
+
const BASE_ACCOUNT_DISPLAY_NAME = "Base Account";
|
|
53
|
+
const BASE_ACCOUNT_ICON = `${_dynamic_labs_sdk_client_core.DYNAMIC_ICONIC_SPRITE_URL}#base`;
|
|
54
|
+
/**
|
|
55
|
+
* Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally
|
|
56
|
+
* by `addBaseAccountEvmExtension`; not part of the public API.
|
|
57
|
+
*
|
|
58
|
+
* The underlying `@base-org/account` SDK is constructed lazily on the first
|
|
59
|
+
* EIP-1193 call. This avoids reading `client.projectSettings` (via
|
|
60
|
+
* `getEvmNetworkIds`) at extension-registration time — which would throw if
|
|
61
|
+
* the extension is added before `initializeClient` resolves project settings.
|
|
62
|
+
*
|
|
63
|
+
* Classification matches dynamic-auth's mapping for the popup-SDK flow:
|
|
64
|
+
* `WalletProviderEnum.CustodialService`. The browser-extension path is owned
|
|
65
|
+
* by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.
|
|
66
|
+
*
|
|
67
|
+
* @param options - Optional Base Account preference.
|
|
68
|
+
* @param client - The Dynamic client whose metadata + networks drive the SDK.
|
|
69
|
+
* @not-instrumented
|
|
70
|
+
*/
|
|
71
|
+
const createBaseAccountEvmWalletProvider = ({ preference }, client) => {
|
|
72
|
+
let cachedProvider;
|
|
73
|
+
const getOrCreateProvider = () => {
|
|
74
|
+
if (cachedProvider) return cachedProvider;
|
|
75
|
+
const { appName, appLogoUrl } = getBaseAccountAppMetadata(client);
|
|
76
|
+
cachedProvider = (0, _base_org_account.createBaseAccountSDK)({
|
|
77
|
+
appChainIds: getEvmNetworkIds(client),
|
|
78
|
+
appLogoUrl,
|
|
79
|
+
appName,
|
|
80
|
+
preference
|
|
81
|
+
}).getProvider();
|
|
82
|
+
return cachedProvider;
|
|
83
|
+
};
|
|
84
|
+
return require_createWalletProviderFromEIP1193Provider.createWalletProviderFromEIP1193Provider({
|
|
85
|
+
displayName: BASE_ACCOUNT_DISPLAY_NAME,
|
|
86
|
+
eip1193: {
|
|
87
|
+
on: (event, listener) => {
|
|
88
|
+
const provider = getOrCreateProvider();
|
|
89
|
+
if (event === "accountsChanged") provider.on("accountsChanged", listener);
|
|
90
|
+
else if (event === "chainChanged") provider.on("chainChanged", listener);
|
|
91
|
+
else provider.on("disconnect", () => listener());
|
|
92
|
+
},
|
|
93
|
+
removeAllListeners: () => cachedProvider?.removeAllListeners(),
|
|
94
|
+
request: (args) => getOrCreateProvider().request(args)
|
|
95
|
+
},
|
|
96
|
+
icon: BASE_ACCOUNT_ICON,
|
|
97
|
+
walletProviderType: _dynamic_labs_sdk_api_core.WalletProviderEnum.CustodialService
|
|
98
|
+
}, client);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.ts
|
|
103
|
+
const BASE_ACCOUNT_EVM_EXTENSION_KEY = "baseAccountEvm";
|
|
104
|
+
/**
|
|
105
|
+
* Adds Base Account (Coinbase Smart Wallet + EOA via popup/QR) as an available
|
|
106
|
+
* wallet provider for EVM. App metadata (name, logo) and supported network IDs
|
|
107
|
+
* are read from the Dynamic client by default, so no per-call configuration is
|
|
108
|
+
* required for the basic case.
|
|
109
|
+
*
|
|
110
|
+
* The Coinbase Wallet **browser extension** path is already handled by
|
|
111
|
+
* `addEIP6963Extension` and `addEvmWindowInjectedExtension`. This extension
|
|
112
|
+
* fills the gap for users without an injected provider — Smart Wallet popups,
|
|
113
|
+
* mobile EOA via QR/deeplink, and any platform where `window.ethereum` is
|
|
114
|
+
* unavailable.
|
|
115
|
+
*
|
|
116
|
+
* Once installed, apps connect via the generic public lifecycle:
|
|
117
|
+
* `connectWithWalletProvider`, `verifyWalletAccount`,
|
|
118
|
+
* `connectAndVerifyWithWalletProvider`.
|
|
119
|
+
*
|
|
120
|
+
* @param [options] - Optional preference and network ID overrides.
|
|
121
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
122
|
+
* @not-instrumented
|
|
123
|
+
*/
|
|
124
|
+
const addBaseAccountEvmExtension = (options = {}, client = (0, _dynamic_labs_sdk_client_core.getDefaultClient)()) => {
|
|
125
|
+
if ((0, _dynamic_labs_sdk_client_core.hasExtension)({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client)) return;
|
|
126
|
+
(0, _dynamic_labs_sdk_client_core.registerExtension)({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client);
|
|
127
|
+
require_evmTransferAmount.registerEvmNetworkProviderBuilder(client);
|
|
128
|
+
const walletProvider = createBaseAccountEvmWalletProvider(options, client);
|
|
129
|
+
(0, _dynamic_labs_sdk_client_core.getWalletProviderRegistry)(client).register({
|
|
130
|
+
priority: _dynamic_labs_sdk_client_core.WalletProviderPriority.WALLET_SDK,
|
|
131
|
+
walletProvider
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/exports/baseAccount.ts
|
|
137
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_createWalletClientForWalletAccount.name, require_createWalletClientForWalletAccount.version);
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
exports.addBaseAccountEvmExtension = addBaseAccountEvmExtension;
|
|
141
|
+
//# sourceMappingURL=baseAccount.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseAccount.cjs","names":["DYNAMIC_ICONIC_SPRITE_URL","cachedProvider: BaseAccountSDKProvider | undefined","createWalletProviderFromEIP1193Provider","WalletProviderEnum","WalletProviderPriority","packageName","packageVersion"],"sources":["../src/utils/getEvmNetworkIds/getEvmNetworkIds.ts","../src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts","../src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts","../src/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.ts","../src/exports/baseAccount.ts"],"sourcesContent":["import { type DynamicClient, getNetworksData } from '@dynamic-labs-sdk/client';\n\n/**\n * Returns the numeric IDs of the EVM networks configured on the Dynamic\n * client. Generic helper available to any EVM extension that needs to\n * advertise the configured chain set to a third-party SDK (e.g. Base\n * Account, WalletConnect).\n *\n * @param client - The Dynamic client whose project settings drive the result.\n * @not-instrumented\n */\nexport const getEvmNetworkIds = (client: DynamicClient): number[] =>\n getNetworksData(client).reduce<number[]>((networkIds, network) => {\n if (network.chain !== 'EVM') return networkIds;\n const networkId = Number.parseInt(network.networkId, 10);\n if (!Number.isFinite(networkId)) return networkIds;\n networkIds.push(networkId);\n return networkIds;\n }, []);\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\ntype BaseAccountAppMetadata = {\n appLogoUrl: string | undefined;\n appName: string;\n};\n\n/**\n * Reads the customer-supplied app name and logo from the Dynamic client.\n * Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`\n * — preferring `core.metadata` (set on the client) over project-settings fallbacks.\n *\n * Used by the Base Account EVM extension so callers do not have to repeat\n * values they already passed to `createDynamicClient`.\n *\n * @param client - The Dynamic client whose configuration drives the result.\n * @not-instrumented\n */\nexport const getBaseAccountAppMetadata = (\n client: DynamicClient\n): BaseAccountAppMetadata => {\n const core = getCore(client);\n const generalSettings = client.projectSettings?.general;\n\n return {\n appLogoUrl:\n core.metadata?.iconUrl ?? generalSettings?.appLogo ?? undefined,\n appName: core.metadata?.name ?? generalSettings?.displayName ?? '',\n };\n};\n","import { createBaseAccountSDK } from '@base-org/account';\nimport type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { DYNAMIC_ICONIC_SPRITE_URL } from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type {\n EIP1193Provider,\n EvmWalletProvider,\n} from '../../EvmWalletProvider.types';\nimport { createWalletProviderFromEIP1193Provider } from '../../utils/createWalletProviderFromEIP1193Provider';\nimport { getEvmNetworkIds } from '../../utils/getEvmNetworkIds/getEvmNetworkIds';\nimport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';\nimport { getBaseAccountAppMetadata } from '../utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata';\n\nconst BASE_ACCOUNT_DISPLAY_NAME = 'Base Account';\nconst BASE_ACCOUNT_ICON = `${DYNAMIC_ICONIC_SPRITE_URL}#base`;\n\ntype BaseAccountSDKProvider = ReturnType<\n ReturnType<typeof createBaseAccountSDK>['getProvider']\n>;\n\n/**\n * Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally\n * by `addBaseAccountEvmExtension`; not part of the public API.\n *\n * The underlying `@base-org/account` SDK is constructed lazily on the first\n * EIP-1193 call. This avoids reading `client.projectSettings` (via\n * `getEvmNetworkIds`) at extension-registration time — which would throw if\n * the extension is added before `initializeClient` resolves project settings.\n *\n * Classification matches dynamic-auth's mapping for the popup-SDK flow:\n * `WalletProviderEnum.CustodialService`. The browser-extension path is owned\n * by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.\n *\n * @param options - Optional Base Account preference.\n * @param client - The Dynamic client whose metadata + networks drive the SDK.\n * @not-instrumented\n */\nexport const createBaseAccountEvmWalletProvider = (\n { preference }: AddBaseAccountEvmExtensionOptions,\n client: DynamicClient\n): EvmWalletProvider => {\n let cachedProvider: BaseAccountSDKProvider | undefined;\n\n const getOrCreateProvider = (): BaseAccountSDKProvider => {\n if (cachedProvider) {\n return cachedProvider;\n }\n const { appName, appLogoUrl } = getBaseAccountAppMetadata(client);\n cachedProvider = createBaseAccountSDK({\n appChainIds: getEvmNetworkIds(client),\n appLogoUrl,\n appName,\n preference,\n }).getProvider();\n return cachedProvider;\n };\n\n // EIP-1193 façade that defers SDK construction until first interaction and\n // bridges the two `on` event vocabularies — `@base-org/account` emits the\n // canonical `disconnect`, while our local `EIP1193Provider` consumer expects\n // `disconnected`. We forward each event explicitly so the divergence is\n // visible in source rather than smoothed over by a blanket cast.\n const lazyEip1193: EIP1193Provider = {\n on: (event, listener) => {\n const provider = getOrCreateProvider();\n if (event === 'accountsChanged') {\n provider.on('accountsChanged', listener as (a: string[]) => void);\n } else if (event === 'chainChanged') {\n provider.on('chainChanged', listener as (c: string) => void);\n } else {\n provider.on('disconnect', () => (listener as () => void)());\n }\n },\n removeAllListeners: () => cachedProvider?.removeAllListeners(),\n request: <T = unknown>(args: { method: string; params: unknown[] }) =>\n getOrCreateProvider().request(args) as Promise<T>,\n };\n\n return createWalletProviderFromEIP1193Provider(\n {\n displayName: BASE_ACCOUNT_DISPLAY_NAME,\n eip1193: lazyEip1193,\n icon: BASE_ACCOUNT_ICON,\n walletProviderType: WalletProviderEnum.CustodialService,\n },\n client\n );\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerEvmNetworkProviderBuilder } from '../../registerEvmNetworkProviderBuilder';\nimport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';\nimport { createBaseAccountEvmWalletProvider } from '../createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider';\n\nexport const BASE_ACCOUNT_EVM_EXTENSION_KEY = 'baseAccountEvm';\n\n/**\n * Adds Base Account (Coinbase Smart Wallet + EOA via popup/QR) as an available\n * wallet provider for EVM. App metadata (name, logo) and supported network IDs\n * are read from the Dynamic client by default, so no per-call configuration is\n * required for the basic case.\n *\n * The Coinbase Wallet **browser extension** path is already handled by\n * `addEIP6963Extension` and `addEvmWindowInjectedExtension`. This extension\n * fills the gap for users without an injected provider — Smart Wallet popups,\n * mobile EOA via QR/deeplink, and any platform where `window.ethereum` is\n * unavailable.\n *\n * Once installed, apps connect via the generic public lifecycle:\n * `connectWithWalletProvider`, `verifyWalletAccount`,\n * `connectAndVerifyWithWalletProvider`.\n *\n * @param [options] - Optional preference and network ID overrides.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @not-instrumented\n */\nexport const addBaseAccountEvmExtension = (\n options: AddBaseAccountEvmExtensionOptions = {},\n client = getDefaultClient()\n): void => {\n if (hasExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension(\n { extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY },\n client\n );\n registerEvmNetworkProviderBuilder(client);\n\n const walletProvider = createBaseAccountEvmWalletProvider(options, client);\n\n getWalletProviderRegistry(client).register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBaseAccountEvmExtension } from '../baseAccount/addBaseAccountEvmExtension';\nexport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount/baseAccount.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA,MAAa,oBAAoB,yDACf,OAAO,CAAC,QAAkB,YAAY,YAAY;AAChE,KAAI,QAAQ,UAAU,MAAO,QAAO;CACpC,MAAM,YAAY,OAAO,SAAS,QAAQ,WAAW,GAAG;AACxD,KAAI,CAAC,OAAO,SAAS,UAAU,CAAE,QAAO;AACxC,YAAW,KAAK,UAAU;AAC1B,QAAO;GACN,EAAE,CAAC;;;;;;;;;;;;;;;ACCR,MAAa,6BACX,WAC2B;CAC3B,MAAM,kDAAe,OAAO;CAC5B,MAAM,kBAAkB,OAAO,iBAAiB;AAEhD,QAAO;EACL,YACE,KAAK,UAAU,WAAW,iBAAiB,WAAW;EACxD,SAAS,KAAK,UAAU,QAAQ,iBAAiB,eAAe;EACjE;;;;;ACfH,MAAM,4BAA4B;AAClC,MAAM,oBAAoB,GAAGA,wDAA0B;;;;;;;;;;;;;;;;;;AAuBvD,MAAa,sCACX,EAAE,cACF,WACsB;CACtB,IAAIC;CAEJ,MAAM,4BAAoD;AACxD,MAAI,eACF,QAAO;EAET,MAAM,EAAE,SAAS,eAAe,0BAA0B,OAAO;AACjE,+DAAsC;GACpC,aAAa,iBAAiB,OAAO;GACrC;GACA;GACA;GACD,CAAC,CAAC,aAAa;AAChB,SAAO;;AAwBT,QAAOC,wFACL;EACE,aAAa;EACb,SAnBiC;GACnC,KAAK,OAAO,aAAa;IACvB,MAAM,WAAW,qBAAqB;AACtC,QAAI,UAAU,kBACZ,UAAS,GAAG,mBAAmB,SAAkC;aACxD,UAAU,eACnB,UAAS,GAAG,gBAAgB,SAAgC;QAE5D,UAAS,GAAG,oBAAqB,UAAyB,CAAC;;GAG/D,0BAA0B,gBAAgB,oBAAoB;GAC9D,UAAuB,SACrB,qBAAqB,CAAC,QAAQ,KAAK;GACtC;EAMG,MAAM;EACN,oBAAoBC,8CAAmB;EACxC,EACD,OACD;;;;;AC3EH,MAAa,iCAAiC;;;;;;;;;;;;;;;;;;;;;AAsB9C,MAAa,8BACX,UAA6C,EAAE,EAC/C,8DAA2B,KAClB;AACT,qDAAiB,EAAE,cAAc,gCAAgC,EAAE,OAAO,CACxE;AAGF,sDACE,EAAE,cAAc,gCAAgC,EAChD,OACD;AACD,6DAAkC,OAAO;CAEzC,MAAM,iBAAiB,mCAAmC,SAAS,OAAO;AAE1E,8DAA0B,OAAO,CAAC,SAAS;EACzC,UAAUC,qDAAuB;EACjC;EACD,CAAC;;;;;mEC/CiBC,iDAAaC,mDAAe"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { a as version, i as name } from "./createWalletClientForWalletAccount-CC2j8qwa.esm.js";
|
|
2
|
+
import { a as registerEvmNetworkProviderBuilder } from "./evmTransferAmount-jBe-KpYe.esm.js";
|
|
3
|
+
import { t as createWalletProviderFromEIP1193Provider } from "./createWalletProviderFromEIP1193Provider-CfTnRCB0.esm.js";
|
|
4
|
+
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
5
|
+
import { DYNAMIC_ICONIC_SPRITE_URL, WalletProviderPriority, getCore, getDefaultClient, getWalletProviderRegistry, hasExtension, registerExtension } from "@dynamic-labs-sdk/client/core";
|
|
6
|
+
import { getNetworksData } from "@dynamic-labs-sdk/client";
|
|
7
|
+
import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
8
|
+
import { createBaseAccountSDK } from "@base-org/account";
|
|
9
|
+
|
|
10
|
+
//#region src/utils/getEvmNetworkIds/getEvmNetworkIds.ts
|
|
11
|
+
/**
|
|
12
|
+
* Returns the numeric IDs of the EVM networks configured on the Dynamic
|
|
13
|
+
* client. Generic helper available to any EVM extension that needs to
|
|
14
|
+
* advertise the configured chain set to a third-party SDK (e.g. Base
|
|
15
|
+
* Account, WalletConnect).
|
|
16
|
+
*
|
|
17
|
+
* @param client - The Dynamic client whose project settings drive the result.
|
|
18
|
+
* @not-instrumented
|
|
19
|
+
*/
|
|
20
|
+
const getEvmNetworkIds = (client) => getNetworksData(client).reduce((networkIds, network) => {
|
|
21
|
+
if (network.chain !== "EVM") return networkIds;
|
|
22
|
+
const networkId = Number.parseInt(network.networkId, 10);
|
|
23
|
+
if (!Number.isFinite(networkId)) return networkIds;
|
|
24
|
+
networkIds.push(networkId);
|
|
25
|
+
return networkIds;
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts
|
|
30
|
+
/**
|
|
31
|
+
* Reads the customer-supplied app name and logo from the Dynamic client.
|
|
32
|
+
* Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`
|
|
33
|
+
* — preferring `core.metadata` (set on the client) over project-settings fallbacks.
|
|
34
|
+
*
|
|
35
|
+
* Used by the Base Account EVM extension so callers do not have to repeat
|
|
36
|
+
* values they already passed to `createDynamicClient`.
|
|
37
|
+
*
|
|
38
|
+
* @param client - The Dynamic client whose configuration drives the result.
|
|
39
|
+
* @not-instrumented
|
|
40
|
+
*/
|
|
41
|
+
const getBaseAccountAppMetadata = (client) => {
|
|
42
|
+
const core = getCore(client);
|
|
43
|
+
const generalSettings = client.projectSettings?.general;
|
|
44
|
+
return {
|
|
45
|
+
appLogoUrl: core.metadata?.iconUrl ?? generalSettings?.appLogo ?? void 0,
|
|
46
|
+
appName: core.metadata?.name ?? generalSettings?.displayName ?? ""
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts
|
|
52
|
+
const BASE_ACCOUNT_DISPLAY_NAME = "Base Account";
|
|
53
|
+
const BASE_ACCOUNT_ICON = `${DYNAMIC_ICONIC_SPRITE_URL}#base`;
|
|
54
|
+
/**
|
|
55
|
+
* Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally
|
|
56
|
+
* by `addBaseAccountEvmExtension`; not part of the public API.
|
|
57
|
+
*
|
|
58
|
+
* The underlying `@base-org/account` SDK is constructed lazily on the first
|
|
59
|
+
* EIP-1193 call. This avoids reading `client.projectSettings` (via
|
|
60
|
+
* `getEvmNetworkIds`) at extension-registration time — which would throw if
|
|
61
|
+
* the extension is added before `initializeClient` resolves project settings.
|
|
62
|
+
*
|
|
63
|
+
* Classification matches dynamic-auth's mapping for the popup-SDK flow:
|
|
64
|
+
* `WalletProviderEnum.CustodialService`. The browser-extension path is owned
|
|
65
|
+
* by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.
|
|
66
|
+
*
|
|
67
|
+
* @param options - Optional Base Account preference.
|
|
68
|
+
* @param client - The Dynamic client whose metadata + networks drive the SDK.
|
|
69
|
+
* @not-instrumented
|
|
70
|
+
*/
|
|
71
|
+
const createBaseAccountEvmWalletProvider = ({ preference }, client) => {
|
|
72
|
+
let cachedProvider;
|
|
73
|
+
const getOrCreateProvider = () => {
|
|
74
|
+
if (cachedProvider) return cachedProvider;
|
|
75
|
+
const { appName, appLogoUrl } = getBaseAccountAppMetadata(client);
|
|
76
|
+
cachedProvider = createBaseAccountSDK({
|
|
77
|
+
appChainIds: getEvmNetworkIds(client),
|
|
78
|
+
appLogoUrl,
|
|
79
|
+
appName,
|
|
80
|
+
preference
|
|
81
|
+
}).getProvider();
|
|
82
|
+
return cachedProvider;
|
|
83
|
+
};
|
|
84
|
+
return createWalletProviderFromEIP1193Provider({
|
|
85
|
+
displayName: BASE_ACCOUNT_DISPLAY_NAME,
|
|
86
|
+
eip1193: {
|
|
87
|
+
on: (event, listener) => {
|
|
88
|
+
const provider = getOrCreateProvider();
|
|
89
|
+
if (event === "accountsChanged") provider.on("accountsChanged", listener);
|
|
90
|
+
else if (event === "chainChanged") provider.on("chainChanged", listener);
|
|
91
|
+
else provider.on("disconnect", () => listener());
|
|
92
|
+
},
|
|
93
|
+
removeAllListeners: () => cachedProvider?.removeAllListeners(),
|
|
94
|
+
request: (args) => getOrCreateProvider().request(args)
|
|
95
|
+
},
|
|
96
|
+
icon: BASE_ACCOUNT_ICON,
|
|
97
|
+
walletProviderType: WalletProviderEnum.CustodialService
|
|
98
|
+
}, client);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.ts
|
|
103
|
+
const BASE_ACCOUNT_EVM_EXTENSION_KEY = "baseAccountEvm";
|
|
104
|
+
/**
|
|
105
|
+
* Adds Base Account (Coinbase Smart Wallet + EOA via popup/QR) as an available
|
|
106
|
+
* wallet provider for EVM. App metadata (name, logo) and supported network IDs
|
|
107
|
+
* are read from the Dynamic client by default, so no per-call configuration is
|
|
108
|
+
* required for the basic case.
|
|
109
|
+
*
|
|
110
|
+
* The Coinbase Wallet **browser extension** path is already handled by
|
|
111
|
+
* `addEIP6963Extension` and `addEvmWindowInjectedExtension`. This extension
|
|
112
|
+
* fills the gap for users without an injected provider — Smart Wallet popups,
|
|
113
|
+
* mobile EOA via QR/deeplink, and any platform where `window.ethereum` is
|
|
114
|
+
* unavailable.
|
|
115
|
+
*
|
|
116
|
+
* Once installed, apps connect via the generic public lifecycle:
|
|
117
|
+
* `connectWithWalletProvider`, `verifyWalletAccount`,
|
|
118
|
+
* `connectAndVerifyWithWalletProvider`.
|
|
119
|
+
*
|
|
120
|
+
* @param [options] - Optional preference and network ID overrides.
|
|
121
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
122
|
+
* @not-instrumented
|
|
123
|
+
*/
|
|
124
|
+
const addBaseAccountEvmExtension = (options = {}, client = getDefaultClient()) => {
|
|
125
|
+
if (hasExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client)) return;
|
|
126
|
+
registerExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client);
|
|
127
|
+
registerEvmNetworkProviderBuilder(client);
|
|
128
|
+
const walletProvider = createBaseAccountEvmWalletProvider(options, client);
|
|
129
|
+
getWalletProviderRegistry(client).register({
|
|
130
|
+
priority: WalletProviderPriority.WALLET_SDK,
|
|
131
|
+
walletProvider
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/exports/baseAccount.ts
|
|
137
|
+
assertPackageVersion(name, version);
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
export { addBaseAccountEvmExtension };
|
|
141
|
+
//# sourceMappingURL=baseAccount.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseAccount.esm.js","names":["cachedProvider: BaseAccountSDKProvider | undefined","packageName","packageVersion"],"sources":["../src/utils/getEvmNetworkIds/getEvmNetworkIds.ts","../src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts","../src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts","../src/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.ts","../src/exports/baseAccount.ts"],"sourcesContent":["import { type DynamicClient, getNetworksData } from '@dynamic-labs-sdk/client';\n\n/**\n * Returns the numeric IDs of the EVM networks configured on the Dynamic\n * client. Generic helper available to any EVM extension that needs to\n * advertise the configured chain set to a third-party SDK (e.g. Base\n * Account, WalletConnect).\n *\n * @param client - The Dynamic client whose project settings drive the result.\n * @not-instrumented\n */\nexport const getEvmNetworkIds = (client: DynamicClient): number[] =>\n getNetworksData(client).reduce<number[]>((networkIds, network) => {\n if (network.chain !== 'EVM') return networkIds;\n const networkId = Number.parseInt(network.networkId, 10);\n if (!Number.isFinite(networkId)) return networkIds;\n networkIds.push(networkId);\n return networkIds;\n }, []);\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\ntype BaseAccountAppMetadata = {\n appLogoUrl: string | undefined;\n appName: string;\n};\n\n/**\n * Reads the customer-supplied app name and logo from the Dynamic client.\n * Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`\n * — preferring `core.metadata` (set on the client) over project-settings fallbacks.\n *\n * Used by the Base Account EVM extension so callers do not have to repeat\n * values they already passed to `createDynamicClient`.\n *\n * @param client - The Dynamic client whose configuration drives the result.\n * @not-instrumented\n */\nexport const getBaseAccountAppMetadata = (\n client: DynamicClient\n): BaseAccountAppMetadata => {\n const core = getCore(client);\n const generalSettings = client.projectSettings?.general;\n\n return {\n appLogoUrl:\n core.metadata?.iconUrl ?? generalSettings?.appLogo ?? undefined,\n appName: core.metadata?.name ?? generalSettings?.displayName ?? '',\n };\n};\n","import { createBaseAccountSDK } from '@base-org/account';\nimport type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { DYNAMIC_ICONIC_SPRITE_URL } from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type {\n EIP1193Provider,\n EvmWalletProvider,\n} from '../../EvmWalletProvider.types';\nimport { createWalletProviderFromEIP1193Provider } from '../../utils/createWalletProviderFromEIP1193Provider';\nimport { getEvmNetworkIds } from '../../utils/getEvmNetworkIds/getEvmNetworkIds';\nimport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';\nimport { getBaseAccountAppMetadata } from '../utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata';\n\nconst BASE_ACCOUNT_DISPLAY_NAME = 'Base Account';\nconst BASE_ACCOUNT_ICON = `${DYNAMIC_ICONIC_SPRITE_URL}#base`;\n\ntype BaseAccountSDKProvider = ReturnType<\n ReturnType<typeof createBaseAccountSDK>['getProvider']\n>;\n\n/**\n * Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally\n * by `addBaseAccountEvmExtension`; not part of the public API.\n *\n * The underlying `@base-org/account` SDK is constructed lazily on the first\n * EIP-1193 call. This avoids reading `client.projectSettings` (via\n * `getEvmNetworkIds`) at extension-registration time — which would throw if\n * the extension is added before `initializeClient` resolves project settings.\n *\n * Classification matches dynamic-auth's mapping for the popup-SDK flow:\n * `WalletProviderEnum.CustodialService`. The browser-extension path is owned\n * by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.\n *\n * @param options - Optional Base Account preference.\n * @param client - The Dynamic client whose metadata + networks drive the SDK.\n * @not-instrumented\n */\nexport const createBaseAccountEvmWalletProvider = (\n { preference }: AddBaseAccountEvmExtensionOptions,\n client: DynamicClient\n): EvmWalletProvider => {\n let cachedProvider: BaseAccountSDKProvider | undefined;\n\n const getOrCreateProvider = (): BaseAccountSDKProvider => {\n if (cachedProvider) {\n return cachedProvider;\n }\n const { appName, appLogoUrl } = getBaseAccountAppMetadata(client);\n cachedProvider = createBaseAccountSDK({\n appChainIds: getEvmNetworkIds(client),\n appLogoUrl,\n appName,\n preference,\n }).getProvider();\n return cachedProvider;\n };\n\n // EIP-1193 façade that defers SDK construction until first interaction and\n // bridges the two `on` event vocabularies — `@base-org/account` emits the\n // canonical `disconnect`, while our local `EIP1193Provider` consumer expects\n // `disconnected`. We forward each event explicitly so the divergence is\n // visible in source rather than smoothed over by a blanket cast.\n const lazyEip1193: EIP1193Provider = {\n on: (event, listener) => {\n const provider = getOrCreateProvider();\n if (event === 'accountsChanged') {\n provider.on('accountsChanged', listener as (a: string[]) => void);\n } else if (event === 'chainChanged') {\n provider.on('chainChanged', listener as (c: string) => void);\n } else {\n provider.on('disconnect', () => (listener as () => void)());\n }\n },\n removeAllListeners: () => cachedProvider?.removeAllListeners(),\n request: <T = unknown>(args: { method: string; params: unknown[] }) =>\n getOrCreateProvider().request(args) as Promise<T>,\n };\n\n return createWalletProviderFromEIP1193Provider(\n {\n displayName: BASE_ACCOUNT_DISPLAY_NAME,\n eip1193: lazyEip1193,\n icon: BASE_ACCOUNT_ICON,\n walletProviderType: WalletProviderEnum.CustodialService,\n },\n client\n );\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerEvmNetworkProviderBuilder } from '../../registerEvmNetworkProviderBuilder';\nimport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';\nimport { createBaseAccountEvmWalletProvider } from '../createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider';\n\nexport const BASE_ACCOUNT_EVM_EXTENSION_KEY = 'baseAccountEvm';\n\n/**\n * Adds Base Account (Coinbase Smart Wallet + EOA via popup/QR) as an available\n * wallet provider for EVM. App metadata (name, logo) and supported network IDs\n * are read from the Dynamic client by default, so no per-call configuration is\n * required for the basic case.\n *\n * The Coinbase Wallet **browser extension** path is already handled by\n * `addEIP6963Extension` and `addEvmWindowInjectedExtension`. This extension\n * fills the gap for users without an injected provider — Smart Wallet popups,\n * mobile EOA via QR/deeplink, and any platform where `window.ethereum` is\n * unavailable.\n *\n * Once installed, apps connect via the generic public lifecycle:\n * `connectWithWalletProvider`, `verifyWalletAccount`,\n * `connectAndVerifyWithWalletProvider`.\n *\n * @param [options] - Optional preference and network ID overrides.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @not-instrumented\n */\nexport const addBaseAccountEvmExtension = (\n options: AddBaseAccountEvmExtensionOptions = {},\n client = getDefaultClient()\n): void => {\n if (hasExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension(\n { extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY },\n client\n );\n registerEvmNetworkProviderBuilder(client);\n\n const walletProvider = createBaseAccountEvmWalletProvider(options, client);\n\n getWalletProviderRegistry(client).register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBaseAccountEvmExtension } from '../baseAccount/addBaseAccountEvmExtension';\nexport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount/baseAccount.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAWA,MAAa,oBAAoB,WAC/B,gBAAgB,OAAO,CAAC,QAAkB,YAAY,YAAY;AAChE,KAAI,QAAQ,UAAU,MAAO,QAAO;CACpC,MAAM,YAAY,OAAO,SAAS,QAAQ,WAAW,GAAG;AACxD,KAAI,CAAC,OAAO,SAAS,UAAU,CAAE,QAAO;AACxC,YAAW,KAAK,UAAU;AAC1B,QAAO;GACN,EAAE,CAAC;;;;;;;;;;;;;;;ACCR,MAAa,6BACX,WAC2B;CAC3B,MAAM,OAAO,QAAQ,OAAO;CAC5B,MAAM,kBAAkB,OAAO,iBAAiB;AAEhD,QAAO;EACL,YACE,KAAK,UAAU,WAAW,iBAAiB,WAAW;EACxD,SAAS,KAAK,UAAU,QAAQ,iBAAiB,eAAe;EACjE;;;;;ACfH,MAAM,4BAA4B;AAClC,MAAM,oBAAoB,GAAG,0BAA0B;;;;;;;;;;;;;;;;;;AAuBvD,MAAa,sCACX,EAAE,cACF,WACsB;CACtB,IAAIA;CAEJ,MAAM,4BAAoD;AACxD,MAAI,eACF,QAAO;EAET,MAAM,EAAE,SAAS,eAAe,0BAA0B,OAAO;AACjE,mBAAiB,qBAAqB;GACpC,aAAa,iBAAiB,OAAO;GACrC;GACA;GACA;GACD,CAAC,CAAC,aAAa;AAChB,SAAO;;AAwBT,QAAO,wCACL;EACE,aAAa;EACb,SAnBiC;GACnC,KAAK,OAAO,aAAa;IACvB,MAAM,WAAW,qBAAqB;AACtC,QAAI,UAAU,kBACZ,UAAS,GAAG,mBAAmB,SAAkC;aACxD,UAAU,eACnB,UAAS,GAAG,gBAAgB,SAAgC;QAE5D,UAAS,GAAG,oBAAqB,UAAyB,CAAC;;GAG/D,0BAA0B,gBAAgB,oBAAoB;GAC9D,UAAuB,SACrB,qBAAqB,CAAC,QAAQ,KAAK;GACtC;EAMG,MAAM;EACN,oBAAoB,mBAAmB;EACxC,EACD,OACD;;;;;AC3EH,MAAa,iCAAiC;;;;;;;;;;;;;;;;;;;;;AAsB9C,MAAa,8BACX,UAA6C,EAAE,EAC/C,SAAS,kBAAkB,KAClB;AACT,KAAI,aAAa,EAAE,cAAc,gCAAgC,EAAE,OAAO,CACxE;AAGF,mBACE,EAAE,cAAc,gCAAgC,EAChD,OACD;AACD,mCAAkC,OAAO;CAEzC,MAAM,iBAAiB,mCAAmC,SAAS,OAAO;AAE1E,2BAA0B,OAAO,CAAC,SAAS;EACzC,UAAU,uBAAuB;EACjC;EACD,CAAC;;;;;AC/CJ,qBAAqBC,MAAaC,QAAe"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { n as version, t as name } from "./package-CAxC7ycE.native.esm.js";
|
|
2
|
+
import { a as registerEvmNetworkProviderBuilder } from "./evmTransferAmount-B__79nVn.native.esm.js";
|
|
3
|
+
import "./createWalletClientForWalletAccount-V4CfRjd4.native.esm.js";
|
|
4
|
+
import { t as createWalletProviderFromEIP1193Provider } from "./createWalletProviderFromEIP1193Provider-RVjz6Jte.native.esm.js";
|
|
5
|
+
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
6
|
+
import { DYNAMIC_ICONIC_SPRITE_URL, WalletProviderPriority, getCore, getDefaultClient, getWalletProviderRegistry, hasExtension, registerExtension } from "@dynamic-labs-sdk/client/core";
|
|
7
|
+
import { getNetworksData } from "@dynamic-labs-sdk/client";
|
|
8
|
+
import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
9
|
+
import { createBaseAccountSDK } from "@base-org/account";
|
|
10
|
+
|
|
11
|
+
//#region src/utils/getEvmNetworkIds/getEvmNetworkIds.ts
|
|
12
|
+
/**
|
|
13
|
+
* Returns the numeric IDs of the EVM networks configured on the Dynamic
|
|
14
|
+
* client. Generic helper available to any EVM extension that needs to
|
|
15
|
+
* advertise the configured chain set to a third-party SDK (e.g. Base
|
|
16
|
+
* Account, WalletConnect).
|
|
17
|
+
*
|
|
18
|
+
* @param client - The Dynamic client whose project settings drive the result.
|
|
19
|
+
* @not-instrumented
|
|
20
|
+
*/
|
|
21
|
+
const getEvmNetworkIds = (client) => getNetworksData(client).reduce((networkIds, network) => {
|
|
22
|
+
if (network.chain !== "EVM") return networkIds;
|
|
23
|
+
const networkId = Number.parseInt(network.networkId, 10);
|
|
24
|
+
if (!Number.isFinite(networkId)) return networkIds;
|
|
25
|
+
networkIds.push(networkId);
|
|
26
|
+
return networkIds;
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts
|
|
31
|
+
/**
|
|
32
|
+
* Reads the customer-supplied app name and logo from the Dynamic client.
|
|
33
|
+
* Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`
|
|
34
|
+
* — preferring `core.metadata` (set on the client) over project-settings fallbacks.
|
|
35
|
+
*
|
|
36
|
+
* Used by the Base Account EVM extension so callers do not have to repeat
|
|
37
|
+
* values they already passed to `createDynamicClient`.
|
|
38
|
+
*
|
|
39
|
+
* @param client - The Dynamic client whose configuration drives the result.
|
|
40
|
+
* @not-instrumented
|
|
41
|
+
*/
|
|
42
|
+
const getBaseAccountAppMetadata = (client) => {
|
|
43
|
+
const core = getCore(client);
|
|
44
|
+
const generalSettings = client.projectSettings?.general;
|
|
45
|
+
return {
|
|
46
|
+
appLogoUrl: core.metadata?.iconUrl ?? generalSettings?.appLogo ?? void 0,
|
|
47
|
+
appName: core.metadata?.name ?? generalSettings?.displayName ?? ""
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts
|
|
53
|
+
const BASE_ACCOUNT_DISPLAY_NAME = "Base Account";
|
|
54
|
+
const BASE_ACCOUNT_ICON = `${DYNAMIC_ICONIC_SPRITE_URL}#base`;
|
|
55
|
+
/**
|
|
56
|
+
* Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally
|
|
57
|
+
* by `addBaseAccountEvmExtension`; not part of the public API.
|
|
58
|
+
*
|
|
59
|
+
* The underlying `@base-org/account` SDK is constructed lazily on the first
|
|
60
|
+
* EIP-1193 call. This avoids reading `client.projectSettings` (via
|
|
61
|
+
* `getEvmNetworkIds`) at extension-registration time — which would throw if
|
|
62
|
+
* the extension is added before `initializeClient` resolves project settings.
|
|
63
|
+
*
|
|
64
|
+
* Classification matches dynamic-auth's mapping for the popup-SDK flow:
|
|
65
|
+
* `WalletProviderEnum.CustodialService`. The browser-extension path is owned
|
|
66
|
+
* by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.
|
|
67
|
+
*
|
|
68
|
+
* @param options - Optional Base Account preference.
|
|
69
|
+
* @param client - The Dynamic client whose metadata + networks drive the SDK.
|
|
70
|
+
* @not-instrumented
|
|
71
|
+
*/
|
|
72
|
+
const createBaseAccountEvmWalletProvider = ({ preference }, client) => {
|
|
73
|
+
let cachedProvider;
|
|
74
|
+
const getOrCreateProvider = () => {
|
|
75
|
+
if (cachedProvider) return cachedProvider;
|
|
76
|
+
const { appName, appLogoUrl } = getBaseAccountAppMetadata(client);
|
|
77
|
+
cachedProvider = createBaseAccountSDK({
|
|
78
|
+
appChainIds: getEvmNetworkIds(client),
|
|
79
|
+
appLogoUrl,
|
|
80
|
+
appName,
|
|
81
|
+
preference
|
|
82
|
+
}).getProvider();
|
|
83
|
+
return cachedProvider;
|
|
84
|
+
};
|
|
85
|
+
return createWalletProviderFromEIP1193Provider({
|
|
86
|
+
displayName: BASE_ACCOUNT_DISPLAY_NAME,
|
|
87
|
+
eip1193: {
|
|
88
|
+
on: (event, listener) => {
|
|
89
|
+
const provider = getOrCreateProvider();
|
|
90
|
+
if (event === "accountsChanged") provider.on("accountsChanged", listener);
|
|
91
|
+
else if (event === "chainChanged") provider.on("chainChanged", listener);
|
|
92
|
+
else provider.on("disconnect", () => listener());
|
|
93
|
+
},
|
|
94
|
+
removeAllListeners: () => cachedProvider?.removeAllListeners(),
|
|
95
|
+
request: (args) => getOrCreateProvider().request(args)
|
|
96
|
+
},
|
|
97
|
+
icon: BASE_ACCOUNT_ICON,
|
|
98
|
+
walletProviderType: WalletProviderEnum.CustodialService
|
|
99
|
+
}, client);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.ts
|
|
104
|
+
const BASE_ACCOUNT_EVM_EXTENSION_KEY = "baseAccountEvm";
|
|
105
|
+
/**
|
|
106
|
+
* Adds Base Account (Coinbase Smart Wallet + EOA via popup/QR) as an available
|
|
107
|
+
* wallet provider for EVM. App metadata (name, logo) and supported network IDs
|
|
108
|
+
* are read from the Dynamic client by default, so no per-call configuration is
|
|
109
|
+
* required for the basic case.
|
|
110
|
+
*
|
|
111
|
+
* The Coinbase Wallet **browser extension** path is already handled by
|
|
112
|
+
* `addEIP6963Extension` and `addEvmWindowInjectedExtension`. This extension
|
|
113
|
+
* fills the gap for users without an injected provider — Smart Wallet popups,
|
|
114
|
+
* mobile EOA via QR/deeplink, and any platform where `window.ethereum` is
|
|
115
|
+
* unavailable.
|
|
116
|
+
*
|
|
117
|
+
* Once installed, apps connect via the generic public lifecycle:
|
|
118
|
+
* `connectWithWalletProvider`, `verifyWalletAccount`,
|
|
119
|
+
* `connectAndVerifyWithWalletProvider`.
|
|
120
|
+
*
|
|
121
|
+
* @param [options] - Optional preference and network ID overrides.
|
|
122
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
123
|
+
* @not-instrumented
|
|
124
|
+
*/
|
|
125
|
+
const addBaseAccountEvmExtension = (options = {}, client = getDefaultClient()) => {
|
|
126
|
+
if (hasExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client)) return;
|
|
127
|
+
registerExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client);
|
|
128
|
+
registerEvmNetworkProviderBuilder(client);
|
|
129
|
+
const walletProvider = createBaseAccountEvmWalletProvider(options, client);
|
|
130
|
+
getWalletProviderRegistry(client).register({
|
|
131
|
+
priority: WalletProviderPriority.WALLET_SDK,
|
|
132
|
+
walletProvider
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/exports/baseAccount.ts
|
|
138
|
+
assertPackageVersion(name, version);
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
export { addBaseAccountEvmExtension };
|
|
142
|
+
//# sourceMappingURL=baseAccount.native.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseAccount.native.esm.js","names":["cachedProvider: BaseAccountSDKProvider | undefined","packageName","packageVersion"],"sources":["../src/utils/getEvmNetworkIds/getEvmNetworkIds.ts","../src/baseAccount/utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata.ts","../src/baseAccount/createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider.ts","../src/baseAccount/addBaseAccountEvmExtension/addBaseAccountEvmExtension.ts","../src/exports/baseAccount.ts"],"sourcesContent":["import { type DynamicClient, getNetworksData } from '@dynamic-labs-sdk/client';\n\n/**\n * Returns the numeric IDs of the EVM networks configured on the Dynamic\n * client. Generic helper available to any EVM extension that needs to\n * advertise the configured chain set to a third-party SDK (e.g. Base\n * Account, WalletConnect).\n *\n * @param client - The Dynamic client whose project settings drive the result.\n * @not-instrumented\n */\nexport const getEvmNetworkIds = (client: DynamicClient): number[] =>\n getNetworksData(client).reduce<number[]>((networkIds, network) => {\n if (network.chain !== 'EVM') return networkIds;\n const networkId = Number.parseInt(network.networkId, 10);\n if (!Number.isFinite(networkId)) return networkIds;\n networkIds.push(networkId);\n return networkIds;\n }, []);\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { getCore } from '@dynamic-labs-sdk/client/core';\n\ntype BaseAccountAppMetadata = {\n appLogoUrl: string | undefined;\n appName: string;\n};\n\n/**\n * Reads the customer-supplied app name and logo from the Dynamic client.\n * Mirrors the lookup used by `createSignClient` in `@dynamic-labs-sdk/wallet-connect`\n * — preferring `core.metadata` (set on the client) over project-settings fallbacks.\n *\n * Used by the Base Account EVM extension so callers do not have to repeat\n * values they already passed to `createDynamicClient`.\n *\n * @param client - The Dynamic client whose configuration drives the result.\n * @not-instrumented\n */\nexport const getBaseAccountAppMetadata = (\n client: DynamicClient\n): BaseAccountAppMetadata => {\n const core = getCore(client);\n const generalSettings = client.projectSettings?.general;\n\n return {\n appLogoUrl:\n core.metadata?.iconUrl ?? generalSettings?.appLogo ?? undefined,\n appName: core.metadata?.name ?? generalSettings?.displayName ?? '',\n };\n};\n","import { createBaseAccountSDK } from '@base-org/account';\nimport type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport { DYNAMIC_ICONIC_SPRITE_URL } from '@dynamic-labs-sdk/client/core';\nimport { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type {\n EIP1193Provider,\n EvmWalletProvider,\n} from '../../EvmWalletProvider.types';\nimport { createWalletProviderFromEIP1193Provider } from '../../utils/createWalletProviderFromEIP1193Provider';\nimport { getEvmNetworkIds } from '../../utils/getEvmNetworkIds/getEvmNetworkIds';\nimport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';\nimport { getBaseAccountAppMetadata } from '../utils/getBaseAccountAppMetadata/getBaseAccountAppMetadata';\n\nconst BASE_ACCOUNT_DISPLAY_NAME = 'Base Account';\nconst BASE_ACCOUNT_ICON = `${DYNAMIC_ICONIC_SPRITE_URL}#base`;\n\ntype BaseAccountSDKProvider = ReturnType<\n ReturnType<typeof createBaseAccountSDK>['getProvider']\n>;\n\n/**\n * Builds an `EvmWalletProvider` backed by `@base-org/account`. Used internally\n * by `addBaseAccountEvmExtension`; not part of the public API.\n *\n * The underlying `@base-org/account` SDK is constructed lazily on the first\n * EIP-1193 call. This avoids reading `client.projectSettings` (via\n * `getEvmNetworkIds`) at extension-registration time — which would throw if\n * the extension is added before `initializeClient` resolves project settings.\n *\n * Classification matches dynamic-auth's mapping for the popup-SDK flow:\n * `WalletProviderEnum.CustodialService`. The browser-extension path is owned\n * by `addEIP6963Extension` / `addEvmWindowInjectedExtension`.\n *\n * @param options - Optional Base Account preference.\n * @param client - The Dynamic client whose metadata + networks drive the SDK.\n * @not-instrumented\n */\nexport const createBaseAccountEvmWalletProvider = (\n { preference }: AddBaseAccountEvmExtensionOptions,\n client: DynamicClient\n): EvmWalletProvider => {\n let cachedProvider: BaseAccountSDKProvider | undefined;\n\n const getOrCreateProvider = (): BaseAccountSDKProvider => {\n if (cachedProvider) {\n return cachedProvider;\n }\n const { appName, appLogoUrl } = getBaseAccountAppMetadata(client);\n cachedProvider = createBaseAccountSDK({\n appChainIds: getEvmNetworkIds(client),\n appLogoUrl,\n appName,\n preference,\n }).getProvider();\n return cachedProvider;\n };\n\n // EIP-1193 façade that defers SDK construction until first interaction and\n // bridges the two `on` event vocabularies — `@base-org/account` emits the\n // canonical `disconnect`, while our local `EIP1193Provider` consumer expects\n // `disconnected`. We forward each event explicitly so the divergence is\n // visible in source rather than smoothed over by a blanket cast.\n const lazyEip1193: EIP1193Provider = {\n on: (event, listener) => {\n const provider = getOrCreateProvider();\n if (event === 'accountsChanged') {\n provider.on('accountsChanged', listener as (a: string[]) => void);\n } else if (event === 'chainChanged') {\n provider.on('chainChanged', listener as (c: string) => void);\n } else {\n provider.on('disconnect', () => (listener as () => void)());\n }\n },\n removeAllListeners: () => cachedProvider?.removeAllListeners(),\n request: <T = unknown>(args: { method: string; params: unknown[] }) =>\n getOrCreateProvider().request(args) as Promise<T>,\n };\n\n return createWalletProviderFromEIP1193Provider(\n {\n displayName: BASE_ACCOUNT_DISPLAY_NAME,\n eip1193: lazyEip1193,\n icon: BASE_ACCOUNT_ICON,\n walletProviderType: WalletProviderEnum.CustodialService,\n },\n client\n );\n};\n","import {\n WalletProviderPriority,\n getDefaultClient,\n getWalletProviderRegistry,\n hasExtension,\n registerExtension,\n} from '@dynamic-labs-sdk/client/core';\n\nimport { registerEvmNetworkProviderBuilder } from '../../registerEvmNetworkProviderBuilder';\nimport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount.types';\nimport { createBaseAccountEvmWalletProvider } from '../createBaseAccountEvmWalletProvider/createBaseAccountEvmWalletProvider';\n\nexport const BASE_ACCOUNT_EVM_EXTENSION_KEY = 'baseAccountEvm';\n\n/**\n * Adds Base Account (Coinbase Smart Wallet + EOA via popup/QR) as an available\n * wallet provider for EVM. App metadata (name, logo) and supported network IDs\n * are read from the Dynamic client by default, so no per-call configuration is\n * required for the basic case.\n *\n * The Coinbase Wallet **browser extension** path is already handled by\n * `addEIP6963Extension` and `addEvmWindowInjectedExtension`. This extension\n * fills the gap for users without an injected provider — Smart Wallet popups,\n * mobile EOA via QR/deeplink, and any platform where `window.ethereum` is\n * unavailable.\n *\n * Once installed, apps connect via the generic public lifecycle:\n * `connectWithWalletProvider`, `verifyWalletAccount`,\n * `connectAndVerifyWithWalletProvider`.\n *\n * @param [options] - Optional preference and network ID overrides.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @not-instrumented\n */\nexport const addBaseAccountEvmExtension = (\n options: AddBaseAccountEvmExtensionOptions = {},\n client = getDefaultClient()\n): void => {\n if (hasExtension({ extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY }, client)) {\n return;\n }\n\n registerExtension(\n { extensionKey: BASE_ACCOUNT_EVM_EXTENSION_KEY },\n client\n );\n registerEvmNetworkProviderBuilder(client);\n\n const walletProvider = createBaseAccountEvmWalletProvider(options, client);\n\n getWalletProviderRegistry(client).register({\n priority: WalletProviderPriority.WALLET_SDK,\n walletProvider,\n });\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { addBaseAccountEvmExtension } from '../baseAccount/addBaseAccountEvmExtension';\nexport type { AddBaseAccountEvmExtensionOptions } from '../baseAccount/baseAccount.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAWA,MAAa,oBAAoB,WAC/B,gBAAgB,OAAO,CAAC,QAAkB,YAAY,YAAY;AAChE,KAAI,QAAQ,UAAU,MAAO,QAAO;CACpC,MAAM,YAAY,OAAO,SAAS,QAAQ,WAAW,GAAG;AACxD,KAAI,CAAC,OAAO,SAAS,UAAU,CAAE,QAAO;AACxC,YAAW,KAAK,UAAU;AAC1B,QAAO;GACN,EAAE,CAAC;;;;;;;;;;;;;;;ACCR,MAAa,6BACX,WAC2B;CAC3B,MAAM,OAAO,QAAQ,OAAO;CAC5B,MAAM,kBAAkB,OAAO,iBAAiB;AAEhD,QAAO;EACL,YACE,KAAK,UAAU,WAAW,iBAAiB,WAAW;EACxD,SAAS,KAAK,UAAU,QAAQ,iBAAiB,eAAe;EACjE;;;;;ACfH,MAAM,4BAA4B;AAClC,MAAM,oBAAoB,GAAG,0BAA0B;;;;;;;;;;;;;;;;;;AAuBvD,MAAa,sCACX,EAAE,cACF,WACsB;CACtB,IAAIA;CAEJ,MAAM,4BAAoD;AACxD,MAAI,eACF,QAAO;EAET,MAAM,EAAE,SAAS,eAAe,0BAA0B,OAAO;AACjE,mBAAiB,qBAAqB;GACpC,aAAa,iBAAiB,OAAO;GACrC;GACA;GACA;GACD,CAAC,CAAC,aAAa;AAChB,SAAO;;AAwBT,QAAO,wCACL;EACE,aAAa;EACb,SAnBiC;GACnC,KAAK,OAAO,aAAa;IACvB,MAAM,WAAW,qBAAqB;AACtC,QAAI,UAAU,kBACZ,UAAS,GAAG,mBAAmB,SAAkC;aACxD,UAAU,eACnB,UAAS,GAAG,gBAAgB,SAAgC;QAE5D,UAAS,GAAG,oBAAqB,UAAyB,CAAC;;GAG/D,0BAA0B,gBAAgB,oBAAoB;GAC9D,UAAuB,SACrB,qBAAqB,CAAC,QAAQ,KAAK;GACtC;EAMG,MAAM;EACN,oBAAoB,mBAAmB;EACxC,EACD,OACD;;;;;AC3EH,MAAa,iCAAiC;;;;;;;;;;;;;;;;;;;;;AAsB9C,MAAa,8BACX,UAA6C,EAAE,EAC/C,SAAS,kBAAkB,KAClB;AACT,KAAI,aAAa,EAAE,cAAc,gCAAgC,EAAE,OAAO,CACxE;AAGF,mBACE,EAAE,cAAc,gCAAgC,EAChD,OACD;AACD,mCAAkC,OAAO;CAEzC,MAAM,iBAAiB,mCAAmC,SAAS,OAAO;AAE1E,2BAA0B,OAAO,CAAC,SAAS;EACzC,UAAU,uBAAuB;EACjC;EACD,CAAC;;;;;AC/CJ,qBAAqBC,MAAaC,QAAe"}
|
|
@@ -5,7 +5,7 @@ let viem_accounts = require("viem/accounts");
|
|
|
5
5
|
|
|
6
6
|
//#region package.json
|
|
7
7
|
var name = "@dynamic-labs-sdk/evm";
|
|
8
|
-
var version = "0.26.
|
|
8
|
+
var version = "0.26.7";
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/viem/utils/mapNetworkDataToViemChain/mapNetworkDataToViemChain.ts
|
|
@@ -131,4 +131,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
131
131
|
return version;
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
//# sourceMappingURL=createWalletClientForWalletAccount-
|
|
134
|
+
//# sourceMappingURL=createWalletClientForWalletAccount-CBDDVIYV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWalletClientForWalletAccount-
|
|
1
|
+
{"version":3,"file":"createWalletClientForWalletAccount-CBDDVIYV.cjs","names":["InvalidParamError"],"sources":["../package.json","../src/viem/utils/mapNetworkDataToViemChain/mapNetworkDataToViemChain.ts","../src/viem/createPublicClientFromNetworkData/createPublicClientFromNetworkData.ts","../src/isEvmWalletProvider/isEvmWalletProvider.ts","../src/utils/isEIP1193Provider/isEIP1193Provider.ts","../src/viem/utils/walletProviderHasCustomWalletClient/isEvmWalletProviderWithCustomViemClient.ts","../src/viem/createWalletClientForWalletAccount/createWalletClientForWalletAccount.ts"],"sourcesContent":["","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport type { Chain } from 'viem';\n\n/**\n * Created a viem Chain object from a NetworkData object.\n * @not-instrumented\n */\nexport const mapNetworkDataToViemChain = (networkData: NetworkData): Chain => ({\n blockExplorers: networkData.blockExplorerUrls?.[0]\n ? {\n default: {\n name: networkData.blockExplorerUrls[0],\n url: networkData.blockExplorerUrls[0],\n },\n }\n : undefined,\n id: Number(networkData.networkId),\n name: networkData.displayName,\n nativeCurrency: networkData.nativeCurrency,\n rpcUrls: {\n default: { http: networkData.rpcUrls.http },\n },\n});\n","import type { NetworkData } from '@dynamic-labs-sdk/client';\nimport type {\n Chain,\n HttpTransport,\n HttpTransportConfig,\n PublicClient,\n PublicClientConfig,\n} from 'viem';\nimport { createPublicClient, http } from 'viem';\n\nimport { mapNetworkDataToViemChain } from '../utils/mapNetworkDataToViemChain';\n\ntype CreatePublicClientFromNetworkDataProps = {\n httpTransportConfig?: HttpTransportConfig;\n networkData: NetworkData;\n publicClientConfig?: Partial<PublicClientConfig<HttpTransport, Chain>>;\n};\n\n/**\n * Creates a viem PublicClient from a given NetworkData object.\n *\n * This function configures a viem PublicClient instance for reading data from\n * an EVM-compatible blockchain using the network provider's RPC endpoint.\n *\n * @param props - The configuration object.\n * @param props.networkData - The NetworkData object containing network configuration.\n * @param props.publicClientConfig - Optional additional configuration for the viem PublicClient.\n * @param props.httpTransportConfig - Optional HTTP transport configuration.\n * @returns A configured viem PublicClient instance.\n * @not-instrumented\n */\nexport const createPublicClientFromNetworkData = ({\n networkData,\n publicClientConfig = {},\n httpTransportConfig = {},\n}: CreatePublicClientFromNetworkDataProps): PublicClient<\n HttpTransport,\n Chain\n> =>\n createPublicClient({\n chain: mapNetworkDataToViemChain(networkData),\n transport: http(networkData.rpcUrls.http[0], httpTransportConfig),\n ...publicClientConfig,\n });\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { EvmWalletProvider } from '../EvmWalletProvider.types';\n\n/** @not-instrumented */\nexport const isEvmWalletProvider = (\n walletProvider: WalletProvider\n): walletProvider is EvmWalletProvider => walletProvider.chain === 'EVM';\n","import type { EIP1193Provider } from '../../EvmWalletProvider.types';\n\n/** @not-instrumented */\nexport const isEIP1193Provider = <T>(\n provider: T\n): provider is EIP1193Provider & T => {\n return (\n provider !== null &&\n provider !== undefined &&\n typeof provider === 'object' &&\n 'request' in provider &&\n typeof provider.request === 'function'\n );\n};\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { EvmWalletProviderWithCustomViemClient } from '../../EvmWalletProviderWithCustomViemClient.types';\n\n/** @not-instrumented */\nexport const isEvmWalletProviderWithCustomViemClient = (\n walletProvider: WalletProvider\n): walletProvider is EvmWalletProviderWithCustomViemClient => {\n return 'createViemWalletClient' in walletProvider;\n};\n","import {\n InvalidParamError,\n getActiveNetworkData,\n} from '@dynamic-labs-sdk/client';\nimport {\n assertDefined,\n getDefaultClient,\n getWalletProviderFromWalletAccount,\n} from '@dynamic-labs-sdk/client/core';\nimport type {\n Account,\n Chain,\n Hex,\n HttpTransportConfig,\n Transport,\n WalletClient,\n WalletClientConfig,\n} from 'viem';\nimport { createWalletClient, custom } from 'viem';\nimport { toAccount } from 'viem/accounts';\n\nimport type { EvmWalletAccount } from '../../EvmWalletAccount.types';\nimport { isEvmWalletProvider } from '../../isEvmWalletProvider';\nimport { isEIP1193Provider } from '../../utils/isEIP1193Provider';\nimport { mapNetworkDataToViemChain } from '../utils/mapNetworkDataToViemChain';\nimport { isEvmWalletProviderWithCustomViemClient } from '../utils/walletProviderHasCustomWalletClient';\n\ntype CreateWalletClientForWalletAccountProps = {\n httpTransportConfig?: HttpTransportConfig;\n walletAccount: EvmWalletAccount;\n walletClientConfig?: Omit<\n WalletClientConfig,\n 'account' | 'chain' | 'transport'\n >;\n};\n\n/**\n * Creates a viem WalletClient from an EVM WalletAccount object.\n *\n * This function configures a viem WalletClient instance for sending transactions\n * and signing messages using the specified wallet account. It automatically\n * handles network configuration and transport setup.\n *\n * @param props - The configuration object.\n * @param props.walletAccount - The EVM wallet account to create the client for.\n * @param [props.walletClientConfig] - Optional additional configuration for the viem WalletClient.\n * @param [props.httpTransportConfig] - Optional HTTP transport configuration.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to a configured viem WalletClient instance.\n * @not-instrumented\n */\nexport const createWalletClientForWalletAccount = async (\n {\n walletAccount,\n walletClientConfig = {},\n httpTransportConfig = {},\n }: CreateWalletClientForWalletAccountProps,\n client = getDefaultClient()\n): Promise<WalletClient<Transport, Chain, Account>> => {\n const walletProvider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isEvmWalletProvider(walletProvider)) {\n throw new InvalidParamError(\n `${walletAccount.address} is not an EVM wallet account`\n );\n }\n\n if (isEvmWalletProviderWithCustomViemClient(walletProvider)) {\n return walletProvider.createViemWalletClient({\n httpTransportConfig,\n viemWalletClientConfig: walletClientConfig,\n walletAccount,\n });\n }\n\n const { networkData: activeNetworkData } = await getActiveNetworkData(\n { walletAccount },\n client\n );\n\n assertDefined(\n activeNetworkData,\n `No network data found for wallet account ${walletAccount.address}`\n );\n\n if (!isEIP1193Provider(walletProvider)) {\n throw new InvalidParamError(\n 'Wallet provider does not implement the EIP1193Provider interface'\n );\n }\n\n return createWalletClient({\n account: toAccount(walletAccount.address as Hex),\n chain: mapNetworkDataToViemChain(activeNetworkData),\n transport: custom(walletProvider, httpTransportConfig),\n ...walletClientConfig,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;ACOA,MAAa,6BAA6B,iBAAqC;CAC7E,gBAAgB,YAAY,oBAAoB,KAC5C,EACE,SAAS;EACP,MAAM,YAAY,kBAAkB;EACpC,KAAK,YAAY,kBAAkB;EACpC,EACF,GACD;CACJ,IAAI,OAAO,YAAY,UAAU;CACjC,MAAM,YAAY;CAClB,gBAAgB,YAAY;CAC5B,SAAS,EACP,SAAS,EAAE,MAAM,YAAY,QAAQ,MAAM,EAC5C;CACF;;;;;;;;;;;;;;;;;ACSD,MAAa,qCAAqC,EAChD,aACA,qBAAqB,EAAE,EACvB,sBAAsB,EAAE,oCAKL;CACjB,OAAO,0BAA0B,YAAY;CAC7C,0BAAgB,YAAY,QAAQ,KAAK,IAAI,oBAAoB;CACjE,GAAG;CACJ,CAAC;;;;;ACtCJ,MAAa,uBACX,mBACwC,eAAe,UAAU;;;;;ACJnE,MAAa,qBACX,aACoC;AACpC,QACE,aAAa,QACb,aAAa,UACb,OAAO,aAAa,YACpB,aAAa,YACb,OAAO,SAAS,YAAY;;;;;;ACNhC,MAAa,2CACX,mBAC4D;AAC5D,QAAO,4BAA4B;;;;;;;;;;;;;;;;;;;;AC2CrC,MAAa,qCAAqC,OAChD,EACE,eACA,qBAAqB,EAAE,EACvB,sBAAsB,EAAE,IAE1B,8DAA2B,KAC0B;CACrD,MAAM,uFACJ,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAAC,oBAAoB,eAAe,CACtC,OAAM,IAAIA,2CACR,GAAG,cAAc,QAAQ,+BAC1B;AAGH,KAAI,wCAAwC,eAAe,CACzD,QAAO,eAAe,uBAAuB;EAC3C;EACA,wBAAwB;EACxB;EACD,CAAC;CAGJ,MAAM,EAAE,aAAa,sBAAsB,yDACzC,EAAE,eAAe,EACjB,OACD;AAED,kDACE,mBACA,4CAA4C,cAAc,UAC3D;AAED,KAAI,CAAC,kBAAkB,eAAe,CACpC,OAAM,IAAIA,2CACR,mEACD;AAGH,qCAA0B;EACxB,sCAAmB,cAAc,QAAe;EAChD,OAAO,0BAA0B,kBAAkB;EACnD,4BAAkB,gBAAgB,oBAAoB;EACtD,GAAG;EACJ,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { toAccount } from "viem/accounts";
|
|
|
5
5
|
|
|
6
6
|
//#region package.json
|
|
7
7
|
var name = "@dynamic-labs-sdk/evm";
|
|
8
|
-
var version = "0.26.
|
|
8
|
+
var version = "0.26.7";
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/viem/utils/mapNetworkDataToViemChain/mapNetworkDataToViemChain.ts
|
|
@@ -102,4 +102,4 @@ const createWalletClientForWalletAccount = async ({ walletAccount, walletClientC
|
|
|
102
102
|
|
|
103
103
|
//#endregion
|
|
104
104
|
export { version as a, name as i, createPublicClientFromNetworkData as n, mapNetworkDataToViemChain as r, createWalletClientForWalletAccount as t };
|
|
105
|
-
//# sourceMappingURL=createWalletClientForWalletAccount-
|
|
105
|
+
//# sourceMappingURL=createWalletClientForWalletAccount-CC2j8qwa.esm.js.map
|