@kimafinance/kima-transaction-api 1.0.9-beta.1 → 1.0.11-beta.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/build/index.d.ts +28 -0
- package/build/index.js +59 -0
- package/build/kima/common.d.ts +14 -0
- package/build/kima/common.js +36 -0
- package/build/kima/tx.d.ts +609 -0
- package/build/kima/tx.js +4293 -0
- package/package.json +1 -1
- package/src/kima/common.ts +2 -2
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum SupportedNetworks {
|
|
2
|
+
ETHEREUM = "ETH",
|
|
3
|
+
POLYGON = "POL",
|
|
4
|
+
AVALANCHE = "AVX",
|
|
5
|
+
SOLANA = "SOL",
|
|
6
|
+
FUSE = "FUS",
|
|
7
|
+
CELO = "CEL",
|
|
8
|
+
BSC = "BSC",
|
|
9
|
+
ARBITRIUM = "ARB",
|
|
10
|
+
OPTIMISM = "OPT",
|
|
11
|
+
POLYGON_ZKEVM = "ZKE"
|
|
12
|
+
}
|
|
13
|
+
export declare enum CurrencyOptions {
|
|
14
|
+
USDT = "USDT",
|
|
15
|
+
USDC = "USDC",
|
|
16
|
+
USDK = "USDK"
|
|
17
|
+
}
|
|
18
|
+
interface Props {
|
|
19
|
+
originChain: SupportedNetworks;
|
|
20
|
+
originAddress: string;
|
|
21
|
+
targetChain: SupportedNetworks;
|
|
22
|
+
targetAddress: string;
|
|
23
|
+
symbol: CurrencyOptions;
|
|
24
|
+
amount: number;
|
|
25
|
+
fee: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, }: Props): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
28
|
+
export {};
|
package/build/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitKimaTransaction = exports.CurrencyOptions = exports.SupportedNetworks = void 0;
|
|
4
|
+
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
5
|
+
const common_1 = require("./kima/common");
|
|
6
|
+
var SupportedNetworks;
|
|
7
|
+
(function (SupportedNetworks) {
|
|
8
|
+
SupportedNetworks["ETHEREUM"] = "ETH";
|
|
9
|
+
SupportedNetworks["POLYGON"] = "POL";
|
|
10
|
+
SupportedNetworks["AVALANCHE"] = "AVX";
|
|
11
|
+
SupportedNetworks["SOLANA"] = "SOL";
|
|
12
|
+
SupportedNetworks["FUSE"] = "FUS";
|
|
13
|
+
SupportedNetworks["CELO"] = "CEL";
|
|
14
|
+
SupportedNetworks["BSC"] = "BSC";
|
|
15
|
+
SupportedNetworks["ARBITRIUM"] = "ARB";
|
|
16
|
+
SupportedNetworks["OPTIMISM"] = "OPT";
|
|
17
|
+
SupportedNetworks["POLYGON_ZKEVM"] = "ZKE";
|
|
18
|
+
})(SupportedNetworks = exports.SupportedNetworks || (exports.SupportedNetworks = {}));
|
|
19
|
+
var CurrencyOptions;
|
|
20
|
+
(function (CurrencyOptions) {
|
|
21
|
+
CurrencyOptions["USDT"] = "USDT";
|
|
22
|
+
CurrencyOptions["USDC"] = "USDC";
|
|
23
|
+
CurrencyOptions["USDK"] = "USDK";
|
|
24
|
+
})(CurrencyOptions = exports.CurrencyOptions || (exports.CurrencyOptions = {}));
|
|
25
|
+
async function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, }) {
|
|
26
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
27
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
28
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
29
|
+
const params = {
|
|
30
|
+
creator: firstAccount.address,
|
|
31
|
+
originChain,
|
|
32
|
+
originAddress,
|
|
33
|
+
targetChain,
|
|
34
|
+
targetAddress,
|
|
35
|
+
symbol,
|
|
36
|
+
amount: amount.toString(),
|
|
37
|
+
fee: fee.toString(),
|
|
38
|
+
};
|
|
39
|
+
let msg = await client.msgRequestTransaction(params);
|
|
40
|
+
const result = await client.signAndBroadcast([msg]);
|
|
41
|
+
let txId = "1";
|
|
42
|
+
for (const event of result.events) {
|
|
43
|
+
if (event.type === "transaction_requested") {
|
|
44
|
+
for (const attr of event.attributes) {
|
|
45
|
+
if (attr.key === "txId") {
|
|
46
|
+
txId = attr.value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
msg = await client.msgSetTxHash({
|
|
52
|
+
creator: firstAccount.address,
|
|
53
|
+
txId,
|
|
54
|
+
txHash: result.transactionHash,
|
|
55
|
+
});
|
|
56
|
+
await client.signAndBroadcast([msg]);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
exports.submitKimaTransaction = submitKimaTransaction;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StdFee } from "@cosmjs/stargate";
|
|
2
|
+
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
3
|
+
import { MsgRequestTransaction, MsgSetTxHash } from "./tx";
|
|
4
|
+
interface SignAndBroadcastOptions {
|
|
5
|
+
fee: StdFee;
|
|
6
|
+
memo?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const registry: Registry;
|
|
9
|
+
export declare const TxClient: (wallet: OfflineSigner) => Promise<{
|
|
10
|
+
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }?: SignAndBroadcastOptions) => Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
11
|
+
msgRequestTransaction: (data: MsgRequestTransaction) => EncodeObject;
|
|
12
|
+
msgSetTxHash: (data: MsgSetTxHash) => EncodeObject;
|
|
13
|
+
}>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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.TxClient = exports.registry = void 0;
|
|
7
|
+
const stargate_1 = require("@cosmjs/stargate");
|
|
8
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
|
+
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
10
|
+
const tx_1 = require("./tx");
|
|
11
|
+
dotenv_1.default.config();
|
|
12
|
+
const defaultFee = {
|
|
13
|
+
amount: [],
|
|
14
|
+
gas: "200000",
|
|
15
|
+
};
|
|
16
|
+
const types = [
|
|
17
|
+
["/KimaFinance.kima.MsgRequestTransaction", tx_1.MsgRequestTransaction],
|
|
18
|
+
["/KimaFinance.kima.MsgSetTxHash", tx_1.MsgSetTxHash],
|
|
19
|
+
];
|
|
20
|
+
exports.registry = new proto_signing_1.Registry(types);
|
|
21
|
+
const TxClient = async (wallet) => {
|
|
22
|
+
const client = await stargate_1.SigningStargateClient.connectWithSigner(process.env.KIMA_BACKEND_NODE_PROVIDER, wallet, { registry: exports.registry });
|
|
23
|
+
const { address } = (await wallet.getAccounts())[0];
|
|
24
|
+
return {
|
|
25
|
+
signAndBroadcast: (msgs, { fee, memo } = { fee: defaultFee, memo: "" }) => client.signAndBroadcast(address, msgs, fee, memo),
|
|
26
|
+
msgRequestTransaction: (data) => ({
|
|
27
|
+
typeUrl: "/KimaFinance.kima.kima.MsgRequestTransaction",
|
|
28
|
+
value: tx_1.MsgRequestTransaction.fromPartial(data),
|
|
29
|
+
}),
|
|
30
|
+
msgSetTxHash: (data) => ({
|
|
31
|
+
typeUrl: "/KimaFinance.kima.kima.MsgSetTxHash",
|
|
32
|
+
value: tx_1.MsgSetTxHash.fromPartial(data),
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.TxClient = TxClient;
|