Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eth-multisig-v4): add arbeth and opeth wallet contract #111

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions contracts/coins/ArbethWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';

/**
*
* WalletSimple
* ============
*
* Basic multi-signer wallet designed for use in a co-signing environment where 2 signatures are required to move funds.
* Typically used in a 2-of-3 signing configuration. Uses ecrecover to allow for 2 signatures in a single transaction.
*
* The first signature is created on the operation hash (see Data Formats) and passed to sendMultiSig/sendMultiSigToken
* The signer is determined by verifyMultiSig().
*
* The second signature is created by the submitter of the transaction and determined by msg.signer.
*
* Data Formats
* ============
*
* The signature is created with ethereumjs-util.ecsign(operationHash).
* Like the eth_sign RPC call, it packs the values as a 65-byte array of [r, s, v].
* Unlike eth_sign, the message is not prefixed.
*
* The operationHash the result of keccak256(prefix, toAddress, value, data, expireTime).
* For ether transactions, `prefix` is "ARBETH".
* For token transaction, `prefix` is "ARBETH-ERC20" and `data` is the tokenContractAddress.
*
*
*/
contract ArbethWalletSimple is WalletSimple {
/**
* Get the network identifier that signers must sign over
* This provides protection signatures being replayed on other chains
*/
function getNetworkId() internal override pure returns (string memory) {
return 'ARBETH';
}

/**
* Get the network identifier that signers must sign over for token transfers
* This provides protection signatures being replayed on other chains
*/
function getTokenNetworkId() internal override pure returns (string memory) {
return 'ARBETH-ERC20';
}

/**
* Get the network identifier that signers must sign over for batch transfers
* This provides protection signatures being replayed on other chains
*/
function getBatchNetworkId() internal override pure returns (string memory) {
return 'ARBETH-Batch';
}
}
57 changes: 57 additions & 0 deletions contracts/coins/OpethWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';

/**
*
* WalletSimple
* ============
*
* Basic multi-signer wallet designed for use in a co-signing environment where 2 signatures are required to move funds.
* Typically used in a 2-of-3 signing configuration. Uses ecrecover to allow for 2 signatures in a single transaction.
*
* The first signature is created on the operation hash (see Data Formats) and passed to sendMultiSig/sendMultiSigToken
* The signer is determined by verifyMultiSig().
*
* The second signature is created by the submitter of the transaction and determined by msg.signer.
*
* Data Formats
* ============
*
* The signature is created with ethereumjs-util.ecsign(operationHash).
* Like the eth_sign RPC call, it packs the values as a 65-byte array of [r, s, v].
* Unlike eth_sign, the message is not prefixed.
*
* The operationHash the result of keccak256(prefix, toAddress, value, data, expireTime).
* For ether transactions, `prefix` is "OPETH".
* For token transaction, `prefix` is "OPETH-ERC20" and `data` is the tokenContractAddress.
*
*
*/
contract OpethWalletSimple is WalletSimple {
/**
* Get the network identifier that signers must sign over
* This provides protection signatures being replayed on other chains
*/
function getNetworkId() internal override pure returns (string memory) {
return 'OPETH';
}

/**
* Get the network identifier that signers must sign over for token transfers
* This provides protection signatures being replayed on other chains
*/
function getTokenNetworkId() internal override pure returns (string memory) {
return 'OPETH-ERC20';
}

/**
* Get the network identifier that signers must sign over for batch transfers
* This provides protection signatures being replayed on other chains
*/
function getBatchNetworkId() internal override pure returns (string memory) {
return 'OPETH-Batch';
}
}
2 changes: 1 addition & 1 deletion test/gas.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe(`Wallet Operations Gas Usage`, function () {

it('WalletSimple send batch [ @skip-on-coverage ]', async function () {
const gasUsageByBatchSize = [
101810, 113113, 124451, 135753, 147126, 158442, 169709, 181023, 192397,
101810, 113113, 124451, 135753, 147126, 158442, 169709, 181023, 192338,
203641
];

Expand Down
16 changes: 16 additions & 0 deletions test/walletSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const RskWalletSimple = artifacts.require('./RskWalletSimple.sol');
const EtcWalletSimple = artifacts.require('./EtcWalletSimple.sol');
const CeloWalletSimple = artifacts.require('./CeloWalletSimple.sol');
const PolygonWalletSimple = artifacts.require('./PolygonWalletSimple.sol');
const ArbethWalletSimple = artifacts.require('./ArbethWalletSimple.sol');
const OpethWalletSimple = artifacts.require('./OpethWalletSimple.sol');
const Fail = artifacts.require('./Fail.sol');
const GasGuzzler = artifacts.require('./GasGuzzler.sol');
const GasHeavy = artifacts.require('./GasHeavy.sol');
Expand Down Expand Up @@ -79,6 +81,20 @@ const coins = [
nativeBatchPrefix: 'POLYGON-Batch',
tokenPrefix: 'POLYGON-ERC20',
WalletSimple: PolygonWalletSimple
},
{
name: 'Arbeth',
nativePrefix: 'ARBETH',
nativeBatchPrefix: 'ARBETH-Batch',
tokenPrefix: 'ARBETH-ERC20',
WalletSimple: ArbethWalletSimple
},
{
name: 'Opeth',
nativePrefix: 'OPETH',
nativeBatchPrefix: 'OPETH-Batch',
tokenPrefix: 'OPETH-ERC20',
WalletSimple: OpethWalletSimple
}
];

Expand Down