feat(invocation): use dedicated type for invocation.Token.Arguments

This commit is contained in:
Steve Moyer
2024-11-07 13:50:20 -05:00
parent 11bc085c60
commit 1fa2b5e6fc
6 changed files with 16 additions and 45 deletions

View File

@@ -4,7 +4,6 @@ import (
"time"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime/datamodel"
"github.com/ucan-wg/go-ucan/did"
)
@@ -14,24 +13,9 @@ import (
type Option func(*Token) error
// WithArgument adds a key/value pair to the Token's Arguments field.
func WithArgument(key string, val datamodel.Node) Option {
func WithArgument(key string, val any) Option {
return func(t *Token) error {
t.arguments[key] = val
return nil
}
}
// WithArguments sets the Token's Arguments field to the provided map.
//
// Note that this will overwrite any existing Arguments whether provided
// by a previous call to this function or by one or more calls to
// WithArgument.
func WithArguments(args map[string]datamodel.Node) Option {
return func(t *Token) error {
t.arguments = args
return nil
return t.arguments.Add(key, val)
}
}