@clockwork-xyz/sdk
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "@clockwork-xyz/sdk", | ||
"author": "Clockwork", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Clockwork Typescript SDK", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -13,1 +13,97 @@ <p align="center"> | ||
</div> | ||
## Getting Started | ||
For a quickstart guide and in depth tutorials, see the [Clockwork Docs](https://docs.clockwork.xyz/about/readme). | ||
To jump straight to examples, go [here](https://github.com/clockwork-xyz/sdk/tree/main/tests). For the latest Rust API documentation, see [Clockwork Rust SDK](https://docs.rs/clockwork-sdk/latest/clockwork_sdk/). | ||
## Note | ||
- **Clockwork SDK is in active development, so all APIs are subject to change.** | ||
- **This code is unaudited. Use at your own risk.** | ||
## Usage | ||
First, initialize a `ClockworkProvider` | ||
```rust | ||
const wallet = new NodeWallet(new Keypair()); | ||
const connection = new Connection(clusterApiUrl("devnet")); | ||
const provider = new ClockworkProvider(wallet, connection); | ||
``` | ||
Get Thread Address | ||
```rust | ||
let [pubkey, bump] = provider.getThreadPDA( | ||
wallet.publicKey, | ||
"ThreadProgramTest" | ||
); | ||
``` | ||
Initialize a Thread | ||
```rust | ||
let tx = await provider.threadCreate( | ||
wallet.publicKey, // authority | ||
"ThreadProgramTest", // id | ||
[], // instructions to execute | ||
{ now: {} }, // thread trigger | ||
0.1 * LAMPORTS_PER_SOL // amount to send to the thread | ||
); | ||
``` | ||
Get Thread Data Deserialized | ||
```rust | ||
let threadAccount = await provider.getThreadAccount(threadPubkey); | ||
``` | ||
Pause/Resume/Reset/Delete/ Thread | ||
```rust | ||
let tx = await provider.threadPause(wallet.publicKey, threadPubkey); | ||
let tx = await provider.threadResume(wallet.publicKey, threadPubkey); | ||
let tx = await provider.threadReset(wallet.publicKey, threadPubkey); | ||
let tx = await provider.threadDelete(wallet.publicKey, threadPubkey); | ||
``` | ||
Update a Thread | ||
```rust | ||
let tx = await provider.threadUpdate(wallet.publicKey, threadPubkey, { | ||
name: "TestUpdateThread", | ||
rateLimit: new BN(32), | ||
trigger: { now: {} }, | ||
}); | ||
``` | ||
Withdraw from Thread | ||
```rust | ||
let tx = await provider.threadWithdraw( | ||
wallet.publicKey, | ||
threadPubkey, | ||
0.01 * LAMPORTS_PER_SOL | ||
); | ||
``` | ||
Get Crate Info | ||
```rust | ||
let tx = await provider.getCrateInfo(); | ||
``` | ||
Get Worker Address | ||
```rust | ||
let [pubkey, bump] = provider.getWorkerPDA("8"); | ||
``` | ||
Get Worker Account | ||
```rust | ||
let workerAccount = await provider.getWorkerAccount(workerPubkey); | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
183300
109
0