@ocap/tx-pipeline 1.31.0 → 1.31.2

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 (107) hide show
  1. package/esm/bridge-release-keys.d.mts +33 -0
  2. package/esm/bridge-release-keys.mjs +81 -0
  3. package/esm/bridge-reserves.d.mts +107 -0
  4. package/esm/bridge-reserves.mjs +242 -0
  5. package/esm/helpers/bridge-withdraw.d.mts +86 -0
  6. package/esm/helpers/bridge-withdraw.mjs +123 -0
  7. package/esm/helpers/replay-guard.d.mts +19 -1
  8. package/esm/helpers/replay-guard.mjs +39 -1
  9. package/esm/index.d.mts +3 -1
  10. package/esm/index.mjs +8 -6
  11. package/esm/legacy-protocol-sunset.d.mts +2 -2
  12. package/esm/legacy-protocol-sunset.mjs +5 -5
  13. package/esm/legacy-rollup-archive.d.mts +67 -0
  14. package/esm/legacy-rollup-archive.mjs +199 -0
  15. package/esm/library.d.mts +4 -4
  16. package/esm/library.mjs +3 -3
  17. package/esm/native-abt-exchange.d.mts +3 -0
  18. package/esm/native-abt-exchange.mjs +93 -46
  19. package/esm/pipes/bridge-release-gate.d.mts +30 -0
  20. package/esm/pipes/bridge-release-gate.mjs +143 -0
  21. package/esm/pipes/bridge-reserve-v2-gate.d.mts +53 -0
  22. package/esm/pipes/bridge-reserve-v2-gate.mjs +264 -0
  23. package/esm/pipes/decode-itx.mjs +3 -0
  24. package/esm/pipes/decode-tx.mjs +32 -4
  25. package/esm/pipes/extract-signer.mjs +1 -1
  26. package/esm/pipes/extract-state.mjs +2 -2
  27. package/esm/pipes/post-execution-invariant-gate.d.mts +19 -2
  28. package/esm/pipes/post-execution-invariant-gate.mjs +121 -6
  29. package/esm/pipes/pre-flight-waf.d.mts +58 -2
  30. package/esm/pipes/pre-flight-waf.mjs +202 -14
  31. package/esm/pipes/update-owner.mjs +1 -1
  32. package/esm/pipes/verify-account-migration.mjs +1 -1
  33. package/esm/pipes/verify-delegation.mjs +49 -25
  34. package/esm/pipes/verify-multisig-v2.mjs +5 -4
  35. package/esm/pipes/verify-multisig.mjs +5 -4
  36. package/esm/pipes/verify-signature.d.mts +7 -1
  37. package/esm/pipes/verify-signature.mjs +119 -16
  38. package/esm/pipes/verify-signer.mjs +2 -2
  39. package/esm/pipes/verify-token-access.mjs +1 -1
  40. package/esm/pipes/verify-token-balance.mjs +1 -1
  41. package/esm/pipes/verify-tx-input.mjs +1 -1
  42. package/esm/pipes/verify-tx-size.mjs +1 -1
  43. package/esm/pipes/verify-tx.mjs +12 -5
  44. package/esm/super-suites-foundation.mjs +6 -6
  45. package/esm/transaction-block.d.mts +6 -2
  46. package/esm/transaction-block.mjs +282 -40
  47. package/esm/uniswap-router.d.mts +247 -1
  48. package/esm/uniswap-router.mjs +573 -2
  49. package/lib/bridge-release-keys.cjs +88 -0
  50. package/lib/bridge-release-keys.d.cts +33 -0
  51. package/lib/bridge-reserves.cjs +257 -0
  52. package/lib/bridge-reserves.d.cts +107 -0
  53. package/lib/helpers/bridge-withdraw.cjs +136 -0
  54. package/lib/helpers/bridge-withdraw.d.cts +86 -0
  55. package/lib/helpers/replay-guard.cjs +39 -0
  56. package/lib/helpers/replay-guard.d.cts +20 -2
  57. package/lib/index.cjs +25 -5
  58. package/lib/index.d.cts +3 -1
  59. package/lib/legacy-protocol-sunset.cjs +7 -7
  60. package/lib/legacy-protocol-sunset.d.cts +2 -2
  61. package/lib/legacy-rollup-archive.cjs +208 -0
  62. package/lib/legacy-rollup-archive.d.cts +67 -0
  63. package/lib/library.cjs +14 -68
  64. package/lib/library.d.cts +4 -4
  65. package/lib/native-abt-exchange.cjs +93 -46
  66. package/lib/native-abt-exchange.d.cts +3 -0
  67. package/lib/pipes/bridge-release-gate.cjs +145 -0
  68. package/lib/pipes/bridge-release-gate.d.cts +30 -0
  69. package/lib/pipes/bridge-reserve-v2-gate.cjs +273 -0
  70. package/lib/pipes/bridge-reserve-v2-gate.d.cts +53 -0
  71. package/lib/pipes/decode-itx.cjs +3 -0
  72. package/lib/pipes/decode-itx.d.cts +1 -1
  73. package/lib/pipes/decode-tx.cjs +31 -3
  74. package/lib/pipes/decode-tx.d.cts +1 -1
  75. package/lib/pipes/extract-signer.cjs +1 -1
  76. package/lib/pipes/extract-state.cjs +3 -3
  77. package/lib/pipes/post-execution-invariant-gate.cjs +121 -4
  78. package/lib/pipes/post-execution-invariant-gate.d.cts +19 -2
  79. package/lib/pipes/pre-flight-waf.cjs +209 -15
  80. package/lib/pipes/pre-flight-waf.d.cts +58 -2
  81. package/lib/pipes/update-owner.cjs +1 -1
  82. package/lib/pipes/update-owner.d.cts +1 -1
  83. package/lib/pipes/verify-account-migration.cjs +1 -1
  84. package/lib/pipes/verify-delegation.cjs +50 -26
  85. package/lib/pipes/verify-multisig-v2.cjs +5 -4
  86. package/lib/pipes/verify-multisig.cjs +5 -4
  87. package/lib/pipes/verify-service-fee.d.cts +1 -1
  88. package/lib/pipes/verify-signature.cjs +118 -14
  89. package/lib/pipes/verify-signature.d.cts +8 -2
  90. package/lib/pipes/verify-signer.cjs +2 -2
  91. package/lib/pipes/verify-token-access.cjs +1 -1
  92. package/lib/pipes/verify-token-balance.cjs +1 -1
  93. package/lib/pipes/verify-tx-input.cjs +1 -1
  94. package/lib/pipes/verify-tx-size.cjs +1 -1
  95. package/lib/pipes/verify-tx-size.d.cts +1 -1
  96. package/lib/pipes/verify-tx.cjs +11 -5
  97. package/lib/pipes/verify-tx.d.cts +1 -1
  98. package/lib/super-suites-foundation.cjs +6 -6
  99. package/lib/transaction-block.cjs +282 -40
  100. package/lib/transaction-block.d.cts +6 -2
  101. package/lib/uniswap-router.cjs +576 -1
  102. package/lib/uniswap-router.d.cts +247 -1
  103. package/package.json +10 -10
  104. package/esm/evm-simplified-bridge.d.mts +0 -1370
  105. package/esm/evm-simplified-bridge.mjs +0 -3875
  106. package/lib/evm-simplified-bridge.cjs +0 -3943
  107. package/lib/evm-simplified-bridge.d.cts +0 -1370
