-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(idea/frontend): update test-balance and meta requests (#1679)
- Loading branch information
1 parent
08f3f25
commit 0e891be
Showing
29 changed files
with
125 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { NodeSection } from '@/entities/node'; | ||
import { NODES_API_URL } from '@/shared/config'; | ||
|
||
import { fetchMetadata, addMetadata } from './metadata'; | ||
import { PaginationParameters, PaginationResponse } from './types'; | ||
import { INFINITE_QUERY } from './consts'; | ||
|
||
const getNodes = () => fetch(NODES_API_URL).then((result) => result.json() as unknown as NodeSection[]); | ||
|
||
export { INFINITE_QUERY, getNodes, addMetadata, fetchMetadata }; | ||
export { INFINITE_QUERY, getNodes }; | ||
|
||
export type { PaginationParameters, PaginationResponse }; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,20 +1,12 @@ | ||
import { HexString } from '@gear-js/api'; | ||
|
||
import { rpcService } from '@/shared/services/rpcService'; | ||
|
||
const METHOD = { | ||
GET_TEST_BALANCE: 'testBalance.get', | ||
IS_TEST_BALANCE_AVAILABLE: 'testBalance.available', | ||
} as const; | ||
import { GENESIS } from '@/shared/config'; | ||
import { fetchWithGuard } from '@/shared/helpers'; | ||
import { FAUCET_API_URL } from './consts'; | ||
|
||
type GetTestBalanceParameters = { | ||
token: string; | ||
address: string; | ||
}; | ||
|
||
const getIsTestBalanceAvailable = (genesis: HexString) => | ||
rpcService.callRPC<boolean>(METHOD.IS_TEST_BALANCE_AVAILABLE, { genesis }); | ||
|
||
const getTestBalance = (params: GetTestBalanceParameters) => rpcService.callRPC(METHOD.GET_TEST_BALANCE, params); | ||
|
||
export { getIsTestBalanceAvailable, getTestBalance }; | ||
const getTestBalance = ({ token, address }: GetTestBalanceParameters) => | ||
fetchWithGuard(`${FAUCET_API_URL}/balance`, 'POST', { token, payload: { address, genesis: GENESIS.TESTNET } }); | ||
export { getTestBalance }; |
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,3 @@ | ||
const FAUCET_API_URL = import.meta.env.VITE_FAUCET_API_URL as string; | ||
|
||
export { FAUCET_API_URL }; |
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,4 +1,3 @@ | ||
import { ProgramBalance, BalanceDropdown, TransferBalanceModal } from './ui'; | ||
import { getIsTestBalanceAvailable } from './api'; | ||
|
||
export { ProgramBalance, BalanceDropdown, getIsTestBalanceAvailable, TransferBalanceModal }; | ||
export { ProgramBalance, BalanceDropdown, TransferBalanceModal }; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { addMetadata } from './requests'; |
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 '@polkadot/util/types'; | ||
|
||
import { METADATA_STORAGE_API_URL } from '@/shared/config'; | ||
import { fetchWithGuard } from '@/shared/helpers'; | ||
import { GetMetaResponse } from './types'; | ||
|
||
const fetchMetadata = (hash: HexString) => { | ||
const url = new URL(`${METADATA_STORAGE_API_URL}/meta`); | ||
url.searchParams.append('hash', hash); | ||
|
||
return fetchWithGuard<GetMetaResponse>(url, 'GET').then(({ hex }) => ({ result: { hex } })); | ||
}; | ||
|
||
const addMetadata = (hash: HexString, hex: HexString) => | ||
fetchWithGuard(`${METADATA_STORAGE_API_URL}/meta`, 'POST', { hash, hex }); | ||
|
||
export { addMetadata, fetchMetadata }; |
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 @@ | ||
import { HexString } from '@gear-js/api'; | ||
|
||
type GetMetaResponse = { | ||
hash: string; | ||
hex: HexString; | ||
hasState: boolean; | ||
}; | ||
|
||
export type { GetMetaResponse }; |
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,5 @@ | ||
const errorMessage = { | ||
metadataNotFound: 'MetadataNotFound', | ||
}; | ||
|
||
export { errorMessage }; |
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,5 +1,15 @@ | ||
import { useMetadata, useMetadataHash, useMetadataWithFile } from './hooks'; | ||
import { MetadataTable, MetadataPreview } from './ui'; | ||
import { isHumanTypesRepr, isState } from './utils'; | ||
import { addMetadata } from './api'; | ||
|
||
export { useMetadata, useMetadataHash, useMetadataWithFile, MetadataTable, MetadataPreview, isHumanTypesRepr, isState }; | ||
export { | ||
useMetadata, | ||
useMetadataHash, | ||
useMetadataWithFile, | ||
MetadataTable, | ||
MetadataPreview, | ||
isHumanTypesRepr, | ||
isState, | ||
addMetadata, | ||
}; |
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,8 +1,10 @@ | ||
const METHOD = { | ||
GET_EVENT: 'event.data', | ||
GET_EVENTS: 'event.all', | ||
ADD_SAILS: 'sails.add', | ||
GET_SAILS: 'sails.get', | ||
} as const; | ||
|
||
export { METHOD }; | ||
const errorMessage = { | ||
sailsIdlNotFound: 'SailsIdlNotFound', | ||
}; | ||
|
||
export { METHOD, errorMessage }; |
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
Oops, something went wrong.