@kimafinance/kima-transaction-api 1.4.1 → 1.4.3

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 (89) hide show
  1. package/README.md +37 -3
  2. package/build/index.d.ts +6 -3
  3. package/build/index.js +91 -17
  4. package/build/kima/common.d.ts +3 -4
  5. package/build/kima/common.js +15 -12
  6. package/build/kima/swap_tx.d.ts +387 -0
  7. package/build/kima/swap_tx.js +1109 -0
  8. package/build/kima/transfer_tx.d.ts +674 -0
  9. package/build/kima/transfer_tx.js +2170 -0
  10. package/build/types.d.ts +68 -0
  11. package/build/types.js +34 -0
  12. package/package.json +10 -10
  13. package/src/index.ts +167 -3
  14. package/src/kima/common.ts +22 -5
  15. package/src/kima/swap_tx.ts +1353 -0
  16. package/src/kima/transfer_tx.ts +2945 -0
  17. package/src/types.ts +78 -0
  18. package/build/api/htlc-lock.d.ts +0 -23
  19. package/build/api/htlc-lock.js +0 -37
  20. package/build/api/htlc-reclaim.d.ts +0 -14
  21. package/build/api/htlc-reclaim.js +0 -28
  22. package/build/api/submit.d.ts +0 -54
  23. package/build/api/submit.js +0 -94
  24. package/build/config/global-this.config.d.ts +0 -2
  25. package/build/config/global-this.config.js +0 -18
  26. package/build/config/probuff.config.d.ts +0 -2
  27. package/build/config/probuff.config.js +0 -12
  28. package/build/kima/tx/cancel.d.ts +0 -35
  29. package/build/kima/tx/cancel.js +0 -115
  30. package/build/kima/tx/drain-finalize.d.ts +0 -47
  31. package/build/kima/tx/drain-finalize.js +0 -155
  32. package/build/kima/tx/drain.d.ts +0 -50
  33. package/build/kima/tx/drain.js +0 -164
  34. package/build/kima/tx/finalize.d.ts +0 -47
  35. package/build/kima/tx/finalize.js +0 -155
  36. package/build/kima/tx/htlc-lock.d.ts +0 -42
  37. package/build/kima/tx/htlc-lock.js +0 -152
  38. package/build/kima/tx/htlc-reclaim.d.ts +0 -30
  39. package/build/kima/tx/htlc-reclaim.js +0 -105
  40. package/build/kima/tx/index.d.ts +0 -1
  41. package/build/kima/tx/index.js +0 -4
  42. package/build/kima/tx/liquidity-provision.d.ts +0 -30
  43. package/build/kima/tx/liquidity-provision.js +0 -102
  44. package/build/kima/tx/message-service.d.ts +0 -54
  45. package/build/kima/tx/message-service.js +0 -117
  46. package/build/kima/tx/provision-finalize.d.ts +0 -47
  47. package/build/kima/tx/provision-finalize.js +0 -155
  48. package/build/kima/tx/provision.d.ts +0 -70
  49. package/build/kima/tx/provision.js +0 -230
  50. package/build/kima/tx/request.d.ts +0 -63
  51. package/build/kima/tx/request.js +0 -222
  52. package/build/kima/tx/response.d.ts +0 -21
  53. package/build/kima/tx/response.js +0 -69
  54. package/build/kima/tx/rpc.d.ts +0 -0
  55. package/build/kima/tx/rpc.js +0 -1
  56. package/build/kima/tx/set-hash.d.ts +0 -42
  57. package/build/kima/tx/set-hash.js +0 -130
  58. package/build/kima/tx/set-process.d.ts +0 -37
  59. package/build/kima/tx/set-process.js +0 -121
  60. package/build/kima/tx/transfer-limit.d.ts +0 -30
  61. package/build/kima/tx/transfer-limit.js +0 -102
  62. package/build/kima/tx/withdraw.d.ts +0 -47
  63. package/build/kima/tx/withdraw.js +0 -155
  64. package/build/utils.d.ts +0 -17
  65. package/build/utils.js +0 -49
  66. package/src/api/htlc-lock.ts +0 -57
  67. package/src/api/htlc-reclaim.ts +0 -39
  68. package/src/api/submit.ts +0 -132
  69. package/src/config/global-this.config.ts +0 -20
  70. package/src/config/probuff.config.ts +0 -9
  71. package/src/kima/tx/cancel.ts +0 -147
  72. package/src/kima/tx/drain-finalize.ts +0 -191
  73. package/src/kima/tx/drain.ts +0 -201
  74. package/src/kima/tx/finalize.ts +0 -191
  75. package/src/kima/tx/htlc-lock.ts +0 -183
  76. package/src/kima/tx/htlc-reclaim.ts +0 -132
  77. package/src/kima/tx/index.ts +0 -1
  78. package/src/kima/tx/liquidity-provision.ts +0 -132
  79. package/src/kima/tx/message-service.ts +0 -278
  80. package/src/kima/tx/provision-finalize.ts +0 -191
  81. package/src/kima/tx/provision.ts +0 -279
  82. package/src/kima/tx/request.ts +0 -256
  83. package/src/kima/tx/response.ts +0 -83
  84. package/src/kima/tx/rpc.ts +0 -0
  85. package/src/kima/tx/set-hash.ts +0 -162
  86. package/src/kima/tx/set-process.ts +0 -151
  87. package/src/kima/tx/transfer-limit.ts +0 -132
  88. package/src/kima/tx/withdraw.ts +0 -191
  89. package/src/utils.ts +0 -67
