@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/index.d.ts
CHANGED
|
@@ -15,7 +15,21 @@ export declare enum CurrencyOptions {
|
|
|
15
15
|
USDC = "USDC",
|
|
16
16
|
USDK = "USDK"
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface RequestHtlcReclaimProps {
|
|
19
|
+
senderAddress: string;
|
|
20
|
+
txHash: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function HtlcReclaim({ senderAddress, txHash, }: RequestHtlcReclaimProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
23
|
+
interface RequestHtlcLockProps {
|
|
24
|
+
fromAddress: string;
|
|
25
|
+
senderPubkey: string;
|
|
26
|
+
amount: string;
|
|
27
|
+
htlcTimeout: string;
|
|
28
|
+
txHash: string;
|
|
29
|
+
htlcAddress: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function submitHtlcLock({ fromAddress, senderPubkey, amount, htlcTimeout, txHash, htlcAddress, }: RequestHtlcLockProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
32
|
+
interface RequestTxProps {
|
|
19
33
|
originChain: SupportedNetworks;
|
|
20
34
|
originAddress: string;
|
|
21
35
|
targetChain: SupportedNetworks;
|
|
@@ -29,5 +43,5 @@ interface Props {
|
|
|
29
43
|
htlcVersion: string;
|
|
30
44
|
senderPubKey: Uint8Array;
|
|
31
45
|
}
|
|
32
|
-
export declare function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, }:
|
|
46
|
+
export declare function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, }: RequestTxProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
33
47
|
export {};
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.submitKimaTransaction = exports.CurrencyOptions = exports.SupportedNetworks = void 0;
|
|
3
|
+
exports.submitKimaTransaction = exports.submitHtlcLock = exports.HtlcReclaim = exports.CurrencyOptions = exports.SupportedNetworks = void 0;
|
|
4
4
|
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
5
5
|
const common_1 = require("./kima/common");
|
|
6
6
|
var SupportedNetworks;
|
|
@@ -22,6 +22,38 @@ var CurrencyOptions;
|
|
|
22
22
|
CurrencyOptions["USDC"] = "USDC";
|
|
23
23
|
CurrencyOptions["USDK"] = "USDK";
|
|
24
24
|
})(CurrencyOptions = exports.CurrencyOptions || (exports.CurrencyOptions = {}));
|
|
25
|
+
async function HtlcReclaim({ senderAddress, txHash, }) {
|
|
26
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
27
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
28
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
29
|
+
const params = {
|
|
30
|
+
creator: firstAccount.address,
|
|
31
|
+
senderAddress,
|
|
32
|
+
txHash,
|
|
33
|
+
};
|
|
34
|
+
let msg = await client.msgHtlcReclaim(params);
|
|
35
|
+
const result = await client.signAndBroadcast([msg]);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
exports.HtlcReclaim = HtlcReclaim;
|
|
39
|
+
async function submitHtlcLock({ fromAddress, senderPubkey, amount, htlcTimeout, txHash, htlcAddress, }) {
|
|
40
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
41
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
42
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
43
|
+
const params = {
|
|
44
|
+
creator: firstAccount.address,
|
|
45
|
+
fromAddress,
|
|
46
|
+
senderPubkey,
|
|
47
|
+
amount,
|
|
48
|
+
htlcTimeout,
|
|
49
|
+
htlcAddress,
|
|
50
|
+
txHash,
|
|
51
|
+
};
|
|
52
|
+
let msg = await client.msgRequestHtlcLock(params);
|
|
53
|
+
const result = await client.signAndBroadcast([msg]);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
exports.submitHtlcLock = submitHtlcLock;
|
|
25
57
|
function sleep(ms) {
|
|
26
58
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
59
|
}
|
package/build/kima/common.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StdFee } from "@cosmjs/stargate";
|
|
2
2
|
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
3
|
-
import { MsgRequestTransaction, MsgSetTxHash } from "./tx";
|
|
3
|
+
import { MsgRequestHtlcLock, MsgRequestTransaction, MsgSetTxHash, MsgHtlcReclaim } from "./tx";
|
|
4
4
|
interface SignAndBroadcastOptions {
|
|
5
5
|
fee: StdFee;
|
|
6
6
|
memo?: string;
|
|
@@ -9,6 +9,8 @@ export declare const registry: Registry;
|
|
|
9
9
|
export declare const TxClient: (wallet: OfflineSigner) => Promise<{
|
|
10
10
|
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }?: SignAndBroadcastOptions) => Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
11
11
|
msgRequestTransaction: (data: MsgRequestTransaction) => EncodeObject;
|
|
12
|
+
msgRequestHtlcLock: (data: MsgRequestHtlcLock) => EncodeObject;
|
|
12
13
|
msgSetTxHash: (data: MsgSetTxHash) => EncodeObject;
|
|
14
|
+
msgHtlcReclaim: (data: MsgHtlcReclaim) => EncodeObject;
|
|
13
15
|
}>;
|
|
14
16
|
export {};
|
package/build/kima/common.js
CHANGED
|
@@ -15,7 +15,9 @@ const defaultFee = {
|
|
|
15
15
|
};
|
|
16
16
|
const types = [
|
|
17
17
|
["/kimablockchain.transaction.MsgRequestTransaction", tx_1.MsgRequestTransaction],
|
|
18
|
+
["/kimablockchain.transaction.MsgRequestHtlcLock", tx_1.MsgRequestHtlcLock],
|
|
18
19
|
["/kimablockchain.transaction.MsgSetTxHash", tx_1.MsgSetTxHash],
|
|
20
|
+
["/kimablockchain.transaction.MsgHtlcReclaim", tx_1.MsgHtlcReclaim],
|
|
19
21
|
];
|
|
20
22
|
exports.registry = new proto_signing_1.Registry(types);
|
|
21
23
|
const TxClient = async (wallet) => {
|
|
@@ -27,10 +29,18 @@ const TxClient = async (wallet) => {
|
|
|
27
29
|
typeUrl: "/kimablockchain.transaction.MsgRequestTransaction",
|
|
28
30
|
value: tx_1.MsgRequestTransaction.fromPartial(data),
|
|
29
31
|
}),
|
|
32
|
+
msgRequestHtlcLock: (data) => ({
|
|
33
|
+
typeUrl: "/kimablockchain.transaction.MsgRequestHtlcLock",
|
|
34
|
+
value: tx_1.MsgRequestHtlcLock.fromPartial(data),
|
|
35
|
+
}),
|
|
30
36
|
msgSetTxHash: (data) => ({
|
|
31
37
|
typeUrl: "/kimablockchain.transaction.MsgSetTxHash",
|
|
32
38
|
value: tx_1.MsgSetTxHash.fromPartial(data),
|
|
33
39
|
}),
|
|
40
|
+
msgHtlcReclaim: (data) => ({
|
|
41
|
+
typeUrl: "/kimablockchain.transaction.MsgHtlcReclaim",
|
|
42
|
+
value: tx_1.MsgHtlcReclaim.fromPartial(data),
|
|
43
|
+
}),
|
|
34
44
|
};
|
|
35
45
|
};
|
|
36
46
|
exports.TxClient = TxClient;
|
package/build/kima/tx.d.ts
CHANGED
|
@@ -29,8 +29,9 @@ export interface MsgFinalizeTransaction {
|
|
|
29
29
|
creator: string;
|
|
30
30
|
txId: number;
|
|
31
31
|
txHash: string;
|
|
32
|
-
success:
|
|
32
|
+
success: boolean;
|
|
33
33
|
signedKey: string;
|
|
34
|
+
errReason: string;
|
|
34
35
|
}
|
|
35
36
|
export interface MsgFinalizeTransactionResponse {
|
|
36
37
|
code: string;
|
|
@@ -40,8 +41,9 @@ export interface MsgFinalizeProvisionTransaction {
|
|
|
40
41
|
creator: string;
|
|
41
42
|
txId: number;
|
|
42
43
|
txHash: string;
|
|
43
|
-
success:
|
|
44
|
+
success: boolean;
|
|
44
45
|
signedKey: string;
|
|
46
|
+
errReason: string;
|
|
45
47
|
}
|
|
46
48
|
export interface MsgFinalizeProvisionTransactionResponse {
|
|
47
49
|
code: string;
|
|
@@ -116,13 +118,32 @@ export interface MsgFinalizeDrainTransaction {
|
|
|
116
118
|
creator: string;
|
|
117
119
|
txId: number;
|
|
118
120
|
txHash: string;
|
|
119
|
-
success:
|
|
121
|
+
success: boolean;
|
|
120
122
|
signedKey: string;
|
|
123
|
+
errReason: string;
|
|
121
124
|
}
|
|
122
125
|
export interface MsgFinalizeDrainTransactionResponse {
|
|
123
126
|
code: string;
|
|
124
127
|
msg: string;
|
|
125
128
|
}
|
|
129
|
+
export interface MsgRequestHtlcLock {
|
|
130
|
+
creator: string;
|
|
131
|
+
fromAddress: string;
|
|
132
|
+
senderPubkey: string;
|
|
133
|
+
amount: string;
|
|
134
|
+
htlcTimeout: string;
|
|
135
|
+
txHash: string;
|
|
136
|
+
htlcAddress: string;
|
|
137
|
+
}
|
|
138
|
+
export interface MsgRequestHtlcLockResponse {
|
|
139
|
+
}
|
|
140
|
+
export interface MsgHtlcReclaim {
|
|
141
|
+
creator: string;
|
|
142
|
+
txHash: string;
|
|
143
|
+
senderAddress: string;
|
|
144
|
+
}
|
|
145
|
+
export interface MsgHtlcReclaimResponse {
|
|
146
|
+
}
|
|
126
147
|
export declare const MsgRequestTransaction: {
|
|
127
148
|
encode(message: MsgRequestTransaction, writer?: _m0.Writer): _m0.Writer;
|
|
128
149
|
decode(input: _m0.Reader | Uint8Array, length?: number): MsgRequestTransaction;
|
|
@@ -182,14 +203,16 @@ export declare const MsgFinalizeTransaction: {
|
|
|
182
203
|
creator?: string | undefined;
|
|
183
204
|
txId?: number | undefined;
|
|
184
205
|
txHash?: string | undefined;
|
|
185
|
-
success?:
|
|
206
|
+
success?: boolean | undefined;
|
|
186
207
|
signedKey?: string | undefined;
|
|
208
|
+
errReason?: string | undefined;
|
|
187
209
|
} & {
|
|
188
210
|
creator?: string | undefined;
|
|
189
211
|
txId?: number | undefined;
|
|
190
212
|
txHash?: string | undefined;
|
|
191
|
-
success?:
|
|
213
|
+
success?: boolean | undefined;
|
|
192
214
|
signedKey?: string | undefined;
|
|
215
|
+
errReason?: string | undefined;
|
|
193
216
|
} & { [K in Exclude<keyof I, keyof MsgFinalizeTransaction>]: never; }>(object: I): MsgFinalizeTransaction;
|
|
194
217
|
};
|
|
195
218
|
export declare const MsgFinalizeTransactionResponse: {
|
|
@@ -214,14 +237,16 @@ export declare const MsgFinalizeProvisionTransaction: {
|
|
|
214
237
|
creator?: string | undefined;
|
|
215
238
|
txId?: number | undefined;
|
|
216
239
|
txHash?: string | undefined;
|
|
217
|
-
success?:
|
|
240
|
+
success?: boolean | undefined;
|
|
218
241
|
signedKey?: string | undefined;
|
|
242
|
+
errReason?: string | undefined;
|
|
219
243
|
} & {
|
|
220
244
|
creator?: string | undefined;
|
|
221
245
|
txId?: number | undefined;
|
|
222
246
|
txHash?: string | undefined;
|
|
223
|
-
success?:
|
|
247
|
+
success?: boolean | undefined;
|
|
224
248
|
signedKey?: string | undefined;
|
|
249
|
+
errReason?: string | undefined;
|
|
225
250
|
} & { [K in Exclude<keyof I, keyof MsgFinalizeProvisionTransaction>]: never; }>(object: I): MsgFinalizeProvisionTransaction;
|
|
226
251
|
};
|
|
227
252
|
export declare const MsgFinalizeProvisionTransactionResponse: {
|
|
@@ -410,14 +435,16 @@ export declare const MsgFinalizeDrainTransaction: {
|
|
|
410
435
|
creator?: string | undefined;
|
|
411
436
|
txId?: number | undefined;
|
|
412
437
|
txHash?: string | undefined;
|
|
413
|
-
success?:
|
|
438
|
+
success?: boolean | undefined;
|
|
414
439
|
signedKey?: string | undefined;
|
|
440
|
+
errReason?: string | undefined;
|
|
415
441
|
} & {
|
|
416
442
|
creator?: string | undefined;
|
|
417
443
|
txId?: number | undefined;
|
|
418
444
|
txHash?: string | undefined;
|
|
419
|
-
success?:
|
|
445
|
+
success?: boolean | undefined;
|
|
420
446
|
signedKey?: string | undefined;
|
|
447
|
+
errReason?: string | undefined;
|
|
421
448
|
} & { [K in Exclude<keyof I, keyof MsgFinalizeDrainTransaction>]: never; }>(object: I): MsgFinalizeDrainTransaction;
|
|
422
449
|
};
|
|
423
450
|
export declare const MsgFinalizeDrainTransactionResponse: {
|
|
@@ -433,6 +460,58 @@ export declare const MsgFinalizeDrainTransactionResponse: {
|
|
|
433
460
|
msg?: string | undefined;
|
|
434
461
|
} & { [K in Exclude<keyof I, keyof MsgFinalizeDrainTransactionResponse>]: never; }>(object: I): MsgFinalizeDrainTransactionResponse;
|
|
435
462
|
};
|
|
463
|
+
export declare const MsgRequestHtlcLock: {
|
|
464
|
+
encode(message: MsgRequestHtlcLock, writer?: _m0.Writer): _m0.Writer;
|
|
465
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgRequestHtlcLock;
|
|
466
|
+
fromJSON(object: any): MsgRequestHtlcLock;
|
|
467
|
+
toJSON(message: MsgRequestHtlcLock): unknown;
|
|
468
|
+
fromPartial<I extends {
|
|
469
|
+
creator?: string | undefined;
|
|
470
|
+
fromAddress?: string | undefined;
|
|
471
|
+
senderPubkey?: string | undefined;
|
|
472
|
+
amount?: string | undefined;
|
|
473
|
+
htlcTimeout?: string | undefined;
|
|
474
|
+
txHash?: string | undefined;
|
|
475
|
+
htlcAddress?: string | undefined;
|
|
476
|
+
} & {
|
|
477
|
+
creator?: string | undefined;
|
|
478
|
+
fromAddress?: string | undefined;
|
|
479
|
+
senderPubkey?: string | undefined;
|
|
480
|
+
amount?: string | undefined;
|
|
481
|
+
htlcTimeout?: string | undefined;
|
|
482
|
+
txHash?: string | undefined;
|
|
483
|
+
htlcAddress?: string | undefined;
|
|
484
|
+
} & { [K in Exclude<keyof I, keyof MsgRequestHtlcLock>]: never; }>(object: I): MsgRequestHtlcLock;
|
|
485
|
+
};
|
|
486
|
+
export declare const MsgRequestHtlcLockResponse: {
|
|
487
|
+
encode(_: MsgRequestHtlcLockResponse, writer?: _m0.Writer): _m0.Writer;
|
|
488
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgRequestHtlcLockResponse;
|
|
489
|
+
fromJSON(_: any): MsgRequestHtlcLockResponse;
|
|
490
|
+
toJSON(_: MsgRequestHtlcLockResponse): unknown;
|
|
491
|
+
fromPartial<I extends {} & {} & { [K in Exclude<keyof I, never>]: never; }>(_: I): MsgRequestHtlcLockResponse;
|
|
492
|
+
};
|
|
493
|
+
export declare const MsgHtlcReclaim: {
|
|
494
|
+
encode(message: MsgHtlcReclaim, writer?: _m0.Writer): _m0.Writer;
|
|
495
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgHtlcReclaim;
|
|
496
|
+
fromJSON(object: any): MsgHtlcReclaim;
|
|
497
|
+
toJSON(message: MsgHtlcReclaim): unknown;
|
|
498
|
+
fromPartial<I extends {
|
|
499
|
+
creator?: string | undefined;
|
|
500
|
+
txHash?: string | undefined;
|
|
501
|
+
senderAddress?: string | undefined;
|
|
502
|
+
} & {
|
|
503
|
+
creator?: string | undefined;
|
|
504
|
+
txHash?: string | undefined;
|
|
505
|
+
senderAddress?: string | undefined;
|
|
506
|
+
} & { [K in Exclude<keyof I, keyof MsgHtlcReclaim>]: never; }>(object: I): MsgHtlcReclaim;
|
|
507
|
+
};
|
|
508
|
+
export declare const MsgHtlcReclaimResponse: {
|
|
509
|
+
encode(_: MsgHtlcReclaimResponse, writer?: _m0.Writer): _m0.Writer;
|
|
510
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgHtlcReclaimResponse;
|
|
511
|
+
fromJSON(_: any): MsgHtlcReclaimResponse;
|
|
512
|
+
toJSON(_: MsgHtlcReclaimResponse): unknown;
|
|
513
|
+
fromPartial<I extends {} & {} & { [K in Exclude<keyof I, never>]: never; }>(_: I): MsgHtlcReclaimResponse;
|
|
514
|
+
};
|
|
436
515
|
/** Msg defines the Msg service. */
|
|
437
516
|
export interface Msg {
|
|
438
517
|
RequestTransaction(request: MsgRequestTransaction): Promise<MsgRequestTransactionResponse>;
|
|
@@ -444,6 +523,8 @@ export interface Msg {
|
|
|
444
523
|
FinalizeProvisionTransaction(request: MsgFinalizeProvisionTransaction): Promise<MsgFinalizeProvisionTransactionResponse>;
|
|
445
524
|
RequestDrainTransaction(request: MsgRequestDrainTransaction): Promise<MsgRequestDrainTransactionResponse>;
|
|
446
525
|
FinalizeDrainTransaction(request: MsgFinalizeDrainTransaction): Promise<MsgFinalizeDrainTransactionResponse>;
|
|
526
|
+
RequestHtlcLock(request: MsgRequestHtlcLock): Promise<MsgRequestHtlcLockResponse>;
|
|
527
|
+
HtlcReclaim(request: MsgHtlcReclaim): Promise<MsgHtlcReclaimResponse>;
|
|
447
528
|
}
|
|
448
529
|
export declare class MsgClientImpl implements Msg {
|
|
449
530
|
private readonly rpc;
|
|
@@ -457,6 +538,8 @@ export declare class MsgClientImpl implements Msg {
|
|
|
457
538
|
FinalizeProvisionTransaction(request: MsgFinalizeProvisionTransaction): Promise<MsgFinalizeProvisionTransactionResponse>;
|
|
458
539
|
RequestDrainTransaction(request: MsgRequestDrainTransaction): Promise<MsgRequestDrainTransactionResponse>;
|
|
459
540
|
FinalizeDrainTransaction(request: MsgFinalizeDrainTransaction): Promise<MsgFinalizeDrainTransactionResponse>;
|
|
541
|
+
RequestHtlcLock(request: MsgRequestHtlcLock): Promise<MsgRequestHtlcLockResponse>;
|
|
542
|
+
HtlcReclaim(request: MsgHtlcReclaim): Promise<MsgHtlcReclaimResponse>;
|
|
460
543
|
}
|
|
461
544
|
interface Rpc {
|
|
462
545
|
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|