Skip to content

Commit

Permalink
Order processor UI (#208)
Browse files Browse the repository at this point in the history
* wip: order processor ui

* updates

* Update src/pages/processor.tsx

* fix sidebar

* update order card

* restructure apis

* add cocos indexer to env

* fix timeago

* order pages

* hooks

* order details modal

* order processor table

* update fetching orders

* remove link to the extrinsic id

* show not processed orders only

* disable pages under secondary market on kusama

* center account links in purchase history table

* purchase type

* update parachain table

* fix contributed amount

* fix sidebar responsive

* fix: relay token for order rewards

* fix order id

---------

Co-authored-by: Sergej Sakac <[email protected]>
Co-authored-by: cuteolaf <[email protected]>
  • Loading branch information
3 people authored Aug 15, 2024
1 parent 7b32fac commit e9a80cb
Show file tree
Hide file tree
Showing 28 changed files with 822 additions and 233 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ WS_REGIONX_COCOS_CHAIN="WSS endpoint of the regionx chain"

ROCOCO_CORETIME_INDEXER="Subquery indexer for Rococo Coretime"
KUSAMA_CORETIME_INDEXER="Subquery indexer for Kusama Coretime"
COCOS_INDEXER="Subquery indexer for RegionX Cocos"

ROCOCO_CORETIME_DICT="Subquery dictionary for Rococo Coretime"
KUSAMA_CORETIME_DICT="Subquery dictionary for Kusama Coretime"
Expand Down
2 changes: 2 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const nextConfig = {
WS_KUSAMA_CORETIME_CHAIN: process.env.WS_KUSAMA_CORETIME_CHAIN || '',
WS_WESTEND_CORETIME_CHAIN: process.env.WS_WESTEND_CORETIME_CHAIN || '',

COCOS_INDEXER: process.env.COCOS_INDEXER || '',

ROCOCO_CORETIME_INDEXER: process.env.ROCOCO_CORETIME_INDEXER || '',
KUSAMA_CORETIME_INDEXER: process.env.KUSAMA_CORETIME_INDEXER || '',
SUBSCAN_CORETIME_WESTEND_INDEXER:
Expand Down
34 changes: 34 additions & 0 deletions src/apis/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { fetchGraphql } from '@/utils/fetchGraphql';

import { API_CORETIME_DICT } from '@/consts';
import { Address, ApiResponse, NetworkType } from '@/models';

export const fetchAccountExtrinsics = async (
network: NetworkType,
address: Address,
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);
};
151 changes: 3 additions & 148 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,148 +1,3 @@
import { API_CORETIME_DICT, API_CORETIME_INDEXER } from '@/consts';
import { Address, ApiResponse, NetworkType } from '@/models';

import { fetchGraphql } from '../utils/fetchGraphql';

export const fetchBurnInfo = async (
network: NetworkType
): Promise<ApiResponse> => {
const query = `{
stats {
nodes {
id
saleCycle
totalBurn
}
}
sales(
orderBy: HEIGHT_DESC,
first: 2
) {
nodes {
burn
}
}
}`;
return fetchGraphql(API_CORETIME_INDEXER[network], query);
};

export const fetchPurchaseHistoryData = async (
network: NetworkType,
regionBegin: number,
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 fetchSaleDetailsData = async (
network: NetworkType,
saleCycle: number,
after: string | null,
orderBy = 'HEIGHT_DESC'
): Promise<ApiResponse> => {
const query = `{
purchases(
filter: {saleCycle: {equalTo: ${saleCycle}}}
after: ${after ? `"${after}"` : null}
orderBy: ${orderBy}
) {
nodes {
account
core
extrinsicId
height
price
purchaseType
timestamp
}
pageInfo {
hasNextPage
endCursor
}
totalCount
}
}`;
return fetchGraphql(API_CORETIME_INDEXER[network], query);
};

export const fetchSalesHistoryData = async (
network: NetworkType,
after: string | null
): Promise<ApiResponse> => {
const query = `{
sales(
after: ${after},
orderBy: SALE_CYCLE_DESC
) {
nodes {
saleCycle
regionBegin
regionEnd
height
saleEnd
timestamp
tsSaleEnd
startPrice
endPrice
}
pageInfo {
hasNextPage
endCursor
}
}
}`;
return fetchGraphql(API_CORETIME_INDEXER[network], query);
};

export const fetchAccountExtrinsics = async (
network: NetworkType,
address: Address,
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);
};
export * from './accounts';
export * from './orders';
export * from './sales';
77 changes: 77 additions & 0 deletions src/apis/orders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { fetchGraphql } from '@/utils/fetchGraphql';

import { API_COCOS_INDEXER } from '@/consts';
import { Address, ApiResponse } from '@/models';

export const fetchContribution = async (
orderId: number,
address: Address | undefined,
after: string | null
): Promise<ApiResponse> => {
const query = `{
orderContributions(
after: ${after}
filter: {orderId: {equalTo: ${orderId}}, account: {equalTo: "${address}"}}
) {
nodes {
amount
}
pageInfo {
hasNextPage
endCursor
}
}
}`;
return fetchGraphql(API_COCOS_INDEXER, query);
};

export const fetchOrders = async (
after: string | null
): Promise<ApiResponse> => {
const query = `{
orders(after: ${after}) {
nodes {
orderId
begin
end
creator
exist
coreOccupancy
contribution
paraId
processed
}
pageInfo {
hasNextPage
endCursor
}
}
}`;
return fetchGraphql(API_COCOS_INDEXER, query);
};

export const fetchProcessedOrders = async (
after: string | null,
order = 'ORDER_ID_ASC'
): Promise<ApiResponse> => {
const query = `{
processedOrders(after: ${after}, orderBy: ${order}) {
nodes {
orderId
height
extrinsicId
timestamp
begin
core
mask
seller
reward
}
pageInfo {
hasNextPage
endCursor
}
}
}`;
return fetchGraphql(API_COCOS_INDEXER, query);
};
Loading

0 comments on commit e9a80cb

Please sign in to comment.