@moon-x/react-sdk 0.8.1 → 0.9.0
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 +98 -19
- package/dist/{chunk-Y6HSLN2H.mjs → chunk-7XFCJAFG.mjs} +75 -74
- package/dist/{chunk-4YS67FSE.js → chunk-F345C4FX.js} +107 -102
- package/dist/{chunk-RFAKWGRF.mjs → chunk-OAG4S5VJ.mjs} +20 -19
- package/dist/{chunk-YFGHPPR5.js → chunk-VBAVYDWQ.js} +236 -241
- package/dist/{ethereum-CWhbeptv.d.ts → ethereum-Eg3cJKce.d.ts} +20 -6
- package/dist/{ethereum-CGSlkQOw.d.mts → ethereum-lovLlqC2.d.mts} +20 -6
- package/dist/index.d.mts +146 -17
- package/dist/index.d.ts +146 -17
- package/dist/index.js +3042 -2546
- package/dist/index.mjs +385 -246
- package/dist/{solana-Cr7r3wi8.d.mts → solana-BVrNImZ1.d.mts} +13 -4
- package/dist/{solana-nUvZo4Zp.d.ts → solana-C9rN8lxH.d.ts} +13 -4
- package/dist/wallets/ethereum.d.mts +1 -1
- package/dist/wallets/ethereum.d.ts +1 -1
- package/dist/wallets/ethereum.js +15 -15
- package/dist/wallets/ethereum.mjs +1 -1
- package/dist/wallets/solana.d.mts +1 -1
- package/dist/wallets/solana.d.ts +1 -1
- package/dist/wallets/solana.js +11 -11
- package/dist/wallets/solana.mjs +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -25,8 +25,14 @@ export default function App() {
|
|
|
25
25
|
accentColor: "#6366f1",
|
|
26
26
|
backgroundColor: "#ffffff",
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// One unified list for EVM + Solana. A bare viem chain uses its
|
|
29
|
+
// built-in RPC; wrap a chain to override it; Solana entries carry an id.
|
|
30
|
+
chains: [
|
|
31
|
+
mainnet,
|
|
32
|
+
sepolia,
|
|
33
|
+
{ id: "solana:mainnet", rpcUrl: "https://api.mainnet-beta.solana.com" },
|
|
34
|
+
],
|
|
35
|
+
defaultChain: "eip155:1", // CAIP-2 | numeric (1) | name alias ("eth:sepolia")
|
|
30
36
|
}}
|
|
31
37
|
>
|
|
32
38
|
<YourApp />
|
|
@@ -82,15 +88,14 @@ function SignDemo() {
|
|
|
82
88
|
|
|
83
89
|
| Field | Type | Purpose |
|
|
84
90
|
|---|---|---|
|
|
85
|
-
| `appearance` | `AuthAppearance` |
|
|
91
|
+
| `appearance` | `AuthAppearance` | The single theming surface — branding (`accentColor`, `backgroundColor`, `displayMode`, `logo`, `loginHeaderTitle`, `fontFamily`) **and** all design tokens inline (`colors`, `borderRadius`, `typography`, `card`, `backdrop`, `components`, per-mode `light` / `dark`). See [Theming](#theming). |
|
|
86
92
|
| `loginMethods` | `("email" \| "google" \| "apple" \| "wallet")[]` | Which auth methods to show in the modal. |
|
|
87
93
|
| `walletChainType` | `"ethereum" \| "solana" \| "ethereum-or-solana"` | Which wallet type to create at signup. |
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
94
|
+
| `chains` | `ChainConfigItem[]` | Unified RPC / chain config for **both** EVM and Solana. Each element is a bare viem `Chain` (use its built-in RPC), an `{ chain, rpcUrl?, wsUrl? }` EVM entry (to override the RPC), or a `{ id, rpcUrl, wsUrl? }` Solana entry. Common viem chains are re-exported by this package. See `docs/rpc-configuration.md`. |
|
|
95
|
+
| `defaultChain` | `string \| number` | Which configured chain is the default. Referenced by alias, CAIP-2 id, or numeric chainId — e.g. `"eth:base"`, `"eip155:8453"`, `8453`, `"solana:mainnet"`. Defaults to the first entry in `chains`. |
|
|
90
96
|
| `walletConnect.projectId` | `string` | WalletConnect v2 project ID for external-wallet flows. |
|
|
91
97
|
| `emailConfig`, `passkeyEnrollConfig`, `signMessageConfig`, `signTransactionConfig`, `sendTransactionConfig`, `exportKeyConfig` | various | Per-flow UI overrides — titles, button text, etc. |
|
|
92
98
|
| `security` | `Record<string, never>` | Reserved for future per-app security knobs. The previously-configurable `assertionCacheTtlMs` was removed in Phase 4 of the presence-token gating work — every sensitive op now does a fresh WebAuthn ceremony and mints scope-bound single-use JWTs via the iframe's internal orchestrator, so there is no parent-side cache left to configure. See [Security](#security) below. |
|
|
93
|
-
| `theme` | `MoonKeyThemeConfig` | Low-level token overrides — fine-grained color palette, full borderRadius scale. Most apps don't need this; `appearance` is the recommended surface. |
|
|
94
99
|
|
|
95
100
|
## Hooks
|
|
96
101
|
|
|
@@ -138,14 +143,15 @@ import { useSignMessage as useSignSolanaMessage } from "@moon-x/react-sdk/solana
|
|
|
138
143
|
- `useSignTypedData` — EIP-712. Returns `{ signature: "0x..." }`.
|
|
139
144
|
- `useSignHash` — Raw ECDSA digest sign (Privy parity — `secp256k1_sign`).
|
|
140
145
|
- `useSign7702Authorization` — EIP-7702 delegation auth.
|
|
141
|
-
- `useSendTransaction` — Sign + broadcast
|
|
142
|
-
- `useGetBalance` — Native token balance.
|
|
146
|
+
- `useSendTransaction` — Sign + broadcast. Accepts a per-call `chain` selector and an inline `rpcUrl` override (both fall back to provider config).
|
|
147
|
+
- `useGetBalance` — Native token balance. Same per-call `chain` / `rpcUrl` options.
|
|
143
148
|
|
|
144
149
|
**Solana hooks:**
|
|
145
150
|
- `useSignMessage` — Ed25519 signature.
|
|
146
151
|
- `useSignTransaction` — Signs a serialized base58 tx. Returns `{ signedTransaction: Uint8Array }`.
|
|
147
|
-
- `useSendTransaction` — Sign + broadcast.
|
|
148
|
-
- `useGetBalance` — Lamport balance.
|
|
152
|
+
- `useSendTransaction` — Sign + broadcast. Accepts a per-call `chain` selector and an inline `rpcUrl` override.
|
|
153
|
+
- `useGetBalance` — Lamport balance. Same per-call `chain` / `rpcUrl` options.
|
|
154
|
+
- `useGetTokenAccounts` — SPL token accounts by owner. Same per-call `chain` / `rpcUrl` options.
|
|
149
155
|
|
|
150
156
|
Every signing hook accepts `options.uiOptions.showWalletUI` to toggle modal vs headless mode. With UI, the user sees the message/transaction in a modal and the biometric prompt fires only on the Sign tap. Headless skips the modal entirely.
|
|
151
157
|
|
|
@@ -166,31 +172,99 @@ The previously-configurable `security.assertionCacheTtlMs` and per-call `require
|
|
|
166
172
|
|
|
167
173
|
### Theming
|
|
168
174
|
|
|
169
|
-
|
|
175
|
+
All theming flows through a single `appearance` object. Set a few high-level
|
|
176
|
+
branding fields (`accentColor`, `backgroundColor`, `displayMode`, `logo`,
|
|
177
|
+
`loginHeaderTitle`, `fontFamily`) — the SDK derives a full palette from
|
|
178
|
+
`accentColor` / `backgroundColor` — and reach for the inline design tokens
|
|
179
|
+
(`colors`, `borderRadius`, `typography`, `card`, `backdrop`, `components`,
|
|
180
|
+
per-mode `light` / `dark`) when you want finer control.
|
|
170
181
|
|
|
171
182
|
```tsx
|
|
172
183
|
<MoonKeyProvider
|
|
173
184
|
config={{
|
|
174
185
|
appearance: {
|
|
186
|
+
// Branding
|
|
175
187
|
accentColor: "#6366f1",
|
|
176
188
|
backgroundColor: "#0f172a",
|
|
177
|
-
displayMode: "dark",
|
|
178
|
-
borderRadius: "md", // "none" | "sm" | "md" | "lg" — or { sm, md, lg }
|
|
189
|
+
displayMode: "dark", // "light" | "dark" | "auto"
|
|
179
190
|
fontFamily: "Inter, sans-serif",
|
|
180
|
-
logo: "
|
|
191
|
+
logo: { src: "/logo.svg", srcDark: "/logo-dark.svg", height: 32 },
|
|
192
|
+
|
|
193
|
+
// Design tokens (all inline on appearance)
|
|
194
|
+
colors: { warning: "#f59e0b", info: "#3b82f6", link: "#6366f1", ring: "#6366f1" },
|
|
195
|
+
borderRadius: { button: "9999px", card: "1rem", input: "0.5rem" }, // or "none" | "sm" | "md" | "lg"
|
|
196
|
+
typography: {
|
|
197
|
+
fontFamilyHeading: "Poppins, sans-serif",
|
|
198
|
+
fontUrl: "https://fonts.googleapis.com/css2?family=Poppins&display=swap",
|
|
199
|
+
letterSpacing: "0.01em",
|
|
200
|
+
fontSize: { sm: "0.8125rem", lg: "1.0625rem", xl: "1.375rem" },
|
|
201
|
+
},
|
|
202
|
+
card: { shadow: "0 10px 25px -5px rgb(0 0 0 / 0.2)", padding: "1.5rem", maxWidth: "26rem" },
|
|
203
|
+
backdrop: { color: "rgb(0 0 0 / 0.5)", blur: "8px" },
|
|
204
|
+
|
|
205
|
+
// Per-mode overrides (merged on top of the base tokens for the resolved mode)
|
|
206
|
+
dark: { colors: { background: "#0b0b0f" } },
|
|
181
207
|
},
|
|
182
208
|
}}
|
|
183
209
|
>
|
|
184
210
|
```
|
|
185
211
|
|
|
186
|
-
|
|
212
|
+
Update appearance at runtime — handy for a light/dark toggle:
|
|
187
213
|
|
|
188
214
|
```tsx
|
|
189
215
|
const { setAppearance } = useMoonKey();
|
|
190
216
|
setAppearance({ displayMode: colorScheme });
|
|
191
217
|
```
|
|
192
218
|
|
|
193
|
-
|
|
219
|
+
**Merge order** (low → high): base light/dark theme → `accentColor` /
|
|
220
|
+
`backgroundColor` derivations → `appearance` tokens (`colors`, `borderRadius`, …)
|
|
221
|
+
→ per-mode `appearance.light` / `appearance.dark`. So an explicit `appearance`
|
|
222
|
+
token always wins over the high-level derivations.
|
|
223
|
+
|
|
224
|
+
#### Token reference
|
|
225
|
+
|
|
226
|
+
The original palette/radius/font emit `--moonkey-*` CSS variables; the newer tokens
|
|
227
|
+
emit `--moonx-*` (each with a `--moonkey-*` fallback, so defaults are unchanged until set).
|
|
228
|
+
|
|
229
|
+
| Group | Tokens | CSS variables |
|
|
230
|
+
|---|---|---|
|
|
231
|
+
| `colors` | `accent`, `accentForeground`, `background`, `background2/3`, `foreground`, `foreground2–4`, `border`, `success`, `error`, … | `--moonkey-color-*` |
|
|
232
|
+
| `colors` | `warning`, `info`, `link`, `ring` (focus) | `--moonx-color-*` |
|
|
233
|
+
| `borderRadius` | `sm`, `md`, `lg`, `full` | `--moonkey-border-radius-*` |
|
|
234
|
+
| `borderRadius` | `button`, `card`, `input` | `--moonx-radius-*` |
|
|
235
|
+
| `typography` | `fontFamilyHeading`, `letterSpacing`, `fontSize.{sm,lg,xl}`, `fontWeight.{medium,bold}` | `--moonx-font-*`, `--moonx-letter-spacing` |
|
|
236
|
+
| `typography` | `fontUrl` | injected `<link rel="stylesheet">` |
|
|
237
|
+
| `card` | `padding`, `shadow`, `borderWidth`, `maxWidth` | `--moonx-card-*` |
|
|
238
|
+
| `backdrop` | `color`, `blur` | `--moonx-backdrop-*` |
|
|
239
|
+
|
|
240
|
+
#### Per-component overrides
|
|
241
|
+
|
|
242
|
+
For finer control, `appearance.components` styles individual surfaces — `card`,
|
|
243
|
+
`button`, `input` — independently of the global tokens. `button` and `input`
|
|
244
|
+
accept `background`, `text`, `border` (color), `borderWidth`, and `radius`;
|
|
245
|
+
`card` accepts the same minus `background` (the card surface **is** the global
|
|
246
|
+
`backgroundColor`). Anything you omit falls through to the global tokens /
|
|
247
|
+
`--moonkey-*` defaults. The header is styled via the typography tokens instead
|
|
248
|
+
(`appearance.typography.colorHeading`, `fontFamilyHeading`, …).
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
<MoonKeyProvider
|
|
252
|
+
config={{
|
|
253
|
+
appearance: {
|
|
254
|
+
components: {
|
|
255
|
+
card: { border: "#23233a", radius: "1rem" },
|
|
256
|
+
button: { background: "#a78bfa", text: "#0b0b14", radius: "9999px" },
|
|
257
|
+
input: { background: "#15151f", border: "#23233a", borderWidth: "1px" },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
}}
|
|
261
|
+
>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Each field maps to a `--moonx-<component>-*` CSS variable (e.g. `--moonx-card-bg`,
|
|
265
|
+
`--moonx-button-border-color`); `radius` reuses `--moonx-radius-<component>`.
|
|
266
|
+
Overrides layer **on top of** the global tokens, so you can restyle just the card
|
|
267
|
+
while everything else follows the theme.
|
|
194
268
|
|
|
195
269
|
## EVM chain helpers
|
|
196
270
|
|
|
@@ -204,15 +278,20 @@ import {
|
|
|
204
278
|
estimateEvmGas,
|
|
205
279
|
estimateEvmGasReserve,
|
|
206
280
|
getRpcUrl,
|
|
207
|
-
setChainRpcUrl,
|
|
208
281
|
getChainById,
|
|
209
|
-
getDefaultChain,
|
|
210
282
|
isChainSupported,
|
|
211
283
|
validateChainConfig,
|
|
284
|
+
// Unified-config resolution (also used internally by the hooks):
|
|
285
|
+
resolveChainEntry,
|
|
286
|
+
resolveRpcUrl,
|
|
287
|
+
resolveWsUrl,
|
|
288
|
+
normalizeChainKey,
|
|
289
|
+
buildChainIndex,
|
|
290
|
+
isEvmEntry,
|
|
212
291
|
} from "@moon-x/react-sdk";
|
|
213
292
|
```
|
|
214
293
|
|
|
215
|
-
Useful when you need a pre-flight gas reserve estimate, want to
|
|
294
|
+
Useful when you need a pre-flight gas reserve estimate, want to resolve a configured chain's RPC yourself, or are building a custom chain-picker.
|
|
216
295
|
|
|
217
296
|
## React Native
|
|
218
297
|
|
|
@@ -319,15 +319,15 @@ __export(ethereum_exports, {
|
|
|
319
319
|
import { useSignMessage as useSharedEthSignMessage, useSignTransaction as useSharedEthSignTransaction, useSignTypedData as useSharedEthSignTypedData, useSignHash as useSharedEthSignHash, useSign7702Authorization as useSharedEthSign7702Authorization, useSendTransaction as useSharedEthSendTransaction, useGetBalance as useSharedEthGetBalance } from "@moon-x/core/react/ethereum";
|
|
320
320
|
import { useWallets as useSharedWallets, useCreateWallet as useSharedCreateWallet, useImportKey as useSharedImportKey } from "@moon-x/core/react";
|
|
321
321
|
import { useCallback } from "react";
|
|
322
|
-
import {
|
|
322
|
+
import { prepareEvmSendTransaction, prepareEvmSignTransaction, resolveEvmChainEntry as resolveEvmChainEntry2, resolveRpcUrl as resolveRpcUrl2 } from "@moon-x/core/lib";
|
|
323
323
|
// src/wallets/ethereum-provider.ts
|
|
324
|
-
import {
|
|
324
|
+
import { resolveEvmChainEntry, resolveRpcUrl } from "@moon-x/core/lib";
|
|
325
325
|
var useEthereumProvider = function useEthereumProvider(wallet) {
|
|
326
326
|
var coreSDK = useAuthSDK();
|
|
327
327
|
var currentChainId = wallet.chainId || 1;
|
|
328
328
|
var request = function request(args) {
|
|
329
329
|
return _async_to_generator(function() {
|
|
330
|
-
var method, _args_params, params, message, messageText, response,
|
|
330
|
+
var method, _args_params, params, message, messageText, response, _coreSDK_config, _coreSDK_config1, _params, transaction, requestedSendChainId, sendEntry, sendRpcUrl, sendResponse, _params1, txToSign, signResponse, _params2, typedData, accountAddr, typedDataResponse, _params3, typedDataV4, accountAddrV4, typedDataV4Response, _params4, hash, secp256k1Response, _coreSDK_config2, _coreSDK_config3, defaultEntry, rpcUrl, response2, data, error;
|
|
331
331
|
return _ts_generator(this, function(_state) {
|
|
332
332
|
switch(_state.label){
|
|
333
333
|
case 0:
|
|
@@ -436,14 +436,17 @@ var useEthereumProvider = function useEthereumProvider(wallet) {
|
|
|
436
436
|
throw new Error("eth_sendTransaction requires transaction parameter");
|
|
437
437
|
}
|
|
438
438
|
_params = _sliced_to_array(params, 1), transaction = _params[0];
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
439
|
+
requestedSendChainId = (transaction === null || transaction === void 0 ? void 0 : transaction.chainId) != null && Number.isFinite(Number(transaction.chainId)) ? Number(transaction.chainId) : void 0;
|
|
440
|
+
sendEntry = resolveEvmChainEntry({
|
|
441
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
442
|
+
requestedChainId: requestedSendChainId,
|
|
443
|
+
walletChainId: currentChainId,
|
|
444
|
+
defaultSelector: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain
|
|
445
|
+
});
|
|
446
|
+
if (!sendEntry) {
|
|
447
|
+
throw new Error(requestedSendChainId != null ? "Transaction targets chainId ".concat(requestedSendChainId, ", which is not in the configured chains.") : "No chain configured. Please set `chains` (and optionally `defaultChain`) in MoonKeyProvider config.");
|
|
446
448
|
}
|
|
449
|
+
sendRpcUrl = resolveRpcUrl(sendEntry);
|
|
447
450
|
return [
|
|
448
451
|
4,
|
|
449
452
|
coreSDK.sendEthereumTransactionHeadless({
|
|
@@ -542,22 +545,14 @@ var useEthereumProvider = function useEthereumProvider(wallet) {
|
|
|
542
545
|
secp256k1Response.signature
|
|
543
546
|
];
|
|
544
547
|
case 16:
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
548
|
+
defaultEntry = resolveEvmChainEntry({
|
|
549
|
+
chains: (_coreSDK_config2 = coreSDK.config) === null || _coreSDK_config2 === void 0 ? void 0 : _coreSDK_config2.chains,
|
|
550
|
+
walletChainId: currentChainId,
|
|
551
|
+
defaultSelector: (_coreSDK_config3 = coreSDK.config) === null || _coreSDK_config3 === void 0 ? void 0 : _coreSDK_config3.defaultChain
|
|
552
|
+
});
|
|
553
|
+
rpcUrl = defaultEntry ? resolveRpcUrl(defaultEntry) : void 0;
|
|
552
554
|
if (!rpcUrl) {
|
|
553
|
-
;
|
|
554
|
-
fallbackChain = (_coreSDK_config2 = coreSDK.config) === null || _coreSDK_config2 === void 0 ? void 0 : (_coreSDK_config_ethereum2 = _coreSDK_config2.ethereum) === null || _coreSDK_config_ethereum2 === void 0 ? void 0 : _coreSDK_config_ethereum2.defaultChain;
|
|
555
|
-
if (fallbackChain) {
|
|
556
|
-
rpcUrl = getRpcUrl(fallbackChain);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
if (!rpcUrl) {
|
|
560
|
-
throw new Error("Unsupported method: ".concat(method, ". No RPC configured for chain ID ").concat(currentChainId, ". Please configure 'defaultChain' and 'supportedChains' in MoonKeyProvider."));
|
|
555
|
+
throw new Error("Unsupported method: ".concat(method, ". No RPC configured for chain ID ").concat(currentChainId, ". Please configure 'chains' (and optionally 'defaultChain') in MoonKeyProvider."));
|
|
561
556
|
}
|
|
562
557
|
_state.label = 17;
|
|
563
558
|
case 17:
|
|
@@ -679,7 +674,7 @@ var createEthereumProvider = function createEthereumProvider(wallet, coreSDK) {
|
|
|
679
674
|
var currentChainId = wallet.chainId || 1;
|
|
680
675
|
var request = function request(args) {
|
|
681
676
|
return _async_to_generator(function() {
|
|
682
|
-
var method, _args_params, params, message, messageText, response,
|
|
677
|
+
var method, _args_params, params, message, messageText, response, _coreSDK_config, _coreSDK_config1, _params, transaction, requestedSendChainId, sendEntry, sendTxRpcUrl, txResponse, _params1, txToSign, signResponse, _params2, typedData, typedDataResponse, _coreSDK_config2, _coreSDK_config3, defaultEntry, rpcUrl, rpcResponse, rpcResult;
|
|
683
678
|
return _ts_generator(this, function(_state) {
|
|
684
679
|
switch(_state.label){
|
|
685
680
|
case 0:
|
|
@@ -783,11 +778,17 @@ var createEthereumProvider = function createEthereumProvider(wallet, coreSDK) {
|
|
|
783
778
|
throw new Error("eth_sendTransaction requires transaction parameter");
|
|
784
779
|
}
|
|
785
780
|
_params = _sliced_to_array(params, 1), transaction = _params[0];
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
781
|
+
requestedSendChainId = (transaction === null || transaction === void 0 ? void 0 : transaction.chainId) != null && Number.isFinite(Number(transaction.chainId)) ? Number(transaction.chainId) : void 0;
|
|
782
|
+
sendEntry = resolveEvmChainEntry({
|
|
783
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
784
|
+
requestedChainId: requestedSendChainId,
|
|
785
|
+
walletChainId: currentChainId,
|
|
786
|
+
defaultSelector: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain
|
|
787
|
+
});
|
|
788
|
+
if (!sendEntry) {
|
|
789
|
+
throw new Error(requestedSendChainId != null ? "Transaction targets chainId ".concat(requestedSendChainId, ", which is not in the configured chains.") : "No default chain configured");
|
|
789
790
|
}
|
|
790
|
-
sendTxRpcUrl =
|
|
791
|
+
sendTxRpcUrl = resolveRpcUrl(sendEntry);
|
|
791
792
|
return [
|
|
792
793
|
4,
|
|
793
794
|
coreSDK.sendEthereumTransactionHeadless({
|
|
@@ -842,16 +843,12 @@ var createEthereumProvider = function createEthereumProvider(wallet, coreSDK) {
|
|
|
842
843
|
typedDataResponse.signature
|
|
843
844
|
];
|
|
844
845
|
case 12:
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (defaultChain2) {
|
|
852
|
-
rpcUrl = getRpcUrl(defaultChain2);
|
|
853
|
-
}
|
|
854
|
-
}
|
|
846
|
+
defaultEntry = resolveEvmChainEntry({
|
|
847
|
+
chains: (_coreSDK_config2 = coreSDK.config) === null || _coreSDK_config2 === void 0 ? void 0 : _coreSDK_config2.chains,
|
|
848
|
+
walletChainId: currentChainId,
|
|
849
|
+
defaultSelector: (_coreSDK_config3 = coreSDK.config) === null || _coreSDK_config3 === void 0 ? void 0 : _coreSDK_config3.defaultChain
|
|
850
|
+
});
|
|
851
|
+
rpcUrl = defaultEntry ? resolveRpcUrl(defaultEntry) : void 0;
|
|
855
852
|
if (!rpcUrl) {
|
|
856
853
|
throw new Error("Unsupported method: ".concat(method, ". No RPC URL found for chain ").concat(currentChainId));
|
|
857
854
|
}
|
|
@@ -1032,9 +1029,12 @@ var useWallets = function useWallets() {
|
|
|
1032
1029
|
var coreSDK = useAuthSDK();
|
|
1033
1030
|
var shared = useSharedWallets("ethereum");
|
|
1034
1031
|
var enhanceWallet = useCallback(function(wallet) {
|
|
1035
|
-
var
|
|
1032
|
+
var _resolveEvmChainEntry2, _coreSDK_config, _coreSDK_config1;
|
|
1036
1033
|
var ethereumWallet = _object_spread_props(_object_spread({}, wallet), {
|
|
1037
|
-
chainId: wallet.chainId || ((
|
|
1034
|
+
chainId: wallet.chainId || ((_resolveEvmChainEntry2 = resolveEvmChainEntry2({
|
|
1035
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
1036
|
+
defaultSelector: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain
|
|
1037
|
+
})) === null || _resolveEvmChainEntry2 === void 0 ? void 0 : _resolveEvmChainEntry2.chain.id),
|
|
1038
1038
|
switchChain: function switchChain(chainId) {
|
|
1039
1039
|
return _async_to_generator(function() {
|
|
1040
1040
|
return _ts_generator(this, function(_state) {
|
|
@@ -1126,9 +1126,9 @@ var useSignTransaction = function useSignTransaction() {
|
|
|
1126
1126
|
var shared = useSharedEthSignTransaction();
|
|
1127
1127
|
return {
|
|
1128
1128
|
signTransaction: function signTransaction(param) {
|
|
1129
|
-
var transaction = param.transaction, wallet = param.wallet, options = param.options;
|
|
1129
|
+
var transaction = param.transaction, wallet = param.wallet, chain = param.chain, options = param.options;
|
|
1130
1130
|
return _async_to_generator(function() {
|
|
1131
|
-
var
|
|
1131
|
+
var _coreSDK_config, _coreSDK_config1, _coreSDK_config_signTransactionConfig, _coreSDK_config2, serializedTransaction, showWalletUI, error;
|
|
1132
1132
|
return _ts_generator(this, function(_state) {
|
|
1133
1133
|
switch(_state.label){
|
|
1134
1134
|
case 0:
|
|
@@ -1146,8 +1146,9 @@ var useSignTransaction = function useSignTransaction() {
|
|
|
1146
1146
|
public_address: wallet.public_address,
|
|
1147
1147
|
chainId: wallet.chainId
|
|
1148
1148
|
},
|
|
1149
|
-
|
|
1150
|
-
defaultChain: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 :
|
|
1149
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
1150
|
+
defaultChain: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain,
|
|
1151
|
+
chainSelector: chain
|
|
1151
1152
|
})
|
|
1152
1153
|
];
|
|
1153
1154
|
case 1:
|
|
@@ -1285,24 +1286,23 @@ var useSign7702Authorization = function useSign7702Authorization() {
|
|
|
1285
1286
|
var coreSDK = useAuthSDK();
|
|
1286
1287
|
return {
|
|
1287
1288
|
signAuthorization: function signAuthorization(param) {
|
|
1288
|
-
var contractAddress = param.contractAddress, nonce = param.nonce, executor = param.executor, wallet = param.wallet, options = param.options;
|
|
1289
|
+
var contractAddress = param.contractAddress, nonce = param.nonce, executor = param.executor, wallet = param.wallet, chain = param.chain, options = param.options;
|
|
1289
1290
|
return _async_to_generator(function() {
|
|
1290
|
-
var
|
|
1291
|
+
var _coreSDK_config, _coreSDK_config1, walletChainId, targetEntry, derivedChainId, _coreSDK_config_signMessageConfig, _coreSDK_config2, showWalletUI, error;
|
|
1291
1292
|
return _ts_generator(this, function(_state) {
|
|
1292
1293
|
switch(_state.label){
|
|
1293
1294
|
case 0:
|
|
1294
1295
|
walletChainId = wallet.chainId;
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1296
|
+
targetEntry = resolveEvmChainEntry2({
|
|
1297
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
1298
|
+
selector: chain,
|
|
1299
|
+
walletChainId: walletChainId,
|
|
1300
|
+
defaultSelector: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain
|
|
1301
|
+
});
|
|
1302
|
+
if (!targetEntry) {
|
|
1303
|
+
throw new Error(chain != null ? 'chain "'.concat(chain, '" is not in the configured chains.') : "No chain configured. Please set `chains` (and optionally `defaultChain`) in MoonKeyProvider config.");
|
|
1301
1304
|
}
|
|
1302
|
-
|
|
1303
|
-
throw new Error("No chain configured. Please set ethereum.defaultChain in MoonKeyProvider config.");
|
|
1304
|
-
}
|
|
1305
|
-
derivedChainId = targetChain.id;
|
|
1305
|
+
derivedChainId = targetEntry.chain.id;
|
|
1306
1306
|
_state.label = 1;
|
|
1307
1307
|
case 1:
|
|
1308
1308
|
_state.trys.push([
|
|
@@ -1355,9 +1355,9 @@ var useSendTransaction = function useSendTransaction() {
|
|
|
1355
1355
|
var shared = useSharedEthSendTransaction();
|
|
1356
1356
|
return {
|
|
1357
1357
|
sendTransaction: function sendTransaction(param) {
|
|
1358
|
-
var transaction = param.transaction, wallet = param.wallet, options = param.options;
|
|
1358
|
+
var transaction = param.transaction, wallet = param.wallet, chain = param.chain, rpcUrlOverride = param.rpcUrl, options = param.options;
|
|
1359
1359
|
return _async_to_generator(function() {
|
|
1360
|
-
var
|
|
1360
|
+
var _coreSDK_config, _coreSDK_config1, _coreSDK_config_signMessageConfig, _coreSDK_config2, _ref, preparedTx, rpcUrl, showWalletUI, response, error;
|
|
1361
1361
|
return _ts_generator(this, function(_state) {
|
|
1362
1362
|
switch(_state.label){
|
|
1363
1363
|
case 0:
|
|
@@ -1375,8 +1375,10 @@ var useSendTransaction = function useSendTransaction() {
|
|
|
1375
1375
|
public_address: wallet.public_address,
|
|
1376
1376
|
chainId: wallet.chainId
|
|
1377
1377
|
},
|
|
1378
|
-
|
|
1379
|
-
defaultChain: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 :
|
|
1378
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
1379
|
+
defaultChain: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain,
|
|
1380
|
+
chainSelector: chain,
|
|
1381
|
+
rpcUrlOverride: rpcUrlOverride
|
|
1380
1382
|
})
|
|
1381
1383
|
];
|
|
1382
1384
|
case 1:
|
|
@@ -1427,7 +1429,7 @@ var useGetBalance = function useGetBalance() {
|
|
|
1427
1429
|
return {
|
|
1428
1430
|
getBalance: function getBalance(params) {
|
|
1429
1431
|
return _async_to_generator(function() {
|
|
1430
|
-
var
|
|
1432
|
+
var _params_rpcUrl, _coreSDK_config, _coreSDK_config1, walletChainId, entry, rpcUrl, error;
|
|
1431
1433
|
return _ts_generator(this, function(_state) {
|
|
1432
1434
|
switch(_state.label){
|
|
1433
1435
|
case 0:
|
|
@@ -1438,19 +1440,18 @@ var useGetBalance = function useGetBalance() {
|
|
|
1438
1440
|
3
|
|
1439
1441
|
]);
|
|
1440
1442
|
walletChainId = params.wallet.chainId;
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
throw new Error("No chain configured. Please set ethereum.defaultChain in MoonKeyProvider config.");
|
|
1443
|
+
entry = resolveEvmChainEntry2({
|
|
1444
|
+
chains: (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : _coreSDK_config.chains,
|
|
1445
|
+
selector: params.chain,
|
|
1446
|
+
walletChainId: walletChainId,
|
|
1447
|
+
defaultSelector: (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : _coreSDK_config1.defaultChain
|
|
1448
|
+
});
|
|
1449
|
+
if (params.chain != null && !entry && !params.rpcUrl) {
|
|
1450
|
+
throw new Error('chain "'.concat(params.chain, '" is not in the configured chains.'));
|
|
1450
1451
|
}
|
|
1451
|
-
rpcUrl =
|
|
1452
|
+
rpcUrl = (_params_rpcUrl = params.rpcUrl) !== null && _params_rpcUrl !== void 0 ? _params_rpcUrl : entry ? resolveRpcUrl2(entry) : void 0;
|
|
1452
1453
|
if (!rpcUrl) {
|
|
1453
|
-
throw new Error("No RPC URL
|
|
1454
|
+
throw new Error("No RPC URL \u2014 set `chains` (and optionally `defaultChain`) in MoonKeyProvider config, or pass an `rpcUrl`.");
|
|
1454
1455
|
}
|
|
1455
1456
|
return [
|
|
1456
1457
|
4,
|