Skip to content

feat: shinzohub client package#226

Merged
VanishMax merged 5 commits into
mainfrom
feat/shinzohub
May 23, 2026
Merged

feat: shinzohub client package#226
VanishMax merged 5 commits into
mainfrom
feat/shinzohub

Conversation

@VanishMax
Copy link
Copy Markdown
Collaborator

Closes #222

Read #220 for description of why do we need this package. Quick recap: all big APIs should have their client libraries to centralize the usage and update it in only one place. Plus, ShinzoHub developers can do it themselves when they create new changes.

How it's done:

  1. A simple TypeScript ESM library that builds types and code separately.
  2. All methods are just an extension of Viem. This way developers keep using a very familiar web3 library but with the power of ShinzoHub.
  3. All methods are tested and documented extensively, making it easy for humans and AI to use the library.

@VanishMax VanishMax requested a review from NiranjanaBinoy May 22, 2026 13:12
@VanishMax VanishMax self-assigned this May 22, 2026
Comment on lines +80 to +84
export function hexToShinzoAddress(value: string, options: ShinzoAddressOptions = {}): ShinzoAddress {
const prefix = options.prefix ?? SHINZO_BECH32_PREFIX;
const hexAddress = normalizeHexAddress(value);
return encodeBech32(prefix, hexToBytes(hexAddress)) as ShinzoAddress;
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: this function can be used in registration, faucet and studio apps for switching from EVM to Shinzo address.

Comment on lines +44 to +53
export const shinzoHubDevelop = defineChain({
id: 91273002,
name: "ShinzoHub Develop",
nativeCurrency: currency,
rpcUrls: {
default: { http: ["http://rpc.develop.devnet.shinzo.network:8545"] },
cosmosRest: { http: ["http://rpc.develop.devnet.shinzo.network:1317"] },
cometRpc: { http: ["http://rpc.develop.devnet.shinzo.network:26657"] },
},
});
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: the library defines different shinzohub environments

Comment on lines +318 to +326
export async function createView(client: Client, parameters: CreateViewParameters): Promise<Hex> {
const tx = buildCreateViewTransaction(parameters);
return sendTransaction(client, {
to: tx.to,
data: tx.data,
chain: client.chain,
account: parameters.account ?? (client as { account?: Account | Address }).account,
} as any);
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: this function sends a transaction to register a view on shinzohub

Comment on lines +409 to +427
export async function listViews(
client: Client,
parameters: ListViewsParameters = {},
): Promise<ListViewsResult> {
const fetchFn = globalThis.fetch?.bind(globalThis);
if (!fetchFn) {
throw new Error("No fetch implementation is available.");
}

const response = await requestJson<ListViewsWireResponse>(
fetchFn,
buildListViewsUrl(getCosmosRestUrl(client, parameters), parameters),
);

return {
views: (response.views ?? []).map(toView),
pagination: toPageResponse(response.pagination),
};
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: the /shinzonetwork/view/v1/views endpoint has many many acceptable query params. This function simplifies it, adds full typing and docs on each field.

Comment on lines +104 to +106
export function createShinzoHubClient<TClient extends Client>(client: TClient) {
return client.extend(shinzoHubActions);
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

note: main entry point into the library

}

const hexAddress = shinzoAddressToHex(input, options);
return hexToShinzoAddress(hexAddress, options);
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.

[question]: why are we converting shinzoAddress to hex and then back to shinzoAddress here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it was done to reuse the address validation, but i agree that it brought the overhead. Extracted validateShinzoAddress out of the shinzo address-related functions and reused it more nicely.

Copy link
Copy Markdown
Contributor

@NiranjanaBinoy NiranjanaBinoy left a comment

Choose a reason for hiding this comment

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

I left a question, otherwise the changes looks good to me.

VanishMax added 2 commits May 23, 2026 08:46
* feat(lenses): add view bundling to lenses package

* feat(studio): apply shinzohub package to deploy a view

* fix(studio): build
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 23, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shinzo-studio 0cca34a Commit Preview URL

Branch Preview URL
May 23 2026, 04:48 AM

@VanishMax VanishMax merged commit 6112f3f into main May 23, 2026
2 checks passed
@VanishMax VanishMax deleted the feat/shinzohub branch May 23, 2026 04:49
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.

shinzohub client: create initial library skeleton

2 participants