From d488bc4a5e70445a62f978b0bc7df131b3e7f0c5 Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Mon, 2 Oct 2023 17:20:00 +0200 Subject: [PATCH] Fix #311 - Add Cold Committee Key text envelope --- cabal.project | 2 +- cardano-cli/cardano-cli.cabal | 2 +- cardano-cli/src/Cardano/CLI/Read.hs | 3 ++ .../Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs | 37 +++++++++++++++++++ .../files/golden/conway/cold1-cc.skey | 5 +++ .../cardano-cli-golden/files/input/conway/tx | 5 +++ flake.lock | 6 +-- 7 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/conway/cold1-cc.skey create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/conway/tx diff --git a/cabal.project b/cabal.project index 5d31bd9478..0d7e656bc1 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- you need to run if you change them index-state: , hackage.haskell.org 2023-08-08T19:56:09Z - , cardano-haskell-packages 2023-10-01T12:37:02Z + , cardano-haskell-packages 2023-10-03T08:51:40Z packages: cardano-cli diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 30a434b616..c4d9c22ce5 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -200,7 +200,7 @@ library , binary , bytestring , canonical-json - , cardano-api ^>= 8.23.1 + , cardano-api ^>= 8.23.2 , cardano-binary , cardano-crypto , cardano-crypto-class ^>= 2.1.2 diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index ca5491fc8f..52c5b8be1e 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -619,6 +619,7 @@ data SomeSigningWitness | AGenesisDelegateExtendedSigningWitness (SigningKey GenesisDelegateExtendedKey) | AGenesisUTxOSigningWitness (SigningKey GenesisUTxOKey) | ADRepSigningWitness (SigningKey DRepKey) + | ACommitteeSigningWitness (SigningKey CommitteeColdKey) -- | Data required for constructing a Shelley bootstrap witness. @@ -652,6 +653,7 @@ categoriseSomeSigningWitness swsk = AGenesisDelegateExtendedSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisDelegateExtendedKey sk) AGenesisUTxOSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisUTxOKey sk) ADRepSigningWitness sk -> AShelleyKeyWitness (WitnessPaymentKey $ castDrep sk) + ACommitteeSigningWitness sk -> AShelleyKeyWitness (WitnessCommitteeColdKey sk) -- TODO: Conway era - Add constrctor for SigningKey DrepKey to ShelleyWitnessSigningKey castDrep :: SigningKey DRepKey -> SigningKey PaymentKey @@ -704,6 +706,7 @@ readWitnessSigningData (KeyWitnessSigningData skFile mbByronAddr) = do , FromSomeType (AsSigningKey AsGenesisDelegateExtendedKey ) AGenesisDelegateExtendedSigningWitness , FromSomeType (AsSigningKey AsGenesisUTxOKey ) AGenesisUTxOSigningWitness , FromSomeType (AsSigningKey AsDRepKey ) ADRepSigningWitness + , FromSomeType (AsSigningKey AsCommitteeColdKey ) ACommitteeSigningWitness ] bech32FileTypes = diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs index df890563df..62a3bb7bc1 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs @@ -47,3 +47,40 @@ hprop_golden_shelleyTx = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Check the newly created files have not deviated from the -- golden files checkTxCddlFormat referenceTx transactionFile + + +hprop_golden_checkIfConstitutionalCommitteeKeyCanSign :: Property +hprop_golden_checkIfConstitutionalCommitteeKeyCanSign = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + -- Reference keys + let referenceTx = "test/cardano-cli-golden/files/input/conway/tx" + + -- Key filepaths + paymentSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-sign/utxo.skey" + -- constitutional committee signing key + paymentSignKey2 <- noteInputFile "test/cardano-cli-golden/files/golden/conway/cold1-cc.skey" + transactionFile <- noteTempFile tempDir "tx-file" + transactionBodyFile <- noteTempFile tempDir "tx-body-file" + + -- Create transaction body + void $ execCardanoCLI + [ "conway", "transaction", "build-raw" + , "--tx-in", "f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d#0" + , "--tx-out", "addr_test1qpmxr8d8jcl25kyz2tz9a9sxv7jxglhddyf475045y8j3zxjcg9vquzkljyfn3rasfwwlkwu7hhm59gzxmsyxf3w9dps8832xh+1199989833223" + , "--tx-out", "addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4+10000000" + , "--fee", "166777" + , "--out-file", transactionBodyFile + ] + + -- Sign transaction + void $ execCardanoCLI + [ "transaction", "sign" + , "--tx-body-file", transactionBodyFile + , "--signing-key-file", paymentSignKey + , "--signing-key-file", paymentSignKey2 + , "--testnet-magic", "42" + , "--out-file", transactionFile + ] + + -- Check the newly created files have not deviated from the + -- golden files + checkTxCddlFormat referenceTx transactionFile diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/conway/cold1-cc.skey b/cardano-cli/test/cardano-cli-golden/files/golden/conway/cold1-cc.skey new file mode 100644 index 0000000000..4b6b7ff107 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/conway/cold1-cc.skey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeColdSigningKey_ed25519", + "description": "Constitutional Committee Cold Signing Key", + "cborHex": "5820f213c36a77aea6174875b778d8cc60b4c5a3f47eb3a75c11effe64d2b7ce34db" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/conway/tx b/cardano-cli/test/cardano-cli-golden/files/input/conway/tx new file mode 100644 index 0000000000..159aa406c6 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/conway/tx @@ -0,0 +1,5 @@ +{ + "type": "Witnessed Tx ConwayEra", + "description": "Ledger Cddl Format", + "cborHex": "84a30081825820f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d000182a20058390076619da7963eaa588252c45e960667a4647eed69135f51f5a10f2888d2c20ac07056fc8899c47d825cefd9dcf5efba150236e043262e2b43011b0000011764f7be07a200581d604088059bbeb6add02eecd0c6a2a52c06910f2a6b4ba0029e9fe6ed13011a00989680021a00028b79a100828258208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea4234275840963b5af8b899f154f35cb9effe40474035dad7f403fe5b1a7e70690f69971683b7c99da2fab04e02a28a765815eab76b9c4c8f0cd5b407a8e1cd7e214478560f825820ccb96e5d87424375c30b5d1539be8beca496bd87f48d8a4111145c92575dc22458403531dba28f0eafdd77363efc135ec56ec2e118506b61a26c6f8089aa17402532afc2bd16d92009263b749d49cfe0b97289ba73293e1c18af0c1605cadbe5270cf5f6" +} diff --git a/flake.lock b/flake.lock index 64d1bf1a8a..7f8e4a6b6f 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1696197224, - "narHash": "sha256-dLz7+qtfK92aA6oW5Ybz+ybhZW34La9etWDr6GNWlBg=", + "lastModified": 1696323677, + "narHash": "sha256-HeJucJp1o8VoKW3Z3Mw8R0OBCAs9oANhtaMVrICTz7g=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "ffb9ee2dfbf65c4b41d750021c04be3b9b76952c", + "rev": "3191a4624f848fa366b44e179e4bb8ca37181efa", "type": "github" }, "original": {