@plasius/economy 0.9.0 → 0.10.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/README.md CHANGED
@@ -50,7 +50,7 @@ outside signed PostgreSQL `bigint` range are rejected. Runtime validators also
50
50
  reject non-string JSON values rather than coercing numbers into wire amounts.
51
51
 
52
52
  `ActivityEntryV1` contains both a stable `source` (`shopify`, `ayet`, `bitlabs`,
53
- `subscription`, `event`, `competition`, or `adjustment`) and a bounded
53
+ `google-ad-manager`, `subscription`, `event`, `competition`, or `adjustment`) and a bounded
54
54
  display-oriented `sourceLabel`. Filters and reconciliation must use `source`;
55
55
  localized UI must use `sourceLabel`.
56
56
 
@@ -78,6 +78,25 @@ The default server ceilings are £50 per order and £100 per payer and household
78
78
  over 30 days. A consuming service may apply a lower household control but must
79
79
  not raise these defaults without a separately versioned policy decision.
80
80
 
81
+ ## Google rewarded web
82
+
83
+ `GoogleRewardedWebGrantClaimV1` deliberately labels GPT browser completion as
84
+ `client-claimed`; Google rewarded web has no server-side verification contract.
85
+ `GoogleRewardedWebReconciliationV1` separately proves final paid-impression,
86
+ eligible-net-revenue, nominal-liability, and reserve coverage.
87
+
88
+ `createGoogleRewardedWebQuote()` uses exact integer GBP micros and issues one
89
+ whole Token only when conservative eligible net is at least 125,000 micros for
90
+ the 100,000-micro nominal liability. The completion bundle has no package
91
+ default. `google-ad-manager` source lots must be `same-user-only` and retain an
92
+ opaque internal claim identifier; the package exposes no Token transfer to a
93
+ linked account.
94
+
95
+ A parent-owned household service may eventually provide dependent family
96
+ access without moving Tokens or assigning the entitlement. That journey is
97
+ outside this V1 contract and must stay separately flagged off until Google has
98
+ approved its exact policy treatment in writing.
99
+
81
100
  ## Balanced journal transactions
82
101
 
