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

fix(legacy): fix the display issue in conflux transactions where data… #575

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: 'https://releases.nixos.org/nix/nix-2.23.3/install'
name: "Run style check"
- run: nix-shell --run "poetry install"
- run: nix-shell --run "poetry run make style_check"
Expand All @@ -26,6 +27,7 @@ jobs:
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: 'https://releases.nixos.org/nix/nix-2.23.3/install'
name: "Run defs check"
- run: nix-shell --run "poetry install"
- run: nix-shell --run "poetry run make defs_check"
Expand All @@ -41,6 +43,7 @@ jobs:
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: 'https://releases.nixos.org/nix/nix-2.23.3/install'
name: "Run gen check"
- run: nix-shell --run "poetry install"
- run: nix-shell --run "poetry run make gen_check"
Expand Down
53 changes: 18 additions & 35 deletions legacy/firmware/conflux.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static bool layoutConfluxConfirmTx(
uint8_t *to, uint32_t to_len, const char *signer, const uint8_t *value,
uint32_t value_len, const ConfluxTokenType *token, uint32_t chain_ids,
const uint8_t *gas_price, uint32_t gas_price_len, const uint8_t *gas_limit,
uint32_t gas_limit_len, bool has_data) {
uint32_t gas_limit_len, const uint8_t *data, uint32_t data_len) {
bignum256 val = {0}, gas = {0};
uint8_t pad_val[32] = {0};
char gas_value[32] = {0};
Expand All @@ -414,17 +414,12 @@ static bool layoutConfluxConfirmTx(
} else {
strlcpy(to_str, _("to new contract?"), sizeof(to_str));
}
confluxFormatAmount(&val, token, amount, sizeof(amount));
if (token == NULL) {
if (bn_is_zero(&val) && has_data) {
strcpy(amount, _("message")); // contract
} else {
confluxFormatAmount(&val, NULL, amount, sizeof(amount));
return layoutTransactionSign(
"Conflux", 0, false, amount, to_str, signer, NULL, NULL, NULL, 0,
_("Maximum Fee:"), gas_value, NULL, NULL, NULL, NULL, NULL, NULL);
}
return layoutTransactionSign("Conflux", 0, false, amount, to_str, signer,
NULL, NULL, data, data_len, _("Maximum Fee:"),
gas_value, NULL, NULL, NULL, NULL, NULL, NULL);
} else {
confluxFormatAmount(&val, token, amount, sizeof(amount));
return layoutTransactionSign("Conflux", 0, true, amount, to_str, signer,
NULL, NULL, NULL, 0, _("Maximum Fee"),
gas_value, NULL, NULL, NULL, NULL, NULL, NULL);
Expand Down Expand Up @@ -565,36 +560,24 @@ void conflux_signing_init(ConfluxSignTx *msg, const HDNode *node) {
}

if (token != NULL) {
if (!layoutConfluxConfirmTx(
msg->data_initial_chunk.bytes + 16, 20, signer,
msg->data_initial_chunk.bytes + 36, 32, token, msg->chain_id,
msg->gas_price.bytes, msg->gas_price.size, msg->gas_limit.bytes,
msg->gas_limit.size, data_total > 0 ? true : false)) {
if (!layoutConfluxConfirmTx(msg->data_initial_chunk.bytes + 16, 20, signer,
msg->data_initial_chunk.bytes + 36, 32, token,
msg->chain_id, msg->gas_price.bytes,
msg->gas_price.size, msg->gas_limit.bytes,
msg->gas_limit.size, NULL, 0)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
conflux_signing_abort();
return;
}
} else {
if (toset) {
if (!layoutConfluxConfirmTx(pubkeyhash, 20, signer, msg->value.bytes,
msg->value.size, NULL, msg->chain_id,
msg->gas_price.bytes, msg->gas_price.size,
msg->gas_limit.bytes, msg->gas_limit.size,
data_total > 0 ? true : false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
conflux_signing_abort();
return;
}
} else {
if (!layoutConfluxConfirmTx(pubkeyhash, 0, signer, msg->value.bytes,
msg->value.size, NULL, msg->chain_id,
msg->gas_price.bytes, msg->gas_price.size,
msg->gas_limit.bytes, msg->gas_limit.size,
data_total > 0 ? true : false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
conflux_signing_abort();
return;
}
if (!layoutConfluxConfirmTx(
pubkeyhash, toset ? 20 : 0, signer, msg->value.bytes,
msg->value.size, NULL, msg->chain_id, msg->gas_price.bytes,
msg->gas_price.size, msg->gas_limit.bytes, msg->gas_limit.size,
msg->data_initial_chunk.bytes, msg->data_initial_chunk.size)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
conflux_signing_abort();
return;
}
}

Expand Down
Loading