@mysten/dapp-kit 1.0.5 → 1.0.6
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/CHANGELOG.md +12 -0
- package/dist/components/AccountDropdownMenu.css.d.ts +7 -0
- package/dist/components/AccountDropdownMenu.css.d.ts.map +1 -0
- package/dist/components/AccountDropdownMenu.d.ts +11 -0
- package/dist/components/AccountDropdownMenu.d.ts.map +1 -0
- package/dist/components/ConnectButton.d.ts +10 -0
- package/dist/components/ConnectButton.d.ts.map +1 -0
- package/dist/components/SuiClientProvider.d.ts +26 -0
- package/dist/components/SuiClientProvider.d.ts.map +1 -0
- package/dist/components/WalletProvider.d.ts +27 -0
- package/dist/components/WalletProvider.d.ts.map +1 -0
- package/dist/components/connect-modal/ConnectModal.css.d.ts +12 -0
- package/dist/components/connect-modal/ConnectModal.css.d.ts.map +1 -0
- package/dist/components/connect-modal/ConnectModal.d.ts +24 -0
- package/dist/components/connect-modal/ConnectModal.d.ts.map +1 -0
- package/dist/components/connect-modal/InfoSection.css.d.ts +2 -0
- package/dist/components/connect-modal/InfoSection.css.d.ts.map +1 -0
- package/dist/components/connect-modal/InfoSection.d.ts +7 -0
- package/dist/components/connect-modal/InfoSection.d.ts.map +1 -0
- package/dist/components/connect-modal/views/ConnectionStatus.css.d.ts +6 -0
- package/dist/components/connect-modal/views/ConnectionStatus.css.d.ts.map +1 -0
- package/dist/components/connect-modal/views/ConnectionStatus.d.ts +9 -0
- package/dist/components/connect-modal/views/ConnectionStatus.d.ts.map +1 -0
- package/dist/components/connect-modal/views/GettingStarted.css.d.ts +4 -0
- package/dist/components/connect-modal/views/GettingStarted.css.d.ts.map +1 -0
- package/dist/components/connect-modal/views/GettingStarted.d.ts +2 -0
- package/dist/components/connect-modal/views/GettingStarted.d.ts.map +1 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.css.d.ts +3 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.css.d.ts.map +1 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.d.ts +2 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletList.css.d.ts +2 -0
- package/dist/components/connect-modal/wallet-list/WalletList.css.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletList.d.ts +10 -0
- package/dist/components/connect-modal/wallet-list/WalletList.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.css.d.ts +5 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.css.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.d.ts +10 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.d.ts.map +1 -0
- package/dist/components/icons/BackIcon.d.ts +3 -0
- package/dist/components/icons/BackIcon.d.ts.map +1 -0
- package/dist/components/icons/CheckIcon.d.ts +3 -0
- package/dist/components/icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/ChevronIcon.d.ts +3 -0
- package/dist/components/icons/ChevronIcon.d.ts.map +1 -0
- package/dist/components/icons/CloseIcon.d.ts +3 -0
- package/dist/components/icons/CloseIcon.d.ts.map +1 -0
- package/dist/components/styling/InjectedThemeStyles.d.ts +7 -0
- package/dist/components/styling/InjectedThemeStyles.d.ts.map +1 -0
- package/dist/components/styling/StyleMarker.css.d.ts +2 -0
- package/dist/components/styling/StyleMarker.css.d.ts.map +1 -0
- package/dist/components/styling/StyleMarker.d.ts +3 -0
- package/dist/components/styling/StyleMarker.d.ts.map +1 -0
- package/dist/components/ui/Button.css.d.ts +34 -0
- package/dist/components/ui/Button.css.d.ts.map +1 -0
- package/dist/components/ui/Button.d.ts +9 -0
- package/dist/components/ui/Button.d.ts.map +1 -0
- package/dist/components/ui/Heading.css.d.ts +34 -0
- package/dist/components/ui/Heading.css.d.ts.map +1 -0
- package/dist/components/ui/Heading.d.ts +13 -0
- package/dist/components/ui/Heading.d.ts.map +1 -0
- package/dist/components/ui/IconButton.css.d.ts +2 -0
- package/dist/components/ui/IconButton.css.d.ts.map +1 -0
- package/dist/components/ui/IconButton.d.ts +7 -0
- package/dist/components/ui/IconButton.d.ts.map +1 -0
- package/dist/components/ui/Text.css.d.ts +34 -0
- package/dist/components/ui/Text.css.d.ts.map +1 -0
- package/dist/components/ui/Text.d.ts +13 -0
- package/dist/components/ui/Text.d.ts.map +1 -0
- package/dist/constants/styleDataAttribute.d.ts +6 -0
- package/dist/constants/styleDataAttribute.d.ts.map +1 -0
- package/dist/constants/walletDefaults.d.ts +7 -0
- package/dist/constants/walletDefaults.d.ts.map +1 -0
- package/dist/constants/walletMutationKeys.d.ts +14 -0
- package/dist/constants/walletMutationKeys.d.ts.map +1 -0
- package/dist/contexts/walletContext.d.ts +14 -0
- package/dist/contexts/walletContext.d.ts.map +1 -0
- package/dist/errors/walletErrors.d.ts +23 -0
- package/dist/errors/walletErrors.d.ts.map +1 -0
- package/dist/hooks/networkConfig.d.ts +11 -0
- package/dist/hooks/networkConfig.d.ts.map +1 -0
- package/dist/hooks/useResolveSuiNSNames.d.ts +4 -0
- package/dist/hooks/useResolveSuiNSNames.d.ts.map +1 -0
- package/dist/hooks/useSuiClient.d.ts +4 -0
- package/dist/hooks/useSuiClient.d.ts.map +1 -0
- package/dist/hooks/useSuiClientInfiniteQuery.d.ts +26 -0
- package/dist/hooks/useSuiClientInfiniteQuery.d.ts.map +1 -0
- package/dist/hooks/useSuiClientMutation.d.ts +5 -0
- package/dist/hooks/useSuiClientMutation.d.ts.map +1 -0
- package/dist/hooks/useSuiClientQueries.d.ts +28 -0
- package/dist/hooks/useSuiClientQueries.d.ts.map +1 -0
- package/dist/hooks/useSuiClientQuery.d.ts +39 -0
- package/dist/hooks/useSuiClientQuery.d.ts.map +1 -0
- package/dist/hooks/wallet/useAccounts.d.ts +6 -0
- package/dist/hooks/wallet/useAccounts.d.ts.map +1 -0
- package/dist/hooks/wallet/useAutoConnectWallet.d.ts +2 -0
- package/dist/hooks/wallet/useAutoConnectWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useConnectWallet.d.ts +16 -0
- package/dist/hooks/wallet/useConnectWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useCurrentAccount.d.ts +6 -0
- package/dist/hooks/wallet/useCurrentAccount.d.ts.map +1 -0
- package/dist/hooks/wallet/useCurrentWallet.d.ts +26 -0
- package/dist/hooks/wallet/useCurrentWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useDisconnectWallet.d.ts +10 -0
- package/dist/hooks/wallet/useDisconnectWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useSignAndExecuteTransaction.d.ts +30 -0
- package/dist/hooks/wallet/useSignAndExecuteTransaction.d.ts.map +1 -0
- package/dist/hooks/wallet/useSignPersonalMessage.d.ts +14 -0
- package/dist/hooks/wallet/useSignPersonalMessage.d.ts.map +1 -0
- package/dist/hooks/wallet/useSignTransaction.d.ts +18 -0
- package/dist/hooks/wallet/useSignTransaction.d.ts.map +1 -0
- package/dist/hooks/wallet/useSlushWallet.d.ts +6 -0
- package/dist/hooks/wallet/useSlushWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useSwitchAccount.d.ts +15 -0
- package/dist/hooks/wallet/useSwitchAccount.d.ts.map +1 -0
- package/dist/hooks/wallet/useUnsafeBurnerWallet.d.ts +2 -0
- package/dist/hooks/wallet/useUnsafeBurnerWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useWalletPropertiesChanged.d.ts +5 -0
- package/dist/hooks/wallet/useWalletPropertiesChanged.d.ts.map +1 -0
- package/dist/hooks/wallet/useWalletStore.d.ts +3 -0
- package/dist/hooks/wallet/useWalletStore.d.ts.map +1 -0
- package/dist/hooks/wallet/useWallets.d.ts +5 -0
- package/dist/hooks/wallet/useWallets.d.ts.map +1 -0
- package/dist/hooks/wallet/useWalletsChanged.d.ts +6 -0
- package/dist/hooks/wallet/useWalletsChanged.d.ts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/themes/lightTheme.d.ts +3 -0
- package/dist/themes/lightTheme.d.ts.map +1 -0
- package/dist/themes/themeContract.d.ts +141 -0
- package/dist/themes/themeContract.d.ts.map +1 -0
- package/dist/types/utilityTypes.d.ts +2 -0
- package/dist/types/utilityTypes.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/assertUnreachable.d.ts +5 -0
- package/dist/utils/assertUnreachable.d.ts.map +1 -0
- package/dist/utils/stateStorage.d.ts +3 -0
- package/dist/utils/stateStorage.d.ts.map +1 -0
- package/dist/utils/walletUtils.d.ts +4 -0
- package/dist/utils/walletUtils.d.ts.map +1 -0
- package/dist/walletStore.d.ts +45 -0
- package/dist/walletStore.d.ts.map +1 -0
- package/docs/index.md +93 -0
- package/docs/llms-index.md +22 -0
- package/docs/rpc-hooks.md +166 -0
- package/docs/slush.md +29 -0
- package/docs/sui-client-provider.md +196 -0
- package/docs/themes.md +117 -0
- package/docs/wallet-components/ConnectButton.md +22 -0
- package/docs/wallet-components/ConnectModal.md +67 -0
- package/docs/wallet-hooks/useAccounts.md +36 -0
- package/docs/wallet-hooks/useAutoConnectWallet.md +29 -0
- package/docs/wallet-hooks/useConnectWallet.md +48 -0
- package/docs/wallet-hooks/useCurrentAccount.md +36 -0
- package/docs/wallet-hooks/useCurrentWallet.md +59 -0
- package/docs/wallet-hooks/useDisconnectWallet.md +26 -0
- package/docs/wallet-hooks/useSignAndExecuteTransaction.md +124 -0
- package/docs/wallet-hooks/useSignPersonalMessage.md +59 -0
- package/docs/wallet-hooks/useSignTransaction.md +67 -0
- package/docs/wallet-hooks/useSwitchAccount.md +47 -0
- package/docs/wallet-hooks/useWallets.md +38 -0
- package/docs/wallet-provider.md +38 -0
- package/package.json +5 -5
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
declare const themeContractValues: {
|
|
2
|
+
blurs: {
|
|
3
|
+
modalOverlay: string;
|
|
4
|
+
};
|
|
5
|
+
backgroundColors: {
|
|
6
|
+
primaryButton: string;
|
|
7
|
+
primaryButtonHover: string;
|
|
8
|
+
outlineButtonHover: string;
|
|
9
|
+
walletItemHover: string;
|
|
10
|
+
walletItemSelected: string;
|
|
11
|
+
modalOverlay: string;
|
|
12
|
+
modalPrimary: string;
|
|
13
|
+
modalSecondary: string;
|
|
14
|
+
iconButton: string;
|
|
15
|
+
iconButtonHover: string;
|
|
16
|
+
dropdownMenu: string;
|
|
17
|
+
dropdownMenuSeparator: string;
|
|
18
|
+
};
|
|
19
|
+
borderColors: {
|
|
20
|
+
outlineButton: string;
|
|
21
|
+
};
|
|
22
|
+
colors: {
|
|
23
|
+
primaryButton: string;
|
|
24
|
+
outlineButton: string;
|
|
25
|
+
body: string;
|
|
26
|
+
bodyMuted: string;
|
|
27
|
+
bodyDanger: string;
|
|
28
|
+
iconButton: string;
|
|
29
|
+
};
|
|
30
|
+
radii: {
|
|
31
|
+
small: string;
|
|
32
|
+
medium: string;
|
|
33
|
+
large: string;
|
|
34
|
+
xlarge: string;
|
|
35
|
+
};
|
|
36
|
+
shadows: {
|
|
37
|
+
primaryButton: string;
|
|
38
|
+
walletItemSelected: string;
|
|
39
|
+
};
|
|
40
|
+
fontWeights: {
|
|
41
|
+
normal: string;
|
|
42
|
+
medium: string;
|
|
43
|
+
bold: string;
|
|
44
|
+
};
|
|
45
|
+
fontSizes: {
|
|
46
|
+
small: string;
|
|
47
|
+
medium: string;
|
|
48
|
+
large: string;
|
|
49
|
+
xlarge: string;
|
|
50
|
+
};
|
|
51
|
+
typography: {
|
|
52
|
+
fontFamily: string;
|
|
53
|
+
fontStyle: string;
|
|
54
|
+
lineHeight: string;
|
|
55
|
+
letterSpacing: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export type ThemeVars = typeof themeContractValues;
|
|
59
|
+
/**
|
|
60
|
+
* A custom theme that is enabled when various conditions are
|
|
61
|
+
*/
|
|
62
|
+
export type DynamicTheme = {
|
|
63
|
+
/**
|
|
64
|
+
* An optional media query required for the given theme to be enabled. This is useful
|
|
65
|
+
* when you want the theme of your application to automatically switch depending on
|
|
66
|
+
* a media feature.
|
|
67
|
+
*
|
|
68
|
+
* @example '(prefers-color-scheme: dark)'
|
|
69
|
+
*/
|
|
70
|
+
mediaQuery?: string;
|
|
71
|
+
/**
|
|
72
|
+
* An optional CSS selector required for the given theme to be enabled. This is useful
|
|
73
|
+
* when you have a manual theme switcher on your application that sets a top-level
|
|
74
|
+
* class name or data-attribute to control the current theme.
|
|
75
|
+
*
|
|
76
|
+
* @example '.data-dark'
|
|
77
|
+
*/
|
|
78
|
+
selector?: string;
|
|
79
|
+
/** The theme definitions that will be set when the selector and mediaQuery criteria are matched. */
|
|
80
|
+
variables: ThemeVars;
|
|
81
|
+
};
|
|
82
|
+
export type Theme = ThemeVars | DynamicTheme[];
|
|
83
|
+
export declare const themeVars: {
|
|
84
|
+
blurs: {
|
|
85
|
+
modalOverlay: `var(--${string})`;
|
|
86
|
+
};
|
|
87
|
+
backgroundColors: {
|
|
88
|
+
primaryButton: `var(--${string})`;
|
|
89
|
+
primaryButtonHover: `var(--${string})`;
|
|
90
|
+
outlineButtonHover: `var(--${string})`;
|
|
91
|
+
walletItemHover: `var(--${string})`;
|
|
92
|
+
walletItemSelected: `var(--${string})`;
|
|
93
|
+
modalOverlay: `var(--${string})`;
|
|
94
|
+
modalPrimary: `var(--${string})`;
|
|
95
|
+
modalSecondary: `var(--${string})`;
|
|
96
|
+
iconButton: `var(--${string})`;
|
|
97
|
+
iconButtonHover: `var(--${string})`;
|
|
98
|
+
dropdownMenu: `var(--${string})`;
|
|
99
|
+
dropdownMenuSeparator: `var(--${string})`;
|
|
100
|
+
};
|
|
101
|
+
borderColors: {
|
|
102
|
+
outlineButton: `var(--${string})`;
|
|
103
|
+
};
|
|
104
|
+
colors: {
|
|
105
|
+
primaryButton: `var(--${string})`;
|
|
106
|
+
outlineButton: `var(--${string})`;
|
|
107
|
+
body: `var(--${string})`;
|
|
108
|
+
bodyMuted: `var(--${string})`;
|
|
109
|
+
bodyDanger: `var(--${string})`;
|
|
110
|
+
iconButton: `var(--${string})`;
|
|
111
|
+
};
|
|
112
|
+
radii: {
|
|
113
|
+
small: `var(--${string})`;
|
|
114
|
+
medium: `var(--${string})`;
|
|
115
|
+
large: `var(--${string})`;
|
|
116
|
+
xlarge: `var(--${string})`;
|
|
117
|
+
};
|
|
118
|
+
shadows: {
|
|
119
|
+
primaryButton: `var(--${string})`;
|
|
120
|
+
walletItemSelected: `var(--${string})`;
|
|
121
|
+
};
|
|
122
|
+
fontWeights: {
|
|
123
|
+
normal: `var(--${string})`;
|
|
124
|
+
medium: `var(--${string})`;
|
|
125
|
+
bold: `var(--${string})`;
|
|
126
|
+
};
|
|
127
|
+
fontSizes: {
|
|
128
|
+
small: `var(--${string})`;
|
|
129
|
+
medium: `var(--${string})`;
|
|
130
|
+
large: `var(--${string})`;
|
|
131
|
+
xlarge: `var(--${string})`;
|
|
132
|
+
};
|
|
133
|
+
typography: {
|
|
134
|
+
fontFamily: `var(--${string})`;
|
|
135
|
+
fontStyle: `var(--${string})`;
|
|
136
|
+
lineHeight: `var(--${string})`;
|
|
137
|
+
letterSpacing: `var(--${string})`;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
export {};
|
|
141
|
+
//# sourceMappingURL=themeContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeContract.d.ts","sourceRoot":"","sources":["../../src/themes/themeContract.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDxB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IAC1B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oGAAoG;IACpG,SAAS,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,YAAY,EAAE,CAAC;AAE/C,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilityTypes.d.ts","sourceRoot":"","sources":["../../src/types/utilityTypes.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACxF,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertUnreachable.d.ts","sourceRoot":"","sources":["../../src/utils/assertUnreachable.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAErD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateStorage.d.ts","sourceRoot":"","sources":["../../src/utils/stateStorage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,mBAAmB,IAAI,YAAY,CAalD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Wallet, WalletWithFeatures, WalletWithRequiredFeatures } from '@mysten/wallet-standard';
|
|
2
|
+
export declare function getRegisteredWallets<AdditionalFeatures extends Wallet['features']>(preferredWallets: string[], walletFilter?: (wallet: WalletWithRequiredFeatures) => boolean): WalletWithFeatures<import("@mysten/wallet-standard").StandardConnectFeature & import("@mysten/wallet-standard").StandardEventsFeature & AdditionalFeatures>[];
|
|
3
|
+
export declare function getWalletUniqueIdentifier(wallet?: Wallet): string | undefined;
|
|
4
|
+
//# sourceMappingURL=walletUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletUtils.d.ts","sourceRoot":"","sources":["../../src/utils/walletUtils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEX,MAAM,EACN,kBAAkB,EAClB,0BAA0B,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,wBAAgB,oBAAoB,CAAC,kBAAkB,SAAS,MAAM,CAAC,UAAU,CAAC,EACjF,gBAAgB,EAAE,MAAM,EAAE,EAC1B,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,OAAO,iKAmB9D;AAED,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,MAAM,sBAExD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Wallet, WalletAccount, WalletWithRequiredFeatures } from '@mysten/wallet-standard';
|
|
2
|
+
import type { StateStorage } from 'zustand/middleware';
|
|
3
|
+
type WalletConnectionStatus = 'disconnected' | 'connecting' | 'connected';
|
|
4
|
+
export type WalletActions = {
|
|
5
|
+
setAccountSwitched: (selectedAccount: WalletAccount) => void;
|
|
6
|
+
setConnectionStatus: (connectionStatus: WalletConnectionStatus) => void;
|
|
7
|
+
setWalletConnected: (wallet: WalletWithRequiredFeatures, connectedAccounts: readonly WalletAccount[], selectedAccount: WalletAccount | null, supportedIntents?: string[]) => void;
|
|
8
|
+
updateWalletAccounts: (accounts: readonly WalletAccount[]) => void;
|
|
9
|
+
setWalletDisconnected: () => void;
|
|
10
|
+
setWalletRegistered: (updatedWallets: WalletWithRequiredFeatures[]) => void;
|
|
11
|
+
setWalletUnregistered: (updatedWallets: WalletWithRequiredFeatures[], unregisteredWallet: Wallet) => void;
|
|
12
|
+
};
|
|
13
|
+
export type WalletStore = ReturnType<typeof createWalletStore>;
|
|
14
|
+
export type StoreState = {
|
|
15
|
+
autoConnectEnabled: boolean;
|
|
16
|
+
wallets: WalletWithRequiredFeatures[];
|
|
17
|
+
accounts: readonly WalletAccount[];
|
|
18
|
+
currentWallet: WalletWithRequiredFeatures | null;
|
|
19
|
+
currentAccount: WalletAccount | null;
|
|
20
|
+
lastConnectedAccountAddress: string | null;
|
|
21
|
+
lastConnectedWalletName: string | null;
|
|
22
|
+
connectionStatus: WalletConnectionStatus;
|
|
23
|
+
supportedIntents: string[];
|
|
24
|
+
} & WalletActions;
|
|
25
|
+
type WalletConfiguration = {
|
|
26
|
+
autoConnectEnabled: boolean;
|
|
27
|
+
wallets: WalletWithRequiredFeatures[];
|
|
28
|
+
storage: StateStorage;
|
|
29
|
+
storageKey: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function createWalletStore({ wallets, storage, storageKey, autoConnectEnabled, }: WalletConfiguration): Omit<import("zustand").StoreApi<StoreState>, "setState" | "persist"> & {
|
|
32
|
+
setState(partial: StoreState | Partial<StoreState> | ((state: StoreState) => StoreState | Partial<StoreState>), replace?: false | undefined): unknown;
|
|
33
|
+
setState(state: StoreState | ((state: StoreState) => StoreState), replace: true): unknown;
|
|
34
|
+
persist: {
|
|
35
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<StoreState, unknown, unknown>>) => void;
|
|
36
|
+
clearStorage: () => void;
|
|
37
|
+
rehydrate: () => Promise<void> | void;
|
|
38
|
+
hasHydrated: () => boolean;
|
|
39
|
+
onHydrate: (fn: (state: StoreState) => void) => () => void;
|
|
40
|
+
onFinishHydration: (fn: (state: StoreState) => void) => () => void;
|
|
41
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<StoreState, unknown, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=walletStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletStore.d.ts","sourceRoot":"","sources":["../src/walletStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAEjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,KAAK,sBAAsB,GAAG,cAAc,GAAG,YAAY,GAAG,WAAW,CAAC;AAE1E,MAAM,MAAM,aAAa,GAAG;IAC3B,kBAAkB,EAAE,CAAC,eAAe,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7D,mBAAmB,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACxE,kBAAkB,EAAE,CACnB,MAAM,EAAE,0BAA0B,EAClC,iBAAiB,EAAE,SAAS,aAAa,EAAE,EAC3C,eAAe,EAAE,aAAa,GAAG,IAAI,EACrC,gBAAgB,CAAC,EAAE,MAAM,EAAE,KACvB,IAAI,CAAC;IACV,oBAAoB,EAAE,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,KAAK,IAAI,CAAC;IACnE,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,mBAAmB,EAAE,CAAC,cAAc,EAAE,0BAA0B,EAAE,KAAK,IAAI,CAAC;IAC5E,qBAAqB,EAAE,CACtB,cAAc,EAAE,0BAA0B,EAAE,EAC5C,kBAAkB,EAAE,MAAM,KACtB,IAAI,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG;IACxB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,aAAa,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACjD,cAAc,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,2BAA2B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,gBAAgB,EAAE,sBAAsB,CAAC;IACzC,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC3B,GAAG,aAAa,CAAC;AAElB,KAAK,mBAAmB,GAAG;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EACjC,OAAO,EACP,OAAO,EACP,UAAU,EACV,kBAAkB,GAClB,EAAE,mBAAmB;;;;;;;;;;;;EAuFrB"}
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Sui dApp Kit (Legacy)
|
|
2
|
+
|
|
3
|
+
> Legacy dApp Kit API reference for the deprecated @mysten/dapp-kit package using JSON RPC.
|
|
4
|
+
|
|
5
|
+
> **Warning:** **Deprecated - JSON RPC Only**: This legacy version of `@mysten/dapp-kit` only works with the
|
|
6
|
+
> deprecated JSON RPC API and will not be updated to support gRPC or GraphQL. For new projects, use
|
|
7
|
+
> [`@mysten/dapp-kit-core` and `@mysten/dapp-kit-react`](/dapp-kit).
|
|
8
|
+
|
|
9
|
+
The Sui dApp Kit is a set of React components, hooks, and utilities to help you build an app for the
|
|
10
|
+
Sui ecosystem. Its hooks and components provide an interface for querying data from the Sui network
|
|
11
|
+
and connecting to Sui wallets.
|
|
12
|
+
|
|
13
|
+
### Core features
|
|
14
|
+
|
|
15
|
+
Some of the core features of the dApp Kit include:
|
|
16
|
+
|
|
17
|
+
- Query hooks to get the information your app needs
|
|
18
|
+
- Automatic wallet state management
|
|
19
|
+
- Support for all Sui wallets
|
|
20
|
+
- Pre-built React components
|
|
21
|
+
- Lower level hooks for custom components
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
To use the Sui dApp Kit in your project, run the following command in your project root:
|
|
26
|
+
|
|
27
|
+
```sh npm2yarn
|
|
28
|
+
npm i --save @mysten/dapp-kit @mysten/sui @tanstack/react-query
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Setting up providers
|
|
32
|
+
|
|
33
|
+
To use the hooks and components in the dApp Kit, wrap your app with the providers shown in the
|
|
34
|
+
following example. The props available on the providers are covered in more detail in their
|
|
35
|
+
respective pages.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
|
|
39
|
+
// Config options for the networks you want to connect to
|
|
40
|
+
const { networkConfig } = createNetworkConfig({
|
|
41
|
+
localnet: { url: getFullnodeUrl('localnet') },
|
|
42
|
+
mainnet: { url: getFullnodeUrl('mainnet') },
|
|
43
|
+
});
|
|
44
|
+
const queryClient = new QueryClient();
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<QueryClientProvider client={queryClient}>
|
|
49
|
+
<SuiClientProvider networks={networkConfig} defaultNetwork="localnet">
|
|
50
|
+
<WalletProvider>
|
|
51
|
+
<YourApp />
|
|
52
|
+
</WalletProvider>
|
|
53
|
+
</SuiClientProvider>
|
|
54
|
+
</QueryClientProvider>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Using UI components to connect to a wallet
|
|
60
|
+
|
|
61
|
+
The dApp Kit provides a set of flexible UI components that you can use to connect and manage wallet
|
|
62
|
+
accounts from your app. The components are built on top of
|
|
63
|
+
[Radix UI](https://www.radix-ui.com/primitives) and are customizable.
|
|
64
|
+
|
|
65
|
+
To use the provided UI components, import the dApp Kit CSS stylesheet into your app. For more
|
|
66
|
+
information regarding customization options, check out the respective documentation pages for the
|
|
67
|
+
components and [themes](/dapp-kit/legacy/themes).
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Using hooks to make RPC calls
|
|
74
|
+
|
|
75
|
+
The dApp Kit provides a set of hooks for making RPC calls to the Sui blockchain. The hooks are thin
|
|
76
|
+
wrappers around `useQuery` from `@tanstack/react-query`. For more comprehensive documentation on how
|
|
77
|
+
to use these query hooks, check out the
|
|
78
|
+
[react-query documentation](https://tanstack.com/query/latest/docs/react/overview).
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
|
|
82
|
+
function MyComponent() {
|
|
83
|
+
const { data, isPending, error, refetch } = useSuiClientQuery('getOwnedObjects', {
|
|
84
|
+
owner: '0x123',
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (isPending) {
|
|
88
|
+
return <div>Loading...</div>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return <pre>{JSON.stringify(data, null, 2)}</pre>;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# dApp Kit (Legacy)
|
|
2
|
+
> Build Sui dapps in React with @mysten/dapp-kit
|
|
3
|
+
|
|
4
|
+
- [Sui dApp Kit (Legacy)](..md): Legacy dApp Kit API reference for the deprecated @mysten/dapp-kit package using JSON RPC.
|
|
5
|
+
- [SuiClientProvider](./sui-client-provider.md): React provider for managing the active SuiJsonRpcClient in legacy dApp Kit.
|
|
6
|
+
- [RPC Hooks](./rpc-hooks.md): React hooks for querying the Sui blockchain using JSON RPC methods.
|
|
7
|
+
- [WalletProvider](./wallet-provider.md): React context provider for wallet connections in legacy dApp Kit.
|
|
8
|
+
- [ConnectButton](./wallet-components/ConnectButton.md): Legacy React button component for connecting and disconnecting a Sui wallet.
|
|
9
|
+
- [ConnectModal](./wallet-components/ConnectModal.md): Legacy React modal component that guides users through connecting their wallet.
|
|
10
|
+
- [useWallets](./wallet-hooks/useWallets.md): Legacy React hook to list available wallet extensions sorted by priority.
|
|
11
|
+
- [useAccounts](./wallet-hooks/useAccounts.md): Legacy React hook to list connected wallet accounts authorized by the app.
|
|
12
|
+
- [useCurrentWallet](./wallet-hooks/useCurrentWallet.md): Legacy React hook to get the currently connected wallet and connection status.
|
|
13
|
+
- [useCurrentAccount](./wallet-hooks/useCurrentAccount.md): Legacy React hook to get the currently selected wallet account.
|
|
14
|
+
- [useAutoConnectWallet](./wallet-hooks/useAutoConnectWallet.md): Legacy React hook to check the auto-connection status for the last connected wallet.
|
|
15
|
+
- [useConnectWallet](./wallet-hooks/useConnectWallet.md): Legacy React mutation hook to establish a connection with a specific wallet.
|
|
16
|
+
- [useDisconnectWallet](./wallet-hooks/useDisconnectWallet.md): Legacy React mutation hook to disconnect from the currently connected wallet.
|
|
17
|
+
- [useSwitchAccount](./wallet-hooks/useSwitchAccount.md): Legacy React mutation hook to switch the active wallet account.
|
|
18
|
+
- [useSignPersonalMessage](./wallet-hooks/useSignPersonalMessage.md): Legacy React hook to sign a personal message with the connected wallet.
|
|
19
|
+
- [useSignTransaction](./wallet-hooks/useSignTransaction.md): Legacy React hook to sign a transaction without executing it on the Sui network.
|
|
20
|
+
- [useSignAndExecuteTransaction](./wallet-hooks/useSignAndExecuteTransaction.md): Legacy React hook to sign and execute a transaction block on the Sui network.
|
|
21
|
+
- [Slush Integration](./slush.md): Integrate Slush wallet with the legacy dApp Kit WalletProvider.
|
|
22
|
+
- [Themes](./themes.md): Theming API for customizing the appearance of legacy dApp Kit components.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# RPC Hooks
|
|
2
|
+
|
|
3
|
+
> React hooks for querying the Sui blockchain using JSON RPC methods.
|
|
4
|
+
|
|
5
|
+
Sui dApp Kit ships with hooks for each of the RPC methods defined in the
|
|
6
|
+
[JSON RPC specification](https://docs.sui.io/sui-api-ref).
|
|
7
|
+
|
|
8
|
+
## `useSuiClientQuery`
|
|
9
|
+
|
|
10
|
+
Load data from the Sui RPC using the `useSuiClientQuery` hook. This hook is a wrapper around the
|
|
11
|
+
[`useQuery`](https://tanstack.com/query/latest/docs/react/guides/queries) hook from
|
|
12
|
+
@tanstack/react-query.
|
|
13
|
+
|
|
14
|
+
The hook takes the RPC method name as the first argument and any parameters as the second argument.
|
|
15
|
+
You can pass any additional `useQuery` options as the third argument. You can read the
|
|
16
|
+
[useQuery documentation](https://tanstack.com/query/latest/docs/react/guides/queries) for more
|
|
17
|
+
details on the full set of options available.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
|
|
21
|
+
function MyComponent() {
|
|
22
|
+
const { data, isPending, isError, error, refetch } = useSuiClientQuery(
|
|
23
|
+
'getOwnedObjects',
|
|
24
|
+
{ owner: '0x123' },
|
|
25
|
+
{
|
|
26
|
+
gcTime: 10000,
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (isPending) {
|
|
31
|
+
return <div>Loading...</div>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (isError) {
|
|
35
|
+
return <div>Error: {error.message}</div>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return <pre>{JSON.stringify(data, null, 2)}</pre>;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## `useSuiClientQueries`
|
|
43
|
+
|
|
44
|
+
You can fetch a variable number of Sui RPC queries using the `useSuiClientQueries` hook. This hook
|
|
45
|
+
is a wrapper around the
|
|
46
|
+
[`useQueries`](https://tanstack.com/query/latest/docs/react/reference/useQueries) hook from
|
|
47
|
+
@tanstack/react-query.
|
|
48
|
+
|
|
49
|
+
The `queries` value is an array of query option objects identical to the `useSuiClientQuery` hook.
|
|
50
|
+
|
|
51
|
+
The `combine` parameter is optional. Use this parameter to combine the results of the queries into a
|
|
52
|
+
single value. The result is structurally shared to be as referentially stable as possible.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
|
|
56
|
+
function MyComponent() {
|
|
57
|
+
const { data, isPending, isError } = useSuiClientQueries({
|
|
58
|
+
queries: [
|
|
59
|
+
{
|
|
60
|
+
method: 'getAllBalances',
|
|
61
|
+
params: {
|
|
62
|
+
owner: '0x123',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
method: 'queryTransactionBlocks',
|
|
67
|
+
params: {
|
|
68
|
+
filter: {
|
|
69
|
+
FromAddress: '0x123',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
combine: (result) => {
|
|
75
|
+
return {
|
|
76
|
+
data: result.map((res) => res.data),
|
|
77
|
+
isSuccess: result.every((res) => res.isSuccess),
|
|
78
|
+
isPending: result.some((res) => res.isPending),
|
|
79
|
+
isError: result.some((res) => res.isError),
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (isPending) {
|
|
85
|
+
return <div>Loading...</div>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (isError) {
|
|
89
|
+
return <div>Fetching Error</div>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return <pre>{JSON.stringify(data, null, 2)}</pre>;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## `useSuiClientInfiniteQuery`
|
|
97
|
+
|
|
98
|
+
For RPC methods that support pagination, dApp Kit also implements a `useSuiClientInfiniteQuery`
|
|
99
|
+
hook. For more details check out the
|
|
100
|
+
[`useInfiniteQuery` documentation](https://tanstack.com/query/latest/docs/react/guides/infinite-queries).
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
|
|
104
|
+
function MyComponent() {
|
|
105
|
+
const { data, isPending, isError, error, isFetching, fetchNextPage, hasNextPage } =
|
|
106
|
+
useSuiClientInfiniteQuery('getOwnedObjects', {
|
|
107
|
+
owner: '0x123',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (isPending) {
|
|
111
|
+
return <div>Loading...</div>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (isError) {
|
|
115
|
+
return <div>Error: {error.message}</div>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return <pre>{JSON.stringify(data, null, 2)}</pre>;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## `useSuiClientMutation`
|
|
123
|
+
|
|
124
|
+
For RPC methods that mutate state, dApp Kit implements a `useSuiClientMutation` hook. Use this hook
|
|
125
|
+
with any RPC method to imperatively call the RPC method. For more details, check out the
|
|
126
|
+
[`useMutation` documentation](https://tanstack.com/query/latest/docs/react/guides/mutations).
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
|
|
130
|
+
function MyComponent() {
|
|
131
|
+
const { mutate } = useSuiClientMutation('dryRunTransactionBlock');
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<Button
|
|
135
|
+
onClick={() => {
|
|
136
|
+
mutate({
|
|
137
|
+
transactionBlock: tx,
|
|
138
|
+
});
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
Dry run transaction
|
|
142
|
+
</Button>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## `useResolveSuiNSName`
|
|
148
|
+
|
|
149
|
+
To get the SuiNS name for a given address, use the `useResolveSuiNSName` hook.
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
|
|
153
|
+
function MyComponent() {
|
|
154
|
+
const { data, isPending } = useResolveSuiNSName('0x123');
|
|
155
|
+
|
|
156
|
+
if (isPending) {
|
|
157
|
+
return <div>Loading...</div>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (data) {
|
|
161
|
+
return <div>Domain name is: {data}</div>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return <div>Domain name not found</div>;
|
|
165
|
+
}
|
|
166
|
+
```
|
package/docs/slush.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Slush Integration
|
|
2
|
+
|
|
3
|
+
> Integrate Slush wallet with the legacy dApp Kit WalletProvider.
|
|
4
|
+
|
|
5
|
+
The dApp Kit provides out-of-the-box opt-in support for the [Slush wallet](/slush-wallet/dapp).
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
To enable support for Slush wallets, pass the `slushWallet` object to the `WalletProvider`
|
|
10
|
+
component. This object has the following properties:
|
|
11
|
+
|
|
12
|
+
- **`name`:** The name of your app, shown to the user when connecting to the app.
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
function App({ children }) {
|
|
16
|
+
return (
|
|
17
|
+
<WalletProvider
|
|
18
|
+
slushWallet={{
|
|
19
|
+
name: 'Your dApp name',
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</WalletProvider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> In the connect modal, users with the Slush Wallet extension installed will only see the extension.
|
|
29
|
+
> If they do not have it, the connection defaults to the Slush web app.
|