New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hirosystems/clarinet-sdk-browser

Package Overview
Dependencies
Maintainers
4
Versions
56
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-beta1 to 2.7.0-beta10

2

dist/esm/browser/src/defaultVfs.js

@@ -50,4 +50,2 @@ export const defaultFileStore = new Map();

export function defaultVfs(action, data) {
console.log("action", action);
console.log("data", data);
if (action === "vfs/exists")

@@ -54,0 +52,0 @@ return exists(data);

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";
/** @deprecated use `simnet.execute(command)` instead */
type RunSnippet = SDK["runSnippet"];
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 "runSnippet" ? RunSnippet : 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);
};
export {};

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

}
if (prop === "runSnippet") {
const runSnippet = (snippet) => {
const response = session[prop](snippet);
if (response.startsWith("0x")) {
return Cl.deserialize(response);
}
else {
return response;
}
if (prop === "execute") {
const execute = (snippet) => {
const response = session.execute(snippet);
return parseTxResponse(response);
};
return runSnippet;
return execute;
}

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

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

export type MineBlock = (txs: Array<Tx>) => 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;
export type RunSnippet = (snippet: string) => ClarityValue | string;
{
"name": "@hirosystems/clarinet-sdk-browser",
"version": "2.7.0-beta1",
"version": "2.7.0-beta10",
"description": "A SDK to interact with Clarity Smart Contracts in the browser",

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

"type": "git",
"url": "https://github.com/hirosystems/clarinet"
"url": "git+https://github.com/hirosystems/clarinet.git"
},

@@ -32,5 +32,5 @@ "files": [

"dependencies": {
"@hirosystems/clarinet-sdk-wasm-browser": "2.7.0-beta1",
"@hirosystems/clarinet-sdk-wasm-browser": "^2.7.0-beta10",
"@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

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