@gerritsen/supra-connect 0.0.1
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/.turbo/turbo-build.log +20 -0
- package/.turbo/turbo-dev.log +4 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/LICENSE +21 -0
- package/README.md +293 -0
- package/dist/index.d.ts +403 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +1 -0
- package/package.json +54 -0
- package/panda.config.ts +66 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
> @gerritsen/supra-connect@0.0.1 build /Users/martin.gerritsen/Projects/private/Supra/supra-connect/packages/supra-connect
|
|
3
|
+
> tsup && panda cssgen --outfile dist/styles.css
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.0
|
|
8
|
+
CLI Using tsup config: /Users/martin.gerritsen/Projects/private/Supra/supra-connect/packages/supra-connect/tsup.config.ts
|
|
9
|
+
CLI Target: es2020
|
|
10
|
+
CLI Cleaning output folder
|
|
11
|
+
ESM Build start
|
|
12
|
+
TERSER Minifying with Terser
|
|
13
|
+
TERSER Terser Minification success
|
|
14
|
+
DTS Build start
|
|
15
|
+
ESM dist/index.js 55.28 KB
|
|
16
|
+
ESM ⚡️ Build success in 174ms
|
|
17
|
+
DTS ⚡️ Build success in 804ms
|
|
18
|
+
DTS dist/index.d.ts 14.08 KB
|
|
19
|
+
🐼 info [css] /Users/martin.gerritsen/Projects/private/Supra/supra-connect/packages/supra-connect/dist/styles.css
|
|
20
|
+
🐼 info [hrtime] Successfully extracted css from 20 file(s) ✨ (26.73ms)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Martin Gerritsen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# @gerritsen/supra-connect
|
|
2
|
+
|
|
3
|
+
A custom-built React wallet connector for the Supra L1 blockchain. Native support for Starkey and Ribbit wallets with a unified API. Built with care and passion for the Supra ecosystem.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install react react-dom @gerritsen/supra-connect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or with your favorite package manager:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm install react react-dom @gerritsen/supra-connect
|
|
15
|
+
yarn add react react-dom @gerritsen/supra-connect
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The package is a React library and requires React 18+ as a peer dependency. If you're already using React in your project, you're all set!
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- ✨ **Unified wallet API** - Single interface for Starkey and Ribbit wallets
|
|
23
|
+
- 🔐 **Full transaction support** - Send transfers, call contracts, stake, swap, and more
|
|
24
|
+
- 💬 **Message signing** - Sign and verify messages natively
|
|
25
|
+
- 🎨 **Pre-built components** - Production-ready connect button component
|
|
26
|
+
- 🪝 **React hook** - `useSupraConnect()` hook for complete wallet management
|
|
27
|
+
- ⚡ **Automatic wallet detection** - Detects installed wallets at runtime
|
|
28
|
+
- 🔧 **Custom RPC configuration** - Support for mainnet, testnet, and custom RPC endpoints
|
|
29
|
+
- 💯 **Built for Supra** - Optimized from the ground up for the Supra L1 ecosystem
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Step 1: Wrap your app with the provider
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import '@gerritsen/supra-connect/styles.css';
|
|
37
|
+
import { SupraConnectProvider, SupraConnectButton } from '@gerritsen/supra-connect';
|
|
38
|
+
|
|
39
|
+
export function App() {
|
|
40
|
+
return (
|
|
41
|
+
<SupraConnectProvider>
|
|
42
|
+
<div>
|
|
43
|
+
<h1>My Supra dApp</h1>
|
|
44
|
+
<SupraConnectButton
|
|
45
|
+
dappMetadata={{
|
|
46
|
+
name: "My dApp",
|
|
47
|
+
description: "My awesome Supra dApp",
|
|
48
|
+
url: "https://mydapp.com",
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
</SupraConnectProvider>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The provider initializes wallet detection and makes the `useSupraConnect` hook available throughout your app.
|
|
58
|
+
|
|
59
|
+
#### Custom RPC Configuration
|
|
60
|
+
|
|
61
|
+
By default, the provider uses the Supra mainnet RPC. To use a different RPC endpoint (e.g., testnet):
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<SupraConnectProvider rpcUrl="https://rpc-testnet.supra.com">
|
|
65
|
+
{/* Your app */}
|
|
66
|
+
</SupraConnectProvider>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or use a custom RPC:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { DEFAULT_RPC_URL } from '@gerritsen/supra-connect';
|
|
73
|
+
|
|
74
|
+
<SupraConnectProvider rpcUrl="https://your-custom-rpc.com">
|
|
75
|
+
{/* Your app */}
|
|
76
|
+
</SupraConnectProvider>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Step 2: Use the `useSupraConnect` hook
|
|
80
|
+
|
|
81
|
+
Once a wallet is connected, use the hook to send transactions:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useSupraConnect } from '@gerritsen/supra-connect';
|
|
85
|
+
import { BCS, HexString } from 'supra-l1-sdk';
|
|
86
|
+
|
|
87
|
+
export function MyComponent() {
|
|
88
|
+
const { isConnected, connectedWallet, sendTransaction } = useSupraConnect();
|
|
89
|
+
|
|
90
|
+
const handleSendTransfer = async () => {
|
|
91
|
+
if (!isConnected) {
|
|
92
|
+
alert('Please connect your wallet first');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Serialize the arguments (receiver and amount)
|
|
97
|
+
const receiverBytes = new HexString('0x1234...').toUint8Array();
|
|
98
|
+
const amountBytes = BCS.bcsSerializeUint64(BigInt(1000000000)); // 1 SUPRA
|
|
99
|
+
|
|
100
|
+
// Send the transaction
|
|
101
|
+
const result = await sendTransaction({
|
|
102
|
+
payload: {
|
|
103
|
+
moduleAddress: '0x1',
|
|
104
|
+
moduleName: 'supra_account',
|
|
105
|
+
functionName: 'transfer',
|
|
106
|
+
typeArguments: [],
|
|
107
|
+
arguments: [receiverBytes, amountBytes],
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (result.success) {
|
|
112
|
+
alert(`Transfer successful! Hash: ${result.txHash}`);
|
|
113
|
+
} else {
|
|
114
|
+
alert(`Transfer failed: ${result.error}`);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div>
|
|
120
|
+
<p>Wallet: {connectedWallet?.walletAddress}</p>
|
|
121
|
+
<button onClick={handleSendTransfer}>Send 1 SUPRA</button>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## API Reference
|
|
128
|
+
|
|
129
|
+
### useSupraConnect()
|
|
130
|
+
|
|
131
|
+
The main hook to access wallet state and methods.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const {
|
|
135
|
+
// Wallet State
|
|
136
|
+
connectedWallet, // { walletAddress, type: 'starkey' | 'ribbit' } or null
|
|
137
|
+
isConnected, // boolean - is wallet connected?
|
|
138
|
+
isConnecting, // boolean - currently connecting?
|
|
139
|
+
connectionError, // string | null - any connection errors
|
|
140
|
+
availableWallets, // Array - detected wallets ['starkey', 'ribbit']
|
|
141
|
+
|
|
142
|
+
// Connection Methods
|
|
143
|
+
connectStarkey, // () => Promise<void>
|
|
144
|
+
connectRibbit, // () => Promise<void>
|
|
145
|
+
disconnect, // () => Promise<void>
|
|
146
|
+
|
|
147
|
+
// Wallet Operations (main methods you'll use)
|
|
148
|
+
sendTransaction, // (request) => Promise<TransactionResult>
|
|
149
|
+
signMessage, // (message: string) => Promise<SignMessageResult>
|
|
150
|
+
|
|
151
|
+
// Info Methods
|
|
152
|
+
getPublicAddress, // (chainType?: string) => string | null
|
|
153
|
+
getRpcUrl, // () => string - get configured RPC URL
|
|
154
|
+
|
|
155
|
+
// Utilities
|
|
156
|
+
clearError, // () => void - clear error messages
|
|
157
|
+
} = useSupraConnect();
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### sendTransaction()
|
|
161
|
+
|
|
162
|
+
Send any transaction to the blockchain.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const result = await sendTransaction({
|
|
166
|
+
payload: {
|
|
167
|
+
moduleAddress: '0x1', // Module address
|
|
168
|
+
moduleName: 'supra_account', // Module name
|
|
169
|
+
functionName: 'transfer', // Function to call
|
|
170
|
+
typeArguments: [], // Type args (for generics)
|
|
171
|
+
arguments: [bytes1, bytes2], // Pre-serialized arguments as Uint8Array
|
|
172
|
+
},
|
|
173
|
+
options: {
|
|
174
|
+
maxGasAmount: '10000', // Optional
|
|
175
|
+
gasUnitPrice: '100', // Optional
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Result
|
|
180
|
+
if (result.success) {
|
|
181
|
+
console.log(result.txHash); // Transaction was successful
|
|
182
|
+
} else {
|
|
183
|
+
console.log(result.error); // Transaction failed
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### signMessage()
|
|
188
|
+
|
|
189
|
+
Sign a message with the connected wallet.
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const result = await signMessage('Hello, Supra!');
|
|
193
|
+
|
|
194
|
+
if (result.success) {
|
|
195
|
+
console.log(result.signature); // Hex string of signature
|
|
196
|
+
} else {
|
|
197
|
+
console.log(result.reason); // Why signing failed
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Common Examples
|
|
202
|
+
|
|
203
|
+
### Transfer Tokens
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
import { useSupraConnect } from '@gerritsen/supra-connect';
|
|
207
|
+
import { BCS, HexString } from 'supra-l1-sdk';
|
|
208
|
+
|
|
209
|
+
const { sendTransaction } = useSupraConnect();
|
|
210
|
+
|
|
211
|
+
const recipient = '0x1234...';
|
|
212
|
+
const amountSupra = '1'; // 1 SUPRA
|
|
213
|
+
|
|
214
|
+
const result = await sendTransaction({
|
|
215
|
+
payload: {
|
|
216
|
+
moduleAddress: '0x1',
|
|
217
|
+
moduleName: 'supra_account',
|
|
218
|
+
functionName: 'transfer',
|
|
219
|
+
typeArguments: [],
|
|
220
|
+
arguments: [
|
|
221
|
+
new HexString(recipient).toUint8Array(),
|
|
222
|
+
BCS.bcsSerializeUint64(BigInt(1000000000)), // 1 SUPRA = 1e8 units (8 decimals)
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
console.log(result.success ? `Sent! ${result.txHash}` : `Failed: ${result.error}`);
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Components
|
|
231
|
+
|
|
232
|
+
### SupraConnectButton
|
|
233
|
+
|
|
234
|
+
A pre-built button that handles wallet connection/disconnection.
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { SupraConnectButton } from '@gerritsen/supra-connect';
|
|
238
|
+
import '@gerritsen/supra-connect/styles.css';
|
|
239
|
+
|
|
240
|
+
export function Header() {
|
|
241
|
+
return (
|
|
242
|
+
<header>
|
|
243
|
+
<h1>My dApp</h1>
|
|
244
|
+
<SupraConnectButton
|
|
245
|
+
dappMetadata={{
|
|
246
|
+
name: 'My dApp',
|
|
247
|
+
description: 'My awesome Supra dApp',
|
|
248
|
+
url: 'https://mydapp.com',
|
|
249
|
+
}}
|
|
250
|
+
/>
|
|
251
|
+
</header>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**What it does:**
|
|
257
|
+
- Shows "Connect Wallet" button if not connected
|
|
258
|
+
- Shows wallet address and "Disconnect" if connected
|
|
259
|
+
- Auto-detects Starkey and Ribbit wallets
|
|
260
|
+
|
|
261
|
+
## FAQ
|
|
262
|
+
|
|
263
|
+
**Q: Do I need both wallets installed?**
|
|
264
|
+
No! The library auto-detects which wallets are available. It works with just Starkey, just Ribbit, or both.
|
|
265
|
+
|
|
266
|
+
**Q: What chains does this support?**
|
|
267
|
+
Currently Supra L1 mainnet. The library handles all network setup automatically.
|
|
268
|
+
|
|
269
|
+
**Q: How do I serialize arguments for custom functions?**
|
|
270
|
+
Use the `supra-l1-sdk` utilities:
|
|
271
|
+
- `BCS.bcsSerializeStr(string)` - for strings
|
|
272
|
+
- `BCS.bcsSerializeUint64(number)` - for u64 numbers
|
|
273
|
+
- `new HexString(address).toUint8Array()` - for addresses
|
|
274
|
+
|
|
275
|
+
**Q: Can I use this with Next.js?**
|
|
276
|
+
Yes! The library is SSR-safe. It checks `typeof window` before accessing wallet APIs.
|
|
277
|
+
|
|
278
|
+
**Q: How do I handle errors?**
|
|
279
|
+
All errors are returned in the result object, never thrown:
|
|
280
|
+
```tsx
|
|
281
|
+
const result = await sendTransaction(...);
|
|
282
|
+
if (!result.success) {
|
|
283
|
+
console.error(result.error, result.reason);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT © 2024 Martin Gerritsen
|
|
290
|
+
|
|
291
|
+
You can use, modify, and redistribute this library freely. Just include the copyright notice!
|
|
292
|
+
|
|
293
|
+
See [LICENSE](./LICENSE) for details.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ReactNode, Component, ErrorInfo } from 'react';
|
|
3
|
+
|
|
4
|
+
interface StarkeyWallet {
|
|
5
|
+
walletAddress: string;
|
|
6
|
+
connected: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface StarkeyAccountInfo {
|
|
9
|
+
address: string;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
}
|
|
12
|
+
interface StarkeyDappMetadata {
|
|
13
|
+
name: string;
|
|
14
|
+
url: string;
|
|
15
|
+
chainId?: string | number;
|
|
16
|
+
}
|
|
17
|
+
interface SupraTransactionPayload$2 {
|
|
18
|
+
moduleAddress: string;
|
|
19
|
+
moduleName: string;
|
|
20
|
+
functionName: string;
|
|
21
|
+
typeArguments?: any[];
|
|
22
|
+
arguments: any[];
|
|
23
|
+
}
|
|
24
|
+
interface SupraTransactionOptions$2 {
|
|
25
|
+
txExpiryTime?: number;
|
|
26
|
+
maxGasAmount?: string;
|
|
27
|
+
gasUnitPrice?: string;
|
|
28
|
+
}
|
|
29
|
+
interface SupraTransactionRequest$2 {
|
|
30
|
+
payload: SupraTransactionPayload$2;
|
|
31
|
+
options?: SupraTransactionOptions$2;
|
|
32
|
+
}
|
|
33
|
+
interface TransactionResult$2 {
|
|
34
|
+
success: boolean;
|
|
35
|
+
txHash?: string;
|
|
36
|
+
error?: string;
|
|
37
|
+
reason?: string;
|
|
38
|
+
}
|
|
39
|
+
declare class StarkeyWalletUtils {
|
|
40
|
+
static isInstalled(): boolean;
|
|
41
|
+
static connect(dappMetadata?: StarkeyDappMetadata): Promise<StarkeyWallet>;
|
|
42
|
+
static disconnect(): Promise<void>;
|
|
43
|
+
static getAccounts(): Promise<string[]>;
|
|
44
|
+
static getNetwork(): Promise<string>;
|
|
45
|
+
static getChainId(): Promise<{
|
|
46
|
+
chainId: string | number;
|
|
47
|
+
} | null>;
|
|
48
|
+
static getAccountInfo(): Promise<StarkeyAccountInfo[]>;
|
|
49
|
+
static getPublicKey(address?: string): Promise<string>;
|
|
50
|
+
static getBalance(): Promise<{
|
|
51
|
+
balance: number;
|
|
52
|
+
formattedBalance: number;
|
|
53
|
+
decimal: number;
|
|
54
|
+
displayUnit: string;
|
|
55
|
+
}>;
|
|
56
|
+
static signMessage(message: string, isHexMessage?: boolean): Promise<string | null>;
|
|
57
|
+
static verifySignature(message: string, signature: string, publicKey: string, isHexMessage?: boolean): Promise<boolean>;
|
|
58
|
+
static getPublicKeyFromAddress(address: string): Promise<string>;
|
|
59
|
+
static sendTransaction(transactionRequest: SupraTransactionRequest$2): Promise<TransactionResult$2>;
|
|
60
|
+
static transfer(transferRequest: SupraTransferRequest): Promise<TransactionResult$2>;
|
|
61
|
+
private static isErrorResponse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface RibbitWallet {
|
|
65
|
+
walletAddress: string;
|
|
66
|
+
connected: boolean;
|
|
67
|
+
chainId?: number;
|
|
68
|
+
allAccounts?: RibbitAccount[];
|
|
69
|
+
}
|
|
70
|
+
interface RibbitDappMetadata {
|
|
71
|
+
name: string;
|
|
72
|
+
url: string;
|
|
73
|
+
description: string;
|
|
74
|
+
logo: string;
|
|
75
|
+
}
|
|
76
|
+
interface RibbitAccount {
|
|
77
|
+
chain: string;
|
|
78
|
+
walletAddress: string;
|
|
79
|
+
}
|
|
80
|
+
interface RibbitConnectSuccessData {
|
|
81
|
+
approved: true;
|
|
82
|
+
accounts: RibbitAccount[];
|
|
83
|
+
error: null;
|
|
84
|
+
}
|
|
85
|
+
interface RibbitConnectSuccessResponse {
|
|
86
|
+
data: RibbitConnectSuccessData;
|
|
87
|
+
}
|
|
88
|
+
interface RibbitConnectFailureResponse {
|
|
89
|
+
approved: false;
|
|
90
|
+
error: string;
|
|
91
|
+
}
|
|
92
|
+
type RibbitConnectResponse = RibbitConnectSuccessResponse | RibbitConnectFailureResponse;
|
|
93
|
+
interface RibbitBalanceRequest {
|
|
94
|
+
chainId: number;
|
|
95
|
+
resourceType?: string;
|
|
96
|
+
decimals?: number;
|
|
97
|
+
}
|
|
98
|
+
interface RibbitMessageRequest {
|
|
99
|
+
message: string;
|
|
100
|
+
isHexMessage?: boolean;
|
|
101
|
+
}
|
|
102
|
+
interface RibbitTransactionRequest {
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface SupraTransactionPayload$1 {
|
|
107
|
+
moduleAddress: string;
|
|
108
|
+
moduleName: string;
|
|
109
|
+
functionName: string;
|
|
110
|
+
typeArguments?: string[];
|
|
111
|
+
arguments: any[];
|
|
112
|
+
}
|
|
113
|
+
interface SupraTransactionOptions$1 {
|
|
114
|
+
txExpiryTime?: number;
|
|
115
|
+
maxGasAmount?: string;
|
|
116
|
+
gasUnitPrice?: string;
|
|
117
|
+
}
|
|
118
|
+
interface SupraTransactionRequest$1 {
|
|
119
|
+
payload: SupraTransactionPayload$1;
|
|
120
|
+
options?: SupraTransactionOptions$1;
|
|
121
|
+
}
|
|
122
|
+
interface TransactionResult$1 {
|
|
123
|
+
success: boolean;
|
|
124
|
+
txHash?: string;
|
|
125
|
+
error?: string;
|
|
126
|
+
reason?: string;
|
|
127
|
+
}
|
|
128
|
+
interface SupraTransferRequest$1 {
|
|
129
|
+
to: string;
|
|
130
|
+
amount: string | number;
|
|
131
|
+
options?: SupraTransactionOptions$1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare class RibbitWalletUtils {
|
|
135
|
+
private static defaultDappMetadata;
|
|
136
|
+
private static initializeClient;
|
|
137
|
+
static isInstalled(): boolean;
|
|
138
|
+
static getWalletType(): "app" | "extension" | null;
|
|
139
|
+
static setDefaultDappMetadata(metadata: Partial<RibbitDappMetadata>): void;
|
|
140
|
+
static getDefaultDappMetadata(): RibbitDappMetadata;
|
|
141
|
+
static connect(dappMetadata?: Partial<RibbitDappMetadata>): Promise<RibbitWallet>;
|
|
142
|
+
static disconnect(): Promise<void>;
|
|
143
|
+
static getWalletInfo(): RibbitWallet | null;
|
|
144
|
+
static getWalletBalance(request: RibbitBalanceRequest): Promise<any>;
|
|
145
|
+
static signMessage(messageRequest: RibbitMessageRequest): Promise<any>;
|
|
146
|
+
static sendTransaction(transactionRequest: SupraTransactionRequest$1 | RibbitTransactionRequest): Promise<TransactionResult$1>;
|
|
147
|
+
static transfer(transferRequest: SupraTransferRequest$1): Promise<TransactionResult$1>;
|
|
148
|
+
static onWalletChanged(handler: (...args: any[]) => void): void;
|
|
149
|
+
static onNetworkChanged(handler: (...args: any[]) => void): void;
|
|
150
|
+
static offWalletChanged(handler: (...args: any[]) => void): void;
|
|
151
|
+
static offNetworkChanged(handler: (...args: any[]) => void): void;
|
|
152
|
+
static getPublicKey(address?: string): Promise<string>;
|
|
153
|
+
static verifySignature(message: string, signature: string, publicKey: string, isHexMessage?: boolean): Promise<boolean>;
|
|
154
|
+
static getPublicKeyFromAddress(address: string): Promise<string>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface Transport {
|
|
158
|
+
sendMessage<T = any>(method: string, payload: any): Promise<T>;
|
|
159
|
+
listen?(): void;
|
|
160
|
+
on?(event: string, handler: (...args: any[]) => void): void;
|
|
161
|
+
off?(event: string, handler: (...args: any[]) => void): void;
|
|
162
|
+
registerHandler?(event: string, handler: (...args: any[]) => void): void;
|
|
163
|
+
}
|
|
164
|
+
declare class AppTransport implements Transport {
|
|
165
|
+
static isAvailable(): boolean;
|
|
166
|
+
listen(): void;
|
|
167
|
+
sendMessage<T = any>(method: string, payload: any): Promise<T>;
|
|
168
|
+
registerHandler(event: string, handler: (...args: any[]) => void): void;
|
|
169
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
170
|
+
off(event: string, handler: (...args: any[]) => void): void;
|
|
171
|
+
}
|
|
172
|
+
declare class ExtensionTransport implements Transport {
|
|
173
|
+
static isAvailable(): boolean;
|
|
174
|
+
listen(): void;
|
|
175
|
+
sendMessage<T = any>(method: string, payload: any): Promise<T>;
|
|
176
|
+
registerHandler(event: string, handler: (...args: any[]) => void): void;
|
|
177
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
178
|
+
off(event: string, handler: (...args: any[]) => void): void;
|
|
179
|
+
}
|
|
180
|
+
declare class TransportFactory {
|
|
181
|
+
static createTransport(): Transport;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare const CHAIN_TYPE: {
|
|
185
|
+
readonly SUPRA: "supra";
|
|
186
|
+
};
|
|
187
|
+
declare const TransportMessageType: {
|
|
188
|
+
readonly CONNECT_REQUEST: "CONNECT_REQUEST";
|
|
189
|
+
readonly DISCONNECT_REQUEST: "DISCONNECT_REQUEST";
|
|
190
|
+
readonly SIGN_MESSAGE: "SIGN_MESSAGE";
|
|
191
|
+
readonly SEND_TRANSACTION: "SEND_TRANSACTION";
|
|
192
|
+
readonly CREATE_RAW_TRANSACTION_BUFFER: "CREATE_RAW_TRANSACTION_BUFFER";
|
|
193
|
+
readonly GET_WALLET_BALANCE: "GET_WALLET_BALANCE";
|
|
194
|
+
readonly WALLET_CHANGED: "WALLET_CHANGED";
|
|
195
|
+
readonly NETWORK_CHANGED: "NETWORK_CHANGED";
|
|
196
|
+
};
|
|
197
|
+
declare const SupraChainId: {
|
|
198
|
+
readonly TESTNET: 6;
|
|
199
|
+
readonly MAINNET: 8;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
interface SupraConnectConfig$1 {
|
|
203
|
+
dappMetadata?: Partial<RibbitDappMetadata>;
|
|
204
|
+
}
|
|
205
|
+
declare class SupraConnectUtils {
|
|
206
|
+
static configure(config: SupraConnectConfig$1): void;
|
|
207
|
+
static getConfig(): {
|
|
208
|
+
ribbitDappMetadata: RibbitDappMetadata;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type WalletType = 'starkey' | 'ribbit';
|
|
213
|
+
interface WalletInfo {
|
|
214
|
+
walletAddress: string;
|
|
215
|
+
connected: boolean;
|
|
216
|
+
type: WalletType;
|
|
217
|
+
}
|
|
218
|
+
declare class WalletUtils {
|
|
219
|
+
static getAvailableWallets(): WalletType[];
|
|
220
|
+
static isWalletInstalled(walletType: WalletType): boolean;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface SupraTransactionPayload {
|
|
224
|
+
/** Module address (e.g., "0x1") */
|
|
225
|
+
moduleAddress: string;
|
|
226
|
+
/** Module name (e.g., "supra_account") */
|
|
227
|
+
moduleName: string;
|
|
228
|
+
/** Function name (e.g., "transfer") */
|
|
229
|
+
functionName: string;
|
|
230
|
+
/** Type arguments for the function */
|
|
231
|
+
typeArguments?: string[];
|
|
232
|
+
/** Function arguments */
|
|
233
|
+
arguments: any[];
|
|
234
|
+
}
|
|
235
|
+
interface SupraTransactionOptions {
|
|
236
|
+
/** Transaction expiry time in seconds (default: 30 seconds from now) */
|
|
237
|
+
txExpiryTime?: number;
|
|
238
|
+
/** Maximum gas amount (optional) */
|
|
239
|
+
maxGasAmount?: string;
|
|
240
|
+
/** Gas unit price (optional) */
|
|
241
|
+
gasUnitPrice?: string;
|
|
242
|
+
}
|
|
243
|
+
interface SupraTransactionRequest {
|
|
244
|
+
/** Transaction payload */
|
|
245
|
+
payload: SupraTransactionPayload;
|
|
246
|
+
/** Transaction options */
|
|
247
|
+
options?: SupraTransactionOptions;
|
|
248
|
+
}
|
|
249
|
+
interface TransactionResult {
|
|
250
|
+
success: boolean;
|
|
251
|
+
/** Transaction hash if successful */
|
|
252
|
+
txHash?: string;
|
|
253
|
+
/** Error message if failed */
|
|
254
|
+
error?: string;
|
|
255
|
+
/** Reason for failure */
|
|
256
|
+
reason?: string;
|
|
257
|
+
}
|
|
258
|
+
interface SupraTransferRequest {
|
|
259
|
+
/** Recipient address */
|
|
260
|
+
to: string;
|
|
261
|
+
/** Amount to transfer (in smallest unit) */
|
|
262
|
+
amount: string | number;
|
|
263
|
+
type?: string;
|
|
264
|
+
/** Transaction options */
|
|
265
|
+
options?: SupraTransactionOptions;
|
|
266
|
+
}
|
|
267
|
+
interface GasEstimation {
|
|
268
|
+
mean_gas_price: number;
|
|
269
|
+
max_gas_price: number;
|
|
270
|
+
median_gas_price: number;
|
|
271
|
+
}
|
|
272
|
+
interface SignMessageResult {
|
|
273
|
+
success: boolean;
|
|
274
|
+
signature?: string;
|
|
275
|
+
reason?: string;
|
|
276
|
+
}
|
|
277
|
+
interface ConnectionState {
|
|
278
|
+
connectedWallet: (WalletInfo & {
|
|
279
|
+
type: WalletType;
|
|
280
|
+
}) | null;
|
|
281
|
+
allAccounts: Array<{
|
|
282
|
+
walletAddress: string;
|
|
283
|
+
chain: string;
|
|
284
|
+
}>;
|
|
285
|
+
isConnecting: boolean;
|
|
286
|
+
connectionError: string | null;
|
|
287
|
+
availableWallets: WalletType[];
|
|
288
|
+
}
|
|
289
|
+
interface DappMetadata {
|
|
290
|
+
name?: string;
|
|
291
|
+
url?: string;
|
|
292
|
+
description?: string;
|
|
293
|
+
logo?: string;
|
|
294
|
+
chainId?: string | number;
|
|
295
|
+
}
|
|
296
|
+
interface SupraConnectConfig {
|
|
297
|
+
dappMetadata?: DappMetadata;
|
|
298
|
+
}
|
|
299
|
+
type StateListener = (state: ConnectionState) => void;
|
|
300
|
+
declare const DEFAULT_RPC_URL = "https://rpc-mainnet.supra.com";
|
|
301
|
+
declare class ConnectionStore {
|
|
302
|
+
private state;
|
|
303
|
+
private listeners;
|
|
304
|
+
private storeId;
|
|
305
|
+
private globalMetadata;
|
|
306
|
+
private rpcUrl;
|
|
307
|
+
constructor(rpcUrl?: string);
|
|
308
|
+
private updateAvailableWallets;
|
|
309
|
+
private setupPeriodicWalletDetection;
|
|
310
|
+
private checkExistingConnections;
|
|
311
|
+
private setState;
|
|
312
|
+
getState(): ConnectionState;
|
|
313
|
+
subscribe(listener: StateListener): () => void;
|
|
314
|
+
connectStarkey(config?: SupraConnectConfig): Promise<void>;
|
|
315
|
+
connectRibbit(config?: SupraConnectConfig): Promise<void>;
|
|
316
|
+
disconnect(): Promise<void>;
|
|
317
|
+
getPublicAddress(chainType?: string): string | null;
|
|
318
|
+
getPublicAddresses(): string[];
|
|
319
|
+
signMessage(message: string): Promise<SignMessageResult>;
|
|
320
|
+
clearError(): void;
|
|
321
|
+
refreshConnections(): Promise<void>;
|
|
322
|
+
setDappMetadata(metadata: DappMetadata): void;
|
|
323
|
+
getDappMetadata(): DappMetadata;
|
|
324
|
+
clearDappMetadata(): void;
|
|
325
|
+
refreshWalletDetection(): void;
|
|
326
|
+
getRpcUrl(): string;
|
|
327
|
+
private mergeMetadata;
|
|
328
|
+
verifySignature(message: string, signature: string): Promise<boolean>;
|
|
329
|
+
sendTransaction(transactionRequest: SupraTransactionRequest): Promise<TransactionResult>;
|
|
330
|
+
transfer(transferRequest: SupraTransferRequest): Promise<TransactionResult>;
|
|
331
|
+
/**
|
|
332
|
+
* Estimates gas price from Supra network using the official API
|
|
333
|
+
* @param network - Network to query (testnet or mainnet)
|
|
334
|
+
* @returns Gas estimation with recommended gas unit price
|
|
335
|
+
*/
|
|
336
|
+
static estimateGasPrice(network?: "testnet" | "mainnet"): Promise<GasEstimation>;
|
|
337
|
+
static getRecommendedGasSettings(network?: "testnet" | "mainnet"): Promise<{
|
|
338
|
+
gasUnitPrice: string;
|
|
339
|
+
maxGasAmount: string;
|
|
340
|
+
}>;
|
|
341
|
+
}
|
|
342
|
+
declare global {
|
|
343
|
+
var __supraConnectStore: ConnectionStore | undefined;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
interface SupraConnectProviderProps {
|
|
347
|
+
children: ReactNode;
|
|
348
|
+
rpcUrl?: string;
|
|
349
|
+
}
|
|
350
|
+
declare function SupraConnectProvider({ children, rpcUrl }: SupraConnectProviderProps): react_jsx_runtime.JSX.Element;
|
|
351
|
+
declare function useSupraConnectStore(): ConnectionStore;
|
|
352
|
+
|
|
353
|
+
interface SupraConnectHookReturn {
|
|
354
|
+
connectedWallet: (WalletInfo & {
|
|
355
|
+
type: WalletType;
|
|
356
|
+
}) | null;
|
|
357
|
+
isConnected: boolean;
|
|
358
|
+
isConnecting: boolean;
|
|
359
|
+
connectionError: string | null;
|
|
360
|
+
availableWallets: WalletType[];
|
|
361
|
+
connectStarkey: () => Promise<void>;
|
|
362
|
+
connectRibbit: () => Promise<void>;
|
|
363
|
+
disconnect: () => Promise<void>;
|
|
364
|
+
getPublicAddress: (chainType?: string) => string | null;
|
|
365
|
+
getPublicAddresses: () => string[];
|
|
366
|
+
getAllAccounts: () => Array<{
|
|
367
|
+
walletAddress: string;
|
|
368
|
+
chain: string;
|
|
369
|
+
}>;
|
|
370
|
+
signMessage: (message: string) => Promise<SignMessageResult>;
|
|
371
|
+
sendTransaction: (transactionRequest: SupraTransactionRequest) => Promise<TransactionResult>;
|
|
372
|
+
transfer: (transferRequest: SupraTransferRequest) => Promise<TransactionResult>;
|
|
373
|
+
clearError: () => void;
|
|
374
|
+
refreshWalletDetection: () => void;
|
|
375
|
+
getRpcUrl: () => string;
|
|
376
|
+
setDappMetadata: (metadata: DappMetadata) => void;
|
|
377
|
+
getDappMetadata: () => DappMetadata;
|
|
378
|
+
clearDappMetadata: () => void;
|
|
379
|
+
}
|
|
380
|
+
declare function useSupraConnect(): SupraConnectHookReturn;
|
|
381
|
+
|
|
382
|
+
interface SupraConnectButtonProps extends SupraConnectConfig {
|
|
383
|
+
metadata?: DappMetadata;
|
|
384
|
+
}
|
|
385
|
+
declare const SupraConnectButton: (props?: SupraConnectButtonProps) => react_jsx_runtime.JSX.Element;
|
|
386
|
+
|
|
387
|
+
interface Props {
|
|
388
|
+
children: ReactNode;
|
|
389
|
+
fallback?: ReactNode;
|
|
390
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
391
|
+
}
|
|
392
|
+
interface State {
|
|
393
|
+
hasError: boolean;
|
|
394
|
+
error?: Error;
|
|
395
|
+
}
|
|
396
|
+
declare class SupraConnectErrorBoundary extends Component<Props, State> {
|
|
397
|
+
state: State;
|
|
398
|
+
static getDerivedStateFromError(error: Error): State;
|
|
399
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
400
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export { AppTransport, CHAIN_TYPE, ConnectionStore, DEFAULT_RPC_URL, type DappMetadata, ExtensionTransport, type GasEstimation, type RibbitAccount, type RibbitBalanceRequest, type RibbitConnectResponse, type RibbitDappMetadata, type RibbitMessageRequest, type RibbitTransactionRequest, type RibbitWallet, RibbitWalletUtils, type SignMessageResult, type StarkeyAccountInfo, type StarkeyDappMetadata, type StarkeyWallet, StarkeyWalletUtils, SupraChainId, SupraConnectButton, type SupraConnectConfig, SupraConnectErrorBoundary, type SupraConnectHookReturn, SupraConnectProvider, SupraConnectUtils, type SupraTransactionOptions, type SupraTransactionPayload, type SupraTransactionRequest, type SupraTransferRequest, type TransactionResult, TransportFactory, TransportMessageType, type WalletInfo, type WalletType, WalletUtils, useSupraConnect, useSupraConnectStore };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{createContext as t,useContext as n,useState as r,useEffect as o,useCallback as a,Component as s}from"react";import*as i from"@noble/ed25519";import{TxnBuilderTypes as l,HexString as c,BCS as d}from"supra-l1-sdk";import{jsx as g,jsxs as u}from"react/jsx-runtime";!function(e,{insertAt:t}={}){if("undefined"==typeof document)return;const n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===t&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}("@layer reset, base, tokens, recipes, utilities;\n");var p=class{static isInstalled(){return"undefined"!=typeof window&&!!window.starkey?.supra}static async connect(e){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{const t={chainId:e?.chainId||8},n=await window.starkey.supra.connect(t);if(!n||0===n.length)throw new Error("No accounts found or connection rejected");return{walletAddress:n[0],connected:!0}}catch(e){throw new Error(`Failed to connect to Starkey wallet: ${e instanceof Error?e.message:"Unknown error"}`)}}static async disconnect(){if(this.isInstalled())try{await window.starkey.supra.disconnect()}catch(e){console.warn("Error disconnecting from Starkey wallet:",e)}}static async getAccounts(){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{return await window.starkey.supra.account()}catch(e){throw new Error(`Failed to get accounts: ${e instanceof Error?e.message:"Unknown error"}`)}}static async getNetwork(){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");return window.starkey.supra.network()}static async getChainId(){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{return await window.starkey.supra.getChainId()}catch(e){throw new Error(`Failed to get chain ID: ${e instanceof Error?e.message:"Unknown error"}`)}}static async getAccountInfo(){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{if("function"==typeof window.starkey.supra.getAccountInfo){const e=await window.starkey.supra.getAccountInfo();if(e&&Array.isArray(e))return e}return(await window.starkey.supra.account()).map(e=>({address:e,publicKey:e}))}catch(e){throw new Error(`Failed to get account info: ${e instanceof Error?e.message:"Unknown error"}`)}}static async getPublicKey(e){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{if("function"==typeof window.starkey.supra.getPublicKey)return await window.starkey.supra.getPublicKey(e);const t=await this.getAccountInfo(),n=e||t[0]?.address,r=t.find(e=>e.address===n);if(r?.publicKey&&r.publicKey!==r.address)return r.publicKey;throw new Error("Public key not available from wallet - StarKey wallet needs to provide actual public keys for signature verification")}catch(e){throw new Error(`Failed to get public key: ${e instanceof Error?e.message:"Unknown error"}`)}}static async getBalance(){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{return await window.starkey.supra.balance()}catch(e){throw new Error(`Failed to get balance: ${e instanceof Error?e.message:"Unknown error"}`)}}static async signMessage(e,t=!1){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{const n=t?e:"0x"+Array.from((new TextEncoder).encode(e)).map(e=>e.toString(16).padStart(2,"0")).join(""),r=await window.starkey.supra.signMessage({message:n});if(this.isErrorResponse(r)){if(4001===r.error.code||r.error.message.toLowerCase().includes("reject")||r.error.message.toLowerCase().includes("cancel")||r.error.message.toLowerCase().includes("denied"))return null;throw new Error(`Signing failed: ${r.error.message}`)}return r.signature}catch(e){if(e instanceof Error){const t=e.message.toLowerCase();if(t.includes("user rejected")||t.includes("user denied")||t.includes("user cancelled")||t.includes("cancelled by user"))return null}throw new Error(`Failed to sign message: ${e instanceof Error?e.message:"Unknown error"}`)}}static async verifySignature(e,t,n,r=!1){try{if(!t.startsWith("0x")||130!==t.length)return!1;if(!n)return!1;const o=new Uint8Array(t.slice(2).match(/.{2}/g)?.map(e=>parseInt(e,16))||[]);if(64!==o.length)return!1;const a=r?new Uint8Array(e.slice(2).match(/.{2}/g)?.map(e=>parseInt(e,16))||[]):(new TextEncoder).encode(e);let s;if(!n.startsWith("0x"))throw new Error("Cannot verify signature: actual public key required, got address");if(s=new Uint8Array(n.slice(2).match(/.{2}/g)?.map(e=>parseInt(e,16))||[]),32!==s.length)return!1;return await i.verifyAsync(o,a,s)}catch(e){return!1}}static async getPublicKeyFromAddress(e){try{return await this.getPublicKey(e)}catch(t){throw new Error(`Cannot get public key for address ${e}: ${t instanceof Error?t.message:"Unknown error"}`)}}static async sendTransaction(e){if(!this.isInstalled())throw new Error("Starkey wallet is not installed");try{const{payload:t,options:n={}}=e,r=n.txExpiryTime||Math.ceil(Date.now()/1e3)+30,o={txExpiryTime:r,...n.maxGasAmount&&{maxGasAmount:n.maxGasAmount},...n.gasUnitPrice&&{gasUnitPrice:n.gasUnitPrice}},a=await this.getAccounts();if(!a||0===a.length)throw new Error("No connected accounts found");console.log("🌟 === STARKEY SEND TRANSACTION DEBUG ==="),console.log("👤 Connected Accounts:",a),console.log("⏰ Transaction Details:"),console.log(" - Expiry Time:",r),console.log(" - Current Time:",Math.ceil(Date.now()/1e3)),console.log("🔧 Final Gas Settings:",o),console.log("🔄 Using Supra provider createRawTransactionData approach...");const s=[a[0],0,t.moduleAddress,t.moduleName,t.functionName,t.typeArguments||[],t.arguments,o];console.log("📤 Raw Transaction Payload for createRawTransactionData:"),console.log(" - Sender:",a[0]),console.log(" - Sequence:",0),console.log(" - Module Address:",t.moduleAddress),console.log(" - Module Name:",t.moduleName),console.log(" - Function Name:",t.functionName),console.log(" - Type Arguments:",t.typeArguments),console.log(" - Arguments:",t.arguments),console.log(" - Options:",o);try{console.log("🔄 Step 1: Creating raw transaction data...");const e=await window.starkey.supra.createRawTransactionData(s);if(console.log("✅ Raw transaction data created:",e),!e)throw new Error("Failed to create raw transaction data");console.log("🔄 Step 2: Sending transaction with data...");const t={data:e},n=await window.starkey.supra.sendTransaction(t);if(console.log("🎉 Supra provider transaction successful! Hash:",n),console.log("================================"),!n)throw new Error("Transaction failed - no hash returned from Supra provider");return{success:!0,txHash:n}}catch(e){console.log("❌ Supra provider approach failed:",e)}return{success:!1,reason:"All transaction approaches failed",error:"No valid transaction format accepted by wallet"}}catch(e){if(e instanceof Error){const t=e.message.toLowerCase();if(t.includes("user rejected")||t.includes("user denied")||t.includes("user cancelled")||t.includes("cancelled by user"))return{success:!1,reason:"User cancelled transaction"}}return{success:!1,error:e instanceof Error?e.message:"Unknown error",reason:"Transaction failed"}}}static async transfer(e){const{to:t,amount:n,options:r,type:o}=e;console.log("yy",e);const a={payload:{moduleAddress:"0000000000000000000000000000000000000000000000000000000000000001",moduleName:"supra_account",functionName:o?"transfer_coins":"transfer",typeArguments:o?[o]:[],arguments:[new c(t).toUint8Array(),d.bcsSerializeUint64(BigInt(n))]},options:r};return console.log("xx:",a),this.sendTransaction(a)}static isErrorResponse(e){return e&&"string"==typeof e.jsonrpc&&"object"==typeof e.error}},h={SUPRA:"supra"},f={CONNECT_REQUEST:"CONNECT_REQUEST",DISCONNECT_REQUEST:"DISCONNECT_REQUEST",SIGN_MESSAGE:"SIGN_MESSAGE",SEND_TRANSACTION:"SEND_TRANSACTION",CREATE_RAW_TRANSACTION_BUFFER:"CREATE_RAW_TRANSACTION_BUFFER",GET_WALLET_BALANCE:"GET_WALLET_BALANCE",WALLET_CHANGED:"WALLET_CHANGED",NETWORK_CHANGED:"NETWORK_CHANGED"},w={TESTNET:6,MAINNET:8},b=class{static isAvailable(){return"undefined"!=typeof window&&!!window.ribbit&&"app"===window.ribbit.type}listen(){}async sendMessage(e,t){if("undefined"==typeof window)throw new Error("SSR mode");if(!window.ribbit||"app"!==window.ribbit.type)throw new Error("AppTransport: ribbit app not detected");console.log(`🚀 AppTransport.sendMessage(${e})`);const n=await window.ribbit.postMessage(e,t);return console.log(`✅ AppTransport.sendMessage(${e}) result:`,n),console.log(" - typeof result:",typeof n),console.log(" - has 'data' property:","data"in n),console.log(" - result.data:",n.data),console.log(" - Object.keys(result):",Object.keys(n)),n}registerHandler(e,t){"undefined"!=typeof window&&window.ribbit?.on?.(e,t)}on(e,t){"undefined"!=typeof window&&window.ribbit?.on?.(e,t)}off(e,t){"undefined"!=typeof window&&window.ribbit?.off?.(e,t)}},m=class{static isAvailable(){return"undefined"!=typeof window&&!!window.ribbit&&"extension"===window.ribbit.type}listen(){}async sendMessage(e,t){if("undefined"==typeof window)throw new Error("SSR mode");if(!window.ribbit||"extension"!==window.ribbit.type)throw new Error("ExtensionTransport: ribbit extension not detected");console.log(`🚀 ExtensionTransport.sendMessage(${e})`);const n=await window.ribbit.postMessage(e,t);return console.log(`✅ ExtensionTransport.sendMessage(${e}) result:`,n),console.log(" - typeof result:",typeof n),console.log(" - has 'data' property:","data"in n),console.log(" - result.data:",n.data),console.log(" - Object.keys(result):",Object.keys(n)),n}registerHandler(e,t){"undefined"!=typeof window&&window.ribbit?.on?.(e,t)}on(e,t){"undefined"!=typeof window&&window.ribbit?.on?.(e,t)}off(e,t){"undefined"!=typeof window&&window.ribbit?.off?.(e,t)}},y=class{static createTransport(){if(b.isAvailable())return new b;if(m.isAvailable())return new m;throw new Error("No Ribbit wallet detected")}};function S(){return"undefined"==typeof window?"":window.location.origin||window.location.hostname}function E(){return`ribbit_connected_wallet::${S()}`}function A(){return`ribbit_accounts::${S()}`}function C(){try{localStorage.removeItem(E()),localStorage.removeItem(A())}catch{}}var k=null,_=Math.random().toString(36).substring(7),v=class{static initializeClient(){if("undefined"==typeof window)return null;if(!window.ribbit?.type)return null;if(k?console.log(`🐸 Reusing existing clientInstance (ID: ${_})`):console.log(`🐸 Creating NEW clientInstance (ID: ${_})`),!k){if(k={transport:null,wallet:null},"app"===window.ribbit.type)k.transport=new b;else{if("extension"!==window.ribbit.type)throw new Error(`Unknown ribbit type: ${window.ribbit.type}`);k.transport=new m}k.transport.listen();const e=function(){try{const e=localStorage.getItem(E());if(e){const{address:t,expiry:n}=JSON.parse(e);return Date.now()<n?t:(C(),null)}return null}catch{return null}}();if(e){const t=function(){try{const e=localStorage.getItem(A());if(e){const{accounts:t,expiry:n}=JSON.parse(e);return Date.now()<n?t:(C(),null)}return null}catch{return null}}()||[];k.wallet={walletAddress:e,connected:!0,chainId:w.MAINNET,allAccounts:t},console.log("🐸 Ribbit: Restored wallet from storage:",k.wallet.walletAddress),console.log(`🐸 Ribbit: Restored ${t.length} account(s)`)}}return k}static isInstalled(){return"undefined"!=typeof window&&!!window.ribbit}static getWalletType(){return this.isInstalled()?window.ribbit.type:null}static setDefaultDappMetadata(e){this.defaultDappMetadata={...this.defaultDappMetadata,...e}}static getDefaultDappMetadata(){return{...this.defaultDappMetadata}}static async connect(e){if(console.log("LFG DUDE!!"),!this.isInstalled())throw new Error("Ribbit wallet is not installed");const t={name:e?.name||this.defaultDappMetadata.name,url:e?.url||this.defaultDappMetadata.url,description:e?.description||this.defaultDappMetadata.description,logo:e?.logo||this.defaultDappMetadata.logo},n=this.initializeClient();if(!n||!n.transport)throw new Error("No transport available");const r=await n.transport.sendMessage(f.CONNECT_REQUEST,{dapp:t});console.log("response",JSON.stringify(r,null,2));const o="data"in r?r.data:r;if(!o?.approved||!("accounts"in o)||!o.accounts?.length)throw new Error(`Connection to wallet failed: ${o?.error||"Unknown error"}`);const a=o.accounts.filter(e=>e.chain===h.SUPRA)[0]?.walletAddress;if(void 0===a)throw new Error("No wallet address found");const s=w.MAINNET;return n.wallet={walletAddress:a,connected:!0,chainId:s,allAccounts:o.accounts},function(e,t,n=10){try{const r=Date.now()+24*n*60*60*1e3,o=E(),a=JSON.stringify({address:e,expiry:r});if(console.log("💾 Saving wallet to localStorage"),console.log(` - Key: ${o}`),console.log(` - Value: ${a}`),localStorage.setItem(o,a),t&&t.length>0){const e=A(),n=JSON.stringify({accounts:t,expiry:r});console.log("💾 Saving accounts to localStorage"),console.log(` - Key: ${e}`),localStorage.setItem(e,n)}console.log("✅ Wallet saved successfully"),console.log(` - Verification: localStorage.getItem("${o}") =`,localStorage.getItem(o))}catch(e){console.error("❌ Failed to save wallet:",e)}}(a,o.accounts),n.wallet}static async disconnect(){const e=this.initializeClient();e&&(e.wallet=null,C(),e.transport&&await e.transport.sendMessage(f.DISCONNECT_REQUEST,{}))}static getWalletInfo(){const e=this.initializeClient();return console.log("🔍 getWalletInfo - returning client.wallet:",e?.wallet),e?.wallet||null}static async getWalletBalance(e){const t=this.initializeClient();if(!t||!t.transport)throw new Error("No transport available");if(!t.wallet)throw new Error("Not connected");const{chainId:n,resourceType:r,decimals:o}=e;return t.transport.sendMessage(f.GET_WALLET_BALANCE,{chainId:n,resourceType:r,decimals:o})}static async signMessage(e){const t=this.initializeClient();if(!t||!t.transport)throw new Error("No transport available");if(!t.wallet)throw new Error("Not connected");try{const n=await t.transport.sendMessage(f.SIGN_MESSAGE,e);return n?.error&&(4001===n.error.code||n.error.message?.toLowerCase().includes("reject")||n.error.message?.toLowerCase().includes("cancel")||n.error.message?.toLowerCase().includes("denied"))?null:n}catch(e){if(e instanceof Error){const t=e.message.toLowerCase();if(t.includes("user rejected")||t.includes("user denied")||t.includes("user cancelled")||t.includes("cancelled by user"))return null}throw e}}static async sendTransaction(e){console.log("::: SEND TRANSACTION - change");const t=this.initializeClient();if(console.log("🔍 sendTransaction - client:",t),console.log("🔍 sendTransaction - client.wallet:",t?.wallet),!t||!t.transport)throw new Error("No transport available");if(!t.wallet)throw console.log("❌ client.wallet is null/undefined!"),console.log("clientInstance at this point:",k),new Error("Wallet not connected");try{let n;if(console.log("111 🐸 === RIBBIT SEND TRANSACTION DEBUG ==="),console.log("📥 Input Transaction Request:",e),"payload"in e){const r=e,o=r.options||{};console.log("🔄 Converting Supra format to Ribbit format..."),console.log("📦 Payload:",r.payload),console.log("📦 Options:",o);const a={sender:t.wallet.walletAddress,moduleAddress:r.payload.moduleAddress,moduleName:r.payload.moduleName,functionName:r.payload.functionName,typeArgs:r.payload.typeArguments||[],args:r.payload.arguments,chainId:t.wallet.chainId||w.MAINNET,gasUnitPrice:o.gasUnitPrice?Number(o.gasUnitPrice):void 0,maxGasAmount:o.maxGasAmount?Number(o.maxGasAmount):void 0};console.log("🔍 Raw Transaction Request:",a);try{const e=r.payload.typeArguments?.map(e=>"string"==typeof e?new l.TypeTagParser(e).parseTypeTag():e)||[];console.log("🔍 Type Arguments:",e);const o=r.payload.arguments.map(e=>e instanceof Uint8Array?Array.from(e):e);console.log("🔍 Converted Arguments for BCS:",o.map((e,t)=>({index:t,type:Array.isArray(e)?"Array":typeof e,length:e?.length})));const a=l.EntryFunction.natural(`${r.payload.moduleAddress}::${r.payload.moduleName}`,r.payload.functionName,e,o);console.log("✅ Created EntryFunction using natural()");const s=new l.TransactionPayloadEntryFunction(a);let i,g;console.log("🔄 Fetching sequence number and gas price from network...");const u="https://rpc-mainnet.supra.com/rpc/v3";try{console.log("🔄 Fetching sequence number from RPC...");const e=await fetch(`${u}/accounts/${encodeURIComponent(t.wallet.walletAddress)}`);if(e.ok){const t=await e.json();i=BigInt(t.sequence_number||0),console.log("✅ Fetched sequence number:",i.toString())}else console.warn("⚠️ Failed to fetch sequence number:",e.status),i=BigInt(0)}catch(e){console.warn("⚠️ Failed to fetch sequence number:",e),i=BigInt(0)}try{console.log("🔄 Fetching gas price from RPC...");const e=await fetch(`${u}/transactions/estimate_gas_price`);e.ok?(g=await e.json(),console.log("✅ Fetched gas prices:",g)):(console.warn("⚠️ Failed to fetch gas price:",e.status),g={max_gas_price:200,mean_gas_price:100})}catch(e){console.warn("⚠️ Failed to fetch gas price:",e),g={max_gas_price:200,mean_gas_price:100}}const p=BigInt(Math.floor(Date.now()/1e3)+300);console.log("🔄 Creating RawTransaction..."),console.log(" - Sender:",t.wallet.walletAddress),console.log(" - Sequence:",i.toString()),console.log(" - Max Gas Price:",g.max_gas_price),console.log(" - Mean Gas Price:",g.mean_gas_price),console.log(" - Expiration:",p.toString()),console.log(" - Payload Module:",`${r.payload.moduleAddress}::${r.payload.moduleName}`),console.log(" - Payload Function:",r.payload.functionName);const h=new l.RawTransaction(l.AccountAddress.fromHex(new c(t.wallet.walletAddress)),i,s,BigInt(Math.floor(50*g.max_gas_price)),BigInt(g.mean_gas_price),p,new l.ChainId(t.wallet.chainId||w.MAINNET)),f=d.bcsToBytes(h);let b;if("undefined"!=typeof Buffer)b=Buffer.from(f).toString("base64");else{if("undefined"==typeof btoa)throw new Error("Cannot encode to base64: no Buffer or btoa available");b=btoa(String.fromCharCode(...Array.from(f)))}console.log("✅ Serialized Transaction (base64):",b),console.log(" Base64 Length:",b.length),console.log(" Serialized bytes length:",f.length),n={rawTxn:b,chainId:t.wallet.chainId||w.MAINNET,meta:{description:`${r.payload.functionName} on ${r.payload.moduleName}`}}}catch(e){throw console.error("❌ Transaction serialization failed:",e),new Error(`Failed to serialize transaction: ${e instanceof Error?e.message:"Unknown error"}`)}}else n=e;console.log("📤 Sending to Ribbit transport..."),console.log("Message Type:",f.SEND_TRANSACTION),console.log("Data:",JSON.stringify(n,null,2));const r=await t.transport.sendMessage(f.SEND_TRANSACTION,n);return console.log("✅ Ribbit Result:",r),console.log("================================"),r?.txHash||r?.transactionHash||r?.hash?{success:!0,txHash:r.txHash||r.transactionHash||r.hash}:r?.error?{success:!1,error:r.error,reason:"Transaction failed"}:"string"==typeof r?{success:!0,txHash:r}:{success:!1,error:"Unknown response format from wallet",reason:"Transaction failed"}}catch(e){if(e instanceof Error){const t=e.message.toLowerCase();if(t.includes("user rejected")||t.includes("user denied")||t.includes("user cancelled")||t.includes("cancelled by user"))return{success:!1,reason:"User cancelled transaction"}}return{success:!1,error:e instanceof Error?e.message:"Unknown error",reason:"Transaction failed"}}}static async transfer(e){const{to:t,amount:n,options:r}=e;console.log("🐸 === RIBBIT TRANSFER DEBUG ==="),console.log("📥 Input Transfer Request:",JSON.stringify(e,null,2)),console.log("🎯 Parsed Components:"),console.log(" - To Address:",t),console.log(" - Amount (raw):",n),console.log(" - Amount Type:",typeof n),console.log(" - Options:",r);const o=new c(t).toUint8Array(),a=d.bcsSerializeUint64(BigInt(n)),s={payload:{moduleAddress:"0000000000000000000000000000000000000000000000000000000000000001",moduleName:"supra_account",functionName:"transfer",typeArguments:[],arguments:[o,a]},options:r};return console.log("🔄 Converted to Transaction Request:"),console.log(" - Module Address:",s.payload.moduleAddress),console.log(" - Module Name:",s.payload.moduleName),console.log(" - Function Name:",s.payload.functionName),console.log(" - Type Arguments:",s.payload.typeArguments),console.log(" - Arguments Length:",s.payload.arguments.length),console.log(" - Arguments Types:",s.payload.arguments.map(e=>typeof e)),console.log(" - Address Bytes Length:",o.length),console.log(" - Amount Bytes Length:",a.length),console.log("📋 Transaction Request created successfully"),console.log("================================"),this.sendTransaction(s)}static onWalletChanged(e){const t=this.initializeClient();t?.transport?.on?.(f.WALLET_CHANGED,e)}static onNetworkChanged(e){const t=this.initializeClient();t?.transport?.on?.(f.NETWORK_CHANGED,e)}static offWalletChanged(e){const t=this.initializeClient();t?.transport?.off?.(f.WALLET_CHANGED,e)}static offNetworkChanged(e){const t=this.initializeClient();t?.transport?.off?.(f.NETWORK_CHANGED,e)}static async getPublicKey(e){const t=this.initializeClient();if(!t||!t.transport)throw new Error("No transport available");if(!t.wallet)throw new Error("Not connected");try{const n=await t.transport.sendMessage("GET_PUBLIC_KEY",{address:e||t.wallet.walletAddress});if(n?.publicKey)return n.publicKey;throw new Error("Public key not available from wallet")}catch(e){throw new Error(`Failed to get public key: ${e instanceof Error?e.message:"Unknown error"}`)}}static async verifySignature(e,t,n,r=!1){try{if(!t||!t.startsWith("0x")&&t.length<128)return!1;if(!n)return!1;let o;if(o=t.startsWith("0x")?new Uint8Array(t.slice(2).match(/.{2}/g)?.map(e=>parseInt(e,16))||[]):new Uint8Array(t.match(/.{2}/g)?.map(e=>parseInt(e,16))||[]),64!==o.length)return!1;const a=r?new Uint8Array(e.slice(2).match(/.{2}/g)?.map(e=>parseInt(e,16))||[]):(new TextEncoder).encode(e);let s;if(n.startsWith("0x"))s=new Uint8Array(n.slice(2).match(/.{2}/g)?.map(e=>parseInt(e,16))||[]);else{if(64!==n.length)throw new Error("Invalid public key format");s=new Uint8Array(n.match(/.{2}/g)?.map(e=>parseInt(e,16))||[])}if(32!==s.length)return!1;return await i.verifyAsync(o,a,s)}catch(e){return!1}}static async getPublicKeyFromAddress(e){try{return await this.getPublicKey(e)}catch(t){throw new Error(`Cannot get public key for address ${e}: ${t instanceof Error?t.message:"Unknown error"}`)}}};v.defaultDappMetadata={name:"Supra Connect",url:"undefined"!=typeof window?window.location.origin:"https://supra.com",description:"Connect to Supra blockchain wallets",logo:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEwIDJMMTcgNkwxNyAxNEwxMCAxOEwzIDE0TDMgNkwxMCAyWiIgZmlsbD0iI0REMTQzOCIvPgo8L3N2Zz4K"};var x=class{static configure(e){e.dappMetadata&&v.setDefaultDappMetadata(e.dappMetadata)}static getConfig(){return{ribbitDappMetadata:v.getDefaultDappMetadata()}}},T=class{static getAvailableWallets(){const e=[];return"undefined"!=typeof window&&(window.starkey?.supra&&e.push("starkey"),window.ribbit&&e.push("ribbit")),e}static isWalletInstalled(e){switch(e){case"starkey":return"undefined"!=typeof window&&!!window.starkey?.supra;case"ribbit":return"undefined"!=typeof window&&!!window.ribbit;default:return!1}}},I="https://rpc-mainnet.supra.com",N=class{constructor(e=I){this.state={connectedWallet:null,allAccounts:[],isConnecting:!1,connectionError:null,availableWallets:[]},this.listeners=new Set,this.globalMetadata={},this.storeId=Math.random().toString(36).substring(2,9),this.rpcUrl=e,"undefined"!=typeof window&&(this.updateAvailableWallets(),this.setupPeriodicWalletDetection(),setTimeout(()=>{this.checkExistingConnections().catch(()=>{})},100))}updateAvailableWallets(){const e=[];p.isInstalled()&&e.push("starkey"),v.isInstalled()&&e.push("ribbit");const t=this.state.availableWallets;e.length===t.length&&e.every(e=>t.includes(e))||this.setState({availableWallets:e})}setupPeriodicWalletDetection(){const e=setInterval(()=>{this.updateAvailableWallets()},1e3);setTimeout(()=>{clearInterval(e)},3e4),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",()=>{setTimeout(()=>this.updateAvailableWallets(),500)}),window.addEventListener("load",()=>{setTimeout(()=>this.updateAvailableWallets(),1e3)})}async checkExistingConnections(){const e=v.getWalletInfo();if(e)this.setState({connectedWallet:{...e,type:"ribbit"},allAccounts:e.allAccounts||[{walletAddress:e.walletAddress,chain:"supra"}]});else if(p.isInstalled())try{const e=await p.getAccounts();if(e&&e.length>0)return void this.setState({connectedWallet:{walletAddress:e[0],connected:!0,type:"starkey"},allAccounts:[{walletAddress:e[0],chain:"supra"}]})}catch(e){}}setState(e){this.state={...this.state,...e},this.listeners.forEach(e=>e(this.state))}getState(){return{...this.state}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async connectStarkey(e){if(!this.state.isConnecting){this.setState({isConnecting:!0,connectionError:null});try{const t=this.mergeMetadata(e?.dappMetadata),n=Object.keys(t).length>0?{name:t.name||"Supra Connect",url:t.url||("undefined"!=typeof window?window.location.origin:"https://supra.com"),chainId:t.chainId}:void 0,r=await p.connect(n);this.setState({connectedWallet:{...r,type:"starkey"},allAccounts:[{walletAddress:r.walletAddress,chain:"supra"}],isConnecting:!1,connectionError:null})}catch(e){throw this.setState({connectionError:e instanceof Error?e.message:"Failed to connect to Starkey wallet",isConnecting:!1}),e}}}async connectRibbit(e){if(console.log("Connecting to Ribbit wallet"),!this.state.isConnecting){this.setState({isConnecting:!0,connectionError:null});try{const t=this.mergeMetadata(e?.dappMetadata),n=Object.keys(t).length>0?{name:t.name,url:t.url,description:t.description,logo:t.logo}:void 0,r=await v.connect(n);console.log("✅ RibbitWalletUtils.connect() returned:",r),console.log("🐸 Setting connectedWallet state:",{...r,type:"ribbit"}),this.setState({connectedWallet:{...r,type:"ribbit"},allAccounts:r.allAccounts||[{walletAddress:r.walletAddress,chain:"supra"}],isConnecting:!1,connectionError:null}),console.log("📊 New state after connection:",this.state)}catch(e){throw this.setState({connectionError:e instanceof Error?e.message:"Failed to connect to Ribbit wallet",isConnecting:!1}),e}}}async disconnect(){if(this.state.connectedWallet)try{"starkey"===this.state.connectedWallet.type?await p.disconnect():"ribbit"===this.state.connectedWallet.type&&await v.disconnect(),this.setState({connectedWallet:null,allAccounts:[],connectionError:null})}catch(e){console.warn("Error disconnecting wallet:",e),this.setState({connectedWallet:null,allAccounts:[],connectionError:null})}}getPublicAddress(e="supra"){if(!this.state.connectedWallet)return null;if(this.state.allAccounts.length>0){const t=this.state.allAccounts.find(t=>t.chain===e);return t?.walletAddress||null}return this.state.connectedWallet.walletAddress||null}getPublicAddresses(){return this.state.allAccounts.length>0?this.state.allAccounts.map(e=>e.walletAddress):this.state.connectedWallet?[this.state.connectedWallet.walletAddress]:[]}async signMessage(e){if(!this.state.connectedWallet)return{success:!1,reason:"No wallet connected"};try{let t=null;if("starkey"===this.state.connectedWallet.type)t=await p.signMessage(e);else{if("ribbit"!==this.state.connectedWallet.type)return{success:!1,reason:"Unsupported wallet type"};{const n=await v.signMessage({message:e});t=null===n?null:n.signature||n}}if(null===t)return{success:!1,reason:"User cancelled"};try{return await this.verifySignature(e,t)?{success:!0,signature:t}:{success:!1,reason:"Signature verification failed"}}catch(e){return{success:!0,signature:t,reason:"Signature obtained but verification failed"}}}catch(e){return{success:!1,reason:e instanceof Error?e.message:"Failed to sign message"}}}clearError(){this.setState({connectionError:null})}async refreshConnections(){await this.checkExistingConnections()}setDappMetadata(e){this.globalMetadata={...this.globalMetadata,...e}}getDappMetadata(){return{...this.globalMetadata}}clearDappMetadata(){this.globalMetadata={}}refreshWalletDetection(){this.updateAvailableWallets()}getRpcUrl(){return this.rpcUrl}mergeMetadata(e){return{...this.globalMetadata,...e}}async verifySignature(e,t){if(!this.state.connectedWallet)throw new Error("No wallet connected");try{if("starkey"===this.state.connectedWallet.type){const n=await p.getPublicKeyFromAddress(this.state.connectedWallet.walletAddress);return await p.verifySignature(e,t,n)}if("ribbit"===this.state.connectedWallet.type){const n=await v.getPublicKeyFromAddress(this.state.connectedWallet.walletAddress);return await v.verifySignature(e,t,n)}throw new Error("Unsupported wallet type")}catch(e){throw new Error(e instanceof Error?e.message:"Failed to verify signature")}}async sendTransaction(e){if(!this.state.connectedWallet)return{success:!1,reason:"No wallet connected"};try{return"starkey"===this.state.connectedWallet.type?await p.sendTransaction(e):"ribbit"===this.state.connectedWallet.type?await v.sendTransaction(e):{success:!1,reason:"Unsupported wallet type"}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to send transaction",reason:"Transaction failed"}}}async transfer(e){if(!this.state.connectedWallet)return{success:!1,reason:"No wallet connected"};console.log(`GOING FOR IT: ${this.state.connectedWallet.type}`);try{return"starkey"===this.state.connectedWallet.type?await p.transfer(e):"ribbit"===this.state.connectedWallet.type?await v.transfer(e):{success:!1,reason:"Unsupported wallet type"}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to send transfer",reason:"Transfer failed"}}}static async estimateGasPrice(e="testnet"){const t="mainnet"===e?"https://rpc-mainnet.supra.com":"https://rpc-testnet.supra.com";try{const e=await fetch(`${t}/rpc/v2/transactions/estimate_gas_price`);if(e.ok)return await e.json();const n=await fetch(`${t}/rpc/v1/transactions/estimate_gas_price`);if(n.ok){const e=await n.json();return{mean_gas_price:e.gas_estimate||e.mean_gas_price||100,max_gas_price:e.max_gas_price||2*(e.gas_estimate||100),median_gas_price:e.median_gas_price||e.gas_estimate||100}}throw new Error("Both gas estimation endpoints failed")}catch(e){return console.warn("Gas estimation failed, using safe defaults:",e),{mean_gas_price:100,max_gas_price:200,median_gas_price:100}}}static async getRecommendedGasSettings(e="testnet"){try{const t=await this.estimateGasPrice(e),n=Math.max(1.2*t.mean_gas_price,100);return{gasUnitPrice:Math.ceil(n).toString(),maxGasAmount:"200000"}}catch(e){return{gasUnitPrice:"100",maxGasAmount:"200000"}}}};"undefined"!=typeof window?(window.__supraConnectStore||(window.__supraConnectStore=new N),window.__supraConnectStore):(global.__supraConnectStore||(global.__supraConnectStore=new N),global.__supraConnectStore);var M=t(void 0);function R({children:t,rpcUrl:n=I}){const r=e.useMemo(()=>new N(n),[n]);return g(M.Provider,{value:r,children:t})}function W(){const e=n(M);if(!e)throw new Error("useSupraConnectStore must be used within a SupraConnectProvider. Make sure to wrap your app with <SupraConnectProvider>.</SupraConnectProvider>");return e}function D(){const e=W(),[t,n]=r(()=>e.getState());o(()=>e.subscribe(n),[e]);const s=a(async()=>{await e.connectStarkey()},[e]),i=a(async()=>{await e.connectRibbit()},[e]),l=a(async()=>{await e.disconnect()},[e]),c=a(t=>e.getPublicAddress(t),[e]),d=a(()=>e.getPublicAddresses(),[e]),g=a(()=>t.allAccounts,[t.allAccounts]),u=a(async t=>e.signMessage(t),[e]),p=a(async t=>e.sendTransaction(t),[e]),h=a(async t=>e.transfer(t),[e]),f=a(()=>{e.clearError()},[e]),w=a(()=>{e.refreshWalletDetection()},[e]),b=a(()=>e.getRpcUrl(),[e]),m=a(t=>{e.setDappMetadata(t)},[e]),y=a(()=>e.getDappMetadata(),[e]),S=a(()=>{e.clearDappMetadata()},[e]);return{connectedWallet:t.connectedWallet,isConnected:!!t.connectedWallet,isConnecting:t.isConnecting,connectionError:t.connectionError,availableWallets:t.availableWallets,connectStarkey:s,connectRibbit:i,disconnect:l,getPublicAddress:c,getPublicAddresses:d,getAllAccounts:g,signMessage:u,sendTransaction:p,transfer:h,clearError:f,refreshWalletDetection:w,getRpcUrl:b,setDappMetadata:m,getDappMetadata:y,clearDappMetadata:S}}var B=({width:e=24,height:t=24})=>u("svg",{width:e,height:t,viewBox:"0 0 70 70",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g("circle",{cx:"35",cy:"35",r:"35",fill:"#dd1438"}),g("path",{d:"M54.81,17.92A16.52,16.52,0,0,0,51,12.34a18.51,18.51,0,0,0-5.68-3.63,16.57,16.57,0,0,0-4.45-1.09,17.21,17.21,0,0,0-18.7,22.47v.05h0A17.12,17.12,0,0,0,18.69,33,17.92,17.92,0,0,0,15,38.76a18.45,18.45,0,0,0-1.21,6.71,16.48,16.48,0,0,0,1.4,6.61A16.66,16.66,0,0,0,19,57.66a18.67,18.67,0,0,0,5.69,3.63,17.23,17.23,0,0,0,6,1.2H31A17.26,17.26,0,0,0,47.58,40a17.34,17.34,0,0,0,3.69-3A17.9,17.9,0,0,0,55,31.25a18.34,18.34,0,0,0,1.22-6.72,16.49,16.49,0,0,0-1.41-6.61ZM39.73,19.16a6.61,6.61,0,0,1-.17-1.65,8.39,8.39,0,0,1,1.82.52,5.92,5.92,0,0,1,2.14,1.57,7.23,7.23,0,0,1,1.3,2.25,7.35,7.35,0,0,1,.38,2.52,6.49,6.49,0,0,1-1.91,4.23ZM43.8,29.94c.11-.1.22-.21.32-.32a7.47,7.47,0,0,0,1.57-2.52,7.82,7.82,0,0,0,.46-2.9,6.69,6.69,0,0,0-.65-2.79,8,8,0,0,0-1.68-2.24,6.548,6.548,0,0,0-4.27-1.77,7.29,7.29,0,0,1,.82-3.13,9.4,9.4,0,0,1,2.2.7,10.63,10.63,0,0,1,3.25,2.33,12.31,12.31,0,0,1,2.06,3.36,10.64,10.64,0,0,1,.65,3.81,8.21,8.21,0,0,1-.84,3.74,8.16,8.16,0,0,1-2.14,3.06,7.74,7.74,0,0,1-1,.75Zm1.27,3.35a11.84,11.84,0,0,0,1.37-1.18,11.43,11.43,0,0,0,3-7.82,10.28,10.28,0,0,0-.92-4.09,10.05,10.05,0,0,0-2.41-3.36,10.36,10.36,0,0,0-3.44-2.14,11.08,11.08,0,0,0-2.26-.53,6.86,6.86,0,0,1,1.22-1.64,6.76,6.76,0,0,1,1.24-1,9,9,0,0,1,1,.41,12.5,12.5,0,0,1,4.28,3A13.61,13.61,0,0,1,51,19.33a14.22,14.22,0,0,1,.92,5.12,14.86,14.86,0,0,1-1.11,5,13.56,13.56,0,0,1-2.9,4.08,11.72,11.72,0,0,1-2.08,1.67ZM26.88,58.37a7.38,7.38,0,0,1-.82-.33,12.5,12.5,0,0,1-4.28-3A13.61,13.61,0,0,1,19,50.67a14.22,14.22,0,0,1-.92-5.12,14.81,14.81,0,0,1,1.11-5,13.6,13.6,0,0,1,2.9-4.09A12.7,12.7,0,0,1,24,34.87l.76,2a12.48,12.48,0,0,0-1.23,1.06,11.12,11.12,0,0,0-2.24,3.63,11,11,0,0,0-.76,4.2,10.32,10.32,0,0,0,.92,4.09,10.53,10.53,0,0,0,5.85,5.49,11.07,11.07,0,0,0,2,.51,7.36,7.36,0,0,1-1.18,1.56,7,7,0,0,1-1.24.96ZM27.39,55a10.63,10.63,0,0,1-3.25-2.33,12.41,12.41,0,0,1-2.06-3.35,10.73,10.73,0,0,1-.65-3.82,8.21,8.21,0,0,1,.84-3.74,8.16,8.16,0,0,1,2.14-3.06,8.4,8.4,0,0,1,.8-.65L26,40.19l-.19.19a7.47,7.47,0,0,0-1.57,2.52,7.82,7.82,0,0,0-.46,2.9,6.69,6.69,0,0,0,.65,2.79,8,8,0,0,0,1.68,2.24,7,7,0,0,0,2.33,1.41,6.53,6.53,0,0,0,1.77.34,7.13,7.13,0,0,1-.86,3.11A9.3,9.3,0,0,1,27.39,55Zm2.71-4.22a7.76,7.76,0,0,1,.14,1.66,8.81,8.81,0,0,1-1.66-.5,5.92,5.92,0,0,1-2.14-1.57,7.23,7.23,0,0,1-1.3-2.25,7.35,7.35,0,0,1-.38-2.52,6.54,6.54,0,0,1,1.78-4.1Zm-14.28,1a18.45,18.45,0,0,1-1.11-6.33,18.18,18.18,0,0,1,1.41-6.23,16.76,16.76,0,0,1,3.63-5.23,15,15,0,0,1,3-2.31l.56,1.48a13.09,13.09,0,0,0-2.41,2A14.12,14.12,0,0,0,18,40a15.85,15.85,0,0,0-.92,5.5,15.34,15.34,0,0,0,1.22,5.39A14.16,14.16,0,0,0,26,58.23c.24.09.49.16.74.24a7.74,7.74,0,0,1-3.65,1.06,5.79,5.79,0,0,1-1.38-.16,15.94,15.94,0,0,1-2.32-2,16.25,16.25,0,0,1-3.57-5.51Zm38-21.16a16.76,16.76,0,0,1-3.63,5.23A15.07,15.07,0,0,1,47,38.35l-.56-1.48a12.48,12.48,0,0,0,2.6-2.1A14,14,0,0,0,52,30a15.85,15.85,0,0,0,.92-5.5,15.34,15.34,0,0,0-1.22-5.39A14.16,14.16,0,0,0,44,11.77c-.31-.12-.64-.21-1-.31a7.22,7.22,0,0,1,5.25-.83,16.57,16.57,0,0,1,2.32,2,16.25,16.25,0,0,1,3.55,5.5,18.49,18.49,0,0,1,1.11,6.33,18.18,18.18,0,0,1-1.39,6.24Z",fill:"#fff"})]});function P(e){return"object"==typeof e&&null!=e&&!Array.isArray(e)}function O(e){return String.fromCharCode(e+(e>25?39:97))}function U(e){return function(e){let t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=O(t%52)+n;return O(t%52)+n}(function(e,t){let n=t.length;for(;n;)e=33*e^t.charCodeAt(--n);return e}(5381,e)>>>0)}var L=/\s*!(important)?/i;function F(e){return"string"==typeof e?e.replaceAll(" ","_"):e}var z=e=>{const t=new Map;return(...n)=>{const r=JSON.stringify(n);if(t.has(r))return t.get(r);const o=e(...n);return t.set(r,o),o}},G=new Set(["__proto__","constructor","prototype"]);function j(...e){return e.reduce((e,t)=>t?(Object.keys(t).forEach(n=>{if(G.has(n))return;const r=e[n],o=t[n];P(r)&&P(o)?e[n]=j(r,o):e[n]=o}),e):e,{})}var $=e=>null!=e;function H(e,t,n={}){const{stop:r,getKey:o}=n;return function e(n,a=[]){if("object"==typeof(s=n)&&null!==s){const s={};for(const[i,l]of Object.entries(n)){const c=o?.(i,l)??i,d=[...a,c];if(r?.(n,d))return t(n,a);const g=e(l,d);$(g)&&(s[c]=g)}return s}var s;return t(n,a)}(e)}function K(e,t,n=!0){const{utility:r,conditions:o}=t,{hasShorthand:a,resolveShorthand:s}=r;return H(e,e=>{return Array.isArray(e)?(t=e,n=o.breakpoints.keys,t.reduce((e,t,r)=>{const o=n[r];return null!=t&&(e[o]=t),e},{})):e;var t,n},{stop:e=>Array.isArray(e),getKey:n?e=>a?s(e):e:void 0})}var Z={shift:e=>e,finalize:e=>e,breakpoints:{keys:[]}};function q(...e){return e.flat().filter(e=>{return P(e)&&Object.keys((t=e,Object.fromEntries(Object.entries(t??{}).filter(([e,t])=>void 0!==t)))).length>0;var t})}var X=/([A-Z])/g,Y=/^ms-/,V=z(e=>e.startsWith("--")?e:e.replace(X,"-$1").replace(Y,"-ms-").toLowerCase());"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%".split(",").join("|");var J=new Set("_hover,_focus,_focusWithin,_focusVisible,_disabled,_active,_visited,_target,_readOnly,_readWrite,_empty,_checked,_enabled,_expanded,_highlighted,_complete,_incomplete,_dragging,_before,_after,_firstLetter,_firstLine,_marker,_selection,_file,_backdrop,_first,_last,_only,_even,_odd,_firstOfType,_lastOfType,_onlyOfType,_peerFocus,_peerHover,_peerActive,_peerFocusWithin,_peerFocusVisible,_peerDisabled,_peerChecked,_peerInvalid,_peerExpanded,_peerPlaceholderShown,_groupFocus,_groupHover,_groupActive,_groupFocusWithin,_groupFocusVisible,_groupDisabled,_groupChecked,_groupExpanded,_groupInvalid,_indeterminate,_required,_valid,_invalid,_autofill,_inRange,_outOfRange,_placeholder,_placeholderShown,_pressed,_selected,_grabbed,_underValue,_overValue,_atValue,_default,_optional,_open,_closed,_fullscreen,_loading,_hidden,_current,_currentPage,_currentStep,_today,_unavailable,_rangeStart,_rangeEnd,_now,_topmost,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,_icon,_starting,_noscript,_invertedColors,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,2xl,2xlOnly,2xlDown,smToMd,smToLg,smToXl,smTo2xl,mdToLg,mdToXl,mdTo2xl,lgToXl,lgTo2xl,xlTo2xl,@/xs,@/sm,@/md,@/lg,@/xl,@/2xl,@/3xl,@/4xl,@/5xl,@/6xl,@/7xl,@/8xl,base".split(",")),Q=/^@|&|&$/;function ee(e){return J.has(e)||Q.test(e)}var te=/^_/,ne=/&|@/;var re=new Map,oe=new Map;"aspectRatio:asp,boxDecorationBreak:bx-db,zIndex:z,boxSizing:bx-s,objectPosition:obj-p,objectFit:obj-f,overscrollBehavior:ovs-b,overscrollBehaviorX:ovs-bx,overscrollBehaviorY:ovs-by,position:pos/1,top:top,left:left,inset:inset,insetInline:inset-x/insetX,insetBlock:inset-y/insetY,insetBlockEnd:inset-be,insetBlockStart:inset-bs,insetInlineEnd:inset-e/insetEnd/end,insetInlineStart:inset-s/insetStart/start,right:right,bottom:bottom,float:float,visibility:vis,display:d,hideFrom:hide,hideBelow:show,flexBasis:flex-b,flex:flex,flexDirection:flex-d/flexDir,flexGrow:flex-g,flexShrink:flex-sh,gridTemplateColumns:grid-tc,gridTemplateRows:grid-tr,gridColumn:grid-c,gridRow:grid-r,gridColumnStart:grid-cs,gridColumnEnd:grid-ce,gridAutoFlow:grid-af,gridAutoColumns:grid-ac,gridAutoRows:grid-ar,gap:gap,gridGap:grid-g,gridRowGap:grid-rg,gridColumnGap:grid-cg,rowGap:rg,columnGap:cg,justifyContent:jc,alignContent:ac,alignItems:ai,alignSelf:as,padding:p/1,paddingLeft:pl/1,paddingRight:pr/1,paddingTop:pt/1,paddingBottom:pb/1,paddingBlock:py/1/paddingY,paddingBlockEnd:pbe,paddingBlockStart:pbs,paddingInline:px/paddingX/1,paddingInlineEnd:pe/1/paddingEnd,paddingInlineStart:ps/1/paddingStart,marginLeft:ml/1,marginRight:mr/1,marginTop:mt/1,marginBottom:mb/1,margin:m/1,marginBlock:my/1/marginY,marginBlockEnd:mbe,marginBlockStart:mbs,marginInline:mx/1/marginX,marginInlineEnd:me/1/marginEnd,marginInlineStart:ms/1/marginStart,spaceX:sx,spaceY:sy,outlineWidth:ring-w/ringWidth,outlineColor:ring-c/ringColor,outline:ring/1,outlineOffset:ring-o/ringOffset,focusRing:focus-ring,focusVisibleRing:focus-v-ring,focusRingColor:focus-ring-c,focusRingOffset:focus-ring-o,focusRingWidth:focus-ring-w,focusRingStyle:focus-ring-s,divideX:dvd-x,divideY:dvd-y,divideColor:dvd-c,divideStyle:dvd-s,width:w/1,inlineSize:w-is,minWidth:min-w/minW,minInlineSize:min-w-is,maxWidth:max-w/maxW,maxInlineSize:max-w-is,height:h/1,blockSize:h-bs,minHeight:min-h/minH,minBlockSize:min-h-bs,maxHeight:max-h/maxH,maxBlockSize:max-b,boxSize:size,color:c,fontFamily:ff,fontSize:fs,fontSizeAdjust:fs-a,fontPalette:fp,fontKerning:fk,fontFeatureSettings:ff-s,fontWeight:fw,fontSmoothing:fsmt,fontVariant:fv,fontVariantAlternates:fv-alt,fontVariantCaps:fv-caps,fontVariationSettings:fv-s,fontVariantNumeric:fv-num,letterSpacing:ls,lineHeight:lh,textAlign:ta,textDecoration:td,textDecorationColor:td-c,textEmphasisColor:te-c,textDecorationStyle:td-s,textDecorationThickness:td-t,textUnderlineOffset:tu-o,textTransform:tt,textIndent:ti,textShadow:tsh,textShadowColor:tsh-c/textShadowColor,textOverflow:tov,verticalAlign:va,wordBreak:wb,textWrap:tw,truncate:trunc,lineClamp:lc,listStyleType:li-t,listStylePosition:li-pos,listStyleImage:li-img,listStyle:li-s,backgroundPosition:bg-p/bgPosition,backgroundPositionX:bg-p-x/bgPositionX,backgroundPositionY:bg-p-y/bgPositionY,backgroundAttachment:bg-a/bgAttachment,backgroundClip:bg-cp/bgClip,background:bg/1,backgroundColor:bg-c/bgColor,backgroundOrigin:bg-o/bgOrigin,backgroundImage:bg-i/bgImage,backgroundRepeat:bg-r/bgRepeat,backgroundBlendMode:bg-bm/bgBlendMode,backgroundSize:bg-s/bgSize,backgroundGradient:bg-grad/bgGradient,backgroundLinear:bg-linear/bgLinear,backgroundRadial:bg-radial/bgRadial,backgroundConic:bg-conic/bgConic,textGradient:txt-grad,gradientFromPosition:grad-from-pos,gradientToPosition:grad-to-pos,gradientFrom:grad-from,gradientTo:grad-to,gradientVia:grad-via,gradientViaPosition:grad-via-pos,borderRadius:bdr/rounded,borderTopLeftRadius:bdr-tl/roundedTopLeft,borderTopRightRadius:bdr-tr/roundedTopRight,borderBottomRightRadius:bdr-br/roundedBottomRight,borderBottomLeftRadius:bdr-bl/roundedBottomLeft,borderTopRadius:bdr-t/roundedTop,borderRightRadius:bdr-r/roundedRight,borderBottomRadius:bdr-b/roundedBottom,borderLeftRadius:bdr-l/roundedLeft,borderStartStartRadius:bdr-ss/roundedStartStart,borderStartEndRadius:bdr-se/roundedStartEnd,borderStartRadius:bdr-s/roundedStart,borderEndStartRadius:bdr-es/roundedEndStart,borderEndEndRadius:bdr-ee/roundedEndEnd,borderEndRadius:bdr-e/roundedEnd,border:bd,borderWidth:bd-w,borderTopWidth:bd-t-w,borderLeftWidth:bd-l-w,borderRightWidth:bd-r-w,borderBottomWidth:bd-b-w,borderBlockStartWidth:bd-bs-w,borderBlockEndWidth:bd-be-w,borderColor:bd-c,borderInline:bd-x/borderX,borderInlineWidth:bd-x-w/borderXWidth,borderInlineColor:bd-x-c/borderXColor,borderBlock:bd-y/borderY,borderBlockWidth:bd-y-w/borderYWidth,borderBlockColor:bd-y-c/borderYColor,borderLeft:bd-l,borderLeftColor:bd-l-c,borderInlineStart:bd-s/borderStart,borderInlineStartWidth:bd-s-w/borderStartWidth,borderInlineStartColor:bd-s-c/borderStartColor,borderRight:bd-r,borderRightColor:bd-r-c,borderInlineEnd:bd-e/borderEnd,borderInlineEndWidth:bd-e-w/borderEndWidth,borderInlineEndColor:bd-e-c/borderEndColor,borderTop:bd-t,borderTopColor:bd-t-c,borderBottom:bd-b,borderBottomColor:bd-b-c,borderBlockEnd:bd-be,borderBlockEndColor:bd-be-c,borderBlockStart:bd-bs,borderBlockStartColor:bd-bs-c,opacity:op,boxShadow:bx-sh/shadow,boxShadowColor:bx-sh-c/shadowColor,mixBlendMode:mix-bm,filter:filter,brightness:brightness,contrast:contrast,grayscale:grayscale,hueRotate:hue-rotate,invert:invert,saturate:saturate,sepia:sepia,dropShadow:drop-shadow,blur:blur,backdropFilter:bkdp,backdropBlur:bkdp-blur,backdropBrightness:bkdp-brightness,backdropContrast:bkdp-contrast,backdropGrayscale:bkdp-grayscale,backdropHueRotate:bkdp-hue-rotate,backdropInvert:bkdp-invert,backdropOpacity:bkdp-opacity,backdropSaturate:bkdp-saturate,backdropSepia:bkdp-sepia,borderCollapse:bd-cl,borderSpacing:bd-sp,borderSpacingX:bd-sx,borderSpacingY:bd-sy,tableLayout:tbl,transitionTimingFunction:trs-tmf,transitionDelay:trs-dly,transitionDuration:trs-dur,transitionProperty:trs-prop,transition:trs,animation:anim,animationName:anim-n,animationTimingFunction:anim-tmf,animationDuration:anim-dur,animationDelay:anim-dly,animationPlayState:anim-ps,animationComposition:anim-comp,animationFillMode:anim-fm,animationDirection:anim-dir,animationIterationCount:anim-ic,animationRange:anim-r,animationState:anim-s,animationRangeStart:anim-rs,animationRangeEnd:anim-re,animationTimeline:anim-tl,transformOrigin:trf-o,transformBox:trf-b,transformStyle:trf-s,transform:trf,rotate:rotate,rotateX:rotate-x,rotateY:rotate-y,rotateZ:rotate-z,scale:scale,scaleX:scale-x,scaleY:scale-y,translate:translate,translateX:translate-x/x,translateY:translate-y/y,translateZ:translate-z/z,accentColor:ac-c,caretColor:ca-c,scrollBehavior:scr-bhv,scrollbar:scr-bar,scrollbarColor:scr-bar-c,scrollbarGutter:scr-bar-g,scrollbarWidth:scr-bar-w,scrollMargin:scr-m,scrollMarginLeft:scr-ml,scrollMarginRight:scr-mr,scrollMarginTop:scr-mt,scrollMarginBottom:scr-mb,scrollMarginBlock:scr-my/scrollMarginY,scrollMarginBlockEnd:scr-mbe,scrollMarginBlockStart:scr-mbt,scrollMarginInline:scr-mx/scrollMarginX,scrollMarginInlineEnd:scr-me,scrollMarginInlineStart:scr-ms,scrollPadding:scr-p,scrollPaddingBlock:scr-py/scrollPaddingY,scrollPaddingBlockStart:scr-pbs,scrollPaddingBlockEnd:scr-pbe,scrollPaddingInline:scr-px/scrollPaddingX,scrollPaddingInlineEnd:scr-pe,scrollPaddingInlineStart:scr-ps,scrollPaddingLeft:scr-pl,scrollPaddingRight:scr-pr,scrollPaddingTop:scr-pt,scrollPaddingBottom:scr-pb,scrollSnapAlign:scr-sa,scrollSnapStop:scrs-s,scrollSnapType:scrs-t,scrollSnapStrictness:scrs-strt,scrollSnapMargin:scrs-m,scrollSnapMarginTop:scrs-mt,scrollSnapMarginBottom:scrs-mb,scrollSnapMarginLeft:scrs-ml,scrollSnapMarginRight:scrs-mr,scrollSnapCoordinate:scrs-c,scrollSnapDestination:scrs-d,scrollSnapPointsX:scrs-px,scrollSnapPointsY:scrs-py,scrollSnapTypeX:scrs-tx,scrollSnapTypeY:scrs-ty,scrollTimeline:scrtl,scrollTimelineAxis:scrtl-a,scrollTimelineName:scrtl-n,touchAction:tch-a,userSelect:us,overflow:ov,overflowWrap:ov-wrap,overflowX:ov-x,overflowY:ov-y,overflowAnchor:ov-a,overflowBlock:ov-b,overflowInline:ov-i,overflowClipBox:ovcp-bx,overflowClipMargin:ovcp-m,overscrollBehaviorBlock:ovs-bb,overscrollBehaviorInline:ovs-bi,fill:fill,stroke:stk,strokeWidth:stk-w,strokeDasharray:stk-dsh,strokeDashoffset:stk-do,strokeLinecap:stk-lc,strokeLinejoin:stk-lj,strokeMiterlimit:stk-ml,strokeOpacity:stk-op,srOnly:sr,debug:debug,appearance:ap,backfaceVisibility:bfv,clipPath:cp-path,hyphens:hy,mask:msk,maskImage:msk-i,maskSize:msk-s,textSizeAdjust:txt-adj,container:cq,containerName:cq-n,containerType:cq-t,cursor:cursor,textStyle:textStyle".split(",").forEach(e=>{const[t,n]=e.split(":"),[r,...o]=n.split("/");re.set(t,r),o.length&&o.forEach(e=>{oe.set("1"===e?r:e,t)})});var ae=e=>oe.get(e)||e,se={conditions:{shift:function(e){return e.sort((e,t)=>{const n=ee(e),r=ee(t);return n&&!r?1:!n&&r?-1:0})},finalize:function(e){return e.map(e=>J.has(e)?e.replace(te,""):ne.test(e)?`[${F(e.trim())}]`:e)},breakpoints:{keys:["base","sm","md","lg","xl","2xl"]}},utility:{prefix:"sc",transform:(e,t)=>{const n=ae(e);return{className:`${re.get(n)||V(n)}_${F(t)}`}},hasShorthand:!0,toHash:(e,t)=>t(e.join(":")),resolveShorthand:ae}},ie=function(e){const{utility:t,hash:n,conditions:r=Z}=e,o=e=>[t.prefix,e].filter(Boolean).join("-");return z(({base:a,...s}={})=>{const i=K(Object.assign(s,a),e),l=new Set;return H(i,(e,a)=>{if(null==e)return;const s=function(e){return"string"==typeof e&&L.test(e)}(e),[i,...c]=r.shift(a),d=c.slice().filter(e=>!(e=>"base"===e)(e));const g=t.transform(i,function(e){return"string"==typeof e?e.replace(L,"").trim():e}((e=>"string"==typeof e?e.replaceAll(/[\n\s]+/g," "):e)(e)));let u=((e,a)=>{let s;if(n){const n=[...r.finalize(e),a];s=o(t.toHash(n,U))}else s=[...r.finalize(e),o(a)].join(":");return s})(d,g.className);s&&(u=`${u}!`),l.add(u)}),Array.from(l).join(" ")})}(se),le=(...e)=>ie(ce(...e));le.raw=(...e)=>ce(...e);var{mergeCss:ce}=function(e){function t(t){const n=q(...t);return 1===n.length?n:n.map(t=>K(t,e))}return{mergeCss:z(function(...e){return j(...t(e))}),assignCss:function(...e){return Object.assign({},...t(e))}}}(se),de=({width:e=24,height:t=24})=>u("svg",{width:e,height:t,viewBox:"0 0 51 49",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[g("path",{d:"M25.6912 0.895264C11.9301 0.895264 0.772217 12.1784 0.772217 26.0887C0.772217 36.1757 6.63365 44.869 15.0984 48.8953L19.3546 37.2704C15.5262 35.049 12.9439 30.8733 12.9439 26.0887C12.9439 18.9707 18.6522 13.2036 25.686 13.2036C32.7197 13.2036 38.428 18.976 38.428 26.0887C38.428 30.8733 35.8458 35.0437 32.0174 37.2704L36.2735 48.8953C44.7383 44.869 50.5997 36.1704 50.5997 26.0887C50.605 12.1784 39.4472 0.895264 25.6912 0.895264Z",fill:"url(#paint0_linear_1463_870)"}),g("path",{d:"M35.4972 26.0887C28.9599 27.915 27.4971 29.3941 25.6912 36.0048C23.8852 29.3941 22.4225 27.915 15.8851 26.0887C22.4225 24.2625 23.8852 22.7833 25.6912 16.1726C27.4971 22.7833 28.9599 24.2625 35.4972 26.0887Z",fill:"white"}),g("defs",{children:u("linearGradient",{id:"paint0_linear_1463_870",x1:"0",y1:"25.4765",x2:"50.2406",y2:"25.4765",gradientUnits:"userSpaceOnUse",children:[g("stop",{"stop-color":"#FEBF4E"}),g("stop",{offset:"0.715","stop-color":"#FC4CD2"})]})})]}),ge=({width:e=24,height:t=24})=>u("svg",{id:"Logo",xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:e,height:t,viewBox:"0 0 148.8 85.5",children:[g("path",{fill:"#a5ff71",d:"M144.6,39c-1.4-2.1-2-4.6-1.7-7s.4-4.6.2-7c-1.3-13.4-12.7-24.2-26.1-24.8-9.3-.4-17.7,3.8-22.9,10.6-2.2,2.8-5.7,4.1-9.2,3.9-3.4-.2-6.9-.4-10.5-.4s-8.1.2-12.1.5-5.9-1.1-7.7-3.6C48.5,3,38-1.7,26.6.7,17,2.7,9.1,10.1,6.3,19.5c-1.2,4.2-1.5,8.3-.9,12.1.4,2.9-.2,5.8-1.8,8.3-2.2,3.5-3.4,7.1-3.4,11,0,16.8,22.7,34,54.3,34.5,6.2,0,13.9-3.5,22.2-3.3,8.9.2,15.3,3.1,23,3.3,29,.9,49-18.6,49-34.5s-1.4-8.2-4.1-11.9ZM25.3,40.6c-9.9,0-17.9-8-17.9-17.9S15.5,4.9,25.3,4.9s17.9,8,17.9,17.9-8,17.9-17.9,17.9ZM69.1,48.1c-1,0-1.8-1-1.8-2.2s.8-2.2,1.8-2.2,1.8,1,1.8,2.2-.8,2.2-1.8,2.2ZM79.7,48.1c-1,0-1.8-1-1.8-2.2s.8-2.2,1.8-2.2,1.8,1,1.8,2.2-.8,2.2-1.8,2.2ZM123.3,40.6c-9.9,0-17.9-8-17.9-17.9s8-17.9,17.9-17.9,17.9,8,17.9,17.9-8,17.9-17.9,17.9Z"}),g("circle",{fill:"#a5ff71",cx:"30.6",cy:"22.7",r:"7.8"}),g("circle",{fill:"#a5ff71",cx:"118.5",cy:"22.7",r:"7.8"})]}),ue=class extends s{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("SupraConnect Error:",e,t),this.props.onError?.(e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:u("div",{className:le({backgroundColor:"#fee2e2",color:"#dc2626",padding:"1rem",borderRadius:"0.5rem",border:"1px solid #fecaca",textAlign:"center",maxWidth:"400px",margin:"0 auto"}),children:[g("h3",{className:le({fontSize:"1.1rem",fontWeight:"600",marginBottom:"0.5rem"}),children:"Wallet Connection Error"}),g("p",{className:le({fontSize:"0.9rem",marginBottom:"1rem"}),children:"Something went wrong while connecting to your wallet. Please try refreshing the page."}),g("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),className:le({backgroundColor:"#dc2626",color:"white",padding:"0.5rem 1rem",borderRadius:"0.25rem",border:"none",cursor:"pointer",fontSize:"0.9rem",fontWeight:"500",_hover:{backgroundColor:"#b91c1c"}}),children:"Try Again"})]}):this.props.children}},pe=(e={})=>{const t=W(),[n,a]=r(!1),[s,i]=r(!1),[l,c]=r(()=>t.getState());o(()=>t.subscribe(c),[t]);const{connectedWallet:d,isConnecting:p,connectionError:h,availableWallets:f}=l,w=f.includes("starkey"),b=f.includes("ribbit"),m=()=>{i(!0),setTimeout(()=>{a(!1),i(!1),t.clearError()},300)};return u(ue,{children:[u("button",{onClick:d?async()=>{try{await t.disconnect()}catch(e){}}:()=>a(!0),className:le({display:"flex",gap:"0.75rem",alignItems:"center",justifyContent:"center",color:"#DD1438",fontWeight:"600",fontSize:"0.95rem",backgroundColor:"white",borderRadius:"0.375rem",border:"2px solid #DD1438",padding:"0.75rem 1.25rem",cursor:"pointer",transition:"all 0.2s ease",_hover:{backgroundColor:"#DD1438",color:"white"},_active:{backgroundColor:"#C1122D",color:"white"}}),children:[g(B,{width:20,height:20}),d?`Connected (${d.walletAddress.slice(0,6)}...${d.walletAddress.slice(-4)})`:"Connect Wallet"]}),n&&g("div",{className:le({position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,animation:s?"fadeOut 0.3s ease-in":"fadeIn 0.3s ease-out"}),onClick:m,children:u("div",{className:le({backgroundColor:"white",borderRadius:"0.75rem",padding:"2rem",maxWidth:"420px",border:"2px solid #DD1438",width:"90%",position:"relative",animation:s?"popOut 0.3s ease-in":"popUp 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55)",transformOrigin:"center"}),onClick:e=>e.stopPropagation(),children:[g("button",{onClick:m,className:le({position:"absolute",top:"1rem",right:"1rem",background:"none",border:"none",fontSize:"1.5rem",cursor:"pointer",color:"gray",_hover:{color:"black"}}),children:"×"}),u("div",{className:le({textAlign:"center",marginBottom:"2rem"}),children:[g("h2",{className:le({fontSize:"1.5rem",fontWeight:"700",color:"#DD1438",marginBottom:"0.5rem"}),children:"Connect Wallet"}),g("p",{className:le({color:"#6b7280",fontSize:"0.9rem"}),children:"Choose your preferred wallet to connect"})]}),u("div",{className:le({display:"flex",flexDirection:"column",gap:"1rem"}),children:[h&&g("div",{className:le({backgroundColor:"#fee2e2",color:"#dc2626",padding:"0.75rem",borderRadius:"0.5rem",marginBottom:"1rem",fontSize:"0.9rem",textAlign:"center"}),children:h}),w?u("button",{onClick:async()=>{try{const n={dappMetadata:{...e.dappMetadata,...e.metadata}};await t.connectStarkey(n),m()}catch(e){}},disabled:p,className:le({display:"flex",alignItems:"center",gap:"1rem",padding:"1.25rem",border:"2px solid #e5e7eb",borderRadius:"0.5rem",backgroundColor:"#1e1b4b",cursor:p?"not-allowed":"pointer",fontWeight:"600",fontSize:"1rem",color:"white",opacity:p?.6:1,transition:"all 0.2s ease",_hover:{backgroundColor:p?"#1e1b4b":"#312e81",color:"white"}}),children:[g(de,{width:28,height:28}),g("span",{children:p?"Connecting...":"Starkey Wallet"})]}):u("a",{href:"https://starkey.app/",target:"_blank",rel:"noopener noreferrer",className:le({display:"flex",alignItems:"center",gap:"1rem",padding:"1.25rem",border:"2px solid #e5e7eb",borderRadius:"0.5rem",backgroundColor:"#1e1b4b",cursor:"pointer",fontWeight:"600",fontSize:"1rem",color:"white",textDecoration:"none",transition:"all 0.2s ease",_hover:{backgroundColor:"#312e81",color:"white"}}),children:[g(de,{width:28,height:28}),g("span",{children:"Install Starkey Wallet"})]}),b?u("button",{onClick:async()=>{try{const n={dappMetadata:{...e.dappMetadata,...e.metadata}};await t.connectRibbit(n),m()}catch(e){}},disabled:p,className:le({display:"flex",alignItems:"center",gap:"1rem",padding:"1.25rem",border:"2px solid #e5e7eb",borderRadius:"0.5rem",backgroundColor:"#1e1b4b",cursor:p?"not-allowed":"pointer",fontWeight:"600",fontSize:"1rem",color:"white",opacity:p?.6:1,transition:"all 0.2s ease",_hover:{backgroundColor:p?"#1e1b4b":"#312e81",color:"white"}}),children:[g(ge,{width:28,height:28}),g("span",{children:p?"Connecting...":"Ribbit Wallet"})]}):u("a",{href:"https://ribbitwallet.com/",target:"_blank",rel:"noopener noreferrer",className:le({display:"flex",alignItems:"center",gap:"1rem",padding:"1.25rem",border:"2px solid #e5e7eb",borderRadius:"0.5rem",backgroundColor:"#1e1b4b",cursor:"pointer",fontWeight:"600",fontSize:"1rem",color:"white",textDecoration:"none",transition:"all 0.2s ease",_hover:{backgroundColor:"#312e81",color:"white"}}),children:[g(ge,{width:28,height:28}),g("span",{children:"Install Ribbit Wallet"})]})]})]})})]})};export{b as AppTransport,h as CHAIN_TYPE,N as ConnectionStore,I as DEFAULT_RPC_URL,m as ExtensionTransport,v as RibbitWalletUtils,p as StarkeyWalletUtils,w as SupraChainId,pe as SupraConnectButton,ue as SupraConnectErrorBoundary,R as SupraConnectProvider,x as SupraConnectUtils,y as TransportFactory,f as TransportMessageType,T as WalletUtils,D as useSupraConnect,W as useSupraConnectStore};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer reset, base, tokens, recipes, utilities;@layer base{:root{--made-with-panda:'🐼'}*,::backdrop,:after,:before{--blur: ;--brightness: ;--contrast: ;--grayscale: ;--hue-rotate: ;--invert: ;--saturate: ;--sepia: ;--drop-shadow: ;--backdrop-blur: ;--backdrop-brightness: ;--backdrop-contrast: ;--backdrop-grayscale: ;--backdrop-hue-rotate: ;--backdrop-invert: ;--backdrop-opacity: ;--backdrop-saturate: ;--backdrop-sepia: ;--gradient-from-position: ;--gradient-to-position: ;--gradient-via-position: ;--scroll-snap-strictness:proximity;--border-spacing-x:0;--border-spacing-y:0;--translate-x:0;--translate-y:0;--rotate:0;--rotate-x:0;--rotate-y:0;--skew-x:0;--skew-y:0;--scale-x:1;--scale-y:1}}@layer tokens{:where(:root,:host){--sc-aspect-ratios-square:1/1;--sc-aspect-ratios-landscape:4/3;--sc-aspect-ratios-portrait:3/4;--sc-aspect-ratios-wide:16/9;--sc-aspect-ratios-ultrawide:18/5;--sc-aspect-ratios-golden:1.618/1;--sc-borders-none:none;--sc-easings-default:cubic-bezier(0.4,0,0.2,1);--sc-easings-linear:linear;--sc-easings-in:cubic-bezier(0.4,0,1,1);--sc-easings-out:cubic-bezier(0,0,0.2,1);--sc-easings-in-out:cubic-bezier(0.4,0,0.2,1);--sc-durations-fastest:50ms;--sc-durations-faster:100ms;--sc-durations-fast:150ms;--sc-durations-normal:200ms;--sc-durations-slow:300ms;--sc-durations-slower:400ms;--sc-durations-slowest:500ms;--sc-radii-xs:0.125rem;--sc-radii-sm:0.25rem;--sc-radii-md:0.375rem;--sc-radii-lg:0.5rem;--sc-radii-xl:0.75rem;--sc-radii-2xl:1rem;--sc-radii-3xl:1.5rem;--sc-radii-4xl:2rem;--sc-radii-full:9999px;--sc-font-weights-thin:100;--sc-font-weights-extralight:200;--sc-font-weights-light:300;--sc-font-weights-normal:400;--sc-font-weights-medium:500;--sc-font-weights-semibold:600;--sc-font-weights-bold:700;--sc-font-weights-extrabold:800;--sc-font-weights-black:900;--sc-line-heights-none:1;--sc-line-heights-tight:1.25;--sc-line-heights-snug:1.375;--sc-line-heights-normal:1.5;--sc-line-heights-relaxed:1.625;--sc-line-heights-loose:2;--sc-fonts-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--sc-fonts-serif:ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;--sc-fonts-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--sc-letter-spacings-tighter:-0.05em;--sc-letter-spacings-tight:-0.025em;--sc-letter-spacings-normal:0em;--sc-letter-spacings-wide:0.025em;--sc-letter-spacings-wider:0.05em;--sc-letter-spacings-widest:0.1em;--sc-font-sizes-2xs:0.5rem;--sc-font-sizes-xs:0.75rem;--sc-font-sizes-sm:0.875rem;--sc-font-sizes-md:1rem;--sc-font-sizes-lg:1.125rem;--sc-font-sizes-xl:1.25rem;--sc-font-sizes-2xl:1.5rem;--sc-font-sizes-3xl:1.875rem;--sc-font-sizes-4xl:2.25rem;--sc-font-sizes-5xl:3rem;--sc-font-sizes-6xl:3.75rem;--sc-font-sizes-7xl:4.5rem;--sc-font-sizes-8xl:6rem;--sc-font-sizes-9xl:8rem;--sc-shadows-2xs:0 1px rgb(0 0 0/0.05);--sc-shadows-xs:0 1px 2px 0 rgb(0 0 0/0.05);--sc-shadows-sm:0 1px 3px 0 rgb(0 0 0/0.1),0 1px 2px -1px rgb(0 0 0/0.1);--sc-shadows-md:0 4px 6px -1px rgb(0 0 0/0.1),0 2px 4px -2px rgb(0 0 0/0.1);--sc-shadows-lg:0 10px 15px -3px rgb(0 0 0/0.1),0 4px 6px -4px rgb(0 0 0/0.1);--sc-shadows-xl:0 20px 25px -5px rgb(0 0 0/0.1),0 8px 10px -6px rgb(0 0 0/0.1);--sc-shadows-2xl:0 25px 50px -12px rgb(0 0 0/0.25);--sc-shadows-inset-2xs:inset 0 1px rgb(0 0 0/0.05);--sc-shadows-inset-xs:inset 0 1px 1px rgb(0 0 0/0.05);--sc-shadows-inset-sm:inset 0 2px 4px rgb(0 0 0/0.05);--sc-colors-current:currentColor;--sc-colors-black:#000;--sc-colors-white:#fff;--sc-colors-transparent:rgb(0 0 0/0);--sc-colors-rose-50:#fff1f2;--sc-colors-rose-100:#ffe4e6;--sc-colors-rose-200:#fecdd3;--sc-colors-rose-300:#fda4af;--sc-colors-rose-400:#fb7185;--sc-colors-rose-500:#f43f5e;--sc-colors-rose-600:#e11d48;--sc-colors-rose-700:#be123c;--sc-colors-rose-800:#9f1239;--sc-colors-rose-900:#881337;--sc-colors-rose-950:#4c0519;--sc-colors-pink-50:#fdf2f8;--sc-colors-pink-100:#fce7f3;--sc-colors-pink-200:#fbcfe8;--sc-colors-pink-300:#f9a8d4;--sc-colors-pink-400:#f472b6;--sc-colors-pink-500:#ec4899;--sc-colors-pink-600:#db2777;--sc-colors-pink-700:#be185d;--sc-colors-pink-800:#9d174d;--sc-colors-pink-900:#831843;--sc-colors-pink-950:#500724;--sc-colors-fuchsia-50:#fdf4ff;--sc-colors-fuchsia-100:#fae8ff;--sc-colors-fuchsia-200:#f5d0fe;--sc-colors-fuchsia-300:#f0abfc;--sc-colors-fuchsia-400:#e879f9;--sc-colors-fuchsia-500:#d946ef;--sc-colors-fuchsia-600:#c026d3;--sc-colors-fuchsia-700:#a21caf;--sc-colors-fuchsia-800:#86198f;--sc-colors-fuchsia-900:#701a75;--sc-colors-fuchsia-950:#4a044e;--sc-colors-purple-50:#faf5ff;--sc-colors-purple-100:#f3e8ff;--sc-colors-purple-200:#e9d5ff;--sc-colors-purple-300:#d8b4fe;--sc-colors-purple-400:#c084fc;--sc-colors-purple-500:#a855f7;--sc-colors-purple-600:#9333ea;--sc-colors-purple-700:#7e22ce;--sc-colors-purple-800:#6b21a8;--sc-colors-purple-900:#581c87;--sc-colors-purple-950:#3b0764;--sc-colors-violet-50:#f5f3ff;--sc-colors-violet-100:#ede9fe;--sc-colors-violet-200:#ddd6fe;--sc-colors-violet-300:#c4b5fd;--sc-colors-violet-400:#a78bfa;--sc-colors-violet-500:#8b5cf6;--sc-colors-violet-600:#7c3aed;--sc-colors-violet-700:#6d28d9;--sc-colors-violet-800:#5b21b6;--sc-colors-violet-900:#4c1d95;--sc-colors-violet-950:#2e1065;--sc-colors-indigo-50:#eef2ff;--sc-colors-indigo-100:#e0e7ff;--sc-colors-indigo-200:#c7d2fe;--sc-colors-indigo-300:#a5b4fc;--sc-colors-indigo-400:#818cf8;--sc-colors-indigo-500:#6366f1;--sc-colors-indigo-600:#4f46e5;--sc-colors-indigo-700:#4338ca;--sc-colors-indigo-800:#3730a3;--sc-colors-indigo-900:#312e81;--sc-colors-indigo-950:#1e1b4b;--sc-colors-blue-50:#eff6ff;--sc-colors-blue-100:#dbeafe;--sc-colors-blue-200:#bfdbfe;--sc-colors-blue-300:#93c5fd;--sc-colors-blue-400:#60a5fa;--sc-colors-blue-500:#3b82f6;--sc-colors-blue-600:#2563eb;--sc-colors-blue-700:#1d4ed8;--sc-colors-blue-800:#1e40af;--sc-colors-blue-900:#1e3a8a;--sc-colors-blue-950:#172554;--sc-colors-sky-50:#f0f9ff;--sc-colors-sky-100:#e0f2fe;--sc-colors-sky-200:#bae6fd;--sc-colors-sky-300:#7dd3fc;--sc-colors-sky-400:#38bdf8;--sc-colors-sky-500:#0ea5e9;--sc-colors-sky-600:#0284c7;--sc-colors-sky-700:#0369a1;--sc-colors-sky-800:#075985;--sc-colors-sky-900:#0c4a6e;--sc-colors-sky-950:#082f49;--sc-colors-cyan-50:#ecfeff;--sc-colors-cyan-100:#cffafe;--sc-colors-cyan-200:#a5f3fc;--sc-colors-cyan-300:#67e8f9;--sc-colors-cyan-400:#22d3ee;--sc-colors-cyan-500:#06b6d4;--sc-colors-cyan-600:#0891b2;--sc-colors-cyan-700:#0e7490;--sc-colors-cyan-800:#155e75;--sc-colors-cyan-900:#164e63;--sc-colors-cyan-950:#083344;--sc-colors-teal-50:#f0fdfa;--sc-colors-teal-100:#ccfbf1;--sc-colors-teal-200:#99f6e4;--sc-colors-teal-300:#5eead4;--sc-colors-teal-400:#2dd4bf;--sc-colors-teal-500:#14b8a6;--sc-colors-teal-600:#0d9488;--sc-colors-teal-700:#0f766e;--sc-colors-teal-800:#115e59;--sc-colors-teal-900:#134e4a;--sc-colors-teal-950:#042f2e;--sc-colors-emerald-50:#ecfdf5;--sc-colors-emerald-100:#d1fae5;--sc-colors-emerald-200:#a7f3d0;--sc-colors-emerald-300:#6ee7b7;--sc-colors-emerald-400:#34d399;--sc-colors-emerald-500:#10b981;--sc-colors-emerald-600:#059669;--sc-colors-emerald-700:#047857;--sc-colors-emerald-800:#065f46;--sc-colors-emerald-900:#064e3b;--sc-colors-emerald-950:#022c22;--sc-colors-green-50:#f0fdf4;--sc-colors-green-100:#dcfce7;--sc-colors-green-200:#bbf7d0;--sc-colors-green-300:#86efac;--sc-colors-green-400:#4ade80;--sc-colors-green-500:#22c55e;--sc-colors-green-600:#16a34a;--sc-colors-green-700:#15803d;--sc-colors-green-800:#166534;--sc-colors-green-900:#14532d;--sc-colors-green-950:#052e16;--sc-colors-lime-50:#f7fee7;--sc-colors-lime-100:#ecfccb;--sc-colors-lime-200:#d9f99d;--sc-colors-lime-300:#bef264;--sc-colors-lime-400:#a3e635;--sc-colors-lime-500:#84cc16;--sc-colors-lime-600:#65a30d;--sc-colors-lime-700:#4d7c0f;--sc-colors-lime-800:#3f6212;--sc-colors-lime-900:#365314;--sc-colors-lime-950:#1a2e05;--sc-colors-yellow-50:#fefce8;--sc-colors-yellow-100:#fef9c3;--sc-colors-yellow-200:#fef08a;--sc-colors-yellow-300:#fde047;--sc-colors-yellow-400:#facc15;--sc-colors-yellow-500:#eab308;--sc-colors-yellow-600:#ca8a04;--sc-colors-yellow-700:#a16207;--sc-colors-yellow-800:#854d0e;--sc-colors-yellow-900:#713f12;--sc-colors-yellow-950:#422006;--sc-colors-amber-50:#fffbeb;--sc-colors-amber-100:#fef3c7;--sc-colors-amber-200:#fde68a;--sc-colors-amber-300:#fcd34d;--sc-colors-amber-400:#fbbf24;--sc-colors-amber-500:#f59e0b;--sc-colors-amber-600:#d97706;--sc-colors-amber-700:#b45309;--sc-colors-amber-800:#92400e;--sc-colors-amber-900:#78350f;--sc-colors-amber-950:#451a03;--sc-colors-orange-50:#fff7ed;--sc-colors-orange-100:#ffedd5;--sc-colors-orange-200:#fed7aa;--sc-colors-orange-300:#fdba74;--sc-colors-orange-400:#fb923c;--sc-colors-orange-500:#f97316;--sc-colors-orange-600:#ea580c;--sc-colors-orange-700:#c2410c;--sc-colors-orange-800:#9a3412;--sc-colors-orange-900:#7c2d12;--sc-colors-orange-950:#431407;--sc-colors-red-50:#fef2f2;--sc-colors-red-100:#fee2e2;--sc-colors-red-200:#fecaca;--sc-colors-red-300:#fca5a5;--sc-colors-red-400:#f87171;--sc-colors-red-500:#ef4444;--sc-colors-red-600:#dc2626;--sc-colors-red-700:#b91c1c;--sc-colors-red-800:#991b1b;--sc-colors-red-900:#7f1d1d;--sc-colors-red-950:#450a0a;--sc-colors-neutral-50:#fafafa;--sc-colors-neutral-100:#f5f5f5;--sc-colors-neutral-200:#e5e5e5;--sc-colors-neutral-300:#d4d4d4;--sc-colors-neutral-400:#a3a3a3;--sc-colors-neutral-500:#737373;--sc-colors-neutral-600:#525252;--sc-colors-neutral-700:#404040;--sc-colors-neutral-800:#262626;--sc-colors-neutral-900:#171717;--sc-colors-neutral-950:#0a0a0a;--sc-colors-stone-50:#fafaf9;--sc-colors-stone-100:#f5f5f4;--sc-colors-stone-200:#e7e5e4;--sc-colors-stone-300:#d6d3d1;--sc-colors-stone-400:#a8a29e;--sc-colors-stone-500:#78716c;--sc-colors-stone-600:#57534e;--sc-colors-stone-700:#44403c;--sc-colors-stone-800:#292524;--sc-colors-stone-900:#1c1917;--sc-colors-stone-950:#0c0a09;--sc-colors-zinc-50:#fafafa;--sc-colors-zinc-100:#f4f4f5;--sc-colors-zinc-200:#e4e4e7;--sc-colors-zinc-300:#d4d4d8;--sc-colors-zinc-400:#a1a1aa;--sc-colors-zinc-500:#71717a;--sc-colors-zinc-600:#52525b;--sc-colors-zinc-700:#3f3f46;--sc-colors-zinc-800:#27272a;--sc-colors-zinc-900:#18181b;--sc-colors-zinc-950:#09090b;--sc-colors-gray-50:#f9fafb;--sc-colors-gray-100:#f3f4f6;--sc-colors-gray-200:#e5e7eb;--sc-colors-gray-300:#d1d5db;--sc-colors-gray-400:#9ca3af;--sc-colors-gray-500:#6b7280;--sc-colors-gray-600:#4b5563;--sc-colors-gray-700:#374151;--sc-colors-gray-800:#1f2937;--sc-colors-gray-900:#111827;--sc-colors-gray-950:#030712;--sc-colors-slate-50:#f8fafc;--sc-colors-slate-100:#f1f5f9;--sc-colors-slate-200:#e2e8f0;--sc-colors-slate-300:#cbd5e1;--sc-colors-slate-400:#94a3b8;--sc-colors-slate-500:#64748b;--sc-colors-slate-600:#475569;--sc-colors-slate-700:#334155;--sc-colors-slate-800:#1e293b;--sc-colors-slate-900:#0f172a;--sc-colors-slate-950:#020617;--sc-blurs-xs:4px;--sc-blurs-sm:8px;--sc-blurs-md:12px;--sc-blurs-lg:16px;--sc-blurs-xl:24px;--sc-blurs-2xl:40px;--sc-blurs-3xl:64px;--sc-spacing-0:0rem;--sc-spacing-1:0.25rem;--sc-spacing-2:0.5rem;--sc-spacing-3:0.75rem;--sc-spacing-4:1rem;--sc-spacing-5:1.25rem;--sc-spacing-6:1.5rem;--sc-spacing-7:1.75rem;--sc-spacing-8:2rem;--sc-spacing-9:2.25rem;--sc-spacing-10:2.5rem;--sc-spacing-11:2.75rem;--sc-spacing-12:3rem;--sc-spacing-14:3.5rem;--sc-spacing-16:4rem;--sc-spacing-20:5rem;--sc-spacing-24:6rem;--sc-spacing-28:7rem;--sc-spacing-32:8rem;--sc-spacing-36:9rem;--sc-spacing-40:10rem;--sc-spacing-44:11rem;--sc-spacing-48:12rem;--sc-spacing-52:13rem;--sc-spacing-56:14rem;--sc-spacing-60:15rem;--sc-spacing-64:16rem;--sc-spacing-72:18rem;--sc-spacing-80:20rem;--sc-spacing-96:24rem;--sc-spacing-0\.5:0.125rem;--sc-spacing-1\.5:0.375rem;--sc-spacing-2\.5:0.625rem;--sc-spacing-3\.5:0.875rem;--sc-spacing-4\.5:1.125rem;--sc-spacing-5\.5:1.375rem;--sc-sizes-0:0rem;--sc-sizes-1:0.25rem;--sc-sizes-2:0.5rem;--sc-sizes-3:0.75rem;--sc-sizes-4:1rem;--sc-sizes-5:1.25rem;--sc-sizes-6:1.5rem;--sc-sizes-7:1.75rem;--sc-sizes-8:2rem;--sc-sizes-9:2.25rem;--sc-sizes-10:2.5rem;--sc-sizes-11:2.75rem;--sc-sizes-12:3rem;--sc-sizes-14:3.5rem;--sc-sizes-16:4rem;--sc-sizes-20:5rem;--sc-sizes-24:6rem;--sc-sizes-28:7rem;--sc-sizes-32:8rem;--sc-sizes-36:9rem;--sc-sizes-40:10rem;--sc-sizes-44:11rem;--sc-sizes-48:12rem;--sc-sizes-52:13rem;--sc-sizes-56:14rem;--sc-sizes-60:15rem;--sc-sizes-64:16rem;--sc-sizes-72:18rem;--sc-sizes-80:20rem;--sc-sizes-96:24rem;--sc-sizes-0\.5:0.125rem;--sc-sizes-1\.5:0.375rem;--sc-sizes-2\.5:0.625rem;--sc-sizes-3\.5:0.875rem;--sc-sizes-4\.5:1.125rem;--sc-sizes-5\.5:1.375rem;--sc-sizes-xs:20rem;--sc-sizes-sm:24rem;--sc-sizes-md:28rem;--sc-sizes-lg:32rem;--sc-sizes-xl:36rem;--sc-sizes-2xl:42rem;--sc-sizes-3xl:48rem;--sc-sizes-4xl:56rem;--sc-sizes-5xl:64rem;--sc-sizes-6xl:72rem;--sc-sizes-7xl:80rem;--sc-sizes-8xl:90rem;--sc-sizes-prose:65ch;--sc-sizes-full:100%;--sc-sizes-min:min-content;--sc-sizes-max:max-content;--sc-sizes-fit:fit-content;--sc-sizes-breakpoint-sm:640px;--sc-sizes-breakpoint-md:768px;--sc-sizes-breakpoint-lg:1024px;--sc-sizes-breakpoint-xl:1280px;--sc-sizes-breakpoint-2xl:1536px;--sc-animations-spin:spin 1s linear infinite;--sc-animations-ping:ping 1s cubic-bezier(0,0,0.2,1) infinite;--sc-animations-pulse:pulse 2s cubic-bezier(0.4,0,0.6,1) infinite;--sc-animations-bounce:bounce 1s infinite;--sc-breakpoints-sm:640px;--sc-breakpoints-md:768px;--sc-breakpoints-lg:1024px;--sc-breakpoints-xl:1280px;--sc-breakpoints-2xl:1536px}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{transform:scale(2);opacity:0}}@keyframes pulse{50%{opacity:0.5}}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(0.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,0.2,1)}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}@keyframes popUp{0%{opacity:0;transform:scale(0.8) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}@keyframes popOut{0%{opacity:1;transform:scale(1) translateY(0)}to{opacity:0;transform:scale(0.8) translateY(20px)}}}@layer utilities{.sc-p_1rem{padding:1rem}.sc-bd_1px_solid_\#fecaca{border:1px solid #fecaca}.sc-m_0_auto{margin:0 auto}.sc-p_0\.5rem_1rem{padding:0.5rem 1rem}.sc-bd_none{border:var(--sc-borders-none)}.sc-bd_2px_solid_\#DD1438{border:2px solid #DD1438}.sc-p_0\.75rem_1\.25rem{padding:0.75rem 1.25rem}.sc-anim_fadeOut_0\.3s_ease-in{animation:fadeOut 0.3s ease-in}.sc-anim_fadeIn_0\.3s_ease-out{animation:fadeIn 0.3s ease-out}.sc-anim_popOut_0\.3s_ease-in{animation:popOut 0.3s ease-in}.sc-anim_popUp_0\.3s_cubic-bezier\(0\.68\,_-0\.55\,_0\.265\,_1\.55\){animation:popUp 0.3s cubic-bezier(0.68,-0.55,0.265,1.55)}.sc-p_2rem{padding:2rem}.sc-bg_none{background:none}.sc-p_0\.75rem{padding:0.75rem}.sc-p_1\.25rem{padding:1.25rem}.sc-bd_2px_solid_\#e5e7eb{border:2px solid #e5e7eb}.sc-bdr_0\.5rem{border-radius:0.5rem}.sc-bdr_0\.25rem{border-radius:0.25rem}.sc-gap_0\.75rem{gap:0.75rem}.sc-bdr_0\.375rem{border-radius:0.375rem}.sc-trs_all_0\.2s_ease{transition:all 0.2s ease}.sc-bdr_0\.75rem{border-radius:0.75rem}.sc-gap_1rem{gap:1rem}.sc-td_none{text-decoration:none}.sc-bg-c_\#fee2e2{background-color:#fee2e2}.sc-c_\#dc2626{color:#dc2626}.sc-ta_center{text-align:center}.sc-fs_1\.1rem{font-size:1.1rem}.sc-fw_600{font-weight:600}.sc-fs_0\.9rem{font-size:0.9rem}.sc-bg-c_\#dc2626{background-color:#dc2626}.sc-c_white{color:var(--sc-colors-white)}.sc-cursor_pointer{cursor:pointer}.sc-fw_500{font-weight:500}.sc-d_flex{display:flex}.sc-ai_center{align-items:center}.sc-jc_center{justify-content:center}.sc-c_\#DD1438{color:#DD1438}.sc-fs_0\.95rem{font-size:0.95rem}.sc-bg-c_white{background-color:var(--sc-colors-white)}.sc-pos_fixed{position:fixed}.sc-bg-c_rgba\(0\,_0\,_0\,_0\.8\){background-color:rgba(0,0,0,0.8)}.sc-z_1000{z-index:1000}.sc-pos_relative{position:relative}.sc-trf-o_center{transform-origin:center}.sc-pos_absolute{position:absolute}.sc-fs_1\.5rem{font-size:1.5rem}.sc-c_gray{color:gray}.sc-fw_700{font-weight:700}.sc-c_\#6b7280{color:#6b7280}.sc-flex-d_column{flex-direction:column}.sc-cursor_not-allowed{cursor:not-allowed}.sc-op_0\.6{opacity:0.6}.sc-op_1{opacity:1}.sc-bg-c_\#1e1b4b{background-color:#1e1b4b}.sc-fs_1rem{font-size:1rem}.sc-max-w_400px{max-width:400px}.sc-mb_0\.5rem{margin-bottom:0.5rem}.sc-mb_1rem{margin-bottom:1rem}.sc-top_0{top:var(--sc-spacing-0)}.sc-left_0{left:var(--sc-spacing-0)}.sc-right_0{right:var(--sc-spacing-0)}.sc-bottom_0{bottom:var(--sc-spacing-0)}.sc-max-w_420px{max-width:420px}.sc-w_90\%{width:90%}.sc-top_1rem{top:1rem}.sc-right_1rem{right:1rem}.sc-mb_2rem{margin-bottom:2rem}.sc-w_20{width:var(--sc-sizes-20)}.sc-h_20{height:var(--sc-sizes-20)}.sc-w_28{width:var(--sc-sizes-28)}.sc-h_28{height:var(--sc-sizes-28)}.hover\:sc-bg-c_\#b91c1c:is(:hover,[data-hover]){background-color:#b91c1c}.hover\:sc-bg-c_\#DD1438:is(:hover,[data-hover]){background-color:#DD1438}.hover\:sc-c_white:is(:hover,[data-hover]){color:var(--sc-colors-white)}.hover\:sc-c_black:is(:hover,[data-hover]){color:var(--sc-colors-black)}.hover\:sc-bg-c_\#1e1b4b:is(:hover,[data-hover]){background-color:#1e1b4b}.hover\:sc-bg-c_\#312e81:is(:hover,[data-hover]){background-color:#312e81}.active\:sc-bg-c_\#C1122D:is(:active,[data-active]){background-color:#C1122D}.active\:sc-c_white:is(:active,[data-active]){color:var(--sc-colors-white)}}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gerritsen/supra-connect",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Custom React wallet connector for Supra L1 blockchain. Native support for Starkey and Ribbit wallets with a unified API. Built with care for the Supra ecosystem.",
|
|
5
|
+
"author": "Martin Gerritsen",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./styles.css": "./dist/styles.css"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup && panda cssgen --outfile dist/styles.css",
|
|
22
|
+
"dev": "tsup --watch",
|
|
23
|
+
"dev:full": "concurrently \"tsup --watch\" \"panda cssgen --watch --outfile dist/styles.css\"",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"supra",
|
|
28
|
+
"wallet",
|
|
29
|
+
"nextjs",
|
|
30
|
+
"starkey",
|
|
31
|
+
"ribbit",
|
|
32
|
+
"connect",
|
|
33
|
+
"web3"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@pandacss/dev": "^1.4.2",
|
|
37
|
+
"@pandacss/types": "^1.4.2",
|
|
38
|
+
"@types/node": "^24.7.2",
|
|
39
|
+
"@types/react": "^19.2.2",
|
|
40
|
+
"@types/react-dom": "^19.2.2",
|
|
41
|
+
"concurrently": "^8.0.0",
|
|
42
|
+
"ngrok": "^5.0.0-beta.2",
|
|
43
|
+
"terser": "^5.44.1",
|
|
44
|
+
"tsup": "^8.5.0",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@noble/ed25519": "^3.0.0",
|
|
52
|
+
"supra-l1-sdk": "^4.6.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/panda.config.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { defineConfig } from "@pandacss/dev";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
preflight: false,
|
|
5
|
+
prefix: "sc",
|
|
6
|
+
include: ["./src/**/*.{ts,tsx}"],
|
|
7
|
+
exclude: [],
|
|
8
|
+
optimize: true,
|
|
9
|
+
minify: true,
|
|
10
|
+
theme: {
|
|
11
|
+
extend: {
|
|
12
|
+
keyframes: {
|
|
13
|
+
fadeIn: {
|
|
14
|
+
"0%": { opacity: "0" },
|
|
15
|
+
"100%": { opacity: "1" }
|
|
16
|
+
},
|
|
17
|
+
fadeOut: {
|
|
18
|
+
"0%": { opacity: "1" },
|
|
19
|
+
"100%": { opacity: "0" }
|
|
20
|
+
},
|
|
21
|
+
popUp: {
|
|
22
|
+
"0%": {
|
|
23
|
+
opacity: "0",
|
|
24
|
+
transform: "scale(0.8) translateY(20px)"
|
|
25
|
+
},
|
|
26
|
+
"100%": {
|
|
27
|
+
opacity: "1",
|
|
28
|
+
transform: "scale(1) translateY(0)"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
popOut: {
|
|
32
|
+
"0%": {
|
|
33
|
+
opacity: "1",
|
|
34
|
+
transform: "scale(1) translateY(0)"
|
|
35
|
+
},
|
|
36
|
+
"100%": {
|
|
37
|
+
opacity: "0",
|
|
38
|
+
transform: "scale(0.8) translateY(20px)"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
recipes: {
|
|
43
|
+
"sc-button": {
|
|
44
|
+
description: "Style for the connect button",
|
|
45
|
+
base: {
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
gap: "2",
|
|
49
|
+
bg: "red.600",
|
|
50
|
+
color: "white",
|
|
51
|
+
px: "4",
|
|
52
|
+
py: "2",
|
|
53
|
+
borderRadius: "md",
|
|
54
|
+
fontWeight: "semibold",
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
_hover: {
|
|
57
|
+
bg: "red.700",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
outdir: "src/styled-system",
|
|
65
|
+
jsxFramework: "react",
|
|
66
|
+
});
|