Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit af40ab2

Browse files
authored
Upgrade axios and web3 (#77)
* chore: upgrade deps axios and web3. * chore: bump version.
1 parent 8484da6 commit af40ab2

9 files changed

Lines changed: 362 additions & 1503 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"url": "https://github.com/AstarNetwork/astar.js.git"
1313
},
1414
"sideEffects": false,
15-
"version": "0.2.8",
15+
"version": "0.2.9",
1616
"workspaces": [
1717
"packages/*",
1818
"examples/*"

‎packages/api-derive/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-api-derive",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "Astar JS API",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",

‎packages/api/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-api",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "Astar JS API",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",

‎packages/api/src/index.spec.ts‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { options } from '@astar-network/astar-api';
22
import { ApiPromise, WsProvider } from '@polkadot/api';
33

4-
const getAddressEnum = (address: string) => ({ Evm: address });
5-
64
const endpoint = 'wss://shiden.api.onfinality.io/public-ws';
75
const provider = new WsProvider(endpoint);
86

@@ -12,21 +10,12 @@ describe('astar-api', () => {
1210
await api.isReadyOrError;
1311
});
1412

15-
test('api.query.dappsStaking.contractEraStake.entries', async (): Promise<void> => {
16-
const address = '0x072416b9df2382a62Df34956DffB7B0aDdf668F9';
13+
test('api.query.dappStaking.contractStake', async (): Promise<void> => {
1714
if (api === null) {
1815
fail('API is not initialized');
1916
}
20-
const stakingByEra = await api.query.dappsStaking.contractEraStake.entries(getAddressEnum(address));
21-
// stakingByEra.forEach(([era, stakeInfo]) => {
22-
stakingByEra.forEach(([_, stakeInfo]) => {
23-
// console.log({
24-
// era: (era.toHuman() as any[])[1],
25-
// stakeInfo: `${Object.keys(stakeInfo.unwrap().stakers.toHuman()).length} stakers`
26-
// });
27-
// expect(era).toBeInstanceOf(StorageKey);
28-
expect(stakeInfo).not.toBeNull();
29-
});
17+
const stakingByEra = await api.query.dappStaking.contractStake(0);
18+
expect(stakingByEra).not.toBeNull();
3019
});
3120

3221
afterAll(async () => {

‎packages/sdk-core/package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-sdk-core",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "the core for astar SDK",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",
@@ -25,10 +25,10 @@
2525
"@ethersproject/bignumber": "^5.6.2",
2626
"@polkadot/util": "^12.3.2",
2727
"@polkadot/util-crypto": "^12.3.2",
28-
"axios": "^0.24.0",
28+
"axios": "^1.6.8",
2929
"bn.js": "^5.2.1",
3030
"ethers": "^5.6.9",
31-
"web3": "^1.7.3"
31+
"web3": "^4.7.0"
3232
},
3333
"devDependencies": {
3434
"@types/jest": "^28.1.1",

‎packages/sdk-core/src/modules/gas-api/utils/index.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import axios from 'axios';
22
import { BN } from '@polkadot/util';
33
import { ethers } from 'ethers';
44
import Web3 from 'web3';
5-
import { TransactionConfig } from 'web3-eth';
5+
import { TransactionCall } from 'web3-types';
66
import { ApiGasNow, GasPrice, GAS_API_URL } from '../index';
77
import { astarChain } from '../../config';
88

99
export const getEvmGas = async (web3: Web3, selectedGasPrice: string): Promise<string> => {
1010
const gasPriceFallback = await web3.eth.getGasPrice();
11-
const gasPrice = selectedGasPrice !== '0' ? selectedGasPrice : gasPriceFallback;
11+
const gasPrice = selectedGasPrice !== '0' ? selectedGasPrice : gasPriceFallback.toString();
1212
return gasPrice;
1313
};
1414

@@ -27,7 +27,7 @@ export const getEvmGasCost = async ({ isNativeToken,
2727
value: string;
2828
encodedData?: string;
2929
}): Promise<GasPrice> => {
30-
const tx: TransactionConfig = isNativeToken
30+
const tx: TransactionCall = isNativeToken
3131
? {
3232
from: fromAddress,
3333
to: toAddress,
@@ -42,7 +42,7 @@ export const getEvmGasCost = async ({ isNativeToken,
4242
};
4343

4444
const numEstimatedGas = await web3.eth.estimateGas(tx);
45-
const estimatedGas = new BN(numEstimatedGas);
45+
const estimatedGas = new BN(numEstimatedGas.toString());
4646
const data = {
4747
...evmGasPrice,
4848
slow: ethers.utils.formatEther(estimatedGas.mul(new BN(evmGasPrice.slow)).toString()),

‎packages/type-definitions/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-type-definitions",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "Polkadot.js type definitions for astar Network",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",

‎packages/types/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-types",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "Polkadot.js type definitions for Astar Network",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",

0 commit comments

Comments
 (0)