Skip to content

Commit

Permalink
rework warning fixing and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alinat committed Oct 3, 2024
1 parent 6ce44f3 commit 3767bc6
Show file tree
Hide file tree
Showing 13 changed files with 1,297 additions and 1,531 deletions.
10 changes: 5 additions & 5 deletions docs/reference/rust-api/src/ton_client/debot/routines.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@
<span class="macro">debug</span><span class="macro">!</span>(<span class="string">&quot;genKeypairFromSecret({})&quot;</span>, <span class="ident">arg_json</span>);
<span class="ident">nacl_box_gen_keypair</span>(<span class="ident">ton</span>, <span class="ident">arg_json</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">keypair</span><span class="op">|</span> {
<span class="macro">json</span><span class="macro">!</span>({
<span class="string">&quot;publicKey&quot;</span> : <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">keypair</span>.<span class="ident">public</span>),
<span class="string">&quot;secretKey&quot;</span>: <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">keypair</span>.<span class="ident">secret</span>)
<span class="string">&quot;public_key&quot;</span> : <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">keypair</span>.<span class="ident">public</span>),
<span class="string">&quot;secret_key&quot;</span>: <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">keypair</span>.<span class="ident">secret</span>)
})
})
}
Expand Down Expand Up @@ -552,8 +552,8 @@
}

