From 129b3808ade61c78fbf8f215ee949a3f76d43c20 Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Wed, 29 Mar 2023 16:13:40 +0200 Subject: [PATCH] =?UTF-8?q?refactor(ethereum):=20=E2=99=BB=EF=B8=8F=20use?= =?UTF-8?q?=20local=20variable=20in=20storage=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/crypto_ethereum.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lua/crypto_ethereum.lua b/src/lua/crypto_ethereum.lua index 43ce9e976..f2402a6ac 100644 --- a/src/lua/crypto_ethereum.lua +++ b/src/lua/crypto_ethereum.lua @@ -45,6 +45,7 @@ end function ETH.encodeRLP(data) local header = nil local res = nil + local byt = nil if type(data) == 'zenroom.big' then data = ETH.n2o(data) @@ -284,13 +285,14 @@ function ETH.make_storage_data(src) offset = O.from_hex('0000000000000000000000000000000000000000000000000000000000000020') -- length as a 256 unsigned integer - if iszen(type(src)) then - src = src:octet() + local src_o = src + if iszen(type(src_o)) then + src_o = src_o:octet() end - bytLen = INT.new(#src):octet() + bytLen = INT.new(#src_o):octet() paddingLength = 32-#bytLen paddingLen = O.zero(paddingLength) - paddingLength = #src % 32 + paddingLength = #src_o % 32 if paddingLength > 0 then paddingLength = 32 - paddingLength padding = O.zero(paddingLength) @@ -299,7 +301,7 @@ function ETH.make_storage_data(src) end -- done with padding - return fId .. offset .. paddingLen .. bytLen .. src .. padding + return fId .. offset .. paddingLen .. bytLen .. src_o .. padding end -- generate an ethereum keypair