Closed marslab2022 closed 1 year ago
Thanks! Should I run this: https://github.com/marslab2022/ThetARExchange/blob/main/contract/tests/test_thetar_badcase.ts testcase?
Thanks! Should I run this: https://github.com/marslab2022/ThetARExchange/blob/main/contract/tests/test_thetar_badcase.ts testcase?
Yes. But maybe I need to check whether the latest contract code can reproduce this problem, please wait.
So sorry to keep you waiting. I just pushed new code to the repository. test_thetar_badcase1.ts reproduces the issue. And at the same time, we also tested a scenario(test_thetar_badcase2.ts) - user tries to obtain the latest order book info(readState) before the operation of creating an order is completed(writeInteraction). In this case I got error like below. I am not sure if it is the same issue as badcase1, or just there's something wrong I called these functions.
running...
(node:46034) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
{"owner":"9-vYItKDZ1bE9r1GBaSOmrCgeCkt8o-wRR3O0vSG7VI","tokenSrcTxs":[],"thetarTokenAddress":"UDl0d1SjeJXa3_S8WGEOk9j8qtRJV6JBA1mouLtM16o","maxPairId":0,"pairInfos":[{"pairId":0,"tokenAddress":"mygwOSptyIFeoPmARQcFGHU0Huv9qq6KWlW8aFg82oE","logo":"TEST_00000lQgApM_a3Z6bGFHYE7SXnBI6C5_2_24MQ","description":"test token","name":"TEST token","symbol":"TEST","decimals":2}],"userOrders":{},"orderInfos":{"0":{"orders":[]}},"logs":[],"tokenSrcTemplateHashs":[0]}
txid: LPf1vMkJwJ_MblxyC_pSdqpTdAdCiFz0abmDXMUhyrI
wallet address: 9-vYItKDZ1bE9r1GBaSOmrCgeCkt8o-wRR3O0vSG7VI
create order...
BEFORE: {"sortKey":"000000000230,0000000000000,2fd8f01bfe56ab20f54ba24d84cdbc2cd8e0a3e90e6c7df0aa6b31cd64fa3332","cachedValue":{"state":{"owner":"9-vYItKDZ1bE9r1GBaSOmrCgeCkt8o-wRR3O0vSG7VI","tokenSrcTxs":[],"thetarTokenAddress":"UDl0d1SjeJXa3_S8WGEOk9j8qtRJV6JBA1mouLtM16o","maxPairId":0,"pairInfos":[{"pairId":0,"tokenAddress":"mygwOSptyIFeoPmARQcFGHU0Huv9qq6KWlW8aFg82oE","logo":"TEST_00000lQgApM_a3Z6bGFHYE7SXnBI6C5_2_24MQ","description":"test token","name":"TEST token","symbol":"TEST","decimals":2}],"userOrders":{},"orderInfos":{"0":{"orders":[]}},"logs":[],"tokenSrcTemplateHashs":[0]},"validity":{"gRFJ70bY-IlbM3Dsk_oGMuWpX7D97xVjU85q8gkPfPI":true},"errorMessages":{}}}
Get order book: {"sortKey":"000000000230,0000000000000,2fd8f01bfe56ab20f54ba24d84cdbc2cd8e0a3e90e6c7df0aa6b31cd64fa3332","cachedValue":{"state":{"owner":"9-vYItKDZ1bE9r1GBaSOmrCgeCkt8o-wRR3O0vSG7VI","tokenSrcTxs":[],"thetarTokenAddress":"UDl0d1SjeJXa3_S8WGEOk9j8qtRJV6JBA1mouLtM16o","maxPairId":0,"pairInfos":[{"pairId":0,"tokenAddress":"mygwOSptyIFeoPmARQcFGHU0Huv9qq6KWlW8aFg82oE","logo":"TEST_00000lQgApM_a3Z6bGFHYE7SXnBI6C5_2_24MQ","description":"test token","name":"TEST token","symbol":"TEST","decimals":2}],"userOrders":{},"orderInfos":{"0":{"orders":[]}},"logs":[],"tokenSrcTemplateHashs":[0]},"validity":{"gRFJ70bY-IlbM3Dsk_oGMuWpX7D97xVjU85q8gkPfPI":true},"errorMessages":{}}}
Get order book: {"sortKey":"000000000230,0000000000000,2fd8f01bfe56ab20f54ba24d84cdbc2cd8e0a3e90e6c7df0aa6b31cd64fa3332","cachedValue":{"state":{"owner":"9-vYItKDZ1bE9r1GBaSOmrCgeCkt8o-wRR3O0vSG7VI","tokenSrcTxs":[],"thetarTokenAddress":"UDl0d1SjeJXa3_S8WGEOk9j8qtRJV6JBA1mouLtM16o","maxPairId":0,"pairInfos":[{"pairId":0,"tokenAddress":"mygwOSptyIFeoPmARQcFGHU0Huv9qq6KWlW8aFg82oE","logo":"TEST_00000lQgApM_a3Z6bGFHYE7SXnBI6C5_2_24MQ","description":"test token","name":"TEST token","symbol":"TEST","decimals":2}],"userOrders":{},"orderInfos":{"0":{"orders":[]}},"logs":[],"tokenSrcTemplateHashs":[0]},"validity":{"gRFJ70bY-IlbM3Dsk_oGMuWpX7D97xVjU85q8gkPfPI":true},"errorMessages":{}}}
Get order book: {"sortKey":"000000000230,0000000000000,2fd8f01bfe56ab20f54ba24d84cdbc2cd8e0a3e90e6c7df0aa6b31cd64fa3332","cachedValue":{"state":{"owner":"9-vYItKDZ1bE9r1GBaSOmrCgeCkt8o-wRR3O0vSG7VI","tokenSrcTxs":[],"thetarTokenAddress":"UDl0d1SjeJXa3_S8WGEOk9j8qtRJV6JBA1mouLtM16o","maxPairId":0,"pairInfos":[{"pairId":0,"tokenAddress":"mygwOSptyIFeoPmARQcFGHU0Huv9qq6KWlW8aFg82oE","logo":"TEST_00000lQgApM_a3Z6bGFHYE7SXnBI6C5_2_24MQ","description":"test token","name":"TEST token","symbol":"TEST","decimals":2}],"userOrders":{},"orderInfos":{"0":{"orders":[]}},"logs":[],"tokenSrcTemplateHashs":[0]},"validity":{"gRFJ70bY-IlbM3Dsk_oGMuWpX7D97xVjU85q8gkPfPI":true},"errorMessages":{}}}
2023-01-14T14:56:10.903Z FATAL [HandlerBasedContract] Error while interacting with contract [
{
type: 'exception',
error: "TypeError: Cannot read properties of undefined (reading 'interactionInput')\n" +
' at new HandlerBasedContract (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/contract/HandlerBasedContract.ts:84:19)\n' +
' at Warp.contract (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/core/Warp.ts:66:12)\n' +
' at Object.swGlobal.contracts.write (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/core/modules/impl/handler/AbstractContractHandler.ts:58:52)\n' +
' at checkOrderQuantity (eval at create (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/core/modules/impl/HandlerExecutorFactory.ts:194:34), <anonymous>:116:32)\n' +
' at async createOrder (eval at create (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/core/modules/impl/HandlerExecutorFactory.ts:194:34), <anonymous>:94:17)\n' +
' at async JsHandlerApi.handle [as contractFunction] (eval at create (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/core/modules/impl/HandlerExecutorFactory.ts:194:34), <anonymous>:302:16)\n' +
' at async JsHandlerApi.handle (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/core/modules/impl/handler/JsHandlerApi.ts:39:29)\n' +
' at async HandlerBasedContract.evalInteraction (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/contract/HandlerBasedContract.ts:645:20)\n' +
' at async HandlerBasedContract.callContract (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/contract/HandlerBasedContract.ts:580:26)\n' +
' at async HandlerBasedContract.createInteraction (/Users/lab/mARsLab/thetar_exchange/contract/node_modules/warp-contracts/src/contract/HandlerBasedContract.ts:313:29)'
}
]
Ok, this looks like an issue in the test itself, I will take a look later this week.
In the meantime - I've released a 1.2.48-beta.1
with refactored internal writes (https://github.com/warp-contracts/warp/pull/311) - feel free to test :-)
The updateCacheForEachInteraction
should no longer be necessary.
This works fine with refactored internalWrite, Thank you guys :)
Hi, team. I got different evaluated contract states when integrate contract to DApp - The result of two calls to the function
readState
is not the same. Could team please check this? Thanks.Test environment preparation
Clone code to local: https://github.com/marslab2022/ThetAR_exchange
Cmd:
npm install
Cmd:
npx arlocal 1984
Head to
contract/
folder and runyarn install
&npm run build:contracts
. Then, tocontract/deploy/
folder, and run command:ts-node deploy-test-contract.ts
It will shows: And generate a JWK file: key-file-for-test.jsonHead to file:
src/lib/api.js
.ReplacethetARContractAddress
with txid. ReplacefeeWalletAdrress
withwallet address
generated below(step 4).Cmd:
npm run build
Cmd:
serve -s build
Head to
localhost:3000
Connect wallet using
key-file-for-test.json
generated in step 4.Go to
my
page and clickregister
;Refresh page and click
activate
:Test for badcase
Click
home
botton and enter #0 pair detailsCreate 3 orders:
Head to
My
page and cancel these 3 orders respectively:Check the console log: After click
cancel
button, print the newest contract state to console. Check the last state, we can find userInfos->orders is Array(0), means no remaining orders.Go to
Home
page and click#0
, you could find order: And when clickRefresh
button, it will print contract state to console. Check it:The order that had been cancelled came back???