suiport-sdk 0.1.4 → 0.1.5
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 +49 -115
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# suiport-sdk
|
|
2
2
|
|
|
3
|
-
Cross-chain payment SDK for Sui. Accept payments from any blockchain.
|
|
3
|
+
Cross-chain payment SDK for Sui. Accept payments from any blockchain with one line of code.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -14,148 +14,82 @@ npm install suiport-sdk
|
|
|
14
14
|
import { initSuiport, SuiportButton } from 'suiport-sdk'
|
|
15
15
|
|
|
16
16
|
// Initialize once at app startup
|
|
17
|
+
// Get your API key from https://partners.near-intents.org/
|
|
17
18
|
initSuiport({
|
|
18
|
-
apiKey: 'your-near-api-key',
|
|
19
|
+
apiKey: 'your-near-intents-api-key',
|
|
19
20
|
})
|
|
20
21
|
|
|
21
|
-
// Add the button
|
|
22
|
-
function PaymentPage() {
|
|
23
|
-
return (
|
|
24
|
-
<SuiportButton
|
|
25
|
-
recipient="0x..." // Sui wallet address
|
|
26
|
-
destinationToken="suiUSDC"
|
|
27
|
-
onSuccess={(result) => {
|
|
28
|
-
console.log('Payment complete!', result.txHash)
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Components
|
|
36
|
-
|
|
37
|
-
### SuiportButton
|
|
38
|
-
|
|
39
|
-
Drop-in payment button that opens the payment modal. This is the recommended way to use Suiport in your app.
|
|
40
|
-
|
|
41
|
-
```tsx
|
|
22
|
+
// Add the payment button
|
|
42
23
|
<SuiportButton
|
|
43
|
-
recipient="
|
|
44
|
-
|
|
45
|
-
destinationToken="suiUSDC"
|
|
46
|
-
amount="10"
|
|
47
|
-
label="Pay Now"
|
|
48
|
-
variant="default"
|
|
49
|
-
disabled={false}
|
|
50
|
-
className="my-custom-class"
|
|
51
|
-
onSuccess={(result) => console.log(result)}
|
|
52
|
-
onError={(error) => console.error(error)}
|
|
53
|
-
onOpenChange={(open) => console.log('Modal open:', open)}
|
|
24
|
+
recipient="0x..." // Your Sui wallet address
|
|
25
|
+
onSuccess={(result) => console.log('Paid!', result.txHash)}
|
|
54
26
|
/>
|
|
55
27
|
```
|
|
56
28
|
|
|
57
|
-
|
|
29
|
+
That's it! Users can now pay you from 21+ blockchains. The token received is USDC on Sui by default.
|
|
30
|
+
|
|
31
|
+
## SuiportButton Props
|
|
58
32
|
|
|
59
33
|
| Prop | Type | Required | Default | Description |
|
|
60
34
|
|------|------|----------|---------|-------------|
|
|
61
35
|
| `recipient` | `string` | ✅ | - | Sui wallet address to receive payment |
|
|
62
|
-
| `refundAddress` | `string` | ❌ | - | Address for refunds if payment fails |
|
|
63
36
|
| `destinationToken` | `'suiUSDC' \| 'suiSUI'` | ❌ | `'suiUSDC'` | Token to receive on Sui |
|
|
64
|
-
| `amount` | `string` | ❌ | - | Fixed amount
|
|
37
|
+
| `amount` | `string` | ❌ | - | Fixed amount (user selects if omitted) |
|
|
38
|
+
| `refundAddress` | `string` | ❌ | - | Refund address if payment fails* |
|
|
65
39
|
| `label` | `string` | ❌ | `'Pay with Crypto'` | Button text |
|
|
66
|
-
| `variant` | `'default' \| 'compact' \| 'outline'` | ❌ | `'default'` | Button style
|
|
40
|
+
| `variant` | `'default' \| 'compact' \| 'outline'` | ❌ | `'default'` | Button style |
|
|
67
41
|
| `disabled` | `boolean` | ❌ | `false` | Disable the button |
|
|
68
42
|
| `className` | `string` | ❌ | - | Custom CSS class |
|
|
69
|
-
| `onSuccess` | `(result
|
|
70
|
-
| `onError` | `(error
|
|
71
|
-
| `onOpenChange` | `(open
|
|
43
|
+
| `onSuccess` | `(result) => void` | ❌ | - | Called when payment completes |
|
|
44
|
+
| `onError` | `(error) => void` | ❌ | - | Called when payment fails |
|
|
45
|
+
| `onOpenChange` | `(open) => void` | ❌ | - | Called when modal opens/closes |
|
|
72
46
|
|
|
73
|
-
|
|
47
|
+
> *Note: In a future version, refund address input will be added directly in the modal UI, removing the need to pass it as a prop.
|
|
48
|
+
|
|
49
|
+
### Button Variants
|
|
74
50
|
|
|
75
51
|
- **`default`** - Gradient purple button with shadow (recommended)
|
|
76
52
|
- **`compact`** - Smaller version for tight spaces
|
|
77
53
|
- **`outline`** - Transparent with purple border
|
|
78
54
|
|
|
79
|
-
### SuiportModal
|
|
80
|
-
|
|
81
|
-
For custom implementations, use the modal directly:
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
import { SuiportModal } from 'suiport-sdk'
|
|
85
|
-
|
|
86
|
-
<SuiportModal
|
|
87
|
-
open={isOpen}
|
|
88
|
-
onClose={() => setIsOpen(false)}
|
|
89
|
-
recipient="0x..."
|
|
90
|
-
destinationToken="suiUSDC"
|
|
91
|
-
onSuccess={handleSuccess}
|
|
92
|
-
/>
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Hooks
|
|
96
|
-
|
|
97
|
-
### useSuiportPayment
|
|
98
|
-
|
|
99
|
-
Full control over the payment flow:
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
import { useSuiportPayment } from 'suiport-sdk'
|
|
103
|
-
|
|
104
|
-
const payment = useSuiportPayment({
|
|
105
|
-
recipient: '0x...',
|
|
106
|
-
destinationToken: 'suiUSDC',
|
|
107
|
-
onSuccess: (result) => console.log('Done!', result),
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
// Access state
|
|
111
|
-
payment.paymentState // 'idle' | 'quoting' | 'awaiting_deposit' | 'processing' | 'success' | 'error'
|
|
112
|
-
payment.quote // Quote details with deposit address
|
|
113
|
-
payment.status // Execution status with tx hashes
|
|
114
|
-
payment.error // Error if payment failed
|
|
115
|
-
|
|
116
|
-
// Actions
|
|
117
|
-
payment.selectToken(token) // Select source token
|
|
118
|
-
payment.setAmount(amount) // Set amount
|
|
119
|
-
payment.getPreview() // Get quote preview
|
|
120
|
-
payment.execute() // Execute the payment
|
|
121
|
-
payment.reset() // Reset to initial state
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Core Functions
|
|
125
|
-
|
|
126
|
-
```tsx
|
|
127
|
-
import { initSuiport, getQuote, getExecutionStatus } from 'suiport-sdk'
|
|
128
|
-
|
|
129
|
-
// Initialize SDK (required once)
|
|
130
|
-
initSuiport({ apiKey: 'your-api-key' })
|
|
131
|
-
|
|
132
|
-
// Get a quote
|
|
133
|
-
const quote = await getQuote({
|
|
134
|
-
srcToken: 'base:usdc',
|
|
135
|
-
destToken: 'sui:usdc',
|
|
136
|
-
amount: '10000000', // 10 USDC (6 decimals)
|
|
137
|
-
recipient: '0x...',
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
// Check execution status
|
|
141
|
-
const status = await getExecutionStatus(quote.depositAddress, quote.memo)
|
|
142
|
-
```
|
|
143
|
-
|
|
144
55
|
## Supported Chains & Tokens
|
|
145
56
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
**
|
|
149
|
-
|
|
150
|
-
|
|
57
|
+
| Chain | Tokens |
|
|
58
|
+
|-------|--------|
|
|
59
|
+
| **Sui** (destination) | SUI, USDC |
|
|
60
|
+
| **Ethereum** | ETH, USDC, USDT, WBTC, DAI, AAVE, UNI, LINK, SHIB, PEPE, TURBO, SAFE |
|
|
61
|
+
| **Solana** | SOL, USDC, USDT, TRUMP, WIF, MELANIA |
|
|
62
|
+
| **Bitcoin** | BTC |
|
|
63
|
+
| **Optimism** | ETH, USDC, USDT, OP |
|
|
64
|
+
| **Base** | ETH, USDC, cbBTC, BRETT |
|
|
65
|
+
| **Polygon** | POL, USDC, USDT |
|
|
66
|
+
| **Arbitrum** | ETH, USDC, USDT, ARB, GMX |
|
|
67
|
+
| **Avalanche** | AVAX, USDC, USDT |
|
|
68
|
+
| **BSC** | BNB, USDC, USDT |
|
|
69
|
+
| **TON** | TON, USDT |
|
|
70
|
+
| **Tron** | TRX, USDT |
|
|
71
|
+
| **NEAR** | wNEAR, USDC, USDT |
|
|
72
|
+
| **Cardano** | ADA |
|
|
73
|
+
| **XRP Ledger** | XRP |
|
|
74
|
+
| **Dogecoin** | DOGE |
|
|
75
|
+
| **Litecoin** | LTC |
|
|
76
|
+
| **Bitcoin Cash** | BCH |
|
|
77
|
+
| **Aptos** | APT |
|
|
78
|
+
| **Starknet** | STRK |
|
|
79
|
+
| **Berachain** | BERA |
|
|
80
|
+
| **Zcash** | ZEC |
|
|
151
81
|
|
|
152
82
|
## Features
|
|
153
83
|
|
|
154
|
-
- 🌐 Accept payments from
|
|
155
|
-
- ⚡
|
|
84
|
+
- 🌐 Accept payments from 21+ blockchains
|
|
85
|
+
- ⚡ Sub-minute settlement via NEAR Intents
|
|
156
86
|
- 💎 Premium glassmorphism UI
|
|
157
|
-
- 🔧 Fully customizable via hooks
|
|
158
87
|
- 📱 Mobile-responsive modal
|
|
88
|
+
- 🔧 Zero wallet connection required from payers
|
|
89
|
+
|
|
90
|
+
## Advanced Usage
|
|
91
|
+
|
|
92
|
+
For custom implementations, the SDK also exports `SuiportModal`, `useSuiportPayment` hook, and core functions like `getQuote` and `getExecutionStatus`. See the source code for details.
|
|
159
93
|
|
|
160
94
|
## License
|
|
161
95
|
|