@ocap/tx-pipeline 1.31.5 → 1.31.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/bridge-release-keys.d.mts +17 -1
- package/esm/bridge-release-keys.mjs +35 -20
- package/esm/bridge-reserves.d.mts +48 -9
- package/esm/bridge-reserves.mjs +66 -16
- package/esm/helpers/bridge-withdraw.d.mts +22 -38
- package/esm/helpers/bridge-withdraw.mjs +57 -77
- package/esm/helpers/replay-guard.d.mts +29 -12
- package/esm/helpers/replay-guard.mjs +68 -22
- package/esm/index.d.mts +3 -3
- package/esm/index.mjs +3 -3
- package/esm/legacy-protocol-sunset.d.mts +35 -21
- package/esm/legacy-protocol-sunset.mjs +124 -70
- package/esm/legacy-rollup-archive.d.mts +44 -7
- package/esm/legacy-rollup-archive.mjs +78 -13
- package/esm/library.d.mts +3 -3
- package/esm/library.mjs +3 -3
- package/esm/pipes/bridge-release-gate.d.mts +3 -2
- package/esm/pipes/bridge-release-gate.mjs +90 -35
- package/esm/pipes/bridge-reserve-v2-gate.d.mts +2 -0
- package/esm/pipes/bridge-reserve-v2-gate.mjs +31 -13
- package/esm/pipes/decode-tx.mjs +1 -1
- package/esm/pipes/post-execution-invariant-gate.mjs +5 -4
- package/esm/pipes/pre-flight-waf.mjs +6 -3
- package/esm/pipes/verify-multisig-v2.mjs +1 -1
- package/esm/pipes/verify-multisig.mjs +1 -1
- package/esm/pipes/verify-tx-size.mjs +8 -2
- package/esm/pipes/verify-tx.mjs +1 -1
- package/esm/transaction-block.mjs +11 -0
- package/lib/bridge-release-keys.cjs +35 -18
- package/lib/bridge-release-keys.d.cts +17 -1
- package/lib/bridge-reserves.cjs +73 -18
- package/lib/bridge-reserves.d.cts +48 -9
- package/lib/helpers/bridge-withdraw.cjs +60 -80
- package/lib/helpers/bridge-withdraw.d.cts +22 -38
- package/lib/helpers/replay-guard.cjs +64 -17
- package/lib/helpers/replay-guard.d.cts +29 -12
- package/lib/index.cjs +2 -2
- package/lib/index.d.cts +3 -3
- package/lib/legacy-protocol-sunset.cjs +122 -69
- package/lib/legacy-protocol-sunset.d.cts +35 -21
- package/lib/legacy-rollup-archive.cjs +82 -14
- package/lib/legacy-rollup-archive.d.cts +44 -7
- package/lib/library.cjs +1 -2
- package/lib/library.d.cts +3 -3
- package/lib/pipes/bridge-release-gate.cjs +89 -33
- package/lib/pipes/bridge-release-gate.d.cts +3 -2
- package/lib/pipes/bridge-reserve-v2-gate.cjs +30 -12
- package/lib/pipes/bridge-reserve-v2-gate.d.cts +2 -0
- package/lib/pipes/decode-tx.cjs +1 -1
- package/lib/pipes/post-execution-invariant-gate.cjs +3 -2
- package/lib/pipes/pre-flight-waf.cjs +6 -3
- package/lib/pipes/verify-multisig-v2.cjs +1 -1
- package/lib/pipes/verify-multisig.cjs +1 -1
- package/lib/pipes/verify-tx-size.cjs +8 -2
- package/lib/pipes/verify-tx.cjs +1 -1
- package/lib/transaction-block.cjs +11 -0
- package/package.json +10 -10
|
@@ -11,23 +11,40 @@ import { parseNonceBn } from "@ocap/state";
|
|
|
11
11
|
* deduplication and `nonce > 0` for replay protection.
|
|
12
12
|
*/
|
|
13
13
|
declare function isCanonicalPasskeyExtra(extra: string): boolean;
|
|
14
|
+
type WithdrawExpectation = {
|
|
15
|
+
bridge: string;
|
|
16
|
+
amount: string;
|
|
17
|
+
token: string;
|
|
18
|
+
ethRecipient: string;
|
|
19
|
+
};
|
|
14
20
|
/**
|
|
15
21
|
* Clear-signing expectation for a wallet envelope (#1465, bridge/docs/ocap-protocols.md §2, §v2.4).
|
|
16
22
|
*
|
|
17
|
-
* Returns the decoded `{ bridge, amount, token, ethRecipient }` when the tx is a
|
|
18
|
-
*
|
|
19
|
-
* itx is not even shaped like one (other tokens, assets, missing recipient), or whose reserve maps to no bridge, returns
|
|
20
|
-
* empty fields, which no envelope can match: the withdraw rule rejects it anyway, this keeps the signature stage from
|
|
21
|
-
* blessing it first.
|
|
23
|
+
* Returns the decoded `{ bridge, amount, token, ethRecipient }` when the tx is a bridge withdraw (`withdraw_token_v2` into
|
|
24
|
+
* a v2 bridge, `getWithdrawTokenV2EnvelopeContext`, fail closed) and `null` for every other tx.
|
|
22
25
|
*/
|
|
23
26
|
declare function getBridgeWithdrawEnvelopeContext(context: {
|
|
24
27
|
txType?: string;
|
|
25
28
|
itx?: unknown;
|
|
26
|
-
}): Promise<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
}): Promise<WithdrawExpectation | null>;
|
|
30
|
+
/**
|
|
31
|
+
* §2.4 step 6: inside the bridge branch, check the wallet envelope again against the bridge row read by THIS execution.
|
|
32
|
+
* The signature stage may have run on a pre-flight snapshot (execute.ts skips VerifySignature then), with a row read
|
|
33
|
+
* outside the transaction. Returns an error message, or null when there is no wallet envelope or it matches. The
|
|
34
|
+
* signature itself was verified over `extra` by VerifySignature; only the shown fields are compared here.
|
|
35
|
+
*/
|
|
36
|
+
declare function assertBridgeWithdrawEnvelopeInBranch(context: {
|
|
37
|
+
tx?: {
|
|
38
|
+
from?: string;
|
|
39
|
+
delegator?: string;
|
|
40
|
+
pk?: string;
|
|
41
|
+
chainId?: string;
|
|
42
|
+
nonce?: unknown;
|
|
43
|
+
} | null;
|
|
44
|
+
txType?: string;
|
|
45
|
+
extra?: {
|
|
46
|
+
txExtra?: unknown;
|
|
47
|
+
} | null;
|
|
48
|
+
}, withdraw: WithdrawExpectation): string | null;
|
|
32
49
|
//#endregion
|
|
33
|
-
export { assertEnvelopeMatchesTxContext, getBridgeWithdrawEnvelopeContext, isCanonicalPasskeyExtra, isCanonicalWalletEnvelopeExtra, parseNonceBn };
|
|
50
|
+
export { assertBridgeWithdrawEnvelopeInBranch, assertEnvelopeMatchesTxContext, getBridgeWithdrawEnvelopeContext, isCanonicalPasskeyExtra, isCanonicalWalletEnvelopeExtra, parseNonceBn };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { assertEnvelopeMatchesTxContext, isCanonicalWalletEnvelopeExtra } from "@ocap/mcrypto";
|
|
4
|
-
import {
|
|
1
|
+
import { BRIDGE_WITHDRAW_V2_TX_TYPE, stripTxTypePrefix } from "../bridge-reserves.mjs";
|
|
2
|
+
import { decodeBridgeWithdrawV2Fields } from "./bridge-withdraw.mjs";
|
|
3
|
+
import { assertEnvelopeMatchesTxContext, isCanonicalWalletEnvelopeExtra, types } from "@ocap/mcrypto";
|
|
4
|
+
import { toTypeInfo } from "@arcblock/did";
|
|
5
|
+
import { parseNonceBn, rollup } from "@ocap/state";
|
|
5
6
|
|
|
6
7
|
//#region src/helpers/replay-guard.ts
|
|
7
8
|
/**
|
|
@@ -27,35 +28,80 @@ const WITHDRAW_NONE = {
|
|
|
27
28
|
ethRecipient: ""
|
|
28
29
|
};
|
|
29
30
|
/**
|
|
30
|
-
* Clear-signing expectation
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
31
|
+
* Clear-signing expectation of a `withdraw_token_v2` (#1691, bridge/docs/deposit-withdraw-v2-unification.md §4).
|
|
32
|
+
* Whether it is a withdraw depends on the version of the row `itx.rollup` names, so this reads state, outside the
|
|
33
|
+
* transaction (pre-flight) and possibly from a snapshot that execution later trusts. Fail closed:
|
|
34
|
+
* - `null` (not a withdraw, an ordinary tx) ONLY when the row was read and is a v1 rollup;
|
|
35
|
+
* - a missing `itx.rollup`, a missing row, a read error, or a v2 row that does not decode return empty fields, which
|
|
36
|
+
* no envelope can match. A v1 withdraw to a missing rollup signed with a wallet envelope is therefore rejected at the
|
|
37
|
+
* signature stage (the one difference §2.7 allows); raw-signed v1 withdraws never get here.
|
|
38
|
+
* The bridge branch re-checks the envelope against the row it executes on (`assertBridgeWithdrawEnvelopeInBranch`).
|
|
37
39
|
*/
|
|
38
|
-
async function
|
|
39
|
-
if (String(context.txType || "").replace(/^fg:t:/, "") !== "transfer_v2") return null;
|
|
40
|
+
async function getWithdrawTokenV2EnvelopeContext(context) {
|
|
40
41
|
const itx = context.itx || {};
|
|
41
|
-
if (!itx.to || !isBridgeReserveRole(itx.to)) return null;
|
|
42
42
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
if (typeof itx.rollup !== "string" || !itx.rollup) return { ...WITHDRAW_NONE };
|
|
44
|
+
const row = await context.statedb.rollup.get(itx.rollup, context);
|
|
45
|
+
if (!row) return { ...WITHDRAW_NONE };
|
|
46
|
+
if (!rollup.isBridgeV2(row)) return null;
|
|
47
|
+
if (!rollup.getBridgeBody(row) || typeof row.address !== "string" || row.address !== itx.rollup) return { ...WITHDRAW_NONE };
|
|
48
|
+
const token$1 = typeof row.tokenAddress === "string" ? row.tokenAddress : "";
|
|
49
|
+
const fields = decodeBridgeWithdrawV2Fields(itx, token$1);
|
|
47
50
|
if (!fields) return { ...WITHDRAW_NONE };
|
|
48
51
|
return {
|
|
49
|
-
bridge:
|
|
52
|
+
bridge: row.address,
|
|
50
53
|
amount: fields.amount,
|
|
51
|
-
token:
|
|
54
|
+
token: token$1,
|
|
52
55
|
ethRecipient: fields.ethRecipient
|
|
53
56
|
};
|
|
54
57
|
} catch (err) {
|
|
55
|
-
console.warn(`bridge withdraw envelope expectation failed for ${String(itx.
|
|
58
|
+
console.warn(`bridge withdraw envelope expectation failed for rollup ${String(itx.rollup).slice(0, 12)}...: ${String(err?.message || err).slice(0, 120)}`);
|
|
56
59
|
return { ...WITHDRAW_NONE };
|
|
57
60
|
}
|
|
58
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Clear-signing expectation for a wallet envelope (#1465, bridge/docs/ocap-protocols.md §2, §v2.4).
|
|
64
|
+
*
|
|
65
|
+
* Returns the decoded `{ bridge, amount, token, ethRecipient }` when the tx is a bridge withdraw (`withdraw_token_v2` into
|
|
66
|
+
* a v2 bridge, `getWithdrawTokenV2EnvelopeContext`, fail closed) and `null` for every other tx.
|
|
67
|
+
*/
|
|
68
|
+
async function getBridgeWithdrawEnvelopeContext(context) {
|
|
69
|
+
if (stripTxTypePrefix(context.txType) !== BRIDGE_WITHDRAW_V2_TX_TYPE) return null;
|
|
70
|
+
return getWithdrawTokenV2EnvelopeContext(context);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* §2.4 step 6: inside the bridge branch, check the wallet envelope again against the bridge row read by THIS execution.
|
|
74
|
+
* The signature stage may have run on a pre-flight snapshot (execute.ts skips VerifySignature then), with a row read
|
|
75
|
+
* outside the transaction. Returns an error message, or null when there is no wallet envelope or it matches. The
|
|
76
|
+
* signature itself was verified over `extra` by VerifySignature; only the shown fields are compared here.
|
|
77
|
+
*/
|
|
78
|
+
function assertBridgeWithdrawEnvelopeInBranch(context, withdraw) {
|
|
79
|
+
const tx = context.tx || {};
|
|
80
|
+
const rawTxExtra = context.extra?.txExtra;
|
|
81
|
+
if (typeof rawTxExtra !== "string" || !rawTxExtra) return null;
|
|
82
|
+
const signer = tx.delegator || tx.from;
|
|
83
|
+
if (!signer) return "Bridge withdraw has no signer";
|
|
84
|
+
let type;
|
|
85
|
+
try {
|
|
86
|
+
type = toTypeInfo(signer);
|
|
87
|
+
} catch {
|
|
88
|
+
return "Bridge withdraw signer is not a valid DID";
|
|
89
|
+
}
|
|
90
|
+
if (type.role === types.RoleType.ROLE_PASSKEY || type.pk === types.KeyType.PASSKEY || !isCanonicalWalletEnvelopeExtra(rawTxExtra, type.pk)) return null;
|
|
91
|
+
try {
|
|
92
|
+
assertEnvelopeMatchesTxContext(rawTxExtra, {
|
|
93
|
+
chainId: tx.chainId,
|
|
94
|
+
signer,
|
|
95
|
+
from: tx.from,
|
|
96
|
+
nonce: tx.nonce,
|
|
97
|
+
action: context.txType,
|
|
98
|
+
withdraw
|
|
99
|
+
});
|
|
100
|
+
return null;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
return String(err?.message || err);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
59
105
|
|
|
60
106
|
//#endregion
|
|
61
|
-
export { assertEnvelopeMatchesTxContext, getBridgeWithdrawEnvelopeContext, isCanonicalPasskeyExtra, isCanonicalWalletEnvelopeExtra, parseNonceBn };
|
|
107
|
+
export { assertBridgeWithdrawEnvelopeInBranch, assertEnvelopeMatchesTxContext, getBridgeWithdrawEnvelopeContext, isCanonicalPasskeyExtra, isCanonicalWalletEnvelopeExtra, parseNonceBn };
|
package/esm/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RELEASE_RING_SLOTS, ReleaseRing, formatBucketData, getReleaseBucketKey, getReleaseTombstoneKey, parseBucketData } from "./bridge-release-keys.mjs";
|
|
2
|
-
import { BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES,
|
|
1
|
+
import { RELEASE_RING_SLOTS, ReleaseRing, V1_EVIDENCE_DATA, formatBucketData, getReleaseBucketKey, getReleaseTombstoneKey, isV1EvidenceRow, parseBucketData } from "./bridge-release-keys.mjs";
|
|
2
|
+
import { BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES, BRIDGE_RESERVE_CREDIT_TX_TYPES, BRIDGE_RESERVE_DEBIT_TX_TYPES, BridgeReserveResolution, ReleaseResolution, ResolvedBridge, describeBridge, isBridgeReserveRole, prepareBridgeReserveGate, reserveIndexKey, resolveBridge, resolveBridgeForRelease, resolveBridgeForReserve } from "./bridge-reserves.mjs";
|
|
3
3
|
import { ENCRYPTED_NFT_SCHEMA_VERSION, EncryptedAssetEnvelope, EncryptedNftAlgorithm, EncryptedNftOwnerCipherEnvelope, EncryptedNftPrivateMetadata, EncryptedNftPublicDiscoveryHeader, MAX_ENCRYPTED_NFT_CATEGORY_LENGTH, MAX_ENCRYPTED_NFT_CIPHERTEXT_HEX_CHARS, MAX_ENCRYPTED_NFT_SUMMARY_LENGTH, MAX_ENCRYPTED_NFT_TAGS, MAX_ENCRYPTED_NFT_TAG_LENGTH, MAX_ENCRYPTED_NFT_URI_LENGTH, OpenEncryptedNftAsOwnerInput, OpenEncryptedNftAsOwnerResult, RewrapEncryptedNftForNewOwnerInput, SealEncryptedNftForOwnerInput, VALID_ENCRYPTED_NFT_ALGORITHMS, VerifyEncryptedNftHandoverInput, canonicalizeEncryptedNftMetadata, computeEncryptedNftCekCommitmentHash, computeEncryptedNftPlaintextHash, computeEncryptedNftPublicHeaderAad, deriveOwnerPublicKeyHexFromSecretKey, openEncryptedNftAsOwner, rewrapEncryptedNftForNewOwner, sealEncryptedNftForOwner, validateEncryptedAssetEnvelope, verifyEncryptedNftHandover } from "./encrypted-nft-envelope.mjs";
|
|
4
4
|
import { isCanonicalPasskeyExtra, parseNonceBn } from "./helpers/replay-guard.mjs";
|
|
5
5
|
import PipelineRunner, { ErrorPipeFunction, PipeFunction, PipeNext, PipeOptions } from "./runner.mjs";
|
|
@@ -101,4 +101,4 @@ declare const _default: {
|
|
|
101
101
|
};
|
|
102
102
|
};
|
|
103
103
|
//#endregion
|
|
104
|
-
export { CreateAntiLandAttackPipe as AntiLandAttack, BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES,
|
|
104
|
+
export { CreateAntiLandAttackPipe as AntiLandAttack, BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES, BRIDGE_RESERVE_CREDIT_TX_TYPES, BRIDGE_RESERVE_DEBIT_TX_TYPES, type BridgeReserveResolution, DecodeItx, DecodeTx, ENCRYPTED_NFT_SCHEMA_VERSION, type EncryptedAssetEnvelope, type EncryptedNftAlgorithm, type EncryptedNftOwnerCipherEnvelope, type EncryptedNftPrivateMetadata, type EncryptedNftPublicDiscoveryHeader, type ErrorPipeFunction, CreateExtractReceiverPipe as ExtractReceiver, CreateExtractSignerPipe as ExtractSigner, CreateExtractStatePipe as ExtractState, type IAccountUpdate, type IBaseContext, type IDecodedContext, type IDecodedTransaction, type IExecutedContext, type IGasContext, type IReadyContext, type IStateWriteTracker, type ITxOnlyContext, type IWithAsset, type IWithAssets, type IWithDelegation, type IWithDelegator, type IWithEvidence, type IWithFactory, type IWithLocked, type IWithOwner, type IWithReceiver, type IWithRollup, type IWithRollupBlock, type IWithSender, type IWithStake, type IWithStakes, type IWithToken, type IWithTokenFactory, type IWithTokens, MAX_DELEGATE_TYPE_URLS_LIST_SIZE, MAX_ENCRYPTED_NFT_CATEGORY_LENGTH, MAX_ENCRYPTED_NFT_CIPHERTEXT_HEX_CHARS, MAX_ENCRYPTED_NFT_SUMMARY_LENGTH, MAX_ENCRYPTED_NFT_TAGS, MAX_ENCRYPTED_NFT_TAG_LENGTH, MAX_ENCRYPTED_NFT_URI_LENGTH, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, MAX_PREFLIGHT_STRING_FIELD_BYTES, MAX_PREFLIGHT_WIRE_BYTES_FALLBACK, MAX_ROLLUP_TXS_LIST_SIZE, type OpenEncryptedNftAsOwnerInput, type OpenEncryptedNftAsOwnerResult, type PipeFunction, type PipeNext, type PipeOptions, CreatePostExecutionInvariantGatePipe as PostExecutionInvariantGate, PreFlightWaf, RELEASE_RING_SLOTS, type ReleaseResolution, type ReleaseRing, type ResolvedBridge, type RewrapEncryptedNftForNewOwnerInput, PipelineRunner as Runner, type SealEncryptedNftForOwnerInput, TRACKED_STATE_TABLES, type TTransactionReceipt, CreateTakeStateSnapshotPipe as TakeStateSnapshot, type TrackedStateTable, CreateUpdateOwnerPipe as UpdateOwner, V1_EVIDENCE_DATA, VALID_ENCRYPTED_NFT_ALGORITHMS, CreateVerifyAccountMigrationPipe as VerifyAccountMigration, CreatedVerifyBlockedPipe as VerifyBlocked, CreateVerifyDelegationPipe as VerifyDelegation, type VerifyEncryptedNftHandoverInput, CreateVerifyInfoPipe as VerifyInfo, CreateVerifyListSizePipe as VerifyListSize, CreateVerifyMultiSigPipe as VerifyMultiSig, CreateVerifyMultiSigV2Pipe as VerifyMultiSigV2, CreateVerifySenderPipe as VerifySender, VerifyServiceFee, VerifySignature, CreateVerifySignerPipe as VerifySigner, CreateVerifyStateDiffPipe as VerifyStateDiff, CreateVerifyTokenBalancePipe as VerifyTokenBalance, CreateVerifyTransferrablePipe as VerifyTransferrable, VerifyTx, CreateVerifyTxInputPipe as VerifyTxInput, VerifyTxSize, CreateVerifyUpdaterPipe as VerifyUpdater, assertKnownItxFields, assertRawWireEnvelope, canonicalizeEncryptedNftMetadata, computeEncryptedNftCekCommitmentHash, computeEncryptedNftPlaintextHash, computeEncryptedNftPublicHeaderAad, _default as default, deriveOwnerPublicKeyHexFromSecretKey, describeBridge, formatBucketData, getReleaseBucketKey, getReleaseTombstoneKey, groupStatesByAddress, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, isBridgeReserveRole, isCanonicalPasskeyExtra, isDelegationSufficient, isV1EvidenceRow, normalizeEntityKey, openEncryptedNftAsOwner, parseBucketData, parseNonceBn, pipes, prepareBridgeReserveGate, reserveIndexKey, resolveBridge, resolveBridgeForRelease, resolveBridgeForReserve, rewrapEncryptedNftForNewOwner, rollbackTrackedStateWrites, scanItxPayloadAnomalies, sealEncryptedNftForOwner, validateEncryptedAssetEnvelope, verifyAssetHierarchy, verifyEncryptedNftHandover, verifyImplicitAssetOwnership, CreateVerifyTokenAccessPipe as verifyTokenAccess };
|
package/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RELEASE_RING_SLOTS, formatBucketData, getReleaseBucketKey, getReleaseTombstoneKey, parseBucketData } from "./bridge-release-keys.mjs";
|
|
2
|
-
import { BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES,
|
|
1
|
+
import { RELEASE_RING_SLOTS, V1_EVIDENCE_DATA, formatBucketData, getReleaseBucketKey, getReleaseTombstoneKey, isV1EvidenceRow, parseBucketData } from "./bridge-release-keys.mjs";
|
|
2
|
+
import { BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES, BRIDGE_RESERVE_CREDIT_TX_TYPES, BRIDGE_RESERVE_DEBIT_TX_TYPES, describeBridge, isBridgeReserveRole, prepareBridgeReserveGate, reserveIndexKey, resolveBridge, resolveBridgeForRelease, resolveBridgeForReserve } from "./bridge-reserves.mjs";
|
|
3
3
|
import { ENCRYPTED_NFT_SCHEMA_VERSION, MAX_ENCRYPTED_NFT_CATEGORY_LENGTH, MAX_ENCRYPTED_NFT_CIPHERTEXT_HEX_CHARS, MAX_ENCRYPTED_NFT_SUMMARY_LENGTH, MAX_ENCRYPTED_NFT_TAGS, MAX_ENCRYPTED_NFT_TAG_LENGTH, MAX_ENCRYPTED_NFT_URI_LENGTH, VALID_ENCRYPTED_NFT_ALGORITHMS, canonicalizeEncryptedNftMetadata, computeEncryptedNftCekCommitmentHash, computeEncryptedNftPlaintextHash, computeEncryptedNftPublicHeaderAad, deriveOwnerPublicKeyHexFromSecretKey, openEncryptedNftAsOwner, rewrapEncryptedNftForNewOwner, sealEncryptedNftForOwner, validateEncryptedAssetEnvelope, verifyEncryptedNftHandover } from "./encrypted-nft-envelope.mjs";
|
|
4
4
|
import { isCanonicalPasskeyExtra, parseNonceBn } from "./helpers/replay-guard.mjs";
|
|
5
5
|
import CreateAntiLandAttackPipe from "./pipes/anti-land-attack.mjs";
|
|
@@ -71,4 +71,4 @@ var src_default = {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
//#endregion
|
|
74
|
-
export { CreateAntiLandAttackPipe as AntiLandAttack, BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES,
|
|
74
|
+
export { CreateAntiLandAttackPipe as AntiLandAttack, BRIDGE_MAX_MIGRATION_HOPS, BRIDGE_RECONCILE_TX_TYPES, BRIDGE_RESERVE_CREDIT_TX_TYPES, BRIDGE_RESERVE_DEBIT_TX_TYPES, DecodeItx, DecodeTx, ENCRYPTED_NFT_SCHEMA_VERSION, CreateExtractReceiverPipe as ExtractReceiver, CreateExtractSignerPipe as ExtractSigner, CreateExtractStatePipe as ExtractState, MAX_DELEGATE_TYPE_URLS_LIST_SIZE, MAX_ENCRYPTED_NFT_CATEGORY_LENGTH, MAX_ENCRYPTED_NFT_CIPHERTEXT_HEX_CHARS, MAX_ENCRYPTED_NFT_SUMMARY_LENGTH, MAX_ENCRYPTED_NFT_TAGS, MAX_ENCRYPTED_NFT_TAG_LENGTH, MAX_ENCRYPTED_NFT_URI_LENGTH, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, MAX_PREFLIGHT_STRING_FIELD_BYTES, MAX_PREFLIGHT_WIRE_BYTES_FALLBACK, MAX_ROLLUP_TXS_LIST_SIZE, post_execution_invariant_gate_default as PostExecutionInvariantGate, PreFlightWaf, RELEASE_RING_SLOTS, runner_default as Runner, TRACKED_STATE_TABLES, CreateTakeStateSnapshotPipe as TakeStateSnapshot, CreateUpdateOwnerPipe as UpdateOwner, V1_EVIDENCE_DATA, VALID_ENCRYPTED_NFT_ALGORITHMS, CreateVerifyAccountMigrationPipe as VerifyAccountMigration, CreatedVerifyBlockedPipe as VerifyBlocked, CreateVerifyDelegationPipe as VerifyDelegation, CreateVerifyInfoPipe as VerifyInfo, CreateVerifyListSizePipe as VerifyListSize, CreateVerifyMultiSigPipe as VerifyMultiSig, CreateVerifyMultiSigV2Pipe as VerifyMultiSigV2, CreateVerifySenderPipe as VerifySender, VerifyServiceFee, VerifySignature, CreateVerifySignerPipe as VerifySigner, CreateVerifyStateDiffPipe as VerifyStateDiff, CreateVerifyTokenBalancePipe as VerifyTokenBalance, CreateVerifyTransferrablePipe as VerifyTransferrable, VerifyTx, CreateVerifyTxInputPipe as VerifyTxInput, VerifyTxSize, CreateVerifyUpdaterPipe as VerifyUpdater, assertKnownItxFields, assertRawWireEnvelope, canonicalizeEncryptedNftMetadata, computeEncryptedNftCekCommitmentHash, computeEncryptedNftPlaintextHash, computeEncryptedNftPublicHeaderAad, src_default as default, deriveOwnerPublicKeyHexFromSecretKey, describeBridge, formatBucketData, getReleaseBucketKey, getReleaseTombstoneKey, groupStatesByAddress, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, isBridgeReserveRole, isCanonicalPasskeyExtra, isDelegationSufficient, isV1EvidenceRow, normalizeEntityKey, openEncryptedNftAsOwner, parseBucketData, parseNonceBn, pipes, prepareBridgeReserveGate, reserveIndexKey, resolveBridge, resolveBridgeForRelease, resolveBridgeForReserve, rewrapEncryptedNftForNewOwner, rollbackTrackedStateWrites, scanItxPayloadAnomalies, sealEncryptedNftForOwner, validateEncryptedAssetEnvelope, verifyAssetHierarchy, verifyEncryptedNftHandover, verifyImplicitAssetOwnership, CreateVerifyTokenAccessPipe as verifyTokenAccess };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { LegacyRollupReadOnlySummary } from "./legacy-rollup-archive.mjs";
|
|
1
|
+
import { LegacyRollupReadOnlySummary, RollupBranchInfo, RollupBranchResolver } from "./legacy-rollup-archive.mjs";
|
|
2
2
|
import { StatementExecutor, TransactionBlockInput, TransactionBlockResult } from "./transaction-block.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/legacy-protocol-sunset.d.ts
|
|
5
|
-
declare const DEFAULT_LEGACY_PROTOCOL_SUNSET_HEIGHT = 1;
|
|
6
5
|
declare const MAX_LEGACY_MIOTX_PARTICIPANTS = 64;
|
|
7
6
|
declare const MAX_LEGACY_MIOTX_TOKENS_PER_ENTRY = 32;
|
|
8
7
|
declare const MAX_LEGACY_MIOTX_ASSETS_PER_ENTRY = 64;
|
|
@@ -23,7 +22,7 @@ declare const DEPRECATED_VERSIONED_ASSET_TYPE_URLS: readonly ["fg:t:acquire_asse
|
|
|
23
22
|
declare const DEPRECATED_ROLLUP_AND_BRIDGE_TYPE_URLS: readonly ["fg:t:create_rollup", "fg:t:update_rollup", "fg:t:join_rollup", "fg:t:leave_rollup", "fg:t:create_rollup_block", "fg:t:claim_block_reward", "fg:t:pause_rollup", "fg:t:resume_rollup", "fg:t:close_rollup", "fg:t:migrate_rollup", "fg:t:deposit_token", "fg:t:deposit_token_v2", "fg:t:withdraw_token", "fg:t:withdraw_token_v2", "fg:t:revoke_withdraw"];
|
|
24
23
|
/**
|
|
25
24
|
* Complete list of all 27 deprecated legacy `V1/V2/V3`, `miotx`, and Rollup write protocols
|
|
26
|
-
* frozen into `READ_ONLY_LEGACY_ARCHIVE` mode
|
|
25
|
+
* frozen into `READ_ONLY_LEGACY_ARCHIVE` mode once the sunset is switched on.
|
|
27
26
|
*/
|
|
28
27
|
declare const DEPRECATED_LEGACY_PROTOCOL_TYPE_URLS: readonly ["fg:t:transfer_v2", "fg:t:transfer_v3", "fg:t:exchange", "fg:t:exchange_v2", "fg:t:setup_swap", "fg:t:retrieve_swap", "fg:t:revoke_swap", "fg:t:acquire_asset_v2", "fg:t:acquire_asset_v3", "fg:t:mint_asset_v2", "fg:t:update_asset_v2", "fg:t:create_factory_v2", "fg:t:create_rollup", "fg:t:update_rollup", "fg:t:join_rollup", "fg:t:leave_rollup", "fg:t:create_rollup_block", "fg:t:claim_block_reward", "fg:t:pause_rollup", "fg:t:resume_rollup", "fg:t:close_rollup", "fg:t:migrate_rollup", "fg:t:deposit_token", "fg:t:deposit_token_v2", "fg:t:withdraw_token", "fg:t:withdraw_token_v2", "fg:t:revoke_withdraw"];
|
|
29
28
|
/**
|
|
@@ -93,14 +92,23 @@ declare function resolveDomainAgnosticVNextProtocol(typeUrl: string): VNextCanon
|
|
|
93
92
|
declare function getLegacyProtocolReplacementSpec(typeUrl: string): LegacyProtocolReplacementSpec | null;
|
|
94
93
|
/**
|
|
95
94
|
* Active Write Pipeline Sunset Gate (`assertLegacyProtocolNotSunset`):
|
|
96
|
-
* - When `readOnlyArchiveMode === true
|
|
97
|
-
* -
|
|
98
|
-
*
|
|
95
|
+
* - When `readOnlyArchiveMode === true`, allows historical read/replay.
|
|
96
|
+
* - Otherwise fails closed (`FORBIDDEN_LEGACY_PROTOCOL_SUNSET`) on all 27 deprecated `V1/V2/V3`, `miotx`, and Rollup
|
|
97
|
+
* write protocols of the v1 branch with actionable VNext migration guidance.
|
|
98
|
+
*
|
|
99
|
+
* #1720 (S4b, bridge/docs/deposit-withdraw-v2-unification.md §7.1): `branch` is required (missing throws, whatever the
|
|
100
|
+
* type) and the blockHeight parameters are gone (CHAIN_DESIGN §1 item 2): the sunset is switched on by wiring the guard
|
|
101
|
+
* (or the add-on's `SUNSET_READ_ONLY_ARCHIVE` mode), not by a height.
|
|
99
102
|
*/
|
|
100
103
|
declare function assertLegacyProtocolNotSunset(params: {
|
|
101
104
|
typeUrl: string;
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
/**
|
|
106
|
+
* #1692 (bridge/docs/deposit-withdraw-v2-unification.md §7.1): the branch of a `deposit_token_v2` / `withdraw_token_v2`
|
|
107
|
+
* / rollup governance tx (`rollupBranchOf(row itx.rollup names, itx)`). The bridge branch (a deposit with kind 1/2/3
|
|
108
|
+
* or a withdraw on a v2 bridge, bridge governance) reuses the type names, not the retired rollup mechanism: it is
|
|
109
|
+
* never sunset. A tx that names no rollup passes the v1 branch `{ isBridgeV2: false }`.
|
|
110
|
+
*/
|
|
111
|
+
branch: RollupBranchInfo;
|
|
104
112
|
readOnlyArchiveMode?: boolean;
|
|
105
113
|
}): void;
|
|
106
114
|
/**
|
|
@@ -109,8 +117,8 @@ declare function assertLegacyProtocolNotSunset(params: {
|
|
|
109
117
|
* or nested `ContractNFT` `statementTemplates`.
|
|
110
118
|
*/
|
|
111
119
|
declare function assertTransactionBlockVNextPure(block: TransactionBlockInput, options?: {
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
/** #1720 (S4b): the branch of a rollup-family statement; required when the block has one (missing throws) */
|
|
121
|
+
resolveBranch?: RollupBranchResolver;
|
|
114
122
|
requireStrictCanonicalWhitelist?: boolean;
|
|
115
123
|
}): void;
|
|
116
124
|
interface LegacyTokenAmountEntry {
|
|
@@ -145,26 +153,28 @@ interface LegacyTxReadOnlyArchiveSummary {
|
|
|
145
153
|
* and Rollup records into a deeply frozen (`Object.freeze`) read-only archive summary (`mode: 'READ_ONLY_LEGACY_ARCHIVE'`).
|
|
146
154
|
* Enforces strict zero-sum token and asset conservation for historical `transfer_v3` `miotx` records.
|
|
147
155
|
*/
|
|
148
|
-
declare function parseLegacyTxReadOnlyArchiveRecord(rawRecord: Record<string, unknown
|
|
156
|
+
declare function parseLegacyTxReadOnlyArchiveRecord(rawRecord: Record<string, unknown>, /** #1720 (S4b): the branch of the row a rollup record belongs to (`rollupBranchOf`); required for rollup records */
|
|
157
|
+
branch?: RollupBranchInfo): LegacyTxReadOnlyArchiveSummary;
|
|
149
158
|
/**
|
|
150
159
|
* Deterministically compiles any legacy `transfer_v2`, `transfer_v3` (`miotx`), `exchange_v2` (`miotx`),
|
|
151
160
|
* or `acquire_asset_v2` / `acquire_asset_v3` record into a 100% VNext-pure `TransactionBlockInput`
|
|
152
161
|
* containing only versionless atomic statements (`fg:t:transfer`, `fg:t:acquire_asset`) with explicit
|
|
153
162
|
* `readSet` / `writeSet` footprints and zero-sum conservation.
|
|
154
163
|
*/
|
|
155
|
-
declare function compileLegacyTxToVNextTransactionBlock(rawRecord: Record<string, unknown
|
|
164
|
+
declare function compileLegacyTxToVNextTransactionBlock(rawRecord: Record<string, unknown>, /** #1720 (S4b): forwarded to `parseLegacyTxReadOnlyArchiveRecord`; required for rollup records */
|
|
165
|
+
branch?: RollupBranchInfo): {
|
|
156
166
|
archiveSummary: LegacyTxReadOnlyArchiveSummary;
|
|
157
167
|
transactionBlock: TransactionBlockInput;
|
|
158
168
|
};
|
|
159
169
|
/**
|
|
160
170
|
* Executes a VNext `TransactionBlockInput` after enforcing `assertTransactionBlockVNextPure`
|
|
161
|
-
* (guaranteeing no deprecated `V1/V2/V3`, `miotx`, or Rollup protocol
|
|
171
|
+
* (guaranteeing no deprecated `V1/V2/V3`, `miotx`, or Rollup protocol of the v1 branch can execute).
|
|
162
172
|
*/
|
|
163
173
|
declare function executeVNextTransactionBlock(block: TransactionBlockInput, options: {
|
|
164
174
|
statedb: Record<string, any>;
|
|
165
175
|
executeStatement: StatementExecutor;
|
|
166
|
-
|
|
167
|
-
|
|
176
|
+
/** #1720 (S4b): see `assertTransactionBlockVNextPure` */
|
|
177
|
+
resolveBranch?: RollupBranchResolver;
|
|
168
178
|
dryRun?: boolean;
|
|
169
179
|
}): Promise<TransactionBlockResult>;
|
|
170
180
|
type CompatibilityAddonMode = 'ADDON_TRANSLATE_AND_EXECUTE' | 'SUNSET_READ_ONLY_ARCHIVE';
|
|
@@ -206,7 +216,6 @@ interface CompatibilityAddonMetrics {
|
|
|
206
216
|
declare class LegacyProtocolCompatibilityAddon {
|
|
207
217
|
private mode;
|
|
208
218
|
private readonly targetRemovalRelease;
|
|
209
|
-
private readonly sunsetActivationHeight;
|
|
210
219
|
private totalTranslatedTxs;
|
|
211
220
|
private totalPassthroughVNextTxs;
|
|
212
221
|
private rejectedAfterSunsetCount;
|
|
@@ -214,7 +223,6 @@ declare class LegacyProtocolCompatibilityAddon {
|
|
|
214
223
|
constructor(options?: {
|
|
215
224
|
mode?: CompatibilityAddonMode;
|
|
216
225
|
targetRemovalRelease?: string;
|
|
217
|
-
sunsetActivationHeight?: number;
|
|
218
226
|
});
|
|
219
227
|
getMode(): CompatibilityAddonMode;
|
|
220
228
|
setMode(mode: CompatibilityAddonMode): void;
|
|
@@ -228,8 +236,13 @@ declare class LegacyProtocolCompatibilityAddon {
|
|
|
228
236
|
* domain-coupled statement (`contract_nft`, `give_karma`, `claim_karma`, `evm_bridge_settlement`),
|
|
229
237
|
* or `TransactionBlockInput` into a 100% pure, domain-agnostic VNext `TransactionBlockInput`.
|
|
230
238
|
*/
|
|
231
|
-
translateToVNextTransactionBlock(txOrBlock: Record<string, unknown> | TransactionBlockInput,
|
|
232
|
-
|
|
239
|
+
translateToVNextTransactionBlock(txOrBlock: Record<string, unknown> | TransactionBlockInput,
|
|
240
|
+
/**
|
|
241
|
+
* #1720 (S4b): `resolveBranch` gives the branch of each rollup-family statement / record (`rollupBranchOf` of the
|
|
242
|
+
* row `itx.rollup` names); required when there is one (missing throws). No blockHeight: the mode is the switch.
|
|
243
|
+
*/
|
|
244
|
+
options?: {
|
|
245
|
+
resolveBranch?: RollupBranchResolver;
|
|
233
246
|
}): CompatibilityTranslationResult;
|
|
234
247
|
/**
|
|
235
248
|
* End-to-end execution through the Compatibility Add-On Layer:
|
|
@@ -240,7 +253,8 @@ declare class LegacyProtocolCompatibilityAddon {
|
|
|
240
253
|
executeWithCompatibilityAddon(txOrBlock: Record<string, unknown> | TransactionBlockInput, options: {
|
|
241
254
|
statedb: Record<string, any>;
|
|
242
255
|
executeStatement: StatementExecutor;
|
|
243
|
-
|
|
256
|
+
/** #1720 (S4b): see `translateToVNextTransactionBlock` */
|
|
257
|
+
resolveBranch?: RollupBranchResolver;
|
|
244
258
|
dryRun?: boolean;
|
|
245
259
|
}): Promise<{
|
|
246
260
|
executionResult: TransactionBlockResult;
|
|
@@ -248,4 +262,4 @@ declare class LegacyProtocolCompatibilityAddon {
|
|
|
248
262
|
}>;
|
|
249
263
|
}
|
|
250
264
|
//#endregion
|
|
251
|
-
export { CompatibilityAddonMetrics, CompatibilityAddonMode, CompatibilityDeprecationWarning, CompatibilityTranslationResult,
|
|
265
|
+
export { CompatibilityAddonMetrics, CompatibilityAddonMode, CompatibilityDeprecationWarning, CompatibilityTranslationResult, DEPRECATED_LEGACY_PROTOCOL_TYPE_URLS, DEPRECATED_MIOTX_AND_TRADE_TYPE_URLS, DEPRECATED_MIOTX_PROTOCOL_TYPE_URLS, DEPRECATED_ROLLUP_AND_BRIDGE_TYPE_URLS, DEPRECATED_VERSIONED_ASSET_TYPE_URLS, DOMAIN_COUPLED_PROTOCOL_ALIAS_MAP, DeprecatedLegacyProtocolTypeUrl, DomainCoupledProtocolAliasTypeUrl, LegacyMiotxParticipantEntry, LegacyProtocolCompatibilityAddon, LegacyProtocolReplacementSpec, LegacyProtocolSunsetCategory, LegacyTokenAmountEntry, LegacyTxReadOnlyArchiveSummary, MAX_LEGACY_MIOTX_ASSETS_PER_ENTRY, MAX_LEGACY_MIOTX_PARTICIPANTS, MAX_LEGACY_MIOTX_TOKENS_PER_ENTRY, VNEXT_CANONICAL_WRITE_PROTOCOL_TYPE_URLS, VNextCanonicalWriteProtocolTypeUrl, assertLegacyProtocolNotSunset, assertTransactionBlockVNextPure, compileLegacyTxToVNextTransactionBlock, executeVNextTransactionBlock, getLegacyProtocolReplacementSpec, isDeprecatedLegacyWriteProtocol, isDomainCoupledProtocolAlias, isMiotxLegacyProtocol, isVNextCanonicalWriteProtocol, normalizeProtocolTypeUrl, parseLegacyTxReadOnlyArchiveRecord, resolveDomainAgnosticVNextProtocol };
|