@coin-voyage/swapkit 0.1.0-beta.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/LICENSE +8 -0
- package/README.md +68 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright (c) 2026 Coin Voyage
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
7
|
+
|
|
8
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @coin-voyage/swapkit
|
|
2
|
+
|
|
3
|
+
Embeddable Coin Voyage swap UI for React applications. SwapKit uses styled-components and does not require Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @coin-voyage/swapkit @tanstack/react-query react react-dom styled-components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Install the wallet peer dependencies listed in this package's `package.json` for the chains your application supports.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Swap, SwapKitProvider, WalletProvider } from "@coin-voyage/swapkit"
|
|
17
|
+
|
|
18
|
+
export function App() {
|
|
19
|
+
return (
|
|
20
|
+
<WalletProvider>
|
|
21
|
+
<SwapKitProvider apiKey={process.env.NEXT_PUBLIC_COIN_VOYAGE_API_KEY!} environment="development" mode="dark">
|
|
22
|
+
<Swap
|
|
23
|
+
defaultSourceCurrency={{ chain_id: 1 }}
|
|
24
|
+
defaultDestinationCurrency={{
|
|
25
|
+
chain_id: 30000000000001,
|
|
26
|
+
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
</SwapKitProvider>
|
|
30
|
+
</WalletProvider>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`SwapKitProvider` deliberately uses the public API client and never accepts an admin signing key. It must be rendered
|
|
36
|
+
inside `WalletProvider`, which SwapKit re-exports from its canonical implementation in `@coin-voyage/crypto/wallets`.
|
|
37
|
+
The wallet provider supplies React Query and the supported chain contexts, while reusing a compatible host Query
|
|
38
|
+
Client when one already exists.
|
|
39
|
+
|
|
40
|
+
`Swap` optionally accepts `defaultSourceCurrency`, `defaultDestinationCurrency`, and `defaultSlippageBps`, plus
|
|
41
|
+
`onComplete` and `onError` callbacks for host notifications. Currency defaults use `{ chain_id, address? }`; token
|
|
42
|
+
addresses are matched case-insensitively. Slippage is an integer from `0` to `10000` basis points.
|
|
43
|
+
|
|
44
|
+
When `defaultSlippageBps` is omitted, slippage starts in Auto mode and SwapKit lets the quote service choose the
|
|
45
|
+
appropriate tolerance. The custom control retains a `1%` draft. Supplying `defaultSlippageBps` starts the widget in
|
|
46
|
+
Custom mode and sends that value with quote and execution requests.
|
|
47
|
+
|
|
48
|
+
Defaults are read once when a widget mounts. Changing them later does not interrupt an in-progress swap; remount the
|
|
49
|
+
widget with a new React `key` to apply a new set of defaults. Unsupported defaults fall back to the normal automatic
|
|
50
|
+
selection.
|
|
51
|
+
|
|
52
|
+
### Theming
|
|
53
|
+
|
|
54
|
+
Use `mode="light"` or `mode="dark"`. The optional `theme` prop overrides individual widget colors:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<SwapKitProvider apiKey={apiKey} mode="dark" theme={{ accent: "#7c3aed", radius: "18px" }}>
|
|
58
|
+
<Swap />
|
|
59
|
+
</SwapKitProvider>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
pnpm --filter @coin-voyage/swapkit test
|
|
66
|
+
pnpm --filter @coin-voyage/swapkit type-check
|
|
67
|
+
pnpm --filter @coin-voyage/swapkit build
|
|
68
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coin-voyage/swapkit",
|
|
3
|
+
"description": "A reusable cross-chain swap component for CoinVoyage.",
|
|
4
|
+
"version": "0.1.0-beta.0",
|
|
5
|
+
"private": false,
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"author": "Lars <lars@coinvoyage.io>",
|
|
8
|
+
"homepage": "https://coinvoyage.io",
|
|
9
|
+
"license": "BSD-2-Clause",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@coin-voyage/shared": "3.4.1-beta.0",
|
|
26
|
+
"@coin-voyage/crypto": "3.3.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@testing-library/react": "^16.3.0",
|
|
30
|
+
"@testing-library/user-event": "^14.6.1",
|
|
31
|
+
"@types/styled-components": "^5.1.36",
|
|
32
|
+
"@vitest/coverage-v8": "3.2.0",
|
|
33
|
+
"jsdom": "^26.1.0",
|
|
34
|
+
"react": "19.2.6",
|
|
35
|
+
"react-dom": "19.2.6",
|
|
36
|
+
"typescript-plugin-styled-components": "^3.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@bigmi/react": "^0.8.0",
|
|
40
|
+
"@mysten/dapp-kit-react": "^2.1.4",
|
|
41
|
+
"@solana/wallet-adapter-react": "^0.15.39",
|
|
42
|
+
"@tanstack/react-query": "^5.90.6",
|
|
43
|
+
"react": "^18 || ^19",
|
|
44
|
+
"react-dom": "^18 || ^19",
|
|
45
|
+
"styled-components": "^5.3.11",
|
|
46
|
+
"viem": "^2.55.10",
|
|
47
|
+
"wagmi": "^3.6.16"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"blockchain",
|
|
51
|
+
"swap",
|
|
52
|
+
"cross-chain",
|
|
53
|
+
"react",
|
|
54
|
+
"coin-voyage"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"watch": "tsc -w -p ./tsconfig.json",
|
|
58
|
+
"build": "tsc --build --force",
|
|
59
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
60
|
+
"test:coverage": "vitest run --coverage --maxWorkers=1 --no-file-parallelism --config ./vitest.config.ts",
|
|
61
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo coverage",
|
|
62
|
+
"pre:release": "pnpm version prerelease --preid=beta",
|
|
63
|
+
"pre:publish": "pnpm publish --access public --tag beta --no-git-checks",
|
|
64
|
+
"pre:steps": "pnpm pre:release && pnpm release:build && pnpm pre:publish",
|
|
65
|
+
"release:build": "pnpm clean && pnpm build",
|
|
66
|
+
"release": "pnpm publish --access public --no-git-checks",
|
|
67
|
+
"type-check": "tsc --noEmit"
|
|
68
|
+
}
|
|
69
|
+
}
|