-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/stable-cadence' into jribbink/c1-dev-wallet
- Loading branch information
Showing
36 changed files
with
3,643 additions
and
469 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,6 @@ git | |
# Ignore built CLI | ||
main | ||
*.pkey | ||
|
||
# Local development file generation folder | ||
imports |
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,79 @@ | ||
/* | ||
* Flow CLI | ||
* | ||
* Copyright 2019 Dapper Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package config | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/onflow/flow-go-sdk" | ||
) | ||
|
||
func ParseSourceString(s string) (network, address, contractName string, err error) { | ||
parts := strings.Split(s, "://") | ||
if len(parts) != 2 { | ||
return "", "", "", fmt.Errorf("invalid dependency source format: %s", s) | ||
} | ||
network = parts[0] | ||
|
||
subParts := strings.Split(parts[1], ".") | ||
if len(subParts) != 2 { | ||
return "", "", "", fmt.Errorf("invalid dependency source format: %s", s) | ||
} | ||
address = subParts[0] | ||
contractName = subParts[1] | ||
|
||
return network, address, contractName, nil | ||
} | ||
|
||
type Source struct { | ||
NetworkName string | ||
Address flow.Address | ||
ContractName string | ||
} | ||
|
||
type Dependency struct { | ||
Name string | ||
Source Source | ||
Hash string | ||
Aliases Aliases | ||
} | ||
|
||
type Dependencies []Dependency | ||
|
||
func (d *Dependencies) ByName(name string) *Dependency { | ||
for i, dep := range *d { | ||
if dep.Name == name { | ||
return &(*d)[i] | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (d *Dependencies) AddOrUpdate(dep Dependency) { | ||
for i, dependency := range *d { | ||
if dependency.Name == dep.Name { | ||
(*d)[i] = dep | ||
return | ||
} | ||
} | ||
|
||
*d = append(*d, dep) | ||
} |
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,44 @@ | ||
/* | ||
* Flow CLI | ||
* | ||
* Copyright 2019 Dapper Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDependencies_ByName(t *testing.T) { | ||
dependencies := Dependencies{ | ||
Dependency{Name: "mydep"}, | ||
} | ||
|
||
dep := dependencies.ByName("mydep") | ||
assert.NotNil(t, dep) | ||
} | ||
|
||
func TestDependencies_AddOrUpdate(t *testing.T) { | ||
dependencies := Dependencies{} | ||
dependencies.AddOrUpdate(Dependency{Name: "mydep"}) | ||
|
||
assert.Len(t, dependencies, 1) | ||
|
||
dep := dependencies.ByName("mydep") | ||
assert.NotNil(t, dep) | ||
} |
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
Oops, something went wrong.