diff --git a/.gas-snapshot b/.gas-snapshot index 3c644ac..5d47b59 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -3,11 +3,11 @@ IETest:testBalanceInETH() (gas: 40280) IETest:testCommandSendERC0() (gas: 102922) IETest:testCommandSendETH() (gas: 69404) IETest:testCommandSendUSDC() (gas: 118552) -IETest:testCommandSwapDAI() (gas: 105520) -IETest:testCommandSwapETH() (gas: 119728) -IETest:testCommandSwapForETH() (gas: 123983) -IETest:testCommandSwapUSDC() (gas: 164744) -IETest:testCommandSwapUSDCForWBTC() (gas: 166495) +IETest:testCommandSwapDAI() (gas: 105526) +IETest:testCommandSwapETH() (gas: 119716) +IETest:testCommandSwapForETH() (gas: 123988) +IETest:testCommandSwapUSDC() (gas: 165762) +IETest:testCommandSwapUSDCForWBTC() (gas: 166485) IETest:testDeploy() (gas: 2831664) IETest:testENSNameOwnership() (gas: 83841) IETest:testIENameSetting() (gas: 8142) diff --git a/.gitignore b/.gitignore index 7639b71..42c4870 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ cache ui/node_modules ui/.next -ui/.env \ No newline at end of file +ui/.env + +.env \ No newline at end of file diff --git a/ui/components/account.tsx b/ui/components/account.tsx index c1b78e9..2526e95 100644 --- a/ui/components/account.tsx +++ b/ui/components/account.tsx @@ -26,7 +26,7 @@ export const Account = () => { Connected to{" "} diff --git a/ui/components/version.tsx b/ui/components/version.tsx new file mode 100644 index 0000000..059410f --- /dev/null +++ b/ui/components/version.tsx @@ -0,0 +1,15 @@ +"use client"; +import { useAccount } from "wagmi"; + +const versions: { + [key: number]: string; +} = { + 1: "1.0.0", + 42161: "1.1.1 (nightly)", +}; + +export const Version = () => { + const { chain } = useAccount(); + + return {`[ Version ${versions[chain ? chain.id : 1]} ]`}; +}; diff --git a/ui/lib/abi/IntentsEngineAbiArb.ts b/ui/lib/abi/IntentsEngineAbiArb.ts new file mode 100644 index 0000000..000b698 --- /dev/null +++ b/ui/lib/abi/IntentsEngineAbiArb.ts @@ -0,0 +1,549 @@ +export const IntentsEngineAbiArb = [ + { + type: "constructor", + inputs: [], + stateMutability: "payable", + }, + { + type: "fallback", + stateMutability: "payable", + }, + { + type: "receive", + stateMutability: "payable", + }, + { + type: "function", + name: "checkPackedUserOp", + inputs: [ + { + name: "intent", + type: "string", + internalType: "string", + }, + { + name: "userOp", + type: "tuple", + internalType: "struct IE.PackedUserOperation", + components: [ + { + name: "sender", + type: "address", + internalType: "address", + }, + { + name: "nonce", + type: "uint256", + internalType: "uint256", + }, + { + name: "initCode", + type: "bytes", + internalType: "bytes", + }, + { + name: "callData", + type: "bytes", + internalType: "bytes", + }, + { + name: "accountGasLimits", + type: "bytes32", + internalType: "bytes32", + }, + { + name: "preVerificationGas", + type: "uint256", + internalType: "uint256", + }, + { + name: "gasFees", + type: "bytes32", + internalType: "bytes32", + }, + { + name: "paymasterAndData", + type: "bytes", + internalType: "bytes", + }, + { + name: "signature", + type: "bytes", + internalType: "bytes", + }, + ], + }, + ], + outputs: [ + { + name: "", + type: "bool", + internalType: "bool", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "checkUserOp", + inputs: [ + { + name: "intent", + type: "string", + internalType: "string", + }, + { + name: "userOp", + type: "tuple", + internalType: "struct IE.UserOperation", + components: [ + { + name: "sender", + type: "address", + internalType: "address", + }, + { + name: "nonce", + type: "uint256", + internalType: "uint256", + }, + { + name: "initCode", + type: "bytes", + internalType: "bytes", + }, + { + name: "callData", + type: "bytes", + internalType: "bytes", + }, + { + name: "callGasLimit", + type: "uint256", + internalType: "uint256", + }, + { + name: "verificationGasLimit", + type: "uint256", + internalType: "uint256", + }, + { + name: "preVerificationGas", + type: "uint256", + internalType: "uint256", + }, + { + name: "maxFeePerGas", + type: "uint256", + internalType: "uint256", + }, + { + name: "maxPriorityFeePerGas", + type: "uint256", + internalType: "uint256", + }, + { + name: "paymasterAndData", + type: "bytes", + internalType: "bytes", + }, + { + name: "signature", + type: "bytes", + internalType: "bytes", + }, + ], + }, + ], + outputs: [ + { + name: "", + type: "bool", + internalType: "bool", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "command", + inputs: [ + { + name: "intent", + type: "string", + internalType: "string", + }, + ], + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + name: "previewCommand", + inputs: [ + { + name: "intent", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "to", + type: "address", + internalType: "address", + }, + { + name: "amount", + type: "uint256", + internalType: "uint256", + }, + { + name: "minAmountOut", + type: "uint256", + internalType: "uint256", + }, + { + name: "token", + type: "address", + internalType: "address", + }, + { + name: "callData", + type: "bytes", + internalType: "bytes", + }, + { + name: "executeCallData", + type: "bytes", + internalType: "bytes", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "previewSend", + inputs: [ + { + name: "to", + type: "string", + internalType: "string", + }, + { + name: "amount", + type: "string", + internalType: "string", + }, + { + name: "token", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "_to", + type: "address", + internalType: "address", + }, + { + name: "_amount", + type: "uint256", + internalType: "uint256", + }, + { + name: "_token", + type: "address", + internalType: "address", + }, + { + name: "callData", + type: "bytes", + internalType: "bytes", + }, + { + name: "executeCallData", + type: "bytes", + internalType: "bytes", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "previewSwap", + inputs: [ + { + name: "amountIn", + type: "string", + internalType: "string", + }, + { + name: "amountOutMinimum", + type: "string", + internalType: "string", + }, + { + name: "tokenIn", + type: "string", + internalType: "string", + }, + { + name: "tokenOut", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "_amountIn", + type: "uint256", + internalType: "uint256", + }, + { + name: "_amountOut", + type: "uint256", + internalType: "uint256", + }, + { + name: "_tokenIn", + type: "address", + internalType: "address", + }, + { + name: "_tokenOut", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "send", + inputs: [ + { + name: "to", + type: "string", + internalType: "string", + }, + { + name: "amount", + type: "string", + internalType: "string", + }, + { + name: "token", + type: "string", + internalType: "string", + }, + ], + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + name: "setName", + inputs: [ + { + name: "token", + type: "address", + internalType: "address", + }, + { + name: "name", + type: "string", + internalType: "string", + }, + ], + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + name: "setNameAndTicker", + inputs: [ + { + name: "token", + type: "address", + internalType: "address", + }, + ], + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + name: "swap", + inputs: [ + { + name: "amountIn", + type: "string", + internalType: "string", + }, + { + name: "amountOutMinimum", + type: "string", + internalType: "string", + }, + { + name: "tokenIn", + type: "string", + internalType: "string", + }, + { + name: "tokenOut", + type: "string", + internalType: "string", + }, + ], + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + name: "tokens", + inputs: [ + { + name: "name", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "whatIsTheAddressOf", + inputs: [ + { + name: "name", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "owner", + type: "address", + internalType: "address", + }, + { + name: "receiver", + type: "address", + internalType: "address", + }, + { + name: "node", + type: "bytes32", + internalType: "bytes32", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "whatIsTheBalanceOf", + inputs: [ + { + name: "name", + type: "string", + internalType: "string", + }, + { + name: "token", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "balance", + type: "uint256", + internalType: "uint256", + }, + { + name: "balanceAdjusted", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "whatIsTheTotalSupplyOf", + inputs: [ + { + name: "token", + type: "string", + internalType: "string", + }, + ], + outputs: [ + { + name: "supply", + type: "uint256", + internalType: "uint256", + }, + { + name: "supplyAdjusted", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "event", + name: "NameSet", + inputs: [ + { + name: "token", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "name", + type: "string", + indexed: false, + internalType: "string", + }, + ], + anonymous: false, + }, + { + type: "error", + name: "InsufficientSwap", + inputs: [], + }, + { + type: "error", + name: "InvalidCharacter", + inputs: [], + }, + { + type: "error", + name: "InvalidSwap", + inputs: [], + }, + { + type: "error", + name: "InvalidSyntax", + inputs: [], + }, + { + type: "error", + name: "Overflow", + inputs: [], + }, +] as const; diff --git a/ui/lib/constants.ts b/ui/lib/constants.ts index dabcc99..690a9e5 100644 --- a/ui/lib/constants.ts +++ b/ui/lib/constants.ts @@ -1,2 +1,10 @@ -export const IE_ADDRESS = "0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00"; +import { Address } from "viem"; + +export const IE_ADDRESS: { + [key: number]: Address; +} = { + 1: "0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00", + 42161: "0x000000001e202b5b84e56400f409800065cb6d3c", +}; + export const ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";