@kodiak-finance/orderly-wallet-connector-privy 2.7.4
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/README.md +91 -0
- package/dist/index.d.mts +112 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +3403 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3366 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# wallet connector privy
|
|
2
|
+
|
|
3
|
+
The new wallet connector consists of three parts:
|
|
4
|
+
|
|
5
|
+
- Privy: Privy provides social login, featuring an injected wallet, EVM wallets, and Solana wallets.
|
|
6
|
+
- Wagmi: Wagmi offers connectivity for EVM wallets, such as MetaMask and WalletConnect.
|
|
7
|
+
- Solana: Solana provides connectivity for Solana wallets, such as Phantom and Ledger.
|
|
8
|
+
|
|
9
|
+
other configure:
|
|
10
|
+
|
|
11
|
+
- `network` require, mainnet or testnet, For example, Solana and Abstract will use this network to determine what network it is.
|
|
12
|
+
- `customChains` optional, Brokers can define which chains to display
|
|
13
|
+
- `termsOfUse` optional
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
interface WalletConnectorPrivyProps{
|
|
17
|
+
network: Network;
|
|
18
|
+
customChains?: Chains;
|
|
19
|
+
termsOfUse?: string;
|
|
20
|
+
privyConfig?: InitPrivy;
|
|
21
|
+
wagmiConfig?: InitWagmi;
|
|
22
|
+
solanaConfig?: InitSolana;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
if termsOfUse is not configured, will not show terms part.
|
|
27
|
+
|
|
28
|
+
If privyConfig is not configured, the Privy connector will be disabled.
|
|
29
|
+
|
|
30
|
+
If wagmiConfig is not configured, the Wagmi connector will be disabled.
|
|
31
|
+
|
|
32
|
+
If solanaConfig is not configured, the Solana connector will be disabled.
|
|
33
|
+
|
|
34
|
+
If abstractConfig is not configured, the Abstract Global Wallet connector will be disabled.
|
|
35
|
+
|
|
36
|
+
At least one of privyConfig, wagmiConfig, or solanaConfig must be provided.
|
|
37
|
+
|
|
38
|
+
If customChains only includes a Solana chain, then Privy will only display the Solana injected wallet, and the Wagmi connector will be disabled.
|
|
39
|
+
|
|
40
|
+
If customChains only includes EVM chains, then Privy will only display the EVM injected wallet, and the Solana connector will be disabled.
|
|
41
|
+
|
|
42
|
+
eg:
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
<WalletConnectorPrivyProvider
|
|
46
|
+
termsOfUse="https://learn.woo.org/legal/terms-of-use"
|
|
47
|
+
network={Network.testnet}
|
|
48
|
+
// customChains={customChains}
|
|
49
|
+
privyConfig={{
|
|
50
|
+
appid: "you privy appid",
|
|
51
|
+
config: {
|
|
52
|
+
appearance: {
|
|
53
|
+
theme: "dark",
|
|
54
|
+
accentColor: "#181C23",
|
|
55
|
+
logo: "/orderly-logo.svg",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}}
|
|
59
|
+
wagmiConfig={{
|
|
60
|
+
connectors: [
|
|
61
|
+
wagmiConnectors.injected(),
|
|
62
|
+
wagmiConnectors.walletConnect({
|
|
63
|
+
projectId: "you project id",
|
|
64
|
+
showQrModal: true,
|
|
65
|
+
storageOptions: {},
|
|
66
|
+
metadata: {
|
|
67
|
+
name: "Orderly Network",
|
|
68
|
+
description: "Orderly Network",
|
|
69
|
+
url: "https://orderly.network",
|
|
70
|
+
icons: ["https://oss.orderly.network/static/sdk/chains.png"],
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
}}
|
|
75
|
+
solanaConfig={{
|
|
76
|
+
mainnetRpc: "",
|
|
77
|
+
devnetRpc: "https://api.devnet.solana.com",
|
|
78
|
+
wallets: wallets,
|
|
79
|
+
onError: (error: WalletError, adapter?: Adapter) => {
|
|
80
|
+
console.log("-- error", error, adapter);
|
|
81
|
+
},
|
|
82
|
+
}}
|
|
83
|
+
abstractConfig={{}}
|
|
84
|
+
>
|
|
85
|
+
<OrderlyAppProvider
|
|
86
|
+
// ...orderAppConfig
|
|
87
|
+
>
|
|
88
|
+
{props.children}
|
|
89
|
+
</OrderlyAppProvider>
|
|
90
|
+
</WalletConnectorPrivyProvider>
|
|
91
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { WalletState, Chains } from '@kodiak-finance/orderly-hooks';
|
|
3
|
+
import { PrivyClientConfig } from '@privy-io/react-auth';
|
|
4
|
+
import { Adapter, WalletError, WalletAdapterNetwork, WalletAdapter } from '@solana/wallet-adapter-base';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
import * as WagmiExport from 'wagmi';
|
|
7
|
+
import { CreateConnectorFn, Storage, Connector } from 'wagmi';
|
|
8
|
+
import { ChainNamespace } from '@kodiak-finance/orderly-types';
|
|
9
|
+
import * as viemExport from 'viem';
|
|
10
|
+
import * as WagmiConnectorsExport from 'wagmi/connectors';
|
|
11
|
+
|
|
12
|
+
type SolanaInitialProps = PropsWithChildren<{
|
|
13
|
+
network?: WalletAdapterNetwork;
|
|
14
|
+
endPoint?: string;
|
|
15
|
+
mainnetRpc?: string;
|
|
16
|
+
devnetRpc?: string;
|
|
17
|
+
wallets?: Adapter[];
|
|
18
|
+
onError?: (error: WalletError, adapter?: Adapter) => void;
|
|
19
|
+
}>;
|
|
20
|
+
declare enum Network {
|
|
21
|
+
mainnet = "mainnet",
|
|
22
|
+
testnet = "testnet"
|
|
23
|
+
}
|
|
24
|
+
declare enum WalletType {
|
|
25
|
+
EVM = "EVM",
|
|
26
|
+
SOL = "SOL",
|
|
27
|
+
ABSTRACT = "Abstract"
|
|
28
|
+
}
|
|
29
|
+
declare enum WalletConnectType {
|
|
30
|
+
EVM = "EVM",
|
|
31
|
+
SOL = "SOL",
|
|
32
|
+
PRIVY = "privy",
|
|
33
|
+
ABSTRACT = "Abstract"
|
|
34
|
+
}
|
|
35
|
+
interface ConnectProps {
|
|
36
|
+
walletType: WalletConnectType;
|
|
37
|
+
extraType?: string;
|
|
38
|
+
connector?: Connector;
|
|
39
|
+
walletAdapter?: WalletAdapter;
|
|
40
|
+
}
|
|
41
|
+
interface InitPrivy {
|
|
42
|
+
appid: string;
|
|
43
|
+
config?: {
|
|
44
|
+
appearance: Omit<PrivyClientConfig["appearance"], "walletChainType" | "walletList">;
|
|
45
|
+
loginMethods?: PrivyClientConfig["loginMethods"];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
interface InitWagmi {
|
|
49
|
+
connectors?: CreateConnectorFn[];
|
|
50
|
+
storage?: Storage;
|
|
51
|
+
}
|
|
52
|
+
interface InitSolana {
|
|
53
|
+
mainnetRpc?: string;
|
|
54
|
+
devnetRpc?: string;
|
|
55
|
+
wallets: Adapter[];
|
|
56
|
+
onError: (error: WalletError, adapter?: Adapter) => void;
|
|
57
|
+
}
|
|
58
|
+
interface InitAbstract {
|
|
59
|
+
queryClient?: QueryClient;
|
|
60
|
+
}
|
|
61
|
+
declare const SolanaChains: Map<WalletAdapterNetwork, number>;
|
|
62
|
+
declare const SolanaChainsMap: Map<WalletAdapterNetwork | Network, number>;
|
|
63
|
+
declare const AbstractChainsMap: Map<Network, number>;
|
|
64
|
+
interface ConnectorWalletType {
|
|
65
|
+
disableWagmi?: boolean;
|
|
66
|
+
disablePrivy?: boolean;
|
|
67
|
+
disableSolana?: boolean;
|
|
68
|
+
disableAGW?: boolean;
|
|
69
|
+
}
|
|
70
|
+
interface WalletChainTypeConfig {
|
|
71
|
+
hasEvm: boolean;
|
|
72
|
+
hasSol: boolean;
|
|
73
|
+
hasAbstract: boolean;
|
|
74
|
+
}
|
|
75
|
+
declare enum WalletChainTypeEnum {
|
|
76
|
+
onlyEVM = "onlyEVM",
|
|
77
|
+
onlySOL = "onlySOL",
|
|
78
|
+
EVM_SOL = "EVM_SOL"
|
|
79
|
+
}
|
|
80
|
+
type WalletChainType = WalletChainTypeEnum;
|
|
81
|
+
type IWalletState = WalletState & {
|
|
82
|
+
chain?: {
|
|
83
|
+
namespace: ChainNamespace;
|
|
84
|
+
id: number;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
interface WalletConnectorPrivyProps extends PropsWithChildren {
|
|
89
|
+
privyConfig?: InitPrivy;
|
|
90
|
+
wagmiConfig?: InitWagmi;
|
|
91
|
+
solanaConfig?: InitSolana;
|
|
92
|
+
abstractConfig?: InitAbstract;
|
|
93
|
+
network: Network;
|
|
94
|
+
customChains?: Chains;
|
|
95
|
+
termsOfUse?: string;
|
|
96
|
+
headerProps?: {
|
|
97
|
+
mobile: React.ReactNode;
|
|
98
|
+
};
|
|
99
|
+
enableSwapDeposit?: boolean;
|
|
100
|
+
}
|
|
101
|
+
declare function WalletConnectorPrivyProvider(props: WalletConnectorPrivyProps): React.JSX.Element | null;
|
|
102
|
+
|
|
103
|
+
declare function UserCenter(props: any): React.JSX.Element;
|
|
104
|
+
declare const MwebUserCenter: (props: any) => React.JSX.Element;
|
|
105
|
+
|
|
106
|
+
declare const viem: typeof viemExport;
|
|
107
|
+
|
|
108
|
+
declare const wagmiConnectors: typeof WagmiConnectorsExport;
|
|
109
|
+
|
|
110
|
+
declare const wagmi: typeof WagmiExport;
|
|
111
|
+
|
|
112
|
+
export { AbstractChainsMap, type ConnectProps, type ConnectorWalletType, type IWalletState, type InitAbstract, type InitPrivy, type InitSolana, type InitWagmi, MwebUserCenter, Network, SolanaChains, SolanaChainsMap, type SolanaInitialProps, UserCenter, type WalletChainType, type WalletChainTypeConfig, WalletChainTypeEnum, WalletConnectType, WalletConnectorPrivyProvider, WalletType, viem, wagmi, wagmiConnectors };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { WalletState, Chains } from '@kodiak-finance/orderly-hooks';
|
|
3
|
+
import { PrivyClientConfig } from '@privy-io/react-auth';
|
|
4
|
+
import { Adapter, WalletError, WalletAdapterNetwork, WalletAdapter } from '@solana/wallet-adapter-base';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
import * as WagmiExport from 'wagmi';
|
|
7
|
+
import { CreateConnectorFn, Storage, Connector } from 'wagmi';
|
|
8
|
+
import { ChainNamespace } from '@kodiak-finance/orderly-types';
|
|
9
|
+
import * as viemExport from 'viem';
|
|
10
|
+
import * as WagmiConnectorsExport from 'wagmi/connectors';
|
|
11
|
+
|
|
12
|
+
type SolanaInitialProps = PropsWithChildren<{
|
|
13
|
+
network?: WalletAdapterNetwork;
|
|
14
|
+
endPoint?: string;
|
|
15
|
+
mainnetRpc?: string;
|
|
16
|
+
devnetRpc?: string;
|
|
17
|
+
wallets?: Adapter[];
|
|
18
|
+
onError?: (error: WalletError, adapter?: Adapter) => void;
|
|
19
|
+
}>;
|
|
20
|
+
declare enum Network {
|
|
21
|
+
mainnet = "mainnet",
|
|
22
|
+
testnet = "testnet"
|
|
23
|
+
}
|
|
24
|
+
declare enum WalletType {
|
|
25
|
+
EVM = "EVM",
|
|
26
|
+
SOL = "SOL",
|
|
27
|
+
ABSTRACT = "Abstract"
|
|
28
|
+
}
|
|
29
|
+
declare enum WalletConnectType {
|
|
30
|
+
EVM = "EVM",
|
|
31
|
+
SOL = "SOL",
|
|
32
|
+
PRIVY = "privy",
|
|
33
|
+
ABSTRACT = "Abstract"
|
|
34
|
+
}
|
|
35
|
+
interface ConnectProps {
|
|
36
|
+
walletType: WalletConnectType;
|
|
37
|
+
extraType?: string;
|
|
38
|
+
connector?: Connector;
|
|
39
|
+
walletAdapter?: WalletAdapter;
|
|
40
|
+
}
|
|
41
|
+
interface InitPrivy {
|
|
42
|
+
appid: string;
|
|
43
|
+
config?: {
|
|
44
|
+
appearance: Omit<PrivyClientConfig["appearance"], "walletChainType" | "walletList">;
|
|
45
|
+
loginMethods?: PrivyClientConfig["loginMethods"];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
interface InitWagmi {
|
|
49
|
+
connectors?: CreateConnectorFn[];
|
|
50
|
+
storage?: Storage;
|
|
51
|
+
}
|
|
52
|
+
interface InitSolana {
|
|
53
|
+
mainnetRpc?: string;
|
|
54
|
+
devnetRpc?: string;
|
|
55
|
+
wallets: Adapter[];
|
|
56
|
+
onError: (error: WalletError, adapter?: Adapter) => void;
|
|
57
|
+
}
|
|
58
|
+
interface InitAbstract {
|
|
59
|
+
queryClient?: QueryClient;
|
|
60
|
+
}
|
|
61
|
+
declare const SolanaChains: Map<WalletAdapterNetwork, number>;
|
|
62
|
+
declare const SolanaChainsMap: Map<WalletAdapterNetwork | Network, number>;
|
|
63
|
+
declare const AbstractChainsMap: Map<Network, number>;
|
|
64
|
+
interface ConnectorWalletType {
|
|
65
|
+
disableWagmi?: boolean;
|
|
66
|
+
disablePrivy?: boolean;
|
|
67
|
+
disableSolana?: boolean;
|
|
68
|
+
disableAGW?: boolean;
|
|
69
|
+
}
|
|
70
|
+
interface WalletChainTypeConfig {
|
|
71
|
+
hasEvm: boolean;
|
|
72
|
+
hasSol: boolean;
|
|
73
|
+
hasAbstract: boolean;
|
|
74
|
+
}
|
|
75
|
+
declare enum WalletChainTypeEnum {
|
|
76
|
+
onlyEVM = "onlyEVM",
|
|
77
|
+
onlySOL = "onlySOL",
|
|
78
|
+
EVM_SOL = "EVM_SOL"
|
|
79
|
+
}
|
|
80
|
+
type WalletChainType = WalletChainTypeEnum;
|
|
81
|
+
type IWalletState = WalletState & {
|
|
82
|
+
chain?: {
|
|
83
|
+
namespace: ChainNamespace;
|
|
84
|
+
id: number;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
interface WalletConnectorPrivyProps extends PropsWithChildren {
|
|
89
|
+
privyConfig?: InitPrivy;
|
|
90
|
+
wagmiConfig?: InitWagmi;
|
|
91
|
+
solanaConfig?: InitSolana;
|
|
92
|
+
abstractConfig?: InitAbstract;
|
|
93
|
+
network: Network;
|
|
94
|
+
customChains?: Chains;
|
|
95
|
+
termsOfUse?: string;
|
|
96
|
+
headerProps?: {
|
|
97
|
+
mobile: React.ReactNode;
|
|
98
|
+
};
|
|
99
|
+
enableSwapDeposit?: boolean;
|
|
100
|
+
}
|
|
101
|
+
declare function WalletConnectorPrivyProvider(props: WalletConnectorPrivyProps): React.JSX.Element | null;
|
|
102
|
+
|
|
103
|
+
declare function UserCenter(props: any): React.JSX.Element;
|
|
104
|
+
declare const MwebUserCenter: (props: any) => React.JSX.Element;
|
|
105
|
+
|
|
106
|
+
declare const viem: typeof viemExport;
|
|
107
|
+
|
|
108
|
+
declare const wagmiConnectors: typeof WagmiConnectorsExport;
|
|
109
|
+
|
|
110
|
+
declare const wagmi: typeof WagmiExport;
|
|
111
|
+
|
|
112
|
+
export { AbstractChainsMap, type ConnectProps, type ConnectorWalletType, type IWalletState, type InitAbstract, type InitPrivy, type InitSolana, type InitWagmi, MwebUserCenter, Network, SolanaChains, SolanaChainsMap, type SolanaInitialProps, UserCenter, type WalletChainType, type WalletChainTypeConfig, WalletChainTypeEnum, WalletConnectType, WalletConnectorPrivyProvider, WalletType, viem, wagmi, wagmiConnectors };
|