@@ -1,19 +1,20 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ const require_pipes_verify_signature = require('./verify-signature.cjs');
3
4
  let _ocap_mcrypto = require("@ocap/mcrypto");
4
5
  let _ocap_util = require("@ocap/util");
5
6
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
7
+ let _arcblock_did = require("@arcblock/did");
8
+ let _arcblock_did_util = require("@arcblock/did-util");
9
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
6
10
  let lodash_get = require("lodash/get");
7
11
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
8
- let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
9
- let lodash_set = require("lodash/set");
10
- lodash_set = require_rolldown_runtime.__toESM(lodash_set);
11
- let _arcblock_did = require("@arcblock/did");
12
12
  let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
13
+ let _ocap_wallet = require("@ocap/wallet");
13
14
  let lodash_isEmpty = require("lodash/isEmpty");
14
15
  lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
15
- let _ocap_wallet = require("@ocap/wallet");
16
- let _arcblock_did_util = require("@arcblock/did-util");
16
+ let lodash_set = require("lodash/set");
17
+ lodash_set = require_rolldown_runtime.__toESM(lodash_set);
17
18
 
18
19
  //#region src/pipes/verify-delegation.ts
19
20
  const ZERO = (0, _ocap_util.toBN)(0);
@@ -326,22 +327,31 @@ function CreateVerifyDelegationPipe({ type = "signature", delegationKey = "deleg
326
327
  }
327
328
  return null;
328
329
  };
