@cryptorubic/web3 0.2.10 → 0.2.11-test-cd.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 CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "0.2.10",
3
+ "version": "0.2.11-test-cd.0",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "bignumber.js": "9.1.2",
7
- "@cryptorubic/core": "0.2.10",
7
+ "@cryptorubic/core": "0.2.11-test-cd.0",
8
8
  "viem": "^2.19.1",
9
9
  "web3-utils": "^4.3.1",
10
10
  "@ton/ton": "^15.1.0",
11
11
  "@solana/web3.js": "1.95.3",
12
12
  "@solflare-wallet/utl-sdk": "^1.4.0",
13
13
  "@ethersproject/bignumber": "^5.7.0",
14
- "@cryptorubic/tron-types": "0.2.10",
14
+ "@cryptorubic/tron-types": "0.2.11-test-cd.0",
15
15
  "bitcoin-address-validation": "^2.2.3",
16
16
  "axios": "0.27.2",
17
17
  "crc-32": "^1.2.2",
@@ -33,9 +33,6 @@ export declare class EvmAdapter extends AbstractAdapter<PublicActions & PublicCl
33
33
  encodeApprove(tokenAddress: string, spenderAddress: string, amount?: string): EvmTransactionConfig;
34
34
  needApprove(token: TokenAmount, contractAddress: string, walletAddress: string, amount: string): Promise<boolean>;
35
35
  approve(fromAddress: string, tokenAddress: string, spenderAddress: string, amount?: string): Promise<string>;
36
- needPermit2Approve(token: TokenAmount, permit2Address: string, walletAddress: string, spenderAddress: string): Promise<boolean>;
37
- encodePermit2Approve(tokenAddress: string, spenderAddress: string, permit2Address: string, expiration: string, amount: string): EvmTransactionConfig;
38
- approveOnPermit2(fromAddress: string, tokenAddress: string, permit2Address: string, spenderAddress: string, deadline?: BigNumber, amount?: BigNumber): Promise<string>;
39
36
  /**
40
37
  * Calculates EIP-1559 specific gas details.
41
38
  * @see {@link https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-provider/src.ts/index.ts#L235}
@@ -9,7 +9,6 @@ const core_1 = require("@cryptorubic/core");
9
9
  const bignumber_js_1 = require("bignumber.js");
10
10
  const web3_pure_1 = require("../../utils/web3-pure");
11
11
  const possible_errors_1 = require("./constants/possible-errors");
12
- const uni_v3_permit_abi_1 = require("./constants/uni-v3-permit-abi");
13
12
  class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
14
13
  async needPreswapAction(token, contractAddress, walletAddress, amount) {
15
14
  return this.needApprove(token, contractAddress, walletAddress, amount);
@@ -39,9 +38,7 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
39
38
  const transports = rpcList.map((rpc) => (0, viem_1.http)(rpc, {
40
39
  batch: { batchSize: 2000, wait: 16 },
41
40
  onFetchResponse: (response) => {
42
- if ('error' in response) {
43
- this.handlePossibleError(response);
44
- }
41
+ this.handlePossibleError(response);
45
42
  },
46
43
  retryCount: 2,
47
44
  retryDelay: 100,
@@ -265,25 +262,6 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
265
262
  const config = this.encodeApprove(tokenAddress, spenderAddress, amount);
266
263
  return this.write(fromAddress, config.to, config.value, config.data);
267
264
  }
268
- async needPermit2Approve(token, permit2Address, walletAddress, spenderAddress) {
269
- const res = await this.read(permit2Address, uni_v3_permit_abi_1.UNI_V3_PERMIT_2_ABI, 'allowance', [walletAddress, token.address, spenderAddress]);
270
- return (token.weiAmount.gt(res.amount) ||
271
- new bignumber_js_1.default(Date.now()).gt(res.expiration));
272
- }
273
- encodePermit2Approve(tokenAddress, spenderAddress, permit2Address, expiration, amount) {
274
- const tx = EvmAdapter.encodeMethodCall(permit2Address, uni_v3_permit_abi_1.UNI_V3_PERMIT_2_ABI, 'approve', [tokenAddress, spenderAddress, amount, expiration]);
275
- return {
276
- data: tx.data,
277
- value: tx.value,
278
- to: tx.to,
279
- };
280
- }
281
- async approveOnPermit2(fromAddress, tokenAddress, permit2Address, spenderAddress, deadline = new bignumber_js_1.default(1000000), amount) {
282
- const approveAmount = amount ? amount : new bignumber_js_1.default(2).pow(256).minus(1);
283
- const expiration = new bignumber_js_1.default(Date.now()).plus(deadline).toFixed();
284
- const tx = this.encodePermit2Approve(tokenAddress, spenderAddress, permit2Address, expiration, approveAmount.toFixed());
285
- return this.write(fromAddress, tx.to, tx.value, tx.data);
286
- }
287
265
  /**
288
266
  * Calculates EIP-1559 specific gas details.
289
267
  * @see {@link https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-provider/src.ts/index.ts#L235}
@@ -1,2 +0,0 @@
1
- import { Abi } from 'viem';
2
- export declare const UNI_V3_PERMIT_2_ABI: Abi;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UNI_V3_PERMIT_2_ABI = void 0;
4
- exports.UNI_V3_PERMIT_2_ABI = [
5
- {
6
- inputs: [
7
- {
8
- internalType: 'address',
9
- name: 'owner',
10
- type: 'address',
11
- },
12
- {
13
- internalType: 'address',
14
- name: 'token',
15
- type: 'address',
16
- },
17
- {
18
- internalType: 'address',
19
- name: 'spender',
20
- type: 'address',
21
- },
22
- ],
23
- name: 'allowance',
24
- outputs: [
25
- {
26
- internalType: 'uint160',
27
- name: 'amount',
28
- type: 'uint160',
29
- },
30
- {
31
- internalType: 'uint48',
32
- name: 'expiration',
33
- type: 'uint48',
34
- },
35
- {
36
- internalType: 'uint48',
37
- name: 'nonce',
38
- type: 'uint48',
39
- },
40
- ],
41
- stateMutability: 'view',
42
- type: 'function',
43
- },
44
- {
45
- inputs: [
46
- {
47
- internalType: 'address',
48
- name: 'token',
49
- type: 'address',
50
- },
51
- {
52
- internalType: 'address',
53
- name: 'spender',
54
- type: 'address',
55
- },
56
- {
57
- internalType: 'uint160',
58
- name: 'amount',
59
- type: 'uint160',
60
- },
61
- {
62
- internalType: 'uint48',
63
- name: 'expiration',
64
- type: 'uint48',
65
- },
66
- ],
67
- name: 'approve',
68
- outputs: [],
69
- stateMutability: 'nonpayable',
70
- type: 'function',
71
- },
72
- ];
@@ -1,5 +0,0 @@
1
- export interface Permit2AllowanceContractResponse {
2
- amount: string;
3
- expiration: string;
4
- nonce: string;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });