Skip to content

Add Vesting - #425

Merged
immrsd merged 18 commits into
OpenZeppelin:masterfrom
immrsd:vesting-wallet
Jan 13, 2025
Merged

Add Vesting#425
immrsd merged 18 commits into
OpenZeppelin:masterfrom
immrsd:vesting-wallet

Conversation

@immrsd

@immrsd immrsd commented Dec 24, 2024

Copy link
Copy Markdown
Contributor

No description provided.

@immrsd immrsd self-assigned this Dec 24, 2024
@socket-security

socket-security Bot commented Dec 24, 2024

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@andrew-fleming andrew-fleming left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice PR, @immrsd! I left a few questions and comments

import { durationToTimestamp } from './utils/duration';
import { toUint, validateUint } from './utils/convert-strings';

export type VestingSchedule = 'linear' | 'custom';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already have the "steps" schedule implemented as a mock and as an example in "Usage", do you think it's worth adding the option here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't reckon it's worth it. The steps schedule is mostly for demonstration purposes, it's kinda naive and I expect it to be used almost never or very rarely

Comment on lines +54 to +63
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/access#ownership_and_ownable">
Simple mechanism with a single account authorized for all privileged actions.
</HelpTooltip>
</label>
<label class:checked={opts.schedule === "custom"}>
<input type="radio" bind:group={opts.schedule} value="custom">
Custom
<HelpTooltip link="https://docs.openzeppelin.com/contracts-cairo/access#role_based_accesscontrol">
Flexible mechanism with a separate role for each privileged action. A role can have many authorized accounts.
</HelpTooltip>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooltips need to be fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't want to include the steps vesting option, I think we can at least direct users to it as an example when hovering the Custom tooltip

const match = duration.trim().match(durationPattern);

if (!match) {
if (!match || match.length < 2) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there cases where a happy match also has match.length < 2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, since later on we access the 1st and the 2nd items of the match array in unsafe manner. Either way it'll result in a runtime exception, but it's better to have a straightforward error than index-out-of-bounds one

image

@ericglau ericglau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Just a few suggestions.

Comment thread packages/core-cairo/src/generate/sources.ts
Comment thread packages/core-cairo/src/test.ts Outdated
Comment thread packages/core-cairo/src/test.ts

@ericnordelo ericnordelo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR and generated code look good, but I wonder if there's anything we can do to make the date input UI compatible with the rest of the inputs, since it looks kind of broken cc @ericglau

@ericglau

ericglau commented Jan 7, 2025

Copy link
Copy Markdown
Member

Applied styling to the date input. cc @ericnordelo

Screenshot 2025-01-07 at 3 07 15 PM

@ericglau ericglau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@immrsd

immrsd commented Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

Results of test project compilation with only Vesting being enabled:

image

@immrsd
immrsd merged commit e08725a into OpenZeppelin:master Jan 13, 2025
@github-actions github-actions Bot mentioned this pull request Jun 20, 2025
@github-actions github-actions Bot mentioned this pull request Aug 20, 2025
This was referenced Sep 9, 2025
@github-actions github-actions Bot mentioned this pull request Sep 16, 2025
@github-actions github-actions Bot mentioned this pull request Jan 10, 2026
@github-actions github-actions Bot mentioned this pull request Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants