Skip to content

fix(ts): validate instruction args before borsh encode#4560

Open
swaroop-osec wants to merge 2 commits into
otter-sec:masterfrom
swaroop-osec:fix/instruction-encode-arg-validation
Open

fix(ts): validate instruction args before borsh encode#4560
swaroop-osec wants to merge 2 commits into
otter-sec:masterfrom
swaroop-osec:fix/instruction-encode-arg-validation

Conversation

@swaroop-osec
Copy link
Copy Markdown
Collaborator

Fixes #2615

@jamie-osec
Copy link
Copy Markdown
Collaborator

@swaroop-osec Please fix the lint issues

Copy link
Copy Markdown
Collaborator

@0x4ka5h 0x4ka5h left a comment

Choose a reason for hiding this comment

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

the pr looks good to me, expect that case which i'm not sure about. @jamie-osec can you have a look at it once.

}
const missing = encoder.args
.map((a) => a.name)
.filter((name) => !(name in ix));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i'm not sure about using in here. I got this explanation from GPT

in returns true when the property exists anywhere in the prototype chain, not just as an own property. Every plain {} inherits a fixed set of property names from Object.prototype
e.g; "toString" in {} -> true

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.

Add field validation to instruction.encode

3 participants