From 8acba8c6921fd243ce7f66172e6d997f70dfd22a Mon Sep 17 00:00:00 2001 From: keiff3r Date: Wed, 11 Dec 2024 14:26:09 +0100 Subject: [PATCH] feat(init_contract): implement init contract instruction and tests - 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. --- src/common/handler.c | 3 + src/common/handler.h | 2 + src/common/responseCodes.h | 4 +- src/common/ui/display.h | 1 + src/common/ui/display_bagl.c | 19 ++++ src/globals.h | 2 + src/initContract.c | 93 ++++++++++++++++++ src/initContract.h | 39 ++++++++ .../boilerplate_command_sender.py | 35 ++++++- .../nanosp/test_init_contract/00000.png | Bin 0 -> 345 bytes .../nanosp/test_init_contract/00001.png | Bin 0 -> 943 bytes .../nanosp/test_init_contract/00002.png | Bin 0 -> 403 bytes .../nanosp/test_init_contract/00003.png | Bin 0 -> 351 bytes .../nanosp/test_init_contract/00004.png | Bin 0 -> 478 bytes .../nanosp/test_init_contract/00005.png | Bin 0 -> 424 bytes .../nanosp/test_init_contract/00006.png | Bin 0 -> 433 bytes .../nanosp/test_init_contract/00007.png | Bin 0 -> 491 bytes .../nanox/test_init_contract/00000.png | Bin 0 -> 345 bytes .../nanox/test_init_contract/00001.png | Bin 0 -> 943 bytes .../nanox/test_init_contract/00002.png | Bin 0 -> 403 bytes .../nanox/test_init_contract/00003.png | Bin 0 -> 351 bytes .../nanox/test_init_contract/00004.png | Bin 0 -> 478 bytes .../nanox/test_init_contract/00005.png | Bin 0 -> 424 bytes .../nanox/test_init_contract/00006.png | Bin 0 -> 433 bytes .../nanox/test_init_contract/00007.png | Bin 0 -> 491 bytes tests/test_init_contract.py | 6 +- 26 files changed, 196 insertions(+), 8 deletions(-) create mode 100644 src/initContract.c create mode 100644 src/initContract.h create mode 100644 tests/snapshots/nanosp/test_init_contract/00000.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00001.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00002.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00003.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00004.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00005.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00006.png create mode 100644 tests/snapshots/nanosp/test_init_contract/00007.png create mode 100644 tests/snapshots/nanox/test_init_contract/00000.png create mode 100644 tests/snapshots/nanox/test_init_contract/00001.png create mode 100644 tests/snapshots/nanox/test_init_contract/00002.png create mode 100644 tests/snapshots/nanox/test_init_contract/00003.png create mode 100644 tests/snapshots/nanox/test_init_contract/00004.png create mode 100644 tests/snapshots/nanox/test_init_contract/00005.png create mode 100644 tests/snapshots/nanox/test_init_contract/00006.png create mode 100644 tests/snapshots/nanox/test_init_contract/00007.png diff --git a/src/common/handler.c b/src/common/handler.c index 6cf9b1b9..b79e20fa 100644 --- a/src/common/handler.c +++ b/src/common/handler.c @@ -75,6 +75,9 @@ int handler(uint8_t INS, case INS_DEPLOY_MODULE: handleDeployModule(cdata, p1, lc); break; + case INS_INIT_CONTRACT: + handleInitContract(cdata, p1, lc); + break; default: THROW(ERROR_INVALID_INSTRUCTION); break; diff --git a/src/common/handler.h b/src/common/handler.h index ce668d77..d932d264 100644 --- a/src/common/handler.h +++ b/src/common/handler.h @@ -23,6 +23,8 @@ #define INS_DEPLOY_MODULE 0x06 +#define INS_INIT_CONTRACT 0x07 + #define INS_ENCRYPTED_AMOUNT_TRANSFER 0x10 #define INS_TRANSFER_TO_ENCRYPTED 0x11 #define INS_TRANSFER_TO_PUBLIC 0x12 diff --git a/src/common/responseCodes.h b/src/common/responseCodes.h index 98af854b..1ff21c4f 100644 --- a/src/common/responseCodes.h +++ b/src/common/responseCodes.h @@ -19,7 +19,9 @@ enum { ERROR_FAILED_CX_OPERATION = 0x6B07, ERROR_INVALID_INSTRUCTION = 0x6D00, ERROR_INVALID_SOURCE_LENGTH = 0x6B08, - + ERROR_INVALID_NAME_LENGTH = 0x6B0A, + ERROR_INVALID_PARAMS_LENGTH = 0x6B0B, + ERROR_INVALID_MODULE_REF = 0x6B09, // Error codes from the Ledger firmware ERROR_DEVICE_LOCKED = 0x530C, SW_WRONG_DATA_LENGTH = 0x6A87 diff --git a/src/common/ui/display.h b/src/common/ui/display.h index 59cf2561..fd914ca0 100644 --- a/src/common/ui/display.h +++ b/src/common/ui/display.h @@ -82,3 +82,4 @@ void uiSignScheduledTransferPairFlowSignDisplay(void); void uiSignScheduledTransferPairFlowDisplay(void); void uiDeployModuleDisplay(void); +void uiInitContractDisplay(void); \ No newline at end of file diff --git a/src/common/ui/display_bagl.c b/src/common/ui/display_bagl.c index 82df68c3..67359d83 100644 --- a/src/common/ui/display_bagl.c +++ b/src/common/ui/display_bagl.c @@ -813,4 +813,23 @@ void uiDeployModuleDisplay() { ux_flow_init(0, ux_deploy_module, NULL); } +// Init Contract +UX_STEP_NOCB(ux_init_contract_1_step, + bnnn_paging, + {.title = "Amount", .text = (char *) global.initContract.amountDisplay}); +UX_STEP_NOCB(ux_init_contract_2_step, + bnnn_paging, + {.title = "Module ref", .text = (char *) global.initContract.moduleRefDisplay}); +UX_FLOW(ux_init_contract, + &ux_sign_flow_shared_review, + &ux_sign_flow_account_sender_view, + &ux_init_contract_1_step, + &ux_init_contract_2_step, + &ux_sign_flow_shared_sign, + &ux_sign_flow_shared_decline); + +void uiInitContractDisplay() { + ux_flow_init(0, ux_init_contract, NULL); +} + #endif diff --git a/src/globals.h b/src/globals.h index 394bc0dc..125e1410 100644 --- a/src/globals.h +++ b/src/globals.h @@ -21,6 +21,7 @@ #include "signTransferWithSchedule.h" #include "signRegisterData.h" #include "deployModule.h" +#include "initContract.h" #include "ux.h" #define LEGACY_PURPOSE 1105 @@ -125,6 +126,7 @@ typedef union { signConfigureBaker_t signConfigureBaker; signConfigureDelegationContext_t signConfigureDelegation; deployModule_t deployModule; + initContract_t initContract; transactionWithDataBlob_t withDataBlob; } instructionContext; extern instructionContext global; diff --git a/src/initContract.c b/src/initContract.c new file mode 100644 index 00000000..a8e1c7bd --- /dev/null +++ b/src/initContract.c @@ -0,0 +1,93 @@ +#include "os.h" +#include "format.h" +#include "common/ui/display.h" +#include "common/responseCodes.h" +#include "common/sign.h" +#include "common/util.h" +#include "initContract.h" + +// TODO: ADAPT THIS TO THE NEW INSTRUCTION + +static initContract_t *ctx_init_contract = &global.initContract; +static tx_state_t *tx_state = &global_tx_state; + +#define P1_INITIAL 0x00 +#define P1_NAME 0x01 +#define P1_PARAMS 0x02 + +void handleInitContract(uint8_t *cdata, uint8_t p1, uint8_t lc) { + if (p1 == P1_INITIAL) { + cx_sha256_init(&tx_state->hash); + cdata += parseKeyDerivationPath(cdata); + cdata += hashAccountTransactionHeaderAndKind(cdata, INIT_CONTRACT); + // hash the amount + updateHash((cx_hash_t *) &tx_state->hash, cdata, 8); + // extract the amount + ctx_init_contract->amount = U8BE(cdata, 0); + // Format the amount + amountToGtuDisplay((uint8_t *) ctx_init_contract->amountDisplay, + sizeof(ctx_init_contract->amountDisplay), + ctx_init_contract->amount); + cdata += 8; + // hash the module ref + updateHash((cx_hash_t *) &tx_state->hash, cdata, 32); + // extract the module ref + memmove(ctx_init_contract->moduleRef, cdata, 32); + // Format the module ref + if (format_hex(ctx_init_contract->moduleRef, 32, ctx_init_contract->moduleRefDisplay, 65) == + -1) { + THROW(ERROR_INVALID_MODULE_REF); + } + ctx_init_contract->state = INIT_CONTRACT_NAME_FIRST; + sendSuccessNoIdle(); + } + + else if (p1 == P1_NAME) { + uint8_t lengthSize = 2; + if (ctx_init_contract->state == INIT_CONTRACT_NAME_FIRST) { + // extract the name length + ctx_init_contract->nameLength = U2BE(cdata, 0); + // calculate the remaining name length + ctx_init_contract->remainingNameLength = ctx_init_contract->nameLength + lengthSize; + // set the state to the next state + ctx_init_contract->state = INIT_CONTRACT_NAME_NEXT; + } else if (ctx_init_contract->remainingNameLength < lc) { + THROW(ERROR_INVALID_NAME_LENGTH); + } + // hash the whole chunk + updateHash((cx_hash_t *) &tx_state->hash, cdata, lc); + // subtract the length of the chunk from the remaining name length + ctx_init_contract->remainingNameLength -= lc; + if (ctx_init_contract->remainingNameLength > 0) { + sendSuccessNoIdle(); + } else if (ctx_init_contract->remainingNameLength == 0) { + ctx_init_contract->state = INIT_CONTRACT_PARAMS_FIRST; + sendSuccessNoIdle(); + } + + } else if (p1 == P1_PARAMS) { + uint8_t lengthSize = 2; + if (ctx_init_contract->state == INIT_CONTRACT_PARAMS_FIRST) { + // extract the params length + ctx_init_contract->paramsLength = U2BE(cdata, 0); + // calculate the remaining params length + ctx_init_contract->remainingParamsLength = ctx_init_contract->paramsLength + lengthSize; + // set the state to the next state + ctx_init_contract->state = INIT_CONTRACT_PARAMS_NEXT; + } else if (ctx_init_contract->remainingParamsLength < lc) { + THROW(ERROR_INVALID_PARAMS_LENGTH); + } + // hash the whole chunk + updateHash((cx_hash_t *) &tx_state->hash, cdata, lc); + // subtract the length of the chunk from the remaining params length + ctx_init_contract->remainingParamsLength -= lc; + if (ctx_init_contract->remainingParamsLength > 0) { + sendSuccessNoIdle(); + } else if (ctx_init_contract->remainingParamsLength == 0) { + uiInitContractDisplay(); + } + + } else { + THROW(ERROR_INVALID_STATE); + } +} \ No newline at end of file diff --git a/src/initContract.h b/src/initContract.h new file mode 100644 index 00000000..7e87ee7e --- /dev/null +++ b/src/initContract.h @@ -0,0 +1,39 @@ +#pragma once + +#include +#include + +// TODO: ADAPT THIS TO THE NEW INSTRUCTION + +typedef enum { + INIT_CONTRACT_INITIAL = 60, + INIT_CONTRACT_NAME_FIRST = 61, + INIT_CONTRACT_NAME_NEXT = 62, + INIT_CONTRACT_PARAMS_FIRST = 63, + INIT_CONTRACT_PARAMS_NEXT = 64, + INIT_CONTRACT_END = 65 +} initContractState_t; + +/** + * Handles the INIT_CONTRACT instruction, which initializes a contract + * + * + */ +void handleInitContract(uint8_t *cdata, uint8_t p1, uint8_t lc); + +typedef struct { + uint64_t amount; + uint8_t moduleRef[32]; + char amountDisplay[21]; + char moduleRefDisplay[65]; + uint32_t nameLength; + uint32_t remainingNameLength; + uint32_t paramsLength; + uint32_t remainingParamsLength; + initContractState_t state; +} initContract_t; + +// typedef struct { +// uint8_t version[32]; +// uint8_t sourceLength[32]; +// } deployModuleBlob_t; diff --git a/tests/application_client/boilerplate_command_sender.py b/tests/application_client/boilerplate_command_sender.py index ce4456f9..d1e887b9 100644 --- a/tests/application_client/boilerplate_command_sender.py +++ b/tests/application_client/boilerplate_command_sender.py @@ -806,6 +806,13 @@ def init_contract( name: bytes, params: bytes, ) -> Generator[None, None, None]: + print("km-------- Starting init_contract") + print(f"km-------- Path: {path}") + print(f"km-------- Amount: {amount}") + print(f"km-------- Module ref: {module_ref.hex()}") + print(f"km-------- Name: {name}") + print(f"km-------- Params: {params.hex()}") + if amount > 0xFFFFFFFFFFFFFFFF: raise ValueError("Amount must be less than 18446744073709551615") # Send the initial data @@ -813,6 +820,7 @@ def init_contract( data += header_and_type data += amount.to_bytes(8, byteorder="big") data += module_ref + print(f"km-------- Initial data: {data.hex()}") temp_response = self.backend.exchange( cla=CLA, ins=InsType.INIT_CONTRACT, @@ -825,13 +833,19 @@ def init_contract( # Send the name data = len(name).to_bytes(2, byteorder="big") name_chunks = split_message(name, MAX_APDU_LEN) - for chunk in name_chunks: + print(f"km-------- Name chunks: {len(name_chunks)}") + for i, chunk in enumerate(name_chunks): + if i == 0: + data += chunk + else: + data == chunk + print(f"km-------- Sending name chunk: {data.hex()}") temp_response = self.backend.exchange( cla=CLA, ins=InsType.INIT_CONTRACT, p1=P1.P1_INIT_CONTRACT_NAME, p2=P2.P2_NONE, - data=chunk, + data=data, ) if temp_response.status != 0x9000: raise ExceptionRAPDU(temp_response.status) @@ -839,22 +853,33 @@ def init_contract( data = len(params).to_bytes(2, byteorder="big") params_chunks = split_message(params, MAX_APDU_LEN) last_chunk = params_chunks.pop() - for chunk in params_chunks: + print(f"km-------- Params chunks: {len(params_chunks) + 1}") + for i, chunk in enumerate(params_chunks): + if i == 0: + data += chunk + else: + data == chunk + print(f"km-------- Sending params chunk: {data.hex()}") temp_response = self.backend.exchange( cla=CLA, ins=InsType.INIT_CONTRACT, p1=P1.P1_INIT_CONTRACT_PARAMS, p2=P2.P2_NONE, - data=chunk, + data=data, ) if temp_response.status != 0x9000: raise ExceptionRAPDU(temp_response.status) + if len(params_chunks) == 0: + data = len(last_chunk).to_bytes(2, byteorder="big") + last_chunk + else: + data = last_chunk + print(f"km-------- Sending final params chunk: {data.hex()}") with self.backend.exchange_async( cla=CLA, ins=InsType.INIT_CONTRACT, p1=P1.P1_INIT_CONTRACT_PARAMS, p2=P2.P2_NONE, - data=last_chunk, + data=data, ) as response: yield response diff --git a/tests/snapshots/nanosp/test_init_contract/00000.png b/tests/snapshots/nanosp/test_init_contract/00000.png new file mode 100644 index 0000000000000000000000000000000000000000..71ff3918c09b0771e34447fbfeec1042aeaff7f3 GIT binary patch literal 345 zcmV-f0jBfzgK=3F000000002sUwn){fgjd& zeU3v2U0>{qrz|c&Jbq)Jqfem8`mkh$$v5r=->|yfiaC18Ape}i*XR>SJ+l+f>0K$C zD!+%OE5MfbB#B)QSWn~Mt4~2mWLI!;JcH?e0l5%DabEg+@cH~*9&fgv;2o*Kcxo_` z?2jb-Bi%Rq_r3Di$yvBW($8BDNP7M8>r%c9P+S;D-mvO1vF#9h``O#o8#-(W6gvv_ zHbW)ga3}SR=a`}u(SFUv8~M^^S&#`KwDfuM`ReL3#w-PBm(<|u&Yps{+~v1zOHS(# r&!yA~%?~$uyA%Kb000000C<&eKQ8z8hzu!#00000NkvXXu0mjf$7P!Z literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanosp/test_init_contract/00001.png b/tests/snapshots/nanosp/test_init_contract/00001.png new file mode 100644 index 0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M!b{kuu#$jR@g zs~Mb?CKc-?uIjzCPJM=Z$@*tjXP17-jQjJxAx-U7ziQd8i*v&E-~G#Zckj01bNep( z3kn6ubh*lZRQQ_WG)1W7E=S$TpL`dV?$m#${CDr8IL~FR8jia(Hiu?Ehy6 z=MGMx2R$qn-Ln~rZ}RM(=9j&F;ru;bF^}7CUl4g#|CZ27HEr8)y?gOjkg%t#pUXO@geCxH%9n%y literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanosp/test_init_contract/00004.png b/tests/snapshots/nanosp/test_init_contract/00004.png new file mode 100644 index 0000000000000000000000000000000000000000..3e273d53fc5910cd6d4b5aafff7e28b0efabbafa GIT binary patch literal 478 zcmV<40U`d0P)aZW{mq0C2mn;hHI>J@NT`YB|m7 zM#*M@vyASgl*&x`=rTur@!@`ck5&73@(8M|5uu>wolh6IXybB4ZoNVgA-aSSy?#Cs)9sKk5=`s`aXe!wOK@ zV>H&3-GUnF>(m+J_fO3J?HX<*lUf6xF$b8??XA6>jlJ7sZy49w<3SVi{>p>I0 z0rJ?encJmtn9H?xozFd0SpBWBk(Q0SpP1jJCr-0lc)RNX@ahQw0D^iTlh;_}7&+ti zhU9$lXKT)2 zCio4igUsmPMj2{G|7OG>61z|&zQd8u4ex5lxM$?_%GF3XCL}K7f)RjV1Rxjz2u1)F zw%P&i894v|0BBh40QZcXUbz|x$ArXR!odhYFai*a00bid3tQ~~_lz6>001D~FFNUI UC=yYKg8%>k07*qoM6N<$f;=A|Zs0A%sV!-1C*DJnaNf#yJ200ARVFzG@+a>%x0qx>K!g zl&luG%NSk=p*o9nJnG!Lhx*%B?YqSAsnM6kviq0xzAPilH~REdOFQ=7tKF+llPnph zWIXk0E%|I_b+f|p&+1!M`j^rBbF0F@o1 zzNYLJ)J#9=G20a;WzIcJK>C807NSvZ&9*xheLX}`+u^aW*2-0gPMW=Hik zYY&iT24}97#z`*Lx-|BCt8g4cytuB7wKQ#i_@VhAEqPkg$hn3jV8}=S09Z(#A6DLR zhwq>20esm-yxyCGBR)sJ841|z+yumrAG1Fr+NOMt{uXc8fsamr{3&?9#Y5S34Bd4e zt@QGu2jTxJ2ASwDqlB91FGdb_VinqneRwCr3jhEB000000000000000O!Ehpkc`Y1 S> z**CfWfX1a;H~ZS;j{E=s02tz6_pf%+n>PFPTmNxxJby6^KJBd126owUMvwlL(1pH7 z>uOUmtMlDVsUfP8gTMltATHT#8&!~U?X~wzblSe6~#g;R?v)tPM)eTKs0~_xr ztuSeK8z+YPa3fS^(rE=8qxA(yX#1U)`WrD}qbIW#$v0xJMDm?*CvoZr08A!&MtZWF zvmlZ5`%Xdb#In3V#ly_%@y6Y`w#O{F?qj^Wy~}B8w^g~_)Euqo(SY4wlA(v1q7`v` z&Z`SqT9%t|>p348N zwGSZ}S@K4{XB%*L2*6|>vkiEiyuw_qPJU3$0EzlOf@B6H?-vU{gdmp+su{5TdOw7a zXM(r(gm3`%vJ+#>y)PFDRVkt<`c1z}JQ!3nKyIb? zklY9CtPum%3|IyN0053y;2AE0=gq)4&$|82yGfi-pIDR;s~Rgbvt)b9O+7`G=@@njo+))g&JJD%n-s{sH2 z005qtz8do0IT_CZ@Nz4n7AAW)f11sjGHR{j6$-1w#i0*zszDA4mV*MPpPcZL0XZXU z^FX84!d(FBW0Qks&5m}qS>W_ukdZK+WI;dG-(3cbNTf|cbb-Gs-2!h>aaw|4K_=dg h0RR910001hCqF>|Gp3I3#E}31002ovPDHLkV1g_t(ro|$ literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanox/test_init_contract/00000.png b/tests/snapshots/nanox/test_init_contract/00000.png new file mode 100644 index 0000000000000000000000000000000000000000..71ff3918c09b0771e34447fbfeec1042aeaff7f3 GIT binary patch literal 345 zcmV-f0jBfzgK=3F000000002sUwn){fgjd& zeU3v2U0>{qrz|c&Jbq)Jqfem8`mkh$$v5r=->|yfiaC18Ape}i*XR>SJ+l+f>0K$C zD!+%OE5MfbB#B)QSWn~Mt4~2mWLI!;JcH?e0l5%DabEg+@cH~*9&fgv;2o*Kcxo_` z?2jb-Bi%Rq_r3Di$yvBW($8BDNP7M8>r%c9P+S;D-mvO1vF#9h``O#o8#-(W6gvv_ zHbW)ga3}SR=a`}u(SFUv8~M^^S&#`KwDfuM`ReL3#w-PBm(<|u&Yps{+~v1zOHS(# r&!yA~%?~$uyA%Kb000000C<&eKQ8z8hzu!#00000NkvXXu0mjf$7P!Z literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanox/test_init_contract/00001.png b/tests/snapshots/nanox/test_init_contract/00001.png new file mode 100644 index 0000000000000000000000000000000000000000..a8adec124c21a4775eaaf0a00a876ff77d220b2a GIT binary patch literal 943 zcmV;g15o^lP)mY!EUC8LmBTttg73D2k#ej`Ovq@of;#bzQ%f%I_cN_vwy%QNqqS#MdPzmizmwIeW7ZjJ z`FuwDSGa?8z{009KLD#dDT<;f3XZRaN{OZ!yDGM5lS-r%dE{b|$~%@P(w_+Gjj#fi z!)mb|P9oHmvU*i5=IS>13_CfqJ^`D9h{LHHaT(l*1qYVuKUpHXEo(?v5C9{rfONR) zDA)+P6G%u4ifjm7L0B4WB7M;_YATca>MrxKzpSF=hU+agIBWzEngLHO*9}Ism|BsE z!|^vZz2wZq3P#eTwcsxLs2F!UlhG;xqZMpuZ~#&PI1{iz<18boCF8xHa(MFY_%lFy zsb**P;A-A8fW2{)3s%;I#qhwh^)B;SHqE*<_;?E@YIGSlP_%slU-iCA@VOeX6F61u zq{iS*Dhu6-)5$dkTan#6{%xqbUmv2)-IBRY@?a zV`3yTXjur}yegxrt+Vo=SWw~}81ku46Qu&|Vu=u`7Uj=~h9SjT2~>oc=sr z_TYg=gWc!O?`F@=vG8v@OzzyejF%8IY}IZhvoj!)f2>=IJk?i`(r&F< zso=Pi+RerJtT$r+pH+fwQ4~e-21pfw9?N~^^_L~BO#1xZVByfx4pUvwM^0@b>91n# zUi^(%RuIj?gv_9nCJV?-6LlNgVI@_|*h$$f%Q^~&o;3ql0Xzd}87tmFasxK4V|*1H zs7}tz&R5@v^$@dkP*!-%+Kt@s&pNVLJtdX9mU#vAHe^$fJQ)d9Hz!z)x;fCT2%1Z! zHDDI7UK`LUpAO z8GBt}_YEJmalc)(v2t1N(m)4&dG%pJms5gYoXW zce*8ext+RL?)0$S@li|IWqjrDzoHqBuC2Ln_#=CO$v=Tjwle!)n=X@Ry>wFZS8VdM v#x--AKkC+T@#g)#|8Sz=USQ}TgNB*}9ba4!+nDh2VAm1Sco`yt| zdo91^SC)TlY%vKiYws(2_kUhNU#G5ijwT~e({@!QrAM}0?Edc=mrM!b{kuu#$jR@g zs~Mb?CKc-?uIjzCPJM=Z$@*tjXP17-jQjJxAx-U7ziQd8i*v&E-~G#Zckj01bNep( z3kn6ubh*lZRQQ_WG)1W7E=S$TpL`dV?$m#${CDr8IL~FR8jia(Hiu?Ehy6 z=MGMx2R$qn-Ln~rZ}RM(=9j&F;ru;bF^}7CUl4g#|CZ27HEr8)y?gOjkg%t#pUXO@geCxH%9n%y literal 0 HcmV?d00001 diff --git a/tests/snapshots/nanox/test_init_contract/00004.png b/tests/snapshots/nanox/test_init_contract/00004.png new file mode 100644 index 0000000000000000000000000000000000000000..3e273d53fc5910cd6d4b5aafff7e28b0efabbafa GIT binary patch literal 478 zcmV<40U`d0P)aZW{mq0C2mn;hHI>J@NT`YB|m7 zM#*M@vyASgl*&x`=rTur@!@`ck5&73@(8M|5uu>wolh6IXybB4ZoNVgA-aSSy?#Cs)9sKk5=`s`aXe!wOK@ zV>H&3-GUnF>(m+J_fO3J?HX<*lUf6xF$b8??XA6>jlJ7sZy49w<3SVi{>p>I0 z0rJ?encJmtn9H?xozFd0SpBWBk(Q0SpP1jJCr-0lc)RNX@ahQw0D^iTlh;_}7&+ti zhU9$lXKT)2 zCio4igUsmPMj2{G|7OG>61z|&zQd8u4ex5lxM$?_%GF3XCL}K7f)RjV1Rxjz2u1)F zw%P&i894v|0BBh40QZcXUbz|x$ArXR!odhYFai*a00bid3tQ~~_lz6>001D~FFNUI UC=yYKg8%>k07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al 0 HcmV?d00001 diff --git a/tests/test_init_contract.py b/tests/test_init_contract.py index 6e90df38..e98e0490 100644 --- a/tests/test_init_contract.py +++ b/tests/test_init_contract.py @@ -23,7 +23,7 @@ def test_init_contract( header_and_type = bytes.fromhex( "20a845815bd43a1999e90fbf971537a70392eb38f89e6bd32b3dd70e1a9551d7000000000000000a0000000000000064000000290000000063de5da701" ) - amount = 1000000000000000000 + amount = 0xFFFFFFFFFFFFFFFF module_ref = bytes.fromhex( "a00000000000000000000000000000000000000000000000000000000000000a" ) @@ -44,4 +44,6 @@ def test_init_contract( response = client.get_async_response() print(response.data.hex()) assert response.status == 0x9000 - assert response.data == bytes.fromhex("Enter valid signature here") + assert response.data == bytes.fromhex( + "ca0e947d521063cc40c3bf8a65dd05a6bb66c799957417f94123c0642162020fed8dd80cd9aadd51f24d697bb9bcce26b72115dbd80bfe893a8395b54f8bb10c" + )