@cryptorubic/web3 0.8.7 → 0.8.8
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/models/solana-web3-types.d.ts +9 -0
- package/src/lib/adapter/adapters/solana-adapter.d.ts +5 -1
- package/src/lib/adapter/adapters/solana-adapter.js +26 -0
- package/src/lib/adapter/constants/chain-configs/chain-configs.js +19 -0
- package/src/lib/adapter/constants/viem-blockchain-mapping.js +1 -0
- package/src/lib/utils/constants/changenow-api-blockchain.d.ts +2 -0
- package/src/lib/utils/constants/changenow-api-blockchain.js +1 -0
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptorubic/web3",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
6
|
"bignumber.js": "9.1.2",
|
|
7
|
-
"@cryptorubic/core": "0.8.
|
|
7
|
+
"@cryptorubic/core": "0.8.8",
|
|
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.
|
|
14
|
+
"@cryptorubic/tron-types": "0.8.8",
|
|
15
15
|
"bitcoin-address-validation": "^2.2.3",
|
|
16
16
|
"axios": "0.27.2",
|
|
17
17
|
"crc-32": "^1.2.2",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Abi, MulticallResponse, MulticallParameters } from 'viem';
|
|
2
2
|
import { AbstractAdapter } from './abstract-adapter';
|
|
3
|
-
import { Connection } from '@solana/web3.js';
|
|
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';
|
|
7
|
+
import { SolanaRawInstruction } from './models/solana-web3-types';
|
|
7
8
|
export declare const NATIVE_SOLANA_MINT_ADDRESS = "So11111111111111111111111111111111111111111";
|
|
8
9
|
export declare class SolanaAdapter extends AbstractAdapter<Connection, Connection, SolanaBlockchainName> {
|
|
9
10
|
private readonly httpClient;
|
|
@@ -23,4 +24,7 @@ export declare class SolanaAdapter extends AbstractAdapter<Connection, Connectio
|
|
|
23
24
|
*/
|
|
24
25
|
getTokensBalances(address: string, tokensAddresses: string[]): Promise<BigNumber[]>;
|
|
25
26
|
callForTokensInfo(tokenAddresses: string[] | ReadonlyArray<string>): Promise<Token<SolanaBlockchainName>[]>;
|
|
27
|
+
parseRawInstruction(rawInstruction: SolanaRawInstruction[], dataFormat: BufferEncoding): TransactionInstruction[];
|
|
28
|
+
parseLUTAddresses(lookupTableAddresses: string[]): Promise<AddressLookupTableAccount[]>;
|
|
29
|
+
createVersionedTransaction(instructions: TransactionInstruction[], walletAddress: string, addressLookupTableAccounts?: AddressLookupTableAccount[]): Promise<VersionedTransaction>;
|
|
26
30
|
}
|
|
@@ -95,5 +95,31 @@ class SolanaAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
95
95
|
tokens.splice(nativeTokenIndex, 0, nativeToken);
|
|
96
96
|
return tokens;
|
|
97
97
|
}
|
|
98
|
+
parseRawInstruction(rawInstruction, dataFormat) {
|
|
99
|
+
return rawInstruction.map((instruction) => {
|
|
100
|
+
return new web3_js_1.TransactionInstruction({
|
|
101
|
+
keys: instruction.keys.map((key) => ({
|
|
102
|
+
pubkey: new web3_js_1.PublicKey(key.pubkey),
|
|
103
|
+
isWritable: key.isWritable,
|
|
104
|
+
isSigner: key.isSigner
|
|
105
|
+
})),
|
|
106
|
+
data: Buffer.from(instruction.data, dataFormat),
|
|
107
|
+
programId: new web3_js_1.PublicKey(instruction.programId)
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async parseLUTAddresses(lookupTableAddresses) {
|
|
112
|
+
const accounts = await Promise.all(lookupTableAddresses.map((address) => this.public.getAddressLookupTable(new web3_js_1.PublicKey(address)).then((v) => v.value)));
|
|
113
|
+
return accounts.filter((v) => !!v);
|
|
114
|
+
}
|
|
115
|
+
async createVersionedTransaction(instructions, walletAddress, addressLookupTableAccounts = []) {
|
|
116
|
+
const { blockhash } = await this.public.getLatestBlockhash();
|
|
117
|
+
const message = new web3_js_1.TransactionMessage({
|
|
118
|
+
instructions,
|
|
119
|
+
payerKey: new web3_js_1.PublicKey(walletAddress),
|
|
120
|
+
recentBlockhash: blockhash
|
|
121
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
122
|
+
return new web3_js_1.VersionedTransaction(message);
|
|
123
|
+
}
|
|
98
124
|
}
|
|
99
125
|
exports.SolanaAdapter = SolanaAdapter;
|
|
@@ -610,6 +610,25 @@ 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
|
+
}),
|
|
613
632
|
OPTIMISM: (0, viem_1.defineChain)({
|
|
614
633
|
blockExplorers: {
|
|
615
634
|
default: {
|
|
@@ -26,6 +26,7 @@ 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],
|
|
29
30
|
[core_1.BLOCKCHAIN_NAME.KAVA]: chains_1.kava,
|
|
30
31
|
[core_1.BLOCKCHAIN_NAME.BITGERT]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.BITGERT],
|
|
31
32
|
[core_1.BLOCKCHAIN_NAME.OASIS]: chain_configs_1.viemConfig[core_1.BLOCKCHAIN_NAME.OASIS],
|
|
@@ -7,6 +7,7 @@ export declare const changeNowEvmSupportedBlockchain: {
|
|
|
7
7
|
AVALANCHE: string;
|
|
8
8
|
CELO: string;
|
|
9
9
|
ETHEREUM_CLASSIC: string;
|
|
10
|
+
ETHW: string;
|
|
10
11
|
FANTOM: string;
|
|
11
12
|
IOTEX: string;
|
|
12
13
|
KLAYTN: string;
|
|
@@ -107,6 +108,7 @@ export declare const changenowApiBlockchain: {
|
|
|
107
108
|
AVALANCHE: string;
|
|
108
109
|
CELO: string;
|
|
109
110
|
ETHEREUM_CLASSIC: string;
|
|
111
|
+
ETHW: string;
|
|
110
112
|
FANTOM: string;
|
|
111
113
|
IOTEX: string;
|
|
112
114
|
KLAYTN: string;
|
|
@@ -11,6 +11,7 @@ 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',
|
|
14
15
|
[core_1.BLOCKCHAIN_NAME.FANTOM]: 'ftm',
|
|
15
16
|
[core_1.BLOCKCHAIN_NAME.IOTEX]: 'iotx',
|
|
16
17
|
[core_1.BLOCKCHAIN_NAME.KLAYTN]: 'klay',
|