-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] Select contracts implementing the correct trait from the Clarinet project for argument generation #88
Draft
BowTiedRadone
wants to merge
10
commits into
master
Choose a base branch
from
feat/project-trait-selection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c7871e0
Add contract referencing a trait to the `example`
BowTiedRadone ae0d20c
WIP: Add support for direct and tuple-nested traits in property testing
BowTiedRadone a10e0a5
Add test for list-nested traits
BowTiedRadone 47a4da4
Add support for list-nested trait references
BowTiedRadone 3e8743c
Remove comments and no longer used imports in `property`
BowTiedRadone 27a72ec
Move the trait test ASTs and interfaces to the test file
BowTiedRadone c189840
Add support for response-nested trait references
BowTiedRadone 1d76720
Add support for optional nested trait references
BowTiedRadone bef6767
Stick to general `actual` and `expected` in trait tests
BowTiedRadone 47a425b
Add support for trait references in invariant testing
BowTiedRadone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
example/.cache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.dao.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
;; @contract DAO | ||
;; @version 1 | ||
|
||
;;------------------------------------- | ||
;; Constants | ||
;;------------------------------------- | ||
|
||
(define-constant ERR_NOT_ADMIN u20001) | ||
(define-constant ERR_CONTRACTS_DISABLED u20002) | ||
(define-constant ERR_INACTIVE_CONTRACT u20003) | ||
|
||
;;------------------------------------- | ||
;; Variables | ||
;;------------------------------------- | ||
|
||
(define-data-var contracts-enabled bool true) | ||
|
||
;;------------------------------------- | ||
;; Maps | ||
;;------------------------------------- | ||
|
||
(define-map contracts | ||
{ | ||
address: principal | ||
} | ||
{ | ||
active: bool, | ||
} | ||
) | ||
|
||
(define-map admins | ||
{ | ||
address: principal | ||
} | ||
{ | ||
active: bool, | ||
} | ||
) | ||
|
||
;;------------------------------------- | ||
;; Getters | ||
;;------------------------------------- | ||
|
||
(define-read-only (get-contracts-enabled) | ||
(var-get contracts-enabled) | ||
) | ||
|
||
(define-read-only (get-contract-active (address principal)) | ||
(get active | ||
(default-to | ||
{ active: false } | ||
(map-get? contracts { address: address }) | ||
) | ||
) | ||
) | ||
|
||
(define-read-only (get-admin (address principal)) | ||
(get active | ||
(default-to | ||
{ active: false } | ||
(map-get? admins { address: address }) | ||
) | ||
) | ||
) | ||
|
||
;;------------------------------------- | ||
;; Checks | ||
;;------------------------------------- | ||
|
||
(define-public (check-is-enabled) | ||
(begin | ||
(asserts! (var-get contracts-enabled) (err ERR_CONTRACTS_DISABLED)) | ||
(ok true) | ||
) | ||
) | ||
|
||
(define-public (check-is-protocol (contract principal)) | ||
(begin | ||
(asserts! (get-contract-active contract) (err ERR_INACTIVE_CONTRACT)) | ||
(ok true) | ||
) | ||
) | ||
|
||
(define-public (check-is-admin (contract principal)) | ||
(begin | ||
(asserts! (get-admin contract) (err ERR_NOT_ADMIN)) | ||
(ok true) | ||
) | ||
) | ||
|
||
;;------------------------------------- | ||
;; Set | ||
;;------------------------------------- | ||
|
||
(define-public (set-contracts-enabled (enabled bool)) | ||
(begin | ||
(try! (check-is-admin tx-sender)) | ||
(var-set contracts-enabled enabled) | ||
(ok true) | ||
) | ||
) | ||
|
||
(define-public (set-contract-active (address principal) (active bool)) | ||
(begin | ||
(try! (check-is-admin tx-sender)) | ||
(map-set contracts { address: address } { active: active } | ||
) | ||
(ok true) | ||
) | ||
) | ||
|
||
(define-public (set-admin (address principal) (active bool)) | ||
(begin | ||
(try! (check-is-admin tx-sender)) | ||
(map-set admins { address: address } { active: active } | ||
) | ||
(ok true) | ||
) | ||
) | ||
|
||
;;------------------------------------- | ||
;; Init | ||
;;------------------------------------- | ||
|
||
(begin | ||
(map-set admins { address: tx-sender } { active: true }) | ||
|
||
(map-set contracts { address: tx-sender } { active: true }) | ||
|
||
(map-set contracts { address: .stacking-dao-core-v1 } { active: true }) | ||
(map-set contracts { address: .reserve-v1 } { active: true }) | ||
(map-set contracts { address: .commission-v1 } { active: true }) | ||
|
||
(map-set contracts { address: .stacker-1 } { active: true }) | ||
(map-set contracts { address: .stacker-2 } { active: true }) | ||
(map-set contracts { address: .stacker-3 } { active: true }) | ||
(map-set contracts { address: .stacker-4 } { active: true }) | ||
(map-set contracts { address: .stacker-5 } { active: true }) | ||
(map-set contracts { address: .stacker-6 } { active: true }) | ||
(map-set contracts { address: .stacker-7 } { active: true }) | ||
(map-set contracts { address: .stacker-8 } { active: true }) | ||
(map-set contracts { address: .stacker-9 } { active: true }) | ||
(map-set contracts { address: .stacker-10 } { active: true }) | ||
) |
4 changes: 4 additions & 0 deletions
4
example/.cache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.dao.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"epoch": "Epoch24", | ||
"clarity_version": "Clarity2" | ||
} |
24 changes: 24 additions & 0 deletions
24
...ache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.sip-010-trait-ft-standard.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(define-trait sip-010-trait | ||
( | ||
;; Transfer from the caller to a new principal | ||
(transfer (uint principal principal (optional (buff 34))) (response bool uint)) | ||
|
||
;; the human readable name of the token | ||
(get-name () (response (string-ascii 32) uint)) | ||
|
||
;; the ticker symbol, or empty if none | ||
(get-symbol () (response (string-ascii 32) uint)) | ||
|
||
;; the number of decimals used, e.g. 6 would mean 1_000_000 represents 1 token | ||
(get-decimals () (response uint uint)) | ||
|
||
;; the balance of the passed principal | ||
(get-balance (principal) (response uint uint)) | ||
|
||
;; the current total supply (which does not need to be a constant) | ||
(get-total-supply () (response uint uint)) | ||
|
||
;; an optional URI that represents metadata of this token | ||
(get-token-uri () (response (optional (string-utf8 256)) uint)) | ||
) | ||
) |
4 changes: 4 additions & 0 deletions
4
...ache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.sip-010-trait-ft-standard.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"epoch": "Epoch24", | ||
"clarity_version": "Clarity2" | ||
} |
93 changes: 93 additions & 0 deletions
93
example/.cache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
(impl-trait .sip-010-trait-ft-standard.sip-010-trait) | ||
|
||
;; Defines the Stacked STX according to the SIP010 Standard | ||
(define-fungible-token ststx) | ||
|
||
(define-constant ERR_NOT_AUTHORIZED u1401) | ||
|
||
;;------------------------------------- | ||
;; Variables | ||
;;------------------------------------- | ||
|
||
(define-data-var token-uri (string-utf8 256) u"") | ||
|
||
;;------------------------------------- | ||
;; SIP-010 | ||
;;------------------------------------- | ||
|
||
(define-read-only (get-total-supply) | ||
(ok (ft-get-supply ststx)) | ||
) | ||
|
||
(define-read-only (get-name) | ||
(ok "Stacked STX Token") | ||
) | ||
|
||
(define-read-only (get-symbol) | ||
(ok "stSTX") | ||
) | ||
|
||
(define-read-only (get-decimals) | ||
(ok u6) | ||
) | ||
|
||
(define-read-only (get-balance (account principal)) | ||
(ok (ft-get-balance ststx account)) | ||
) | ||
|
||
(define-read-only (get-token-uri) | ||
(ok (some (var-get token-uri))) | ||
) | ||
|
||
(define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34)))) | ||
(begin | ||
(asserts! (is-eq tx-sender sender) (err ERR_NOT_AUTHORIZED)) | ||
|
||
(match (ft-transfer? ststx amount sender recipient) | ||
response (begin | ||
(print memo) | ||
(print { action: "transfer", data: { sender: tx-sender, recipient: recipient, amount: amount, block-height: block-height } }) | ||
(ok response) | ||
) | ||
error (err error) | ||
) | ||
) | ||
) | ||
|
||
;;------------------------------------- | ||
;; Admin | ||
;;------------------------------------- | ||
|
||
(define-public (set-token-uri (value (string-utf8 256))) | ||
(begin | ||
(try! (contract-call? .dao check-is-protocol tx-sender)) | ||
(ok (var-set token-uri value)) | ||
) | ||
) | ||
|
||
;;------------------------------------- | ||
;; Mint / Burn | ||
;;------------------------------------- | ||
|
||
;; Mint method | ||
(define-public (mint-for-protocol (amount uint) (recipient principal)) | ||
(begin | ||
(try! (contract-call? .dao check-is-protocol contract-caller)) | ||
(ft-mint? ststx amount recipient) | ||
) | ||
) | ||
|
||
;; Burn method | ||
(define-public (burn-for-protocol (amount uint) (sender principal)) | ||
(begin | ||
(try! (contract-call? .dao check-is-protocol contract-caller)) | ||
(ft-burn? ststx amount sender) | ||
) | ||
) | ||
|
||
;; Burn external | ||
(define-public (burn (amount uint)) | ||
(begin | ||
(ft-burn? ststx amount tx-sender) | ||
) | ||
) |
4 changes: 4 additions & 0 deletions
4
example/.cache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"epoch": "Epoch24", | ||
"clarity_version": "Clarity2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(define-public (function) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This contract is named trait but has just a function in it? |
||
(ok true) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(use-trait ft-trait 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.sip-010-trait-ft-standard.sip-010-trait) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use this trait in the examples, why do we require |
||
|
||
(define-public (test-no-trait) | ||
(ok true) | ||
) | ||
|
||
(define-public (test-trait (token <ft-trait>)) | ||
(ok true) | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it that adding this as requirement adds also
dao
andsip-010-trait-ft-standard
, right?