@@ -0,0 +1,68 @@
1
+ export declare enum SupportedNetworks {
2
+ ETHEREUM = "ETH",
3
+ POLYGON = "POL",
4
+ AVALANCHE = "AVX",
5
+ SOLANA = "SOL",
6
+ BSC = "BSC",
7
+ ARBITRIUM = "ARB",
8
+ OPTIMISM = "OPT",
9
+ POLYGON_ZKEVM = "ZKE",
10
+ BITCOIN = "BTC",
11
+ BERA = "BERA",
12
+ CFX = "CFX",
13
+ TRON = "TRX",
14
+ FIAT = "FIAT",
15
+ CREDITCARD = "CC",
16
+ BASE = "BASE"
17
+ }
18
+ export declare enum CurrencyOptions {
19
+ USDT = "USDT",
20
+ USDC = "USDC",
21
+ USDK = "USDK",
22
+ EURC = "EURC",
23
+ EURK = "EURK",
24
+ EUR = "EUR",
25
+ USD = "USD"
26
+ }
27
+ export interface RequestHtlcReclaimProps {
28
+ senderAddress: string;
29
+ txHash: string;
30
+ }
31
+ export interface RequestHtlcLockProps {
32
+ fromAddress: string;
33
+ senderPubkey: string;
34
+ amount: string;
35
+ htlcTimeout: string;
36
+ txHash: string;
37
+ htlcAddress: string;
38
+ }
39
+ export interface RequestTransferTxProps {
40
+ originChain: SupportedNetworks;
41
+ originAddress: string;
42
+ targetChain: SupportedNetworks;
43
+ targetAddress: string;
44
+ originSymbol: CurrencyOptions;
45
+ targetSymbol: CurrencyOptions;
46
+ amount: string;
47
+ fee: string;
48
+ htlcCreationHash?: string;
49
+ htlcCreationVout?: number;
50
+ htlcExpirationTimestamp?: string;
51
+ htlcVersion?: string;
52
+ senderPubKey?: Uint8Array;
53
+ options: string;
54
+ }
55
+ export interface RequestSwapTxProps {
56
+ originChain: SupportedNetworks;
57
+ originAddress: string;
58
+ targetChain: SupportedNetworks;
59
+ targetAddress: string;
60
+ originSymbol: CurrencyOptions;
61
+ targetSymbol: CurrencyOptions;
62
+ amountIn: string;
63
+ amountOut: string;
64
+ fee: string;
65
+ dex: string;
66
+ slippage: string;
67
+ options: string;
68
+ }
package/build/types.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CurrencyOptions = exports.SupportedNetworks = void 0;
4
+ var SupportedNetworks;
5
+ (function (SupportedNetworks) {
6
+ SupportedNetworks["ETHEREUM"] = "ETH";
7
+ SupportedNetworks["POLYGON"] = "POL";
8
+ SupportedNetworks["AVALANCHE"] = "AVX";
9
+ SupportedNetworks["SOLANA"] = "SOL";
10
+ SupportedNetworks["BSC"] = "BSC";
11
+ SupportedNetworks["ARBITRIUM"] = "ARB";
12
+ SupportedNetworks["OPTIMISM"] = "OPT";
13
+ SupportedNetworks["POLYGON_ZKEVM"] = "ZKE";
14
+ SupportedNetworks["BITCOIN"] = "BTC";
15
+ SupportedNetworks["BERA"] = "BERA";
16
+ SupportedNetworks["CFX"] = "CFX";
17
+ SupportedNetworks["TRON"] = "TRX";
18
+ SupportedNetworks["FIAT"] = "FIAT";
19
+ SupportedNetworks["CREDITCARD"] = "CC";
20
+ SupportedNetworks["BASE"] = "BASE";
21
+ })(SupportedNetworks = exports.SupportedNetworks || (exports.SupportedNetworks = {}));
22
+ var CurrencyOptions;
23
+ (function (CurrencyOptions) {
24
+ CurrencyOptions["USDT"] = "USDT";
25
+ CurrencyOptions["USDC"] = "USDC";
26
+ CurrencyOptions["USDK"] = "USDK";
27
+ CurrencyOptions["EURC"] = "EURC";
28
+ CurrencyOptions["EURK"] = "EURK";
29
+ CurrencyOptions["EUR"] = "EUR";
30
+ CurrencyOptions["USD"] = "USD";
31
+ })(CurrencyOptions = exports.CurrencyOptions || (exports.CurrencyOptions = {}));
32
+ function sleep(ms) {
33
+ return new Promise((resolve) => setTimeout(resolve, ms));
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimafinance/kima-transaction-api",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
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": "",
@@ -8,7 +8,7 @@
8
8
  "main": "build/index.js",
9
9
  "source": "src/index.ts",
10
10
  "engines": {
11
- "node": ">=20"
11
+ "node": ">=10"
12
12
  },
13
13
  "scripts": {
14
14
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -18,16 +18,16 @@
18
18
  },
19
19
  "keywords": [],
20
20
  "devDependencies": {
21
- "@types/node": "^20.17.6",
22
- "nodemon": "^3.1.7",
23
- "rimraf": "^5.0.10",
24
- "ts-node": "^10.9.2",
21
+ "@types/node": "^18.11.9",
22
+ "nodemon": "^2.0.20",
23
+ "rimraf": "^3.0.2",
24
+ "ts-node": "^10.9.1",
25
25
  "typescript": "^4.9.3"
26
26
  },
27
27
  "dependencies": {
28
- "@cosmjs/cosmwasm-stargate": "^0.32.4",
29
- "@cosmjs/proto-signing": "^0.32.4",
30
- "@cosmjs/stargate": "^0.32.4",
31
- "dotenv": "^16.4.5"
28
+ "@cosmjs/cosmwasm-stargate": "^0.31.1",
29
+ "@cosmjs/proto-signing": "^0.31.1",
30
+ "@cosmjs/stargate": "^0.31.1",
31
+ "dotenv": "^16.0.3"
32
32
  }
33
33
  }
package/src/index.ts CHANGED
@@ -1,3 +1,167 @@
1
- export * from "./api/htlc-reclaim";
2
- export * from "./api/htlc-lock";
3
- export * from "./api/submit";
1
+ import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
2
+ import { TxClient } from "./kima/common";
3
+ import {
4
+ MsgHtlcReclaim,
5
+ MsgRequestHtlcLock,
6
+ MsgRequestTransaction,
7
+ } from "./kima/transfer_tx";
8
+
9
+ import {
10
+ MsgRequestSwapTransaction,
11
+ } from "./kima/swap_tx";
12
+
13
+ import {
14
+ RequestHtlcReclaimProps,
15
+ RequestHtlcLockProps,
16
+ RequestTransferTxProps,
17
+ RequestSwapTxProps,
18
+ } from "./types";
19
+
20
+ export async function HtlcReclaim({
21
+ senderAddress,
22
+ txHash,
23
+ }: RequestHtlcReclaimProps) {
24
+ const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
25
+ process.env.KIMA_BACKEND_MNEMONIC as string,
26
+ { prefix: "kima" }
27
+ );
28
+ const client = await TxClient(wallet);
29
+ const [firstAccount] = await wallet.getAccounts();
30
+ const params: MsgHtlcReclaim = {
31
+ creator: firstAccount.address,
32
+ senderAddress,
33
+ txHash,
34
+ };
35
+
36
+ let msg = await client.msgHtlcReclaim(params);
37
+ const result = await client.signAndBroadcast([msg]);
38
+
39
+ return result;
40
+ }
41
+
42
+ export async function submitHtlcLock({
43
+ fromAddress,
44
+ senderPubkey,
45
+ amount,
46
+ htlcTimeout,
47
+ txHash,
48
+ htlcAddress,
49
+ }: RequestHtlcLockProps) {
50
+ const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
51
+ process.env.KIMA_BACKEND_MNEMONIC as string,
52
+ { prefix: "kima" }
53
+ );
54
+ const client = await TxClient(wallet);
55
+ const [firstAccount] = await wallet.getAccounts();
56
+ const params: MsgRequestHtlcLock = {
57
+ creator: firstAccount.address,
58
+ fromAddress,
59
+ senderPubkey,
60
+ amount,
61
+ htlcTimeout,
62
+ htlcAddress,
63
+ txHash,
64
+ };
65
+
66
+ let msg = await client.msgRequestHtlcLock(params);
67
+ const result = await client.signAndBroadcast([msg]);
68
+
69
+ return result;
70
+ }
71
+
72
+ export async function getCreatorAddress() {
73
+ const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
74
+ process.env.KIMA_BACKEND_MNEMONIC as string,
75
+ { prefix: "kima" }
76
+ );
77
+ const [firstAccount] = await wallet.getAccounts();
78
+ return firstAccount;
79
+ }
80
+
81
+ export async function submitKimaTransferTransaction({
82
+ originChain,
83
+ originAddress,
84
+ targetChain,
85
+ targetAddress,
86
+ originSymbol,
87
+ targetSymbol,
88
+ amount,
89
+ fee,
90
+ htlcCreationHash,
91
+ htlcCreationVout = 0,
92
+ htlcExpirationTimestamp,
93
+ htlcVersion = "",
94
+ senderPubKey,
95
+ options,
96
+ }: RequestTransferTxProps) {
97
+ const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
98
+ process.env.KIMA_BACKEND_MNEMONIC as string,
99
+ { prefix: "kima" }
100
+ );
101
+ const client = await TxClient(wallet);
102
+ const [firstAccount] = await wallet.getAccounts();
103
+ const params: MsgRequestTransaction = {
104
+ creator: firstAccount.address,
105
+ originChain,
106
+ originAddress,
107
+ targetChain,
108
+ targetAddress,
109
+ originSymbol,
110
+ targetSymbol,
111
+ amount: amount,
112
+ fee: fee,
113
+ htlcCreationHash: htlcCreationHash || "",
114
+ htlcCreationVout: htlcCreationVout || 0,
115
+ htlcExpirationTimestamp: htlcExpirationTimestamp || "",
116
+ htlcVersion,
117
+ senderPubKey: senderPubKey || new Uint8Array(),
118
+ options,
119
+ };
120
+
121
+ const msgTx = await client.msgRequestTransaction(params);
122
+ const result = await client.signAndBroadcast([msgTx]);
123
+
124
+ return result;
125
+ }
126
+
127
+ export async function submitKimaSwapTransaction({
128
+ originChain,
129
+ originAddress,
130
+ targetChain,
131
+ targetAddress,
132
+ originSymbol,
133
+ targetSymbol,
134
+ amountIn,
135
+ amountOut,
136
+ fee,
137
+ dex,
138
+ slippage,
139
+ options,
140
+ }: RequestSwapTxProps) {
141
+ const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
142
+ process.env.KIMA_BACKEND_MNEMONIC as string,
143
+ { prefix: "kima" }
144
+ );
145
+ const client = await TxClient(wallet);
146
+ const [firstAccount] = await wallet.getAccounts();
147
+ const params: MsgRequestSwapTransaction = {
148
+ creator: firstAccount.address,
149
+ originChain,
150
+ originAddress,
151
+ targetChain,
152
+ targetAddress,
153
+ originSymbol,
154
+ targetSymbol,
155
+ amountIn: amountIn,
156
+ amountOut: amountOut,
157
+ fee: fee,
158
+ dex: dex,
159
+ slippage: slippage,
160
+ options: options,
161
+ };
162
+
163
+ const msgTx = await client.msgRequestSwapTransaction(params);
164
+ const result = await client.signAndBroadcast([msgTx]);
165
+
166
+ return result;
167
+ }
@@ -1,10 +1,22 @@
1
1
  import { SigningStargateClient, StdFee } from "@cosmjs/stargate";
