@kimafinance/kima-transaction-api 1.5.7 → 1.5.9

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/types.d.ts CHANGED
@@ -67,3 +67,14 @@ export interface RequestSwapTxProps {
67
67
  slippage: string;
68
68
  options: string;
69
69
  }
70
+ export interface RequestExternalTxProps {
71
+ originChain: SupportedNetworks;
72
+ originAddress: string;
73
+ targetChain: SupportedNetworks;
74
+ targetAddress: string;
75
+ originSymbol: CurrencyOptions;
76
+ targetSymbol: CurrencyOptions;
77
+ amount: string;
78
+ fee: string;
79
+ options: string;
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimafinance/kima-transaction-api",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
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
@@ -4,6 +4,7 @@ import {
4
4
  MsgHtlcReclaim,
5
5
  MsgRequestHtlcLock,
6
6
  MsgRequestTransaction,
7
+ MsgRequestExternalTransaction,
7
8
  } from "./kima/transfer_tx";
8
9
 
9
10
  import {
@@ -15,6 +16,7 @@ import {
15
16
  RequestHtlcLockProps,
16
17
  RequestTransferTxProps,
17
18
  RequestSwapTxProps,
19
+ RequestExternalTxProps,
18
20
  } from "./types";
19
21
 
20
22
  export async function HtlcReclaim({
@@ -165,3 +167,39 @@ export async function submitKimaSwapTransaction({
165
167
 
166
168
  return result;
167
169
  }
170
+
171
+ export async function submitKimaExternalTransaction({
172
+ originChain,
173
+ originAddress,
174
+ targetChain,
175
+ targetAddress,
176
+ originSymbol,
177
+ targetSymbol,
178
+ amount,
179
+ fee,
180
+ options,
181
+ }: RequestExternalTxProps) {
182
+ const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
183
+ process.env.KIMA_BACKEND_MNEMONIC as string,
184
+ { prefix: "kima" }
185
+ );
186
+ const client = await TxClient(wallet);
187
+ const [firstAccount] = await wallet.getAccounts();
188
+ const params: MsgRequestExternalTransaction = {
189
+ creator: firstAccount.address,
190
+ originChain,
191
+ originAddress,
192
+ targetChain,
193
+ targetAddress,
194
+ originSymbol,
195
+ targetSymbol,
196
+ amount: amount,
197
+ fee: fee,
198
+ options,
199
+ };
200
+
201
+ const msgTx = await client.msgRequestExternalTransaction(params);
202
+ const result = await client.signAndBroadcast([msgTx]);
203
+
204
+ return result;
205
+ }
@@ -12,6 +12,7 @@ import {
12
12
  MsgRequestTransaction,
13
13
  MsgSetTxHash,
14
14
  MsgHtlcReclaim,
15
+ MsgRequestExternalTransaction,
15
16
  } from "./transfer_tx";
16
17
 
17
18
  import {
@@ -32,6 +33,7 @@ interface SignAndBroadcastOptions {
32
33
 
33
34
  const types = [
34
35
  ["/kimablockchain.transaction.MsgRequestTransaction", MsgRequestTransaction],
36
+ ["/kimablockchain.transaction.MsgRequestExternalTransaction", MsgRequestExternalTransaction],
35
37
  ["/kimablockchain.transaction.MsgRequestHtlcLock", MsgRequestHtlcLock],
36
38
  ["/kimablockchain.transaction.MsgSetTxHash", MsgSetTxHash],
37
39
  ["/kimablockchain.transaction.MsgHtlcReclaim", MsgHtlcReclaim],
@@ -79,5 +81,9 @@ export const TxClient = async (wallet: OfflineSigner) => {
79
81
  typeUrl: "/kimablockchain.swap.MsgRequestSwapTransaction",
80
82
  value: MsgRequestSwapTransaction.fromPartial(data),
81
83
  }),
84
+ msgRequestExternalTransaction: (data: MsgRequestExternalTransaction): EncodeObject => ({
85
+ typeUrl: "/kimablockchain.transaction.MsgRequestExternalTransaction",
86
+ value: MsgRequestExternalTransaction.fromPartial(data),
87
+ }),
82
88
  };
83
89
  };