lucasvanmol / algodot

Algorand integration in Godot
MIT License
5 stars 1 forks source link

_test_asset_transfers(): breaks at line " var asset_index = int(tx_info.get("asset-index"))" #4

Closed Sam2much96 closed 2 years ago

Sam2much96 commented 2 years ago

Godot IDE throws out the following errors:

E 0:00:24.132 : property url on native class Algodot does not have a getter <C++ Source> /cargo/registry/src/github.com-1ecc6299db9ec823/gdnative-core-0.10.0/src/export/property/invalid_accessor.rs:68 @ ()

main.gd:132 @ _test_asset_transfers() E 0:00:24.132 : property token on native class Algodot does not have a getter /cargo/registry/src/github.com-1ecc6299db9ec823/gdnative-core-0.10.0/src/export/property/invalid_accessor.rs:68 @ () main.gd:132 @ _test_asset_transfers() E 0:00:24.132 : property headers on native class Algodot does not have a getter /cargo/registry/src/github.com-1ecc6299db9ec823/gdnative-core-0.10.0/src/export/property/invalid_accessor.rs:68 @ () main.gd:132 @ _test_asset_transfers() E 0:04:25.404 : property url on native class Algodot does not have a getter /cargo/registry/src/github.com-1ecc6299db9ec823/gdnative-core-0.10.0/src/export/property/invalid_accessor.rs:68 @ () main.gd:132 @ _test_asset_transfers() E 0:04:25.404 : property token on native class Algodot does not have a getter /cargo/registry/src/github.com-1ecc6299db9ec823/gdnative-core-0.10.0/src/export/property/invalid_accessor.rs:68 @ () main.gd:132 @ _test_asset_transfers() E 0:04:25.404 : property headers on native class Algodot does not have a getter /cargo/registry/src/github.com-1ecc6299db9ec823/gdnative-core-0.10.0/src/export/property/invalid_accessor.rs:68 @ () main.gd:132 @ _test_asset_transfers()
Sam2much96 commented 2 years ago

Output prints:

--- Debugging process started --- Godot Engine v3.4.3.rc.custom_build.f7c191e17 - https://godotengine.org OpenGL ES 3.0 Renderer: Mesa Intel(R) HD Graphics 500 (APL 2) OpenGL ES Batching: ON

-- Initialize Algod -- Get funder account -- _test_algod_connection -- _test_transaction sending tx waiting for confirmation -- _test_asset_transfers create --- Debugging process stopped ---

Sam2much96 commented 2 years ago

Teal Debugger outputs:

   
current-round 2386
next-token "0wgAAAAAAAAAAAAA"
transactions  
0  
close-rewards 0
closing-amount 0
confirmed-round 2257
fee 1000
first-valid 2254
genesis-hash "9UzLRhMO7Ii+FcS18Mv32zg+Xuw2E1+9SfMnMCJT/H4="
genesis-id "sandnet-v1"
id "IT3P6TSTFREZ6LDECV4CBPTK33O7DAPFWKYZOLO34W3OXYQSGOQA"
intra-round-offset 0
last-valid 3254
payment-transaction  
amount 123456789
close-amount 0
receiver "6PJ6REGJL4HUXGIBPCV5JHTGX7UR2BRR7OHRRNMS6TUZZWDTWZUSLIWAFA"
receiver-rewards 0
round-time 1658681948
sender "L5ESENBL23J2GJGM64Y767IXWGBCKXMGS2OGZ3MC5BBGWJAKJJAUK7BJK4"
sender-rewards 224000000000
signature  
sig "IsPSulaeJk+0azfQQz9YtDwY98tBw8b3+I0QueqGK7q9jcrGIiXcD8nnqJdsAytLoVOQDtQVbkqbH1U1NS5HCw=="
tx-type "pay"
1  
asset-config-transaction  
asset-id 0
params  
creator "6PJ6REGJL4HUXGIBPCV5JHTGX7UR2BRR7OHRRNMS6TUZZWDTWZUSLIWAFA"
decimals 2
default-frozen false
name "TestCoin"
name-b64 "VGVzdENvaW4="
total 100000
unit-name "TC"
unit-name-b64 "VEM="
close-rewards 0
closing-amount 0
confirmed-round 2259
created-asset-index 2
fee 1000
first-valid 2254
genesis-hash "9UzLRhMO7Ii+FcS18Mv32zg+Xuw2E1+9SfMnMCJT/H4="
genesis-id "sandnet-v1"
id "OET3IXTMA6R4PD4XUZJXYZSAF3VWM3MYS5YSRIW75VAARZ7W2PLQ"
intra-round-offset 0
last-valid 3254
receiver-rewards 0
round-time 1658681998
sender "6PJ6REGJL4HUXGIBPCV5JHTGX7UR2BRR7OHRRNMS6TUZZWDTWZUSLIWAFA"
sender-rewards 0
signature  
sig "p6tAbm0NHcTNVBete9ioqKRSB/XLMPOL1CtJNQ7ypSiaevReTD9Oe+t6type7xttx54ClYx4lNwDzpNdyKq1Cg=="
tx-type "acfg"
Sam2much96 commented 2 years ago

tx_info.get("asset-index") #returns Null

Sam2much96 commented 2 years ago

print (tx_info) returns the json bellow {application-index:Null, asset-index:Null, close-rewards:Null, closing-amount:Null, confirmed-round:Null, pool-error:, receiver-rewards:Null, sender-rewards:Null, txn:{}}

Sam2much96 commented 2 years ago

The code breaks from var tx_info = yield(algod.transaction_information(txid), "completed") which returns null parameters

Sam2much96 commented 2 years ago

so tx_info.get("asset-index") is null because:

asset-index: Null from the transaction info

so constructing an integer from a null variable breaks the function.

How to fix?:

Sam2much96 commented 2 years ago

fix 1: temporary error catcher

if tx_info.get("asset-index") != null:

continue running _test_asset_transfer()

else: _timeout()

It doesn't fix the bug, but it at least stops the engine from crashing

Sam2much96 commented 2 years ago

Fix 2(works): including the line

var wait= yield(algod.wait_for_transaction(txid), "completed")

allows the transaction to go through and stops the error from happening. Closing issue now

P.S.: I made some updates to your main.gd test script, making it easier to read , debug and breaking up each of the individual tests into separate functions. I'll make a pull request once i'm done debugging.