https://github.com/bluesky-social/goat but with tangled's CI
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

goat plc calc-did

+48 -1
+48 -1
plc.go
··· 9 9 "strings" 10 10 "time" 11 11 12 + "github.com/bluesky-social/indigo/atproto/crypto" 12 13 "github.com/bluesky-social/indigo/atproto/identity" 13 14 "github.com/bluesky-social/indigo/atproto/syntax" 14 - "github.com/bluesky-social/indigo/atproto/crypto" 15 15 "github.com/bluesky-social/indigo/util" 16 16 17 17 "github.com/did-method-plc/go-didplc" ··· 96 96 }, 97 97 }, 98 98 Action: runPLCGenesis, 99 + }, 100 + &cli.Command{ 101 + Name: "calc-did", 102 + Usage: "calculate the DID corresponding to a signed PLC operation (input in JSON format)", 103 + ArgsUsage: `<genesis.json>`, 104 + Flags: []cli.Flag{}, 105 + Action: runPLCCalcDID, 99 106 }, 100 107 }, 101 108 } ··· 400 407 401 408 return nil 402 409 } 410 + 411 + func runPLCCalcDID(cctx *cli.Context) error { 412 + s := cctx.Args().First() 413 + if s == "" { 414 + return fmt.Errorf("need to provide genesis json path as input") 415 + } 416 + 417 + inputReader, err := getFileOrStdin(s) 418 + if err != nil { 419 + return err 420 + } 421 + 422 + inBytes, err := io.ReadAll(inputReader) 423 + if err != nil { 424 + return err 425 + } 426 + 427 + var enum didplc.OpEnum 428 + if err := json.Unmarshal(inBytes, &enum); err != nil { 429 + return err 430 + } 431 + op := enum.AsOperation() 432 + 433 + if !op.IsGenesis() { 434 + return fmt.Errorf("not a genesis op") 435 + } 436 + 437 + if !op.IsSigned() { 438 + return fmt.Errorf("genesis op must be signed") 439 + } 440 + 441 + didplc, err := op.DID() 442 + if err != nil { 443 + return err 444 + } 445 + 446 + fmt.Println(didplc) 447 + 448 + return nil 449 + }