-
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.
feat: initialize clarinet-sdk with the core js lib (#1068)
* feat: initialize clarinet-sdk with the test-core js lib * fix: clarity value arguments deserialisation * chore: version 0.0.4 * feat: clarity-sdk: get contracts interfaces * fat: implement get_data_var and get_map_entry * refactor: lint * chore: switch to webpack and handme esm * fix: rename cargo.toml to Cargo.toml * chore: handle cjs and esm * refactor: update components/clarinet-sdk/src/utils.rs Co-authored-by: Micaiah Reid <micaiahreid@gmail.com> * refactor: improve exports and address reviews * docs: update readme.md * docs: udpate readme.md --------- Co-authored-by: Micaiah Reid <micaiahreid@gmail.com>
- Loading branch information
1 parent
a259141
commit eb7670e
Showing
27 changed files
with
4,005 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/ | ||
src-ts/sdk | ||
node_modules/ |
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,76 @@ | ||
[package] | ||
edition = "2021" | ||
name = "clarinet-sdk" | ||
version = "0.0.1" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
name = "clarinet_sdk" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
serde = { version = "1.0.136", features = ["derive"] } | ||
serde_json = "1.0" | ||
clarinet-files = { path = "../clarinet-files", default-features = false } | ||
clarity-repl = { path = "../clarity-repl", default-features = false, optional = true } | ||
clarinet-deployments = { path = "../clarinet-deployments", default-features = false } | ||
# WASM | ||
console_error_panic_hook = { version = "0.1", optional = true } | ||
js-sys = { version = "0.3", optional = true } | ||
serde-wasm-bindgen = { version = "0.5", optional = true } | ||
wasm-bindgen = { version = "0.2", optional = true } | ||
wasm-bindgen-futures = { version = "0.4", optional = true } | ||
web-sys = { version = "0.3", features = ["console"], optional = true } | ||
|
||
[features] | ||
default = ["wasm"] | ||
wasm = [ | ||
"wasm-bindgen", | ||
"wasm-bindgen-futures", | ||
"serde-wasm-bindgen", | ||
"js-sys", | ||
"web-sys", | ||
"console_error_panic_hook", | ||
"clarinet-deployments/wasm", | ||
"clarity-repl/wasm", | ||
"clarinet-files/wasm", | ||
] | ||
|
||
# DEV | ||
[profile.dev] | ||
inherits = "release" | ||
opt-level = 3 | ||
debug = false | ||
debug-assertions = false | ||
incremental = false | ||
codegen-units = 256 | ||
|
||
[profile.dev.build-override] | ||
inherits = "release" | ||
opt-level = 3 | ||
|
||
[package.metadata.wasm-pack.profile.dev] | ||
wasm-opt = false | ||
|
||
[package.metadata.wasm-pack.profile.dev.wasm-bindgen] | ||
debug-js-glue = false | ||
demangle-name-section = true | ||
dwarf-debug-info = false | ||
|
||
# RELEASE | ||
[profile.release] | ||
opt-level = 3 | ||
debug = false | ||
debug-assertions = false | ||
lto = true | ||
incremental = false | ||
codegen-units = 16 | ||
|
||
[package.metadata.wasm-pack.profile.release] | ||
wasm-opt = false | ||
# wasm-opt = ['-O1'] | ||
|
||
[package.metadata.wasm-pack.profile.release.wasm-bindgen] | ||
debug-js-glue = false | ||
demangle-name-section = true | ||
dwarf-debug-info = false |
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,43 @@ | ||
# Clarinet SDK | ||
|
||
## Core | ||
|
||
### Usage | ||
|
||
```ts | ||
import { Cl } from "@stacks/transactions"; | ||
import { initVM } from "obscurity-sdk"; | ||
|
||
async function main() { | ||
const vm = await initVM(); | ||
const accounts = vm.getAccounts(); | ||
const w1 = accounts.get("wallet_1"); | ||
if (!w1) return; | ||
|
||
const call = vm.callPublicFn("counter", "increment", [Cl.uint(1)], w1); | ||
console.log(call.result); // Cl.int(Cl.ok(true)) | ||
|
||
const counter = vm.getDataVar("counter", "counter"); | ||
console.log(counter); // Cl.int(2) | ||
} | ||
|
||
main(); | ||
``` | ||
|
||
## Contributing | ||
|
||
Clone the clarinet repo adn switch to the sdk component | ||
``` | ||
git clone git@github.com:hirosystems/clarinet.git | ||
cd clarinet/components/clarinet-sdk | ||
``` | ||
|
||
Open the SDK workspace in VSCode: | ||
``` | ||
code ./clarinet-sdk.code-workspace | ||
``` | ||
|
||
Compile the project (both WASM and JS): | ||
``` | ||
npm run build | ||
``` |
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,17 @@ | ||
{ | ||
"folders": [{ "path": "../../" }], | ||
"settings": { | ||
// "rust-analyzer.checkOnSave.command": "clippy -p clarinet-sdk -- --no-deps", | ||
// "rust-analyzer.check.command": "check", | ||
"rust-analyzer.check.overrideCommand": [ | ||
"cargo", | ||
"clippy", | ||
"--no-default-features", | ||
"--package=clarinet-sdk", | ||
"--features=wasm", | ||
"--message-format=json", | ||
"--", | ||
"--no-deps" | ||
] | ||
} | ||
} |
Oops, something went wrong.