Skip to content

Commit 8b4e316

Browse files
committed
feat: expose single-package SDK integration surface
1 parent 42e7b0f commit 8b4e316

8 files changed

Lines changed: 89 additions & 32 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dependencies. Integrators normally need only the SDK:
5050
```ts
5151
import {
5252
createAssetAuctionRound,
53+
quicknet,
5354
sealAssetBid,
5455
SubRosaClient,
5556
} from "@sub-rosa/sdk";
@@ -60,6 +61,7 @@ const client = new SubRosaClient({
6061
contractId,
6162
secretKey,
6263
});
64+
const drand = quicknet();
6365

6466
const roundId = await createAssetAuctionRound(client, {
6567
itemRef,

apps/web/src/pages/DocsPage.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ const client = new SubRosaClient({
8383
const auctionCreateCode = `import { createHash } from "node:crypto";
8484
import {
8585
createAssetAuctionRound,
86-
SubRosaClient,
87-
} from "@sub-rosa/sdk";
88-
import {
8986
generateAuditorKeypair,
9087
quicknet,
9188
roundInSeconds,
92-
} from "@sub-rosa/tlock";
89+
SubRosaClient,
90+
} from "@sub-rosa/sdk";
9391
9492
const drand = quicknet();
9593
const chain = await drand.chain().info();
@@ -111,8 +109,7 @@ const roundId = await createAssetAuctionRound(sellerClient, {
111109
eligibleParticipants: collectorAddresses, // omit for an open round
112110
});`;
113111

114-
const auctionBidCode = `import { sealAssetBid, SubRosaClient } from "@sub-rosa/sdk";
115-
import { quicknet } from "@sub-rosa/tlock";
112+
const auctionBidCode = `import { quicknet, sealAssetBid, SubRosaClient } from "@sub-rosa/sdk";
116113
117114
const bidderClient = new SubRosaClient({
118115
rpcUrl,
@@ -199,7 +196,7 @@ const contract = new RoundContract({
199196
},
200197
});`;
201198

202-
const lifecycleCode = `import { fetchRoundSignature, openPayload } from "@sub-rosa/tlock";
199+
const lifecycleCode = `import { fetchRoundSignature, openPayload } from "@sub-rosa/sdk";
203200
204201
const signature = await fetchRoundSignature(drand, Number(round.reveal_round));
205202
await keeperClient.openRevealV2(roundId, signature);
@@ -388,7 +385,7 @@ export function DocsPage({ goHome }: { goHome: () => void }) {
388385
)}
389386
</div>
390387
<div className="docs-top-actions">
391-
<span className="docs-version">SDK v0.2.0</span>
388+
<span className="docs-version">SDK v0.2.1</span>
392389
<a href="https://github.com/karagozemin/Sub-Rosa" target="_blank" rel="noreferrer"><Code2 size={17} />GitHub</a>
393390
<a href="#/pilot" target="_blank" rel="noreferrer" className="docs-pilot-link">Open pilot<ArrowRight size={16} /></a>
394391
<button type="button" className="docs-mobile-menu" onClick={() => setMobileNav((value) => !value)} aria-label="Toggle documentation navigation">
@@ -424,7 +421,7 @@ export function DocsPage({ goHome }: { goHome: () => void }) {
424421
<button type="button" onClick={() => jump("auction")}><Code2 size={17} />Auction guide</button>
425422
</div>
426423
<div className="docs-proof-strip">
427-
<div><Package size={18} /><span>Public package</span><strong>@sub-rosa/sdk@0.2.0</strong></div>
424+
<div><Package size={18} /><span>Public package</span><strong>@sub-rosa/sdk@0.2.1</strong></div>
428425
<div><Server size={18} /><span>Live contract</span><strong>Core v2 testnet</strong></div>
429426
<div><FileCheck2 size={18} /><span>Live proofs</span><strong>Rounds #2 and #3</strong></div>
430427
</div>
@@ -539,7 +536,7 @@ export function DocsPage({ goHome }: { goHome: () => void }) {
539536
<div className="head" role="row"><span>Method</span><span>Purpose</span><span>Returns</span></div>
540537
{API_ROWS.map(([method, purpose, returns]) => <div role="row" key={method}><code>{method}</code><span>{purpose}</span><code>{returns}</code></div>)}
541538
</div>
542-
<div className="docs-package-row"><div><Package size={18} /><span>@sub-rosa/sdk</span><code>0.2.0</code></div><div><Package size={18} /><span>@sub-rosa/tlock</span><code>0.2.0</code></div><div><Package size={18} /><span>@sub-rosa/round-bindings</span><code>0.2.0</code></div></div>
539+
<div className="docs-package-row"><div><Package size={18} /><span>@sub-rosa/sdk</span><code>0.2.1</code></div><div><Package size={18} /><span>@sub-rosa/tlock</span><code>0.2.0</code></div><div><Package size={18} /><span>@sub-rosa/round-bindings</span><code>0.2.0</code></div></div>
543540
</section>
544541

545542
<section className="docs-section" id="errors">

docs/INTEGRATION.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ the reviewed templates.
1010
npm install @sub-rosa/sdk
1111
```
1212

13-
`@sub-rosa/sdk` depends on version-matched releases of `@sub-rosa/tlock` and
14-
`@sub-rosa/round-bindings`. Install those packages directly only when using
15-
their lower-level APIs.
13+
`@sub-rosa/sdk` exposes the complete partner integration surface, including
14+
Drand timing, seal/open helpers, auditor keys, and generated contract types. It
15+
depends on version-matched releases of `@sub-rosa/tlock` and
16+
`@sub-rosa/round-bindings`; install those packages directly only when building
17+
custom low-level cryptography or contract tooling.
1618

1719
## Client configuration
1820

@@ -39,10 +41,13 @@ asset.
3941
```ts
4042
import {
4143
createAssetAuctionRound,
44+
quicknet,
4245
sealAssetBid,
4346
SubRosaClient,
4447
} from "@sub-rosa/sdk";
4548

49+
const drand = quicknet();
50+
4651
const roundId = await createAssetAuctionRound(client, {
4752
itemRef,
4853
paymentAsset: usdcSac,

packages/sdk/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ that amount.
5151
```ts
5252
import {
5353
createSealedProposalRound,
54+
generateAuditorKeypair,
55+
quicknet,
56+
roundInSeconds,
5457
sealProposal,
5558
} from "@sub-rosa/sdk";
5659

60+
const drand = quicknet();
61+
const revealRound = await roundInSeconds(drand, 5 * 60);
62+
const auditor = generateAuditorKeypair();
63+
5764
const roundId = await createSealedProposalRound(client, {
5865
itemRef,
5966
revealRound,
6067
commitDeadline,
6168
revealDeadline,
62-
auditorPubkey,
69+
auditorPubkey: auditor.publicKey,
6370
eligibleParticipants: [providerA, providerB], // optional
6471
});
6572

@@ -109,9 +116,10 @@ simulate every state-changing call before signing.
109116

110117
## Low-level packages
111118

112-
`@sub-rosa/sdk` installs compatible `@sub-rosa/tlock` and
113-
`@sub-rosa/round-bindings` versions automatically. Install either package
114-
directly only when building custom crypto, indexing, or contract tooling.
119+
`@sub-rosa/sdk` exposes the complete partner integration surface and installs
120+
compatible `@sub-rosa/tlock` and `@sub-rosa/round-bindings` versions
121+
automatically. Install either package directly only when building custom
122+
cryptography, indexing, or contract tooling.
115123

116124
## Security boundary
117125

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sub-rosa/sdk",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"private": false,
55
"type": "module",
66
"description": "TypeScript SDK for integrating Sub Rosa sealed auctions and receipt-only proposal rounds on Stellar.",

packages/sdk/src/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,33 @@ export {
182182
type Status,
183183
type DataKey,
184184
} from "@sub-rosa/round-bindings";
185+
186+
// Partner-facing cryptography and Drand helpers. Keep this list explicit so
187+
// the SDK stays a stable facade without exposing every tlock implementation detail.
188+
export {
189+
generateAuditorKeypair,
190+
auditorPublicKey,
191+
sealIdentity,
192+
openIdentity,
193+
quicknet,
194+
chainInfo,
195+
currentRound,
196+
roundInSeconds,
197+
fetchRoundBeacon,
198+
fetchRoundSignature,
199+
QUICKNET_HASH,
200+
generateNonce,
201+
encodePayloadEnvelope,
202+
decodePayloadEnvelope,
203+
payloadCommitment,
204+
sealPayload,
205+
openPayload,
206+
PAYLOAD_ENVELOPE_VERSION,
207+
PAYLOAD_HEADER_BYTES,
208+
MAX_APPLICATION_PAYLOAD_BYTES,
209+
type AuditorKeypair,
210+
type DrandClient,
211+
type PayloadEnvelope,
212+
type SealPayloadParams,
213+
type SealedPayload,
214+
} from "@sub-rosa/tlock";

packages/sdk/src/public-api-snapshot.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ const EXPECTED_EXPORTS = [
1414
"MAINNET_DEPLOY_MIN_XLM_STROOPS",
1515
"MAINNET_MICRO_MAX_ESCROW",
1616
"MAINNET_MIN_FEE_RESERVE_STROOPS",
17+
"MAX_APPLICATION_PAYLOAD_BYTES",
1718
"MAX_AUDITOR_BLOB_BYTES",
1819
"MAX_CIPHERTEXT_BYTES",
1920
"MAX_V2_PARTICIPANTS",
21+
"PAYLOAD_ENVELOPE_VERSION",
22+
"PAYLOAD_HEADER_BYTES",
23+
"QUICKNET_HASH",
2024
"RECEIPT_VERSION",
2125
"SEALED_PROPOSAL_SCHEMA_ID",
2226
"SEALED_PROPOSAL_SCHEMA_REF",
@@ -35,31 +39,47 @@ const EXPECTED_EXPORTS = [
3539
"assertMicroAmounts",
3640
"assertReadinessForExecute",
3741
"assetAuctionRound",
42+
"auditorPublicKey",
43+
"chainInfo",
3844
"contractErrorCode",
3945
"createOzChannelsSubmitter",
4046
"createOzChannelsSubmitterFromEnv",
4147
"createSacBalanceReader",
4248
"createAssetAuctionRound",
4349
"createSealedProposalRound",
50+
"currentRound",
51+
"decodePayloadEnvelope",
4452
"decodeSealedProposal",
4553
"defaultMainnetReadinessInput",
4654
"evaluatePreflight",
4755
"encodeSealedProposal",
56+
"encodePayloadEnvelope",
4857
"fetchContractWasmHash",
4958
"fetchKeeperStatus",
59+
"fetchRoundBeacon",
60+
"fetchRoundSignature",
5061
"formatReadinessReport",
62+
"generateAuditorKeypair",
63+
"generateNonce",
5164
"hasBlockingFailures",
5265
"nativeXlmSacId",
5366
"networkFingerprint",
5467
"normalizeRoundId",
5568
"normalizeSorobanContractId",
69+
"openIdentity",
70+
"openPayload",
5671
"parseReceipt",
5772
"parseReceiptV2",
73+
"payloadCommitment",
74+
"quicknet",
5875
"redactReceipt",
76+
"roundInSeconds",
5977
"runMainnetReadiness",
6078
"serializeReceipt",
6179
"serializeReceiptV2",
6280
"sealAssetBid",
81+
"sealIdentity",
82+
"sealPayload",
6383
"sealProposal",
6484
"sealedProposalRound",
6585
"tryDecodeBase64",

scripts/verify-public-packages.mjs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ try {
6060
`expected ${packages.length} tarballs, found ${tarballs.length}`,
6161
);
6262
}
63+
const sdkTarball = tarballs.find((entry) => entry.includes("sub-rosa-sdk"));
64+
if (!sdkTarball) throw new Error("missing tarball for @sub-rosa/sdk");
6365

6466
writeFileSync(
6567
join(consumerDir, "package.json"),
@@ -69,14 +71,9 @@ try {
6971
version: "1.0.0",
7072
private: true,
7173
type: "module",
72-
dependencies: Object.fromEntries(
73-
packages.map((pkg) => {
74-
const slug = pkg.name.replace("@sub-rosa/", "sub-rosa-");
75-
const tarball = tarballs.find((entry) => entry.includes(slug));
76-
if (!tarball) throw new Error(`missing tarball for ${pkg.name}`);
77-
return [pkg.name, `file:${tarball}`];
78-
}),
79-
),
74+
dependencies: {
75+
"@sub-rosa/sdk": `file:${sdkTarball}`,
76+
},
8077
},
8178
null,
8279
2,
@@ -85,13 +82,11 @@ try {
8582

8683
writeFileSync(
8784
join(consumerDir, "verify.mjs"),
88-
`import { ASSET_AUCTION_SCHEMA_ID, SubRosaClient } from "@sub-rosa/sdk";\n` +
89-
`import { payloadCommitment } from "@sub-rosa/tlock";\n` +
90-
`import { Errors } from "@sub-rosa/round-bindings";\n` +
85+
`import { ASSET_AUCTION_SCHEMA_ID, RoundErrors, SubRosaClient, openPayload, quicknet } from "@sub-rosa/sdk";\n` +
9186
`if (!ASSET_AUCTION_SCHEMA_ID || typeof SubRosaClient !== "function") throw new Error("sdk exports missing");\n` +
92-
`if (typeof payloadCommitment !== "function") throw new Error("tlock exports missing");\n` +
93-
`if (!Errors[1]) throw new Error("bindings exports missing");\n` +
94-
`console.log("public package imports verified");\n`,
87+
`if (typeof openPayload !== "function" || typeof quicknet !== "function") throw new Error("tlock facade exports missing");\n` +
88+
`if (!RoundErrors[1]) throw new Error("bindings facade exports missing");\n` +
89+
`console.log("single-package SDK imports verified");\n`,
9590
);
9691

9792
run(

0 commit comments

Comments
 (0)