From 16344760c9e6c9203305626c323f8f61da8c0fdf Mon Sep 17 00:00:00 2001 From: frrist Date: Thu, 21 May 2026 12:55:41 -0700 Subject: [PATCH] refactor: migrate to ucantone typed Binding[Args, OK] Adopt the ucantone changes from #17 (Binding[Args, OK]), #18 (big ints), and - Drop commands/bind.go: the MustParse wrapper was a pass-through to binding.Bind(command.MustParse(...)), so command declarations now call ucantone directly as binding.Bind[*Args, *OK](command.MustParse("/x")). - Pair every command with its existing OK result type as the second type parameter (#17). - Regenerate commands/access cbor/json: the Command field now marshals via command.Command's own methods rather than as a string (#21). - Update retrieval tests from validator/bindcom to binding.Bind. --- commands/access/cbor_gen.go | 21 ++++++--------------- commands/access/claim.go | 8 ++++++-- commands/access/confirm.go | 5 +++-- commands/access/delegate.go | 8 ++++++-- commands/access/grant.go | 6 +++--- commands/access/json_gen.go | 25 ++++++++----------------- commands/access/request.go | 7 +++++-- commands/assert/equals.go | 8 ++++++-- commands/assert/index.go | 8 ++++++-- commands/assert/location.go | 8 ++++++-- commands/bind.go | 16 ---------------- commands/blob/accept.go | 7 +++++-- commands/blob/add.go | 7 +++++-- commands/blob/allocate.go | 7 +++++-- commands/blob/list.go | 7 +++++-- commands/blob/remove.go | 8 ++++++-- commands/blob/replica/allocate.go | 7 +++++-- commands/blob/replica/transfer.go | 7 +++++-- commands/blob/replicate.go | 7 +++++-- commands/blob/retrieve.go | 7 +++++-- commands/claim/cache.go | 8 ++++++-- commands/content/retrieve.go | 8 ++++++-- commands/debug/echo.go | 7 +++++-- commands/http/put.go | 8 ++++++-- commands/index/add.go | 4 +++- commands/pdp/accept.go | 7 +++++-- commands/pdp/info.go | 7 +++++-- commands/pdp/sign/sign.go | 11 ++++++----- commands/provider/add.go | 5 +++-- commands/space/egress/track.go | 7 +++++-- commands/space/info.go | 8 ++++++-- commands/ucan/attest/proof.go | 8 ++++++-- commands/ucan/conclude.go | 4 +++- commands/upload/add.go | 8 ++++++-- commands/upload/list.go | 7 +++++-- commands/upload/remove.go | 8 ++++++-- commands/upload/shard/list.go | 7 +++++-- go.mod | 3 ++- go.sum | 10 ++++++---- ucan/retrieval/server_test.go | 5 +++-- 40 files changed, 199 insertions(+), 125 deletions(-) delete mode 100644 commands/bind.go diff --git a/commands/access/cbor_gen.go b/commands/access/cbor_gen.go index faf7e5d..e4fd858 100644 --- a/commands/access/cbor_gen.go +++ b/commands/access/cbor_gen.go @@ -10,7 +10,6 @@ import ( "math" "sort" - command "github.com/fil-forge/ucantone/ucan/command" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" @@ -190,7 +189,7 @@ func (t *CapabilityRequest) MarshalCBOR(w io.Writer) error { return err } - // t.Command (command.Command) (string) + // t.Command (command.Command) (struct) if len("cmd") > 8192 { return xerrors.Errorf("Value in field \"cmd\" was too long") } @@ -202,14 +201,7 @@ func (t *CapabilityRequest) MarshalCBOR(w io.Writer) error { return err } - if len(t.Command) > 8192 { - return xerrors.Errorf("Value in field t.Command was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Command))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Command)); err != nil { + if err := t.Command.MarshalCBOR(cw); err != nil { return err } return nil @@ -256,16 +248,15 @@ func (t *CapabilityRequest) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Command (command.Command) (string) + // t.Command (command.Command) (struct) case "cmd": { - sval, err := cbg.ReadStringWithMax(cr, 8192) - if err != nil { - return err + + if err := t.Command.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Command: %w", err) } - t.Command = command.Command(sval) } default: diff --git a/commands/access/claim.go b/commands/access/claim.go index e671123..15c3adc 100644 --- a/commands/access/claim.go +++ b/commands/access/claim.go @@ -2,10 +2,14 @@ package access -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + command "github.com/fil-forge/ucantone/ucan/command" +) type ClaimArguments = commands.Unit // Claim can be invoked by an agent to claim a set of delegations from the // account. -var Claim = commands.MustParse[*ClaimArguments]("/access/claim") +var Claim = binding.Bind[*ClaimArguments, *ClaimOK](command.MustParse("/access/claim")) diff --git a/commands/access/confirm.go b/commands/access/confirm.go index c07f4f5..71caaae 100644 --- a/commands/access/confirm.go +++ b/commands/access/confirm.go @@ -3,8 +3,9 @@ package access import ( - "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" "github.com/fil-forge/ucantone/errors" + command "github.com/fil-forge/ucantone/ucan/command" ) // ConfirmOK mirrors ClaimOK — confirming an access request grants the same @@ -17,7 +18,7 @@ type ConfirmOK = ClaimOK const ConfirmMetaKey = "accessConfirm" // Confirm can be invoked by an agent to confirm an access request. -var Confirm = commands.MustParse[*ConfirmArguments]("/access/confirm") +var Confirm = binding.Bind[*ConfirmArguments, *ConfirmOK](command.MustParse("/access/confirm")) const ( InvalidAccessConfirmSubjectErrorName = "InvalidAccessConfirmSubject" diff --git a/commands/access/delegate.go b/commands/access/delegate.go index 07d9a01..43842d6 100644 --- a/commands/access/delegate.go +++ b/commands/access/delegate.go @@ -2,13 +2,17 @@ package access -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + command "github.com/fil-forge/ucantone/ucan/command" +) type DelegateOK = commands.Unit // Delegate can be invoked by an agent to delegate a set of capabilities that // may be subsequently claimed by another agent. -var Delegate = commands.MustParse[*DelegateArguments]("/access/delegate") +var Delegate = binding.Bind[*DelegateArguments, *DelegateOK](command.MustParse("/access/delegate")) const ( DelegationNotFoundErrorName = "DelegationNotFound" diff --git a/commands/access/grant.go b/commands/access/grant.go index a03037f..74f984a 100644 --- a/commands/access/grant.go +++ b/commands/access/grant.go @@ -3,9 +3,9 @@ package access import ( + "github.com/fil-forge/ucantone/binding" "github.com/fil-forge/ucantone/errors" - - "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/ucan/command" ) const GrantCommand = "/access/grant" @@ -18,7 +18,7 @@ type GrantOK = ClaimOK // Grant can be invoked by an agent to request that a set of capabilities be // granted directly. Unlike Request -> Confirm, Grant is one-shot: the // executor decides immediately whether to issue the delegation. -var Grant = commands.MustParse[*GrantArguments](GrantCommand) +var Grant = binding.Bind[*GrantArguments, *GrantOK](command.MustParse(GrantCommand)) const ( UnknownAbilityErrorName = "UnknownAbility" diff --git a/commands/access/json_gen.go b/commands/access/json_gen.go index 12f7185..9d805c5 100644 --- a/commands/access/json_gen.go +++ b/commands/access/json_gen.go @@ -12,7 +12,6 @@ import ( "sort" jsg "github.com/alanshaw/dag-json-gen" - command "github.com/fil-forge/ucantone/ucan/command" cid "github.com/ipfs/go-cid" ) @@ -204,7 +203,7 @@ func (t *CapabilityRequest) MarshalDagJSON(w io.Writer) error { return err } - // t.Command (command.Command) (string) + // t.Command (command.Command) (struct) if len("cmd") > 8192 { return fmt.Errorf("string in field \"cmd\" was too long") } @@ -214,11 +213,8 @@ func (t *CapabilityRequest) MarshalDagJSON(w io.Writer) error { if err := jw.WriteObjectColon(); err != nil { return err } - if len(t.Command) > 8192 { - return fmt.Errorf("string in field t.Command was too long") - } - if err := jw.WriteString(string(t.Command)); err != nil { - return fmt.Errorf("writing string for field t.Command: %w", err) + if err := t.Command.MarshalDagJSON(jw); err != nil { + return fmt.Errorf("marshaling field t.Command: %w", err) } if err := jw.WriteObjectClose(); err != nil { return err @@ -259,18 +255,13 @@ func (t *CapabilityRequest) UnmarshalDagJSON(r io.Reader) (err error) { } switch name { - // t.Command (command.Command) (string) + // t.Command (command.Command) (struct) case "cmd": - { - sval, err := jr.ReadString(8192) - if err != nil { - if errors.Is(err, jsg.ErrLimitExceeded) { - return fmt.Errorf("reading string for field t.Command: string too long") - } - return fmt.Errorf("reading string for field t.Command: %w", err) - } - t.Command = command.Command(sval) + + if err := t.Command.UnmarshalDagJSON(jr); err != nil { + return fmt.Errorf("unmarshaling t.Command: %w", err) } + default: // Field doesn't exist on this type, so ignore it if err := jr.DiscardType(); err != nil { diff --git a/commands/access/request.go b/commands/access/request.go index 265fd58..10da7c0 100644 --- a/commands/access/request.go +++ b/commands/access/request.go @@ -2,7 +2,10 @@ package access -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + command "github.com/fil-forge/ucantone/ucan/command" +) // RequestFactKey is the key in metadata in any delegation created by a // successful access request. The value is a link back to the `/access/request` @@ -11,7 +14,7 @@ const RequestMetaKey = "accessRequest" // Request can be invoked by an agent to request set of capabilities from the // account. -var Request = commands.MustParse[*RequestArguments]("/access/request") +var Request = binding.Bind[*RequestArguments, *RequestOK](command.MustParse("/access/request")) const ( InvalidAuthorizationAccountErrorName = "InvalidAuthorizationAccount" diff --git a/commands/assert/equals.go b/commands/assert/equals.go index cbfcadd..d749181 100644 --- a/commands/assert/equals.go +++ b/commands/assert/equals.go @@ -2,9 +2,13 @@ package assert -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type EqualsOK = commands.Unit // Equals claims data is referred to by another CID e.g CAR CID & Piece CID -var Equals = commands.MustParse[*EqualsArguments]("/assert/equals") +var Equals = binding.Bind[*EqualsArguments, *EqualsOK](command.MustParse("/assert/equals")) diff --git a/commands/assert/index.go b/commands/assert/index.go index a0684c5..2966c1b 100644 --- a/commands/assert/index.go +++ b/commands/assert/index.go @@ -2,10 +2,14 @@ package assert -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type IndexOK = commands.Unit // Index claims that a content graph can be found in blob(s) that are identified // and indexed in the given index CID. -var Index = commands.MustParse[*IndexArguments]("/assert/index") +var Index = binding.Bind[*IndexArguments, *IndexOK](command.MustParse("/assert/index")) diff --git a/commands/assert/location.go b/commands/assert/location.go index 5e8e27d..a510b9e 100644 --- a/commands/assert/location.go +++ b/commands/assert/location.go @@ -2,8 +2,12 @@ package assert -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type LocationOK = commands.Unit -var Location = commands.MustParse[*LocationArguments]("/assert/location") +var Location = binding.Bind[*LocationArguments, *LocationOK](command.MustParse("/assert/location")) diff --git a/commands/bind.go b/commands/bind.go deleted file mode 100644 index ab1fc5e..0000000 --- a/commands/bind.go +++ /dev/null @@ -1,16 +0,0 @@ -package commands - -import "github.com/fil-forge/ucantone/validator/bindcom" - -// MustParse is like [bindcom.Parse] but panics if the command cannot be -// constructed. It exists for package-level command declarations where the -// command and options are static — any error indicates a programming bug -// (malformed command string, invalid option) and should fail loudly at init -// rather than be silently dropped with `, _`. -func MustParse[A bindcom.Arguments](cmd string) bindcom.Command[A] { - c, err := bindcom.Parse[A](cmd) - if err != nil { - panic(err) - } - return c -} diff --git a/commands/blob/accept.go b/commands/blob/accept.go index d9f7e26..9494302 100644 --- a/commands/blob/accept.go +++ b/commands/blob/accept.go @@ -2,6 +2,9 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var Accept = commands.MustParse[*AcceptArguments]("/blob/accept") +var Accept = binding.Bind[*AcceptArguments, *AcceptOK](command.MustParse("/blob/accept")) diff --git a/commands/blob/add.go b/commands/blob/add.go index 7856b38..8c2a918 100644 --- a/commands/blob/add.go +++ b/commands/blob/add.go @@ -2,6 +2,9 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var Add = commands.MustParse[*AddArguments]("/blob/add") +var Add = binding.Bind[*AddArguments, *AddOK](command.MustParse("/blob/add")) diff --git a/commands/blob/allocate.go b/commands/blob/allocate.go index 5bd10af..1bf3d03 100644 --- a/commands/blob/allocate.go +++ b/commands/blob/allocate.go @@ -2,8 +2,11 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) const MaxBlobSize = 268_435_456 -var Allocate = commands.MustParse[*AllocateArguments]("/blob/allocate") +var Allocate = binding.Bind[*AllocateArguments, *AllocateOK](command.MustParse("/blob/allocate")) diff --git a/commands/blob/list.go b/commands/blob/list.go index dc2a71d..5df28a4 100644 --- a/commands/blob/list.go +++ b/commands/blob/list.go @@ -2,6 +2,9 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var List = commands.MustParse[*ListArguments]("/blob/list") +var List = binding.Bind[*ListArguments, *ListOK](command.MustParse("/blob/list")) diff --git a/commands/blob/remove.go b/commands/blob/remove.go index 6432b01..0c3a4f1 100644 --- a/commands/blob/remove.go +++ b/commands/blob/remove.go @@ -2,8 +2,12 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type RemoveOK = commands.Unit -var Remove = commands.MustParse[*RemoveArguments]("/blob/remove") +var Remove = binding.Bind[*RemoveArguments, *RemoveOK](command.MustParse("/blob/remove")) diff --git a/commands/blob/replica/allocate.go b/commands/blob/replica/allocate.go index 8edbfe8..102501a 100644 --- a/commands/blob/replica/allocate.go +++ b/commands/blob/replica/allocate.go @@ -2,6 +2,9 @@ package replica -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var Allocate = commands.MustParse[*AllocateArguments]("/blob/replica/allocate") +var Allocate = binding.Bind[*AllocateArguments, *AllocateOK](command.MustParse("/blob/replica/allocate")) diff --git a/commands/blob/replica/transfer.go b/commands/blob/replica/transfer.go index 8ab0da5..09deb75 100644 --- a/commands/blob/replica/transfer.go +++ b/commands/blob/replica/transfer.go @@ -2,6 +2,9 @@ package replica -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var Transfer = commands.MustParse[*TransferArguments]("/blob/replica/transfer") +var Transfer = binding.Bind[*TransferArguments, *TransferOK](command.MustParse("/blob/replica/transfer")) diff --git a/commands/blob/replicate.go b/commands/blob/replicate.go index eebba2c..9a03256 100644 --- a/commands/blob/replicate.go +++ b/commands/blob/replicate.go @@ -2,7 +2,10 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) // Replicate is a capability that allows an agent to replicate a Blob into a // space identified by did:key in the `with` field. @@ -18,4 +21,4 @@ import "github.com/fil-forge/libforge/commands" // transferred and stored the blob. The number of `/blob/replica/allocate` and // `/blob/replica/transfer` tasks corresponds directly to number of replicas // requested. -var Replicate = commands.MustParse[*ReplicateArguments]("/blob/replicate") +var Replicate = binding.Bind[*ReplicateArguments, *ReplicateOK](command.MustParse("/blob/replicate")) diff --git a/commands/blob/retrieve.go b/commands/blob/retrieve.go index e6f45e7..1b512dd 100644 --- a/commands/blob/retrieve.go +++ b/commands/blob/retrieve.go @@ -2,7 +2,10 @@ package blob -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) // Retrieve is the service-level retrieval capability (e.g. used by the // indexer to fetch content claims from a Piri node). It is NOT space-scoped: @@ -12,4 +15,4 @@ import "github.com/fil-forge/libforge/commands" // For user-facing retrieval that requires an allocation in a specific space // see `libforge/commands/content.Retrieve` (the `/content/retrieve` // capability). -var Retrieve = commands.MustParse[*RetrieveArguments]("/blob/retrieve") +var Retrieve = binding.Bind[*RetrieveArguments, *RetrieveOK](command.MustParse("/blob/retrieve")) diff --git a/commands/claim/cache.go b/commands/claim/cache.go index b2539ba..b37c61e 100644 --- a/commands/claim/cache.go +++ b/commands/claim/cache.go @@ -2,8 +2,12 @@ package claim -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type CacheOK = commands.Unit -var Cache = commands.MustParse[*CacheArguments]("/claim/cache") +var Cache = binding.Bind[*CacheArguments, *CacheOK](command.MustParse("/claim/cache")) diff --git a/commands/content/retrieve.go b/commands/content/retrieve.go index aecb622..2214c5f 100644 --- a/commands/content/retrieve.go +++ b/commands/content/retrieve.go @@ -2,8 +2,12 @@ package content -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type RetrieveOK = commands.Unit -var Retrieve = commands.MustParse[*RetrieveArguments]("/content/retrieve") +var Retrieve = binding.Bind[*RetrieveArguments, *RetrieveOK](command.MustParse("/content/retrieve")) diff --git a/commands/debug/echo.go b/commands/debug/echo.go index 4827f25..9f19c93 100644 --- a/commands/debug/echo.go +++ b/commands/debug/echo.go @@ -2,8 +2,11 @@ package debug -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type EchoOK = EchoArguments -var Echo = commands.MustParse[*EchoArguments]("/debug/echo") +var Echo = binding.Bind[*EchoArguments, *EchoOK](command.MustParse("/debug/echo")) diff --git a/commands/http/put.go b/commands/http/put.go index aff6151..91431c5 100644 --- a/commands/http/put.go +++ b/commands/http/put.go @@ -2,8 +2,12 @@ package http -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type PutOK = commands.Unit -var Put = commands.MustParse[*PutArguments]("/http/put") +var Put = binding.Bind[*PutArguments, *PutOK](command.MustParse("/http/put")) diff --git a/commands/index/add.go b/commands/index/add.go index 763aedc..317a2d6 100644 --- a/commands/index/add.go +++ b/commands/index/add.go @@ -4,12 +4,14 @@ package index import ( "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" "github.com/fil-forge/ucantone/errors" + "github.com/fil-forge/ucantone/ucan/command" ) type AddOK = commands.Unit -var Add = commands.MustParse[*AddArguments]("/index/add") +var Add = binding.Bind[*AddArguments, *AddOK](command.MustParse("/index/add")) const IndexNotFoundErrorName = "IndexNotFound" diff --git a/commands/pdp/accept.go b/commands/pdp/accept.go index 91df730..2b740ed 100644 --- a/commands/pdp/accept.go +++ b/commands/pdp/accept.go @@ -2,6 +2,9 @@ package pdp -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var Accept = commands.MustParse[*AcceptArguments]("/pdp/accept") +var Accept = binding.Bind[*AcceptArguments, *AcceptOK](command.MustParse("/pdp/accept")) diff --git a/commands/pdp/info.go b/commands/pdp/info.go index 31d694a..6aec637 100644 --- a/commands/pdp/info.go +++ b/commands/pdp/info.go @@ -2,8 +2,11 @@ package pdp -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) const InfoCommand = "/pdp/info" -var Info = commands.MustParse[*InfoArguments]("/pdp/info") +var Info = binding.Bind[*InfoArguments, *InfoOK](command.MustParse(InfoCommand)) diff --git a/commands/pdp/sign/sign.go b/commands/pdp/sign/sign.go index fcd462c..800feee 100644 --- a/commands/pdp/sign/sign.go +++ b/commands/pdp/sign/sign.go @@ -3,7 +3,8 @@ package sign import ( - "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" ) // Every /pdp/sign/* operation returns the same shape; these per-operation @@ -16,8 +17,8 @@ type ( ) var ( - DataSetCreate = commands.MustParse[*DataSetCreateArguments]("/pdp/sign/dataset/create") - DataSetDelete = commands.MustParse[*DataSetDeleteArguments]("/pdp/sign/dataset/delete") - PiecesAdd = commands.MustParse[*PiecesAddArguments]("/pdp/sign/pieces/add") - PiecesRemoveSchedule = commands.MustParse[*PiecesRemoveScheduleArguments]("/pdp/sign/pieces/remove/schedule") + DataSetCreate = binding.Bind[*DataSetCreateArguments, *DataSetCreateOK](command.MustParse("/pdp/sign/dataset/create")) + DataSetDelete = binding.Bind[*DataSetDeleteArguments, *DataSetDeleteOK](command.MustParse("/pdp/sign/dataset/delete")) + PiecesAdd = binding.Bind[*PiecesAddArguments, *PiecesAddOK](command.MustParse("/pdp/sign/pieces/add")) + PiecesRemoveSchedule = binding.Bind[*PiecesRemoveScheduleArguments, *PiecesRemoveScheduleOK](command.MustParse("/pdp/sign/pieces/remove/schedule")) ) diff --git a/commands/provider/add.go b/commands/provider/add.go index ff6bd1b..df40e62 100644 --- a/commands/provider/add.go +++ b/commands/provider/add.go @@ -3,11 +3,12 @@ package provider import ( - "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" "github.com/fil-forge/ucantone/errors" + "github.com/fil-forge/ucantone/ucan/command" ) -var Add = commands.MustParse[*AddArguments]("/provider/add") +var Add = binding.Bind[*AddArguments, *AddOK](command.MustParse("/provider/add")) const ( InvalidAccountErrorName = "InvalidAccount" diff --git a/commands/space/egress/track.go b/commands/space/egress/track.go index 3cb2127..afb270e 100644 --- a/commands/space/egress/track.go +++ b/commands/space/egress/track.go @@ -2,11 +2,14 @@ package egress -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) // Track is the capability a storage node invokes to ask the egress // tracking service to record egress accounted for in a batch of // `/content/retrieve` receipts. The tracking service responds by forking // a `/space/egress/consolidate` sub-invocation onto the receipt's // effects; the typed OK return is empty. -var Track = commands.MustParse[*TrackArguments]("/space/egress/track") +var Track = binding.Bind[*TrackArguments, *TrackOK](command.MustParse("/space/egress/track")) diff --git a/commands/space/info.go b/commands/space/info.go index c97a3e5..d68f9a0 100644 --- a/commands/space/info.go +++ b/commands/space/info.go @@ -2,10 +2,14 @@ package space -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type InfoArguments = commands.Unit -var Info = commands.MustParse[*InfoArguments]("/space/info") +var Info = binding.Bind[*InfoArguments, *InfoOK](command.MustParse("/space/info")) const UnknownSpaceErrorName = "UnknownSpace" diff --git a/commands/ucan/attest/proof.go b/commands/ucan/attest/proof.go index cf64a8c..15c8ef7 100644 --- a/commands/ucan/attest/proof.go +++ b/commands/ucan/attest/proof.go @@ -2,10 +2,14 @@ package attest -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type ProofOK = commands.Unit // Issued by a trusted authority (usually the one handling invocation) that // attests a specific UCAN delegation has been considered authentic. -var Proof = commands.MustParse[*ProofArguments]("/ucan/attest/proof") +var Proof = binding.Bind[*ProofArguments, *ProofOK](command.MustParse("/ucan/attest/proof")) diff --git a/commands/ucan/conclude.go b/commands/ucan/conclude.go index 2b9b216..af5b3f0 100644 --- a/commands/ucan/conclude.go +++ b/commands/ucan/conclude.go @@ -4,12 +4,14 @@ package ucan import ( "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" "github.com/fil-forge/ucantone/errors" + "github.com/fil-forge/ucantone/ucan/command" ) type ConcludeOK = commands.Unit -var Conclude = commands.MustParse[*ConcludeArguments]("/ucan/conclude") +var Conclude = binding.Bind[*ConcludeArguments, *ConcludeOK](command.MustParse("/ucan/conclude")) const ConclusionReceiptNotFoundErrorName = "ConclusionReceiptNotFound" diff --git a/commands/upload/add.go b/commands/upload/add.go index 59d08b2..ca75ae1 100644 --- a/commands/upload/add.go +++ b/commands/upload/add.go @@ -2,8 +2,12 @@ package upload -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type AddOK = commands.Unit -var Add = commands.MustParse[*AddArguments]("/upload/add") +var Add = binding.Bind[*AddArguments, *AddOK](command.MustParse("/upload/add")) diff --git a/commands/upload/list.go b/commands/upload/list.go index 780da8d..7be55ae 100644 --- a/commands/upload/list.go +++ b/commands/upload/list.go @@ -2,6 +2,9 @@ package upload -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var List = commands.MustParse[*ListArguments]("/upload/list") +var List = binding.Bind[*ListArguments, *ListOK](command.MustParse("/upload/list")) diff --git a/commands/upload/remove.go b/commands/upload/remove.go index 875791a..62fbdab 100644 --- a/commands/upload/remove.go +++ b/commands/upload/remove.go @@ -2,8 +2,12 @@ package upload -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/libforge/commands" + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) type RemoveOK = commands.Unit -var Remove = commands.MustParse[*RemoveArguments]("/upload/remove") +var Remove = binding.Bind[*RemoveArguments, *RemoveOK](command.MustParse("/upload/remove")) diff --git a/commands/upload/shard/list.go b/commands/upload/shard/list.go index 0e9fb9d..1bb7ea5 100644 --- a/commands/upload/shard/list.go +++ b/commands/upload/shard/list.go @@ -2,6 +2,9 @@ package shard -import "github.com/fil-forge/libforge/commands" +import ( + "github.com/fil-forge/ucantone/binding" + "github.com/fil-forge/ucantone/ucan/command" +) -var List = commands.MustParse[*ListArguments]("/upload/shard/list") +var List = binding.Bind[*ListArguments, *ListOK](command.MustParse("/upload/shard/list")) diff --git a/go.mod b/go.mod index f93e16d..44741d9 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.25.3 require ( github.com/alanshaw/dag-json-gen v0.0.5 github.com/fil-forge/automobile v0.0.1 - github.com/fil-forge/ucantone v0.0.0-20260519193222-ad31490eaa10 + github.com/fil-forge/ucantone v0.0.0-20260521210642-84d8c533075b github.com/filecoin-project/go-data-segment v0.0.1 github.com/gobwas/glob v0.2.3 github.com/ipfs/go-cid v0.6.1 @@ -20,6 +20,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/filecoin-project/go-state-types v0.18.0 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/minio/sha256-simd v1.0.1 // indirect diff --git a/go.sum b/go.sum index 7a817f3..2d6326c 100644 --- a/go.sum +++ b/go.sum @@ -4,12 +4,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fil-forge/automobile v0.0.1 h1:9xB3yc4l5b9EdRJSJcNwudgBFNHoMPEAdcb7GfobLhA= github.com/fil-forge/automobile v0.0.1/go.mod h1:TsO7jlO8ykJZY5tF8j4GsUcu3F02lEzxO7ULoB61hRA= -github.com/fil-forge/ucantone v0.0.0-20260519193222-ad31490eaa10 h1:ApgWAIpXjCYjZw/yDxLn8IA9WrH/ENPRWCWPT/MoCvU= -github.com/fil-forge/ucantone v0.0.0-20260519193222-ad31490eaa10/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= +github.com/fil-forge/ucantone v0.0.0-20260521210642-84d8c533075b h1:ILG7dtSWiOO/fYiesqYj8Esm1qeIxFy7qkZoFdnjPpU= +github.com/fil-forge/ucantone v0.0.0-20260521210642-84d8c533075b/go.mod h1:XAVqsZwYoZ9vncjZoRUAJ+mL/ApLMFn9HHX7ipohVdY= github.com/filecoin-project/go-data-segment v0.0.1 h1:1wmDxOG4ubWQm3ZC1XI5nCon5qgSq7Ra3Rb6Dbu10Gs= github.com/filecoin-project/go-data-segment v0.0.1/go.mod h1:H0/NKbsRxmRFBcLibmABv+yFNHdmtl5AyplYLnb0Zv4= -github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88OqLYEo6roi+GiIeOh8= -github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= +github.com/filecoin-project/go-fil-commcid v0.2.0 h1:B+5UX8XGgdg/XsdUpST4pEBviKkFOw+Fvl2bLhSKGpI= +github.com/filecoin-project/go-fil-commcid v0.2.0/go.mod h1:8yigf3JDIil+/WpqR5zoKyP0jBPCOGtEqq/K1CcMy9Q= +github.com/filecoin-project/go-state-types v0.18.0 h1:oDcjihXRlf2cM176atZzllp79Zc+kcbiuQM9DPL/1a4= +github.com/filecoin-project/go-state-types v0.18.0/go.mod h1:CcyG4ZQRDWW+QUY2WDf1KtVDRN7W4twjsfgnGbQfJVI= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/ipfs/go-cid v0.6.1 h1:T5TnNb08+ueovG76Z5gx1L4Y7QOaGTXHg1F6raWFxIc= diff --git a/ucan/retrieval/server_test.go b/ucan/retrieval/server_test.go index 9b02d3b..9b4f013 100644 --- a/ucan/retrieval/server_test.go +++ b/ucan/retrieval/server_test.go @@ -8,18 +8,19 @@ import ( "net/url" "testing" + "github.com/fil-forge/ucantone/binding" "github.com/fil-forge/ucantone/execution" "github.com/fil-forge/ucantone/ipld/datamodel" "github.com/fil-forge/ucantone/testutil" + "github.com/fil-forge/ucantone/ucan/command" "github.com/fil-forge/ucantone/ucan/container" "github.com/fil-forge/ucantone/ucan/invocation" - "github.com/fil-forge/ucantone/validator/bindcom" "github.com/stretchr/testify/require" "github.com/fil-forge/libforge/ucan/retrieval" ) -var contentRetrieve, _ = bindcom.Parse[*datamodel.Map]("/content/retrieve") +var contentRetrieve = binding.Bind[*datamodel.Map, *datamodel.Map](command.MustParse("/content/retrieve")) func TestServer(t *testing.T) { service := testutil.RandomSigner(t)