- https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/bit_array/bit_array.rb#L56-L59 is this the right algorithm to do that? seems like
read_cursor
is not taken into account at all when reading (as an index), but the actual bit length that is read is not the specifiedbits_amount
, butread_cursor + bits_amount
! same with read_sint - https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/bit_array/bit_array.rb#L36-L39 the index is not properly checked - the start of the byte is checked against the length of the array, but the end index of the byte is not, and I believe this will actually lead to different results when you say, read a byte that overlaps with the end, append a bit or two, then re-read the byte - the byte values will be different even if you append
0
bits - https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/bit_array/bit_array.rb#L78-L94 - again, seems like the index is not properly checked when it's near the end of the array
- https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/boc/builder.rb#L104-L119 - there's no check that
value
does not exceedlength
, same withvar_uint
- https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/boc/builder.rb#L189-L196 - this doesn't seem right. Refer to https://github.com/ton-blockchain/ton/blob/65d22c46d9955041baad11a5dbd9a2c8c21beaf9/crypto/block/block.tlb#L36-L37 - when a dict is empty, it is stored as a
0
bit and nothing else. When it is not, it is stored as a1
bit and a ref with its serialization. To avoid confusion, the JS library has 2 methods to store dicts https://github.com/ton-org/ton-core/blob/562fb15f33544db73a932b20f4ae3ee60c977562/src/boc/Builder.ts#L450-L467 - one stores the dicts as I described (asHashmapE
) (storeDict
), and another stores the serialized dict directly into the builder, or throws if it's empty (storeDictDirect
) - https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/johnny_mnemonic/ton_mnemonic.rb#L41 - if ruby has a bit limit for integers, then
min
andmax
likely need to be checked in the same fashion. If not, this check is unnecessary - https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby/types/coins.rb#L12-L36 - this is rather confusing, because
nano
inherently means decimals = 9. IMO it would be better to store coins in terms ofnanoTON
s always, because that's the way it is stored in TON everywhere (you can't subdivide ananoTON
any further onchain), then it's just a simple integer, and you can have convenience methods to get/set/construct Coins using BigDecimals/strings/floats/anything else. The current logic with decimals and whatnot looks confusing - The import from the example fails on these lines https://github.com/nerzh/ton-sdk-ruby/blob/13ad5b3d7a6df843b975a4289c0d1b3ae657ee9c/lib/ton-sdk-ruby.rb#L10-L12, changing them to
require_relative './ton-sdk-ruby/types/address'; require_relative './ton-sdk-ruby/types/block'; require_relative './ton-sdk-ruby/types/coins'
(locally) fixes the bug - the smc package gives the following warning when importing:
.../ton-sdk-ruby-smc-0.0.5/lib/ton-sdk-ruby-smc/wallets/wallet_v4.rb:41: warning: already initialized constant TonSdkRubySmc::SUB_WALLET_ID; .../ton-sdk-ruby-smc-0.0.5/lib/ton-sdk-ruby-smc/wallets/wallet_v3.rb:43: warning: previous definition of SUB_WALLET_ID was here
- mnemonic generation algorithm is bad - it only generates mnemonics with words starting from
a
, likelyget_secure_random_number
has a bug - wallets must implement getting seqno through the get method, parsing storage is not the way to do that
- wallet v4 has copypasted code from wallet v3 https://github.com/nerzh/ton-sdk-ruby-smc/blob/92a458ac5e0a3fd4a3325b17f95b8613aca3ee73/lib/ton-sdk-ruby-smc/wallets/wallet_v4.rb#L98-L99
- wrong variable name https://github.com/nerzh/ton-sdk-ruby-smc/blob/92a458ac5e0a3fd4a3325b17f95b8613aca3ee73/lib/ton-sdk-ruby-smc/wallets/wallet_v4.rb#L139
- wallet v4 does not work, please fix it and add an example with it to README
-
-
Save krigga/5b311d82dc40d93a84ea4f173494193b to your computer and use it in GitHub Desktop.
Ruby SDK review
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment