@ocap/tx-protocols 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.
- package/esm/bridge-release-crypto.d.mts +39 -0
- package/esm/bridge-release-crypto.mjs +88 -0
- package/esm/bridge-release-window.d.mts +47 -0
- package/esm/bridge-release-window.mjs +62 -0
- package/esm/bridge-reserve.d.mts +24 -0
- package/esm/bridge-reserve.mjs +41 -0
- package/esm/execute.d.mts +5 -3
- package/esm/execute.mjs +593 -21
- package/esm/gas-security-guard.d.mts +7 -2
- package/esm/gas-security-guard.mjs +25 -16
- package/esm/index.d.mts +38 -19
- package/esm/index.mjs +7 -3
- package/esm/pipes/ensure-cost.mjs +36 -10
- package/esm/pipes/write-ledger.d.mts +2 -2
- package/esm/pipes/write-ledger.mjs +6 -3
- package/esm/protocols/account/delegate.mjs +6 -4
- package/esm/protocols/account/migrate.mjs +5 -3
- package/esm/protocols/account/revoke-delegate.mjs +5 -3
- package/esm/protocols/asset/acquire-v2.mjs +3 -1
- package/esm/protocols/asset/acquire-v3.mjs +4 -2
- package/esm/protocols/asset/consume.mjs +3 -1
- package/esm/protocols/asset/create.mjs +4 -2
- package/esm/protocols/asset/mint.mjs +4 -2
- package/esm/protocols/asset/pipes/exec-mint-hook.mjs +1 -1
- package/esm/protocols/asset/pipes/verify-itx-address.mjs +1 -1
- package/esm/protocols/asset/pipes/verify-itx-assets.mjs +1 -1
- package/esm/protocols/asset/update.mjs +4 -2
- package/esm/protocols/bridge/release.d.mts +34 -0
- package/esm/protocols/bridge/release.mjs +385 -0
- package/esm/protocols/factory/create.mjs +4 -2
- package/esm/protocols/governance/claim-stake.mjs +35 -11
- package/esm/protocols/governance/return-stake.mjs +4 -2
- package/esm/protocols/governance/revoke-ledger.d.mts +34 -0
- package/esm/protocols/governance/revoke-ledger.mjs +179 -0
- package/esm/protocols/governance/revoke-stake.d.mts +7 -2
- package/esm/protocols/governance/revoke-stake.mjs +58 -29
- package/esm/protocols/governance/slash-stake.mjs +14 -4
- package/esm/protocols/governance/stake.mjs +6 -4
- package/esm/protocols/rollup/bridge-create.d.mts +13 -0
- package/esm/protocols/rollup/bridge-create.mjs +206 -0
- package/esm/protocols/rollup/bridge-membership.d.mts +10 -0
- package/esm/protocols/rollup/bridge-membership.mjs +154 -0
- package/esm/protocols/rollup/bridge-migrate.d.mts +10 -0
- package/esm/protocols/rollup/bridge-migrate.mjs +208 -0
- package/esm/protocols/rollup/bridge-v2.d.mts +113 -0
- package/esm/protocols/rollup/bridge-v2.mjs +219 -0
- package/esm/protocols/rollup/claim-reward.mjs +4 -2
- package/esm/protocols/rollup/close.d.mts +2 -1
- package/esm/protocols/rollup/close.mjs +59 -6
- package/esm/protocols/rollup/create-block.mjs +4 -2
- package/esm/protocols/rollup/create.d.mts +3 -0
- package/esm/protocols/rollup/create.mjs +45 -6
- package/esm/protocols/rollup/join.d.mts +2 -1
- package/esm/protocols/rollup/join.mjs +31 -23
- package/esm/protocols/rollup/leave.d.mts +2 -1
- package/esm/protocols/rollup/leave.mjs +32 -24
- package/esm/protocols/rollup/migrate.d.mts +2 -1
- package/esm/protocols/rollup/migrate.mjs +19 -10
- package/esm/protocols/rollup/pause.d.mts +4 -1
- package/esm/protocols/rollup/pause.mjs +50 -6
- package/esm/protocols/rollup/pipes/verify-evidence.mjs +2 -2
- package/esm/protocols/rollup/resume.d.mts +2 -1
- package/esm/protocols/rollup/resume.mjs +26 -6
- package/esm/protocols/rollup/update.d.mts +5 -1
- package/esm/protocols/rollup/update.mjs +56 -9
- package/esm/protocols/token/create.mjs +4 -2
- package/esm/protocols/token/deposit-v2.mjs +5 -3
- package/esm/protocols/token/withdraw-v2.mjs +5 -3
- package/esm/protocols/token-factory/burn.mjs +4 -2
- package/esm/protocols/token-factory/create.mjs +8 -4
- package/esm/protocols/token-factory/mint.mjs +4 -2
- package/esm/protocols/token-factory/update.mjs +20 -5
- package/esm/protocols/trade/exchange-v2.d.mts +5 -1
- package/esm/protocols/trade/exchange-v2.mjs +89 -4
- package/esm/protocols/trade/transfer-v2.mjs +15 -4
- package/esm/protocols/trade/transfer-v3.mjs +5 -3
- package/esm/stateless-prefix.d.mts +16 -0
- package/esm/stateless-prefix.mjs +82 -0
- package/esm/tx-timer.d.mts +1 -1
- package/esm/tx-timer.mjs +1 -1
- package/esm/util.mjs +2 -2
- package/lib/bridge-release-crypto.cjs +93 -0
- package/lib/bridge-release-crypto.d.cts +39 -0
- package/lib/bridge-release-window.cjs +69 -0
- package/lib/bridge-release-window.d.cts +47 -0
- package/lib/bridge-reserve.cjs +45 -0
- package/lib/bridge-reserve.d.cts +24 -0
- package/lib/execute.cjs +594 -19
- package/lib/execute.d.cts +4 -2
- package/lib/gas-security-guard.cjs +25 -16
- package/lib/gas-security-guard.d.cts +7 -2
- package/lib/index.cjs +10 -1
- package/lib/index.d.cts +37 -18
- package/lib/pipes/ensure-cost.cjs +37 -11
- package/lib/pipes/write-ledger.cjs +6 -3
- package/lib/pipes/write-ledger.d.cts +2 -2
- package/lib/protocols/account/delegate.cjs +6 -4
- package/lib/protocols/account/migrate.cjs +5 -3
- package/lib/protocols/account/revoke-delegate.cjs +5 -3
- package/lib/protocols/asset/acquire-v2.cjs +3 -1
- package/lib/protocols/asset/acquire-v3.cjs +4 -2
- package/lib/protocols/asset/consume.cjs +3 -1
- package/lib/protocols/asset/create.cjs +4 -2
- package/lib/protocols/asset/mint.cjs +4 -2
- package/lib/protocols/asset/pipes/exec-mint-hook.cjs +1 -1
- package/lib/protocols/asset/pipes/verify-itx-address.cjs +1 -1
- package/lib/protocols/asset/pipes/verify-itx-assets.cjs +1 -1
- package/lib/protocols/asset/update.cjs +4 -2
- package/lib/protocols/bridge/release.cjs +390 -0
- package/lib/protocols/bridge/release.d.cts +34 -0
- package/lib/protocols/factory/create.cjs +4 -2
- package/lib/protocols/governance/claim-stake.cjs +35 -11
- package/lib/protocols/governance/return-stake.cjs +4 -2
- package/lib/protocols/governance/revoke-ledger.cjs +184 -0
- package/lib/protocols/governance/revoke-ledger.d.cts +34 -0
- package/lib/protocols/governance/revoke-stake.cjs +58 -29
- package/lib/protocols/governance/revoke-stake.d.cts +7 -2
- package/lib/protocols/governance/slash-stake.cjs +14 -4
- package/lib/protocols/governance/stake.cjs +6 -4
- package/lib/protocols/rollup/bridge-create.cjs +209 -0
- package/lib/protocols/rollup/bridge-create.d.cts +13 -0
- package/lib/protocols/rollup/bridge-membership.cjs +157 -0
- package/lib/protocols/rollup/bridge-membership.d.cts +10 -0
- package/lib/protocols/rollup/bridge-migrate.cjs +212 -0
- package/lib/protocols/rollup/bridge-migrate.d.cts +10 -0
- package/lib/protocols/rollup/bridge-v2.cjs +244 -0
- package/lib/protocols/rollup/bridge-v2.d.cts +113 -0
- package/lib/protocols/rollup/claim-reward.cjs +4 -2
- package/lib/protocols/rollup/close.cjs +59 -6
- package/lib/protocols/rollup/close.d.cts +2 -1
- package/lib/protocols/rollup/create-block.cjs +4 -2
- package/lib/protocols/rollup/create.cjs +45 -6
- package/lib/protocols/rollup/create.d.cts +3 -0
- package/lib/protocols/rollup/join.cjs +31 -23
- package/lib/protocols/rollup/join.d.cts +2 -1
- package/lib/protocols/rollup/leave.cjs +32 -24
- package/lib/protocols/rollup/leave.d.cts +2 -1
- package/lib/protocols/rollup/migrate.cjs +19 -10
- package/lib/protocols/rollup/migrate.d.cts +2 -1
- package/lib/protocols/rollup/pause.cjs +50 -6
- package/lib/protocols/rollup/pause.d.cts +4 -1
- package/lib/protocols/rollup/pipes/verify-evidence.cjs +2 -2
- package/lib/protocols/rollup/resume.cjs +26 -6
- package/lib/protocols/rollup/resume.d.cts +2 -1
- package/lib/protocols/rollup/update.cjs +56 -9
- package/lib/protocols/rollup/update.d.cts +5 -1
- package/lib/protocols/token/create.cjs +4 -2
- package/lib/protocols/token/deposit-v2.cjs +5 -3
- package/lib/protocols/token/withdraw-v2.cjs +5 -3
- package/lib/protocols/token-factory/burn.cjs +4 -2
- package/lib/protocols/token-factory/create.cjs +8 -4
- package/lib/protocols/token-factory/mint.cjs +4 -2
- package/lib/protocols/token-factory/update.cjs +20 -5
- package/lib/protocols/trade/exchange-v2.cjs +90 -3
- package/lib/protocols/trade/exchange-v2.d.cts +5 -1
- package/lib/protocols/trade/transfer-v2.cjs +15 -4
- package/lib/protocols/trade/transfer-v3.cjs +5 -3
- package/lib/stateless-prefix.cjs +88 -0
- package/lib/stateless-prefix.d.cts +16 -0
- package/lib/tx-timer.cjs +1 -1
- package/lib/tx-timer.d.cts +1 -1
- package/lib/util.cjs +2 -2
- package/package.json +16 -16
- package/tools/fixtures.ts +9 -4
|
@@ -18,7 +18,7 @@ declare const DEFAULT_FISHERMAN_BOUNTY_BPS = 1000;
|
|
|
18
18
|
/**
|
|
19
19
|
* High-overhead creator, factory, token-issuance, rollup, and batch transaction types
|
|
20
20
|
* that ALWAYS require direct gas payment (`requiresDirectGas: true`) and cannot waive
|
|
21
|
-
* gas via self-staked `Stake-for-Gas
|
|
21
|
+
* gas via self-staked `Stake-for-Gas`, Unlinkable Gas Pass or a third-party sponsor's stake (#1420).
|
|
22
22
|
*/
|
|
23
23
|
declare const DIRECT_GAS_REQUIRED_TX_TYPES: ReadonlySet<string>;
|
|
24
24
|
/**
|
|
@@ -150,7 +150,11 @@ interface IStakeForGasEligibilityResult {
|
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* 3D `Stake-for-Gas` Eligibility Gate:
|
|
153
|
-
*
|
|
153
|
+
* 0. `txType` must not be in `DIRECT_GAS_REQUIRED_TX_TYPES`. This holds for every stake-based waiver: self
|
|
154
|
+
* stake, gas pass and third-party sponsor stake (#1420). Only an operator-configured
|
|
155
|
+
* `txGas.freeGasAllowedTxTypes` entry can lift it.
|
|
156
|
+
* 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only). Third-party sponsors are
|
|
157
|
+
* exempt from this allowlist unless `enforceSponsor3DEligibility` is on.
|
|
154
158
|
* 2. `txSize` must be <= `maxFreeGasTxSize` (default 4096 bytes).
|
|
155
159
|
* 3. `stateOps` (`estimate.create + estimate.update`) must be <= `maxFreeGasStateOps` (default 6).
|
|
156
160
|
* 4. Failed transactions (`isFailedTxGasCharge === true`) NEVER waive gas.
|
|
@@ -222,6 +226,7 @@ declare function verifyAndConsumeUnlinkableGasPass(params: {
|
|
|
222
226
|
nowMs?: number;
|
|
223
227
|
config: IChainConfig;
|
|
224
228
|
statedb?: unknown;
|
|
229
|
+
consumeNullifier?: boolean;
|
|
225
230
|
}): {
|
|
226
231
|
valid: boolean;
|
|
227
232
|
reason?: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isFromPublicKey, toTypeInfo } from "@arcblock/did";
|
|
2
|
-
import { toStakeAddress } from "@arcblock/did-util";
|
|
3
1
|
import { getHasher, getSigner } from "@ocap/mcrypto";
|
|
4
|
-
import { account, evidence, parseNonceBn, stake } from "@ocap/state";
|
|
5
2
|
import { pipes } from "@ocap/tx-pipeline";
|
|
6
|
-
import { BN, fromTokenToUnit, isSameDid, toAddress as toAddress$1 } from "@ocap/util";
|
|
7
3
|
import { CustomError } from "@ocap/util/lib/error";
|
|
8
4
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
5
|
+
import { isFromPublicKey, toTypeInfo } from "@arcblock/did";
|
|
6
|
+
import { toStakeAddress } from "@arcblock/did-util";
|
|
7
|
+
import { account, evidence, parseNonceBn, stake } from "@ocap/state";
|
|
8
|
+
import { BN, fromTokenToUnit, isSameDid, toAddress as toAddress$1 } from "@ocap/util";
|
|
9
9
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { fromPublicKey as fromPublicKey$1 } from "@ocap/wallet";
|
|
@@ -32,7 +32,7 @@ const MAX_FREE_VARIANTS = 2;
|
|
|
32
32
|
/**
|
|
33
33
|
* High-overhead creator, factory, token-issuance, rollup, and batch transaction types
|
|
34
34
|
* that ALWAYS require direct gas payment (`requiresDirectGas: true`) and cannot waive
|
|
35
|
-
* gas via self-staked `Stake-for-Gas
|
|
35
|
+
* gas via self-staked `Stake-for-Gas`, Unlinkable Gas Pass or a third-party sponsor's stake (#1420).
|
|
36
36
|
*/
|
|
37
37
|
const DIRECT_GAS_REQUIRED_TX_TYPES = new Set([
|
|
38
38
|
"create_token",
|
|
@@ -189,7 +189,11 @@ function getOrCreateActorRecord(reg, rawActor, nowMs, cfg) {
|
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* 3D `Stake-for-Gas` Eligibility Gate:
|
|
192
|
-
*
|
|
192
|
+
* 0. `txType` must not be in `DIRECT_GAS_REQUIRED_TX_TYPES`. This holds for every stake-based waiver: self
|
|
193
|
+
* stake, gas pass and third-party sponsor stake (#1420). Only an operator-configured
|
|
194
|
+
* `txGas.freeGasAllowedTxTypes` entry can lift it.
|
|
195
|
+
* 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only). Third-party sponsors are
|
|
196
|
+
* exempt from this allowlist unless `enforceSponsor3DEligibility` is on.
|
|
193
197
|
* 2. `txSize` must be <= `maxFreeGasTxSize` (default 4096 bytes).
|
|
194
198
|
* 3. `stateOps` (`estimate.create + estimate.update`) must be <= `maxFreeGasStateOps` (default 6).
|
|
195
199
|
* 4. Failed transactions (`isFailedTxGasCharge === true`) NEVER waive gas.
|
|
@@ -202,13 +206,15 @@ function evaluateStakeForGasEligibility(params) {
|
|
|
202
206
|
};
|
|
203
207
|
const shortType = normalizeShortTxType(params.txType);
|
|
204
208
|
const customAllowlist = (params.config?.transaction?.txGas)?.freeGasAllowedTxTypes;
|
|
205
|
-
|
|
209
|
+
const enforceAllowlist = !params.isThirdPartySponsor || params.enforceSponsor3DEligibility === true;
|
|
210
|
+
if (shortType) {
|
|
211
|
+
const requiresDirectGas = DIRECT_GAS_REQUIRED_TX_TYPES.has(shortType);
|
|
206
212
|
if (Array.isArray(customAllowlist) && customAllowlist.length > 0) {
|
|
207
|
-
if (!customAllowlist.some((t) => normalizeShortTxType(t) === shortType || t === params.txType)) return {
|
|
213
|
+
if (!customAllowlist.some((t) => normalizeShortTxType(t) === shortType || t === params.txType) && (enforceAllowlist || requiresDirectGas)) return {
|
|
208
214
|
eligible: false,
|
|
209
215
|
reason: "TX_TYPE_REQUIRES_DIRECT_GAS"
|
|
210
216
|
};
|
|
211
|
-
} else if (
|
|
217
|
+
} else if (requiresDirectGas || enforceAllowlist && typeof params.txType === "string" && params.txType.startsWith("fg:t:") && !FREE_GAS_ELIGIBLE_TX_TYPES.has(shortType)) return {
|
|
212
218
|
eligible: false,
|
|
213
219
|
reason: "TX_TYPE_REQUIRES_DIRECT_GAS"
|
|
214
220
|
};
|
|
@@ -464,14 +470,16 @@ function verifyAndConsumeUnlinkableGasPass(params) {
|
|
|
464
470
|
reason: "GAS_PASS_NULLIFIER_ALREADY_SPENT"
|
|
465
471
|
};
|
|
466
472
|
}
|
|
467
|
-
if (
|
|
468
|
-
|
|
469
|
-
|
|
473
|
+
if (params.consumeNullifier !== false) {
|
|
474
|
+
if (nullifierMap.size >= MAX_NULLIFIERS_PER_STAKE) {
|
|
475
|
+
const oldest = nullifierMap.keys().next().value;
|
|
476
|
+
if (oldest) nullifierMap.delete(oldest);
|
|
477
|
+
}
|
|
478
|
+
nullifierMap.set(nullifier, {
|
|
479
|
+
epoch,
|
|
480
|
+
txHash
|
|
481
|
+
});
|
|
470
482
|
}
|
|
471
|
-
nullifierMap.set(nullifier, {
|
|
472
|
-
epoch,
|
|
473
|
-
txHash
|
|
474
|
-
});
|
|
475
483
|
return {
|
|
476
484
|
valid: true,
|
|
477
485
|
stakeId
|
|
@@ -563,6 +571,7 @@ const BENIGN_REJECT_CODES = new Set([
|
|
|
563
571
|
"INVALID_TX_TIME",
|
|
564
572
|
"EXPIRED",
|
|
565
573
|
"TX_EXPIRED",
|
|
574
|
+
"EXPIRED_TX",
|
|
566
575
|
"NOT_FOUND",
|
|
567
576
|
"STAKE_NOT_FOUND",
|
|
568
577
|
"INVALID_LOCK_STATUS",
|
package/esm/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, IAbuseSlashEvidence, IGasSecurityConfig, IPaymasterDecodedClaims, IStakeForGasEligibilityResult, ITxGasQuotaTelemetry, ITxSecurityWarning, IUnlinkableGasPass, SecurityStrikeTier, StrikeReasonCategory, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, evaluateBurstQuota, evaluateStakeForGasEligibility, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getTxSecurityWarningByHash, normalizeActorAddress, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, setTxSecurityWarningForHash, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints } from "./gas-security-guard.mjs";
|
|
2
2
|
import { COUNTER_NAMES, CounterName, QueueState, STAGE_LABELS, StageLabel, TxMeta, TxStatus, TxTimer, TxTimerSummaryV2 } from "./tx-timer.mjs";
|
|
3
|
-
import { UNSIGNED_TX_EVIDENCE_DATA_PREFIX, toUnsignedEvidenceKey } from "./execute.mjs";
|
|
3
|
+
import { PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot } from "./execute.mjs";
|
|
4
4
|
import { TokenInput } from "./protocols/trade/transfer-v2.mjs";
|
|
5
5
|
import { MultiInput } from "./protocols/trade/transfer-v3.mjs";
|
|
6
6
|
import { TokenInput as TokenInput$1 } from "./protocols/trade/exchange-v2.mjs";
|
|
@@ -12,17 +12,20 @@ import { TokenInput as TokenInput$4 } from "./protocols/token/withdraw-v2.mjs";
|
|
|
12
12
|
import { TokenInfoForVerification } from "./protocols/token-factory/update.mjs";
|
|
13
13
|
import { MultiInput as MultiInput$2 } from "./protocols/token-factory/mint.mjs";
|
|
14
14
|
import { MultiInput as MultiInput$3 } from "./protocols/token-factory/burn.mjs";
|
|
15
|
+
import { Context } from "./protocols/bridge/release.mjs";
|
|
15
16
|
import { MultiInput as MultiInput$4 } from "./protocols/governance/stake.mjs";
|
|
16
17
|
import { MultiOutput, TokenCondition } from "./protocols/governance/revoke-stake.mjs";
|
|
17
18
|
import { MultiOutput as MultiOutput$1, TokenCondition as TokenCondition$1, TokenInput as TokenInput$5 } from "./protocols/governance/claim-stake.mjs";
|
|
18
19
|
import { MultiOutput as MultiOutput$2 } from "./protocols/governance/slash-stake.mjs";
|
|
19
20
|
import { MultiInput as MultiInput$5, TokenCondition as TokenCondition$2 } from "./protocols/governance/return-stake.mjs";
|
|
21
|
+
import { BridgeCtxMixin } from "./protocols/rollup/bridge-v2.mjs";
|
|
20
22
|
import { TokenChange as TokenChange$1 } from "./protocols/rollup/create-block.mjs";
|
|
21
23
|
import { TokenChange as TokenChange$2 } from "./protocols/rollup/claim-reward.mjs";
|
|
22
24
|
import { WriteLedger } from "./pipes/write-ledger.mjs";
|
|
23
|
-
import
|
|
25
|
+
import { assertStatelessTxRules, getStatelessPrefixLength, markStatelessPrefix } from "./stateless-prefix.mjs";
|
|
24
26
|
import * as _ocap_tx_pipeline0 from "@ocap/tx-pipeline";
|
|
25
27
|
import { MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PostExecutionInvariantGate, PreFlightWaf, TRACKED_STATE_TABLES, assertKnownItxFields, assertRawWireEnvelope, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, normalizeEntityKey, rollbackTrackedStateWrites, scanItxPayloadAnomalies } from "@ocap/tx-pipeline";
|
|
28
|
+
import * as states from "@ocap/state";
|
|
26
29
|
import * as _ocap_util0 from "@ocap/util";
|
|
27
30
|
import * as _ocap_message0 from "@ocap/message";
|
|
28
31
|
import * as _ocap_types0 from "@ocap/types";
|
|
@@ -300,6 +303,7 @@ declare const createExecutor: ({
|
|
|
300
303
|
delta: string;
|
|
301
304
|
}[];
|
|
302
305
|
}>;
|
|
306
|
+
releaseBridgeToken: _ocap_tx_pipeline0.Runner<Context>;
|
|
303
307
|
stake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TStakeTx> & Partial<_ocap_types0.IWithSender> & Partial<_ocap_types0.IWithSigners> & Partial<_ocap_types0.IWithReceiver> & Partial<_ocap_types0.IWithStake> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
|
|
304
308
|
inputs?: MultiInput$4[];
|
|
305
309
|
senders?: string[];
|
|
@@ -310,7 +314,8 @@ declare const createExecutor: ({
|
|
|
310
314
|
revokeWaitingPeriod?: number;
|
|
311
315
|
slashers?: string[];
|
|
312
316
|
}>;
|
|
313
|
-
revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
|
|
317
|
+
revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & Partial<Pick<_ocap_types0.IWithToken, "tokenState">> & Partial<_ocap_types0.IWithTokenFactory> & {
|
|
318
|
+
tokenStakeRelease?: "retire" | "retired";
|
|
314
319
|
outputs?: MultiOutput[];
|
|
315
320
|
receivers?: string[];
|
|
316
321
|
tokens?: string[];
|
|
@@ -357,23 +362,29 @@ declare const createExecutor: ({
|
|
|
357
362
|
tokenState?: _ocap_types0.ITokenState;
|
|
358
363
|
rollupState?: _ocap_types0.IRollupState | null;
|
|
359
364
|
isDelegationChanged?: boolean;
|
|
365
|
+
isBridgeV2?: boolean;
|
|
366
|
+
bridgeInput?: unknown;
|
|
367
|
+
}>;
|
|
368
|
+
updateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TUpdateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
|
|
369
|
+
bridgePlan?: states.rollup.BridgePatchPlan;
|
|
360
370
|
}>;
|
|
361
|
-
|
|
362
|
-
joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
|
|
371
|
+
joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
|
|
363
372
|
evidenceState?: _ocap_types0.IEvidenceState | null;
|
|
364
373
|
newValidator?: _ocap_types0.IRollupValidator;
|
|
365
374
|
validatorsHash?: string;
|
|
366
375
|
}>;
|
|
367
|
-
leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
|
|
376
|
+
leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
|
|
368
377
|
validatorsHash?: string;
|
|
369
378
|
evidenceState?: _ocap_types0.IEvidenceState | null;
|
|
370
379
|
}>;
|
|
371
|
-
pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners
|
|
372
|
-
|
|
380
|
+
pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
|
|
381
|
+
pauseKind?: "quorum" | "lone";
|
|
382
|
+
}>;
|
|
383
|
+
closeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCloseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
|
|
373
384
|
stakeAddresses?: string[];
|
|
374
385
|
stakeStates?: _ocap_types0.IStakeState[];
|
|
375
386
|
}>;
|
|
376
|
-
resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
|
|
387
|
+
resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
|
|
377
388
|
createRollupBlock: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCreateRollupBlockTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStakes & {
|
|
378
389
|
formattedItx?: Record<string, unknown>;
|
|
379
390
|
previousBlock?: _ocap_types0.IRollupBlock | null;
|
|
@@ -422,7 +433,7 @@ declare const createExecutor: ({
|
|
|
422
433
|
missingAccountStates?: _ocap_types0.IAccountState[];
|
|
423
434
|
stakeStates?: _ocap_types0.IStakeState[];
|
|
424
435
|
}>;
|
|
425
|
-
migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
|
|
436
|
+
migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
|
|
426
437
|
};
|
|
427
438
|
declare const defaultExecutor: {
|
|
428
439
|
execute: (context: unknown, done?: (err: Error | null, res?: unknown) => void) => any;
|
|
@@ -684,6 +695,7 @@ declare const defaultExecutor: {
|
|
|
684
695
|
delta: string;
|
|
685
696
|
}[];
|
|
686
697
|
}>;
|
|
698
|
+
releaseBridgeToken: _ocap_tx_pipeline0.Runner<Context>;
|
|
687
699
|
stake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TStakeTx> & Partial<_ocap_types0.IWithSender> & Partial<_ocap_types0.IWithSigners> & Partial<_ocap_types0.IWithReceiver> & Partial<_ocap_types0.IWithStake> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
|
|
688
700
|
inputs?: MultiInput$4[];
|
|
689
701
|
senders?: string[];
|
|
@@ -694,7 +706,8 @@ declare const defaultExecutor: {
|
|
|
694
706
|
revokeWaitingPeriod?: number;
|
|
695
707
|
slashers?: string[];
|
|
696
708
|
}>;
|
|
697
|
-
revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
|
|
709
|
+
revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & Partial<Pick<_ocap_types0.IWithToken, "tokenState">> & Partial<_ocap_types0.IWithTokenFactory> & {
|
|
710
|
+
tokenStakeRelease?: "retire" | "retired";
|
|
698
711
|
outputs?: MultiOutput[];
|
|
699
712
|
receivers?: string[];
|
|
700
713
|
tokens?: string[];
|
|
@@ -741,23 +754,29 @@ declare const defaultExecutor: {
|
|
|
741
754
|
tokenState?: _ocap_types0.ITokenState;
|
|
742
755
|
rollupState?: _ocap_types0.IRollupState | null;
|
|
743
756
|
isDelegationChanged?: boolean;
|
|
757
|
+
isBridgeV2?: boolean;
|
|
758
|
+
bridgeInput?: unknown;
|
|
759
|
+
}>;
|
|
760
|
+
updateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TUpdateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
|
|
761
|
+
bridgePlan?: states.rollup.BridgePatchPlan;
|
|
744
762
|
}>;
|
|
745
|
-
|
|
746
|
-
joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
|
|
763
|
+
joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
|
|
747
764
|
evidenceState?: _ocap_types0.IEvidenceState | null;
|
|
748
765
|
newValidator?: _ocap_types0.IRollupValidator;
|
|
749
766
|
validatorsHash?: string;
|
|
750
767
|
}>;
|
|
751
|
-
leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
|
|
768
|
+
leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
|
|
752
769
|
validatorsHash?: string;
|
|
753
770
|
evidenceState?: _ocap_types0.IEvidenceState | null;
|
|
754
771
|
}>;
|
|
755
|
-
pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners
|
|
756
|
-
|
|
772
|
+
pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
|
|
773
|
+
pauseKind?: "quorum" | "lone";
|
|
774
|
+
}>;
|
|
775
|
+
closeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCloseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
|
|
757
776
|
stakeAddresses?: string[];
|
|
758
777
|
stakeStates?: _ocap_types0.IStakeState[];
|
|
759
778
|
}>;
|
|
760
|
-
resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
|
|
779
|
+
resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
|
|
761
780
|
createRollupBlock: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCreateRollupBlockTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStakes & {
|
|
762
781
|
formattedItx?: Record<string, unknown>;
|
|
763
782
|
previousBlock?: _ocap_types0.IRollupBlock | null;
|
|
@@ -806,8 +825,8 @@ declare const defaultExecutor: {
|
|
|
806
825
|
missingAccountStates?: _ocap_types0.IAccountState[];
|
|
807
826
|
stakeStates?: _ocap_types0.IStakeState[];
|
|
808
827
|
}>;
|
|
809
|
-
migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
|
|
828
|
+
migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
|
|
810
829
|
};
|
|
811
830
|
declare const execute: (context: unknown, done?: (err: Error | null, res?: unknown) => void) => any;
|
|
812
831
|
//#endregion
|
|
813
|
-
export { COUNTER_NAMES, type CounterName, DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, type IAbuseSlashEvidence, type IGasSecurityConfig, type IPaymasterDecodedClaims, type IStakeForGasEligibilityResult, type ITxGasQuotaTelemetry, type ITxSecurityWarning, type IUnlinkableGasPass, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PostExecutionInvariantGate, PreFlightWaf, type QueueState, STAGE_LABELS, type SecurityStrikeTier, type StageLabel, type StrikeReasonCategory, TRACKED_STATE_TABLES, type TxMeta, type TxStatus, TxTimer, type TxTimerSummaryV2, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, WriteLedger, assertKnownItxFields, assertRawWireEnvelope, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, createExecutor, defaultExecutor as default, evaluateBurstQuota, evaluateStakeForGasEligibility, execute, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getTxSecurityWarningByHash, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, normalizeActorAddress, normalizeEntityKey, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, rollbackTrackedStateWrites, scanItxPayloadAnomalies, setTxSecurityWarningForHash, toUnsignedEvidenceKey, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints };
|
|
832
|
+
export { COUNTER_NAMES, type CounterName, DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, type IAbuseSlashEvidence, type IGasSecurityConfig, type IPaymasterDecodedClaims, type IStakeForGasEligibilityResult, type ITxGasQuotaTelemetry, type ITxSecurityWarning, type IUnlinkableGasPass, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, PostExecutionInvariantGate, PreFlightWaf, type QueueState, STAGE_LABELS, type SecurityStrikeTier, type StageLabel, type StrikeReasonCategory, TRACKED_STATE_TABLES, type TxMeta, type TxStatus, TxTimer, type TxTimerSummaryV2, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, WriteLedger, assertKnownItxFields, assertRawWireEnvelope, assertStatelessTxRules, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, createExecutor, defaultExecutor as default, evaluateBurstQuota, evaluateStakeForGasEligibility, execute, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getStatelessPrefixLength, getTxSecurityWarningByHash, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, markStatelessPrefix, normalizeActorAddress, normalizeEntityKey, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, rollbackTrackedStateWrites, scanItxPayloadAnomalies, setTxSecurityWarningForHash, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints };
|
package/esm/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, evaluateBurstQuota, evaluateStakeForGasEligibility, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getTxSecurityWarningByHash, normalizeActorAddress, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, setTxSecurityWarningForHash, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints } from "./gas-security-guard.mjs";
|
|
2
2
|
import { WriteLedger } from "./pipes/write-ledger.mjs";
|
|
3
|
+
import { assertStatelessTxRules, getStatelessPrefixLength, markStatelessPrefix, setDefaultStatelessProtocols } from "./stateless-prefix.mjs";
|
|
3
4
|
import { COUNTER_NAMES, STAGE_LABELS, TxTimer } from "./tx-timer.mjs";
|
|
4
|
-
import execute_default, { UNSIGNED_TX_EVIDENCE_DATA_PREFIX, toUnsignedEvidenceKey } from "./execute.mjs";
|
|
5
|
+
import execute_default, { PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot } from "./execute.mjs";
|
|
5
6
|
import delegate_default from "./protocols/account/delegate.mjs";
|
|
6
7
|
import migrate_default from "./protocols/account/migrate.mjs";
|
|
7
8
|
import revoke_delegate_default from "./protocols/account/revoke-delegate.mjs";
|
|
@@ -11,6 +12,7 @@ import consume_default from "./protocols/asset/consume.mjs";
|
|
|
11
12
|
import create_default from "./protocols/asset/create.mjs";
|
|
12
13
|
import mint_default from "./protocols/asset/mint.mjs";
|
|
13
14
|
import update_default from "./protocols/asset/update.mjs";
|
|
15
|
+
import release_default from "./protocols/bridge/release.mjs";
|
|
14
16
|
import create_default$1 from "./protocols/factory/create.mjs";
|
|
15
17
|
import claim_stake_default from "./protocols/governance/claim-stake.mjs";
|
|
16
18
|
import return_stake_default from "./protocols/governance/return-stake.mjs";
|
|
@@ -37,8 +39,8 @@ import withdraw_v2_default from "./protocols/token/withdraw-v2.mjs";
|
|
|
37
39
|
import exchange_v2_default from "./protocols/trade/exchange-v2.mjs";
|
|
38
40
|
import transfer_v2_default from "./protocols/trade/transfer-v2.mjs";
|
|
39
41
|
import transfer_v3_default from "./protocols/trade/transfer-v3.mjs";
|
|
40
|
-
import * as states from "@ocap/state";
|
|
41
42
|
import { MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PostExecutionInvariantGate, PreFlightWaf, TRACKED_STATE_TABLES, assertKnownItxFields, assertRawWireEnvelope, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, normalizeEntityKey, rollbackTrackedStateWrites, scanItxPayloadAnomalies } from "@ocap/tx-pipeline";
|
|
43
|
+
import * as states from "@ocap/state";
|
|
42
44
|
|
|
43
45
|
//#region src/index.ts
|
|
44
46
|
const createExecutor = ({ filter, runAsLambda }) => {
|
|
@@ -64,6 +66,7 @@ const createExecutor = ({ filter, runAsLambda }) => {
|
|
|
64
66
|
updateTokenFactory: update_default$2,
|
|
65
67
|
mintToken: mint_default$1,
|
|
66
68
|
burnToken: burn_default,
|
|
69
|
+
releaseBridgeToken: release_default,
|
|
67
70
|
stake: stake_default,
|
|
68
71
|
revokeStake: revoke_stake_default,
|
|
69
72
|
claimStake: claim_stake_default,
|
|
@@ -80,6 +83,7 @@ const createExecutor = ({ filter, runAsLambda }) => {
|
|
|
80
83
|
claimBlockReward: claim_reward_default,
|
|
81
84
|
migrateRollup: migrate_default$1
|
|
82
85
|
};
|
|
86
|
+
setDefaultStatelessProtocols(protocols);
|
|
83
87
|
const execute$1 = execute_default({
|
|
84
88
|
filter,
|
|
85
89
|
runAsLambda
|
|
@@ -101,4 +105,4 @@ const { execute } = defaultExecutor;
|
|
|
101
105
|
var src_default = defaultExecutor;
|
|
102
106
|
|
|
103
107
|
//#endregion
|
|
104
|
-
export { COUNTER_NAMES, DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PostExecutionInvariantGate, PreFlightWaf, STAGE_LABELS, TRACKED_STATE_TABLES, TxTimer, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, WriteLedger, assertKnownItxFields, assertRawWireEnvelope, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, createExecutor, src_default as default, evaluateBurstQuota, evaluateStakeForGasEligibility, execute, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getTxSecurityWarningByHash, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, normalizeActorAddress, normalizeEntityKey, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, rollbackTrackedStateWrites, scanItxPayloadAnomalies, setTxSecurityWarningForHash, toUnsignedEvidenceKey, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints };
|
|
108
|
+
export { COUNTER_NAMES, DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, PostExecutionInvariantGate, PreFlightWaf, STAGE_LABELS, TRACKED_STATE_TABLES, TxTimer, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, WriteLedger, assertKnownItxFields, assertRawWireEnvelope, assertStatelessTxRules, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, createExecutor, src_default as default, evaluateBurstQuota, evaluateStakeForGasEligibility, execute, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getStatelessPrefixLength, getTxSecurityWarningByHash, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, markStatelessPrefix, normalizeActorAddress, normalizeEntityKey, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, rollbackTrackedStateWrites, scanItxPayloadAnomalies, setTxSecurityWarningForHash, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { assertBridgeReserveNotSponsor } from "../bridge-reserve.mjs";
|
|
1
2
|
import { evaluateStakeForGasEligibility, extractTransactionTargets, getActorSecurityStatus, resolveGasSecurityConfig, setTxSecurityWarningForHash, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints } from "../gas-security-guard.mjs";
|
|
2
3
|
import { applyTokenUpdates, isGasStakeValid } from "../util.mjs";
|
|
4
|
+
import { CustomError } from "@ocap/util/lib/error";
|
|
3
5
|
import { isFromPublicKey, toAddress } from "@arcblock/did";
|
|
4
6
|
import { toStakeAddress } from "@arcblock/did-util";
|
|
7
|
+
import * as JWT from "@arcblock/jwt";
|
|
5
8
|
import { account } from "@ocap/state";
|
|
6
9
|
import { BN, fromTokenToUnit, fromUnitToToken, hexToNumber, isSameDid, toBase58, toBase64, toBuffer } from "@ocap/util";
|
|
7
|
-
import { CustomError } from "@ocap/util/lib/error";
|
|
8
10
|
import { getRelatedAddresses } from "@ocap/util/lib/get-related-addr";
|
|
9
|
-
import * as JWT from "@arcblock/jwt";
|
|
10
11
|
import noop from "lodash/noop.js";
|
|
11
12
|
import Debug from "debug";
|
|
12
13
|
|
|
@@ -27,6 +28,8 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
27
28
|
const { config } = context;
|
|
28
29
|
const { tx: tx$1, extra = {}, txHash = "", txTime } = context;
|
|
29
30
|
const isFailedTxGasCharge = Boolean(context.isFailedTxGasCharge);
|
|
31
|
+
const canChargeSenderDirectly = Boolean(senderState);
|
|
32
|
+
const txSize = context._baseTxSize ?? context.txSize;
|
|
30
33
|
const nowMs = txTime ? +new Date(txTime) : Date.now();
|
|
31
34
|
const { token: token$1, pk } = extra.gasStakeHeaders || {};
|
|
32
35
|
const rawGasPass = extra.gasPass || extra.txExtra?.gasPass;
|
|
@@ -65,7 +68,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
65
68
|
};
|
|
66
69
|
};
|
|
67
70
|
let isThirdPartyGasPass = false;
|
|
68
|
-
if (!isFailedTxGasCharge && rawGasPass) {
|
|
71
|
+
if ((!isFailedTxGasCharge || !canChargeSenderDirectly) && rawGasPass) {
|
|
69
72
|
const passStakeState = rawGasPass.stakeId ? await statedb.stake?.get?.(rawGasPass.stakeId, context) : null;
|
|
70
73
|
const passResult = verifyAndConsumeUnlinkableGasPass({
|
|
71
74
|
gasPass: rawGasPass,
|
|
@@ -83,7 +86,16 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
83
86
|
const passOwner = passStakeState?.sender || rawGasPass.stakeId;
|
|
84
87
|
isThirdPartyGasPass = Boolean(passOwner && (!tx$1?.from || !isSameDid(passOwner, tx$1.from)) && (!tx$1?.delegator || !isSameDid(passOwner, tx$1.delegator)));
|
|
85
88
|
const selfStakeInfo = isThirdPartyGasPass ? await resolveSignerSelfGasStake() : null;
|
|
86
|
-
|
|
89
|
+
const selfStakeEligible = Boolean(selfStakeInfo?.valid) && evaluateStakeForGasEligibility({
|
|
90
|
+
txType,
|
|
91
|
+
txSize,
|
|
92
|
+
gasEstimate,
|
|
93
|
+
isFailedTxGasCharge: isFailedTxGasCharge && canChargeSenderDirectly,
|
|
94
|
+
isThirdPartySponsor: false,
|
|
95
|
+
enforceSponsor3DEligibility: false,
|
|
96
|
+
config
|
|
97
|
+
}).eligible;
|
|
98
|
+
if (selfStakeInfo?.valid && selfStakeEligible) {
|
|
87
99
|
gasStake.owner = selfStakeInfo.owner;
|
|
88
100
|
gasStake.stakeId = selfStakeInfo.stakeId;
|
|
89
101
|
gasStake.state = selfStakeInfo.state;
|
|
@@ -93,7 +105,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
93
105
|
gasStake.stakeId = passResult.stakeId;
|
|
94
106
|
gasStake.state = passStakeState;
|
|
95
107
|
}
|
|
96
|
-
} else if (!isFailedTxGasCharge && token$1 && pk) {
|
|
108
|
+
} else if ((!isFailedTxGasCharge || !canChargeSenderDirectly) && token$1 && pk) {
|
|
97
109
|
const decoded = JWT.decode(token$1) || {};
|
|
98
110
|
const sponsorAddress = toAddress(decoded.iss || "");
|
|
99
111
|
if (!sponsorAddress || !isFromPublicKey(sponsorAddress, pk)) {
|
|
@@ -101,6 +113,11 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
101
113
|
hdrErr._unauthenticatedExtraFailure = true;
|
|
102
114
|
return next(hdrErr);
|
|
103
115
|
}
|
|
116
|
+
try {
|
|
117
|
+
assertBridgeReserveNotSponsor(sponsorAddress);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
return next(err);
|
|
120
|
+
}
|
|
104
121
|
if (await JWT.verify(token$1, pk, {
|
|
105
122
|
enforceTimestamp: !txTime,
|
|
106
123
|
tolerance: 5
|
|
@@ -138,7 +155,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
138
155
|
}
|
|
139
156
|
if (!isSponsorMigrated && !isSponsorBlocked) {
|
|
140
157
|
const sponsorStakeId = toStakeAddress(sponsorAddress, sponsorAddress);
|
|
141
|
-
const isDirectMode = decoded.mode === "paymaster";
|
|
158
|
+
const isDirectMode = decoded.mode === "paymaster" || decoded.chargeSponsorBalance === true;
|
|
142
159
|
const sponsorStakeState = !isDirectMode ? await statedb.stake?.get?.(sponsorStakeId, context) : null;
|
|
143
160
|
const officialTok = config.token?.address || "";
|
|
144
161
|
const sponsorIsBacked = isDirectMode ? Boolean(sponsorState && officialTok && new BN(sponsorState.tokens?.[officialTok] || 0).gte((totalGas ?? ZERO).gt(ZERO) ? totalGas ?? ZERO : new BN(1))) : isGasStakeValid(sponsorStakeState, config);
|
|
@@ -173,7 +190,16 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
173
190
|
}
|
|
174
191
|
}
|
|
175
192
|
const selfStakeInfo = await resolveSignerSelfGasStake();
|
|
176
|
-
|
|
193
|
+
const selfStakeEligible = Boolean(selfStakeInfo.valid) && evaluateStakeForGasEligibility({
|
|
194
|
+
txType,
|
|
195
|
+
txSize,
|
|
196
|
+
gasEstimate,
|
|
197
|
+
isFailedTxGasCharge: isFailedTxGasCharge && canChargeSenderDirectly,
|
|
198
|
+
isThirdPartySponsor: false,
|
|
199
|
+
enforceSponsor3DEligibility: false,
|
|
200
|
+
config
|
|
201
|
+
}).eligible;
|
|
202
|
+
if (selfStakeInfo.valid && selfStakeEligible) {
|
|
177
203
|
gasStake.owner = selfStakeInfo.owner;
|
|
178
204
|
gasStake.stakeId = selfStakeInfo.stakeId;
|
|
179
205
|
gasStake.state = selfStakeInfo.state;
|
|
@@ -199,9 +225,9 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
199
225
|
if (!gasStake.state && gasStake.stakeId) gasStake.state = await statedb.stake.get(gasStake.stakeId, context);
|
|
200
226
|
const eligibility = evaluateStakeForGasEligibility({
|
|
201
227
|
txType,
|
|
202
|
-
txSize
|
|
228
|
+
txSize,
|
|
203
229
|
gasEstimate,
|
|
204
|
-
isFailedTxGasCharge,
|
|
230
|
+
isFailedTxGasCharge: isFailedTxGasCharge && canChargeSenderDirectly,
|
|
205
231
|
isThirdPartySponsor,
|
|
206
232
|
enforceSponsor3DEligibility,
|
|
207
233
|
config
|
|
@@ -246,7 +272,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
|
|
|
246
272
|
value: totalGasBN.toString(10)
|
|
247
273
|
};
|
|
248
274
|
context.gasVaultChange = changes.gas;
|
|
249
|
-
if (isPaymasterDirectCharge && !isFailedTxGasCharge) sponsorGasCost = totalGasBN;
|
|
275
|
+
if (isPaymasterDirectCharge && (!isFailedTxGasCharge || !canChargeSenderDirectly)) sponsorGasCost = totalGasBN;
|
|
250
276
|
else txCost = txCost.add(totalGasBN);
|
|
251
277
|
}
|
|
252
278
|
if (changes.fee) if (config.vaults.txFees?.length) {
|
|
@@ -68,8 +68,8 @@ declare const LEDGER_ERRORS: {
|
|
|
68
68
|
* ```typescript
|
|
69
69
|
* import { WriteLedger } from '@ocap/tx-protocols/pipes/write-ledger';
|
|
70
70
|
*
|
|
71
|
-
* //
|
|
72
|
-
*
|
|
71
|
+
* // After the protocol runner, right before the tx state is written:
|
|
72
|
+
* await runSinglePipe(WriteLedger, context);
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
75
|
declare const WriteLedger: PipeFunction<IWriteLedgerContext>;
|
|
@@ -6,7 +6,10 @@ import { formatMessage } from "@ocap/message";
|
|
|
6
6
|
* WriteLedger Pipe
|
|
7
7
|
*
|
|
8
8
|
* Writes verified transactions to the Ledger append-only log.
|
|
9
|
-
* Must
|
|
9
|
+
* Must run AFTER VerifySignature to ensure only authenticated txs are recorded, and (#1419) only at the point
|
|
10
|
+
* where the tx state is written: after the protocol accepted the tx, or after a failed tx was charged
|
|
11
|
+
* failed-tx gas. It still runs before `statedb.tx.create` and the statedb commit. See `appendLedgerEntry` in
|
|
12
|
+
* `execute.ts`.
|
|
10
13
|
*
|
|
11
14
|
* The ledger provides:
|
|
12
15
|
* - Append-only immutable transaction log
|
|
@@ -32,8 +35,8 @@ const LEDGER_ERRORS = {
|
|
|
32
35
|
* ```typescript
|
|
33
36
|
* import { WriteLedger } from '@ocap/tx-protocols/pipes/write-ledger';
|
|
34
37
|
*
|
|
35
|
-
* //
|
|
36
|
-
*
|
|
38
|
+
* // After the protocol runner, right before the tx state is written:
|
|
39
|
+
* await runSinglePipe(WriteLedger, context);
|
|
37
40
|
* ```
|
|
38
41
|
*/
|
|
39
42
|
const WriteLedger = async (context, next) => {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import ensure_cost_default from "../../pipes/ensure-cost.mjs";
|
|
2
2
|
import ensure_gas_default from "../../pipes/ensure-gas.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { toDelegateAddress } from "@arcblock/did-util";
|
|
3
|
+
import { markStatelessPrefix } from "../../stateless-prefix.mjs";
|
|
5
4
|
import { types } from "@ocap/mcrypto";
|
|
6
|
-
import { account, delegation } from "@ocap/state";
|
|
7
5
|
import { Runner, pipes } from "@ocap/tx-pipeline";
|
|
8
|
-
import { isSameDid, scopeMatchAny } from "@ocap/util";
|
|
9
6
|
import { CustomError } from "@ocap/util/lib/error";
|
|
10
7
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
8
|
+
import { toTypeInfo } from "@arcblock/did";
|
|
9
|
+
import { toDelegateAddress } from "@arcblock/did-util";
|
|
10
|
+
import { account, delegation } from "@ocap/state";
|
|
11
|
+
import { isSameDid, scopeMatchAny } from "@ocap/util";
|
|
11
12
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
12
13
|
import get from "lodash/get.js";
|
|
13
14
|
import pick from "lodash/pick.js";
|
|
@@ -116,6 +117,7 @@ runner.use(pipes.VerifyInfo([{
|
|
|
116
117
|
return (context.formattedItx?.ops || []).every((op) => scopeMatchAny(op.typeUrl, allowed));
|
|
117
118
|
}
|
|
118
119
|
}]));
|
|
120
|
+
markStatelessPrefix(runner);
|
|
119
121
|
runner.use(pipes.ExtractState({
|
|
120
122
|
from: "tx.from",
|
|
121
123
|
to: "senderState",
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { decodeAnySafe } from "../../util.mjs";
|
|
2
2
|
import ensure_cost_default from "../../pipes/ensure-cost.mjs";
|
|
3
3
|
import ensure_gas_default from "../../pipes/ensure-gas.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { markStatelessPrefix } from "../../stateless-prefix.mjs";
|
|
5
5
|
import { types } from "@ocap/mcrypto";
|
|
6
|
-
import { account } from "@ocap/state";
|
|
7
6
|
import { Runner, pipes } from "@ocap/tx-pipeline";
|
|
8
|
-
import { toBN } from "@ocap/util";
|
|
9
7
|
import { CustomError } from "@ocap/util/lib/error";
|
|
10
8
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
9
|
+
import { MAX_ROTATION_CHAIN_LENGTH, createPreRotationCommitment, extractAccountPreRotationData, fromPublicKey, isSameEntity, isValidPreRotationCommitment, normalizePreRotationCommitment, normalizePublicKeyHex, toTypeInfo, verifyPreRotationCommitment, verifySingleKeyRotationEvent } from "@arcblock/did";
|
|
10
|
+
import { account } from "@ocap/state";
|
|
11
|
+
import { toBN } from "@ocap/util";
|
|
11
12
|
import { getRelatedAddresses } from "@ocap/util/lib/get-related-addr";
|
|
12
13
|
import Debug from "debug";
|
|
13
14
|
import { v, vDID, vStripUnknown, vValidate } from "@arcblock/validator";
|
|
@@ -66,6 +67,7 @@ runner.use(pipes.VerifyInfo([{
|
|
|
66
67
|
return isSameEntity(fromPublicKey(typeof context.itx.pk === "string" ? `0x${pkHex}` : context.itx.pk, toTypeInfo(context.itx.address)), context.itx.address) && !isSameEntity(context.itx.address, context.tx.from);
|
|
67
68
|
}
|
|
68
69
|
}]));
|
|
70
|
+
markStatelessPrefix(runner);
|
|
69
71
|
runner.use(pipes.ExtractState({
|
|
70
72
|
from: "tx.from",
|
|
71
73
|
to: "senderState",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import ensure_cost_default from "../../pipes/ensure-cost.mjs";
|
|
2
2
|
import ensure_gas_default from "../../pipes/ensure-gas.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { account, delegation } from "@ocap/state";
|
|
3
|
+
import { markStatelessPrefix } from "../../stateless-prefix.mjs";
|
|
5
4
|
import { Runner, pipes } from "@ocap/tx-pipeline";
|
|
6
|
-
import { scopeMatch, scopeMatchAny } from "@ocap/util";
|
|
7
5
|
import { CustomError } from "@ocap/util/lib/error";
|
|
8
6
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
7
|
+
import { toDelegateAddress } from "@arcblock/did-util";
|
|
8
|
+
import { account, delegation } from "@ocap/state";
|
|
9
|
+
import { scopeMatch, scopeMatchAny } from "@ocap/util";
|
|
9
10
|
import { getRelatedAddresses } from "@ocap/util/lib/get-related-addr";
|
|
10
11
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
11
12
|
import get from "lodash/get.js";
|
|
@@ -35,6 +36,7 @@ runner.use((context, next) => {
|
|
|
35
36
|
if (error) return next(new CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
36
37
|
return next();
|
|
37
38
|
});
|
|
39
|
+
markStatelessPrefix(runner);
|
|
38
40
|
runner.use(pipes.ExtractState({
|
|
39
41
|
from: "itx.to",
|
|
40
42
|
to: "receiverState",
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { applyTokenChange, applyTokenUpdates } from "../../util.mjs";
|
|
2
2
|
import ensure_cost_default from "../../pipes/ensure-cost.mjs";
|
|
3
3
|
import ensure_gas_default from "../../pipes/ensure-gas.mjs";
|
|
4
|
+
import { markStatelessPrefix } from "../../stateless-prefix.mjs";
|
|
4
5
|
import exec_mint_hook_default, { getMintTokenPayLegs, verifyMintHook } from "./pipes/exec-mint-hook.mjs";
|
|
5
6
|
import extract_factory_tokens_default from "./pipes/extract-factory-tokens.mjs";
|
|
6
7
|
import verify_itx_address_default from "./pipes/verify-itx-address.mjs";
|
|
7
8
|
import verify_itx_assets_default from "./pipes/verify-itx-assets.mjs";
|
|
8
9
|
import verify_itx_variables_default from "./pipes/verify-itx-variables.mjs";
|
|
9
10
|
import verify_mint_limit_default from "./pipes/verify-mint-limit.mjs";
|
|
10
|
-
import { account, asset, delegation, factory } from "@ocap/state";
|
|
11
11
|
import { Runner, pipes, verifyAssetHierarchy } from "@ocap/tx-pipeline";
|
|
12
12
|
import { CustomError } from "@ocap/util/lib/error";
|
|
13
13
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
14
|
+
import { account, asset, delegation, factory } from "@ocap/state";
|
|
14
15
|
import { getRelatedAddresses } from "@ocap/util/lib/get-related-addr";
|
|
15
16
|
import Debug from "debug";
|
|
16
17
|
import { schemas, v, vDID, vStripUnknown, vValidate } from "@arcblock/validator";
|
|
@@ -46,6 +47,7 @@ runner.use(({ itx }, next) => {
|
|
|
46
47
|
if (error) return next(new CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
|
|
47
48
|
return next();
|
|
48
49
|
});
|
|
50
|
+
markStatelessPrefix(runner);
|
|
49
51
|
runner.use(pipes.ExtractState({
|
|
50
52
|
from: "itx.address",
|
|
51
53
|
to: "duplicateAsset",
|