From bcdaf0cca3810e59525f0d7b96cbf622bc4ae23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Tue, 5 Nov 2024 17:39:39 +0100 Subject: [PATCH] invocation: round of cleanups/fixes --- token/invocation/examples_test.go | 1 + token/invocation/invocation.go | 27 +-------------------------- token/invocation/options.go | 1 + token/invocation/schema_test.go | 1 + 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/token/invocation/examples_test.go b/token/invocation/examples_test.go index ce1743f..f948041 100644 --- a/token/invocation/examples_test.go +++ b/token/invocation/examples_test.go @@ -15,6 +15,7 @@ import ( "github.com/ipld/go-ipld-prime/fluent/qp" "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/libp2p/go-libp2p/core/crypto" + "github.com/ucan-wg/go-ucan/did" "github.com/ucan-wg/go-ucan/pkg/command" "github.com/ucan-wg/go-ucan/token/invocation" diff --git a/token/invocation/invocation.go b/token/invocation/invocation.go index 0a44285..a1fdcb9 100644 --- a/token/invocation/invocation.go +++ b/token/invocation/invocation.go @@ -15,6 +15,7 @@ import ( "github.com/ipfs/go-cid" "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ucan-wg/go-ucan/did" "github.com/ucan-wg/go-ucan/pkg/command" "github.com/ucan-wg/go-ucan/pkg/meta" @@ -229,29 +230,3 @@ func generateNonce() ([]byte, error) { } return res, nil } - -func parseOptionalCID(c *cid.Cid) (*cid.Cid, error) { - if c == nil { - return nil, nil - } - - return c, nil -} - -func parseOptionalDID(s *string) (did.DID, error) { - if s == nil { - return did.Undef, nil - } - - return did.Parse(*s) -} - -func parseOptionalTimestamp(sec *int64) (*time.Time, error) { - if sec == nil { - return nil, nil - } - - t := time.Unix(*sec, 0) - - return &t, nil -} diff --git a/token/invocation/options.go b/token/invocation/options.go index f2f870a..1c557b9 100644 --- a/token/invocation/options.go +++ b/token/invocation/options.go @@ -5,6 +5,7 @@ import ( "github.com/ipfs/go-cid" "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ucan-wg/go-ucan/did" ) diff --git a/token/invocation/schema_test.go b/token/invocation/schema_test.go index 92483ac..77b1afb 100644 --- a/token/invocation/schema_test.go +++ b/token/invocation/schema_test.go @@ -79,6 +79,7 @@ func TestSchemaRoundTrip(t *testing.T) { assert.JSONEq(t, string(invocationJson), readJson.String()) }) } + func privKey(t require.TestingT, privKeyCfg string) crypto.PrivKey { privKeyMar, err := crypto.ConfigDecodeKey(privKeyCfg) require.NoError(t, err)