@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/build/index.js +10 -3
- package/build/kima/common.js +2 -2
- package/build/kima/tx.d.ts +101 -8
- package/build/kima/tx.js +613 -50
- package/package.json +1 -1
- package/src/index.ts +11 -3
- package/src/kima/common.ts +2 -2
- package/src/kima/tx.ts +725 -58
package/build/index.js
CHANGED
|
@@ -22,6 +22,9 @@ var CurrencyOptions;
|
|
|
22
22
|
CurrencyOptions["USDC"] = "USDC";
|
|
23
23
|
CurrencyOptions["USDK"] = "USDK";
|
|
24
24
|
})(CurrencyOptions = exports.CurrencyOptions || (exports.CurrencyOptions = {}));
|
|
25
|
+
function sleep(ms) {
|
|
26
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
+
}
|
|
25
28
|
async function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, }) {
|
|
26
29
|
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
27
30
|
const client = await (0, common_1.TxClient)(wallet);
|
|
@@ -38,12 +41,12 @@ async function submitKimaTransaction({ originChain, originAddress, targetChain,
|
|
|
38
41
|
};
|
|
39
42
|
let msg = await client.msgRequestTransaction(params);
|
|
40
43
|
const result = await client.signAndBroadcast([msg]);
|
|
41
|
-
let txId =
|
|
44
|
+
let txId = 1;
|
|
42
45
|
for (const event of result.events) {
|
|
43
46
|
if (event.type === "transaction_requested") {
|
|
44
47
|
for (const attr of event.attributes) {
|
|
45
48
|
if (attr.key === "txId") {
|
|
46
|
-
txId = attr.value;
|
|
49
|
+
txId = +attr.value;
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -53,7 +56,11 @@ async function submitKimaTransaction({ originChain, originAddress, targetChain,
|
|
|
53
56
|
txId,
|
|
54
57
|
txHash: result.transactionHash,
|
|
55
58
|
});
|
|
56
|
-
|
|
59
|
+
let hashResult;
|
|
60
|
+
do {
|
|
61
|
+
hashResult = await client.signAndBroadcast([msg]);
|
|
62
|
+
await sleep(1000);
|
|
63
|
+
} while (hashResult.code !== 0);
|
|
57
64
|
return result;
|
|
58
65
|
}
|
|
59
66
|
exports.submitKimaTransaction = submitKimaTransaction;
|
package/build/kima/common.js
CHANGED
|
@@ -14,8 +14,8 @@ const defaultFee = {
|
|
|
14
14
|
gas: "200000",
|
|
15
15
|
};
|
|
16
16
|
const types = [
|
|
17
|
-
["/KimaFinance.kima.MsgRequestTransaction", tx_1.MsgRequestTransaction],
|
|
18
|
-
["/KimaFinance.kima.MsgSetTxHash", tx_1.MsgSetTxHash],
|
|
17
|
+
["/KimaFinance.kima.kima.MsgRequestTransaction", tx_1.MsgRequestTransaction],
|
|
18
|
+
["/KimaFinance.kima.kima.MsgSetTxHash", tx_1.MsgSetTxHash],
|
|
19
19
|
];
|
|
20
20
|
exports.registry = new proto_signing_1.Registry(types);
|
|
21
21
|
const TxClient = async (wallet) => {
|
package/build/kima/tx.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ export interface MsgRequestTransaction {
|
|
|
13
13
|
export interface MsgRequestTransactionResponse {
|
|
14
14
|
code: string;
|
|
15
15
|
msg: string;
|
|
16
|
-
txId:
|
|
16
|
+
txId: number;
|
|
17
17
|
}
|
|
18
18
|
export interface MsgApproveTransaction {
|
|
19
19
|
creator: string;
|
|
20
|
-
txId:
|
|
20
|
+
txId: number;
|
|
21
21
|
txTHash: string;
|
|
22
22
|
success: string;
|
|
23
23
|
signedKey: string;
|
|
@@ -34,7 +34,7 @@ export interface MsgObservationVote {
|
|
|
34
34
|
to: string;
|
|
35
35
|
amount: string;
|
|
36
36
|
payType: string;
|
|
37
|
-
kimaTxID:
|
|
37
|
+
kimaTxID: number;
|
|
38
38
|
succeed: string;
|
|
39
39
|
}
|
|
40
40
|
export interface MsgObservationVoteResponse {
|
|
@@ -164,7 +164,7 @@ export interface MsgAddChainResponse {
|
|
|
164
164
|
}
|
|
165
165
|
export interface MsgUpdateTssHash {
|
|
166
166
|
creator: string;
|
|
167
|
-
txId:
|
|
167
|
+
txId: number;
|
|
168
168
|
tssPullHash: string;
|
|
169
169
|
}
|
|
170
170
|
export interface MsgUpdateTssHashResponse {
|
|
@@ -197,7 +197,7 @@ export interface MsgUpdateTssStatusResponse {
|
|
|
197
197
|
}
|
|
198
198
|
export interface MsgSetTxHash {
|
|
199
199
|
creator: string;
|
|
200
|
-
txId:
|
|
200
|
+
txId: number;
|
|
201
201
|
txHash: string;
|
|
202
202
|
}
|
|
203
203
|
export interface MsgSetTxHashResponse {
|
|
@@ -206,7 +206,7 @@ export interface MsgSetTxHashResponse {
|
|
|
206
206
|
}
|
|
207
207
|
export interface MsgSetTxProcess {
|
|
208
208
|
creator: string;
|
|
209
|
-
txId:
|
|
209
|
+
txId: number;
|
|
210
210
|
timestamp: string;
|
|
211
211
|
msgId: string;
|
|
212
212
|
}
|
|
@@ -214,7 +214,7 @@ export interface MsgSetTxProcessResponse {
|
|
|
214
214
|
}
|
|
215
215
|
export interface MsgFinalizeTransaction {
|
|
216
216
|
creator: string;
|
|
217
|
-
txId:
|
|
217
|
+
txId: number;
|
|
218
218
|
txHash: string;
|
|
219
219
|
success: string;
|
|
220
220
|
signedKey: string;
|
|
@@ -223,6 +223,35 @@ export interface MsgFinalizeTransactionResponse {
|
|
|
223
223
|
code: string;
|
|
224
224
|
msg: string;
|
|
225
225
|
}
|
|
226
|
+
export interface MsgWithdrawPool {
|
|
227
|
+
creator: string;
|
|
228
|
+
chain: string;
|
|
229
|
+
targetAddress: string;
|
|
230
|
+
amount: string;
|
|
231
|
+
}
|
|
232
|
+
export interface MsgWithdrawPoolResponse {
|
|
233
|
+
}
|
|
234
|
+
export interface MsgUpdateToken {
|
|
235
|
+
creator: string;
|
|
236
|
+
chain: string;
|
|
237
|
+
address: string;
|
|
238
|
+
}
|
|
239
|
+
export interface MsgUpdateTokenResponse {
|
|
240
|
+
}
|
|
241
|
+
export interface MsgUpdatePoolRequest {
|
|
242
|
+
creator: string;
|
|
243
|
+
reqId: string;
|
|
244
|
+
processed: string;
|
|
245
|
+
}
|
|
246
|
+
export interface MsgUpdatePoolRequestResponse {
|
|
247
|
+
}
|
|
248
|
+
export interface MsgLeaderReady {
|
|
249
|
+
creator: string;
|
|
250
|
+
msgId: string;
|
|
251
|
+
peerId: string;
|
|
252
|
+
}
|
|
253
|
+
export interface MsgLeaderReadyResponse {
|
|
254
|
+
}
|
|
226
255
|
export declare const MsgRequestTransaction: {
|
|
227
256
|
encode(message: MsgRequestTransaction, writer?: Writer): Writer;
|
|
228
257
|
decode(input: Reader | Uint8Array, length?: number): MsgRequestTransaction;
|
|
@@ -545,6 +574,62 @@ export declare const MsgFinalizeTransactionResponse: {
|
|
|
545
574
|
toJSON(message: MsgFinalizeTransactionResponse): unknown;
|
|
546
575
|
fromPartial(object: DeepPartial<MsgFinalizeTransactionResponse>): MsgFinalizeTransactionResponse;
|
|
547
576
|
};
|
|
577
|
+
export declare const MsgWithdrawPool: {
|
|
578
|
+
encode(message: MsgWithdrawPool, writer?: Writer): Writer;
|
|
579
|
+
decode(input: Reader | Uint8Array, length?: number): MsgWithdrawPool;
|
|
580
|
+
fromJSON(object: any): MsgWithdrawPool;
|
|
581
|
+
toJSON(message: MsgWithdrawPool): unknown;
|
|
582
|
+
fromPartial(object: DeepPartial<MsgWithdrawPool>): MsgWithdrawPool;
|
|
583
|
+
};
|
|
584
|
+
export declare const MsgWithdrawPoolResponse: {
|
|
585
|
+
encode(_: MsgWithdrawPoolResponse, writer?: Writer): Writer;
|
|
586
|
+
decode(input: Reader | Uint8Array, length?: number): MsgWithdrawPoolResponse;
|
|
587
|
+
fromJSON(_: any): MsgWithdrawPoolResponse;
|
|
588
|
+
toJSON(_: MsgWithdrawPoolResponse): unknown;
|
|
589
|
+
fromPartial(_: DeepPartial<MsgWithdrawPoolResponse>): MsgWithdrawPoolResponse;
|
|
590
|
+
};
|
|
591
|
+
export declare const MsgUpdateToken: {
|
|
592
|
+
encode(message: MsgUpdateToken, writer?: Writer): Writer;
|
|
593
|
+
decode(input: Reader | Uint8Array, length?: number): MsgUpdateToken;
|
|
594
|
+
fromJSON(object: any): MsgUpdateToken;
|
|
595
|
+
toJSON(message: MsgUpdateToken): unknown;
|
|
596
|
+
fromPartial(object: DeepPartial<MsgUpdateToken>): MsgUpdateToken;
|
|
597
|
+
};
|
|
598
|
+
export declare const MsgUpdateTokenResponse: {
|
|
599
|
+
encode(_: MsgUpdateTokenResponse, writer?: Writer): Writer;
|
|
600
|
+
decode(input: Reader | Uint8Array, length?: number): MsgUpdateTokenResponse;
|
|
601
|
+
fromJSON(_: any): MsgUpdateTokenResponse;
|
|
602
|
+
toJSON(_: MsgUpdateTokenResponse): unknown;
|
|
603
|
+
fromPartial(_: DeepPartial<MsgUpdateTokenResponse>): MsgUpdateTokenResponse;
|
|
604
|
+
};
|
|
605
|
+
export declare const MsgUpdatePoolRequest: {
|
|
606
|
+
encode(message: MsgUpdatePoolRequest, writer?: Writer): Writer;
|
|
607
|
+
decode(input: Reader | Uint8Array, length?: number): MsgUpdatePoolRequest;
|
|
608
|
+
fromJSON(object: any): MsgUpdatePoolRequest;
|
|
609
|
+
toJSON(message: MsgUpdatePoolRequest): unknown;
|
|
610
|
+
fromPartial(object: DeepPartial<MsgUpdatePoolRequest>): MsgUpdatePoolRequest;
|
|
611
|
+
};
|
|
612
|
+
export declare const MsgUpdatePoolRequestResponse: {
|
|
613
|
+
encode(_: MsgUpdatePoolRequestResponse, writer?: Writer): Writer;
|
|
614
|
+
decode(input: Reader | Uint8Array, length?: number): MsgUpdatePoolRequestResponse;
|
|
615
|
+
fromJSON(_: any): MsgUpdatePoolRequestResponse;
|
|
616
|
+
toJSON(_: MsgUpdatePoolRequestResponse): unknown;
|
|
617
|
+
fromPartial(_: DeepPartial<MsgUpdatePoolRequestResponse>): MsgUpdatePoolRequestResponse;
|
|
618
|
+
};
|
|
619
|
+
export declare const MsgLeaderReady: {
|
|
620
|
+
encode(message: MsgLeaderReady, writer?: Writer): Writer;
|
|
621
|
+
decode(input: Reader | Uint8Array, length?: number): MsgLeaderReady;
|
|
622
|
+
fromJSON(object: any): MsgLeaderReady;
|
|
623
|
+
toJSON(message: MsgLeaderReady): unknown;
|
|
624
|
+
fromPartial(object: DeepPartial<MsgLeaderReady>): MsgLeaderReady;
|
|
625
|
+
};
|
|
626
|
+
export declare const MsgLeaderReadyResponse: {
|
|
627
|
+
encode(_: MsgLeaderReadyResponse, writer?: Writer): Writer;
|
|
628
|
+
decode(input: Reader | Uint8Array, length?: number): MsgLeaderReadyResponse;
|
|
629
|
+
fromJSON(_: any): MsgLeaderReadyResponse;
|
|
630
|
+
toJSON(_: MsgLeaderReadyResponse): unknown;
|
|
631
|
+
fromPartial(_: DeepPartial<MsgLeaderReadyResponse>): MsgLeaderReadyResponse;
|
|
632
|
+
};
|
|
548
633
|
/** Msg defines the Msg service. */
|
|
549
634
|
export interface Msg {
|
|
550
635
|
RequestTransaction(request: MsgRequestTransaction): Promise<MsgRequestTransactionResponse>;
|
|
@@ -569,8 +654,12 @@ export interface Msg {
|
|
|
569
654
|
UpdateTssStatus(request: MsgUpdateTssStatus): Promise<MsgUpdateTssStatusResponse>;
|
|
570
655
|
SetTxHash(request: MsgSetTxHash): Promise<MsgSetTxHashResponse>;
|
|
571
656
|
SetTxProcess(request: MsgSetTxProcess): Promise<MsgSetTxProcessResponse>;
|
|
572
|
-
/** this line is used by starport scaffolding # proto/tx/rpc */
|
|
573
657
|
FinalizeTransaction(request: MsgFinalizeTransaction): Promise<MsgFinalizeTransactionResponse>;
|
|
658
|
+
WithdrawPool(request: MsgWithdrawPool): Promise<MsgWithdrawPoolResponse>;
|
|
659
|
+
UpdateToken(request: MsgUpdateToken): Promise<MsgUpdateTokenResponse>;
|
|
660
|
+
UpdatePoolRequest(request: MsgUpdatePoolRequest): Promise<MsgUpdatePoolRequestResponse>;
|
|
661
|
+
/** this line is used by starport scaffolding # proto/tx/rpc */
|
|
662
|
+
LeaderReady(request: MsgLeaderReady): Promise<MsgLeaderReadyResponse>;
|
|
574
663
|
}
|
|
575
664
|
export declare class MsgClientImpl implements Msg {
|
|
576
665
|
private readonly rpc;
|
|
@@ -598,6 +687,10 @@ export declare class MsgClientImpl implements Msg {
|
|
|
598
687
|
SetTxHash(request: MsgSetTxHash): Promise<MsgSetTxHashResponse>;
|
|
599
688
|
SetTxProcess(request: MsgSetTxProcess): Promise<MsgSetTxProcessResponse>;
|
|
600
689
|
FinalizeTransaction(request: MsgFinalizeTransaction): Promise<MsgFinalizeTransactionResponse>;
|
|
690
|
+
WithdrawPool(request: MsgWithdrawPool): Promise<MsgWithdrawPoolResponse>;
|
|
691
|
+
UpdateToken(request: MsgUpdateToken): Promise<MsgUpdateTokenResponse>;
|
|
692
|
+
UpdatePoolRequest(request: MsgUpdatePoolRequest): Promise<MsgUpdatePoolRequestResponse>;
|
|
693
|
+
LeaderReady(request: MsgLeaderReady): Promise<MsgLeaderReadyResponse>;
|
|
601
694
|
}
|
|
602
695
|
interface Rpc {
|
|
603
696
|
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|