@reown/appkit-core 1.6.0 → 1.6.1-rc.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.
Files changed (37) hide show
  1. package/dist/esm/exports/index.js.map +1 -1
  2. package/dist/esm/src/controllers/AssetController.js +1 -1
  3. package/dist/esm/src/controllers/AssetController.js.map +1 -1
  4. package/dist/esm/src/controllers/ChainController.js +40 -1
  5. package/dist/esm/src/controllers/ChainController.js.map +1 -1
  6. package/dist/esm/src/controllers/ConnectionController.js +3 -12
  7. package/dist/esm/src/controllers/ConnectionController.js.map +1 -1
  8. package/dist/esm/src/controllers/OptionsController.js +3 -0
  9. package/dist/esm/src/controllers/OptionsController.js.map +1 -1
  10. package/dist/esm/src/controllers/SendController.js +3 -3
  11. package/dist/esm/src/controllers/SendController.js.map +1 -1
  12. package/dist/esm/src/controllers/SwapController.js +2 -1
  13. package/dist/esm/src/controllers/SwapController.js.map +1 -1
  14. package/dist/esm/src/utils/ConstantsUtil.js +2 -2
  15. package/dist/esm/src/utils/ConstantsUtil.js.map +1 -1
  16. package/dist/esm/src/utils/CoreHelperUtil.js +9 -0
  17. package/dist/esm/src/utils/CoreHelperUtil.js.map +1 -1
  18. package/dist/esm/src/utils/SIWXUtil.js +9 -0
  19. package/dist/esm/src/utils/SIWXUtil.js.map +1 -1
  20. package/dist/esm/tests/controllers/ChainController.test.js +83 -6
  21. package/dist/esm/tests/controllers/ChainController.test.js.map +1 -1
  22. package/dist/esm/tests/controllers/OptionsController.test.js +4 -0
  23. package/dist/esm/tests/controllers/OptionsController.test.js.map +1 -1
  24. package/dist/esm/tests/utils/CoreHelperUtil.test.js +13 -0
  25. package/dist/esm/tests/utils/CoreHelperUtil.test.js.map +1 -1
  26. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  27. package/dist/types/exports/index.d.ts +1 -1
  28. package/dist/types/src/controllers/ChainController.d.ts +1 -0
  29. package/dist/types/src/controllers/ConnectorController.d.ts +1 -2
  30. package/dist/types/src/controllers/OptionsController.d.ts +6 -0
  31. package/dist/types/src/utils/ConstantsUtil.d.ts +1 -1
  32. package/dist/types/src/utils/CoreHelperUtil.d.ts +1 -0
  33. package/dist/types/src/utils/OptionsUtil.d.ts +1 -1
  34. package/dist/types/src/utils/SIWXUtil.d.ts +71 -9
  35. package/dist/types/src/utils/SwapApiUtil.d.ts +1 -1
  36. package/dist/types/src/utils/TypeUtil.d.ts +6 -3
  37. package/package.json +4 -4
@@ -11,7 +11,7 @@ export type { OnRampControllerState, OnRampProvider } from '../src/controllers/O
11
11
  export { ConnectionController } from '../src/controllers/ConnectionController.js';
12
12
  export type { ConnectionControllerClient, ConnectionControllerState } from '../src/controllers/ConnectionController.js';
13
13
  export { ConnectorController } from '../src/controllers/ConnectorController.js';
14
- export type { ConnectorControllerState } from '../src/controllers/ConnectorController.js';
14
+ export type { ConnectorControllerState, ConnectorWithProviders } from '../src/controllers/ConnectorController.js';
15
15
  export { SnackController } from '../src/controllers/SnackController.js';
16
16
  export type { SnackControllerState } from '../src/controllers/SnackController.js';
17
17
  export { ApiController } from '../src/controllers/ApiController.js';
@@ -45,4 +45,5 @@ export declare const ChainController: {
45
45
  checkIfNamesSupported(): boolean;
46
46
  resetNetwork(namespace: ChainNamespace): void;
47
47
  resetAccount(chain: ChainNamespace | undefined): void;
48
+ disconnect(): Promise<void>;
48
49
  };
@@ -1,5 +1,5 @@
1
1
  import type { AuthConnector, Connector } from '../utils/TypeUtil.js';
