@ocap/tx-pipeline 1.30.25 → 1.31.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.
Files changed (149) hide show
  1. package/esm/appchain-sovereign-hub.d.mts +160 -0
  2. package/esm/appchain-sovereign-hub.mjs +348 -0
  3. package/esm/arcvault-external-adapter.d.mts +166 -0
  4. package/esm/arcvault-external-adapter.mjs +376 -0
  5. package/esm/encrypted-nft-envelope.d.mts +172 -0
  6. package/esm/encrypted-nft-envelope.mjs +458 -0
  7. package/esm/evm-simplified-bridge.d.mts +1370 -0
  8. package/esm/evm-simplified-bridge.mjs +3875 -0
  9. package/esm/give-to-mint-karma.d.mts +472 -0
  10. package/esm/give-to-mint-karma.mjs +1057 -0
  11. package/esm/helpers/replay-guard.d.mts +15 -0
  12. package/esm/helpers/replay-guard.mjs +23 -0
  13. package/esm/index.d.mts +10 -5
  14. package/esm/index.mjs +14 -10
  15. package/esm/legacy-protocol-sunset.d.mts +251 -0
  16. package/esm/legacy-protocol-sunset.mjs +1519 -0
  17. package/esm/library.d.mts +16 -0
  18. package/esm/library.mjs +17 -0
  19. package/esm/native-abt-exchange.d.mts +2055 -0
  20. package/esm/native-abt-exchange.mjs +7250 -0
  21. package/esm/ofac-screening.d.mts +17 -0
  22. package/esm/ofac-screening.mjs +39 -0
  23. package/esm/pipes/anti-land-attack.mjs +1 -1
  24. package/esm/pipes/decode-itx.mjs +43 -4
  25. package/esm/pipes/decode-tx.d.mts +2 -3
  26. package/esm/pipes/decode-tx.mjs +53 -115
  27. package/esm/pipes/extract-signer.mjs +2 -2
  28. package/esm/pipes/extract-state.mjs +14 -3
  29. package/esm/pipes/post-execution-invariant-gate.d.mts +61 -0
  30. package/esm/pipes/post-execution-invariant-gate.mjs +789 -0
  31. package/esm/pipes/pre-flight-waf.d.mts +34 -0
  32. package/esm/pipes/pre-flight-waf.mjs +603 -0
  33. package/esm/pipes/take-state-snapshot.mjs +3 -2
  34. package/esm/pipes/update-owner.mjs +39 -4
  35. package/esm/pipes/verify-account-migration.mjs +14 -4
  36. package/esm/pipes/verify-blocked.mjs +1 -1
  37. package/esm/pipes/verify-delegation.d.mts +22 -3
  38. package/esm/pipes/verify-delegation.mjs +259 -36
  39. package/esm/pipes/verify-list-size.mjs +1 -1
  40. package/esm/pipes/verify-multisig-v2.mjs +15 -7
  41. package/esm/pipes/verify-multisig.mjs +15 -7
  42. package/esm/pipes/verify-sender.mjs +1 -1
  43. package/esm/pipes/verify-signature.mjs +35 -6
  44. package/esm/pipes/verify-signer.mjs +2 -2
  45. package/esm/pipes/verify-state-diff.mjs +3 -3
  46. package/esm/pipes/verify-token-access.mjs +1 -1
  47. package/esm/pipes/verify-token-balance.mjs +13 -5
  48. package/esm/pipes/verify-transferrable.d.mts +8 -1
  49. package/esm/pipes/verify-transferrable.mjs +3 -3
  50. package/esm/pipes/verify-tx-input.mjs +2 -2
  51. package/esm/pipes/verify-tx-size.mjs +46 -2
  52. package/esm/pipes/verify-tx.mjs +5 -7
  53. package/esm/pipes/verify-updater.mjs +1 -1
  54. package/esm/social-economy-factories.d.mts +346 -0
  55. package/esm/social-economy-factories.mjs +845 -0
  56. package/esm/super-suites-foundation.d.mts +513 -0
  57. package/esm/super-suites-foundation.mjs +1241 -0
  58. package/esm/transaction-block.d.mts +471 -0
  59. package/esm/transaction-block.mjs +1906 -0
  60. package/esm/uniswap-erc7683-solver.d.mts +201 -0
  61. package/esm/uniswap-erc7683-solver.mjs +321 -0
  62. package/esm/uniswap-lp-copilot.d.mts +113 -0
  63. package/esm/uniswap-lp-copilot.mjs +320 -0
  64. package/esm/uniswap-router.d.mts +335 -0
  65. package/esm/uniswap-router.mjs +578 -0
  66. package/esm/uniswap-token-factory-graduation.d.mts +187 -0
  67. package/esm/uniswap-token-factory-graduation.mjs +426 -0
  68. package/esm/uniswap-v4-hook.d.mts +173 -0
  69. package/esm/uniswap-v4-hook.mjs +517 -0
  70. package/lib/appchain-sovereign-hub.cjs +352 -0
  71. package/lib/appchain-sovereign-hub.d.cts +160 -0
  72. package/lib/arcvault-external-adapter.cjs +383 -0
  73. package/lib/arcvault-external-adapter.d.cts +166 -0
  74. package/lib/encrypted-nft-envelope.cjs +477 -0
  75. package/lib/encrypted-nft-envelope.d.cts +172 -0
  76. package/lib/evm-simplified-bridge.cjs +3943 -0
  77. package/lib/evm-simplified-bridge.d.cts +1370 -0
  78. package/lib/give-to-mint-karma.cjs +1084 -0
  79. package/lib/give-to-mint-karma.d.cts +472 -0
  80. package/lib/helpers/replay-guard.cjs +27 -0
  81. package/lib/helpers/replay-guard.d.cts +15 -0
  82. package/lib/index.cjs +49 -16
  83. package/lib/index.d.cts +10 -5
  84. package/lib/legacy-protocol-sunset.cjs +1543 -0
  85. package/lib/legacy-protocol-sunset.d.cts +251 -0
  86. package/lib/library.cjs +303 -0
  87. package/lib/library.d.cts +16 -0
  88. package/lib/native-abt-exchange.cjs +7322 -0
  89. package/lib/native-abt-exchange.d.cts +2055 -0
  90. package/lib/ofac-screening.cjs +42 -0
  91. package/lib/ofac-screening.d.cts +17 -0
  92. package/lib/pipes/anti-land-attack.cjs +2 -2
  93. package/lib/pipes/decode-itx.cjs +43 -4
  94. package/lib/pipes/decode-itx.d.cts +1 -1
  95. package/lib/pipes/decode-tx.cjs +52 -116
  96. package/lib/pipes/decode-tx.d.cts +3 -4
  97. package/lib/pipes/extract-signer.cjs +2 -2
  98. package/lib/pipes/extract-state.cjs +14 -3
  99. package/lib/pipes/post-execution-invariant-gate.cjs +800 -0
  100. package/lib/pipes/post-execution-invariant-gate.d.cts +61 -0
  101. package/lib/pipes/pre-flight-waf.cjs +616 -0
  102. package/lib/pipes/pre-flight-waf.d.cts +34 -0
  103. package/lib/pipes/take-state-snapshot.cjs +3 -2
  104. package/lib/pipes/update-owner.cjs +40 -5
  105. package/lib/pipes/update-owner.d.cts +1 -1
  106. package/lib/pipes/verify-account-migration.cjs +14 -4
  107. package/lib/pipes/verify-blocked.cjs +1 -1
  108. package/lib/pipes/verify-delegation.cjs +259 -36
  109. package/lib/pipes/verify-delegation.d.cts +22 -3
  110. package/lib/pipes/verify-list-size.cjs +1 -1
  111. package/lib/pipes/verify-multisig-v2.cjs +15 -7
  112. package/lib/pipes/verify-multisig.cjs +15 -7
  113. package/lib/pipes/verify-sender.cjs +1 -1
  114. package/lib/pipes/verify-service-fee.d.cts +1 -1
  115. package/lib/pipes/verify-signature.cjs +35 -6
  116. package/lib/pipes/verify-signature.d.cts +1 -1
  117. package/lib/pipes/verify-signer.cjs +2 -2
  118. package/lib/pipes/verify-state-diff.cjs +4 -4
  119. package/lib/pipes/verify-token-access.cjs +2 -2
  120. package/lib/pipes/verify-token-balance.cjs +13 -5
  121. package/lib/pipes/verify-transferrable.cjs +3 -3
  122. package/lib/pipes/verify-transferrable.d.cts +8 -1
  123. package/lib/pipes/verify-tx-input.cjs +3 -3
  124. package/lib/pipes/verify-tx-size.cjs +46 -2
  125. package/lib/pipes/verify-tx-size.d.cts +1 -1
  126. package/lib/pipes/verify-tx.cjs +6 -8
  127. package/lib/pipes/verify-tx.d.cts +1 -1
  128. package/lib/pipes/verify-updater.cjs +1 -1
  129. package/lib/social-economy-factories.cjs +852 -0
  130. package/lib/social-economy-factories.d.cts +346 -0
  131. package/lib/super-suites-foundation.cjs +1257 -0
  132. package/lib/super-suites-foundation.d.cts +513 -0
  133. package/lib/transaction-block.cjs +1941 -0
  134. package/lib/transaction-block.d.cts +471 -0
  135. package/lib/uniswap-erc7683-solver.cjs +327 -0
  136. package/lib/uniswap-erc7683-solver.d.cts +201 -0
  137. package/lib/uniswap-lp-copilot.cjs +328 -0
  138. package/lib/uniswap-lp-copilot.d.cts +113 -0
  139. package/lib/uniswap-router.cjs +593 -0
  140. package/lib/uniswap-router.d.cts +335 -0
  141. package/lib/uniswap-token-factory-graduation.cjs +431 -0
  142. package/lib/uniswap-token-factory-graduation.d.cts +187 -0
  143. package/lib/uniswap-v4-hook.cjs +527 -0
  144. package/lib/uniswap-v4-hook.d.cts +173 -0
  145. package/package.json +11 -10
  146. package/esm/helpers/dedup-height.d.mts +0 -16
  147. package/esm/helpers/dedup-height.mjs +0 -61
  148. package/lib/helpers/dedup-height.cjs +0 -72
  149. package/lib/helpers/dedup-height.d.cts +0 -16
