Skip to content

Added blob download example - #6

Merged
affinity-matrix merged 14 commits into
mainfrom
akasha/download-example
Oct 13, 2025
Merged

affinity-matrix merged 14 commits into
mainfrom
akasha/download-example

Conversation

@affinity-matrix

Copy link
Copy Markdown
Member

No description provided.

@affinity-matrix
affinity-matrix force-pushed the akasha/download-example branch from fb8350c to f3c5c9c Compare October 12, 2025 11:15
Comment thread apps/download-blob/.env.example Outdated
Comment on lines +1 to +2
SHELBY_ACCOUNT_ADDRESS=0x0ab30174c5f0d720e1471bd22579e8d654e02609f753cc246552dc62e6c93d85
SHELBY_API_KEY=AG-MR5SFEFY8BSVMEMVG9YETVQBZJJ2QYEPF No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk if we want to commit this...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we stub the values

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can stub, yeah. This API key is a default but I can understand the concern.

Comment thread apps/download-blob/src/index.ts Outdated
const account = AccountAddress.fromString(SHELBY_ACCOUNT_ADDRESS)

// Away we go!
async function main() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit on linting: i think this is using tabs, can we switch to two spaces to be consistent with the rest of the repo?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yeah. I thought I ran pnpm fmt but I may have also made an assumption about how it works.

Comment thread apps/download-blob/src/index.ts Outdated
Comment thread apps/download-blob/tsup.config.ts Outdated
@@ -0,0 +1,15 @@
import { defineConfig } from "tsup"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rm, we don't need this

Comment thread apps/download-blob/package.json Outdated
"@types/node": "^24.3.1",
"dotenv": "^17.2.2",
"rimraf": "^6.0.1",
"tsup": "^8.5.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rm

Comment thread apps/download-blob/package.json Outdated
Comment on lines +14 to +17
"build": "tsup",
"start": "node dist/index.js",
"dev": "tsup --watch",
"clean": "rimraf dist",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably replace this with one script that uses tsx to execute. That way we don't need to transpile to javascript. Something like

Suggested change
"build": "tsup",
"start": "node dist/index.js",
"dev": "tsup --watch",
"clean": "rimraf dist",
"download": "tsx index.ts",
"lint": "biome check .",
"fmt": "biome check . --write",

Also need lint and fmt scripts

Comment thread apps/download-blob/package.json Outdated
Comment on lines +26 to +29
"os": [
"darwin",
"linux"
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove

Comment thread pnpm-lock.yaml
@@ -16,10 +16,10 @@ importers:
version: 2.0.6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of confused why this caused so many lock changes, can we just double check maayan's example with x-chain accounts is using the same versions as this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was confusing for me as well. I could be wrong but I think it's because I forgot to pull main before starting this branch. I rebased from main to end up with this.

affinity-matrix and others added 4 commits October 12, 2025 15:39
Co-authored-by: Andrew Hariri <31301117+hariria@users.noreply.github.com>

@affinity-matrix affinity-matrix left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely much simpler, but the error output when user neglects to provide env vars is much less intuitive:

/Users/krbn/Source/examples/node_modules/.pnpm/@aptos-labs+ts-sdk@5.1.1_got@11.8.6/node_modules/@aptos-labs/ts-sdk/src/core/accountAddress.ts:385
    if (input.startsWith("0x")) {

@affinity-matrix

Copy link
Copy Markdown
Member Author

Oh, we also have these issues with fmt:

src/index.ts:26:11 lint/style/noNonNullAssertion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ⚠ Forbidden non-null assertion.

    24 │ const client = new ShelbyNodeClient({
    25 │   network: Network.SHELBYNET,
  > 26 │   apiKey: process.env.SHELBY_API_KEY!, // ensure .env is loaded
       │           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    27 │ });
    28 │


src/index.ts:31:43 lint/style/noNonNullAssertion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ⚠ Forbidden non-null assertion.

    29 │ // 2) Parse the account address you'll download from.
    30 │ //    ⚠� This should be the *same account* that previously uploaded the blob.
  > 31 │ const account = AccountAddress.fromString(process.env.SHELBY_ACCOUNT_ADDRESS!);
       │                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    32 │
    33 │ // 3) Ask Shelby for a readable Web stream of the blob bytes.


src/index.ts:40:45 lint/suspicious/noExplicitAny ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ⚠ Unexpected any. Specify a different type.

    39 │ // 5) Pipe the Web stream directly to a Node write stream (no buffering).
  > 40 │ await pipeline(Readable.fromWeb(readable as any), createWriteStream(OUT_PATH));
       │                                             ^^^
    41 │
    42 │ console.log("✓ Saved to", OUT_PATH);

@affinity-matrix

Copy link
Copy Markdown
Member Author

@hariria I'm not familiar enough with the CI process to know how to best fix this. However, now I recall this is why my PR ended up with so many changes to the pnpm-lock file:

 Failure reason:
  specifiers in the lockfile ({}) don't match specs in package.json ({"@biomejs/biome":"2.2.4","tsx":"^4.20.5","typescript":"^5.9.2","vitest":"^3.2.4","@aptos-labs/ts-sdk":"^5.1.1","@shelby-protocol/sdk":"^0.0.4"})
Error: Process completed with exit code 1.

I had regenerated the file with pnpm -w install --lockfile-only

@affinity-matrix
affinity-matrix merged commit 1b7dd48 into main Oct 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants