@cryptorubic/web3 1.0.2-alpha-rub-1224.0 → 1.0.2-alpha-rub-977.0
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/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 +11 -13
- package/src/lib/adapter/constants/chain-configs/chain-configs.js +57 -57
- package/src/lib/adapter/constants/viem-blockchain-mapping.js +3 -3
- package/src/lib/errors/blockchain/user-reject.error.d.ts +1 -1
- package/src/lib/errors/blockchain/user-reject.error.js +2 -2
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Abi, MulticallResponse, MulticallParameters, PublicActions, PublicClient, WalletClient, WalletActions, BlockNumber, BlockTag, GetBlockReturnType, TransactionReceipt } from 'viem';
|
|
2
|
+
import { AbstractAdapter } from '../common/abstract-adapter';
|
|
3
|
+
import { EvmBlockchainName, ICustomLogger, Token, TokenAmount, PriceTokenAmount, HttpClient } from '@cryptorubic/core';
|
|
2
4
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import {
|
|
5
|
+
import { EvmAdapterOptions } from '../models/evm-adapter-options';
|
|
4
6
|
import { EvmTransactionConfig } from '../../../utils/models/evm-transaction-config';
|
|
5
|
-
import {
|
|
7
|
+
import { EvmAdapterSigner } from './signer/evm-adapter-signer';
|
|
6
8
|
import { ClientAdaptersFactoryParams } from '../../models/create-factory-params';
|
|
7
|
-
import {
|
|
8
|
-
import { ApprovableAdapter } from '../models/approve-adapter';
|
|
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';
|
|
9
|
+
import { Web3PrimitiveType } from '../../../utils/models/primitive-types';
|
|
12
10
|
import { ContractMulticallResponse } from '../models/web3-public-models/contract-multicall-response';
|
|
13
11
|
import { MethodData } from '../models/web3-public-models/method-data';
|
|
14
|
-
import {
|
|
12
|
+
import { GasPrice } from '../models/evm-web3-public-models/gas-price';
|
|
15
13
|
import { EvmTransactionOptions } from './models/evm-send-tx-params';
|
|
16
|
-
import {
|
|
14
|
+
import { ApprovableAdapter } from '../models/approve-adapter';
|
|
15
|
+
import { AllowanceInfo } from '../models/common-types';
|
|
16
|
+
import { TxStatus } from '../models/web3-public-models/tx-status';
|
|
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,30 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EvmAdapter = void 0;
|
|
4
|
-
const core_1 = require("@cryptorubic/core");
|
|
5
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
6
4
|
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");
|
|
9
|
-
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
10
5
|
const viem_blockchain_mapping_1 = require("../../constants/viem-blockchain-mapping");
|
|
11
|
-
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
12
6
|
const erc20_token_abi_1 = require("../constants/erc20-token-abi");
|
|
7
|
+
const abstract_adapter_1 = require("../common/abstract-adapter");
|
|
8
|
+
const core_1 = require("@cryptorubic/core");
|
|
9
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
10
|
+
const web3_pure_1 = require("../../../utils/web3-pure");
|
|
13
11
|
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
|
|
15
|
+
const insufficient_funds_gas_price_value_error_1 = require("../../../errors/cross-chain/insufficient-funds-gas-price-value.error");
|
|
16
16
|
const options_1 = require("../utils/options");
|
|
17
|
-
const
|
|
17
|
+
const tx_status_1 = require("../models/web3-public-models/tx-status");
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// : tokenAmount.stringTokenAmount;
|
|
27
|
-
const approveAmount = tokenAmount.stringTokenAmount;
|
|
23
|
+
const approveAmount = this.blockchain === core_1.BLOCKCHAIN_NAME.GNOSIS || this.blockchain === core_1.BLOCKCHAIN_NAME.CRONOS
|
|
24
|
+
? tokenAmount.stringWeiAmount
|
|
25
|
+
: tokenAmount.stringTokenAmount;
|
|
28
26
|
const isNative = web3_pure_1.Web3Pure.isNativeAddress(this.blockchain, tokenAmount.address);
|
|
29
27
|
const fromTokenAddress = isNative && tokenAmount.blockchain === core_1.BLOCKCHAIN_NAME.METIS
|
|
30
28
|
? '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000'
|
|
@@ -237,25 +237,25 @@ exports.viemConfig = {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
259
|
MUMBAI: (0, viem_1.defineChain)({
|
|
260
260
|
blockExplorers: {
|
|
261
261
|
default: {
|
|
@@ -277,25 +277,25 @@ exports.viemConfig = {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
}),
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
299
|
HARMONY: (0, viem_1.defineChain)({
|
|
300
300
|
blockExplorers: {
|
|
301
301
|
default: {
|
|
@@ -1048,25 +1048,25 @@ exports.viemConfig = {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
}
|
|
1050
1050
|
}),
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
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
1070
|
ZK_SYNC: (0, viem_1.defineChain)({
|
|
1071
1071
|
blockExplorers: {
|
|
1072
1072
|
default: {
|
|
@@ -17,9 +17,9 @@ 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
|
-
|
|
20
|
+
[core_1.BLOCKCHAIN_NAME.CRONOS]: chains_1.cronos,
|
|
21
21
|
[core_1.BLOCKCHAIN_NAME.OKE_X_CHAIN]: chains_1.okc,
|
|
22
|
-
|
|
22
|
+
[core_1.BLOCKCHAIN_NAME.GNOSIS]: chains_1.gnosis,
|
|
23
23
|
[core_1.BLOCKCHAIN_NAME.FUSE]: chains_1.fuse,
|
|
24
24
|
[core_1.BLOCKCHAIN_NAME.MOONBEAM]: chains_1.moonbeam,
|
|
25
25
|
[core_1.BLOCKCHAIN_NAME.CELO]: chains_1.celo,
|
|
@@ -60,7 +60,7 @@ exports.viemBlockchainMapping = {
|
|
|
60
60
|
[core_1.BLOCKCHAIN_NAME.HOLESKY]: chains_1.holesky,
|
|
61
61
|
[core_1.BLOCKCHAIN_NAME.HORIZEN_EON]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.HORIZEN_EON],
|
|
62
62
|
[core_1.BLOCKCHAIN_NAME.MERLIN]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MERLIN],
|
|
63
|
-
|
|
63
|
+
[core_1.BLOCKCHAIN_NAME.ROOTSTOCK]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.ROOTSTOCK],
|
|
64
64
|
[core_1.BLOCKCHAIN_NAME.MODE]: chains_1.mode,
|
|
65
65
|
[core_1.BLOCKCHAIN_NAME.ZK_FAIR]: chains_1.zkFair,
|
|
66
66
|
[core_1.BLOCKCHAIN_NAME.ZK_LINK]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.ZK_LINK],
|
|
@@ -6,8 +6,8 @@ const rubic_sdk_error_1 = require("../rubic-sdk.error");
|
|
|
6
6
|
* Thrown, when user cancels transaction.
|
|
7
7
|
*/
|
|
8
8
|
class UserRejectError extends rubic_sdk_error_1.RubicSdkError {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
11
|
Object.setPrototypeOf(this, UserRejectError.prototype);
|
|
12
12
|
}
|
|
13
13
|
}
|