@cloakely/sdk 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,6 +84,11 @@ export async function buildTransaction(p) {
84
84
  const privKey = randomField();
85
85
  ins.push({ amount: 0n, privKey, pubKey: await poseidon([privKey]), blinding: randomField(), leafIndex: 0 });
86
86
  }
87
+ const shared = p.asset !== undefined;
88
+ if (shared && p.inputs.some((n) => n.asset !== p.asset))
89
+ throw new Error("every input must hold the same token");
90
+ if (shared && (extAmount !== 0n || fee !== 0n) && p.publicAsset !== p.asset)
91
+ throw new Error("moving tokens in or out must name the token");
87
92
  const outs = p.outputs.map((o) => ({ ...o, blinding: o.blinding ?? randomField() }));
88
93
  while (outs.length < 2)
89
94
  outs.push({ amount: 0n, pubKey: p.dummyPubKey, blinding: randomField(), memo: p.dummyMemo });
@@ -119,8 +124,9 @@ export async function buildTransaction(p) {
119
124
  root,
120
125
  publicAmount: fieldMod(extAmount - fee),
121
126
  extDataHash: hashExtData(extData),
122
- inputNullifier: await Promise.all(ins.map((n) => nullifierOf(n, n.leafIndex, n.privKey))),
123
- outputCommitment: await Promise.all(outs.map((o) => noteCommitment(o))),
127
+ ...(shared ? { publicAsset: p.publicAsset ?? 0n, asset: p.asset } : {}),
128
+ inputNullifier: await Promise.all(ins.map((n) => nullifierOf({ ...n, asset: p.asset }, n.leafIndex, n.privKey))),
129
+ outputCommitment: await Promise.all(outs.map((o) => noteCommitment({ ...o, asset: p.asset }))),
124
130
  inAmount: ins.map((n) => n.amount),
125
131
  inPrivateKey: ins.map((n) => n.privKey),
126
132
  inBlinding: ins.map((n) => n.blinding),
@@ -37,6 +37,11 @@ export interface CloakRegistry {
37
37
  batcher?: Address;
38
38
  batcherBlock?: bigint;
39
39
  migrator?: Address;
40
+ /** SharedVault: one private vault for every new Uniswap launch token (testnet experiment). */
41
+ shared?: Address;
42
+ sharedBlock?: bigint;
43
+ /** SharedRouter: private buys, sells and hidden sends for the shared vault. */
44
+ sharedRouter?: Address;
40
45
  factory: Address;
41
46
  factoryBlock: bigint;
42
47
  /** Earlier factories of the current version (a factory added next to the first), newest first. */
package/dist/registry.js CHANGED
@@ -32,6 +32,9 @@ export async function readRegistry(publicClient, config) {
32
32
  batcher: batcher?.addr,
33
33
  batcherBlock: batcher?.startBlock,
34
34
  migrator: newest("migrator", router.version)?.addr,
35
+ shared: newest("shared")?.addr,
36
+ sharedBlock: newest("shared")?.startBlock,
37
+ sharedRouter: newest("sharedRouter")?.addr,
35
38
  factory: factory.addr,
36
39
  factoryBlock: factory.startBlock,
37
40
  earlierFactories: entries.filter((e) => e.kind === "factory" && e.version === factory.version && e.addr !== factory.addr).reverse().map((e) => e.addr),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloakely/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Cloak on Elysium: sealed-bid token launches and private trading (shielded balances, private swaps, batch auctions, private sends) with on-device zero-knowledge proofs.",
5
5
  "keywords": [
6
6
  "cloak",