@coin-voyage/swapkit 0.1.0-beta.0 → 0.1.0-beta.1
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/dist/components/connected-wallets.d.ts +1 -0
- package/dist/components/connected-wallets.js +66 -0
- package/dist/components/execution-modal.d.ts +5 -0
- package/dist/components/execution-modal.js +79 -0
- package/dist/components/icons.d.ts +23 -0
- package/dist/components/icons.js +49 -0
- package/dist/components/modal.d.ts +11 -0
- package/dist/components/modal.js +40 -0
- package/dist/components/styles.d.ts +124 -0
- package/dist/components/styles.js +1239 -0
- package/dist/components/swap.d.ts +2 -0
- package/dist/components/swap.js +295 -0
- package/dist/components/token-icon.d.ts +5 -0
- package/dist/components/token-icon.js +9 -0
- package/dist/components/token-picker.d.ts +11 -0
- package/dist/components/token-picker.js +69 -0
- package/dist/components/wallet-connector.d.ts +8 -0
- package/dist/components/wallet-connector.js +33 -0
- package/dist/components/wallet-icon.d.ts +5 -0
- package/dist/components/wallet-icon.js +6 -0
- package/dist/hooks/use-order-status.d.ts +9 -0
- package/dist/hooks/use-order-status.js +36 -0
- package/dist/hooks/use-swap-execution.d.ts +7 -0
- package/dist/hooks/use-swap-execution.js +105 -0
- package/dist/hooks/use-swap-quote.d.ts +6 -0
- package/dist/hooks/use-swap-quote.js +63 -0
- package/dist/hooks/use-swap-state.d.ts +70 -0
- package/dist/hooks/use-swap-state.js +147 -0
- package/dist/hooks/use-token-data.d.ts +12 -0
- package/dist/hooks/use-token-data.js +80 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/lib/amount-input.d.ts +3 -0
- package/dist/lib/amount-input.js +11 -0
- package/dist/lib/currency-selection.d.ts +13 -0
- package/dist/lib/currency-selection.js +26 -0
- package/dist/lib/execution.d.ts +38 -0
- package/dist/lib/execution.js +26 -0
- package/dist/lib/output-wallet.d.ts +24 -0
- package/dist/lib/output-wallet.js +24 -0
- package/dist/lib/quote.d.ts +13 -0
- package/dist/lib/quote.js +24 -0
- package/dist/lib/version.d.ts +1 -0
- package/dist/lib/version.js +2 -0
- package/dist/providers/swapkit-context.d.ts +10 -0
- package/dist/providers/swapkit-context.js +8 -0
- package/dist/providers/swapkit-provider.d.ts +2 -0
- package/dist/providers/swapkit-provider.js +18 -0
- package/dist/styles/root.d.ts +5 -0
- package/dist/styles/root.js +75 -0
- package/dist/styles/styled.d.ts +2 -0
- package/dist/styles/styled.js +3 -0
- package/dist/styles/theme.d.ts +3 -0
- package/dist/styles/theme.js +36 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { css } from "styled-components";
|
|
2
|
+
import styled from "./styled";
|
|
3
|
+
import { darkTheme, lightTheme } from "./theme";
|
|
4
|
+
function variables(theme) {
|
|
5
|
+
return css `
|
|
6
|
+
--sk-font-family: ${theme.fontFamily};
|
|
7
|
+
--sk-background: ${theme.background};
|
|
8
|
+
--sk-surface: ${theme.surface};
|
|
9
|
+
--sk-surface-elevated: ${theme.surfaceElevated};
|
|
10
|
+
--sk-border: ${theme.border};
|
|
11
|
+
--sk-text: ${theme.text};
|
|
12
|
+
--sk-text-muted: ${theme.textMuted};
|
|
13
|
+
--sk-accent: ${theme.accent};
|
|
14
|
+
--sk-accent-hover: ${theme.accentHover};
|
|
15
|
+
--sk-accent-text: ${theme.accentText};
|
|
16
|
+
--sk-danger: ${theme.danger};
|
|
17
|
+
--sk-warning: ${theme.warning};
|
|
18
|
+
--sk-success: ${theme.success};
|
|
19
|
+
--sk-overlay: ${theme.overlay};
|
|
20
|
+
--sk-shadow: ${theme.shadow};
|
|
21
|
+
--sk-radius: ${theme.radius};
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
function modeVariables(mode, customTheme) {
|
|
25
|
+
const light = { ...lightTheme, ...customTheme };
|
|
26
|
+
const dark = { ...darkTheme, ...customTheme };
|
|
27
|
+
if (mode === "light")
|
|
28
|
+
return variables(light);
|
|
29
|
+
if (mode === "dark")
|
|
30
|
+
return variables(dark);
|
|
31
|
+
return css `
|
|
32
|
+
${variables(light)}
|
|
33
|
+
@media (prefers-color-scheme: dark) {
|
|
34
|
+
${variables(dark)}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
export const SwapKitRoot = styled.div `
|
|
39
|
+
${({ $mode, $customTheme }) => modeVariables($mode, $customTheme)}
|
|
40
|
+
|
|
41
|
+
all: initial;
|
|
42
|
+
display: block;
|
|
43
|
+
width: 100%;
|
|
44
|
+
color: var(--sk-text);
|
|
45
|
+
background: var(--sk-background);
|
|
46
|
+
font-family: var(--sk-font-family);
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
text-align: left;
|
|
49
|
+
text-rendering: optimizeLegibility;
|
|
50
|
+
-webkit-font-smoothing: antialiased;
|
|
51
|
+
|
|
52
|
+
&,
|
|
53
|
+
* {
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
font-family: var(--sk-font-family);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
button,
|
|
59
|
+
input {
|
|
60
|
+
font-family: var(--sk-font-family);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
button:focus-visible,
|
|
64
|
+
input:focus-visible,
|
|
65
|
+
a:focus-visible {
|
|
66
|
+
outline: 2px solid var(--sk-accent);
|
|
67
|
+
outline-offset: 2px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
img,
|
|
71
|
+
svg {
|
|
72
|
+
display: block;
|
|
73
|
+
max-width: 100%;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const lightTheme = {
|
|
2
|
+
fontFamily: `Roboto, Arial, Helvetica, sans-serif`,
|
|
3
|
+
background: "#f4f5f7",
|
|
4
|
+
surface: "#ffffff",
|
|
5
|
+
surfaceElevated: "#f7f8fa",
|
|
6
|
+
border: "#e4e7ec",
|
|
7
|
+
text: "#15181e",
|
|
8
|
+
textMuted: "#697386",
|
|
9
|
+
accent: "#866cff",
|
|
10
|
+
accentHover: "#7559f0",
|
|
11
|
+
accentText: "#ffffff",
|
|
12
|
+
danger: "#dc2626",
|
|
13
|
+
warning: "#d97706",
|
|
14
|
+
success: "#16a34a",
|
|
15
|
+
overlay: "rgba(15, 18, 25, 0.58)",
|
|
16
|
+
shadow: "0 18px 50px rgba(15, 18, 25, 0.16)",
|
|
17
|
+
radius: "12px",
|
|
18
|
+
};
|
|
19
|
+
export const darkTheme = {
|
|
20
|
+
fontFamily: lightTheme.fontFamily,
|
|
21
|
+
background: "hsl(180 6% 9%)",
|
|
22
|
+
surface: "hsl(180 5% 11%)",
|
|
23
|
+
surfaceElevated: "hsl(180 6% 9%)",
|
|
24
|
+
border: "hsl(180 7% 14%)",
|
|
25
|
+
text: "hsl(0 0% 100%)",
|
|
26
|
+
textMuted: "hsl(171 6% 53%)",
|
|
27
|
+
accent: "hsl(332 83% 60%)",
|
|
28
|
+
accentHover: "hsl(332 83% 56%)",
|
|
29
|
+
accentText: "#ffffff",
|
|
30
|
+
danger: "#f87171",
|
|
31
|
+
warning: "#fbbf24",
|
|
32
|
+
success: "#4ade80",
|
|
33
|
+
overlay: "rgba(0, 0, 0, 0.72)",
|
|
34
|
+
shadow: "0 18px 50px rgba(0, 0, 0, 0.5)",
|
|
35
|
+
radius: "12px",
|
|
36
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { APIEnvironment } from "@coin-voyage/shared/api";
|
|
2
|
+
import type { CurrencyBase } from "@coin-voyage/shared/types";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
export type SwapKitMode = "light" | "dark" | "auto";
|
|
5
|
+
export interface SwapKitTheme {
|
|
6
|
+
fontFamily: string;
|
|
7
|
+
background: string;
|
|
8
|
+
surface: string;
|
|
9
|
+
surfaceElevated: string;
|
|
10
|
+
border: string;
|
|
11
|
+
text: string;
|
|
12
|
+
textMuted: string;
|
|
13
|
+
accent: string;
|
|
14
|
+
accentHover: string;
|
|
15
|
+
accentText: string;
|
|
16
|
+
danger: string;
|
|
17
|
+
warning: string;
|
|
18
|
+
success: string;
|
|
19
|
+
overlay: string;
|
|
20
|
+
shadow: string;
|
|
21
|
+
radius: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SwapKitProviderProps {
|
|
24
|
+
apiKey: string;
|
|
25
|
+
environment?: APIEnvironment;
|
|
26
|
+
mode?: SwapKitMode;
|
|
27
|
+
theme?: Partial<SwapKitTheme>;
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export interface SwapCompleteResult {
|
|
31
|
+
orderId: string;
|
|
32
|
+
transactionHash: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SwapError {
|
|
35
|
+
message: string;
|
|
36
|
+
}
|
|
37
|
+
export type SwapCurrency = CurrencyBase;
|
|
38
|
+
export interface SwapProps {
|
|
39
|
+
defaultSourceCurrency?: SwapCurrency;
|
|
40
|
+
defaultDestinationCurrency?: SwapCurrency;
|
|
41
|
+
defaultSlippageBps?: number;
|
|
42
|
+
onComplete?: (result: SwapCompleteResult) => void;
|
|
43
|
+
onError?: (error: SwapError) => void;
|
|
44
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coin-voyage/swapkit",
|
|
3
3
|
"description": "A reusable cross-chain swap component for CoinVoyage.",
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "Lars <lars@coinvoyage.io>",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"clean": "rm -rf dist tsconfig.tsbuildinfo coverage",
|
|
62
62
|
"pre:release": "pnpm version prerelease --preid=beta",
|
|
63
63
|
"pre:publish": "pnpm publish --access public --tag beta --no-git-checks",
|
|
64
|
-
"pre:steps": "pnpm pre:release && pnpm
|
|
64
|
+
"pre:steps": "pnpm pre:release && pnpm pre:publish",
|
|
65
65
|
"release:build": "pnpm clean && pnpm build",
|
|
66
66
|
"release": "pnpm publish --access public --no-git-checks",
|
|
67
67
|
"type-check": "tsc --noEmit"
|