@ocap/state 1.30.26 → 1.31.1
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/index.d.mts +4 -4
- package/esm/index.mjs +4 -4
- package/esm/states/account.d.mts +2 -8
- package/esm/states/account.mjs +2 -64
- package/esm/states/asset.mjs +5 -1
- package/esm/states/chain.mjs +1 -3
- package/esm/states/delegation.mjs +2 -0
- package/esm/states/rollup-block.mjs +1 -4
- package/esm/states/rollup.d.mts +37 -10
- package/esm/states/rollup.mjs +193 -19
- package/esm/states/stake.d.mts +5 -0
- package/esm/states/stake.mjs +26 -4
- package/esm/states/token-factory.mjs +28 -9
- package/esm/states/token.d.mts +111 -7
- package/esm/states/token.mjs +365 -6
- package/esm/states/tx.mjs +1 -1
- package/lib/index.cjs +28 -8
- package/lib/index.d.cts +4 -4
- package/lib/states/account.cjs +1 -70
- package/lib/states/account.d.cts +2 -8
- package/lib/states/asset.cjs +5 -1
- package/lib/states/chain.cjs +2 -4
- package/lib/states/delegation.cjs +2 -0
- package/lib/states/rollup-block.cjs +1 -4
- package/lib/states/rollup.cjs +205 -17
- package/lib/states/rollup.d.cts +37 -10
- package/lib/states/stake.cjs +25 -3
- package/lib/states/stake.d.cts +5 -0
- package/lib/states/token-factory.cjs +28 -9
- package/lib/states/token.cjs +380 -6
- package/lib/states/token.d.cts +111 -7
- package/lib/states/tx.cjs +2 -2
- package/package.json +9 -9
package/esm/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { account_d_exports, parseNonceBn } from "./states/account.mjs";
|
|
2
2
|
import { asset_d_exports } from "./states/asset.mjs";
|
|
3
3
|
import { ChainState, chain_d_exports } from "./states/chain.mjs";
|
|
4
4
|
import { delegation_d_exports } from "./states/delegation.mjs";
|
|
5
5
|
import { evidence_d_exports } from "./states/evidence.mjs";
|
|
6
6
|
import { factory_d_exports } from "./states/factory.mjs";
|
|
7
|
-
import { rollup_d_exports } from "./states/rollup.mjs";
|
|
7
|
+
import { RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isProposerSponsoredDepositAllowed, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, recordRollupDeposit, recordRollupWithdraw, rollup_d_exports } from "./states/rollup.mjs";
|
|
8
8
|
import { rollup_block_d_exports } from "./states/rollup-block.mjs";
|
|
9
9
|
import { stake_d_exports } from "./states/stake.mjs";
|
|
10
|
-
import { token_d_exports } from "./states/token.mjs";
|
|
10
|
+
import { TOKEN_CHARTER_KIND, TokenCharterAssetPayload, buildTokenCharterAssetData, buildTokenCharterAssetState, extractTokenUpdatesFromCharterAsset, iconToNftDisplay, isTokenCharterAsset, migrateTokensToCharterAssets, normalizeLegacyTokenStateForUpdate, resolveCharterMoniker, sanitizeTokenSvg, syncCharterAssetWithToken, syncTokenCharterOwnership, toTokenCharterAssetAddress, token_d_exports, websiteToNftEndpoint } from "./states/token.mjs";
|
|
11
11
|
import { token_factory_d_exports } from "./states/token-factory.mjs";
|
|
12
12
|
import { ItxJson, Receipt, ReceiptChange, TokenInput, TxContext, TxData, TxInput, TxOutput, TxResult, tx_d_exports } from "./states/tx.mjs";
|
|
13
13
|
import Blacklist, { BlacklistOptions, TrustedAccountConfig } from "./states/blacklist.mjs";
|
|
@@ -17,4 +17,4 @@ import Blacklist, { BlacklistOptions, TrustedAccountConfig } from "./states/blac
|
|
|
17
17
|
declare const indexes: readonly ["account", "asset", "delegation", "tx", "factory", "token", "stake", "rollup", "rollupBlock", "rollupValidator", "tokenDistribution", "tokenFactory"];
|
|
18
18
|
declare const tables: readonly ["chain", "account", "asset", "delegation", "tx", "factory", "token", "stake", "rollup", "rollupBlock", "evidence", "balance", "tokenFactory"];
|
|
19
19
|
//#endregion
|
|
20
|
-
export { Blacklist, type BlacklistOptions,
|
|
20
|
+
export { Blacklist, type BlacklistOptions, type ChainState, type ItxJson, type Receipt, type ReceiptChange, type RollupTargetType, type RollupTokenReserve, TOKEN_CHARTER_KIND, type TokenCharterAssetPayload, type TokenInput, type TrustedAccountConfig, type TxContext, type TxData, type TxInput, type TxOutput, type TxResult, VALID_ROLLUP_TARGET_TYPES, account_d_exports as account, asset_d_exports as asset, buildTokenCharterAssetData, buildTokenCharterAssetState, chain_d_exports as chain, delegation_d_exports as delegation, evidence_d_exports as evidence, extractTokenUpdatesFromCharterAsset, factory_d_exports as factory, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, iconToNftDisplay, indexes, isProposerSponsoredDepositAllowed, isTokenCharterAsset, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, migrateTokensToCharterAssets, normalizeLegacyTokenStateForUpdate, parseNonceBn, recordRollupDeposit, recordRollupWithdraw, resolveCharterMoniker, rollup_d_exports as rollup, rollup_block_d_exports as rollupBlock, sanitizeTokenSvg, stake_d_exports as stake, syncCharterAssetWithToken, syncTokenCharterOwnership, tables, toTokenCharterAssetAddress, token_d_exports as token, token_factory_d_exports as tokenFactory, tx_d_exports as tx, websiteToNftEndpoint };
|
package/esm/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { account_exports, parseNonceBn } from "./states/account.mjs";
|
|
2
2
|
import { asset_exports } from "./states/asset.mjs";
|
|
3
3
|
import { chain_exports } from "./states/chain.mjs";
|
|
4
4
|
import { delegation_exports } from "./states/delegation.mjs";
|
|
5
5
|
import { evidence_exports } from "./states/evidence.mjs";
|
|
6
6
|
import { factory_exports } from "./states/factory.mjs";
|
|
7
|
-
import { rollup_exports } from "./states/rollup.mjs";
|
|
7
|
+
import { VALID_ROLLUP_TARGET_TYPES, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isProposerSponsoredDepositAllowed, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, recordRollupDeposit, recordRollupWithdraw, rollup_exports } from "./states/rollup.mjs";
|
|
8
8
|
import { rollup_block_exports } from "./states/rollup-block.mjs";
|
|
9
9
|
import { stake_exports } from "./states/stake.mjs";
|
|
10
|
-
import { token_exports } from "./states/token.mjs";
|
|
11
10
|
import { token_factory_exports } from "./states/token-factory.mjs";
|
|
11
|
+
import { TOKEN_CHARTER_KIND, buildTokenCharterAssetData, buildTokenCharterAssetState, extractTokenUpdatesFromCharterAsset, iconToNftDisplay, isTokenCharterAsset, migrateTokensToCharterAssets, normalizeLegacyTokenStateForUpdate, resolveCharterMoniker, sanitizeTokenSvg, syncCharterAssetWithToken, syncTokenCharterOwnership, toTokenCharterAssetAddress, token_exports, websiteToNftEndpoint } from "./states/token.mjs";
|
|
12
12
|
import { tx_exports } from "./states/tx.mjs";
|
|
13
13
|
import blacklist_default from "./states/blacklist.mjs";
|
|
14
14
|
|
|
@@ -44,4 +44,4 @@ const tables = [
|
|
|
44
44
|
];
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
|
-
export { blacklist_default as Blacklist,
|
|
47
|
+
export { blacklist_default as Blacklist, TOKEN_CHARTER_KIND, VALID_ROLLUP_TARGET_TYPES, account_exports as account, asset_exports as asset, buildTokenCharterAssetData, buildTokenCharterAssetState, chain_exports as chain, delegation_exports as delegation, evidence_exports as evidence, extractTokenUpdatesFromCharterAsset, factory_exports as factory, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, iconToNftDisplay, indexes, isProposerSponsoredDepositAllowed, isTokenCharterAsset, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, migrateTokensToCharterAssets, normalizeLegacyTokenStateForUpdate, parseNonceBn, recordRollupDeposit, recordRollupWithdraw, resolveCharterMoniker, rollup_exports as rollup, rollup_block_exports as rollupBlock, sanitizeTokenSvg, stake_exports as stake, syncCharterAssetWithToken, syncTokenCharterOwnership, tables, toTokenCharterAssetAddress, token_exports as token, token_factory_exports as tokenFactory, tx_exports as tx, websiteToNftEndpoint };
|
package/esm/states/account.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { IAccountState } from "@ocap/types";
|
|
|
5
5
|
|
|
6
6
|
//#region src/states/account.d.ts
|
|
7
7
|
declare namespace account_d_exports {
|
|
8
|
-
export {
|
|
8
|
+
export { create, ensureChecksumAddress, isMigrated, parseNonceBn, schema, update, updateOrCreate, validate };
|
|
9
9
|
}
|
|
10
10
|
declare const schema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
11
11
|
readonly address: any;
|
|
@@ -25,12 +25,6 @@ declare const schema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
25
25
|
readonly data: v.OptionalSchema<v.NullableSchema<v.AnySchema, undefined>, undefined>;
|
|
26
26
|
}, undefined>, any]>;
|
|
27
27
|
declare const create: (attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
|
|
28
|
-
declare const PENDING_DEDUP_ACTIVATION_HEIGHT: number;
|
|
29
|
-
declare const CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS: Readonly<Record<string, number>>;
|
|
30
|
-
declare const EXPLICIT_HEIGHT_PATHS: readonly ["height", "blockHeight", "sequence", "ledgerSequence", "expectedLedgerSequence", "extra.height", "extra.blockHeight", "extra.sequence", "tx.height"];
|
|
31
|
-
declare const readExplicitHeight: (context: unknown) => number | undefined;
|
|
32
|
-
declare const resolveDedupActivationHeight: (context: unknown) => number;
|
|
33
|
-
declare const isExplicitlyPreActivation: (context: unknown) => boolean;
|
|
34
28
|
declare const parseNonceBn: (rawNonce: unknown) => InstanceType<typeof BN> | null;
|
|
35
29
|
declare const update: (state: IAccountState, attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
|
|
36
30
|
declare const updateOrCreate: (state: IAccountState | null, attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
|
|
@@ -40,4 +34,4 @@ declare const isMigrated: (state: {
|
|
|
40
34
|
}) => boolean;
|
|
41
35
|
declare const ensureChecksumAddress: (address: string) => string;
|
|
42
36
|
//#endregion
|
|
43
|
-
export {
|
|
37
|
+
export { account_d_exports, create, ensureChecksumAddress, isMigrated, parseNonceBn, schema, update, updateOrCreate, validate };
|
package/esm/states/account.mjs
CHANGED
|
@@ -5,23 +5,16 @@ import { isEthereumDid, toChecksumAddress } from "@arcblock/did/lib/type";
|
|
|
5
5
|
import { BN, toAddress, toBase58 } from "@ocap/util";
|
|
6
6
|
import { CustomError } from "@ocap/util/lib/error";
|
|
7
7
|
import flatten from "lodash/flatten.js";
|
|
8
|
-
import get from "lodash/get.js";
|
|
9
8
|
import pick from "lodash/pick.js";
|
|
10
9
|
import uniq from "lodash/uniq.js";
|
|
11
10
|
import { schemas, v, vBN, vBNMin, vDID, vFilteredRecord, vStripUnknown, vValidate } from "@arcblock/validator";
|
|
12
11
|
|
|
13
12
|
//#region src/states/account.ts
|
|
14
13
|
var account_exports = /* @__PURE__ */ __exportAll({
|
|
15
|
-
CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS: () => CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS,
|
|
16
|
-
EXPLICIT_HEIGHT_PATHS: () => EXPLICIT_HEIGHT_PATHS,
|
|
17
|
-
PENDING_DEDUP_ACTIVATION_HEIGHT: () => PENDING_DEDUP_ACTIVATION_HEIGHT,
|
|
18
14
|
create: () => create,
|
|
19
15
|
ensureChecksumAddress: () => ensureChecksumAddress,
|
|
20
|
-
isExplicitlyPreActivation: () => isExplicitlyPreActivation,
|
|
21
16
|
isMigrated: () => isMigrated,
|
|
22
17
|
parseNonceBn: () => parseNonceBn,
|
|
23
|
-
readExplicitHeight: () => readExplicitHeight,
|
|
24
|
-
resolveDedupActivationHeight: () => resolveDedupActivationHeight,
|
|
25
18
|
schema: () => schema,
|
|
26
19
|
update: () => update,
|
|
27
20
|
updateOrCreate: () => updateOrCreate,
|
|
@@ -67,57 +60,6 @@ const create = (attrs, context) => {
|
|
|
67
60
|
if (!account.moniker) account.moniker = [account.address.slice(0, 6), account.address.slice(-5)].join("-");
|
|
68
61
|
return validate(account);
|
|
69
62
|
};
|
|
70
|
-
const PENDING_DEDUP_ACTIVATION_HEIGHT = Number.MAX_SAFE_INTEGER;
|
|
71
|
-
const CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS = Object.freeze({
|
|
72
|
-
main: PENDING_DEDUP_ACTIVATION_HEIGHT,
|
|
73
|
-
"xenon-2020-01-15": PENDING_DEDUP_ACTIVATION_HEIGHT,
|
|
74
|
-
xenon: PENDING_DEDUP_ACTIVATION_HEIGHT,
|
|
75
|
-
beta: 1,
|
|
76
|
-
"test-chain": 1,
|
|
77
|
-
test: 1
|
|
78
|
-
});
|
|
79
|
-
const EXPLICIT_HEIGHT_PATHS = [
|
|
80
|
-
"height",
|
|
81
|
-
"blockHeight",
|
|
82
|
-
"sequence",
|
|
83
|
-
"ledgerSequence",
|
|
84
|
-
"expectedLedgerSequence",
|
|
85
|
-
"extra.height",
|
|
86
|
-
"extra.blockHeight",
|
|
87
|
-
"extra.sequence",
|
|
88
|
-
"tx.height"
|
|
89
|
-
];
|
|
90
|
-
const readExplicitHeight = (context) => {
|
|
91
|
-
for (const path of EXPLICIT_HEIGHT_PATHS) {
|
|
92
|
-
const val = get(context, path);
|
|
93
|
-
if (val !== void 0 && val !== null && val !== "") {
|
|
94
|
-
const parsed = Number(val);
|
|
95
|
-
if (Number.isFinite(parsed) && parsed >= 0) return Math.floor(parsed);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const resolveDedupActivationHeight = (context) => {
|
|
100
|
-
const rawChainId = get(context, "config.chainId") ?? get(context, "tx.chainId") ?? get(context, "chainId");
|
|
101
|
-
const chainId = typeof rawChainId === "string" ? rawChainId.trim() : "";
|
|
102
|
-
const registryHeight = chainId && Object.prototype.hasOwnProperty.call(CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS, chainId) ? CHAIN_UNSIGNED_TX_DEDUP_HEIGHTS[chainId] : void 0;
|
|
103
|
-
if (typeof registryHeight === "number" && Number.isFinite(registryHeight) && registryHeight > 1 && registryHeight < PENDING_DEDUP_ACTIVATION_HEIGHT) return Math.floor(registryHeight);
|
|
104
|
-
const rawConfig = get(context, "config.transaction.unsignedTxHashDedupHeight", 0);
|
|
105
|
-
const parsedConfig = Number(rawConfig);
|
|
106
|
-
if (Number.isFinite(parsedConfig) && parsedConfig > 0) return Math.floor(parsedConfig);
|
|
107
|
-
if (typeof registryHeight === "number" && Number.isFinite(registryHeight) && registryHeight > 0) return Math.floor(registryHeight);
|
|
108
|
-
if (chainId) return PENDING_DEDUP_ACTIVATION_HEIGHT;
|
|
109
|
-
return 0;
|
|
110
|
-
};
|
|
111
|
-
const isExplicitlyPreActivation = (context) => {
|
|
112
|
-
const explicitFlag = get(context, "dedupActive");
|
|
113
|
-
if (typeof explicitFlag === "boolean") return !explicitFlag;
|
|
114
|
-
const dedupHeight = resolveDedupActivationHeight(context);
|
|
115
|
-
if (!Number.isFinite(dedupHeight) || dedupHeight <= 0) return false;
|
|
116
|
-
const explicitHeight = readExplicitHeight(context);
|
|
117
|
-
if (explicitHeight !== void 0) return explicitHeight < dedupHeight;
|
|
118
|
-
if (dedupHeight >= PENDING_DEDUP_ACTIVATION_HEIGHT) return true;
|
|
119
|
-
return false;
|
|
120
|
-
};
|
|
121
63
|
const parseNonceBn = (rawNonce) => {
|
|
122
64
|
if (typeof rawNonce === "number") {
|
|
123
65
|
if (!Number.isFinite(rawNonce) || !Number.isInteger(rawNonce)) return null;
|
|
@@ -134,11 +76,7 @@ const update = (state, attrs, context) => {
|
|
|
134
76
|
const hasExplicitNonce = attrs.nonce !== void 0 && attrs.nonce !== null;
|
|
135
77
|
let shouldUpdateNonce = false;
|
|
136
78
|
let normalizedNonce;
|
|
137
|
-
if (hasExplicitNonce)
|
|
138
|
-
if (attrs.nonce && Number(attrs.nonce) <= Number(state.nonce)) throw new CustomError("INVALID_NONCE", "nonce must be greater in newer transactions");
|
|
139
|
-
shouldUpdateNonce = true;
|
|
140
|
-
normalizedNonce = attrs.nonce;
|
|
141
|
-
} else {
|
|
79
|
+
if (hasExplicitNonce) {
|
|
142
80
|
const incomingNonceBn = parseNonceBn(attrs.nonce);
|
|
143
81
|
const currentNonceBn = parseNonceBn(state.nonce) ?? new BN(0);
|
|
144
82
|
if (!incomingNonceBn || incomingNonceBn.lte(currentNonceBn) || incomingNonceBn.lte(new BN(0))) throw new CustomError("INVALID_NONCE", "nonce must be greater in newer transactions");
|
|
@@ -183,4 +121,4 @@ const isMigrated = (state) => (state.migratedTo || []).length > 0;
|
|
|
183
121
|
const ensureChecksumAddress = (address) => isEthereumDid(address) ? toChecksumAddress(address) : address;
|
|
184
122
|
|
|
185
123
|
//#endregion
|
|
186
|
-
export {
|
|
124
|
+
export { account_exports, create, ensureChecksumAddress, isMigrated, parseNonceBn, schema, update, updateOrCreate, validate };
|
package/esm/states/asset.mjs
CHANGED
package/esm/states/chain.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/rolldown_runtime.mjs";
|
|
2
2
|
import { create as create$1, update as update$1 } from "../contexts/state.mjs";
|
|
3
3
|
import { CustomError } from "@ocap/util/lib/error";
|
|
4
|
-
import get from "lodash/get.js";
|
|
5
4
|
import pick from "lodash/pick.js";
|
|
5
|
+
import get from "lodash/get.js";
|
|
6
6
|
import isEqual from "lodash/isEqual.js";
|
|
7
7
|
|
|
8
8
|
//#region src/states/chain.ts
|
|
@@ -34,8 +34,6 @@ const update = (state, updates) => {
|
|
|
34
34
|
];
|
|
35
35
|
if (!process.env.CHAIN_TOKEN_ADDRESS) immutableAttrs.push("token.name", "token.description", "token.unit", "token.totalSupply", "token.initialSupply", "token.foreignToken");
|
|
36
36
|
for (const attr of immutableAttrs) if (get(updates, attr) && !isEqual(get(updates, attr), get(state, attr))) throw new CustomError("FORBIDDEN", `Cannot update ${attr} field on chain state`);
|
|
37
|
-
const prevDedupHeight = Number(get(state, "transaction.unsignedTxHashDedupHeight", 0));
|
|
38
|
-
if (prevDedupHeight > 0 && updates.transaction !== void 0 && Number(get(updates, "transaction.unsignedTxHashDedupHeight", 0)) !== prevDedupHeight) throw new CustomError("FORBIDDEN", "Cannot update transaction.unsignedTxHashDedupHeight field on chain state");
|
|
39
37
|
const context = { txTime: (/* @__PURE__ */ new Date()).toISOString() };
|
|
40
38
|
return {
|
|
41
39
|
...state,
|
|
@@ -46,6 +46,8 @@ const create = (attrs, context) => {
|
|
|
46
46
|
if (delegation.deny === void 0 || delegation.deny === null) delegation.deny = [];
|
|
47
47
|
if (delegation.validUntil === void 0 || delegation.validUntil === null) delegation.validUntil = 0;
|
|
48
48
|
if (typeof delegation.address === "string") delegation.address = toAddress(delegation.address);
|
|
49
|
+
if (typeof delegation.to === "string" && delegation.to) delegation.to = toAddress(delegation.to);
|
|
50
|
+
if (typeof delegation.from === "string" && delegation.from) delegation.from = toAddress(delegation.from);
|
|
49
51
|
if (Array.isArray(delegation.ops)) delegation.ops = nullify(delegation.ops);
|
|
50
52
|
return validate(delegation);
|
|
51
53
|
};
|
|
@@ -18,10 +18,7 @@ const schema = v.pipe(v.object({
|
|
|
18
18
|
previousHash: v.optional(v.nullable(v.string())),
|
|
19
19
|
txsHash: v.pipe(v.string(), v.regex(patterns.txHash)),
|
|
20
20
|
txs: v.pipe(v.array(v.pipe(v.string(), v.regex(patterns.txHash))), v.minLength(1), v.check((arr) => new Set(arr).size === arr.length, "Must contain unique values")),
|
|
21
|
-
proposer: vDID({
|
|
22
|
-
prefix: true,
|
|
23
|
-
wallet: "ethereum"
|
|
24
|
-
}),
|
|
21
|
+
proposer: vDID({ prefix: true }),
|
|
25
22
|
signatures: v.pipe(schemas.multiSig, v.minLength(1)),
|
|
26
23
|
rollup: vDID({
|
|
27
24
|
prefix: true,
|
package/esm/states/rollup.d.mts
CHANGED
|
@@ -4,15 +4,31 @@ import { IRollupState } from "@ocap/types";
|
|
|
4
4
|
|
|
5
5
|
//#region src/states/rollup.d.ts
|
|
6
6
|
declare namespace rollup_d_exports {
|
|
7
|
-
export { close, create, migrateContract, migrateVault, pause, resume, schema, update, validate };
|
|
7
|
+
export { RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, close, create, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isProposerSponsoredDepositAllowed, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, migrateContract, migrateVault, pause, recordRollupDeposit, recordRollupWithdraw, resume, schema, update, validate };
|
|
8
8
|
}
|
|
9
|
+
type RollupTargetType = 'EVM' | 'OCAP_ISOMORPHIC';
|
|
10
|
+
interface RollupTokenReserve {
|
|
11
|
+
totalDeposited: string;
|
|
12
|
+
totalWithdrawn: string;
|
|
13
|
+
}
|
|
14
|
+
declare const VALID_ROLLUP_TARGET_TYPES: readonly RollupTargetType[];
|
|
15
|
+
declare function isValidRollupTargetType(value: unknown): value is RollupTargetType;
|
|
16
|
+
declare function getRollupTargetType(state?: Record<string, any> | null): RollupTargetType;
|
|
17
|
+
declare function isValidRollupContractAddress(address: unknown, targetType?: RollupTargetType): boolean;
|
|
18
|
+
declare function isValidRollupVaultAddress(address: unknown, targetType?: RollupTargetType): boolean;
|
|
19
|
+
declare function isValidRollupValidatorAddress(address: unknown, targetType?: RollupTargetType): boolean;
|
|
20
|
+
declare function getRollupSupportedTokens(state?: Record<string, any> | null): string[];
|
|
21
|
+
declare function isTokenSupportedByRollup(state: Record<string, any> | null | undefined, tokenAddress: string): boolean;
|
|
22
|
+
declare function isProposerSponsoredDepositAllowed(state?: Record<string, any> | null): boolean;
|
|
23
|
+
declare function hasRollupReserveTracking(state?: Record<string, any> | null): boolean;
|
|
24
|
+
declare function getRollupTokenReserve(state: Record<string, any> | null | undefined, tokenAddress: string): RollupTokenReserve;
|
|
9
25
|
declare const schema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
10
26
|
readonly address: any;
|
|
11
27
|
readonly tokenAddress: any;
|
|
12
|
-
readonly contractAddress:
|
|
13
|
-
readonly vaultAddress: v.OptionalSchema<v.NullableSchema<v.
|
|
14
|
-
readonly migrateHistory: v.OptionalSchema<v.ArraySchema<
|
|
15
|
-
readonly vaultHistory: v.OptionalSchema<v.ArraySchema<
|
|
28
|
+
readonly contractAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
29
|
+
readonly vaultAddress: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
30
|
+
readonly migrateHistory: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, readonly []>;
|
|
31
|
+
readonly vaultHistory: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, readonly []>;
|
|
16
32
|
readonly paused: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
17
33
|
readonly closed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
18
34
|
readonly seedValidators: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
@@ -59,6 +75,15 @@ declare const schema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
59
75
|
readonly leaveWaitingPeriod: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>, 0>;
|
|
60
76
|
readonly publishWaitingPeriod: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>, 0>;
|
|
61
77
|
readonly publishSlashRate: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 10000, undefined>]>;
|
|
78
|
+
readonly targetType: v.OptionalSchema<v.PicklistSchema<["EVM", "OCAP_ISOMORPHIC"], undefined>, undefined>;
|
|
79
|
+
readonly targetChainId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>]>, undefined>;
|
|
80
|
+
readonly supportedTokens: v.OptionalSchema<v.ArraySchema<any, undefined>, undefined>;
|
|
81
|
+
readonly reserves: v.OptionalSchema<v.RecordSchema<any, v.ObjectSchema<{
|
|
82
|
+
readonly totalDeposited: any;
|
|
83
|
+
readonly totalWithdrawn: any;
|
|
84
|
+
}, undefined>, undefined>, undefined>;
|
|
85
|
+
readonly allowProposerSponsor: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
86
|
+
readonly enforceReserveWatermark: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
62
87
|
readonly context: v.ObjectSchema<{
|
|
63
88
|
readonly genesisTime: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must be valid ISO date">]>;
|
|
64
89
|
readonly genesisTx: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must match tx hash pattern or be empty">]>;
|
|
@@ -66,14 +91,16 @@ declare const schema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
66
91
|
readonly renaissanceTx: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must match tx hash pattern or be empty">]>;
|
|
67
92
|
}, undefined>;
|
|
68
93
|
readonly data: v.OptionalSchema<v.NullableSchema<v.AnySchema, undefined>, undefined>;
|
|
69
|
-
}, undefined>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, any]>;
|
|
70
|
-
declare const create: (attrs: Partial<IRollupState>, context: StateContextInput) => IRollupState;
|
|
71
|
-
declare const update: (state: IRollupState, updates: Partial<IRollupState>, context: StateContextInput) => IRollupState;
|
|
94
|
+
}, undefined>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, v.BaseValidation<any, any, v.CheckIssue<any>>, any]>;
|
|
95
|
+
declare const create: (attrs: Partial<IRollupState> & Record<string, any>, context: StateContextInput) => IRollupState;
|
|
96
|
+
declare const update: (state: IRollupState, updates: Partial<IRollupState> & Record<string, any>, context: StateContextInput) => IRollupState;
|
|
72
97
|
declare const pause: (state: IRollupState, context: StateContextInput) => IRollupState;
|
|
73
98
|
declare const close: (state: IRollupState, context: StateContextInput) => IRollupState;
|
|
74
99
|
declare const resume: (state: IRollupState, context: StateContextInput) => IRollupState;
|
|
75
100
|
declare const migrateContract: (state: IRollupState, to: string, context: StateContextInput) => IRollupState;
|
|
76
101
|
declare const migrateVault: (state: IRollupState, to: string, context: StateContextInput) => IRollupState;
|
|
77
|
-
declare const
|
|
102
|
+
declare const recordRollupDeposit: (state: IRollupState & Record<string, any>, tokenAddress: string, amount: string, context: StateContextInput) => IRollupState;
|
|
103
|
+
declare const recordRollupWithdraw: (state: IRollupState & Record<string, any>, tokenAddress: string, amount: string, context: StateContextInput) => IRollupState;
|
|
104
|
+
declare const validate: (state: IRollupState & Record<string, any>) => IRollupState;
|
|
78
105
|
//#endregion
|
|
79
|
-
export { close, create, migrateContract, migrateVault, pause, resume, rollup_d_exports, schema, update, validate };
|
|
106
|
+
export { RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, close, create, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isProposerSponsoredDepositAllowed, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, migrateContract, migrateVault, pause, recordRollupDeposit, recordRollupWithdraw, resume, rollup_d_exports, schema, update, validate };
|