From 16af072ac04413f9610426dcb7c5a1e11ed7184c Mon Sep 17 00:00:00 2001 From: izmiradami Date: Tue, 21 Jul 2026 11:33:01 +0000 Subject: [PATCH 1/2] Add additional SDK query examples --- examples/blob-activities-count.mjs | 42 ++++++++++++++++++++++++++++++ examples/blob-activities.mjs | 42 ++++++++++++++++++++++++++++++ examples/blob-count.mjs | 42 ++++++++++++++++++++++++++++++ examples/blob-metadata.mjs | 39 +++++++++++++++++++++++++++ examples/delete-blob.mjs | 40 ++++++++++++++++++++++++++++ examples/list-account-blobs.mjs | 42 ++++++++++++++++++++++++++++++ examples/placement-group-count.mjs | 28 ++++++++++++++++++++ examples/placement-groups.mjs | 34 ++++++++++++++++++++++++ examples/storage-providers.mjs | 25 ++++++++++++++++++ examples/total-storage-size.mjs | 42 ++++++++++++++++++++++++++++++ 10 files changed, 376 insertions(+) create mode 100644 examples/blob-activities-count.mjs create mode 100644 examples/blob-activities.mjs create mode 100644 examples/blob-count.mjs create mode 100644 examples/blob-metadata.mjs create mode 100644 examples/delete-blob.mjs create mode 100644 examples/list-account-blobs.mjs create mode 100644 examples/placement-group-count.mjs create mode 100644 examples/placement-groups.mjs create mode 100644 examples/storage-providers.mjs create mode 100644 examples/total-storage-size.mjs diff --git a/examples/blob-activities-count.mjs b/examples/blob-activities-count.mjs new file mode 100644 index 0000000..2198a39 --- /dev/null +++ b/examples/blob-activities-count.mjs @@ -0,0 +1,42 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const count = await client.getBlobActivitiesCount({ + where: { + owner: { + _eq: account.accountAddress.toString(), + }, + }, + }); + + console.log(`Blob activity count: ${count}`); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/blob-activities.mjs b/examples/blob-activities.mjs new file mode 100644 index 0000000..c120912 --- /dev/null +++ b/examples/blob-activities.mjs @@ -0,0 +1,42 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const activities = await client.getBlobActivities({ + where: { + owner: { + _eq: account.accountAddress.toString(), + }, + }, + }); + + console.dir(activities, { depth: null }); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/blob-count.mjs b/examples/blob-count.mjs new file mode 100644 index 0000000..a8f58df --- /dev/null +++ b/examples/blob-count.mjs @@ -0,0 +1,42 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const count = await client.getBlobsCount({ + where: { + owner: { + _eq: account.accountAddress.toString(), + }, + }, + }); + + console.log(`Blob count: ${count}`); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/blob-metadata.mjs b/examples/blob-metadata.mjs new file mode 100644 index 0000000..fbbb45d --- /dev/null +++ b/examples/blob-metadata.mjs @@ -0,0 +1,39 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const metadata = await client.getBlobMetadata({ + account: account.accountAddress, + name: "sdk-test.txt", + }); + + console.dir(metadata, { depth: null }); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/delete-blob.mjs b/examples/delete-blob.mjs new file mode 100644 index 0000000..a00d182 --- /dev/null +++ b/examples/delete-blob.mjs @@ -0,0 +1,40 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const { transaction } = await client.deleteBlob({ + account, + blobName: "sdk-test.txt", + }); + + console.log("Delete transaction submitted!"); + console.log("Hash:", transaction.hash); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/list-account-blobs.mjs b/examples/list-account-blobs.mjs new file mode 100644 index 0000000..7c22779 --- /dev/null +++ b/examples/list-account-blobs.mjs @@ -0,0 +1,42 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + console.log(`Account: ${account.accountAddress.toString()}\n`); + + const blobs = await client.getAccountBlobs({ + account: account.accountAddress, + }); + + console.log(`Found ${blobs.length} blob(s)\n`); + + console.dir(blobs, { depth: null }); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/placement-group-count.mjs b/examples/placement-group-count.mjs new file mode 100644 index 0000000..2060788 --- /dev/null +++ b/examples/placement-group-count.mjs @@ -0,0 +1,28 @@ +import { ShelbyPlacementGroupClient } from "@shelby-protocol/sdk/node"; +import { Network } from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const client = new ShelbyPlacementGroupClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const count = await client.getPlacementGroupSlotsCount({}); + + console.log(`Placement group slot count: ${count}`); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/placement-groups.mjs b/examples/placement-groups.mjs new file mode 100644 index 0000000..5c39421 --- /dev/null +++ b/examples/placement-groups.mjs @@ -0,0 +1,34 @@ +import { ShelbyPlacementGroupClient } from "@shelby-protocol/sdk/node"; +import { Network } from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const client = new ShelbyPlacementGroupClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const slots = await client.getPlacementGroupSlots({ + pagination: { + limit: 10, + }, + }); + + console.log(`Found ${slots.length} placement group slot(s)\n`); + + console.dir(slots, { depth: null }); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/storage-providers.mjs b/examples/storage-providers.mjs new file mode 100644 index 0000000..131de85 --- /dev/null +++ b/examples/storage-providers.mjs @@ -0,0 +1,25 @@ +import { ShelbyMetadataClient } from "@shelby-protocol/sdk/node"; +import { Network } from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; + +dotenv.config(); + +async function main() { + const client = new ShelbyMetadataClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + console.log("Fetching storage providers...\n"); + + const providers = await client.getStorageProviders(); + + console.log(`Found ${providers.length} storage provider(s)\n`); + + console.dir(providers, { depth: null }); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/examples/total-storage-size.mjs b/examples/total-storage-size.mjs new file mode 100644 index 0000000..a1cc2b6 --- /dev/null +++ b/examples/total-storage-size.mjs @@ -0,0 +1,42 @@ +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; +import { + Account, + Ed25519PrivateKey, + Network, +} from "@aptos-labs/ts-sdk"; +import dotenv from "dotenv"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +dotenv.config({ + path: path.join(__dirname, "../.env"), +}); + +async function main() { + const account = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), + }); + + const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, + }); + + const totalSize = await client.getTotalBlobsSize({ + where: { + owner: { + _eq: account.accountAddress.toString(), + }, + }, + }); + + console.log(`Total blob size: ${totalSize} bytes`); +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); From 87bb0d6e9df34e915249f5f122b902f53334fe16 Mon Sep 17 00:00:00 2001 From: izmiradami Date: Fri, 24 Jul 2026 11:42:30 +0000 Subject: [PATCH 2/2] feat: add sdk query examples app Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 1 + apps/sdk-queries/.env.example | 5 + apps/sdk-queries/README.md | 163 ++++++++++++++++++ apps/sdk-queries/package.json | 43 +++++ apps/sdk-queries/src/account-blobs.ts | 26 +++ apps/sdk-queries/src/blob-activities-count.ts | 25 +++ apps/sdk-queries/src/blob-activities.ts | 26 +++ apps/sdk-queries/src/blob-count.ts | 26 +++ apps/sdk-queries/src/blob-metadata.ts | 32 ++++ apps/sdk-queries/src/delete-blob.ts | 37 ++++ apps/sdk-queries/src/placement-group-count.ts | 18 ++ apps/sdk-queries/src/placement-groups.ts | 24 +++ apps/sdk-queries/src/storage-providers.ts | 19 ++ apps/sdk-queries/src/total-storage-size.ts | 26 +++ apps/sdk-queries/tsconfig.json | 25 +++ examples/blob-activities-count.mjs | 42 ----- examples/blob-activities.mjs | 42 ----- examples/blob-count.mjs | 42 ----- examples/blob-metadata.mjs | 39 ----- examples/delete-blob.mjs | 40 ----- examples/list-account-blobs.mjs | 42 ----- examples/placement-group-count.mjs | 28 --- examples/placement-groups.mjs | 34 ---- examples/storage-providers.mjs | 25 --- examples/total-storage-size.mjs | 42 ----- pnpm-lock.yaml | 44 ++++- 26 files changed, 537 insertions(+), 379 deletions(-) create mode 100644 apps/sdk-queries/.env.example create mode 100644 apps/sdk-queries/README.md create mode 100644 apps/sdk-queries/package.json create mode 100644 apps/sdk-queries/src/account-blobs.ts create mode 100644 apps/sdk-queries/src/blob-activities-count.ts create mode 100644 apps/sdk-queries/src/blob-activities.ts create mode 100644 apps/sdk-queries/src/blob-count.ts create mode 100644 apps/sdk-queries/src/blob-metadata.ts create mode 100644 apps/sdk-queries/src/delete-blob.ts create mode 100644 apps/sdk-queries/src/placement-group-count.ts create mode 100644 apps/sdk-queries/src/placement-groups.ts create mode 100644 apps/sdk-queries/src/storage-providers.ts create mode 100644 apps/sdk-queries/src/total-storage-size.ts create mode 100644 apps/sdk-queries/tsconfig.json delete mode 100644 examples/blob-activities-count.mjs delete mode 100644 examples/blob-activities.mjs delete mode 100644 examples/blob-count.mjs delete mode 100644 examples/blob-metadata.mjs delete mode 100644 examples/delete-blob.mjs delete mode 100644 examples/list-account-blobs.mjs delete mode 100644 examples/placement-group-count.mjs delete mode 100644 examples/placement-groups.mjs delete mode 100644 examples/storage-providers.mjs delete mode 100644 examples/total-storage-size.mjs diff --git a/README.md b/README.md index d880f97..d96e6a7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ This Turborepo includes the following example applications: | `@shelby-protocol/cross-chain-accounts` | Shelby cross chain accounts example | [`apps/cross-chain-accounts`](./apps/cross-chain-accounts) | | `@shelby-protocol/download-example` | An example app to demonstrate downloading blobs using the Shelby SDK | [`apps/download-blob`](./apps/download-blob) | | `@shelby-protocol/list-example` | An example app to demonstrate listing blobs using the Shelby SDK | [`apps/list-blob`](./apps/list-blob) | +| `@shelby-protocol/query-example` | An example app to demonstrate querying blobs, activities, and network metadata using the Shelby SDK | [`apps/sdk-queries`](./apps/sdk-queries) | | `@shelby-protocol/upload-example` | An example app to demonstrate uploading blobs using the Shelby SDK | [`apps/upload-blob`](./apps/upload-blob) | diff --git a/apps/sdk-queries/.env.example b/apps/sdk-queries/.env.example new file mode 100644 index 0000000..19e9cc0 --- /dev/null +++ b/apps/sdk-queries/.env.example @@ -0,0 +1,5 @@ +SHELBY_ACCOUNT_ADDRESS=0xYourAccountAddressHere +SHELBY_API_KEY=AG-YourApiKeyHere + +# Only required by the delete-blob script, which signs an on-chain transaction. +SHELBY_ACCOUNT_PRIVATE_KEY=ed25519-priv-0xYourPrivateKeyHere diff --git a/apps/sdk-queries/README.md b/apps/sdk-queries/README.md new file mode 100644 index 0000000..a556cb0 --- /dev/null +++ b/apps/sdk-queries/README.md @@ -0,0 +1,163 @@ +# Shelby SDK Query Examples + +A collection of small, self-contained scripts demonstrating how to read data from the Shelby protocol using the Shelby SDK. Each script is one file in `src/` and answers a single question — how many blobs does this account own, what is stored under a given name, which storage providers are serving the network, and so on. + +Most of these queries hit the Shelby indexer and are read-only, so they need nothing more than an account address and an API key. The one exception is `delete-blob`, which signs an on-chain transaction. + +## Prerequisites + +- Node.js >= 22 +- pnpm package manager +- A Shelby account with uploaded blobs +- Shelby API key + +## Installation + +1. Clone the repository and navigate to the sdk-queries directory: + ```bash + cd apps/sdk-queries + ``` + +2. Install dependencies: + ```bash + pnpm install + ``` + +## Environment Variables + +Create a `.env` file in the root of this project directory with the following required environment variables. You can copy the `.env.example` file as a starting point: + +```bash +cp .env.example .env +``` + +Then update the values in your `.env` file: + +```env +SHELBY_ACCOUNT_ADDRESS=your_account_address_here +SHELBY_API_KEY=your_api_key_here + +# Only required by the delete-blob script. +SHELBY_ACCOUNT_PRIVATE_KEY=your_private_key_here +``` + +More information on obtaining an API key on the [Shelby docs site](https://docs.shelby.xyz/sdks/typescript/acquire-api-keys). + +## Usage + +Each query has its own script. Run whichever one you're interested in: + +| Script | File | What it does | +| --- | --- | --- | +| `pnpm query:blobs` | `src/account-blobs.ts` | Lists every blob owned by the account, with full metadata | +| `pnpm query:metadata` | `src/blob-metadata.ts` | Fetches the on-chain metadata for a single named blob | +| `pnpm query:blob-count` | `src/blob-count.ts` | Counts the account's blobs without fetching them | +| `pnpm query:storage-size` | `src/total-storage-size.ts` | Sums the byte size of everything the account stores | +| `pnpm query:activities` | `src/blob-activities.ts` | Shows the account's blob activity log | +| `pnpm query:activities-count` | `src/blob-activities-count.ts` | Counts activity records for the account | +| `pnpm query:placement-groups` | `src/placement-groups.ts` | Lists a page of network placement group slots | +| `pnpm query:placement-group-count` | `src/placement-group-count.ts` | Counts placement group slots network-wide | +| `pnpm query:storage-providers` | `src/storage-providers.ts` | Lists the storage providers serving the network | +| `pnpm delete-blob` | `src/delete-blob.ts` | ⚠️ Permanently deletes a blob (mutates on-chain state) | + +Each runs the TypeScript file directly using tsx with the environment variables from your `.env` file. + +### Alternative Execution + +You can also run any of the files directly using tsx: + +```bash +npx tsx --env-file=.env src/account-blobs.ts +``` + +### Customizing the queries + +Two scripts act on a specific blob name, set as a constant at the top of the file: + +```ts +const BLOB_NAME = "sdk-test.txt"; +``` + +Change that to a blob your account actually owns before running `query:metadata` or `delete-blob`. + +The count and list queries accept a Hasura-style `where` clause, so they can be narrowed beyond "everything this account owns". For example, to count only blobs owned by someone else: + +```ts +const count = await client.getBlobsCount({ + where: { owner: { _eq: "0x1" } }, +}); +``` + +## How It Works + +1. **Environment Validation**: Each script validates that the environment variables it needs are set +2. **Client Initialization**: Creates the client for the data being queried — `ShelbyBlobClient` for blobs and activities, `ShelbyPlacementGroupClient` for placement groups, `ShelbyMetadataClient` for storage providers +3. **Account Setup**: Parses the account address from the environment variable (`delete-blob` builds a signing account from a private key instead) +4. **Query**: Issues a single SDK call — the list and count variants are separate methods, so counts never transfer the underlying rows +5. **Display Results**: Prints scalars directly, and object results via `console.dir` with unlimited depth + +## Output + +Counting queries print a single line: + +``` +Blob count: 3 +``` + +``` +Total blob size: 1539615 bytes +``` + +Listing queries print a summary line followed by the full objects: + +``` +Account: 0x1234...abcd +Found 3 blob(s) +[ + { + name: 'whitepaper.pdf', + size: 1024567, + expirationMicros: 1760628600000000, + ... + }, + ... +] +``` + +And `delete-blob` prints the submitted transaction: + +``` +Delete transaction submitted! +Hash: 0x9f8e... +``` + +## Troubleshooting + +### Common Issues + +1. **SHELBY_ACCOUNT_ADDRESS is not set in .env** + - Ensure you have created a `.env` file with the required variables + - Check that the variable name is spelled correctly + - Verify the account address format is valid + +2. **SHELBY_API_KEY is not set in .env** + - Verify your API key is correctly set in the `.env` file + - Ensure there are no extra spaces or quotes around the API key + +3. **No blob named "..." found** + - `getBlobMetadata` returns `undefined` rather than throwing when the blob doesn't exist + - Update the `BLOB_NAME` constant to a blob the account actually owns + - Run `pnpm query:blobs` to see which names are available + +4. **Empty results from every query** + - Verify that the account address contains uploaded blobs + - Check that you're using the correct account address + - Ensure blobs haven't expired + +5. **Rate limit exceeded (429)** + - Wait a moment before retrying + - Consider implementing exponential backoff for production use + +6. **Server errors (500)** + - This indicates an issue with the Shelby service + - Contact Shelby support if this occurs repeatedly diff --git a/apps/sdk-queries/package.json b/apps/sdk-queries/package.json new file mode 100644 index 0000000..317f7bf --- /dev/null +++ b/apps/sdk-queries/package.json @@ -0,0 +1,43 @@ +{ + "name": "@shelby-protocol/query-example", + "version": "1.0.0", + "description": "An example app to demonstrate querying blobs, activities, and network metadata using the Shelby SDK", + "type": "module", + "scripts": { + "query:blobs": "tsx --env-file=.env src/account-blobs.ts", + "query:metadata": "tsx --env-file=.env src/blob-metadata.ts", + "query:blob-count": "tsx --env-file=.env src/blob-count.ts", + "query:storage-size": "tsx --env-file=.env src/total-storage-size.ts", + "query:activities": "tsx --env-file=.env src/blob-activities.ts", + "query:activities-count": "tsx --env-file=.env src/blob-activities-count.ts", + "query:placement-groups": "tsx --env-file=.env src/placement-groups.ts", + "query:placement-group-count": "tsx --env-file=.env src/placement-group-count.ts", + "query:storage-providers": "tsx --env-file=.env src/storage-providers.ts", + "delete-blob": "tsx --env-file=.env src/delete-blob.ts", + "lint": "biome check .", + "fmt": "biome check . --write" + }, + "keywords": [ + "shelby", + "sdk", + "blob", + "storage", + "query", + "indexer" + ], + "author": "Akasha ", + "license": "MIT", + "dependencies": { + "@aptos-labs/ts-sdk": "^5.2.1", + "@shelby-protocol/sdk": "^0.3.1" + }, + "devDependencies": { + "@biomejs/biome": "2.2.4", + "tsx": "^4.20.5", + "typescript": "^5.9.2", + "vitest": "^3.2.4" + }, + "engines": { + "node": ">=22" + } +} diff --git a/apps/sdk-queries/src/account-blobs.ts b/apps/sdk-queries/src/account-blobs.ts new file mode 100644 index 0000000..6e5a491 --- /dev/null +++ b/apps/sdk-queries/src/account-blobs.ts @@ -0,0 +1,26 @@ +import { AccountAddress, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_ADDRESS) { + throw new Error("Missing SHELBY_ACCOUNT_ADDRESS"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Parse the account address you'll query. +const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS); + +// 3) Ask the indexer for every blob owned by that account. +const blobs = await client.getAccountBlobs({ account }); + +// 4) Print the full metadata for each blob. +console.log(`Account: ${account.toString()}`); +console.log(`Found ${blobs.length} blob(s)`); +console.dir(blobs, { depth: null }); diff --git a/apps/sdk-queries/src/blob-activities-count.ts b/apps/sdk-queries/src/blob-activities-count.ts new file mode 100644 index 0000000..47d1e8f --- /dev/null +++ b/apps/sdk-queries/src/blob-activities-count.ts @@ -0,0 +1,25 @@ +import { AccountAddress, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_ADDRESS) { + throw new Error("Missing SHELBY_ACCOUNT_ADDRESS"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Parse the account address you'll query. +const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS); + +// 3) Count activity records without transferring them. +const count = await client.getBlobActivitiesCount({ + where: { owner: { _eq: account.toString() } }, +}); + +console.log(`Blob activity count: ${count}`); diff --git a/apps/sdk-queries/src/blob-activities.ts b/apps/sdk-queries/src/blob-activities.ts new file mode 100644 index 0000000..380c4ae --- /dev/null +++ b/apps/sdk-queries/src/blob-activities.ts @@ -0,0 +1,26 @@ +import { AccountAddress, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_ADDRESS) { + throw new Error("Missing SHELBY_ACCOUNT_ADDRESS"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Parse the account address you'll query. +const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS); + +// 3) Fetch the activity log (uploads, deletions, extensions) for the account. +const activities = await client.getBlobActivities({ + where: { owner: { _eq: account.toString() } }, +}); + +console.log(`Found ${activities.length} activity record(s)`); +console.dir(activities, { depth: null }); diff --git a/apps/sdk-queries/src/blob-count.ts b/apps/sdk-queries/src/blob-count.ts new file mode 100644 index 0000000..ccddb80 --- /dev/null +++ b/apps/sdk-queries/src/blob-count.ts @@ -0,0 +1,26 @@ +import { AccountAddress, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_ADDRESS) { + throw new Error("Missing SHELBY_ACCOUNT_ADDRESS"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Parse the account address you'll query. +const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS); + +// 3) Count blobs via an indexer filter instead of fetching them all. +// The `where` clause is a Hasura-style boolean expression. +const count = await client.getBlobsCount({ + where: { owner: { _eq: account.toString() } }, +}); + +console.log(`Blob count: ${count}`); diff --git a/apps/sdk-queries/src/blob-metadata.ts b/apps/sdk-queries/src/blob-metadata.ts new file mode 100644 index 0000000..a824e73 --- /dev/null +++ b/apps/sdk-queries/src/blob-metadata.ts @@ -0,0 +1,32 @@ +import { AccountAddress, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +// The blob name as stored in Shelby (must match what you uploaded or already have). +const BLOB_NAME = "sdk-test.txt"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_ADDRESS) { + throw new Error("Missing SHELBY_ACCOUNT_ADDRESS"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Parse the account address the blob lives under. +const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS); + +// 3) Look up the on-chain metadata for a single blob. +// ⚠️ Returns `undefined` when no blob with that name exists. +const metadata = await client.getBlobMetadata({ account, name: BLOB_NAME }); + +// 4) Print the metadata (or say so when the blob isn't there). +if (!metadata) { + console.log(`No blob named "${BLOB_NAME}" found for ${account.toString()}`); +} else { + console.dir(metadata, { depth: null }); +} diff --git a/apps/sdk-queries/src/delete-blob.ts b/apps/sdk-queries/src/delete-blob.ts new file mode 100644 index 0000000..1f6a568 --- /dev/null +++ b/apps/sdk-queries/src/delete-blob.ts @@ -0,0 +1,37 @@ +// ⚠️ This script MUTATES on-chain state: it permanently deletes a blob. +// Unlike the other scripts here it signs a transaction, so it needs a +// private key rather than just an account address. + +import { Account, Ed25519PrivateKey, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +// The blob to delete, as stored in Shelby. +const BLOB_NAME = "sdk-test.txt"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_PRIVATE_KEY) { + throw new Error("Missing SHELBY_ACCOUNT_PRIVATE_KEY"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Create an Aptos account object from your private key. +// ⚠️ This must be the *same account* that uploaded the blob. +const signer = Account.fromPrivateKey({ + privateKey: new Ed25519PrivateKey(process.env.SHELBY_ACCOUNT_PRIVATE_KEY), +}); + +// 3) Submit the delete transaction. +const { transaction } = await client.deleteBlob({ + account: signer, + blobName: BLOB_NAME, +}); + +console.log("Delete transaction submitted!"); +console.log("Hash:", transaction.hash); diff --git a/apps/sdk-queries/src/placement-group-count.ts b/apps/sdk-queries/src/placement-group-count.ts new file mode 100644 index 0000000..e75cda5 --- /dev/null +++ b/apps/sdk-queries/src/placement-group-count.ts @@ -0,0 +1,18 @@ +import { Network } from "@aptos-labs/ts-sdk"; +import { ShelbyPlacementGroupClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} + +// 1) Initialize a placement group client (auth via API key; target shelbynet). +const client = new ShelbyPlacementGroupClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Count every slot on the network. Pass a `where` clause to narrow it down, +// e.g. { where: { status: { _eq: "active" } } }. +const count = await client.getPlacementGroupSlotsCount({}); + +console.log(`Placement group slot count: ${count}`); diff --git a/apps/sdk-queries/src/placement-groups.ts b/apps/sdk-queries/src/placement-groups.ts new file mode 100644 index 0000000..a285162 --- /dev/null +++ b/apps/sdk-queries/src/placement-groups.ts @@ -0,0 +1,24 @@ +import { Network } from "@aptos-labs/ts-sdk"; +import { ShelbyPlacementGroupClient } from "@shelby-protocol/sdk/node"; + +// How many slots to fetch in one page. +const PAGE_SIZE = 10; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} + +// 1) Initialize a placement group client (auth via API key; target shelbynet). +// Placement groups are network-wide, so no account address is needed. +const client = new ShelbyPlacementGroupClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Fetch a page of placement group slots. +const slots = await client.getPlacementGroupSlots({ + pagination: { limit: PAGE_SIZE }, +}); + +console.log(`Found ${slots.length} placement group slot(s)`); +console.dir(slots, { depth: null }); diff --git a/apps/sdk-queries/src/storage-providers.ts b/apps/sdk-queries/src/storage-providers.ts new file mode 100644 index 0000000..5dd73b1 --- /dev/null +++ b/apps/sdk-queries/src/storage-providers.ts @@ -0,0 +1,19 @@ +import { Network } from "@aptos-labs/ts-sdk"; +import { ShelbyMetadataClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} + +// 1) Initialize a metadata client (auth via API key; target shelbynet). +const client = new ShelbyMetadataClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) List the storage providers currently serving the network. +console.log("Fetching storage providers..."); +const providers = await client.getStorageProviders(); + +console.log(`Found ${providers.length} storage provider(s)`); +console.dir(providers, { depth: null }); diff --git a/apps/sdk-queries/src/total-storage-size.ts b/apps/sdk-queries/src/total-storage-size.ts new file mode 100644 index 0000000..1587946 --- /dev/null +++ b/apps/sdk-queries/src/total-storage-size.ts @@ -0,0 +1,26 @@ +import { AccountAddress, Network } from "@aptos-labs/ts-sdk"; +import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; + +if (!process.env.SHELBY_API_KEY) { + throw new Error("Missing SHELBY_API_KEY"); +} +if (!process.env.SHELBY_ACCOUNT_ADDRESS) { + throw new Error("Missing SHELBY_ACCOUNT_ADDRESS"); +} + +// 1) Initialize a blob client (auth via API key; target shelbynet). +const client = new ShelbyBlobClient({ + network: Network.SHELBYNET, + apiKey: process.env.SHELBY_API_KEY, // ensure .env is loaded +}); + +// 2) Parse the account address you'll query. +const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS); + +// 3) Sum the size of every blob the account owns, server-side. +// Omit `where` to get the total across the whole network. +const totalSize = await client.getTotalBlobsSize({ + where: { owner: { _eq: account.toString() } }, +}); + +console.log(`Total blob size: ${totalSize} bytes`); diff --git a/apps/sdk-queries/tsconfig.json b/apps/sdk-queries/tsconfig.json new file mode 100644 index 0000000..dac2510 --- /dev/null +++ b/apps/sdk-queries/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "allowJs": true, + "strict": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "./dist", + "rootDir": "./src", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": false, + "lib": ["ES2022", "DOM"], + "types": ["node", "vitest/globals"] + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "**/*.test.ts"] +} diff --git a/examples/blob-activities-count.mjs b/examples/blob-activities-count.mjs deleted file mode 100644 index 2198a39..0000000 --- a/examples/blob-activities-count.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const count = await client.getBlobActivitiesCount({ - where: { - owner: { - _eq: account.accountAddress.toString(), - }, - }, - }); - - console.log(`Blob activity count: ${count}`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/blob-activities.mjs b/examples/blob-activities.mjs deleted file mode 100644 index c120912..0000000 --- a/examples/blob-activities.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const activities = await client.getBlobActivities({ - where: { - owner: { - _eq: account.accountAddress.toString(), - }, - }, - }); - - console.dir(activities, { depth: null }); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/blob-count.mjs b/examples/blob-count.mjs deleted file mode 100644 index a8f58df..0000000 --- a/examples/blob-count.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const count = await client.getBlobsCount({ - where: { - owner: { - _eq: account.accountAddress.toString(), - }, - }, - }); - - console.log(`Blob count: ${count}`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/blob-metadata.mjs b/examples/blob-metadata.mjs deleted file mode 100644 index fbbb45d..0000000 --- a/examples/blob-metadata.mjs +++ /dev/null @@ -1,39 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const metadata = await client.getBlobMetadata({ - account: account.accountAddress, - name: "sdk-test.txt", - }); - - console.dir(metadata, { depth: null }); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/delete-blob.mjs b/examples/delete-blob.mjs deleted file mode 100644 index a00d182..0000000 --- a/examples/delete-blob.mjs +++ /dev/null @@ -1,40 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const { transaction } = await client.deleteBlob({ - account, - blobName: "sdk-test.txt", - }); - - console.log("Delete transaction submitted!"); - console.log("Hash:", transaction.hash); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/list-account-blobs.mjs b/examples/list-account-blobs.mjs deleted file mode 100644 index 7c22779..0000000 --- a/examples/list-account-blobs.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - console.log(`Account: ${account.accountAddress.toString()}\n`); - - const blobs = await client.getAccountBlobs({ - account: account.accountAddress, - }); - - console.log(`Found ${blobs.length} blob(s)\n`); - - console.dir(blobs, { depth: null }); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/placement-group-count.mjs b/examples/placement-group-count.mjs deleted file mode 100644 index 2060788..0000000 --- a/examples/placement-group-count.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import { ShelbyPlacementGroupClient } from "@shelby-protocol/sdk/node"; -import { Network } from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const client = new ShelbyPlacementGroupClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const count = await client.getPlacementGroupSlotsCount({}); - - console.log(`Placement group slot count: ${count}`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/placement-groups.mjs b/examples/placement-groups.mjs deleted file mode 100644 index 5c39421..0000000 --- a/examples/placement-groups.mjs +++ /dev/null @@ -1,34 +0,0 @@ -import { ShelbyPlacementGroupClient } from "@shelby-protocol/sdk/node"; -import { Network } from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const client = new ShelbyPlacementGroupClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const slots = await client.getPlacementGroupSlots({ - pagination: { - limit: 10, - }, - }); - - console.log(`Found ${slots.length} placement group slot(s)\n`); - - console.dir(slots, { depth: null }); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/storage-providers.mjs b/examples/storage-providers.mjs deleted file mode 100644 index 131de85..0000000 --- a/examples/storage-providers.mjs +++ /dev/null @@ -1,25 +0,0 @@ -import { ShelbyMetadataClient } from "@shelby-protocol/sdk/node"; -import { Network } from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; - -dotenv.config(); - -async function main() { - const client = new ShelbyMetadataClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - console.log("Fetching storage providers...\n"); - - const providers = await client.getStorageProviders(); - - console.log(`Found ${providers.length} storage provider(s)\n`); - - console.dir(providers, { depth: null }); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/examples/total-storage-size.mjs b/examples/total-storage-size.mjs deleted file mode 100644 index a1cc2b6..0000000 --- a/examples/total-storage-size.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { ShelbyBlobClient } from "@shelby-protocol/sdk/node"; -import { - Account, - Ed25519PrivateKey, - Network, -} from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -dotenv.config({ - path: path.join(__dirname, "../.env"), -}); - -async function main() { - const account = Account.fromPrivateKey({ - privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY), - }); - - const client = new ShelbyBlobClient({ - network: Network.SHELBYNET, - apiKey: process.env.SHELBY_API_KEY, - }); - - const totalSize = await client.getTotalBlobsSize({ - where: { - owner: { - _eq: account.accountAddress.toString(), - }, - }, - }); - - console.log(`Total blob size: ${totalSize} bytes`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0989b1..14dec76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -245,6 +245,28 @@ importers: specifier: ^3.2.4 version: 3.2.4(@types/debug@4.1.12)(@types/node@25.1.0)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0) + apps/sdk-queries: + dependencies: + '@aptos-labs/ts-sdk': + specifier: ^5.2.1 + version: 5.2.1(got@11.8.6) + '@shelby-protocol/sdk': + specifier: ^0.3.1 + version: 0.3.1(@aptos-labs/ts-sdk@5.2.1(got@11.8.6)) + devDependencies: + '@biomejs/biome': + specifier: 2.2.4 + version: 2.2.4 + tsx: + specifier: ^4.20.5 + version: 4.21.0 + typescript: + specifier: ^5.9.2 + version: 5.9.3 + vitest: + specifier: ^3.2.4 + version: 3.2.4(@types/debug@4.1.12)(@types/node@25.1.0)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0) + apps/solana/file-upload: dependencies: '@shelby-protocol/react': @@ -2050,6 +2072,11 @@ packages: peerDependencies: '@aptos-labs/ts-sdk': ^2.0.1 || ^3.0.0 || ^4.0.0 || ^5.0.0 + '@shelby-protocol/sdk@0.3.1': + resolution: {integrity: sha512-4Q3Q6BuK/IhS2Z0Eqb8LuVORd8udFFI9zdWswxdl0CHcmFK4h9Ysb4BQdWcHE8LfpwUOi+U54Gk55t7WW6Ns6w==} + peerDependencies: + '@aptos-labs/ts-sdk': ^5.2.1 || ^6.0.0 + '@shelby-protocol/solana-kit@0.2.0': resolution: {integrity: sha512-lKIBrVNZxeIod1RlG4VM+YcBbZIkIWLp9sBlae7H+EV7dzE/t5ECUuKb9MrH1a/S213rAnrV8OpxDazoYp39vw==} peerDependencies: @@ -7250,6 +7277,17 @@ snapshots: p-limit: 7.1.1 zod: 3.25.76 + '@shelby-protocol/sdk@0.3.1(@aptos-labs/ts-sdk@5.2.1(got@11.8.6))': + dependencies: + '@aptos-labs/ts-sdk': 5.2.1(got@11.8.6) + '@shelby-protocol/clay-codes': 0.0.2 + '@shelby-protocol/reed-solomon': 0.0.1 + graphql: 16.12.0 + graphql-request: 7.4.0(graphql@16.12.0) + graphql-tag: 2.12.6(graphql@16.12.0) + p-limit: 7.1.1 + zod: 3.25.76 + '@shelby-protocol/solana-kit@0.2.0(@wallet-standard/core@1.1.1)(bs58@6.0.0)(bufferutil@4.1.0)(got@11.8.6)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(typescript@5.9.3)(utf-8-validate@5.0.10)': dependencies: '@aptos-labs/derived-wallet-solana': 0.12.0(@aptos-labs/ts-sdk@5.2.1(got@11.8.6))(@wallet-standard/core@1.1.1)(bs58@6.0.0)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10) @@ -9282,7 +9320,7 @@ snapshots: eslint: 9.39.2(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.2(jiti@2.6.1)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.39.2(jiti@2.6.1)) eslint-plugin-react: 7.37.5(eslint@9.39.2(jiti@2.6.1)) eslint-plugin-react-hooks: 7.0.1(eslint@9.39.2(jiti@2.6.1)) @@ -9335,7 +9373,7 @@ snapshots: tinyglobby: 0.2.15 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.2(jiti@2.6.1)) transitivePeerDependencies: - supports-color @@ -9375,7 +9413,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)))(eslint@9.39.2(jiti@2.6.1)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.39.2(jiti@2.6.1)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9