-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into chainhooks-edits
- Loading branch information
Showing
17 changed files
with
95 additions
and
198 deletions.
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
28 changes: 13 additions & 15 deletions
28
components/clarinet-cli/examples/billboard/contracts/billboard.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 |
---|---|---|
@@ -1,35 +1,33 @@ | ||
;; billboard contract | ||
|
||
;; error consts | ||
(define-constant ERR_STX_TRANSFER u0) | ||
(define-constant ERR_STX_TRANSFER u0) | ||
|
||
;; data vars | ||
(define-data-var billboard-message (string-utf8 500) u"Hello World!") | ||
(define-data-var price uint u100) | ||
|
||
;; public functions | ||
(define-read-only (get-price) | ||
(var-get price) | ||
(var-get price) | ||
) | ||
|
||
(define-read-only (get-message) | ||
(var-get billboard-message) | ||
(var-get billboard-message) | ||
) | ||
|
||
(define-public (set-message (message (string-utf8 500))) | ||
(let ((cur-price (var-get price)) | ||
(new-price (+ u10 cur-price))) | ||
(let ((cur-price (var-get price)) (new-price (+ u10 cur-price))) | ||
;; pay the contract | ||
(unwrap! (stx-transfer? cur-price tx-sender (as-contract tx-sender)) (err ERR_STX_TRANSFER)) | ||
|
||
;; pay the contract | ||
(unwrap! (stx-transfer? cur-price tx-sender (as-contract tx-sender)) (err ERR_STX_TRANSFER)) | ||
;; update the billboard's message | ||
(var-set billboard-message message) | ||
|
||
;; update the billboard's message | ||
(var-set billboard-message message) | ||
;; update the price of setting a message | ||
(var-set price new-price) | ||
|
||
;; update the price of setting a message | ||
(var-set price new-price) | ||
|
||
;; return the updated price | ||
(ok new-price) | ||
) | ||
;; return the updated price | ||
(ok new-price) | ||
) | ||
) |
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 |
---|---|---|
@@ -1,10 +1,4 @@ | ||
import { | ||
Clarinet, | ||
Tx, | ||
Chain, | ||
Account, | ||
types, | ||
} from "https://deno.land/x/[email protected]/index.ts"; | ||
import { Clarinet, Tx, Chain, Account, types } from "https://deno.land/x/[email protected]/index.ts"; | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
|
||
Clarinet.test({ | ||
|
@@ -17,19 +11,9 @@ Clarinet.test({ | |
const balance = assetMaps.assets["STX"][wallet_1.address]; | ||
|
||
const block = chain.mineBlock([ | ||
Tx.contractCall( | ||
"billboard", | ||
"set-message", | ||
[types.utf8("testing")], | ||
wallet_1.address | ||
), | ||
Tx.contractCall("billboard", "set-message", [types.utf8("testing")], wallet_1.address), | ||
Tx.contractCall("billboard", "get-message", [], wallet_1.address), | ||
Tx.contractCall( | ||
"billboard", | ||
"set-message", | ||
[types.utf8("testing...")], | ||
wallet_1.address | ||
), | ||
Tx.contractCall("billboard", "set-message", [types.utf8("testing...")], wallet_1.address), | ||
Tx.contractCall("billboard", "get-message", [], wallet_1.address), | ||
]); | ||
|
||
|
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
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 |
---|---|---|
@@ -1,9 +1,4 @@ | ||
import { | ||
Clarinet, | ||
Tx, | ||
Chain, | ||
types, | ||
} from "https://deno.land/x/[email protected]/index.ts"; | ||
import { Clarinet, Tx, Chain, types } from "https://deno.land/x/[email protected]/index.ts"; | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
|
||
Clarinet.test({ | ||
|
@@ -13,10 +8,7 @@ Clarinet.test({ | |
Tx.contractCall( | ||
"cbtc-token", | ||
"mint", | ||
[ | ||
types.uint(1000), | ||
types.principal("ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG"), | ||
], | ||
[types.uint(1000), types.principal("ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG")], | ||
"ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5" | ||
), | ||
Tx.contractCall( | ||
|
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
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 |
---|---|---|
@@ -1,10 +1,4 @@ | ||
import { | ||
Clarinet, | ||
Tx, | ||
Chain, | ||
Account, | ||
types, | ||
} from "https://deno.land/x/[email protected]/index.ts"; | ||
import { Clarinet, Tx, Chain, Account, types } from "https://deno.land/x/[email protected]/index.ts"; | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
|
||
Clarinet.test({ | ||
|
@@ -14,49 +8,19 @@ Clarinet.test({ | |
const wallet_2 = accounts.get("wallet_2")!; | ||
|
||
let block = chain.mineBlock([ | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(1)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(4)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(10)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address), | ||
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address), | ||
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address), | ||
]); | ||
assertEquals(block.height, 3); | ||
block.receipts[0].result.expectOk().expectUint(2); | ||
block.receipts[1].result.expectOk().expectUint(6); | ||
block.receipts[2].result.expectOk().expectUint(16); | ||
|
||
block = chain.mineBlock([ | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(1)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(4)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(10)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address), | ||
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address), | ||
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address), | ||
Tx.transferSTX(1, wallet_2.address, wallet_1.address), | ||
]); | ||
|
||
|
@@ -68,12 +32,7 @@ Clarinet.test({ | |
const result = chain.getAssetsMaps(); | ||
assertEquals(result.assets["STX"][wallet_1.address], 99999999999999); | ||
|
||
const call = chain.callReadOnlyFn( | ||
"counter", | ||
"read-counter", | ||
[], | ||
wallet_1.address | ||
); | ||
const call = chain.callReadOnlyFn("counter", "read-counter", [], wallet_1.address); | ||
call.result.expectOk().expectUint(31); | ||
|
||
"0x0001020304".expectBuff(new Uint8Array([0, 1, 2, 3, 4])); | ||
|
@@ -92,24 +51,9 @@ Clarinet.test({ | |
const wallet_1 = accounts.get("wallet_1")!; | ||
|
||
const block = chain.mineBlock([ | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(1)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(4)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall( | ||
"counter", | ||
"increment", | ||
[types.uint(10)], | ||
wallet_1.address | ||
), | ||
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address), | ||
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address), | ||
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address), | ||
]); | ||
assertEquals(block.height, 103); | ||
block.receipts[0].result.expectOk().expectUint(2); | ||
|
23 changes: 11 additions & 12 deletions
23
components/clarinet-cli/examples/simple-nft/Clarinet.toml
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
15 changes: 0 additions & 15 deletions
15
...nents/clarinet-cli/examples/simple-nft/contracts/external/sip-009-nft-trait-standard.clar
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.