Skip to content

Commit 28ad317

Browse files
Merge pull request #64 from kaleido-io/ffi-publish
Add "networkName" and "published" to FFI fields
2 parents f460a22 + 695901d commit 28ad317

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

pkg/fftypes/ffi.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ type FFI struct {
4242
Message *UUID `ffstruct:"FFI" json:"message,omitempty" ffexcludeinput:"true"`
4343
Namespace string `ffstruct:"FFI" json:"namespace,omitempty" ffexcludeinput:"true"`
4444
Name string `ffstruct:"FFI" json:"name"`
45+
NetworkName string `ffstruct:"FFI" json:"networkName,omitempty"`
4546
Description string `ffstruct:"FFI" json:"description"`
4647
Version string `ffstruct:"FFI" json:"version"`
4748
Methods []*FFIMethod `ffstruct:"FFI" json:"methods,omitempty"`
4849
Events []*FFIEvent `ffstruct:"FFI" json:"events,omitempty"`
4950
Errors []*FFIError `ffstruct:"FFI" json:"errors,omitempty"`
51+
Published bool `ffstruct:"FFI" json:"published" ffexcludeinput:"true"`
5052
}
5153

5254
type FFIMethod struct {
@@ -111,7 +113,15 @@ func (f *FFI) Validate(ctx context.Context) (err error) {
111113
if err = ValidateFFNameField(ctx, f.Name, "name"); err != nil {
112114
return err
113115
}
114-
return ValidateFFNameField(ctx, f.Version, "version")
116+
if err = ValidateFFNameField(ctx, f.Version, "version"); err != nil {
117+
return err
118+
}
119+
if f.NetworkName != "" {
120+
if err = ValidateFFNameField(ctx, f.NetworkName, "networkName"); err != nil {
121+
return err
122+
}
123+
}
124+
return nil
115125
}
116126

117127
func (f *FFI) Topic() string {

pkg/fftypes/ffi_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ func TestValidateFFIBadName(t *testing.T) {
100100
assert.Regexp(t, "FF00140", err)
101101
}
102102

103+
func TestValidateFFIBadNetworkName(t *testing.T) {
104+
ffi := &FFI{
105+
Name: "math",
106+
NetworkName: "(*%&#%)",
107+
Namespace: "default",
108+
Version: "v1.0.0",
109+
}
110+
err := ffi.Validate(context.Background())
111+
assert.Regexp(t, "FF00140", err)
112+
}
113+
103114
func TestFFIParamsScan(t *testing.T) {
104115
params := &FFIParams{}
105116
err := params.Scan([]byte(`[{"name": "x", "type": "integer", "internalType": "uint256"}]`))

0 commit comments

Comments
 (0)