diff --git a/Cargo.lock b/Cargo.lock index 4d803bb49..cb022710a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -661,7 +661,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chainhook-sdk" version = "0.12.5" -source = "git+https://github.com/hirosystems/chainhook.git?rev=ac59025#ac59025280d76180ca72a5aa1b9c4214573be64c" +source = "git+https://github.com/hirosystems/chainhook.git?branch=chore/update-clarinet-and-clarity#ccd1be54d401cec59ac2fb33a2510a3e06b17f6d" dependencies = [ "base58 0.2.0", "base64 0.21.7", @@ -687,7 +687,7 @@ dependencies = [ "serde-hex", "serde_derive", "serde_json", - "stacks-rpc-client 2.2.1", + "stacks-rpc-client 2.3.1 (git+https://github.com/hirosystems/clarinet.git?branch=feat/update-stacks-core)", "threadpool", "tokio", ] @@ -695,7 +695,7 @@ dependencies = [ [[package]] name = "chainhook-types" version = "1.3.3" -source = "git+https://github.com/hirosystems/chainhook.git?rev=ac59025#ac59025280d76180ca72a5aa1b9c4214573be64c" +source = "git+https://github.com/hirosystems/chainhook.git?branch=chore/update-clarinet-and-clarity#ccd1be54d401cec59ac2fb33a2510a3e06b17f6d" dependencies = [ "hex 0.4.3", "schemars", @@ -782,7 +782,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "clar2wasm" version = "0.1.0" -source = "git+https://github.com/stacks-network/clarity-wasm.git?rev=b12002d#b12002d9576a9ebf90e5ddca3bf2fffb2bf12975" +source = "git+https://github.com/stacks-network/clarity-wasm.git#bcda26f40779ddb8222687a1bbc4e7a53ff02924" dependencies = [ "clap", "clarity", @@ -906,6 +906,7 @@ dependencies = [ "colored 2.1.0", "console_error_panic_hook", "gloo-utils", + "hashbrown 0.14.3", "js-sys", "serde", "serde-wasm-bindgen", @@ -926,13 +927,15 @@ dependencies = [ [[package]] name = "clarity" -version = "2.2.0" -source = "git+https://github.com/stacks-network/stacks-core.git?rev=1e9df56b255247928679961d0a7c2541ad127f59#1e9df56b255247928679961d0a7c2541ad127f59" +version = "2.3.0" +source = "git+https://github.com/stacks-network/stacks-core.git?branch=feat/clarity-wasm-next#2ab366d28d473f204b67a431ba8b522c0c9a8e78" dependencies = [ + "getrandom 0.2.8", + "hashbrown 0.14.3", "integer-sqrt", "lazy_static", - "rand 0.7.3", - "rand_chacha 0.2.2", + "rand 0.8.5", + "rand_chacha 0.3.1", "regex", "rusqlite", "serde", @@ -999,28 +1002,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "clarity-repl" -version = "2.2.1" -source = "git+https://github.com/hirosystems/clarinet.git?rev=1458e224#1458e224d6aa8b53f49f50d880d6d0d078454438" -dependencies = [ - "ansi_term", - "atty", - "chrono", - "clarity", - "getrandom 0.2.8", - "hiro-system-kit 0.1.0 (git+https://github.com/hirosystems/clarinet.git?rev=1458e224)", - "integer-sqrt", - "lazy_static", - "regex", - "reqwest", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.6", - "wsts 7.0.0", -] - [[package]] name = "clarity-repl" version = "2.3.1" @@ -1053,16 +1034,29 @@ dependencies = [ "tokio-util", "wasm-bindgen", "wasm-bindgen-futures", - "wsts 7.0.0", + "wsts", ] [[package]] -name = "clear_on_drop" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38508a63f4979f0048febc9966fadbd48e5dab31fd0ec6a3f151bbf4a74f7423" +name = "clarity-repl" +version = "2.3.1" +source = "git+https://github.com/hirosystems/clarinet.git?branch=feat/update-stacks-core#11f77eebff53776838c3f64308423f531b5468c3" dependencies = [ - "cc", + "ansi_term", + "atty", + "chrono", + "clarity", + "getrandom 0.2.8", + "hiro-system-kit 0.1.0 (git+https://github.com/hirosystems/clarinet.git?branch=feat/update-stacks-core)", + "integer-sqrt", + "lazy_static", + "regex", + "reqwest", + "serde", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "wsts", ] [[package]] @@ -1123,6 +1117,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "cookie" version = "0.17.0" @@ -1161,9 +1161,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -1451,6 +1451,34 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle 2.4.1", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] + [[package]] name = "cxx" version = "1.0.90" @@ -1528,6 +1556,16 @@ dependencies = [ "uuid", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -1657,17 +1695,30 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "serde", + "signature", +] + [[package]] name = "ed25519-dalek" -version = "1.0.0-pre.3" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ - "clear_on_drop", - "curve25519-dalek", - "rand 0.7.3", + "curve25519-dalek 4.1.2", + "ed25519", + "rand_core 0.6.4", "serde", - "sha2 0.8.2", + "sha2 0.10.6", + "subtle 2.4.1", + "zeroize", ] [[package]] @@ -1789,6 +1840,12 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "fiat-crypto" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" + [[package]] name = "figment" version = "0.10.12" @@ -2206,7 +2263,7 @@ dependencies = [ [[package]] name = "hiro-system-kit" version = "0.1.0" -source = "git+https://github.com/hirosystems/clarinet.git?rev=1458e224#1458e224d6aa8b53f49f50d880d6d0d078454438" +source = "git+https://github.com/hirosystems/clarinet.git?branch=feat/update-stacks-core#11f77eebff53776838c3f64308423f531b5468c3" dependencies = [ "ansi_term", "atty", @@ -3233,9 +3290,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "p256k1" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5afcf536d20c074ef45371ee9a654dcfc46fb2dde18ecc54ec30c936eb850fa2" +checksum = "3a64d160b891178fb9d43d1a58ddcafb6502daeb54d810e5e92a7c3c9bfacc07" dependencies = [ "bitvec", "bs58 0.4.0", @@ -3398,12 +3455,28 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +[[package]] +name = "platforms" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" + [[package]] name = "polynomial" version = "0.2.6" @@ -3999,6 +4072,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.16", +] + [[package]] name = "rustfmt-wrapper" version = "0.2.1" @@ -4483,6 +4565,15 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "similar" version = "2.2.1" @@ -4615,6 +4706,16 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "sptr" version = "0.3.2" @@ -4662,17 +4763,19 @@ dependencies = [ [[package]] name = "stacks-common" version = "0.0.2" -source = "git+https://github.com/stacks-network/stacks-core.git?branch=feat/clarity-wasm-next#1e9df56b255247928679961d0a7c2541ad127f59" +source = "git+https://github.com/stacks-network/stacks-core.git?branch=feat/clarity-wasm-next#2ab366d28d473f204b67a431ba8b522c0c9a8e78" dependencies = [ "chrono", - "curve25519-dalek", + "curve25519-dalek 2.0.0", "ed25519-dalek", + "getrandom 0.2.8", + "hashbrown 0.14.3", "lazy_static", "libc", "libsecp256k1 0.5.0", "nix 0.23.2", "percent-encoding", - "rand 0.7.3", + "rand 0.8.5", "ripemd", "rusqlite", "secp256k1 0.24.3", @@ -4686,7 +4789,7 @@ dependencies = [ "slog-term", "time", "winapi", - "wsts 6.1.0", + "wsts", ] [[package]] @@ -4744,10 +4847,9 @@ dependencies = [ [[package]] name = "stacks-rpc-client" -version = "2.2.1" -source = "git+https://github.com/hirosystems/clarinet.git?rev=1458e224#1458e224d6aa8b53f49f50d880d6d0d078454438" +version = "2.3.1" dependencies = [ - "clarity-repl 2.2.1", + "clarity-repl 2.3.1", "hmac 0.12.1", "libsecp256k1 0.7.1", "pbkdf2", @@ -4762,8 +4864,9 @@ dependencies = [ [[package]] name = "stacks-rpc-client" version = "2.3.1" +source = "git+https://github.com/hirosystems/clarinet.git?branch=feat/update-stacks-core#11f77eebff53776838c3f64308423f531b5468c3" dependencies = [ - "clarity-repl 2.3.1", + "clarity-repl 2.3.1 (git+https://github.com/hirosystems/clarinet.git?branch=feat/update-stacks-core)", "hmac 0.12.1", "libsecp256k1 0.7.1", "pbkdf2", @@ -6173,31 +6276,9 @@ dependencies = [ [[package]] name = "wsts" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c7db3d3fe28c359e0cdb7f7ad83e3316bda0ba982b8cd1bf0fbe73ae4127e4b" -dependencies = [ - "aes-gcm", - "bs58 0.5.0", - "hashbrown 0.14.3", - "hex 0.4.3", - "num-traits", - "p256k1", - "polynomial", - "primitive-types", - "rand_core 0.6.4", - "serde", - "sha2 0.10.6", - "thiserror", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "wsts" -version = "7.0.0" +version = "8.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c398736468f3322a43b6419be5315e68ae035e6565628603503c2a62ad726f36" +checksum = "467aa8e40ed0277d19922fd0e7357c16552cb900e5138f61a48ac23c4b7878e0" dependencies = [ "aes-gcm", "bs58 0.5.0", diff --git a/components/clarinet-cli/Cargo.toml b/components/clarinet-cli/Cargo.toml index 458fd11ea..77315baab 100644 --- a/components/clarinet-cli/Cargo.toml +++ b/components/clarinet-cli/Cargo.toml @@ -21,7 +21,7 @@ ansi_term = "0.12.1" clap = { version = "4.4.8", features = ["derive"], optional = true } clap_complete = { version = "4.4.4", optional = true } toml = { version = "0.5.6", features = ["preserve_order"] } -serde = { version = "1.0.136", features = ["derive"] } +serde = { version = "1", features = ["derive"] } serde_json = { version = "1.0.79", features = ["preserve_order"] } serde_derive = "1" log = { version = "=0.4.17", features = ["serde"] } diff --git a/components/clarinet-files/Cargo.toml b/components/clarinet-files/Cargo.toml index 22c813a78..f2d09e23e 100644 --- a/components/clarinet-files/Cargo.toml +++ b/components/clarinet-files/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" serde = "1" serde_derive = "1" # chainhook-types = "1.2" -chainhook-types = { version = "1.2", git = "https://github.com/hirosystems/chainhook.git", rev="ac59025" } +chainhook-types = { version = "1.2", git = "https://github.com/hirosystems/chainhook.git", branch="chore/update-clarinet-and-clarity" } bip39 = { version = "1.0.1", default-features = false } libsecp256k1 = "0.7.0" toml = { version = "0.5.6", features = ["preserve_order"] } diff --git a/components/clarinet-sdk-wasm/Cargo.toml b/components/clarinet-sdk-wasm/Cargo.toml index b1c27ed00..62e805828 100644 --- a/components/clarinet-sdk-wasm/Cargo.toml +++ b/components/clarinet-sdk-wasm/Cargo.toml @@ -15,13 +15,14 @@ path = "src/lib.rs" console_error_panic_hook = { version = "0.1", optional = true } gloo-utils = { version = "0.2", features = ["serde"] } js-sys = { version = "0.3", optional = true } -serde = { version = "1.0.136", features = ["derive"] } +serde = { version = "1", features = ["derive"] } serde_json = "1.0" serde-wasm-bindgen = { version = "0.6.4", optional = true } wasm-bindgen = { version = "0.2.91", optional = true } wasm-bindgen-futures = { version = "0.4.41", optional = true } web-sys = { version = "0.3", features = ["console"], optional = true } colored = "2.1.0" +hashbrown = { version = "0.14.3", features = ["serde"]} clarinet-files = { path = "../clarinet-files", default-features = false } clarity-repl = { path = "../clarity-repl", default-features = false, optional = true } diff --git a/components/clarinet-sdk-wasm/src/utils/events.rs b/components/clarinet-sdk-wasm/src/utils/events.rs index c001be785..2f438fbf8 100644 --- a/components/clarinet-sdk-wasm/src/utils/events.rs +++ b/components/clarinet-sdk-wasm/src/utils/events.rs @@ -29,7 +29,9 @@ pub fn serialize_event(event: &StacksTransactionEvent) -> StacksEvent { match event { StacksTransactionEvent::SmartContractEvent(data) => StacksEvent { event: "print_event".into(), - data: data.json_serialize(), + data: data + .json_serialize() + .expect("failed to serialize smart contract event"), }, StacksTransactionEvent::STXEvent(STXEventType::STXTransferEvent(data)) => StacksEvent { event: "stx_transfer_event".into(), @@ -49,15 +51,21 @@ pub fn serialize_event(event: &StacksTransactionEvent) -> StacksEvent { }, StacksTransactionEvent::NFTEvent(NFTEventType::NFTTransferEvent(data)) => StacksEvent { event: "nft_transfer_event".into(), - data: data.json_serialize(), + data: data + .json_serialize() + .expect("failed to serialize nft transfer event"), }, StacksTransactionEvent::NFTEvent(NFTEventType::NFTMintEvent(data)) => StacksEvent { event: "nft_mint_event".into(), - data: data.json_serialize(), + data: data + .json_serialize() + .expect("failed to serialize nft mint event"), }, StacksTransactionEvent::NFTEvent(NFTEventType::NFTBurnEvent(data)) => StacksEvent { event: "nft_burn_event".into(), - data: data.json_serialize(), + data: data + .json_serialize() + .expect("failed to serialize nft burn event"), }, StacksTransactionEvent::FTEvent(FTEventType::FTTransferEvent(data)) => StacksEvent { event: "ft_transfer_event".into(), diff --git a/components/clarinet-sdk/tests/pox-locking.test.ts b/components/clarinet-sdk/tests/pox-locking.test.ts new file mode 100644 index 000000000..273f43aa0 --- /dev/null +++ b/components/clarinet-sdk/tests/pox-locking.test.ts @@ -0,0 +1,240 @@ +import crypto from "crypto"; +import { describe, expect, it, beforeEach } from "vitest"; + +import { Pox4SignatureTopic, StackingClient, poxAddressToTuple } from "@stacks/stacking"; +import { StacksDevnet } from "@stacks/network"; +import { getPublicKeyFromPrivate, publicKeyToBtcAddress } from "@stacks/encryption"; +import { + Cl, + ClarityType, + getAddressFromPrivateKey, + TransactionVersion, + createStacksPrivateKey, +} from "@stacks/transactions"; + +// test the built package and not the source code +// makes it simpler to handle wasm build +import { Simnet, initSimnet } from "../dist/esm"; + +const MAX_U128 = 340282366920938463463374607431768211455n; +const maxAmount = MAX_U128; + +const randInt = () => crypto.randomInt(0, 0xffffffffffff); + +const address1 = "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5"; +const address2 = "ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG"; +const poxDeployer = "ST000000000000000000002AMW42H"; + +let simnet: Simnet; + +const initialSTXBalance = 100_000_000 * 1e6; + +describe("test pox-3", () => { + const poxContract = `${poxDeployer}.pox-3`; + beforeEach(async () => { + simnet = await initSimnet("tests/fixtures/Clarinet.toml"); + simnet.setEpoch("2.4"); + }); + + const ustxAmount = initialSTXBalance * 0.9; // lock 90% of the initial balance + + it("can transfer-stx", () => { + // safe check that address1 can transfer 90% of its balance if not locked + const transfer = simnet.transferSTX(ustxAmount, address2, address1); + expect(transfer.result).toStrictEqual(Cl.ok(Cl.bool(true))); + }); + + it("can call is-pox-active", () => { + const isPoxActive = simnet.callReadOnlyFn( + poxContract, + "is-pox-active", + [Cl.uint(100)], + address1, + ); + expect(isPoxActive.result).toStrictEqual(Cl.bool(true)); + }); + + it("can stack-stx on pox-3", () => { + const stackStxArgs = [ + Cl.uint(ustxAmount), + Cl.tuple({ + version: Cl.bufferFromHex("00"), + hashbytes: Cl.bufferFromHex("7321b74e2b6a7e949e6c4ad313035b1665095017"), + }), + Cl.uint(0), + Cl.uint(1), + ]; + const stackStx = simnet.callPublicFn(poxContract, "stack-stx", stackStxArgs, address1); + expect(stackStx.events).toHaveLength(2); + expect(stackStx.result).toStrictEqual( + Cl.ok( + Cl.tuple({ + "lock-amount": Cl.uint(ustxAmount), + "unlock-burn-height": Cl.uint(2100), + stacker: Cl.principal(address1), + }), + ), + ); + + const stxAccount = simnet.runSnippet(`(stx-account '${address1})`); + expect(stxAccount).toStrictEqual( + Cl.tuple({ + locked: Cl.uint(ustxAmount), + unlocked: Cl.uint(initialSTXBalance - ustxAmount), + "unlock-height": Cl.uint(2100), + }), + ); + + const transfer = simnet.transferSTX(ustxAmount, address2, address1); + expect(transfer.result).toStrictEqual(Cl.error(Cl.uint(1))); + }); + + it("unlocks stx after a certain number of blocks", () => { + const stackStxArgs = [ + Cl.uint(ustxAmount), + Cl.tuple({ + version: Cl.bufferFromHex("00"), + hashbytes: Cl.bufferFromHex("7321b74e2b6a7e949e6c4ad313035b1665095017"), + }), + Cl.uint(0), + Cl.uint(1), + ]; + simnet.callPublicFn(poxContract, "stack-stx", stackStxArgs, address1); + + simnet.mineEmptyBlocks(2098); + const stxAccountBefore = simnet.runSnippet(`(stx-account '${address1})`); + expect(stxAccountBefore).toStrictEqual( + Cl.tuple({ + locked: Cl.uint(ustxAmount), + unlocked: Cl.uint(initialSTXBalance - ustxAmount), + "unlock-height": Cl.uint(2100), + }), + ); + + simnet.mineEmptyBlocks(1); + const stxAccountAfter = simnet.runSnippet(`(stx-account '${address1})`); + expect(stxAccountAfter).toStrictEqual( + Cl.tuple({ + locked: Cl.uint(0), + unlocked: Cl.uint(initialSTXBalance), + "unlock-height": Cl.uint(0), + }), + ); + }); +}); + +describe("test pox-4", () => { + const poxContract = `${poxDeployer}.pox-4`; + + // wallet_1, wallet_2, wallet_3 private keys + const stackingKeys = [ + "7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801", + "530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101", + ]; + + const accounts = stackingKeys.map((privKey) => { + const network = new StacksDevnet(); + + const pubKey = getPublicKeyFromPrivate(privKey); + const stxAddress = getAddressFromPrivateKey(privKey, TransactionVersion.Testnet); + const signerPrivKey = createStacksPrivateKey(privKey); + const signerPubKey = getPublicKeyFromPrivate(signerPrivKey.data); + + return { + privKey, + pubKey, + stxAddress, + btcAddr: publicKeyToBtcAddress(pubKey), + signerPrivKey: signerPrivKey, + signerPubKey: signerPubKey, + client: new StackingClient(stxAddress, { + ...network, + transactionVersion: network.version, + magicBytes: "X2", + peerNetworkId: network.chainId, + }), + }; + }); + + const stackingThreshold = 50000000000; + + beforeEach(async () => { + simnet = await initSimnet("tests/fixtures/Clarinet.toml"); + simnet.setEpoch("3.0"); + }); + + it("can call get-pox-info", async () => { + const poxInfo = simnet.callReadOnlyFn(poxContract, "get-pox-info", [], address1); + expect(poxInfo.result.type).toBe(ClarityType.ResponseOk); + }); + + it("can call get-pox-info", async () => { + const account = accounts[0]; + const rewardCycle = 0; + const burnBlockHeight = 0; + const period = 1; + const authId = randInt(); + const poxInfo = simnet.callReadOnlyFn(poxContract, "get-pox-info", [], address1); + + expect(poxInfo.result.type).toBe(ClarityType.ResponseOk); + + expect(poxInfo.result).toHaveProperty("value.data.min-amount-ustx", Cl.uint(stackingThreshold)); + expect(poxInfo.result).toHaveProperty("value.data.reward-cycle-id", Cl.uint(rewardCycle)); + + const sigArgs = { + authId, + maxAmount, + rewardCycle, + period, + topic: Pox4SignatureTopic.StackStx, + poxAddress: account.btcAddr, + signerPrivateKey: account.signerPrivKey, + }; + const signerSignature = account.client.signPoxSignature(sigArgs); + const ustxAmount = Math.floor(stackingThreshold * 1.5); + + /* + (stack-stx (amount-ustx uint) + (pox-addr (tuple (version (buff 1)) (hashbytes (buff 32)))) + (start-burn-ht uint) + (lock-period uint) + (signer-sig (optional (buff 65))) + (signer-key (buff 33)) + (max-amount uint) + (auth-id uint)) + */ + + const stackStxArgs = [ + Cl.uint(ustxAmount), + poxAddressToTuple(account.btcAddr), + Cl.uint(burnBlockHeight), + Cl.uint(period), + Cl.some(Cl.bufferFromHex(signerSignature)), + Cl.bufferFromHex(account.signerPubKey), + Cl.uint(maxAmount), + Cl.uint(authId), + ]; + + const stackStx = simnet.callPublicFn(poxContract, "stack-stx", stackStxArgs, address1); + + expect(stackStx.result).toStrictEqual( + Cl.ok( + Cl.tuple({ + "lock-amount": Cl.uint(75000000000), + "signer-key": Cl.bufferFromHex(account.signerPubKey), + stacker: Cl.principal(address1), + "unlock-burn-height": Cl.uint(2100), + }), + ), + ); + + const stxAccount = simnet.runSnippet(`(stx-account '${address1})`); + expect(stxAccount).toStrictEqual( + Cl.tuple({ + locked: Cl.uint(ustxAmount), + unlocked: Cl.uint(initialSTXBalance - ustxAmount), + "unlock-height": Cl.uint(2100), + }), + ); + }); +}); diff --git a/components/clarity-events/Cargo.toml b/components/clarity-events/Cargo.toml index 1d443d9b1..e27d3417a 100644 --- a/components/clarity-events/Cargo.toml +++ b/components/clarity-events/Cargo.toml @@ -8,7 +8,7 @@ clarinet-files = { path = "../clarinet-files", default-features = false, optiona clarity-repl = { path = "../clarity-repl", default-features = false } clap = { version = "4.4.8", features = ["derive"], optional = true } toml = { version = "0.5.6", features = ["preserve_order"], optional = true } -serde = { version = "1.0.136", features = ["derive"] } +serde = { version = "1", features = ["derive"] } serde_json = { version = "1.0.79", features = ["preserve_order"] } serde_derive = "1" diff --git a/components/clarity-events/src/analysis/mod.rs b/components/clarity-events/src/analysis/mod.rs index 08fb6e40d..13f69b97d 100644 --- a/components/clarity-events/src/analysis/mod.rs +++ b/components/clarity-events/src/analysis/mod.rs @@ -538,7 +538,7 @@ pub fn serialize_type_signature( SymbolicExpressionType::LiteralValue(value), ) => { json!({ - "value": value.clone().expect_ascii(), + "value": value.clone().expect_ascii().expect("failed to parse ascii"), "type": "string", }) } @@ -656,14 +656,19 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &amount.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.amount = Some(value.clone().expect_u128()); + data.amount = Some(value.clone().expect_u128().expect("failed to parse u128")); } _ => {} } match &sender.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.sender = Some(value.clone().expect_principal()); + data.sender = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -685,21 +690,31 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &amount.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.amount = Some(value.clone().expect_u128()); + data.amount = Some(value.clone().expect_u128().expect("failed to parse u128")); } _ => {} } match &sender.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.sender = Some(value.clone().expect_principal()); + data.sender = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } match &recipient.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.recipient = Some(value.clone().expect_principal()); + data.recipient = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -720,14 +735,19 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &amount.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.amount = Some(value.clone().expect_u128()); + data.amount = Some(value.clone().expect_u128().expect("failed to parse u128")); } _ => {} } match &sender.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.sender = Some(value.clone().expect_principal()); + data.sender = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -749,21 +769,31 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &amount.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.amount = Some(value.clone().expect_u128()); + data.amount = Some(value.clone().expect_u128().expect("failed to parse u128")); } _ => {} } match &sender.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.sender = Some(value.clone().expect_principal()); + data.sender = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } match &recipient.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.recipient = Some(value.clone().expect_principal()); + data.recipient = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -784,14 +814,19 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &amount.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.amount = Some(value.clone().expect_u128()); + data.amount = Some(value.clone().expect_u128().expect("failed to parse u128")); } _ => {} } match &recipient.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.recipient = Some(value.clone().expect_principal()); + data.recipient = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -825,7 +860,12 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &sender.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.sender = Some(value.clone().expect_principal()); + data.sender = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -861,14 +901,24 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &sender.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.sender = Some(value.clone().expect_principal()); + data.sender = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } match &recipient.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.recipient = Some(value.clone().expect_principal()); + data.recipient = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } @@ -903,7 +953,12 @@ impl ASTVisitor<'_> for EventCollector<'_, '_> { match &recipient.expr { SymbolicExpressionType::AtomValue(value) | SymbolicExpressionType::LiteralValue(value) => { - data.recipient = Some(value.clone().expect_principal()); + data.recipient = Some( + value + .clone() + .expect_principal() + .expect("failed to parse principal"), + ); } _ => {} } diff --git a/components/clarity-lsp/Cargo.toml b/components/clarity-lsp/Cargo.toml index b63e9c194..05919e0fa 100644 --- a/components/clarity-lsp/Cargo.toml +++ b/components/clarity-lsp/Cargo.toml @@ -7,7 +7,7 @@ version = "1.0.0" lazy_static = "1.4.0" lsp-types = "0.94.0" regex = "1.7" -serde = { version = "1.0.136", features = ["derive"] } +serde = { version = "1", features = ["derive"] } serde_json = "1.0" clarinet-files = { path = "../clarinet-files", default-features = false } clarity-repl = { path = "../clarity-repl", default-features = false, optional = true } diff --git a/components/clarity-repl/Cargo.toml b/components/clarity-repl/Cargo.toml index 935e2f9a8..66fb5aa42 100644 --- a/components/clarity-repl/Cargo.toml +++ b/components/clarity-repl/Cargo.toml @@ -25,7 +25,7 @@ ansi_term = "0.12.1" chrono = "0.4.31" lazy_static = "1.4.0" regex = "1.7" -serde = { version = "1.0", features = ["derive"] } +serde = { version = "1", features = ["derive"] } serde_json = { version = "1.0.47", features = ["unbounded_depth"] } sha2 = "0.10" serde_derive = "1.0" @@ -33,9 +33,9 @@ integer-sqrt = "0.1.3" getrandom = { version = "0.2.3", features = ["js"] } atty = "0.2.14" # clarity-vm = "2" -clarity = { version = "2", default-features = false, optional = true, git = "https://github.com/stacks-network/stacks-core.git", rev ="1e9df56b255247928679961d0a7c2541ad127f59", package = "clarity" } +clarity = { git = "https://github.com/stacks-network/stacks-core.git", branch="feat/clarity-wasm-next", package = "clarity", optional = true, default-features = false } # clarity = { version = "2", default-features = false, optional = true, path ="../../../clarity-wasm/stacks-core/clarity" } -clar2wasm = { git = "https://github.com/stacks-network/clarity-wasm.git", rev = "b12002d", optional = true } +clar2wasm = { git = "https://github.com/stacks-network/clarity-wasm.git", optional = true } # clar2wasm = { path="../../../clarity-wasm/clar2wasm", optional = true } # DAP Debugger @@ -57,7 +57,7 @@ reqwest = { version = "0.11", default-features = false, features = [ "json", "rustls-tls", ] } -wsts = { version = "7.0.0", default-features = false, optional = true } +wsts = { version = "8.1.0", default-features = false, optional = true } # WASM wasm-bindgen = { version = "0.2.91", optional = true } diff --git a/components/clarity-repl/src/analysis/ast_dependency_detector.rs b/components/clarity-repl/src/analysis/ast_dependency_detector.rs index c3663bf41..a08343156 100644 --- a/components/clarity-repl/src/analysis/ast_dependency_detector.rs +++ b/components/clarity-repl/src/analysis/ast_dependency_detector.rs @@ -896,7 +896,7 @@ impl GraphWalker { fn get_cycling_dependencies( &mut self, graph: &Graph, - sorted_indexes: &Vec, + sorted_indexes: &[usize], ) -> Option> { let mut tainted: HashSet = HashSet::new(); diff --git a/components/clarity-repl/src/analysis/mod.rs b/components/clarity-repl/src/analysis/mod.rs index 97bf8975a..6627befb1 100644 --- a/components/clarity-repl/src/analysis/mod.rs +++ b/components/clarity-repl/src/analysis/mod.rs @@ -134,10 +134,10 @@ pub fn run_analysis( } } - analysis_db.execute(|db| { + execute(analysis_db, |database| { for pass in passes { // Collect warnings and continue, or if there is an error, return. - match pass(contract_analysis, db, annotations, settings) { + match pass(contract_analysis, database, annotations, settings) { Ok(mut w) => errors.append(&mut w), Err(mut e) => { errors.append(&mut e); @@ -148,3 +148,16 @@ pub fn run_analysis( Ok(errors) }) } + +pub fn execute(conn: &mut AnalysisDatabase, f: F) -> std::result::Result +where + F: FnOnce(&mut AnalysisDatabase) -> std::result::Result, +{ + conn.begin(); + let result = f(conn).map_err(|e| { + conn.roll_back().expect("Failed to roll back"); + e + })?; + conn.commit().expect("Failed to commit"); + Ok(result) +} diff --git a/components/clarity-repl/src/macros.rs b/components/clarity-repl/src/macros.rs index 144cf99c6..3d357180d 100644 --- a/components/clarity-repl/src/macros.rs +++ b/components/clarity-repl/src/macros.rs @@ -42,7 +42,7 @@ macro_rules! impl_byte_array_newtype { /// Instantiates from a vector of bytes #[allow(dead_code)] - pub fn from_vec(inp: &Vec) -> Option<$thing> { + pub fn from_vec(inp: &[u8]) -> Option<$thing> { match inp.len() { $len => { let mut ret = [0; $len]; @@ -56,7 +56,7 @@ macro_rules! impl_byte_array_newtype { /// Instantiates from a big-endian vector of bytes, converting to host byte order #[allow(dead_code)] - pub fn from_vec_be(b: &Vec) -> Option<$thing> { + pub fn from_vec_be(b: &[u8]) -> Option<$thing> { match b.len() { $len => { let mut ret = [0; $len]; diff --git a/components/clarity-repl/src/repl/datastore.rs b/components/clarity-repl/src/repl/datastore.rs index 28f0fad2a..5c28d512e 100644 --- a/components/clarity-repl/src/repl/datastore.rs +++ b/components/clarity-repl/src/repl/datastore.rs @@ -180,28 +180,29 @@ impl Datastore { } impl ClarityBackingStore for Datastore { - fn put_all(&mut self, items: Vec<(String, String)>) { + fn put_all(&mut self, items: Vec<(String, String)>) -> Result<()> { for (key, value) in items { self.put(&key, &value); } + Ok(()) } /// fetch K-V out of the committed datastore - fn get(&mut self, key: &str) -> Option { + fn get(&mut self, key: &str) -> Result> { let lookup_id = self .block_id_lookup .get(&self.current_chain_tip) .expect("Could not find current chain tip in block_id_lookup map"); if let Some(map) = self.store.get(lookup_id) { - map.get(key).cloned() + Ok(map.get(key).cloned()) } else { panic!("Block does not exist for current chain tip"); } } - fn has_entry(&mut self, key: &str) -> bool { - self.get(key).is_some() + fn has_entry(&mut self, key: &str) -> Result { + Ok(self.get(key)?.is_some()) } /// change the current MARF context to service reads from a different chain_tip @@ -241,11 +242,17 @@ impl ClarityBackingStore for Datastore { "".to_string() } - fn insert_metadata(&mut self, contract: &QualifiedContractIdentifier, key: &str, value: &str) { + fn insert_metadata( + &mut self, + contract: &QualifiedContractIdentifier, + key: &str, + value: &str, + ) -> Result<()> { // let bhh = self.get_open_chain_tip(); // self.get_side_store().insert_metadata(&bhh, &contract.to_string(), key, value) self.metadata .insert((contract.to_string(), key.to_string()), value.to_string()); + Ok(()) } fn get_metadata( @@ -263,8 +270,8 @@ impl ClarityBackingStore for Datastore { } } - fn get_with_proof(&mut self, _key: &str) -> Option<(String, Vec)> { - None + fn get_with_proof(&mut self, _key: &str) -> Result)>> { + Ok(None) } fn get_contract_hash( diff --git a/components/clarity-repl/src/repl/debug/dap/mod.rs b/components/clarity-repl/src/repl/debug/dap/mod.rs index d3e56207f..c0b3a186c 100644 --- a/components/clarity-repl/src/repl/debug/dap/mod.rs +++ b/components/clarity-repl/src/repl/debug/dap/mod.rs @@ -1146,8 +1146,18 @@ fn type_for_value(value: &Value) -> String { Value::Bool(_) => "bool".to_string(), Value::Tuple(data) => format!("{}", data.type_signature), Value::Principal(_) => "principal".to_string(), - Value::Optional(opt_data) => format!("{}", opt_data.type_signature()), - Value::Response(res_data) => format!("{}", res_data.type_signature()), + Value::Optional(opt_data) => format!( + "{}", + opt_data + .type_signature() + .expect("failed to format optional value") + ), + Value::Response(res_data) => format!( + "{}", + res_data + .type_signature() + .expect("failed to format response value") + ), Value::Sequence(SequenceData::Buffer(_)) => "buff".to_string(), Value::Sequence(SequenceData::String(_)) => "string".to_string(), Value::Sequence(SequenceData::List(_)) => "list".to_string(), diff --git a/components/clarity-repl/src/repl/interpreter.rs b/components/clarity-repl/src/repl/interpreter.rs index 3506ee5b3..b008a9be0 100644 --- a/components/clarity-repl/src/repl/interpreter.rs +++ b/components/clarity-repl/src/repl/interpreter.rs @@ -348,7 +348,7 @@ impl ClarityInterpreter { // Run standard clarity analyses let mut contract_analysis = clarity::vm::analysis::run_analysis( &contract.expect_resolved_contract_identifier(Some(&self.tx_sender)), - &mut contract_ast.expressions, + &contract_ast.expressions, &mut analysis_db, false, LimitedCostTracker::new_free(), @@ -409,7 +409,8 @@ impl ClarityInterpreter { let contract = Contract { contract_context }; global_context .database - .insert_contract(&contract_id, contract); + .insert_contract(&contract_id, contract) + .expect("failed to insert contract"); global_context .database .set_contract_data_size(&contract_id, 0) @@ -422,7 +423,7 @@ impl ClarityInterpreter { analysis_db .insert_contract(&contract_id, &contract_analysis) .unwrap(); - analysis_db.commit(); + analysis_db.commit().expect("unable to save data"); } pub fn get_block_time(&mut self) -> u64 { @@ -433,6 +434,7 @@ impl ClarityInterpreter { &self.burn_datastore, ); conn.get_block_time(block_height) + .expect("unable to get block time") } pub fn get_data_var( @@ -441,7 +443,10 @@ impl ClarityInterpreter { var_name: &str, ) -> Option { let key = ClarityDatabase::make_key_for_trip(contract_id, StoreType::Variable, var_name); - let value_hex = self.datastore.get(&key)?; + let value_hex = self + .datastore + .get(&key) + .expect("failed to get key from datastore")?; Some(format!("0x{value_hex}")) } @@ -451,8 +456,12 @@ impl ClarityInterpreter { map_name: &str, map_key: &Value, ) -> Option { - let key = ClarityDatabase::make_key_for_data_map_entry(contract_id, map_name, map_key); - let value_hex = self.datastore.get(&key)?; + let key = + ClarityDatabase::make_key_for_data_map_entry(contract_id, map_name, map_key).unwrap(); + let value_hex = self + .datastore + .get(&key) + .expect("failed to get map entry from datastore")?; Some(format!("0x{value_hex}")) } @@ -476,8 +485,9 @@ impl ClarityInterpreter { ); let tx_sender: PrincipalData = self.tx_sender.clone().into(); conn.begin(); - conn.set_clarity_epoch_version(contract.epoch); - conn.commit(); + conn.set_clarity_epoch_version(contract.epoch) + .map_err(|e| e.to_string())?; + conn.commit().map_err(|e| e.to_string())?; let cost_tracker = if cost_track { LimitedCostTracker::new( false, @@ -528,7 +538,7 @@ impl ClarityInterpreter { .clone() .expect_principal() { - PrincipalData::Contract(contract_id) => contract_id, + Ok(PrincipalData::Contract(contract_id)) => contract_id, _ => unreachable!(), }; let method = expression[2].match_atom().unwrap().to_string(); @@ -630,7 +640,8 @@ impl ClarityInterpreter { let contract = Contract { contract_context }; global_context .database - .insert_contract(&contract_id, contract); + .insert_contract(&contract_id, contract) + .expect("failed to insert contract"); global_context .database .set_contract_data_size(&contract_id, 0) @@ -703,8 +714,9 @@ impl ClarityInterpreter { ); let tx_sender: PrincipalData = self.tx_sender.clone().into(); conn.begin(); - conn.set_clarity_epoch_version(contract.epoch); - conn.commit(); + conn.set_clarity_epoch_version(contract.epoch) + .expect("failed to set epoch"); + conn.commit().expect("failed to commit"); let cost_tracker = if cost_track { LimitedCostTracker::new( false, @@ -754,7 +766,7 @@ impl ClarityInterpreter { .clone() .expect_principal() { - PrincipalData::Contract(contract_id) => contract_id, + Ok(PrincipalData::Contract(contract_id)) => contract_id, _ => unreachable!(), }; let method = expression[2].match_atom().unwrap().to_string(); @@ -868,7 +880,8 @@ impl ClarityInterpreter { let contract = Contract { contract_context }; global_context .database - .insert_contract(&contract_id, contract); + .insert_contract(&contract_id, contract) + .expect("failed to insert contract"); global_context .database .set_contract_data_size(&contract_id, 0) @@ -1040,10 +1053,17 @@ impl ClarityInterpreter { DEFAULT_EPOCH, ); global_context.begin(); - let mut cur_balance = global_context.database.get_stx_balance_snapshot(&recipient); - cur_balance.credit(amount as u128); - let final_balance = cur_balance.get_available_balance(); - cur_balance.save(); + let mut cur_balance = global_context + .database + .get_stx_balance_snapshot(&recipient) + .expect("failed to get balance snapshot"); + cur_balance + .credit(amount as u128) + .expect("failed to credit balance"); + let final_balance = cur_balance + .get_available_balance() + .expect("failed to get balance"); + cur_balance.save().expect("failed to save balance"); global_context .database .increment_ustx_liquid_supply(amount as u128) diff --git a/components/clarity-repl/src/repl/tracer.rs b/components/clarity-repl/src/repl/tracer.rs index f037ff091..d695a1a96 100644 --- a/components/clarity-repl/src/repl/tracer.rs +++ b/components/clarity-repl/src/repl/tracer.rs @@ -159,7 +159,9 @@ impl EvalHook for Tracer { "│ ".repeat(self.stack.len() - self.pending_call_string.len() - 1), black!(format!( "✸ {}", - event.json_serialize(0, &Txid([0u8; 32]), true) + event + .json_serialize(0, &Txid([0u8; 32]), true) + .expect("Failed to serialize event") )), ) } diff --git a/components/clarity-repl/src/utils.rs b/components/clarity-repl/src/utils.rs index 721e97523..f93f64fd2 100644 --- a/components/clarity-repl/src/utils.rs +++ b/components/clarity-repl/src/utils.rs @@ -191,7 +191,10 @@ mod tests { )))); assert_eq!(s, "\"Hello, \"world\"\n\""); - s = value_to_string(&UTF8Data::to_value(&"Hello, 'world'\n".as_bytes().to_vec())); + s = value_to_string( + &UTF8Data::to_value(&"Hello, 'world'\n".as_bytes().to_vec()) + .expect("failed to convert to value"), + ); assert_eq!(s, "u\"Hello, 'world'\n\""); s = value_to_string(&Value::Sequence(SequenceData::List(ListData { diff --git a/components/stacks-network/Cargo.toml b/components/stacks-network/Cargo.toml index 4642c6b32..e259df543 100644 --- a/components/stacks-network/Cargo.toml +++ b/components/stacks-network/Cargo.toml @@ -12,7 +12,7 @@ bollard = "0.15.0" bytes = "1.4.0" bitcoin = "0.29.2" bitcoincore-rpc = "0.16.0" -serde = { version = "1.0.136", features = ["derive"] } +serde = { version = "1", features = ["derive"] } serde_json = { version = "1.0.79", features = ["preserve_order"] } serde_derive = "1" tracing = "0.1" @@ -32,7 +32,7 @@ futures = "0.3.12" base58 = "0.2.0" tokio = { version = "1.35.1", features = ["full"] } -chainhook-sdk = { default-features = true, git = "https://github.com/hirosystems/chainhook.git", rev = "ac59025" } +chainhook-sdk = { default-features = true, git = "https://github.com/hirosystems/chainhook.git", branch="chore/update-clarinet-and-clarity" } # chainhook-sdk = { version = "=0.11", default-features = true } stacks-rpc-client = { path = "../stacks-rpc-client" } clarinet-files = { path = "../clarinet-files", features = ["cli"] } diff --git a/components/stacks-rpc-client/src/rpc_client.rs b/components/stacks-rpc-client/src/rpc_client.rs index 23635f725..1dd081d37 100644 --- a/components/stacks-rpc-client/src/rpc_client.rs +++ b/components/stacks-rpc-client/src/rpc_client.rs @@ -291,7 +291,7 @@ impl StacksRpc { let arguments = args .iter() - .map(|a| bytes_to_hex(&a.serialize_to_vec())) + .map(|a| bytes_to_hex(&a.serialize_to_vec().expect("failed to serialize value"))) .collect::>(); let res = self .client