Skip to content

fix(ts): encode undefined option args as null#4583

Open
abhinavgautam01 wants to merge 1 commit into
otter-sec:masterfrom
abhinavgautam01:fix/1637-ts-optional-args
Open

fix(ts): encode undefined option args as null#4583
abhinavgautam01 wants to merge 1 commit into
otter-sec:masterfrom
abhinavgautam01:fix/1637-ts-optional-args

Conversation

@abhinavgautam01
Copy link
Copy Markdown

Fixes #1637

Summary

  • Normalizes undefined instruction args to null when the IDL type is option.
  • Prevents buffer-layout from skipping undefined optional fields during instruction encoding.
  • Handles nested option fields inside defined structs/enums as well.
  • Keeps non-option fields unchanged.

Testing

  • yarn prettier src/coder/borsh/instruction.ts tests/coder-instructions.spec.ts --check
  • yarn build:node
  • yarn jest tests/coder-instructions.spec.ts --runInBand
  • yarn test --runInBand
  • git diff --check

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.

TS: Optional fields encoding

1 participant