Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vesting #425

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Add Vesting #425

wants to merge 12 commits into from

Conversation

immrsd
Copy link
Contributor

@immrsd immrsd commented Dec 24, 2024

No description provided.

@immrsd immrsd self-assigned this Dec 24, 2024
Copy link

socket-security bot commented Dec 24, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

View full report↗︎

Copy link

socket-security bot commented Dec 24, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

Copy link
Contributor

@andrew-fleming andrew-fleming left a comment

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
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
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
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
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

if (!match) {
if (!match || match.length < 2) {
Copy link
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
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

Copy link
Member

@ericglau ericglau left a comment

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.

case 'Governor':
case 'Custom':
return c.options.upgradeable === isUpgradeable;
}
Copy link
Member

Choose a reason for hiding this comment

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

In case we add new contract kinds and forget to update this later on, this will help force a compile error:

Suggested change
}
default:
const _: never = c.options;
throw new Error('Unknown kind');
}

Comment on lines +70 to +71
// These contracts have no acess control
return
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// These contracts have no acess control
return
// These contracts have no access control option
break;

} else {
t.notRegex(contract.source, regexOwnable, JSON.stringify(contract.options));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

In case we add new contract kinds and forget to update this later on, this will help force a compile error:

Suggested change
}
}
break;
default:
const _: never = contract.options;
throw new Error('Unknown kind');

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.

3 participants