Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a2f86db5
Commit
a2f86db5
authored
Oct 24, 2022
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: sent message migration-data parsing
Add go code for reading output of the `migration-data` package.
parent
1479cda3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
migration.go
op-chain-ops/genesis/migration.go
+52
-0
No files found.
op-chain-ops/genesis/migration.go
0 → 100644
View file @
a2f86db5
package
genesis
import
(
"encoding/json"
"os"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
// SentMessageJSON represents an entry in the JSON file that is created by
// the `migration-data` package. Each entry represents a call to the
// `LegacyMessagePasser`. The `who` should always be the
// `L2CrossDomainMessenger` and the `msg` should be an abi encoded
// `relayMessage(address,address,bytes,uint256)`
type
SentMessageJSON
struct
{
Who
common
.
Address
`json:"who"`
Msg
hexutil
.
Bytes
`json:"msg"`
}
// NewSentMessageJSON will read a JSON file from disk given a path to the JSON
// file. The JSON file this function reads from disk is an output from the
// `migration-data` package.
func
NewSentMessageJSON
(
path
string
)
([]
*
SentMessageJSON
,
error
)
{
file
,
err
:=
os
.
ReadFile
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
var
j
[]
*
SentMessageJSON
if
err
:=
json
.
Unmarshal
(
file
,
&
j
);
err
!=
nil
{
return
nil
,
err
}
return
j
,
nil
}
// ToLegacyWithdrawal will convert a SentMessageJSON to a LegacyWithdrawal
// struct. This is useful because the LegacyWithdrawal struct has helper
// functions on it that can compute the withdrawal hash and the storage slot.
func
(
s
*
SentMessageJSON
)
ToLegacyWithdrawal
()
(
*
crossdomain
.
LegacyWithdrawal
,
error
)
{
data
:=
make
([]
byte
,
0
,
len
(
s
.
Who
)
+
len
(
s
.
Msg
))
copy
(
data
,
s
.
Msg
)
copy
(
data
[
len
(
s
.
Msg
)
:
],
s
.
Who
[
:
])
var
w
crossdomain
.
LegacyWithdrawal
if
err
:=
w
.
Decode
(
data
);
err
!=
nil
{
return
nil
,
err
}
return
&
w
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment