nearprotocol / near-runtime-ts

Typescript library for writing near smart contracts
22 stars 7 forks source link

Update to use generic decoder #76

Closed willemneal closed 5 years ago

willemneal commented 5 years ago

The newest staging branch for asc uses a generic decode function, which this is updated to use.

vgrichina commented 5 years ago

@willemneal let's merge directly to master

which assemblyscript branch is needed for this?

willemneal commented 5 years ago

The generic function is in the current near/assemblyscript master, but with the new PR breaks because of the way I had to solve the polymorphism for the decode function. See: https://github.com/AssemblyScript/assemblyscript/issues/828

Basically can't have a union type with a reference and a typedarry. However, I was able to get around this with a generic type with a default.

So in the current PR: decode is decode<T, V = Uint8Array>(buf: V): T, which then can check the instance of buf inside the function. This, however, broke something when you are calling decode on a generic object like in this instance, but the generic decode function is the way to handle this anyway since it does what was done here internally.

willemneal commented 5 years ago

@janedegtiareva I changed some internal functions to get the test to build. I also added some type files so thatencode<T>() and decode<T>() are defined for IDEs.

willemneal commented 5 years ago

The failure seems that the gitlab isn't getting the newest version of assemblyscript. Is there a reason that yarn.lock is ignored?

DanielRX commented 5 years ago

Can we have a tester function in this?

i.e. type StrAlias = string; export function aliased(s: StrAlias): StrAlias {return s; } and then a test calling the function, as when we last tried this branch, it did not work to fix this bug

willemneal commented 5 years ago

That test is in the assemblyscript repo.

On Tue, Sep 17, 2019, 10:03 Daniel notifications@github.com wrote:

Can we have a tester function in this?

i.e. type StrAlias = string; export function aliased(s: StrAlias): StrAlias {return s; } and then a test calling the function, as when we last tried this branch, it did not work to fix this bug

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nearprotocol/near-runtime-ts/pull/76?email_source=notifications&email_token=AALKD3H4M67ZGVQAVBDUXVTQKDPSFA5CNFSM4IUWAF62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64UIVY#issuecomment-532235351, or mute the thread https://github.com/notifications/unsubscribe-auth/AALKD3GP5GZBB5DUOA32VMLQKDPSFANCNFSM4IUWAF6Q .

willemneal commented 5 years ago

I was waiting to for this to pass CI tests before I updated near-shell to the new assemblyscript. In the repo you're testing try adding nearprotocol/assemblyscript as a dependency which nearshell should pick up.

On Tue, Sep 17, 2019, 10:20 Willem Wyndham willem@cs.umd.edu wrote:

That test is in the assemblyscript repo.

On Tue, Sep 17, 2019, 10:03 Daniel notifications@github.com wrote:

Can we have a tester function in this?

i.e. type StrAlias = string; export function aliased(s: StrAlias): StrAlias {return s; } and then a test calling the function, as when we last tried this branch, it did not work to fix this bug

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nearprotocol/near-runtime-ts/pull/76?email_source=notifications&email_token=AALKD3H4M67ZGVQAVBDUXVTQKDPSFA5CNFSM4IUWAF62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD64UIVY#issuecomment-532235351, or mute the thread https://github.com/notifications/unsubscribe-auth/AALKD3GP5GZBB5DUOA32VMLQKDPSFANCNFSM4IUWAF6Q .

willemneal commented 5 years ago

Was able to test this locally and I get the following error:

Running promiseTests
[FAIL] {"balance":0,"storage_usage":0,"return_data":"None","burnt_gas":14639,"used_gas":14889,"logs":["LOG: promiseTests"]}
{"receipt_indices":[],"receiver_id":"contractNameForPromise","method_name":"methodName","arguments":"","attached_deposit":0,"prepaid_gas":100}
{"receipt_indices":[0],"receiver_id":"contractNameForPromise","method_name":"methodName","arguments":"","attached_deposit":0,"prepaid_gas":100}
WasmerCallError("Returning joint promise is currently prohibited.")
willemneal commented 5 years ago

Okay so assemblyscript compilation and testing is fixed, but nearcore is failing the promise test. @janedegtiareva What seems to be the issue with it?