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

Feat/LDG-537--nano-app-implement-initialize-method #40

Merged
merged 8 commits into from
Dec 11, 2024

Conversation

keiff3r
Copy link

@keiff3r keiff3r commented Dec 11, 2024

  • Add new instruction INS_INIT_CONTRACT (0x07) for contract initialization
  • Create initContract.c/.h files with handler implementation
  • Add UI flow for displaying contract amount and module reference
  • Add new error codes for name/params length and module ref validation
  • Implement chunked processing for contract name and parameters
  • Add Python test client support for init contract instruction
  • Add test case with snapshots for contract initialization flow
  • Update handler.c and globals.h to support new instruction

The implementation allows users to initialize contracts by providing the
amount, module reference, contract name, and parameters, with appropriate
UI confirmation steps and chunked data processing for larger inputs.

- Add new instruction INS_INIT_CONTRACT (0x07) for contract initialization
- Create initContract.c/.h files with handler implementation
- Add UI flow for displaying contract amount and module reference
- Add new error codes for name/params length and module ref validation
- Implement chunked processing for contract name and parameters
- Add Python test client support for init contract instruction
- Add test case with snapshots for contract initialization flow
- Update handler.c and globals.h to support new instruction

The implementation allows users to initialize contracts by providing the
amount, module reference, contract name, and parameters, with appropriate
UI confirmation steps and chunked data processing for larger inputs.
Comment on lines +36 to +39
// typedef struct {
// uint8_t version[32];
// uint8_t sourceLength[32];
// } deployModuleBlob_t;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@keiff3r keiff3r marked this pull request as ready for review December 11, 2024 13:36
@keiff3r keiff3r requested a review from a team December 11, 2024 13:36
@n4l5u0r n4l5u0r removed the request for review from a team December 11, 2024 13:49
- Increase amountDisplay buffer from 21 to 30 chars in initContract.h
- Update test to use max uint64 value (0xFFFFFFFFFFFFFFFF)
- Update test signature to match new amount value
- Update snapshot images to reflect larger amount display

Fixes buffer overflow issue when displaying large contract amounts by
increasing the display buffer size to accommodate maximum uint64 values.
- Subtract data length from MAX_APDU_LEN when splitting messages
- Fix chunk size calculation in deployModule and initContract
- Update split_message calls to account for header bytes
- Ensure first chunk (len + data) stays within MAX_APDU_LEN limit

Fixes APDU length overflow where first chunk (2 bytes length + data)
exceeded MAX_APDU_LEN by not accounting for the length bytes in the
available space calculation.
@keiff3r keiff3r requested a review from GuilaneDen December 11, 2024 15:23
@n4l5u0r n4l5u0r requested review from a team and removed request for GuilaneDen December 11, 2024 15:38
@n4l5u0r n4l5u0r merged commit 47c776f into main Dec 11, 2024
29 of 30 checks passed
@n4l5u0r n4l5u0r deleted the feat/LDG-537--nano-app-implement-initialize-method branch December 11, 2024 15:40
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