|
| 1 | +import { parseAbiItem, type Address } from "viem"; |
| 2 | + |
| 3 | +/** |
| 4 | + * USDC ERC20 token contract address used for benchmarking ERC20 shielding and transfers. |
| 5 | + * https://github.com/circlefin/stablecoin-evm/blob/master/contracts/v2/FiatTokenV2_2.sol |
| 6 | + */ |
| 7 | +export const USDC_ERC20_TOKEN_ADDRESS: Address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; |
| 8 | + |
| 9 | +/** |
| 10 | + * A normal ERC20 transfer to any address (including stealth addresses) could be a shield/deposit for Fluidkey |
| 11 | + * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/9cfdccd35350f7bcc585cf2ede08cd04e7f0ec10/contracts/token/ERC20/IERC20.sol#L16 |
| 12 | + * |
| 13 | + * Emits: |
| 14 | + * Transfer() - ERC20 token transfer to the stealth address (emitted by the token contract) |
| 15 | + * |
| 16 | + * Example: |
| 17 | + * https://etherscan.io/tx/0xc8a00a361491b878ec68a0f4f452aedc86eea316b0d6e4acee2f53e6719b4fb0 |
| 18 | + */ |
| 19 | +export const SHIELD_ERC20_EVENTS = [ |
| 20 | + parseAbiItem("event Transfer(address indexed from, address indexed to, uint256 value)"), |
| 21 | +] as const; |
| 22 | + |
| 23 | +/** |
| 24 | + * Fluidkey relayer send txs to this relayer contract to deploy the Safe contract and execute the transfer to the recipient in a single transaction. |
| 25 | + * There is no open source code for the relayer contract (searched for relayer contracts in Safe and Gelato) |
| 26 | + * https://etherscan.io/address/0x8090a9db6aca56ffa186c75ca0787b18af1058a0 |
| 27 | + * |
| 28 | + * A sample implementation of the relayer contract can be found here: |
| 29 | + * https://www.codeslaw.app/contracts/arbitrum/0x7f3319f55ef4a96ae717c5ac27b5adb0435a9280?file=src%2FSmartAccountRelayer.sol |
| 30 | + */ |
| 31 | +export const FLUIDKEY_RELAYER_CONTRACT: Address = "0x8090a9DB6Aca56fFA186C75Ca0787B18af1058a0"; |
| 32 | + |
| 33 | +/** |
| 34 | + * A "Relay Operation" transaction is executed when the user sends funds from the Fluidkey interface. As stated before, there is no open source code. |
| 35 | + * The transaction deploys the Safe Singleton 1.3.0 contract and sends funds to the public recipient in one bundled transaction. |
| 36 | + * An example of the SmartAccountRelayer.relayOperation function: |
| 37 | + * https://www.codeslaw.app/contracts/arbitrum/0x7f3319f55ef4a96ae717c5ac27b5adb0435a9280?file=src%2FSmartAccountRelayer.sol&start=30 |
| 38 | + * |
| 39 | + * Emits: |
| 40 | + * EnabledModule() - Safe module enabled (emitted by the Safe stealth address) |
| 41 | + * ModuleInitialized() - Safe module initialized (emitted by the Safe) |
| 42 | + * ConfigHashChanged() - Safe config hash changed after module setup (emitted by the Safe) |
| 43 | + * SafeSetup() - Safe setup with 1 owner and threshold 1 (emitted by the Safe stealth address) |
| 44 | + * ProxyCreation() - New Safe proxy deployed at sender's stealth address (emitted by Safe: Proxy Factory 1.3.0) |
| 45 | + * ExecutionSuccess() - Safe stealth transfers fee to relayer (emitted by the Safe stealth address) |
| 46 | + * SafeReceived() - Relayer (Safe stealth address) receives the fee (emitted by the Safe stealth address) |
| 47 | + * ExecutionSuccess() - Safe stealth address executes the transfer to the recipient (emitted by the Safe stealth address) |
| 48 | + * OperationRelayed() - Operation executed successfully (emitted by the relayer contract) |
| 49 | + * |
| 50 | + * Example: |
| 51 | + * https://etherscan.io/tx/0x8a63395db9779ab66661653be4ffe2a15bd5df345d9389ec12f7bd44bb07f7d4 |
| 52 | + */ |
| 53 | +export const TRANSFER_ETH_EVENTS = [ |
| 54 | + parseAbiItem("event EnabledModule(address module)"), |
| 55 | + parseAbiItem("event ModuleInitialized(address indexed account)"), |
| 56 | + parseAbiItem("event ConfigHashChanged(address indexed account, uint256 oldConfigHash, uint256 newConfigHash)"), |
| 57 | + parseAbiItem( |
| 58 | + "event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler)", |
| 59 | + ), |
| 60 | + parseAbiItem("event ProxyCreation(address proxy, address singleton)"), |
| 61 | + parseAbiItem("event ExecutionSuccess(bytes32 txHash, uint256 payment)"), |
| 62 | + parseAbiItem("event SafeReceived(address indexed sender, uint256 value)"), |
| 63 | + parseAbiItem("event ExecutionSuccess(bytes32 txHash, uint256 payment)"), |
| 64 | + parseAbiItem("event OperationRelayed(uint256 indexed operationId, bool indexed success)"), |
| 65 | +] as const; |
| 66 | + |
| 67 | +/** |
| 68 | + * A "Relay Operation" transaction is executed when the user sends funds from the Fluidkey interface. As stated before, there is no open source code. |
| 69 | + * The transaction deploys the Safe Singleton 1.3.0 contract and sends funds to the public recipient in one bundled transaction. |
| 70 | + * An example of the SmartAccountRelayer.relayOperation function: |
| 71 | + * https://www.codeslaw.app/contracts/arbitrum/0x7f3319f55ef4a96ae717c5ac27b5adb0435a9280?file=src%2FSmartAccountRelayer.sol&start=30 |
| 72 | + * |
| 73 | + * Emits: |
| 74 | + * EnabledModule() - Safe module enabled (emitted by the Safe stealth address) |
| 75 | + * ModuleInitialized() - Safe module initialized (emitted by the Safe) |
| 76 | + * ConfigHashChanged() - Safe config hash changed after module setup (emitted by the Safe) |
| 77 | + * SafeSetup() - Safe setup with 1 owner and threshold 1 (emitted by the Safe stealth address) |
| 78 | + * ProxyCreation() - New Safe proxy deployed at sender's stealth address (emitted by Safe: Proxy Factory 1.3.0) |
| 79 | + * Transfer() - ERC20 transfer to recipient (emitted by the ERC20 token contract) |
| 80 | + * ExecutionSuccess() - Safe stealth transfers fee to relayer (emitted by the Safe stealth address) |
| 81 | + * Transfer() - ERC20 fee transfer to relayer (emitted by the ERC20 token contract) |
| 82 | + * ExecutionSuccess() - Safe stealth address executes the transfer to the recipient (emitted by the Safe stealth address) |
| 83 | + * OperationRelayed() - Operation executed successfully (emitted by the relayer contract) |
| 84 | + * |
| 85 | + * Example: |
| 86 | + * https://etherscan.io/tx/0xf10db1f5474b8ef4592fa95abef49e73f53f5c2773297dade0d8e209176f7aec |
| 87 | + */ |
| 88 | +export const TRANSFER_ERC20_EVENTS = [ |
| 89 | + parseAbiItem("event EnabledModule(address module)"), |
| 90 | + parseAbiItem("event ModuleInitialized(address indexed account)"), |
| 91 | + parseAbiItem("event ConfigHashChanged(address indexed account, uint256 oldConfigHash, uint256 newConfigHash)"), |
| 92 | + parseAbiItem( |
| 93 | + "event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler)", |
| 94 | + ), |
| 95 | + parseAbiItem("event ProxyCreation(address proxy, address singleton)"), |
| 96 | + parseAbiItem("event Transfer(address indexed from, address indexed to, uint256 value)"), |
| 97 | + parseAbiItem("event ExecutionSuccess(bytes32 txHash, uint256 payment)"), |
| 98 | + parseAbiItem("event Transfer(address indexed from, address indexed to, uint256 value)"), |
| 99 | + parseAbiItem("event ExecutionSuccess(bytes32 txHash, uint256 payment)"), |
| 100 | + parseAbiItem("event OperationRelayed(uint256 indexed operationId, bool indexed success)"), |
| 101 | +] as const; |
0 commit comments