<span class="kw">pub</span>(<span class="kw">super</span>) <span class="kw">fn</span> <span class="ident">nacl_box</span>(<span class="ident">ton</span>: <span class="ident">TonClient</span>, <span class="ident">args</span>: <span class="ident">serde_json</span>::<span class="ident">Value</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">String</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">public</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;publicKey&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">secret</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;secretKey&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">public</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;public_key&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">secret</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;secret_key&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="kw">crate</span>::<span class="ident">crypto</span>::<span class="ident">nacl_box</span>(
<span class="ident">ton</span>,
<span class="ident">ParamsOfNaclBox</span> {
Expand Down Expand Up @@ -642,4 +642,4 @@
}
</pre></div>
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="ton_client" data-search-js="../../../search-index.js"></div>
<script src="../../../main.js"></script><script src="../../../source-script.js"></script><script src="../../../source-files.js"></script></body></html>
<script src="../../../main.js"></script><script src="../../../source-script.js"></script><script src="../../../source-files.js"></script></body></html>
26 changes: 13 additions & 13 deletions docs/reference/rust-api/src/ton_client/debot/sdk_interface.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@
{&quot;name&quot;:&quot;answerId&quot;,&quot;type&quot;:&quot;uint32&quot;},
{&quot;name&quot;:&quot;decrypted&quot;,&quot;type&quot;:&quot;bytes&quot;},
{&quot;name&quot;:&quot;nonce&quot;,&quot;type&quot;:&quot;bytes&quot;},
{&quot;name&quot;:&quot;publicKey&quot;,&quot;type&quot;:&quot;uint256&quot;},
{&quot;name&quot;:&quot;secretKey&quot;,&quot;type&quot;:&quot;uint256&quot;}
{&quot;name&quot;:&quot;public_key&quot;,&quot;type&quot;:&quot;uint256&quot;},
{&quot;name&quot;:&quot;secret_key&quot;,&quot;type&quot;:&quot;uint256&quot;}
],
&quot;outputs&quot;: [
{&quot;name&quot;:&quot;encrypted&quot;,&quot;type&quot;:&quot;bytes&quot;}
Expand All @@ -932,8 +932,8 @@
{&quot;name&quot;:&quot;answerId&quot;,&quot;type&quot;:&quot;uint32&quot;},
{&quot;name&quot;:&quot;encrypted&quot;,&quot;type&quot;:&quot;bytes&quot;},
{&quot;name&quot;:&quot;nonce&quot;,&quot;type&quot;:&quot;bytes&quot;},
{&quot;name&quot;:&quot;publicKey&quot;,&quot;type&quot;:&quot;uint256&quot;},
{&quot;name&quot;:&quot;secretKey&quot;,&quot;type&quot;:&quot;uint256&quot;}
{&quot;name&quot;:&quot;public_key&quot;,&quot;type&quot;:&quot;uint256&quot;},
{&quot;name&quot;:&quot;secret_key&quot;,&quot;type&quot;:&quot;uint256&quot;}
],
&quot;outputs&quot;: [
{&quot;name&quot;:&quot;decrypted&quot;,&quot;type&quot;:&quot;bytes&quot;}
Expand All @@ -946,8 +946,8 @@
{&quot;name&quot;:&quot;secret&quot;,&quot;type&quot;:&quot;uint256&quot;}
],
&quot;outputs&quot;: [
{&quot;name&quot;:&quot;publicKey&quot;,&quot;type&quot;:&quot;uint256&quot;},
{&quot;name&quot;:&quot;secretKey&quot;,&quot;type&quot;:&quot;uint256&quot;}
{&quot;name&quot;:&quot;public_key&quot;,&quot;type&quot;:&quot;uint256&quot;},
{&quot;name&quot;:&quot;secret_key&quot;,&quot;type&quot;:&quot;uint256&quot;}
]
},
{
Expand Down Expand Up @@ -1238,8 +1238,8 @@
<span class="kw-2">&amp;</span><span class="ident">hex</span>::<span class="ident">decode</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="ident">args</span>, <span class="string">&quot;decrypted&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">e</span>))<span class="question-mark">?</span>,
);
<span class="kw">let</span> <span class="ident">nonce</span> <span class="op">=</span> <span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;nonce&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">public</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;publicKey&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">secret</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;secretKey&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">public</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;public_key&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">secret</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;secret_key&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">nacl_box</span>(
<span class="self">self</span>.<span class="ident">ton</span>.<span class="ident">clone</span>(),
<span class="ident">ParamsOfNaclBox</span> {
Expand All @@ -1262,8 +1262,8 @@
<span class="kw-2">&amp;</span><span class="ident">hex</span>::<span class="ident">decode</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="ident">args</span>, <span class="string">&quot;encrypted&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">e</span>))<span class="question-mark">?</span>,
);
<span class="kw">let</span> <span class="ident">nonce</span> <span class="op">=</span> <span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;nonce&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">public</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;publicKey&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">secret</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;secretKey&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">public</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;public_key&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">secret</span> <span class="op">=</span> <span class="ident">decode_abi_bigint</span>(<span class="kw-2">&amp;</span><span class="ident">get_arg</span>(<span class="kw-2">&amp;</span><span class="ident">args</span>, <span class="string">&quot;secret_key&quot;</span>)<span class="question-mark">?</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">e</span><span class="op">|</span> <span class="ident">e</span>.<span class="ident">to_string</span>())<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">nacl_box_open</span>(
<span class="self">self</span>.<span class="ident">ton</span>.<span class="ident">clone</span>(),
<span class="ident">ParamsOfNaclBoxOpen</span> {
Expand Down Expand Up @@ -1293,8 +1293,8 @@
<span class="prelude-val">Ok</span>((
<span class="ident">answer_id</span>,
<span class="macro">json</span><span class="macro">!</span>({
<span class="string">&quot;publicKey&quot;</span>: <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">result</span>.<span class="ident">public</span>),
<span class="string">&quot;secretKey&quot;</span>: <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">result</span>.<span class="ident">secret</span>.<span class="ident">get</span>(<span class="number">0</span>..<span class="number">64</span>).<span class="ident">ok_or</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;secret key is invalid&quot;</span>))<span class="question-mark">?</span>)
<span class="string">&quot;public_key&quot;</span>: <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">result</span>.<span class="ident">public</span>),
<span class="string">&quot;secret_key&quot;</span>: <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;0x{}&quot;</span>, <span class="ident">result</span>.<span class="ident">secret</span>.<span class="ident">get</span>(<span class="number">0</span>..<span class="number">64</span>).<span class="ident">ok_or</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;secret key is invalid&quot;</span>))<span class="question-mark">?</span>)
}),
))
}
Expand Down Expand Up @@ -1450,4 +1450,4 @@
}
</pre></div>
</section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="ton_client" data-search-js="../../../search-index.js"></div>
<script src="../../../main.js"></script><script src="../../../source-script.js"></script><script src="../../../source-files.js"></script></body></html>
<script src="../../../main.js"></script><script src="../../../source-script.js"></script><script src="../../../source-files.js"></script></body></html>
20 changes: 10 additions & 10 deletions tvm_cli/tests/samples/Sdk.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ function naclSignKeypairFromSecretKey (uint32 answerId, uint256 secret) externa
//string
function substring(uint32 answerId, string str, uint32 start, uint32 count) external returns (string substr);
//crypto
function naclBox(uint32 answerId, bytes decrypted, bytes nonce, uint256 publicKey, uint256 secretKey) external returns (bytes encrypted);
function naclBoxOpen(uint32 answerId, bytes encrypted, bytes nonce, uint256 publicKey, uint256 secretKey) external returns (bytes decrypted);
function naclKeypairFromSecret(uint32 answerId, uint256 secret) external returns (uint256 publicKey, uint256 secretKey);
function naclBox(uint32 answerId, bytes decrypted, bytes nonce, uint256 public_key, uint256 secret_key) external returns (bytes encrypted);
function naclBoxOpen(uint32 answerId, bytes encrypted, bytes nonce, uint256 public_key, uint256 secret_key) external returns (bytes decrypted);
function naclKeypairFromSecret(uint32 answerId, uint256 secret) external returns (uint256 public_key, uint256 secret_key);
//query
function getAccountsDataByHash(uint32 answerId, uint256 codeHash, address gt) external returns (AccData[] accounts);
}
Expand Down Expand Up @@ -124,13 +124,13 @@ library Sdk {
ISdk(addr).substring(answerId, str, start, count);
}

