@kimafinance/kima-transaction-api 1.0.1 → 1.0.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.
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
- {
2
- "name": "@kimafinance/kima-transaction-api",
3
- "version": "1.0.1",
4
- "description": "A wrapper around Kima's API, enabling sending and monitoring transactions",
5
- "author": "",
6
- "license": "MIT",
7
- "main": "build/index.js",
8
- "source": "src/index.ts",
9
- "engines": {
10
- "node": ">=10"
11
- },
12
- "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1",
14
- "dev": "nodemon",
15
- "build": "rimraf ./build && tsc",
16
- "start": "npm run build && node build/index.js"
17
- },
18
- "keywords": [],
19
- "devDependencies": {
20
- "@types/node": "^18.11.9",
21
- "nodemon": "^2.0.20",
22
- "rimraf": "^3.0.2",
23
- "ts-node": "^10.9.1",
24
- "typescript": "^4.9.3"
25
- },
26
- "dependencies": {
27
- "@cosmjs/cosmwasm-stargate": "^0.29.4",
28
- "@cosmjs/proto-signing": "^0.29.4",
29
- "@cosmjs/stargate": "^0.29.4",
30
- "dotenv": "^16.0.3"
31
- }
32
- }
1
+ {
2
+ "name": "@kimafinance/kima-transaction-api",
3
+ "version": "1.0.3",
4
+ "description": "A wrapper around Kima's API, enabling sending and monitoring transactions",
5
+ "author": "",
6
+ "license": "MIT",
7
+ "main": "build/index.js",
8
+ "source": "src/index.ts",
9
+ "engines": {
10
+ "node": ">=10"
11
+ },
12
+ "scripts": {
13
+ "test": "echo \"Error: no test specified\" && exit 1",
14
+ "dev": "nodemon",
15
+ "build": "rimraf ./build && tsc",
16
+ "start": "npm run build && node build/index.js"
17
+ },
18
+ "keywords": [],
19
+ "devDependencies": {
20
+ "@types/node": "^18.11.9",
21
+ "nodemon": "^2.0.20",
22
+ "rimraf": "^3.0.2",
23
+ "ts-node": "^10.9.1",
24
+ "typescript": "^4.9.3"
25
+ },
26
+ "dependencies": {
27
+ "@cosmjs/cosmwasm-stargate": "^0.29.4",
28
+ "@cosmjs/proto-signing": "^0.29.4",
29
+ "@cosmjs/stargate": "^0.29.4",
30
+ "dotenv": "^16.0.3"
31
+ }
32
+ }
package/src/index.ts CHANGED
@@ -2,25 +2,12 @@ import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
2
2
  import { TxClient } from "./kima/common";
3
3
  import { MsgRequestTransaction } from "./kima/tx";
4
4
 
5
- export enum SupportNetworks {
6
- Ethereum = "ETH",
7
- Polygon = "POL",
8
- Avalanche = "AVX",
9
- Solana = "SOL",
10
- }
11
-
12
- export enum CurrencyOptions {
13
- USDK = "USDK",
14
- USDT = "USDT",
15
- USDC = "USDC",
16
- }
17
-
18
5
  interface Props {
19
- originChain: SupportNetworks;
6
+ originChain: string;
20
7
  originAddress: string;
21
- targetChain: SupportNetworks;
8
+ targetChain: string;
22
9
  targetAddress: string;
23
- symbol: CurrencyOptions;
10
+ symbol: string;
24
11
  amount: number;
25
12
  fee: number;
26
13
  }
@@ -51,6 +38,28 @@ export async function submitKimaTransaction({
51
38
  fee: fee.toString(),
52
39
  };
53
40
 
54
- const msg = await client.msgRequestTransaction(params);
55
- return await client.signAndBroadcast([msg]);
41
+ let msg = await client.msgRequestTransaction(params);
42
+ const result = await client.signAndBroadcast([msg]);
43
+
44
+ let txId = "1";
45
+
46
+ for (const event of result.events) {
47
+ if (event.type === "transaction_requested") {
48
+ for (const attr of event.attributes) {
49
+ if (attr.key === "txId") {
50
+ txId = attr.value;
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ msg = await client.msgSetTxHash({
57
+ creator: firstAccount.address,
58
+ txId,
59
+ txHash: result.transactionHash,
60
+ });
61
+
62
+ await client.signAndBroadcast([msg]);
63
+
64
+ return result;
56
65
  }
@@ -1,7 +1,7 @@
1
1
  import { SigningStargateClient, StdFee } from "@cosmjs/stargate";
2
2
  import dotenv from "dotenv";
3
3
  import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
4
- import { MsgRequestTransaction } from "./tx";
4
+ import { MsgRequestTransaction, MsgSetTxHash } from "./tx";
5
5
 
6
6
  dotenv.config();
7
7
 
@@ -17,6 +17,7 @@ interface SignAndBroadcastOptions {
17
17
 
18
18
  const types = [
19
19
  ["/KimaFinance.kima.kima.MsgRequestTransaction", MsgRequestTransaction],
20
+ ["/KimaFinance.kima.kima.MsgSetTxHash", MsgSetTxHash],
20
21
  ];
21
22
 
22
23
  export const registry = new Registry(<any>types);
@@ -38,5 +39,9 @@ export const TxClient = async (wallet: OfflineSigner) => {
38
39
  typeUrl: "/KimaFinance.kima.kima.MsgRequestTransaction",
39
40
  value: MsgRequestTransaction.fromPartial(data),
40
41
  }),
42
+ msgSetTxHash: (data: MsgSetTxHash): EncodeObject => ({
43
+ typeUrl: "/KimaFinance.kima.kima.MsgSetTxHash",
44
+ value: MsgSetTxHash.fromPartial(data),
45
+ }),
41
46
  };
42
47
  };