Skip to content

Commit 0b2ba88

Browse files
feat(eth-multisig-v4): add arbeth and opeth wallet contract
2 parents bebf6c7 + ded40bc commit 0b2ba88

File tree

4 files changed

+131
-1
lines changed

4 files changed

+131
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 "ARBETH".
29+
* For token transaction, `prefix` is "ARBETH-ERC20" and `data` is the tokenContractAddress.
30+
*
31+
*
32+
*/
33+
contract ArbethWalletSimple 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 'ARBETH';
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 'ARBETH-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 'ARBETH-Batch';
56+
}
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
}

test/gas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe(`Wallet Operations Gas Usage`, function () {
178178

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

test/walletSimple.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const RskWalletSimple = artifacts.require('./RskWalletSimple.sol');
2929
const EtcWalletSimple = artifacts.require('./EtcWalletSimple.sol');
3030
const CeloWalletSimple = artifacts.require('./CeloWalletSimple.sol');
3131
const PolygonWalletSimple = artifacts.require('./PolygonWalletSimple.sol');
32+
const ArbethWalletSimple = artifacts.require('./ArbethWalletSimple.sol');
33+
const OpethWalletSimple = artifacts.require('./OpethWalletSimple.sol');
3234
const Fail = artifacts.require('./Fail.sol');
3335
const GasGuzzler = artifacts.require('./GasGuzzler.sol');
3436
const GasHeavy = artifacts.require('./GasHeavy.sol');
@@ -79,6 +81,20 @@ const coins = [
7981
nativeBatchPrefix: 'POLYGON-Batch',
8082
tokenPrefix: 'POLYGON-ERC20',
8183
WalletSimple: PolygonWalletSimple
84+
},
85+
{
86+
name: 'Arbeth',
87+
nativePrefix: 'ARBETH',
88+
nativeBatchPrefix: 'ARBETH-Batch',
89+
tokenPrefix: 'ARBETH-ERC20',
90+
WalletSimple: ArbethWalletSimple
91+
},
92+
{
93+
name: 'Opeth',
94+
nativePrefix: 'OPETH',
95+
nativeBatchPrefix: 'OPETH-Batch',
96+
tokenPrefix: 'OPETH-ERC20',
97+
WalletSimple: OpethWalletSimple
8298
}
8399
];
84100

0 commit comments

Comments
 (0)