-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(sdk): add support for Bedrock #2701
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fa02c10
feat(ctb): add SentMessageV2 event to XDM
smartcontracts ca3c2fd
feat(sdk): add support for Bedrock
smartcontracts daca0e4
wip: various bugs
smartcontracts beeeacc
wip: fixs
smartcontracts f87b03b
wip
smartcontracts 6be5e79
wip
smartcontracts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@eth-optimism/sdk': minor | ||
| --- | ||
|
|
||
| Adds Bedrock support to the SDK |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts-bedrock': patch | ||
| --- | ||
|
|
||
| Emit SentMessageV2 event with more information |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ coverage.out | |
| deployments | ||
| broadcast | ||
| genesis.json | ||
| src/contract-artifacts.ts | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import path from 'path' | ||
| import fs from 'fs' | ||
|
|
||
| import glob from 'glob' | ||
|
|
||
| /** | ||
| * Script for automatically generating a file which has a series of `require` statements for | ||
| * importing JSON contract artifacts. We do this to preserve browser compatibility. | ||
| */ | ||
| const main = async () => { | ||
| const contractArtifactsFolder = path.resolve( | ||
| __dirname, | ||
| `../artifacts/contracts` | ||
| ) | ||
|
|
||
| const artifactPaths = glob | ||
| .sync(`${contractArtifactsFolder}/**/*.json`) | ||
| .filter((match) => { | ||
| // Filter out the debug outputs. | ||
| return !match.endsWith('.dbg.json') | ||
| }) | ||
|
|
||
| const content = ` | ||
| /* eslint-disable @typescript-eslint/no-var-requires, no-empty */ | ||
| /* | ||
| THIS FILE IS AUTOMATICALLY GENERATED. | ||
| DO NOT EDIT. | ||
| */ | ||
|
|
||
| ${artifactPaths | ||
| .map((artifactPath) => { | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const artifact = require(artifactPath) | ||
| // handles the case - '\u' (\utils folder) is considered as an unicode encoded char | ||
| const pattern = /\\/g | ||
| const relPath = path | ||
| .relative(__dirname, artifactPath) | ||
| .replace(pattern, '/') | ||
| return ` | ||
| let ${artifact.contractName} | ||
| try { | ||
| ${artifact.contractName} = require('${relPath}') | ||
| } catch {} | ||
| ` | ||
| }) | ||
| .join('\n')} | ||
|
|
||
| export const getContractArtifact = (name: string): any => { | ||
| return { | ||
| ${artifactPaths | ||
| .map((artifactPath) => { | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const artifact = require(artifactPath) | ||
| return `${artifact.contractName}` | ||
| }) | ||
| .join(',\n')} | ||
| }[name] | ||
| } | ||
| ` | ||
|
|
||
| fs.writeFileSync( | ||
| path.resolve(__dirname, `../src/contract-artifacts.ts`), | ||
| content | ||
| ) | ||
| } | ||
|
|
||
| main() |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { ethers } from 'ethers' | ||
|
|
||
| /** | ||
| * Gets the hardhat artifact for the given contract name. | ||
| * Will throw an error if the contract artifact is not found. | ||
| * | ||
| * @param name Contract name. | ||
| * @returns The artifact for the given contract name. | ||
| */ | ||
| export const getContractDefinition = (name: string): any => { | ||
| // We import this using `require` because hardhat tries to build this file when compiling | ||
| // the contracts, but we need the contracts to be compiled before the contract-artifacts.ts | ||
| // file can be generated. | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const { getContractArtifact } = require('./contract-artifacts') | ||
| const artifact = getContractArtifact(name) | ||
| if (artifact === undefined) { | ||
| throw new Error(`Unable to find artifact for contract: ${name}`) | ||
| } | ||
| return artifact | ||
| } | ||
|
|
||
| /** | ||
| * Gets an ethers Interface instance for the given contract name. | ||
| * | ||
| * @param name Contract name. | ||
| * @returns The interface for the given contract name. | ||
| */ | ||
| export const getContractInterface = (name: string): ethers.utils.Interface => { | ||
| const definition = getContractDefinition(name) | ||
| return new ethers.utils.Interface(definition.abi) | ||
| } | ||
|
|
||
| /** | ||
| * Gets an ethers ContractFactory instance for the given contract name. | ||
| * | ||
| * @param name Contract name. | ||
| * @param signer The signer for the ContractFactory to use. | ||
| * @returns The contract factory for the given contract name. | ||
| */ | ||
| export const getContractFactory = ( | ||
| name: string, | ||
| signer?: ethers.Signer | ||
| ): ethers.ContractFactory => { | ||
| const definition = getContractDefinition(name) | ||
| const contractInterface = getContractInterface(name) | ||
| return new ethers.ContractFactory( | ||
| contractInterface, | ||
| definition.bytecode, | ||
| signer | ||
| ) | ||
| } |
This file contains hidden or 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,3 +1,4 @@ | ||
| export * from './utils' | ||
| export * from './generateProofs' | ||
| export * from './constants' | ||
| export * from './contract-defs' |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
SentMessage is a legacy event that shouldn't be changed so we can preserve the interface. Instead of adding a completely new event, we add
SentMessageExtraData.