@ardrive/turbo-sdk 1.44.1-alpha.4 → 2.0.0-alpha.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/lib/cjs/cli/errors.js +1 -1
- package/lib/cjs/cli/options.js +2 -10
- package/lib/cjs/cli/utils.js +4 -13
- package/lib/cjs/common/factory.js +0 -3
- package/lib/cjs/common/folderIndex.js +1 -1
- package/lib/cjs/common/signer.js +2 -10
- package/lib/cjs/common/token/index.js +0 -5
- package/lib/cjs/types.js +0 -8
- package/lib/cjs/utils/common.js +0 -30
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/errors.js +1 -1
- package/lib/esm/cli/options.js +2 -10
- package/lib/esm/cli/utils.js +5 -14
- package/lib/esm/common/factory.js +0 -3
- package/lib/esm/common/folderIndex.js +1 -1
- package/lib/esm/common/signer.js +0 -8
- package/lib/esm/common/token/index.js +0 -5
- package/lib/esm/types.js +0 -7
- package/lib/esm/utils/common.js +1 -28
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/options.d.ts +21 -85
- package/lib/types/cli/options.d.ts.map +1 -1
- package/lib/types/cli/types.d.ts +0 -1
- package/lib/types/cli/types.d.ts.map +1 -1
- package/lib/types/cli/utils.d.ts +1 -1
- package/lib/types/cli/utils.d.ts.map +1 -1
- package/lib/types/common/factory.d.ts.map +1 -1
- package/lib/types/common/signer.d.ts.map +1 -1
- package/lib/types/common/token/index.d.ts +0 -1
- package/lib/types/common/token/index.d.ts.map +1 -1
- package/lib/types/types.d.ts +1 -3
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils/common.d.ts +0 -3
- package/lib/types/utils/common.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/lib/types/version.d.ts.map +1 -1
- package/package.json +1 -3
- package/lib/cjs/common/token/kyve.js +0 -212
- package/lib/esm/common/token/kyve.js +0 -203
- package/lib/types/common/token/kyve.d.ts +0 -84
- package/lib/types/common/token/kyve.d.ts.map +0 -1
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUPPORTED_CHAIN_CONFIGS = exports.KyveToken = exports.KYVEToTokenAmount = exports.ukyveToTokenAmount = void 0;
|
|
4
|
-
exports.signerFromKyvePrivateKey = signerFromKyvePrivateKey;
|
|
5
|
-
exports.privateKeyFromKyveMnemonic = privateKeyFromKyveMnemonic;
|
|
6
|
-
exports.signerFromKyveMnemonic = signerFromKyveMnemonic;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License.
|
|
12
|
-
* You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
const amino_1 = require("@cosmjs/amino");
|
|
23
|
-
const crypto_1 = require("@cosmjs/crypto");
|
|
24
|
-
const encoding_1 = require("@cosmjs/encoding");
|
|
25
|
-
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
26
|
-
const stargate_1 = require("@cosmjs/stargate");
|
|
27
|
-
const arbundles_1 = require("@dha-team/arbundles");
|
|
28
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
29
|
-
const common_js_1 = require("../../utils/common.js");
|
|
30
|
-
const common_js_2 = require("../../utils/common.js");
|
|
31
|
-
const logger_js_1 = require("../logger.js");
|
|
32
|
-
function hasKyveTxResponse(response) {
|
|
33
|
-
return response.tx_response !== undefined;
|
|
34
|
-
}
|
|
35
|
-
const ukyveToTokenAmount = (winston) => winston;
|
|
36
|
-
exports.ukyveToTokenAmount = ukyveToTokenAmount;
|
|
37
|
-
const KYVEToTokenAmount = (sol) => new bignumber_js_1.BigNumber(sol).times(1e6).valueOf();
|
|
38
|
-
exports.KYVEToTokenAmount = KYVEToTokenAmount;
|
|
39
|
-
class KyveToken {
|
|
40
|
-
constructor({ logger = logger_js_1.Logger.default, gatewayUrl = common_js_1.defaultProdGatewayUrls.kyve, pollingOptions = {
|
|
41
|
-
maxAttempts: 5,
|
|
42
|
-
pollingIntervalMs: 1_000,
|
|
43
|
-
initialBackoffMs: 500,
|
|
44
|
-
}, }) {
|
|
45
|
-
this.logger = logger;
|
|
46
|
-
this.gatewayUrl = gatewayUrl;
|
|
47
|
-
this.pollingOptions = pollingOptions;
|
|
48
|
-
}
|
|
49
|
-
async createAndSubmitTx({ target, tokenAmount, signer, }) {
|
|
50
|
-
this.logger.debug('Creating and submitting transaction...', {
|
|
51
|
-
target,
|
|
52
|
-
tokenAmount,
|
|
53
|
-
signer,
|
|
54
|
-
});
|
|
55
|
-
const chainId = this.gatewayUrl.includes('kaon')
|
|
56
|
-
? 'kaon-1'
|
|
57
|
-
: this.gatewayUrl.includes('korellia')
|
|
58
|
-
? 'korellia-2'
|
|
59
|
-
: 'kyve-1';
|
|
60
|
-
const txHash = await this.sendTokens({
|
|
61
|
-
chainId,
|
|
62
|
-
privateKeyUint8Array: signer['signer'].key,
|
|
63
|
-
recipientAddress: target,
|
|
64
|
-
amount: tokenAmount.toString(),
|
|
65
|
-
});
|
|
66
|
-
return { id: txHash, target };
|
|
67
|
-
}
|
|
68
|
-
async pollTxAvailability({ txId }) {
|
|
69
|
-
const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
|
|
70
|
-
this.logger.debug('Polling for transaction...', {
|
|
71
|
-
txId,
|
|
72
|
-
pollingOptions: this.pollingOptions,
|
|
73
|
-
});
|
|
74
|
-
await (0, common_js_2.sleep)(initialBackoffMs);
|
|
75
|
-
let attempts = 0;
|
|
76
|
-
while (attempts < maxAttempts) {
|
|
77
|
-
let data = undefined;
|
|
78
|
-
attempts++;
|
|
79
|
-
try {
|
|
80
|
-
const res = await fetch(this.gatewayUrl + '/cosmos/tx/v1beta1/txs/' + txId);
|
|
81
|
-
if (res.ok) {
|
|
82
|
-
data = await res.json();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
// Continue retries when request errors
|
|
87
|
-
this.logger.debug('Failed to poll for transaction...', { err });
|
|
88
|
-
}
|
|
89
|
-
if (data !== undefined && hasKyveTxResponse(data)) {
|
|
90
|
-
if (data.tx_response.code !== 0) {
|
|
91
|
-
throw new Error(`Transaction failed: ${data.tx_response.code}`);
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this.logger.debug('Transaction not found, polling...', {
|
|
96
|
-
txId,
|
|
97
|
-
attempts,
|
|
98
|
-
maxAttempts,
|
|
99
|
-
pollingIntervalMs,
|
|
100
|
-
});
|
|
101
|
-
await (0, common_js_2.sleep)(pollingIntervalMs);
|
|
102
|
-
}
|
|
103
|
-
throw new Error('Transaction not found after polling, transaction id: ' + txId);
|
|
104
|
-
}
|
|
105
|
-
// ref: https://github.com/KYVENetwork/kyvejs/blob/e6c68b007fb50ab026e60ea6eaadf37b7cf8c76f/common/sdk/src/clients/rpc-client/signing.ts#L109-L183
|
|
106
|
-
async sendTokens({ chainId, privateKeyUint8Array, recipientAddress, amount, gasMultiplier = 1.5, }) {
|
|
107
|
-
const config = exports.SUPPORTED_CHAIN_CONFIGS[chainId];
|
|
108
|
-
if (config === undefined) {
|
|
109
|
-
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
110
|
-
}
|
|
111
|
-
const wallet = await proto_signing_1.DirectSecp256k1Wallet.fromKey(privateKeyUint8Array, 'kyve');
|
|
112
|
-
const [account] = await wallet.getAccounts();
|
|
113
|
-
const senderAddress = account.address;
|
|
114
|
-
const gasPrice = stargate_1.GasPrice.fromString(`${config.gasPrice}${config.coinDenom}`);
|
|
115
|
-
const client = await stargate_1.SigningStargateClient.connectWithSigner(config.rpc, wallet, { gasPrice });
|
|
116
|
-
// Create MsgSend message
|
|
117
|
-
const msg = {
|
|
118
|
-
fromAddress: senderAddress,
|
|
119
|
-
toAddress: recipientAddress,
|
|
120
|
-
amount: [{ denom: config.coinDenom, amount }],
|
|
121
|
-
};
|
|
122
|
-
const encodedMsg = {
|
|
123
|
-
typeUrl: '/cosmos.bank.v1beta1.MsgSend',
|
|
124
|
-
value: msg,
|
|
125
|
-
};
|
|
126
|
-
// Simulate gas usage
|
|
127
|
-
const gasEstimate = await client.simulate(senderAddress, [encodedMsg], '');
|
|
128
|
-
// Calculate fee with buffer
|
|
129
|
-
const fee = (0, stargate_1.calculateFee)(Math.round(gasEstimate * gasMultiplier), stargate_1.GasPrice.fromString(`${config.gasPrice}${config.coinDenom}`));
|
|
130
|
-
// Send the actual transaction
|
|
131
|
-
const result = await client.sendTokens(senderAddress, recipientAddress, [{ denom: config.coinDenom, amount }], fee, '');
|
|
132
|
-
return result.transactionHash;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.KyveToken = KyveToken;
|
|
136
|
-
function signerFromKyvePrivateKey(privateKey) {
|
|
137
|
-
// TODO: Use KyveSigner when implemented for on chain native address support
|
|
138
|
-
return new arbundles_1.EthereumSigner(privateKey);
|
|
139
|
-
}
|
|
140
|
-
async function privateKeyFromKyveMnemonic(mnemonic) {
|
|
141
|
-
const kyveWallet = await amino_1.Secp256k1HdWallet.fromMnemonic(mnemonic, {
|
|
142
|
-
prefix: 'kyve',
|
|
143
|
-
});
|
|
144
|
-
return (0, encoding_1.toHex)(crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, kyveWallet['seed'], (0, amino_1.makeCosmoshubPath)(0)).privkey);
|
|
145
|
-
}
|
|
146
|
-
async function signerFromKyveMnemonic(mnemonic) {
|
|
147
|
-
const privateKey = await privateKeyFromKyveMnemonic(mnemonic);
|
|
148
|
-
return signerFromKyvePrivateKey(privateKey);
|
|
149
|
-
}
|
|
150
|
-
// ref: https://github.com/KYVENetwork/kyvejs/blob/e6c68b007fb50ab026e60ea6eaadf37b7cf8c76f/common/sdk/src/constants.ts#L26-L89
|
|
151
|
-
exports.SUPPORTED_CHAIN_CONFIGS = {
|
|
152
|
-
'kyve-1': {
|
|
153
|
-
chainId: 'kyve-1',
|
|
154
|
-
chainName: 'KYVE',
|
|
155
|
-
rpc: 'https://rpc.kyve.network',
|
|
156
|
-
rest: 'https://api.kyve.network',
|
|
157
|
-
coin: 'KYVE',
|
|
158
|
-
coinDenom: 'ukyve',
|
|
159
|
-
coinDecimals: 6,
|
|
160
|
-
gasPrice: 62.5,
|
|
161
|
-
},
|
|
162
|
-
'kaon-1': {
|
|
163
|
-
chainId: 'kaon-1',
|
|
164
|
-
chainName: 'KYVE Kaon',
|
|
165
|
-
rpc: 'https://rpc.kaon.kyve.network',
|
|
166
|
-
rest: 'https://api.kaon.kyve.network',
|
|
167
|
-
coin: 'KYVE',
|
|
168
|
-
coinDenom: 'tkyve',
|
|
169
|
-
coinDecimals: 6,
|
|
170
|
-
gasPrice: 0.02,
|
|
171
|
-
},
|
|
172
|
-
'korellia-2': {
|
|
173
|
-
chainId: 'korellia-2',
|
|
174
|
-
chainName: 'KYVE Korellia',
|
|
175
|
-
rpc: 'https://rpc.korellia.kyve.network',
|
|
176
|
-
rest: 'https://api.korellia.kyve.network',
|
|
177
|
-
coin: 'KYVE',
|
|
178
|
-
coinDenom: 'tkyve',
|
|
179
|
-
coinDecimals: 6,
|
|
180
|
-
gasPrice: 62.5,
|
|
181
|
-
},
|
|
182
|
-
'kyve-beta': {
|
|
183
|
-
chainId: 'kyve-beta',
|
|
184
|
-
chainName: 'KYVE-Beta',
|
|
185
|
-
rpc: 'https://rpc.beta.kyve.network',
|
|
186
|
-
rest: 'https://api.beta.kyve.network',
|
|
187
|
-
coin: 'KYVE',
|
|
188
|
-
coinDenom: 'tkyve',
|
|
189
|
-
coinDecimals: 6,
|
|
190
|
-
gasPrice: 2,
|
|
191
|
-
},
|
|
192
|
-
'kyve-alpha': {
|
|
193
|
-
chainId: 'kyve-alpha',
|
|
194
|
-
chainName: 'KYVE Alpha',
|
|
195
|
-
rpc: 'https://rpc.alpha.kyve.network',
|
|
196
|
-
rest: 'https://api.alpha.kyve.network',
|
|
197
|
-
coin: 'KYVE',
|
|
198
|
-
coinDenom: 'tkyve',
|
|
199
|
-
coinDecimals: 6,
|
|
200
|
-
gasPrice: 2,
|
|
201
|
-
},
|
|
202
|
-
'kyve-local': {
|
|
203
|
-
chainId: 'kyve-local',
|
|
204
|
-
chainName: 'KYVE Local',
|
|
205
|
-
rpc: 'http://0.0.0.0:26657',
|
|
206
|
-
rest: 'http://0.0.0.0:1317',
|
|
207
|
-
coin: 'KYVE',
|
|
208
|
-
coinDenom: 'tkyve',
|
|
209
|
-
coinDecimals: 6,
|
|
210
|
-
gasPrice: 2,
|
|
211
|
-
},
|
|
212
|
-
};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Secp256k1HdWallet, makeCosmoshubPath } from '@cosmjs/amino';
|
|
17
|
-
import { Slip10, Slip10Curve } from '@cosmjs/crypto';
|
|
18
|
-
import { toHex } from '@cosmjs/encoding';
|
|
19
|
-
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
|
|
20
|
-
import { GasPrice, SigningStargateClient, calculateFee, } from '@cosmjs/stargate';
|
|
21
|
-
import { EthereumSigner } from '@dha-team/arbundles';
|
|
22
|
-
import { BigNumber } from 'bignumber.js';
|
|
23
|
-
import { defaultProdGatewayUrls } from '../../utils/common.js';
|
|
24
|
-
import { sleep } from '../../utils/common.js';
|
|
25
|
-
import { Logger } from '../logger.js';
|
|
26
|
-
function hasKyveTxResponse(response) {
|
|
27
|
-
return response.tx_response !== undefined;
|
|
28
|
-
}
|
|
29
|
-
export const ukyveToTokenAmount = (winston) => winston;
|
|
30
|
-
export const KYVEToTokenAmount = (sol) => new BigNumber(sol).times(1e6).valueOf();
|
|
31
|
-
export class KyveToken {
|
|
32
|
-
constructor({ logger = Logger.default, gatewayUrl = defaultProdGatewayUrls.kyve, pollingOptions = {
|
|
33
|
-
maxAttempts: 5,
|
|
34
|
-
pollingIntervalMs: 1_000,
|
|
35
|
-
initialBackoffMs: 500,
|
|
36
|
-
}, }) {
|
|
37
|
-
this.logger = logger;
|
|
38
|
-
this.gatewayUrl = gatewayUrl;
|
|
39
|
-
this.pollingOptions = pollingOptions;
|
|
40
|
-
}
|
|
41
|
-
async createAndSubmitTx({ target, tokenAmount, signer, }) {
|
|
42
|
-
this.logger.debug('Creating and submitting transaction...', {
|
|
43
|
-
target,
|
|
44
|
-
tokenAmount,
|
|
45
|
-
signer,
|
|
46
|
-
});
|
|
47
|
-
const chainId = this.gatewayUrl.includes('kaon')
|
|
48
|
-
? 'kaon-1'
|
|
49
|
-
: this.gatewayUrl.includes('korellia')
|
|
50
|
-
? 'korellia-2'
|
|
51
|
-
: 'kyve-1';
|
|
52
|
-
const txHash = await this.sendTokens({
|
|
53
|
-
chainId,
|
|
54
|
-
privateKeyUint8Array: signer['signer'].key,
|
|
55
|
-
recipientAddress: target,
|
|
56
|
-
amount: tokenAmount.toString(),
|
|
57
|
-
});
|
|
58
|
-
return { id: txHash, target };
|
|
59
|
-
}
|
|
60
|
-
async pollTxAvailability({ txId }) {
|
|
61
|
-
const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
|
|
62
|
-
this.logger.debug('Polling for transaction...', {
|
|
63
|
-
txId,
|
|
64
|
-
pollingOptions: this.pollingOptions,
|
|
65
|
-
});
|
|
66
|
-
await sleep(initialBackoffMs);
|
|
67
|
-
let attempts = 0;
|
|
68
|
-
while (attempts < maxAttempts) {
|
|
69
|
-
let data = undefined;
|
|
70
|
-
attempts++;
|
|
71
|
-
try {
|
|
72
|
-
const res = await fetch(this.gatewayUrl + '/cosmos/tx/v1beta1/txs/' + txId);
|
|
73
|
-
if (res.ok) {
|
|
74
|
-
data = await res.json();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
// Continue retries when request errors
|
|
79
|
-
this.logger.debug('Failed to poll for transaction...', { err });
|
|
80
|
-
}
|
|
81
|
-
if (data !== undefined && hasKyveTxResponse(data)) {
|
|
82
|
-
if (data.tx_response.code !== 0) {
|
|
83
|
-
throw new Error(`Transaction failed: ${data.tx_response.code}`);
|
|
84
|
-
}
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
this.logger.debug('Transaction not found, polling...', {
|
|
88
|
-
txId,
|
|
89
|
-
attempts,
|
|
90
|
-
maxAttempts,
|
|
91
|
-
pollingIntervalMs,
|
|
92
|
-
});
|
|
93
|
-
await sleep(pollingIntervalMs);
|
|
94
|
-
}
|
|
95
|
-
throw new Error('Transaction not found after polling, transaction id: ' + txId);
|
|
96
|
-
}
|
|
97
|
-
// ref: https://github.com/KYVENetwork/kyvejs/blob/e6c68b007fb50ab026e60ea6eaadf37b7cf8c76f/common/sdk/src/clients/rpc-client/signing.ts#L109-L183
|
|
98
|
-
async sendTokens({ chainId, privateKeyUint8Array, recipientAddress, amount, gasMultiplier = 1.5, }) {
|
|
99
|
-
const config = SUPPORTED_CHAIN_CONFIGS[chainId];
|
|
100
|
-
if (config === undefined) {
|
|
101
|
-
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
102
|
-
}
|
|
103
|
-
const wallet = await DirectSecp256k1Wallet.fromKey(privateKeyUint8Array, 'kyve');
|
|
104
|
-
const [account] = await wallet.getAccounts();
|
|
105
|
-
const senderAddress = account.address;
|
|
106
|
-
const gasPrice = GasPrice.fromString(`${config.gasPrice}${config.coinDenom}`);
|
|
107
|
-
const client = await SigningStargateClient.connectWithSigner(config.rpc, wallet, { gasPrice });
|
|
108
|
-
// Create MsgSend message
|
|
109
|
-
const msg = {
|
|
110
|
-
fromAddress: senderAddress,
|
|
111
|
-
toAddress: recipientAddress,
|
|
112
|
-
amount: [{ denom: config.coinDenom, amount }],
|
|
113
|
-
};
|
|
114
|
-
const encodedMsg = {
|
|
115
|
-
typeUrl: '/cosmos.bank.v1beta1.MsgSend',
|
|
116
|
-
value: msg,
|
|
117
|
-
};
|
|
118
|
-
// Simulate gas usage
|
|
119
|
-
const gasEstimate = await client.simulate(senderAddress, [encodedMsg], '');
|
|
120
|
-
// Calculate fee with buffer
|
|
121
|
-
const fee = calculateFee(Math.round(gasEstimate * gasMultiplier), GasPrice.fromString(`${config.gasPrice}${config.coinDenom}`));
|
|
122
|
-
// Send the actual transaction
|
|
123
|
-
const result = await client.sendTokens(senderAddress, recipientAddress, [{ denom: config.coinDenom, amount }], fee, '');
|
|
124
|
-
return result.transactionHash;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
export function signerFromKyvePrivateKey(privateKey) {
|
|
128
|
-
// TODO: Use KyveSigner when implemented for on chain native address support
|
|
129
|
-
return new EthereumSigner(privateKey);
|
|
130
|
-
}
|
|
131
|
-
export async function privateKeyFromKyveMnemonic(mnemonic) {
|
|
132
|
-
const kyveWallet = await Secp256k1HdWallet.fromMnemonic(mnemonic, {
|
|
133
|
-
prefix: 'kyve',
|
|
134
|
-
});
|
|
135
|
-
return toHex(Slip10.derivePath(Slip10Curve.Secp256k1, kyveWallet['seed'], makeCosmoshubPath(0)).privkey);
|
|
136
|
-
}
|
|
137
|
-
export async function signerFromKyveMnemonic(mnemonic) {
|
|
138
|
-
const privateKey = await privateKeyFromKyveMnemonic(mnemonic);
|
|
139
|
-
return signerFromKyvePrivateKey(privateKey);
|
|
140
|
-
}
|
|
141
|
-
// ref: https://github.com/KYVENetwork/kyvejs/blob/e6c68b007fb50ab026e60ea6eaadf37b7cf8c76f/common/sdk/src/constants.ts#L26-L89
|
|
142
|
-
export const SUPPORTED_CHAIN_CONFIGS = {
|
|
143
|
-
'kyve-1': {
|
|
144
|
-
chainId: 'kyve-1',
|
|
145
|
-
chainName: 'KYVE',
|
|
146
|
-
rpc: 'https://rpc.kyve.network',
|
|
147
|
-
rest: 'https://api.kyve.network',
|
|
148
|
-
coin: 'KYVE',
|
|
149
|
-
coinDenom: 'ukyve',
|
|
150
|
-
coinDecimals: 6,
|
|
151
|
-
gasPrice: 62.5,
|
|
152
|
-
},
|
|
153
|
-
'kaon-1': {
|
|
154
|
-
chainId: 'kaon-1',
|
|
155
|
-
chainName: 'KYVE Kaon',
|
|
156
|
-
rpc: 'https://rpc.kaon.kyve.network',
|
|
157
|
-
rest: 'https://api.kaon.kyve.network',
|
|
158
|
-
coin: 'KYVE',
|
|
159
|
-
coinDenom: 'tkyve',
|
|
160
|
-
coinDecimals: 6,
|
|
161
|
-
gasPrice: 0.02,
|
|
162
|
-
},
|
|
163
|
-
'korellia-2': {
|
|
164
|
-
chainId: 'korellia-2',
|
|
165
|
-
chainName: 'KYVE Korellia',
|
|
166
|
-
rpc: 'https://rpc.korellia.kyve.network',
|
|
167
|
-
rest: 'https://api.korellia.kyve.network',
|
|
168
|
-
coin: 'KYVE',
|
|
169
|
-
coinDenom: 'tkyve',
|
|
170
|
-
coinDecimals: 6,
|
|
171
|
-
gasPrice: 62.5,
|
|
172
|
-
},
|
|
173
|
-
'kyve-beta': {
|
|
174
|
-
chainId: 'kyve-beta',
|
|
175
|
-
chainName: 'KYVE-Beta',
|
|
176
|
-
rpc: 'https://rpc.beta.kyve.network',
|
|
177
|
-
rest: 'https://api.beta.kyve.network',
|
|
178
|
-
coin: 'KYVE',
|
|
179
|
-
coinDenom: 'tkyve',
|
|
180
|
-
coinDecimals: 6,
|
|
181
|
-
gasPrice: 2,
|
|
182
|
-
},
|
|
183
|
-
'kyve-alpha': {
|
|
184
|
-
chainId: 'kyve-alpha',
|
|
185
|
-
chainName: 'KYVE Alpha',
|
|
186
|
-
rpc: 'https://rpc.alpha.kyve.network',
|
|
187
|
-
rest: 'https://api.alpha.kyve.network',
|
|
188
|
-
coin: 'KYVE',
|
|
189
|
-
coinDenom: 'tkyve',
|
|
190
|
-
coinDecimals: 6,
|
|
191
|
-
gasPrice: 2,
|
|
192
|
-
},
|
|
193
|
-
'kyve-local': {
|
|
194
|
-
chainId: 'kyve-local',
|
|
195
|
-
chainName: 'KYVE Local',
|
|
196
|
-
rpc: 'http://0.0.0.0:26657',
|
|
197
|
-
rest: 'http://0.0.0.0:1317',
|
|
198
|
-
coin: 'KYVE',
|
|
199
|
-
coinDenom: 'tkyve',
|
|
200
|
-
coinDecimals: 6,
|
|
201
|
-
gasPrice: 2,
|
|
202
|
-
},
|
|
203
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from 'bignumber.js';
|
|
2
|
-
import { TokenConfig, TokenCreateTxParams, TokenPollingOptions, TokenTools, TurboLogger, TurboSigner } from '../../types.js';
|
|
3
|
-
export declare const ukyveToTokenAmount: (winston: BigNumber.Value) => BigNumber.Value;
|
|
4
|
-
export declare const KYVEToTokenAmount: (sol: BigNumber.Value) => string;
|
|
5
|
-
export declare class KyveToken implements TokenTools {
|
|
6
|
-
protected logger: TurboLogger;
|
|
7
|
-
protected gatewayUrl: string;
|
|
8
|
-
protected pollingOptions: TokenPollingOptions;
|
|
9
|
-
constructor({ logger, gatewayUrl, pollingOptions, }: TokenConfig);
|
|
10
|
-
createAndSubmitTx({ target, tokenAmount, signer, }: TokenCreateTxParams): Promise<{
|
|
11
|
-
id: string;
|
|
12
|
-
target: string;
|
|
13
|
-
}>;
|
|
14
|
-
pollTxAvailability({ txId }: {
|
|
15
|
-
txId: string;
|
|
16
|
-
}): Promise<void>;
|
|
17
|
-
private sendTokens;
|
|
18
|
-
}
|
|
19
|
-
export declare function signerFromKyvePrivateKey(privateKey: string): TurboSigner;
|
|
20
|
-
export declare function privateKeyFromKyveMnemonic(mnemonic: string): Promise<string>;
|
|
21
|
-
export declare function signerFromKyveMnemonic(mnemonic: string): Promise<TurboSigner>;
|
|
22
|
-
export declare const SUPPORTED_CHAIN_CONFIGS: {
|
|
23
|
-
'kyve-1': {
|
|
24
|
-
chainId: string;
|
|
25
|
-
chainName: string;
|
|
26
|
-
rpc: string;
|
|
27
|
-
rest: string;
|
|
28
|
-
coin: string;
|
|
29
|
-
coinDenom: string;
|
|
30
|
-
coinDecimals: number;
|
|
31
|
-
gasPrice: number;
|
|
32
|
-
};
|
|
33
|
-
'kaon-1': {
|
|
34
|
-
chainId: string;
|
|
35
|
-
chainName: string;
|
|
36
|
-
rpc: string;
|
|
37
|
-
rest: string;
|
|
38
|
-
coin: string;
|
|
39
|
-
coinDenom: string;
|
|
40
|
-
coinDecimals: number;
|
|
41
|
-
gasPrice: number;
|
|
42
|
-
};
|
|
43
|
-
'korellia-2': {
|
|
44
|
-
chainId: string;
|
|
45
|
-
chainName: string;
|
|
46
|
-
rpc: string;
|
|
47
|
-
rest: string;
|
|
48
|
-
coin: string;
|
|
49
|
-
coinDenom: string;
|
|
50
|
-
coinDecimals: number;
|
|
51
|
-
gasPrice: number;
|
|
52
|
-
};
|
|
53
|
-
'kyve-beta': {
|
|
54
|
-
chainId: string;
|
|
55
|
-
chainName: string;
|
|
56
|
-
rpc: string;
|
|
57
|
-
rest: string;
|
|
58
|
-
coin: string;
|
|
59
|
-
coinDenom: string;
|
|
60
|
-
coinDecimals: number;
|
|
61
|
-
gasPrice: number;
|
|
62
|
-
};
|
|
63
|
-
'kyve-alpha': {
|
|
64
|
-
chainId: string;
|
|
65
|
-
chainName: string;
|
|
66
|
-
rpc: string;
|
|
67
|
-
rest: string;
|
|
68
|
-
coin: string;
|
|
69
|
-
coinDenom: string;
|
|
70
|
-
coinDecimals: number;
|
|
71
|
-
gasPrice: number;
|
|
72
|
-
};
|
|
73
|
-
'kyve-local': {
|
|
74
|
-
chainId: string;
|
|
75
|
-
chainName: string;
|
|
76
|
-
rpc: string;
|
|
77
|
-
rest: string;
|
|
78
|
-
coin: string;
|
|
79
|
-
coinDenom: string;
|
|
80
|
-
coinDecimals: number;
|
|
81
|
-
gasPrice: number;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=kyve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kyve.d.ts","sourceRoot":"","sources":["../../../../src/common/token/kyve.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,gBAAgB,CAAC;AA8CxB,eAAO,MAAM,kBAAkB,YAAa,SAAS,CAAC,KAAK,oBAAY,CAAC;AACxE,eAAO,MAAM,iBAAiB,QAAS,SAAS,CAAC,KAAK,WACb,CAAC;AAE1C,qBAAa,SAAU,YAAW,UAAU;IAC1C,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAC9B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,cAAc,EAAE,mBAAmB,CAAC;gBAElC,EACV,MAAuB,EACvB,UAAwC,EACxC,cAIC,GACF,EAAE,WAAW;IAOD,iBAAiB,CAAC,EAC7B,MAAM,EACN,WAAW,EACX,MAAM,GACP,EAAE,mBAAmB,GAAG,OAAO,CAAC;QAC/B,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAsBW,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAiD5D,UAAU;CAkEzB;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAGxE;AAED,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAItB;AAGD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DnC,CAAC"}
|