@kimafinance/kima-transaction-api 1.3.4 → 1.3.6

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/build/index.js CHANGED
@@ -84,8 +84,11 @@ async function submitKimaTransaction({ originChain, originAddress, targetChain,
84
84
  senderPubKey,
85
85
  options,
86
86
  };
87
- let msg = await client.msgRequestTransaction(params);
88
- const result = await client.signAndBroadcast([msg]);
87
+ const msgTx = await client.msgRequestTransaction(params);
88
+ const result = await client.signAndBroadcast([msgTx]);
89
+ if (result.code !== 0) {
90
+ return result;
91
+ }
89
92
  let txId = 1;
90
93
  for (const event of result.events) {
91
94
  if (event.type === "transaction_requested") {
@@ -96,18 +99,25 @@ async function submitKimaTransaction({ originChain, originAddress, targetChain,
96
99
  }
97
100
  }
98
101
  }
99
- msg = await client.msgSetTxHash({
102
+ await sleep(5000);
103
+ const msgSetHash = await client.msgSetTxHash({
100
104
  creator: firstAccount.address,
101
105
  txId,
102
106
  txHash: result.transactionHash,
103
107
  txType: "request_transaction",
104
108
  });
105
- console.log(msg);
109
+ console.log(msgSetHash);
106
110
  let hashResult;
107
111
  do {
108
- hashResult = await client.signAndBroadcast([msg]);
109
- await sleep(1000);
110
- } while (hashResult.code !== 0);
112
+ try {
113
+ hashResult = await client.signAndBroadcast([msgSetHash]);
114
+ }
115
+ catch (error) {
116
+ console.log(error);
117
+ await sleep(5000);
118
+ continue;
119
+ }
120
+ } while (hashResult?.code !== 0);
111
121
  return result;
112
122
  }
113
123
  exports.submitKimaTransaction = submitKimaTransaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimafinance/kima-transaction-api",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "A wrapper around Kima's API, enabling sending and monitoring transactions (Beta version)",
5
5
  "repository": "https://github.com/kima-finance/kima-transaction-api",
6
6
  "author": "",
package/src/index.ts CHANGED
@@ -118,7 +118,7 @@ export async function getCreatorAddress() {
118
118
  { prefix: "kima" }
119
119
  );
120
120
  const [firstAccount] = await wallet.getAccounts();
121
- return firstAccount
121
+ return firstAccount;
122
122
  }
123
123
 
124
124
  export async function submitKimaTransaction({
@@ -161,8 +161,12 @@ export async function submitKimaTransaction({
161
161
  options,
162
162
  };
163
163
 
164
- let msg = await client.msgRequestTransaction(params);
165
- const result = await client.signAndBroadcast([msg]);
164
+ const msgTx = await client.msgRequestTransaction(params);
165
+ const result = await client.signAndBroadcast([msgTx]);
166
+
167
+ if (result.code !== 0) {
168
+ return result;
169
+ }
166
170
 
167
171
  let txId = 1;
168
172
 
@@ -176,20 +180,27 @@ export async function submitKimaTransaction({
176
180
  }
177
181
  }
178
182
 
179
- msg = await client.msgSetTxHash({
183
+ await sleep(5000);
184
+
185
+ const msgSetHash = await client.msgSetTxHash({
180
186
  creator: firstAccount.address,
181
187
  txId,
182
188
  txHash: result.transactionHash,
183
189
  txType: "request_transaction",
184
190
  });
185
191
 
186
- console.log(msg);
192
+ console.log(msgSetHash);
187
193
 
188
194
  let hashResult;
189
195
  do {
190
- hashResult = await client.signAndBroadcast([msg]);
191
- await sleep(1000);
192
- } while (hashResult.code !== 0);
196
+ try {
197
+ hashResult = await client.signAndBroadcast([msgSetHash]);
198
+ } catch (error) {
199
+ console.log(error);
200
+ await sleep(5000);
201
+ continue;
202
+ }
203
+ } while (hashResult?.code !== 0);
193
204
 
194
205
  return result;
195
206
  }