Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: type change #5

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/Charts/ClaimChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const xGap = 100;
const yGap = 100;
const yBase = 100;

const isAttack = (cur: number, parent: number): boolean => {
if (parent * 2 === cur) {
const isAttack = (cur: bigint, parent: bigint): boolean => {
if (parent * BigInt(2) === cur) {
return true;
}
return false;
Expand Down Expand Up @@ -47,7 +47,7 @@ const genNodesAndLinks = (data: ClaimData[]): any => {
continue;
}
queue.push(i);
const deep = depth(current.position);
const deep = depth(BigInt(current.position));
if (deep > maxDepth) {
maxDepth = deep;
}
Expand All @@ -74,7 +74,7 @@ const genNodesAndLinks = (data: ClaimData[]): any => {
formatter: "attack",
},
};
if (!isAttack(current.position, parent.position)) {
if (!isAttack(BigInt(current.position), BigInt(parent.position))) {
node.itemStyle.color = "blue";
link.lineStyle.color = "blue";
link.label.formatter = "defend";
Expand Down Expand Up @@ -406,7 +406,7 @@ const genTreeData = (data: ClaimData[]): any => {
},
children: [],
};
if (!isAttack(current.position, parent.position)) {
if (!isAttack(BigInt(current.position), BigInt(parent.position))) {
node.itemStyle.color = "blue";
node.lineStyle.color = "blue";
node.value = `${current.position}🏁 ${shortenAddress(
Expand Down
1 change: 0 additions & 1 deletion src/pages/game/[game].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const GameDetail = () => {
hitsPerPage: 1,
q: address,
});
console.log({ game });
const { explorer_l1: EXPLORER_L1, explorer_l2: EXPLORER_L2 } =
useNetworkConfig();
return (
Expand Down
1 change: 0 additions & 1 deletion src/pages/game/graphviz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ const GameDetail = () => {
}
});
const maxIndex = 2 ** (maxDepth + 1);
console.log(maxIndex);
let nodes = "";
let links = "";
for (let i = 1; i <= maxIndex; i++) {
Expand Down
42 changes: 21 additions & 21 deletions src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ClaimData {
claimant: string;
bond: number;
claim: string;
position: number;
position: string;
clock: number;
output_block: number;
event_id: number;
Expand Down Expand Up @@ -56,26 +56,26 @@ export interface Amountperday {
}

export interface BoundProgress {
amount: string,
date: string
amount: string;
date: string;
}

export interface LatestEvents {
block_hash: string
block_log_indexed: number
block_number: number
block_time: number
blockchain: string
contract_address: string
created_at: number
data: string
event_hash: string
event_name: string
id: number
retry_count: number
status: string
sync_block_id: number
tx_hash: string
tx_index: string
updated_at: number
}
block_hash: string;
block_log_indexed: number;
block_number: number;
block_time: number;
blockchain: string;
contract_address: string;
created_at: number;
data: string;
event_hash: string;
event_name: string;
id: number;
retry_count: number;
status: string;
sync_block_id: number;
tx_hash: string;
tx_index: string;
updated_at: number;
}
5 changes: 3 additions & 2 deletions src/utils/tree.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const depth = (position: number): number => {
return 31 - Math.clz32(position);
export const depth = (position: bigint): number => {
const bitLength = position.toString(2).length; // 将 position 转为二进制字符串并获取其长度
return 31 - (bitLength - 1);
};
Loading