@reown/appkit 1.6.4 → 1.6.5-rc.0.0
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/esm/exports/connectors.js +2 -0
- package/dist/esm/exports/connectors.js.map +1 -0
- package/dist/esm/exports/constants.js +1 -1
- package/dist/esm/exports/constants.js.map +1 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/react.js +2 -2
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/vue.js +2 -2
- package/dist/esm/exports/vue.js.map +1 -1
- package/dist/esm/package.json +6 -1
- package/dist/esm/src/adapters/ChainAdapterBlueprint.js +47 -35
- package/dist/esm/src/adapters/ChainAdapterBlueprint.js.map +1 -1
- package/dist/esm/src/client.js +57 -92
- package/dist/esm/src/client.js.map +1 -1
- package/dist/esm/src/connectors/WalletConnectConnector.js +70 -0
- package/dist/esm/src/connectors/WalletConnectConnector.js.map +1 -0
- package/dist/esm/src/connectors/index.js +2 -0
- package/dist/esm/src/connectors/index.js.map +1 -0
- package/dist/esm/src/library/react/index.js.map +1 -1
- package/dist/esm/src/library/vue/index.js.map +1 -1
- package/dist/esm/src/networks/solana/eclipseDevnet.js +17 -0
- package/dist/esm/src/networks/solana/eclipseDevnet.js.map +1 -0
- package/dist/esm/src/networks/utils.js.map +1 -1
- package/dist/esm/src/store/ProviderUtil.js.map +1 -1
- package/dist/esm/src/universal-adapter/client.js +24 -29
- package/dist/esm/src/universal-adapter/client.js.map +1 -1
- package/dist/esm/src/utils/HelpersUtil.js.map +1 -1
- package/dist/esm/tests/appkit.test.js +1494 -0
- package/dist/esm/tests/appkit.test.js.map +1 -0
- package/dist/esm/tests/connectors/WalletConnectConnector.test.js +63 -0
- package/dist/esm/tests/connectors/WalletConnectConnector.test.js.map +1 -0
- package/dist/esm/tests/mocks/Adapter.js +30 -0
- package/dist/esm/tests/mocks/Adapter.js.map +1 -0
- package/dist/esm/tests/mocks/AppKit.js +24 -0
- package/dist/esm/tests/mocks/AppKit.js.map +1 -0
- package/dist/esm/tests/mocks/Options.js +33 -0
- package/dist/esm/tests/mocks/Options.js.map +1 -0
- package/dist/esm/tests/mocks/UniversalProvider.js +137 -0
- package/dist/esm/tests/mocks/UniversalProvider.js.map +1 -0
- package/dist/esm/tests/siwe.test.js +258 -0
- package/dist/esm/tests/siwe.test.js.map +1 -0
- package/dist/esm/tests/universal-adapter.test.js +156 -0
- package/dist/esm/tests/universal-adapter.test.js.map +1 -0
- package/dist/esm/tests/utils/HelpersUtil.test.js +217 -0
- package/dist/esm/tests/utils/HelpersUtil.test.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/types/exports/connectors.d.ts +1 -0
- package/dist/types/exports/constants.d.ts +1 -1
- package/dist/types/exports/react.d.ts +1 -1
- package/dist/types/exports/vue.d.ts +2 -2
- package/dist/types/src/adapters/ChainAdapterBlueprint.d.ts +13 -9
- package/dist/types/src/client.d.ts +6 -6
- package/dist/types/src/connectors/WalletConnectConnector.d.ts +35 -0
- package/dist/types/src/connectors/index.d.ts +1 -0
- package/dist/types/src/library/react/index.d.ts +1 -1
- package/dist/types/src/library/vue/index.d.ts +2 -2
- package/dist/types/src/networks/solana/eclipseDevnet.d.ts +42 -0
- package/dist/types/src/networks/utils.d.ts +1 -1
- package/dist/types/src/universal-adapter/client.d.ts +5 -3
- package/dist/types/src/utils/HelpersUtil.d.ts +1 -1
- package/dist/types/src/utils/TypesUtil.d.ts +7 -2
- package/dist/types/tests/appkit.test.d.ts +1 -0
- package/dist/types/tests/connectors/WalletConnectConnector.test.d.ts +1 -0
- package/dist/types/tests/mocks/Adapter.d.ts +3 -0
- package/dist/types/tests/mocks/AppKit.d.ts +3 -0
- package/dist/types/tests/mocks/Options.d.ts +6 -0
- package/dist/types/tests/mocks/UniversalProvider.d.ts +3 -0
- package/dist/types/tests/siwe.test.d.ts +1 -0
- package/dist/types/tests/universal-adapter.test.d.ts +1 -0
- package/dist/types/tests/utils/HelpersUtil.test.d.ts +1 -0
- package/package.json +14 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../../../exports/connectors.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = '1.6.
|
|
1
|
+
export const PACKAGE_VERSION = '1.6.5-rc.0.0';
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../exports/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../exports/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,wEAAwE;AACxE,cAAc,2BAA2B,CAAA;AAEzC,yEAAyE;AACzE,cAAc,uBAAuB,CAAA;AAGrC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAItE,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,OAAO,IAAI,MAAM,CAAC;QAChB,GAAG,OAAO;QACV,UAAU,EAAE,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC;KAC/F,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CoreHelperUtil } from '@reown/appkit-core';
|
|
2
|
+
import { useAppKitNetworkCore } from '@reown/appkit-core/react';
|
|
1
3
|
import { AppKit } from '../src/client.js';
|
|
2
4
|
import { getAppKit } from '../src/library/react/index.js';
|
|
3
|
-
import { CoreHelperUtil } from '@reown/appkit-core';
|
|
4
5
|
import { PACKAGE_VERSION } from './constants.js';
|
|
5
|
-
import { useAppKitNetworkCore } from '@reown/appkit-core/react';
|
|
6
6
|
// -- Views ------------------------------------------------------------
|
|
7
7
|
export * from '@reown/appkit-scaffold-ui';
|
|
8
8
|
// -- Hooks ------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../exports/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../exports/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA+B,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAG/D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,wEAAwE;AACxE,cAAc,2BAA2B,CAAA;AAEzC,wEAAwE;AACxE,cAAc,+BAA+B,CAAA;AAE7C,yEAAyE;AACzE,cAAc,uBAAuB,CAAA;AAGrC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtE,MAAM,CAAC,IAAI,KAAK,GAAuB,SAAS,CAAA;AAIhD,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,MAAM,CAAC;YACjB,GAAG,OAAO;YACV,UAAU,EAAE,cAAc,CAAC,kBAAkB,CAC3C,OAAO,CAAC,QAAQ,IAAI,EAAE,EACtB,OAAO,EACP,eAAe,CAChB;SACF,CAAC,CAAA;QACF,SAAS,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAGjB,wEAAwE;AACxE,cAAc,+BAA+B,CAAA;AAE7C,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,oBAAoB,EAAE,CAAA;IAEtE,SAAS,aAAa,CAAC,OAAsB;QAC3C,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED,OAAO;QACL,WAAW;QACX,aAAa;QACb,OAAO;QACP,aAAa;KACd,CAAA;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA"}
|
package/dist/esm/exports/vue.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { onUnmounted, ref } from 'vue';
|
|
2
|
+
import { ChainController, CoreHelperUtil } from '@reown/appkit-core';
|
|
1
3
|
import { AppKit } from '../src/client.js';
|
|
2
4
|
import { getAppKit } from '../src/library/vue/index.js';
|
|
3
|
-
import { ChainController, CoreHelperUtil } from '@reown/appkit-core';
|
|
4
5
|
import { PACKAGE_VERSION } from './constants.js';
|
|
5
|
-
import { onUnmounted, ref } from 'vue';
|
|
6
6
|
// -- Views ------------------------------------------------------------
|
|
7
7
|
export * from '@reown/appkit-scaffold-ui';
|
|
8
8
|
// -- Hooks ------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","sourceRoot":"","sources":["../../../exports/vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"vue.js","sourceRoot":"","sources":["../../../exports/vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,cAAc,EAA+B,MAAM,oBAAoB,CAAA;AAGjG,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,wEAAwE;AACxE,cAAc,2BAA2B,CAAA;AAEzC,wEAAwE;AACxE,cAAc,6BAA6B,CAAA;AAE3C,yEAAyE;AACzE,cAAc,uBAAuB,CAAA;AAGrC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtE,IAAI,KAAK,GAAuB,SAAS,CAAA;AAIzC,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,MAAM,CAAC;YACjB,GAAG,OAAO;YACV,UAAU,EAAE,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC;SAC/F,CAAC,CAAA;QACF,SAAS,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAGjB,wEAAwE;AACxE,MAAM,UAAU,gBAAgB;IAC9B,MAAM,KAAK,GAAG,GAAG,CAAC;QAChB,WAAW,EAAE,eAAe,CAAC,KAAK,CAAC,iBAAiB;QACpD,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE;QACpD,aAAa,EAAE,eAAe,CAAC,KAAK,CAAC,iBAAiB,EAAE,aAAa;QACrE,aAAa,EAAE,CAAC,OAAsB,EAAE,EAAE;YACxC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;QAC/B,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,eAAe,CAAC,YAAY,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAE;QAC1E,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAA;QAC7B,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,EAAE,CAAA;QAC7B,KAAK,CAAC,KAAK,CAAC,aAAa,GAAG,GAAG,EAAE,aAAa,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,WAAW,CAAC,GAAG,EAAE;QACf,WAAW,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC;AAED,cAAc,6BAA6B,CAAA"}
|
package/dist/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5-rc.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/esm/exports/index.js",
|
|
6
6
|
"types": "./dist/types/exports/index.d.ts",
|
|
@@ -66,6 +66,11 @@
|
|
|
66
66
|
"types": "./dist/types/exports/adapters.d.ts",
|
|
67
67
|
"import": "./dist/esm/exports/adapters.js",
|
|
68
68
|
"default": "./dist/esm/exports/adapters.js"
|
|
69
|
+
},
|
|
70
|
+
"./connectors": {
|
|
71
|
+
"types": "./dist/types/exports/connectors.d.ts",
|
|
72
|
+
"import": "./dist/esm/exports/connectors.js",
|
|
73
|
+
"default": "./dist/esm/exports/connectors.js"
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"typesVersions": {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import UniversalProvider from '@walletconnect/universal-provider';
|
|
2
|
+
import { ConstantsUtil as CommonConstantsUtil } from '@reown/appkit-common';
|
|
3
|
+
import { AccountController, OptionsController } from '@reown/appkit-core';
|
|
3
4
|
import { PresetsUtil } from '@reown/appkit-utils';
|
|
4
|
-
import {
|
|
5
|
+
import { W3mFrameProvider } from '@reown/appkit-wallet';
|
|
6
|
+
import { WalletConnectConnector } from '../connectors/WalletConnectConnector.js';
|
|
5
7
|
/**
|
|
6
8
|
* Abstract class representing a chain adapter blueprint.
|
|
7
9
|
* @template Connector - The type of connector extending ChainAdapterConnector
|
|
@@ -41,21 +43,6 @@ export class AdapterBlueprint {
|
|
|
41
43
|
get networks() {
|
|
42
44
|
return this.caipNetworks || [];
|
|
43
45
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Sets the universal provider for WalletConnect.
|
|
46
|
-
* @param {UniversalProvider} universalProvider - The universal provider instance
|
|
47
|
-
*/
|
|
48
|
-
setUniversalProvider(universalProvider) {
|
|
49
|
-
this.addConnector({
|
|
50
|
-
id: CommonConstantsUtil.CONNECTOR_ID.WALLET_CONNECT,
|
|
51
|
-
type: 'WALLET_CONNECT',
|
|
52
|
-
name: PresetsUtil.ConnectorNamesMap[CommonConstantsUtil.CONNECTOR_ID.WALLET_CONNECT],
|
|
53
|
-
provider: universalProvider,
|
|
54
|
-
imageId: PresetsUtil.ConnectorImageIds[CommonConstantsUtil.CONNECTOR_ID.WALLET_CONNECT],
|
|
55
|
-
chain: this.namespace,
|
|
56
|
-
chains: []
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
46
|
/**
|
|
60
47
|
* Sets the auth provider.
|
|
61
48
|
* @param {W3mFrameProvider} authProvider - The auth provider instance
|
|
@@ -76,23 +63,6 @@ export class AdapterBlueprint {
|
|
|
76
63
|
* @param {...Connector} connectors - The connectors to add
|
|
77
64
|
*/
|
|
78
65
|
addConnector(...connectors) {
|
|
79
|
-
if (connectors.some(connector => connector.id === CommonConstantsUtil.CONNECTOR_ID.AUTH)) {
|
|
80
|
-
const authConnector = connectors.find(connector => connector.id === CommonConstantsUtil.CONNECTOR_ID.AUTH);
|
|
81
|
-
const optionsState = snapshot(OptionsController.state);
|
|
82
|
-
const themeMode = ThemeController.getSnapshot().themeMode;
|
|
83
|
-
const themeVariables = ThemeController.getSnapshot().themeVariables;
|
|
84
|
-
authConnector?.provider?.syncDappData?.({
|
|
85
|
-
metadata: optionsState.metadata,
|
|
86
|
-
sdkVersion: optionsState.sdkVersion,
|
|
87
|
-
projectId: optionsState.projectId,
|
|
88
|
-
sdkType: optionsState.sdkType
|
|
89
|
-
});
|
|
90
|
-
authConnector.provider.syncTheme({
|
|
91
|
-
themeMode,
|
|
92
|
-
themeVariables,
|
|
93
|
-
w3mThemeVariables: getW3mThemeVariables(themeVariables, themeMode)
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
66
|
const connectorsAdded = new Set();
|
|
97
67
|
this.availableConnectors = [...connectors, ...this.availableConnectors].filter(connector => {
|
|
98
68
|
if (connectorsAdded.has(connector.id)) {
|
|
@@ -150,5 +120,47 @@ export class AdapterBlueprint {
|
|
|
150
120
|
listeners.forEach(callback => callback(data));
|
|
151
121
|
}
|
|
152
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Connects to WalletConnect.
|
|
125
|
+
* @param {(uri: string) => void} onUri - Callback function to handle the WalletConnect URI
|
|
126
|
+
* @param {number | string} [_chainId] - Optional chain ID to connect to
|
|
127
|
+
*/
|
|
128
|
+
async connectWalletConnect(onUri, _chainId) {
|
|
129
|
+
const connector = this.getWalletConnectConnector();
|
|
130
|
+
const result = await connector.connectWalletConnect({ onUri });
|
|
131
|
+
return { clientId: result.clientId };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Switches the network.
|
|
135
|
+
* @param {AdapterBlueprint.SwitchNetworkParams} params - Network switching parameters
|
|
136
|
+
*/
|
|
137
|
+
async switchNetwork(params) {
|
|
138
|
+
const { caipNetwork, providerType } = params;
|
|
139
|
+
if (!params.provider) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const provider = 'provider' in params.provider ? params.provider.provider : params.provider;
|
|
143
|
+
if (providerType === 'WALLET_CONNECT') {
|
|
144
|
+
;
|
|
145
|
+
provider.setDefaultChain(caipNetwork.caipNetworkId);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (provider && providerType === 'AUTH') {
|
|
149
|
+
const authProvider = provider;
|
|
150
|
+
await authProvider.switchNetwork(caipNetwork.caipNetworkId);
|
|
151
|
+
const user = await authProvider.getUser({
|
|
152
|
+
chainId: caipNetwork.caipNetworkId,
|
|
153
|
+
preferredAccountType: OptionsController.state.defaultAccountTypes[caipNetwork.chainNamespace]
|
|
154
|
+
});
|
|
155
|
+
this.emit('switchNetwork', user);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
getWalletConnectConnector() {
|
|
159
|
+
const connector = this.connectors.find(c => c instanceof WalletConnectConnector);
|
|
160
|
+
if (!connector) {
|
|
161
|
+
throw new Error('WalletConnectConnector not found');
|
|
162
|
+
}
|
|
163
|
+
return connector;
|
|
164
|
+
}
|
|
153
165
|
}
|
|
154
166
|
//# sourceMappingURL=ChainAdapterBlueprint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainAdapterBlueprint.js","sourceRoot":"","sources":["../../../../src/adapters/ChainAdapterBlueprint.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChainAdapterBlueprint.js","sourceRoot":"","sources":["../../../../src/adapters/ChainAdapterBlueprint.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,mCAAmC,CAAA;AAEjE,OAAO,EAIL,aAAa,IAAI,mBAAmB,EACrC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,iBAAiB,EAIjB,iBAAiB,EAGlB,MAAM,oBAAoB,CAAA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,WAAW,CAAC,aAAa,CAAC,CAAA;YAC3D,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC;gBACtC,OAAO,EAAE,WAAW,CAAC,aAAa;gBAClC,oBAAoB,EAClB,iBAAiB,CAAC,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,cAAc,CAAC;aAC1E,CAAC,CAAA;YAEF,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;IAiIS,yBAAyB;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,sBAAsB,CAElE,CAAA;QAEb,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACrD,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;CACF"}
|
package/dist/esm/src/client.js
CHANGED
|
@@ -1,45 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import { ConstantsUtil
|
|
3
|
-
import {
|
|
1
|
+
import UniversalProvider from '@walletconnect/universal-provider';
|
|
2
|
+
import { ConstantsUtil, NetworkUtil, ParseUtil, getW3mThemeVariables } from '@reown/appkit-common';
|
|
3
|
+
import { ConstantsUtil as CoreConstantsUtil } from '@reown/appkit-core';
|
|
4
|
+
import { AccountController, AlertController, ApiController, AssetUtil, BlockchainApiController, ChainController, ConnectionController, ConnectorController, CoreHelperUtil, EnsController, EventsController, ModalController, OptionsController, PublicStateController, RouterController, SnackController, StorageUtil, ThemeController } from '@reown/appkit-core';
|
|
5
|
+
import { WalletUtil } from '@reown/appkit-scaffold-ui/utils';
|
|
4
6
|
import { setColorTheme, setThemeVariables } from '@reown/appkit-ui';
|
|
5
|
-
import { NetworkUtil, ConstantsUtil, ParseUtil } from '@reown/appkit-common';
|
|
6
|
-
import { UniversalAdapter, UniversalAdapter as UniversalAdapterClient } from './universal-adapter/client.js';
|
|
7
7
|
import { CaipNetworksUtil, ErrorUtil, HelpersUtil, LoggerUtil, ConstantsUtil as UtilConstantsUtil } from '@reown/appkit-utils';
|
|
8
|
-
import { W3mFrameHelpers, W3mFrameRpcConstants } from '@reown/appkit-wallet';
|
|
9
|
-
import { ProviderUtil } from './store/ProviderUtil.js';
|
|
10
|
-
import UniversalProvider from '@walletconnect/universal-provider';
|
|
8
|
+
import { W3mFrameHelpers, W3mFrameProvider, W3mFrameRpcConstants } from '@reown/appkit-wallet';
|
|
11
9
|
import { W3mFrameProviderSingleton } from './auth-provider/W3MFrameProviderSingleton.js';
|
|
10
|
+
import { ProviderUtil } from './store/ProviderUtil.js';
|
|
11
|
+
import { UniversalAdapter, UniversalAdapter as UniversalAdapterClient } from './universal-adapter/client.js';
|
|
12
12
|
import { WcHelpersUtil } from './utils/HelpersUtil.js';
|
|
13
|
-
import { WalletUtil } from '@reown/appkit-scaffold-ui/utils';
|
|
14
13
|
// -- Export Controllers -------------------------------------------------------
|
|
15
14
|
export { AccountController };
|
|
16
|
-
// -- Constants ----------------------------------------- //
|
|
17
|
-
const OPTIONAL_METHODS = [
|
|
18
|
-
'eth_accounts',
|
|
19
|
-
'eth_requestAccounts',
|
|
20
|
-
'eth_sendRawTransaction',
|
|
21
|
-
'eth_sign',
|
|
22
|
-
'eth_signTransaction',
|
|
23
|
-
'eth_signTypedData',
|
|
24
|
-
'eth_signTypedData_v3',
|
|
25
|
-
'eth_signTypedData_v4',
|
|
26
|
-
'eth_sendTransaction',
|
|
27
|
-
'personal_sign',
|
|
28
|
-
'wallet_switchEthereumChain',
|
|
29
|
-
'wallet_addEthereumChain',
|
|
30
|
-
'wallet_getPermissions',
|
|
31
|
-
'wallet_requestPermissions',
|
|
32
|
-
'wallet_registerOnboarding',
|
|
33
|
-
'wallet_watchAsset',
|
|
34
|
-
'wallet_scanQRCode',
|
|
35
|
-
// EIP-5792
|
|
36
|
-
'wallet_getCallsStatus',
|
|
37
|
-
'wallet_sendCalls',
|
|
38
|
-
'wallet_getCapabilities',
|
|
39
|
-
// EIP-7715
|
|
40
|
-
'wallet_grantPermissions',
|
|
41
|
-
'wallet_revokePermissions'
|
|
42
|
-
];
|
|
43
15
|
// -- Helpers -------------------------------------------------------------------
|
|
44
16
|
let isInitialized = false;
|
|
45
17
|
// -- Client --------------------------------------------------------------------
|
|
@@ -440,6 +412,7 @@ export class AppKit {
|
|
|
440
412
|
OptionsController.setCustomWallets(options.customWallets);
|
|
441
413
|
OptionsController.setFeatures(options.features);
|
|
442
414
|
OptionsController.setAllowUnsupportedChain(options.allowUnsupportedChain);
|
|
415
|
+
OptionsController.setDefaultAccountTypes(options.defaultAccountTypes);
|
|
443
416
|
const defaultMetaData = this.getDefaultMetaData();
|
|
444
417
|
if (!options.metadata && defaultMetaData) {
|
|
445
418
|
options.metadata = defaultMetaData;
|
|
@@ -541,24 +514,13 @@ export class AppKit {
|
|
|
541
514
|
this.connectionControllerClient = {
|
|
542
515
|
connectWalletConnect: async (onUri) => {
|
|
543
516
|
const adapter = this.getAdapter(ChainController.state.activeChain);
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
let isAuthenticated = false;
|
|
547
|
-
if (this.universalProvider) {
|
|
548
|
-
const chains = this.caipNetworks?.map(network => network.caipNetworkId) || [];
|
|
549
|
-
isAuthenticated = await SIWXUtil.universalProviderAuthenticate({
|
|
550
|
-
universalProvider: this.universalProvider,
|
|
551
|
-
chains,
|
|
552
|
-
methods: OPTIONAL_METHODS
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
if (isAuthenticated) {
|
|
556
|
-
this.close();
|
|
557
|
-
}
|
|
558
|
-
else {
|
|
559
|
-
await adapter?.connectWalletConnect(onUri, this.getCaipNetwork()?.id);
|
|
560
|
-
StorageUtil.setConnectedNamespaces([...ChainController.state.chains.keys()]);
|
|
517
|
+
if (!adapter) {
|
|
518
|
+
throw new Error('Adapter not found');
|
|
561
519
|
}
|
|
520
|
+
const result = await adapter.connectWalletConnect(onUri, this.getCaipNetwork()?.id);
|
|
521
|
+
this.close();
|
|
522
|
+
this.setClientId(result?.clientId || null);
|
|
523
|
+
StorageUtil.setConnectedNamespaces([...ChainController.state.chains.keys()]);
|
|
562
524
|
await this.syncWalletConnectAccount();
|
|
563
525
|
},
|
|
564
526
|
connectExternal: async ({ id, info, type, provider, chain, caipNetwork }) => {
|
|
@@ -583,24 +545,14 @@ export class AppKit {
|
|
|
583
545
|
rpcUrl: caipNetwork?.rpcUrls?.default?.http?.[0] ||
|
|
584
546
|
this.getCaipNetwork()?.rpcUrls?.default?.http?.[0]
|
|
585
547
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
this.syncProvider({
|
|
589
|
-
...res,
|
|
590
|
-
chainNamespace: chainToUse
|
|
591
|
-
});
|
|
592
|
-
await this.syncAccount({
|
|
593
|
-
...res,
|
|
594
|
-
chainNamespace: chainToUse
|
|
595
|
-
});
|
|
596
|
-
const { accounts } = await adapter.getAccounts({ namespace: chainToUse, id });
|
|
597
|
-
this.setAllAccounts(accounts, chainToUse);
|
|
598
|
-
}
|
|
599
|
-
if (!this.caipNetworks?.some(network => network.id === res?.chainId)) {
|
|
600
|
-
if (res?.chainId) {
|
|
601
|
-
this.setUnsupportedNetwork(res.chainId);
|
|
602
|
-
}
|
|
548
|
+
if (!res) {
|
|
549
|
+
return;
|
|
603
550
|
}
|
|
551
|
+
StorageUtil.addConnectedNamespace(chainToUse);
|
|
552
|
+
this.syncProvider({ ...res, chainNamespace: chainToUse });
|
|
553
|
+
await this.syncAccount({ ...res, chainNamespace: chainToUse });
|
|
554
|
+
const { accounts } = await adapter.getAccounts({ namespace: chainToUse, id });
|
|
555
|
+
this.setAllAccounts(accounts, chainToUse);
|
|
604
556
|
},
|
|
605
557
|
reconnectExternal: async ({ id, info, type, provider }) => {
|
|
606
558
|
const namespace = ChainController.state.activeChain;
|
|
@@ -748,6 +700,7 @@ export class AppKit {
|
|
|
748
700
|
type: UtilConstantsUtil.CONNECTOR_TYPE_AUTH,
|
|
749
701
|
caipNetwork
|
|
750
702
|
});
|
|
703
|
+
this.setCaipNetwork(caipNetwork);
|
|
751
704
|
}
|
|
752
705
|
catch (error) {
|
|
753
706
|
const adapter = this.getAdapter(caipNetwork.chainNamespace);
|
|
@@ -855,18 +808,8 @@ export class AppKit {
|
|
|
855
808
|
this.setLoading(false);
|
|
856
809
|
}
|
|
857
810
|
});
|
|
858
|
-
provider.onIsConnected(() => {
|
|
859
|
-
provider.connect();
|
|
860
|
-
StorageUtil.addConnectedNamespace(ChainController.state.activeChain);
|
|
861
|
-
});
|
|
862
811
|
provider.onConnect(async (user) => {
|
|
863
812
|
const namespace = ChainController.state.activeChain;
|
|
864
|
-
this.syncProvider({
|
|
865
|
-
type: UtilConstantsUtil.CONNECTOR_TYPE_AUTH,
|
|
866
|
-
provider,
|
|
867
|
-
id: ConstantsUtil.CONNECTOR_ID.AUTH,
|
|
868
|
-
chainNamespace: namespace
|
|
869
|
-
});
|
|
870
813
|
// To keep backwards compatibility, eip155 chainIds are numbers and not actual caipChainIds
|
|
871
814
|
const caipAddress = namespace === ConstantsUtil.CHAIN.EVM
|
|
872
815
|
? `eip155:${user.chainId}:${user.address}`
|
|
@@ -881,9 +824,10 @@ export class AppKit {
|
|
|
881
824
|
}
|
|
882
825
|
this.setCaipAddress(caipAddress, namespace);
|
|
883
826
|
this.setUser({ ...(AccountController.state.user || {}), email: user.email });
|
|
884
|
-
const preferredAccountType = (user.preferredAccountType ||
|
|
827
|
+
const preferredAccountType = (user.preferredAccountType ||
|
|
828
|
+
OptionsController.state.defaultAccountTypes[namespace]);
|
|
885
829
|
this.setPreferredAccountType(preferredAccountType, namespace);
|
|
886
|
-
const userAccounts = user.accounts?.map(account => CoreHelperUtil.createAccount(namespace, account.address,
|
|
830
|
+
const userAccounts = user.accounts?.map(account => CoreHelperUtil.createAccount(namespace, account.address, account.type || OptionsController.state.defaultAccountTypes[namespace]));
|
|
887
831
|
this.setAllAccounts(userAccounts || [
|
|
888
832
|
CoreHelperUtil.createAccount(namespace, user.address, preferredAccountType)
|
|
889
833
|
], namespace);
|
|
@@ -915,6 +859,19 @@ export class AppKit {
|
|
|
915
859
|
this.setUser({ ...(AccountController.state?.user || {}), username, email });
|
|
916
860
|
this.setupAuthConnectorListeners(provider);
|
|
917
861
|
const { isConnected } = await provider.isConnected();
|
|
862
|
+
const theme = ThemeController.getSnapshot();
|
|
863
|
+
const options = OptionsController.getSnapshot();
|
|
864
|
+
provider.syncDappData({
|
|
865
|
+
metadata: options.metadata,
|
|
866
|
+
sdkVersion: options.sdkVersion,
|
|
867
|
+
projectId: options.projectId,
|
|
868
|
+
sdkType: options.sdkType
|
|
869
|
+
});
|
|
870
|
+
provider.syncTheme({
|
|
871
|
+
themeMode: theme.themeMode,
|
|
872
|
+
themeVariables: theme.themeVariables,
|
|
873
|
+
w3mThemeVariables: getW3mThemeVariables(theme.themeVariables, theme.themeMode)
|
|
874
|
+
});
|
|
918
875
|
const namespace = StorageUtil.getActiveNamespace();
|
|
919
876
|
if (namespace) {
|
|
920
877
|
if (isConnected && this.connectionControllerClient?.connectExternal) {
|
|
@@ -944,15 +901,14 @@ export class AppKit {
|
|
|
944
901
|
ConnectionController.resetWcConnection();
|
|
945
902
|
});
|
|
946
903
|
this.universalProvider.on('chainChanged', (chainId) => {
|
|
947
|
-
const caipNetwork = this.caipNetworks?.find(
|
|
948
904
|
// eslint-disable-next-line eqeqeq
|
|
949
|
-
|
|
905
|
+
const caipNetwork = this.caipNetworks?.find(c => c.id == chainId);
|
|
950
906
|
const currentCaipNetwork = this.getCaipNetwork();
|
|
951
907
|
if (!caipNetwork) {
|
|
952
908
|
this.setUnsupportedNetwork(chainId);
|
|
953
909
|
return;
|
|
954
910
|
}
|
|
955
|
-
if (
|
|
911
|
+
if (currentCaipNetwork?.id !== caipNetwork?.id) {
|
|
956
912
|
this.setCaipNetwork(caipNetwork);
|
|
957
913
|
}
|
|
958
914
|
});
|
|
@@ -981,7 +937,8 @@ export class AppKit {
|
|
|
981
937
|
this.setStatus(connectionStatus, chainNamespace);
|
|
982
938
|
}
|
|
983
939
|
adapter.on('switchNetwork', ({ address, chainId }) => {
|
|
984
|
-
if (chainId &&
|
|
940
|
+
if (chainId &&
|
|
941
|
+
this.caipNetworks?.find(n => n.id === chainId || n.caipNetworkId === chainId)) {
|
|
985
942
|
if (ChainController.state.activeChain === chainNamespace && address) {
|
|
986
943
|
this.syncAccount({ address, chainId, chainNamespace });
|
|
987
944
|
}
|
|
@@ -1124,7 +1081,7 @@ export class AppKit {
|
|
|
1124
1081
|
}
|
|
1125
1082
|
async syncAccount(params) {
|
|
1126
1083
|
const { address, chainId, chainNamespace } = params;
|
|
1127
|
-
const {
|
|
1084
|
+
const { chainId: activeChainId } = StorageUtil.getActiveNetworkProps();
|
|
1128
1085
|
const chainIdToUse = chainId || activeChainId;
|
|
1129
1086
|
// Only update state when needed
|
|
1130
1087
|
if (!HelpersUtil.isLowerCaseMatch(address, AccountController.state.address)) {
|
|
@@ -1132,20 +1089,24 @@ export class AppKit {
|
|
|
1132
1089
|
await this.syncIdentity({ address, chainId, chainNamespace });
|
|
1133
1090
|
}
|
|
1134
1091
|
this.setStatus('connected', chainNamespace);
|
|
1135
|
-
if (chainIdToUse
|
|
1092
|
+
if (chainIdToUse) {
|
|
1136
1093
|
let caipNetwork = this.caipNetworks?.find(n => n.id.toString() === chainIdToUse.toString());
|
|
1137
1094
|
let fallbackCaipNetwork = this.caipNetworks?.find(n => n.chainNamespace === chainNamespace);
|
|
1138
|
-
const
|
|
1139
|
-
if (!
|
|
1095
|
+
const shouldSupportAllNetworks = ChainController.getNetworkProp('supportsAllNetworks', chainNamespace);
|
|
1096
|
+
if (!shouldSupportAllNetworks) {
|
|
1140
1097
|
// Connection can be requested for a chain that is not supported by the wallet so we need to use approved networks here
|
|
1141
1098
|
const caipNetworkIds = this.getApprovedCaipNetworkIds() || [];
|
|
1142
1099
|
const caipNetworkId = caipNetworkIds.find(id => ParseUtil.parseCaipNetworkId(id)?.chainId === chainIdToUse.toString());
|
|
1143
1100
|
const fallBackCaipNetworkId = caipNetworkIds.find(id => ParseUtil.parseCaipNetworkId(id)?.chainNamespace === chainNamespace);
|
|
1144
1101
|
caipNetwork = this.caipNetworks?.find(n => n.caipNetworkId === caipNetworkId);
|
|
1145
|
-
fallbackCaipNetwork = this.caipNetworks?.find(n => n.caipNetworkId === fallBackCaipNetworkId
|
|
1102
|
+
fallbackCaipNetwork = this.caipNetworks?.find(n => n.caipNetworkId === fallBackCaipNetworkId ||
|
|
1103
|
+
// This is a workaround used in Solana network to support deprecated caipNetworkId
|
|
1104
|
+
('deprecatedCaipNetworkId' in n && n.deprecatedCaipNetworkId === fallBackCaipNetworkId));
|
|
1146
1105
|
}
|
|
1147
1106
|
const network = (caipNetwork || fallbackCaipNetwork);
|
|
1148
|
-
|
|
1107
|
+
if (network.chainNamespace === ChainController.state.activeChain) {
|
|
1108
|
+
this.setCaipNetwork(network);
|
|
1109
|
+
}
|
|
1149
1110
|
this.syncConnectedWalletInfo(chainNamespace);
|
|
1150
1111
|
await this.syncBalance({ address, chainId: network.id, chainNamespace });
|
|
1151
1112
|
}
|
|
@@ -1318,6 +1279,9 @@ export class AppKit {
|
|
|
1318
1279
|
await Promise.allSettled(this.chainNamespaces.map(namespace => this.syncNamespaceConnection(namespace)));
|
|
1319
1280
|
}
|
|
1320
1281
|
getAdapter(namespace) {
|
|
1282
|
+
if (!namespace) {
|
|
1283
|
+
return undefined;
|
|
1284
|
+
}
|
|
1321
1285
|
return this.chainAdapters?.[namespace];
|
|
1322
1286
|
}
|
|
1323
1287
|
createUniversalProvider() {
|
|
@@ -1386,6 +1350,7 @@ export class AppKit {
|
|
|
1386
1350
|
this.authProvider = W3mFrameProviderSingleton.getInstance({
|
|
1387
1351
|
projectId: this.options.projectId,
|
|
1388
1352
|
enableLogger: this.options.enableAuthLogger,
|
|
1353
|
+
chainId: this.getCaipNetwork()?.caipNetworkId,
|
|
1389
1354
|
onTimeout: () => {
|
|
1390
1355
|
AlertController.open(ErrorUtil.ALERT_ERRORS.SOCIALS_TIMEOUT, 'error');
|
|
1391
1356
|
}
|