@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 +20 -1
- package/dist/index.cjs +367 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -3
- package/dist/index.d.ts +96 -3
- package/dist/index.js +359 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1931,6 +1931,7 @@ var PROVIDERS = /* @__PURE__ */ new Set([
|
|
|
1931
1931
|
]);
|
|
1932
1932
|
var FINGERPRINT_DOMAINS = /* @__PURE__ */ new Set([
|
|
1933
1933
|
"economy.idempotency-key.v1",
|
|
1934
|
+
"economy.google-reporting-key.v1",
|
|
1934
1935
|
"economy.provider-event-key.v1",
|
|
1935
1936
|
"economy.provider-object-key.v1",
|
|
1936
1937
|
"economy.provider-payload.v1",
|
|
@@ -3441,6 +3442,7 @@ var ACTIVITY_SOURCES2 = /* @__PURE__ */ new Set([
|
|
|
3441
3442
|
"shopify",
|
|
3442
3443
|
"ayet",
|
|
3443
3444
|
"bitlabs",
|
|
3445
|
+
"google-ad-manager",
|
|
3444
3446
|
"subscription",
|
|
3445
3447
|
"event",
|
|
3446
3448
|
"competition",
|
|
@@ -4234,6 +4236,324 @@ function evaluateEarlyBackerBySettlementV2(payerAccountId, receivingHouseholdId,
|
|
|
4234
4236
|
};
|
|
4235
4237
|
}
|
|
4236
4238
|
|
|
4239
|
+
// src/google-rewarded-web.ts
|
|
4240
|
+
var GOOGLE_REWARDED_WEB_PROVIDER = "google-ad-manager";
|
|
4241
|
+
var GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN = 100000n;
|
|
4242
|
+
var GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN = 125000n;
|
|
4243
|
+
var SIGNED_BIGINT_MAX = 2n ** 63n - 1n;
|
|
4244
|
+
var CANONICAL_UNSIGNED_INTEGER = /^(?:0|[1-9][0-9]*)$/u;
|
|
4245
|
+
var SHA256 = /^sha256:[a-f0-9]{64}$/u;
|
|
4246
|
+
function assertExactKeys4(value, allowed, label) {
|
|
4247
|
+
economyAssert(
|
|
4248
|
+
Object.keys(value).every((key) => allowed.has(key)) && [...allowed].every(
|
|
4249
|
+
(key) => key === "effectiveUntil" || Object.prototype.hasOwnProperty.call(value, key)
|
|
4250
|
+
),
|
|
4251
|
+
"INVALID_CONTRACT",
|
|
4252
|
+
`${label} contains missing or unsupported fields`
|
|
4253
|
+
);
|
|
4254
|
+
}
|
|
4255
|
+
function parseGbpMicros(value, label) {
|
|
4256
|
+
economyAssert(
|
|
4257
|
+
typeof value === "string" && CANONICAL_UNSIGNED_INTEGER.test(value),
|
|
4258
|
+
"INVALID_CONTRACT",
|
|
4259
|
+
`${label} must be canonical non-negative GBP micros`
|
|
4260
|
+
);
|
|
4261
|
+
const parsed = BigInt(value);
|
|
4262
|
+
economyAssert(
|
|
4263
|
+
parsed <= SIGNED_BIGINT_MAX,
|
|
4264
|
+
"AMOUNT_OUT_OF_RANGE",
|
|
4265
|
+
`${label} is outside the signed 64-bit range`
|
|
4266
|
+
);
|
|
4267
|
+
return parsed;
|
|
4268
|
+
}
|
|
4269
|
+
function assertRewardPayload(payload) {
|
|
4270
|
+
assertExactKeys4(payload, /* @__PURE__ */ new Set(["type", "amount"]), "Reward payload");
|
|
4271
|
+
economyAssert(
|
|
4272
|
+
payload.type === "plasius-token-progress" && payload.amount === 1,
|
|
4273
|
+
"INVALID_CONTRACT",
|
|
4274
|
+
"Reward payload must disclose exactly one Token of bundle progress"
|
|
4275
|
+
);
|
|
4276
|
+
}
|
|
4277
|
+
function assertBoundedCount(value, label) {
|
|
4278
|
+
economyAssert(
|
|
4279
|
+
Number.isSafeInteger(value) && value >= 0,
|
|
4280
|
+
"INVALID_CONTRACT",
|
|
4281
|
+
`${label} must be a non-negative safe integer`
|
|
4282
|
+
);
|
|
4283
|
+
}
|
|
4284
|
+
function createGoogleRewardedWebQuote(input) {
|
|
4285
|
+
const gross = parseGbpMicros(
|
|
4286
|
+
input.grossRevenueFloorMicros,
|
|
4287
|
+
"grossRevenueFloorMicros"
|
|
4288
|
+
);
|
|
4289
|
+
const providerFee = parseGbpMicros(
|
|
4290
|
+
input.providerFeeMicros,
|
|
4291
|
+
"providerFeeMicros"
|
|
4292
|
+
);
|
|
4293
|
+
const invalidTrafficHaircut = parseGbpMicros(
|
|
4294
|
+
input.invalidTrafficHaircutMicros,
|
|
4295
|
+
"invalidTrafficHaircutMicros"
|
|
4296
|
+
);
|
|
4297
|
+
const otherCost = parseGbpMicros(input.otherCostMicros, "otherCostMicros");
|
|
4298
|
+
const deductions = providerFee + invalidTrafficHaircut + otherCost;
|
|
4299
|
+
economyAssert(
|
|
4300
|
+
deductions <= gross,
|
|
4301
|
+
"INVALID_CONTRACT",
|
|
4302
|
+
"Rewarded-web costs cannot exceed the gross revenue floor"
|
|
4303
|
+
);
|
|
4304
|
+
const eligibleNet = gross - deductions;
|
|
4305
|
+
const retainedMargin = eligibleNet - GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN;
|
|
4306
|
+
const quote = {
|
|
4307
|
+
schemaVersion: ECONOMY_CONTRACT_VERSION,
|
|
4308
|
+
quoteVersion: input.quoteVersion,
|
|
4309
|
+
provider: GOOGLE_REWARDED_WEB_PROVIDER,
|
|
4310
|
+
currency: "GBP",
|
|
4311
|
+
bundleCompletions: input.bundleCompletions,
|
|
4312
|
+
rewardPayload: input.rewardPayload,
|
|
4313
|
+
grossRevenueFloorMicros: gross.toString(10),
|
|
4314
|
+
providerFeeMicros: providerFee.toString(10),
|
|
4315
|
+
invalidTrafficHaircutMicros: invalidTrafficHaircut.toString(10),
|
|
4316
|
+
otherCostMicros: otherCost.toString(10),
|
|
4317
|
+
eligibleNetRevenueMicros: eligibleNet.toString(10),
|
|
4318
|
+
tokenAmount: serializeTokenSubunits(TOKEN_SUBUNITS_PER_TOKEN),
|
|
4319
|
+
nominalLiabilityMicros: GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN.toString(10),
|
|
4320
|
+
retainedMarginMicros: retainedMargin.toString(10),
|
|
4321
|
+
effectiveFrom: input.effectiveFrom,
|
|
4322
|
+
...input.effectiveUntil === void 0 ? {} : { effectiveUntil: input.effectiveUntil }
|
|
4323
|
+
};
|
|
4324
|
+
assertGoogleRewardedWebQuote(quote);
|
|
4325
|
+
return Object.freeze(quote);
|
|
4326
|
+
}
|
|
4327
|
+
function assertGoogleRewardedWebQuote(quote) {
|
|
4328
|
+
assertExactKeys4(
|
|
4329
|
+
quote,
|
|
4330
|
+
/* @__PURE__ */ new Set([
|
|
4331
|
+
"schemaVersion",
|
|
4332
|
+
"quoteVersion",
|
|
4333
|
+
"provider",
|
|
4334
|
+
"currency",
|
|
4335
|
+
"bundleCompletions",
|
|
4336
|
+
"rewardPayload",
|
|
4337
|
+
"grossRevenueFloorMicros",
|
|
4338
|
+
"providerFeeMicros",
|
|
4339
|
+
"invalidTrafficHaircutMicros",
|
|
4340
|
+
"otherCostMicros",
|
|
4341
|
+
"eligibleNetRevenueMicros",
|
|
4342
|
+
"tokenAmount",
|
|
4343
|
+
"nominalLiabilityMicros",
|
|
4344
|
+
"retainedMarginMicros",
|
|
4345
|
+
"effectiveFrom",
|
|
4346
|
+
"effectiveUntil"
|
|
4347
|
+
]),
|
|
4348
|
+
"Google rewarded-web quote"
|
|
4349
|
+
);
|
|
4350
|
+
economyAssert(
|
|
4351
|
+
quote.schemaVersion === ECONOMY_CONTRACT_VERSION && quote.provider === GOOGLE_REWARDED_WEB_PROVIDER && quote.currency === "GBP",
|
|
4352
|
+
"INVALID_CONTRACT",
|
|
4353
|
+
"Unsupported Google rewarded-web quote contract"
|
|
4354
|
+
);
|
|
4355
|
+
assertEconomyIdentifier(quote.quoteVersion, "quoteVersion");
|
|
4356
|
+
economyAssert(
|
|
4357
|
+
Number.isSafeInteger(quote.bundleCompletions) && quote.bundleCompletions >= 1 && quote.bundleCompletions <= 1e3,
|
|
4358
|
+
"INVALID_CONTRACT",
|
|
4359
|
+
"Bundle completions must be between 1 and 1,000"
|
|
4360
|
+
);
|
|
4361
|
+
assertRewardPayload(quote.rewardPayload);
|
|
4362
|
+
const gross = parseGbpMicros(
|
|
4363
|
+
quote.grossRevenueFloorMicros,
|
|
4364
|
+
"grossRevenueFloorMicros"
|
|
4365
|
+
);
|
|
4366
|
+
const providerFee = parseGbpMicros(
|
|
4367
|
+
quote.providerFeeMicros,
|
|
4368
|
+
"providerFeeMicros"
|
|
4369
|
+
);
|
|
4370
|
+
const invalidTrafficHaircut = parseGbpMicros(
|
|
4371
|
+
quote.invalidTrafficHaircutMicros,
|
|
4372
|
+
"invalidTrafficHaircutMicros"
|
|
4373
|
+
);
|
|
4374
|
+
const otherCost = parseGbpMicros(quote.otherCostMicros, "otherCostMicros");
|
|
4375
|
+
const eligibleNet = parseGbpMicros(
|
|
4376
|
+
quote.eligibleNetRevenueMicros,
|
|
4377
|
+
"eligibleNetRevenueMicros"
|
|
4378
|
+
);
|
|
4379
|
+
const nominalLiability = parseGbpMicros(
|
|
4380
|
+
quote.nominalLiabilityMicros,
|
|
4381
|
+
"nominalLiabilityMicros"
|
|
4382
|
+
);
|
|
4383
|
+
const retainedMargin = parseGbpMicros(
|
|
4384
|
+
quote.retainedMarginMicros,
|
|
4385
|
+
"retainedMarginMicros"
|
|
4386
|
+
);
|
|
4387
|
+
economyAssert(
|
|
4388
|
+
gross === providerFee + invalidTrafficHaircut + otherCost + eligibleNet,
|
|
4389
|
+
"INVALID_CONTRACT",
|
|
4390
|
+
"Rewarded-web quote revenue arithmetic is inconsistent"
|
|
4391
|
+
);
|
|
4392
|
+
economyAssert(
|
|
4393
|
+
parseTokenSubunits(quote.tokenAmount) === TOKEN_SUBUNITS_PER_TOKEN && nominalLiability === GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
|
|
4394
|
+
"INVALID_CONTRACT",
|
|
4395
|
+
"Rewarded-web quote must issue exactly one whole Token"
|
|
4396
|
+
);
|
|
4397
|
+
economyAssert(
|
|
4398
|
+
eligibleNet >= GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN && retainedMargin === eligibleNet - nominalLiability && retainedMargin * 5n >= eligibleNet,
|
|
4399
|
+
"INVALID_CONTRACT",
|
|
4400
|
+
"Rewarded-web quote does not preserve the 20% contribution margin"
|
|
4401
|
+
);
|
|
4402
|
+
const effectiveFrom = parseIsoTimestamp(quote.effectiveFrom);
|
|
4403
|
+
if (quote.effectiveUntil !== void 0) {
|
|
4404
|
+
economyAssert(
|
|
4405
|
+
parseIsoTimestamp(quote.effectiveUntil) > effectiveFrom,
|
|
4406
|
+
"INVALID_TIME_WINDOW",
|
|
4407
|
+
"Rewarded-web quote expiry must follow its effective time"
|
|
4408
|
+
);
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
4411
|
+
function assertGoogleRewardedWebGrantClaim(claim) {
|
|
4412
|
+
assertExactKeys4(
|
|
4413
|
+
claim,
|
|
4414
|
+
/* @__PURE__ */ new Set([
|
|
4415
|
+
"schemaVersion",
|
|
4416
|
+
"provider",
|
|
4417
|
+
"evidenceTrust",
|
|
4418
|
+
"claimId",
|
|
4419
|
+
"sessionId",
|
|
4420
|
+
"beneficiaryAccountId",
|
|
4421
|
+
"quoteVersion",
|
|
4422
|
+
"reportingKeyFingerprint",
|
|
4423
|
+
"rewardPayload",
|
|
4424
|
+
"claimedAt"
|
|
4425
|
+
]),
|
|
4426
|
+
"Google rewarded-web grant claim"
|
|
4427
|
+
);
|
|
4428
|
+
economyAssert(
|
|
4429
|
+
claim.schemaVersion === ECONOMY_CONTRACT_VERSION && claim.provider === GOOGLE_REWARDED_WEB_PROVIDER && claim.evidenceTrust === "client-claimed",
|
|
4430
|
+
"INVALID_CONTRACT",
|
|
4431
|
+
"Rewarded-web grant evidence must remain client-claimed"
|
|
4432
|
+
);
|
|
4433
|
+
assertEconomyIdentifier(claim.claimId, "claimId");
|
|
4434
|
+
assertEconomyIdentifier(claim.sessionId, "sessionId");
|
|
4435
|
+
assertEconomyIdentifier(claim.beneficiaryAccountId, "beneficiaryAccountId");
|
|
4436
|
+
assertEconomyIdentifier(claim.quoteVersion, "quoteVersion");
|
|
4437
|
+
assertEconomyHmacFingerprint(
|
|
4438
|
+
claim.reportingKeyFingerprint,
|
|
4439
|
+
"economy.google-reporting-key.v1"
|
|
4440
|
+
);
|
|
4441
|
+
assertRewardPayload(claim.rewardPayload);
|
|
4442
|
+
parseIsoTimestamp(claim.claimedAt);
|
|
4443
|
+
}
|
|
4444
|
+
function assertGoogleRewardedWebReconciliation(reconciliation, quote) {
|
|
4445
|
+
assertGoogleRewardedWebQuote(quote);
|
|
4446
|
+
assertExactKeys4(
|
|
4447
|
+
reconciliation,
|
|
4448
|
+
/* @__PURE__ */ new Set([
|
|
4449
|
+
"schemaVersion",
|
|
4450
|
+
"provider",
|
|
4451
|
+
"batchId",
|
|
4452
|
+
"quoteVersion",
|
|
4453
|
+
"state",
|
|
4454
|
+
"reportFinality",
|
|
4455
|
+
"reportFingerprint",
|
|
4456
|
+
"adUnitFingerprint",
|
|
4457
|
+
"periodStartedAt",
|
|
4458
|
+
"periodEndedAt",
|
|
4459
|
+
"acceptedClaimCount",
|
|
4460
|
+
"matchedPaidImpressionCount",
|
|
4461
|
+
"creditedBundleCount",
|
|
4462
|
+
"grossRevenueMicros",
|
|
4463
|
+
"eligibleNetRevenueMicros",
|
|
4464
|
+
"nominalLiabilityMicros",
|
|
4465
|
+
"reserveHeldMicros",
|
|
4466
|
+
"reconciledAt"
|
|
4467
|
+
]),
|
|
4468
|
+
"Google rewarded-web reconciliation"
|
|
4469
|
+
);
|
|
4470
|
+
economyAssert(
|
|
4471
|
+
reconciliation.schemaVersion === ECONOMY_CONTRACT_VERSION && reconciliation.provider === GOOGLE_REWARDED_WEB_PROVIDER && reconciliation.quoteVersion === quote.quoteVersion && ["report-matched", "financially-reconciled", "mismatch"].includes(
|
|
4472
|
+
reconciliation.state
|
|
4473
|
+
) && ["estimated", "final"].includes(reconciliation.reportFinality),
|
|
4474
|
+
"INVALID_CONTRACT",
|
|
4475
|
+
"Unsupported Google rewarded-web reconciliation contract"
|
|
4476
|
+
);
|
|
4477
|
+
assertEconomyIdentifier(reconciliation.batchId, "batchId");
|
|
4478
|
+
assertEconomyHmacFingerprint(
|
|
4479
|
+
reconciliation.reportFingerprint,
|
|
4480
|
+
"economy.provider-reconciliation.v1"
|
|
4481
|
+
);
|
|
4482
|
+
economyAssert(
|
|
4483
|
+
SHA256.test(reconciliation.adUnitFingerprint),
|
|
4484
|
+
"INVALID_CONTRACT",
|
|
4485
|
+
"Ad-unit fingerprint must be a canonical SHA-256 reference"
|
|
4486
|
+
);
|
|
4487
|
+
const periodStartedAt = parseIsoTimestamp(reconciliation.periodStartedAt);
|
|
4488
|
+
const periodEndedAt = parseIsoTimestamp(reconciliation.periodEndedAt);
|
|
4489
|
+
const reconciledAt = parseIsoTimestamp(reconciliation.reconciledAt);
|
|
4490
|
+
economyAssert(
|
|
4491
|
+
periodEndedAt > periodStartedAt && reconciledAt >= periodEndedAt,
|
|
4492
|
+
"INVALID_TIME_WINDOW",
|
|
4493
|
+
"Reconciliation period and completion times are inconsistent"
|
|
4494
|
+
);
|
|
4495
|
+
assertBoundedCount(reconciliation.acceptedClaimCount, "acceptedClaimCount");
|
|
4496
|
+
assertBoundedCount(
|
|
4497
|
+
reconciliation.matchedPaidImpressionCount,
|
|
4498
|
+
"matchedPaidImpressionCount"
|
|
4499
|
+
);
|
|
4500
|
+
assertBoundedCount(
|
|
4501
|
+
reconciliation.creditedBundleCount,
|
|
4502
|
+
"creditedBundleCount"
|
|
4503
|
+
);
|
|
4504
|
+
const gross = parseGbpMicros(
|
|
4505
|
+
reconciliation.grossRevenueMicros,
|
|
4506
|
+
"grossRevenueMicros"
|
|
4507
|
+
);
|
|
4508
|
+
const eligibleNet = parseGbpMicros(
|
|
4509
|
+
reconciliation.eligibleNetRevenueMicros,
|
|
4510
|
+
"eligibleNetRevenueMicros"
|
|
4511
|
+
);
|
|
4512
|
+
const nominalLiability = parseGbpMicros(
|
|
4513
|
+
reconciliation.nominalLiabilityMicros,
|
|
4514
|
+
"nominalLiabilityMicros"
|
|
4515
|
+
);
|
|
4516
|
+
const reserveHeld = parseGbpMicros(
|
|
4517
|
+
reconciliation.reserveHeldMicros,
|
|
4518
|
+
"reserveHeldMicros"
|
|
4519
|
+
);
|
|
4520
|
+
const expectedCompletions = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.bundleCompletions);
|
|
4521
|
+
const expectedEligibleNet = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.eligibleNetRevenueMicros);
|
|
4522
|
+
const expectedLiability = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.nominalLiabilityMicros);
|
|
4523
|
+
economyAssert(
|
|
4524
|
+
gross >= eligibleNet && nominalLiability === expectedLiability && reserveHeld >= nominalLiability,
|
|
4525
|
+
"INVALID_CONTRACT",
|
|
4526
|
+
"Reconciliation liability or reserve arithmetic is inconsistent"
|
|
4527
|
+
);
|
|
4528
|
+
if (reconciliation.state === "financially-reconciled") {
|
|
4529
|
+
economyAssert(
|
|
4530
|
+
reconciliation.reportFinality === "final" && BigInt(reconciliation.acceptedClaimCount) >= expectedCompletions && BigInt(reconciliation.matchedPaidImpressionCount) >= expectedCompletions && eligibleNet >= expectedEligibleNet,
|
|
4531
|
+
"INVALID_CONTRACT",
|
|
4532
|
+
"Financial reconciliation requires final paid impressions and revenue coverage"
|
|
4533
|
+
);
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
var STATE_TRANSITIONS = {
|
|
4537
|
+
created: /* @__PURE__ */ new Set(["bootstrapped", "suspended", "expired"]),
|
|
4538
|
+
bootstrapped: /* @__PURE__ */ new Set(["client-claimed", "suspended", "expired"]),
|
|
4539
|
+
"client-claimed": /* @__PURE__ */ new Set(["report-matched", "suspended", "expired"]),
|
|
4540
|
+
"report-matched": /* @__PURE__ */ new Set([
|
|
4541
|
+
"financially-reconciled",
|
|
4542
|
+
"suspended",
|
|
4543
|
+
"expired"
|
|
4544
|
+
]),
|
|
4545
|
+
"financially-reconciled": /* @__PURE__ */ new Set(),
|
|
4546
|
+
suspended: /* @__PURE__ */ new Set(),
|
|
4547
|
+
expired: /* @__PURE__ */ new Set()
|
|
4548
|
+
};
|
|
4549
|
+
function assertGoogleRewardedWebStateTransition(from, to) {
|
|
4550
|
+
economyAssert(
|
|
4551
|
+
STATE_TRANSITIONS[from]?.has(to) === true,
|
|
4552
|
+
"INVALID_CONTRACT",
|
|
4553
|
+
"Rewarded-web session transition is not forward-safe"
|
|
4554
|
+
);
|
|
4555
|
+
}
|
|
4556
|
+
|
|
4237
4557
|
// src/integrity.ts
|
|
4238
4558
|
function assertCanonicalHash5(value, label) {
|
|
4239
4559
|
economyAssert(
|
|
@@ -4428,6 +4748,7 @@ function assertSourceLot(lot) {
|
|
|
4428
4748
|
"shopify",
|
|
4429
4749
|
"ayet",
|
|
4430
4750
|
"bitlabs",
|
|
4751
|
+
"google-ad-manager",
|
|
4431
4752
|
"subscription",
|
|
4432
4753
|
"event",
|
|
4433
4754
|
"competition",
|
|
@@ -4450,7 +4771,7 @@ function assertSourceLot(lot) {
|
|
|
4450
4771
|
"INVALID_CONTRACT",
|
|
4451
4772
|
"Source lot has an unsupported refund state"
|
|
4452
4773
|
);
|
|
4453
|
-
if (lot.source === "ayet" || lot.source === "bitlabs") {
|
|
4774
|
+
if (lot.source === "ayet" || lot.source === "bitlabs" || lot.source === "google-ad-manager") {
|
|
4454
4775
|
economyAssert(
|
|
4455
4776
|
lot.transferPolicy === "same-user-only" && lot.providerEventId !== void 0,
|
|
4456
4777
|
"SOURCE_LOT_RESTRICTED",
|
|
@@ -5544,7 +5865,7 @@ var DECISIONS = /* @__PURE__ */ new Set([
|
|
|
5544
5865
|
"approve",
|
|
5545
5866
|
"reject"
|
|
5546
5867
|
]);
|
|
5547
|
-
function
|
|
5868
|
+
function assertExactKeys5(value, allowed, label) {
|
|
5548
5869
|
economyAssert(
|
|
5549
5870
|
value !== null && typeof value === "object" && !Array.isArray(value),
|
|
5550
5871
|
"INVALID_CONTRACT",
|
|
@@ -5571,7 +5892,7 @@ function assertReasonCode(reasonCode) {
|
|
|
5571
5892
|
);
|
|
5572
5893
|
}
|
|
5573
5894
|
function assertOperatorAdjustmentPreview(preview) {
|
|
5574
|
-
|
|
5895
|
+
assertExactKeys5(preview, PREVIEW_KEYS, "Operator adjustment preview");
|
|
5575
5896
|
economyAssert(
|
|
5576
5897
|
preview.schemaVersion === ECONOMY_CONTRACT_VERSION && OPERATIONS.has(preview.operation) && TARGET_COMPONENTS.has(preview.targetComponent) && TRANSFER_POLICIES.has(preview.transferPolicy) && preview.refundPolicy === "not-refundable",
|
|
5577
5898
|
"INVALID_CONTRACT",
|
|
@@ -5650,7 +5971,7 @@ function canonicalOperatorAdjustmentPreviewPayload(preview) {
|
|
|
5650
5971
|
function assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash) {
|
|
5651
5972
|
assertOperatorAdjustmentPreview(preview);
|
|
5652
5973
|
assertCanonicalHash6(expectedPreviewHash, "expectedPreviewHash");
|
|
5653
|
-
|
|
5974
|
+
assertExactKeys5(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
|
|
5654
5975
|
economyAssert(
|
|
5655
5976
|
proposal.schemaVersion === ECONOMY_CONTRACT_VERSION && proposal.status === "pending-approval",
|
|
5656
5977
|
"INVALID_CONTRACT",
|
|
@@ -5677,7 +5998,7 @@ function assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash
|
|
|
5677
5998
|
);
|
|
5678
5999
|
}
|
|
5679
6000
|
function canonicalOperatorAdjustmentProposalPayload(proposal) {
|
|
5680
|
-
|
|
6001
|
+
assertExactKeys5(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
|
|
5681
6002
|
return JSON.stringify({
|
|
5682
6003
|
schemaVersion: proposal.schemaVersion,
|
|
5683
6004
|
proposalId: proposal.proposalId,
|
|
@@ -5692,7 +6013,7 @@ function canonicalOperatorAdjustmentProposalPayload(proposal) {
|
|
|
5692
6013
|
function assertOperatorAdjustmentDecision(decision, proposal, preview, expectedPreviewHash, expectedProposalHash) {
|
|
5693
6014
|
assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash);
|
|
5694
6015
|
assertCanonicalHash6(expectedProposalHash, "expectedProposalHash");
|
|
5695
|
-
|
|
6016
|
+
assertExactKeys5(decision, DECISION_KEYS, "Operator adjustment decision");
|
|
5696
6017
|
economyAssert(
|
|
5697
6018
|
decision.schemaVersion === ECONOMY_CONTRACT_VERSION && DECISIONS.has(decision.decision),
|
|
5698
6019
|
"INVALID_CONTRACT",
|
|
@@ -5735,7 +6056,7 @@ function assertOperatorAdjustmentDecision(decision, proposal, preview, expectedP
|
|
|
5735
6056
|
);
|
|
5736
6057
|
}
|
|
5737
6058
|
function canonicalOperatorAdjustmentDecisionPayload(decision) {
|
|
5738
|
-
|
|
6059
|
+
assertExactKeys5(decision, DECISION_KEYS, "Operator adjustment decision");
|
|
5739
6060
|
return JSON.stringify({
|
|
5740
6061
|
schemaVersion: decision.schemaVersion,
|
|
5741
6062
|
decisionId: decision.decisionId,
|
|
@@ -5759,7 +6080,7 @@ function assertOperatorAdjustmentExecution(execution, preview, proposal, decisio
|
|
|
5759
6080
|
expectedProposalHash
|
|
5760
6081
|
);
|
|
5761
6082
|
assertCanonicalHash6(expectedDecisionHash, "expectedDecisionHash");
|
|
5762
|
-
|
|
6083
|
+
assertExactKeys5(execution, EXECUTION_KEYS, "Operator adjustment execution");
|
|
5763
6084
|
economyAssert(
|
|
5764
6085
|
execution.schemaVersion === ECONOMY_CONTRACT_VERSION,
|
|
5765
6086
|
"INVALID_CONTRACT",
|
|
@@ -5790,7 +6111,7 @@ function assertOperatorAdjustmentExecution(execution, preview, proposal, decisio
|
|
|
5790
6111
|
);
|
|
5791
6112
|
}
|
|
5792
6113
|
function canonicalOperatorAdjustmentExecutionPayload(execution) {
|
|
5793
|
-
|
|
6114
|
+
assertExactKeys5(execution, EXECUTION_KEYS, "Operator adjustment execution");
|
|
5794
6115
|
return JSON.stringify({
|
|
5795
6116
|
schemaVersion: execution.schemaVersion,
|
|
5796
6117
|
executionId: execution.executionId,
|
|
@@ -6863,6 +7184,7 @@ var ACTIVITY_SOURCES3 = /* @__PURE__ */ new Set([
|
|
|
6863
7184
|
"shopify",
|
|
6864
7185
|
"ayet",
|
|
6865
7186
|
"bitlabs",
|
|
7187
|
+
"google-ad-manager",
|
|
6866
7188
|
"subscription",
|
|
6867
7189
|
"event",
|
|
6868
7190
|
"competition",
|
|
@@ -8345,7 +8667,7 @@ var PORTABLE_KEYS = /* @__PURE__ */ new Set([
|
|
|
8345
8667
|
"signature",
|
|
8346
8668
|
...PORTABLE_BODY_KEYS
|
|
8347
8669
|
]);
|
|
8348
|
-
function
|
|
8670
|
+
function assertExactKeys6(value, allowedKeys, label) {
|
|
8349
8671
|
economyAssert(
|
|
8350
8672
|
value !== null && typeof value === "object" && !Array.isArray(value),
|
|
8351
8673
|
"INVALID_CONTRACT",
|
|
@@ -8434,7 +8756,7 @@ function canonicalSignatureMetadata(signature) {
|
|
|
8434
8756
|
};
|
|
8435
8757
|
}
|
|
8436
8758
|
function assertEconomySealedRecoveryPayload(payload) {
|
|
8437
|
-
|
|
8759
|
+
assertExactKeys6(
|
|
8438
8760
|
payload,
|
|
8439
8761
|
/* @__PURE__ */ new Set([
|
|
8440
8762
|
"schemaVersion",
|
|
@@ -8474,7 +8796,7 @@ function assertEconomySealedRecoveryPayload(payload) {
|
|
|
8474
8796
|
);
|
|
8475
8797
|
}
|
|
8476
8798
|
function assertAcceptanceBody(body) {
|
|
8477
|
-
|
|
8799
|
+
assertExactKeys6(
|
|
8478
8800
|
body,
|
|
8479
8801
|
"acceptanceEnvelopeId" in body ? ACCEPTANCE_KEYS : ACCEPTANCE_BODY_KEYS,
|
|
8480
8802
|
"Recovery acceptance body"
|
|
@@ -8543,7 +8865,7 @@ function createEconomyRecoveryAcceptanceEnvelope(body, hashCanonicalPayload2) {
|
|
|
8543
8865
|
};
|
|
8544
8866
|
}
|
|
8545
8867
|
function assertEconomyRecoveryAcceptanceEnvelope(envelope, hashCanonicalPayload2) {
|
|
8546
|
-
|
|
8868
|
+
assertExactKeys6(envelope, ACCEPTANCE_KEYS, "Recovery acceptance envelope");
|
|
8547
8869
|
assertAcceptanceBody(envelope);
|
|
8548
8870
|
assertEconomyIdentifier(
|
|
8549
8871
|
envelope.acceptanceEnvelopeId,
|
|
@@ -8584,7 +8906,7 @@ function canonicalEconomyRecoveryAcceptanceEnvelopePayload(envelope, hashCanonic
|
|
|
8584
8906
|
});
|
|
8585
8907
|
}
|
|
8586
8908
|
function assertCommittedResultBody(body) {
|
|
8587
|
-
|
|
8909
|
+
assertExactKeys6(
|
|
8588
8910
|
body,
|
|
8589
8911
|
"committedResultId" in body ? COMMITTED_RESULT_KEYS : COMMITTED_RESULT_BODY_KEYS,
|
|
8590
8912
|
"Recovery committed-result body"
|
|
@@ -8678,7 +9000,7 @@ function createEconomyRecoveryCommittedResult(body, hashCanonicalPayload2) {
|
|
|
8678
9000
|
};
|
|
8679
9001
|
}
|
|
8680
9002
|
function assertEconomyRecoveryCommittedResult(result, hashCanonicalPayload2) {
|
|
8681
|
-
|
|
9003
|
+
assertExactKeys6(
|
|
8682
9004
|
result,
|
|
8683
9005
|
COMMITTED_RESULT_KEYS,
|
|
8684
9006
|
"Recovery committed result"
|
|
@@ -8737,7 +9059,7 @@ function assertEconomyRecoveryResultLink(acceptance, result, hashCanonicalPayloa
|
|
|
8737
9059
|
);
|
|
8738
9060
|
}
|
|
8739
9061
|
function assertEconomyEvidenceSignatureMetadata(signature) {
|
|
8740
|
-
|
|
9062
|
+
assertExactKeys6(
|
|
8741
9063
|
signature,
|
|
8742
9064
|
/* @__PURE__ */ new Set([
|
|
8743
9065
|
"schemaVersion",
|
|
@@ -8757,7 +9079,7 @@ function assertEconomyEvidenceSignatureMetadata(signature) {
|
|
|
8757
9079
|
parseIsoTimestamp(signature.signedAt);
|
|
8758
9080
|
}
|
|
8759
9081
|
function assertEconomyEvidenceSignature(signature) {
|
|
8760
|
-
|
|
9082
|
+
assertExactKeys6(
|
|
8761
9083
|
signature,
|
|
8762
9084
|
/* @__PURE__ */ new Set([
|
|
8763
9085
|
"schemaVersion",
|
|
@@ -8779,7 +9101,7 @@ function assertEconomyEvidenceSignature(signature) {
|
|
|
8779
9101
|
assertBase64url(signature.value, "Evidence signature value", 32, 2048);
|
|
8780
9102
|
}
|
|
8781
9103
|
function assertRegionalEvidenceBody(body) {
|
|
8782
|
-
|
|
9104
|
+
assertExactKeys6(
|
|
8783
9105
|
body,
|
|
8784
9106
|
"evidenceReceiptId" in body ? REGIONAL_KEYS : REGIONAL_BODY_KEYS,
|
|
8785
9107
|
"Regional evidence-receipt body"
|
|
@@ -8871,7 +9193,7 @@ function createEconomyRegionalEvidenceReceipt(body, signature, hashCanonicalPayl
|
|
|
8871
9193
|
};
|
|
8872
9194
|
}
|
|
8873
9195
|
function assertEconomyRegionalEvidenceReceipt(receipt, hashCanonicalPayload2) {
|
|
8874
|
-
|
|
9196
|
+
assertExactKeys6(receipt, REGIONAL_KEYS, "Regional evidence receipt");
|
|
8875
9197
|
assertRegionalEvidenceBody(receipt);
|
|
8876
9198
|
assertEconomyIdentifier(receipt.evidenceReceiptId, "evidenceReceiptId");
|
|
8877
9199
|
assertEconomyEvidenceSignature(receipt.signature);
|
|
@@ -9073,7 +9395,7 @@ function assertEconomyRegionalEvidenceEquality(receipts, expectedRegions, hashCa
|
|
|
9073
9395
|
);
|
|
9074
9396
|
}
|
|
9075
9397
|
function assertEconomyMerkleInclusionProof(proof) {
|
|
9076
|
-
|
|
9398
|
+
assertExactKeys6(
|
|
9077
9399
|
proof,
|
|
9078
9400
|
/* @__PURE__ */ new Set([
|
|
9079
9401
|
"schemaVersion",
|
|
@@ -9104,7 +9426,7 @@ function assertEconomyMerkleInclusionProof(proof) {
|
|
|
9104
9426
|
"Merkle leaf position is outside its bounded tree"
|
|
9105
9427
|
);
|
|
9106
9428
|
for (const step of proof.siblings) {
|
|
9107
|
-
|
|
9429
|
+
assertExactKeys6(
|
|
9108
9430
|
step,
|
|
9109
9431
|
/* @__PURE__ */ new Set(["schemaVersion", "side", "hash"]),
|
|
9110
9432
|
"Merkle proof step"
|
|
@@ -9193,7 +9515,7 @@ function assertEconomyMerkleInclusion(proof, anchor, hashCanonicalPayload2) {
|
|
|
9193
9515
|
);
|
|
9194
9516
|
}
|
|
9195
9517
|
function assertPortableEvidenceReference(reference) {
|
|
9196
|
-
|
|
9518
|
+
assertExactKeys6(
|
|
9197
9519
|
reference,
|
|
9198
9520
|
/* @__PURE__ */ new Set([
|
|
9199
9521
|
"schemaVersion",
|
|
@@ -9230,7 +9552,7 @@ function canonicalPortableEvidenceReference(reference) {
|
|
|
9230
9552
|
};
|
|
9231
9553
|
}
|
|
9232
9554
|
function assertPortableBody(body) {
|
|
9233
|
-
|
|
9555
|
+
assertExactKeys6(
|
|
9234
9556
|
body,
|
|
9235
9557
|
"portableReceiptId" in body ? PORTABLE_KEYS : PORTABLE_BODY_KEYS,
|
|
9236
9558
|
"Portable customer-receipt body"
|
|
@@ -9354,7 +9676,7 @@ function createEconomyPortableCustomerReceipt(body, signature, hashCanonicalPayl
|
|
|
9354
9676
|
};
|
|
9355
9677
|
}
|
|
9356
9678
|
function assertEconomyPortableCustomerReceipt(receipt, hashCanonicalPayload2) {
|
|
9357
|
-
|
|
9679
|
+
assertExactKeys6(receipt, PORTABLE_KEYS, "Portable customer receipt");
|
|
9358
9680
|
assertPortableBody(receipt);
|
|
9359
9681
|
assertEconomyIdentifier(receipt.portableReceiptId, "portableReceiptId");
|
|
9360
9682
|
assertEconomyEvidenceSignature(receipt.signature);
|
|
@@ -9654,7 +9976,7 @@ var DOCUMENT_ID_KEYS = /* @__PURE__ */ new Set([
|
|
|
9654
9976
|
"lifetimeProjectionId",
|
|
9655
9977
|
"outboxEventId"
|
|
9656
9978
|
]);
|
|
9657
|
-
function
|
|
9979
|
+
function assertExactKeys7(value, allowed, label) {
|
|
9658
9980
|
economyAssert(
|
|
9659
9981
|
value !== null && typeof value === "object" && !Array.isArray(value),
|
|
9660
9982
|
"INVALID_CONTRACT",
|
|
@@ -9694,7 +10016,7 @@ function createPersonalWalletInitializationDocumentIds(subjectAccountId, hash) {
|
|
|
9694
10016
|
};
|
|
9695
10017
|
}
|
|
9696
10018
|
function assertPersonalWalletInitializationCommand(command) {
|
|
9697
|
-
|
|
10019
|
+
assertExactKeys7(command, COMMAND_KEYS, "Wallet initialization command");
|
|
9698
10020
|
economyAssert(
|
|
9699
10021
|
command.schemaVersion === ECONOMY_CONTRACT_VERSION && command.commandType === "initialize-wallet" && command.walletKind === "personal",
|
|
9700
10022
|
"INVALID_CONTRACT",
|
|
@@ -9718,7 +10040,7 @@ function canonicalPersonalWalletInitializationCommandPayload(command) {
|
|
|
9718
10040
|
});
|
|
9719
10041
|
}
|
|
9720
10042
|
function assertPersonalWalletInitializationOutboxIntent(intent) {
|
|
9721
|
-
|
|
10043
|
+
assertExactKeys7(intent, OUTBOX_KEYS, "Wallet initialization outbox intent");
|
|
9722
10044
|
economyAssert(
|
|
9723
10045
|
intent.schemaVersion === ECONOMY_CONTRACT_VERSION && intent.eventType === "wallet.initialized.v1",
|
|
9724
10046
|
"INVALID_CONTRACT",
|
|
@@ -9818,8 +10140,8 @@ function createPersonalWalletInitializationState(input, hash) {
|
|
|
9818
10140
|
return state;
|
|
9819
10141
|
}
|
|
9820
10142
|
function assertPersonalWalletInitializationState(state) {
|
|
9821
|
-
|
|
9822
|
-
|
|
10143
|
+
assertExactKeys7(state, STATE_KEYS, "Wallet initialization state");
|
|
10144
|
+
assertExactKeys7(
|
|
9823
10145
|
state.documentIds,
|
|
9824
10146
|
DOCUMENT_ID_KEYS,
|
|
9825
10147
|
"Wallet initialization document IDs"
|
|
@@ -9870,6 +10192,9 @@ export {
|
|
|
9870
10192
|
ECONOMY_CONTRACT_VERSION,
|
|
9871
10193
|
ECONOMY_RECOVERY_PROTOCOL_VERSION,
|
|
9872
10194
|
EconomyError,
|
|
10195
|
+
GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN,
|
|
10196
|
+
GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
|
|
10197
|
+
GOOGLE_REWARDED_WEB_PROVIDER,
|
|
9873
10198
|
MODULE_ALLOWANCE_PURPOSE,
|
|
9874
10199
|
PRE_UTILITY_BACKER_COHORT,
|
|
9875
10200
|
TOKEN_SUBUNITS_MAX,
|
|
@@ -9942,6 +10267,10 @@ export {
|
|
|
9942
10267
|
assertFlatTokenCatalog,
|
|
9943
10268
|
assertFxSnapshot,
|
|
9944
10269
|
assertGameplayAllocation,
|
|
10270
|
+
assertGoogleRewardedWebGrantClaim,
|
|
10271
|
+
assertGoogleRewardedWebQuote,
|
|
10272
|
+
assertGoogleRewardedWebReconciliation,
|
|
10273
|
+
assertGoogleRewardedWebStateTransition,
|
|
9945
10274
|
assertJournalChainHead,
|
|
9946
10275
|
assertModuleAllowance,
|
|
9947
10276
|
assertModulePurchaseReceipt,
|
|
@@ -10035,6 +10364,7 @@ export {
|
|
|
10035
10364
|
createEconomyRecoveryCommittedResult,
|
|
10036
10365
|
createEconomyRegionalEvidenceReceipt,
|
|
10037
10366
|
createGameplayAllocation,
|
|
10367
|
+
createGoogleRewardedWebQuote,
|
|
10038
10368
|
createInitialSourceLotSnapshot,
|
|
10039
10369
|
createModuleAllowance,
|
|
10040
10370
|
createModulePurchaseReceipt,
|