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

Commit

Permalink
Merge branch 'main' into add_FinalRewards+FinalUsedFee
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyji-dev authored Jul 7, 2024
2 parents 3f0e8e5 + 0669d89 commit 1c6b8db
Show file tree
Hide file tree
Showing 9 changed files with 362 additions and 1,503 deletions.
2 changes: 1 addition & 1 deletion .123trigger
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0.1.4
0.1.50.1.80.1.80.1.90.1.90.1.90.1.100.1.110.1.110.1.110.1.12
0.1.120.1.130.1.130.1.130.1.130.1.140.1.140.1.150.1.150.1.160.1.160.1.170.1.170.1.170.1.170.1.190.1.190.2.20.2.30.2.40.2.40.2.40.2.50.2.50.2.50.2.60.2.60.2.70.2.8
0.1.120.1.130.1.130.1.130.1.130.1.140.1.140.1.150.1.150.1.160.1.160.1.170.1.170.1.170.1.170.1.190.1.190.2.20.2.30.2.40.2.40.2.40.2.50.2.50.2.50.2.60.2.60.2.70.2.80.2.9
2 changes: 1 addition & 1 deletion packages/api-derive/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astar-network/astar-api-derive",
"version": "0.2.8",
"version": "0.2.9",
"description": "Astar JS API",
"main": "index.js",
"author": "Astar Network <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astar-network/astar-api",
"version": "0.2.8",
"version": "0.2.9",
"description": "Astar JS API",
"main": "index.js",
"author": "Astar Network <[email protected]>",
Expand Down
17 changes: 3 additions & 14 deletions packages/api/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { options } from '@astar-network/astar-api';
import { ApiPromise, WsProvider } from '@polkadot/api';

const getAddressEnum = (address: string) => ({ Evm: address });

const endpoint = 'wss://shiden.api.onfinality.io/public-ws';
const provider = new WsProvider(endpoint);

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

test('api.query.dappsStaking.contractEraStake.entries', async (): Promise<void> => {
const address = '0x072416b9df2382a62Df34956DffB7B0aDdf668F9';
test('api.query.dappStaking.contractStake', async (): Promise<void> => {
if (api === null) {
fail('API is not initialized');
}
const stakingByEra = await api.query.dappsStaking.contractEraStake.entries(getAddressEnum(address));
// stakingByEra.forEach(([era, stakeInfo]) => {
stakingByEra.forEach(([_, stakeInfo]) => {
// console.log({
// era: (era.toHuman() as any[])[1],
// stakeInfo: `${Object.keys(stakeInfo.unwrap().stakers.toHuman()).length} stakers`
// });
// expect(era).toBeInstanceOf(StorageKey);
expect(stakeInfo).not.toBeNull();
});
const stakingByEra = await api.query.dappStaking.contractStake(0);
expect(stakingByEra).not.toBeNull();
});

afterAll(async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astar-network/astar-sdk-core",
"version": "0.2.8",
"version": "0.2.9",
"description": "the core for astar SDK",
"main": "index.js",
"author": "Astar Network <[email protected]>",
Expand All @@ -25,10 +25,10 @@
"@ethersproject/bignumber": "^5.6.2",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"axios": "^0.24.0",
"axios": "^1.6.8",
"bn.js": "^5.2.1",
"ethers": "^5.6.9",
"web3": "^1.7.3"
"web3": "^4.7.0"
},
"devDependencies": {
"@types/jest": "^28.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-core/src/modules/gas-api/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import axios from 'axios';
import { BN } from '@polkadot/util';
import { ethers } from 'ethers';
import Web3 from 'web3';
import { TransactionConfig } from 'web3-eth';
import { TransactionCall } from 'web3-types';
import { ApiGasNow, GasPrice, GAS_API_URL } from '../index';
import { astarChain } from '../../config';

export const getEvmGas = async (web3: Web3, selectedGasPrice: string): Promise<string> => {
const gasPriceFallback = await web3.eth.getGasPrice();
const gasPrice = selectedGasPrice !== '0' ? selectedGasPrice : gasPriceFallback;
const gasPrice = selectedGasPrice !== '0' ? selectedGasPrice : gasPriceFallback.toString();
return gasPrice;
};

Expand All @@ -27,7 +27,7 @@ export const getEvmGasCost = async ({ isNativeToken,
value: string;
encodedData?: string;
}): Promise<GasPrice> => {
const tx: TransactionConfig = isNativeToken
const tx: TransactionCall = isNativeToken
? {
from: fromAddress,
to: toAddress,
Expand All @@ -42,7 +42,7 @@ export const getEvmGasCost = async ({ isNativeToken,
};

const numEstimatedGas = await web3.eth.estimateGas(tx);
const estimatedGas = new BN(numEstimatedGas);
const estimatedGas = new BN(numEstimatedGas.toString());
const data = {
...evmGasPrice,
slow: ethers.utils.formatEther(estimatedGas.mul(new BN(evmGasPrice.slow)).toString()),
Expand Down
2 changes: 1 addition & 1 deletion packages/type-definitions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astar-network/astar-type-definitions",
"version": "0.2.8",
"version": "0.2.9",
"description": "Polkadot.js type definitions for astar Network",
"main": "index.js",
"author": "Astar Network <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@astar-network/astar-types",
"version": "0.2.8",
"version": "0.2.9",
"description": "Polkadot.js type definitions for Astar Network",
"main": "index.js",
"author": "Astar Network <[email protected]>",
Expand Down
Loading

0 comments on commit 1c6b8db

Please sign in to comment.