Skip to content

Commit 60f9271

Browse files
authored
Add overrideable _generateSalt to BaseAccountFactory (#392)
* Add _generateSalt to BaseAccountFactory * docs update * package update
1 parent 94930f3 commit 60f9271

File tree

7 files changed

+137
-2
lines changed

7 files changed

+137
-2
lines changed

contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thirdweb-dev/contracts",
33
"description": "Collection of smart contracts deployable via the thirdweb SDK, dashboard and CLI",
4-
"version": "3.5.1",
4+
"version": "3.5.2",
55
"license": "Apache-2.0",
66
"repository": {
77
"type": "git",

contracts/smart-wallet/utils/BaseAccountFactory.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
4747
/// @notice Deploys a new Account for admin.
4848
function createAccount(address _admin, bytes calldata _data) external virtual override returns (address) {
4949
address impl = accountImplementation;
50-
bytes32 salt = keccak256(abi.encode(_admin));
50+
bytes32 salt = _generateSalt(_admin, _data);
5151
address account = Clones.predictDeterministicAddress(impl, salt);
5252

5353
if (account.code.length > 0) {
@@ -115,6 +115,11 @@ abstract contract BaseAccountFactory is IAccountFactory, Multicall {
115115
Internal functions
116116
//////////////////////////////////////////////////////////////*/
117117

118+
/// @dev Returns the salt used when deploying an Account.
119+
function _generateSalt(address _admin, bytes calldata) internal view virtual returns (bytes32) {
120+
return keccak256(abi.encode(_admin));
121+
}
122+
118123
/// @dev Called in `createAccount`. Initializes the account contract created in `createAccount`.
119124
function _initializeAccount(
120125
address _account,

docs/Account.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,29 @@ Initializes the smart contract wallet.
323323
| _defaultAdmin | address | undefined |
324324
| _1 | bytes | undefined |
325325

326+
### isValidSignature
327+
328+
```solidity
329+
function isValidSignature(bytes32 _hash, bytes _signature) external view returns (bytes4 magicValue)
330+
```
331+
332+
See EIP-1271
333+
334+
335+
336+
#### Parameters
337+
338+
| Name | Type | Description |
339+
|---|---|---|
340+
| _hash | bytes32 | undefined |
341+
| _signature | bytes | undefined |
342+
343+
#### Returns
344+
345+
| Name | Type | Description |
346+
|---|---|---|
347+
| magicValue | bytes4 | undefined |
348+
326349
### isValidSigner
327350

328351
```solidity

docs/AccountCore.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,29 @@ Initializes the smart contract wallet.
123123
| _defaultAdmin | address | undefined |
124124
| _1 | bytes | undefined |
125125

126+
### isValidSignature
127+
128+
```solidity
129+
function isValidSignature(bytes32 _hash, bytes _signature) external view returns (bytes4 magicValue)
130+
```
131+
132+
See EIP-1271
133+
134+
135+
136+
#### Parameters
137+
138+
| Name | Type | Description |
139+
|---|---|---|
140+
| _hash | bytes32 | undefined |
141+
| _signature | bytes | undefined |
142+
143+
#### Returns
144+
145+
| Name | Type | Description |
146+
|---|---|---|
147+
| magicValue | bytes4 | undefined |
148+
126149
### isValidSigner
127150

128151
```solidity

docs/DynamicAccount.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,29 @@ Initializes the smart contract wallet.
300300
| _defaultAdmin | address | undefined |
301301
| _1 | bytes | undefined |
302302

303+
### isValidSignature
304+
305+
```solidity
306+
function isValidSignature(bytes32 _hash, bytes _signature) external view returns (bytes4 magicValue)
307+
```
308+
309+
See EIP-1271
310+
311+
312+
313+
#### Parameters
314+
315+
| Name | Type | Description |
316+
|---|---|---|
317+
| _hash | bytes32 | undefined |
318+
| _signature | bytes | undefined |
319+
320+
#### Returns
321+
322+
| Name | Type | Description |
323+
|---|---|---|
324+
| magicValue | bytes4 | undefined |
325+
303326
### isValidSigner
304327

305328
```solidity

docs/ERC1271.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ERC1271
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
## Methods
12+
13+
### isValidSignature
14+
15+
```solidity
16+
function isValidSignature(bytes32 _hash, bytes _signature) external view returns (bytes4 magicValue)
17+
```
18+
19+
20+
21+
*Should return whether the signature provided is valid for the provided hash*
22+
23+
#### Parameters
24+
25+
| Name | Type | Description |
26+
|---|---|---|
27+
| _hash | bytes32 | Hash of the data to be signed |
28+
| _signature | bytes | Signature byte array associated with _hash MUST return the bytes4 magic value 0x1626ba7e when function passes. MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) MUST allow external calls |
29+
30+
#### Returns
31+
32+
| Name | Type | Description |
33+
|---|---|---|
34+
| magicValue | bytes4 | undefined |
35+
36+
37+
38+

docs/ManagedAccount.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ Initializes the smart contract wallet.
162162
| _defaultAdmin | address | undefined |
163163
| _1 | bytes | undefined |
164164

165+
### isValidSignature
166+
167+
```solidity
168+
function isValidSignature(bytes32 _hash, bytes _signature) external view returns (bytes4 magicValue)
169+
```
170+
171+
See EIP-1271
172+
173+
174+
175+
#### Parameters
176+
177+
| Name | Type | Description |
178+
|---|---|---|
179+
| _hash | bytes32 | undefined |
180+
| _signature | bytes | undefined |
181+
182+
#### Returns
183+
184+
| Name | Type | Description |
185+
|---|---|---|
186+
| magicValue | bytes4 | undefined |
187+
165188
### isValidSigner
166189

167190
```solidity

0 commit comments

Comments
 (0)