Agoric / ui-kit

Components and tools for building graphical UIs
https://ui-kit-dwm.pages.dev/
Apache License 2.0
3 stars 3 forks source link

UI hangs following attempt to close vault when it's really failing due to insufficient funds (no error given to user) #57

Closed otoole-brendan closed 8 months ago

otoole-brendan commented 9 months ago

Describe the bug

During smoke-testing of upgrade 12 I was able to succeed in adjusting a vault but then unable to close a vault. The UI would sit spinning with 'Submitting' with no outcome. When I refresh - nothing happened.

Following investigation of logs - the txn was failing due to insufficient IST to repay debt. No error is given to user in UI to know this.

To Reproduce

Steps to reproduce the behavior:

  1. Go to app.inter.trade (Emerynet)
  2. Create a vault with IST.
  3. Have less IST in your wallet than would be required to pay off debt
  4. Attempt to close vault

Expected behavior

Error should be shown so clear a) txn failed and b) due to insufficient IST

samsiegart commented 9 months ago

I'm seeing similar behavior sometimes in the PSM when doing a successful swap (toast keeps spinning after wallet balances update), but difficult to repro reliably

samsiegart commented 9 months ago

I'm seeing an error when casting tries to unserialize a wallet update value here

I put console.logs as such image

And got the following console output:

follower-cosmjs.js?t=1700639988082:337 casting unserializing {body: '#{"status":{"error":"Error: cannot grab 8048108572…},"status":"rejected"}]},"updated":"offerStatus"}', slots: Array(2)}body: "#{\"status\":{\"error\":\"Error: cannot grab 8048108572uist coins: 348263093uist is smaller than 8048108572uist: insufficient funds\",\"id\":1700638965176,\"invitationSpec\":{\"invitationMakerName\":\"CloseVault\",\"previousOffer\":\"1695480430119\",\"source\":\"continuing\"},\"offerArgs\":\"#undefined\",\"proposal\":{\"give\":{\"Minted\":{\"brand\":\"$0.Alleged: IST brand\",\"value\":\"+8048108572\"}},\"want\":{\"Collateral\":{\"brand\":\"$1.Alleged: ATOM brand\",\"value\":\"+2000000000\"}}},\"result\":[{\"reason\":{\"#error\":\"cannot grab 8048108572uist coins: 348263093uist is smaller than 8048108572uist: insufficient funds\",\"errorId\":\"error:anon-marshal#10001\",\"name\":\"Error\"},\"status\":\"rejected\"}]},\"updated\":\"offerStatus\"}"slots: (2) ['board0257', 'board01547']constructor: (...)hasOwnProperty: (...)isPrototypeOf: (...)propertyIsEnumerable: (...)toLocaleString: (...)toString: (...)valueOf: (...)__defineGetter__: (...)__defineSetter__: (...)__lookupGetter__: (...)__lookupSetter__: (...)[[Prototype]]: Object
follower-cosmjs.js?t=1700639988082:343 casting error during unserialize: Error: Passed Error "stack" {"configurable":false,"enumerable":false,"get":"[Function <anon>]","set":"[Function <anon>]"} must be a string-valued data property.
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
  at Array.map (<anonymous>)
followerElementFromStreamCellValue @ follower-cosmjs.js?t=1700639988082:343
await in followerElementFromStreamCellValue (async)
allValuesFromCell @ follower-cosmjs.js?t=1700639988082:356
getEachIterableAtHeight @ follower-cosmjs.js?t=1700639988082:467
localApplyMethod @ local.js:99
(anonymous) @ handled-promise.js:455

And this is the copied json output of the data:

{
    "body": "#{\"status\":{\"error\":\"Error: cannot grab 8048108572uist coins: 348263093uist is smaller than 8048108572uist: insufficient funds\",\"id\":1700638965176,\"invitationSpec\":{\"invitationMakerName\":\"CloseVault\",\"previousOffer\":\"1695480430119\",\"source\":\"continuing\"},\"offerArgs\":\"#undefined\",\"proposal\":{\"give\":{\"Minted\":{\"brand\":\"$0.Alleged: IST brand\",\"value\":\"+8048108572\"}},\"want\":{\"Collateral\":{\"brand\":\"$1.Alleged: ATOM brand\",\"value\":\"+2000000000\"}}},\"result\":[{\"reason\":{\"#error\":\"cannot grab 8048108572uist coins: 348263093uist is smaller than 8048108572uist: insufficient funds\",\"errorId\":\"error:anon-marshal#10001\",\"name\":\"Error\"},\"status\":\"rejected\"}]},\"updated\":\"offerStatus\"}",
    "slots": [
        "board0257",
        "board01547"
    ]
}
samsiegart commented 9 months ago

It seems like casting is hitting this error, and then fails to keep yielding more updates, so we never see the updated offer statuses.

I tried removing the serializer arg here to use the default, and see the same error.

It seems like this is just not valid capdata being emitted? If so, it needs to be fixed on the contract side. In the meantime, perhaps we can modify casting to skip, or yield empty values if it can't unserialize, rather than getting stuck.