clarinet
clarinet copied to clipboard
Ability to fork contract easily
At some point, clarinet was able to facilitate the fork of contracts, thanks to the command:
clarinet contracts fork <contract-id>
This command broke a few times in presence of requirements, and was removed with #333. If there's some demand for this feature, we could re-implement it pretty quickly with the new deployments design, but I think that this feature might be superseded by https://github.com/hirosystems/clarinet/issues/341.
Yes, perhaps a template can also be derived from an existing contract. The best I can currently think of is via adding support for multiple sources, as already mentioned in #341, for example:
$ clarinet new --add-source <contract-id> [other-options-here]
I used this feature quite often when I was trying understand some contracts which were already deployed. Anything that allows me to download a contract and save it as a file is a "must have" for me.
@lgalabru, how can one fork/fetch a contract from testnet locally via deployment plans?
For example, this one: ST3QFME3CANQFQNR86TYVKQYCFT7QX4PRXM1V9W6H.cargo, by @kenrogers.
@moodmosaic this can be achieved with the command:
clarinet requirements add ST3QFME3CANQFQNR86TYVKQYCFT7QX4PRXM1V9W6H.cargo
@lgalabru, thank you. — Sidenote: running the command above touched Clarinet.toml in more places than I would expect:
@@ -1,21 +1,25 @@
-
[project]
name = "cargo"
authors = []
+description = ""
telemetry = false
-cache_dir = "./.requirements"
+cache_dir = "C:\\Snapshot\\dev\\pub\\stacks\\tmp\\cargo\\.\\.requirements"
+boot_contracts = ["pox", "costs-v2", "bns"]
+
+[[project.requirements]]
+contract_id = "ST3QFME3CANQFQNR86TYVKQYCFT7QX4PRXM1V9W6H.cargo"
+
+[contracts]
-# [contracts.counter]
-# path = "contracts/counter.clar"
+[repl]
+costs_version = 2
+parser_version = 2
[repl.analysis]
passes = ["check_checker"]
-check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
-# Check-checker settings:
-# trusted_sender: if true, inputs are trusted after tx_sender has been checked.
-# trusted_caller: if true, inputs are trusted after contract-caller has been checked.
-# callee_filter: if true, untrusted data may be passed into a private function without a
-# warning, if it gets checked inside. This check will also propagate up to the
-# caller.
-# More informations: https://www.hiro.so/blog/new-safety-checks-in-clarinet
+[repl.analysis.check_checker]
+strict = false
+trusted_sender = false
+trusted_caller = false
+callee_filter = false
Apart from that, this works fine 👍 Here's some output from a demo property-based test against that contract. All I had to do was
clarinet requirements add ST3QFME3CANQFQNR86TYVKQYCFT7QX4PRXM1V9W6H.cargo
(and write the actual test code, obviously, which references the contract using it's full contract principal).
