-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: replace subscan API * adjustments * last fixes * fix lint errors * remove console.log * fix build error * rename subscan api consts
- Loading branch information
Showing
19 changed files
with
283 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
WS_ROCOCO_CORETIME_CHAIN="WSS endpoint of the coretime chain on Rococo" | ||
WS_KUSAMA_CORETIME_CHAIN="WSS endpoint of the coretime chain on Kusama" | ||
WS_WESTEND_CORETIME_CHAIN="WSS endpiontof the coretime chain on Westend" | ||
WS_WESTEND_CORETIME_CHAIN="WSS endpiont of the coretime chain on Westend" | ||
|
||
WS_ROCOCO_RELAY_CHAIN="WSS endpoint of the coretime relay chain - Rococo" | ||
WS_KUSAMA_RELAY_CHAIN="WSS endpoint of the coretime relay chain - Kusama" | ||
WS_WESTEND_RELAY_CHAIN="WSS endpoint of the coretime relay chain - Westend" | ||
|
||
WS_REGIONX_COCOS_CHAIN="WSS endpoint of the regionx chain" | ||
|
||
SUBSCAN_CORETIME_ROCOCO_API="API endpoint for Rococo Coretime" | ||
SUBSCAN_CORETIME_KUSAMA_API="API endpoint for Kusama Coretime" | ||
SUBSCAN_CORETIME_WESTEND_API="API endpoint for Westend Coretime" | ||
ROCOCO_CORETIME_INDEXER="Subquery indexer for Rococo Coretime" | ||
KUSAMA_CORETIME_INDEXER="Subquery indexer for Kusama Coretime" | ||
|
||
ROCOCO_CORETIME_DICT="Subquery dictionary for Rococo Coretime" | ||
KUSAMA_CORETIME_DICT="Subquery dictionary for Kusama Coretime" | ||
|
||
EXPERIMENTAL=false |
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,46 +1,65 @@ | ||
import { SUBSCAN_CORETIME_API } from '@/consts'; | ||
import { Address, NetworkType } from '@/models'; | ||
import { API_CORETIME_DICT, API_CORETIME_INDEXER } from '@/consts'; | ||
import { Address, ApiResponse, NetworkType } from '@/models'; | ||
|
||
import { fetchGraphql } from '../utils/fetchGraphql'; | ||
|
||
export const fetchPurchaseHistoryData = async ( | ||
network: NetworkType, | ||
regionBegin: number, | ||
page: number, | ||
row: number | ||
) => { | ||
const res = await fetch( | ||
`${SUBSCAN_CORETIME_API[network]}/api/scan/broker/purchased`, | ||
{ | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
region_begin: regionBegin, | ||
row, | ||
page, | ||
}), | ||
} | ||
); | ||
return res; | ||
after: string | null, | ||
orderBy = 'HEIGHT_DESC' | ||
): Promise<ApiResponse> => { | ||
const query = `{ | ||
purchases( | ||
after: ${after} | ||
filter: {begin: {equalTo: ${regionBegin}}} | ||
orderBy: ${orderBy} | ||
) { | ||
nodes { | ||
account | ||
core | ||
extrinsicId | ||
height | ||
price | ||
purchaseType | ||
timestamp | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
totalCount | ||
} | ||
}`; | ||
return fetchGraphql(API_CORETIME_INDEXER[network], query); | ||
}; | ||
|
||
export const fetchAccountExtrinsics = async ( | ||
network: NetworkType, | ||
address: Address, | ||
page: number, | ||
row: number | ||
) => { | ||
const res = await fetch( | ||
`${SUBSCAN_CORETIME_API[network]}/api/v2/scan/extrinsics`, | ||
{ | ||
method: 'POST', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
address, | ||
row, | ||
page, | ||
}), | ||
} | ||
); | ||
return res; | ||
after: string | null, | ||
orderBy = 'BLOCK_HEIGHT_DESC' | ||
): Promise<ApiResponse> => { | ||
const query = `{ | ||
extrinsics( | ||
after: ${after} | ||
filter: {signer: {equalTo: "${address}"}} | ||
orderBy: ${orderBy} | ||
) { | ||
nodes { | ||
id | ||
module | ||
call | ||
blockHeight | ||
success | ||
timestamp | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
totalCount | ||
} | ||
}`; | ||
return fetchGraphql(API_CORETIME_DICT[network], query); | ||
}; |
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
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.