@chipi-stack/core 0.4.0 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -1127,6 +1127,16 @@ interface ProofResult {
1127
1127
  data: string;
1128
1128
  output: string[];
1129
1129
  proofFacts: string[];
1130
+ /** Screening attestation side-channel from a screening-capable prover
1131
+ * (hosted proving). Pool v2.0 REQUIRES it on deposits; the bundled SDK
1132
+ * packs it into apply_actions calldata when present. */
1133
+ additionalData?: {
1134
+ signature?: {
1135
+ issued_at: number;
1136
+ sig_r: string;
1137
+ sig_s: string;
1138
+ };
1139
+ };
1130
1140
  }
1131
1141
  interface ProofInvocation {
1132
1142
  sender_address: string;
package/dist/index.js CHANGED
@@ -1071,7 +1071,7 @@ function buildUnshieldCalls(params) {
1071
1071
  function resolveFetch(f) {
1072
1072
  const impl = f ?? globalThis.fetch;
1073
1073
  if (!impl) throw new Error("No fetch implementation available \u2014 pass one explicitly");
1074
- return impl;
1074
+ return (url, init) => impl(url, init);
1075
1075
  }
1076
1076
  var DelegatedProver = class {
1077
1077
  constructor(opts) {
@@ -3278,6 +3278,16 @@ var PrivateTransfers = class extends AbstractPrivateTransfers {
3278
3278
  const { invocation, registry, warnings } = await this.createProofInvocation(actions, options);
3279
3279
  const proof = await this.params.provingProvider.prove(invocation, options?.provingBlockId);
3280
3280
  const serverActionsCalldata2 = proof.output.slice(1);
3281
+ const attestation = options?.screening ? {
3282
+ issuedAt: options.screening.issuedAt,
3283
+ r: options.screening.signatureR,
3284
+ s: options.screening.signatureS
3285
+ } : proof.additionalData?.signature ? {
3286
+ issuedAt: proof.additionalData.signature.issued_at,
3287
+ r: proof.additionalData.signature.sig_r,
3288
+ s: proof.additionalData.signature.sig_s
3289
+ } : void 0;
3290
+ const screeningCalldata = attestation ? ["0x0", "0x" + BigInt(attestation.issuedAt).toString(16), attestation.r, attestation.s] : ["0x1"];
3281
3291
  const parsedOutput = () => this.params.proofInvocationFactory.parseOutput(serverActionsCalldata2);
3282
3292
  debugLog("private-transfers", "execute", "parsed server actions", parsedOutput);
3283
3293
  return {
@@ -3285,7 +3295,7 @@ var PrivateTransfers = class extends AbstractPrivateTransfers {
3285
3295
  call: {
3286
3296
  contractAddress: toHex(this.params.poolContractAddress),
3287
3297
  entrypoint: "apply_actions",
3288
- calldata: serverActionsCalldata2
3298
+ calldata: [...serverActionsCalldata2, ...screeningCalldata]
3289
3299
  },
3290
3300
  proof
3291
3301
  },
@@ -10055,10 +10065,19 @@ var MessageToL1Schema = external_exports.object({
10055
10065
  to_address: external_exports.string(),
10056
10066
  payload: external_exports.array(external_exports.string())
10057
10067
  }).strict();
10068
+ var ScreeningSignatureSchema = external_exports.object({
10069
+ issued_at: external_exports.number(),
10070
+ sig_r: external_exports.string(),
10071
+ sig_s: external_exports.string()
10072
+ }).strict();
10073
+ var AdditionalDataSchema = external_exports.object({
10074
+ signature: ScreeningSignatureSchema.optional()
10075
+ }).passthrough();
10058
10076
  var ProveTransactionResultSchema = external_exports.object({
10059
10077
  proof: external_exports.string().min(1),
10060
10078
  proof_facts: external_exports.array(external_exports.string()),
10061
- l2_to_l1_messages: external_exports.array(MessageToL1Schema)
10079
+ l2_to_l1_messages: external_exports.array(MessageToL1Schema),
10080
+ additional_data: AdditionalDataSchema.optional()
10062
10081
  }).strict();
10063
10082
  var ProvingService = class {
10064
10083
  constructor(config) {
@@ -10148,7 +10167,8 @@ var ProvingServiceProofProvider = class {
10148
10167
  return {
10149
10168
  data: result.proof,
10150
10169
  output,
10151
- proofFacts
10170
+ proofFacts,
10171
+ additionalData: result.additional_data
10152
10172
  };
10153
10173
  }
10154
10174
  };
@@ -10546,9 +10566,7 @@ var ChipiProofProvider = class extends ProvingServiceProofProvider {
10546
10566
  this.chipiGetBearer = opts.getBearerToken;
10547
10567
  this.chipiProvePath = opts.provePath ?? "/privacy/prove";
10548
10568
  this.chipiBlockId = opts.blockId ?? "latest";
10549
- const impl = opts.fetchImpl ?? globalThis.fetch;
10550
- if (!impl) throw new Error("No fetch implementation available \u2014 pass one explicitly");
10551
- this.chipiFetch = impl;
10569
+ this.chipiFetch = resolveFetch(opts.fetchImpl);
10552
10570
  }
10553
10571
  async prove(invocation, blockIdentifier) {
10554
10572
  const post = async () => {
@@ -10581,7 +10599,15 @@ var ChipiProofProvider = class extends ProvingServiceProofProvider {
10581
10599
  const poolMsg = (body.l2ToL1Messages ?? []).find(
10582
10600
  (m) => m.from_address !== void 0 && BigInt(m.from_address) === poolAddr
10583
10601
  );
10584
- return { data: body.proof, output: poolMsg?.payload ?? [], proofFacts: body.proofFacts };
10602
+ return {
10603
+ data: body.proof,
10604
+ output: poolMsg?.payload ?? [],
10605
+ proofFacts: body.proofFacts,
10606
+ // Screening-capable provers attach the deposit attestation here; the
10607
+ // bundled SDK packs it into apply_actions calldata (pool v2.0 requires
10608
+ // it on deposits — SCREENING_REQUIRED).
10609
+ additionalData: body.additionalData
10610
+ };
10585
10611
  }
10586
10612
  };
10587
10613