aegis-swap-widget 0.3.2 → 0.3.4
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/CHANGELOG.md +37 -0
- package/README.md +114 -43
- package/dist/abis.d.ts +0 -73
- package/dist/aegis-swap-widget.js +3468 -2344
- package/dist/config/chains.d.ts +11 -0
- package/dist/config/constants.d.ts +8 -0
- package/dist/config/contracts.d.ts +6 -0
- package/dist/config/createMarket.d.ts +3 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/markets.d.ts +3 -0
- package/dist/config/tokens.d.ts +11 -0
- package/dist/{config.d.ts → config/types.d.ts} +5 -26
- package/dist/core.d.ts +3 -15
- package/dist/core.js +4 -64
- package/dist/encoding.d.ts +0 -29
- package/dist/hooks/useSubmitSwap.d.ts +11 -29
- package/dist/hooks/useSwapQuote.d.ts +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/markets-LIeOtFf_.js +229 -0
- package/dist/permit.d.ts +1 -47
- package/dist/quote/aggregatedSwapQuote.d.ts +5 -0
- package/dist/services/kyberSwap.d.ts +84 -0
- package/dist/styles.css +1 -1
- package/dist/types/aggregatedSwap.d.ts +29 -0
- package/dist/widget/AegisAggregatedSwapWidget.d.ts +3 -0
- package/dist/widget/AmountField.d.ts +5 -1
- package/dist/widget/SwapWidgetShell.d.ts +51 -0
- package/dist/widget/TokenSelector.d.ts +13 -0
- package/dist/widget/types.d.ts +23 -2
- package/dist/widget/useAggregatedSwapController.d.ts +74 -0
- package/dist/widget/useRailAutoReset.d.ts +11 -0
- package/dist/widget/useStatusSurface.d.ts +32 -0
- package/dist/widget/useSwapController.d.ts +13 -14
- package/dist/widget/useWidgetStyle.d.ts +13 -0
- package/dist/widget/viewState.d.ts +21 -1
- package/package.json +23 -21
- package/dist/polling-BI4pZg8Z.js +0 -1252
- package/dist/swap/authorizePermit.d.ts +0 -30
- package/dist/swap/executeSwapTransaction.d.ts +0 -39
- package/dist/swap/types.d.ts +0 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import { type AegisSwapChainConfig } from '../config';
|
|
3
|
+
import { type AegisSwapStatusSnapshot, type SubmitStatus } from '../transactionProgress';
|
|
4
|
+
import type { AegisSwapStatusSurface } from './types';
|
|
5
|
+
export type UseStatusSurfaceParams = {
|
|
6
|
+
status: SubmitStatus;
|
|
7
|
+
txHash: Hex | null;
|
|
8
|
+
actionError: string | null;
|
|
9
|
+
inputSymbol: string;
|
|
10
|
+
approvalRequired: boolean;
|
|
11
|
+
approvalDone: boolean;
|
|
12
|
+
authorizationRequired: boolean;
|
|
13
|
+
statusSurface: AegisSwapStatusSurface;
|
|
14
|
+
activeChain: AegisSwapChainConfig;
|
|
15
|
+
onStatusChange?: (snapshot: AegisSwapStatusSnapshot) => void;
|
|
16
|
+
successDescription: string | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Shared status-surface wiring for both swap controllers: derives the progress
|
|
20
|
+
* view + state, the rail/toast visibility flags, and the explorer URL (with the
|
|
21
|
+
* `'#'` fallback guarded to null), then mirrors lifecycle snapshots to the host
|
|
22
|
+
* and drives the lifecycle toast. Deliberately scoped to the genuinely-shared
|
|
23
|
+
* core — `approvalHint` and the tx-receipt summary stay in each controller
|
|
24
|
+
* because they diverge between the direct and aggregated variants.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useStatusSurface({ status, txHash, actionError, inputSymbol, approvalRequired, approvalDone, authorizationRequired, statusSurface, activeChain, onStatusChange, successDescription }: UseStatusSurfaceParams): {
|
|
27
|
+
progress: import("../transactionProgress").TransactionProgressView | null;
|
|
28
|
+
progressState: import("..").TransactionProgressState | null;
|
|
29
|
+
showRail: boolean;
|
|
30
|
+
showToast: boolean;
|
|
31
|
+
explorerUrl: string | null;
|
|
32
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type KeyboardEvent } from 'react';
|
|
2
2
|
import { type AegisSwapMarket } from '../config';
|
|
3
3
|
import { type AegisSwapApprovalMode } from '../hooks/useSubmitSwap';
|
|
4
|
-
import type { AegisDirectSwapWidgetProps,
|
|
4
|
+
import type { AegisDirectSwapWidgetProps, SwapDirection } from './types';
|
|
5
5
|
import { type ExecutionDetailsView, type LatestTransactionSummary } from './viewState';
|
|
6
6
|
/**
|
|
7
7
|
* Owns the entire swap form: configuration derivation, hook orchestration,
|
|
@@ -11,9 +11,9 @@ import { type ExecutionDetailsView, type LatestTransactionSummary } from './view
|
|
|
11
11
|
* isolation through `renderHook`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function useSwapController(props: AegisDirectSwapWidgetProps): {
|
|
14
|
-
rootRef: import("react").
|
|
14
|
+
rootRef: import("react").RefObject<HTMLElement | null>;
|
|
15
15
|
resolvedThemeMode: import("../hooks/useResolvedTheme").ResolvedThemeMode;
|
|
16
|
-
widgetStyle: AegisSwapWidgetStyle;
|
|
16
|
+
widgetStyle: import("./types").AegisSwapWidgetStyle;
|
|
17
17
|
className: string | undefined;
|
|
18
18
|
ariaLabel: string;
|
|
19
19
|
title: string;
|
|
@@ -28,21 +28,21 @@ export declare function useSwapController(props: AegisDirectSwapWidgetProps): {
|
|
|
28
28
|
showExecutionDetails: boolean;
|
|
29
29
|
showPoolLink: boolean;
|
|
30
30
|
showApprovalMode: boolean;
|
|
31
|
-
progress: import("
|
|
31
|
+
progress: import("../transactionProgress").TransactionProgressView | null;
|
|
32
32
|
progressState: import("..").TransactionProgressState | null;
|
|
33
33
|
poolIds: string[];
|
|
34
34
|
activePoolId: string;
|
|
35
35
|
marketMap: Record<string, AegisSwapMarket>;
|
|
36
|
-
metadataByAddress: import("
|
|
37
|
-
poolButtonRefs: import("react").
|
|
36
|
+
metadataByAddress: import("../metadata").TokenMetadataByAddress;
|
|
37
|
+
poolButtonRefs: import("react").RefObject<Map<string, HTMLButtonElement | null>>;
|
|
38
38
|
onSelectPool: (poolId: string) => void;
|
|
39
39
|
onPoolKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
40
|
-
activeChain: import("
|
|
40
|
+
activeChain: import("../config").AegisSwapChainConfig;
|
|
41
41
|
networkOptions: import("./types").AegisSwapNetworkOption[] | undefined;
|
|
42
42
|
hasAvailablePools: boolean;
|
|
43
43
|
balances: import("../hooks/useTokenBalances").BalanceState;
|
|
44
44
|
sellInputId: string;
|
|
45
|
-
inputToken: import("
|
|
45
|
+
inputToken: import("../config").AegisSwapToken;
|
|
46
46
|
sellFieldValue: string;
|
|
47
47
|
sellInvalid: boolean;
|
|
48
48
|
sellRefreshEnabled: boolean;
|
|
@@ -53,7 +53,7 @@ export declare function useSwapController(props: AegisDirectSwapWidgetProps): {
|
|
|
53
53
|
market: AegisSwapMarket | null;
|
|
54
54
|
onFlipDirection: () => void;
|
|
55
55
|
buyInputId: string;
|
|
56
|
-
outputToken: import("
|
|
56
|
+
outputToken: import("../config").AegisSwapToken;
|
|
57
57
|
buyFieldValue: string;
|
|
58
58
|
buyInvalid: boolean;
|
|
59
59
|
buyRefreshEnabled: boolean;
|
|
@@ -77,20 +77,19 @@ export declare function useSwapController(props: AegisDirectSwapWidgetProps): {
|
|
|
77
77
|
onSlippageBlur: () => void;
|
|
78
78
|
approvalMode: AegisSwapApprovalMode;
|
|
79
79
|
onApprovalModeChange: import("react").Dispatch<import("react").SetStateAction<AegisSwapApprovalMode>>;
|
|
80
|
-
counterToken: import("
|
|
81
|
-
targetToken: import("
|
|
80
|
+
counterToken: import("../config").AegisSwapToken;
|
|
81
|
+
targetToken: import("../config").AegisSwapToken;
|
|
82
82
|
poolUrl: string | null;
|
|
83
83
|
onCopyPoolId: () => Promise<void>;
|
|
84
84
|
routePoolCopied: boolean;
|
|
85
|
-
status: import("
|
|
85
|
+
status: import("@aegis-engine/core").SubmitStatus;
|
|
86
86
|
txHash: `0x${string}` | null;
|
|
87
|
-
quote: import("
|
|
87
|
+
quote: import("../quote").DirectSwapQuote | null;
|
|
88
88
|
quoteError: string | null;
|
|
89
89
|
quoteLoading: boolean;
|
|
90
90
|
actionError: string | null;
|
|
91
91
|
allowanceError: string | null;
|
|
92
92
|
inlineTxExplorerHref: string | null;
|
|
93
|
-
txExplorerHref: string | null;
|
|
94
93
|
approvalHint: string | null;
|
|
95
94
|
txSummary: LatestTransactionSummary | null;
|
|
96
95
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AegisSwapWidgetStyle } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Shared accent → CSS-variable derivation for both swap controllers. Writes
|
|
4
|
+
* `--aegis-swap-accent` from `accentColor` and derives a readable
|
|
5
|
+
* `--aegis-swap-accent-text` (pickReadableTextColor) unless the host supplies
|
|
6
|
+
* `accentTextColor`. Stabilizes the incoming host `style` so inline objects
|
|
7
|
+
* don't reset the memo every render.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useWidgetStyle({ accentColor, accentTextColor, style }: {
|
|
10
|
+
accentColor?: string;
|
|
11
|
+
accentTextColor?: string;
|
|
12
|
+
style?: AegisSwapWidgetStyle;
|
|
13
|
+
}): AegisSwapWidgetStyle;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
2
|
import type { DirectSwapQuote } from '../quote';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AggregatedSwapQuote } from '../types/aggregatedSwap';
|
|
4
|
+
import type { AegisSwapReceiptSummary, SubmitStatus } from '../transactionProgress';
|
|
4
5
|
import type { AegisSwapWidgetDirection, SwapDirection } from './types';
|
|
6
|
+
export declare function readRailResetDelayMs(root: HTMLElement | null): number;
|
|
5
7
|
export declare function normalizeWidgetDirection(direction?: AegisSwapWidgetDirection): SwapDirection;
|
|
6
8
|
export declare function formatRoutePoolId(poolId: Hex): string;
|
|
7
9
|
export declare function nextRovingIndex(key: string, currentIndex: number, count: number): number | null;
|
|
@@ -63,3 +65,21 @@ export declare function getTradeDetailRows({ quote, inputSymbol, inputDecimals,
|
|
|
63
65
|
outputSymbol: string;
|
|
64
66
|
outputDecimals: number;
|
|
65
67
|
}): TradeDetailRow[];
|
|
68
|
+
export declare function getAggregatedTradeDetailRows({ quote, inputSymbol, inputDecimals, outputSymbol, outputDecimals }: {
|
|
69
|
+
quote: AggregatedSwapQuote | null;
|
|
70
|
+
inputSymbol: string;
|
|
71
|
+
inputDecimals: number;
|
|
72
|
+
outputSymbol: string;
|
|
73
|
+
outputDecimals: number;
|
|
74
|
+
}): TradeDetailRow[];
|
|
75
|
+
export declare function buildTxReceiptSummary({ receiptSummary, quote, outputDecimals, outputSymbol, isSuccess, explorerUrl, nativeSymbol }: {
|
|
76
|
+
receiptSummary: AegisSwapReceiptSummary | null;
|
|
77
|
+
quote: {
|
|
78
|
+
amountOut: bigint;
|
|
79
|
+
} | null;
|
|
80
|
+
outputDecimals: number;
|
|
81
|
+
outputSymbol: string;
|
|
82
|
+
isSuccess: boolean;
|
|
83
|
+
explorerUrl: string | null;
|
|
84
|
+
nativeSymbol: string;
|
|
85
|
+
}): LatestTransactionSummary | null;
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegis-swap-widget",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Embeddable direct-pool Aegis swap widget for WATER, WOOD, GRASS, and STONE.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/amplifi-liquidity/aegis-widget.git"
|
|
9
|
-
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/amplifi-liquidity/aegis-widget/issues"
|
|
8
|
+
"url": "git+https://github.com/amplifi-liquidity/aegis-widget.git",
|
|
9
|
+
"directory": "packages/widget"
|
|
12
10
|
},
|
|
11
|
+
"bugs": "https://github.com/amplifi-liquidity/aegis-widget/issues",
|
|
13
12
|
"homepage": "https://github.com/amplifi-liquidity/aegis-widget#readme",
|
|
14
13
|
"keywords": [
|
|
15
14
|
"aegis",
|
|
@@ -45,18 +44,6 @@
|
|
|
45
44
|
"CHANGELOG.md",
|
|
46
45
|
"DESIGN.md"
|
|
47
46
|
],
|
|
48
|
-
"scripts": {
|
|
49
|
-
"dev": "vite",
|
|
50
|
-
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
51
|
-
"typecheck:test": "tsc -p tsconfig.test.json --noEmit",
|
|
52
|
-
"test": "vitest run",
|
|
53
|
-
"test:watch": "vitest",
|
|
54
|
-
"coverage": "vitest run --coverage",
|
|
55
|
-
"build": "vite build && tsc -p tsconfig.build.json",
|
|
56
|
-
"preview": "vite preview",
|
|
57
|
-
"prepack": "npm run build",
|
|
58
|
-
"prepublishOnly": "npm run typecheck && npm run typecheck:test && npm run test && npm run build"
|
|
59
|
-
},
|
|
60
47
|
"peerDependencies": {
|
|
61
48
|
"react": ">=18 <20",
|
|
62
49
|
"react-dom": ">=18 <20",
|
|
@@ -66,8 +53,8 @@
|
|
|
66
53
|
"@testing-library/react": "^16.3.2",
|
|
67
54
|
"@types/jsdom": "^28.0.3",
|
|
68
55
|
"@types/node": "^25.9.1",
|
|
69
|
-
"@types/react": "^
|
|
70
|
-
"@types/react-dom": "^
|
|
56
|
+
"@types/react": "^19",
|
|
57
|
+
"@types/react-dom": "^19",
|
|
71
58
|
"@vitejs/plugin-react": "^4.3.4",
|
|
72
59
|
"@vitest/coverage-v8": "^4.1.8",
|
|
73
60
|
"jsdom": "^29.1.1",
|
|
@@ -77,6 +64,21 @@
|
|
|
77
64
|
"vitest": "^4.1.8"
|
|
78
65
|
},
|
|
79
66
|
"dependencies": {
|
|
80
|
-
"lucide-react": "^0.562.0"
|
|
67
|
+
"lucide-react": "^0.562.0",
|
|
68
|
+
"@aegis-engine/core": "^0.1.2"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=22.14"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"dev": "vite",
|
|
75
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
76
|
+
"typecheck:test": "tsc -p tsconfig.test.json --noEmit",
|
|
77
|
+
"test": "vitest run",
|
|
78
|
+
"test:watch": "vitest",
|
|
79
|
+
"coverage": "vitest run --coverage",
|
|
80
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
81
|
+
"build:preview": "vite build --config vite.preview.config.ts",
|
|
82
|
+
"preview": "vite preview"
|
|
81
83
|
}
|
|
82
|
-
}
|
|
84
|
+
}
|