-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,621 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...rontend/components/ImageDisplay/index.tsx → ...nts/Agents/Imagen/ImageDisplayMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../components/ClaimMessage/ClaimMessage.tsx → ...ponents/Agents/MorClaims/ClaimMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
submodules/moragents_dockers/frontend/components/Agents/Swaps/useSwapTransaction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { useState, useCallback } from "react"; | ||
import { useAccount, useChainId, useSendTransaction } from "wagmi"; | ||
import { sendSwapStatus } from "@/services/apiHooks"; | ||
import { getHttpClient, SWAP_STATUS } from "@/services/constants"; | ||
import { SwapTxPayloadType } from "@/services/types"; | ||
|
||
export const useSwapTransaction = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [txHash, setTxHash] = useState(""); | ||
const { address } = useAccount(); | ||
const chainId = useChainId(); | ||
const { sendTransaction } = useSendTransaction(); | ||
|
||
const handleSwap = useCallback( | ||
async (swapTx: SwapTxPayloadType) => { | ||
if (!address) return; | ||
|
||
setIsLoading(true); | ||
setTxHash(""); | ||
|
||
try { | ||
sendTransaction( | ||
{ | ||
account: address, | ||
data: (swapTx?.tx.data || "0x") as `0x${string}`, | ||
to: (swapTx?.tx.to || "0x") as `0x${string}`, | ||
value: BigInt(swapTx?.tx.value || "0"), | ||
}, | ||
{ | ||
onSuccess: async (hash) => { | ||
setTxHash(hash); | ||
await sendSwapStatus( | ||
getHttpClient(), | ||
chainId, | ||
address.toLowerCase(), | ||
SWAP_STATUS.INIT, | ||
hash, | ||
0 | ||
); | ||
}, | ||
onError: async (error) => { | ||
console.error(`Error sending transaction: ${error}`); | ||
await sendSwapStatus( | ||
getHttpClient(), | ||
chainId, | ||
address.toLowerCase(), | ||
SWAP_STATUS.FAIL, | ||
"", | ||
0 | ||
); | ||
}, | ||
onSettled: () => setIsLoading(false), | ||
} | ||
); | ||
} catch (error) { | ||
setIsLoading(false); | ||
console.error("Swap failed:", error); | ||
} | ||
}, | ||
[address, chainId, sendTransaction] | ||
); | ||
|
||
const handleCancel = useCallback( | ||
async (fromAction: number) => { | ||
if (!address) return; | ||
|
||
setIsLoading(true); | ||
try { | ||
await sendSwapStatus( | ||
getHttpClient(), | ||
chainId, | ||
address, | ||
SWAP_STATUS.CANCELLED, | ||
"", | ||
fromAction | ||
); | ||
} catch (error) { | ||
console.error(`Failed to cancel swap: ${error}`); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}, | ||
[address, chainId] | ||
); | ||
|
||
return { | ||
handleSwap, | ||
handleCancel, | ||
isLoading, | ||
txHash, | ||
}; | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
submodules/moragents_dockers/frontend/components/CDPWallets/CreateWalletForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from "react"; | ||
import { | ||
VStack, | ||
FormControl, | ||
FormLabel, | ||
Input, | ||
Select, | ||
Button, | ||
} from "@chakra-ui/react"; | ||
import styles from "./index.module.css"; | ||
interface CreateWalletFormProps { | ||
walletName: string; | ||
selectedNetwork: string; | ||
networks: string[]; | ||
onWalletNameChange: (value: string) => void; | ||
onNetworkChange: (value: string) => void; | ||
onSubmit: () => void; | ||
} | ||
|
||
export const CreateWalletForm: React.FC<CreateWalletFormProps> = ({ | ||
walletName, | ||
selectedNetwork, | ||
networks, | ||
onWalletNameChange, | ||
onNetworkChange, | ||
onSubmit, | ||
}) => ( | ||
<VStack spacing={4} className={styles.createWalletForm}> | ||
<FormControl> | ||
<FormLabel className={styles.formLabel}>Wallet Name</FormLabel> | ||
<Input | ||
className={styles.input} | ||
placeholder="Enter wallet name" | ||
value={walletName} | ||
onChange={(e) => onWalletNameChange(e.target.value)} | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<FormLabel className={styles.formLabel}>Network</FormLabel> | ||
<Select | ||
className={styles.select} | ||
value={selectedNetwork} | ||
onChange={(e) => onNetworkChange(e.target.value)} | ||
> | ||
{networks.map((network) => ( | ||
<option key={network} value={network}> | ||
{network} | ||
</option> | ||
))} | ||
</Select> | ||
</FormControl> | ||
<Button className={styles.submitButton} onClick={onSubmit}> | ||
Create Wallet | ||
</Button> | ||
</VStack> | ||
); |
Oops, something went wrong.