-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-deployer: Separate L1 and L2 contract artifacts (#12480)
* op-deployer: Separate L1 and L2 contract artifacts Adds support for specifying separate artifact URLs for L1 and L2. There are two new fields in the intent - `L1ContractsLocator` and `L2ContractsLocator` - which together replace the `ContractArtifactsURL` and `ContractsRelease` fields. Specifying a file or HTTPS URL for either field will automatically enable dev mode for the deployment. Specifying a `tag://` URL will use the standard deployment for L1 and L2. The default have been set to the following: - L1: `op-contracts/v1.6.0` - L2: `op-contracts/v1.7.0-beta.1+l2-contracts` Fixes ethereum-optimism/platforms-team#337. * fix test * fix another test
- Loading branch information
Showing
20 changed files
with
390 additions
and
179 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,78 @@ | ||
package opcm | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
type schemeUnmarshaler func(string) (*ArtifactsLocator, error) | ||
|
||
var schemeUnmarshalerDispatch = map[string]schemeUnmarshaler{ | ||
"tag": unmarshalTag, | ||
"file": unmarshalURL, | ||
"https": unmarshalURL, | ||
} | ||
|
||
type ArtifactsLocator struct { | ||
URL *url.URL | ||
Tag string | ||
} | ||
|
||
func (a *ArtifactsLocator) UnmarshalText(text []byte) error { | ||
str := string(text) | ||
|
||
for scheme, unmarshaler := range schemeUnmarshalerDispatch { | ||
if !strings.HasPrefix(str, scheme+"://") { | ||
continue | ||
} | ||
|
||
loc, err := unmarshaler(str) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*a = *loc | ||
return nil | ||
} | ||
|
||
return fmt.Errorf("unsupported scheme") | ||
} | ||
|
||
func (a *ArtifactsLocator) MarshalText() ([]byte, error) { | ||
if a.URL != nil { | ||
return []byte(a.URL.String()), nil | ||
} | ||
|
||
if a.Tag != "" { | ||
return []byte(a.Tag), nil | ||
} | ||
|
||
return nil, fmt.Errorf("no URL, path or tag set") | ||
} | ||
|
||
func (a *ArtifactsLocator) IsTag() bool { | ||
return a.Tag != "" | ||
} | ||
|
||
func unmarshalTag(tag string) (*ArtifactsLocator, error) { | ||
tag = strings.TrimPrefix(tag, "tag://") | ||
if !strings.HasPrefix(tag, "op-contracts/") { | ||
return nil, fmt.Errorf("invalid tag: %s", tag) | ||
} | ||
|
||
if _, err := StandardArtifactsURLForTag(tag); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &ArtifactsLocator{Tag: tag}, nil | ||
} | ||
|
||
func unmarshalURL(text string) (*ArtifactsLocator, error) { | ||
u, err := url.Parse(text) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &ArtifactsLocator{URL: u}, nil | ||
} |
Oops, something went wrong.