-
Notifications
You must be signed in to change notification settings - Fork 190
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: add support L2 block range lookup for Orbit chains #317
Conversation
getBlockRangesForL1Block
src/lib/utils/lib.ts
Outdated
|
||
while (start <= end) { | ||
// Calculate the midpoint of the current range. | ||
const mid = start + Math.floor((end - start) / 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little bit unsure about these casting between BigNumber and number, it should be fine and I used it somewhere else in the sdk too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly lgtm, some comments
src/lib/utils/lib.ts
Outdated
maxL2Block?: number | 'latest' | ||
}): Promise<number | undefined> { | ||
if (!isArbitrumChain(provider)) { | ||
throw new Error('Arbitrum provider is required.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we assume the provider is L1 if its not Arbitrum, and return forL1Block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do
export const isArbitrumChain = async (provider: Provider): Promise<boolean> => { | ||
try { | ||
await ArbSys__factory.connect(ARB_SYS_ADDRESS, provider).arbOSVersion() | ||
} catch (error) { | ||
return false | ||
} | ||
return true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to do some caching here or in the network object, can do later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…o l2-l1-message-orbit-support
No description provided.