@rhinestone/deposit-modal 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -67
- package/dist/DepositModalReown-324WTBDE.cjs +33 -0
- package/dist/DepositModalReown-YTWIR7A4.mjs +33 -0
- package/dist/WithdrawModalReown-ICP3DH6Q.mjs +33 -0
- package/dist/WithdrawModalReown-ZNTE2G6W.cjs +33 -0
- package/dist/chunk-6VJ2ZTNQ.cjs +90 -0
- package/dist/chunk-A6QLADED.mjs +304 -0
- package/dist/chunk-BO745KAB.cjs +1648 -0
- package/dist/chunk-CEIWN53N.cjs +304 -0
- package/dist/chunk-J7UK4L5T.mjs +1524 -0
- package/dist/chunk-JBT2ZV3Q.mjs +1648 -0
- package/dist/chunk-LBEP3A2Z.mjs +90 -0
- package/dist/chunk-N2LJOFT2.mjs +2346 -0
- package/dist/chunk-V6HZJZOL.cjs +1524 -0
- package/dist/chunk-W7ZYJB2X.cjs +2346 -0
- package/dist/constants.cjs +58 -0
- package/dist/constants.d.cts +41 -0
- package/dist/constants.d.ts +41 -0
- package/dist/constants.mjs +58 -0
- package/dist/deposit.cjs +8 -0
- package/dist/deposit.d.cts +12 -0
- package/dist/deposit.d.ts +12 -0
- package/dist/deposit.mjs +8 -0
- package/dist/index.cjs +36 -5953
- package/dist/index.d.cts +8 -220
- package/dist/index.d.ts +8 -220
- package/dist/index.mjs +33 -5923
- package/dist/safe.cjs +1 -0
- package/dist/safe.d.cts +62 -0
- package/dist/safe.d.ts +62 -0
- package/dist/safe.mjs +0 -0
- package/dist/types-D_xeOU8G.d.cts +144 -0
- package/dist/types-DnGF9RJJ.d.ts +144 -0
- package/dist/withdraw.cjs +8 -0
- package/dist/withdraw.d.cts +12 -0
- package/dist/withdraw.d.ts +12 -0
- package/dist/withdraw.mjs +8 -0
- package/package.json +26 -5
package/README.md
CHANGED
|
@@ -8,6 +8,17 @@ React components for cross-chain deposits and withdrawals via Rhinestone smart a
|
|
|
8
8
|
npm install @rhinestone/deposit-modal viem
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Bundle Size Tips
|
|
12
|
+
|
|
13
|
+
Prefer subpath imports so apps only bundle what they use:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { DepositModal } from "@rhinestone/deposit-modal/deposit";
|
|
17
|
+
import { WithdrawModal } from "@rhinestone/deposit-modal/withdraw";
|
|
18
|
+
import { executeSafeEthTransfer } from "@rhinestone/deposit-modal/safe";
|
|
19
|
+
import { getChainName } from "@rhinestone/deposit-modal/constants";
|
|
20
|
+
```
|
|
21
|
+
|
|
11
22
|
## DepositModal
|
|
12
23
|
|
|
13
24
|
Deposits tokens from any supported chain into a target chain/token via a Rhinestone smart account.
|
|
@@ -17,7 +28,7 @@ User wallet → transfer → Rhinestone smart account → bridge → target chai
|
|
|
17
28
|
```
|
|
18
29
|
|
|
19
30
|
```tsx
|
|
20
|
-
import { DepositModal } from "@rhinestone/deposit-modal";
|
|
31
|
+
import { DepositModal } from "@rhinestone/deposit-modal/deposit";
|
|
21
32
|
import "@rhinestone/deposit-modal/styles.css";
|
|
22
33
|
|
|
23
34
|
<DepositModal
|
|
@@ -29,31 +40,32 @@ import "@rhinestone/deposit-modal/styles.css";
|
|
|
29
40
|
targetChain={8453}
|
|
30
41
|
targetToken="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
31
42
|
onDepositComplete={(data) => console.log("Done!", data)}
|
|
32
|
-
|
|
43
|
+
/>;
|
|
33
44
|
```
|
|
34
45
|
|
|
35
46
|
### Deposit flow matrix
|
|
36
47
|
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
| Typical dapp input
|
|
40
|
-
| Connect step options
|
|
41
|
-
| Smart-account owner (`ownerAddress`)
|
|
42
|
-
| `createSmartAccount(userSigner, sessionOwner.account)` `userSigner` | `walletClientToAccount(dappWalletClient)`
|
|
43
|
-
| `createSmartAccount(..., sessionOwner.account)` co-owner
|
|
44
|
-
| Smart account `S` owners passed to SDK
|
|
45
|
-
| Session-owner localStorage key
|
|
46
|
-
| Session policy signer in `sessionDetails`
|
|
47
|
-
| Who signs source transfer
|
|
48
|
-
| How processing starts
|
|
49
|
-
| `POST /register` `address`
|
|
50
|
-
| `POST /register` `eoaAddress`
|
|
51
|
-
| `POST /register` `sessionOwner`
|
|
52
|
-
| `POST /register` `accountParams.sessionDetails`
|
|
53
|
-
| `POST /register` `target`
|
|
54
|
-
| If `dappAddress` is missing
|
|
48
|
+
| | Flow 1: Dapp signer | Flow 2: External wallet | Flow 3: QR deposit |
|
|
49
|
+
| ------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
50
|
+
| Typical dapp input | `dappWalletClient` + `dappAddress` | `dappAddress` (user selects/connects external wallet in modal) | `dappAddress` only |
|
|
51
|
+
| Connect step options | `Connected Wallet` (+ `External Wallet`/`Transfer Crypto` if available) | Usually `External Wallet` + `Transfer Crypto` | Same options, user picks `Transfer Crypto` |
|
|
52
|
+
| Smart-account owner (`ownerAddress`) | `dappWalletClient.account.address` | Selected external wallet address | `dappAddress` |
|
|
53
|
+
| `createSmartAccount(userSigner, sessionOwner.account)` `userSigner` | `walletClientToAccount(dappWalletClient)` | `walletClientToAccount(externalWalletClient)` | `createViewOnlyAccount(dappAddress)` |
|
|
54
|
+
| `createSmartAccount(..., sessionOwner.account)` co-owner | Local browser session-owner keypair (`sessionOwner.account`) | Local browser session-owner keypair (`sessionOwner.account`) | Local browser session-owner keypair (`sessionOwner.account`) |
|
|
55
|
+
| Smart account `S` owners passed to SDK | `[ownerAddress, sessionOwner.address]` | `[ownerAddress, sessionOwner.address]` | `[ownerAddress, sessionOwner.address]` |
|
|
56
|
+
| Session-owner localStorage key | `rhinestone:session-owner:<ownerAddress.lowercase()>` | `rhinestone:session-owner:<ownerAddress.lowercase()>` | `rhinestone:session-owner:<ownerAddress.lowercase()>` |
|
|
57
|
+
| Session policy signer in `sessionDetails` | `DEFAULT_SIGNER_ADDRESS` (or `signerAddress` prop override) | `DEFAULT_SIGNER_ADDRESS` (or `signerAddress` prop override) | `DEFAULT_SIGNER_ADDRESS` (or `signerAddress` prop override) |
|
|
58
|
+
| Who signs source transfer | `dappWalletClient` | External wallet client | No modal signer (user sends funds manually) |
|
|
59
|
+
| How processing starts | Confirm step submits transfer tx | Confirm step submits transfer tx | User sends to QR address; modal polls status |
|
|
60
|
+
| `POST /register` `address` | Smart account address (`S`) | Smart account address (`S`) | Smart account address (`S`) |
|
|
61
|
+
| `POST /register` `eoaAddress` | `ownerAddress` | `ownerAddress` | `dappAddress` |
|
|
62
|
+
| `POST /register` `sessionOwner` | `sessionOwner.address` (local co-owner key) | `sessionOwner.address` (local co-owner key) | `sessionOwner.address` (local co-owner key) |
|
|
63
|
+
| `POST /register` `accountParams.sessionDetails` | Built from session policy signer + `sessionOwner.account` signature | Built from session policy signer + `sessionOwner.account` signature | Built from session policy signer + `sessionOwner.account` signature |
|
|
64
|
+
| `POST /register` `target` | `{ chain: targetChain, token: targetToken, recipient? }` | `{ chain: targetChain, token: targetToken, recipient? }` | `{ chain: targetChain, token: targetToken, recipient? }` |
|
|
65
|
+
| If `dappAddress` is missing | Unsupported for this flow | External-only flow can still run | Not available (QR hidden) |
|
|
55
66
|
|
|
56
67
|
Notes:
|
|
68
|
+
|
|
57
69
|
- External wallet option is available when Reown is enabled (`reownAppId`) and a wallet can be connected in the modal.
|
|
58
70
|
- `onConnected({ address, smartAccount })` reports the active owner address used for that flow.
|
|
59
71
|
- Smart-account owner config is passed to the SDK as two ECDSA owners (`ownerAddress` + local `sessionOwner`) with threshold `1`.
|
|
@@ -61,41 +73,41 @@ Notes:
|
|
|
61
73
|
|
|
62
74
|
### Props
|
|
63
75
|
|
|
64
|
-
| Prop
|
|
65
|
-
|
|
66
|
-
| `isOpen`
|
|
67
|
-
| `onClose`
|
|
68
|
-
| `targetChain`
|
|
69
|
-
| `targetToken`
|
|
70
|
-
| `dappWalletClient`
|
|
71
|
-
| `dappPublicClient`
|
|
72
|
-
| `dappAddress`
|
|
73
|
-
| `inline`
|
|
74
|
-
| `sourceChain`
|
|
75
|
-
| `sourceToken`
|
|
76
|
-
| `defaultAmount`
|
|
77
|
-
| `recipient`
|
|
78
|
-
| `backendUrl`
|
|
79
|
-
| `rhinestoneApiKey`
|
|
80
|
-
| `signerAddress`
|
|
81
|
-
| `waitForFinalTx`
|
|
82
|
-
| `onRequestConnect`
|
|
83
|
-
| `connectButtonLabel` | `string`
|
|
84
|
-
| `theme`
|
|
85
|
-
| `branding`
|
|
86
|
-
| `uiConfig`
|
|
87
|
-
| `className`
|
|
76
|
+
| Prop | Type | Required | Description |
|
|
77
|
+
| -------------------- | ---------------------- | -------- | ---------------------------------------------------------------------------- |
|
|
78
|
+
| `isOpen` | `boolean` | Yes | Modal open state |
|
|
79
|
+
| `onClose` | `() => void` | Yes | Close handler |
|
|
80
|
+
| `targetChain` | `Chain \| number` | Yes | Destination chain |
|
|
81
|
+
| `targetToken` | `Address` | Yes | Destination token address |
|
|
82
|
+
| `dappWalletClient` | `WalletClient \| null` | No | Host-provided signer wallet client |
|
|
83
|
+
| `dappPublicClient` | `PublicClient \| null` | No | Host-provided public client (fallbacks are created internally if missing) |
|
|
84
|
+
| `dappAddress` | `Address \| null` | No | Dapp identity / owner anchor used by setup and QR flow |
|
|
85
|
+
| `inline` | `boolean` | No | Render inline without overlay |
|
|
86
|
+
| `sourceChain` | `Chain \| number` | No | Pre-selected source chain |
|
|
87
|
+
| `sourceToken` | `Address` | No | Pre-selected source token |
|
|
88
|
+
| `defaultAmount` | `string` | No | Pre-filled amount |
|
|
89
|
+
| `recipient` | `Address` | No | Custom recipient address |
|
|
90
|
+
| `backendUrl` | `string` | No | Backend URL |
|
|
91
|
+
| `rhinestoneApiKey` | `string` | No | Optional SDK api key forwarded to `RhinestoneSDK` during smart-account setup |
|
|
92
|
+
| `signerAddress` | `Address` | No | Session signer address |
|
|
93
|
+
| `waitForFinalTx` | `boolean` | No | Wait for destination tx (default: true) |
|
|
94
|
+
| `onRequestConnect` | `() => void` | No | Called when wallet connection needed |
|
|
95
|
+
| `connectButtonLabel` | `string` | No | Custom connect button label |
|
|
96
|
+
| `theme` | `DepositModalTheme` | No | Theme customization |
|
|
97
|
+
| `branding` | `DepositModalBranding` | No | Logo and title |
|
|
98
|
+
| `uiConfig` | `DepositModalUIConfig` | No | UI display options |
|
|
99
|
+
| `className` | `string` | No | Additional CSS class |
|
|
88
100
|
|
|
89
101
|
### Callbacks
|
|
90
102
|
|
|
91
|
-
| Callback
|
|
92
|
-
|
|
93
|
-
| `onReady`
|
|
94
|
-
| `onConnected(data)`
|
|
103
|
+
| Callback | Description |
|
|
104
|
+
| -------------------------- | --------------------------------------------------- |
|
|
105
|
+
| `onReady` | Modal initialized |
|
|
106
|
+
| `onConnected(data)` | Smart account created (`{ address, smartAccount }`) |
|
|
95
107
|
| `onDepositSubmitted(data)` | Transfer signed (`{ txHash, sourceChain, amount }`) |
|
|
96
|
-
| `onDepositComplete(data)`
|
|
97
|
-
| `onDepositFailed(data)`
|
|
98
|
-
| `onError(data)`
|
|
108
|
+
| `onDepositComplete(data)` | Deposit arrived (`{ txHash, destinationTxHash? }`) |
|
|
109
|
+
| `onDepositFailed(data)` | Bridge failed (`{ txHash, error? }`) |
|
|
110
|
+
| `onError(data)` | Error payload (`{ message, code? }`) |
|
|
99
111
|
|
|
100
112
|
## WithdrawModal
|
|
101
113
|
|
|
@@ -106,7 +118,7 @@ Safe → ERC20 transfer → Rhinestone smart account → bridge → target chain
|
|
|
106
118
|
```
|
|
107
119
|
|
|
108
120
|
```tsx
|
|
109
|
-
import { WithdrawModal } from "@rhinestone/deposit-modal";
|
|
121
|
+
import { WithdrawModal } from "@rhinestone/deposit-modal/withdraw";
|
|
110
122
|
import "@rhinestone/deposit-modal/styles.css";
|
|
111
123
|
|
|
112
124
|
<WithdrawModal
|
|
@@ -121,16 +133,18 @@ import "@rhinestone/deposit-modal/styles.css";
|
|
|
121
133
|
targetChain={1}
|
|
122
134
|
targetToken="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
|
123
135
|
onWithdrawComplete={(data) => console.log("Done!", data)}
|
|
124
|
-
|
|
136
|
+
/>;
|
|
125
137
|
```
|
|
126
138
|
|
|
127
139
|
### Withdrawal flow
|
|
128
140
|
|
|
129
141
|
Prerequisites:
|
|
142
|
+
|
|
130
143
|
- A 1/1 Safe (single owner) with ERC20 token balance on a supported source chain
|
|
131
144
|
- The connected wallet must be the sole owner of the Safe
|
|
132
145
|
|
|
133
146
|
End-to-end steps:
|
|
147
|
+
|
|
134
148
|
1. User connects wallet (must be the Safe owner)
|
|
135
149
|
2. Modal creates a Rhinestone smart account and signs session authorization
|
|
136
150
|
3. Modal registers the smart account with the backend (`/register`)
|
|
@@ -140,6 +154,7 @@ End-to-end steps:
|
|
|
140
154
|
7. Modal polls `/status/:address` for webhook events until the bridge completes on the destination chain
|
|
141
155
|
|
|
142
156
|
To test with the demo configurator:
|
|
157
|
+
|
|
143
158
|
1. Switch flow to "Withdraw"
|
|
144
159
|
2. Enter the Safe address
|
|
145
160
|
3. Select the source chain/token matching the Safe's holdings
|
|
@@ -148,19 +163,19 @@ To test with the demo configurator:
|
|
|
148
163
|
|
|
149
164
|
### Additional Props (beyond shared DepositModal props)
|
|
150
165
|
|
|
151
|
-
| Prop
|
|
152
|
-
|
|
153
|
-
| `safeAddress` | `Address`
|
|
154
|
-
| `sourceChain` | `Chain \| number` | Yes
|
|
155
|
-
| `sourceToken` | `Address`
|
|
166
|
+
| Prop | Type | Required | Description |
|
|
167
|
+
| ------------- | ----------------- | -------- | --------------------------- |
|
|
168
|
+
| `safeAddress` | `Address` | Yes | Safe holding funds |
|
|
169
|
+
| `sourceChain` | `Chain \| number` | Yes | Chain where the Safe exists |
|
|
170
|
+
| `sourceToken` | `Address` | Yes | Token in the Safe |
|
|
156
171
|
|
|
157
172
|
### Callbacks
|
|
158
173
|
|
|
159
|
-
| Callback
|
|
160
|
-
|
|
174
|
+
| Callback | Description |
|
|
175
|
+
| --------------------------- | --------------------------------------------------------------------- |
|
|
161
176
|
| `onWithdrawSubmitted(data)` | Safe transfer signed (`{ txHash, sourceChain, amount, safeAddress }`) |
|
|
162
|
-
| `onWithdrawComplete(data)`
|
|
163
|
-
| `onWithdrawFailed(data)`
|
|
177
|
+
| `onWithdrawComplete(data)` | Withdrawal arrived (`{ txHash, destinationTxHash? }`) |
|
|
178
|
+
| `onWithdrawFailed(data)` | Bridge failed (`{ txHash, error? }`) |
|
|
164
179
|
|
|
165
180
|
Also supports `onReady`, `onConnected`, and `onError` (same as DepositModal).
|
|
166
181
|
|
|
@@ -184,11 +199,21 @@ Also supports `onReady`, `onConnected`, and `onError` (same as DepositModal).
|
|
|
184
199
|
|
|
185
200
|
```tsx
|
|
186
201
|
import {
|
|
187
|
-
SOURCE_CHAINS,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
SOURCE_CHAINS,
|
|
203
|
+
SUPPORTED_CHAINS,
|
|
204
|
+
chainRegistry,
|
|
205
|
+
getChainName,
|
|
206
|
+
getChainIcon,
|
|
207
|
+
getChainObject,
|
|
208
|
+
getUsdcAddress,
|
|
209
|
+
getTokenAddress,
|
|
210
|
+
getTokenDecimals,
|
|
211
|
+
getTokenSymbol,
|
|
212
|
+
getTokenIcon,
|
|
213
|
+
getExplorerTxUrl,
|
|
214
|
+
DEFAULT_BACKEND_URL,
|
|
215
|
+
NATIVE_TOKEN_ADDRESS,
|
|
216
|
+
} from "@rhinestone/deposit-modal/constants";
|
|
192
217
|
```
|
|
193
218
|
|
|
194
219
|
## Supported Chains
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkW7ZYJB2Xcjs = require('./chunk-W7ZYJB2X.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk6VJ2ZTNQcjs = require('./chunk-6VJ2ZTNQ.cjs');
|
|
8
|
+
require('./chunk-BO745KAB.cjs');
|
|
9
|
+
require('./chunk-CEIWN53N.cjs');
|
|
10
|
+
|
|
11
|
+
// src/DepositModalReown.tsx
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
+
function DepositModalWithReown(props) {
|
|
15
|
+
const reown = _chunk6VJ2ZTNQcjs.useReownWallet.call(void 0, );
|
|
16
|
+
const handleConnect = _react.useCallback.call(void 0, () => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
20
|
+
_chunkW7ZYJB2Xcjs.DepositModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function DepositModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk6VJ2ZTNQcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DepositModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.DepositModalReown = DepositModalReown;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DepositModalInner
|
|
3
|
+
} from "./chunk-N2LJOFT2.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ReownWalletProvider,
|
|
6
|
+
useReownWallet
|
|
7
|
+
} from "./chunk-LBEP3A2Z.mjs";
|
|
8
|
+
import "./chunk-JBT2ZV3Q.mjs";
|
|
9
|
+
import "./chunk-A6QLADED.mjs";
|
|
10
|
+
|
|
11
|
+
// src/DepositModalReown.tsx
|
|
12
|
+
import { useCallback } from "react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
function DepositModalWithReown(props) {
|
|
15
|
+
const reown = useReownWallet();
|
|
16
|
+
const handleConnect = useCallback(() => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
DepositModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function DepositModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ jsx(DepositModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
DepositModalReown
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WithdrawModalInner
|
|
3
|
+
} from "./chunk-J7UK4L5T.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ReownWalletProvider,
|
|
6
|
+
useReownWallet
|
|
7
|
+
} from "./chunk-LBEP3A2Z.mjs";
|
|
8
|
+
import "./chunk-JBT2ZV3Q.mjs";
|
|
9
|
+
import "./chunk-A6QLADED.mjs";
|
|
10
|
+
|
|
11
|
+
// src/WithdrawModalReown.tsx
|
|
12
|
+
import { useCallback } from "react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
function WithdrawModalWithReown(props) {
|
|
15
|
+
const reown = useReownWallet();
|
|
16
|
+
const handleConnect = useCallback(() => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
WithdrawModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function WithdrawModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ jsx(ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ jsx(WithdrawModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
WithdrawModalReown
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkV6HZJZOLcjs = require('./chunk-V6HZJZOL.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk6VJ2ZTNQcjs = require('./chunk-6VJ2ZTNQ.cjs');
|
|
8
|
+
require('./chunk-BO745KAB.cjs');
|
|
9
|
+
require('./chunk-CEIWN53N.cjs');
|
|
10
|
+
|
|
11
|
+
// src/WithdrawModalReown.tsx
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
+
function WithdrawModalWithReown(props) {
|
|
15
|
+
const reown = _chunk6VJ2ZTNQcjs.useReownWallet.call(void 0, );
|
|
16
|
+
const handleConnect = _react.useCallback.call(void 0, () => {
|
|
17
|
+
reown.openConnect();
|
|
18
|
+
}, [reown.openConnect]);
|
|
19
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
20
|
+
_chunkV6HZJZOLcjs.WithdrawModalInner,
|
|
21
|
+
{
|
|
22
|
+
...props,
|
|
23
|
+
reownWallet: reown,
|
|
24
|
+
onConnect: handleConnect
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function WithdrawModalReown(props) {
|
|
29
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk6VJ2ZTNQcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props }) });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.WithdrawModalReown = WithdrawModalReown;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core/reown.tsx
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
var _reactquery = require('@tanstack/react-query');
|
|
4
|
+
var _appkitadapterwagmi = require('@reown/appkit-adapter-wagmi');
|
|
5
|
+
var _wagmi = require('wagmi');
|
|
6
|
+
var _react3 = require('@reown/appkit/react');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _networks = require('@reown/appkit/networks');
|
|
15
|
+
|
|
16
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
17
|
+
var NETWORKS = [
|
|
18
|
+
_networks.mainnet,
|
|
19
|
+
_networks.base,
|
|
20
|
+
_networks.arbitrum,
|
|
21
|
+
_networks.optimism,
|
|
22
|
+
_networks.polygon,
|
|
23
|
+
_networks.bsc
|
|
24
|
+
];
|
|
25
|
+
var cachedAdapter = null;
|
|
26
|
+
var cachedProjectId = null;
|
|
27
|
+
function mapTheme(theme) {
|
|
28
|
+
const themeMode = _optionalChain([theme, 'optionalAccess', _ => _.mode]) === "light" ? "light" : "dark";
|
|
29
|
+
const themeVariables = {};
|
|
30
|
+
if (_optionalChain([theme, 'optionalAccess', _2 => _2.ctaColor])) {
|
|
31
|
+
themeVariables["--apkt-accent"] = theme.ctaColor;
|
|
32
|
+
}
|
|
33
|
+
return { themeMode, themeVariables };
|
|
34
|
+
}
|
|
35
|
+
function getOrCreateAdapter(projectId, theme) {
|
|
36
|
+
if (cachedAdapter && cachedProjectId === projectId) return cachedAdapter;
|
|
37
|
+
cachedAdapter = new (0, _appkitadapterwagmi.WagmiAdapter)({
|
|
38
|
+
networks: NETWORKS,
|
|
39
|
+
projectId
|
|
40
|
+
});
|
|
41
|
+
cachedProjectId = projectId;
|
|
42
|
+
const { themeMode, themeVariables } = mapTheme(theme);
|
|
43
|
+
_react3.createAppKit.call(void 0, {
|
|
44
|
+
adapters: [cachedAdapter],
|
|
45
|
+
networks: NETWORKS,
|
|
46
|
+
projectId,
|
|
47
|
+
themeMode,
|
|
48
|
+
themeVariables,
|
|
49
|
+
features: {
|
|
50
|
+
connectMethodsOrder: ["wallet"],
|
|
51
|
+
email: false,
|
|
52
|
+
socials: false
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return cachedAdapter;
|
|
56
|
+
}
|
|
57
|
+
function ReownWalletProvider({
|
|
58
|
+
projectId,
|
|
59
|
+
theme,
|
|
60
|
+
children
|
|
61
|
+
}) {
|
|
62
|
+
const [queryClient] = _react.useState.call(void 0, () => new (0, _reactquery.QueryClient)());
|
|
63
|
+
const adapter = getOrCreateAdapter(projectId, theme);
|
|
64
|
+
const config = adapter.wagmiConfig;
|
|
65
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children }) });
|
|
66
|
+
}
|
|
67
|
+
function useReownWallet() {
|
|
68
|
+
const { open } = _react3.useAppKit.call(void 0, );
|
|
69
|
+
const { address, isConnected } = _react3.useAppKitAccount.call(void 0, );
|
|
70
|
+
const { data: walletClient } = _wagmi.useWalletClient.call(void 0, );
|
|
71
|
+
const publicClient = _wagmi.usePublicClient.call(void 0, );
|
|
72
|
+
const { switchChainAsync } = _wagmi.useSwitchChain.call(void 0, );
|
|
73
|
+
return {
|
|
74
|
+
walletClient: _nullishCoalesce(walletClient, () => ( void 0)),
|
|
75
|
+
publicClient: _nullishCoalesce(publicClient, () => ( void 0)),
|
|
76
|
+
address,
|
|
77
|
+
isConnected,
|
|
78
|
+
openConnect: () => {
|
|
79
|
+
void open({ view: isConnected ? "Account" : "Connect" });
|
|
80
|
+
},
|
|
81
|
+
switchChain: async (chainId) => {
|
|
82
|
+
await switchChainAsync({ chainId });
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
exports.ReownWalletProvider = ReownWalletProvider; exports.useReownWallet = useReownWallet;
|