@getpara/evm-wallet-connectors 2.0.0-alpha.19 → 2.0.0-alpha.20
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/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/dist/providers/ParaEvmContext.d.ts +2 -1
- package/dist/providers/ParaEvmContext.js +6 -2
- package/dist/providers/createParaWagmiConfig.d.ts +10 -0
- package/dist/providers/createParaWagmiConfig.js +62 -0
- package/dist/stores/wagmiConfigStore.d.ts +11 -0
- package/dist/utils/resolveWalletList.d.ts +3 -0
- package/dist/utils/resolveWalletList.js +16 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { createParaWagmiConfig } from './providers/createParaWagmiConfig.js';
|
|
1
2
|
export { EvmExternalWalletContext } from './providers/EvmExternalWalletContext.js';
|
|
2
3
|
export type { EvmExternalWalletContextType } from './providers/EvmExternalWalletContext.js';
|
|
3
4
|
export { ParaEvmProvider } from './providers/ParaEvmContext.js';
|
|
4
5
|
export type { ParaEvmProviderProps, ParaEvmProviderConfig, ParaWagmiProviderProps } from './providers/ParaEvmContext.js';
|
|
5
|
-
export * from './wallets/connectors/index.js';
|
|
6
|
-
export type { WalletList } from './types/Wallet.js';
|
|
7
6
|
export { getWagmiConfig } from './stores/wagmiConfigStore.js';
|
|
7
|
+
export type { WalletList } from './types/Wallet.js';
|
|
8
|
+
export * from './wallets/connectors/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./chunk-MMUBH76A.js";
|
|
3
|
+
import { createParaWagmiConfig } from "./providers/createParaWagmiConfig.js";
|
|
3
4
|
import { EvmExternalWalletContext } from "./providers/EvmExternalWalletContext.js";
|
|
4
5
|
import { ParaEvmProvider } from "./providers/ParaEvmContext.js";
|
|
5
|
-
export * from "./wallets/connectors/index.js";
|
|
6
6
|
import { getWagmiConfig } from "./stores/wagmiConfigStore.js";
|
|
7
|
+
export * from "./wallets/connectors/index.js";
|
|
7
8
|
export {
|
|
8
9
|
EvmExternalWalletContext,
|
|
9
10
|
ParaEvmProvider,
|
|
11
|
+
createParaWagmiConfig,
|
|
10
12
|
getWagmiConfig
|
|
11
13
|
};
|
|
@@ -4,12 +4,13 @@ import { WalletList } from '../types/Wallet.js';
|
|
|
4
4
|
import { Chain, Transport } from 'viem';
|
|
5
5
|
import { EvmExternalWalletProviderConfig } from './EvmExternalWalletContext.js';
|
|
6
6
|
import { InjectedParameters } from 'wagmi/connectors';
|
|
7
|
+
import { TExternalWallet } from '@getpara/react-common';
|
|
7
8
|
export interface ParaEvmProviderConfig<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends Omit<CreateConfigParameters<chains, transports>, 'connectors'> {
|
|
8
9
|
appName: string;
|
|
9
10
|
appDescription?: string;
|
|
10
11
|
appUrl?: string;
|
|
11
12
|
appIcon?: string;
|
|
12
|
-
wallets?: WalletList;
|
|
13
|
+
wallets?: WalletList | TExternalWallet[];
|
|
13
14
|
projectId: string;
|
|
14
15
|
paraConnectorOptions?: InjectedParameters;
|
|
15
16
|
}
|
|
@@ -12,7 +12,8 @@ import { http } from "viem";
|
|
|
12
12
|
import { computeWalletConnectMetaData } from "../utils/computeWalletConnectMetaData.js";
|
|
13
13
|
import { EvmExternalWalletProvider } from "./EvmExternalWalletContext.js";
|
|
14
14
|
import { paraConnector } from "@getpara/wagmi-v2-connector";
|
|
15
|
-
import { setWagmiConfig } from "../stores/wagmiConfigStore.js";
|
|
15
|
+
import { setWagmiConfig, getWagmiConfig } from "../stores/wagmiConfigStore.js";
|
|
16
|
+
import { resolveWalletList } from "../utils/resolveWalletList.js";
|
|
16
17
|
const createDefaultTransports = (chains) => {
|
|
17
18
|
const transportsObject = chains.reduce((acc, chain) => {
|
|
18
19
|
const key = chain.id;
|
|
@@ -59,8 +60,11 @@ function ParaEvmProvider({
|
|
|
59
60
|
});
|
|
60
61
|
}, [para]);
|
|
61
62
|
const config = useMemo(() => {
|
|
63
|
+
const existing = getWagmiConfig();
|
|
64
|
+
if (existing) return existing;
|
|
62
65
|
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
63
|
-
const
|
|
66
|
+
const walletFactories = resolveWalletList(wallets);
|
|
67
|
+
const baseConnectors = connectorsForWallets(walletFactories, {
|
|
64
68
|
projectId,
|
|
65
69
|
appName,
|
|
66
70
|
appDescription,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Chain, Transport } from 'viem';
|
|
2
|
+
import type { ParaEvmProviderConfig } from './ParaEvmContext.js';
|
|
3
|
+
import ParaWeb from '@getpara/web-sdk';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Wagmi configuration for the Para EVM provider.
|
|
6
|
+
* @param para - The ParaWeb instance to use.
|
|
7
|
+
* @param cfg - The configuration options for the Para EVM provider.
|
|
8
|
+
* @returns The created Wagmi configuration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createParaWagmiConfig<const chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>>(para: ParaWeb, cfg: ParaEvmProviderConfig<chains, transports>): import("wagmi").Config<chains, transports, readonly import("wagmi").CreateConnectorFn[]>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../chunk-MMUBH76A.js";
|
|
7
|
+
import { createConfig } from "wagmi";
|
|
8
|
+
import { connectorsForWallets } from "../wallets/connectorsForWallets.js";
|
|
9
|
+
import { computeWalletConnectMetaData } from "../utils/computeWalletConnectMetaData.js";
|
|
10
|
+
import { paraConnector } from "@getpara/wagmi-v2-connector";
|
|
11
|
+
import { setWagmiConfig } from "../stores/wagmiConfigStore.js";
|
|
12
|
+
import { resolveWalletList } from "../utils/resolveWalletList.js";
|
|
13
|
+
function createParaWagmiConfig(para, cfg) {
|
|
14
|
+
const _a = cfg, {
|
|
15
|
+
projectId,
|
|
16
|
+
appName,
|
|
17
|
+
appDescription,
|
|
18
|
+
appIcon,
|
|
19
|
+
appUrl,
|
|
20
|
+
wallets,
|
|
21
|
+
chains,
|
|
22
|
+
transports,
|
|
23
|
+
paraConnectorOptions
|
|
24
|
+
} = _a, wagmiParams = __objRest(_a, [
|
|
25
|
+
"projectId",
|
|
26
|
+
"appName",
|
|
27
|
+
"appDescription",
|
|
28
|
+
"appIcon",
|
|
29
|
+
"appUrl",
|
|
30
|
+
"wallets",
|
|
31
|
+
"chains",
|
|
32
|
+
"transports",
|
|
33
|
+
"paraConnectorOptions"
|
|
34
|
+
]);
|
|
35
|
+
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
36
|
+
const walletFactories = resolveWalletList(wallets);
|
|
37
|
+
const baseConnectors = connectorsForWallets(walletFactories, {
|
|
38
|
+
projectId,
|
|
39
|
+
appName,
|
|
40
|
+
appDescription,
|
|
41
|
+
appUrl,
|
|
42
|
+
appIcon,
|
|
43
|
+
walletConnectParameters: { metadata: wcMetadata }
|
|
44
|
+
});
|
|
45
|
+
const paraConn = paraConnector({
|
|
46
|
+
para,
|
|
47
|
+
chains: [...chains],
|
|
48
|
+
disableModal: true,
|
|
49
|
+
appName,
|
|
50
|
+
options: paraConnectorOptions != null ? paraConnectorOptions : {}
|
|
51
|
+
});
|
|
52
|
+
const created = createConfig(__spreadProps(__spreadValues({}, wagmiParams), {
|
|
53
|
+
chains,
|
|
54
|
+
transports,
|
|
55
|
+
connectors: [...baseConnectors, paraConn]
|
|
56
|
+
}));
|
|
57
|
+
setWagmiConfig(created);
|
|
58
|
+
return created;
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
createParaWagmiConfig
|
|
62
|
+
};
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { Config } from 'wagmi';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the Wagmi configuration in the global store.
|
|
4
|
+
*
|
|
5
|
+
* @param config - The Wagmi configuration object to be stored
|
|
6
|
+
* @returns {void}
|
|
7
|
+
*/
|
|
2
8
|
export declare const setWagmiConfig: (config: Config) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the current Wagmi configuration from the global store.
|
|
11
|
+
*
|
|
12
|
+
* @returns {Config | null} - The current Wagmi configuration or null if not set
|
|
13
|
+
*/
|
|
3
14
|
export declare const getWagmiConfig: () => Config;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-MMUBH76A.js";
|
|
3
|
+
import { allWallets } from "../wallets/connectors/index.js";
|
|
4
|
+
function resolveWalletList(wallets) {
|
|
5
|
+
if (!wallets || !wallets.length) return [];
|
|
6
|
+
if (typeof wallets[0] === "function") return wallets;
|
|
7
|
+
const ids = wallets;
|
|
8
|
+
const resolved = allWallets.filter((createWalletFn) => {
|
|
9
|
+
const meta = createWalletFn({ projectId: "", appName: "" });
|
|
10
|
+
return ids.includes(meta.id.toUpperCase());
|
|
11
|
+
});
|
|
12
|
+
return resolved;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
resolveWalletList
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@coinbase/wallet-sdk": "4.3.0",
|
|
13
|
-
"@getpara/wagmi-v2-connector": "2.0.0-alpha.
|
|
14
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
13
|
+
"@getpara/wagmi-v2-connector": "2.0.0-alpha.20",
|
|
14
|
+
"@getpara/web-sdk": "2.0.0-alpha.20",
|
|
15
15
|
"viem": "^2.24.2",
|
|
16
16
|
"wagmi": "^2.14.16",
|
|
17
17
|
"zustand": "^4.5.2",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "vitest run --coverage"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
26
|
+
"@getpara/react-common": "2.0.0-alpha.20",
|
|
27
27
|
"@tanstack/react-query": ">=5.0.0",
|
|
28
28
|
"@types/react": "^18.0.31",
|
|
29
29
|
"@types/react-dom": "^18.2.7",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"dist",
|
|
40
40
|
"package.json"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4c8d918b9fc387476968bfc08524fe1a8b6ec83b"
|
|
43
43
|
}
|