@@ -0,0 +1,852 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_give_to_mint_karma = require('./give-to-mint-karma.cjs');
3
+ let _ocap_util_lib_error = require("@ocap/util/lib/error");
4
+ let node_crypto = require("node:crypto");
5
+
6
+ //#region src/social-economy-factories.ts
7
+ const ErrorCode = {
8
+ InvalidFactory: "INVALID_SOCIAL_ECONOMY_FACTORY",
9
+ ForbiddenFactory: "FORBIDDEN_SOCIAL_ECONOMY_FACTORY"
10
+ };
11
+ const MAX_SOVEREIGN_NFT_FACTORY_SUPPLY = 1e6;
12
+ const MAX_ISSUER_STAGING_TTL_EPOCHS = 90;
13
+ const DEFAULT_ISSUER_STAGING_TTL_EPOCHS = 7;
14
+ const BYTES32_HEX_REGEX = /^0x[0-9a-fA-F]{64}$/;
15
+ const VALID_VISIBILITIES = new Set([
16
+ "public",
17
+ "authorized_only",
18
+ "private"
19
+ ]);
20
+ const VALID_NFT_CATEGORIES = new Set([
21
+ "PUBLIC_HONOR_BADGE",
22
+ "PRIVATE_ENCRYPTED_DELIVERABLE",
23
+ "MEMBERSHIP_PASS"
24
+ ]);
25
+ const VALID_POOL_KINDS = new Set([
26
+ "PERSONAL_BAT_TIPPING_POOL",
27
+ "CRYPTO_ADSENSE_SPONSOR_POOL",
28
+ "PHILANTHROPY_TAX_DONATION_POOL"
29
+ ]);
30
+ function assertCleanId(value, label) {
31
+ if (typeof value !== "string" || value.trim().length === 0) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: ${label} must be a non-empty string`);
32
+ const trimmed = value.trim();
33
+ if (trimmed !== value || /[\s/\\?#%]|::|->/.test(trimmed)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: ${label} contains invalid characters`);
34
+ return trimmed;
35
+ }
36
+ function assertValidEpoch(epochIndex) {
37
+ if (!Number.isSafeInteger(epochIndex) || epochIndex < 0) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: epochIndex must be a non-negative safe integer");
38
+ }
39
+ function deriveSovereignNftDid(factoryDid, recipientHolderDid, serialNumber, payloadCommitmentDigest) {
40
+ return `did:abt:snft:${(0, node_crypto.createHash)("sha256").update(`ocap:sovereign-nft:v1:${factoryDid}:${recipientHolderDid}:${serialNumber}:${payloadCommitmentDigest.toLowerCase()}`).digest("hex").slice(0, 40)}`;
41
+ }
42
+ /**
43
+ * Issue #1233 (Phase 1 — Foundation):
44
+ * Unified OCAP Social-Economy Factory Registry providing standardized, parameter-driven
45
+ * factories for:
46
+ * 1. `ReputationTokenFactory` (`type = "give_to_mint"`)
47
+ * 2. `SovereignNftFactory` (Holder-hosted `ArcSpace` payload, `public/authorized_only/private` consent gate,
48
+ * and 3-stage delivery custody handover `ISSUER_TEMP_STAGED -> HOLDER_SAVED_IN_ARCSPACE -> ISSUER_STORAGE_RELEASED`)
49
+ * 3. `KarmaSettlementPoolFactory` (Pro-rata KARMA-indexed epoch pool settlement)
50
+ */
51
+ var OcapSocialEconomyFactoryRegistry = class {
52
+ constructor(karmaEngine) {
53
+ this.tokenFactories = /* @__PURE__ */ new Map();
54
+ this.nftFactories = /* @__PURE__ */ new Map();
55
+ this.nftInstances = /* @__PURE__ */ new Map();
56
+ this.poolFactories = /* @__PURE__ */ new Map();
57
+ this.processedPilotRunIds = /* @__PURE__ */ new Set();
58
+ this.processedBlueprintIds = /* @__PURE__ */ new Set();
59
+ this.karmaEngine = karmaEngine ?? new require_give_to_mint_karma.OcapGiveToMintEngine();
60
+ const defaultTokenConfig = this.karmaEngine.getTokenConfig(require_give_to_mint_karma.DEFAULT_KARMA_TOKEN_ADDRESS);
61
+ this.tokenFactories.set("did:abt:factory:token:default-karma", {
62
+ factoryDid: "did:abt:factory:token:default-karma",
63
+ tokenConfig: defaultTokenConfig,
64
+ createdAtEpoch: 0
65
+ });
66
+ }
67
+ assertFactoryDidAvailable(factoryDid) {
68
+ if (this.tokenFactories.has(factoryDid) || this.nftFactories.has(factoryDid) || this.poolFactories.has(factoryDid)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: factoryDid ${factoryDid} already exists`);
69
+ }
70
+ assertVerifiedIdentity(did, roleLabel) {
71
+ const state = this.karmaEngine.getIdentityState(did);
72
+ if (!state || !state.verifiedHumanOrStaker || state.trustMultiplierBps <= 0) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: ${roleLabel} ${did} must be an active verified identity with positive trustMultiplierBps`);
73
+ }
74
+ /**
75
+ * 1. `ReputationTokenFactory`: Instantiates a new non-transferable `give_to_mint` reputation token
76
+ * via a standardized factory specification.
77
+ */
78
+ createReputationTokenFromFactory(input) {
79
+ const factoryDid = assertCleanId(input.factoryDid, "factoryDid");
80
+ assertValidEpoch(input.epochIndex);
81
+ this.assertFactoryDidAvailable(factoryDid);
82
+ const record = {
83
+ factoryDid,
84
+ tokenConfig: this.karmaEngine.createGiveToMintToken({
85
+ tokenAddress: input.tokenAddress,
86
+ symbol: input.symbol,
87
+ name: input.name,
88
+ issuerDid: input.issuerDid,
89
+ epochBaseAllowance: input.epochBaseAllowance ?? require_give_to_mint_karma.DEFAULT_EPOCH_KARMA_ALLOWANCE,
90
+ maxHistoricalClaimPerDid: input.maxHistoricalClaimPerDid ?? require_give_to_mint_karma.DEFAULT_MAX_HISTORICAL_KARMA_CLAIM,
91
+ transferrable: false,
92
+ creationFeePaid: input.creationFeePaid,
93
+ epochIndex: input.epochIndex
94
+ }),
95
+ createdAtEpoch: input.epochIndex
96
+ };
97
+ this.tokenFactories.set(factoryDid, record);
98
+ return {
99
+ ...record,
100
+ tokenConfig: { ...record.tokenConfig }
101
+ };
102
+ }
103
+ /**
104
+ * 2. `SovereignNftFactory`: Registers a standardized NFT factory template where payloads are
105
+ * hosted in the holder's own ArcSpace and visibility/custody follow the 2019 OCAP NFT sovereignty model.
106
+ */
107
+ registerSovereignNftFactory(spec) {
108
+ const factoryDid = assertCleanId(spec.factoryDid, "factoryDid");
109
+ const creatorDid = assertCleanId(spec.creatorDid, "creatorDid");
110
+ assertValidEpoch(spec.createdAtEpoch);
111
+ this.assertFactoryDidAvailable(factoryDid);
112
+ const seriesName = typeof spec.seriesName === "string" ? spec.seriesName.trim() : "";
113
+ if (seriesName.length === 0 || seriesName.length > 80 || /[\r\n\0]/.test(seriesName)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: seriesName must be 1..80 single-line characters");
114
+ if (!VALID_NFT_CATEGORIES.has(spec.category)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: invalid NFT category ${String(spec.category)}`);
115
+ if (!VALID_VISIBILITIES.has(spec.defaultVisibility)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: invalid defaultVisibility ${String(spec.defaultVisibility)}`);
116
+ if (spec.category === "PRIVATE_ENCRYPTED_DELIVERABLE" && spec.defaultVisibility === "public") throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: PRIVATE_ENCRYPTED_DELIVERABLE factories cannot default to public visibility");
117
+ const transferrable = Boolean(spec.transferrable ?? false);
118
+ if ((spec.category === "PUBLIC_HONOR_BADGE" || spec.category === "PRIVATE_ENCRYPTED_DELIVERABLE") && transferrable) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: ${spec.category} NFTs must be non-transferable (transferrable: false)`);
119
+ if (!Number.isSafeInteger(spec.maxSupply) || spec.maxSupply <= 0 || spec.maxSupply > MAX_SOVEREIGN_NFT_FACTORY_SUPPLY) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: maxSupply must be between 1 and ${MAX_SOVEREIGN_NFT_FACTORY_SUPPLY}`);
120
+ const issuerStagingTtlEpochs = spec.issuerStagingTtlEpochs ?? DEFAULT_ISSUER_STAGING_TTL_EPOCHS;
121
+ if (!Number.isSafeInteger(issuerStagingTtlEpochs) || issuerStagingTtlEpochs <= 0 || issuerStagingTtlEpochs > MAX_ISSUER_STAGING_TTL_EPOCHS) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: issuerStagingTtlEpochs must be between 1 and ${MAX_ISSUER_STAGING_TTL_EPOCHS}`);
122
+ this.assertVerifiedIdentity(creatorDid, "creator");
123
+ const record = {
124
+ factoryDid,
125
+ creatorDid,
126
+ seriesName,
127
+ category: spec.category,
128
+ defaultVisibility: spec.defaultVisibility,
129
+ transferrable,
130
+ maxSupply: spec.maxSupply,
131
+ totalMinted: 0,
132
+ issuerStagingTtlEpochs,
133
+ createdAtEpoch: spec.createdAtEpoch
134
+ };
135
+ this.nftFactories.set(factoryDid, record);
136
+ return { ...record };
137
+ }
138
+ /**
139
+ * Mints a new Sovereign NFT from a registered `SovereignNftFactory`.
140
+ * On-chain state records only the authorization header and 32B `payloadCommitmentDigest`,
141
+ * while the binary payload is staged for the holder's `ArcSpace`.
142
+ */
143
+ mintSovereignNft(input) {
144
+ const factoryDid = assertCleanId(input.factoryDid, "factoryDid");
145
+ const callerDid = assertCleanId(input.callerDid, "callerDid");
146
+ const recipientHolderDid = assertCleanId(input.recipientHolderDid, "recipientHolderDid");
147
+ assertValidEpoch(input.epochIndex);
148
+ const factory = this.nftFactories.get(factoryDid);
149
+ if (!factory) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: NFT factory ${factoryDid} not found`);
150
+ if (callerDid !== factory.creatorDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: only factory creator (${factory.creatorDid}) can mint from ${factoryDid}`);
151
+ this.assertVerifiedIdentity(factory.creatorDid, "creator");
152
+ if (input.epochIndex < factory.createdAtEpoch) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: mint epochIndex (${input.epochIndex}) cannot precede factory createdAtEpoch (${factory.createdAtEpoch})`);
153
+ if (factory.totalMinted >= factory.maxSupply) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: factory ${factoryDid} has reached maxSupply (${factory.maxSupply})`);
154
+ if (!this.karmaEngine.getIdentityState(recipientHolderDid)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: recipientHolderDid ${recipientHolderDid} is not registered`);
155
+ if (typeof input.payloadCommitmentDigest !== "string" || !BYTES32_HEX_REGEX.test(input.payloadCommitmentDigest)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: payloadCommitmentDigest must be a canonical 32-byte 0x-prefixed hex digest");
156
+ const visibility = input.initialVisibility ?? factory.defaultVisibility;
157
+ if (!VALID_VISIBILITIES.has(visibility)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: invalid initialVisibility ${String(visibility)}`);
158
+ if (factory.category === "PRIVATE_ENCRYPTED_DELIVERABLE" && visibility === "public") throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: PRIVATE_ENCRYPTED_DELIVERABLE cannot be minted with public visibility");
159
+ const normalizedViewers = [];
160
+ if (input.authorizedViewerDids !== void 0) {
161
+ if (!Array.isArray(input.authorizedViewerDids) || input.authorizedViewerDids.length > 100) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: authorizedViewerDids must be an array of at most 100 DIDs");
162
+ const seen = /* @__PURE__ */ new Set();
163
+ for (const v of input.authorizedViewerDids) {
164
+ const cleanViewer = assertCleanId(v, "authorizedViewerDid");
165
+ if (!seen.has(cleanViewer)) {
166
+ seen.add(cleanViewer);
167
+ normalizedViewers.push(cleanViewer);
168
+ }
169
+ }
170
+ }
171
+ factory.totalMinted += 1;
172
+ const serialNumber = factory.totalMinted;
173
+ const nftDid = deriveSovereignNftDid(factoryDid, recipientHolderDid, serialNumber, input.payloadCommitmentDigest);
174
+ const instance = {
175
+ nftDid,
176
+ factoryDid,
177
+ category: factory.category,
178
+ serialNumber,
179
+ issuerDid: factory.creatorDid,
180
+ holderDid: recipientHolderDid,
181
+ transferrable: factory.transferrable,
182
+ mintedAtEpoch: input.epochIndex,
183
+ stagingExpiresAtEpoch: input.epochIndex + factory.issuerStagingTtlEpochs,
184
+ payloadCommitmentDigest: input.payloadCommitmentDigest.toLowerCase(),
185
+ holderArcSpaceUri: `arcspace://${recipientHolderDid}/nfts/${nftDid}`,
186
+ issuerStagingUri: `arcspace://${factory.creatorDid}/staging/${nftDid}`,
187
+ payloadVisibility: visibility,
188
+ authorizedViewerDids: visibility === "authorized_only" ? normalizedViewers : [],
189
+ payloadCustodyState: "ISSUER_TEMP_STAGED"
190
+ };
191
+ this.nftInstances.set(nftDid, instance);
192
+ return {
193
+ ...instance,
194
+ authorizedViewerDids: [...instance.authorizedViewerDids]
195
+ };
196
+ }
197
+ /**
198
+ * Holder-Sovereign Visibility Control: ONLY `holderDid` can decide whether outsiders can view
199
+ * the NFT payload hosted in `holderArcSpaceUri`.
200
+ */
201
+ configureSovereignNftVisibility(params) {
202
+ const nftDid = assertCleanId(params.nftDid, "nftDid");
203
+ const callerDid = assertCleanId(params.callerDid, "callerDid");
204
+ if (!VALID_VISIBILITIES.has(params.visibility)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: invalid visibility ${String(params.visibility)}`);
205
+ const nft = this.nftInstances.get(nftDid);
206
+ if (!nft) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: NFT ${nftDid} not found`);
207
+ if (nft.holderDid !== callerDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: only the NFT holder (${nft.holderDid}) can configure visibility for ${nftDid}`);
208
+ if (nft.category === "PRIVATE_ENCRYPTED_DELIVERABLE" && params.visibility === "public") throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: PRIVATE_ENCRYPTED_DELIVERABLE NFTs cannot be switched to public visibility");
209
+ const normalizedViewers = [];
210
+ if (params.authorizedViewerDids !== void 0) {
211
+ if (!Array.isArray(params.authorizedViewerDids) || params.authorizedViewerDids.length > 100) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: authorizedViewerDids must be an array of at most 100 DIDs");
212
+ const seen = /* @__PURE__ */ new Set();
213
+ for (const v of params.authorizedViewerDids) {
214
+ const cleanViewer = assertCleanId(v, "authorizedViewerDid");
215
+ if (!seen.has(cleanViewer)) {
216
+ seen.add(cleanViewer);
217
+ normalizedViewers.push(cleanViewer);
218
+ }
219
+ }
220
+ }
221
+ nft.payloadVisibility = params.visibility;
222
+ nft.authorizedViewerDids = params.visibility === "authorized_only" ? normalizedViewers : [];
223
+ return {
224
+ ...nft,
225
+ authorizedViewerDids: [...nft.authorizedViewerDids]
226
+ };
227
+ }
228
+ /**
229
+ * Evaluates whether `viewerDid` can access the NFT payload.
230
+ * When denied (`private` or unwhitelisted `authorized_only`), both `holderArcSpaceUri` and
231
+ * `issuerStagingUri` are withheld so outsiders cannot see the NFT content.
232
+ */
233
+ resolveSovereignNftPayloadAccess(params) {
234
+ const nftDid = assertCleanId(params.nftDid, "nftDid");
235
+ const viewerDid = assertCleanId(params.viewerDid, "viewerDid");
236
+ const nft = this.nftInstances.get(nftDid);
237
+ if (!nft) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: NFT ${nftDid} not found`);
238
+ if (viewerDid === nft.holderDid) return {
239
+ nftDid,
240
+ factoryDid: nft.factoryDid,
241
+ holderDid: nft.holderDid,
242
+ viewerDid,
243
+ visibility: nft.payloadVisibility,
244
+ custodyState: nft.payloadCustodyState,
245
+ accessible: true,
246
+ reason: "ALLOWED_HOLDER",
247
+ holderArcSpaceUri: nft.holderArcSpaceUri,
248
+ issuerStagingUri: nft.issuerStagingUri,
249
+ payloadCommitmentDigest: nft.payloadCommitmentDigest
250
+ };
251
+ if (nft.payloadVisibility === "public") return {
252
+ nftDid,
253
+ factoryDid: nft.factoryDid,
254
+ holderDid: nft.holderDid,
255
+ viewerDid,
256
+ visibility: nft.payloadVisibility,
257
+ custodyState: nft.payloadCustodyState,
258
+ accessible: true,
259
+ reason: "ALLOWED_PUBLIC",
260
+ holderArcSpaceUri: nft.holderArcSpaceUri,
261
+ payloadCommitmentDigest: nft.payloadCommitmentDigest
262
+ };
263
+ if (nft.payloadVisibility === "authorized_only") {
264
+ if (nft.authorizedViewerDids.includes(viewerDid)) return {
265
+ nftDid,
266
+ factoryDid: nft.factoryDid,
267
+ holderDid: nft.holderDid,
268
+ viewerDid,
269
+ visibility: nft.payloadVisibility,
270
+ custodyState: nft.payloadCustodyState,
271
+ accessible: true,
272
+ reason: "ALLOWED_AUTHORIZED_VIEWER",
273
+ holderArcSpaceUri: nft.holderArcSpaceUri,
274
+ payloadCommitmentDigest: nft.payloadCommitmentDigest
275
+ };
276
+ return {
277
+ nftDid,
278
+ factoryDid: nft.factoryDid,
279
+ holderDid: nft.holderDid,
280
+ viewerDid,
281
+ visibility: nft.payloadVisibility,
282
+ custodyState: nft.payloadCustodyState,
283
+ accessible: false,
284
+ reason: "DENIED_UNAUTHORIZED",
285
+ payloadCommitmentDigest: nft.payloadCommitmentDigest
286
+ };
287
+ }
288
+ return {
289
+ nftDid,
290
+ factoryDid: nft.factoryDid,
291
+ holderDid: nft.holderDid,
292
+ viewerDid,
293
+ visibility: nft.payloadVisibility,
294
+ custodyState: nft.payloadCustodyState,
295
+ accessible: false,
296
+ reason: "DENIED_PRIVATE",
297
+ payloadCommitmentDigest: nft.payloadCommitmentDigest
298
+ };
299
+ }
300
+ /**
301
+ * Stage 2 & 3 Custody Handover:
302
+ * Holder verifies `verifiedPayloadDigest === payloadCommitmentDigest`, saves the binary into their
303
+ * own `ArcSpace`, and acknowledges custody. When `releaseIssuerStorageImmediately !== false`,
304
+ * transitions directly to `ISSUER_STORAGE_RELEASED` and clears `issuerStagingUri`.
305
+ */
306
+ acknowledgeSovereignNftCustody(params) {
307
+ const nftDid = assertCleanId(params.nftDid, "nftDid");
308
+ const holderDid = assertCleanId(params.holderDid, "holderDid");
309
+ if (typeof params.verifiedPayloadDigest !== "string" || !BYTES32_HEX_REGEX.test(params.verifiedPayloadDigest)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: verifiedPayloadDigest must be a canonical 32-byte 0x-prefixed hex digest");
310
+ const nft = this.nftInstances.get(nftDid);
311
+ if (!nft) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: NFT ${nftDid} not found`);
312
+ if (nft.holderDid !== holderDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: only the NFT holder (${nft.holderDid}) can acknowledge custody for ${nftDid}`);
313
+ if (nft.payloadCommitmentDigest.toLowerCase() !== params.verifiedPayloadDigest.toLowerCase()) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: verifiedPayloadDigest mismatch against on-chain commitment for ${nftDid}`);
314
+ if (nft.payloadCustodyState === "ISSUER_STORAGE_RELEASED" && params.releaseIssuerStorageImmediately === false) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: cannot regress payloadCustodyState from ISSUER_STORAGE_RELEASED to HOLDER_SAVED_IN_ARCSPACE");
315
+ if (params.releaseIssuerStorageImmediately === false) nft.payloadCustodyState = "HOLDER_SAVED_IN_ARCSPACE";
316
+ else {
317
+ nft.payloadCustodyState = "ISSUER_STORAGE_RELEASED";
318
+ nft.issuerStagingUri = void 0;
319
+ }
320
+ return {
321
+ ...nft,
322
+ authorizedViewerDids: [...nft.authorizedViewerDids]
323
+ };
324
+ }
325
+ /**
326
+ * Releases the creator/issuer's temporary staging buffer (`issuerStagingUri = undefined`,
327
+ * `payloadCustodyState = 'ISSUER_STORAGE_RELEASED'`) once EITHER:
328
+ * - the holder has already saved the binary (`HOLDER_SAVED_IN_ARCSPACE` or `ISSUER_STORAGE_RELEASED`), OR
329
+ * - the temporary staging window has expired (`currentEpoch >= stagingExpiresAtEpoch`).
330
+ * Rejects premature deletion while `currentEpoch < stagingExpiresAtEpoch` and the holder has not yet saved it.
331
+ */
332
+ purgeIssuerStagedNftPayload(params) {
333
+ const nftDid = assertCleanId(params.nftDid, "nftDid");
334
+ const callerDid = assertCleanId(params.callerDid, "callerDid");
335
+ assertValidEpoch(params.currentEpoch);
336
+ const nft = this.nftInstances.get(nftDid);
337
+ if (!nft) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: NFT ${nftDid} not found`);
338
+ if (params.currentEpoch < nft.mintedAtEpoch) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: currentEpoch (${params.currentEpoch}) cannot precede NFT mintedAtEpoch (${nft.mintedAtEpoch})`);
339
+ if (callerDid !== nft.issuerDid && callerDid !== nft.holderDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: only issuer (${nft.issuerDid}) or holder (${nft.holderDid}) can purge staged payload`);
340
+ if (nft.payloadCustodyState === "ISSUER_TEMP_STAGED" && params.currentEpoch < nft.stagingExpiresAtEpoch) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: caller cannot purge staged binary before stagingExpiresAtEpoch (${nft.stagingExpiresAtEpoch}) until holder acknowledges custody with verified digest`);
341
+ nft.payloadCustodyState = "ISSUER_STORAGE_RELEASED";
342
+ nft.issuerStagingUri = void 0;
343
+ return {
344
+ ...nft,
345
+ authorizedViewerDids: [...nft.authorizedViewerDids]
346
+ };
347
+ }
348
+ /**
349
+ * 3. `KarmaSettlementPoolFactory`: Registers a reusable epoch pool settlement factory
350
+ * (e.g., $100/mo BAT Tipping Pool, $1,000/mo Crypto AdSense Pool, $200k Philanthropy Pool).
351
+ */
352
+ registerKarmaSettlementPoolFactory(spec) {
353
+ const factoryDid = assertCleanId(spec.factoryDid, "factoryDid");
354
+ const sponsorDid = assertCleanId(spec.sponsorDid, "sponsorDid");
355
+ const tokenAddress = spec.tokenAddress ? assertCleanId(spec.tokenAddress, "tokenAddress") : require_give_to_mint_karma.DEFAULT_KARMA_TOKEN_ADDRESS;
356
+ assertValidEpoch(spec.createdAtEpoch);
357
+ this.assertFactoryDidAvailable(factoryDid);
358
+ if (!VALID_POOL_KINDS.has(spec.poolKind)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: invalid poolKind ${String(spec.poolKind)}`);
359
+ if (!this.karmaEngine.getTokenConfig(tokenAddress)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: target token ${tokenAddress} is not registered`);
360
+ this.assertVerifiedIdentity(sponsorDid, "sponsor");
361
+ const minRecipientKarmaWeight = spec.minRecipientKarmaWeight ?? 1n;
362
+ if (typeof minRecipientKarmaWeight !== "bigint" || minRecipientKarmaWeight <= 0n) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: minRecipientKarmaWeight must be a positive bigint");
363
+ const record = {
364
+ factoryDid,
365
+ sponsorDid,
366
+ poolKind: spec.poolKind,
367
+ tokenAddress,
368
+ minRecipientKarmaWeight,
369
+ totalPoolsSettled: 0,
370
+ cumulativeSettledAmount: 0n,
371
+ createdAtEpoch: spec.createdAtEpoch
372
+ };
373
+ this.poolFactories.set(factoryDid, record);
374
+ return { ...record };
375
+ }
376
+ /**
377
+ * Executes an epoch pool settlement using a registered `KarmaSettlementPoolFactory`.
378
+ */
379
+ executeFactoryPoolSettlement(params) {
380
+ const factoryDid = assertCleanId(params.factoryDid, "factoryDid");
381
+ const callerDid = assertCleanId(params.callerDid, "callerDid");
382
+ assertValidEpoch(params.epochIndex);
383
+ const poolFactory = this.poolFactories.get(factoryDid);
384
+ if (!poolFactory) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: pool factory ${factoryDid} not found`);
385
+ if (callerDid !== poolFactory.sponsorDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: only sponsor (${poolFactory.sponsorDid}) can settle pool factory ${factoryDid}`);
386
+ this.assertVerifiedIdentity(poolFactory.sponsorDid, "sponsor");
387
+ if (params.epochIndex < poolFactory.createdAtEpoch) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: settlement epochIndex (${params.epochIndex}) cannot precede pool factory createdAtEpoch (${poolFactory.createdAtEpoch})`);
388
+ if (!Array.isArray(params.recipientWeights) || params.recipientWeights.length === 0) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: recipientWeights must be a non-empty array");
389
+ for (const entry of params.recipientWeights) {
390
+ if (!entry || typeof entry.karmaWeight !== "bigint" || entry.karmaWeight <= 0n) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: karmaWeight must be a positive bigint");
391
+ assertCleanId(entry.recipientDid, "recipientDid");
392
+ if (entry.karmaWeight < poolFactory.minRecipientKarmaWeight) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: recipient ${entry.recipientDid} karmaWeight (${entry.karmaWeight}) is below factory minimum (${poolFactory.minRecipientKarmaWeight})`);
393
+ }
394
+ const settlement = this.karmaEngine.settleKarmaIndexedPool({
395
+ poolId: params.poolId,
396
+ poolKind: poolFactory.poolKind,
397
+ sponsorDid: poolFactory.sponsorDid,
398
+ tokenAddress: poolFactory.tokenAddress,
399
+ epochIndex: params.epochIndex,
400
+ totalPoolAmount: params.totalPoolAmount,
401
+ recipientWeights: params.recipientWeights
402
+ });
403
+ poolFactory.totalPoolsSettled += 1;
404
+ poolFactory.cumulativeSettledAmount += params.totalPoolAmount;
405
+ return settlement;
406
+ }
407
+ getTokenFactory(factoryDid) {
408
+ const f = this.tokenFactories.get(factoryDid);
409
+ return f ? {
410
+ ...f,
411
+ tokenConfig: { ...f.tokenConfig }
412
+ } : void 0;
413
+ }
414
+ getSovereignNftFactory(factoryDid) {
415
+ const f = this.nftFactories.get(factoryDid);
416
+ return f ? { ...f } : void 0;
417
+ }
418
+ getSovereignNftInstance(nftDid) {
419
+ const n = this.nftInstances.get(nftDid);
420
+ return n ? {
421
+ ...n,
422
+ authorizedViewerDids: [...n.authorizedViewerDids]
423
+ } : void 0;
424
+ }
425
+ getPoolFactory(factoryDid) {
426
+ const p = this.poolFactories.get(factoryDid);
427
+ return p ? { ...p } : void 0;
428
+ }
429
+ /**
430
+ * Issue #1234 — Pilot App A:
431
+ * Executes the end-to-end Public Community Content Appreciation & Citation Split workflow:
432
+ * 1. Optionally processes the author's retroactive historical contribution claim (`claimHistoricalKarma`).
433
+ * 2. Grants the author protocol-sponsored free badge minting quota (`SponsoredMintQuota`, default 100).
434
+ * 3. Registers the content object and its upstream `citations` graph (`photo`, `music`, `skill`, `blocklet`, etc.).
435
+ * 4. Commits reader `Give-to-Mint` vouchers via `ArcSpace + Checkpoint`, minting `KARMA` FT across the
436
+ * primary author and cited contributors, companion Medal NFTs, and numbered Creator Thank-You Badges.
437
+ */
438
+ runPilotPublicContentAppreciationWorkflow(input) {
439
+ const pilotRunId = assertCleanId(input.pilotRunId, "pilotRunId");
440
+ const authorDid = assertCleanId(input.authorDid, "authorDid");
441
+ const objectDid = assertCleanId(input.objectDid, "objectDid");
442
+ assertValidEpoch(input.epochIndex);
443
+ if (this.processedPilotRunIds.has(pilotRunId)) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: duplicate pilotRunId ${pilotRunId} replay is forbidden`);
444
+ const tokenFactoryDid = input.tokenFactoryDid ? assertCleanId(input.tokenFactoryDid, "tokenFactoryDid") : "did:abt:factory:token:default-karma";
445
+ const tokenFactory = this.tokenFactories.get(tokenFactoryDid);
446
+ if (!tokenFactory) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: tokenFactory ${tokenFactoryDid} not found`);
447
+ const tokenAddress = tokenFactory.tokenConfig.tokenAddress;
448
+ if (!Array.isArray(input.citations)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: citations must be an array");
449
+ const quotaToGrant = input.sponsoredBadgeQuotaGrant ?? require_give_to_mint_karma.DEFAULT_SPONSORED_BADGE_MINT_QUOTA;
450
+ if (!Number.isSafeInteger(quotaToGrant) || quotaToGrant < 0 || quotaToGrant > require_give_to_mint_karma.MAX_SPONSORED_BADGE_MINT_QUOTA_PER_GRANT) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, `SocialEconomyFactory: sponsoredBadgeQuotaGrant must be an integer in 0..${require_give_to_mint_karma.MAX_SPONSORED_BADGE_MINT_QUOTA_PER_GRANT}`);
451
+ if (!Array.isArray(input.vouchers) || input.vouchers.length === 0) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: pilot vouchers must be a non-empty array");
452
+ this.assertVerifiedIdentity(authorDid, "author");
453
+ for (const c of input.citations) {
454
+ if (!c || typeof c !== "object") throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: citation entry must be an object");
455
+ this.assertVerifiedIdentity(assertCleanId(c.contributorDid, "citation.contributorDid"), "cited contributor");
456
+ }
457
+ const seenVoucherIds = /* @__PURE__ */ new Set();
458
+ const checkpointVouchers = [];
459
+ for (const v of input.vouchers) {
460
+ if (!v || typeof v !== "object") throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: voucher entry must be an object");
461
+ const voucherId = assertCleanId(v.voucherId, "voucherId");
462
+ if (seenVoucherIds.has(voucherId)) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: duplicate voucherId ${voucherId} in pilot batch`);
463
+ seenVoucherIds.add(voucherId);
464
+ const readerDid = assertCleanId(v.readerDid, "readerDid");
465
+ if (readerDid === authorDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: readerDid cannot self-give to authorDid in pilot batch");
466
+ this.assertVerifiedIdentity(readerDid, "reader");
467
+ if (typeof v.allowanceAmount !== "bigint" || v.allowanceAmount < require_give_to_mint_karma.MIN_GIVE_TO_MINT_DUST_FLOOR) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: voucher allowanceAmount must be >= ${require_give_to_mint_karma.MIN_GIVE_TO_MINT_DUST_FLOOR}`);
468
+ checkpointVouchers.push({
469
+ voucherId,
470
+ senderDid: readerDid,
471
+ objectDid,
472
+ allowanceAmount: v.allowanceAmount,
473
+ medalKind: v.medalKind
474
+ });
475
+ }
476
+ let historicalClaimResult;
477
+ if (input.historicalClaim) historicalClaimResult = this.karmaEngine.claimHistoricalKarma({
478
+ ...input.historicalClaim,
479
+ claimantDid: authorDid,
480
+ tokenAddress,
481
+ epochIndex: input.epochIndex
482
+ });
483
+ if (quotaToGrant > 0) this.karmaEngine.grantSponsoredBadgeMintQuota(authorDid, quotaToGrant);
484
+ this.karmaEngine.registerCreationObject({
485
+ objectDid,
486
+ authorDid,
487
+ kind: input.objectKind,
488
+ citations: input.citations,
489
+ enableThankYouBadge: true
490
+ });
491
+ const expectedCheckpointRoot = require_give_to_mint_karma.computeArcSpaceCheckpointRoot(tokenAddress, input.epochIndex, checkpointVouchers);
492
+ const checkpointResult = this.karmaEngine.commitArcSpaceKarmaCheckpoint({
493
+ checkpointId: `chk:${pilotRunId}`,
494
+ tokenAddress,
495
+ epochIndex: input.epochIndex,
496
+ expectedCheckpointRoot,
497
+ vouchers: checkpointVouchers
498
+ });
499
+ this.processedPilotRunIds.add(pilotRunId);
500
+ const authorAcct = this.karmaEngine.getPerTokenAccountState(authorDid, tokenAddress);
501
+ const authorEarnedKarmaInEpoch = authorAcct && authorAcct.lastEarnedEpoch === input.epochIndex ? authorAcct.earnedKarmaInEpoch : 0n;
502
+ const citationEarnedKarmaByContributor = {};
503
+ for (const c of input.citations) {
504
+ const citedAcct = this.karmaEngine.getPerTokenAccountState(c.contributorDid, tokenAddress);
505
+ citationEarnedKarmaByContributor[c.contributorDid] = citedAcct && citedAcct.lastEarnedEpoch === input.epochIndex ? citedAcct.earnedKarmaInEpoch : 0n;
506
+ }
507
+ const companionMedalsIssued = this.karmaEngine.getCompanionMedalsForObject(objectDid).filter((m) => m.epochIndex === input.epochIndex && m.tokenAddress === tokenAddress);
508
+ const seenReaders = /* @__PURE__ */ new Set();
509
+ const thankYouBadgesIssued = [];
510
+ for (const v of checkpointVouchers) if (!seenReaders.has(v.senderDid)) {
511
+ seenReaders.add(v.senderDid);
512
+ const badges = this.karmaEngine.getThankYouBadgesForRecipient(v.senderDid).filter((b) => b.sourceObjectDid === objectDid && b.epochIndex === input.epochIndex && b.tokenAddress === tokenAddress);
513
+ thankYouBadgesIssued.push(...badges);
514
+ }
515
+ const remainingSponsoredBadgeQuota = this.karmaEngine.getIdentityState(authorDid)?.sponsoredBadgeMintQuota ?? 0;
516
+ return {
517
+ pilotRunId,
518
+ tokenAddress,
519
+ objectDid,
520
+ historicalClaimResult,
521
+ checkpointResult,
522
+ authorEarnedKarmaInEpoch,
523
+ citationEarnedKarmaByContributor,
524
+ companionMedalsIssued,
525
+ thankYouBadgesIssued,
526
+ remainingSponsoredBadgeQuota
527
+ };
528
+ }
529
+ /**
530
+ * Issue #1234 — Pilot App B:
531
+ * Executes the end-to-end Private Circle & Encrypted Media Pack Delivery workflow
532
+ * (`OnlyFans / 知识星球 Sovereign NFT Mode`):
533
+ * 1. Registers (or safely reuses for subsequent subscribers of the same creator series) a
534
+ * `PRIVATE_ENCRYPTED_DELIVERABLE` `SovereignNftFactory` (`defaultVisibility: 'private'`).
535
+ * 2. Mints an encrypted deliverable NFT (`payloadCommitmentDigest`) to the subscriber's DID.
536
+ * 3. Verifies that an external outsider (`outsiderProbeDid`) is strictly blocked (`DENIED_PRIVATE`)
537
+ * and cannot see `holderArcSpaceUri` or `issuerStagingUri`.
538
+ * 4. Subscriber verifies the 32B digest, saves the binary into their own `ArcSpace`, and calls
539
+ * `acknowledgeSovereignNftCustody`, immediately releasing the creator's staging storage obligation
540
+ * (`payloadCustodyState === 'ISSUER_STORAGE_RELEASED'`, `issuerStagingUri === undefined`).
541
+ */
542
+ runPilotPrivateCircleDeliveryWorkflow(input) {
543
+ const pilotRunId = assertCleanId(input.pilotRunId, "pilotRunId");
544
+ const nftFactoryDid = assertCleanId(input.nftFactoryDid, "nftFactoryDid");
545
+ const creatorDid = assertCleanId(input.creatorDid, "creatorDid");
546
+ const subscriberDid = assertCleanId(input.subscriberDid, "subscriberDid");
547
+ const outsiderProbeDid = assertCleanId(input.outsiderProbeDid, "outsiderProbeDid");
548
+ assertValidEpoch(input.epochIndex);
549
+ if (this.processedPilotRunIds.has(pilotRunId)) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: duplicate pilotRunId ${pilotRunId} replay is forbidden`);
550
+ if (subscriberDid === creatorDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: subscriberDid cannot be the same as creatorDid in Private Circle pilot");
551
+ if (outsiderProbeDid === subscriberDid || outsiderProbeDid === creatorDid) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: outsiderProbeDid must be distinct from both subscriberDid and creatorDid");
552
+ if (typeof input.payloadCommitmentDigest !== "string" || !BYTES32_HEX_REGEX.test(input.payloadCommitmentDigest)) throw new _ocap_util_lib_error.CustomError(ErrorCode.InvalidFactory, "SocialEconomyFactory: payloadCommitmentDigest must be a canonical 32-byte 0x-prefixed hex digest");
553
+ this.assertVerifiedIdentity(creatorDid, "creator");
554
+ this.assertVerifiedIdentity(subscriberDid, "subscriber");
555
+ const existingNftFactory = this.nftFactories.get(nftFactoryDid);
556
+ let nftFactory;
557
+ if (existingNftFactory) {
558
+ if (existingNftFactory.creatorDid !== creatorDid || existingNftFactory.category !== "PRIVATE_ENCRYPTED_DELIVERABLE" || existingNftFactory.defaultVisibility !== "private" || existingNftFactory.transferrable) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: existing nftFactory ${nftFactoryDid} cannot be reused by ${creatorDid} for Private Circle pilot`);
559
+ nftFactory = existingNftFactory;
560
+ } else nftFactory = this.registerSovereignNftFactory({
561
+ factoryDid: nftFactoryDid,
562
+ creatorDid,
563
+ seriesName: input.seriesName,
564
+ category: "PRIVATE_ENCRYPTED_DELIVERABLE",
565
+ defaultVisibility: "private",
566
+ transferrable: false,
567
+ maxSupply: 1e4,
568
+ issuerStagingTtlEpochs: input.issuerStagingTtlEpochs ?? DEFAULT_ISSUER_STAGING_TTL_EPOCHS,
569
+ createdAtEpoch: input.epochIndex
570
+ });
571
+ const mintedNftBeforeSave = this.mintSovereignNft({
572
+ factoryDid: nftFactory.factoryDid,
573
+ callerDid: creatorDid,
574
+ recipientHolderDid: subscriberDid,
575
+ payloadCommitmentDigest: input.payloadCommitmentDigest,
576
+ epochIndex: input.epochIndex
577
+ });
578
+ const outsiderAccessCheck = this.resolveSovereignNftPayloadAccess({
579
+ nftDid: mintedNftBeforeSave.nftDid,
580
+ viewerDid: outsiderProbeDid
581
+ });
582
+ if (outsiderAccessCheck.accessible) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, "SocialEconomyFactory: private deliverable leaked to outsider probe");
583
+ const subscriberAccessCheck = this.resolveSovereignNftPayloadAccess({
584
+ nftDid: mintedNftBeforeSave.nftDid,
585
+ viewerDid: subscriberDid
586
+ });
587
+ const nftAfterSaveAndRelease = this.acknowledgeSovereignNftCustody({
588
+ nftDid: mintedNftBeforeSave.nftDid,
589
+ holderDid: subscriberDid,
590
+ verifiedPayloadDigest: input.payloadCommitmentDigest,
591
+ releaseIssuerStorageImmediately: true
592
+ });
593
+ this.processedPilotRunIds.add(pilotRunId);
594
+ return {
595
+ pilotRunId,
596
+ nftFactory: this.getSovereignNftFactory(nftFactory.factoryDid),
597
+ mintedNftBeforeSave,
598
+ outsiderAccessCheck,
599
+ subscriberAccessCheck,
600
+ nftAfterSaveAndRelease,
601
+ issuerStorageReleased: nftAfterSaveAndRelease.payloadCustodyState === "ISSUER_STORAGE_RELEASED" && nftAfterSaveAndRelease.issuerStagingUri === void 0
602
+ };
603
+ }
604
+ /**
605
+ * Issue #1235 (Phase 3 — Declarative Blueprint Safety Verifier):
606
+ * Verifies that a proposed `SocialEconomyFactoryBlueprint` satisfies all protocol safety invariants
607
+ * (Sybil-verified proposer, non-transferable reputation, holder-sovereign visibility, bounded creator
608
+ * staging custody handover, and unique factory DID / value conservation) without mutating state.
609
+ */
610
+ verifyFactoryBlueprintSafety(blueprint) {
611
+ const violations = [];
612
+ const safetyChecksPassed = [];
613
+ const isCleanId = (v) => typeof v === "string" && v.trim().length > 0 && v.trim() === v && !/[\s/\\?#%]|::|->/.test(v);
614
+ const blueprintId = typeof blueprint?.blueprintId === "string" ? blueprint.blueprintId.trim() : "";
615
+ if (!isCleanId(blueprint?.blueprintId)) violations.push("blueprintId must be a clean non-empty identifier");
616
+ else if (this.processedBlueprintIds.has(blueprint.blueprintId)) violations.push(`blueprintId ${blueprint.blueprintId} has already been instantiated`);
617
+ if (typeof blueprint?.ideaTitle !== "string" || blueprint.ideaTitle.trim().length === 0 || blueprint.ideaTitle.trim().length > 160 || /[\r\n\0]/.test(blueprint.ideaTitle)) violations.push("ideaTitle must be a non-empty single-line string of at most 160 chars");
618
+ if (!Number.isSafeInteger(blueprint?.epochIndex) || blueprint.epochIndex < 0) violations.push("epochIndex must be a non-negative safe integer");
619
+ let sybilCheckPassed = false;
620
+ if (!isCleanId(blueprint?.proposerDid)) violations.push("proposerDid must be a clean non-empty DID");
621
+ else {
622
+ const proposerState = this.karmaEngine.getIdentityState(blueprint.proposerDid);
623
+ if (!proposerState || !proposerState.verifiedHumanOrStaker || proposerState.trustMultiplierBps <= 0) violations.push(`proposerDid ${blueprint.proposerDid} is not an active verified identity`);
624
+ else sybilCheckPassed = true;
625
+ }
626
+ const kind = blueprint?.targetFactoryKind;
627
+ const providedSpecsCount = (blueprint?.tokenSpec !== void 0 ? 1 : 0) + (blueprint?.nftSpec !== void 0 ? 1 : 0) + (blueprint?.poolSpec !== void 0 ? 1 : 0);
628
+ if (providedSpecsCount !== 1) violations.push("blueprint must provide exactly one specification matching targetFactoryKind");
629
+ if (kind === "REPUTATION_TOKEN_FACTORY") {
630
+ const spec = blueprint.tokenSpec;
631
+ if (!spec || typeof spec !== "object") violations.push("tokenSpec is required for REPUTATION_TOKEN_FACTORY");
632
+ else {
633
+ if (!isCleanId(spec.issuerDid) || spec.issuerDid !== blueprint.proposerDid) {
634
+ violations.push("tokenSpec.issuerDid must match blueprint.proposerDid");
635
+ sybilCheckPassed = false;
636
+ }
637
+ let conservationSafe = providedSpecsCount === 1;
638
+ if (!isCleanId(spec.factoryDid)) {
639
+ violations.push("tokenSpec.factoryDid must be a clean non-empty DID");
640
+ conservationSafe = false;
641
+ } else if (this.tokenFactories.has(spec.factoryDid) || this.nftFactories.has(spec.factoryDid) || this.poolFactories.has(spec.factoryDid)) {
642
+ violations.push(`factoryDid ${spec.factoryDid} already exists`);
643
+ conservationSafe = false;
644
+ }
645
+ let tokenSafe = providedSpecsCount === 1;
646
+ if (!isCleanId(spec.tokenAddress)) {
647
+ violations.push("tokenSpec.tokenAddress must be a clean non-empty identifier");
648
+ tokenSafe = false;
649
+ conservationSafe = false;
650
+ } else if (this.karmaEngine.getTokenConfig(spec.tokenAddress)) {
651
+ violations.push(`tokenAddress ${spec.tokenAddress} is already registered`);
652
+ tokenSafe = false;
653
+ conservationSafe = false;
654
+ }
655
+ const existingSymbols = new Set(Array.from(this.tokenFactories.values()).map((f) => f.tokenConfig.symbol.toUpperCase()));
656
+ if (!isCleanId(spec.symbol) || !/^[A-Z0-9_]{2,16}$/.test(spec.symbol)) {
657
+ violations.push("tokenSpec.symbol must be 2..16 uppercase alphanumeric characters without whitespace");
658
+ tokenSafe = false;
659
+ } else if (existingSymbols.has(spec.symbol.toUpperCase())) {
660
+ violations.push(`tokenSpec.symbol ${spec.symbol} is already registered`);
661
+ tokenSafe = false;
662
+ conservationSafe = false;
663
+ }
664
+ if (typeof spec.name !== "string" || spec.name.trim().length === 0 || spec.name.trim().length > 64 || /[\r\n\0]/.test(spec.name)) {
665
+ violations.push("tokenSpec.name must be 1..64 single-line characters");
666
+ tokenSafe = false;
667
+ }
668
+ if (typeof spec.creationFeePaid !== "bigint" || spec.creationFeePaid < require_give_to_mint_karma.MIN_GIVE_TO_MINT_TOKEN_CREATION_FEE) {
669
+ violations.push(`tokenSpec.creationFeePaid must be >= ${require_give_to_mint_karma.MIN_GIVE_TO_MINT_TOKEN_CREATION_FEE.toString()}`);
670
+ tokenSafe = false;
671
+ conservationSafe = false;
672
+ }
673
+ const allowance = spec.epochBaseAllowance ?? require_give_to_mint_karma.DEFAULT_EPOCH_KARMA_ALLOWANCE;
674
+ if (typeof allowance !== "bigint" || allowance <= 0n || allowance > 10000n) {
675
+ violations.push("tokenSpec.epochBaseAllowance must be a bigint in 1..10000");
676
+ tokenSafe = false;
677
+ }
678
+ const maxHist = spec.maxHistoricalClaimPerDid ?? require_give_to_mint_karma.DEFAULT_MAX_HISTORICAL_KARMA_CLAIM;
679
+ if (typeof maxHist !== "bigint" || maxHist < 0n || maxHist > 50000n) {
680
+ violations.push("tokenSpec.maxHistoricalClaimPerDid must be a bigint in 0..50000");
681
+ tokenSafe = false;
682
+ }
683
+ if (conservationSafe) safetyChecksPassed.push("CONSERVATION_AND_UNIQUE_FACTORY_DID_INVARIANT");
684
+ if (tokenSafe) safetyChecksPassed.push("NON_TRANSFERABLE_REPUTATION_INVARIANT");
685
+ }
686
+ } else if (kind === "SOVEREIGN_NFT_FACTORY") {
687
+ const spec = blueprint.nftSpec;
688
+ if (!spec || typeof spec !== "object") violations.push("nftSpec is required for SOVEREIGN_NFT_FACTORY");
689
+ else {
690
+ if (!isCleanId(spec.creatorDid) || spec.creatorDid !== blueprint.proposerDid) {
691
+ violations.push("nftSpec.creatorDid must match blueprint.proposerDid");
692
+ sybilCheckPassed = false;
693
+ }
694
+ let conservationSafe = providedSpecsCount === 1;
695
+ if (!isCleanId(spec.factoryDid)) {
696
+ violations.push("nftSpec.factoryDid must be a clean non-empty DID");
697
+ conservationSafe = false;
698
+ } else if (this.tokenFactories.has(spec.factoryDid) || this.nftFactories.has(spec.factoryDid) || this.poolFactories.has(spec.factoryDid)) {
699
+ violations.push(`factoryDid ${spec.factoryDid} already exists`);
700
+ conservationSafe = false;
701
+ }
702
+ let visibilitySafe = providedSpecsCount === 1;
703
+ if (!VALID_NFT_CATEGORIES.has(spec.category)) {
704
+ violations.push(`nftSpec.category ${String(spec.category)} is invalid`);
705
+ visibilitySafe = false;
706
+ }
707
+ if (!VALID_VISIBILITIES.has(spec.defaultVisibility)) {
708
+ violations.push(`nftSpec.defaultVisibility ${String(spec.defaultVisibility)} is invalid`);
709
+ visibilitySafe = false;
710
+ }
711
+ if (typeof spec.seriesName !== "string" || spec.seriesName.trim().length === 0 || spec.seriesName.trim().length > 80 || /[\r\n\0]/.test(spec.seriesName)) {
712
+ violations.push("nftSpec.seriesName must be 1..80 single-line characters");
713
+ visibilitySafe = false;
714
+ }
715
+ if (!Number.isSafeInteger(spec.maxSupply) || spec.maxSupply <= 0 || spec.maxSupply > MAX_SOVEREIGN_NFT_FACTORY_SUPPLY) {
716
+ violations.push(`nftSpec.maxSupply must be in 1..${MAX_SOVEREIGN_NFT_FACTORY_SUPPLY}`);
717
+ visibilitySafe = false;
718
+ conservationSafe = false;
719
+ }
720
+ const isTransferrable = Boolean(spec.transferrable ?? false);
721
+ if (spec.category === "PRIVATE_ENCRYPTED_DELIVERABLE") {
722
+ if (spec.defaultVisibility === "public") {
723
+ violations.push("PRIVATE_ENCRYPTED_DELIVERABLE NFTs cannot default to public visibility");
724
+ visibilitySafe = false;
725
+ }
726
+ if (isTransferrable) {
727
+ violations.push("PRIVATE_ENCRYPTED_DELIVERABLE NFTs must be non-transferrable");
728
+ visibilitySafe = false;
729
+ }
730
+ } else if (spec.category === "PUBLIC_HONOR_BADGE" && isTransferrable) {
731
+ violations.push("PUBLIC_HONOR_BADGE NFTs are soulbound and must be non-transferrable");
732
+ visibilitySafe = false;
733
+ }
734
+ if (conservationSafe) safetyChecksPassed.push("CONSERVATION_AND_UNIQUE_FACTORY_DID_INVARIANT");
735
+ if (visibilitySafe) safetyChecksPassed.push("HOLDER_SOVEREIGN_VISIBILITY_INVARIANT");
736
+ const ttl = spec.issuerStagingTtlEpochs ?? DEFAULT_ISSUER_STAGING_TTL_EPOCHS;
737
+ if (!Number.isSafeInteger(ttl) || ttl <= 0 || ttl > MAX_ISSUER_STAGING_TTL_EPOCHS) violations.push(`nftSpec.issuerStagingTtlEpochs must be in 1..${MAX_ISSUER_STAGING_TTL_EPOCHS}`);
738
+ else if (providedSpecsCount === 1) safetyChecksPassed.push("CUSTODY_HANDOVER_RELEASE_INVARIANT");
739
+ }
740
+ } else if (kind === "KARMA_SETTLEMENT_POOL_FACTORY") {
741
+ const spec = blueprint.poolSpec;
742
+ if (!spec || typeof spec !== "object") violations.push("poolSpec is required for KARMA_SETTLEMENT_POOL_FACTORY");
743
+ else {
744
+ if (!isCleanId(spec.sponsorDid) || spec.sponsorDid !== blueprint.proposerDid) {
745
+ violations.push("poolSpec.sponsorDid must match blueprint.proposerDid");
746
+ sybilCheckPassed = false;
747
+ }
748
+ let poolConservationSafe = providedSpecsCount === 1;
749
+ if (!isCleanId(spec.factoryDid)) {
750
+ violations.push("poolSpec.factoryDid must be a clean non-empty DID");
751
+ poolConservationSafe = false;
752
+ } else if (this.tokenFactories.has(spec.factoryDid) || this.nftFactories.has(spec.factoryDid) || this.poolFactories.has(spec.factoryDid)) {
753
+ violations.push(`factoryDid ${spec.factoryDid} already exists`);
754
+ poolConservationSafe = false;
755
+ }
756
+ if (!VALID_POOL_KINDS.has(spec.poolKind)) {
757
+ violations.push(`poolSpec.poolKind ${String(spec.poolKind)} is invalid`);
758
+ poolConservationSafe = false;
759
+ }
760
+ const tokenAddress = spec.tokenAddress ?? require_give_to_mint_karma.DEFAULT_KARMA_TOKEN_ADDRESS;
761
+ if (!isCleanId(tokenAddress) || !this.karmaEngine.getTokenConfig(tokenAddress)) {
762
+ violations.push(`poolSpec.tokenAddress ${String(tokenAddress)} is not a registered reputation token`);
763
+ poolConservationSafe = false;
764
+ }
765
+ const minWeight = spec.minRecipientKarmaWeight ?? 1n;
766
+ if (typeof minWeight !== "bigint" || minWeight <= 0n) {
767
+ violations.push("poolSpec.minRecipientKarmaWeight must be a positive bigint");
768
+ poolConservationSafe = false;
769
+ }
770
+ if (poolConservationSafe) {
771
+ safetyChecksPassed.push("CONSERVATION_AND_UNIQUE_FACTORY_DID_INVARIANT");
772
+ safetyChecksPassed.push("NON_TRANSFERABLE_REPUTATION_INVARIANT");
773
+ }
774
+ }
775
+ } else violations.push(`unsupported targetFactoryKind ${String(kind)}`);
776
+ if (sybilCheckPassed) safetyChecksPassed.unshift("SYBIL_VERIFIED_PROPOSER_INVARIANT");
777
+ return {
778
+ blueprintId,
779
+ targetFactoryKind: kind,
780
+ safe: violations.length === 0,
781
+ safetyChecksPassed,
782
+ violations
783
+ };
784
+ }
785
+ /**
786
+ * Issue #1235 (Phase 3 — Idea-to-Factory Autonomous Rollout Pipeline):
787
+ * Verifies `blueprint` against all protocol safety invariants and automatically provisions
788
+ * the corresponding `ReputationTokenFactory`, `SovereignNftFactory`, or `KarmaSettlementPoolFactory`.
789
+ */
790
+ instantiateFactoryBlueprint(blueprint) {
791
+ const safetyReport = this.verifyFactoryBlueprintSafety(blueprint);
792
+ if (!safetyReport.safe) throw new _ocap_util_lib_error.CustomError(ErrorCode.ForbiddenFactory, `SocialEconomyFactory: blueprint ${safetyReport.blueprintId || "<invalid>"} failed safety verification: ${safetyReport.violations.join("; ")}`);
793
+ const blueprintId = assertCleanId(blueprint.blueprintId, "blueprintId");
794
+ const ideaTitle = blueprint.ideaTitle.trim();
795
+ const proposerDid = assertCleanId(blueprint.proposerDid, "proposerDid");
796
+ if (blueprint.targetFactoryKind === "REPUTATION_TOKEN_FACTORY") {
797
+ const tokenFactory = this.createReputationTokenFromFactory({
798
+ ...blueprint.tokenSpec,
799
+ epochIndex: blueprint.epochIndex
800
+ });
801
+ this.processedBlueprintIds.add(blueprintId);
802
+ return {
803
+ blueprintId,
804
+ ideaTitle,
805
+ proposerDid,
806
+ targetFactoryKind: blueprint.targetFactoryKind,
807
+ factoryDid: tokenFactory.factoryDid,
808
+ safetyReport,
809
+ tokenFactory
810
+ };
811
+ }
812
+ if (blueprint.targetFactoryKind === "SOVEREIGN_NFT_FACTORY") {
813
+ const nftFactory = this.registerSovereignNftFactory({
814
+ ...blueprint.nftSpec,
815
+ createdAtEpoch: blueprint.epochIndex
816
+ });
817
+ this.processedBlueprintIds.add(blueprintId);
818
+ return {
819
+ blueprintId,
820
+ ideaTitle,
821
+ proposerDid,
822
+ targetFactoryKind: blueprint.targetFactoryKind,
823
+ factoryDid: nftFactory.factoryDid,
824
+ safetyReport,
825
+ nftFactory
826
+ };
827
+ }
828
+ const poolFactory = this.registerKarmaSettlementPoolFactory({
829
+ ...blueprint.poolSpec,
830
+ createdAtEpoch: blueprint.epochIndex
831
+ });
832
+ this.processedBlueprintIds.add(blueprintId);
833
+ return {
834
+ blueprintId,
835
+ ideaTitle,
836
+ proposerDid,
837
+ targetFactoryKind: blueprint.targetFactoryKind,
838
+ factoryDid: poolFactory.factoryDid,
839
+ safetyReport,
840
+ poolFactory
841
+ };
842
+ }
843
+ };
844
+
845
+ //#endregion
846
+ exports.DEFAULT_ISSUER_STAGING_TTL_EPOCHS = DEFAULT_ISSUER_STAGING_TTL_EPOCHS;
847
+ exports.GIVE_TO_MINT_TOKEN_TYPE = require_give_to_mint_karma.GIVE_TO_MINT_TOKEN_TYPE;
848
+ exports.MAX_ISSUER_STAGING_TTL_EPOCHS = MAX_ISSUER_STAGING_TTL_EPOCHS;
849
+ exports.MAX_SOVEREIGN_NFT_FACTORY_SUPPLY = MAX_SOVEREIGN_NFT_FACTORY_SUPPLY;
850
+ exports.MIN_GIVE_TO_MINT_TOKEN_CREATION_FEE = require_give_to_mint_karma.MIN_GIVE_TO_MINT_TOKEN_CREATION_FEE;
851
+ exports.OcapSocialEconomyFactoryRegistry = OcapSocialEconomyFactoryRegistry;
852
+ exports.deriveSovereignNftDid = deriveSovereignNftDid;