Skip to content

Commit c8f819c

Browse files
committed
rename initialization -> initArgs
1 parent a3bac44 commit c8f819c

File tree

3 files changed

+49
-54
lines changed

3 files changed

+49
-54
lines changed

contracts/finance/VestingWalletConfidentialFactory.sol

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {VestingWalletCliffConfidential} from "./VestingWalletCliffConfidential.s
1616
abstract contract VestingWalletConfidentialFactory {
1717
struct VestingPlan {
1818
externalEuint64 encryptedAmount;
19-
bytes initialization;
19+
bytes initArgs;
2020
}
2121

2222
address private immutable _vestingImplementation;
@@ -25,9 +25,9 @@ abstract contract VestingWalletConfidentialFactory {
2525
address indexed vestingWalletConfidential,
2626
address indexed confidentialFungibleToken,
2727
euint64 transferredAmount,
28-
bytes initialization
28+
bytes initArgs
2929
);
30-
event VestingWalletConfidentialCreated(address indexed vestingWalletConfidential, bytes initialization);
30+
event VestingWalletConfidentialCreated(address indexed vestingWalletConfidential, bytes initArgs);
3131

3232
constructor() {
3333
_vestingImplementation = _deployVestingWalletImplementation();
@@ -49,9 +49,9 @@ abstract contract VestingWalletConfidentialFactory {
4949
uint256 vestingPlansLength = vestingPlans.length;
5050
for (uint256 i = 0; i < vestingPlansLength; i++) {
5151
VestingPlan memory vestingPlan = vestingPlans[i];
52-
_validateVestingWalletInitialization(vestingPlan.initialization);
52+
_validateVestingWalletInitArgs(vestingPlan.initArgs);
5353

54-
address vestingWalletAddress = predictVestingWalletConfidential(vestingPlan.initialization);
54+
address vestingWalletAddress = predictVestingWalletConfidential(vestingPlan.initArgs);
5555

5656
euint64 encryptedAmount = FHE.fromExternal(vestingPlan.encryptedAmount, inputProof);
5757
FHE.allowTransient(encryptedAmount, confidentialFungibleToken);
@@ -65,7 +65,7 @@ abstract contract VestingWalletConfidentialFactory {
6565
vestingWalletAddress,
6666
confidentialFungibleToken,
6767
transferredAmount,
68-
vestingPlan.initialization
68+
vestingPlan.initArgs
6969
);
7070
}
7171
}
@@ -75,33 +75,33 @@ abstract contract VestingWalletConfidentialFactory {
7575
*
7676
* Emits a {VestingWalletConfidentialCreated}.
7777
*/
78-
function createVestingWalletConfidential(bytes calldata initialization) public virtual returns (address) {
78+
function createVestingWalletConfidential(bytes calldata initArgs) public virtual returns (address) {
7979
// Will revert if clone already created
8080
address vestingWalletConfidentialAddress = Clones.cloneDeterministic(
8181
_vestingImplementation,
82-
_getCreate2VestingWalletConfidentialSalt(initialization)
82+
_getCreate2VestingWalletConfidentialSalt(initArgs)
8383
);
84-
_initializeVestingWallet(vestingWalletConfidentialAddress, initialization);
85-
emit VestingWalletConfidentialCreated(vestingWalletConfidentialAddress, initialization);
84+
_initializeVestingWallet(vestingWalletConfidentialAddress, initArgs);
85+
emit VestingWalletConfidentialCreated(vestingWalletConfidentialAddress, initArgs);
8686
return vestingWalletConfidentialAddress;
8787
}
8888

8989
/**
9090
* @dev Predicts the deterministic address for a confidential vesting wallet.
9191
*/
92-
function predictVestingWalletConfidential(bytes memory initialization) public view virtual returns (address) {
92+
function predictVestingWalletConfidential(bytes memory initArgs) public view virtual returns (address) {
9393
return
9494
Clones.predictDeterministicAddress(
9595
_vestingImplementation,
96-
_getCreate2VestingWalletConfidentialSalt(initialization)
96+
_getCreate2VestingWalletConfidentialSalt(initArgs)
9797
);
9898
}
9999

100-
/// @dev Virtual function that must be implemented to validate the initialization bytes.
101-
function _validateVestingWalletInitialization(bytes memory initialization) internal virtual;
100+
/// @dev Virtual function that must be implemented to validate the initArgs bytes.
101+
function _validateVestingWalletInitArgs(bytes memory initArgs) internal virtual;
102102

103103
/// @dev Virtual function that must be implemented to initialize the vesting wallet at `vestingWalletAddress`.
104-
function _initializeVestingWallet(address vestingWalletAddress, bytes calldata initialization) internal virtual;
104+
function _initializeVestingWallet(address vestingWalletAddress, bytes calldata initArgs) internal virtual;
105105

106106
/**
107107
* @dev Internal function that is called once to deploy the vesting wallet implementation.
@@ -113,9 +113,7 @@ abstract contract VestingWalletConfidentialFactory {
113113
/**
114114
* @dev Gets create2 salt for a confidential vesting wallet.
115115
*/
116-
function _getCreate2VestingWalletConfidentialSalt(
117-
bytes memory initialization
118-
) internal pure virtual returns (bytes32) {
119-
return keccak256(initialization);
116+
function _getCreate2VestingWalletConfidentialSalt(bytes memory initArgs) internal pure virtual returns (bytes32) {
117+
return keccak256(initArgs);
120118
}
121119
}

contracts/mocks/finance/VestingWalletConfidentialFactoryMock.sol

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,28 @@ abstract contract VestingWalletConfidentialFactoryMock is VestingWalletConfident
1212
return address(new VestingWalletCliffExecutorConfidential());
1313
}
1414

15-
function _validateVestingWalletInitialization(bytes memory initialization) internal virtual override {
15+
function _validateVestingWalletInitArgs(bytes memory initArgs) internal virtual override {
1616
// solhint-disable no-unused-vars
1717
(
1818
address beneficiary,
1919
uint48 startTimestamp,
2020
uint48 durationSeconds,
2121
uint48 cliffSeconds,
2222
address executor
23-
) = abi.decode(initialization, (address, uint48, uint48, uint48, address));
23+
) = abi.decode(initArgs, (address, uint48, uint48, uint48, address));
2424

2525
require(cliffSeconds <= durationSeconds);
2626
require(beneficiary != address(0));
2727
}
2828

29-
function _initializeVestingWallet(
30-
address vestingWalletAddress,
31-
bytes calldata initialization
32-
) internal virtual override {
29+
function _initializeVestingWallet(address vestingWalletAddress, bytes calldata initArgs) internal virtual override {
3330
(
3431
address beneficiary,
3532
uint48 startTimestamp,
3633
uint48 durationSeconds,
3734
uint48 cliffSeconds,
3835
address executor
39-
) = abi.decode(initialization, (address, uint48, uint48, uint48, address));
36+
) = abi.decode(initArgs, (address, uint48, uint48, uint48, address));
4037

4138
VestingWalletCliffExecutorConfidential(vestingWalletAddress).initialize(
4239
beneficiary,

test/finance/VestingWalletConfidentialFactory.test.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,28 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
5757

5858
it('should create vesting wallet with deterministic address', async function () {
5959
const predictedVestingWalletAddress = await this.factory.predictVestingWalletConfidential(
60-
encodeVestingWalletInitialization(this.recipient.address, startTimestamp, duration, cliff, this.executor.address),
60+
encodeVestingWalletInitArgs(this.recipient.address, startTimestamp, duration, cliff, this.executor.address),
6161
);
6262
const vestingWalletAddress = await this.factory.createVestingWalletConfidential.staticCall(
63-
encodeVestingWalletInitialization(this.recipient.address, startTimestamp, duration, cliff, this.executor.address),
63+
encodeVestingWalletInitArgs(this.recipient.address, startTimestamp, duration, cliff, this.executor.address),
6464
);
6565
expect(vestingWalletAddress).to.be.equal(predictedVestingWalletAddress);
6666
});
6767

6868
it('should create vesting wallet', async function () {
69-
const initialization = encodeVestingWalletInitialization(
69+
const initArgs = encodeVestingWalletInitArgs(
7070
this.recipient.address,
7171
startTimestamp,
7272
duration,
7373
cliff,
7474
this.executor.address,
7575
);
7676

77-
const vestingWalletAddress = await this.factory.predictVestingWalletConfidential(initialization);
77+
const vestingWalletAddress = await this.factory.predictVestingWalletConfidential(initArgs);
7878

79-
await expect(await this.factory.createVestingWalletConfidential(initialization))
79+
await expect(await this.factory.createVestingWalletConfidential(initArgs))
8080
.to.emit(this.factory, 'VestingWalletConfidentialCreated')
81-
.withArgs(vestingWalletAddress, initialization);
81+
.withArgs(vestingWalletAddress, initArgs);
8282
const vestingWallet = await ethers.getContractAt('VestingWalletCliffExecutorConfidential', vestingWalletAddress);
8383
await expect(vestingWallet.owner()).to.eventually.equal(this.recipient);
8484
await expect(vestingWallet.start()).to.eventually.equal(startTimestamp);
@@ -88,18 +88,18 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
8888
});
8989

9090
it('should not create vesting wallet twice', async function () {
91-
const initialization = encodeVestingWalletInitialization(
91+
const initArgs = encodeVestingWalletInitArgs(
9292
this.recipient.address,
9393
startTimestamp,
9494
duration,
9595
cliff,
9696
this.executor.address,
9797
);
98-
await expect(await this.factory.createVestingWalletConfidential(initialization)).to.emit(
98+
await expect(await this.factory.createVestingWalletConfidential(initArgs)).to.emit(
9999
this.factory,
100100
'VestingWalletConfidentialCreated',
101101
);
102-
await expect(this.factory.createVestingWalletConfidential(initialization)).to.be.revertedWithCustomError(
102+
await expect(this.factory.createVestingWalletConfidential(initArgs)).to.be.revertedWithCustomError(
103103
this.factory,
104104
'FailedDeployment',
105105
);
@@ -111,45 +111,45 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
111111
.add64(amount1)
112112
.add64(amount2)
113113
.encrypt();
114-
const initialization1 = encodeVestingWalletInitialization(
114+
const initArgs1 = encodeVestingWalletInitArgs(
115115
this.recipient.address,
116116
startTimestamp,
117117
duration,
118118
cliff,
119119
this.executor.address,
120120
);
121-
const initialization2 = encodeVestingWalletInitialization(
121+
const initArgs2 = encodeVestingWalletInitArgs(
122122
this.recipient2.address,
123123
startTimestamp,
124124
duration,
125125
cliff,
126126
this.executor.address,
127127
);
128-
const vestingWalletAddress1 = await this.factory.predictVestingWalletConfidential(initialization1);
129-
const vestingWalletAddress2 = await this.factory.predictVestingWalletConfidential(initialization2);
128+
const vestingWalletAddress1 = await this.factory.predictVestingWalletConfidential(initArgs1);
129+
const vestingWalletAddress2 = await this.factory.predictVestingWalletConfidential(initArgs2);
130130

131131
const vestingCreationTx = await this.factory.connect(this.holder).batchFundVestingWalletConfidential(
132132
this.token.target,
133133
[
134134
{
135135
encryptedAmount: encryptedInput.handles[0],
136-
initialization: initialization1,
136+
initArgs: initArgs1,
137137
},
138138
{
139139
encryptedAmount: encryptedInput.handles[1],
140-
initialization: initialization2,
140+
initArgs: initArgs2,
141141
},
142142
],
143143
encryptedInput.inputProof,
144144
);
145145

146146
expect(vestingCreationTx)
147147
.to.emit(this.factory, 'VestingWalletConfidentialFunded')
148-
.withArgs(vestingWalletAddress1, this.recipient, this.token.target, anyValue, initialization1)
148+
.withArgs(vestingWalletAddress1, this.recipient, this.token.target, anyValue, initArgs1)
149149
.to.emit(this.token, 'ConfidentialTransfer')
150150
.withArgs(this.holder, vestingWalletAddress2, anyValue)
151151
.to.emit(this.factory, 'VestingWalletConfidentialFunded')
152-
.withArgs(vestingWalletAddress2, this.recipient2, this.token.target, anyValue, initialization2)
152+
.withArgs(vestingWalletAddress2, this.recipient2, this.token.target, anyValue, initArgs2)
153153
.to.emit(this.token, 'ConfidentialTransfer')
154154
.withArgs(this.holder, vestingWalletAddress2, anyValue);
155155

@@ -173,7 +173,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
173173
.add64(amount1)
174174
.encrypt();
175175

176-
const invalidInitialization = encodeVestingWalletInitialization(
176+
const invalidInitArgs = encodeVestingWalletInitArgs(
177177
this.recipient.address,
178178
startTimestamp,
179179
duration,
@@ -188,7 +188,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
188188
{
189189
beneficiary: this.recipient,
190190
encryptedAmount: encryptedInput.handles[0],
191-
initialization: invalidInitialization,
191+
initArgs: invalidInitArgs,
192192
},
193193
],
194194
encryptedInput.inputProof,
@@ -201,7 +201,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
201201
.createEncryptedInput(await this.factory.getAddress(), this.holder.address)
202202
.add64(amount1)
203203
.encrypt();
204-
const invalidInitialization = ethers.AbiCoder.defaultAbiCoder().encode(
204+
const invalidInitArgs = ethers.AbiCoder.defaultAbiCoder().encode(
205205
['address', 'uint48', 'uint48', 'uint48'],
206206
[this.recipient.address, startTimestamp, duration, cliff],
207207
);
@@ -213,7 +213,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
213213
{
214214
beneficiary: this.recipient,
215215
encryptedAmount: encryptedInput.handles[0],
216-
initialization: invalidInitialization,
216+
initArgs: invalidInitArgs,
217217
},
218218
],
219219
encryptedInput.inputProof,
@@ -227,7 +227,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
227227
.add64(amount1)
228228
.encrypt();
229229

230-
const invalidInitialization = encodeVestingWalletInitialization(
230+
const invalidInitArgs = encodeVestingWalletInitArgs(
231231
ethers.ZeroAddress,
232232
startTimestamp,
233233
duration,
@@ -242,7 +242,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
242242
{
243243
beneficiary: ethers.ZeroAddress,
244244
encryptedAmount: encryptedInput.handles[0],
245-
initialization: invalidInitialization,
245+
initArgs: invalidInitArgs,
246246
},
247247
],
248248
encryptedInput.inputProof,
@@ -256,7 +256,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
256256
.add64(amount1)
257257
.encrypt();
258258

259-
const initialization = encodeVestingWalletInitialization(
259+
const initArgs = encodeVestingWalletInitArgs(
260260
this.recipient.address,
261261
startTimestamp,
262262
duration,
@@ -266,7 +266,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
266266

267267
const vestingWallet = await ethers.getContractAt(
268268
'VestingWalletCliffExecutorConfidential',
269-
await this.factory.predictVestingWalletConfidential(initialization),
269+
await this.factory.predictVestingWalletConfidential(initArgs),
270270
);
271271

272272
await this.factory.connect(this.holder).batchFundVestingWalletConfidential(
@@ -275,13 +275,13 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
275275
{
276276
beneficiary: this.recipient,
277277
encryptedAmount: encryptedInput.handles[0],
278-
initialization: initialization,
278+
initArgs: initArgs,
279279
},
280280
],
281281
encryptedInput.inputProof,
282282
);
283283

284-
await this.factory.createVestingWalletConfidential(initialization);
284+
await this.factory.createVestingWalletConfidential(initArgs);
285285

286286
await time.increaseTo(startTimestamp + duration / 2);
287287
await vestingWallet.release(this.token);
@@ -297,7 +297,7 @@ describe('VestingWalletCliffExecutorConfidentialFactory', function () {
297297
});
298298
});
299299

300-
const encodeVestingWalletInitialization = (
300+
const encodeVestingWalletInitArgs = (
301301
beneficiary: string,
302302
startTimestamp: number,
303303
durationSeconds: number,

0 commit comments

Comments
 (0)