diff --git a/go.mod b/go.mod index 768484b..de90535 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/multiformats/go-multihash v0.2.3 github.com/storacha/go-capabilities v0.0.0-20241021134022-7144600f5aeb github.com/storacha/go-metadata v0.0.0-20241021141939-f94d93dcda78 - github.com/storacha/go-ucanto v0.1.1-0.20241028093931-42d9e1db4bfb + github.com/storacha/go-ucanto v0.1.1-0.20241028163940-34de8cd912bb github.com/storacha/ipni-publisher v0.0.0-20241018055706-032286a2dc3f github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.4 diff --git a/go.sum b/go.sum index 2c97b14..bf0daa1 100644 --- a/go.sum +++ b/go.sum @@ -540,8 +540,8 @@ github.com/storacha/go-capabilities v0.0.0-20241021134022-7144600f5aeb h1:A9/44D github.com/storacha/go-capabilities v0.0.0-20241021134022-7144600f5aeb/go.mod h1:1x2qMcvOUvF6prSiWXsEeEfV3OcX/L2fk6iNgPMNfZU= github.com/storacha/go-metadata v0.0.0-20241021141939-f94d93dcda78 h1:NAti9hMLMo8F0Iyz5ldS41CY6MyukRH0OrTPV4u2340= github.com/storacha/go-metadata v0.0.0-20241021141939-f94d93dcda78/go.mod h1:DcwwQnyFuTk531cKD9sUkQg/gzpwKaIqH9I7oZYyeRc= -github.com/storacha/go-ucanto v0.1.1-0.20241028093931-42d9e1db4bfb h1:bjubXTmLyLl7eap6HhIoFmwIH6H4CCtnJlcE4hbc2Qo= -github.com/storacha/go-ucanto v0.1.1-0.20241028093931-42d9e1db4bfb/go.mod h1:7ba9jAgqmwlF/JfyFUQcGV07uiYNlmJNu8qH4hHtrJk= +github.com/storacha/go-ucanto v0.1.1-0.20241028163940-34de8cd912bb h1:lFwFtMjgt162ot9pnu230haLjRQ1rqwJOIAyywOqAX8= +github.com/storacha/go-ucanto v0.1.1-0.20241028163940-34de8cd912bb/go.mod h1:7ba9jAgqmwlF/JfyFUQcGV07uiYNlmJNu8qH4hHtrJk= github.com/storacha/ipni-publisher v0.0.0-20241018055706-032286a2dc3f h1:62fTASO3wRPCWCkl6we2DftsFy/DfbmVpwJyqK7gmUc= github.com/storacha/ipni-publisher v0.0.0-20241018055706-032286a2dc3f/go.mod h1:fEuGSF5WMaOSAyDQCYAvow6Y+YKzpXczEk3A+H+s1fQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/pkg/service/publisher/publisher_test.go b/pkg/service/publisher/publisher_test.go index a8579c2..9b8658f 100644 --- a/pkg/service/publisher/publisher_test.go +++ b/pkg/service/publisher/publisher_test.go @@ -17,7 +17,7 @@ import ( "github.com/storacha/go-ucanto/client" "github.com/storacha/go-ucanto/core/delegation" "github.com/storacha/go-ucanto/core/invocation" - "github.com/storacha/go-ucanto/core/receipt" + "github.com/storacha/go-ucanto/core/receipt/fx" "github.com/storacha/go-ucanto/core/result/ok" "github.com/storacha/go-ucanto/principal" "github.com/storacha/go-ucanto/server" @@ -100,7 +100,7 @@ func TestPublisherService(t *testing.T) { publisherStore := store.FromDatastore(dstore) handlerCalled := false - handler := func(cap ucan.Capability[claim.CacheCaveats], inv invocation.Invocation, ctx server.InvocationContext) (ok.Unit, receipt.Effects, error) { + handler := func(cap ucan.Capability[claim.CacheCaveats], inv invocation.Invocation, ctx server.InvocationContext) (ok.Unit, fx.Effects, error) { handlerCalled = true claim := cap.Nb().Claim for b, err := range inv.Blocks() { diff --git a/pkg/service/storage/ucan.go b/pkg/service/storage/ucan.go index 8b0d106..f931970 100644 --- a/pkg/service/storage/ucan.go +++ b/pkg/service/storage/ucan.go @@ -11,7 +11,7 @@ import ( "github.com/storacha/go-capabilities/pkg/blob" "github.com/storacha/go-ucanto/core/delegation" "github.com/storacha/go-ucanto/core/invocation" - "github.com/storacha/go-ucanto/core/receipt" + "github.com/storacha/go-ucanto/core/receipt/fx" "github.com/storacha/go-ucanto/core/result/failure" "github.com/storacha/go-ucanto/server" "github.com/storacha/go-ucanto/ucan" @@ -31,7 +31,7 @@ func NewUCANServer(storageService Service) (server.ServerView, error) { blob.AllocateAbility, server.Provide( blob.Allocate, - func(cap ucan.Capability[blob.AllocateCaveats], inv invocation.Invocation, iCtx server.InvocationContext) (blob.AllocateOk, receipt.Effects, error) { + func(cap ucan.Capability[blob.AllocateCaveats], inv invocation.Invocation, iCtx server.InvocationContext) (blob.AllocateOk, fx.Effects, error) { ctx := context.TODO() digest := cap.Nb().Blob.Digest log := log.With("blob", digestutil.Format(digest)) @@ -102,7 +102,7 @@ func NewUCANServer(storageService Service) (server.ServerView, error) { blob.AcceptAbility, server.Provide( blob.Accept, - func(cap ucan.Capability[blob.AcceptCaveats], inv invocation.Invocation, iCtx server.InvocationContext) (blob.AcceptOk, receipt.Effects, error) { + func(cap ucan.Capability[blob.AcceptCaveats], inv invocation.Invocation, iCtx server.InvocationContext) (blob.AcceptOk, fx.Effects, error) { ctx := context.TODO() digest := cap.Nb().Blob.Digest log := log.With("blob", digestutil.Format(digest)) @@ -156,7 +156,7 @@ func NewUCANServer(storageService Service) (server.ServerView, error) { return blob.AcceptOk{}, nil, failure.FromError(err) } - return blob.AcceptOk{Site: claim.Link()}, nil, nil + return blob.AcceptOk{Site: claim.Link()}, fx.NewEffects(fx.WithFork(fx.FromInvocation(claim))), nil }, ), ), diff --git a/pkg/service/storage/server_test.go b/pkg/service/storage/ucan_test.go similarity index 96% rename from pkg/service/storage/server_test.go rename to pkg/service/storage/ucan_test.go index 618ea1e..1ec9227 100644 --- a/pkg/service/storage/server_test.go +++ b/pkg/service/storage/ucan_test.go @@ -217,5 +217,11 @@ func TestServer(t *testing.T) { fmt.Println(*f.Stack) require.Nil(t, f) }) + + require.NotEmpty(t, rcpt.Fx().Fork()) + effect := rcpt.Fx().Fork()[0] + claim, ok := effect.Invocation() + require.True(t, ok) + require.Equal(t, assert.LocationAbility, claim.Capabilities()[0].Can()) }) }