Skip to content

Commit dcce135

Browse files
authored
Merge pull request #18 from storacha/feat/add-space-did
Add space did to location commitment
2 parents c835720 + b3a9b74 commit dcce135

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

pkg/capability/assert/assert.go

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/storacha/go-ucanto/core/ipld"
1212
"github.com/storacha/go-ucanto/core/result/failure"
1313
"github.com/storacha/go-ucanto/core/schema"
14+
"github.com/storacha/go-ucanto/did"
1415
"github.com/storacha/go-ucanto/validator"
1516
adm "github.com/storacha/indexing-service/pkg/capability/assert/datamodel"
1617
)
@@ -72,6 +73,7 @@ type LocationCaveats struct {
7273
Content HasMultihash
7374
Location []url.URL
7475
Range *adm.Range
76+
Space did.DID
7577
}
7678

7779
func (lc LocationCaveats) ToIPLD() (datamodel.Node, error) {
@@ -89,6 +91,7 @@ func (lc LocationCaveats) ToIPLD() (datamodel.Node, error) {
8991
Content: cn,
9092
Location: asStrings,
9193
Range: lc.Range,
94+
Space: lc.Space.Bytes(),
9295
}
9396
return ipld.WrapWithRecovery(md, adm.LocationCaveatsType())
9497
}
@@ -109,10 +112,20 @@ var Location = validator.NewCapability(LocationAbility, schema.DIDString(),
109112
}
110113
location = append(location, url)
111114
}
115+
116+
space := did.Undef
117+
if len(model.Space) > 0 {
118+
var serr error
119+
space, serr = did.Decode(model.Space)
120+
if serr != nil {
121+
return LocationCaveats{}, failure.FromError(serr)
122+
}
123+
}
112124
return LocationCaveats{
113125
Content: hasMultihash,
114126
Location: location,
115127
Range: model.Range,
128+
Space: space,
116129
}, nil
117130
}), nil)
118131

pkg/capability/assert/datamodel/assert.go

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type LocationCaveatsModel struct {
5959
Content datamodel.Node
6060
Location []string
6161
Range *Range
62+
Space []byte
6263
}
6364

6465
type DigestModel struct {

pkg/capability/assert/datamodel/assert.ipldsch

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
type DID bytes
12

23
type Range struct {
34
offset Int
@@ -8,6 +9,7 @@ type LocationCaveats struct {
89
content Any
910
location [String]
1011
range optional Range
12+
space optional DID
1113
}
1214

1315
type Digest struct {

0 commit comments

Comments
 (0)