Skip to content

Commit

Permalink
Merge pull request #5 from optimism-java/type
Browse files Browse the repository at this point in the history
feat: type change
  • Loading branch information
fearlessfe authored Aug 29, 2024
2 parents 8800483 + bf2b9a5 commit 18ffde7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
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);
};

0 comments on commit 18ffde7

Please sign in to comment.