|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +pragma solidity 0.8.20; |
| 3 | +import '../Forwarder.sol'; |
| 4 | +import '../ERC20Interface.sol'; |
| 5 | +import '../WalletSimple.sol'; |
| 6 | + |
| 7 | +/** |
| 8 | + * |
| 9 | + * WalletSimple |
| 10 | + * ============ |
| 11 | + * |
| 12 | + * Basic multi-signer wallet designed for use in a co-signing environment where 2 signatures are required to move funds. |
| 13 | + * Typically used in a 2-of-3 signing configuration. Uses ecrecover to allow for 2 signatures in a single transaction. |
| 14 | + * |
| 15 | + * The first signature is created on the operation hash (see Data Formats) and passed to sendMultiSig/sendMultiSigToken |
| 16 | + * The signer is determined by verifyMultiSig(). |
| 17 | + * |
| 18 | + * The second signature is created by the submitter of the transaction and determined by msg.signer. |
| 19 | + * |
| 20 | + * Data Formats |
| 21 | + * ============ |
| 22 | + * |
| 23 | + * The signature is created with ethereumjs-util.ecsign(operationHash). |
| 24 | + * Like the eth_sign RPC call, it packs the values as a 65-byte array of [r, s, v]. |
| 25 | + * Unlike eth_sign, the message is not prefixed. |
| 26 | + * |
| 27 | + * The operationHash the result of keccak256(prefix, toAddress, value, data, expireTime). |
| 28 | + * For ether transactions, `prefix` is "OPETH". |
| 29 | + * For token transaction, `prefix` is "OPETH-ERC20" and `data` is the tokenContractAddress. |
| 30 | + * |
| 31 | + * |
| 32 | + */ |
| 33 | +contract OpethWalletSimple is WalletSimple { |
| 34 | + /** |
| 35 | + * Get the network identifier that signers must sign over |
| 36 | + * This provides protection signatures being replayed on other chains |
| 37 | + */ |
| 38 | + function getNetworkId() internal override pure returns (string memory) { |
| 39 | + return 'OPETH'; |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Get the network identifier that signers must sign over for token transfers |
| 44 | + * This provides protection signatures being replayed on other chains |
| 45 | + */ |
| 46 | + function getTokenNetworkId() internal override pure returns (string memory) { |
| 47 | + return 'OPETH-ERC20'; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Get the network identifier that signers must sign over for batch transfers |
| 52 | + * This provides protection signatures being replayed on other chains |
| 53 | + */ |
| 54 | + function getBatchNetworkId() internal override pure returns (string memory) { |
| 55 | + return 'OPETH-Batch'; |
| 56 | + } |
| 57 | +} |
0 commit comments