Skip to content

Commit

Permalink
adm: add support for the new neofs-contract archives
Browse files Browse the repository at this point in the history
As a part of nspcc-dev/neofs-contract#384 I'd like
to unify different code dealing with them.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed Jun 14, 2024
1 parent 450c4e5 commit d6484fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog for NeoFS Node
## [Unreleased]

### Added
- Support for 0.20.0+ neofs-contract archive format (#2872)

### Fixed

Expand Down
16 changes: 12 additions & 4 deletions cmd/neofs-adm/internal/modules/morph/initialize_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,17 @@ func (c *initializeContext) readContracts(names []string) error {
func readContract(ctrPath, ctrName string) (*contractState, error) {
rawNef, err := os.ReadFile(filepath.Join(ctrPath, ctrName+"_contract.nef"))
if err != nil {
return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)
rawNef, err = os.ReadFile(filepath.Join(ctrPath, "contract.nef"))
if err != nil {
return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)
}
}
rawManif, err := os.ReadFile(filepath.Join(ctrPath, "config.json"))
if err != nil {
return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)
rawManif, err = os.ReadFile(filepath.Join(ctrPath, "manifest.json"))
if err != nil {
return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)
}
}

cs := &contractState{
Expand Down Expand Up @@ -429,12 +435,14 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr
}

switch {
case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")):
case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")) ||
strings.HasSuffix(h.Name, "contract.nef"):
cs.RawNEF, err = io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)
}
case strings.HasSuffix(h.Name, "config.json"):
case strings.HasSuffix(h.Name, "config.json") ||
strings.HasSuffix(h.Name, "manifest.json"):
cs.RawManifest, err = io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)
Expand Down

0 comments on commit d6484fa

Please sign in to comment.