@cryptorubic/web3 1.0.1 → 1.0.2-alpha-rub-1224.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 +1 -1
- package/package.json +1 -1
- package/src/lib/adapter/adapters/adapter-evm/evm-adapter.d.ts +10 -10
- package/src/lib/adapter/adapters/adapter-evm/evm-adapter.js +9 -11
- package/src/lib/adapter/adapters/adapter-evm/signer/evm-adapter-signer.d.ts +1 -1
- package/src/lib/adapter/adapters/adapter-evm/signer/evm-adapter-signer.js +7 -7
- package/src/lib/adapter/constants/chain-configs/chain-configs.js +0 -57
- package/src/lib/adapter/constants/viem-blockchain-mapping.js +0 -3
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# web3
|
|
1
|
+
# web3
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractAdapter } from '../common/abstract-adapter';
|
|
3
|
-
import { EvmBlockchainName, ICustomLogger, Token, TokenAmount, PriceTokenAmount, HttpClient } from '@cryptorubic/core';
|
|
1
|
+
import { EvmBlockchainName, HttpClient, ICustomLogger, PriceTokenAmount, Token, TokenAmount } from '@cryptorubic/core';
|
|
4
2
|
import BigNumber from 'bignumber.js';
|
|
5
|
-
import {
|
|
3
|
+
import { Abi, BlockNumber, BlockTag, GetBlockReturnType, MulticallParameters, MulticallResponse, PublicActions, PublicClient, TransactionReceipt, WalletActions, WalletClient } from 'viem';
|
|
6
4
|
import { EvmTransactionConfig } from '../../../utils/models/evm-transaction-config';
|
|
7
|
-
import { EvmAdapterSigner } from './signer/evm-adapter-signer';
|
|
8
|
-
import { ClientAdaptersFactoryParams } from '../../models/create-factory-params';
|
|
9
5
|
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { GasPrice } from '../models/evm-web3-public-models/gas-price';
|
|
13
|
-
import { EvmTransactionOptions } from './models/evm-send-tx-params';
|
|
6
|
+
import { ClientAdaptersFactoryParams } from '../../models/create-factory-params';
|
|
7
|
+
import { AbstractAdapter } from '../common/abstract-adapter';
|
|
14
8
|
import { ApprovableAdapter } from '../models/approve-adapter';
|
|
15
9
|
import { AllowanceInfo } from '../models/common-types';
|
|
10
|
+
import { EvmAdapterOptions } from '../models/evm-adapter-options';
|
|
11
|
+
import { GasPrice } from '../models/evm-web3-public-models/gas-price';
|
|
12
|
+
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
13
|
+
import { MethodData } from '../models/web3-public-models/method-data';
|
|
16
14
|
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
15
|
+
import { EvmTransactionOptions } from './models/evm-send-tx-params';
|
|
16
|
+
import { EvmAdapterSigner } from './signer/evm-adapter-signer';
|
|
17
17
|
export declare class EvmAdapter extends AbstractAdapter<PublicActions & PublicClient, WalletClient & WalletActions, EvmBlockchainName> implements ApprovableAdapter<EvmTransactionConfig> {
|
|
18
18
|
private readonly adapterOptions;
|
|
19
19
|
private readonly clientParams?;
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EvmAdapter = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const viem_blockchain_mapping_1 = require("../../constants/viem-blockchain-mapping");
|
|
6
|
-
const erc20_token_abi_1 = require("../constants/erc20-token-abi");
|
|
7
|
-
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
8
4
|
const core_1 = require("@cryptorubic/core");
|
|
9
5
|
const bignumber_js_1 = require("bignumber.js");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const insufficient_funds_gas_price_value_error_1 = require("../../../errors/cross-chain/insufficient-funds-gas-price-value.error");
|
|
8
|
+
const rubic_sdk_error_1 = require("../../../errors/rubic-sdk.error");
|
|
10
9
|
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
10
|
+
const viem_blockchain_mapping_1 = require("../../constants/viem-blockchain-mapping");
|
|
11
|
+
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
12
|
+
const erc20_token_abi_1 = require("../constants/erc20-token-abi");
|
|
11
13
|
const possible_errors_1 = require("../constants/possible-errors");
|
|
12
|
-
const evm_adapter_signer_1 = require("./signer/evm-adapter-signer");
|
|
13
|
-
const rubic_sdk_error_1 = require("../../../errors/rubic-sdk.error");
|
|
14
14
|
const uni_v3_permit_abi_1 = require("../constants/uni-v3-permit-abi");
|
|
15
|
-
const insufficient_funds_gas_price_value_error_1 = require("../../../errors/cross-chain/insufficient-funds-gas-price-value.error");
|
|
16
|
-
const options_1 = require("../utils/options");
|
|
17
15
|
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
16
|
+
const options_1 = require("../utils/options");
|
|
17
|
+
const evm_adapter_signer_1 = require("./signer/evm-adapter-signer");
|
|
18
18
|
class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
19
19
|
async needPreswapAction(token, contractAddress, walletAddress, amount) {
|
|
20
20
|
return this.needApprove(token, contractAddress, walletAddress, amount);
|
|
21
21
|
}
|
|
22
22
|
async handlePreswap(contractAddress, walletAddress, tokenAmount) {
|
|
23
|
-
const approveAmount =
|
|
24
|
-
? tokenAmount.stringWeiAmount
|
|
25
|
-
: tokenAmount.stringTokenAmount;
|
|
23
|
+
const approveAmount = tokenAmount.stringTokenAmount;
|
|
26
24
|
const isNative = web3_pure_1.Web3Pure.isNativeAddress(this.blockchain, tokenAmount.address);
|
|
27
25
|
const fromTokenAddress = isNative && tokenAmount.blockchain === core_1.BLOCKCHAIN_NAME.METIS
|
|
28
26
|
? '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockchainName, HttpClient, ICustomLogger } from '@cryptorubic/core';
|
|
2
|
+
import { Abi, PublicActions, PublicClient, TransactionReceipt, WalletActions, WalletClient } from 'viem';
|
|
2
3
|
import { ClientAdaptersFactoryParams } from '../../../models/create-factory-params';
|
|
3
4
|
import { AbstractAdapterSigner } from '../../common/signer/abstract-adapter-signer';
|
|
4
|
-
import { Abi, PublicActions, PublicClient, TransactionReceipt, WalletActions, WalletClient } from 'viem';
|
|
5
5
|
import { EvmSendTxParams, EvmTransactionOptions } from '../models/evm-send-tx-params';
|
|
6
6
|
import { Web3Error } from '../utils/parse-evm-error';
|
|
7
7
|
export declare class EvmAdapterSigner extends AbstractAdapterSigner<WalletClient & WalletActions, EvmSendTxParams, TransactionReceipt> {
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EvmAdapterSigner = void 0;
|
|
4
4
|
const core_1 = require("@cryptorubic/core");
|
|
5
|
-
const
|
|
5
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
const actions_1 = require("viem/actions");
|
|
8
|
-
const
|
|
8
|
+
const tx_reverted_in_chain_error_1 = require("../../../../errors/common/tx-reverted-in-chain.error");
|
|
9
|
+
const rubic_sdk_error_1 = require("../../../../errors/rubic-sdk.error");
|
|
9
10
|
const viem_blockchain_mapping_1 = require("../../../constants/viem-blockchain-mapping");
|
|
11
|
+
const abstract_adapter_signer_1 = require("../../common/signer/abstract-adapter-signer");
|
|
12
|
+
const options_1 = require("../../utils/options");
|
|
10
13
|
const parse_evm_error_1 = require("../utils/parse-evm-error");
|
|
11
|
-
const rubic_sdk_error_1 = require("../../../../errors/rubic-sdk.error");
|
|
12
|
-
const tx_reverted_in_chain_error_1 = require("../../../../errors/common/tx-reverted-in-chain.error");
|
|
13
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
14
14
|
class EvmAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
15
15
|
get publicClient() {
|
|
16
16
|
if (!this.publicRef.public) {
|
|
@@ -73,8 +73,8 @@ class EvmAdapterSigner extends abstract_adapter_signer_1.AbstractAdapterSigner {
|
|
|
73
73
|
value,
|
|
74
74
|
...(params.txOptions.data && { data: params.txOptions.data })
|
|
75
75
|
};
|
|
76
|
-
const gas = await this.publicClient.estimateGas(gaslessParams);
|
|
77
|
-
const calculatedGas = params.txOptions.gasLimitRatio
|
|
76
|
+
const gas = params.txOptions.gas ? BigInt(params.txOptions.gas) : await this.publicClient.estimateGas(gaslessParams);
|
|
77
|
+
const calculatedGas = !params.txOptions.gas && params.txOptions.gasLimitRatio
|
|
78
78
|
? BigInt(new bignumber_js_1.default(gas.toString()).multipliedBy(params.txOptions.gasLimitRatio).toFixed(0))
|
|
79
79
|
: gas;
|
|
80
80
|
const gasfulParams = {
|
|
@@ -237,25 +237,6 @@ exports.viemConfig = {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}),
|
|
240
|
-
CRONOS: (0, viem_1.defineChain)({
|
|
241
|
-
blockExplorers: {
|
|
242
|
-
default: {
|
|
243
|
-
apiUrl: 'https://cronoscan.com/',
|
|
244
|
-
name: 'CRONOS Explorer',
|
|
245
|
-
url: 'https://cronoscan.com/'
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
id: 25,
|
|
249
|
-
name: 'Cronos Mainnet Beta',
|
|
250
|
-
nativeCurrency: { decimals: 18, name: 'CRO', symbol: 'CRO' },
|
|
251
|
-
rpcUrls: { default: { http: ['https://evm.cronos.org'] } },
|
|
252
|
-
testnet: false,
|
|
253
|
-
contracts: {
|
|
254
|
-
multicall3: {
|
|
255
|
-
address: '0x5e954f5972EC6BFc7dECd75779F10d848230345F'
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
240
|
MUMBAI: (0, viem_1.defineChain)({
|
|
260
241
|
blockExplorers: {
|
|
261
242
|
default: {
|
|
@@ -277,25 +258,6 @@ exports.viemConfig = {
|
|
|
277
258
|
}
|
|
278
259
|
}
|
|
279
260
|
}),
|
|
280
|
-
GNOSIS: (0, viem_1.defineChain)({
|
|
281
|
-
blockExplorers: {
|
|
282
|
-
default: {
|
|
283
|
-
apiUrl: 'https://blockscout.com/xdai/mainnet/',
|
|
284
|
-
name: 'GNOSIS Explorer',
|
|
285
|
-
url: 'https://blockscout.com/xdai/mainnet/'
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
id: 100,
|
|
289
|
-
name: 'Gnosis Chain',
|
|
290
|
-
nativeCurrency: { decimals: 18, name: 'xDAI', symbol: 'xDAI' },
|
|
291
|
-
rpcUrls: { default: { http: ['https://rpc.gnosischain.com'] } },
|
|
292
|
-
testnet: false,
|
|
293
|
-
contracts: {
|
|
294
|
-
multicall3: {
|
|
295
|
-
address: '0x67dA5f2FfaDDfF067AB9d5F025F8810634d84287'
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}),
|
|
299
261
|
HARMONY: (0, viem_1.defineChain)({
|
|
300
262
|
blockExplorers: {
|
|
301
263
|
default: {
|
|
@@ -1048,25 +1010,6 @@ exports.viemConfig = {
|
|
|
1048
1010
|
}
|
|
1049
1011
|
}
|
|
1050
1012
|
}),
|
|
1051
|
-
ROOTSTOCK: (0, viem_1.defineChain)({
|
|
1052
|
-
blockExplorers: {
|
|
1053
|
-
default: {
|
|
1054
|
-
apiUrl: 'https://explorer.rsk.co/',
|
|
1055
|
-
name: 'ROOTSTOCK Explorer',
|
|
1056
|
-
url: 'https://explorer.rsk.co/'
|
|
1057
|
-
}
|
|
1058
|
-
},
|
|
1059
|
-
id: 30,
|
|
1060
|
-
name: 'Rootstock',
|
|
1061
|
-
nativeCurrency: { decimals: 18, name: 'RBTC', symbol: 'RBTC' },
|
|
1062
|
-
rpcUrls: { default: { http: ['https://public-node.rsk.co'] } },
|
|
1063
|
-
testnet: false,
|
|
1064
|
-
contracts: {
|
|
1065
|
-
multicall3: {
|
|
1066
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11'
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}),
|
|
1070
1013
|
ZK_SYNC: (0, viem_1.defineChain)({
|
|
1071
1014
|
blockExplorers: {
|
|
1072
1015
|
default: {
|
|
@@ -17,9 +17,7 @@ exports.viemBlockchainMapping = {
|
|
|
17
17
|
[core_1.BLOCKCHAIN_NAME.AURORA]: chains_1.aurora,
|
|
18
18
|
[core_1.BLOCKCHAIN_NAME.TELOS]: chains_1.telos,
|
|
19
19
|
[core_1.BLOCKCHAIN_NAME.OPTIMISM]: chains_1.optimism,
|
|
20
|
-
[core_1.BLOCKCHAIN_NAME.CRONOS]: chains_1.cronos,
|
|
21
20
|
[core_1.BLOCKCHAIN_NAME.OKE_X_CHAIN]: chains_1.okc,
|
|
22
|
-
[core_1.BLOCKCHAIN_NAME.GNOSIS]: chains_1.gnosis,
|
|
23
21
|
[core_1.BLOCKCHAIN_NAME.FUSE]: chains_1.fuse,
|
|
24
22
|
[core_1.BLOCKCHAIN_NAME.MOONBEAM]: chains_1.moonbeam,
|
|
25
23
|
[core_1.BLOCKCHAIN_NAME.CELO]: chains_1.celo,
|
|
@@ -60,7 +58,6 @@ exports.viemBlockchainMapping = {
|
|
|
60
58
|
[core_1.BLOCKCHAIN_NAME.HOLESKY]: chains_1.holesky,
|
|
61
59
|
[core_1.BLOCKCHAIN_NAME.HORIZEN_EON]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.HORIZEN_EON],
|
|
62
60
|
[core_1.BLOCKCHAIN_NAME.MERLIN]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MERLIN],
|
|
63
|
-
[core_1.BLOCKCHAIN_NAME.ROOTSTOCK]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.ROOTSTOCK],
|
|
64
61
|
[core_1.BLOCKCHAIN_NAME.MODE]: chains_1.mode,
|
|
65
62
|
[core_1.BLOCKCHAIN_NAME.ZK_FAIR]: chains_1.zkFair,
|
|
66
63
|
[core_1.BLOCKCHAIN_NAME.ZK_LINK]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.ZK_LINK],
|