Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ordhook-sdk-js experiment: from proof of concept to production-readiness #177

Closed
7 tasks
lgalabru opened this issue Sep 19, 2023 · 2 comments
Closed
7 tasks

Comments

@lgalabru
Copy link
Contributor

The branch feat/improve-sdk is including a solid draft of the upcoming ordinals-api re-architecture.
Instead of starting ordhook and registering ordinals-api as an http observer receiving payloads including ordinals inscriptions / transfers, the incoming version of ordinals-api will pull a NPM @hirosystems/ordhoook-sdk-js library and implement the following skeleton (present in components/ordhook-sdk-js/lib/test.ts:

import { OrdinalsIndexer } from "./index";

const indexer = new OrdinalsIndexer({
    bitcoinRpcUrl: 'http://0.0.0.0:8332',
    bitcoinRpcUsername: 'devnet',
    bitcoinRpcPassword: 'devnet',
    workingDirectory: '/Users/ludovic/ordhook-sdk-js',
    logs: false
});

indexer.applyBlock(block => {
    console.log(`Hello from JS ${JSON.stringify(block)}`);
});

indexer.undoBlock(block => {
    console.log(`Hello from JS ${JSON.stringify(block)}`);
});

indexer.streamBlocks();

The OrdinalsIndexer struct can be fully piloted in Typescript. In case of migrations, the following actions can also be performed:

// Delete blocks and inscriptions
indexer.dropBlocks([32103, 32104]);

// Re-download + index blocks
indexer.rewriteBlocks([32103, 32104]);

// Sync blocks until chain tip
indexer.syncBlocks();

// Replay a list of blocks
indexer.replayBlocks([32103, 32104]);

The ordhook-sdk-js is producing a state (rocksdb+sqlite) identical to the one being produced by ordhook-cli. So a state produced by ordhook-cli can be reused by an app being built with ordhook-sdk-js and vice-versa.

Remaining work:

  • Wire dropBlocks method
  • Wire rewriteBlocks method
  • Wire syncBlocks method
  • Wire replayBlocks method
  • Manually publish ordhook-sdk-js on NPM for end to end testing
  • Automatically publish ordhook-sdk-js via CI
  • Prepare docker image
@smcclellan
Copy link
Contributor

@lgalabru Is this still relevant & has accurate info?

@smcclellan
Copy link
Contributor

Changing ordhook to write to pg may solve this. Closing this optimistically.

@smcclellan smcclellan closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants
@csgui @lgalabru @smcclellan and others