provider-connect 1.0.2
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 +191 -0
- package/dist/index.d.mts +185 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +2422 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2373 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# provider-connect
|
|
2
|
+
|
|
3
|
+
Multi-wallet connection library for Supra blockchain supporting Starkey and Ribbit wallets.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install provider-connect
|
|
9
|
+
# or
|
|
10
|
+
yarn add provider-connect
|
|
11
|
+
# or
|
|
12
|
+
pnpm add provider-connect
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Peer Dependencies
|
|
16
|
+
|
|
17
|
+
This package requires the following peer dependencies:
|
|
18
|
+
|
|
19
|
+
- `react` (^18.0.0 || ^19.0.0)
|
|
20
|
+
- `react-dom` (^18.0.0 || ^19.0.0)
|
|
21
|
+
|
|
22
|
+
**Note:** Wallet icons are automatically included as base64 data URLs in the bundle, so no additional configuration is needed for images.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Basic Wallet Connection
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { ConnectWalletHandler } from 'provider-connect';
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
return (
|
|
33
|
+
<ConnectWalletHandler>
|
|
34
|
+
{({ isConnected, handleConnect, handleDisconnect, accounts, balance }) => (
|
|
35
|
+
<div>
|
|
36
|
+
{isConnected ? (
|
|
37
|
+
<div>
|
|
38
|
+
<p>Connected: {accounts[0]}</p>
|
|
39
|
+
<p>Balance: {balance}</p>
|
|
40
|
+
<button onClick={handleDisconnect}>Disconnect</button>
|
|
41
|
+
</div>
|
|
42
|
+
) : (
|
|
43
|
+
<button onClick={handleConnect}>Connect Wallet</button>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
47
|
+
</ConnectWalletHandler>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Using the Hook Directly
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { useSupraMultiWallet } from 'provider-connect';
|
|
56
|
+
|
|
57
|
+
function MyComponent() {
|
|
58
|
+
const {
|
|
59
|
+
accounts,
|
|
60
|
+
balance,
|
|
61
|
+
connectWallet,
|
|
62
|
+
chainId,
|
|
63
|
+
disconnectWallet,
|
|
64
|
+
sendRawTransaction,
|
|
65
|
+
signMessage,
|
|
66
|
+
loading,
|
|
67
|
+
} = useSupraMultiWallet();
|
|
68
|
+
|
|
69
|
+
const handleConnect = async () => {
|
|
70
|
+
await connectWallet('starkey'); // or 'ribbit'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div>
|
|
75
|
+
{/* Your component */}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Conversion Utils
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useConversionUtils } from 'provider-connect';
|
|
85
|
+
|
|
86
|
+
function MyComponent() {
|
|
87
|
+
const {
|
|
88
|
+
serializeUint64,
|
|
89
|
+
serializeUint128,
|
|
90
|
+
serializeTransactionArgs,
|
|
91
|
+
addressToUint8Array,
|
|
92
|
+
} = useConversionUtils();
|
|
93
|
+
|
|
94
|
+
// Use conversion utilities
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Wallet Icons
|
|
99
|
+
|
|
100
|
+
Wallet icons are included in the package and automatically used by the `ConnectWalletHandler` component. You can also import them directly:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { WALLET_ICONS, starkeyIcon, ribbitIcon } from 'provider-connect';
|
|
104
|
+
|
|
105
|
+
// Use in your components
|
|
106
|
+
<img src={starkeyIcon} alt="Starkey Wallet" />
|
|
107
|
+
<img src={WALLET_ICONS.ribbit} alt="Ribbit Wallet" />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## API Reference
|
|
111
|
+
|
|
112
|
+
### Components
|
|
113
|
+
|
|
114
|
+
#### `ConnectWalletHandler`
|
|
115
|
+
|
|
116
|
+
Main component for wallet connection UI.
|
|
117
|
+
|
|
118
|
+
**Props:**
|
|
119
|
+
- `onConnect?: (account: string) => void` - Callback when wallet connects
|
|
120
|
+
- `onDisconnect?: () => void` - Callback when wallet disconnects
|
|
121
|
+
- `children: (props) => React.ReactNode` - Render prop with wallet state
|
|
122
|
+
|
|
123
|
+
**Children Props:**
|
|
124
|
+
- `isConnected: boolean` - Whether wallet is connected
|
|
125
|
+
- `accounts: string[]` - Connected account addresses
|
|
126
|
+
- `loading: boolean` - Loading state
|
|
127
|
+
- `balance: string` - Wallet balance
|
|
128
|
+
- `userProfile: UserProfile | null` - User profile data
|
|
129
|
+
- `handleConnect: () => void` - Function to trigger connection modal
|
|
130
|
+
- `handleDisconnect: () => void` - Function to disconnect wallet
|
|
131
|
+
|
|
132
|
+
### Hooks
|
|
133
|
+
|
|
134
|
+
#### `useSupraMultiWallet()`
|
|
135
|
+
|
|
136
|
+
Main hook for wallet functionality.
|
|
137
|
+
|
|
138
|
+
**Returns:**
|
|
139
|
+
- `selectedWallet: WalletType` - Currently selected wallet type
|
|
140
|
+
- `accounts: string[]` - Connected accounts
|
|
141
|
+
- `balance: string` - Wallet balance
|
|
142
|
+
- `connectWallet: (walletType?: WalletType) => Promise<boolean>` - Connect wallet
|
|
143
|
+
- `disconnectWallet: () => Promise<void>` - Disconnect wallet
|
|
144
|
+
- `sendRawTransaction: (...) => Promise<string>` - Send raw transaction
|
|
145
|
+
- `signMessage: (...) => Promise<SignMessageResponse>` - Sign message
|
|
146
|
+
- `getAvailableWallets: () => WalletInfo[]` - Get available wallets
|
|
147
|
+
- `loading: boolean` - Loading state
|
|
148
|
+
|
|
149
|
+
#### `useConversionUtils()`
|
|
150
|
+
|
|
151
|
+
Utility hook for data conversion and serialization.
|
|
152
|
+
|
|
153
|
+
**Returns:**
|
|
154
|
+
- `serializeUint8`, `serializeUint16`, `serializeUint32`, `serializeUint64`, `serializeUint128`, `serializeU256`
|
|
155
|
+
- `serializeBool`, `serializeVector`
|
|
156
|
+
- `addressToUint8Array`, `stringToUint8Array`
|
|
157
|
+
- `serializeTransactionArgs` - Serialize transaction arguments from ABI
|
|
158
|
+
- `fetchModuleABI` - Fetch module ABI from RPC
|
|
159
|
+
- `getFunctionParamTypes` - Get function parameter types
|
|
160
|
+
|
|
161
|
+
### Types
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
type WalletType = 'starkey' | 'ribbit';
|
|
165
|
+
|
|
166
|
+
interface UserProfile {
|
|
167
|
+
address: string;
|
|
168
|
+
username: string | null;
|
|
169
|
+
profileImage: string | null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface ModuleABI {
|
|
173
|
+
address: string;
|
|
174
|
+
name: string;
|
|
175
|
+
exposed_functions: Array<{
|
|
176
|
+
name: string;
|
|
177
|
+
params: string[];
|
|
178
|
+
return?: string[];
|
|
179
|
+
}>;
|
|
180
|
+
// ... more fields
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Supported Wallets
|
|
185
|
+
|
|
186
|
+
- **Starkey Wallet** - Browser extension wallet
|
|
187
|
+
- **Ribbit Wallet** - Mobile and browser wallet
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
if i can create a package then user install tthen what they can do direclty install this depandancy ?
|
|
191
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { BCS } from 'supra-l1-sdk-core';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
|
+
import { VariantProps } from 'class-variance-authority';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
|
+
import { Toaster as Toaster$1 } from 'sonner';
|
|
9
|
+
|
|
10
|
+
type WalletType = 'starkey' | 'ribbit';
|
|
11
|
+
interface WalletCapabilities {
|
|
12
|
+
signMessage: boolean;
|
|
13
|
+
accountSwitching: boolean;
|
|
14
|
+
networkSwitching: boolean;
|
|
15
|
+
rawTransactions: boolean;
|
|
16
|
+
eventListeners: boolean;
|
|
17
|
+
tokenRevalidation: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const WALLET_EVENTS: {
|
|
20
|
+
readonly CONNECTED: "wallet-connected";
|
|
21
|
+
readonly PRESIGNED_STATE: "presigned-state";
|
|
22
|
+
readonly POSTSIGNED_STATE: "postsigned-state";
|
|
23
|
+
readonly ERROR: "wallet-error";
|
|
24
|
+
};
|
|
25
|
+
declare const useSupraMultiWallet: (enabledWallets?: WalletType[]) => {
|
|
26
|
+
selectedWallet: WalletType;
|
|
27
|
+
walletCapabilities: WalletCapabilities;
|
|
28
|
+
getAvailableWallets: () => {
|
|
29
|
+
type: WalletType;
|
|
30
|
+
name: string;
|
|
31
|
+
isInstalled: boolean;
|
|
32
|
+
capabilities: WalletCapabilities;
|
|
33
|
+
}[];
|
|
34
|
+
getCurrentProvider: () => any;
|
|
35
|
+
isExtensionInstalled: boolean;
|
|
36
|
+
accounts: string[];
|
|
37
|
+
networkData: any;
|
|
38
|
+
balance: string;
|
|
39
|
+
transactions: {
|
|
40
|
+
hash: string;
|
|
41
|
+
}[];
|
|
42
|
+
selectedChainId: string;
|
|
43
|
+
connectWallet: (walletType?: WalletType) => Promise<boolean>;
|
|
44
|
+
disconnectWallet: () => Promise<void>;
|
|
45
|
+
sendRawTransaction: (moduleAddress?: string, moduleName?: string, functionName?: string, params?: any[], runTimeParams?: any[], txExpiryTime?: number) => Promise<any>;
|
|
46
|
+
signMessage: (message: string, nonce?: string, account?: any, forceSign?: boolean) => Promise<any>;
|
|
47
|
+
setSelectedChainId: React$1.Dispatch<React$1.SetStateAction<string>>;
|
|
48
|
+
loading: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
interface UserProfile {
|
|
52
|
+
address: string;
|
|
53
|
+
username: string | null;
|
|
54
|
+
profileImage: string | null;
|
|
55
|
+
}
|
|
56
|
+
interface ConnectWalletHandlerProps {
|
|
57
|
+
onConnect?: (account: string) => void;
|
|
58
|
+
onDisconnect?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Optional array of wallet types to enable. If not provided, all available wallets will be shown.
|
|
61
|
+
* Example: `enabledWallets={['starkey']}` will only show Starkey Wallet.
|
|
62
|
+
*/
|
|
63
|
+
enabledWallets?: WalletType[];
|
|
64
|
+
children: (props: {
|
|
65
|
+
isConnected: boolean;
|
|
66
|
+
accounts: string[];
|
|
67
|
+
loading: boolean;
|
|
68
|
+
balance: string;
|
|
69
|
+
userProfile: UserProfile | null;
|
|
70
|
+
handleConnect: () => void;
|
|
71
|
+
handleDisconnect: () => void;
|
|
72
|
+
}) => React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
declare const ConnectWalletHandler: React.FC<ConnectWalletHandlerProps>;
|
|
75
|
+
|
|
76
|
+
interface ModuleABI {
|
|
77
|
+
address: string;
|
|
78
|
+
name: string;
|
|
79
|
+
friends?: string[];
|
|
80
|
+
exposed_functions: Array<{
|
|
81
|
+
name: string;
|
|
82
|
+
visibility?: string;
|
|
83
|
+
is_entry?: boolean;
|
|
84
|
+
is_view?: boolean;
|
|
85
|
+
generic_type_params?: Array<{
|
|
86
|
+
constraints?: any[];
|
|
87
|
+
}>;
|
|
88
|
+
params: string[];
|
|
89
|
+
return?: string[];
|
|
90
|
+
}>;
|
|
91
|
+
structs?: Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
is_native?: boolean;
|
|
94
|
+
abilities?: string[];
|
|
95
|
+
generic_type_params?: any[];
|
|
96
|
+
fields?: Array<{
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
}
|
|
102
|
+
interface ABIStorage {
|
|
103
|
+
[moduleAddress: string]: {
|
|
104
|
+
[moduleName: string]: ModuleABI;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
declare function getStoredABI(moduleAddress: string, moduleName: string): ModuleABI | null;
|
|
108
|
+
|
|
109
|
+
declare const useConversionUtils: () => {
|
|
110
|
+
stringToUint8Array: (humanReadableStr: string) => Uint8Array<ArrayBufferLike>;
|
|
111
|
+
addressToUint8Array: (cryptoAddress: string) => Uint8Array<ArrayBufferLike>;
|
|
112
|
+
serializeString: (humanReadableStr: string) => Uint8Array<ArrayBufferLike>;
|
|
113
|
+
serializeUint8: (value: number | string) => Uint8Array<ArrayBufferLike>;
|
|
114
|
+
serializeUint16: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
115
|
+
serializeUint32: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
116
|
+
serializeUint64: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
117
|
+
serializeUint128: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
118
|
+
serializeU256: (value: bigint) => Uint8Array<ArrayBufferLike>;
|
|
119
|
+
serializeBool: (value: boolean) => Uint8Array<ArrayBufferLike>;
|
|
120
|
+
serializeVector: (values: any[], type: "u8" | "u64" | "bool" | "string" | "address") => Uint8Array<ArrayBufferLike>;
|
|
121
|
+
deserializeString: (uint8Array: string) => Uint8Array<ArrayBufferLike>;
|
|
122
|
+
deserializeVector: (uint8Array: Uint8Array) => any[];
|
|
123
|
+
hexToString: (hex: string, type: string) => string;
|
|
124
|
+
stringToHex: (str: string) => string;
|
|
125
|
+
serializeValueByType: (value: any, type: string, serializer?: BCS.Serializer) => Uint8Array;
|
|
126
|
+
serializeArgsFromTypes: (args: any[], paramTypes: string[]) => Uint8Array[];
|
|
127
|
+
fetchModuleABI: (moduleAddress: string, moduleName: string, rpcUrl?: string) => Promise<ModuleABI>;
|
|
128
|
+
getFunctionParamTypes: (moduleAddress: string, moduleName: string, functionName: string, rpcUrl?: string) => Promise<string[]>;
|
|
129
|
+
serializeTransactionArgs: (args: any[], moduleAddress: string, moduleName: string, functionName: string, rpcUrl?: string) => Promise<Uint8Array[]>;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
133
|
+
declare function standardizeAddress(address: string): string;
|
|
134
|
+
|
|
135
|
+
declare const buttonVariants: (props?: ({
|
|
136
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
137
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
138
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
139
|
+
interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
140
|
+
asChild?: boolean;
|
|
141
|
+
}
|
|
142
|
+
declare const Button: React$1.ForwardRefExoticComponent<ButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
143
|
+
|
|
144
|
+
declare const Dialog: React$1.FC<DialogPrimitive.DialogProps>;
|
|
145
|
+
declare const DialogTrigger: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
146
|
+
declare const DialogPortal: React$1.FC<DialogPrimitive.DialogPortalProps>;
|
|
147
|
+
declare const DialogClose: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
148
|
+
declare const DialogOverlay: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
149
|
+
declare const DialogContent: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
150
|
+
declare const DialogHeader: {
|
|
151
|
+
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
152
|
+
displayName: string;
|
|
153
|
+
};
|
|
154
|
+
declare const DialogFooter: {
|
|
155
|
+
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
156
|
+
displayName: string;
|
|
157
|
+
};
|
|
158
|
+
declare const DialogTitle: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<HTMLHeadingElement>>;
|
|
159
|
+
declare const DialogDescription: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
160
|
+
|
|
161
|
+
type ToasterProps = React.ComponentProps<typeof Toaster$1>;
|
|
162
|
+
declare const Toaster: ({ ...props }: ToasterProps) => react_jsx_runtime.JSX.Element;
|
|
163
|
+
|
|
164
|
+
// Type declarations for wallet icons
|
|
165
|
+
declare const WALLET_ICONS: {
|
|
166
|
+
readonly starkey: string;
|
|
167
|
+
readonly ribbit: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
declare const starkeyIcon: string;
|
|
171
|
+
declare const ribbitIcon: string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Optional wallet icon URLs.
|
|
175
|
+
* If provided, these will be used instead of the default bundled static images.
|
|
176
|
+
* If not provided, the component will automatically use bundled PNG images.
|
|
177
|
+
*/
|
|
178
|
+
interface WalletIcons {
|
|
179
|
+
/** Custom URL for Starkey wallet icon (PNG recommended) */
|
|
180
|
+
starkey?: string;
|
|
181
|
+
/** Custom URL for Ribbit wallet icon (PNG recommended) */
|
|
182
|
+
ribbit?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export { type ABIStorage, Button, type ButtonProps, ConnectWalletHandler, type ConnectWalletHandlerProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, type ModuleABI, Toaster, type UserProfile, WALLET_EVENTS, WALLET_ICONS, type WalletIcons, type WalletType, buttonVariants, cn, getStoredABI, ribbitIcon, standardizeAddress, starkeyIcon, useConversionUtils, useSupraMultiWallet };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { BCS } from 'supra-l1-sdk-core';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
|
+
import { VariantProps } from 'class-variance-authority';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
|
+
import { Toaster as Toaster$1 } from 'sonner';
|
|
9
|
+
|
|
10
|
+
type WalletType = 'starkey' | 'ribbit';
|
|
11
|
+
interface WalletCapabilities {
|
|
12
|
+
signMessage: boolean;
|
|
13
|
+
accountSwitching: boolean;
|
|
14
|
+
networkSwitching: boolean;
|
|
15
|
+
rawTransactions: boolean;
|
|
16
|
+
eventListeners: boolean;
|
|
17
|
+
tokenRevalidation: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const WALLET_EVENTS: {
|
|
20
|
+
readonly CONNECTED: "wallet-connected";
|
|
21
|
+
readonly PRESIGNED_STATE: "presigned-state";
|
|
22
|
+
readonly POSTSIGNED_STATE: "postsigned-state";
|
|
23
|
+
readonly ERROR: "wallet-error";
|
|
24
|
+
};
|
|
25
|
+
declare const useSupraMultiWallet: (enabledWallets?: WalletType[]) => {
|
|
26
|
+
selectedWallet: WalletType;
|
|
27
|
+
walletCapabilities: WalletCapabilities;
|
|
28
|
+
getAvailableWallets: () => {
|
|
29
|
+
type: WalletType;
|
|
30
|
+
name: string;
|
|
31
|
+
isInstalled: boolean;
|
|
32
|
+
capabilities: WalletCapabilities;
|
|
33
|
+
}[];
|
|
34
|
+
getCurrentProvider: () => any;
|
|
35
|
+
isExtensionInstalled: boolean;
|
|
36
|
+
accounts: string[];
|
|
37
|
+
networkData: any;
|
|
38
|
+
balance: string;
|
|
39
|
+
transactions: {
|
|
40
|
+
hash: string;
|
|
41
|
+
}[];
|
|
42
|
+
selectedChainId: string;
|
|
43
|
+
connectWallet: (walletType?: WalletType) => Promise<boolean>;
|
|
44
|
+
disconnectWallet: () => Promise<void>;
|
|
45
|
+
sendRawTransaction: (moduleAddress?: string, moduleName?: string, functionName?: string, params?: any[], runTimeParams?: any[], txExpiryTime?: number) => Promise<any>;
|
|
46
|
+
signMessage: (message: string, nonce?: string, account?: any, forceSign?: boolean) => Promise<any>;
|
|
47
|
+
setSelectedChainId: React$1.Dispatch<React$1.SetStateAction<string>>;
|
|
48
|
+
loading: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
interface UserProfile {
|
|
52
|
+
address: string;
|
|
53
|
+
username: string | null;
|
|
54
|
+
profileImage: string | null;
|
|
55
|
+
}
|
|
56
|
+
interface ConnectWalletHandlerProps {
|
|
57
|
+
onConnect?: (account: string) => void;
|
|
58
|
+
onDisconnect?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Optional array of wallet types to enable. If not provided, all available wallets will be shown.
|
|
61
|
+
* Example: `enabledWallets={['starkey']}` will only show Starkey Wallet.
|
|
62
|
+
*/
|
|
63
|
+
enabledWallets?: WalletType[];
|
|
64
|
+
children: (props: {
|
|
65
|
+
isConnected: boolean;
|
|
66
|
+
accounts: string[];
|
|
67
|
+
loading: boolean;
|
|
68
|
+
balance: string;
|
|
69
|
+
userProfile: UserProfile | null;
|
|
70
|
+
handleConnect: () => void;
|
|
71
|
+
handleDisconnect: () => void;
|
|
72
|
+
}) => React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
declare const ConnectWalletHandler: React.FC<ConnectWalletHandlerProps>;
|
|
75
|
+
|
|
76
|
+
interface ModuleABI {
|
|
77
|
+
address: string;
|
|
78
|
+
name: string;
|
|
79
|
+
friends?: string[];
|
|
80
|
+
exposed_functions: Array<{
|
|
81
|
+
name: string;
|
|
82
|
+
visibility?: string;
|
|
83
|
+
is_entry?: boolean;
|
|
84
|
+
is_view?: boolean;
|
|
85
|
+
generic_type_params?: Array<{
|
|
86
|
+
constraints?: any[];
|
|
87
|
+
}>;
|
|
88
|
+
params: string[];
|
|
89
|
+
return?: string[];
|
|
90
|
+
}>;
|
|
91
|
+
structs?: Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
is_native?: boolean;
|
|
94
|
+
abilities?: string[];
|
|
95
|
+
generic_type_params?: any[];
|
|
96
|
+
fields?: Array<{
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
}>;
|
|
100
|
+
}>;
|
|
101
|
+
}
|
|
102
|
+
interface ABIStorage {
|
|
103
|
+
[moduleAddress: string]: {
|
|
104
|
+
[moduleName: string]: ModuleABI;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
declare function getStoredABI(moduleAddress: string, moduleName: string): ModuleABI | null;
|
|
108
|
+
|
|
109
|
+
declare const useConversionUtils: () => {
|
|
110
|
+
stringToUint8Array: (humanReadableStr: string) => Uint8Array<ArrayBufferLike>;
|
|
111
|
+
addressToUint8Array: (cryptoAddress: string) => Uint8Array<ArrayBufferLike>;
|
|
112
|
+
serializeString: (humanReadableStr: string) => Uint8Array<ArrayBufferLike>;
|
|
113
|
+
serializeUint8: (value: number | string) => Uint8Array<ArrayBufferLike>;
|
|
114
|
+
serializeUint16: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
115
|
+
serializeUint32: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
116
|
+
serializeUint64: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
117
|
+
serializeUint128: (value: number | string | bigint) => Uint8Array<ArrayBufferLike>;
|
|
118
|
+
serializeU256: (value: bigint) => Uint8Array<ArrayBufferLike>;
|
|
119
|
+
serializeBool: (value: boolean) => Uint8Array<ArrayBufferLike>;
|
|
120
|
+
serializeVector: (values: any[], type: "u8" | "u64" | "bool" | "string" | "address") => Uint8Array<ArrayBufferLike>;
|
|
121
|
+
deserializeString: (uint8Array: string) => Uint8Array<ArrayBufferLike>;
|
|
122
|
+
deserializeVector: (uint8Array: Uint8Array) => any[];
|
|
123
|
+
hexToString: (hex: string, type: string) => string;
|
|
124
|
+
stringToHex: (str: string) => string;
|
|
125
|
+
serializeValueByType: (value: any, type: string, serializer?: BCS.Serializer) => Uint8Array;
|
|
126
|
+
serializeArgsFromTypes: (args: any[], paramTypes: string[]) => Uint8Array[];
|
|
127
|
+
fetchModuleABI: (moduleAddress: string, moduleName: string, rpcUrl?: string) => Promise<ModuleABI>;
|
|
128
|
+
getFunctionParamTypes: (moduleAddress: string, moduleName: string, functionName: string, rpcUrl?: string) => Promise<string[]>;
|
|
129
|
+
serializeTransactionArgs: (args: any[], moduleAddress: string, moduleName: string, functionName: string, rpcUrl?: string) => Promise<Uint8Array[]>;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
133
|
+
declare function standardizeAddress(address: string): string;
|
|
134
|
+
|
|
135
|
+
declare const buttonVariants: (props?: ({
|
|
136
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
137
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
138
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
139
|
+
interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
140
|
+
asChild?: boolean;
|
|
141
|
+
}
|
|
142
|
+
declare const Button: React$1.ForwardRefExoticComponent<ButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
143
|
+
|
|
144
|
+
declare const Dialog: React$1.FC<DialogPrimitive.DialogProps>;
|
|
145
|
+
declare const DialogTrigger: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
146
|
+
declare const DialogPortal: React$1.FC<DialogPrimitive.DialogPortalProps>;
|
|
147
|
+
declare const DialogClose: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
148
|
+
declare const DialogOverlay: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
149
|
+
declare const DialogContent: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogContentProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
150
|
+
declare const DialogHeader: {
|
|
151
|
+
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
152
|
+
displayName: string;
|
|
153
|
+
};
|
|
154
|
+
declare const DialogFooter: {
|
|
155
|
+
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
156
|
+
displayName: string;
|
|
157
|
+
};
|
|
158
|
+
declare const DialogTitle: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<HTMLHeadingElement>>;
|
|
159
|
+
declare const DialogDescription: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
160
|
+
|
|
161
|
+
type ToasterProps = React.ComponentProps<typeof Toaster$1>;
|
|
162
|
+
declare const Toaster: ({ ...props }: ToasterProps) => react_jsx_runtime.JSX.Element;
|
|
163
|
+
|
|
164
|
+
// Type declarations for wallet icons
|
|
165
|
+
declare const WALLET_ICONS: {
|
|
166
|
+
readonly starkey: string;
|
|
167
|
+
readonly ribbit: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
declare const starkeyIcon: string;
|
|
171
|
+
declare const ribbitIcon: string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Optional wallet icon URLs.
|
|
175
|
+
* If provided, these will be used instead of the default bundled static images.
|
|
176
|
+
* If not provided, the component will automatically use bundled PNG images.
|
|
177
|
+
*/
|
|
178
|
+
interface WalletIcons {
|
|
179
|
+
/** Custom URL for Starkey wallet icon (PNG recommended) */
|
|
180
|
+
starkey?: string;
|
|
181
|
+
/** Custom URL for Ribbit wallet icon (PNG recommended) */
|
|
182
|
+
ribbit?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export { type ABIStorage, Button, type ButtonProps, ConnectWalletHandler, type ConnectWalletHandlerProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, type ModuleABI, Toaster, type UserProfile, WALLET_EVENTS, WALLET_ICONS, type WalletIcons, type WalletType, buttonVariants, cn, getStoredABI, ribbitIcon, standardizeAddress, starkeyIcon, useConversionUtils, useSupraMultiWallet };
|