@kimafinance/kima-transaction-api 1.0.26-beta.1 → 1.0.28-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/build/index.d.ts +16 -2
- package/build/index.js +33 -1
- package/build/kima/common.d.ts +3 -1
- package/build/kima/common.js +10 -0
- package/build/kima/tx.d.ts +92 -9
- package/build/kima/tx.js +320 -19
- package/package.json +1 -1
- package/src/index.ts +73 -3
- package/src/kima/common.ts +16 -1
- package/src/kima/tx.ts +415 -21
package/build/kima/tx.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MsgClientImpl = exports.MsgFinalizeDrainTransactionResponse = exports.MsgFinalizeDrainTransaction = exports.MsgRequestDrainTransactionResponse = exports.MsgRequestDrainTransaction = exports.MsgSetTxProcessResponse = exports.MsgSetTxProcess = exports.MsgSetTxHashResponse = exports.MsgSetTxHash = exports.MsgCancelTransactionResponse = exports.MsgCancelTransaction = exports.MsgRequestProvisionTransactionResponse = exports.MsgRequestProvisionTransaction = exports.MsgFinalizeProvisionTransactionResponse = exports.MsgFinalizeProvisionTransaction = exports.MsgFinalizeTransactionResponse = exports.MsgFinalizeTransaction = exports.MsgRequestTransactionResponse = exports.MsgRequestTransaction = exports.protobufPackage = void 0;
|
|
6
|
+
exports.MsgClientImpl = exports.MsgHtlcReclaimResponse = exports.MsgHtlcReclaim = exports.MsgRequestHtlcLockResponse = exports.MsgRequestHtlcLock = exports.MsgFinalizeDrainTransactionResponse = exports.MsgFinalizeDrainTransaction = exports.MsgRequestDrainTransactionResponse = exports.MsgRequestDrainTransaction = exports.MsgSetTxProcessResponse = exports.MsgSetTxProcess = exports.MsgSetTxHashResponse = exports.MsgSetTxHash = exports.MsgCancelTransactionResponse = exports.MsgCancelTransaction = exports.MsgRequestProvisionTransactionResponse = exports.MsgRequestProvisionTransaction = exports.MsgFinalizeProvisionTransactionResponse = exports.MsgFinalizeProvisionTransaction = exports.MsgFinalizeTransactionResponse = exports.MsgFinalizeTransaction = exports.MsgRequestTransactionResponse = exports.MsgRequestTransaction = exports.protobufPackage = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
@@ -258,7 +258,14 @@ exports.MsgRequestTransactionResponse = {
|
|
|
258
258
|
},
|
|
259
259
|
};
|
|
260
260
|
function createBaseMsgFinalizeTransaction() {
|
|
261
|
-
return {
|
|
261
|
+
return {
|
|
262
|
+
creator: "",
|
|
263
|
+
txId: 0,
|
|
264
|
+
txHash: "",
|
|
265
|
+
success: false,
|
|
266
|
+
signedKey: "",
|
|
267
|
+
errReason: "",
|
|
268
|
+
};
|
|
262
269
|
}
|
|
263
270
|
exports.MsgFinalizeTransaction = {
|
|
264
271
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -271,12 +278,15 @@ exports.MsgFinalizeTransaction = {
|
|
|
271
278
|
if (message.txHash !== "") {
|
|
272
279
|
writer.uint32(26).string(message.txHash);
|
|
273
280
|
}
|
|
274
|
-
if (message.success
|
|
275
|
-
writer.uint32(
|
|
281
|
+
if (message.success === true) {
|
|
282
|
+
writer.uint32(32).bool(message.success);
|
|
276
283
|
}
|
|
277
284
|
if (message.signedKey !== "") {
|
|
278
285
|
writer.uint32(42).string(message.signedKey);
|
|
279
286
|
}
|
|
287
|
+
if (message.errReason !== "") {
|
|
288
|
+
writer.uint32(50).string(message.errReason);
|
|
289
|
+
}
|
|
280
290
|
return writer;
|
|
281
291
|
},
|
|
282
292
|
decode(input, length) {
|
|
@@ -296,11 +306,14 @@ exports.MsgFinalizeTransaction = {
|
|
|
296
306
|
message.txHash = reader.string();
|
|
297
307
|
break;
|
|
298
308
|
case 4:
|
|
299
|
-
message.success = reader.
|
|
309
|
+
message.success = reader.bool();
|
|
300
310
|
break;
|
|
301
311
|
case 5:
|
|
302
312
|
message.signedKey = reader.string();
|
|
303
313
|
break;
|
|
314
|
+
case 6:
|
|
315
|
+
message.errReason = reader.string();
|
|
316
|
+
break;
|
|
304
317
|
default:
|
|
305
318
|
reader.skipType(tag & 7);
|
|
306
319
|
break;
|
|
@@ -313,8 +326,9 @@ exports.MsgFinalizeTransaction = {
|
|
|
313
326
|
creator: isSet(object.creator) ? String(object.creator) : "",
|
|
314
327
|
txId: isSet(object.txId) ? Number(object.txId) : 0,
|
|
315
328
|
txHash: isSet(object.txHash) ? String(object.txHash) : "",
|
|
316
|
-
success: isSet(object.success) ?
|
|
329
|
+
success: isSet(object.success) ? Boolean(object.success) : false,
|
|
317
330
|
signedKey: isSet(object.signedKey) ? String(object.signedKey) : "",
|
|
331
|
+
errReason: isSet(object.errReason) ? String(object.errReason) : "",
|
|
318
332
|
};
|
|
319
333
|
},
|
|
320
334
|
toJSON(message) {
|
|
@@ -324,6 +338,7 @@ exports.MsgFinalizeTransaction = {
|
|
|
324
338
|
message.txHash !== undefined && (obj.txHash = message.txHash);
|
|
325
339
|
message.success !== undefined && (obj.success = message.success);
|
|
326
340
|
message.signedKey !== undefined && (obj.signedKey = message.signedKey);
|
|
341
|
+
message.errReason !== undefined && (obj.errReason = message.errReason);
|
|
327
342
|
return obj;
|
|
328
343
|
},
|
|
329
344
|
fromPartial(object) {
|
|
@@ -331,8 +346,9 @@ exports.MsgFinalizeTransaction = {
|
|
|
331
346
|
message.creator = object.creator ?? "";
|
|
332
347
|
message.txId = object.txId ?? 0;
|
|
333
348
|
message.txHash = object.txHash ?? "";
|
|
334
|
-
message.success = object.success ??
|
|
349
|
+
message.success = object.success ?? false;
|
|
335
350
|
message.signedKey = object.signedKey ?? "";
|
|
351
|
+
message.errReason = object.errReason ?? "";
|
|
336
352
|
return message;
|
|
337
353
|
},
|
|
338
354
|
};
|
|
@@ -389,7 +405,14 @@ exports.MsgFinalizeTransactionResponse = {
|
|
|
389
405
|
},
|
|
390
406
|
};
|
|
391
407
|
function createBaseMsgFinalizeProvisionTransaction() {
|
|
392
|
-
return {
|
|
408
|
+
return {
|
|
409
|
+
creator: "",
|
|
410
|
+
txId: 0,
|
|
411
|
+
txHash: "",
|
|
412
|
+
success: false,
|
|
413
|
+
signedKey: "",
|
|
414
|
+
errReason: "",
|
|
415
|
+
};
|
|
393
416
|
}
|
|
394
417
|
exports.MsgFinalizeProvisionTransaction = {
|
|
395
418
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -402,12 +425,15 @@ exports.MsgFinalizeProvisionTransaction = {
|
|
|
402
425
|
if (message.txHash !== "") {
|
|
403
426
|
writer.uint32(26).string(message.txHash);
|
|
404
427
|
}
|
|
405
|
-
if (message.success
|
|
406
|
-
writer.uint32(
|
|
428
|
+
if (message.success === true) {
|
|
429
|
+
writer.uint32(32).bool(message.success);
|
|
407
430
|
}
|
|
408
431
|
if (message.signedKey !== "") {
|
|
409
432
|
writer.uint32(42).string(message.signedKey);
|
|
410
433
|
}
|
|
434
|
+
if (message.errReason !== "") {
|
|
435
|
+
writer.uint32(50).string(message.errReason);
|
|
436
|
+
}
|
|
411
437
|
return writer;
|
|
412
438
|
},
|
|
413
439
|
decode(input, length) {
|
|
@@ -427,11 +453,14 @@ exports.MsgFinalizeProvisionTransaction = {
|
|
|
427
453
|
message.txHash = reader.string();
|
|
428
454
|
break;
|
|
429
455
|
case 4:
|
|
430
|
-
message.success = reader.
|
|
456
|
+
message.success = reader.bool();
|
|
431
457
|
break;
|
|
432
458
|
case 5:
|
|
433
459
|
message.signedKey = reader.string();
|
|
434
460
|
break;
|
|
461
|
+
case 6:
|
|
462
|
+
message.errReason = reader.string();
|
|
463
|
+
break;
|
|
435
464
|
default:
|
|
436
465
|
reader.skipType(tag & 7);
|
|
437
466
|
break;
|
|
@@ -444,8 +473,9 @@ exports.MsgFinalizeProvisionTransaction = {
|
|
|
444
473
|
creator: isSet(object.creator) ? String(object.creator) : "",
|
|
445
474
|
txId: isSet(object.txId) ? Number(object.txId) : 0,
|
|
446
475
|
txHash: isSet(object.txHash) ? String(object.txHash) : "",
|
|
447
|
-
success: isSet(object.success) ?
|
|
476
|
+
success: isSet(object.success) ? Boolean(object.success) : false,
|
|
448
477
|
signedKey: isSet(object.signedKey) ? String(object.signedKey) : "",
|
|
478
|
+
errReason: isSet(object.errReason) ? String(object.errReason) : "",
|
|
449
479
|
};
|
|
450
480
|
},
|
|
451
481
|
toJSON(message) {
|
|
@@ -455,6 +485,7 @@ exports.MsgFinalizeProvisionTransaction = {
|
|
|
455
485
|
message.txHash !== undefined && (obj.txHash = message.txHash);
|
|
456
486
|
message.success !== undefined && (obj.success = message.success);
|
|
457
487
|
message.signedKey !== undefined && (obj.signedKey = message.signedKey);
|
|
488
|
+
message.errReason !== undefined && (obj.errReason = message.errReason);
|
|
458
489
|
return obj;
|
|
459
490
|
},
|
|
460
491
|
fromPartial(object) {
|
|
@@ -462,8 +493,9 @@ exports.MsgFinalizeProvisionTransaction = {
|
|
|
462
493
|
message.creator = object.creator ?? "";
|
|
463
494
|
message.txId = object.txId ?? 0;
|
|
464
495
|
message.txHash = object.txHash ?? "";
|
|
465
|
-
message.success = object.success ??
|
|
496
|
+
message.success = object.success ?? false;
|
|
466
497
|
message.signedKey = object.signedKey ?? "";
|
|
498
|
+
message.errReason = object.errReason ?? "";
|
|
467
499
|
return message;
|
|
468
500
|
},
|
|
469
501
|
};
|
|
@@ -1240,7 +1272,14 @@ exports.MsgRequestDrainTransactionResponse = {
|
|
|
1240
1272
|
},
|
|
1241
1273
|
};
|
|
1242
1274
|
function createBaseMsgFinalizeDrainTransaction() {
|
|
1243
|
-
return {
|
|
1275
|
+
return {
|
|
1276
|
+
creator: "",
|
|
1277
|
+
txId: 0,
|
|
1278
|
+
txHash: "",
|
|
1279
|
+
success: false,
|
|
1280
|
+
signedKey: "",
|
|
1281
|
+
errReason: "",
|
|
1282
|
+
};
|
|
1244
1283
|
}
|
|
1245
1284
|
exports.MsgFinalizeDrainTransaction = {
|
|
1246
1285
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -1253,12 +1292,15 @@ exports.MsgFinalizeDrainTransaction = {
|
|
|
1253
1292
|
if (message.txHash !== "") {
|
|
1254
1293
|
writer.uint32(26).string(message.txHash);
|
|
1255
1294
|
}
|
|
1256
|
-
if (message.success
|
|
1257
|
-
writer.uint32(
|
|
1295
|
+
if (message.success === true) {
|
|
1296
|
+
writer.uint32(32).bool(message.success);
|
|
1258
1297
|
}
|
|
1259
1298
|
if (message.signedKey !== "") {
|
|
1260
1299
|
writer.uint32(42).string(message.signedKey);
|
|
1261
1300
|
}
|
|
1301
|
+
if (message.errReason !== "") {
|
|
1302
|
+
writer.uint32(50).string(message.errReason);
|
|
1303
|
+
}
|
|
1262
1304
|
return writer;
|
|
1263
1305
|
},
|
|
1264
1306
|
decode(input, length) {
|
|
@@ -1278,11 +1320,14 @@ exports.MsgFinalizeDrainTransaction = {
|
|
|
1278
1320
|
message.txHash = reader.string();
|
|
1279
1321
|
break;
|
|
1280
1322
|
case 4:
|
|
1281
|
-
message.success = reader.
|
|
1323
|
+
message.success = reader.bool();
|
|
1282
1324
|
break;
|
|
1283
1325
|
case 5:
|
|
1284
1326
|
message.signedKey = reader.string();
|
|
1285
1327
|
break;
|
|
1328
|
+
case 6:
|
|
1329
|
+
message.errReason = reader.string();
|
|
1330
|
+
break;
|
|
1286
1331
|
default:
|
|
1287
1332
|
reader.skipType(tag & 7);
|
|
1288
1333
|
break;
|
|
@@ -1295,8 +1340,9 @@ exports.MsgFinalizeDrainTransaction = {
|
|
|
1295
1340
|
creator: isSet(object.creator) ? String(object.creator) : "",
|
|
1296
1341
|
txId: isSet(object.txId) ? Number(object.txId) : 0,
|
|
1297
1342
|
txHash: isSet(object.txHash) ? String(object.txHash) : "",
|
|
1298
|
-
success: isSet(object.success) ?
|
|
1343
|
+
success: isSet(object.success) ? Boolean(object.success) : false,
|
|
1299
1344
|
signedKey: isSet(object.signedKey) ? String(object.signedKey) : "",
|
|
1345
|
+
errReason: isSet(object.errReason) ? String(object.errReason) : "",
|
|
1300
1346
|
};
|
|
1301
1347
|
},
|
|
1302
1348
|
toJSON(message) {
|
|
@@ -1306,6 +1352,7 @@ exports.MsgFinalizeDrainTransaction = {
|
|
|
1306
1352
|
message.txHash !== undefined && (obj.txHash = message.txHash);
|
|
1307
1353
|
message.success !== undefined && (obj.success = message.success);
|
|
1308
1354
|
message.signedKey !== undefined && (obj.signedKey = message.signedKey);
|
|
1355
|
+
message.errReason !== undefined && (obj.errReason = message.errReason);
|
|
1309
1356
|
return obj;
|
|
1310
1357
|
},
|
|
1311
1358
|
fromPartial(object) {
|
|
@@ -1313,8 +1360,9 @@ exports.MsgFinalizeDrainTransaction = {
|
|
|
1313
1360
|
message.creator = object.creator ?? "";
|
|
1314
1361
|
message.txId = object.txId ?? 0;
|
|
1315
1362
|
message.txHash = object.txHash ?? "";
|
|
1316
|
-
message.success = object.success ??
|
|
1363
|
+
message.success = object.success ?? false;
|
|
1317
1364
|
message.signedKey = object.signedKey ?? "";
|
|
1365
|
+
message.errReason = object.errReason ?? "";
|
|
1318
1366
|
return message;
|
|
1319
1367
|
},
|
|
1320
1368
|
};
|
|
@@ -1370,6 +1418,247 @@ exports.MsgFinalizeDrainTransactionResponse = {
|
|
|
1370
1418
|
return message;
|
|
1371
1419
|
},
|
|
1372
1420
|
};
|
|
1421
|
+
function createBaseMsgRequestHtlcLock() {
|
|
1422
|
+
return {
|
|
1423
|
+
creator: "",
|
|
1424
|
+
fromAddress: "",
|
|
1425
|
+
senderPubkey: "",
|
|
1426
|
+
amount: "",
|
|
1427
|
+
htlcTimeout: "",
|
|
1428
|
+
txHash: "",
|
|
1429
|
+
htlcAddress: "",
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
exports.MsgRequestHtlcLock = {
|
|
1433
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
1434
|
+
if (message.creator !== "") {
|
|
1435
|
+
writer.uint32(10).string(message.creator);
|
|
1436
|
+
}
|
|
1437
|
+
if (message.fromAddress !== "") {
|
|
1438
|
+
writer.uint32(18).string(message.fromAddress);
|
|
1439
|
+
}
|
|
1440
|
+
if (message.senderPubkey !== "") {
|
|
1441
|
+
writer.uint32(26).string(message.senderPubkey);
|
|
1442
|
+
}
|
|
1443
|
+
if (message.amount !== "") {
|
|
1444
|
+
writer.uint32(34).string(message.amount);
|
|
1445
|
+
}
|
|
1446
|
+
if (message.htlcTimeout !== "") {
|
|
1447
|
+
writer.uint32(42).string(message.htlcTimeout);
|
|
1448
|
+
}
|
|
1449
|
+
if (message.txHash !== "") {
|
|
1450
|
+
writer.uint32(50).string(message.txHash);
|
|
1451
|
+
}
|
|
1452
|
+
if (message.htlcAddress !== "") {
|
|
1453
|
+
writer.uint32(58).string(message.htlcAddress);
|
|
1454
|
+
}
|
|
1455
|
+
return writer;
|
|
1456
|
+
},
|
|
1457
|
+
decode(input, length) {
|
|
1458
|
+
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
1459
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1460
|
+
const message = createBaseMsgRequestHtlcLock();
|
|
1461
|
+
while (reader.pos < end) {
|
|
1462
|
+
const tag = reader.uint32();
|
|
1463
|
+
switch (tag >>> 3) {
|
|
1464
|
+
case 1:
|
|
1465
|
+
message.creator = reader.string();
|
|
1466
|
+
break;
|
|
1467
|
+
case 2:
|
|
1468
|
+
message.fromAddress = reader.string();
|
|
1469
|
+
break;
|
|
1470
|
+
case 3:
|
|
1471
|
+
message.senderPubkey = reader.string();
|
|
1472
|
+
break;
|
|
1473
|
+
case 4:
|
|
1474
|
+
message.amount = reader.string();
|
|
1475
|
+
break;
|
|
1476
|
+
case 5:
|
|
1477
|
+
message.htlcTimeout = reader.string();
|
|
1478
|
+
break;
|
|
1479
|
+
case 6:
|
|
1480
|
+
message.txHash = reader.string();
|
|
1481
|
+
break;
|
|
1482
|
+
case 7:
|
|
1483
|
+
message.htlcAddress = reader.string();
|
|
1484
|
+
break;
|
|
1485
|
+
default:
|
|
1486
|
+
reader.skipType(tag & 7);
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
return message;
|
|
1491
|
+
},
|
|
1492
|
+
fromJSON(object) {
|
|
1493
|
+
return {
|
|
1494
|
+
creator: isSet(object.creator) ? String(object.creator) : "",
|
|
1495
|
+
fromAddress: isSet(object.fromAddress) ? String(object.fromAddress) : "",
|
|
1496
|
+
senderPubkey: isSet(object.senderPubkey)
|
|
1497
|
+
? String(object.senderPubkey)
|
|
1498
|
+
: "",
|
|
1499
|
+
amount: isSet(object.amount) ? String(object.amount) : "",
|
|
1500
|
+
htlcTimeout: isSet(object.htlcTimeout) ? String(object.htlcTimeout) : "",
|
|
1501
|
+
txHash: isSet(object.txHash) ? String(object.txHash) : "",
|
|
1502
|
+
htlcAddress: isSet(object.htlcAddress) ? String(object.htlcAddress) : "",
|
|
1503
|
+
};
|
|
1504
|
+
},
|
|
1505
|
+
toJSON(message) {
|
|
1506
|
+
const obj = {};
|
|
1507
|
+
message.creator !== undefined && (obj.creator = message.creator);
|
|
1508
|
+
message.fromAddress !== undefined &&
|
|
1509
|
+
(obj.fromAddress = message.fromAddress);
|
|
1510
|
+
message.senderPubkey !== undefined &&
|
|
1511
|
+
(obj.senderPubkey = message.senderPubkey);
|
|
1512
|
+
message.amount !== undefined && (obj.amount = message.amount);
|
|
1513
|
+
message.htlcTimeout !== undefined &&
|
|
1514
|
+
(obj.htlcTimeout = message.htlcTimeout);
|
|
1515
|
+
message.txHash !== undefined && (obj.txHash = message.txHash);
|
|
1516
|
+
message.htlcAddress !== undefined &&
|
|
1517
|
+
(obj.htlcAddress = message.htlcAddress);
|
|
1518
|
+
return obj;
|
|
1519
|
+
},
|
|
1520
|
+
fromPartial(object) {
|
|
1521
|
+
const message = createBaseMsgRequestHtlcLock();
|
|
1522
|
+
message.creator = object.creator ?? "";
|
|
1523
|
+
message.fromAddress = object.fromAddress ?? "";
|
|
1524
|
+
message.senderPubkey = object.senderPubkey ?? "";
|
|
1525
|
+
message.amount = object.amount ?? "";
|
|
1526
|
+
message.htlcTimeout = object.htlcTimeout ?? "";
|
|
1527
|
+
message.txHash = object.txHash ?? "";
|
|
1528
|
+
message.htlcAddress = object.htlcAddress ?? "";
|
|
1529
|
+
return message;
|
|
1530
|
+
},
|
|
1531
|
+
};
|
|
1532
|
+
function createBaseMsgRequestHtlcLockResponse() {
|
|
1533
|
+
return {};
|
|
1534
|
+
}
|
|
1535
|
+
exports.MsgRequestHtlcLockResponse = {
|
|
1536
|
+
encode(_, writer = minimal_1.default.Writer.create()) {
|
|
1537
|
+
return writer;
|
|
1538
|
+
},
|
|
1539
|
+
decode(input, length) {
|
|
1540
|
+
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
1541
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1542
|
+
const message = createBaseMsgRequestHtlcLockResponse();
|
|
1543
|
+
while (reader.pos < end) {
|
|
1544
|
+
const tag = reader.uint32();
|
|
1545
|
+
switch (tag >>> 3) {
|
|
1546
|
+
default:
|
|
1547
|
+
reader.skipType(tag & 7);
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
return message;
|
|
1552
|
+
},
|
|
1553
|
+
fromJSON(_) {
|
|
1554
|
+
return {};
|
|
1555
|
+
},
|
|
1556
|
+
toJSON(_) {
|
|
1557
|
+
const obj = {};
|
|
1558
|
+
return obj;
|
|
1559
|
+
},
|
|
1560
|
+
fromPartial(_) {
|
|
1561
|
+
const message = createBaseMsgRequestHtlcLockResponse();
|
|
1562
|
+
return message;
|
|
1563
|
+
},
|
|
1564
|
+
};
|
|
1565
|
+
function createBaseMsgHtlcReclaim() {
|
|
1566
|
+
return { creator: "", txHash: "", senderAddress: "" };
|
|
1567
|
+
}
|
|
1568
|
+
exports.MsgHtlcReclaim = {
|
|
1569
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
1570
|
+
if (message.creator !== "") {
|
|
1571
|
+
writer.uint32(10).string(message.creator);
|
|
1572
|
+
}
|
|
1573
|
+
if (message.txHash !== "") {
|
|
1574
|
+
writer.uint32(18).string(message.txHash);
|
|
1575
|
+
}
|
|
1576
|
+
if (message.senderAddress !== "") {
|
|
1577
|
+
writer.uint32(26).string(message.senderAddress);
|
|
1578
|
+
}
|
|
1579
|
+
return writer;
|
|
1580
|
+
},
|
|
1581
|
+
decode(input, length) {
|
|
1582
|
+
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
1583
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1584
|
+
const message = createBaseMsgHtlcReclaim();
|
|
1585
|
+
while (reader.pos < end) {
|
|
1586
|
+
const tag = reader.uint32();
|
|
1587
|
+
switch (tag >>> 3) {
|
|
1588
|
+
case 1:
|
|
1589
|
+
message.creator = reader.string();
|
|
1590
|
+
break;
|
|
1591
|
+
case 2:
|
|
1592
|
+
message.txHash = reader.string();
|
|
1593
|
+
break;
|
|
1594
|
+
case 3:
|
|
1595
|
+
message.senderAddress = reader.string();
|
|
1596
|
+
break;
|
|
1597
|
+
default:
|
|
1598
|
+
reader.skipType(tag & 7);
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
return message;
|
|
1603
|
+
},
|
|
1604
|
+
fromJSON(object) {
|
|
1605
|
+
return {
|
|
1606
|
+
creator: isSet(object.creator) ? String(object.creator) : "",
|
|
1607
|
+
txHash: isSet(object.txHash) ? String(object.txHash) : "",
|
|
1608
|
+
senderAddress: isSet(object.senderAddress)
|
|
1609
|
+
? String(object.senderAddress)
|
|
1610
|
+
: "",
|
|
1611
|
+
};
|
|
1612
|
+
},
|
|
1613
|
+
toJSON(message) {
|
|
1614
|
+
const obj = {};
|
|
1615
|
+
message.creator !== undefined && (obj.creator = message.creator);
|
|
1616
|
+
message.txHash !== undefined && (obj.txHash = message.txHash);
|
|
1617
|
+
message.senderAddress !== undefined &&
|
|
1618
|
+
(obj.senderAddress = message.senderAddress);
|
|
1619
|
+
return obj;
|
|
1620
|
+
},
|
|
1621
|
+
fromPartial(object) {
|
|
1622
|
+
const message = createBaseMsgHtlcReclaim();
|
|
1623
|
+
message.creator = object.creator ?? "";
|
|
1624
|
+
message.txHash = object.txHash ?? "";
|
|
1625
|
+
message.senderAddress = object.senderAddress ?? "";
|
|
1626
|
+
return message;
|
|
1627
|
+
},
|
|
1628
|
+
};
|
|
1629
|
+
function createBaseMsgHtlcReclaimResponse() {
|
|
1630
|
+
return {};
|
|
1631
|
+
}
|
|
1632
|
+
exports.MsgHtlcReclaimResponse = {
|
|
1633
|
+
encode(_, writer = minimal_1.default.Writer.create()) {
|
|
1634
|
+
return writer;
|
|
1635
|
+
},
|
|
1636
|
+
decode(input, length) {
|
|
1637
|
+
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
1638
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1639
|
+
const message = createBaseMsgHtlcReclaimResponse();
|
|
1640
|
+
while (reader.pos < end) {
|
|
1641
|
+
const tag = reader.uint32();
|
|
1642
|
+
switch (tag >>> 3) {
|
|
1643
|
+
default:
|
|
1644
|
+
reader.skipType(tag & 7);
|
|
1645
|
+
break;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return message;
|
|
1649
|
+
},
|
|
1650
|
+
fromJSON(_) {
|
|
1651
|
+
return {};
|
|
1652
|
+
},
|
|
1653
|
+
toJSON(_) {
|
|
1654
|
+
const obj = {};
|
|
1655
|
+
return obj;
|
|
1656
|
+
},
|
|
1657
|
+
fromPartial(_) {
|
|
1658
|
+
const message = createBaseMsgHtlcReclaimResponse();
|
|
1659
|
+
return message;
|
|
1660
|
+
},
|
|
1661
|
+
};
|
|
1373
1662
|
class MsgClientImpl {
|
|
1374
1663
|
rpc;
|
|
1375
1664
|
constructor(rpc) {
|
|
@@ -1385,6 +1674,8 @@ class MsgClientImpl {
|
|
|
1385
1674
|
this.FinalizeProvisionTransaction.bind(this);
|
|
1386
1675
|
this.RequestDrainTransaction = this.RequestDrainTransaction.bind(this);
|
|
1387
1676
|
this.FinalizeDrainTransaction = this.FinalizeDrainTransaction.bind(this);
|
|
1677
|
+
this.RequestHtlcLock = this.RequestHtlcLock.bind(this);
|
|
1678
|
+
this.HtlcReclaim = this.HtlcReclaim.bind(this);
|
|
1388
1679
|
}
|
|
1389
1680
|
RequestTransaction(request) {
|
|
1390
1681
|
const data = exports.MsgRequestTransaction.encode(request).finish();
|
|
@@ -1431,6 +1722,16 @@ class MsgClientImpl {
|
|
|
1431
1722
|
const promise = this.rpc.request("kimablockchain.transaction.Msg", "FinalizeDrainTransaction", data);
|
|
1432
1723
|
return promise.then((data) => exports.MsgFinalizeDrainTransactionResponse.decode(new minimal_1.default.Reader(data)));
|
|
1433
1724
|
}
|
|
1725
|
+
RequestHtlcLock(request) {
|
|
1726
|
+
const data = exports.MsgRequestHtlcLock.encode(request).finish();
|
|
1727
|
+
const promise = this.rpc.request("kimablockchain.transaction.Msg", "RequestHtlcLock", data);
|
|
1728
|
+
return promise.then((data) => exports.MsgRequestHtlcLockResponse.decode(new minimal_1.default.Reader(data)));
|
|
1729
|
+
}
|
|
1730
|
+
HtlcReclaim(request) {
|
|
1731
|
+
const data = exports.MsgHtlcReclaim.encode(request).finish();
|
|
1732
|
+
const promise = this.rpc.request("kimablockchain.transaction.Msg", "HtlcReclaim", data);
|
|
1733
|
+
return promise.then((data) => exports.MsgHtlcReclaimResponse.decode(new minimal_1.default.Reader(data)));
|
|
1734
|
+
}
|
|
1434
1735
|
}
|
|
1435
1736
|
exports.MsgClientImpl = MsgClientImpl;
|
|
1436
1737
|
var globalThis = (() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimafinance/kima-transaction-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28-beta.1",
|
|
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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
|
2
2
|
import { TxClient } from "./kima/common";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
MsgHtlcReclaim,
|
|
5
|
+
MsgRequestHtlcLock,
|
|
6
|
+
MsgRequestTransaction,
|
|
7
|
+
} from "./kima/tx";
|
|
4
8
|
|
|
5
9
|
export enum SupportedNetworks {
|
|
6
10
|
ETHEREUM = "ETH",
|
|
@@ -21,7 +25,73 @@ export enum CurrencyOptions {
|
|
|
21
25
|
USDK = "USDK",
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
interface
|
|
28
|
+
interface RequestHtlcReclaimProps {
|
|
29
|
+
senderAddress: string;
|
|
30
|
+
txHash: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function HtlcReclaim({
|
|
34
|
+
senderAddress,
|
|
35
|
+
txHash,
|
|
36
|
+
}: RequestHtlcReclaimProps) {
|
|
37
|
+
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
|
|
38
|
+
process.env.KIMA_BACKEND_MNEMONIC as string,
|
|
39
|
+
{ prefix: "kima" }
|
|
40
|
+
);
|
|
41
|
+
const client = await TxClient(wallet);
|
|
42
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
43
|
+
const params: MsgHtlcReclaim = {
|
|
44
|
+
creator: firstAccount.address,
|
|
45
|
+
senderAddress,
|
|
46
|
+
txHash,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
let msg = await client.msgHtlcReclaim(params);
|
|
50
|
+
const result = await client.signAndBroadcast([msg]);
|
|
51
|
+
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface RequestHtlcLockProps {
|
|
56
|
+
fromAddress: string;
|
|
57
|
+
senderPubkey: string;
|
|
58
|
+
amount: string;
|
|
59
|
+
htlcTimeout: string;
|
|
60
|
+
txHash: string;
|
|
61
|
+
htlcAddress: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function submitHtlcLock({
|
|
65
|
+
fromAddress,
|
|
66
|
+
senderPubkey,
|
|
67
|
+
amount,
|
|
68
|
+
htlcTimeout,
|
|
69
|
+
txHash,
|
|
70
|
+
htlcAddress,
|
|
71
|
+
}: RequestHtlcLockProps) {
|
|
72
|
+
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
|
|
73
|
+
process.env.KIMA_BACKEND_MNEMONIC as string,
|
|
74
|
+
{ prefix: "kima" }
|
|
75
|
+
);
|
|
76
|
+
const client = await TxClient(wallet);
|
|
77
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
78
|
+
const params: MsgRequestHtlcLock = {
|
|
79
|
+
creator: firstAccount.address,
|
|
80
|
+
fromAddress,
|
|
81
|
+
senderPubkey,
|
|
82
|
+
amount,
|
|
83
|
+
htlcTimeout,
|
|
84
|
+
htlcAddress,
|
|
85
|
+
txHash,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
let msg = await client.msgRequestHtlcLock(params);
|
|
89
|
+
const result = await client.signAndBroadcast([msg]);
|
|
90
|
+
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface RequestTxProps {
|
|
25
95
|
originChain: SupportedNetworks;
|
|
26
96
|
originAddress: string;
|
|
27
97
|
targetChain: SupportedNetworks;
|
|
@@ -53,7 +123,7 @@ export async function submitKimaTransaction({
|
|
|
53
123
|
htlcExpirationTimestamp,
|
|
54
124
|
htlcVersion,
|
|
55
125
|
senderPubKey,
|
|
56
|
-
}:
|
|
126
|
+
}: RequestTxProps) {
|
|
57
127
|
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
|
|
58
128
|
process.env.KIMA_BACKEND_MNEMONIC as string,
|
|
59
129
|
{ prefix: "kima" }
|
package/src/kima/common.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { SigningStargateClient, StdFee } from "@cosmjs/stargate";
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
3
|
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
MsgRequestHtlcLock,
|
|
6
|
+
MsgRequestTransaction,
|
|
7
|
+
MsgSetTxHash,
|
|
8
|
+
MsgHtlcReclaim,
|
|
9
|
+
} from "./tx";
|
|
5
10
|
|
|
6
11
|
dotenv.config();
|
|
7
12
|
|
|
@@ -17,7 +22,9 @@ interface SignAndBroadcastOptions {
|
|
|
17
22
|
|
|
18
23
|
const types = [
|
|
19
24
|
["/kimablockchain.transaction.MsgRequestTransaction", MsgRequestTransaction],
|
|
25
|
+
["/kimablockchain.transaction.MsgRequestHtlcLock", MsgRequestHtlcLock],
|
|
20
26
|
["/kimablockchain.transaction.MsgSetTxHash", MsgSetTxHash],
|
|
27
|
+
["/kimablockchain.transaction.MsgHtlcReclaim", MsgHtlcReclaim],
|
|
21
28
|
];
|
|
22
29
|
|
|
23
30
|
export const registry = new Registry(<any>types);
|
|
@@ -39,9 +46,17 @@ export const TxClient = async (wallet: OfflineSigner) => {
|
|
|
39
46
|
typeUrl: "/kimablockchain.transaction.MsgRequestTransaction",
|
|
40
47
|
value: MsgRequestTransaction.fromPartial(data),
|
|
41
48
|
}),
|
|
49
|
+
msgRequestHtlcLock: (data: MsgRequestHtlcLock): EncodeObject => ({
|
|
50
|
+
typeUrl: "/kimablockchain.transaction.MsgRequestHtlcLock",
|
|
51
|
+
value: MsgRequestHtlcLock.fromPartial(data),
|
|
52
|
+
}),
|
|
42
53
|
msgSetTxHash: (data: MsgSetTxHash): EncodeObject => ({
|
|
43
54
|
typeUrl: "/kimablockchain.transaction.MsgSetTxHash",
|
|
44
55
|
value: MsgSetTxHash.fromPartial(data),
|
|
45
56
|
}),
|
|
57
|
+
msgHtlcReclaim: (data: MsgHtlcReclaim): EncodeObject => ({
|
|
58
|
+
typeUrl: "/kimablockchain.transaction.MsgHtlcReclaim",
|
|
59
|
+
value: MsgHtlcReclaim.fromPartial(data),
|
|
60
|
+
}),
|
|
46
61
|
};
|
|
47
62
|
};
|