-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but you might want to call initWallet
directly in the WalletLibrary contructor.
There is no |
Also does resetting |
Yep you should create it. And no it shouldn't, as it will only write to the Library's storage, so the other wallets will just use the logic but their own storage. |
All right, added a constructor that calls |
contracts/walletLibrary.sol
Outdated
address[] noOwners; | ||
noOwners.push(address(0x0)); | ||
initDaylimit(0); | ||
initMultiowned(noOwners, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually put this bit in the constructor, and keep initWallet
as it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
@@ -216,7 +224,7 @@ contract WalletLibrary is WalletEvents { | |||
|
|||
// constructor - just pass on the owner array to the multiowned and | |||
// the limit to daylimit | |||
function initWallet(address[] _owners, uint _required, uint _daylimit) only_uninitialized { | |||
function initWallet(address[] _owners, uint _required, uint _daylimit) only_uninitialized internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will make it impossible for the Wallet
constructor to run, which means it will be impossible to deploy new Wallet
s. Not sure if this was intended but I guess it's actually a good thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the Wallet
constructor then or rather change it to require(false)
otherwise it's really misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do not want anyone to deploy new wallets, at least not with this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #5
@@ -216,7 +224,7 @@ contract WalletLibrary is WalletEvents { | |||
|
|||
// constructor - just pass on the owner array to the multiowned and | |||
// the limit to daylimit | |||
function initWallet(address[] _owners, uint _required, uint _daylimit) only_uninitialized { | |||
function initWallet(address[] _owners, uint _required, uint _daylimit) only_uninitialized internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the Wallet
constructor then or rather change it to require(false)
otherwise it's really misleading.
@@ -198,7 +206,7 @@ contract WalletLibrary is WalletEvents { | |||
} | |||
|
|||
// constructor - stores initial daily limit and records the present day's index. | |||
function initDaylimit(uint _limit) only_uninitialized { | |||
function initDaylimit(uint _limit) only_uninitialized internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH since both initDayLimit
and initMultiOwned
are used only in constructor and are internal I would be inclined to inline them instead.
Also if we inline only_uninitialized
modifier, we'll end-up with single method that initializes the wallet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a single-purpose contract and I do not want to change any of the contract structure unless it's required security-wise. This is important for me to (A) keep the changes in the upcoming EIP as minimal as possible and (B) to maintain maximum compatibility with the already deployed wallet stubs.
If anyone else wants to use a Wallet + WalletLibrary, they should refer to the refactored and peer-reviewed version of https://github.com/paritytech/contracts/pull/74.
m_ownerIndex[uint(msg.sender)] = 1; | ||
function initMultiowned(address[] _owners, uint _required) only_uninitialized internal { | ||
require(_required > 0); | ||
require(_owners.length >= _required); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should also have require(_required < _owners.length)
check here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-)
for (uint i = 0; i < _owners.length; ++i) | ||
{ | ||
m_owners[2 + i] = uint(_owners[i]); | ||
m_ownerIndex[uint(_owners[i])] = 2 + i; | ||
m_owners[1 + i] = uint(_owners[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's stored in m_owners[0]
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see that ownerIndex=0
is reserved to determine if the owner is actually defined. Would be good to add a comment to m_owners
and m_numOwners
(something like: "owners are stored on indices [1, m_numOwners]
, 0
is reserved for uninitialized owner".)
Remove Wallet in #5, left comments on the other suggestions. |
0x0
msg.sender
is not allowed to become an owner by default anymoreinitWallet
,initMultiowned
, andinitDaylimit
internal functions to disallow direct accessref https://github.com/paritytech/contracts/pull/74