-
Notifications
You must be signed in to change notification settings - Fork 71
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
NearContract deletion, init, refactoring #200
Conversation
@@ -4,7 +4,7 @@ export default function () { | |||
visitor: { | |||
ClassDeclaration(path) { | |||
let classNode = path.node; | |||
if (classNode.decorators && classNode.decorators[0].expression.name == 'NearBindgen') { | |||
if (classNode.decorators && classNode.decorators[0].expression.callee.name == 'NearBindgen') { |
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.
Not related to this PR, I thought we have set generated .d.ts
and .js
diff not showing in github, but seems it's not working
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.
Not sure... they were hidden for me.
static _reconstruct(classObject: any, plainObject: JSON) { | ||
for (const item in classObject) { | ||
if (classObject[item].constructor?.deserialize !== undefined) { | ||
classObject[item] = classObject[item].constructor.deserialize(plainObject[item]) |
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 is cool!!!
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.
Fantastic work! Solves at least three issues about initialization, default parameters. While most of mentioned behavior has been tested, I'd suggest to add two little tests about:
- init Function panics if called more then once
- the case when
requiredInit: false
but@initialize
is provided
My in-line comments above mentioned a few trivial devX syntax simplification, but they can be hard to implement. Current API is great too.
@ailisp tests added, merging. |
requireInit
flag inNearBindgen
default()
function, deletedNearContract
. Class is deleted, and logic is moved toNearBindgen