@cryptorubic/web3 0.8.10-alpha-squid-solana.2 → 0.8.10
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 +3 -3
- package/src/lib/adapter/adapters/solana-adapter.d.ts +1 -5
- package/src/lib/adapter/adapters/solana-adapter.js +1 -45
- package/src/lib/adapter/constants/chain-configs/chain-configs.js +27 -19
- package/src/lib/adapter/constants/viem-blockchain-mapping.js +2 -2
- package/src/lib/utils/constants/changenow-api-blockchain.d.ts +0 -2
- package/src/lib/utils/constants/changenow-api-blockchain.js +0 -1
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptorubic/web3",
|
|
3
|
-
"version": "0.8.10
|
|
3
|
+
"version": "0.8.10",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
6
|
"bignumber.js": "9.1.2",
|
|
7
|
-
"@cryptorubic/core": "0.8.10
|
|
7
|
+
"@cryptorubic/core": "0.8.10",
|
|
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.8.10
|
|
14
|
+
"@cryptorubic/tron-types": "0.8.10",
|
|
15
15
|
"bitcoin-address-validation": "^2.2.3",
|
|
16
16
|
"axios": "0.27.2",
|
|
17
17
|
"crc-32": "^1.2.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Abi, MulticallResponse, MulticallParameters } from 'viem';
|
|
2
2
|
import { AbstractAdapter } from './abstract-adapter';
|
|
3
|
-
import { AddressLookupTableAccount, Connection,
|
|
3
|
+
import { AddressLookupTableAccount, Connection, TransactionInstruction, VersionedTransaction } from '@solana/web3.js';
|
|
4
4
|
import { HttpClient, ICustomLogger, PriceTokenAmount, SolanaBlockchainName, Token, TokenAmount } from '@cryptorubic/core';
|
|
5
5
|
import { EvmTransactionConfig } from '../../utils/models/evm-transaction-config';
|
|
6
6
|
import BigNumber from 'bignumber.js';
|
|
@@ -27,8 +27,4 @@ export declare class SolanaAdapter extends AbstractAdapter<Connection, Connectio
|
|
|
27
27
|
parseRawInstruction(rawInstruction: SolanaRawInstruction[], dataFormat: BufferEncoding): TransactionInstruction[];
|
|
28
28
|
parseLUTAddresses(lookupTableAddresses: string[]): Promise<AddressLookupTableAccount[]>;
|
|
29
29
|
createVersionedTransaction(instructions: TransactionInstruction[], walletAddress: string, addressLookupTableAccounts?: AddressLookupTableAccount[]): Promise<VersionedTransaction>;
|
|
30
|
-
createTransferData(fromToken: PriceTokenAmount, walletAddress: string, receiver: string, convertToVersionedTx: boolean): Promise<Transaction | VersionedTransaction>;
|
|
31
|
-
createNativeTransfer(fromAddress: PublicKey, toAddress: PublicKey, fromWeiAmount: string): Transaction;
|
|
32
|
-
createTokenTransfer(fromAddress: PublicKey, toAddress: PublicKey, fromTokenAddress: string, fromWeiAmount: string): Promise<Transaction>;
|
|
33
|
-
getLatestBlockhash(): Promise<string>;
|
|
34
30
|
}
|
|
@@ -113,7 +113,7 @@ class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
113
113
|
return accounts.filter((v) => !!v);
|
|
114
114
|
}
|
|
115
115
|
async createVersionedTransaction(instructions, walletAddress, addressLookupTableAccounts = []) {
|
|
116
|
-
const blockhash = await this.getLatestBlockhash();
|
|
116
|
+
const { blockhash } = await this.public.getLatestBlockhash();
|
|
117
117
|
const message = new web3_js_1.TransactionMessage({
|
|
118
118
|
instructions,
|
|
119
119
|
payerKey: new web3_js_1.PublicKey(walletAddress),
|
|
@@ -121,49 +121,5 @@ class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
121
121
|
}).compileToV0Message(addressLookupTableAccounts);
|
|
122
122
|
return new web3_js_1.VersionedTransaction(message);
|
|
123
123
|
}
|
|
124
|
-
async createTransferData(fromToken, walletAddress, receiver, convertToVersionedTx) {
|
|
125
|
-
const fromAddress = new web3_js_1.PublicKey(walletAddress);
|
|
126
|
-
const toAddress = new web3_js_1.PublicKey(receiver);
|
|
127
|
-
this.logger?.customLog('111111111111111', [fromAddress, toAddress]);
|
|
128
|
-
const transaction = fromToken.isNative
|
|
129
|
-
? this.createNativeTransfer(fromAddress, toAddress, fromToken.stringWeiAmount)
|
|
130
|
-
: await this.createTokenTransfer(fromAddress, toAddress, fromToken.address, fromToken.stringWeiAmount);
|
|
131
|
-
this.logger?.customLog('22222222222222222');
|
|
132
|
-
if (convertToVersionedTx) {
|
|
133
|
-
const blockhash = await this.getLatestBlockhash();
|
|
134
|
-
const message = new web3_js_1.TransactionMessage({
|
|
135
|
-
payerKey: fromAddress,
|
|
136
|
-
recentBlockhash: blockhash,
|
|
137
|
-
instructions: transaction.instructions
|
|
138
|
-
}).compileToV0Message();
|
|
139
|
-
return new web3_js_1.VersionedTransaction(message);
|
|
140
|
-
}
|
|
141
|
-
return transaction;
|
|
142
|
-
}
|
|
143
|
-
createNativeTransfer(fromAddress, toAddress, fromWeiAmount) {
|
|
144
|
-
return new web3_js_1.Transaction().add(web3_js_1.SystemProgram.transfer({
|
|
145
|
-
fromPubkey: fromAddress,
|
|
146
|
-
toPubkey: toAddress,
|
|
147
|
-
lamports: BigInt(fromWeiAmount)
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
async createTokenTransfer(fromAddress, toAddress, fromTokenAddress, fromWeiAmount) {
|
|
151
|
-
const mintTokenAccount = new web3_js_1.PublicKey(fromTokenAddress);
|
|
152
|
-
const [fromATA, toATA] = await Promise.all([
|
|
153
|
-
(0, spl_token_1.getAssociatedTokenAddress)(mintTokenAccount, fromAddress),
|
|
154
|
-
(0, spl_token_1.getAssociatedTokenAddress)(mintTokenAccount, toAddress)
|
|
155
|
-
]);
|
|
156
|
-
const transaction = new web3_js_1.Transaction();
|
|
157
|
-
const receiverAccountInfo = this.public.getAccountInfo(toATA);
|
|
158
|
-
if (!receiverAccountInfo) {
|
|
159
|
-
transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(fromAddress, toATA, toAddress, mintTokenAccount));
|
|
160
|
-
}
|
|
161
|
-
transaction.add((0, spl_token_1.createTransferInstruction)(fromATA, toATA, fromAddress, BigInt(fromWeiAmount)));
|
|
162
|
-
return transaction;
|
|
163
|
-
}
|
|
164
|
-
async getLatestBlockhash() {
|
|
165
|
-
const { blockhash } = await this.public.getLatestBlockhash();
|
|
166
|
-
return blockhash;
|
|
167
|
-
}
|
|
168
124
|
}
|
|
169
125
|
exports.SolanaAdapter = SolanaAdapter;
|
|
@@ -610,25 +610,6 @@ exports.viemConfig = {
|
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
}),
|
|
613
|
-
ETHW: (0, viem_1.defineChain)({
|
|
614
|
-
blockExplorers: {
|
|
615
|
-
default: {
|
|
616
|
-
apiUrl: 'https://www.oklink.com/en/ethw/',
|
|
617
|
-
name: 'ETHW Explorer',
|
|
618
|
-
url: 'https://www.oklink.com/en/ethw/'
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
id: 10001,
|
|
622
|
-
name: 'Ethereum POW',
|
|
623
|
-
nativeCurrency: { decimals: 18, name: 'Ethereum PoW', symbol: 'ETHW' },
|
|
624
|
-
rpcUrls: { default: { http: ['https://mainnet.ethereumpow.org'] } },
|
|
625
|
-
testnet: false,
|
|
626
|
-
contracts: {
|
|
627
|
-
multicall3: {
|
|
628
|
-
address: '0xcA11bde05977b3631167028862bE2a173976CA11'
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}),
|
|
632
613
|
OPTIMISM: (0, viem_1.defineChain)({
|
|
633
614
|
blockExplorers: {
|
|
634
615
|
default: {
|
|
@@ -1420,5 +1401,32 @@ exports.viemConfig = {
|
|
|
1420
1401
|
address: '0xcA11bde05977b3631167028862bE2a173976CA11'
|
|
1421
1402
|
}
|
|
1422
1403
|
}
|
|
1404
|
+
}),
|
|
1405
|
+
HEMI: (0, viem_1.defineChain)({
|
|
1406
|
+
id: 43111,
|
|
1407
|
+
name: 'Hemi',
|
|
1408
|
+
network: 'Hemi',
|
|
1409
|
+
nativeCurrency: {
|
|
1410
|
+
name: 'Ether',
|
|
1411
|
+
symbol: 'ETH',
|
|
1412
|
+
decimals: 18
|
|
1413
|
+
},
|
|
1414
|
+
rpcUrls: {
|
|
1415
|
+
default: {
|
|
1416
|
+
http: ['https://rpc.hemi.network/rpc']
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
blockExplorers: {
|
|
1420
|
+
default: {
|
|
1421
|
+
name: 'blockscout',
|
|
1422
|
+
url: 'https://explorer.hemi.xyz'
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
testnet: false,
|
|
1426
|
+
contracts: {
|
|
1427
|
+
multicall3: {
|
|
1428
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11'
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1423
1431
|
})
|
|
1424
1432
|
};
|
|
@@ -26,7 +26,6 @@ exports.viemBlockchainMapping = {
|
|
|
26
26
|
[core_1.BLOCKCHAIN_NAME.BOBA]: chains_1.boba,
|
|
27
27
|
[core_1.BLOCKCHAIN_NAME.BOBA_BSC]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.BOBA_BSC],
|
|
28
28
|
[core_1.BLOCKCHAIN_NAME.ASTAR_EVM]: chains_1.astar,
|
|
29
|
-
[core_1.BLOCKCHAIN_NAME.ETHEREUM_POW]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.ETHEREUM_POW],
|
|
30
29
|
[core_1.BLOCKCHAIN_NAME.KAVA]: chains_1.kava,
|
|
31
30
|
[core_1.BLOCKCHAIN_NAME.BITGERT]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.BITGERT],
|
|
32
31
|
[core_1.BLOCKCHAIN_NAME.OASIS]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.OASIS],
|
|
@@ -76,5 +75,6 @@ exports.viemBlockchainMapping = {
|
|
|
76
75
|
[core_1.BLOCKCHAIN_NAME.SONEIUM]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.SONEIUM],
|
|
77
76
|
[core_1.BLOCKCHAIN_NAME.WANCHAIN]: chains_1.wanchain,
|
|
78
77
|
[core_1.BLOCKCHAIN_NAME.UNICHAIN]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.UNICHAIN],
|
|
79
|
-
[core_1.BLOCKCHAIN_NAME.MORPH]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MORPH] // viem Morph config without multicall address
|
|
78
|
+
[core_1.BLOCKCHAIN_NAME.MORPH]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.MORPH], // viem Morph config without multicall address
|
|
79
|
+
[core_1.BLOCKCHAIN_NAME.HEMI]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.HEMI]
|
|
80
80
|
};
|
|
@@ -7,7 +7,6 @@ export declare const changeNowEvmSupportedBlockchain: {
|
|
|
7
7
|
AVALANCHE: string;
|
|
8
8
|
CELO: string;
|
|
9
9
|
ETHEREUM_CLASSIC: string;
|
|
10
|
-
ETHW: string;
|
|
11
10
|
FANTOM: string;
|
|
12
11
|
IOTEX: string;
|
|
13
12
|
KLAYTN: string;
|
|
@@ -108,7 +107,6 @@ export declare const changenowApiBlockchain: {
|
|
|
108
107
|
AVALANCHE: string;
|
|
109
108
|
CELO: string;
|
|
110
109
|
ETHEREUM_CLASSIC: string;
|
|
111
|
-
ETHW: string;
|
|
112
110
|
FANTOM: string;
|
|
113
111
|
IOTEX: string;
|
|
114
112
|
KLAYTN: string;
|
|
@@ -11,7 +11,6 @@ exports.changeNowEvmSupportedBlockchain = {
|
|
|
11
11
|
[core_1.BLOCKCHAIN_NAME.AVALANCHE]: 'avaxc',
|
|
12
12
|
[core_1.BLOCKCHAIN_NAME.CELO]: 'celo',
|
|
13
13
|
[core_1.BLOCKCHAIN_NAME.ETHEREUM_CLASSIC]: 'etc',
|
|
14
|
-
[core_1.BLOCKCHAIN_NAME.ETHEREUM_POW]: 'ethw',
|
|
15
14
|
[core_1.BLOCKCHAIN_NAME.FANTOM]: 'ftm',
|
|
16
15
|
[core_1.BLOCKCHAIN_NAME.IOTEX]: 'iotx',
|
|
17
16
|
[core_1.BLOCKCHAIN_NAME.KLAYTN]: 'klay',
|