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