@ixo/editor 5.25.0 → 5.27.0
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/dist/{chunk-VECEVZ6B.mjs → chunk-MP7Q5F3L.mjs} +3914 -1789
- package/dist/chunk-MP7Q5F3L.mjs.map +1 -0
- package/dist/{chunk-UMS6GCME.mjs → chunk-W5M4NLHK.mjs} +935 -6
- package/dist/chunk-W5M4NLHK.mjs.map +1 -0
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.mjs +1 -1
- package/dist/{graphql-client-DrJ0WoCv.d.ts → graphql-client-C2YnVMPy.d.ts} +1 -1
- package/dist/{index-CU_uhH5a.d.ts → index-Bdh5jcT4.d.ts} +33 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/mantine/index.d.ts +3 -3
- package/dist/mantine/index.mjs +2 -2
- package/dist/{store-tXzh_kNG.d.ts → store-CiuZEEsv.d.ts} +438 -1
- package/package.json +1 -1
- package/dist/chunk-UMS6GCME.mjs.map +0 -1
- package/dist/chunk-VECEVZ6B.mjs.map +0 -1
|
@@ -206,6 +206,32 @@ function buildServicesFromHandlers(handlers) {
|
|
|
206
206
|
matrix: handlers?.storeMatrixCredential ? {
|
|
207
207
|
storeCredential: async (params) => handlers.storeMatrixCredential(params)
|
|
208
208
|
} : void 0,
|
|
209
|
+
// Claim-collection lifecycle service (IXO-2573/2579). The consumer exposes
|
|
210
|
+
// a fully-formed `handlers.collection` service group (get + create + the
|
|
211
|
+
// five updates); wire each method straight through. The core run()
|
|
212
|
+
// dispatcher resolves admin from the on-chain collection.admin and
|
|
213
|
+
// re-fetches via `get` after every write, so we only forward calls here.
|
|
214
|
+
collection: handlers?.collection?.get && handlers?.collection?.create && handlers?.collection?.updateState && handlers?.collection?.updateDates && handlers?.collection?.updateQuota && handlers?.collection?.updatePayments && handlers?.collection?.updateIntents ? {
|
|
215
|
+
get: async (params) => handlers.collection.get(params),
|
|
216
|
+
create: async (params) => handlers.collection.create(params),
|
|
217
|
+
updateState: async (params) => handlers.collection.updateState(params),
|
|
218
|
+
updateDates: async (params) => handlers.collection.updateDates(params),
|
|
219
|
+
updateQuota: async (params) => handlers.collection.updateQuota(params),
|
|
220
|
+
updatePayments: async (params) => handlers.collection.updatePayments(params),
|
|
221
|
+
updateIntents: async (params) => handlers.collection.updateIntents(params)
|
|
222
|
+
} : void 0,
|
|
223
|
+
// Claim-collection user-management service (IXO-2586). The consumer exposes a
|
|
224
|
+
// fully-formed `handlers.collectionUsers` service group (grant + revoke +
|
|
225
|
+
// list + classifyAddress + enumerateMembers); wire each method straight
|
|
226
|
+
// through. The core run() dispatcher validates inputs and proof-guards the
|
|
227
|
+
// results, so we only forward calls here.
|
|
228
|
+
collectionUsers: handlers?.collectionUsers?.grant && handlers?.collectionUsers?.revoke && handlers?.collectionUsers?.list && handlers?.collectionUsers?.classifyAddress && handlers?.collectionUsers?.enumerateMembers ? {
|
|
229
|
+
grant: async (params) => handlers.collectionUsers.grant(params),
|
|
230
|
+
revoke: async (params) => handlers.collectionUsers.revoke(params),
|
|
231
|
+
list: async (params) => handlers.collectionUsers.list(params),
|
|
232
|
+
classifyAddress: async (params) => handlers.collectionUsers.classifyAddress(params),
|
|
233
|
+
enumerateMembers: async (params) => handlers.collectionUsers.enumerateMembers(params)
|
|
234
|
+
} : void 0,
|
|
209
235
|
integrations: handlers?.integrations?.executeTool ? {
|
|
210
236
|
executeTool: async (args) => handlers.integrations.executeTool(args),
|
|
211
237
|
fetchCurrentState: handlers.integrations.fetchCurrentState ? async (args) => handlers.integrations.fetchCurrentState(args) : void 0,
|
|
@@ -234,6 +260,15 @@ function buildServicesFromHandlers(handlers) {
|
|
|
234
260
|
updateOracleDomain: handlers.updateOracleDomain || (async () => {
|
|
235
261
|
throw new Error("updateOracleDomain handler not configured");
|
|
236
262
|
})
|
|
263
|
+
} : void 0,
|
|
264
|
+
// Carbon credit batch service (IXO-2675). The consumer exposes a
|
|
265
|
+
// fully-formed `handlers.carbon` service group (loadBatches + harvest +
|
|
266
|
+
// retire); wire each method straight through. The harvest/retire calls are
|
|
267
|
+
// user-signed inside the consumer handler — we only forward here.
|
|
268
|
+
carbon: handlers?.carbon?.loadBatches && handlers?.carbon?.harvest && handlers?.carbon?.retire ? {
|
|
269
|
+
loadBatches: async (params) => handlers.carbon.loadBatches(params),
|
|
270
|
+
harvest: async (params) => handlers.carbon.harvest(params),
|
|
271
|
+
retire: async (params) => handlers.carbon.retire(params)
|
|
237
272
|
} : void 0
|
|
238
273
|
};
|
|
239
274
|
}
|
|
@@ -4866,6 +4901,478 @@ registerAction({
|
|
|
4866
4901
|
}
|
|
4867
4902
|
});
|
|
4868
4903
|
|
|
4904
|
+
// src/core/lib/actionRegistry/actions/collection/index.ts
|
|
4905
|
+
var COLLECTION_LIFECYCLE_ACTION_TYPE = "qi/collection.lifecycle";
|
|
4906
|
+
var COLLECTION_LIFECYCLE_OUTPUT_SCHEMA = [
|
|
4907
|
+
{ path: "collectionId", displayName: "Collection ID", type: "string", description: "Chain-assigned collection identifier" },
|
|
4908
|
+
{ path: "entity", displayName: "Entity DID", type: "string", description: "Entity (deed) DID the collection belongs to" },
|
|
4909
|
+
{ path: "protocol", displayName: "Protocol", type: "string", description: "Protocol DID/id the collection follows" },
|
|
4910
|
+
{ path: "admin", displayName: "Admin Address", type: "string", description: "Address authorised to mutate the collection" },
|
|
4911
|
+
{ path: "state", displayName: "State", type: "number", description: "Lifecycle state (0=OPEN, 1=PAUSED, 2=CLOSED)" },
|
|
4912
|
+
{ path: "startDate", displayName: "Start Date", type: "string", description: "ISO-8601 start date" },
|
|
4913
|
+
{ path: "endDate", displayName: "End Date", type: "string", description: "ISO-8601 end date" },
|
|
4914
|
+
{ path: "quota", displayName: "Quota", type: "string", description: "Max claims; 0 = unlimited" },
|
|
4915
|
+
{ path: "count", displayName: "Count", type: "string", description: "Number of claims submitted" },
|
|
4916
|
+
{ path: "evaluated", displayName: "Evaluated", type: "string", description: "Number of claims evaluated" },
|
|
4917
|
+
{ path: "approved", displayName: "Approved", type: "string", description: "Number of approved claims" },
|
|
4918
|
+
{ path: "rejected", displayName: "Rejected", type: "string", description: "Number of rejected claims" },
|
|
4919
|
+
{ path: "disputed", displayName: "Disputed", type: "string", description: "Number of disputed claims" },
|
|
4920
|
+
{ path: "payments", displayName: "Payments", type: "object", description: "Payment legs (submission/evaluation/approval/rejection)" },
|
|
4921
|
+
{ path: "intents", displayName: "Intents", type: "object", description: "Intent configuration" }
|
|
4922
|
+
];
|
|
4923
|
+
var COLLECTION_CREATED_EVENT_NAME = "created";
|
|
4924
|
+
var COLLECTION_CREATED_EVENT = {
|
|
4925
|
+
name: COLLECTION_CREATED_EVENT_NAME,
|
|
4926
|
+
displayName: "Collection created",
|
|
4927
|
+
description: "Fires once when a new claim collection is created on-chain. Carries the collection id, entity (deed) DID and protocol so a listener can manage the new collection.",
|
|
4928
|
+
payloadSchema: [
|
|
4929
|
+
{ path: "collectionId", displayName: "Collection ID", type: "string", description: "Chain-assigned collection identifier" },
|
|
4930
|
+
{ path: "entity", displayName: "Entity DID", type: "string", description: "Entity (deed) DID the collection belongs to" },
|
|
4931
|
+
{ path: "protocol", displayName: "Protocol", type: "string", description: "Protocol DID/id the collection follows" },
|
|
4932
|
+
{ path: "transactionHash", displayName: "Tx Hash", type: "string", description: "MsgCreateCollection broadcast transaction hash" }
|
|
4933
|
+
],
|
|
4934
|
+
pendingDisplayFields: ["collectionId", "entity"]
|
|
4935
|
+
};
|
|
4936
|
+
|
|
4937
|
+
// src/core/lib/actionRegistry/types.ts
|
|
4938
|
+
var CollectionStateEnum = /* @__PURE__ */ ((CollectionStateEnum2) => {
|
|
4939
|
+
CollectionStateEnum2[CollectionStateEnum2["OPEN"] = 0] = "OPEN";
|
|
4940
|
+
CollectionStateEnum2[CollectionStateEnum2["PAUSED"] = 1] = "PAUSED";
|
|
4941
|
+
CollectionStateEnum2[CollectionStateEnum2["CLOSED"] = 2] = "CLOSED";
|
|
4942
|
+
return CollectionStateEnum2;
|
|
4943
|
+
})(CollectionStateEnum || {});
|
|
4944
|
+
|
|
4945
|
+
// src/core/lib/actionRegistry/actions/collection/collection.ts
|
|
4946
|
+
function normalizeQuota(quota) {
|
|
4947
|
+
if (quota === void 0 || quota === null) return void 0;
|
|
4948
|
+
const trimmed = String(quota).trim();
|
|
4949
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
4950
|
+
}
|
|
4951
|
+
function assertQuotaNotBelowCount(quota, count) {
|
|
4952
|
+
if (quota === "0") return;
|
|
4953
|
+
const quotaNum = Number(quota);
|
|
4954
|
+
const countNum = Number(count);
|
|
4955
|
+
if (!Number.isFinite(quotaNum) || quotaNum < 0) {
|
|
4956
|
+
throw new Error(`Invalid quota "${quota}". Quota must be a non-negative integer string ("0" = unlimited).`);
|
|
4957
|
+
}
|
|
4958
|
+
if (Number.isFinite(countNum) && quotaNum < countNum) {
|
|
4959
|
+
throw new Error(`Quota ${quota} is below the current submitted count ${count} (ErrCollectionQuotaBelowCount). Quota must be 0 (unlimited) or >= ${count}.`);
|
|
4960
|
+
}
|
|
4961
|
+
}
|
|
4962
|
+
function assertNonEmptyCollection(state, collectionId) {
|
|
4963
|
+
if (!state || !String(state.collectionId || "").trim()) {
|
|
4964
|
+
throw new Error(
|
|
4965
|
+
`Collection read-back returned empty state for collectionId "${collectionId}". Broadcast may have succeeded but chain state is not yet readable \u2014 retry via refresh.`
|
|
4966
|
+
);
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
registerAction({
|
|
4970
|
+
type: COLLECTION_LIFECYCLE_ACTION_TYPE,
|
|
4971
|
+
can: "collection/lifecycle",
|
|
4972
|
+
sideEffect: true,
|
|
4973
|
+
defaultRequiresConfirmation: true,
|
|
4974
|
+
requiredCapability: "flow/block/execute",
|
|
4975
|
+
outputSchema: COLLECTION_LIFECYCLE_OUTPUT_SCHEMA,
|
|
4976
|
+
getDynamicOutputSchema: () => COLLECTION_LIFECYCLE_OUTPUT_SCHEMA,
|
|
4977
|
+
// Static vocabulary (used by the pending-invocation preview / compiler).
|
|
4978
|
+
events: [COLLECTION_CREATED_EVENT],
|
|
4979
|
+
// Only a CREATE entry point (no bound collectionId) can emit `created`, so a
|
|
4980
|
+
// manage-mode block bound to an existing collection is hidden from the
|
|
4981
|
+
// trigger picker as a source (IXO-2595).
|
|
4982
|
+
getDynamicEvents: (inputs) => String(inputs?.collectionId || "").trim() ? [] : [COLLECTION_CREATED_EVENT],
|
|
4983
|
+
run: async (inputs, ctx) => {
|
|
4984
|
+
const service = ctx.services.collection;
|
|
4985
|
+
if (!service) {
|
|
4986
|
+
throw new Error("collection service not configured (ctx.services.collection is undefined)");
|
|
4987
|
+
}
|
|
4988
|
+
const operation = inputs.operation;
|
|
4989
|
+
if (!operation) {
|
|
4990
|
+
throw new Error("operation is required (create | updateState | updateDates | updateQuota | updatePayments | updateIntents | refresh)");
|
|
4991
|
+
}
|
|
4992
|
+
if (operation === "create") {
|
|
4993
|
+
const entity = String(inputs.entity || "").trim();
|
|
4994
|
+
const protocol = String(inputs.protocol || "").trim();
|
|
4995
|
+
if (!entity) throw new Error("create: entity is required");
|
|
4996
|
+
if (!protocol) throw new Error("create: protocol is required");
|
|
4997
|
+
if (!protocol.startsWith("did:") || protocol.includes("#")) {
|
|
4998
|
+
throw new Error(
|
|
4999
|
+
`create: protocol "${protocol}" is not a valid DID. The selected claim protocol did not resolve to a ledgered did:ixo: identifier (it may be an unresolved template reference). Re-pick the protocol from the entity's linked claims.`
|
|
5000
|
+
);
|
|
5001
|
+
}
|
|
5002
|
+
const quota = normalizeQuota(inputs.quota);
|
|
5003
|
+
const createParams = {
|
|
5004
|
+
entity,
|
|
5005
|
+
protocol,
|
|
5006
|
+
state: inputs.state,
|
|
5007
|
+
startDate: inputs.startDate,
|
|
5008
|
+
endDate: inputs.endDate,
|
|
5009
|
+
quota,
|
|
5010
|
+
payments: inputs.payments,
|
|
5011
|
+
intents: inputs.intents
|
|
5012
|
+
};
|
|
5013
|
+
const result = await service.create(createParams);
|
|
5014
|
+
const transactionHash2 = String(result?.transactionHash || "").trim();
|
|
5015
|
+
const collectionId2 = String(result?.collectionId || "").trim();
|
|
5016
|
+
if (!transactionHash2) {
|
|
5017
|
+
throw new Error("create: service returned no transactionHash. Collection was not created.");
|
|
5018
|
+
}
|
|
5019
|
+
if (!collectionId2) {
|
|
5020
|
+
throw new Error("create: service returned no collectionId. Cannot read back collection state.");
|
|
5021
|
+
}
|
|
5022
|
+
const state = await service.get({ collectionId: collectionId2 });
|
|
5023
|
+
assertNonEmptyCollection(state, collectionId2);
|
|
5024
|
+
return {
|
|
5025
|
+
output: state,
|
|
5026
|
+
events: [
|
|
5027
|
+
{
|
|
5028
|
+
name: COLLECTION_CREATED_EVENT_NAME,
|
|
5029
|
+
payload: {
|
|
5030
|
+
collectionId: String(state.collectionId || collectionId2),
|
|
5031
|
+
entity: String(state.entity || entity),
|
|
5032
|
+
protocol: String(state.protocol || protocol),
|
|
5033
|
+
transactionHash: transactionHash2
|
|
5034
|
+
}
|
|
5035
|
+
}
|
|
5036
|
+
]
|
|
5037
|
+
};
|
|
5038
|
+
}
|
|
5039
|
+
if (operation === "refresh") {
|
|
5040
|
+
const collectionId2 = String(inputs.collectionId || "").trim();
|
|
5041
|
+
if (!collectionId2) throw new Error("refresh: collectionId is required");
|
|
5042
|
+
const state = await service.get({ collectionId: collectionId2 });
|
|
5043
|
+
assertNonEmptyCollection(state, collectionId2);
|
|
5044
|
+
return { output: state };
|
|
5045
|
+
}
|
|
5046
|
+
const writeOp = operation;
|
|
5047
|
+
const collectionId = String(inputs.collectionId || "").trim();
|
|
5048
|
+
if (!collectionId) throw new Error(`${writeOp}: collectionId is required`);
|
|
5049
|
+
const current = await service.get({ collectionId });
|
|
5050
|
+
assertNonEmptyCollection(current, collectionId);
|
|
5051
|
+
const adminAddress = String(current.admin || "").trim();
|
|
5052
|
+
if (!adminAddress) {
|
|
5053
|
+
throw new Error(`${writeOp}: could not resolve admin address for collection "${collectionId}" (chain state has no admin). Cannot authorise the update.`);
|
|
5054
|
+
}
|
|
5055
|
+
let transactionHash = "";
|
|
5056
|
+
switch (writeOp) {
|
|
5057
|
+
case "updateState": {
|
|
5058
|
+
const state = inputs.state;
|
|
5059
|
+
if (state === void 0 || state === null) {
|
|
5060
|
+
throw new Error("updateState: state is required (0=OPEN, 1=PAUSED, 2=CLOSED)");
|
|
5061
|
+
}
|
|
5062
|
+
if (!(state in CollectionStateEnum) || typeof state !== "number") {
|
|
5063
|
+
throw new Error(`updateState: invalid state "${String(state)}". Expected 0 (OPEN), 1 (PAUSED) or 2 (CLOSED).`);
|
|
5064
|
+
}
|
|
5065
|
+
const res = await service.updateState({ collectionId, state, adminAddress });
|
|
5066
|
+
transactionHash = String(res?.transactionHash || "").trim();
|
|
5067
|
+
break;
|
|
5068
|
+
}
|
|
5069
|
+
case "updateDates": {
|
|
5070
|
+
const startDate = inputs.startDate;
|
|
5071
|
+
const endDate = inputs.endDate;
|
|
5072
|
+
if (!startDate && !endDate) {
|
|
5073
|
+
throw new Error("updateDates: at least one of startDate or endDate is required");
|
|
5074
|
+
}
|
|
5075
|
+
const res = await service.updateDates({ collectionId, startDate, endDate, adminAddress });
|
|
5076
|
+
transactionHash = String(res?.transactionHash || "").trim();
|
|
5077
|
+
break;
|
|
5078
|
+
}
|
|
5079
|
+
case "updateQuota": {
|
|
5080
|
+
const quota = normalizeQuota(inputs.quota);
|
|
5081
|
+
if (quota === void 0) {
|
|
5082
|
+
throw new Error('updateQuota: quota is required ("0" = unlimited)');
|
|
5083
|
+
}
|
|
5084
|
+
assertQuotaNotBelowCount(quota, String(current.count || "0"));
|
|
5085
|
+
const res = await service.updateQuota({ collectionId, quota, adminAddress });
|
|
5086
|
+
transactionHash = String(res?.transactionHash || "").trim();
|
|
5087
|
+
break;
|
|
5088
|
+
}
|
|
5089
|
+
case "updatePayments": {
|
|
5090
|
+
const payments = inputs.payments;
|
|
5091
|
+
if (!payments || typeof payments !== "object") {
|
|
5092
|
+
throw new Error("updatePayments: payments is required");
|
|
5093
|
+
}
|
|
5094
|
+
const res = await service.updatePayments({ collectionId, payments, adminAddress });
|
|
5095
|
+
transactionHash = String(res?.transactionHash || "").trim();
|
|
5096
|
+
break;
|
|
5097
|
+
}
|
|
5098
|
+
case "updateIntents": {
|
|
5099
|
+
const intents = inputs.intents;
|
|
5100
|
+
if (!intents || typeof intents !== "object") {
|
|
5101
|
+
throw new Error("updateIntents: intents is required");
|
|
5102
|
+
}
|
|
5103
|
+
const res = await service.updateIntents({ collectionId, intents, adminAddress });
|
|
5104
|
+
transactionHash = String(res?.transactionHash || "").trim();
|
|
5105
|
+
break;
|
|
5106
|
+
}
|
|
5107
|
+
default: {
|
|
5108
|
+
const _exhaustive = writeOp;
|
|
5109
|
+
throw new Error(`Unsupported collection operation: ${String(_exhaustive)}`);
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
if (!transactionHash) {
|
|
5113
|
+
throw new Error(`${writeOp}: service returned no transactionHash. The update was not broadcast.`);
|
|
5114
|
+
}
|
|
5115
|
+
const updated = await service.get({ collectionId });
|
|
5116
|
+
assertNonEmptyCollection(updated, collectionId);
|
|
5117
|
+
return { output: updated };
|
|
5118
|
+
}
|
|
5119
|
+
});
|
|
5120
|
+
|
|
5121
|
+
// src/core/lib/actionRegistry/actions/collectionUsers/index.ts
|
|
5122
|
+
var COLLECTION_USERS_ACTION_TYPE = "qi/collection.users";
|
|
5123
|
+
var COLLECTION_USERS_OUTPUT_SCHEMA = [
|
|
5124
|
+
{ path: "transactionHash", displayName: "Tx Hash", type: "string", description: "Broadcast transaction hash (add/revoke)" },
|
|
5125
|
+
{ path: "grantedCount", displayName: "Granted Count", type: "number", description: "Number of grants broadcast (fan-out)" },
|
|
5126
|
+
{ path: "role", displayName: "Role", type: "string", description: "submit or evaluate" },
|
|
5127
|
+
{ path: "collectionId", displayName: "Collection ID", type: "string", description: "Target claim collection identifier" },
|
|
5128
|
+
{ path: "granteeAddress", displayName: "Grantee Address", type: "string", description: "Address granted/revoked" },
|
|
5129
|
+
{
|
|
5130
|
+
path: "grantees",
|
|
5131
|
+
displayName: "Grantees",
|
|
5132
|
+
type: "array",
|
|
5133
|
+
description: "Grantees holding a constraint for the collection (list)",
|
|
5134
|
+
itemSchema: [
|
|
5135
|
+
{ path: "address", displayName: "Address", type: "string" },
|
|
5136
|
+
{ path: "role", displayName: "Role", type: "string" },
|
|
5137
|
+
{ path: "agentQuota", displayName: "Agent Quota", type: "string" },
|
|
5138
|
+
{ path: "intentDurationNs", displayName: "Intent Duration (ns)", type: "string" }
|
|
5139
|
+
]
|
|
5140
|
+
}
|
|
5141
|
+
];
|
|
5142
|
+
|
|
5143
|
+
// src/core/lib/actionRegistry/actions/collectionUsers/collectionUsers.ts
|
|
5144
|
+
function normalizeRole(value) {
|
|
5145
|
+
const normalized = String(value || "").trim().toLowerCase();
|
|
5146
|
+
if (normalized === "submit" || normalized === "evaluate") return normalized;
|
|
5147
|
+
throw new Error('role must be either "submit" or "evaluate"');
|
|
5148
|
+
}
|
|
5149
|
+
registerAction({
|
|
5150
|
+
type: COLLECTION_USERS_ACTION_TYPE,
|
|
5151
|
+
can: "collection/users",
|
|
5152
|
+
sideEffect: true,
|
|
5153
|
+
defaultRequiresConfirmation: true,
|
|
5154
|
+
requiredCapability: "flow/block/execute",
|
|
5155
|
+
outputSchema: COLLECTION_USERS_OUTPUT_SCHEMA,
|
|
5156
|
+
getDynamicOutputSchema: () => COLLECTION_USERS_OUTPUT_SCHEMA,
|
|
5157
|
+
// Can be wired to a `block.event` trigger (IXO-2596) — e.g. listen for the
|
|
5158
|
+
// `created` event from a Claim Collection block and manage the new
|
|
5159
|
+
// collection's users. When invoked from a pending invocation, `collectionId`
|
|
5160
|
+
// arrives via the event payload (merged into inputs by name); the FlowDetail
|
|
5161
|
+
// resolves the entity admin account from the payload `entity` and passes it
|
|
5162
|
+
// as `adminAddress`.
|
|
5163
|
+
eligibleForEventTrigger: true,
|
|
5164
|
+
run: async (inputs, ctx) => {
|
|
5165
|
+
const service = ctx.services.collectionUsers;
|
|
5166
|
+
if (!service) {
|
|
5167
|
+
throw new Error("collectionUsers service not configured (ctx.services.collectionUsers is undefined)");
|
|
5168
|
+
}
|
|
5169
|
+
const operation = inputs.operation;
|
|
5170
|
+
if (!operation) {
|
|
5171
|
+
throw new Error("operation is required (add | revoke | list)");
|
|
5172
|
+
}
|
|
5173
|
+
const collectionId = String(inputs.collectionId || "").trim();
|
|
5174
|
+
const adminAddress = String(inputs.adminAddress || "").trim();
|
|
5175
|
+
if (operation === "list") {
|
|
5176
|
+
if (!collectionId) throw new Error("list: collectionId is required");
|
|
5177
|
+
if (!adminAddress) throw new Error("list: adminAddress (entity admin account) is required");
|
|
5178
|
+
const result2 = await service.list({ granterAdminAddress: adminAddress, collectionId });
|
|
5179
|
+
const grantees = Array.isArray(result2?.grantees) ? result2.grantees : void 0;
|
|
5180
|
+
if (!grantees) {
|
|
5181
|
+
throw new Error("list: service returned no grantees array. Check the [collection:list] handler logs.");
|
|
5182
|
+
}
|
|
5183
|
+
return { output: { grantees, collectionId } };
|
|
5184
|
+
}
|
|
5185
|
+
if (!collectionId) throw new Error(`${operation}: collectionId is required`);
|
|
5186
|
+
if (!adminAddress) throw new Error(`${operation}: adminAddress (entity admin account) is required`);
|
|
5187
|
+
const role = normalizeRole(inputs.role);
|
|
5188
|
+
const deedDid = String(inputs.deedDid || "").trim() || void 0;
|
|
5189
|
+
if (operation === "revoke") {
|
|
5190
|
+
const granteeAddress2 = String(inputs.granteeAddress || "").trim();
|
|
5191
|
+
if (!granteeAddress2) throw new Error("revoke: granteeAddress is required");
|
|
5192
|
+
const result2 = await service.revoke({ granterAdminAddress: adminAddress, granteeAddress: granteeAddress2, collectionId, role });
|
|
5193
|
+
const transactionHash2 = String(result2?.transactionHash || "").trim();
|
|
5194
|
+
if (!transactionHash2) {
|
|
5195
|
+
throw new Error("revoke: service returned no transactionHash. The revoke was not broadcast.");
|
|
5196
|
+
}
|
|
5197
|
+
return { output: { transactionHash: transactionHash2, role, collectionId, granteeAddress: granteeAddress2 } };
|
|
5198
|
+
}
|
|
5199
|
+
const granteeKind = inputs.granteeKind || "user";
|
|
5200
|
+
const agentQuota = inputs.agentQuota !== void 0 && inputs.agentQuota !== null ? String(inputs.agentQuota).trim() || void 0 : void 0;
|
|
5201
|
+
const maxAmount = Array.isArray(inputs.maxAmount) ? inputs.maxAmount : void 0;
|
|
5202
|
+
const intentDurationNs = String(inputs.intentDurationNs || "").trim() || void 0;
|
|
5203
|
+
if (granteeKind === "group-members") {
|
|
5204
|
+
const members = Array.isArray(inputs.members) ? inputs.members.filter((m) => !!String(m?.address || "").trim()) : [];
|
|
5205
|
+
if (members.length === 0) {
|
|
5206
|
+
throw new Error("add (group-members): no members resolved to grant to. Enumerate the group members before signing.");
|
|
5207
|
+
}
|
|
5208
|
+
const transactionHashes = [];
|
|
5209
|
+
for (const member of members) {
|
|
5210
|
+
const granteeAddress2 = String(member.address).trim();
|
|
5211
|
+
const res = await service.grant({ granterAdminAddress: adminAddress, granteeAddress: granteeAddress2, collectionId, role, agentQuota, maxAmount, intentDurationNs, deedDid });
|
|
5212
|
+
const hash = String(res?.transactionHash || "").trim();
|
|
5213
|
+
if (!hash) {
|
|
5214
|
+
throw new Error(`add (group-members): grant to ${granteeAddress2} returned no transactionHash. ${transactionHashes.length} of ${members.length} grants completed.`);
|
|
5215
|
+
}
|
|
5216
|
+
transactionHashes.push(hash);
|
|
5217
|
+
}
|
|
5218
|
+
return {
|
|
5219
|
+
output: {
|
|
5220
|
+
transactionHash: transactionHashes[transactionHashes.length - 1],
|
|
5221
|
+
transactionHashes,
|
|
5222
|
+
grantedCount: transactionHashes.length,
|
|
5223
|
+
role,
|
|
5224
|
+
collectionId
|
|
5225
|
+
}
|
|
5226
|
+
};
|
|
5227
|
+
}
|
|
5228
|
+
const granteeAddress = String(inputs.granteeAddress || "").trim();
|
|
5229
|
+
if (!granteeAddress) throw new Error("add: granteeAddress is required");
|
|
5230
|
+
const result = await service.grant({ granterAdminAddress: adminAddress, granteeAddress, collectionId, role, agentQuota, maxAmount, intentDurationNs, deedDid });
|
|
5231
|
+
const transactionHash = String(result?.transactionHash || "").trim();
|
|
5232
|
+
if (!transactionHash) {
|
|
5233
|
+
throw new Error("add: service returned no transactionHash. The grant was not broadcast.");
|
|
5234
|
+
}
|
|
5235
|
+
return {
|
|
5236
|
+
output: {
|
|
5237
|
+
transactionHash,
|
|
5238
|
+
transactionHashes: [transactionHash],
|
|
5239
|
+
grantedCount: 1,
|
|
5240
|
+
role,
|
|
5241
|
+
collectionId,
|
|
5242
|
+
granteeAddress
|
|
5243
|
+
}
|
|
5244
|
+
};
|
|
5245
|
+
}
|
|
5246
|
+
});
|
|
5247
|
+
|
|
5248
|
+
// src/core/lib/actionRegistry/actions/carbon/schemas.ts
|
|
5249
|
+
var HARVESTABLE_ITEM_SCHEMA = [
|
|
5250
|
+
{ path: "id", displayName: "Batch ID", type: "string" },
|
|
5251
|
+
{ path: "entityDid", displayName: "Entity DID", type: "string" },
|
|
5252
|
+
{ path: "adminAddress", displayName: "Admin Address", type: "string" },
|
|
5253
|
+
{ path: "claimable", displayName: "Claimable", type: "number" },
|
|
5254
|
+
{ path: "alsoKnownAs", displayName: "Entity Name", type: "string" }
|
|
5255
|
+
];
|
|
5256
|
+
var RETIREABLE_ITEM_SCHEMA = [
|
|
5257
|
+
{ path: "id", displayName: "Batch ID", type: "string" },
|
|
5258
|
+
{ path: "amount", displayName: "Amount", type: "number" },
|
|
5259
|
+
{ path: "entityDid", displayName: "Entity DID", type: "string" },
|
|
5260
|
+
{ path: "alsoKnownAs", displayName: "Entity Name", type: "string" }
|
|
5261
|
+
];
|
|
5262
|
+
var CARBON_LOAD_OUTPUT = [
|
|
5263
|
+
{ path: "harvestableBatches", displayName: "Harvestable Batches", type: "array", itemSchema: HARVESTABLE_ITEM_SCHEMA, description: "Batches with claimable credits" },
|
|
5264
|
+
{ path: "retireableBatches", displayName: "Retireable Batches", type: "array", itemSchema: RETIREABLE_ITEM_SCHEMA, description: "Batches with credits available to retire" },
|
|
5265
|
+
{ path: "totalClaimable", displayName: "Total Claimable", type: "number", description: "Sum of all claimable credits" },
|
|
5266
|
+
{ path: "totalAvailable", displayName: "Total Available", type: "number", description: "Sum of all retireable credits" },
|
|
5267
|
+
{ path: "totalRetired", displayName: "Total Retired", type: "number", description: "Sum of all retired credits" }
|
|
5268
|
+
];
|
|
5269
|
+
var CARBON_HARVEST_OUTPUT = [
|
|
5270
|
+
{ path: "transactionHash", displayName: "Transaction Hash", type: "string", description: "The harvest transaction hash" },
|
|
5271
|
+
{
|
|
5272
|
+
path: "harvestedBatchIds",
|
|
5273
|
+
displayName: "Harvested Batch IDs",
|
|
5274
|
+
type: "array",
|
|
5275
|
+
itemSchema: [{ path: "", displayName: "Batch ID", type: "string" }],
|
|
5276
|
+
description: "Ids of the harvested batches"
|
|
5277
|
+
},
|
|
5278
|
+
{ path: "harvestedAmount", displayName: "Harvested Amount", type: "number", description: "Total credits harvested into the wallet" }
|
|
5279
|
+
];
|
|
5280
|
+
var CARBON_RETIRE_OUTPUT = [
|
|
5281
|
+
{ path: "transactionHash", displayName: "Transaction Hash", type: "string", description: "The retire transaction hash" },
|
|
5282
|
+
{
|
|
5283
|
+
path: "retiredBatchIds",
|
|
5284
|
+
displayName: "Retired Batch IDs",
|
|
5285
|
+
type: "array",
|
|
5286
|
+
itemSchema: [{ path: "", displayName: "Batch ID", type: "string" }],
|
|
5287
|
+
description: "Ids of the retired batches"
|
|
5288
|
+
},
|
|
5289
|
+
{ path: "retiredAmount", displayName: "Retired Amount", type: "number", description: "Total credits permanently retired" },
|
|
5290
|
+
{ path: "jurisdiction", displayName: "Jurisdiction", type: "string", description: "Jurisdiction recorded on the retirement" }
|
|
5291
|
+
];
|
|
5292
|
+
|
|
5293
|
+
// src/core/lib/actionRegistry/actions/carbon/loadBatches.ts
|
|
5294
|
+
registerAction({
|
|
5295
|
+
type: "qi/carbon.loadBatches",
|
|
5296
|
+
can: "carbon/load",
|
|
5297
|
+
sideEffect: false,
|
|
5298
|
+
defaultRequiresConfirmation: false,
|
|
5299
|
+
outputSchema: CARBON_LOAD_OUTPUT,
|
|
5300
|
+
run: async (inputs, ctx) => {
|
|
5301
|
+
if (!ctx.services.carbon?.loadBatches) {
|
|
5302
|
+
throw new Error("carbon.loadBatches handler not available");
|
|
5303
|
+
}
|
|
5304
|
+
if (!inputs.ownerAddress) throw new Error("ownerAddress is required");
|
|
5305
|
+
const result = await ctx.services.carbon.loadBatches({
|
|
5306
|
+
ownerAddress: inputs.ownerAddress
|
|
5307
|
+
});
|
|
5308
|
+
return { output: result };
|
|
5309
|
+
}
|
|
5310
|
+
});
|
|
5311
|
+
|
|
5312
|
+
// src/core/lib/actionRegistry/actions/carbon/harvest.ts
|
|
5313
|
+
registerAction({
|
|
5314
|
+
type: "qi/carbon.harvest",
|
|
5315
|
+
can: "carbon/harvest",
|
|
5316
|
+
sideEffect: true,
|
|
5317
|
+
defaultRequiresConfirmation: true,
|
|
5318
|
+
outputSchema: CARBON_HARVEST_OUTPUT,
|
|
5319
|
+
run: async (inputs, ctx) => {
|
|
5320
|
+
if (!ctx.services.carbon?.harvest) {
|
|
5321
|
+
throw new Error("carbon.harvest handler not available");
|
|
5322
|
+
}
|
|
5323
|
+
if (!inputs.ownerAddress) throw new Error("ownerAddress is required");
|
|
5324
|
+
const tokens = Array.isArray(inputs.tokens) ? inputs.tokens : [];
|
|
5325
|
+
if (tokens.length === 0) throw new Error("No batches selected to harvest");
|
|
5326
|
+
for (const t of tokens) {
|
|
5327
|
+
if (!t.id) throw new Error("Each harvest token requires an id");
|
|
5328
|
+
if (!t.entityDid) throw new Error(`Batch ${t.id} is missing entityDid (cannot construct harvest)`);
|
|
5329
|
+
if (!t.adminAddress) throw new Error(`Batch ${t.id} is missing adminAddress (cannot construct harvest)`);
|
|
5330
|
+
if (!(Number(t.claimable) > 0)) throw new Error(`Batch ${t.id} has no claimable amount`);
|
|
5331
|
+
}
|
|
5332
|
+
const result = await ctx.services.carbon.harvest({
|
|
5333
|
+
ownerAddress: inputs.ownerAddress,
|
|
5334
|
+
tokens: tokens.map((t) => ({ id: t.id, entityDid: t.entityDid, adminAddress: t.adminAddress, claimable: Number(t.claimable) }))
|
|
5335
|
+
});
|
|
5336
|
+
if (!result?.transactionHash) {
|
|
5337
|
+
throw new Error("carbon.harvest returned no transaction hash. Check the [carbon:harvest] handler logs.");
|
|
5338
|
+
}
|
|
5339
|
+
return { output: result };
|
|
5340
|
+
}
|
|
5341
|
+
});
|
|
5342
|
+
|
|
5343
|
+
// src/core/lib/actionRegistry/actions/carbon/retire.ts
|
|
5344
|
+
registerAction({
|
|
5345
|
+
type: "qi/carbon.retire",
|
|
5346
|
+
can: "carbon/retire",
|
|
5347
|
+
sideEffect: true,
|
|
5348
|
+
defaultRequiresConfirmation: true,
|
|
5349
|
+
outputSchema: CARBON_RETIRE_OUTPUT,
|
|
5350
|
+
run: async (inputs, ctx) => {
|
|
5351
|
+
if (!ctx.services.carbon?.retire) {
|
|
5352
|
+
throw new Error("carbon.retire handler not available");
|
|
5353
|
+
}
|
|
5354
|
+
if (!inputs.owner) throw new Error("owner is required");
|
|
5355
|
+
const tokens = Array.isArray(inputs.tokens) ? inputs.tokens : [];
|
|
5356
|
+
if (tokens.length === 0) throw new Error("No batches selected to retire");
|
|
5357
|
+
for (const t of tokens) {
|
|
5358
|
+
if (!t.id) throw new Error("Each retire token requires an id");
|
|
5359
|
+
if (!(Number(t.amount) > 0)) throw new Error(`Batch ${t.id} has no amount to retire`);
|
|
5360
|
+
}
|
|
5361
|
+
const reason = inputs.reason || "offset";
|
|
5362
|
+
const jurisdiction = inputs.jurisdiction || "Global";
|
|
5363
|
+
const result = await ctx.services.carbon.retire({
|
|
5364
|
+
owner: inputs.owner,
|
|
5365
|
+
reason,
|
|
5366
|
+
jurisdiction,
|
|
5367
|
+
tokens: tokens.map((t) => ({ id: t.id, amount: Number(t.amount) }))
|
|
5368
|
+
});
|
|
5369
|
+
if (!result?.transactionHash) {
|
|
5370
|
+
throw new Error("carbon.retire returned no transaction hash. Check the [carbon:retire] handler logs.");
|
|
5371
|
+
}
|
|
5372
|
+
return { output: { ...result, jurisdiction } };
|
|
5373
|
+
}
|
|
5374
|
+
});
|
|
5375
|
+
|
|
4869
5376
|
// src/core/lib/actionRegistry/actions/calendar/eventCreate.types.ts
|
|
4870
5377
|
var EMPTY = {
|
|
4871
5378
|
connection: null,
|
|
@@ -5494,7 +6001,7 @@ registerDiffResolver("bid", {
|
|
|
5494
6001
|
if (!inputs.surveyStarted) return [];
|
|
5495
6002
|
const collectionId = String(inputs.collectionId || "").trim();
|
|
5496
6003
|
const role = String(inputs.role || "").trim();
|
|
5497
|
-
const
|
|
6004
|
+
const roleLabel2 = role === "evaluation_agent" || role === "ea" ? "Evaluator" : role ? "Contributor" : "Selected at runtime";
|
|
5498
6005
|
return [
|
|
5499
6006
|
{
|
|
5500
6007
|
key: "applicationStatus",
|
|
@@ -5508,7 +6015,7 @@ registerDiffResolver("bid", {
|
|
|
5508
6015
|
key: "role",
|
|
5509
6016
|
label: "Role",
|
|
5510
6017
|
before: "None",
|
|
5511
|
-
after:
|
|
6018
|
+
after: roleLabel2,
|
|
5512
6019
|
changeType: role ? "replace" : "unchanged"
|
|
5513
6020
|
},
|
|
5514
6021
|
{
|
|
@@ -5545,7 +6052,7 @@ registerDiffResolver("evaluateBid", {
|
|
|
5545
6052
|
const applicantDid = String(inputs.applicantDid || "").trim();
|
|
5546
6053
|
const roleLower = role.toLowerCase();
|
|
5547
6054
|
const isEvaluator = roleLower === "evaluation_agent" || roleLower === "ea";
|
|
5548
|
-
const
|
|
6055
|
+
const roleLabel2 = isEvaluator ? "Evaluator" : roleLower === "service_agent" || roleLower === "sa" ? "Contributor" : role || "Unknown";
|
|
5549
6056
|
const isApprove = decision === "approve";
|
|
5550
6057
|
const isReject = decision === "reject";
|
|
5551
6058
|
const decisionLabel = isApprove ? "Approve" : isReject ? "Reject" : "Not selected";
|
|
@@ -5569,8 +6076,8 @@ registerDiffResolver("evaluateBid", {
|
|
|
5569
6076
|
{
|
|
5570
6077
|
key: "applicantRole",
|
|
5571
6078
|
label: "Applicant Role",
|
|
5572
|
-
before:
|
|
5573
|
-
after:
|
|
6079
|
+
before: roleLabel2,
|
|
6080
|
+
after: roleLabel2,
|
|
5574
6081
|
changeType: "unchanged"
|
|
5575
6082
|
},
|
|
5576
6083
|
{
|
|
@@ -6178,6 +6685,428 @@ registerDiffResolver("qi/wallet.fund", {
|
|
|
6178
6685
|
}
|
|
6179
6686
|
});
|
|
6180
6687
|
|
|
6688
|
+
// src/core/lib/actionRegistry/actions/collection/collection.diff.ts
|
|
6689
|
+
var STATE_LABELS = {
|
|
6690
|
+
[0 /* OPEN */]: "Open",
|
|
6691
|
+
[1 /* PAUSED */]: "Paused",
|
|
6692
|
+
[2 /* CLOSED */]: "Closed"
|
|
6693
|
+
};
|
|
6694
|
+
function stateLabel(value) {
|
|
6695
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
6696
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
6697
|
+
if (!Number.isFinite(n)) return null;
|
|
6698
|
+
return STATE_LABELS[n] ?? `Unknown (${n})`;
|
|
6699
|
+
}
|
|
6700
|
+
function readCurrentState(inputs) {
|
|
6701
|
+
const candidate = inputs?.currentState ?? inputs?.__currentState ?? inputs?.__currentOutput ?? inputs?.currentOutput ?? inputs?.output ?? void 0;
|
|
6702
|
+
if (candidate && typeof candidate === "object") return candidate;
|
|
6703
|
+
return {};
|
|
6704
|
+
}
|
|
6705
|
+
function formatQuota(value) {
|
|
6706
|
+
if (value === void 0 || value === null || value === "") return "Unlimited";
|
|
6707
|
+
const s = String(value).trim();
|
|
6708
|
+
if (s === "" || s === "0") return "Unlimited";
|
|
6709
|
+
return s;
|
|
6710
|
+
}
|
|
6711
|
+
function toNumberOrNull(value) {
|
|
6712
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
6713
|
+
const n = Number(value);
|
|
6714
|
+
return Number.isFinite(n) ? n : null;
|
|
6715
|
+
}
|
|
6716
|
+
function formatDate(value) {
|
|
6717
|
+
if (value === void 0 || value === null || value === "") return "Not set";
|
|
6718
|
+
return String(value);
|
|
6719
|
+
}
|
|
6720
|
+
var USDC_IBC_DENOM = "ibc/6BBE9BD4246F8E04948D5A4EEE7164B2630263B9EBB5E7DC5F0A46C62A2FF97B";
|
|
6721
|
+
function formatCoin3(amount, denom) {
|
|
6722
|
+
const rawAmount = amount ?? "?";
|
|
6723
|
+
if (denom === "uixo") {
|
|
6724
|
+
const n = Number(rawAmount);
|
|
6725
|
+
return `${Number.isFinite(n) ? n / 1e6 : rawAmount} IXO`;
|
|
6726
|
+
}
|
|
6727
|
+
if (denom === USDC_IBC_DENOM || (denom ?? "").startsWith("ibc/")) {
|
|
6728
|
+
const n = Number(rawAmount);
|
|
6729
|
+
return `${Number.isFinite(n) ? n / 1e6 : rawAmount} USDC`;
|
|
6730
|
+
}
|
|
6731
|
+
return `${rawAmount} ${denom ?? ""}`.trim();
|
|
6732
|
+
}
|
|
6733
|
+
function summarisePaymentLeg(leg) {
|
|
6734
|
+
if (!leg || typeof leg !== "object") return "None";
|
|
6735
|
+
const parts = [];
|
|
6736
|
+
const coins = Array.isArray(leg.amount) ? leg.amount : [];
|
|
6737
|
+
if (coins.length > 0) {
|
|
6738
|
+
parts.push(coins.map((c) => formatCoin3(c?.amount, c?.denom)).join(", "));
|
|
6739
|
+
}
|
|
6740
|
+
if (Array.isArray(leg.cw20Payment) && leg.cw20Payment.length > 0) {
|
|
6741
|
+
parts.push(`${leg.cw20Payment.length} CW20`);
|
|
6742
|
+
}
|
|
6743
|
+
if (leg.contract_1155Payment) {
|
|
6744
|
+
parts.push("1155");
|
|
6745
|
+
}
|
|
6746
|
+
if (leg.account) {
|
|
6747
|
+
parts.push(`\u2192 ${leg.account}`);
|
|
6748
|
+
}
|
|
6749
|
+
if (leg.isOraclePayment) {
|
|
6750
|
+
parts.push("(oracle)");
|
|
6751
|
+
}
|
|
6752
|
+
return parts.length > 0 ? parts.join(" ") : "None";
|
|
6753
|
+
}
|
|
6754
|
+
function summarisePayments(payments) {
|
|
6755
|
+
const p = payments && typeof payments === "object" ? payments : {};
|
|
6756
|
+
return {
|
|
6757
|
+
submission: summarisePaymentLeg(p.submission),
|
|
6758
|
+
evaluation: summarisePaymentLeg(p.evaluation),
|
|
6759
|
+
approval: summarisePaymentLeg(p.approval),
|
|
6760
|
+
rejection: summarisePaymentLeg(p.rejection)
|
|
6761
|
+
};
|
|
6762
|
+
}
|
|
6763
|
+
function summariseIntents(intents) {
|
|
6764
|
+
const i = intents && typeof intents === "object" ? intents : {};
|
|
6765
|
+
return {
|
|
6766
|
+
allowed: i.allowed === void 0 ? "Not set" : i.allowed ? "Allowed" : "Disallowed",
|
|
6767
|
+
timeout: i.timeoutNs ? String(i.timeoutNs) : "Not set",
|
|
6768
|
+
payment: summarisePaymentLeg(i.payment)
|
|
6769
|
+
};
|
|
6770
|
+
}
|
|
6771
|
+
function changeFor(before, after) {
|
|
6772
|
+
if (before === after) return "unchanged";
|
|
6773
|
+
if (before === null || before === void 0 || before === "") return "add";
|
|
6774
|
+
if (after === null || after === void 0 || after === "") return "remove";
|
|
6775
|
+
if (typeof before === "number" && typeof after === "number") {
|
|
6776
|
+
if (after > before) return "increase";
|
|
6777
|
+
if (after < before) return "decrease";
|
|
6778
|
+
}
|
|
6779
|
+
return "replace";
|
|
6780
|
+
}
|
|
6781
|
+
function diffCreate(inputs) {
|
|
6782
|
+
const results = [];
|
|
6783
|
+
if (inputs.entity) {
|
|
6784
|
+
results.push({ key: "entity", label: "Entity", before: null, after: String(inputs.entity), changeType: "add" });
|
|
6785
|
+
}
|
|
6786
|
+
if (inputs.protocol) {
|
|
6787
|
+
results.push({ key: "protocol", label: "Protocol", before: null, after: String(inputs.protocol), changeType: "add" });
|
|
6788
|
+
}
|
|
6789
|
+
results.push({
|
|
6790
|
+
key: "state",
|
|
6791
|
+
label: "State",
|
|
6792
|
+
before: null,
|
|
6793
|
+
after: stateLabel(inputs.state) ?? STATE_LABELS[0 /* OPEN */],
|
|
6794
|
+
changeType: "add"
|
|
6795
|
+
});
|
|
6796
|
+
results.push({
|
|
6797
|
+
key: "startDate",
|
|
6798
|
+
label: "Start Date",
|
|
6799
|
+
before: null,
|
|
6800
|
+
after: inputs.startDate ? String(inputs.startDate) : "Not set",
|
|
6801
|
+
changeType: inputs.startDate ? "add" : "unchanged"
|
|
6802
|
+
});
|
|
6803
|
+
results.push({
|
|
6804
|
+
key: "endDate",
|
|
6805
|
+
label: "End Date",
|
|
6806
|
+
before: null,
|
|
6807
|
+
after: inputs.endDate ? String(inputs.endDate) : "Not set",
|
|
6808
|
+
changeType: inputs.endDate ? "add" : "unchanged"
|
|
6809
|
+
});
|
|
6810
|
+
results.push({
|
|
6811
|
+
key: "quota",
|
|
6812
|
+
label: "Quota",
|
|
6813
|
+
before: null,
|
|
6814
|
+
after: formatQuota(inputs.quota),
|
|
6815
|
+
changeType: "add",
|
|
6816
|
+
severity: "warning",
|
|
6817
|
+
unit: formatQuota(inputs.quota) === "Unlimited" ? void 0 : "claims"
|
|
6818
|
+
});
|
|
6819
|
+
if (inputs.payments) {
|
|
6820
|
+
const after = summarisePayments(inputs.payments);
|
|
6821
|
+
["submission", "evaluation", "approval", "rejection"].forEach((leg) => {
|
|
6822
|
+
if (after[leg] !== "None") {
|
|
6823
|
+
results.push({
|
|
6824
|
+
key: `payments.${leg}`,
|
|
6825
|
+
label: `Payment \u2014 ${leg.charAt(0).toUpperCase()}${leg.slice(1)}`,
|
|
6826
|
+
before: null,
|
|
6827
|
+
after: after[leg],
|
|
6828
|
+
changeType: "add"
|
|
6829
|
+
});
|
|
6830
|
+
}
|
|
6831
|
+
});
|
|
6832
|
+
}
|
|
6833
|
+
if (inputs.intents) {
|
|
6834
|
+
const after = summariseIntents(inputs.intents);
|
|
6835
|
+
results.push({ key: "intents.allowed", label: "Intents \u2014 Allowed", before: null, after: after.allowed, changeType: "add" });
|
|
6836
|
+
if (after.timeout !== "Not set") {
|
|
6837
|
+
results.push({ key: "intents.timeout", label: "Intents \u2014 Timeout (ns)", before: null, after: after.timeout, changeType: "add" });
|
|
6838
|
+
}
|
|
6839
|
+
if (after.payment !== "None") {
|
|
6840
|
+
results.push({ key: "intents.payment", label: "Intents \u2014 Payment", before: null, after: after.payment, changeType: "add" });
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
return results;
|
|
6844
|
+
}
|
|
6845
|
+
function diffUpdateState(inputs, current) {
|
|
6846
|
+
const before = stateLabel(current.state);
|
|
6847
|
+
const after = stateLabel(inputs.state);
|
|
6848
|
+
return [
|
|
6849
|
+
{
|
|
6850
|
+
key: "state",
|
|
6851
|
+
label: "State",
|
|
6852
|
+
before: before ?? "Unknown",
|
|
6853
|
+
after: after ?? "Unchanged",
|
|
6854
|
+
changeType: changeFor(before, after),
|
|
6855
|
+
severity: after === STATE_LABELS[2 /* CLOSED */] ? "warning" : "info"
|
|
6856
|
+
}
|
|
6857
|
+
];
|
|
6858
|
+
}
|
|
6859
|
+
function diffUpdateDates(inputs, current) {
|
|
6860
|
+
const results = [];
|
|
6861
|
+
const beforeStart = formatDate(current.startDate);
|
|
6862
|
+
const afterStart = inputs.startDate !== void 0 ? formatDate(inputs.startDate) : beforeStart;
|
|
6863
|
+
results.push({
|
|
6864
|
+
key: "startDate",
|
|
6865
|
+
label: "Start Date",
|
|
6866
|
+
before: beforeStart,
|
|
6867
|
+
after: afterStart,
|
|
6868
|
+
changeType: changeFor(beforeStart === "Not set" ? null : beforeStart, afterStart === "Not set" ? null : afterStart)
|
|
6869
|
+
});
|
|
6870
|
+
const beforeEnd = formatDate(current.endDate);
|
|
6871
|
+
const afterEnd = inputs.endDate !== void 0 ? formatDate(inputs.endDate) : beforeEnd;
|
|
6872
|
+
results.push({
|
|
6873
|
+
key: "endDate",
|
|
6874
|
+
label: "End Date",
|
|
6875
|
+
before: beforeEnd,
|
|
6876
|
+
after: afterEnd,
|
|
6877
|
+
changeType: changeFor(beforeEnd === "Not set" ? null : beforeEnd, afterEnd === "Not set" ? null : afterEnd)
|
|
6878
|
+
});
|
|
6879
|
+
return results;
|
|
6880
|
+
}
|
|
6881
|
+
function diffUpdateQuota(inputs, current) {
|
|
6882
|
+
const beforeQuotaStr = formatQuota(current.quota);
|
|
6883
|
+
const afterQuotaStr = formatQuota(inputs.quota);
|
|
6884
|
+
const beforeNum = beforeQuotaStr === "Unlimited" ? null : toNumberOrNull(current.quota);
|
|
6885
|
+
const afterNum = afterQuotaStr === "Unlimited" ? null : toNumberOrNull(inputs.quota);
|
|
6886
|
+
let changeType;
|
|
6887
|
+
if (beforeQuotaStr === afterQuotaStr) {
|
|
6888
|
+
changeType = "unchanged";
|
|
6889
|
+
} else if (beforeNum !== null && afterNum !== null) {
|
|
6890
|
+
changeType = afterNum > beforeNum ? "increase" : afterNum < beforeNum ? "decrease" : "replace";
|
|
6891
|
+
} else {
|
|
6892
|
+
changeType = "replace";
|
|
6893
|
+
}
|
|
6894
|
+
const count = toNumberOrNull(current.count);
|
|
6895
|
+
const belowCount = afterNum !== null && count !== null && afterNum < count;
|
|
6896
|
+
return [
|
|
6897
|
+
{
|
|
6898
|
+
key: "quota",
|
|
6899
|
+
label: "Quota",
|
|
6900
|
+
before: beforeQuotaStr,
|
|
6901
|
+
after: belowCount ? `${afterQuotaStr} (below current count ${count} \u2014 chain will reject)` : afterQuotaStr,
|
|
6902
|
+
changeType,
|
|
6903
|
+
severity: belowCount ? "critical" : "info",
|
|
6904
|
+
unit: afterQuotaStr === "Unlimited" ? void 0 : "claims"
|
|
6905
|
+
}
|
|
6906
|
+
];
|
|
6907
|
+
}
|
|
6908
|
+
function diffUpdatePayments(inputs, current) {
|
|
6909
|
+
const before = summarisePayments(current.payments);
|
|
6910
|
+
const after = summarisePayments(inputs.payments);
|
|
6911
|
+
return ["submission", "evaluation", "approval", "rejection"].map((leg) => ({
|
|
6912
|
+
key: `payments.${leg}`,
|
|
6913
|
+
label: `Payment \u2014 ${leg.charAt(0).toUpperCase()}${leg.slice(1)}`,
|
|
6914
|
+
before: before[leg],
|
|
6915
|
+
after: after[leg],
|
|
6916
|
+
changeType: changeFor(before[leg] === "None" ? null : before[leg], after[leg] === "None" ? null : after[leg])
|
|
6917
|
+
}));
|
|
6918
|
+
}
|
|
6919
|
+
function diffUpdateIntents(inputs, current) {
|
|
6920
|
+
const before = summariseIntents(current.intents);
|
|
6921
|
+
const after = summariseIntents(inputs.intents);
|
|
6922
|
+
return [
|
|
6923
|
+
{
|
|
6924
|
+
key: "intents.allowed",
|
|
6925
|
+
label: "Intents \u2014 Allowed",
|
|
6926
|
+
before: before.allowed,
|
|
6927
|
+
after: after.allowed,
|
|
6928
|
+
changeType: changeFor(before.allowed === "Not set" ? null : before.allowed, after.allowed === "Not set" ? null : after.allowed)
|
|
6929
|
+
},
|
|
6930
|
+
{
|
|
6931
|
+
key: "intents.timeout",
|
|
6932
|
+
label: "Intents \u2014 Timeout (ns)",
|
|
6933
|
+
before: before.timeout,
|
|
6934
|
+
after: after.timeout,
|
|
6935
|
+
changeType: changeFor(before.timeout === "Not set" ? null : before.timeout, after.timeout === "Not set" ? null : after.timeout)
|
|
6936
|
+
},
|
|
6937
|
+
{
|
|
6938
|
+
key: "intents.payment",
|
|
6939
|
+
label: "Intents \u2014 Payment",
|
|
6940
|
+
before: before.payment,
|
|
6941
|
+
after: after.payment,
|
|
6942
|
+
changeType: changeFor(before.payment === "None" ? null : before.payment, after.payment === "None" ? null : after.payment)
|
|
6943
|
+
}
|
|
6944
|
+
];
|
|
6945
|
+
}
|
|
6946
|
+
registerDiffResolver(COLLECTION_LIFECYCLE_ACTION_TYPE, {
|
|
6947
|
+
resolver: async (inputs, _ctx) => {
|
|
6948
|
+
const safeInputs = inputs && typeof inputs === "object" ? inputs : {};
|
|
6949
|
+
const operation = String(safeInputs.operation || "").trim();
|
|
6950
|
+
const current = readCurrentState(safeInputs);
|
|
6951
|
+
switch (operation) {
|
|
6952
|
+
case "create":
|
|
6953
|
+
return diffCreate(safeInputs);
|
|
6954
|
+
case "updateState":
|
|
6955
|
+
return diffUpdateState(safeInputs, current);
|
|
6956
|
+
case "updateDates":
|
|
6957
|
+
return diffUpdateDates(safeInputs, current);
|
|
6958
|
+
case "updateQuota":
|
|
6959
|
+
return diffUpdateQuota(safeInputs, current);
|
|
6960
|
+
case "updatePayments":
|
|
6961
|
+
return diffUpdatePayments(safeInputs, current);
|
|
6962
|
+
case "updateIntents":
|
|
6963
|
+
return diffUpdateIntents(safeInputs, current);
|
|
6964
|
+
case "refresh":
|
|
6965
|
+
return [];
|
|
6966
|
+
default:
|
|
6967
|
+
return [];
|
|
6968
|
+
}
|
|
6969
|
+
}
|
|
6970
|
+
});
|
|
6971
|
+
|
|
6972
|
+
// src/core/lib/actionRegistry/actions/collectionUsers/collectionUsers.diff.ts
|
|
6973
|
+
function formatQuota2(value) {
|
|
6974
|
+
if (value === void 0 || value === null) return "\u2014";
|
|
6975
|
+
const s = String(value).trim();
|
|
6976
|
+
if (s === "") return "\u2014";
|
|
6977
|
+
return s;
|
|
6978
|
+
}
|
|
6979
|
+
function roleLabel(value) {
|
|
6980
|
+
const r = String(value || "").trim().toLowerCase();
|
|
6981
|
+
if (r === "submit") return "Submit (Contributor)";
|
|
6982
|
+
if (r === "evaluate") return "Evaluate (Evaluator)";
|
|
6983
|
+
return "Unknown role";
|
|
6984
|
+
}
|
|
6985
|
+
function diffAdd(inputs) {
|
|
6986
|
+
const results = [];
|
|
6987
|
+
const kind = String(inputs.granteeKind || "user");
|
|
6988
|
+
results.push({ key: "role", label: "Role", before: null, after: roleLabel(inputs.role), changeType: "add" });
|
|
6989
|
+
if (inputs.collectionId) {
|
|
6990
|
+
results.push({ key: "collectionId", label: "Collection", before: null, after: String(inputs.collectionId), changeType: "add" });
|
|
6991
|
+
}
|
|
6992
|
+
if (kind === "group-members") {
|
|
6993
|
+
const count = Array.isArray(inputs.members) ? inputs.members.filter((m) => !!String(m?.address || "").trim()).length : 0;
|
|
6994
|
+
results.push({
|
|
6995
|
+
key: "grantees",
|
|
6996
|
+
label: "Grantees (fan-out)",
|
|
6997
|
+
before: null,
|
|
6998
|
+
after: `${count} group member${count === 1 ? "" : "s"}`,
|
|
6999
|
+
changeType: "add",
|
|
7000
|
+
severity: "warning"
|
|
7001
|
+
});
|
|
7002
|
+
} else {
|
|
7003
|
+
const label = kind === "group-account" ? "Grantee (group account)" : "Grantee";
|
|
7004
|
+
results.push({ key: "grantee", label, before: null, after: String(inputs.granteeAddress || "\u2014"), changeType: "add" });
|
|
7005
|
+
}
|
|
7006
|
+
results.push({
|
|
7007
|
+
key: "agentQuota",
|
|
7008
|
+
label: "Agent Quota",
|
|
7009
|
+
before: null,
|
|
7010
|
+
after: formatQuota2(inputs.agentQuota),
|
|
7011
|
+
changeType: "add",
|
|
7012
|
+
unit: formatQuota2(inputs.agentQuota) === "\u2014" ? void 0 : "claims"
|
|
7013
|
+
});
|
|
7014
|
+
return results;
|
|
7015
|
+
}
|
|
7016
|
+
function diffRevoke(inputs) {
|
|
7017
|
+
const results = [];
|
|
7018
|
+
results.push({ key: "role", label: "Role", before: roleLabel(inputs.role), after: null, changeType: "remove", severity: "warning" });
|
|
7019
|
+
if (inputs.collectionId) {
|
|
7020
|
+
results.push({ key: "collectionId", label: "Collection", before: String(inputs.collectionId), after: null, changeType: "remove", severity: "warning" });
|
|
7021
|
+
}
|
|
7022
|
+
results.push({
|
|
7023
|
+
key: "grantee",
|
|
7024
|
+
label: "Grantee",
|
|
7025
|
+
before: String(inputs.granteeAddress || "\u2014"),
|
|
7026
|
+
after: null,
|
|
7027
|
+
changeType: "remove",
|
|
7028
|
+
severity: "warning"
|
|
7029
|
+
});
|
|
7030
|
+
return results;
|
|
7031
|
+
}
|
|
7032
|
+
registerDiffResolver(COLLECTION_USERS_ACTION_TYPE, {
|
|
7033
|
+
resolver: async (inputs, _ctx) => {
|
|
7034
|
+
const safeInputs = inputs && typeof inputs === "object" ? inputs : {};
|
|
7035
|
+
const operation = String(safeInputs.operation || "").trim();
|
|
7036
|
+
switch (operation) {
|
|
7037
|
+
case "add":
|
|
7038
|
+
return diffAdd(safeInputs);
|
|
7039
|
+
case "revoke":
|
|
7040
|
+
return diffRevoke(safeInputs);
|
|
7041
|
+
case "list":
|
|
7042
|
+
return [];
|
|
7043
|
+
default:
|
|
7044
|
+
return [];
|
|
7045
|
+
}
|
|
7046
|
+
}
|
|
7047
|
+
});
|
|
7048
|
+
|
|
7049
|
+
// src/core/lib/actionRegistry/actions/carbon/harvest.diff.ts
|
|
7050
|
+
registerDiffResolver("qi/carbon.harvest", {
|
|
7051
|
+
resolver: async (inputs, _ctx) => {
|
|
7052
|
+
const selected = Array.isArray(inputs.selectedBatches) ? inputs.selectedBatches : [];
|
|
7053
|
+
if (selected.length === 0) return [];
|
|
7054
|
+
const rows = selected.map((b) => {
|
|
7055
|
+
const claimable = Number(b?.claimable) || 0;
|
|
7056
|
+
return {
|
|
7057
|
+
key: `batch-${b?.id}`,
|
|
7058
|
+
label: b?.alsoKnownAs || b?.id || "Batch",
|
|
7059
|
+
before: 0,
|
|
7060
|
+
after: claimable,
|
|
7061
|
+
changeType: "increase",
|
|
7062
|
+
unit: "CARBON"
|
|
7063
|
+
};
|
|
7064
|
+
});
|
|
7065
|
+
const total = selected.reduce((s, b) => s + (Number(b?.claimable) || 0), 0);
|
|
7066
|
+
rows.push({
|
|
7067
|
+
key: "total",
|
|
7068
|
+
label: "Total harvested to wallet",
|
|
7069
|
+
before: 0,
|
|
7070
|
+
after: total,
|
|
7071
|
+
changeType: "increase",
|
|
7072
|
+
unit: "CARBON",
|
|
7073
|
+
severity: "info"
|
|
7074
|
+
});
|
|
7075
|
+
return rows;
|
|
7076
|
+
}
|
|
7077
|
+
});
|
|
7078
|
+
|
|
7079
|
+
// src/core/lib/actionRegistry/actions/carbon/retire.diff.ts
|
|
7080
|
+
registerDiffResolver("qi/carbon.retire", {
|
|
7081
|
+
resolver: async (inputs, _ctx) => {
|
|
7082
|
+
const selected = Array.isArray(inputs.selectedBatches) ? inputs.selectedBatches : [];
|
|
7083
|
+
if (selected.length === 0) return [];
|
|
7084
|
+
const rows = selected.map((b) => {
|
|
7085
|
+
const amount = Number(b?.amount) || 0;
|
|
7086
|
+
return {
|
|
7087
|
+
key: `batch-${b?.id}`,
|
|
7088
|
+
label: b?.alsoKnownAs || b?.id || "Batch",
|
|
7089
|
+
before: amount,
|
|
7090
|
+
after: 0,
|
|
7091
|
+
changeType: "decrease",
|
|
7092
|
+
unit: "CARBON",
|
|
7093
|
+
severity: "warning"
|
|
7094
|
+
};
|
|
7095
|
+
});
|
|
7096
|
+
const total = selected.reduce((s, b) => s + (Number(b?.amount) || 0), 0);
|
|
7097
|
+
rows.push({
|
|
7098
|
+
key: "total",
|
|
7099
|
+
label: "Total retired (permanent, irreversible)",
|
|
7100
|
+
before: total,
|
|
7101
|
+
after: 0,
|
|
7102
|
+
changeType: "decrease",
|
|
7103
|
+
unit: "CARBON",
|
|
7104
|
+
severity: "critical"
|
|
7105
|
+
});
|
|
7106
|
+
return rows;
|
|
7107
|
+
}
|
|
7108
|
+
});
|
|
7109
|
+
|
|
6181
7110
|
// src/core/services/ucanService.ts
|
|
6182
7111
|
import {
|
|
6183
7112
|
createDelegation as ucanCreateDelegation,
|
|
@@ -10799,4 +11728,4 @@ export {
|
|
|
10799
11728
|
executeQueuedFlowAgentCoreCommands,
|
|
10800
11729
|
FlowAgentService
|
|
10801
11730
|
};
|
|
10802
|
-
//# sourceMappingURL=chunk-
|
|
11731
|
+
//# sourceMappingURL=chunk-W5M4NLHK.mjs.map
|