@cryptorubic/web3 0.4.0 → 0.4.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/package.json +15 -13
- package/src/index.d.ts +0 -2
- package/src/index.js +0 -2
- package/src/lib/adapter/adapters/evm-adapter.d.ts +1 -4
- package/src/lib/adapter/adapters/evm-adapter.js +3 -27
- package/src/lib/adapter/blockchain-adapter-factory.service.d.ts +1 -3
- package/src/lib/adapter/blockchain-adapter-factory.service.js +0 -11
- package/src/lib/adapter/constants/chain-configs/chain-configs.js +5 -1
- package/src/lib/adapter/constants/models/wallet-provider.d.ts +0 -3
- package/README.md +0 -1
- package/src/lib/adapter/adapters/bitcoin-adapter.d.ts +0 -14
- package/src/lib/adapter/adapters/bitcoin-adapter.js +0 -65
- package/src/lib/adapter/adapters/constants/uni-v3-permit-abi.d.ts +0 -2
- package/src/lib/adapter/adapters/constants/uni-v3-permit-abi.js +0 -72
- package/src/lib/adapter/adapters/models/btc-wallet-provider.d.ts +0 -10
- package/src/lib/adapter/adapters/models/btc-wallet-provider.js +0 -2
- package/src/lib/adapter/adapters/models/permit2-contract-types.d.ts +0 -1
- package/src/lib/adapter/adapters/models/permit2-contract-types.js +0 -2
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptorubic/web3",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "tsc --project tsconfig.lib.json --outDir ../../dist && cp package.json ../../dist/packages/web3"
|
|
6
|
+
},
|
|
4
7
|
"dependencies": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"@
|
|
8
|
-
"viem": "^2.19.1",
|
|
9
|
-
"web3-utils": "^4.3.1",
|
|
10
|
-
"@ton/ton": "^15.1.0",
|
|
8
|
+
"@cryptorubic/core": "0.0.1",
|
|
9
|
+
"@cryptorubic/tron-types": "0.0.1",
|
|
10
|
+
"@ethersproject/bignumber": "^5.7.0",
|
|
11
11
|
"@solana/web3.js": "1.95.3",
|
|
12
12
|
"@solflare-wallet/utl-sdk": "^1.4.0",
|
|
13
|
-
"@
|
|
14
|
-
"@cryptorubic/tron-types": "0.4.0",
|
|
15
|
-
"bitcoin-address-validation": "^2.2.3",
|
|
13
|
+
"@ton/ton": "^15.1.0",
|
|
16
14
|
"axios": "0.27.2",
|
|
15
|
+
"bignumber.js": "9.1.2",
|
|
16
|
+
"bitcoin-address-validation": "^2.2.3",
|
|
17
17
|
"crc-32": "^1.2.2",
|
|
18
|
-
"tronweb": "^6.0.0-beta.4"
|
|
18
|
+
"tronweb": "^6.0.0-beta.4",
|
|
19
|
+
"tslib": "^2.3.0",
|
|
20
|
+
"viem": "^2.19.1",
|
|
21
|
+
"web3-utils": "^4.3.1"
|
|
19
22
|
},
|
|
20
23
|
"type": "commonjs",
|
|
21
24
|
"main": "./src/index.js",
|
|
@@ -25,6 +28,5 @@
|
|
|
25
28
|
},
|
|
26
29
|
"author": {
|
|
27
30
|
"name": "Sleta Dmitrii"
|
|
28
|
-
}
|
|
29
|
-
"types": "./src/index.d.ts"
|
|
31
|
+
}
|
|
30
32
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -23,8 +23,6 @@ export * from './lib/adapter/adapters/models/tonapi-models';
|
|
|
23
23
|
export * from './lib/adapter/adapters/models/toncenter-types';
|
|
24
24
|
export * from './lib/adapter/adapters/models/approve-adapter';
|
|
25
25
|
export * from './lib/adapter/adapters/models/gas-price';
|
|
26
|
-
export * from './lib/adapter/adapters/models/btc-wallet-provider';
|
|
27
|
-
export * from './lib/adapter/adapters/bitcoin-adapter';
|
|
28
26
|
export * from './lib/utils/web3-pure';
|
|
29
27
|
export * from './lib/utils/models/evm-transaction-config';
|
|
30
28
|
export * from './lib/utils/web3-types/bitcoin-web3-pure';
|
package/src/index.js
CHANGED
|
@@ -23,8 +23,6 @@ tslib_1.__exportStar(require("./lib/adapter/adapters/models/tonapi-models"), exp
|
|
|
23
23
|
tslib_1.__exportStar(require("./lib/adapter/adapters/models/toncenter-types"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./lib/adapter/adapters/models/approve-adapter"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./lib/adapter/adapters/models/gas-price"), exports);
|
|
26
|
-
tslib_1.__exportStar(require("./lib/adapter/adapters/models/btc-wallet-provider"), exports);
|
|
27
|
-
tslib_1.__exportStar(require("./lib/adapter/adapters/bitcoin-adapter"), exports);
|
|
28
26
|
// utils aka web3pure
|
|
29
27
|
tslib_1.__exportStar(require("./lib/utils/web3-pure"), exports);
|
|
30
28
|
tslib_1.__exportStar(require("./lib/utils/models/evm-transaction-config"), exports);
|
|
@@ -18,7 +18,7 @@ export declare class EvmAdapter extends AbstractAdapter<PublicActions & PublicCl
|
|
|
18
18
|
multicallByContract<T>(contracts: MulticallParameters, allowErrors?: boolean): Promise<MulticallResponse<T>[]>;
|
|
19
19
|
multicallByAddress<T>(address: string, abi: Abi, method: string, methodArgs?: unknown[][], allowErrors?: boolean): Promise<MulticallResponse<T>[]>;
|
|
20
20
|
static encodeMethodCall(contractAddress: string, contractAbi: Abi, method: string, parameters?: unknown[], value?: string): EvmTransactionConfig;
|
|
21
|
-
simulateTransaction(config: EvmTransactionConfig, from: string
|
|
21
|
+
simulateTransaction(config: EvmTransactionConfig, from: string): Promise<string>;
|
|
22
22
|
callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<EvmBlockchainName>[]>;
|
|
23
23
|
getGasPrice(): Promise<string>;
|
|
24
24
|
checkEnoughBalance(token: TokenAmount | PriceTokenAmount, walletAddress: string, amount?: BigNumber): Promise<boolean>;
|
|
@@ -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);
|
|
@@ -138,7 +137,7 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
138
137
|
throw err;
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
|
-
async simulateTransaction(config, from
|
|
140
|
+
async simulateTransaction(config, from) {
|
|
142
141
|
try {
|
|
143
142
|
const callParams = {
|
|
144
143
|
account: from,
|
|
@@ -146,11 +145,8 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
146
145
|
to: config.to,
|
|
147
146
|
...(config.value && { value: BigInt(config.value) }),
|
|
148
147
|
};
|
|
149
|
-
const gasLimitWei = await
|
|
150
|
-
|
|
151
|
-
new Promise((_, reject) => setTimeout(() => reject('Timeout'), timeout)),
|
|
152
|
-
]);
|
|
153
|
-
return gasLimitWei?.toString();
|
|
148
|
+
const gasLimitWei = await this.public.estimateGas(callParams);
|
|
149
|
+
return gasLimitWei.toString();
|
|
154
150
|
}
|
|
155
151
|
catch (err) {
|
|
156
152
|
this.logger?.customError('Error while simulating transaction', err);
|
|
@@ -266,26 +262,6 @@ class EvmAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
266
262
|
const config = this.encodeApprove(tokenAddress, spenderAddress, amount);
|
|
267
263
|
return this.write(fromAddress, config.to, config.value, config.data);
|
|
268
264
|
}
|
|
269
|
-
async needPermit2Approve(token, permit2Address, walletAddress, spenderAddress) {
|
|
270
|
-
const res = await this.read(permit2Address, uni_v3_permit_abi_1.UNI_V3_PERMIT_2_ABI, 'allowance', [walletAddress, token.address, spenderAddress]);
|
|
271
|
-
const [amount, expiration, _nonce] = res;
|
|
272
|
-
return (token.weiAmount.gt(amount) ||
|
|
273
|
-
new bignumber_js_1.default(Date.now()).gt(Number(expiration) * 1000));
|
|
274
|
-
}
|
|
275
|
-
encodePermit2Approve(tokenAddress, spenderAddress, permit2Address, expiration, amount) {
|
|
276
|
-
const tx = EvmAdapter.encodeMethodCall(permit2Address, uni_v3_permit_abi_1.UNI_V3_PERMIT_2_ABI, 'approve', [tokenAddress, spenderAddress, amount, expiration]);
|
|
277
|
-
return {
|
|
278
|
-
data: tx.data,
|
|
279
|
-
value: tx.value,
|
|
280
|
-
to: tx.to,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
async approveOnPermit2(fromAddress, tokenAddress, permit2Address, spenderAddress, deadline = new bignumber_js_1.default(1000000), amount) {
|
|
284
|
-
const approveAmount = amount ? amount : new bignumber_js_1.default(2).pow(256).minus(1);
|
|
285
|
-
const expiration = new bignumber_js_1.default(Date.now()).plus(deadline).toFixed();
|
|
286
|
-
const tx = this.encodePermit2Approve(tokenAddress, spenderAddress, permit2Address, expiration, approveAmount.toFixed());
|
|
287
|
-
return this.write(fromAddress, tx.to, tx.value, tx.data);
|
|
288
|
-
}
|
|
289
265
|
/**
|
|
290
266
|
* Calculates EIP-1559 specific gas details.
|
|
291
267
|
* @see {@link https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-provider/src.ts/index.ts#L235}
|
|
@@ -2,11 +2,10 @@ import { SolanaAdapter } from './adapters/solana-adapter';
|
|
|
2
2
|
import { TronAdapter } from './adapters/tron-adapter';
|
|
3
3
|
import { AbstractAdapter } from './adapters/abstract-adapter';
|
|
4
4
|
import { WalletProvider } from './constants/models/wallet-provider';
|
|
5
|
-
import { BlockchainName, EvmBlockchainName, SolanaBlockchainName, TronBlockchainName, ICustomLogger, HttpClient, TonBlockchainName
|
|
5
|
+
import { BlockchainName, EvmBlockchainName, SolanaBlockchainName, TronBlockchainName, ICustomLogger, HttpClient, TonBlockchainName } from '@cryptorubic/core';
|
|
6
6
|
import { TonAdapter } from './adapters/ton-adapter';
|
|
7
7
|
import { TonAdapterConfig } from './adapters/models/ton-adapter-config';
|
|
8
8
|
import { EvmAdapter } from './adapters/evm-adapter';
|
|
9
|
-
import { BitcoinAdapter } from './adapters/bitcoin-adapter';
|
|
10
9
|
export declare class BlockchainAdapterFactoryService {
|
|
11
10
|
private readonly rpcList;
|
|
12
11
|
private readonly createLogger?;
|
|
@@ -20,7 +19,6 @@ export declare class BlockchainAdapterFactoryService {
|
|
|
20
19
|
getAdapter(blockchain: EvmBlockchainName): EvmAdapter;
|
|
21
20
|
getAdapter(blockchain: TronBlockchainName): TronAdapter;
|
|
22
21
|
getAdapter(blockchain: TonBlockchainName): TonAdapter;
|
|
23
|
-
getAdapter(blockchain: BitcoinBlockchainName): BitcoinAdapter;
|
|
24
22
|
private createStorage;
|
|
25
23
|
private createAdapter;
|
|
26
24
|
connectWallet(walletProvider: WalletProvider): void;
|
|
@@ -8,7 +8,6 @@ const viem_1 = require("viem");
|
|
|
8
8
|
const core_1 = require("@cryptorubic/core");
|
|
9
9
|
const ton_adapter_1 = require("./adapters/ton-adapter");
|
|
10
10
|
const evm_adapter_1 = require("./adapters/evm-adapter");
|
|
11
|
-
const bitcoin_adapter_1 = require("./adapters/bitcoin-adapter");
|
|
12
11
|
class BlockchainAdapterFactoryService {
|
|
13
12
|
constructor(rpcList, createLogger, httpClient, tonParams) {
|
|
14
13
|
this.rpcList = rpcList;
|
|
@@ -47,7 +46,6 @@ class BlockchainAdapterFactoryService {
|
|
|
47
46
|
return [blockchain, null];
|
|
48
47
|
});
|
|
49
48
|
const tonAdapter = this.createAdapter(core_1.BLOCKCHAIN_NAME.TON, []);
|
|
50
|
-
const btcAdapter = this.createAdapter(core_1.BLOCKCHAIN_NAME.BITCOIN, []);
|
|
51
49
|
adapters.push(tonAdapter
|
|
52
50
|
? [core_1.BLOCKCHAIN_NAME.TON, tonAdapter]
|
|
53
51
|
: [core_1.BLOCKCHAIN_NAME.TON, null]);
|
|
@@ -87,9 +85,6 @@ class BlockchainAdapterFactoryService {
|
|
|
87
85
|
this.tonParams?.tonClientConfig) {
|
|
88
86
|
return new ton_adapter_1.TonAdapter(this.httpClient, this.tonParams, this.createLogger?.(`TON_ADAPTER`));
|
|
89
87
|
}
|
|
90
|
-
if (blockchain === core_1.BLOCKCHAIN_NAME.BITCOIN && this.httpClient) {
|
|
91
|
-
return new bitcoin_adapter_1.BitcoinAdapter(this.httpClient, this.createLogger?.(`BTC_ADAPTER`));
|
|
92
|
-
}
|
|
93
88
|
return null;
|
|
94
89
|
}
|
|
95
90
|
connectWallet(walletProvider) {
|
|
@@ -122,12 +117,6 @@ class BlockchainAdapterFactoryService {
|
|
|
122
117
|
store.wallet = walletProvider[core_1.CHAIN_TYPE.TON].core;
|
|
123
118
|
store.walletAddress = walletProvider[core_1.CHAIN_TYPE.TON].address;
|
|
124
119
|
}
|
|
125
|
-
if (walletProvider?.[core_1.CHAIN_TYPE.BITCOIN]?.core &&
|
|
126
|
-
this.adapterStore?.[core_1.BLOCKCHAIN_NAME.BITCOIN]) {
|
|
127
|
-
const store = this.adapterStore[core_1.BLOCKCHAIN_NAME.BITCOIN];
|
|
128
|
-
store.wallet = walletProvider[core_1.CHAIN_TYPE.BITCOIN].core;
|
|
129
|
-
store.walletAddress = walletProvider[core_1.CHAIN_TYPE.BITCOIN].address;
|
|
130
|
-
}
|
|
131
120
|
}
|
|
132
121
|
}
|
|
133
122
|
exports.BlockchainAdapterFactoryService = BlockchainAdapterFactoryService;
|
|
@@ -1242,7 +1242,6 @@ exports.viemConfig = {
|
|
|
1242
1242
|
},
|
|
1243
1243
|
},
|
|
1244
1244
|
}),
|
|
1245
|
-
// unknown Multicall3
|
|
1246
1245
|
ZK_LINK: (0, viem_1.defineChain)({
|
|
1247
1246
|
blockExplorers: {
|
|
1248
1247
|
default: {
|
|
@@ -1256,6 +1255,11 @@ exports.viemConfig = {
|
|
|
1256
1255
|
nativeCurrency: { decimals: 18, name: 'ETH', symbol: 'ETH' },
|
|
1257
1256
|
rpcUrls: { default: { http: ['https://rpc.zklink.io'] } },
|
|
1258
1257
|
testnet: false,
|
|
1258
|
+
contracts: {
|
|
1259
|
+
multicall3: {
|
|
1260
|
+
address: '0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5'
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1259
1263
|
}),
|
|
1260
1264
|
THETA: (0, viem_1.defineChain)({
|
|
1261
1265
|
blockExplorers: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CHAIN_TYPE } from '@cryptorubic/core';
|
|
2
2
|
import { SolanaWeb3 } from './solana-web3';
|
|
3
3
|
import { TronWeb } from 'tronweb';
|
|
4
|
-
import { BtcWallet } from '../../adapters/models/btc-wallet-provider';
|
|
5
4
|
export interface WalletProviderCore<T = any> {
|
|
6
5
|
/**
|
|
7
6
|
* Core provider.
|
|
@@ -18,7 +17,6 @@ export type EvmWalletProviderCore = WalletProviderCore<{
|
|
|
18
17
|
export type TronWalletProviderCore = WalletProviderCore<typeof TronWeb>;
|
|
19
18
|
export type SolanaWalletProviderCore = WalletProviderCore<SolanaWeb3>;
|
|
20
19
|
export type TonWaleltProviderCore = WalletProviderCore<unknown>;
|
|
21
|
-
export type BitcoinWalletProviderCore = WalletProviderCore<BtcWallet>;
|
|
22
20
|
/**
|
|
23
21
|
* Stores wallet core and information about current user, used to make `send` transactions.
|
|
24
22
|
*/
|
|
@@ -27,7 +25,6 @@ interface IWalletProvider {
|
|
|
27
25
|
readonly [CHAIN_TYPE.TRON]?: TronWalletProviderCore;
|
|
28
26
|
readonly [CHAIN_TYPE.SOLANA]?: SolanaWalletProviderCore;
|
|
29
27
|
readonly [CHAIN_TYPE.TON]?: TonWaleltProviderCore;
|
|
30
|
-
readonly [CHAIN_TYPE.BITCOIN]?: BitcoinWalletProviderCore;
|
|
31
28
|
}
|
|
32
29
|
export type WalletProvider = Partial<IWalletProvider>;
|
|
33
30
|
export {};
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# web3
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BitcoinBlockchainName, BlockchainName, HttpClient, ICustomLogger, Token } from '@cryptorubic/core';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { AbstractAdapter } from './abstract-adapter';
|
|
4
|
-
import { BasicTransactionOptions } from './models/basic-transaction-options';
|
|
5
|
-
import { BtcWallet } from './models/btc-wallet-provider';
|
|
6
|
-
export declare class BitcoinAdapter extends AbstractAdapter<BtcWallet, BtcWallet, BitcoinBlockchainName> {
|
|
7
|
-
private readonly httpClient;
|
|
8
|
-
constructor(httpClient: HttpClient, logger?: ICustomLogger);
|
|
9
|
-
getBalance(userAddress: string): Promise<BigNumber>;
|
|
10
|
-
callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<BlockchainName>[]>;
|
|
11
|
-
read<T>(args: unknown): Promise<T>;
|
|
12
|
-
write(args: unknown): Promise<string>;
|
|
13
|
-
transfer(recipient: string, amount: string, fromAddress: string, memo?: string, options?: BasicTransactionOptions): Promise<string>;
|
|
14
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinAdapter = void 0;
|
|
4
|
-
const core_1 = require("@cryptorubic/core");
|
|
5
|
-
const bignumber_js_1 = require("bignumber.js");
|
|
6
|
-
const abstract_adapter_1 = require("./abstract-adapter");
|
|
7
|
-
class BitcoinAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
8
|
-
constructor(httpClient, logger) {
|
|
9
|
-
super(core_1.BLOCKCHAIN_NAME.BITCOIN, logger);
|
|
10
|
-
this.httpClient = httpClient;
|
|
11
|
-
}
|
|
12
|
-
async getBalance(userAddress) {
|
|
13
|
-
const url = `https://api.blockcypher.com/v1/btc/main/addrs/${userAddress}/balance`;
|
|
14
|
-
const response = await this.httpClient.get(url);
|
|
15
|
-
return new bignumber_js_1.default(response.final_balance);
|
|
16
|
-
}
|
|
17
|
-
async callForTokensInfo(tokenAddresses) {
|
|
18
|
-
return [core_1.nativeTokensList[core_1.BLOCKCHAIN_NAME.BITCOIN]];
|
|
19
|
-
}
|
|
20
|
-
read(args) {
|
|
21
|
-
throw new Error('Not implemented');
|
|
22
|
-
}
|
|
23
|
-
write(args) {
|
|
24
|
-
throw new Error('Not implemented');
|
|
25
|
-
}
|
|
26
|
-
async transfer(recipient, amount, fromAddress, memo, options) {
|
|
27
|
-
const hashPromise = new Promise((resolve, reject) => {
|
|
28
|
-
this.wallet.request({
|
|
29
|
-
method: 'transfer',
|
|
30
|
-
params: [
|
|
31
|
-
{
|
|
32
|
-
feeRate: 10,
|
|
33
|
-
from: fromAddress,
|
|
34
|
-
recipient,
|
|
35
|
-
amount: {
|
|
36
|
-
amount,
|
|
37
|
-
decimals: 8,
|
|
38
|
-
},
|
|
39
|
-
...(memo && { memo }),
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
}, (error, txHash) => {
|
|
43
|
-
if (error) {
|
|
44
|
-
reject(error);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
options?.onTransactionHash?.(txHash);
|
|
48
|
-
resolve(txHash);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
try {
|
|
53
|
-
const hash = await hashPromise;
|
|
54
|
-
if (typeof hash === 'string') {
|
|
55
|
-
// const statusData = this.getSrcStatusRecursive(srcTxHash, BLOCKCHAIN_NAME.BITCOIN, 300_000);
|
|
56
|
-
return hash;
|
|
57
|
-
}
|
|
58
|
-
throw new Error();
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
throw new Error('Failed to transfer funds');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.BitcoinAdapter = BitcoinAdapter;
|
|
@@ -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,10 +0,0 @@
|
|
|
1
|
-
export interface BtcWallet {
|
|
2
|
-
on: (event: string, callback: (...args: unknown[]) => void) => unknown;
|
|
3
|
-
request<T>(args: {
|
|
4
|
-
method: string;
|
|
5
|
-
params: unknown[];
|
|
6
|
-
}, fn: (error: Error, txHash: string) => unknown): Promise<{
|
|
7
|
-
error: null | Error;
|
|
8
|
-
result: T;
|
|
9
|
-
}>;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Permit2AllowanceContractResponse = [string, number, number];
|