@kimafinance/kima-transaction-api 1.0.0 → 1.0.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/README.md +12 -9
- package/build/index.d.ts +15 -3
- package/build/index.js +16 -2
- package/build/kima/common.d.ts +3 -5
- package/build/kima/common.js +6 -25
- package/build/kima/tx.d.ts +174 -19
- package/build/kima/tx.js +1462 -345
- package/package.json +1 -1
- package/src/index.ts +18 -2
- package/src/kima/common.ts +20 -45
- package/src/kima/tx.ts +2406 -1110
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,11 +2,25 @@ 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
|
+
|
|
5
18
|
interface Props {
|
|
6
|
-
originChain:
|
|
19
|
+
originChain: SupportNetworks;
|
|
7
20
|
originAddress: string;
|
|
8
|
-
targetChain:
|
|
21
|
+
targetChain: SupportNetworks;
|
|
9
22
|
targetAddress: string;
|
|
23
|
+
symbol: CurrencyOptions;
|
|
10
24
|
amount: number;
|
|
11
25
|
fee: number;
|
|
12
26
|
}
|
|
@@ -16,6 +30,7 @@ export async function submitKimaTransaction({
|
|
|
16
30
|
originAddress,
|
|
17
31
|
targetChain,
|
|
18
32
|
targetAddress,
|
|
33
|
+
symbol,
|
|
19
34
|
amount,
|
|
20
35
|
fee,
|
|
21
36
|
}: Props) {
|
|
@@ -31,6 +46,7 @@ export async function submitKimaTransaction({
|
|
|
31
46
|
originAddress,
|
|
32
47
|
targetChain,
|
|
33
48
|
targetAddress,
|
|
49
|
+
symbol,
|
|
34
50
|
amount: amount.toString(),
|
|
35
51
|
fee: fee.toString(),
|
|
36
52
|
};
|
package/src/kima/common.ts
CHANGED
|
@@ -1,67 +1,42 @@
|
|
|
1
|
-
import { SigningStargateClient, StdFee } from
|
|
2
|
-
import dotenv from
|
|
3
|
-
import { Registry, OfflineSigner, EncodeObject } from
|
|
4
|
-
import {
|
|
5
|
-
MsgRequestTransaction,
|
|
6
|
-
MsgApproveTransaction,
|
|
7
|
-
MsgFetchBalance
|
|
8
|
-
} from './tx'
|
|
1
|
+
import { SigningStargateClient, StdFee } from "@cosmjs/stargate";
|
|
2
|
+
import dotenv from "dotenv";
|
|
3
|
+
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
4
|
+
import { MsgRequestTransaction } from "./tx";
|
|
9
5
|
|
|
10
|
-
dotenv.config()
|
|
6
|
+
dotenv.config();
|
|
11
7
|
|
|
12
8
|
const defaultFee = {
|
|
13
9
|
amount: [],
|
|
14
|
-
gas:
|
|
15
|
-
}
|
|
10
|
+
gas: "200000",
|
|
11
|
+
};
|
|
16
12
|
|
|
17
13
|
interface SignAndBroadcastOptions {
|
|
18
|
-
fee: StdFee
|
|
19
|
-
memo?: string
|
|
14
|
+
fee: StdFee;
|
|
15
|
+
memo?: string;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
const types = [
|
|
23
|
-
[
|
|
24
|
-
|
|
25
|
-
MsgRequestTransaction
|
|
26
|
-
],
|
|
27
|
-
[
|
|
28
|
-
'/DiversifiTechnologies.diversifi.diversifi.MsgApproveTransaction',
|
|
29
|
-
MsgApproveTransaction
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
'/DiversifiTechnologies.diversifi.diversifi.MsgFetchBalance',
|
|
33
|
-
MsgFetchBalance
|
|
34
|
-
]
|
|
35
|
-
]
|
|
19
|
+
["/KimaFinance.kima.kima.MsgRequestTransaction", MsgRequestTransaction],
|
|
20
|
+
];
|
|
36
21
|
|
|
37
|
-
export const registry = new Registry(<any>types)
|
|
22
|
+
export const registry = new Registry(<any>types);
|
|
38
23
|
|
|
39
24
|
export const TxClient = async (wallet: OfflineSigner) => {
|
|
40
25
|
const client = await SigningStargateClient.connectWithSigner(
|
|
41
|
-
|
|
26
|
+
process.env.KIMA_BACKEND_NODE_PROVIDER as string,
|
|
42
27
|
wallet,
|
|
43
28
|
{ registry }
|
|
44
|
-
)
|
|
45
|
-
const { address } = (await wallet.getAccounts())[0]
|
|
29
|
+
);
|
|
30
|
+
const { address } = (await wallet.getAccounts())[0];
|
|
46
31
|
|
|
47
32
|
return {
|
|
48
33
|
signAndBroadcast: (
|
|
49
34
|
msgs: EncodeObject[],
|
|
50
|
-
{ fee, memo }: SignAndBroadcastOptions = { fee: defaultFee, memo:
|
|
35
|
+
{ fee, memo }: SignAndBroadcastOptions = { fee: defaultFee, memo: "" }
|
|
51
36
|
) => client.signAndBroadcast(address, msgs, fee, memo),
|
|
52
37
|
msgRequestTransaction: (data: MsgRequestTransaction): EncodeObject => ({
|
|
53
|
-
typeUrl:
|
|
54
|
-
|
|
55
|
-
value: MsgRequestTransaction.fromPartial(data)
|
|
56
|
-
}),
|
|
57
|
-
msgApproveTransaction: (data: MsgApproveTransaction): EncodeObject => ({
|
|
58
|
-
typeUrl:
|
|
59
|
-
'/DiversifiTechnologies.diversifi.diversifi.MsgApproveTransaction',
|
|
60
|
-
value: MsgApproveTransaction.fromPartial(data)
|
|
38
|
+
typeUrl: "/KimaFinance.kima.kima.MsgRequestTransaction",
|
|
39
|
+
value: MsgRequestTransaction.fromPartial(data),
|
|
61
40
|
}),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
value: MsgFetchBalance.fromPartial(data)
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
|
41
|
+
};
|
|
42
|
+
};
|