@@ -6,7 +6,7 @@ import RPC from "foundry-rpc";
66import { SDK } from "../../sdk/src" ;
77import { H512 , PlatformAddress , U64 } from "../../sdk/src/core/classes" ;
88
9- import { toHex } from "codechain-primitives/lib" ;
9+ import { toHex } from "codechain-primitives/lib" ;
1010import { HANDLER_ID } from "./index" ;
1111import {
1212 decodeH512 ,
@@ -22,16 +22,18 @@ export async function getUndelegatedCCS(
2222 address : PlatformAddressValue ,
2323 blockNumber ?: number
2424) : Promise < U64 > {
25- const data = await rpc . engine . getCustomActionData (
26- { handlerId : HANDLER_ID ,
27- bytes : `0x${ toHex ( RLP . encode ( [
28- "Account" ,
29- PlatformAddress . ensure ( address )
30- . getAccountId ( )
31- . toEncodeObject ( )
32- ] ) ) } `,
33- blockNumber }
34- ) ;
25+ const data = await rpc . engine . getCustomActionData ( {
26+ handlerId : HANDLER_ID ,
27+ bytes : `0x${ toHex (
28+ RLP . encode ( [
29+ "Account" ,
30+ PlatformAddress . ensure ( address )
31+ . getAccountId ( )
32+ . toEncodeObject ( )
33+ ] )
34+ ) } `,
35+ blockNumber
36+ } ) ;
3537 if ( data == null ) {
3638 return new U64 ( 0 ) ;
3739 }
@@ -43,11 +45,11 @@ export async function getCCSHolders(
4345 sdk : SDK ,
4446 blockNumber ?: number
4547) : Promise < PlatformAddress [ ] > {
46- const data = await rpc . engine . getCustomActionData (
47- { handlerId : HANDLER_ID ,
48- bytes : `0x${ toHex ( RLP . encode ( [ "StakeholderAddresses" ] ) ) } ` ,
49- blockNumber }
50- ) ;
48+ const data = await rpc . engine . getCustomActionData ( {
49+ handlerId : HANDLER_ID ,
50+ bytes : `0x${ toHex ( RLP . encode ( [ "StakeholderAddresses" ] ) ) } ` ,
51+ blockNumber
52+ } ) ;
5153 if ( data == null ) {
5254 throw Error ( "Expected non-null value, but got a null" ) ;
5355 }
@@ -70,11 +72,13 @@ export async function getDelegations(
7072 delegator : PlatformAddress ,
7173 blockNumber ?: number
7274) : Promise < Delegation [ ] > {
73- const data = await rpc . engine . getCustomActionData (
74- { handlerId : HANDLER_ID ,
75- bytes : `0x${ toHex ( RLP . encode ( [ "Delegation" , delegator . accountId . toEncodeObject ( ) ] ) ) } ` ,
76- blockNumber}
77- ) ;
75+ const data = await rpc . engine . getCustomActionData ( {
76+ handlerId : HANDLER_ID ,
77+ bytes : `0x${ toHex (
78+ RLP . encode ( [ "Delegation" , delegator . accountId . toEncodeObject ( ) ] )
79+ ) } `,
80+ blockNumber
81+ } ) ;
7882 if ( data == null ) {
7983 return [ ] ;
8084 }
@@ -106,11 +110,11 @@ export async function getCandidates(
106110 rpc : RPC ,
107111 blockNumber ?: number
108112) : Promise < Candidate [ ] > {
109- const data = await rpc . engine . getCustomActionData (
110- { handlerId : HANDLER_ID ,
111- bytes : `0x${ toHex ( RLP . encode ( [ "Candidates" ] ) ) } ` ,
112- blockNumber}
113- ) ;
113+ const data = await rpc . engine . getCustomActionData ( {
114+ handlerId : HANDLER_ID ,
115+ bytes : `0x${ toHex ( RLP . encode ( [ "Candidates" ] ) ) } ` ,
116+ blockNumber
117+ } ) ;
114118 if ( data == null ) {
115119 return [ ] ;
116120 }
@@ -145,9 +149,9 @@ export async function getJailed(
145149) : Promise < Prisoner [ ] > {
146150 const data = await rpc . engine . getCustomActionData ( {
147151 handlerId : HANDLER_ID ,
148- bytes : `0x${ toHex ( RLP . encode ( [ "Jail" ] ) ) } ` ,
149- blockNumber}
150- ) ;
152+ bytes : `0x${ toHex ( RLP . encode ( [ "Jail" ] ) ) } ` ,
153+ blockNumber
154+ } ) ;
151155 if ( data == null ) {
152156 return [ ] ;
153157 }
@@ -172,11 +176,11 @@ export async function getBanned(
172176 sdk : SDK ,
173177 blockNumber ?: number
174178) : Promise < PlatformAddress [ ] > {
175- const data = await rpc . engine . getCustomActionData (
176- { handlerId : HANDLER_ID ,
177- bytes : `0x${ toHex ( RLP . encode ( [ "Banned" ] ) ) } ` ,
178- blockNumber}
179- ) ;
179+ const data = await rpc . engine . getCustomActionData ( {
180+ handlerId : HANDLER_ID ,
181+ bytes : `0x${ toHex ( RLP . encode ( [ "Banned" ] ) ) } ` ,
182+ blockNumber
183+ } ) ;
180184 if ( data == null ) {
181185 return [ ] ;
182186 }
@@ -204,11 +208,11 @@ export async function getIntermediateRewards(
204208 sdk : SDK ,
205209 blockNumber ?: number
206210) : Promise < IntermediateRewards > {
207- const data = await rpc . engine . getCustomActionData (
208- { handlerId : HANDLER_ID ,
209- bytes : `0x${ toHex ( RLP . encode ( [ "IntermediateRewards" ] ) ) } ` ,
210- blockNumber }
211- ) ;
211+ const data = await rpc . engine . getCustomActionData ( {
212+ handlerId : HANDLER_ID ,
213+ bytes : `0x${ toHex ( RLP . encode ( [ "IntermediateRewards" ] ) ) } ` ,
214+ blockNumber
215+ } ) ;
212216 if ( data == null ) {
213217 return {
214218 previous : [ ] ,
@@ -254,11 +258,11 @@ export async function getValidators(
254258 sdk : SDK ,
255259 blockNumber ?: number
256260) : Promise < Validator [ ] > {
257- const data = await rpc . engine . getCustomActionData (
258- { handlerId : HANDLER_ID ,
259- bytes : `0x${ toHex ( RLP . encode ( [ "Validators" ] ) ) } ` ,
260- blockNumber}
261- ) ;
261+ const data = await rpc . engine . getCustomActionData ( {
262+ handlerId : HANDLER_ID ,
263+ bytes : `0x${ toHex ( RLP . encode ( [ "Validators" ] ) ) } ` ,
264+ blockNumber
265+ } ) ;
262266 if ( data == null ) {
263267 return [ ] ;
264268 }
0 commit comments