330
+ const hasExplicitCoSignatureInput = () => {
331
+ const explicitCoSig = (0, lodash_get.default)(context, "extra.coSignature");
332
+ if (explicitCoSig !== void 0 && explicitCoSig !== null) return true;
333
+ const rawTxExtra = (0, lodash_get.default)(context, "extra.txExtra");
334
+ if (typeof rawTxExtra === "string" && rawTxExtra.trim().startsWith("{")) try {
335
+ const parsed = JSON.parse(rawTxExtra);
336
+ return Boolean(parsed && typeof parsed === "object" && !Array.isArray(parsed) && "coSignature" in parsed);
337
+ } catch {
338
+ return false;
339
+ }
340
+ if (rawTxExtra && typeof rawTxExtra === "object" && !Array.isArray(rawTxExtra)) return "coSignature" in rawTxExtra;
341
+ return false;
342
+ };
329
343
  const verifyOwnerCoSignature = async (signerState, delegateePk) => {
330
344
  if (!signerState?.address) return false;
331
345
  if (Array.isArray(signerState.migratedTo) && signerState.migratedTo.length > 0) return false;
332
- let rawCoSig = (0, lodash_get.default)(context, "extra.coSignature");
333
- if (!rawCoSig) {
334
- const rawTxExtra = (0, lodash_get.default)(context, "extra.txExtra");
335
- if (typeof rawTxExtra === "string" && rawTxExtra.trim().startsWith("{")) try {
336
- const parsed = JSON.parse(rawTxExtra);
337
- if (parsed?.coSignature && typeof parsed.coSignature === "object") rawCoSig = parsed.coSignature;
338
- } catch {}
339
- else if (rawTxExtra && typeof rawTxExtra === "object") {
340
- const maybeCoSig = rawTxExtra.coSignature;
341
- if (maybeCoSig && typeof maybeCoSig === "object") rawCoSig = maybeCoSig;
342
- }
343
- }
344
- if (!rawCoSig || typeof rawCoSig.pk !== "string" || typeof rawCoSig.signature !== "string") return false;
346
+ const rawDirectCoSig = (0, lodash_get.default)(context, "extra.coSignature");
347
+ const hasDirectCoSig = rawDirectCoSig !== void 0 && rawDirectCoSig !== null;
348
+ const rawTxExtra = (0, lodash_get.default)(context, "extra.txExtra");
349
+ const parsedFromDirect = hasDirectCoSig ? require_pipes_verify_signature.parseCanonicalCoSignatureTxExtra({ coSignature: rawDirectCoSig }) : null;
350
+ const parsedFromTxExtra = rawTxExtra !== void 0 && rawTxExtra !== null ? require_pipes_verify_signature.parseCanonicalCoSignatureTxExtra(rawTxExtra) : null;
351
+ if (hasDirectCoSig && !parsedFromDirect) return false;
352
+ if (parsedFromDirect && parsedFromTxExtra && (parsedFromDirect.pk !== parsedFromTxExtra.pk || parsedFromDirect.signature !== parsedFromTxExtra.signature || (parsedFromDirect.extra || "") !== (parsedFromTxExtra.extra || ""))) return false;
353
+ const rawCoSig = parsedFromDirect || parsedFromTxExtra;
354
+ if (!rawCoSig) return false;
345
355
  const candidatePayloads = [context.txHash, context.unsignedTxHash].filter((x) => typeof x === "string" && x.length > 0);
346
356
  if (candidatePayloads.length === 0) return false;
347
357
  const ownerAddr = signerState.address;
@@ -350,15 +360,25 @@ function CreateVerifyDelegationPipe({ type = "signature", delegationKey = "deleg
350
360
  const forbiddenPkHex = forbiddenPk ? (0, _arcblock_did.normalizePublicKeyHex)(forbiddenPk) : "";
351
361
  if (!coSigPkHex || forbiddenPkHex && coSigPkHex === forbiddenPkHex) return false;
352
362
  if (!(0, _arcblock_did.isFromPublicKey)(ownerAddr, rawCoSig.pk)) return false;
363
+ const ownerType = (0, _arcblock_did.toTypeInfo)(ownerAddr);
364
+ const isOwnerPasskey = ownerType.role === _ocap_mcrypto.types.RoleType.ROLE_PASSKEY || ownerType.pk === _ocap_mcrypto.types.KeyType.PASSKEY;
365
+ const coSigExtra = rawCoSig.extra || "";
366
+ if (isOwnerPasskey && !coSigExtra) return false;
367
+ if (!isOwnerPasskey && coSigExtra) return false;
368
+ let wallet;
353
369
  try {
354
- const wallet = (0, _ocap_wallet.fromPublicKey)(rawCoSig.pk, (0, _arcblock_did.toTypeInfo)(ownerAddr));
355
- for (const payload of candidatePayloads) {
356
- if (await wallet.verify(payload, rawCoSig.signature, false)) return true;
357
- if (await wallet.verify(payload, rawCoSig.signature, true)) return true;
358
- }
370
+ wallet = (0, _ocap_wallet.fromPublicKey)(rawCoSig.pk, ownerType);
359
371
  } catch {
360
372
  return false;
361
373
  }
374
+ for (const payload of candidatePayloads) {
375
+ try {
376
+ if (await wallet.verify(payload, rawCoSig.signature, false, coSigExtra)) return true;
377
+ } catch {}
378
+ try {
379
+ if (await wallet.verify(payload, rawCoSig.signature, true, coSigExtra)) return true;
380
+ } catch {}
381
+ }
362
382
  return false;
363
383
  };
364
384
  const getTxTimestampSeconds = () => {
@@ -429,6 +449,7 @@ function CreateVerifyDelegationPipe({ type = "signature", delegationKey = "deleg
429
449
  const signerAddress = signerState?.address || tx?.from;
430
450
  if (delegatorState && (tx?.delegator && !(0, _ocap_util.isSameDid)(delegatorState.address, tx.delegator) || Array.isArray(delegatorState.migratedTo) && delegatorState.migratedTo.length > 0)) return next(new _ocap_util_lib_error.CustomError("ACCOUNT_MIGRATED", `Delegator account ${tx?.delegator} is migrated`, { persist: false }));
431
451
  if (signerAddress && (0, _arcblock_did.toTypeInfo)(signerAddress).role === _ocap_mcrypto.types.RoleType.ROLE_ASSET) {
452
+ if (hasExplicitCoSignatureInput()) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Unexpected owner coSignature on implicit asset delegation", { persist: false }));
432
453
  try {
433
454
  if (await verifyImplicitAssetOwnership(signerAddress, delegatorState || (tx?.delegator ? { address: tx.delegator } : null), context, tx?.delegator)) {
434
455
  (0, lodash_set.default)(context, "isImplicitDelegation", true);
@@ -451,6 +472,8 @@ function CreateVerifyDelegationPipe({ type = "signature", delegationKey = "deleg
451
472
  const coSignedByOwner = await verifyOwnerCoSignature(signerState);
452
473
  const result = checkDelegation(delegationState, requirements, coSignedByOwner);
453
474
  if (result.code) return next(new _ocap_util_lib_error.CustomError(result.code, `Delegation check failed: ${result.reason}`, { persist: false }));
475
+ const hasDelegatedMultiSig = (0, _ocap_util_lib_get_list_field.getListField)(tx, "signatures").some((x) => Boolean(x?.delegator));
476
+ if (hasExplicitCoSignatureInput() && !coSignedByOwner && !hasDelegatedMultiSig) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Invalid owner coSignature", { persist: false }));
454
477
  if (coSignedByOwner) (0, lodash_set.default)(context, "coSignedByOwner", true);
455
478
  (0, lodash_set.default)(context, delegationKey, delegationState);
456
479
  (0, lodash_set.default)(context, "isDelegationChanged", true);
@@ -473,8 +496,8 @@ function CreateVerifyDelegationPipe({ type = "signature", delegationKey = "deleg
473
496
  const { signer, delegator } = signature;
474
497
  const sigRequirements = typeof getRequirements === "function" ? getRequirements(context, index, signature) || [] : [];
475
498
  allRequirements.push(...sigRequirements);
476
- const signerState = signerStates?.find((x) => signer && (0, _ocap_util.isSameDid)(x.address, signer));
477
- const delegatorState = delegatorStates?.find((x) => delegator && (0, _ocap_util_lib_get_related_addr.getRelatedAddresses)(x).some((addr) => (0, _ocap_util.isSameDid)(addr, delegator)));
499
+ const signerState = signerStates?.find((x) => Boolean(x && signer && (0, _ocap_util_lib_get_related_addr.getRelatedAddresses)(x).some((addr) => (0, _ocap_util.isSameDid)(addr, signer))));
500
+ const delegatorState = delegatorStates?.find((x) => Boolean(x && delegator && (0, _ocap_util_lib_get_related_addr.getRelatedAddresses)(x).some((addr) => (0, _ocap_util.isSameDid)(addr, delegator))));
478
501
  if (delegatorState && (delegator && !(0, _ocap_util.isSameDid)(delegatorState.address, delegator) || Array.isArray(delegatorState.migratedTo) && delegatorState.migratedTo.length > 0)) return next(new _ocap_util_lib_error.CustomError("ACCOUNT_MIGRATED", `Delegator account ${delegator} is migrated`, { persist: false }));
479
502
  const signerAddress = signerState?.address || signer;
480
503
  if (signerAddress && (0, _arcblock_did.toTypeInfo)(signerAddress).role === _ocap_mcrypto.types.RoleType.ROLE_ASSET) {
@@ -503,6 +526,7 @@ function CreateVerifyDelegationPipe({ type = "signature", delegationKey = "deleg
503
526
  if (coSignedByOwner) (0, lodash_set.default)(context, "coSignedByOwner", true);
504
527
  if (!delegationStates.some((d) => (0, _ocap_util.isSameDid)(d.address, delegationState.address))) delegationStates.push(delegationState);
505
528
  }
529
+ if (hasExplicitCoSignatureInput() && !(0, lodash_get.default)(context, "coSignedByOwner")) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Invalid owner coSignature", { persist: false }));
506
530
  (0, lodash_set.default)(context, requirementsKey, allRequirements);
507
531
  (0, lodash_set.default)(context, delegationKey, delegationStates);
508
532
  (0, lodash_set.default)(context, "isMultiSigDelegationVerified", true);
@@ -6,17 +6,17 @@ const require_helpers_unwrap_opaque_any = require('../helpers/unwrap-opaque-any.
6
6
  const require_helpers_encode_tx_by_context = require('../helpers/encode-tx-by-context.cjs');
7
7
  let _ocap_mcrypto = require("@ocap/mcrypto");
8
8
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
9
- let lodash_get = require("lodash/get");
10
- lodash_get = require_rolldown_runtime.__toESM(lodash_get);
9
+ let _arcblock_did = require("@arcblock/did");
11
10
  let _ocap_message = require("@ocap/message");
12
11
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
12
+ let lodash_get = require("lodash/get");
13
+ lodash_get = require_rolldown_runtime.__toESM(lodash_get);
13
14
  let lodash_cloneDeep = require("lodash/cloneDeep");
14
15
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
15
16
  let lodash_omit = require("lodash/omit");
16
17
  lodash_omit = require_rolldown_runtime.__toESM(lodash_omit);
17
18
  let debug = require("debug");
18
19
  debug = require_rolldown_runtime.__toESM(debug);
19
- let _arcblock_did = require("@arcblock/did");
20
20
  let _ocap_wallet = require("@ocap/wallet");
21
21
 
22
22
  //#region src/pipes/verify-multisig-v2.ts
@@ -72,7 +72,8 @@ function CreateVerifyMultiSigV2Pipe({ signersKey }) {
72
72
  signer: address,
73
73
  from: signer,
74
74
  nonce: tx.nonce,
75
- action: context.txType
75
+ action: context.txType,
76
+ withdraw: await require_helpers_replay_guard.getBridgeWithdrawEnvelopeContext(context)
76
77
  });
77
78
  if (await wallet.verify(txBytes, signature, true, verifiedExtra) === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Signature for ${address} is not valid`));
78
79
  } catch (err) {
@@ -5,13 +5,13 @@ const require_helpers_unwrap_opaque_any = require('../helpers/unwrap-opaque-any.
5
5
  const require_helpers_encode_tx_by_context = require('../helpers/encode-tx-by-context.cjs');
6
6
  let _ocap_mcrypto = require("@ocap/mcrypto");
7
7
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
8
- let lodash_get = require("lodash/get");
9
- lodash_get = require_rolldown_runtime.__toESM(lodash_get);
8
+ let _arcblock_did = require("@arcblock/did");
10
9
  let _ocap_message = require("@ocap/message");
11
10
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
11
+ let lodash_get = require("lodash/get");
12
+ lodash_get = require_rolldown_runtime.__toESM(lodash_get);
12
13
  let lodash_cloneDeep = require("lodash/cloneDeep");
13
14
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
14
- let _arcblock_did = require("@arcblock/did");
15
15
  let _ocap_wallet = require("@ocap/wallet");
16
16
 
17
17
  //#region src/pipes/verify-multisig.ts
@@ -49,7 +49,8 @@ function CreateVerifyMultiSigPipe(numSigs = 0) {
49
49
  signer: address,
50
50
  from: signer,
51
51
  nonce: tx.nonce,
52
- action: context.txType
52
+ action: context.txType,
53
+ withdraw: await require_helpers_replay_guard.getBridgeWithdrawEnvelopeContext(context)
53
54
  });
54
55
  if (await wallet.verify(txBytes, signature, true, extra) === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Multi signature for ${address} is not valid`));
55
56
  } catch (err) {
@@ -1,5 +1,5 @@
1
- import { CustomError } from "@ocap/util/lib/error";
2
1
  import { IDecodedContext } from "@ocap/types";
2
+ import { CustomError } from "@ocap/util/lib/error";
3
3
 
4
4
  //#region src/pipes/verify-service-fee.d.ts
5
5
  declare function VerifyServiceFee(context: IDecodedContext, next: (err?: CustomError) => void): void;
@@ -4,12 +4,12 @@ const require_helpers_replay_guard = require('../helpers/replay-guard.cjs');
4
4
  const require_helpers_encode_tx_by_context = require('../helpers/encode-tx-by-context.cjs');
5
5
  let _ocap_mcrypto = require("@ocap/mcrypto");
6
6
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
7
+ let _arcblock_did = require("@arcblock/did");
8
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
7
9
  let lodash_get = require("lodash/get");
8
10
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
9
- let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
10
11
  let lodash_cloneDeep = require("lodash/cloneDeep");
11
12
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
12
- let _arcblock_did = require("@arcblock/did");
13
13
  let _ocap_wallet = require("@ocap/wallet");
14
14
 
15
15
  //#region src/pipes/verify-signature.ts
@@ -18,6 +18,94 @@ const V1_MULTISIG_TX_TYPES = new Set([
18
18
  "fg:t:exchange_v2",
19
19
  "fg:t:account_migrate"
20
20
  ]);
21
+ const ALLOWED_COSIG_KEYS = new Set([
22
+ "pk",
23
+ "signature",
24
+ "extra"
25
+ ]);
26
+ const ALLOWED_PASSKEY_COSIG_EXTRA_KEYS = new Set(["authenticatorData", "clientDataJSON"]);
27
+ const MAX_CO_SIGNATURE_TX_EXTRA_CHARS = 4096;
28
+ const MAX_CO_SIGNATURE_PASSKEY_EXTRA_CHARS = 2048;
29
+ function isCanonicalPasskeyCoSigExtra(extra) {
30
+ if (typeof extra !== "string" || extra.length === 0 || extra.length > MAX_CO_SIGNATURE_PASSKEY_EXTRA_CHARS || !require_helpers_replay_guard.isCanonicalPasskeyExtra(extra)) return false;
31
+ try {
32
+ const parsed = JSON.parse(extra);
33
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || JSON.stringify(parsed) !== extra) return false;
34
+ if (Object.keys(parsed).some((k) => !ALLOWED_PASSKEY_COSIG_EXTRA_KEYS.has(k))) return false;
35
+ return true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+ function parseCanonicalCoSignatureTxExtra(rawTxExtra) {
41
+ try {
42
+ let parsed = null;
43
+ if (typeof rawTxExtra === "string") {
44
+ if (rawTxExtra.length > MAX_CO_SIGNATURE_TX_EXTRA_CHARS || !rawTxExtra.startsWith("{")) return null;
45
+ parsed = JSON.parse(rawTxExtra);
46
+ if (JSON.stringify(parsed) !== rawTxExtra) return null;
47
+ } else if (rawTxExtra && typeof rawTxExtra === "object" && !Array.isArray(rawTxExtra)) {
48
+ const serialized = JSON.stringify(rawTxExtra);
49
+ if (!serialized || serialized.length > MAX_CO_SIGNATURE_TX_EXTRA_CHARS) return null;
50
+ parsed = rawTxExtra;
51
+ } else return null;
52
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
53
+ const topKeys = Object.keys(parsed);
54
+ if (topKeys.length !== 1 || topKeys[0] !== "coSignature") return null;
55
+ const coSig = parsed.coSignature;
56
+ if (!coSig || typeof coSig !== "object" || Array.isArray(coSig)) return null;
57
+ const coSigKeys = Object.keys(coSig);
58
+ if (coSigKeys.length < 2 || coSigKeys.length > 3 || coSigKeys.some((k) => !ALLOWED_COSIG_KEYS.has(k))) return null;
59
+ const { pk, signature, extra } = coSig;
60
+ if (typeof pk !== "string" || pk.trim().length === 0 || pk.length > 256) return null;
61
+ if (typeof signature !== "string" || signature.trim().length === 0 || signature.length > 512) return null;
62
+ if (extra !== void 0 && extra !== "") {
63
+ if (typeof extra !== "string" || !isCanonicalPasskeyCoSigExtra(extra)) return null;
64
+ return {
65
+ pk,
66
+ signature,
67
+ extra
68
+ };
69
+ }
70
+ return {
71
+ pk,
72
+ signature
73
+ };
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+ async function verifyStatelessCoSignature(coSig, candidates, candidatePayloads) {
79
+ if (candidates.length === 0 || candidatePayloads.length === 0) return false;
80
+ const coSigPkHex = (0, _arcblock_did.normalizePublicKeyHex)(coSig.pk);
81
+ if (!coSigPkHex) return false;
82
+ for (const { ownerAddr, delegateePk } of candidates) {
83
+ if (!ownerAddr) continue;
84
+ const forbiddenPkHex = delegateePk ? (0, _arcblock_did.normalizePublicKeyHex)(delegateePk) : "";
85
+ if (forbiddenPkHex && coSigPkHex === forbiddenPkHex) continue;
86
+ if (!(0, _arcblock_did.isFromPublicKey)(ownerAddr, coSig.pk)) continue;
87
+ const ownerType = (0, _arcblock_did.toTypeInfo)(ownerAddr);
88
+ const isOwnerPasskey = ownerType.role === _ocap_mcrypto.types.RoleType.ROLE_PASSKEY || ownerType.pk === _ocap_mcrypto.types.KeyType.PASSKEY;
89
+ const coSigExtra = coSig.extra || "";
90
+ if (isOwnerPasskey && !coSigExtra) continue;
91
+ if (!isOwnerPasskey && coSigExtra) continue;
92
+ let wallet;
93
+ try {
94
+ wallet = (0, _ocap_wallet.fromPublicKey)(coSig.pk, ownerType);
95
+ } catch {
96
+ continue;
97
+ }
98
+ for (const payload of candidatePayloads) {
99
+ try {
100
+ if (await wallet.verify(payload, coSig.signature, false, coSigExtra)) return true;
101
+ } catch {}
102
+ try {
103
+ if (await wallet.verify(payload, coSig.signature, true, coSigExtra)) return true;
104
+ } catch {}
105
+ }
106
+ }
107
+ return false;
108
+ }
21
109
  async function VerifySignature(context, next) {
22
110
  const tx = (0, lodash_cloneDeep.default)(context.tx);
23
111
  const { signature } = tx;
@@ -39,22 +127,36 @@ async function VerifySignature(context, next) {
39
127
  const type = (0, _arcblock_did.toTypeInfo)(signer);
40
128
  const wallet = (0, _ocap_wallet.fromPublicKey)(pk, type);
41
129
  const rawTxExtra = (0, lodash_get.default)(context, "extra.txExtra");
130
+ const rawDirectCoSig = (0, lodash_get.default)(context, "extra.coSignature");
131
+ const hasDirectCoSig = rawDirectCoSig !== void 0 && rawDirectCoSig !== null;
42
132
  const isPasskey = type.role === _ocap_mcrypto.types.RoleType.ROLE_PASSKEY || type.pk === _ocap_mcrypto.types.KeyType.PASSKEY;
43
133
  if (isPasskey && (typeof rawTxExtra !== "string" || !require_helpers_replay_guard.isCanonicalPasskeyExtra(rawTxExtra))) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Non-canonical extra data for passkey signer"));
44
134
  const isWalletEnvelope = !isPasskey && typeof rawTxExtra === "string" && (0, _ocap_mcrypto.isCanonicalWalletEnvelopeExtra)(rawTxExtra, type.pk);
45
- if (!isPasskey && !isWalletEnvelope && rawTxExtra) {
135
+ if (!isPasskey && !isWalletEnvelope && rawTxExtra || hasDirectCoSig) {
46
136
  const v1Sigs = (0, _ocap_util_lib_get_list_field.getListField)(context.tx, "signatures");
47
137
  const v1Counterparty = v1Sigs[0]?.delegator || v1Sigs[0]?.signer;
48
- const isV1CounterpartyPasskey = Boolean(txType && V1_MULTISIG_TX_TYPES.has(txType) && v1Counterparty && ((0, _arcblock_did.toTypeInfo)(v1Counterparty).role === _ocap_mcrypto.types.RoleType.ROLE_PASSKEY || (0, _arcblock_did.toTypeInfo)(v1Counterparty).pk === _ocap_mcrypto.types.KeyType.PASSKEY) && typeof rawTxExtra === "string" && require_helpers_replay_guard.isCanonicalPasskeyExtra(rawTxExtra));
49
- const hasDelegator = Boolean(tx.delegator) || v1Sigs.some((s) => Boolean(s?.delegator));
50
- let isTier3CoSignatureExtra = false;
51
- if (hasDelegator) try {
52
- const parsed = typeof rawTxExtra === "string" ? rawTxExtra.trim().startsWith("{") ? JSON.parse(rawTxExtra) : null : rawTxExtra;
53
- isTier3CoSignatureExtra = Boolean(parsed && typeof parsed === "object" && !Array.isArray(parsed) && parsed.coSignature && typeof parsed.coSignature === "object" && typeof parsed.coSignature.pk === "string" && typeof parsed.coSignature.signature === "string");
54
- } catch {
55
- isTier3CoSignatureExtra = false;
138
+ if (!Boolean(!hasDirectCoSig && txType && V1_MULTISIG_TX_TYPES.has(txType) && v1Counterparty && ((0, _arcblock_did.toTypeInfo)(v1Counterparty).role === _ocap_mcrypto.types.RoleType.ROLE_PASSKEY || (0, _arcblock_did.toTypeInfo)(v1Counterparty).pk === _ocap_mcrypto.types.KeyType.PASSKEY) && typeof rawTxExtra === "string" && require_helpers_replay_guard.isCanonicalPasskeyExtra(rawTxExtra))) {
139
+ const hasDelegator = Boolean(tx.delegator) || v1Sigs.some((s) => Boolean(s?.delegator));
140
+ const parsedFromTxExtra = !isPasskey && !isWalletEnvelope && rawTxExtra ? parseCanonicalCoSignatureTxExtra(rawTxExtra) : null;
141
+ const parsedFromDirect = hasDirectCoSig ? parseCanonicalCoSignatureTxExtra({ coSignature: rawDirectCoSig }) : null;
142
+ if (hasDirectCoSig && !parsedFromDirect) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Invalid owner coSignature"));
143
+ if (!isPasskey && !isWalletEnvelope && rawTxExtra && !parsedFromTxExtra) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Unexpected extra data for non-passkey signer ${signer}`));
144
+ if (parsedFromTxExtra && parsedFromDirect && (parsedFromTxExtra.pk !== parsedFromDirect.pk || parsedFromTxExtra.signature !== parsedFromDirect.signature || (parsedFromTxExtra.extra || "") !== (parsedFromDirect.extra || ""))) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Conflicting owner coSignature inputs"));
145
+ const parsedCoSig = parsedFromTxExtra || parsedFromDirect;
146
+ if (!hasDelegator || !parsedCoSig) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Unexpected extra data for non-passkey signer ${signer}`));
147
+ const coSigCandidates = [];
148
+ if (tx.delegator && tx.from) coSigCandidates.push({
149
+ ownerAddr: tx.from,
150
+ delegateePk: tx.pk
151
+ });
152
+ for (const s of v1Sigs) if (s?.delegator && s?.signer) coSigCandidates.push({
153
+ ownerAddr: s.signer,
154
+ delegateePk: s.pk
155
+ });
156
+ const ctxTxHash = context.txHash;
157
+ const ctxUnsignedTxHash = context.unsignedTxHash || (0, _ocap_mcrypto.toTxHash)(txBytes);
158
+ if (!await verifyStatelessCoSignature(parsedCoSig, coSigCandidates, Array.from(new Set([ctxTxHash, ctxUnsignedTxHash].filter((x) => typeof x === "string" && x.length > 0))))) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Invalid owner coSignature"));
56
159
  }
57
- if (!isV1CounterpartyPasskey && !isTier3CoSignatureExtra) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Unexpected extra data for non-passkey signer ${signer}`));
58
160
  }
59
161
  const extra = isPasskey ? rawTxExtra : isWalletEnvelope ? rawTxExtra : "";
60
162
  try {
@@ -63,7 +165,8 @@ async function VerifySignature(context, next) {
63
165
  signer,
64
166
  from: tx.from,
65
167
  nonce: tx.nonce,
66
- action: txType
168
+ action: txType,
169
+ withdraw: await require_helpers_replay_guard.getBridgeWithdrawEnvelopeContext(context)
67
170
  });
68
171
  if (!signature || await wallet.verify(txBytes, signature, true, extra || "") === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "tx.signature is invalid"));
69
172
  } catch (err) {
@@ -75,4 +178,5 @@ async function VerifySignature(context, next) {
75
178
  }
76
179
 
77
180
  //#endregion
78
- exports.default = VerifySignature;
181
+ exports.default = VerifySignature;
182
+ exports.parseCanonicalCoSignatureTxExtra = parseCanonicalCoSignatureTxExtra;
@@ -1,7 +1,13 @@
1
- import { CustomError } from "@ocap/util/lib/error";
2
1
  import { IDecodedContext } from "@ocap/types";
2
+ import { CustomError } from "@ocap/util/lib/error";
3
3
 
4
4
  //#region src/pipes/verify-signature.d.ts
5
+ interface ParsedCoSignature {
6
+ pk: string;
7
+ signature: string;
8
+ extra?: string;
9
+ }
10
+ declare function parseCanonicalCoSignatureTxExtra(rawTxExtra: unknown): ParsedCoSignature | null;
5
11
  declare function VerifySignature(context: IDecodedContext, next: (err?: CustomError) => void): Promise<void>;
6
12
  //#endregion
7
- export { VerifySignature as default };
13
+ export { ParsedCoSignature, VerifySignature as default, parseCanonicalCoSignatureTxExtra };
@@ -3,12 +3,12 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  const require_package = require('../package.cjs');
4
4
  let _ocap_mcrypto = require("@ocap/mcrypto");
5
5
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
6
+ let _arcblock_did = require("@arcblock/did");
7
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
6
8
  let lodash_get = require("lodash/get");
7
9
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
8
- let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
9
10
  let debug = require("debug");
10
11
  debug = require_rolldown_runtime.__toESM(debug);
11
- let _arcblock_did = require("@arcblock/did");
12
12
 
13
13
  //#region src/pipes/verify-signer.ts
14
14
  const debug$1 = (0, debug.default)(`${require_package.name}:pipe:verify-signer`);
@@ -2,9 +2,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  let _ocap_util = require("@ocap/util");
4
4
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
5
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
5
6
  let lodash_get = require("lodash/get");
6
7
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
7
- let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
8
8
  let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
9
9
  let lodash_isEmpty = require("lodash/isEmpty");
10
10
  lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
@@ -2,9 +2,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  let _ocap_util = require("@ocap/util");
4
4
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
5
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
5
6
  let lodash_get = require("lodash/get");
6
7
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
7
- let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
8
8
  let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
9
9
  let lodash_isEmpty = require("lodash/isEmpty");
10
10
  lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
@@ -2,9 +2,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  let _ocap_util = require("@ocap/util");
4
4
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
5
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
5
6
  let lodash_get = require("lodash/get");
6
7
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
7
- let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
8
8
  let lodash_isEmpty = require("lodash/isEmpty");
9
9
  lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
10
10
  let _ocap_util_lib_create_sorted_list = require("@ocap/util/lib/create-sorted-list");
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
4
+ let _ocap_message = require("@ocap/message");
4
5
  let lodash_get = require("lodash/get");
5
6
  lodash_get = require_rolldown_runtime.__toESM(lodash_get);
6
- let _ocap_message = require("@ocap/message");
7
7
 
8
8
  //#region src/pipes/verify-tx-size.ts
9
9
  const DEFAULT_MAX_EXTRA_SIZE = 8 * 1024;
@@ -1,5 +1,5 @@
1
- import { CustomError } from "@ocap/util/lib/error";
2
1
  import { IDecodedContext } from "@ocap/types";
2
+ import { CustomError } from "@ocap/util/lib/error";
3
3
 
4
4
  //#region src/pipes/verify-tx-size.d.ts
5
5
  declare function VerifyTxSize(context: IDecodedContext, next: (err?: CustomError) => void): void;
@@ -4,14 +4,14 @@ require('../helpers/replay-guard.cjs');
4
4
  let _ocap_mcrypto = require("@ocap/mcrypto");
5
5
  let _ocap_util = require("@ocap/util");
6
6
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
7
- let lodash_get = require("lodash/get");
8
- lodash_get = require_rolldown_runtime.__toESM(lodash_get);
7
+ let _arcblock_did = require("@arcblock/did");
8
+ let _ocap_state = require("@ocap/state");
9
9
  let _ocap_message = require("@ocap/message");
10
10
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
11
- let _arcblock_did = require("@arcblock/did");
11
+ let lodash_get = require("lodash/get");
12
+ lodash_get = require_rolldown_runtime.__toESM(lodash_get);
12
13
  let lodash_isEmpty = require("lodash/isEmpty");
13
14
  lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
14
- let _ocap_state = require("@ocap/state");
15
15
 
16
16
  //#region src/pipes/verify-tx.ts
17
17
  async function VerifyTx(context, next) {
@@ -27,9 +27,15 @@ async function VerifyTx(context, next) {
27
27
  if (chainId !== expected) return next(new _ocap_util_lib_error.CustomError("INVALID_CHAIN_ID", `Invalid chain id: expected ${expected}, got ${chainId}`));
28
28
  const nonceBn = (0, _ocap_state.parseNonceBn)(nonce);
29
29
  if (!nonceBn || nonceBn.lte(new _ocap_util.BN(0))) return next(new _ocap_util_lib_error.CustomError("INVALID_NONCE", "tx.nonce should be a positive integer"));
30
- const { supportedTxs, maxMultisig } = (0, lodash_get.default)(context, "config.transaction");
31
30
  const rawItx = itx;
32
31
  const itxTypeUrl = rawItx.typeUrl || (rawItx.type ? (0, _ocap_message.toTypeUrl)(rawItx.type) : void 0);
32
+ const isExchangeV2 = itxTypeUrl === "fg:t:exchange_v2" || context.txType === "fg:t:exchange_v2";
33
+ if (!(0, lodash_isEmpty.default)(delegator) || isExchangeV2) {
34
+ const txTimeMs = context.txTime ? new Date(context.txTime).getTime() : NaN;
35
+ const maxNonce = (Number.isFinite(txTimeMs) ? txTimeMs : Date.now()) + _ocap_state.account.DELEGATED_NONCE_MAX_FUTURE_MS;
36
+ if (nonceBn.gt(new _ocap_util.BN(String(maxNonce), 10))) return next(new _ocap_util_lib_error.CustomError("INVALID_NONCE", `tx.nonce of a ${!(0, lodash_isEmpty.default)(delegator) ? "delegated" : "exchange_v2"} tx should not exceed the tx time in milliseconds plus 24 hours (max ${maxNonce}, got ${nonceBn.toString(10)})`));
37
+ }
38
+ const { supportedTxs, maxMultisig } = (0, lodash_get.default)(context, "config.transaction");
33
39
  if (!itxTypeUrl || supportedTxs.includes(itxTypeUrl) === false) return next(new _ocap_util_lib_error.CustomError("UNSUPPORTED_TX", `Transaction ${itxTypeUrl} is not supported`));
34
40
  if ((0, _ocap_util_lib_get_list_field.getListField)(context, "tx.signatures").length > maxMultisig) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "Too many multisig signatures"));
35
41
  if ((0, _arcblock_did.toTypeInfo)(from).role === _ocap_mcrypto.types.RoleType.ROLE_ASSET && (0, lodash_isEmpty.default)(delegator)) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "Asset sender requires a delegator"));
@@ -1,5 +1,5 @@
1
- import { CustomError } from "@ocap/util/lib/error";
2
1
  import { IDecodedContext } from "@ocap/types";
2
+ import { CustomError } from "@ocap/util/lib/error";
3
3
 
4
4
  //#region src/pipes/verify-tx.d.ts
5
5
  declare function VerifyTx(context: IDecodedContext, next: (err?: CustomError) => void): Promise<void>;
@@ -254,7 +254,7 @@ var OcapSuperSuitesFoundationEngine = class {
254
254
  }];
255
255
  const postConditions = {
256
256
  signer: pool.poolDid,
257
- maxTokenOutflow: { [pool.tokenAddress]: redeemAmountAbt.toString(10) },
257
+ maxTokenOutflow: { [pool.poolDid]: { [pool.tokenAddress]: redeemAmountAbt.toString(10) } },
258
258
  strictZeroUnlistedOutflow: true
259
259
  };
260
260
  return {
@@ -472,7 +472,7 @@ var OcapSuperSuitesFoundationEngine = class {
472
472
  pushSplitTransfer(org.creatorDid, creatorNetAbt, "CREATOR_NET_REVENUE");
473
473
  const postConditions = {
474
474
  signer: payerDid,
475
- maxTokenOutflow: { [org.tokenAddress]: ticketPriceAbt.toString(10) },
475
+ maxTokenOutflow: { [payerDid]: { [org.tokenAddress]: ticketPriceAbt.toString(10) } },
476
476
  strictZeroUnlistedOutflow: true
477
477
  };
478
478
  return {
@@ -669,7 +669,7 @@ var OcapSuperSuitesFoundationEngine = class {
669
669
  pushSplit(machineDid, poolCAddedAbt, "C_CONSERVATION_PRIZE_POOL");
670
670
  const postConditions = {
671
671
  signer: payerDid,
672
- maxTokenOutflow: { [machine.tokenAddress]: A.toString(10) },
672
+ maxTokenOutflow: { [payerDid]: { [machine.tokenAddress]: A.toString(10) } },
673
673
  strictZeroUnlistedOutflow: true
674
674
  };
675
675
  return {
@@ -774,7 +774,7 @@ var OcapSuperSuitesFoundationEngine = class {
774
774
  }));
775
775
  const postConditions = {
776
776
  signer: machineDid,
777
- maxTokenOutflow: { [machine.tokenAddress]: totalPayoutAbt.toString(10) },
777
+ maxTokenOutflow: { [machineDid]: { [machine.tokenAddress]: totalPayoutAbt.toString(10) } },
778
778
  strictZeroUnlistedOutflow: true
779
779
  };
780
780
  return {
@@ -945,7 +945,7 @@ var OcapSuperSuitesFoundationEngine = class {
945
945
  });
946
946
  const postConditions = {
947
947
  signer: offer.buyerDid,
948
- maxTokenOutflow: { [DEFAULT_ABT_TOKEN_ADDRESS]: grossOfferAbt.toString(10) },
948
+ maxTokenOutflow: { [offer.buyerDid]: { [DEFAULT_ABT_TOKEN_ADDRESS]: grossOfferAbt.toString(10) } },
949
949
  mustOwnAssetsAfter: { [offer.buyerDid]: [sticker.stickerDid] },
950
950
  strictZeroUnlistedOutflow: true
951
951
  };
@@ -1208,7 +1208,7 @@ var OcapSuperSuitesFoundationEngine = class {
1208
1208
  if (senderRefundAbt + recipientNetAbt + referrerAbt + protocolFeeAbt + spamSinkAbt !== stamp.stampAmountAbt) throw new _ocap_util_lib_error.CustomError(ErrorCode.ConservationViolation, "AttentionStamp resolution violated ABT conservation");
1209
1209
  const postConditions = {
1210
1210
  signer: stampId,
1211
- maxTokenOutflow: { [DEFAULT_ABT_TOKEN_ADDRESS]: stamp.stampAmountAbt.toString(10) },
1211
+ maxTokenOutflow: { [stampId]: { [DEFAULT_ABT_TOKEN_ADDRESS]: stamp.stampAmountAbt.toString(10) } },
1212
1212
  strictZeroUnlistedOutflow: true
1213
1213
  };
1214
1214
  return {