Kava-Labs / javascript-sdk

JavaScript SDK to communicate with Kava.
Apache License 2.0
12 stars 17 forks source link

swap_incoming.ts example is broken #73

Open fwiessner opened 2 years ago

fwiessner commented 2 years ago

The example in swap_incoming.ts seems to be broken.

The script successfully sends HTLT order on binance chain, however, the swapid is never known to https://api.data.kava.io/bep3/swap/ and the script fails at that point:

mrjack@cerebellum:~/dev/binance/kava/example$ node swap_incoming.ts
Secret random number: ac0d10d0004de13078e6bf24e64a8f8adecbeeecc0171c7ec7c2ce0f60067265
Expected Bnbchain swap ID: f9e51c1ec03c5fd689c730356e66858c43067a955b8c6d486eacb56e1033c30e
Expected Kava swap ID: 4b959a0f822b5bdb1e42ef2488cb6efbe35bdb81b3283f6f67c4aa793cb0943d

Create swap tx hash (Binance Chain):  27B4B489EC576647E71B43570CDB3B97C68B3A1EA4A448E66819196AFBCD2E07
Waiting for deputy to witness and relay the swap...
(node:4155415) UnhandledPromiseRejectionWarning: Error: Max retries reached:
    error: Error: Request failed with status code 500
    at retry (/home/mrjack/dev/binance/kava/lib/tx/index.js:65:19)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.getTx (/home/mrjack/dev/binance/kava/lib/tx/index.js:23:16)
    at async KavaClient.getSwap (/home/mrjack/dev/binance/kava/lib/client/index.js:680:21)
    at async incomingSwap (/home/mrjack/dev/binance/kava/example/swap_incoming.ts:96:3)
    at async main (/home/mrjack/dev/binance/kava/example/swap_incoming.ts:10:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4155415) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:4155415) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

the function failing is:

await kavaClient.getSwap(expectedKavaSwapID);

fwiessner commented 2 years ago

Also:

https://swagger.kava.io/#/BEP3/get_bep3_swap__swap_id_ gives errors:

Errors

Resolver error at paths./bep3/swap/{swap-id}.get.responses.200.schema.properties.result.properties.cross_chain.$ref Could not resolve reference: Could not resolve pointer: /definitions/CrossChain does not exist in document

thomasmost commented 2 years ago

@fwiessner Yeah, the examples definitely could use some TLC. They weren't updated with the last major chain upgrade.

I'll log a ticket to update these. Thank you for bringing it to our attention!

fwiessner commented 2 years ago

I would adapt the code, if you would only let me know, what changed and where to find reliable information on how to do it now.