@objectid/oid-provider
v1.0.10
Published
Client-side ObjectID Provider SDK: executes Move calls directly (no backend).
Readme
@objectid/objectid-provider (client-side)
This package exposes:
- A React Provider (
ObjectID) that can auto-load ObjectID configuration from an on-chain config package - A typed API wrapper around ObjectID Move calls (methods)
React usage (auto config)
import { ObjectID, useObjectIDSession, useObjectId } from "@objectid/objectid-provider/react";
function LoginButton() {
const { connect, status, error, config } = useObjectIDSession();
async function onLogin() {
await connect({ network: "testnet", seed: "<64-hex-seed>", gasBudget: 10_000_000 });
}
return (
<div>
<button onClick={onLogin}>Connect</button>
{status === "loading" && <div>Loading config…</div>}
{error && <div>Error: {error}</div>}
{config && <pre>{JSON.stringify({ source: config.source, objectId: config.objectId }, null, 2)}</pre>}
</div>
);
}
function App() {
return (
<ObjectID configPackageIds={{
testnet: "0x...CONFIG_PKG_TESTNET",
mainnet: "0x...CONFIG_PKG_MAINNET"
}}>
<LoginButton />
</ObjectID>
);
}Config discovery (no GraphQL)
The provider uses JSON-RPC only:
- it looks for a user-owned config object of type
<configPkg>::oid_config::Config - if not found, it discovers the shared default config object by querying the latest tx calling:
<configPkg>::oid_config::set_default_jsonand extracting the mutated shared Config object id fromobjectChanges
Windows note (npm install)
This package does not run prepare on install. Build it once with npm run build inside the SDK folder before consuming it via file:.
High-level wrapper: createOid()
This version includes a wrapper with an explicit initialization phase.
import { createOid } from "@objectid/objectid-provider";
const oid = createOid();
// Any tx method before init throws "not initialized"
await oid.config(did, seed, network);
console.log(oid.session.address);
const r = await oid.create_object({ /* ... */ });