function naclBox(uint32 answerId, bytes decrypted, bytes nonce, uint256 publicKey, uint256 secretKey) public pure {
function naclBox(uint32 answerId, bytes decrypted, bytes nonce, uint256 public_key, uint256 secret_key) public pure {
address addr = address.makeAddrStd(DEBOT_WC, ID);
ISdk(addr).naclBox(answerId, decrypted, nonce, publicKey, secretKey);
ISdk(addr).naclBox(answerId, decrypted, nonce, public_key, secret_key);
}
function naclBoxOpen(uint32 answerId, bytes decrypted, bytes nonce, uint256 publicKey, uint256 secretKey) public pure {
function naclBoxOpen(uint32 answerId, bytes decrypted, bytes nonce, uint256 public_key, uint256 secret_key) public pure {
address addr = address.makeAddrStd(DEBOT_WC, ID);
ISdk(addr).naclBoxOpen(answerId, decrypted, nonce, publicKey, secretKey);
ISdk(addr).naclBoxOpen(answerId, decrypted, nonce, public_key, secret_key);
}
function naclKeypairFromSecret(uint32 answerId, uint256 secret) public pure {
address addr = address.makeAddrStd(DEBOT_WC, ID);
Expand Down Expand Up @@ -170,9 +170,9 @@ function naclSignKeypairFromSecretKey (uint32 answerId, uint256 secret) externa
//string
function substring(uint32 answerId, string str, uint32 start, uint32 count) external override returns (string substr) {}
//crypto
function naclBox(uint32 answerId, bytes decrypted, bytes nonce, uint256 publicKey, uint256 secretKey) external override returns (bytes encrypted) {}
function naclBoxOpen(uint32 answerId, bytes encrypted, bytes nonce, uint256 publicKey, uint256 secretKey) external override returns (bytes decrypted) {}
function naclKeypairFromSecret(uint32 answerId, uint256 secret) external override returns (uint256 publicKey, uint256 secretKey) {}
function naclBox(uint32 answerId, bytes decrypted, bytes nonce, uint256 public_key, uint256 secret_key) external override returns (bytes encrypted) {}
function naclBoxOpen(uint32 answerId, bytes encrypted, bytes nonce, uint256 public_key, uint256 secret_key) external override returns (bytes decrypted) {}
function naclKeypairFromSecret(uint32 answerId, uint256 secret) external override returns (uint256 public_key, uint256 secret_key) {}
//query
function getAccountsDataByHash(uint32 answerId, uint256 codeHash, address gt) external override returns (AccData[] accounts) {}
}
Loading

0 comments on commit 3767bc6

Please sign in to comment.