Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hirosystems/clarinet-sdk-browser

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hirosystems/clarinet-sdk-browser - npm Package Compare versions

Comparing version 2.7.0-beta4 to 2.7.0-beta5

2

dist/esm/browser/src/index.d.ts
import init, { SDK } from "@hirosystems/clarinet-sdk-wasm-browser";
import { Simnet, getSessionProxy } from "./sdkProxy.js";
export { tx, type ClarityEvent, type ParsedTransactionResult, type DeployContractOptions, type Tx, type TransferSTX, } from "../../common/src/sdkProxyHelpers.js";
export { init, SDK, getSessionProxy };
export { init, SDK, getSessionProxy, type Simnet };
export { defaultVfs, defaultFileStore } from "./defaultVfs.js";
export declare const initSimnet: (virtualFileSystem?: Function) => Promise<Simnet>;
import init, { SDK } from "@hirosystems/clarinet-sdk-wasm-browser";
import { getSessionProxy } from "./sdkProxy.js";
import { defaultVfs } from "./defaultVfs.js";
export { tx, } from "../../common/src/sdkProxyHelpers.js";
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json

@@ -10,2 +9,3 @@ // @ts-ignore

};
export { tx, } from "../../common/src/sdkProxyHelpers.js";
export { init, SDK, getSessionProxy };

@@ -12,0 +12,0 @@ export { defaultVfs, defaultFileStore } from "./defaultVfs.js";

import { type SDK } from "@hirosystems/clarinet-sdk-wasm-browser";
import { type CallFn, type DeployContract, type GetDataVar, type GetMapEntry, type MineBlock, type RunSnippet, type TransferSTX } from "../../common/src/sdkProxyHelpers.js";
import { type CallFn, type DeployContract, type GetDataVar, type GetMapEntry, type MineBlock, type Execute, type TransferSTX } from "../../common/src/sdkProxyHelpers.js";
export type Simnet = {
[K in keyof SDK]: K extends "callReadOnlyFn" | "callPublicFn" | "callPrivateFn" ? CallFn : K extends "runSnippet" ? RunSnippet : K extends "deployContract" ? DeployContract : K extends "transferSTX" ? TransferSTX : K extends "mineBlock" ? MineBlock : K extends "getDataVar" ? GetDataVar : K extends "getMapEntry" ? GetMapEntry : SDK[K];
[K in keyof SDK]: K extends "callReadOnlyFn" | "callPublicFn" | "callPrivateFn" ? CallFn : K extends "execute" ? Execute : K extends "deployContract" ? DeployContract : K extends "transferSTX" ? TransferSTX : K extends "mineBlock" ? MineBlock : K extends "getDataVar" ? GetDataVar : K extends "getMapEntry" ? GetMapEntry : SDK[K];
};
export declare function getSessionProxy(): {
get(session: SDK, prop: keyof SDK, receiver: any): string | number | CallFn | DeployContract | TransferSTX | MineBlock | GetMapEntry | ((cwd: string, manifest_path: string) => Promise<void>) | ((epoch: import("@hirosystems/clarinet-sdk-wasm-browser").EpochString) => void) | ((count?: number | undefined) => number) | ((include_boot_contracts: boolean, boot_contracts_path: string) => import("@hirosystems/clarinet-sdk-wasm-browser").SessionReport);
get(session: SDK, prop: keyof SDK, receiver: any): string | number | CallFn | DeployContract | TransferSTX | MineBlock | GetMapEntry | ((cwd: string, manifest_path: string) => Promise<void>) | ((epoch: import("@hirosystems/clarinet-sdk-wasm-browser").EpochString) => void) | ((count?: number | undefined) => number) | ((recipient: string, amount: bigint) => string) | ((include_boot_contracts: boolean, boot_contracts_path: string) => import("@hirosystems/clarinet-sdk-wasm-browser").SessionReport);
};

