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

feat(sdk): Add support for Ordexer #107

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feat(sdk): Add support for Ordexer #107

wants to merge 9 commits into from

Conversation

danadi7
Copy link
Contributor

@danadi7 danadi7 commented Jan 28, 2024

What this PR does / why we need it:

  • Adds a OrdexerDatasource, which supports our new Ordexer.

Which issue(s) does this PR fixes?:

Fixes #

Additional comments?:

Copy link

vercel bot commented Jan 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ordit-sdk ✅ Ready (Inspect) Visit Preview Feb 16, 2024 6:41am

@github-actions github-actions bot added the kind/feature New feature request label Jan 28, 2024
export type DataSourceType = JsonRpcDatasource | OrdexerDatasource;

export const DataSource = {
Jsonrpc: JsonRpcDatasource,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to change it to ordit instead of Jsonrpc.

},
},
};

export const ORDEXER_AUTH_TOKEN = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make this configuration customizable to the client?, maybe put the config/opts when user defining the datasource

Comment on lines +86 to +90
const response: GetInscriptionResponse = await ordexer[this.network].get(
`/ordinals/inscriptions/${id}`,
);

const mediaContent: string = await this.getInscriptionContent({ id });
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const response: GetInscriptionResponse = await ordexer[this.network].get(
`/ordinals/inscriptions/${id}`,
);
const mediaContent: string = await this.getInscriptionContent({ id });
const [response, mediaContent] = await Promise.all([
ordexer[this.network].get(
`/ordinals/inscriptions/${id}`,
) as Promise<GetInscriptionResponse>,
this.getInscriptionContent({ id }),
]);

mediaType: inscription.mediaType ?? "",
mediaSize: inscription.mediaSize,
mediaContent: await this.getInscriptionContent({
id: inscription.inscriptionId,
Copy link
Contributor

Choose a reason for hiding this comment

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

the throttle limit would be exceeded if there are too many requests, and also network requests are doubling. i think it's better to include mediaContentBase64 in the ordexer API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking if we actually need this here, since this is GetTransaction. I'm not sure if mediaContent would be needed in this case.

@@ -95,7 +95,7 @@ export type Vin = {
/**
* Hex-encoded witness data
*/
txinwitness: string[];
txinwitness?: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it's better to make empty array on ordexer side instead of changing the type definition

@@ -30,7 +30,7 @@ export type Vout = {
/**
* Is spent (Ordit RPC), can be Outpoint `{txid}:{vout}`, or `false` if not spent
*/
spent: string | false;
spent: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, i think ordexer also should return {txid}:{vout} | false, is the ordit/client(ordzaar) aware about this changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So changing it here just makes it consistent across Ordit, Ordexer, and Ordit SDK.

Copy link
Contributor

@joundy joundy Feb 19, 2024

Choose a reason for hiding this comment

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

need to check whether the client has used the spent string or not, this transaction API will return string | boolean
https://github.com/sadoprotocol/ordit/blob/main/src/Utilities/Transaction.ts#L69C45-L69C59
maybe add spentVin for in the ordexer response if that necessary, and parse the response in sdk client without changing the types

import { Params, removeTrailingSlash } from "../utils";

class OrdexerApi {
constructor(readonly url: string) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about accepting apiKey as a param here?

(readonly url: string, params: { apiKey: string })

baseURL: this.url,
url: endpoint,
headers: {
Authorization: `Bearer ${ORDEXER_AUTH_TOKEN}`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe accept auth token from constructor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants