@kimafinance/kima-transaction-api 1.0.11-beta.1 → 1.0.13-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimafinance/kima-transaction-api",
3
- "version": "1.0.11-beta.1",
3
+ "version": "1.0.13-beta.1",
4
4
  "description": "A wrapper around Kima's API, enabling sending and monitoring transactions (Beta version)",
5
5
  "author": "",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -31,6 +31,10 @@ interface Props {
31
31
  fee: number;
32
32
  }
33
33
 
34
+ function sleep(ms: number) {
35
+ return new Promise((resolve) => setTimeout(resolve, ms));
36
+ }
37
+
34
38
  export async function submitKimaTransaction({
35
39
  originChain,
36
40
  originAddress,
@@ -60,13 +64,13 @@ export async function submitKimaTransaction({
60
64
  let msg = await client.msgRequestTransaction(params);
61
65
  const result = await client.signAndBroadcast([msg]);
62
66
 
63
- let txId = "1";
67
+ let txId = 1;
64
68
 
65
69
  for (const event of result.events) {
66
70
  if (event.type === "transaction_requested") {
67
71
  for (const attr of event.attributes) {
68
72
  if (attr.key === "txId") {
69
- txId = attr.value;
73
+ txId = +attr.value;
70
74
  }
71
75
  }
72
76
  }
@@ -78,7 +82,11 @@ export async function submitKimaTransaction({
78
82
  txHash: result.transactionHash,
79
83
  });
80
84
 
81
- await client.signAndBroadcast([msg]);
85
+ let hashResult;
86
+ do {
87
+ hashResult = await client.signAndBroadcast([msg]);
88
+ await sleep(1000);
89
+ } while (hashResult.code !== 0);
82
90
 
83
91
  return result;
84
92
  }
@@ -16,8 +16,8 @@ interface SignAndBroadcastOptions {
16
16
  }
17
17
 
18
18
  const types = [
19
- ["/KimaFinance.kima.MsgRequestTransaction", MsgRequestTransaction],
20
- ["/KimaFinance.kima.MsgSetTxHash", MsgSetTxHash],
19
+ ["/KimaFinance.kima.kima.MsgRequestTransaction", MsgRequestTransaction],
20
+ ["/KimaFinance.kima.kima.MsgSetTxHash", MsgSetTxHash],
21
21
  ];
22
22
 
23
23
  export const registry = new Registry(<any>types);