2
2
  import dotenv from "dotenv";
3
- import { Registry, OfflineSigner, EncodeObject, coin } from "@cosmjs/proto-signing";
4
- import { MsgRequestTransaction } from "./tx/request";
5
- import { MsgRequestHtlcLock } from "./tx/htlc-lock";
6
- import { MsgSetTxHash } from "./tx/set-hash";
7
- import { MsgHtlcReclaim } from "./tx/htlc-reclaim";
3
+ import {
4
+ Registry,
5
+ OfflineSigner,
6
+ EncodeObject,
7
+ coin,
8
+ } from "@cosmjs/proto-signing";
9
+
10
+ import {
11
+ MsgRequestHtlcLock,
12
+ MsgRequestTransaction,
13
+ MsgSetTxHash,
14
+ MsgHtlcReclaim,
15
+ } from "./transfer_tx";
16
+
17
+ import {
18
+ MsgRequestSwapTransaction,
19
+ } from "./swap_tx";
8
20
 
9
21
  dotenv.config();
10
22
 
@@ -23,6 +35,7 @@ const types = [
23
35
  ["/kimablockchain.transaction.MsgRequestHtlcLock", MsgRequestHtlcLock],
24
36
  ["/kimablockchain.transaction.MsgSetTxHash", MsgSetTxHash],
25
37
  ["/kimablockchain.transaction.MsgHtlcReclaim", MsgHtlcReclaim],
38
+ ["/kimablockchain.swap.MsgRequestSwapTransaction", MsgRequestSwapTransaction],
26
39
  ];
27
40
 
28
41
  export const registry = new Registry(<any>types);
@@ -62,5 +75,9 @@ export const TxClient = async (wallet: OfflineSigner) => {
62
75
  typeUrl: "/kimablockchain.transaction.MsgHtlcReclaim",
63
76
  value: MsgHtlcReclaim.fromPartial(data),
64
77
  }),
78
+ msgRequestSwapTransaction: (data: MsgRequestSwapTransaction): EncodeObject => ({
79
+ typeUrl: "/kimablockchain.swap.MsgRequestSwapTransaction",
80
+ value: MsgRequestSwapTransaction.fromPartial(data),
81
+ }),
65
82
  };
66
83
  };