diff --git a/docs/broadcast-payload.md b/docs/broadcast-payload.md index 4de8039..ae3070c 100644 --- a/docs/broadcast-payload.md +++ b/docs/broadcast-payload.md @@ -6,7 +6,7 @@ This document describes the structure of the payload that is sent to the broadca The broadcast server receives a payload with the following structure: -```typescript +````typescript interface BroadcastRequest { chainId: string; compact: CompactMessage; @@ -117,17 +117,18 @@ Example endpoint structure: ```typescript app.post('/broadcast', async (req, res) => { const { compact, sponsorSignature, allocatorSignature, context } = req.body; - + // Validate signatures and process swap // ... res.json({ success: true }); }); -``` +```` ## EIP-712 Type Definition The Compact payload follows this exact EIP-712 type structure: + ```solidity Compact { address arbiter; @@ -150,4 +151,4 @@ Mandate { uint256 scalingFactor; bytes32 salt; } -``` \ No newline at end of file +``` diff --git a/eslint.config.js b/eslint.config.js index 092408a..c973d7f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,8 +1,8 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' +import js from '@eslint/js'; +import globals from 'globals'; +import reactHooks from 'eslint-plugin-react-hooks'; +import reactRefresh from 'eslint-plugin-react-refresh'; +import tseslint from 'typescript-eslint'; export default tseslint.config( { ignores: ['dist'] }, @@ -19,10 +19,7 @@ export default tseslint.config( }, rules: { ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], + 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], }, - }, -) + } +); diff --git a/index.html b/index.html index de81d00..a1b271c 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,10 @@ - + CompactX diff --git a/package.json b/package.json index a2bc14c..05331fa 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "compactx", - "private": true, - "version": "0.0.0", + "author": "0age", + "version": "0.0.1", "type": "module", "scripts": { "dev": "vite", "build": "tsc && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint . --max-warnings 0", "preview": "vite preview", "test": "dotenv -e .env.test -- vitest run", "test:watch": "vitest", diff --git a/postcss.config.cjs b/postcss.config.cjs index 33ad091..12a703d 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -3,4 +3,4 @@ module.exports = { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/src/api/broadcast.ts b/src/api/broadcast.ts index 107e087..5649dd0 100644 --- a/src/api/broadcast.ts +++ b/src/api/broadcast.ts @@ -260,9 +260,9 @@ export class BroadcastApiClient { } catch (error) { if (error instanceof Error) { // Enhance error message with more context - const context = error.message.includes('signature') ? - ' Please try again or check your wallet connection.' : - ' This may be due to network issues or the broadcast service being unavailable.'; + const context = error.message.includes('signature') + ? ' Please try again or check your wallet connection.' + : ' This may be due to network issues or the broadcast service being unavailable.'; throw new Error(error.message + context); } throw new Error('Failed to broadcast message. Please try again later.'); diff --git a/src/api/smallocator.ts b/src/api/smallocator.ts index 1b7239a..060c6cd 100644 --- a/src/api/smallocator.ts +++ b/src/api/smallocator.ts @@ -284,7 +284,10 @@ export class SmallocatorClient { * @param chainId - The chain ID * @param lockId - The resource lock ID */ - async getResourceLockBalance(chainId: string | number, lockId: string): Promise { + async getResourceLockBalance( + chainId: string | number, + lockId: string + ): Promise { return this.request('GET', `/balance/${chainId}/${lockId}`); } @@ -300,22 +303,22 @@ export class SmallocatorClient { // Use the compact.id as the resource lock ID const lockId = request.compact.id; - + // Get current balance const balance = await this.getResourceLockBalance(request.chainId, lockId); - + // Check if there's enough available balance const requiredAmount = BigInt(request.compact.amount); const availableBalance = BigInt(balance.balanceAvailableToAllocate); - + // Always log the balance check results console.log('Balance check:', { required: requiredAmount.toString(), available: availableBalance.toString(), isDepositAndSwap: options.isDepositAndSwap, - witnessTypeString: request.compact.witnessTypeString + witnessTypeString: request.compact.witnessTypeString, }); - + if (availableBalance < requiredAmount) { const error = `Insufficient balance available to allocate. Required: ${requiredAmount.toString()}, Available: ${availableBalance.toString()}`; console.error(error); diff --git a/src/components/AddCustomToken.tsx b/src/components/AddCustomToken.tsx index f8fe5a6..3b04219 100644 --- a/src/components/AddCustomToken.tsx +++ b/src/components/AddCustomToken.tsx @@ -32,21 +32,21 @@ export function AddCustomToken() { const validateForm = (): boolean => { const errors: Partial> = {}; - + if (!formValues.address) { errors.address = 'Please input token address'; } else if (!isAddress(formValues.address)) { errors.address = 'Invalid address'; } - + if (!formValues.name) { errors.name = 'Please input token name'; } - + if (!formValues.symbol) { errors.symbol = 'Please input token symbol'; } - + if (!formValues.decimals) { errors.decimals = 'Please input token decimals'; } else if (formValues.decimals < 0 || formValues.decimals > 18) { @@ -89,12 +89,14 @@ export function AddCustomToken() {

Add Custom Token

-
@@ -107,7 +109,7 @@ export function AddCustomToken() { setFormValues(prev => ({ ...prev, address: e.target.value }))} + onChange={e => setFormValues(prev => ({ ...prev, address: e.target.value }))} placeholder="0x..." className="w-full px-3 py-2 bg-[#1a1a1a] border border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#00ff00]/50 text-white" /> @@ -117,29 +119,23 @@ export function AddCustomToken() {
- + setFormValues(prev => ({ ...prev, name: e.target.value }))} + onChange={e => setFormValues(prev => ({ ...prev, name: e.target.value }))} placeholder="Token Name" className="w-full px-3 py-2 bg-[#1a1a1a] border border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#00ff00]/50 text-white" /> - {formErrors.name && ( -

{formErrors.name}

- )} + {formErrors.name &&

{formErrors.name}

}
- + setFormValues(prev => ({ ...prev, symbol: e.target.value }))} + onChange={e => setFormValues(prev => ({ ...prev, symbol: e.target.value }))} placeholder="TOKEN" className="w-full px-3 py-2 bg-[#1a1a1a] border border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#00ff00]/50 text-white" /> @@ -149,13 +145,13 @@ export function AddCustomToken() {
- + setFormValues(prev => ({ ...prev, decimals: Number(e.target.value) }))} + onChange={e => + setFormValues(prev => ({ ...prev, decimals: Number(e.target.value) })) + } placeholder="18" min="0" max="18" @@ -177,13 +173,7 @@ export function AddCustomToken() {
)} - {toast && ( - - )} + {toast && } ); } diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index 2e946c9..314a969 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -20,13 +20,16 @@ export function Modal({ title, open, onClose, children }: ModalProps) { className="text-gray-400 hover:text-gray-300 transition-colors" > - + -
- {children} -
+
{children}
diff --git a/src/components/NumberInput.tsx b/src/components/NumberInput.tsx index 786ac69..d369496 100644 --- a/src/components/NumberInput.tsx +++ b/src/components/NumberInput.tsx @@ -25,7 +25,7 @@ export function NumberInput({ }: NumberInputProps) { const handleChange = (e: React.ChangeEvent) => { const val = e.target.value; - + // Allow empty input if (!val) { onChange(''); @@ -60,10 +60,10 @@ export function NumberInput({ onChange(val); }; - const baseClasses = "w-full px-3 py-2 bg-[#1a1a1a] text-white focus:outline-none focus:ring-2 focus:ring-[#00ff00]/50"; - const variantClasses = variant === 'borderless' - ? "border-0" - : "border border-gray-700 rounded-lg"; + const baseClasses = + 'w-full px-3 py-2 bg-[#1a1a1a] text-white focus:outline-none focus:ring-2 focus:ring-[#00ff00]/50'; + const variantClasses = + variant === 'borderless' ? 'border-0' : 'border border-gray-700 rounded-lg'; return ( ({ columns = 1, }: SegmentedControlProps) { const isGrid = columns > 1; - + return ( -
- {options.map((option) => { + {options.map(option => { const isSelected = value === option.value; return (
({ className={` px-3 py-1.5 text-[0.75rem] rounded-md whitespace-nowrap cursor-pointer flex items-center justify-center - ${isSelected - ? 'bg-[#00ff00]/10 text-[#00ff00] border border-[#00ff00]/30' - : 'bg-[#111111] text-gray-500 hover:text-gray-400 border border-gray-800' + ${ + isSelected + ? 'bg-[#00ff00]/10 text-[#00ff00] border border-[#00ff00]/30' + : 'bg-[#111111] text-gray-500 hover:text-gray-400 border border-gray-800' } `} > diff --git a/src/components/Select.tsx b/src/components/Select.tsx index 1c170ae..8e25ea6 100644 --- a/src/components/Select.tsx +++ b/src/components/Select.tsx @@ -43,11 +43,7 @@ export function Select({ const selectedOption = options.find(option => String(option.value) === String(value)); return ( -
+