@kimafinance/kima-transaction-api 1.0.27-beta.1 → 1.0.29-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/.github/workflows/dev_auto_publish_npm.yml +32 -32
- package/LICENSE.md +73 -73
- package/README.md +51 -51
- package/build/index.d.ts +47 -42
- package/build/index.js +105 -91
- package/build/kima/common.d.ts +16 -15
- package/build/kima/common.js +46 -41
- package/build/kima/tx.d.ts +557 -526
- package/build/kima/tx.js +1789 -1686
- package/nodemon.json +5 -5
- package/package.json +33 -33
- package/src/index.ts +180 -149
- package/src/kima/common.ts +62 -52
- package/src/kima/tx.ts +2411 -2267
- package/tsconfig.json +16 -16
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
jobs:
|
|
7
|
-
build:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
permissions:
|
|
10
|
-
contents: read
|
|
11
|
-
id-token: write
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v2
|
|
15
|
-
- uses: actions/setup-node@v1
|
|
16
|
-
with:
|
|
17
|
-
node-version: 18
|
|
18
|
-
registry-url: https://registry.npmjs.org/
|
|
19
|
-
|
|
20
|
-
- name: test
|
|
21
|
-
run: |
|
|
22
|
-
echo ${{ secrets.NPM_TOKEN }}
|
|
23
|
-
|
|
24
|
-
- name: Build the npm module and publish to npmjs.org
|
|
25
|
-
run: |
|
|
26
|
-
|
|
27
|
-
npm install
|
|
28
|
-
npm start
|
|
29
|
-
npm publish --provenance
|
|
30
|
-
|
|
31
|
-
env:
|
|
32
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
- uses: actions/setup-node@v1
|
|
16
|
+
with:
|
|
17
|
+
node-version: 18
|
|
18
|
+
registry-url: https://registry.npmjs.org/
|
|
19
|
+
|
|
20
|
+
- name: test
|
|
21
|
+
run: |
|
|
22
|
+
echo ${{ secrets.NPM_TOKEN }}
|
|
23
|
+
|
|
24
|
+
- name: Build the npm module and publish to npmjs.org
|
|
25
|
+
run: |
|
|
26
|
+
|
|
27
|
+
npm install
|
|
28
|
+
npm start
|
|
29
|
+
npm publish --provenance
|
|
30
|
+
|
|
31
|
+
env:
|
|
32
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/LICENSE.md
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
Business Source License 1.1
|
|
2
|
-
|
|
3
|
-
Copyright © 2023, Diversifi Technologies Ltd.
|
|
4
|
-
|
|
5
|
-
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
6
|
-
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
7
|
-
|
|
8
|
-
Terms
|
|
9
|
-
|
|
10
|
-
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
11
|
-
works, redistribute, and make non-production use of the Licensed Work. The
|
|
12
|
-
Licensor may make an Additional Use Grant, above, permitting limited
|
|
13
|
-
production use.
|
|
14
|
-
|
|
15
|
-
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
16
|
-
available distribution of a specific version of the Licensed Work under this
|
|
17
|
-
License, whichever comes first, the Licensor hereby grants you rights under
|
|
18
|
-
the terms of the Change License, and the rights granted in the paragraph
|
|
19
|
-
above terminate.
|
|
20
|
-
|
|
21
|
-
If your use of the Licensed Work does not comply with the requirements
|
|
22
|
-
currently in effect as described in this License, you must purchase a
|
|
23
|
-
commercial license from the Licensor, its affiliated entities, or authorized
|
|
24
|
-
resellers, or you must refrain from using the Licensed Work.
|
|
25
|
-
|
|
26
|
-
All copies of the original and modified Licensed Work, and derivative works
|
|
27
|
-
of the Licensed Work, are subject to this License. This License applies
|
|
28
|
-
separately for each version of the Licensed Work and the Change Date may vary
|
|
29
|
-
for each version of the Licensed Work released by Licensor.
|
|
30
|
-
|
|
31
|
-
You must conspicuously display this License on each original or modified copy
|
|
32
|
-
of the Licensed Work. If you receive the Licensed Work in original or
|
|
33
|
-
modified form from a third party, the terms and conditions set forth in this
|
|
34
|
-
License apply to your use of that work.
|
|
35
|
-
|
|
36
|
-
Any use of the Licensed Work in violation of this License will automatically
|
|
37
|
-
terminate your rights under this License for the current and all other
|
|
38
|
-
versions of the Licensed Work.
|
|
39
|
-
|
|
40
|
-
This License does not grant you any right in any trademark or logo of
|
|
41
|
-
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
42
|
-
Licensor as expressly required by this License).
|
|
43
|
-
|
|
44
|
-
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
45
|
-
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
46
|
-
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
47
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
48
|
-
TITLE.
|
|
49
|
-
|
|
50
|
-
MariaDB hereby grants you permission to use this License’s text to license
|
|
51
|
-
your works, and to refer to it using the trademark “Business Source License”,
|
|
52
|
-
as long as you comply with the Covenants of Licensor below.
|
|
53
|
-
|
|
54
|
-
Covenants of Licensor
|
|
55
|
-
|
|
56
|
-
In consideration of the right to use this License’s text and the “Business
|
|
57
|
-
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
58
|
-
other recipients of the licensed work to be provided by Licensor:
|
|
59
|
-
|
|
60
|
-
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
61
|
-
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
62
|
-
where “compatible” means that software provided under the Change License can
|
|
63
|
-
be included in a program with software provided under GPL Version 2.0 or a
|
|
64
|
-
later version. Licensor may specify additional Change Licenses without
|
|
65
|
-
limitation.
|
|
66
|
-
|
|
67
|
-
2. To either: (a) specify an additional grant of rights to use that does not
|
|
68
|
-
impose any additional restriction on the right granted in this License, as
|
|
69
|
-
the Additional Use Grant; or (b) insert the text “None”.
|
|
70
|
-
|
|
71
|
-
3. To specify a Change Date.
|
|
72
|
-
|
|
73
|
-
4. Not to modify this License in any other way.
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Copyright © 2023, Diversifi Technologies Ltd.
|
|
4
|
+
|
|
5
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
6
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
7
|
+
|
|
8
|
+
Terms
|
|
9
|
+
|
|
10
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
11
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
12
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
13
|
+
production use.
|
|
14
|
+
|
|
15
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
16
|
+
available distribution of a specific version of the Licensed Work under this
|
|
17
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
18
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
19
|
+
above terminate.
|
|
20
|
+
|
|
21
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
22
|
+
currently in effect as described in this License, you must purchase a
|
|
23
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
24
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
25
|
+
|
|
26
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
27
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
28
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
29
|
+
for each version of the Licensed Work released by Licensor.
|
|
30
|
+
|
|
31
|
+
You must conspicuously display this License on each original or modified copy
|
|
32
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
33
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
34
|
+
License apply to your use of that work.
|
|
35
|
+
|
|
36
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
37
|
+
terminate your rights under this License for the current and all other
|
|
38
|
+
versions of the Licensed Work.
|
|
39
|
+
|
|
40
|
+
This License does not grant you any right in any trademark or logo of
|
|
41
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
42
|
+
Licensor as expressly required by this License).
|
|
43
|
+
|
|
44
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
45
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
48
|
+
TITLE.
|
|
49
|
+
|
|
50
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
51
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
52
|
+
as long as you comply with the Covenants of Licensor below.
|
|
53
|
+
|
|
54
|
+
Covenants of Licensor
|
|
55
|
+
|
|
56
|
+
In consideration of the right to use this License’s text and the “Business
|
|
57
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
58
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
59
|
+
|
|
60
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
61
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
62
|
+
where “compatible” means that software provided under the Change License can
|
|
63
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
64
|
+
later version. Licensor may specify additional Change Licenses without
|
|
65
|
+
limitation.
|
|
66
|
+
|
|
67
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
68
|
+
impose any additional restriction on the right granted in this License, as
|
|
69
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
70
|
+
|
|
71
|
+
3. To specify a Change Date.
|
|
72
|
+
|
|
73
|
+
4. Not to modify this License in any other way.
|
package/README.md
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
# Kima Transaction API
|
|
2
|
-
|
|
3
|
-
[](https://github.com/kima-finance/kima-transaction-api/actions/workflows/dev_auto_publish_npm.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/@kimafinance/kima-transaction-api/)
|
|
5
|
-
[](https://www.npmjs.com/package/@kimafinance/kima-transaction-api/)
|
|
6
|
-
|
|
7
|
-
A wrapper around Kima's API, enabling sending and monitoring transactions. This is for beta version
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install --save @kimafinance/kima-transaction-api
|
|
13
|
-
yarn add @kimafinance/kima-transaction-api
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import {
|
|
20
|
-
submitKimaTransaction,
|
|
21
|
-
SupportNetworks,
|
|
22
|
-
CurrencyOptions,
|
|
23
|
-
} from "@kimafinance/kima-transaction-backend";
|
|
24
|
-
|
|
25
|
-
const txResult = await submitKimaTransaction({
|
|
26
|
-
originAddress: "0x1234123412341234123412341234123412341234",
|
|
27
|
-
originChain: "ETH",
|
|
28
|
-
targetAddress: "0x1234123412341234123412341234123412341234",
|
|
29
|
-
targetChain: "POL",
|
|
30
|
-
symbol: "USDK",
|
|
31
|
-
amount: 100,
|
|
32
|
-
fee: 0.3,
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Available Functions
|
|
37
|
-
|
|
38
|
-
`submitKimaTransaction` : Submit a transaction to transfer liquidity from one change to another.
|
|
39
|
-
|
|
40
|
-
- `originAddress`: sending address
|
|
41
|
-
- `originChain`: sending chain
|
|
42
|
-
- `targetAddress`: receiving address
|
|
43
|
-
- `targetChain`: receiving chain
|
|
44
|
-
- `symbol`: token symbol
|
|
45
|
-
- `amount`: amount of token to transfer
|
|
46
|
-
- `fee`: amount of token that kima consumes to pay gas fee for pulling & releasing token transactions
|
|
47
|
-
|
|
48
|
-
## Environment Variables
|
|
49
|
-
|
|
50
|
-
`KIMA_BACKEND_MNEMONIC` : Seed phrase of developer wallet. This wallet must have KIMA token to submit a transaction to kima chain.
|
|
51
|
-
`KIMA_BACKEND_NODE_PROVIDER` : Node provider for kima chain
|
|
1
|
+
# Kima Transaction API
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kima-finance/kima-transaction-api/actions/workflows/dev_auto_publish_npm.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@kimafinance/kima-transaction-api/)
|
|
5
|
+
[](https://www.npmjs.com/package/@kimafinance/kima-transaction-api/)
|
|
6
|
+
|
|
7
|
+
A wrapper around Kima's API, enabling sending and monitoring transactions. This is for beta version
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save @kimafinance/kima-transaction-api
|
|
13
|
+
yarn add @kimafinance/kima-transaction-api
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {
|
|
20
|
+
submitKimaTransaction,
|
|
21
|
+
SupportNetworks,
|
|
22
|
+
CurrencyOptions,
|
|
23
|
+
} from "@kimafinance/kima-transaction-backend";
|
|
24
|
+
|
|
25
|
+
const txResult = await submitKimaTransaction({
|
|
26
|
+
originAddress: "0x1234123412341234123412341234123412341234",
|
|
27
|
+
originChain: "ETH",
|
|
28
|
+
targetAddress: "0x1234123412341234123412341234123412341234",
|
|
29
|
+
targetChain: "POL",
|
|
30
|
+
symbol: "USDK",
|
|
31
|
+
amount: 100,
|
|
32
|
+
fee: 0.3,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Available Functions
|
|
37
|
+
|
|
38
|
+
`submitKimaTransaction` : Submit a transaction to transfer liquidity from one change to another.
|
|
39
|
+
|
|
40
|
+
- `originAddress`: sending address
|
|
41
|
+
- `originChain`: sending chain
|
|
42
|
+
- `targetAddress`: receiving address
|
|
43
|
+
- `targetChain`: receiving chain
|
|
44
|
+
- `symbol`: token symbol
|
|
45
|
+
- `amount`: amount of token to transfer
|
|
46
|
+
- `fee`: amount of token that kima consumes to pay gas fee for pulling & releasing token transactions
|
|
47
|
+
|
|
48
|
+
## Environment Variables
|
|
49
|
+
|
|
50
|
+
`KIMA_BACKEND_MNEMONIC` : Seed phrase of developer wallet. This wallet must have KIMA token to submit a transaction to kima chain.
|
|
51
|
+
`KIMA_BACKEND_NODE_PROVIDER` : Node provider for kima chain
|
package/build/index.d.ts
CHANGED
|
@@ -1,42 +1,47 @@
|
|
|
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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 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
|
+
symbol: CurrencyOptions;
|
|
38
|
+
amount: number;
|
|
39
|
+
fee: number;
|
|
40
|
+
htlcCreationHash: string;
|
|
41
|
+
htlcCreationVout: number;
|
|
42
|
+
htlcExpirationTimestamp: string;
|
|
43
|
+
htlcVersion: string;
|
|
44
|
+
senderPubKey: Uint8Array;
|
|
45
|
+
}
|
|
46
|
+
export declare function submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, }: RequestTxProps): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
47
|
+
export {};
|
package/build/index.js
CHANGED
|
@@ -1,91 +1,105 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.submitKimaTransaction = exports.submitHtlcLock = 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
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitKimaTransaction = exports.submitHtlcLock = exports.HtlcReclaim = 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 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 submitKimaTransaction({ originChain, originAddress, targetChain, targetAddress, symbol, amount, fee, htlcCreationHash, htlcCreationVout, htlcExpirationTimestamp, htlcVersion, senderPubKey, }) {
|
|
61
|
+
const wallet = await proto_signing_1.DirectSecp256k1HdWallet.fromMnemonic(process.env.KIMA_BACKEND_MNEMONIC, { prefix: "kima" });
|
|
62
|
+
const client = await (0, common_1.TxClient)(wallet);
|
|
63
|
+
const [firstAccount] = await wallet.getAccounts();
|
|
64
|
+
const params = {
|
|
65
|
+
creator: firstAccount.address,
|
|
66
|
+
originChain,
|
|
67
|
+
originAddress,
|
|
68
|
+
targetChain,
|
|
69
|
+
targetAddress,
|
|
70
|
+
symbol,
|
|
71
|
+
amount: amount.toString(),
|
|
72
|
+
fee: fee.toString(),
|
|
73
|
+
htlcCreationHash,
|
|
74
|
+
htlcCreationVout,
|
|
75
|
+
htlcExpirationTimestamp,
|
|
76
|
+
htlcVersion,
|
|
77
|
+
senderPubKey,
|
|
78
|
+
};
|
|
79
|
+
let msg = await client.msgRequestTransaction(params);
|
|
80
|
+
const result = await client.signAndBroadcast([msg]);
|
|
81
|
+
let txId = 1;
|
|
82
|
+
for (const event of result.events) {
|
|
83
|
+
if (event.type === "transaction_requested") {
|
|
84
|
+
for (const attr of event.attributes) {
|
|
85
|
+
if (attr.key === "txId") {
|
|
86
|
+
txId = +attr.value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
msg = await client.msgSetTxHash({
|
|
92
|
+
creator: firstAccount.address,
|
|
93
|
+
txId,
|
|
94
|
+
txHash: result.transactionHash,
|
|
95
|
+
txType: "request_transaction",
|
|
96
|
+
});
|
|
97
|
+
console.log(msg);
|
|
98
|
+
let hashResult;
|
|
99
|
+
do {
|
|
100
|
+
hashResult = await client.signAndBroadcast([msg]);
|
|
101
|
+
await sleep(1000);
|
|
102
|
+
} while (hashResult.code !== 0);
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
exports.submitKimaTransaction = submitKimaTransaction;
|
package/build/kima/common.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { StdFee } from "@cosmjs/stargate";
|
|
2
|
-
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
3
|
-
import { MsgRequestHtlcLock, 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
|
-
msgRequestHtlcLock: (data: MsgRequestHtlcLock) => EncodeObject;
|
|
13
|
-
msgSetTxHash: (data: MsgSetTxHash) => EncodeObject;
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { StdFee } from "@cosmjs/stargate";
|
|
2
|
+
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
|
|
3
|
+
import { MsgRequestHtlcLock, MsgRequestTransaction, MsgSetTxHash, MsgHtlcReclaim } 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
|
+
msgRequestHtlcLock: (data: MsgRequestHtlcLock) => EncodeObject;
|
|
13
|
+
msgSetTxHash: (data: MsgSetTxHash) => EncodeObject;
|
|
14
|
+
msgHtlcReclaim: (data: MsgHtlcReclaim) => EncodeObject;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|