Skip to content

Commit

Permalink
Address example project review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BowTiedRadone committed Jan 25, 2025
1 parent f863cbe commit 2dee9fa
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
8 changes: 4 additions & 4 deletions citizen.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ describe("Simnet deployment plan operations", () => {
},
},
{
"ft-transfer-many": {
path: "contracts/ft-transfer-many.clar",
reverse: {
path: "contracts/reverse.clar",
clarity_version: 3,
},
},
{
reverse: {
path: "contracts/reverse.clar",
"send-tokens": {
path: "contracts/send-tokens.clar",
clarity_version: 3,
},
},
Expand Down
9 changes: 7 additions & 2 deletions example/Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ contract_id = 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token'
[[project.requirements]]
contract_id = 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.sip-010-trait-ft-standard'

# Clarinet currently does not support type checking or dependency resolution
# for concatenated target and test contracts. To ensure successful deployment
# of the send-tokens contract (which only relies on rendezvous-token in its
# corresponding test contract), we set the epoch of rendezvous-token to 2.5.
# This ensures it precedes the epoch of the send-tokens contract (3.0).
[contracts.rendezvous-token]
path = 'contracts/rendezvous-token.clar'
clarity_version = 2
Expand All @@ -34,8 +39,8 @@ path = "contracts/slice.clar"
clarity_version = 3
epoch = 3.0

[contracts.ft-transfer-many]
path = 'contracts/ft-transfer-many.clar'
[contracts.send-tokens]
path = "contracts/send-tokens.clar"
clarity_version = 3
epoch = 3.0

Expand Down
21 changes: 0 additions & 21 deletions example/contracts/ft-transfer-many.clar

This file was deleted.

19 changes: 19 additions & 0 deletions example/contracts/send-tokens.clar
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(use-trait ft-trait 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.sip-010-trait-ft-standard.sip-010-trait)

(define-public (send-tokens
(transfers (list 5 {token: <ft-trait>, to: principal, amount: uint}))
)
(ok (map transfer transfers))
)

(define-private (transfer
(one-transfer {token: <ft-trait>, to: principal, amount: uint})
)
(let
(
(ft (get token one-transfer))
(to (get to one-transfer))
(amount (get amount one-transfer))
)
(contract-call? ft transfer amount tx-sender to none))
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;; Invariants

(define-read-only (invariant-trait (address principal))
(define-read-only (invariant-token-supply-vs-balance (address principal))
(let
(
(total-supply
Expand All @@ -22,14 +22,14 @@
;; Properties

(define-public (test-transfer
(token <ft-trait>) (recipient principal) (amount uint)
(token <ft-trait>) (to principal) (amount uint)
)
(let
(
(sender-balance-before
(unwrap-panic (contract-call? token get-balance tx-sender)))
(transfer-result
(transfer {token: token, recipient: recipient, amount: amount}))
(transfer {token: token, to: to, amount: amount}))
(sender-balance-after
(unwrap-panic (contract-call? token get-balance tx-sender)))
)
Expand Down

0 comments on commit 2dee9fa

Please sign in to comment.