File tree 2 files changed +27
-3
lines changed
2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { HexString } from 'types' ;
2
2
import { GearApi } from './GearApi' ;
3
- import { u64 } from '@polkadot/types-codec' ;
4
3
import { BuiltinQueryIdError } from './errors' ;
5
4
6
5
export class GearBuiltin {
7
6
constructor ( private _api : GearApi ) { }
8
7
9
- async queryId ( builtinId : u64 ) : Promise < HexString > {
8
+ async queryId ( builtinId : number | bigint ) : Promise < HexString > {
10
9
try {
11
- const result = await this . _api . rpc . gearBuiltin . queryId ( builtinId ) ;
10
+ const valueId = this . _api . createType ( 'u64' , BigInt ( builtinId ) ) ;
11
+ const result = await this . _api . rpc . gearBuiltin . queryId ( valueId ) ;
12
12
return result . toHex ( ) ;
13
13
} catch ( err ) {
14
14
throw new BuiltinQueryIdError ( err . message ) ;
Original file line number Diff line number Diff line change
1
+ import { GearApi } from '../src' ;
2
+ import { sleep } from './utilsFunctions' ;
3
+ import { WS_ADDRESS } from './config' ;
4
+ import { BN } from '@polkadot/util' ;
5
+
6
+ const api = new GearApi ( { providerAddress : WS_ADDRESS } ) ;
7
+
8
+ beforeAll ( async ( ) => {
9
+ await api . isReadyOrError ;
10
+ } ) ;
11
+
12
+ afterAll ( async ( ) => {
13
+ await api . disconnect ( ) ;
14
+ await sleep ( 1000 ) ;
15
+ } ) ;
16
+
17
+ describe ( 'Query id' , ( ) => {
18
+ test ( 'Random query id' , async ( ) => {
19
+ const builtinId = Math . floor ( Math . random ( ) * Number . MAX_SAFE_INTEGER ) ;
20
+
21
+ const id = await api . builtin . queryId ( builtinId ) ;
22
+ expect ( id . length ) . toBe ( 66 ) ;
23
+ } ) ;
24
+ } ) ;
You can’t perform that action at this time.
0 commit comments