This repository was archived by the owner on Oct 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { ApiPromise , WsProvider } from '@polkadot/api' ;
2+ import { options } from '@astar-network/astar-api' ;
3+
4+ const getAddressEnum = ( address : string ) => ( { Evm : address } ) ;
5+ const address = '0x072416b9df2382a62Df34956DffB7B0aDdf668F9' ;
6+
7+ const endpoint = 'wss://shiden.api.onfinality.io/public-ws' ;
8+ // const endpoint = 'ws://localhost:9944';
9+ const provider = new WsProvider ( endpoint ) ;
10+
11+ describe ( 'astar-api-derive' , ( ) => {
12+ const api = new ApiPromise ( options ( { provider } ) ) ;
13+ beforeAll ( async ( ) => {
14+ await api . isReadyOrError ;
15+ } ) ;
16+
17+ test ( 'api.derive.stakers' , async ( ) : Promise < void > => {
18+ if ( api === null ) {
19+ fail ( 'API is not initialized' ) ;
20+ }
21+ const stakers = await api . derive . dappStaking . stakers ( getAddressEnum ( address ) ) ;
22+ // If you want top print the result nicely... Go ahead.
23+ // console.log({ stakers: stakers.map((s) => s.toHuman()) });
24+ stakers . forEach ( ( s ) => expect ( s . length ) . toBe ( 32 ) ) ;
25+ } ) ;
26+
27+ afterAll ( async ( ) => {
28+ await api . disconnect ( ) ;
29+ } ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments