near-react-swap-widget 1.0.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 +52 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# near-react-swap-widget
|
|
2
|
+
|
|
3
|
+
A React component for swapping tokens on the NEAR blockchain.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
npm install near-react-swap-widget
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
import { NearReactSwapWidget } from 'near-react-swap-widget'
|
|
12
|
+
|
|
13
|
+
function App() {
|
|
14
|
+
return (
|
|
15
|
+
<NearReactSwapWidget
|
|
16
|
+
defaultFromToken="NEAR"
|
|
17
|
+
defaultToToken="USDC"
|
|
18
|
+
accountId="alice.near"
|
|
19
|
+
theme="light"
|
|
20
|
+
onSwap={(from, to, amount) => {
|
|
21
|
+
console.log(`Swapping ${amount} ${from} → ${to}`)
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
## Props
|
|
28
|
+
|
|
29
|
+
| Prop | Type | Default | Description |
|
|
30
|
+
|------|------|---------|-------------|
|
|
31
|
+
| `className` | `string` | — | CSS class name for the widget container |
|
|
32
|
+
| `style` | `React.CSSProperties` | — | Inline styles for the widget container |
|
|
33
|
+
| `defaultFromToken` | `string` | `"NEAR"` | Token to swap from |
|
|
34
|
+
| `defaultToToken` | `string` | `"USDC"` | Token to swap to |
|
|
35
|
+
| `accountId` | `string` | — | NEAR account ID of the user |
|
|
36
|
+
| `onSwap` | `(from: string, to: string, amount: string) => void` | — | Callback fired when a swap is initiated |
|
|
37
|
+
| `theme` | `'light' \| 'dark'` | — | Color theme of the widget |
|
|
38
|
+
|
|
39
|
+
## Example with Dark Theme
|
|
40
|
+
|
|
41
|
+
<NearReactSwapWidget
|
|
42
|
+
defaultFromToken="NEAR"
|
|
43
|
+
defaultToToken="USDT"
|
|
44
|
+
theme="dark"
|
|
45
|
+
onSwap={(from, to, amount) => {
|
|
46
|
+
console.log(from, to, amount)
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "near-react-swap-widget",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "npm Package - @near-react/swap-widget",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest --passWithNoTests"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"near",
|
|
11
|
+
"blockchain",
|
|
12
|
+
"web3"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"near-api-js": "^4.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.0.0",
|
|
20
|
+
"@types/node": "^20.0.0",
|
|
21
|
+
"@types/react": "^18.0.0",
|
|
22
|
+
"@types/react-dom": "^18.0.0",
|
|
23
|
+
"jest": "^29.0.0",
|
|
24
|
+
"@types/jest": "^29.0.0",
|
|
25
|
+
"ts-jest": "^29.0.0"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=17.0.0",
|
|
33
|
+
"react-dom": ">=17.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|