-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from spacemeshos/v2alpha_v2beta
v2alpha -> v2beta
- Loading branch information
Showing
6 changed files
with
56 additions
and
21 deletions.
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
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
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
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 |
---|---|---|
@@ -1,11 +1,30 @@ | ||
import fetchJSON from '../../utils/fetchJSON'; | ||
import getFetchAll from '../getFetchAll'; | ||
import { parseResponse } from '../schemas/error'; | ||
import { SmesherStatesResponseSchema } from '../schemas/smesherStates'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const fetchSmesherStates = (rpc: string) => | ||
fetchJSON(`${rpc}/spacemesh.v2alpha1.SmeshingIdentitiesService/States`, { | ||
method: 'POST', | ||
}) | ||
const fetchSmesherStatesChunk = ( | ||
rpc: string, | ||
limit: number, | ||
offset: number | ||
) => { | ||
const params = new URLSearchParams({ | ||
limit: limit.toString(), | ||
offset: offset.toString(), | ||
}); | ||
|
||
return fetchJSON( | ||
`${rpc}/spacemesh.v2beta1.SmeshingIdentitiesService/States?${params}`, | ||
{ | ||
method: 'GET', | ||
} | ||
) | ||
.then(parseResponse(SmesherStatesResponseSchema)) | ||
.then((res) => res.identities); | ||
}; | ||
|
||
export const fetchSmesherStates = getFetchAll((rpc, _, limit, offset) => | ||
fetchSmesherStatesChunk(rpc, limit, offset) | ||
); | ||
|
||
export default fetchSmesherStates; |