83
102
  ```ts
package/dist/index.cjs CHANGED
@@ -40,6 +40,9 @@ __export(index_exports, {
40
40
  ECONOMY_CONTRACT_VERSION: () => ECONOMY_CONTRACT_VERSION,
41
41
  ECONOMY_RECOVERY_PROTOCOL_VERSION: () => ECONOMY_RECOVERY_PROTOCOL_VERSION,
42
42
  EconomyError: () => EconomyError,
43
+ GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN: () => GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN,
44
+ GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN: () => GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
45
+ GOOGLE_REWARDED_WEB_PROVIDER: () => GOOGLE_REWARDED_WEB_PROVIDER,
43
46
  MODULE_ALLOWANCE_PURPOSE: () => MODULE_ALLOWANCE_PURPOSE,
44
47
  PRE_UTILITY_BACKER_COHORT: () => PRE_UTILITY_BACKER_COHORT,
45
48
  TOKEN_SUBUNITS_MAX: () => TOKEN_SUBUNITS_MAX,
@@ -112,6 +115,10 @@ __export(index_exports, {
112
115
  assertFlatTokenCatalog: () => assertFlatTokenCatalog,
113
116
  assertFxSnapshot: () => assertFxSnapshot,
114
117
  assertGameplayAllocation: () => assertGameplayAllocation,
118
+ assertGoogleRewardedWebGrantClaim: () => assertGoogleRewardedWebGrantClaim,
119
+ assertGoogleRewardedWebQuote: () => assertGoogleRewardedWebQuote,
120
+ assertGoogleRewardedWebReconciliation: () => assertGoogleRewardedWebReconciliation,
121
+ assertGoogleRewardedWebStateTransition: () => assertGoogleRewardedWebStateTransition,
115
122
  assertJournalChainHead: () => assertJournalChainHead,
116
123
  assertModuleAllowance: () => assertModuleAllowance,
117
124
  assertModulePurchaseReceipt: () => assertModulePurchaseReceipt,
@@ -205,6 +212,7 @@ __export(index_exports, {
205
212
  createEconomyRecoveryCommittedResult: () => createEconomyRecoveryCommittedResult,
206
213
  createEconomyRegionalEvidenceReceipt: () => createEconomyRegionalEvidenceReceipt,
207
214
  createGameplayAllocation: () => createGameplayAllocation,
215
+ createGoogleRewardedWebQuote: () => createGoogleRewardedWebQuote,
208
216
  createInitialSourceLotSnapshot: () => createInitialSourceLotSnapshot,
209
217
  createModuleAllowance: () => createModuleAllowance,
210
218
  createModulePurchaseReceipt: () => createModulePurchaseReceipt,
@@ -2189,6 +2197,7 @@ var PROVIDERS = /* @__PURE__ */ new Set([
2189
2197
  ]);
2190
2198
  var FINGERPRINT_DOMAINS = /* @__PURE__ */ new Set([
2191
2199
  "economy.idempotency-key.v1",
2200
+ "economy.google-reporting-key.v1",
2192
2201
  "economy.provider-event-key.v1",
2193
2202
  "economy.provider-object-key.v1",
2194
2203
  "economy.provider-payload.v1",
@@ -3699,6 +3708,7 @@ var ACTIVITY_SOURCES2 = /* @__PURE__ */ new Set([
3699
3708
  "shopify",
3700
3709
  "ayet",
3701
3710
  "bitlabs",
3711
+ "google-ad-manager",
3702
3712
  "subscription",
3703
3713
  "event",
3704
3714
  "competition",
@@ -4492,6 +4502,324 @@ function evaluateEarlyBackerBySettlementV2(payerAccountId, receivingHouseholdId,
4492
4502
  };
4493
4503
  }
4494
4504
 
4505
+ // src/google-rewarded-web.ts
4506
+ var GOOGLE_REWARDED_WEB_PROVIDER = "google-ad-manager";
4507
+ var GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN = 100000n;
4508
+ var GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN = 125000n;
4509
+ var SIGNED_BIGINT_MAX = 2n ** 63n - 1n;
4510
+ var CANONICAL_UNSIGNED_INTEGER = /^(?:0|[1-9][0-9]*)$/u;
4511
+ var SHA256 = /^sha256:[a-f0-9]{64}$/u;
4512
+ function assertExactKeys4(value, allowed, label) {
4513
+ economyAssert(
4514
+ Object.keys(value).every((key) => allowed.has(key)) && [...allowed].every(
4515
+ (key) => key === "effectiveUntil" || Object.prototype.hasOwnProperty.call(value, key)
4516
+ ),
4517
+ "INVALID_CONTRACT",
4518
+ `${label} contains missing or unsupported fields`
4519
+ );
4520
+ }
4521
+ function parseGbpMicros(value, label) {
4522
+ economyAssert(
4523
+ typeof value === "string" && CANONICAL_UNSIGNED_INTEGER.test(value),
4524
+ "INVALID_CONTRACT",
4525
+ `${label} must be canonical non-negative GBP micros`
4526
+ );
4527
+ const parsed = BigInt(value);
4528
+ economyAssert(
4529
+ parsed <= SIGNED_BIGINT_MAX,
4530
+ "AMOUNT_OUT_OF_RANGE",
4531
+ `${label} is outside the signed 64-bit range`
4532
+ );
4533
+ return parsed;
4534
+ }
4535
+ function assertRewardPayload(payload) {
4536
+ assertExactKeys4(payload, /* @__PURE__ */ new Set(["type", "amount"]), "Reward payload");
4537
+ economyAssert(
4538
+ payload.type === "plasius-token-progress" && payload.amount === 1,
4539
+ "INVALID_CONTRACT",
4540
+ "Reward payload must disclose exactly one Token of bundle progress"
4541
+ );
4542
+ }
4543
+ function assertBoundedCount(value, label) {
4544
+ economyAssert(
4545
+ Number.isSafeInteger(value) && value >= 0,
4546
+ "INVALID_CONTRACT",
4547
+ `${label} must be a non-negative safe integer`
4548
+ );
4549
+ }
4550
+ function createGoogleRewardedWebQuote(input) {
4551
+ const gross = parseGbpMicros(
4552
+ input.grossRevenueFloorMicros,
4553
+ "grossRevenueFloorMicros"
4554
+ );
4555
+ const providerFee = parseGbpMicros(
4556
+ input.providerFeeMicros,
4557
+ "providerFeeMicros"
4558
+ );
4559
+ const invalidTrafficHaircut = parseGbpMicros(
4560
+ input.invalidTrafficHaircutMicros,
4561
+ "invalidTrafficHaircutMicros"
4562
+ );
4563
+ const otherCost = parseGbpMicros(input.otherCostMicros, "otherCostMicros");
4564
+ const deductions = providerFee + invalidTrafficHaircut + otherCost;
4565
+ economyAssert(
4566
+ deductions <= gross,
4567
+ "INVALID_CONTRACT",
4568
+ "Rewarded-web costs cannot exceed the gross revenue floor"
4569
+ );
4570
+ const eligibleNet = gross - deductions;
4571
+ const retainedMargin = eligibleNet - GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN;
4572
+ const quote = {
4573
+ schemaVersion: ECONOMY_CONTRACT_VERSION,
4574
+ quoteVersion: input.quoteVersion,
4575
+ provider: GOOGLE_REWARDED_WEB_PROVIDER,
4576
+ currency: "GBP",
4577
+ bundleCompletions: input.bundleCompletions,
4578
+ rewardPayload: input.rewardPayload,
4579
+ grossRevenueFloorMicros: gross.toString(10),
4580
+ providerFeeMicros: providerFee.toString(10),
4581
+ invalidTrafficHaircutMicros: invalidTrafficHaircut.toString(10),
4582
+ otherCostMicros: otherCost.toString(10),
4583
+ eligibleNetRevenueMicros: eligibleNet.toString(10),
4584
+ tokenAmount: serializeTokenSubunits(TOKEN_SUBUNITS_PER_TOKEN),
4585
+ nominalLiabilityMicros: GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN.toString(10),
4586
+ retainedMarginMicros: retainedMargin.toString(10),
4587
+ effectiveFrom: input.effectiveFrom,
4588
+ ...input.effectiveUntil === void 0 ? {} : { effectiveUntil: input.effectiveUntil }
4589
+ };
4590
+ assertGoogleRewardedWebQuote(quote);
4591
+ return Object.freeze(quote);
4592
+ }
4593
+ function assertGoogleRewardedWebQuote(quote) {
4594
+ assertExactKeys4(
4595
+ quote,
4596
+ /* @__PURE__ */ new Set([
4597
+ "schemaVersion",
4598
+ "quoteVersion",
4599
+ "provider",
4600
+ "currency",
4601
+ "bundleCompletions",
4602
+ "rewardPayload",
4603
+ "grossRevenueFloorMicros",
4604
+ "providerFeeMicros",
4605
+ "invalidTrafficHaircutMicros",
4606
+ "otherCostMicros",
4607
+ "eligibleNetRevenueMicros",
4608
+ "tokenAmount",
4609
+ "nominalLiabilityMicros",
4610
+ "retainedMarginMicros",
4611
+ "effectiveFrom",
4612
+ "effectiveUntil"
4613
+ ]),
4614
+ "Google rewarded-web quote"
4615
+ );
4616
+ economyAssert(
4617
+ quote.schemaVersion === ECONOMY_CONTRACT_VERSION && quote.provider === GOOGLE_REWARDED_WEB_PROVIDER && quote.currency === "GBP",
4618
+ "INVALID_CONTRACT",
4619
+ "Unsupported Google rewarded-web quote contract"
4620
+ );
4621
+ assertEconomyIdentifier(quote.quoteVersion, "quoteVersion");
4622
+ economyAssert(
4623
+ Number.isSafeInteger(quote.bundleCompletions) && quote.bundleCompletions >= 1 && quote.bundleCompletions <= 1e3,
4624
+ "INVALID_CONTRACT",
4625
+ "Bundle completions must be between 1 and 1,000"
4626
+ );
4627
+ assertRewardPayload(quote.rewardPayload);
4628
+ const gross = parseGbpMicros(
4629
+ quote.grossRevenueFloorMicros,
4630
+ "grossRevenueFloorMicros"
4631
+ );
4632
+ const providerFee = parseGbpMicros(
4633
+ quote.providerFeeMicros,
4634
+ "providerFeeMicros"
4635
+ );
4636
+ const invalidTrafficHaircut = parseGbpMicros(
4637
+ quote.invalidTrafficHaircutMicros,
4638
+ "invalidTrafficHaircutMicros"
4639
+ );
4640
+ const otherCost = parseGbpMicros(quote.otherCostMicros, "otherCostMicros");
4641
+ const eligibleNet = parseGbpMicros(
4642
+ quote.eligibleNetRevenueMicros,
4643
+ "eligibleNetRevenueMicros"
4644
+ );
4645
+ const nominalLiability = parseGbpMicros(
4646
+ quote.nominalLiabilityMicros,
4647
+ "nominalLiabilityMicros"
4648
+ );
4649
+ const retainedMargin = parseGbpMicros(
4650
+ quote.retainedMarginMicros,
4651
+ "retainedMarginMicros"
4652
+ );
4653
+ economyAssert(
4654
+ gross === providerFee + invalidTrafficHaircut + otherCost + eligibleNet,
4655
+ "INVALID_CONTRACT",
4656
+ "Rewarded-web quote revenue arithmetic is inconsistent"
4657
+ );
4658
+ economyAssert(
4659
+ parseTokenSubunits(quote.tokenAmount) === TOKEN_SUBUNITS_PER_TOKEN && nominalLiability === GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
4660
+ "INVALID_CONTRACT",
4661
+ "Rewarded-web quote must issue exactly one whole Token"
4662
+ );
4663
+ economyAssert(
4664
+ eligibleNet >= GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN && retainedMargin === eligibleNet - nominalLiability && retainedMargin * 5n >= eligibleNet,
4665
+ "INVALID_CONTRACT",
4666
+ "Rewarded-web quote does not preserve the 20% contribution margin"
4667
+ );
4668
+ const effectiveFrom = parseIsoTimestamp(quote.effectiveFrom);
4669
+ if (quote.effectiveUntil !== void 0) {
4670
+ economyAssert(
4671
+ parseIsoTimestamp(quote.effectiveUntil) > effectiveFrom,
4672
+ "INVALID_TIME_WINDOW",
4673
+ "Rewarded-web quote expiry must follow its effective time"
4674
+ );
4675
+ }
4676
+ }
4677
+ function assertGoogleRewardedWebGrantClaim(claim) {
4678
+ assertExactKeys4(
4679
+ claim,
4680
+ /* @__PURE__ */ new Set([
4681
+ "schemaVersion",
4682
+ "provider",
4683
+ "evidenceTrust",
4684
+ "claimId",
4685
+ "sessionId",
4686
+ "beneficiaryAccountId",
4687
+ "quoteVersion",
4688
+ "reportingKeyFingerprint",
4689
+ "rewardPayload",
4690
+ "claimedAt"
4691
+ ]),
4692
+ "Google rewarded-web grant claim"
4693
+ );
4694
+ economyAssert(
4695
+ claim.schemaVersion === ECONOMY_CONTRACT_VERSION && claim.provider === GOOGLE_REWARDED_WEB_PROVIDER && claim.evidenceTrust === "client-claimed",
4696
+ "INVALID_CONTRACT",
4697
+ "Rewarded-web grant evidence must remain client-claimed"
4698
+ );
4699
+ assertEconomyIdentifier(claim.claimId, "claimId");
4700
+ assertEconomyIdentifier(claim.sessionId, "sessionId");
4701
+ assertEconomyIdentifier(claim.beneficiaryAccountId, "beneficiaryAccountId");
4702
+ assertEconomyIdentifier(claim.quoteVersion, "quoteVersion");
4703
+ assertEconomyHmacFingerprint(
4704
+ claim.reportingKeyFingerprint,
4705
+ "economy.google-reporting-key.v1"
4706
+ );
4707
+ assertRewardPayload(claim.rewardPayload);
4708
+ parseIsoTimestamp(claim.claimedAt);
4709
+ }
4710
+ function assertGoogleRewardedWebReconciliation(reconciliation, quote) {
4711
+ assertGoogleRewardedWebQuote(quote);
4712
+ assertExactKeys4(
4713
+ reconciliation,
4714
+ /* @__PURE__ */ new Set([
4715
+ "schemaVersion",
4716
+ "provider",
4717
+ "batchId",
4718
+ "quoteVersion",
4719
+ "state",
4720
+ "reportFinality",
4721
+ "reportFingerprint",
4722
+ "adUnitFingerprint",
4723
+ "periodStartedAt",
4724
+ "periodEndedAt",
4725
+ "acceptedClaimCount",
4726
+ "matchedPaidImpressionCount",
4727
+ "creditedBundleCount",
4728
+ "grossRevenueMicros",
4729
+ "eligibleNetRevenueMicros",
4730
+ "nominalLiabilityMicros",
4731
+ "reserveHeldMicros",
4732
+ "reconciledAt"
4733
+ ]),
4734
+ "Google rewarded-web reconciliation"
4735
+ );
4736
+ economyAssert(
4737
+ reconciliation.schemaVersion === ECONOMY_CONTRACT_VERSION && reconciliation.provider === GOOGLE_REWARDED_WEB_PROVIDER && reconciliation.quoteVersion === quote.quoteVersion && ["report-matched", "financially-reconciled", "mismatch"].includes(
4738
+ reconciliation.state
4739
+ ) && ["estimated", "final"].includes(reconciliation.reportFinality),
4740
+ "INVALID_CONTRACT",
4741
+ "Unsupported Google rewarded-web reconciliation contract"
4742
+ );
4743
+ assertEconomyIdentifier(reconciliation.batchId, "batchId");
4744
+ assertEconomyHmacFingerprint(
4745
+ reconciliation.reportFingerprint,
4746
+ "economy.provider-reconciliation.v1"
4747
+ );
4748
+ economyAssert(
4749
+ SHA256.test(reconciliation.adUnitFingerprint),
4750
+ "INVALID_CONTRACT",
4751
+ "Ad-unit fingerprint must be a canonical SHA-256 reference"
4752
+ );
4753
+ const periodStartedAt = parseIsoTimestamp(reconciliation.periodStartedAt);
4754
+ const periodEndedAt = parseIsoTimestamp(reconciliation.periodEndedAt);
4755
+ const reconciledAt = parseIsoTimestamp(reconciliation.reconciledAt);
4756
+ economyAssert(
4757
+ periodEndedAt > periodStartedAt && reconciledAt >= periodEndedAt,
4758
+ "INVALID_TIME_WINDOW",
4759
+ "Reconciliation period and completion times are inconsistent"
4760
+ );
4761
+ assertBoundedCount(reconciliation.acceptedClaimCount, "acceptedClaimCount");
4762
+ assertBoundedCount(
4763
+ reconciliation.matchedPaidImpressionCount,
4764
+ "matchedPaidImpressionCount"
4765
+ );
4766
+ assertBoundedCount(
4767
+ reconciliation.creditedBundleCount,
4768
+ "creditedBundleCount"
4769
+ );
4770
+ const gross = parseGbpMicros(
4771
+ reconciliation.grossRevenueMicros,
4772
+ "grossRevenueMicros"
4773
+ );
4774
+ const eligibleNet = parseGbpMicros(
4775
+ reconciliation.eligibleNetRevenueMicros,
4776
+ "eligibleNetRevenueMicros"
4777
+ );
4778
+ const nominalLiability = parseGbpMicros(
4779
+ reconciliation.nominalLiabilityMicros,
4780
+ "nominalLiabilityMicros"
4781
+ );
4782
+ const reserveHeld = parseGbpMicros(
4783
+ reconciliation.reserveHeldMicros,
4784
+ "reserveHeldMicros"
4785
+ );
4786
+ const expectedCompletions = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.bundleCompletions);
4787
+ const expectedEligibleNet = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.eligibleNetRevenueMicros);
4788
+ const expectedLiability = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.nominalLiabilityMicros);
4789
+ economyAssert(
4790
+ gross >= eligibleNet && nominalLiability === expectedLiability && reserveHeld >= nominalLiability,
4791
+ "INVALID_CONTRACT",
4792
+ "Reconciliation liability or reserve arithmetic is inconsistent"
4793
+ );
4794
+ if (reconciliation.state === "financially-reconciled") {
4795
+ economyAssert(
4796
+ reconciliation.reportFinality === "final" && BigInt(reconciliation.acceptedClaimCount) >= expectedCompletions && BigInt(reconciliation.matchedPaidImpressionCount) >= expectedCompletions && eligibleNet >= expectedEligibleNet,
4797
+ "INVALID_CONTRACT",
4798
+ "Financial reconciliation requires final paid impressions and revenue coverage"
4799
+ );
4800
+ }
4801
+ }
4802
+ var STATE_TRANSITIONS = {
4803
+ created: /* @__PURE__ */ new Set(["bootstrapped", "suspended", "expired"]),
4804
+ bootstrapped: /* @__PURE__ */ new Set(["client-claimed", "suspended", "expired"]),
4805
+ "client-claimed": /* @__PURE__ */ new Set(["report-matched", "suspended", "expired"]),
4806
+ "report-matched": /* @__PURE__ */ new Set([
4807
+ "financially-reconciled",
4808
+ "suspended",
4809
+ "expired"
4810
+ ]),
4811
+ "financially-reconciled": /* @__PURE__ */ new Set(),
4812
+ suspended: /* @__PURE__ */ new Set(),
4813
+ expired: /* @__PURE__ */ new Set()
4814
+ };
4815
+ function assertGoogleRewardedWebStateTransition(from, to) {
4816
+ economyAssert(
4817
+ STATE_TRANSITIONS[from]?.has(to) === true,
4818
+ "INVALID_CONTRACT",
4819
+ "Rewarded-web session transition is not forward-safe"
4820
+ );
4821
+ }
4822
+
4495
4823
  // src/integrity.ts
4496
4824
  function assertCanonicalHash5(value, label) {
4497
4825
  economyAssert(
@@ -4686,6 +5014,7 @@ function assertSourceLot(lot) {
4686
5014
  "shopify",
4687
5015
  "ayet",
4688
5016
  "bitlabs",
5017
+ "google-ad-manager",
4689
5018
  "subscription",
4690
5019
  "event",
4691
5020
  "competition",
@@ -4708,7 +5037,7 @@ function assertSourceLot(lot) {
4708
5037
  "INVALID_CONTRACT",
4709
5038
  "Source lot has an unsupported refund state"
4710
5039
  );
4711
- if (lot.source === "ayet" || lot.source === "bitlabs") {
5040
+ if (lot.source === "ayet" || lot.source === "bitlabs" || lot.source === "google-ad-manager") {
4712
5041
  economyAssert(
4713
5042
  lot.transferPolicy === "same-user-only" && lot.providerEventId !== void 0,
4714
5043
  "SOURCE_LOT_RESTRICTED",
@@ -5802,7 +6131,7 @@ var DECISIONS = /* @__PURE__ */ new Set([
5802
6131
  "approve",
5803
6132
  "reject"
5804
6133
  ]);
5805
- function assertExactKeys4(value, allowed, label) {
6134
+ function assertExactKeys5(value, allowed, label) {
5806
6135
  economyAssert(
5807
6136
  value !== null && typeof value === "object" && !Array.isArray(value),
5808
6137
  "INVALID_CONTRACT",
@@ -5829,7 +6158,7 @@ function assertReasonCode(reasonCode) {
5829
6158
  );
5830
6159
  }
5831
6160
  function assertOperatorAdjustmentPreview(preview) {
5832
- assertExactKeys4(preview, PREVIEW_KEYS, "Operator adjustment preview");
6161
+ assertExactKeys5(preview, PREVIEW_KEYS, "Operator adjustment preview");
5833
6162
  economyAssert(
5834
6163
  preview.schemaVersion === ECONOMY_CONTRACT_VERSION && OPERATIONS.has(preview.operation) && TARGET_COMPONENTS.has(preview.targetComponent) && TRANSFER_POLICIES.has(preview.transferPolicy) && preview.refundPolicy === "not-refundable",
5835
6164
  "INVALID_CONTRACT",
@@ -5908,7 +6237,7 @@ function canonicalOperatorAdjustmentPreviewPayload(preview) {
5908
6237
  function assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash) {
5909
6238
  assertOperatorAdjustmentPreview(preview);
5910
6239
  assertCanonicalHash6(expectedPreviewHash, "expectedPreviewHash");
5911
- assertExactKeys4(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
6240
+ assertExactKeys5(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
5912
6241
  economyAssert(
5913
6242
  proposal.schemaVersion === ECONOMY_CONTRACT_VERSION && proposal.status === "pending-approval",
5914
6243
  "INVALID_CONTRACT",
@@ -5935,7 +6264,7 @@ function assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash
5935
6264
  );
5936
6265
  }
5937
6266
  function canonicalOperatorAdjustmentProposalPayload(proposal) {
5938
- assertExactKeys4(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
6267
+ assertExactKeys5(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
5939
6268
  return JSON.stringify({
5940
6269
  schemaVersion: proposal.schemaVersion,
5941
6270
  proposalId: proposal.proposalId,
@@ -5950,7 +6279,7 @@ function canonicalOperatorAdjustmentProposalPayload(proposal) {
5950
6279
  function assertOperatorAdjustmentDecision(decision, proposal, preview, expectedPreviewHash, expectedProposalHash) {
5951
6280
  assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash);
5952
6281
  assertCanonicalHash6(expectedProposalHash, "expectedProposalHash");
5953
- assertExactKeys4(decision, DECISION_KEYS, "Operator adjustment decision");
6282
+ assertExactKeys5(decision, DECISION_KEYS, "Operator adjustment decision");
5954
6283
  economyAssert(
5955
6284
  decision.schemaVersion === ECONOMY_CONTRACT_VERSION && DECISIONS.has(decision.decision),
5956
6285
  "INVALID_CONTRACT",
@@ -5993,7 +6322,7 @@ function assertOperatorAdjustmentDecision(decision, proposal, preview, expectedP
5993
6322
  );
5994
6323
  }
5995
6324
  function canonicalOperatorAdjustmentDecisionPayload(decision) {
5996
- assertExactKeys4(decision, DECISION_KEYS, "Operator adjustment decision");
6325
+ assertExactKeys5(decision, DECISION_KEYS, "Operator adjustment decision");
5997
6326
  return JSON.stringify({
5998
6327
  schemaVersion: decision.schemaVersion,
5999
6328
  decisionId: decision.decisionId,
@@ -6017,7 +6346,7 @@ function assertOperatorAdjustmentExecution(execution, preview, proposal, decisio
6017
6346
  expectedProposalHash
6018
6347
  );
6019
6348
  assertCanonicalHash6(expectedDecisionHash, "expectedDecisionHash");
6020
- assertExactKeys4(execution, EXECUTION_KEYS, "Operator adjustment execution");
6349
+ assertExactKeys5(execution, EXECUTION_KEYS, "Operator adjustment execution");
6021
6350
  economyAssert(
6022
6351
  execution.schemaVersion === ECONOMY_CONTRACT_VERSION,
6023
6352
  "INVALID_CONTRACT",
@@ -6048,7 +6377,7 @@ function assertOperatorAdjustmentExecution(execution, preview, proposal, decisio
6048
6377
  );
6049
6378
  }
6050
6379
  function canonicalOperatorAdjustmentExecutionPayload(execution) {
6051
- assertExactKeys4(execution, EXECUTION_KEYS, "Operator adjustment execution");
6380
+ assertExactKeys5(execution, EXECUTION_KEYS, "Operator adjustment execution");
6052
6381
  return JSON.stringify({
6053
6382
  schemaVersion: execution.schemaVersion,
6054
6383
  executionId: execution.executionId,
@@ -7121,6 +7450,7 @@ var ACTIVITY_SOURCES3 = /* @__PURE__ */ new Set([
7121
7450
  "shopify",
7122
7451
  "ayet",
7123
7452
  "bitlabs",
7453
+ "google-ad-manager",
7124
7454
  "subscription",
7125
7455
  "event",
7126
7456
  "competition",
@@ -8603,7 +8933,7 @@ var PORTABLE_KEYS = /* @__PURE__ */ new Set([
8603
8933
  "signature",
8604
8934
  ...PORTABLE_BODY_KEYS
8605
8935
  ]);
8606
- function assertExactKeys5(value, allowedKeys, label) {
8936
+ function assertExactKeys6(value, allowedKeys, label) {
8607
8937
  economyAssert(
8608
8938
  value !== null && typeof value === "object" && !Array.isArray(value),
8609
8939
  "INVALID_CONTRACT",
@@ -8692,7 +9022,7 @@ function canonicalSignatureMetadata(signature) {
8692
9022
  };
8693
9023
  }
8694
9024
  function assertEconomySealedRecoveryPayload(payload) {
8695
- assertExactKeys5(
9025
+ assertExactKeys6(
8696
9026
  payload,
8697
9027
  /* @__PURE__ */ new Set([
8698
9028
  "schemaVersion",
@@ -8732,7 +9062,7 @@ function assertEconomySealedRecoveryPayload(payload) {
8732
9062
  );
8733
9063
  }
8734
9064
  function assertAcceptanceBody(body) {
8735
- assertExactKeys5(
9065
+ assertExactKeys6(
8736
9066
  body,
8737
9067
  "acceptanceEnvelopeId" in body ? ACCEPTANCE_KEYS : ACCEPTANCE_BODY_KEYS,
8738
9068
  "Recovery acceptance body"
@@ -8801,7 +9131,7 @@ function createEconomyRecoveryAcceptanceEnvelope(body, hashCanonicalPayload2) {
8801
9131
  };
8802
9132
  }
8803
9133
  function assertEconomyRecoveryAcceptanceEnvelope(envelope, hashCanonicalPayload2) {
8804
- assertExactKeys5(envelope, ACCEPTANCE_KEYS, "Recovery acceptance envelope");
9134
+ assertExactKeys6(envelope, ACCEPTANCE_KEYS, "Recovery acceptance envelope");
8805
9135
  assertAcceptanceBody(envelope);
8806
9136
  assertEconomyIdentifier(
8807
9137
  envelope.acceptanceEnvelopeId,
@@ -8842,7 +9172,7 @@ function canonicalEconomyRecoveryAcceptanceEnvelopePayload(envelope, hashCanonic
8842
9172
  });
8843
9173
  }
8844
9174
  function assertCommittedResultBody(body) {
8845
- assertExactKeys5(
9175
+ assertExactKeys6(
8846
9176
  body,
8847
9177
  "committedResultId" in body ? COMMITTED_RESULT_KEYS : COMMITTED_RESULT_BODY_KEYS,
8848
9178
  "Recovery committed-result body"
@@ -8936,7 +9266,7 @@ function createEconomyRecoveryCommittedResult(body, hashCanonicalPayload2) {
8936
9266
  };
8937
9267
  }
8938
9268
  function assertEconomyRecoveryCommittedResult(result, hashCanonicalPayload2) {
8939
- assertExactKeys5(
9269
+ assertExactKeys6(
8940
9270
  result,
8941
9271
  COMMITTED_RESULT_KEYS,
8942
9272
  "Recovery committed result"
@@ -8995,7 +9325,7 @@ function assertEconomyRecoveryResultLink(acceptance, result, hashCanonicalPayloa
8995
9325
  );
8996
9326
  }
8997
9327
  function assertEconomyEvidenceSignatureMetadata(signature) {
8998
- assertExactKeys5(
9328
+ assertExactKeys6(
8999
9329
  signature,
9000
9330
  /* @__PURE__ */ new Set([
9001
9331
  "schemaVersion",
@@ -9015,7 +9345,7 @@ function assertEconomyEvidenceSignatureMetadata(signature) {
9015
9345
  parseIsoTimestamp(signature.signedAt);
9016
9346
  }
9017
9347
  function assertEconomyEvidenceSignature(signature) {
9018
- assertExactKeys5(
9348
+ assertExactKeys6(
9019
9349
  signature,
9020
9350
  /* @__PURE__ */ new Set([
9021
9351
  "schemaVersion",
@@ -9037,7 +9367,7 @@ function assertEconomyEvidenceSignature(signature) {
9037
9367
  assertBase64url(signature.value, "Evidence signature value", 32, 2048);
9038
9368
  }
9039
9369
  function assertRegionalEvidenceBody(body) {
9040
- assertExactKeys5(
9370
+ assertExactKeys6(
9041
9371
  body,
9042
9372
  "evidenceReceiptId" in body ? REGIONAL_KEYS : REGIONAL_BODY_KEYS,
9043
9373
  "Regional evidence-receipt body"
@@ -9129,7 +9459,7 @@ function createEconomyRegionalEvidenceReceipt(body, signature, hashCanonicalPayl
9129
9459
  };
9130
9460
  }
9131
9461
  function assertEconomyRegionalEvidenceReceipt(receipt, hashCanonicalPayload2) {
9132
- assertExactKeys5(receipt, REGIONAL_KEYS, "Regional evidence receipt");
9462
+ assertExactKeys6(receipt, REGIONAL_KEYS, "Regional evidence receipt");
9133
9463
  assertRegionalEvidenceBody(receipt);
9134
9464
  assertEconomyIdentifier(receipt.evidenceReceiptId, "evidenceReceiptId");
9135
9465
  assertEconomyEvidenceSignature(receipt.signature);
@@ -9331,7 +9661,7 @@ function assertEconomyRegionalEvidenceEquality(receipts, expectedRegions, hashCa
9331
9661
  );
9332
9662
  }
9333
9663
  function assertEconomyMerkleInclusionProof(proof) {
9334
- assertExactKeys5(
9664
+ assertExactKeys6(
9335
9665
  proof,
9336
9666
  /* @__PURE__ */ new Set([
9337
9667
  "schemaVersion",
@@ -9362,7 +9692,7 @@ function assertEconomyMerkleInclusionProof(proof) {
9362
9692
  "Merkle leaf position is outside its bounded tree"
9363
9693
  );
9364
9694
  for (const step of proof.siblings) {
9365
- assertExactKeys5(
9695
+ assertExactKeys6(
9366
9696
  step,
9367
9697
  /* @__PURE__ */ new Set(["schemaVersion", "side", "hash"]),
9368
9698
  "Merkle proof step"
@@ -9451,7 +9781,7 @@ function assertEconomyMerkleInclusion(proof, anchor, hashCanonicalPayload2) {
9451
9781
  );
9452
9782
  }
9453
9783
  function assertPortableEvidenceReference(reference) {
9454
- assertExactKeys5(
9784
+ assertExactKeys6(
9455
9785
  reference,
9456
9786
  /* @__PURE__ */ new Set([
9457
9787
  "schemaVersion",
@@ -9488,7 +9818,7 @@ function canonicalPortableEvidenceReference(reference) {
9488
9818
  };
9489
9819
  }
9490
9820
  function assertPortableBody(body) {
9491
- assertExactKeys5(
9821
+ assertExactKeys6(
9492
9822
  body,
9493
9823
  "portableReceiptId" in body ? PORTABLE_KEYS : PORTABLE_BODY_KEYS,
9494
9824
  "Portable customer-receipt body"
@@ -9612,7 +9942,7 @@ function createEconomyPortableCustomerReceipt(body, signature, hashCanonicalPayl
9612
9942
  };
9613
9943
  }
9614
9944
  function assertEconomyPortableCustomerReceipt(receipt, hashCanonicalPayload2) {
9615
- assertExactKeys5(receipt, PORTABLE_KEYS, "Portable customer receipt");
9945
+ assertExactKeys6(receipt, PORTABLE_KEYS, "Portable customer receipt");
9616
9946
  assertPortableBody(receipt);
9617
9947
  assertEconomyIdentifier(receipt.portableReceiptId, "portableReceiptId");
9618
9948
  assertEconomyEvidenceSignature(receipt.signature);
@@ -9912,7 +10242,7 @@ var DOCUMENT_ID_KEYS = /* @__PURE__ */ new Set([
9912
10242
  "lifetimeProjectionId",
9913
10243
  "outboxEventId"
9914
10244
  ]);
9915
- function assertExactKeys6(value, allowed, label) {
10245
+ function assertExactKeys7(value, allowed, label) {
9916
10246
  economyAssert(
9917
10247
  value !== null && typeof value === "object" && !Array.isArray(value),
9918
10248
  "INVALID_CONTRACT",
@@ -9952,7 +10282,7 @@ function createPersonalWalletInitializationDocumentIds(subjectAccountId, hash) {
9952
10282
  };
9953
10283
  }
9954
10284
  function assertPersonalWalletInitializationCommand(command) {
9955
- assertExactKeys6(command, COMMAND_KEYS, "Wallet initialization command");
10285
+ assertExactKeys7(command, COMMAND_KEYS, "Wallet initialization command");
9956
10286
  economyAssert(
9957
10287
  command.schemaVersion === ECONOMY_CONTRACT_VERSION && command.commandType === "initialize-wallet" && command.walletKind === "personal",
9958
10288
  "INVALID_CONTRACT",
@@ -9976,7 +10306,7 @@ function canonicalPersonalWalletInitializationCommandPayload(command) {
9976
10306
  });
9977
10307
  }
9978
10308
  function assertPersonalWalletInitializationOutboxIntent(intent) {
9979
- assertExactKeys6(intent, OUTBOX_KEYS, "Wallet initialization outbox intent");
10309
+ assertExactKeys7(intent, OUTBOX_KEYS, "Wallet initialization outbox intent");
9980
10310
  economyAssert(
9981
10311
  intent.schemaVersion === ECONOMY_CONTRACT_VERSION && intent.eventType === "wallet.initialized.v1",
9982
10312
  "INVALID_CONTRACT",
@@ -10076,8 +10406,8 @@ function createPersonalWalletInitializationState(input, hash) {
10076
10406
  return state;
10077
10407
  }
10078
10408
  function assertPersonalWalletInitializationState(state) {
10079
- assertExactKeys6(state, STATE_KEYS, "Wallet initialization state");
10080
- assertExactKeys6(
10409
+ assertExactKeys7(state, STATE_KEYS, "Wallet initialization state");
10410
+ assertExactKeys7(
10081
10411
  state.documentIds,
10082
10412
  DOCUMENT_ID_KEYS,
10083
10413
  "Wallet initialization document IDs"
@@ -10129,6 +10459,9 @@ function assertPersonalWalletInitializationState(state) {
10129
10459
  ECONOMY_CONTRACT_VERSION,
10130
10460
  ECONOMY_RECOVERY_PROTOCOL_VERSION,
10131
10461
  EconomyError,
10462
+ GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN,
10463
+ GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
10464
+ GOOGLE_REWARDED_WEB_PROVIDER,
10132
10465
  MODULE_ALLOWANCE_PURPOSE,
10133
10466
  PRE_UTILITY_BACKER_COHORT,
10134
10467
  TOKEN_SUBUNITS_MAX,
@@ -10201,6 +10534,10 @@ function assertPersonalWalletInitializationState(state) {
10201
10534
  assertFlatTokenCatalog,
10202
10535
  assertFxSnapshot,
10203
10536
  assertGameplayAllocation,
10537
+ assertGoogleRewardedWebGrantClaim,
10538
+ assertGoogleRewardedWebQuote,
10539
+ assertGoogleRewardedWebReconciliation,
10540
+ assertGoogleRewardedWebStateTransition,
10204
10541
  assertJournalChainHead,
10205
10542
  assertModuleAllowance,
10206
10543
  assertModulePurchaseReceipt,
@@ -10294,6 +10631,7 @@ function assertPersonalWalletInitializationState(state) {
10294
10631
  createEconomyRecoveryCommittedResult,
10295
10632
  createEconomyRegionalEvidenceReceipt,
10296
10633
  createGameplayAllocation,
10634
+ createGoogleRewardedWebQuote,
10297
10635
  createInitialSourceLotSnapshot,
10298
10636
  createModuleAllowance,
10299
10637
  createModulePurchaseReceipt,