@cordystackx/cordy_minikit 2.0.6 → 2.0.9
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 +37 -44
- package/dist/controllers/StellarButton.d.ts.map +1 -1
- package/dist/controllers/StellarButton.js +26 -2
- package/dist/controllers/WagmiButton.d.ts.map +1 -1
- package/dist/controllers/WagmiButton.js +9 -1
- package/dist/package.json +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -35,7 +35,9 @@ Built with **Wagmi**, **Viem**, **Ethers**, and **TypeScript**.
|
|
|
35
35
|
- 📦 **Tree-shakable & Typed** — Optimized bundle size with full TypeScript definitions
|
|
36
36
|
- 🧩 **Framework-Agnostic** — Works seamlessly with Next.js, Vite, and more
|
|
37
37
|
- 🌐 **Multi-Chain Support** — Custom chain configuration support
|
|
38
|
-
|
|
38
|
+
- 🌌 **Non-EVM Wallet Support** — Stellar / Soroban wallet support through Freighter
|
|
39
|
+
- ⭐ **Stellar Balance & Transfers** — Read XLM balances and send native Stellar payments
|
|
40
|
+
- 🧠 **Wallet Context Detection** — Detect `EVM`, `Non-EVM`, `MULTI`, or `NONE`
|
|
39
41
|
---
|
|
40
42
|
|
|
41
43
|
## 📦 Installation
|
|
@@ -64,38 +66,7 @@ and send native Stellar payments using the built-in `CordyStackTransStellar` hel
|
|
|
64
66
|
- `MULTI` — Both EVM and Non-EVM wallets connected
|
|
65
67
|
- `NONE` — No wallet connected
|
|
66
68
|
|
|
67
|
-
This makes Cordy MiniKit ready for multi-chain apps that need both EVM and Stellar support.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Also update your Features section with these bullets:
|
|
71
|
-
|
|
72
|
-
- 🌌 **Non-EVM Wallet Support** — Stellar / Soroban wallet support through Freighter
|
|
73
|
-
- ⭐ **Stellar Balance & Transfers** — Read XLM balances and send native Stellar payments
|
|
74
|
-
- 🧠 **Wallet Context Detection** — Detect `EVM`, `Non_EVM`, `MULTI`, or `NONE`
|
|
75
|
-
|
|
76
|
-
And add this to API Reference → Hooks:
|
|
77
|
-
|
|
78
|
-
#### `useWalletStatus()`
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
const {
|
|
82
|
-
context,
|
|
83
|
-
evm,
|
|
84
|
-
stellar,
|
|
85
|
-
refreshBalances,
|
|
86
|
-
disconnectEVM,
|
|
87
|
-
disconnectStellar,
|
|
88
|
-
disconnectAll,
|
|
89
|
-
} = useWalletStatus();
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Returns wallet status for both EVM and Non-EVM wallets.
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
context: "EVM" | "Non-EVM" | "MULTI" | "NONE"
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Useful for detecting whether the connected wallet is Wagmi/EVM, Stellar/Non-EVM, both, or none.
|
|
69
|
+
This makes Cordy MiniKit ready for multi-chain apps that need both EVM and Stellar support.
|
|
99
70
|
|
|
100
71
|
## 🛠️ Quick Start
|
|
101
72
|
|
|
@@ -362,15 +333,15 @@ Returns:
|
|
|
362
333
|
}
|
|
363
334
|
```
|
|
364
335
|
|
|
365
|
-
┌─────────────────────┬────────────────────────────────────────────────────┐
|
|
366
|
-
│ Function │ Description │
|
|
367
|
-
├─────────────────────┼────────────────────────────────────────────────────┤
|
|
368
|
-
│ disconnectEVM() │ Disconnects the active Wagmi/EVM wallet │
|
|
369
|
-
├─────────────────────┼────────────────────────────────────────────────────┤
|
|
370
|
-
│ disconnectStellar() │ Clears the active Stellar/Freighter wallet session │
|
|
371
|
-
├─────────────────────┼────────────────────────────────────────────────────┤
|
|
372
|
-
│ disconnectAll() │ Disconnects both EVM and Stellar wallet sessions │
|
|
373
|
-
└─────────────────────┴────────────────────────────────────────────────────┘
|
|
336
|
+
┌─────────────────────┬────────────────────────────────────────────────────┐
|
|
337
|
+
│ Function │ Description │
|
|
338
|
+
├─────────────────────┼────────────────────────────────────────────────────┤
|
|
339
|
+
│ disconnectEVM() │ Disconnects the active Wagmi/EVM wallet │
|
|
340
|
+
├─────────────────────┼────────────────────────────────────────────────────┤
|
|
341
|
+
│ disconnectStellar() │ Clears the active Stellar/Freighter wallet session │
|
|
342
|
+
├─────────────────────┼────────────────────────────────────────────────────┤
|
|
343
|
+
│ disconnectAll() │ Disconnects both EVM and Stellar wallet sessions │
|
|
344
|
+
└─────────────────────┴────────────────────────────────────────────────────┘
|
|
374
345
|
|
|
375
346
|
Each function returns:
|
|
376
347
|
|
|
@@ -429,7 +400,7 @@ EVM and Non-EVM wallets.
|
|
|
429
400
|
<p>EVM Address: {evm.address}</p>
|
|
430
401
|
)}
|
|
431
402
|
|
|
432
|
-
{context === "
|
|
403
|
+
{context === "Non-EVM" && (
|
|
433
404
|
<p>Stellar Address: {stellar.address}</p>
|
|
434
405
|
)}
|
|
435
406
|
|
|
@@ -456,7 +427,7 @@ Returns:
|
|
|
456
427
|
|
|
457
428
|
```ts
|
|
458
429
|
{
|
|
459
|
-
context: "EVM" | "
|
|
430
|
+
context: "EVM" | "Non-EVM" | "MULTI" | "NONE";
|
|
460
431
|
|
|
461
432
|
evm: {
|
|
462
433
|
isConnected: boolean;
|
|
@@ -715,6 +686,28 @@ const config = getConfig({ myChain: customChainDefinition });
|
|
|
715
686
|
```
|
|
716
687
|
- Returns: Wagmi configuration with custom chains
|
|
717
688
|
|
|
689
|
+
#### `useWalletStatus()`
|
|
690
|
+
|
|
691
|
+
```tsx
|
|
692
|
+
const {
|
|
693
|
+
context,
|
|
694
|
+
evm,
|
|
695
|
+
stellar,
|
|
696
|
+
refreshBalances,
|
|
697
|
+
disconnectEVM,
|
|
698
|
+
disconnectStellar,
|
|
699
|
+
disconnectAll,
|
|
700
|
+
} = useWalletStatus();
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
Returns wallet status for both EVM and Non-EVM wallets.
|
|
704
|
+
|
|
705
|
+
```ts
|
|
706
|
+
context: "EVM" | "Non-EVM" | "MULTI" | "NONE"
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
Useful for detecting whether the connected wallet is Wagmi/EVM, Stellar/Non-EVM, both, or none.
|
|
710
|
+
|
|
718
711
|
---
|
|
719
712
|
|
|
720
713
|
## 🎨 Customization
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarButton.d.ts","sourceRoot":"","sources":["../../controllers/StellarButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StellarButton.d.ts","sourceRoot":"","sources":["../../controllers/StellarButton.tsx"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,SAAS,EACT,cAAc,GACf,EAAE;IACD,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE;QACxB,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAK,IAAI,CAAC;CACZ,+BA6EA"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { requestAccess, getNetworkDetails } from "@stellar/freighter-api";
|
|
4
|
+
import { requestAccess, getNetworkDetails, isConnected, } from "@stellar/freighter-api";
|
|
5
5
|
import img_src from "../config/Image.json";
|
|
6
|
+
const FREIGHTER_DOWNLOAD_URL = "https://www.freighter.app/";
|
|
7
|
+
function isMobileDevice() {
|
|
8
|
+
if (typeof navigator === "undefined")
|
|
9
|
+
return false;
|
|
10
|
+
return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);
|
|
11
|
+
}
|
|
6
12
|
export default function StellarWalletButton({ onConnect, onStatusChange, }) {
|
|
7
13
|
const [address, setAddress] = useState(null);
|
|
8
14
|
const [isPending, setIsPending] = useState(false);
|
|
@@ -13,10 +19,28 @@ export default function StellarWalletButton({ onConnect, onStatusChange, }) {
|
|
|
13
19
|
setErrorMsg(undefined);
|
|
14
20
|
onStatusChange?.({ isPending: true });
|
|
15
21
|
try {
|
|
22
|
+
const connection = await isConnected();
|
|
23
|
+
if (!connection.isConnected) {
|
|
24
|
+
const message = isMobileDevice()
|
|
25
|
+
? "Open this page in Freighter mobile or install Freighter to connect."
|
|
26
|
+
: "Freighter is not installed.";
|
|
27
|
+
if (isMobileDevice() && typeof window !== "undefined") {
|
|
28
|
+
window.open(FREIGHTER_DOWNLOAD_URL, "_blank", "noopener,noreferrer");
|
|
29
|
+
}
|
|
30
|
+
setErrorMsg(message);
|
|
31
|
+
onStatusChange?.({ isPending: false, error: message });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
16
34
|
const access = await requestAccess();
|
|
35
|
+
if (access.error) {
|
|
36
|
+
throw new Error(access.error.message);
|
|
37
|
+
}
|
|
17
38
|
const publicKey = access.address;
|
|
18
39
|
setAddress(publicKey);
|
|
19
40
|
const networkDetails = await getNetworkDetails();
|
|
41
|
+
if (networkDetails.error) {
|
|
42
|
+
throw new Error(networkDetails.error.message);
|
|
43
|
+
}
|
|
20
44
|
setNetwork(networkDetails.network || "Unknown");
|
|
21
45
|
onConnect?.(publicKey);
|
|
22
46
|
onStatusChange?.({
|
|
@@ -39,5 +63,5 @@ export default function StellarWalletButton({ onConnect, onStatusChange, }) {
|
|
|
39
63
|
? "Connecting..."
|
|
40
64
|
: address
|
|
41
65
|
? `Connected: ${address.slice(0, 6)}...`
|
|
42
|
-
: "Freighter"
|
|
66
|
+
: "Freighter"] }));
|
|
43
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WagmiButton.d.ts","sourceRoot":"","sources":["../../controllers/WagmiButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"WagmiButton.d.ts","sourceRoot":"","sources":["../../controllers/WagmiButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAazC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,cAAc,EACf,EAAE;IACD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAC1E,qBA+CA"}
|
|
@@ -4,6 +4,12 @@ import React, { useEffect } from "react";
|
|
|
4
4
|
import { useConnect } from "wagmi";
|
|
5
5
|
import Images from "../config/Image.json";
|
|
6
6
|
const ACTIVE_WALLET_SESSION_KEY = "cordy_minikit_active_wallet_session";
|
|
7
|
+
const ALWAYS_AVAILABLE_CONNECTOR_NAMES = new Set([
|
|
8
|
+
"WalletConnect",
|
|
9
|
+
"MetaMask",
|
|
10
|
+
"Coinbase Wallet",
|
|
11
|
+
"Trust Wallet",
|
|
12
|
+
]);
|
|
7
13
|
export default function WalletButton({ onStatusChange }) {
|
|
8
14
|
const { connectors, connectAsync } = useConnect();
|
|
9
15
|
const [pendingConnector, setPendingConnector] = React.useState(null);
|
|
@@ -45,7 +51,9 @@ function WalletOption({ connector, onClick, isPending }) {
|
|
|
45
51
|
React.useEffect(() => {
|
|
46
52
|
(async () => {
|
|
47
53
|
try {
|
|
48
|
-
if (connector.
|
|
54
|
+
if (connector.type !== "injected" ||
|
|
55
|
+
ALWAYS_AVAILABLE_CONNECTOR_NAMES.has(connector.name) ||
|
|
56
|
+
isTrustWallet) {
|
|
49
57
|
setInstalled(true);
|
|
50
58
|
return;
|
|
51
59
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cordystackx/cordy_minikit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"@metamask/connect-evm": "^2.1.0",
|
|
40
40
|
"@stellar/freighter-api": "^6.0.1",
|
|
41
41
|
"@stellar/stellar-sdk": "^16.0.1",
|
|
42
|
-
"@tanstack/react-query": "^5.101.
|
|
43
|
-
"@walletconnect/ethereum-provider": "^2.23.
|
|
42
|
+
"@tanstack/react-query": "^5.101.1",
|
|
43
|
+
"@walletconnect/ethereum-provider": "^2.23.10",
|
|
44
44
|
"ethers": "^6.17.0",
|
|
45
45
|
"next": "^16.2.9",
|
|
46
46
|
"react": "^19.2.7",
|
|
47
47
|
"react-dom": "^19.2.7",
|
|
48
48
|
"react-icons": "^5.6.0",
|
|
49
49
|
"viem": "^2.53.1",
|
|
50
|
-
"wagmi": "^3.6.
|
|
50
|
+
"wagmi": "^3.6.20"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^25.9.4",
|