2
- interface ConnectorWithProviders extends Connector {
2
+ export interface ConnectorWithProviders extends Connector {
3
3
  connectors?: Connector[];
4
4
  }
5
5
  export interface ConnectorControllerState {
@@ -21,4 +21,3 @@ export declare const ConnectorController: {
21
21
  getConnector(id: string, rdns?: string | null): ConnectorWithProviders | undefined;
22
22
  syncIfAuthConnector(connector: Connector | AuthConnector): void;
23
23
  };
24
- export {};
@@ -115,6 +115,11 @@ export interface OptionsControllerStatePublic {
115
115
  * @default false
116
116
  */
117
117
  enableEmbedded?: boolean;
118
+ /**
119
+ * Allow users to switch to an unsupported chain.
120
+ * @default false
121
+ */
122
+ allowUnsupportedChain?: boolean;
118
123
  }
119
124
  export interface OptionsControllerStateInternal {
120
125
  sdkType: 'appkit';
@@ -156,5 +161,6 @@ export declare const OptionsController: {
156
161
  setSocialsOrder(socialsOrder: SocialProvider[]): void;
157
162
  setCollapseWallets(collapseWallets: boolean): void;
158
163
  setEnableEmbedded(enableEmbedded: OptionsControllerState['enableEmbedded']): void;
164
+ setAllowUnsupportedChain(allowUnsupportedChain: OptionsControllerState['allowUnsupportedChain']): void;
159
165
  };
160
166
  export {};
@@ -63,7 +63,7 @@ export declare const ConstantsUtil: {
63
63
  legalCheckbox: false;
64
64
  smartSessions: false;
65
65
  collapseWallets: false;
66
- connectMethodsOrder: ("email" | "social" | "wallet")[];
67
66
  walletFeaturesOrder: ("swaps" | "send" | "receive" | "onramp")[];
67
+ connectMethodsOrder: undefined;
68
68
  };
69
69
  };
@@ -47,5 +47,6 @@ export declare const CoreHelperUtil: {
47
47
  uniqueBy<T>(arr: T[], key: keyof T): T[];
48
48
  generateSdkVersion(adapters: ChainAdapter[], platform: SDKFramework, version: string): AppKitSdkVersion;
49
49
  createAccount<N extends ChainNamespace>(namespace: N, address: string, type: NamespaceTypeMap[N]): AccountTypeMap[N];
50
+ isCaipAddress(address?: unknown): address is `eip155:${string}:${string}` | `eip155:${number}:${string}` | `solana:${string}:${string}` | `solana:${number}:${string}` | `polkadot:${string}:${string}` | `polkadot:${number}:${string}` | `bip122:${string}:${string}` | `bip122:${number}:${string}`;
50
51
  };
51
52
  export {};
@@ -1,4 +1,4 @@
1
1
  import type { Features, FeaturesKeys } from './TypeUtil.js';
2
2
  export declare const OptionsUtil: {
3
- getFeatureValue(key: FeaturesKeys, features?: Features): boolean | import("./TypeUtil.js").SocialProvider[] | import("./TypeUtil.js").ConnectMethod[] | import("./TypeUtil.js").WalletFeature[] | undefined;
3
+ getFeatureValue(key: FeaturesKeys, features?: Features): boolean | import("./TypeUtil.js").SocialProvider[] | import("./TypeUtil.js").WalletFeature[] | import("./TypeUtil.js").ConnectMethod[] | undefined;
4
4
  };
@@ -1,5 +1,8 @@
1
1
  import type { CaipNetworkId } from '@reown/appkit-common';
2
2
  import UniversalProvider from '@walletconnect/universal-provider';
3
+ /**
4
+ * SIWXUtil holds the methods to interact with the SIWX plugin and must be called internally on AppKit.
5
+ */
3
6
  export declare const SIWXUtil: {
4
7
  getSIWX(): SIWXConfig | undefined;
5
8
  initializeIfEnabled(): Promise<void>;
@@ -16,19 +19,69 @@ export declare const SIWXUtil: {
16
19
  network: string;
17
20
  isSmartAccount: boolean;
18
21
  };
22
+ clearSessions(): Promise<void>;
19
23
  };
20
24
  /**
21
- * @experimental - This is an experimental feature and it is not production ready
25
+ * This interface represents the SIWX configuration plugin, which is used to create and manage SIWX messages and sessions.
26
+ * AppKit provides predefined implementations for this interface through `@reown/appkit-siwx`.
27
+ * You may use it to create a custom implementation following your needs, but watch close for the methods requirements.
22
28
  */
23
29
  export interface SIWXConfig {
30
+ /**
31
+ * This method will be called to create a new message to be signed by the user.
32
+ *
33
+ * Constraints:
34
+ * - The message MUST be unique and contain all the necessary information to verify the user's identity.
35
+ * - SIWXMessage.toString() method MUST be implemented to return the message string.
36
+ *
37
+ * @param input SIWXMessage.Input
38
+ * @returns SIWXMessage
39
+ */
24
40
  createMessage: (input: SIWXMessage.Input) => Promise<SIWXMessage>;
41
+ /**
42
+ * This method will be called to store a new single session.
43
+ *
44
+ * Constraints:
45
+ * - This method MUST verify if the session is valid and store it in the storage successfully.
46
+ *
47
+ * @param session SIWXSession
48
+ */
25
49
  addSession: (session: SIWXSession) => Promise<void>;
50
+ /**
51
+ * This method will be called to revoke all the sessions stored for a specific chain and address.
52
+ *
53
+ * Constraints:
54
+ * - This method MUST delete all the sessions stored for the specific chain and address successfully.
55
+ *
56
+ * @param chainId CaipNetworkId
57
+ * @param address string
58
+ */
26
59
  revokeSession: (chainId: CaipNetworkId, address: string) => Promise<void>;
60
+ /**
61
+ * This method will be called to replace all the sessions in the storage with the new ones.
62
+ *
63
+ * Constraints:
64
+ * - This method MUST verify all the sessions before storing them in the storage;
65
+ * - This method MUST replace all the sessions in the storage with the new ones succesfully otherwise it MUST throw an error.
66
+ *
67
+ * @param sessions SIWXSession[]
68
+ */
27
69
  setSessions: (sessions: SIWXSession[]) => Promise<void>;
70
+ /**
71
+ * This method will be called to get all the sessions stored for a specific chain and address.
72
+ *
73
+ * Constraints:
74
+ * - This method MUST return only sessions that are verified and valid;
75
+ * - This method MUST NOT return expired sessions.
76
+ *
77
+ * @param chainId CaipNetworkId
78
+ * @param address string
79
+ * @returns
80
+ */
28
81
  getSessions: (chainId: CaipNetworkId, address: string) => Promise<SIWXSession[]>;
29
82
  }
30
83
  /**
31
- * @experimental - This is an experimental feature and it is not production ready
84
+ * This interface represents a SIWX session, which is used to store the user's identity information.
32
85
  */
33
86
  export interface SIWXSession {
34
87
  data: SIWXMessage.Data;
@@ -37,18 +90,20 @@ export interface SIWXSession {
37
90
  cacao?: Cacao;
38
91
  }
39
92
  /**
40
- * @experimental - This is an experimental feature and it is not production ready
93
+ * This interface represents a SIWX message, which is used to create a message to be signed by the user.
94
+ * This must contain the necessary information to verify the user's identity and how to generate the string message.
41
95
  */
42
96
  export interface SIWXMessage extends SIWXMessage.Data, SIWXMessage.Methods {
43
97
  }
44
98
  export declare namespace SIWXMessage {
45
99
  /**
46
- * @experimental - This is an experimental feature and it is not production ready
100
+ * This interface represents the SIWX message data, which is used to create a message to be signed by the user.
47
101
  */
48
102
  interface Data extends Input, Metadata, Identifier {
49
103
  }
50
104
  /**
51
- * @experimental - This is an experimental feature and it is not production ready
105
+ * This interface represents the SIWX message input.
106
+ * Here must contain what is different for each user of the application.
52
107
  */
53
108
  interface Input {
54
109
  accountAddress: string;
@@ -56,7 +111,8 @@ export declare namespace SIWXMessage {
56
111
  notBefore?: Timestamp;
57
112
  }
58
113
  /**
59
- * @experimental - This is an experimental feature and it is not production ready
114
+ * This interface represents the SIWX message metadata.
115
+ * Here must contain the main data related to the app.
60
116
  */
61
117
  interface Metadata {
62
118
  domain: string;
@@ -67,7 +123,8 @@ export declare namespace SIWXMessage {
67
123
  resources?: string[];
68
124
  }
69
125
  /**
70
- * @experimental - This is an experimental feature and it is not production ready
126
+ * This interface represents the SIWX message identifier.
127
+ * Here must contain the request id and the timestamps.
71
128
  */
72
129
  interface Identifier {
73
130
  requestId?: string;
@@ -75,16 +132,21 @@ export declare namespace SIWXMessage {
75
132
  expirationTime?: Timestamp;
76
133
  }
77
134
  /**
78
- * @experimental - This is an experimental feature and it is not production ready
135
+ * This interface represents the SIWX message methods.
136
+ * Here must contain the method to generate the message string and any other method performed by the SIWX message.
79
137
  */
80
138
  interface Methods {
81
139
  toString: () => string;
82
140
  }
83
141
  /**
84
- * @experimental - This is an experimental feature and it is not production ready
142
+ * The timestamp is a UTC string representing the time in ISO 8601 format.
85
143
  */
86
144
  type Timestamp = string;
87
145
  }
146
+ /**
147
+ * The Cacao interface is a reference of CAIP-74 and represents a chain-agnostic Object Capability (OCAP).
148
+ * https://chainagnostic.org/CAIPs/caip-74
149
+ */
88
150
  export interface Cacao {
89
151
  h: Cacao.Header;
90
152
  p: Cacao.Payload;
@@ -18,7 +18,7 @@ export declare const SwapApiUtil: {
18
18
  fast: string | undefined;
19
19
  instant: string | undefined;
20
20
  } | null>;
21
- fetchSwapAllowance({ tokenAddress, userAddress, sourceTokenAmount, sourceTokenDecimals }: Pick<BlockchainApiSwapAllowanceRequest, "userAddress" | "tokenAddress"> & {
21
+ fetchSwapAllowance({ tokenAddress, userAddress, sourceTokenAmount, sourceTokenDecimals }: Pick<BlockchainApiSwapAllowanceRequest, "tokenAddress" | "userAddress"> & {
22
22
  sourceTokenAmount: string;
23
23
  sourceTokenDecimals: number;
24
24
  }): Promise<boolean>;
@@ -347,6 +347,9 @@ export type Event = {
347
347
  } | {
348
348
  type: 'track';
349
349
  event: 'DISCONNECT_ERROR';
350
+ properties?: {
351
+ message: string;
352
+ };
350
353
  } | {
351
354
  type: 'track';
352
355
  event: 'CLICK_WALLET_HELP';
@@ -732,12 +735,12 @@ export type EstimateGasTransactionArgs = {
732
735
  chainNamespace: 'solana';
733
736
  };
734
737
  export interface WriteContractArgs {
735
- receiverAddress: `0x${string}`;
736
- tokenAmount: bigint;
737
738
  tokenAddress: `0x${string}`;
738
739
  fromAddress: `0x${string}`;
739
- method: 'send' | 'transfer' | 'call';
740
+ method: 'send' | 'transfer' | 'call' | 'approve';
740
741
  abi: any;
742
+ args: unknown[];
743
+ chainNamespace: ChainNamespace;
741
744
  }
742
745
  export interface NetworkControllerClient {
743
746
  switchCaipNetwork: (network: CaipNetwork) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reown/appkit-core",
3
- "version": "1.6.0",
3
+ "version": "1.6.1-rc.0",
4
4
  "type": "module",
5
5
  "main": "./dist/esm/exports/index.js",
6
6
  "types": "./dist/types/exports/index.d.ts",
@@ -36,11 +36,11 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@walletconnect/universal-provider": "2.17.0",
39
+ "@walletconnect/universal-provider": "2.17.2",
40
40
  "valtio": "1.11.2",
41
41
  "viem": "2.x",
42
- "@reown/appkit-common": "1.6.0",
43
- "@reown/appkit-wallet": "1.6.0"
42
+ "@reown/appkit-common": "1.6.1-rc.0",
43
+ "@reown/appkit-wallet": "1.6.1-rc.0"
44
44
  },
45
45
  "peerDependencies": {},
46
46
  "devDependencies": {