-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api) add support for
builtin
pallet (#1659)
- Loading branch information
Showing
5 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { HexString } from 'types'; | ||
import { GearApi } from './GearApi'; | ||
import { u64 } from '@polkadot/types-codec'; | ||
import { BuiltinQueryIdError } from './errors'; | ||
|
||
export class GearBuiltin { | ||
constructor(private _api: GearApi) {} | ||
|
||
async queryId(builtinId: u64): Promise<HexString> { | ||
try { | ||
const result = await this._api.rpc.gearBuiltin.queryId(builtinId); | ||
return result.toHex(); | ||
} catch (err) { | ||
throw new BuiltinQueryIdError(err.message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class BuiltinQueryIdError extends Error { | ||
name = 'BuiltInQueryIdError'; | ||
message = 'Unable to query builtin id'; | ||
|
||
constructor(message?: string) { | ||
super(); | ||
this.message = `${this.message}. ${message}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters