-
Notifications
You must be signed in to change notification settings - Fork 126
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
refactor(governance-sdk): DRYer Borsh classes, remove repeated properties & constructors #496
base: main
Are you sure you want to change the base?
Conversation
@johnrees is attempting to deploy a commit to the Solana Team on Vercel. A member of the Team first needs to authorize it. |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/solana-labs/oyster-governance/9HgRZw78xnb7Y5XVCwf4u4FbRiGD |
export abstract class BorshClass<T> { | ||
constructor(args: T) { | ||
Object.assign(this, args); | ||
} | ||
} |
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.
BorshClass
is just a simple helper class that assigns the keys from the args object to properties on the instance
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 could probably be a decorator tbh but I didn't want to get too weird with it yet
This is a proposal to refactor serializable Borsh classes so that there is no repetition of their arguments, as this can create a lot of extra lines of code that devs might potentially forget to update when adding/removing/updating struct properties.
Example 1. Class with no custom properties and/or instance methods
before
after
Example 2. Class with custom properties and/or instance methods
before
after
TODO
this.isWritable = !!args.isWritable;