@ocap/tx-protocols 1.32.0 → 1.32.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/protocols/rollup/bridge-create.mjs +2 -1
- package/esm/protocols/rollup/bridge-governance-vote.mjs +3 -4
- package/esm/protocols/rollup/bridge-migrate.mjs +3 -6
- package/esm/protocols/rollup/create.mjs +5 -4
- package/esm/protocols/rollup/token-authority.d.mts +17 -0
- package/esm/protocols/rollup/token-authority.mjs +40 -0
- package/lib/protocols/rollup/bridge-create.cjs +2 -1
- package/lib/protocols/rollup/bridge-governance-vote.cjs +3 -4
- package/lib/protocols/rollup/bridge-migrate.cjs +3 -6
- package/lib/protocols/rollup/create.cjs +5 -4
- package/lib/protocols/rollup/token-authority.cjs +42 -0
- package/lib/protocols/rollup/token-authority.d.cts +17 -0
- package/package.json +16 -16
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { gatewayIndexKey, indexBlocks, indexData, isV1EvidenceRow, membershipDigest, recoverAll, reserveIndexKey, tokenIndexKey, txSecOf, upsertIndexEvidence } from "./bridge-v2.mjs";
|
|
2
|
+
import { resolveTokenAuthority } from "./token-authority.mjs";
|
|
2
3
|
import { BRIDGE_MEMBERSHIP_ACTION, computeBridgeOwnerAttestationDigest, recoverBridgeSigner } from "@ocap/mcrypto";
|
|
3
4
|
import { CustomError } from "@ocap/util/lib/error";
|
|
4
5
|
import { isEthereumDid } from "@arcblock/did";
|
|
@@ -27,7 +28,7 @@ async function verifyBridgeCreate(context, next) {
|
|
|
27
28
|
const { tx: tx$1, itx, config, tokenState, statedb } = context;
|
|
28
29
|
const input = context.bridgeInput;
|
|
29
30
|
const txSec = txSecOf(context);
|
|
30
|
-
const authority =
|
|
31
|
+
const authority = await resolveTokenAuthority(context, itx.tokenAddress, tokenState);
|
|
31
32
|
const owner = [tx$1.from, tx$1.delegator].filter(Boolean).find((x) => isSameDid(x, authority));
|
|
32
33
|
if (!owner) return next(new CustomError("FORBIDDEN", "Only the token owner can create a bridge for the token"));
|
|
33
34
|
if (!isEthereumDid(owner)) return next(new CustomError("INVALID_TX", "The bridge owner must use an ethereum compatible address"));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isV1EvidenceRow, membershipTombstoneKey } from "./bridge-v2.mjs";
|
|
2
|
+
import { isOfficialToken, resolveTokenAuthority } from "./token-authority.mjs";
|
|
2
3
|
import { verifyOcapProposalTxBinding } from "./bridge-governance-tx-binding.mjs";
|
|
3
4
|
import { MAX_GOV_DOC_JSON_BYTES, assertAllowedKeys, assertPlainObject, assertValidProposalTitle, assertValidRationaleUrl, bridgeGovDocKey, bridgeGovIndexKey, buildCertFromProposal, canonicalJson, checkedBytes32, checkedNonZeroAddress, coerceEvmProposal, coerceOcapProposal, computeBridgeMembershipDigest, computeGovernanceCertDigest, computeOcapProposalId, membershipFromOcapProposal, recoverArcBlockTxEnvelopeSigner, recoverGovernanceCertSigner, recoverOcapMembershipProposalSigner, serializeEvmProposal, serializeOcapProposal, signerManagerFor, toHexDigest, toJsonSafeValue, utf8ByteLength } from "@ocap/mcrypto";
|
|
4
5
|
import { CustomError } from "@ocap/util/lib/error";
|
|
5
6
|
import { account, evidence, rollup } from "@ocap/state";
|
|
6
|
-
import { isSameDid } from "@ocap/util";
|
|
7
7
|
|
|
8
8
|
//#region src/protocols/rollup/bridge-governance-vote.ts
|
|
9
9
|
/**
|
|
@@ -144,9 +144,8 @@ async function verifyAndScoreOcapVote(context, proposal, voteRec, envelope, exis
|
|
|
144
144
|
if (signer !== owner && !activeValidators.has(signer)) invalidSig("Pauser-only key cannot submit govProposalVote; submit PauseRollupTx directly");
|
|
145
145
|
role = "pauser";
|
|
146
146
|
} else if (action.kind === "migrate_rollup" && action.migrateKind === "reserve" && action.step === "cancel") {
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const authority = isOfficial ? context.config?.moderator?.address : tokenState?.issuer;
|
|
147
|
+
const tokenState = isOfficialToken(context.config, rollupState.tokenAddress) ? null : await context.statedb.token.get(rollupState.tokenAddress, context);
|
|
148
|
+
const authority = await resolveTokenAuthority(context, rollupState.tokenAddress, tokenState);
|
|
150
149
|
if (!authority || !rollup.sameAddress(authority, signer)) invalidSig(`Signer ${signer} is not the token authority`);
|
|
151
150
|
role = "authority";
|
|
152
151
|
} else if (action.kind === "update_rollup" && action.patch.cancelOwnerProposal === true) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VerifyBridgeAuthority, bridgeUpdates, readItxData } from "./bridge-v2.mjs";
|
|
2
|
+
import { resolveTokenAuthority } from "./token-authority.mjs";
|
|
2
3
|
import { CustomError } from "@ocap/util/lib/error";
|
|
3
4
|
import { getListField } from "@ocap/util/lib/get-list-field";
|
|
4
5
|
import { toBridgeReserveAddress } from "@arcblock/did-util";
|
|
@@ -36,11 +37,6 @@ const migrateSchemaV2 = function MigrateSchemaV2(context, next) {
|
|
|
36
37
|
};
|
|
37
38
|
const TOKEN_AUTHORITY_ERROR = "Only the token authority can cancel a reserve migration";
|
|
38
39
|
const ZERO_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
39
|
-
/** The token authority of #1411: the moderator for the official token, the token issuer otherwise. */
|
|
40
|
-
function tokenAuthority(context, tokenState) {
|
|
41
|
-
const { config } = context;
|
|
42
|
-
return !!config?.token?.address && isSameDid(context.rollupState.tokenAddress, config.token.address) ? config?.moderator?.address : tokenState?.issuer;
|
|
43
|
-
}
|
|
44
40
|
async function migrateBridgeChecks(context, next) {
|
|
45
41
|
if (!context.isBridgeV2) return next();
|
|
46
42
|
const { itx, statedb } = context;
|
|
@@ -68,7 +64,8 @@ async function migrateBridgeChecks(context, next) {
|
|
|
68
64
|
].includes(action)) throw new CustomError("INVALID_TX", "itx.data.action must be announce, execute or cancel");
|
|
69
65
|
if (action === "cancel") {
|
|
70
66
|
if (!body.pendingMigration) throw new CustomError("INVALID_TX", "There is no pending reserve migration to cancel");
|
|
71
|
-
|
|
67
|
+
const tokenState = await statedb.token.get(state.tokenAddress, context);
|
|
68
|
+
context.tokenAuthority = await resolveTokenAuthority(context, state.tokenAddress, tokenState);
|
|
72
69
|
context.migratePlan = { kind: "cancel" };
|
|
73
70
|
return next();
|
|
74
71
|
}
|
|
@@ -2,6 +2,7 @@ import { decodeAnySafe, getDelegationRequirements } 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
4
|
import { indexBlocks, isRollupV1Enabled, tokenIndexKey } from "./bridge-v2.mjs";
|
|
5
|
+
import { isOfficialToken, resolveTokenAuthority } from "./token-authority.mjs";
|
|
5
6
|
import { createBridgeStep, verifyBridgeCreate } from "./bridge-create.mjs";
|
|
6
7
|
import { Runner, pipes } from "@ocap/tx-pipeline";
|
|
7
8
|
import { CustomError } from "@ocap/util/lib/error";
|
|
@@ -143,12 +144,12 @@ runner.use(pipes.VerifyInfo([{
|
|
|
143
144
|
return isEmpty(ctx.tokenState?.foreignToken) === false;
|
|
144
145
|
}
|
|
145
146
|
}]));
|
|
146
|
-
runner.use((context, next) => {
|
|
147
|
+
runner.use(async (context, next) => {
|
|
147
148
|
const { tx: tx$1, itx, config, tokenState } = context;
|
|
148
|
-
const
|
|
149
|
-
const authority =
|
|
149
|
+
const isOfficial = isOfficialToken(config, itx.tokenAddress);
|
|
150
|
+
const authority = await resolveTokenAuthority(context, itx.tokenAddress, tokenState);
|
|
150
151
|
const creators = [tx$1.from, tx$1.delegator].filter(Boolean);
|
|
151
|
-
if (!authority || !creators.some((x) => isSameDid(x, authority))) return next(new CustomError("FORBIDDEN",
|
|
152
|
+
if (!authority || !creators.some((x) => isSameDid(x, authority))) return next(new CustomError("FORBIDDEN", isOfficial ? "Only the chain moderator can create a rollup for the official token" : "Only the token issuer can create a rollup for the token"));
|
|
152
153
|
return next();
|
|
153
154
|
});
|
|
154
155
|
runner.use(async (context, next) => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/protocols/rollup/token-authority.d.ts
|
|
2
|
+
type Ctx = any;
|
|
3
|
+
/** Whether `tokenAddress` is the chain's official token. */
|
|
4
|
+
declare const isOfficialToken: (config: Ctx, tokenAddress: string) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The configured authority (`config.moderator.address` or `tokenState.issuer`) resolved along the account migration
|
|
7
|
+
* chain to its TERMINAL account (#1795). The configured address stays the old one after `account_migrate`, so only the
|
|
8
|
+
* account it migrated to (transitively) may act; the old address and any intermediate address of the chain are never
|
|
9
|
+
* an authority, and neither are the related addresses of the account.
|
|
10
|
+
*
|
|
11
|
+
* - not migrated: the configured address, unchanged;
|
|
12
|
+
* - no account at all: the configured address, unchanged (an account that does not exist was never migrated);
|
|
13
|
+
* - the chain is broken (cycle or a missing target): no authority, fail closed.
|
|
14
|
+
*/
|
|
15
|
+
declare function resolveTokenAuthority(context: Ctx, tokenAddress: string, tokenState?: Ctx): Promise<string | undefined>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isOfficialToken, resolveTokenAuthority };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isSameDid } from "@ocap/util";
|
|
2
|
+
|
|
3
|
+
//#region src/protocols/rollup/token-authority.ts
|
|
4
|
+
/**
|
|
5
|
+
* The token authority of a rollup / bridge (#1411): the chain moderator for the official token, the token issuer for
|
|
6
|
+
* any other token. Shared by create_rollup, the v2 bridge create, and the reserve migration cancel (direct and by
|
|
7
|
+
* governance vote).
|
|
8
|
+
*/
|
|
9
|
+
/** Whether `tokenAddress` is the chain's official token. */
|
|
10
|
+
const isOfficialToken = (config, tokenAddress) => !!config?.token?.address && isSameDid(tokenAddress, config.token.address);
|
|
11
|
+
/**
|
|
12
|
+
* The configured authority (`config.moderator.address` or `tokenState.issuer`) resolved along the account migration
|
|
13
|
+
* chain to its TERMINAL account (#1795). The configured address stays the old one after `account_migrate`, so only the
|
|
14
|
+
* account it migrated to (transitively) may act; the old address and any intermediate address of the chain are never
|
|
15
|
+
* an authority, and neither are the related addresses of the account.
|
|
16
|
+
*
|
|
17
|
+
* - not migrated: the configured address, unchanged;
|
|
18
|
+
* - no account at all: the configured address, unchanged (an account that does not exist was never migrated);
|
|
19
|
+
* - the chain is broken (cycle or a missing target): no authority, fail closed.
|
|
20
|
+
*/
|
|
21
|
+
async function resolveTokenAuthority(context, tokenAddress, tokenState) {
|
|
22
|
+
const { config, statedb } = context;
|
|
23
|
+
const configured = isOfficialToken(config, tokenAddress) ? config?.moderator?.address : tokenState?.issuer;
|
|
24
|
+
if (!configured) return void 0;
|
|
25
|
+
const terminal = await statedb.account.get(configured, {
|
|
26
|
+
...context,
|
|
27
|
+
traceMigration: true
|
|
28
|
+
});
|
|
29
|
+
if (terminal) {
|
|
30
|
+
if (!terminal.address) return void 0;
|
|
31
|
+
return isSameDid(terminal.address, configured) ? configured : terminal.address;
|
|
32
|
+
}
|
|
33
|
+
return await statedb.account.get(configured, {
|
|
34
|
+
...context,
|
|
35
|
+
traceMigration: false
|
|
36
|
+
}) ? void 0 : configured;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { isOfficialToken, resolveTokenAuthority };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
|
|
3
|
+
const require_protocols_rollup_token_authority = require('./token-authority.cjs');
|
|
3
4
|
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
4
5
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
5
6
|
let _arcblock_did = require("@arcblock/did");
|
|
@@ -29,7 +30,7 @@ async function verifyBridgeCreate(context, next) {
|
|
|
29
30
|
const { tx, itx, config, tokenState, statedb } = context;
|
|
30
31
|
const input = context.bridgeInput;
|
|
31
32
|
const txSec = require_protocols_rollup_bridge_v2.txSecOf(context);
|
|
32
|
-
const authority =
|
|
33
|
+
const authority = await require_protocols_rollup_token_authority.resolveTokenAuthority(context, itx.tokenAddress, tokenState);
|
|
33
34
|
const owner = [tx.from, tx.delegator].filter(Boolean).find((x) => (0, _ocap_util.isSameDid)(x, authority));
|
|
34
35
|
if (!owner) return next(new _ocap_util_lib_error.CustomError("FORBIDDEN", "Only the token owner can create a bridge for the token"));
|
|
35
36
|
if (!(0, _arcblock_did.isEthereumDid)(owner)) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "The bridge owner must use an ethereum compatible address"));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
|
|
3
|
+
const require_protocols_rollup_token_authority = require('./token-authority.cjs');
|
|
3
4
|
const require_protocols_rollup_bridge_governance_tx_binding = require('./bridge-governance-tx-binding.cjs');
|
|
4
5
|
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
5
6
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
6
7
|
let _ocap_state = require("@ocap/state");
|
|
7
|
-
let _ocap_util = require("@ocap/util");
|
|
8
8
|
let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
|
|
9
9
|
|
|
10
10
|
//#region src/protocols/rollup/bridge-governance-vote.ts
|
|
@@ -146,9 +146,8 @@ async function verifyAndScoreOcapVote(context, proposal, voteRec, envelope, exis
|
|
|
146
146
|
if (signer !== owner && !activeValidators.has(signer)) invalidSig("Pauser-only key cannot submit govProposalVote; submit PauseRollupTx directly");
|
|
147
147
|
role = "pauser";
|
|
148
148
|
} else if (action.kind === "migrate_rollup" && action.migrateKind === "reserve" && action.step === "cancel") {
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const authority = isOfficial ? context.config?.moderator?.address : tokenState?.issuer;
|
|
149
|
+
const tokenState = require_protocols_rollup_token_authority.isOfficialToken(context.config, rollupState.tokenAddress) ? null : await context.statedb.token.get(rollupState.tokenAddress, context);
|
|
150
|
+
const authority = await require_protocols_rollup_token_authority.resolveTokenAuthority(context, rollupState.tokenAddress, tokenState);
|
|
152
151
|
if (!authority || !_ocap_state.rollup.sameAddress(authority, signer)) invalidSig(`Signer ${signer} is not the token authority`);
|
|
153
152
|
role = "authority";
|
|
154
153
|
} else if (action.kind === "update_rollup" && action.patch.cancelOwnerProposal === true) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
|
|
3
|
+
const require_protocols_rollup_token_authority = require('./token-authority.cjs');
|
|
3
4
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
4
5
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
5
6
|
let _arcblock_did_util = require("@arcblock/did-util");
|
|
@@ -37,11 +38,6 @@ const migrateSchemaV2 = function MigrateSchemaV2(context, next) {
|
|
|
37
38
|
};
|
|
38
39
|
const TOKEN_AUTHORITY_ERROR = "Only the token authority can cancel a reserve migration";
|
|
39
40
|
const ZERO_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
40
|
-
/** The token authority of #1411: the moderator for the official token, the token issuer otherwise. */
|
|
41
|
-
function tokenAuthority(context, tokenState) {
|
|
42
|
-
const { config } = context;
|
|
43
|
-
return !!config?.token?.address && (0, _ocap_util.isSameDid)(context.rollupState.tokenAddress, config.token.address) ? config?.moderator?.address : tokenState?.issuer;
|
|
44
|
-
}
|
|
45
41
|
async function migrateBridgeChecks(context, next) {
|
|
46
42
|
if (!context.isBridgeV2) return next();
|
|
47
43
|
const { itx, statedb } = context;
|
|
@@ -69,7 +65,8 @@ async function migrateBridgeChecks(context, next) {
|
|
|
69
65
|
].includes(action)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "itx.data.action must be announce, execute or cancel");
|
|
70
66
|
if (action === "cancel") {
|
|
71
67
|
if (!body.pendingMigration) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "There is no pending reserve migration to cancel");
|
|
72
|
-
|
|
68
|
+
const tokenState = await statedb.token.get(state.tokenAddress, context);
|
|
69
|
+
context.tokenAuthority = await require_protocols_rollup_token_authority.resolveTokenAuthority(context, state.tokenAddress, tokenState);
|
|
73
70
|
context.migratePlan = { kind: "cancel" };
|
|
74
71
|
return next();
|
|
75
72
|
}
|
|
@@ -4,6 +4,7 @@ const require_util = require('../../util.cjs');
|
|
|
4
4
|
const require_pipes_ensure_cost = require('../../pipes/ensure-cost.cjs');
|
|
5
5
|
const require_pipes_ensure_gas = require('../../pipes/ensure-gas.cjs');
|
|
6
6
|
const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
|
|
7
|
+
const require_protocols_rollup_token_authority = require('./token-authority.cjs');
|
|
7
8
|
const require_protocols_rollup_bridge_create = require('./bridge-create.cjs');
|
|
8
9
|
let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
|
|
9
10
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
@@ -148,12 +149,12 @@ runner.use(_ocap_tx_pipeline.pipes.VerifyInfo([{
|
|
|
148
149
|
return (0, lodash_isEmpty.default)(ctx.tokenState?.foreignToken) === false;
|
|
149
150
|
}
|
|
150
151
|
}]));
|
|
151
|
-
runner.use((context, next) => {
|
|
152
|
+
runner.use(async (context, next) => {
|
|
152
153
|
const { tx, itx, config, tokenState } = context;
|
|
153
|
-
const
|
|
154
|
-
const authority =
|
|
154
|
+
const isOfficial = require_protocols_rollup_token_authority.isOfficialToken(config, itx.tokenAddress);
|
|
155
|
+
const authority = await require_protocols_rollup_token_authority.resolveTokenAuthority(context, itx.tokenAddress, tokenState);
|
|
155
156
|
const creators = [tx.from, tx.delegator].filter(Boolean);
|
|
156
|
-
if (!authority || !creators.some((x) => (0, _ocap_util.isSameDid)(x, authority))) return next(new _ocap_util_lib_error.CustomError("FORBIDDEN",
|
|
157
|
+
if (!authority || !creators.some((x) => (0, _ocap_util.isSameDid)(x, authority))) return next(new _ocap_util_lib_error.CustomError("FORBIDDEN", isOfficial ? "Only the chain moderator can create a rollup for the official token" : "Only the token issuer can create a rollup for the token"));
|
|
157
158
|
return next();
|
|
158
159
|
});
|
|
159
160
|
runner.use(async (context, next) => {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let _ocap_util = require("@ocap/util");
|
|
3
|
+
|
|
4
|
+
//#region src/protocols/rollup/token-authority.ts
|
|
5
|
+
/**
|
|
6
|
+
* The token authority of a rollup / bridge (#1411): the chain moderator for the official token, the token issuer for
|
|
7
|
+
* any other token. Shared by create_rollup, the v2 bridge create, and the reserve migration cancel (direct and by
|
|
8
|
+
* governance vote).
|
|
9
|
+
*/
|
|
10
|
+
/** Whether `tokenAddress` is the chain's official token. */
|
|
11
|
+
const isOfficialToken = (config, tokenAddress) => !!config?.token?.address && (0, _ocap_util.isSameDid)(tokenAddress, config.token.address);
|
|
12
|
+
/**
|
|
13
|
+
* The configured authority (`config.moderator.address` or `tokenState.issuer`) resolved along the account migration
|
|
14
|
+
* chain to its TERMINAL account (#1795). The configured address stays the old one after `account_migrate`, so only the
|
|
15
|
+
* account it migrated to (transitively) may act; the old address and any intermediate address of the chain are never
|
|
16
|
+
* an authority, and neither are the related addresses of the account.
|
|
17
|
+
*
|
|
18
|
+
* - not migrated: the configured address, unchanged;
|
|
19
|
+
* - no account at all: the configured address, unchanged (an account that does not exist was never migrated);
|
|
20
|
+
* - the chain is broken (cycle or a missing target): no authority, fail closed.
|
|
21
|
+
*/
|
|
22
|
+
async function resolveTokenAuthority(context, tokenAddress, tokenState) {
|
|
23
|
+
const { config, statedb } = context;
|
|
24
|
+
const configured = isOfficialToken(config, tokenAddress) ? config?.moderator?.address : tokenState?.issuer;
|
|
25
|
+
if (!configured) return void 0;
|
|
26
|
+
const terminal = await statedb.account.get(configured, {
|
|
27
|
+
...context,
|
|
28
|
+
traceMigration: true
|
|
29
|
+
});
|
|
30
|
+
if (terminal) {
|
|
31
|
+
if (!terminal.address) return void 0;
|
|
32
|
+
return (0, _ocap_util.isSameDid)(terminal.address, configured) ? configured : terminal.address;
|
|
33
|
+
}
|
|
34
|
+
return await statedb.account.get(configured, {
|
|
35
|
+
...context,
|
|
36
|
+
traceMigration: false
|
|
37
|
+
}) ? void 0 : configured;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.isOfficialToken = isOfficialToken;
|
|
42
|
+
exports.resolveTokenAuthority = resolveTokenAuthority;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/protocols/rollup/token-authority.d.ts
|
|
2
|
+
type Ctx = any;
|
|
3
|
+
/** Whether `tokenAddress` is the chain's official token. */
|
|
4
|
+
declare const isOfficialToken: (config: Ctx, tokenAddress: string) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The configured authority (`config.moderator.address` or `tokenState.issuer`) resolved along the account migration
|
|
7
|
+
* chain to its TERMINAL account (#1795). The configured address stays the old one after `account_migrate`, so only the
|
|
8
|
+
* account it migrated to (transitively) may act; the old address and any intermediate address of the chain are never
|
|
9
|
+
* an authority, and neither are the related addresses of the account.
|
|
10
|
+
*
|
|
11
|
+
* - not migrated: the configured address, unchanged;
|
|
12
|
+
* - no account at all: the configured address, unchanged (an account that does not exist was never migrated);
|
|
13
|
+
* - the chain is broken (cycle or a missing target): no authority, fail closed.
|
|
14
|
+
*/
|
|
15
|
+
declare function resolveTokenAuthority(context: Ctx, tokenAddress: string, tokenState?: Ctx): Promise<string | undefined>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isOfficialToken, resolveTokenAuthority };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.32.
|
|
6
|
+
"version": "1.32.1",
|
|
7
7
|
"description": "Predefined tx pipeline sets to execute certain type of transactions",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -46,22 +46,22 @@
|
|
|
46
46
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@arcblock/did": "1.32.
|
|
50
|
-
"@arcblock/did-util": "1.32.
|
|
51
|
-
"@arcblock/jwt": "1.32.
|
|
52
|
-
"@arcblock/validator": "1.32.
|
|
53
|
-
"@arcblock/vc": "1.32.
|
|
49
|
+
"@arcblock/did": "1.32.1",
|
|
50
|
+
"@arcblock/did-util": "1.32.1",
|
|
51
|
+
"@arcblock/jwt": "1.32.1",
|
|
52
|
+
"@arcblock/validator": "1.32.1",
|
|
53
|
+
"@arcblock/vc": "1.32.1",
|
|
54
54
|
"@blocklet/xss": "^0.3.7",
|
|
55
|
-
"@ocap/asset": "1.32.
|
|
56
|
-
"@ocap/client": "1.32.
|
|
57
|
-
"@ocap/mcrypto": "1.32.
|
|
58
|
-
"@ocap/merkle-tree": "1.32.
|
|
59
|
-
"@ocap/message": "1.32.
|
|
60
|
-
"@ocap/state": "1.32.
|
|
61
|
-
"@ocap/tx-pipeline": "1.32.
|
|
62
|
-
"@ocap/types": "1.32.
|
|
63
|
-
"@ocap/util": "1.32.
|
|
64
|
-
"@ocap/wallet": "1.32.
|
|
55
|
+
"@ocap/asset": "1.32.1",
|
|
56
|
+
"@ocap/client": "1.32.1",
|
|
57
|
+
"@ocap/mcrypto": "1.32.1",
|
|
58
|
+
"@ocap/merkle-tree": "1.32.1",
|
|
59
|
+
"@ocap/message": "1.32.1",
|
|
60
|
+
"@ocap/state": "1.32.1",
|
|
61
|
+
"@ocap/tx-pipeline": "1.32.1",
|
|
62
|
+
"@ocap/types": "1.32.1",
|
|
63
|
+
"@ocap/util": "1.32.1",
|
|
64
|
+
"@ocap/wallet": "1.32.1",
|
|
65
65
|
"debug": "^4.4.3",
|
|
66
66
|
"deep-diff": "^1.0.2",
|
|
67
67
|
"lodash": "^4.17.23",
|