@kimafinance/kima-transaction-api 1.4.1 → 1.4.2

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.
Files changed (82) hide show
  1. package/build/index.d.ts +50 -3
  2. package/build/index.js +121 -17
  3. package/build/kima/common.d.ts +1 -4
  4. package/build/kima/common.js +9 -12
  5. package/build/kima/tx.d.ts +674 -0
  6. package/build/kima/tx.js +2170 -0
  7. package/package.json +10 -10
  8. package/src/index.ts +206 -3
  9. package/src/kima/common.ts +12 -5
  10. package/src/kima/tx.ts +2945 -0
  11. package/build/api/htlc-lock.d.ts +0 -23
  12. package/build/api/htlc-lock.js +0 -37
  13. package/build/api/htlc-reclaim.d.ts +0 -14
  14. package/build/api/htlc-reclaim.js +0 -28
  15. package/build/api/submit.d.ts +0 -54
  16. package/build/api/submit.js +0 -94
  17. package/build/config/global-this.config.d.ts +0 -2
  18. package/build/config/global-this.config.js +0 -18
  19. package/build/config/probuff.config.d.ts +0 -2
  20. package/build/config/probuff.config.js +0 -12
  21. package/build/kima/tx/cancel.d.ts +0 -35
  22. package/build/kima/tx/cancel.js +0 -115
  23. package/build/kima/tx/drain-finalize.d.ts +0 -47
  24. package/build/kima/tx/drain-finalize.js +0 -155
  25. package/build/kima/tx/drain.d.ts +0 -50
  26. package/build/kima/tx/drain.js +0 -164
  27. package/build/kima/tx/finalize.d.ts +0 -47
  28. package/build/kima/tx/finalize.js +0 -155
  29. package/build/kima/tx/htlc-lock.d.ts +0 -42
  30. package/build/kima/tx/htlc-lock.js +0 -152
  31. package/build/kima/tx/htlc-reclaim.d.ts +0 -30
  32. package/build/kima/tx/htlc-reclaim.js +0 -105
  33. package/build/kima/tx/index.d.ts +0 -1
  34. package/build/kima/tx/index.js +0 -4
  35. package/build/kima/tx/liquidity-provision.d.ts +0 -30
  36. package/build/kima/tx/liquidity-provision.js +0 -102
  37. package/build/kima/tx/message-service.d.ts +0 -54
  38. package/build/kima/tx/message-service.js +0 -117
  39. package/build/kima/tx/provision-finalize.d.ts +0 -47
  40. package/build/kima/tx/provision-finalize.js +0 -155
  41. package/build/kima/tx/provision.d.ts +0 -70
  42. package/build/kima/tx/provision.js +0 -230
  43. package/build/kima/tx/request.d.ts +0 -63
  44. package/build/kima/tx/request.js +0 -222
  45. package/build/kima/tx/response.d.ts +0 -21
  46. package/build/kima/tx/response.js +0 -69
  47. package/build/kima/tx/rpc.d.ts +0 -0
  48. package/build/kima/tx/rpc.js +0 -1
  49. package/build/kima/tx/set-hash.d.ts +0 -42
  50. package/build/kima/tx/set-hash.js +0 -130
  51. package/build/kima/tx/set-process.d.ts +0 -37
  52. package/build/kima/tx/set-process.js +0 -121
  53. package/build/kima/tx/transfer-limit.d.ts +0 -30
  54. package/build/kima/tx/transfer-limit.js +0 -102
  55. package/build/kima/tx/withdraw.d.ts +0 -47
  56. package/build/kima/tx/withdraw.js +0 -155
  57. package/build/utils.d.ts +0 -17
  58. package/build/utils.js +0 -49
  59. package/src/api/htlc-lock.ts +0 -57
  60. package/src/api/htlc-reclaim.ts +0 -39
  61. package/src/api/submit.ts +0 -132
  62. package/src/config/global-this.config.ts +0 -20
  63. package/src/config/probuff.config.ts +0 -9
  64. package/src/kima/tx/cancel.ts +0 -147
  65. package/src/kima/tx/drain-finalize.ts +0 -191
  66. package/src/kima/tx/drain.ts +0 -201
  67. package/src/kima/tx/finalize.ts +0 -191
  68. package/src/kima/tx/htlc-lock.ts +0 -183
  69. package/src/kima/tx/htlc-reclaim.ts +0 -132
  70. package/src/kima/tx/index.ts +0 -1
  71. package/src/kima/tx/liquidity-provision.ts +0 -132
  72. package/src/kima/tx/message-service.ts +0 -278
  73. package/src/kima/tx/provision-finalize.ts +0 -191
  74. package/src/kima/tx/provision.ts +0 -279
  75. package/src/kima/tx/request.ts +0 -256
  76. package/src/kima/tx/response.ts +0 -83
  77. package/src/kima/tx/rpc.ts +0 -0
  78. package/src/kima/tx/set-hash.ts +0 -162
  79. package/src/kima/tx/set-process.ts +0 -151
  80. package/src/kima/tx/transfer-limit.ts +0 -132
  81. package/src/kima/tx/withdraw.ts +0 -191
  82. package/src/utils.ts +0 -67
package/build/utils.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.longToNumber = exports.sleep = exports.base64FromBytes = exports.bytesFromBase64 = exports.isSet = void 0;
7
- const global_this_config_1 = __importDefault(require("./config/global-this.config"));
8
- function isSet(value) {
9
- return value !== null && value !== undefined;
10
- }
11
- exports.isSet = isSet;
12
- function bytesFromBase64(b64) {
13
- if (global_this_config_1.default.Buffer) {
14
- return Uint8Array.from(global_this_config_1.default.Buffer.from(b64, "base64"));
15
- }
16
- else {
17
- const bin = global_this_config_1.default.atob(b64);
18
- const arr = new Uint8Array(bin.length);
19
- for (let i = 0; i < bin.length; ++i) {
20
- arr[i] = bin.charCodeAt(i);
21
- }
22
- return arr;
23
- }
24
- }
25
- exports.bytesFromBase64 = bytesFromBase64;
26
- function base64FromBytes(arr) {
27
- if (global_this_config_1.default.Buffer) {
28
- return global_this_config_1.default.Buffer.from(arr).toString("base64");
29
- }
30
- else {
31
- const bin = [];
32
- arr.forEach((byte) => {
33
- bin.push(String.fromCharCode(byte));
34
- });
35
- return global_this_config_1.default.btoa(bin.join(""));
36
- }
37
- }
38
- exports.base64FromBytes = base64FromBytes;
39
- function sleep(ms) {
40
- return new Promise((resolve) => setTimeout(resolve, ms));
41
- }
42
- exports.sleep = sleep;
43
- function longToNumber(long) {
44
- if (long.gt(Number.MAX_SAFE_INTEGER)) {
45
- throw new global_this_config_1.default.Error("Value is larger than Number.MAX_SAFE_INTEGER");
46
- }
47
- return long.toNumber();
48
- }
49
- exports.longToNumber = longToNumber;
@@ -1,57 +0,0 @@
1
- import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
2
- import { TxClient } from "../kima/common";
3
- import { MsgRequestHtlcLock } from "../kima/tx/htlc-lock";
4
-
5
- export interface RequestHtlcLockProps {
6
- fromAddress: string;
7
- senderPubkey: string;
8
- amount: string;
9
- htlcTimeout: string;
10
- txHash: string;
11
- htlcAddress: string;
12
- }
13
-
14
-
15
- /**
16
- * Create an HTCL transaction
17
- *
18
- * @export
19
- * @async
20
- * @param {RequestHtlcLockProps} param0
21
- * @param {string} param0.fromAddress - The creator wallet address
22
- * @param {string} param0.senderPubkey - The creator wallet public key
23
- * @param {string} param0.amount - The total amount to be locked including fees
24
- * @param {string} param0.htlcTimeout - The time in seconds the HTLC will be valid for
25
- * @param {string} param0.txHash - The transaction hash of the HTLC lock
26
- * @param {string} param0.htlcAddress - The HTLC address
27
- * @returns {Promise<DeliverTxResponse>}
28
- */
29
- export async function submitHtlcLock({
30
- fromAddress,
31
- senderPubkey,
32
- amount,
33
- htlcTimeout,
34
- txHash,
35
- htlcAddress,
36
- }: RequestHtlcLockProps) {
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: MsgRequestHtlcLock = {
44
- creator: firstAccount.address,
45
- fromAddress,
46
- senderPubkey,
47
- amount,
48
- htlcTimeout,
49
- htlcAddress,
50
- txHash,
51
- };
52
-
53
- let msg = await client.msgRequestHtlcLock(params);
54
- const result = await client.signAndBroadcast([msg]);
55
-
56
- return result;
57
- }
@@ -1,39 +0,0 @@
1
- import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
2
- import { TxClient } from "../kima/common";
3
- import { MsgHtlcReclaim } from "../kima/tx/htlc-reclaim";
4
-
5
- export interface RequestHtlcReclaimProps {
6
- senderAddress: string;
7
- txHash: string;
8
- }
9
-
10
- /**
11
- * Cancel an HTCL lock by user taking back the funds
12
- * @export
13
- * @async
14
- * @param {RequestHtlcReclaimProps} param0
15
- * @param {string} param0.senderAddress - The creator wallet address
16
- * @param {string} param0.txHash - The transaction hash of the HTLC lock
17
- * @returns {Promise<DeliverTxResponse>}
18
- */
19
- export async function HtlcReclaim({
20
- senderAddress,
21
- txHash,
22
- }: RequestHtlcReclaimProps) {
23
- const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
24
- process.env.KIMA_BACKEND_MNEMONIC as string,
25
- { prefix: "kima" }
26
- );
27
- const client = await TxClient(wallet);
28
- const [firstAccount] = await wallet.getAccounts();
29
- const params: MsgHtlcReclaim = {
30
- creator: firstAccount.address,
31
- senderAddress,
32
- txHash,
33
- };
34
-
35
- let msg = await client.msgHtlcReclaim(params);
36
- const result = await client.signAndBroadcast([msg]);
37
-
38
- return result;
39
- }
package/src/api/submit.ts DELETED
@@ -1,132 +0,0 @@
1
- import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
2
- import { TxClient } from "../kima/common";
3
- import { MsgRequestTransaction } from "../kima/tx/request";
4
- import { sleep } from "../utils";
5
-
6
- export enum SupportedNetworks {
7
- ARBITRIUM = "ARB",
8
- AVALANCHE = "AVX",
9
- BSC = "BSC",
10
- BTC = "BTC",
11
- ETHEREUM = "ETH",
12
- OPTIMISM = "OPT",
13
- POLYGON = "POL",
14
- SOLANA = "SOL",
15
- TRON = "TRX",
16
- }
17
-
18
- export enum CurrencyOptions {
19
- USDT = "USDT",
20
- USDC = "USDC",
21
- USDK = "USDK",
22
- }
23
-
24
- export interface RequestTxProps {
25
- originChain: SupportedNetworks;
26
- originAddress: string;
27
- targetChain: SupportedNetworks;
28
- targetAddress: string;
29
- originSymbol: CurrencyOptions;
30
- targetSymbol: CurrencyOptions;
31
- amount: number;
32
- fee: number;
33
- htlcCreationHash: string;
34
- htlcCreationVout: number;
35
- htlcExpirationTimestamp: string;
36
- htlcVersion: string;
37
- senderPubKey: Uint8Array;
38
- }
39
-
40
- /**
41
- * Create a Kima transfer transaction. The HTLC parameters are only required on Bitcoin, use blank strings (or zeros) for other chains.
42
- * The approval or HTLC transaction must be completed before submitting the Kima transaction or it will fail.
43
- *
44
- * @export
45
- * @async
46
- * @param {RequestTxProps} param0
47
- * @param {SupportedNetworks} param0.originChain - The chain the funds are being transferred from
48
- * @param {string} param0.originAddress - The user wallet address
49
- * @param {SupportedNetworks} param0.targetChain - The chain the funds are being transferred to
50
- * @param {string} param0.targetAddress - The destination wallet address
51
- * @param {CurrencyOptions} param0.originSymbol - The starting token symbol
52
- * @param {CurrencyOptions} param0.targetSymbol - The destination token symbol
53
- * @param {number} param0.amount - amount of tokens to be transferred
54
- * @param {number} param0.fee - The total fees to be paid
55
- * @param {string} param0.htlcCreationHash - (if applicable) The transaction hash of the HTLC lock
56
- * @param {number} param0.htlcCreationVout - (if applicable) The vout of the HTLC lock
57
- * @param {string} param0.htlcExpirationTimestamp - (if applicable) The expiration timestamp of the HTLC lock
58
- * @param {string} param0.htlcVersion - (if applicable) The version of the HTLC lock
59
- * @param {Uint8Array} param0.senderPubKey - (if HTLC) The creator wallet public key
60
- * @returns {Promise<DeliverTxResponse>}
61
- */
62
- export async function submitKimaTransaction({
63
- originChain,
64
- originAddress,
65
- targetChain,
66
- targetAddress,
67
- originSymbol,
68
- targetSymbol,
69
- amount,
70
- fee,
71
- htlcCreationHash,
72
- htlcCreationVout,
73
- htlcExpirationTimestamp,
74
- htlcVersion,
75
- senderPubKey,
76
- }: RequestTxProps) {
77
- const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
78
- process.env.KIMA_BACKEND_MNEMONIC as string,
79
- { prefix: "kima" }
80
- );
81
- const client = await TxClient(wallet);
82
- const [firstAccount] = await wallet.getAccounts();
83
- const params: MsgRequestTransaction = {
84
- creator: firstAccount.address,
85
- originChain,
86
- originAddress,
87
- targetChain,
88
- targetAddress,
89
- originSymbol,
90
- targetSymbol,
91
- amount: amount.toString(),
92
- fee: fee.toString(),
93
- htlcCreationHash,
94
- htlcCreationVout,
95
- htlcExpirationTimestamp,
96
- htlcVersion,
97
- senderPubKey,
98
- options: "",
99
- };
100
-
101
- let msg = await client.msgRequestTransaction(params);
102
- const result = await client.signAndBroadcast([msg]);
103
-
104
- let txId = 1;
105
-
106
- for (const event of result.events) {
107
- if (event.type === "transaction_requested") {
108
- for (const attr of event.attributes) {
109
- if (attr.key === "txId") {
110
- txId = +attr.value;
111
- }
112
- }
113
- }
114
- }
115
-
116
- msg = await client.msgSetTxHash({
117
- creator: firstAccount.address,
118
- txId,
119
- txHash: result.transactionHash,
120
- txType: "request_transaction",
121
- });
122
-
123
- console.log(msg);
124
-
125
- let hashResult;
126
- do {
127
- hashResult = await client.signAndBroadcast([msg]);
128
- await sleep(1000);
129
- } while (hashResult.code !== 0);
130
-
131
- return result;
132
- }
@@ -1,20 +0,0 @@
1
- declare var self: any | undefined;
2
- declare var window: any | undefined;
3
- declare var global: any | undefined;
4
- var globalThis: any = (() => {
5
- if (typeof globalThis !== "undefined") {
6
- return globalThis;
7
- }
8
- if (typeof self !== "undefined") {
9
- return self;
10
- }
11
- if (typeof window !== "undefined") {
12
- return window;
13
- }
14
- if (typeof global !== "undefined") {
15
- return global;
16
- }
17
- throw "Unable to locate global object";
18
- })();
19
-
20
- export default globalThis;
@@ -1,9 +0,0 @@
1
- import _m0 from "protobufjs/minimal";
2
- import Long from "long";
3
-
4
- if (_m0.util.Long !== Long) {
5
- _m0.util.Long = Long as any;
6
- _m0.configure();
7
- }
8
-
9
- export default _m0
@@ -1,147 +0,0 @@
1
- import _m0 from "../../config/probuff.config";
2
- import { DeepPartial, Exact, isSet } from "../../utils";
3
-
4
- export interface MsgCancelTransaction {
5
- creator: string;
6
- transactionId: string;
7
- }
8
-
9
- export interface MsgCancelTransactionResponse {
10
- code: string;
11
- msg: string;
12
- }
13
-
14
- function createBaseMsgCancelTransaction(): MsgCancelTransaction {
15
- return { creator: "", transactionId: "" };
16
- }
17
-
18
- export const MsgCancelTransaction = {
19
- encode(
20
- message: MsgCancelTransaction,
21
- writer: _m0.Writer = _m0.Writer.create()
22
- ): _m0.Writer {
23
- if (message.creator !== "") {
24
- writer.uint32(10).string(message.creator);
25
- }
26
- if (message.transactionId !== "") {
27
- writer.uint32(18).string(message.transactionId);
28
- }
29
- return writer;
30
- },
31
-
32
- decode(
33
- input: _m0.Reader | Uint8Array,
34
- length?: number
35
- ): MsgCancelTransaction {
36
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
37
- let end = length === undefined ? reader.len : reader.pos + length;
38
- const message = createBaseMsgCancelTransaction();
39
- while (reader.pos < end) {
40
- const tag = reader.uint32();
41
- switch (tag >>> 3) {
42
- case 1:
43
- message.creator = reader.string();
44
- break;
45
- case 2:
46
- message.transactionId = reader.string();
47
- break;
48
- default:
49
- reader.skipType(tag & 7);
50
- break;
51
- }
52
- }
53
- return message;
54
- },
55
-
56
- fromJSON(object: any): MsgCancelTransaction {
57
- return {
58
- creator: isSet(object.creator) ? String(object.creator) : "",
59
- transactionId: isSet(object.transactionId)
60
- ? String(object.transactionId)
61
- : "",
62
- };
63
- },
64
-
65
- toJSON(message: MsgCancelTransaction): unknown {
66
- const obj: any = {};
67
- message.creator !== undefined && (obj.creator = message.creator);
68
- message.transactionId !== undefined &&
69
- (obj.transactionId = message.transactionId);
70
- return obj;
71
- },
72
-
73
- fromPartial<I extends Exact<DeepPartial<MsgCancelTransaction>, I>>(
74
- object: I
75
- ): MsgCancelTransaction {
76
- const message = createBaseMsgCancelTransaction();
77
- message.creator = object.creator ?? "";
78
- message.transactionId = object.transactionId ?? "";
79
- return message;
80
- },
81
- };
82
-
83
- function createBaseMsgCancelTransactionResponse(): MsgCancelTransactionResponse {
84
- return { code: "", msg: "" };
85
- }
86
-
87
- export const MsgCancelTransactionResponse = {
88
- encode(
89
- message: MsgCancelTransactionResponse,
90
- writer: _m0.Writer = _m0.Writer.create()
91
- ): _m0.Writer {
92
- if (message.code !== "") {
93
- writer.uint32(10).string(message.code);
94
- }
95
- if (message.msg !== "") {
96
- writer.uint32(18).string(message.msg);
97
- }
98
- return writer;
99
- },
100
-
101
- decode(
102
- input: _m0.Reader | Uint8Array,
103
- length?: number
104
- ): MsgCancelTransactionResponse {
105
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
106
- let end = length === undefined ? reader.len : reader.pos + length;
107
- const message = createBaseMsgCancelTransactionResponse();
108
- while (reader.pos < end) {
109
- const tag = reader.uint32();
110
- switch (tag >>> 3) {
111
- case 1:
112
- message.code = reader.string();
113
- break;
114
- case 2:
115
- message.msg = reader.string();
116
- break;
117
- default:
118
- reader.skipType(tag & 7);
119
- break;
120
- }
121
- }
122
- return message;
123
- },
124
-
125
- fromJSON(object: any): MsgCancelTransactionResponse {
126
- return {
127
- code: isSet(object.code) ? String(object.code) : "",
128
- msg: isSet(object.msg) ? String(object.msg) : "",
129
- };
130
- },
131
-
132
- toJSON(message: MsgCancelTransactionResponse): unknown {
133
- const obj: any = {};
134
- message.code !== undefined && (obj.code = message.code);
135
- message.msg !== undefined && (obj.msg = message.msg);
136
- return obj;
137
- },
138
-
139
- fromPartial<I extends Exact<DeepPartial<MsgCancelTransactionResponse>, I>>(
140
- object: I
141
- ): MsgCancelTransactionResponse {
142
- const message = createBaseMsgCancelTransactionResponse();
143
- message.code = object.code ?? "";
144
- message.msg = object.msg ?? "";
145
- return message;
146
- },
147
- };
@@ -1,191 +0,0 @@
1
- import _m0 from "../../config/probuff.config";
2
- import { DeepPartial, Exact, isSet, longToNumber } from "../../utils";
3
-
4
- export interface MsgFinalizeDrainTransaction {
5
- creator: string;
6
- txId: number;
7
- txHash: string;
8
- success: boolean;
9
- signedKey: string;
10
- errReason: string;
11
- }
12
-
13
- export interface MsgFinalizeDrainTransactionResponse {
14
- code: string;
15
- msg: string;
16
- }
17
-
18
- function createBaseMsgFinalizeDrainTransaction(): MsgFinalizeDrainTransaction {
19
- return {
20
- creator: "",
21
- txId: 0,
22
- txHash: "",
23
- success: false,
24
- signedKey: "",
25
- errReason: "",
26
- };
27
- }
28
-
29
- export const MsgFinalizeDrainTransaction = {
30
- encode(
31
- message: MsgFinalizeDrainTransaction,
32
- writer: _m0.Writer = _m0.Writer.create()
33
- ): _m0.Writer {
34
- if (message.creator !== "") {
35
- writer.uint32(10).string(message.creator);
36
- }
37
- if (message.txId !== 0) {
38
- writer.uint32(16).uint64(message.txId);
39
- }
40
- if (message.txHash !== "") {
41
- writer.uint32(26).string(message.txHash);
42
- }
43
- if (message.success === true) {
44
- writer.uint32(32).bool(message.success);
45
- }
46
- if (message.signedKey !== "") {
47
- writer.uint32(42).string(message.signedKey);
48
- }
49
- if (message.errReason !== "") {
50
- writer.uint32(50).string(message.errReason);
51
- }
52
- return writer;
53
- },
54
-
55
- decode(
56
- input: _m0.Reader | Uint8Array,
57
- length?: number
58
- ): MsgFinalizeDrainTransaction {
59
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
60
- let end = length === undefined ? reader.len : reader.pos + length;
61
- const message = createBaseMsgFinalizeDrainTransaction();
62
- while (reader.pos < end) {
63
- const tag = reader.uint32();
64
- switch (tag >>> 3) {
65
- case 1:
66
- message.creator = reader.string();
67
- break;
68
- case 2:
69
- message.txId = longToNumber(reader.uint64() as Long);
70
- break;
71
- case 3:
72
- message.txHash = reader.string();
73
- break;
74
- case 4:
75
- message.success = reader.bool();
76
- break;
77
- case 5:
78
- message.signedKey = reader.string();
79
- break;
80
- case 6:
81
- message.errReason = reader.string();
82
- break;
83
- default:
84
- reader.skipType(tag & 7);
85
- break;
86
- }
87
- }
88
- return message;
89
- },
90
-
91
- fromJSON(object: any): MsgFinalizeDrainTransaction {
92
- return {
93
- creator: isSet(object.creator) ? String(object.creator) : "",
94
- txId: isSet(object.txId) ? Number(object.txId) : 0,
95
- txHash: isSet(object.txHash) ? String(object.txHash) : "",
96
- success: isSet(object.success) ? Boolean(object.success) : false,
97
- signedKey: isSet(object.signedKey) ? String(object.signedKey) : "",
98
- errReason: isSet(object.errReason) ? String(object.errReason) : "",
99
- };
100
- },
101
-
102
- toJSON(message: MsgFinalizeDrainTransaction): unknown {
103
- const obj: any = {};
104
- message.creator !== undefined && (obj.creator = message.creator);
105
- message.txId !== undefined && (obj.txId = Math.round(message.txId));
106
- message.txHash !== undefined && (obj.txHash = message.txHash);
107
- message.success !== undefined && (obj.success = message.success);
108
- message.signedKey !== undefined && (obj.signedKey = message.signedKey);
109
- message.errReason !== undefined && (obj.errReason = message.errReason);
110
- return obj;
111
- },
112
-
113
- fromPartial<I extends Exact<DeepPartial<MsgFinalizeDrainTransaction>, I>>(
114
- object: I
115
- ): MsgFinalizeDrainTransaction {
116
- const message = createBaseMsgFinalizeDrainTransaction();
117
- message.creator = object.creator ?? "";
118
- message.txId = object.txId ?? 0;
119
- message.txHash = object.txHash ?? "";
120
- message.success = object.success ?? false;
121
- message.signedKey = object.signedKey ?? "";
122
- message.errReason = object.errReason ?? "";
123
- return message;
124
- },
125
- };
126
-
127
- function createBaseMsgFinalizeDrainTransactionResponse(): MsgFinalizeDrainTransactionResponse {
128
- return { code: "", msg: "" };
129
- }
130
-
131
- export const MsgFinalizeDrainTransactionResponse = {
132
- encode(
133
- message: MsgFinalizeDrainTransactionResponse,
134
- writer: _m0.Writer = _m0.Writer.create()
135
- ): _m0.Writer {
136
- if (message.code !== "") {
137
- writer.uint32(10).string(message.code);
138
- }
139
- if (message.msg !== "") {
140
- writer.uint32(18).string(message.msg);
141
- }
142
- return writer;
143
- },
144
-
145
- decode(
146
- input: _m0.Reader | Uint8Array,
147
- length?: number
148
- ): MsgFinalizeDrainTransactionResponse {
149
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
150
- let end = length === undefined ? reader.len : reader.pos + length;
151
- const message = createBaseMsgFinalizeDrainTransactionResponse();
152
- while (reader.pos < end) {
153
- const tag = reader.uint32();
154
- switch (tag >>> 3) {
155
- case 1:
156
- message.code = reader.string();
157
- break;
158
- case 2:
159
- message.msg = reader.string();
160
- break;
161
- default:
162
- reader.skipType(tag & 7);
163
- break;
164
- }
165
- }
166
- return message;
167
- },
168
-
169
- fromJSON(object: any): MsgFinalizeDrainTransactionResponse {
170
- return {
171
- code: isSet(object.code) ? String(object.code) : "",
172
- msg: isSet(object.msg) ? String(object.msg) : "",
173
- };
174
- },
175
-
176
- toJSON(message: MsgFinalizeDrainTransactionResponse): unknown {
177
- const obj: any = {};
178
- message.code !== undefined && (obj.code = message.code);
179
- message.msg !== undefined && (obj.msg = message.msg);
180
- return obj;
181
- },
182
-
183
- fromPartial<
184
- I extends Exact<DeepPartial<MsgFinalizeDrainTransactionResponse>, I>
185
- >(object: I): MsgFinalizeDrainTransactionResponse {
186
- const message = createBaseMsgFinalizeDrainTransactionResponse();
187
- message.code = object.code ?? "";
188
- message.msg = object.msg ?? "";
189
- return message;
190
- },
191
- };