@@ -23,6 +23,7 @@ type Arguments interface {
2323
2424type Task [A Arguments ] struct {
2525 * invocation.Task
26+ args A
2627}
2728
2829func NewTask [A Arguments ](
@@ -31,26 +32,26 @@ func NewTask[A Arguments](
3132 arguments ipld.Map ,
3233 nonce ucan.Nonce ,
3334) (* Task [A ], error ) {
34- task , err := invocation .NewTask (subject , command , arguments , nonce )
35- if err != nil {
36- return nil , err
37- }
38- return & Task [A ]{Task : task }, nil
39- }
40-
41- // BindArguments binds the arguments to the arguments type for this task.
42- func (t * Task [A ]) BindArguments () (A , error ) {
4335 var args A
4436 // if args is a pointer type, then we need to create an instance of it because
4537 // rebind requires a non-nil pointer.
4638 typ := reflect .TypeOf (args )
4739 if typ .Kind () == reflect .Ptr {
4840 args = reflect .New (typ .Elem ()).Interface ().(A )
4941 }
50- if err := datamodel .Rebind (datamodel .Map (t . Arguments () ), args ); err != nil {
51- return args , verrs .NewMalformedArgumentsError (t . Command () , err )
42+ if err := datamodel .Rebind (datamodel .Map (arguments ), args ); err != nil {
43+ return nil , verrs .NewMalformedArgumentsError (command , err )
5244 }
53- return args , nil
45+ task , err := invocation .NewTask (subject , command , arguments , nonce )
46+ if err != nil {
47+ return nil , err
48+ }
49+ return & Task [A ]{Task : task , args : args }, nil
50+ }
51+
52+ // BindArguments returns the arguments bound to the type for this task.
53+ func (t * Task [A ]) BindArguments () A {
54+ return t .args
5455}
5556
5657var _ ucan.Task = (* Task [Arguments ])(nil )
@@ -61,6 +62,8 @@ type Match[A Arguments] struct {
6162 Proofs map [cid.Cid ]ucan.Delegation
6263}
6364
65+ // Capability is a capability that can be used to validate an invocation and its
66+ // proofs.
6467type Capability [A Arguments ] struct {
6568 cmd ucan.Command
6669 pol ucan.Policy
0 commit comments