@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 +17 -7
- package/package.json +1 -1
- package/src/index.ts +19 -8
package/build/index.js
CHANGED
|
@@ -84,8 +84,11 @@ async function submitKimaTransaction({ originChain, originAddress, targetChain,
|
|
|
84
84
|
senderPubKey,
|
|
85
85
|
options,
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
const result = await client.signAndBroadcast([
|
|
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
|
-
|
|
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(
|
|
109
|
+
console.log(msgSetHash);
|
|
106
110
|
let hashResult;
|
|
107
111
|
do {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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.
|
|
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
|
-
|
|
165
|
-
const result = await client.signAndBroadcast([
|
|
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
|
-
|
|
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(
|
|
192
|
+
console.log(msgSetHash);
|
|
187
193
|
|
|
188
194
|
let hashResult;
|
|
189
195
|
do {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
}
|