@@ -23,8 +23,8 @@ import { Cl } from "@stacks/transactions";

}
if (prop === "runSnippet") {
const runSnippet = (snippet) => {
const response = session.runSnippet(snippet);
if (prop === "execute") {
const execute = (snippet) => {
const response = session.execute(snippet);
return parseTxResponse(response);
};
return runSnippet;
return execute;
}

@@ -31,0 +31,0 @@ if (prop === "deployContract") {

@@ -68,4 +68,4 @@ import { ClarityValue } from "@stacks/transactions";

export type MineBlock = (txs: Array<Tx>) => ParsedTransactionResult[];
export type RunSnippet = (snippet: string) => ParsedTransactionResult;
export type Execute = (snippet: string) => ParsedTransactionResult;
export type GetDataVar = (contract: string, dataVar: string) => ClarityValue;
export type GetMapEntry = (contract: string, mapName: string, mapKey: ClarityValue) => ClarityValue;
{
"name": "@hirosystems/clarinet-sdk-browser",
"version": "2.7.0-beta4",
"version": "2.7.0-beta5",
"description": "A SDK to interact with Clarity Smart Contracts in the browser",

@@ -31,5 +31,5 @@ "homepage": "https://docs.hiro.so/clarinet/feature-guides/clarinet-js-sdk",

"dependencies": {
"@hirosystems/clarinet-sdk-wasm-browser": "^2.7.0-beta3",
"@hirosystems/clarinet-sdk-wasm-browser": "^2.7.0-beta6",
"@stacks/transactions": "^6.13.0"
}
}

@@ -1,5 +0,7 @@

# Clarinet SDK
# Clarinet SDK for the Web
The Clarinet SDK can be used to interact with the simnet from web browsers.
If you want to use the Clarinet SDK in Node.js, try [@hirosystems/clarinet-sdk](https://www.npmjs.com/package/@hirosystems/clarinet-sdk).
Find the API references of the SDK in [our documentation](https://docs.hiro.so/clarinet/feature-guides/clarinet-js-sdk).

@@ -15,3 +17,3 @@ Learn more about unit testing Clarity smart contracts in [this guide](https://docs.hiro.so/clarinet/feature-guides/test-contract-with-clarinet-sdk).

## Core
## Installation

@@ -24,63 +26,19 @@ ```sh

```ts
import { initSimnet } from "@hirosystems/clarinet-sdk-browser";
import { Cl } from "@stacks/transactions";
There are two ways to use the sdk in the browser:
async function main() {
const simnet = await initSimnet();
- With an empty clarinet session:
```js
const simnet = await initSimnet();
await simnet.initEmtpySession();
const accounts = simnet.getAccounts();
const address1 = accounts.get("wallet_1");
if (!address1) throw new Error("invalid wallet name.");
const call = simnet.callPublicFn("counter", "add", [Cl.uint(1)], address1);
console.log(Cl.prettyPrint(call.result)); // (ok u1)
const counter = simnet.getDataVar("counter", "counter");
console.log(Cl.prettyPrint(counter)); // 2
}
main();
simnet.runSnippet("(+ 1 2)")
```
- With a clarinet project (ie: with a Clarinet.toml)
💡 It requires to use a virtual file system. More documentation and examples soon.
```js
const simnet = await initSimnet();
await simnet.initSession("/project", "Clarinet.toml")
By default, the SDK will look for a Clarinet.toml file in the current working directory.
It's also possible to provide the path to the manifest like so:
```ts
const simnet = await initSimnet("./path/to/Clarinet.toml");
```
## Contributing
The clarinet-sdk requires a few steps to be built and tested locally.
We'll look into simplifying this workflow in a future version.
Clone the clarinet repo and `cd` into it:
```sh
git clone git@github.com:hirosystems/clarinet.git
cd clarinet
```
Open the SDK workspace in VSCode, it's especially useful to get rust-analyzer
to consider the right files with the right cargo features.
```sh
code components/clarinet-sdk/clarinet-sdk.code-workspace
```
The SDK mainly relies on two components:
- the Rust component: `components/clarinet-sdk-wasm`
- the TS component: `components/clarinet-sdk`
To work with these two packages locally, the first one needs to be built with
wasm-pack and linked with: [npm link](https://docs.npmjs.com/cli/v8/commands/npm-link).
Install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer) and run:
```sh
cd components/clarinet-sdk-wasm
wasm-pack build --release --scope hirosystems --out-dir pkg-node --target nodejs
cd pkg-node
npm link
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc