@kimafinance/kima-transaction-api 1.3.7 → 1.4.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 +19 -5
- package/build/api/htlc-lock.d.ts +23 -0
- package/build/api/htlc-lock.js +37 -0
- package/build/api/htlc-reclaim.d.ts +14 -0
- package/build/api/htlc-reclaim.js +28 -0
- package/build/api/submit.d.ts +54 -0
- package/build/api/submit.js +94 -0
- package/build/config/global-this.config.d.ts +2 -0
- package/build/config/global-this.config.js +18 -0
- package/build/config/probuff.config.d.ts +2 -0
- package/build/config/probuff.config.js +12 -0
- package/build/index.d.ts +3 -50
- package/build/index.js +17 -121
- package/build/kima/common.d.ts +4 -1
- package/build/kima/common.js +12 -9
- package/build/kima/tx/cancel.d.ts +35 -0
- package/build/kima/tx/cancel.js +115 -0
- package/build/kima/tx/drain-finalize.d.ts +47 -0
- package/build/kima/tx/drain-finalize.js +155 -0
- package/build/kima/tx/drain.d.ts +50 -0
- package/build/kima/tx/drain.js +164 -0
- package/build/kima/tx/finalize.d.ts +47 -0
- package/build/kima/tx/finalize.js +155 -0
- package/build/kima/tx/htlc-lock.d.ts +42 -0
- package/build/kima/tx/htlc-lock.js +152 -0
- package/build/kima/tx/htlc-reclaim.d.ts +30 -0
- package/build/kima/tx/htlc-reclaim.js +105 -0
- package/build/kima/tx/index.d.ts +1 -0
- package/build/kima/tx/index.js +4 -0
- package/build/kima/tx/liquidity-provision.d.ts +30 -0
- package/build/kima/tx/liquidity-provision.js +102 -0
- package/build/kima/tx/message-service.d.ts +54 -0
- package/build/kima/tx/message-service.js +117 -0
- package/build/kima/tx/provision-finalize.d.ts +47 -0
- package/build/kima/tx/provision-finalize.js +155 -0
- package/build/kima/tx/provision.d.ts +70 -0
- package/build/kima/tx/provision.js +230 -0
- package/build/kima/tx/request.d.ts +63 -0
- package/build/kima/tx/request.js +222 -0
- package/build/kima/tx/response.d.ts +21 -0
- package/build/kima/tx/response.js +69 -0
- package/build/kima/tx/rpc.d.ts +0 -0
- package/build/kima/tx/rpc.js +1 -0
- package/build/kima/tx/set-hash.d.ts +42 -0
- package/build/kima/tx/set-hash.js +130 -0
- package/build/kima/tx/set-process.d.ts +37 -0
- package/build/kima/tx/set-process.js +121 -0
- package/build/kima/tx/transfer-limit.d.ts +30 -0
- package/build/kima/tx/transfer-limit.js +102 -0
- package/build/kima/tx/withdraw.d.ts +47 -0
- package/build/kima/tx/withdraw.js +155 -0
- package/build/utils.d.ts +17 -0
- package/build/utils.js +49 -0
- package/package.json +10 -10
- package/src/api/htlc-lock.ts +57 -0
- package/src/api/htlc-reclaim.ts +39 -0
- package/src/api/submit.ts +132 -0
- package/src/config/global-this.config.ts +20 -0
- package/src/config/probuff.config.ts +9 -0
- package/src/index.ts +3 -206
- package/src/kima/common.ts +5 -12
- package/src/kima/tx/cancel.ts +147 -0
- package/src/kima/tx/drain-finalize.ts +191 -0
- package/src/kima/tx/drain.ts +201 -0
- package/src/kima/tx/finalize.ts +191 -0
- package/src/kima/tx/htlc-lock.ts +183 -0
- package/src/kima/tx/htlc-reclaim.ts +132 -0
- package/src/kima/tx/index.ts +1 -0
- package/src/kima/tx/liquidity-provision.ts +132 -0
- package/src/kima/tx/message-service.ts +278 -0
- package/src/kima/tx/provision-finalize.ts +191 -0
- package/src/kima/tx/provision.ts +279 -0
- package/src/kima/tx/request.ts +256 -0
- package/src/kima/tx/response.ts +83 -0
- package/src/kima/tx/rpc.ts +0 -0
- package/src/kima/tx/set-hash.ts +162 -0
- package/src/kima/tx/set-process.ts +151 -0
- package/src/kima/tx/transfer-limit.ts +132 -0
- package/src/kima/tx/withdraw.ts +191 -0
- package/src/utils.ts +67 -0
- package/build/kima/tx.d.ts +0 -674
- package/build/kima/tx.js +0 -2170
- package/src/kima/tx.ts +0 -2945
package/README.md
CHANGED
|
@@ -20,16 +20,29 @@ import {
|
|
|
20
20
|
submitKimaTransaction,
|
|
21
21
|
SupportNetworks,
|
|
22
22
|
CurrencyOptions,
|
|
23
|
-
} from "@kimafinance/kima-transaction-
|
|
23
|
+
} from "@kimafinance/kima-transaction-api";
|
|
24
24
|
|
|
25
25
|
const txResult = await submitKimaTransaction({
|
|
26
26
|
originAddress: "0x1234123412341234123412341234123412341234",
|
|
27
27
|
originChain: "ETH",
|
|
28
|
+
originSymbol: "USDK",
|
|
28
29
|
targetAddress: "0x1234123412341234123412341234123412341234",
|
|
29
30
|
targetChain: "POL",
|
|
30
|
-
|
|
31
|
-
amount: 100,
|
|
32
|
-
fee: 0.3,
|
|
31
|
+
targetSymbol: "USDK",
|
|
32
|
+
amount: "100",
|
|
33
|
+
fee: "0.3",
|
|
34
|
+
htlcCreationHash: "", // required to send empty strings for now
|
|
35
|
+
htlcCreationVout: "",
|
|
36
|
+
htlcExpirationTimestamp: "",
|
|
37
|
+
htlcVersion: "",
|
|
38
|
+
senderPubKey: "",
|
|
39
|
+
options: {
|
|
40
|
+
signature: "", // required: generated signature from the approval message
|
|
41
|
+
feeId: "", // required: id returned from calculated fee in fcs
|
|
42
|
+
chargeFeeAtTarget: false // required: wether to deduct fees from origin or target
|
|
43
|
+
transactionIdSeed: "", // optional: used in fiat on ramp payments
|
|
44
|
+
transactionIdSignature: "", // optional: used to validate transaction idempotency
|
|
45
|
+
}
|
|
33
46
|
});
|
|
34
47
|
```
|
|
35
48
|
|
|
@@ -39,9 +52,10 @@ const txResult = await submitKimaTransaction({
|
|
|
39
52
|
|
|
40
53
|
- `originAddress`: sending address
|
|
41
54
|
- `originChain`: sending chain
|
|
55
|
+
- `originSymbol`: sending token symbol
|
|
42
56
|
- `targetAddress`: receiving address
|
|
43
57
|
- `targetChain`: receiving chain
|
|
44
|
-
- `
|
|
58
|
+
- `targetSymbol`: receiving token symbol
|
|
45
59
|
- `amount`: amount of token to transfer
|
|
46
60
|
- `fee`: amount of token that kima consumes to pay gas fee for pulling & releasing token transactions
|
|
47
61
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface RequestHtlcLockProps {
|
|
2
|
+
fromAddress: string;
|
|
3
|
+
senderPubkey: string;
|
|
4
|
+
amount: string;
|
|
5
|
+
htlcTimeout: string;
|
|
6
|
+
txHash: string;
|
|
7
|
+
htlcAddress: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create an HTCL transaction
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @async
|
|
14
|
+
* @param {RequestHtlcLockProps} param0
|
|
15
|
+
* @param {string} param0.fromAddress - The creator wallet address
|
|
16
|
+
* @param {string} param0.senderPubkey - The creator wallet public key
|
|
17
|
+
* @param {string} param0.amount - The total amount to be locked including fees
|
|
18
|
+
* @param {string} param0.htlcTimeout - The time in seconds the HTLC will be valid for
|
|
19
|
+
* @param {string} param0.txHash - The transaction hash of the HTLC lock
|
|
20
|
+
* @param {string} param0.htlcAddress - The HTLC address
|
|
21
|
+
* @returns {Promise<DeliverTxResponse>}
|
|
22
|
+
*/
|
|
23
|
+
export declare function submitHtlcLock({ fromAddress, senderPubkey, amount, htlcTimeout, txHash, htlcAddress, }: RequestHtlcLockProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitHtlcLock = void 0;
|
|
4
|
+
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
5
|
+
const common_1 = require("../kima/common");
|
|
6
|
+
/**
|
|
7
|
+
* Create an HTCL transaction
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @async
|
|
11
|
+
* @param {RequestHtlcLockProps} param0
|
|
12
|
+
* @param {string} param0.fromAddress - The creator wallet address
|
|
13
|
+
* @param {string} param0.senderPubkey - The creator wallet public key
|
|
14
|
+
* @param {string} param0.amount - The total amount to be locked including fees
|
|
15
|
+
* @param {string} param0.htlcTimeout - The time in seconds the HTLC will be valid for
|
|
16
|
+
* @param {string} param0.txHash - The transaction hash of the HTLC lock
|
|
17
|
+
* @param {string} param0.htlcAddress - The HTLC address
|
|
18
|
+
* @returns {Promise<DeliverTxResponse>}
|
|
19
|
+
*/
|
|
20
|
+
async function submitHtlcLock({ fromAddress, senderPubkey, amount, htlcTimeout, txHash, htlcAddress, }) {
|
|
21
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
22
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
23
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
24
|
+
const params = {
|
|
25
|
+
creator: firstAccount.address,
|
|
26
|
+
fromAddress,
|
|
27
|
+
senderPubkey,
|
|
28
|
+
amount,
|
|
29
|
+
htlcTimeout,
|
|
30
|
+
htlcAddress,
|
|
31
|
+
txHash,
|
|
32
|
+
};
|
|
33
|
+
let msg = await client.msgRequestHtlcLock(params);
|
|
34
|
+
const result = await client.signAndBroadcast([msg]);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
exports.submitHtlcLock = submitHtlcLock;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface RequestHtlcReclaimProps {
|
|
2
|
+
senderAddress: string;
|
|
3
|
+
txHash: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Cancel an HTCL lock by user taking back the funds
|
|
7
|
+
* @export
|
|
8
|
+
* @async
|
|
9
|
+
* @param {RequestHtlcReclaimProps} param0
|
|
10
|
+
* @param {string} param0.senderAddress - The creator wallet address
|
|
11
|
+
* @param {string} param0.txHash - The transaction hash of the HTLC lock
|
|
12
|
+
* @returns {Promise<DeliverTxResponse>}
|
|
13
|
+
*/
|
|
14
|
+
export declare function HtlcReclaim({ senderAddress, txHash, }: RequestHtlcReclaimProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HtlcReclaim = void 0;
|
|
4
|
+
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
5
|
+
const common_1 = require("../kima/common");
|
|
6
|
+
/**
|
|
7
|
+
* Cancel an HTCL lock by user taking back the funds
|
|
8
|
+
* @export
|
|
9
|
+
* @async
|
|
10
|
+
* @param {RequestHtlcReclaimProps} param0
|
|
11
|
+
* @param {string} param0.senderAddress - The creator wallet address
|
|
12
|
+
* @param {string} param0.txHash - The transaction hash of the HTLC lock
|
|
13
|
+
* @returns {Promise<DeliverTxResponse>}
|
|
14
|
+
*/
|
|
15
|
+
async function HtlcReclaim({ senderAddress, txHash, }) {
|
|
16
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
17
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
18
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
19
|
+
const params = {
|
|
20
|
+
creator: firstAccount.address,
|
|
21
|
+
senderAddress,
|
|
22
|
+
txHash,
|
|
23
|
+
};
|
|
24
|
+
let msg = await client.msgHtlcReclaim(params);
|
|
25
|
+
const result = await client.signAndBroadcast([msg]);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
exports.HtlcReclaim = HtlcReclaim;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare enum SupportedNetworks {
|
|
2
|
+
ARBITRIUM = "ARB",
|
|
3
|
+
AVALANCHE = "AVX",
|
|
4
|
+
BSC = "BSC",
|
|
5
|
+
BTC = "BTC",
|
|
6
|
+
ETHEREUM = "ETH",
|
|
7
|
+
OPTIMISM = "OPT",
|
|
8
|
+
POLYGON = "POL",
|
|
9
|
+
SOLANA = "SOL",
|
|
10
|
+
TRON = "TRX"
|
|
11
|
+
}
|
|
12
|
+
export declare enum CurrencyOptions {
|
|
13
|
+
USDT = "USDT",
|
|
14
|
+
USDC = "USDC",
|
|
15
|
+
USDK = "USDK"
|
|
16
|
+
}
|
|
17
|
+
export interface RequestTxProps {
|
|
18
|
+
originChain: SupportedNetworks;
|
|
19
|
+
originAddress: string;
|
|
20
|
+
targetChain: SupportedNetworks;
|
|
21
|
+
targetAddress: string;
|
|
22
|
+
originSymbol: CurrencyOptions;
|
|
23
|
+
targetSymbol: CurrencyOptions;
|
|
24
|
+
amount: number;
|
|
25
|
+
fee: number;
|
|
26
|
+
htlcCreationHash: string;
|
|
27
|
+
htlcCreationVout: number;
|
|
28
|
+
htlcExpirationTimestamp: string;
|
|
29
|
+
htlcVersion: string;
|
|
30
|
+
senderPubKey: Uint8Array;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a Kima transfer transaction. The HTLC parameters are only required on Bitcoin, use blank strings (or zeros) for other chains.
|
|
34
|
+
* The approval or HTLC transaction must be completed before submitting the Kima transaction or it will fail.
|
|
35
|
+
*
|
|
36
|
+
* @export
|
|
37
|
+
* @async
|
|
38
|
+
* @param {RequestTxProps} param0
|
|
39
|
+
* @param {SupportedNetworks} param0.originChain - The chain the funds are being transferred from
|
|
40
|
+
* @param {string} param0.originAddress - The user wallet address
|
|
41
|
+
* @param {SupportedNetworks} param0.targetChain - The chain the funds are being transferred to
|
|
42
|
+
* @param {string} param0.targetAddress - The destination wallet address
|
|
43
|
+
* @param {CurrencyOptions} param0.originSymbol - The starting token symbol
|
|
44
|
+
* @param {CurrencyOptions} param0.targetSymbol - The destination token symbol
|
|
45
|
+
* @param {number} param0.amount - amount of tokens to be transferred
|
|
46
|
+
* @param {number} param0.fee - The total fees to be paid
|
|
47
|
+
* @param {string} param0.htlcCreationHash - (if applicable) The transaction hash of the HTLC lock
|
|
48
|
+
* @param {number} param0.htlcCreationVout - (if applicable) The vout of the HTLC lock
|
|
49
|
+
* @param {string} param0.htlcExpirationTimestamp - (if applicable) The expiration timestamp of the HTLC lock
|
|
50
|
+
* @param {string} param0.htlcVersion - (if applicable) The version of the HTLC lock
|
|
51
|
+
* @param {Uint8Array} param0.senderPubKey - (if HTLC) The creator wallet public key
|
|
52
|
+
* @returns {Promise<DeliverTxResponse>}
|
|
53
|
+
*/
|
|
54
|
+
export declare function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, originSymbol, targetSymbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, }: RequestTxProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
const utils_1 = require("../utils");
|
|
7
|
+
var SupportedNetworks;
|
|
8
|
+
(function (SupportedNetworks) {
|
|
9
|
+
SupportedNetworks["ARBITRIUM"] = "ARB";
|
|
10
|
+
SupportedNetworks["AVALANCHE"] = "AVX";
|
|
11
|
+
SupportedNetworks["BSC"] = "BSC";
|
|
12
|
+
SupportedNetworks["BTC"] = "BTC";
|
|
13
|
+
SupportedNetworks["ETHEREUM"] = "ETH";
|
|
14
|
+
SupportedNetworks["OPTIMISM"] = "OPT";
|
|
15
|
+
SupportedNetworks["POLYGON"] = "POL";
|
|
16
|
+
SupportedNetworks["SOLANA"] = "SOL";
|
|
17
|
+
SupportedNetworks["TRON"] = "TRX";
|
|
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
|
+
/**
|
|
26
|
+
* Create a Kima transfer transaction. The HTLC parameters are only required on Bitcoin, use blank strings (or zeros) for other chains.
|
|
27
|
+
* The approval or HTLC transaction must be completed before submitting the Kima transaction or it will fail.
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
* @async
|
|
31
|
+
* @param {RequestTxProps} param0
|
|
32
|
+
* @param {SupportedNetworks} param0.originChain - The chain the funds are being transferred from
|
|
33
|
+
* @param {string} param0.originAddress - The user wallet address
|
|
34
|
+
* @param {SupportedNetworks} param0.targetChain - The chain the funds are being transferred to
|
|
35
|
+
* @param {string} param0.targetAddress - The destination wallet address
|
|
36
|
+
* @param {CurrencyOptions} param0.originSymbol - The starting token symbol
|
|
37
|
+
* @param {CurrencyOptions} param0.targetSymbol - The destination token symbol
|
|
38
|
+
* @param {number} param0.amount - amount of tokens to be transferred
|
|
39
|
+
* @param {number} param0.fee - The total fees to be paid
|
|
40
|
+
* @param {string} param0.htlcCreationHash - (if applicable) The transaction hash of the HTLC lock
|
|
41
|
+
* @param {number} param0.htlcCreationVout - (if applicable) The vout of the HTLC lock
|
|
42
|
+
* @param {string} param0.htlcExpirationTimestamp - (if applicable) The expiration timestamp of the HTLC lock
|
|
43
|
+
* @param {string} param0.htlcVersion - (if applicable) The version of the HTLC lock
|
|
44
|
+
* @param {Uint8Array} param0.senderPubKey - (if HTLC) The creator wallet public key
|
|
45
|
+
* @returns {Promise<DeliverTxResponse>}
|
|
46
|
+
*/
|
|
47
|
+
async function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, originSymbol, targetSymbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, }) {
|
|
48
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
49
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
50
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
51
|
+
const params = {
|
|
52
|
+
creator: firstAccount.address,
|
|
53
|
+
originChain,
|
|
54
|
+
originAddress,
|
|
55
|
+
targetChain,
|
|
56
|
+
targetAddress,
|
|
57
|
+
originSymbol,
|
|
58
|
+
targetSymbol,
|
|
59
|
+
amount: amount.toString(),
|
|
60
|
+
fee: fee.toString(),
|
|
61
|
+
htlcCreationHash,
|
|
62
|
+
htlcCreationVout,
|
|
63
|
+
htlcExpirationTimestamp,
|
|
64
|
+
htlcVersion,
|
|
65
|
+
senderPubKey,
|
|
66
|
+
options: "",
|
|
67
|
+
};
|
|
68
|
+
let msg = await client.msgRequestTransaction(params);
|
|
69
|
+
const result = await client.signAndBroadcast([msg]);
|
|
70
|
+
let txId = 1;
|
|
71
|
+
for (const event of result.events) {
|
|
72
|
+
if (event.type === "transaction_requested") {
|
|
73
|
+
for (const attr of event.attributes) {
|
|
74
|
+
if (attr.key === "txId") {
|
|
75
|
+
txId = +attr.value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
msg = await client.msgSetTxHash({
|
|
81
|
+
creator: firstAccount.address,
|
|
82
|
+
txId,
|
|
83
|
+
txHash: result.transactionHash,
|
|
84
|
+
txType: "request_transaction",
|
|
85
|
+
});
|
|
86
|
+
console.log(msg);
|
|
87
|
+
let hashResult;
|
|
88
|
+
do {
|
|
89
|
+
hashResult = await client.signAndBroadcast([msg]);
|
|
90
|
+
await (0, utils_1.sleep)(1000);
|
|
91
|
+
} while (hashResult.code !== 0);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
exports.submitKimaTransaction = submitKimaTransaction;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var globalThis = (() => {
|
|
4
|
+
if (typeof globalThis !== "undefined") {
|
|
5
|
+
return globalThis;
|
|
6
|
+
}
|
|
7
|
+
if (typeof self !== "undefined") {
|
|
8
|
+
return self;
|
|
9
|
+
}
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
return window;
|
|
12
|
+
}
|
|
13
|
+
if (typeof global !== "undefined") {
|
|
14
|
+
return global;
|
|
15
|
+
}
|
|
16
|
+
throw "Unable to locate global object";
|
|
17
|
+
})();
|
|
18
|
+
exports.default = globalThis;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
7
|
+
const long_1 = __importDefault(require("long"));
|
|
8
|
+
if (minimal_1.default.util.Long !== long_1.default) {
|
|
9
|
+
minimal_1.default.util.Long = long_1.default;
|
|
10
|
+
minimal_1.default.configure();
|
|
11
|
+
}
|
|
12
|
+
exports.default = minimal_1.default;
|
package/build/index.d.ts
CHANGED
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
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 RequestHtlcReclaimProps {
|
|
19
|
-
senderAddress: string;
|
|
20
|
-
txHash: string;
|
|
21
|
-
}
|
|
22
|
-
export declare function HtlcReclaim({ senderAddress, txHash, }: RequestHtlcReclaimProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
23
|
-
interface RequestHtlcLockProps {
|
|
24
|
-
fromAddress: string;
|
|
25
|
-
senderPubkey: string;
|
|
26
|
-
amount: string;
|
|
27
|
-
htlcTimeout: string;
|
|
28
|
-
txHash: string;
|
|
29
|
-
htlcAddress: string;
|
|
30
|
-
}
|
|
31
|
-
export declare function submitHtlcLock({ fromAddress, senderPubkey, amount, htlcTimeout, txHash, htlcAddress, }: RequestHtlcLockProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
32
|
-
interface RequestTxProps {
|
|
33
|
-
originChain: SupportedNetworks;
|
|
34
|
-
originAddress: string;
|
|
35
|
-
targetChain: SupportedNetworks;
|
|
36
|
-
targetAddress: string;
|
|
37
|
-
originSymbol: CurrencyOptions;
|
|
38
|
-
targetSymbol: CurrencyOptions;
|
|
39
|
-
amount: string;
|
|
40
|
-
fee: string;
|
|
41
|
-
htlcCreationHash: string;
|
|
42
|
-
htlcCreationVout: number;
|
|
43
|
-
htlcExpirationTimestamp: string;
|
|
44
|
-
htlcVersion: string;
|
|
45
|
-
senderPubKey: Uint8Array;
|
|
46
|
-
options: string;
|
|
47
|
-
}
|
|
48
|
-
export declare function getCreatorAddress(): Promise<import("@cosmjs/proto-signing").AccountData>;
|
|
49
|
-
export declare function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, originSymbol, targetSymbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, options, }: RequestTxProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
50
|
-
export {};
|
|
1
|
+
export * from "./api/htlc-reclaim";
|
|
2
|
+
export * from "./api/htlc-lock";
|
|
3
|
+
export * from "./api/submit";
|
package/build/index.js
CHANGED
|
@@ -1,123 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 HtlcReclaim({ senderAddress, txHash, }) {
|
|
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
|
-
senderAddress,
|
|
32
|
-
txHash,
|
|
33
|
-
};
|
|
34
|
-
let msg = await client.msgHtlcReclaim(params);
|
|
35
|
-
const result = await client.signAndBroadcast([msg]);
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
exports.HtlcReclaim = HtlcReclaim;
|
|
39
|
-
async function submitHtlcLock({ fromAddress, senderPubkey, amount, htlcTimeout, txHash, htlcAddress, }) {
|
|
40
|
-
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
41
|
-
const client = await (0, common_1.TxClient)(wallet);
|
|
42
|
-
const [firstAccount] = await wallet.getAccounts();
|
|
43
|
-
const params = {
|
|
44
|
-
creator: firstAccount.address,
|
|
45
|
-
fromAddress,
|
|
46
|
-
senderPubkey,
|
|
47
|
-
amount,
|
|
48
|
-
htlcTimeout,
|
|
49
|
-
htlcAddress,
|
|
50
|
-
txHash,
|
|
51
|
-
};
|
|
52
|
-
let msg = await client.msgRequestHtlcLock(params);
|
|
53
|
-
const result = await client.signAndBroadcast([msg]);
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
exports.submitHtlcLock = submitHtlcLock;
|
|
57
|
-
function sleep(ms) {
|
|
58
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
59
|
-
}
|
|
60
|
-
async function getCreatorAddress() {
|
|
61
|
-
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
62
|
-
const [firstAccount] = await wallet.getAccounts();
|
|
63
|
-
return firstAccount;
|
|
64
|
-
}
|
|
65
|
-
exports.getCreatorAddress = getCreatorAddress;
|
|
66
|
-
async function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, originSymbol, targetSymbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, options, }) {
|
|
67
|
-
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
68
|
-
const client = await (0, common_1.TxClient)(wallet);
|
|
69
|
-
const [firstAccount] = await wallet.getAccounts();
|
|
70
|
-
const params = {
|
|
71
|
-
creator: firstAccount.address,
|
|
72
|
-
originChain,
|
|
73
|
-
originAddress,
|
|
74
|
-
targetChain,
|
|
75
|
-
targetAddress,
|
|
76
|
-
originSymbol,
|
|
77
|
-
targetSymbol,
|
|
78
|
-
amount: amount,
|
|
79
|
-
fee: fee,
|
|
80
|
-
htlcCreationHash,
|
|
81
|
-
htlcCreationVout,
|
|
82
|
-
htlcExpirationTimestamp,
|
|
83
|
-
htlcVersion,
|
|
84
|
-
senderPubKey,
|
|
85
|
-
options,
|
|
86
|
-
};
|
|
87
|
-
const msgTx = await client.msgRequestTransaction(params);
|
|
88
|
-
const result = await client.signAndBroadcast([msgTx]);
|
|
89
|
-
if (result.code !== 0) {
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
let txId = 1;
|
|
93
|
-
for (const event of result.events) {
|
|
94
|
-
if (event.type === "transaction_requested") {
|
|
95
|
-
for (const attr of event.attributes) {
|
|
96
|
-
if (attr.key === "txId") {
|
|
97
|
-
txId = +attr.value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
101
7
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
console.log(error);
|
|
117
|
-
await sleep(5000);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
} while (hashResult?.code !== 0);
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
exports.submitKimaTransaction = submitKimaTransaction;
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api/htlc-reclaim"), exports);
|
|
18
|
+
__exportStar(require("./api/htlc-lock"), exports);
|
|
19
|
+
__exportStar(require("./api/submit"), exports);
|
package/build/kima/common.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
2
|
-
import {
|
|
2
|
+
import { MsgRequestTransaction } from "./tx/request";
|
|
3
|
+
import { MsgRequestHtlcLock } from "./tx/htlc-lock";
|
|
4
|
+
import { MsgSetTxHash } from "./tx/set-hash";
|
|
5
|
+
import { MsgHtlcReclaim } from "./tx/htlc-reclaim";
|
|
3
6
|
export declare const registry: Registry;
|
|
4
7
|
export declare const TxClient: (wallet: OfflineSigner) => Promise<{
|
|
5
8
|
signAndBroadcast: (msgs: EncodeObject[]) => Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
package/build/kima/common.js
CHANGED
|
@@ -7,17 +7,20 @@ exports.TxClient = exports.registry = void 0;
|
|
|
7
7
|
const stargate_1 = require("@cosmjs/stargate");
|
|
8
8
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
9
|
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
10
|
-
const
|
|
10
|
+
const request_1 = require("./tx/request");
|
|
11
|
+
const htlc_lock_1 = require("./tx/htlc-lock");
|
|
12
|
+
const set_hash_1 = require("./tx/set-hash");
|
|
13
|
+
const htlc_reclaim_1 = require("./tx/htlc-reclaim");
|
|
11
14
|
dotenv_1.default.config();
|
|
12
15
|
const defaultFee = {
|
|
13
16
|
amount: [(0, proto_signing_1.coin)(200, "uKIMA")],
|
|
14
17
|
gas: "200000", // Gas limit
|
|
15
18
|
};
|
|
16
19
|
const types = [
|
|
17
|
-
["/kimablockchain.transaction.MsgRequestTransaction",
|
|
18
|
-
["/kimablockchain.transaction.MsgRequestHtlcLock",
|
|
19
|
-
["/kimablockchain.transaction.MsgSetTxHash",
|
|
20
|
-
["/kimablockchain.transaction.MsgHtlcReclaim",
|
|
20
|
+
["/kimablockchain.transaction.MsgRequestTransaction", request_1.MsgRequestTransaction],
|
|
21
|
+
["/kimablockchain.transaction.MsgRequestHtlcLock", htlc_lock_1.MsgRequestHtlcLock],
|
|
22
|
+
["/kimablockchain.transaction.MsgSetTxHash", set_hash_1.MsgSetTxHash],
|
|
23
|
+
["/kimablockchain.transaction.MsgHtlcReclaim", htlc_reclaim_1.MsgHtlcReclaim],
|
|
21
24
|
];
|
|
22
25
|
exports.registry = new proto_signing_1.Registry(types);
|
|
23
26
|
const TxClient = async (wallet) => {
|
|
@@ -30,19 +33,19 @@ const TxClient = async (wallet) => {
|
|
|
30
33
|
},
|
|
31
34
|
msgRequestTransaction: (data) => ({
|
|
32
35
|
typeUrl: "/kimablockchain.transaction.MsgRequestTransaction",
|
|
33
|
-
value:
|
|
36
|
+
value: request_1.MsgRequestTransaction.fromPartial(data),
|
|
34
37
|
}),
|
|
35
38
|
msgRequestHtlcLock: (data) => ({
|
|
36
39
|
typeUrl: "/kimablockchain.transaction.MsgRequestHtlcLock",
|
|
37
|
-
value:
|
|
40
|
+
value: htlc_lock_1.MsgRequestHtlcLock.fromPartial(data),
|
|
38
41
|
}),
|
|
39
42
|
msgSetTxHash: (data) => ({
|
|
40
43
|
typeUrl: "/kimablockchain.transaction.MsgSetTxHash",
|
|
41
|
-
value:
|
|
44
|
+
value: set_hash_1.MsgSetTxHash.fromPartial(data),
|
|
42
45
|
}),
|
|
43
46
|
msgHtlcReclaim: (data) => ({
|
|
44
47
|
typeUrl: "/kimablockchain.transaction.MsgHtlcReclaim",
|
|
45
|
-
value:
|
|
48
|
+
value: htlc_reclaim_1.MsgHtlcReclaim.fromPartial(data),
|
|
46
49
|
}),
|
|
47
50
|
};
|
|
48
51
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _m0 from "../../config/probuff.config";
|
|
2
|
+
export interface MsgCancelTransaction {
|
|
3
|
+
creator: string;
|
|
4
|
+
transactionId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface MsgCancelTransactionResponse {
|
|
7
|
+
code: string;
|
|
8
|
+
msg: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const MsgCancelTransaction: {
|
|
11
|
+
encode(message: MsgCancelTransaction, writer?: _m0.Writer): _m0.Writer;
|
|
12
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgCancelTransaction;
|
|
13
|
+
fromJSON(object: any): MsgCancelTransaction;
|
|
14
|
+
toJSON(message: MsgCancelTransaction): unknown;
|
|
15
|
+
fromPartial<I extends {
|
|
16
|
+
creator?: string | undefined;
|
|
17
|
+
transactionId?: string | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
creator?: string | undefined;
|
|
20
|
+
transactionId?: string | undefined;
|
|
21
|
+
} & { [K in Exclude<keyof I, keyof MsgCancelTransaction>]: never; }>(object: I): MsgCancelTransaction;
|
|
22
|
+
};
|
|
23
|
+
export declare const MsgCancelTransactionResponse: {
|
|
24
|
+
encode(message: MsgCancelTransactionResponse, writer?: _m0.Writer): _m0.Writer;
|
|
25
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgCancelTransactionResponse;
|
|
26
|
+
fromJSON(object: any): MsgCancelTransactionResponse;
|
|
27
|
+
toJSON(message: MsgCancelTransactionResponse): unknown;
|
|
28
|
+
fromPartial<I extends {
|
|
29
|
+
code?: string | undefined;
|
|
30
|
+
msg?: string | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
code?: string | undefined;
|
|
33
|
+
msg?: string | undefined;
|
|
34
|
+
} & { [K in Exclude<keyof I, keyof MsgCancelTransactionResponse>]: never; }>(object: I): MsgCancelTransactionResponse;
|
|
35
|
+
};
|