@ixo/action-protocol 0.7.0 → 0.9.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.
@@ -92,7 +92,97 @@ const chainText = (min, max) => ({
92
92
  ...string(min, max),
93
93
  pattern: min > 0 ? "^[A-Za-z0-9:._/-]+$" : "^[A-Za-z0-9:._/-]*$",
94
94
  });
95
- const chainTxMessage = {
95
+ // 0.8.0 (wire level 6) shapes. Cross-field rules (end after start, at least
96
+ // one date, role-only options, distinct payment denoms, uint64/10^9 maxima,
97
+ // calendar dates, https host parsing, `admin`) are the field parser's.
98
+ const denom = { ...string(3, 128), pattern: "^[a-zA-Z][a-zA-Z0-9/:._-]{2,127}$" };
99
+ const valoper = {
100
+ ...string(49, 49),
101
+ pattern: "^ixovaloper1[023456789acdefghjklmnpqrstuvwxyz]{38}$",
102
+ };
103
+ const entityDid = { ...string(47, 47), pattern: "^did:ixo:entity:[0-9a-f]{32}$" };
104
+ const uint64Text = collectionId;
105
+ const proposalId = { ...string(1, 20), pattern: "^[1-9][0-9]{0,19}$" };
106
+ const claimPermissionCount = { ...string(1, 10), pattern: "^[1-9][0-9]{0,9}$" };
107
+ const seconds = integer(0, 31536000);
108
+ const boolean = { type: "boolean" };
109
+ // The field parser's CONTROL set (index.js), as a character class body.
110
+ const control =
111
+ "\\u0000-\\u001f\\u007f-\\u009f\\u061c\\u200b-\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069\\ufeff";
112
+ // PLAIN_TEXT(max): 1..max characters, not blank, no control/bidi/zero-width.
113
+ const plainText = (max) => ({
114
+ ...string(1, max),
115
+ pattern: `^(?!\\s*$)[^${control}]+$`,
116
+ });
117
+ // No whitespace, backslash or CONTROL character anywhere; no user info.
118
+ const httpsUrl = `https://[^\\s/?#@\\\\${control}]+(?:[/?#][^\\s\\\\${control}]*)?`;
119
+ const ipfsUrl = `ipfs://[A-Za-z0-9]+(?:/[^\\s\\\\${control}]*)?`;
120
+ const httpsLink = { ...string(9, 300), pattern: `^${httpsUrl}$` };
121
+ const link = { ...string(8, 300), pattern: `^(?:${httpsUrl}|${ipfsUrl})$` };
122
+ const itemId = {
123
+ ...string(6, 233),
124
+ pattern: "^(?:\\{id\\}|did:ixo:[A-Za-z0-9._:%-]{1,160})#[A-Za-z0-9._~:-]{1,64}$",
125
+ };
126
+ // D28: an item to remove is named exactly as the document holds it.
127
+ const removeId = { ...string(1, 300), pattern: `^[^\\s${control}]+$` };
128
+ const iidType = { ...string(1, 64), pattern: "^[A-Za-z][A-Za-z0-9._:/+-]{0,63}$" };
129
+ // D28: linked resources and claims as Portal stores them.
130
+ const linkDescription = { ...string(0, 300), pattern: `^[^${control}]*$` };
131
+ const linkRight = optional({
132
+ ...string(0, 300),
133
+ pattern: `^(?:(?!\\s*$)[^${control}]+)?$`,
134
+ });
135
+ const linkedEntityId = {
136
+ anyOf: [
137
+ ixoDid,
138
+ {
139
+ ...string(42, 67),
140
+ pattern:
141
+ "^(?:\\{id\\}#)?ixo1(?:[023456789acdefghjklmnpqrstuvwxyz]{38}|[023456789acdefghjklmnpqrstuvwxyz]{58})$",
142
+ },
143
+ ],
144
+ };
145
+ const contextKey = { ...string(1, 64), pattern: "^[A-Za-z][A-Za-z0-9_-]{0,63}$" };
146
+ const coins = {
147
+ type: "array",
148
+ items: object({ denom, amountBaseUnits: baseUnits }),
149
+ minItems: 0,
150
+ maxItems: 4,
151
+ };
152
+ const leg = object({ amount: coins, payAfterSeconds: optional(seconds) });
153
+ const payments = object({
154
+ submission: optional(leg),
155
+ evaluation: optional(leg),
156
+ approval: optional(
157
+ object({
158
+ amount: coins,
159
+ payAfterSeconds: optional(seconds),
160
+ networkSplit: optional(boolean),
161
+ }),
162
+ ),
163
+ rejection: optional(leg),
164
+ });
165
+ const tokenLines = {
166
+ type: "array",
167
+ items: object({ id: chainText(1, 128), amount: baseUnits }),
168
+ minItems: 1,
169
+ maxItems: 32,
170
+ };
171
+ const collectionState = enumeration("open", "paused", "closed");
172
+ const entityPermission = enumeration(
173
+ "change-collection-state",
174
+ "change-collection-dates",
175
+ "change-collection-quota",
176
+ "change-collection-payments",
177
+ "authorize-claim-agents",
178
+ "file-claims",
179
+ "check-claims",
180
+ );
181
+ const ixoDidOrHttps = {
182
+ anyOf: [httpsLink, { ...ixoDid, maxLength: 300 }],
183
+ };
184
+ // The 33 message branches of wire level 6, in CHAIN_TX_MESSAGE_TYPES order.
185
+ const level6Messages = {
96
186
  anyOf: [
97
187
  object({
98
188
  type: { const: "cosmos.bank.send" },
@@ -133,6 +223,306 @@ const chainTxMessage = {
133
223
  maxItems: 32,
134
224
  },
135
225
  }),
226
+ // 0.8.0 (wire level 6), in CHAIN_TX_MESSAGE_TYPES order.
227
+ object({
228
+ type: { const: "ixo.token.retire" },
229
+ tokens: tokenLines,
230
+ jurisdiction: {
231
+ ...string(2, 71),
232
+ pattern:
233
+ "^(?:Global|[A-Z]{2}(?:-[A-Za-z0-9]{1,3}(?: [A-Za-z0-9]{1,64})?)?)$",
234
+ },
235
+ reason: plainText(200),
236
+ }),
237
+ object({
238
+ type: { const: "cosmos.staking.delegate" },
239
+ validatorAddress: valoper,
240
+ amountBaseUnits: baseUnits,
241
+ }),
242
+ object({
243
+ type: { const: "cosmos.staking.undelegate" },
244
+ validatorAddress: valoper,
245
+ amountBaseUnits: baseUnits,
246
+ }),
247
+ object({
248
+ type: { const: "cosmos.staking.redelegate" },
249
+ fromValidatorAddress: valoper,
250
+ toValidatorAddress: valoper,
251
+ amountBaseUnits: baseUnits,
252
+ }),
253
+ object({
254
+ type: { const: "cosmos.distribution.withdraw-rewards" },
255
+ validatorAddress: valoper,
256
+ }),
257
+ object({
258
+ type: { const: "cosmos.gov.vote" },
259
+ proposalId,
260
+ option: enumeration("yes", "no", "abstain", "no_with_veto"),
261
+ }),
262
+ object({
263
+ type: { const: "ixo.claims.claim-intent" },
264
+ collectionId,
265
+ agentDid: ixoDid,
266
+ }),
267
+ object({
268
+ type: { const: "ixo.claims.dispute" },
269
+ claimId: chainText(1, 256),
270
+ collectionId,
271
+ agentDid: ixoDid,
272
+ reason: enumeration("not_as_asked", "not_delivered", "check_wrong", "other"),
273
+ evidence: object({
274
+ uri: link,
275
+ type: { ...string(1, 100), pattern: "^[A-Za-z0-9][A-Za-z0-9.+/_-]{0,99}$" },
276
+ proof: chainText(1, 300),
277
+ encrypted: optional(boolean),
278
+ }),
279
+ }),
280
+ object({
281
+ type: { const: "ixo.claims.update-collection-state" },
282
+ collectionId,
283
+ adminAddress: account,
284
+ state: collectionState,
285
+ }),
286
+ object({
287
+ type: { const: "ixo.claims.update-collection-dates" },
288
+ collectionId,
289
+ adminAddress: account,
290
+ startDate: optional(instant),
291
+ endDate: optional(nullable(instant)),
292
+ }),
293
+ object({
294
+ type: { const: "ixo.claims.update-collection-quota" },
295
+ collectionId,
296
+ adminAddress: account,
297
+ maxClaims: uint64Text,
298
+ }),
299
+ object({
300
+ type: { const: "ixo.claims.create-claim-authorization" },
301
+ collectionId,
302
+ adminAddress: account,
303
+ granteeAddress: account,
304
+ role: enumeration("file-claims", "check-claims"),
305
+ maxClaims: claimPermissionCount,
306
+ expiresAt: optional(instant),
307
+ reservationSeconds: optional(seconds),
308
+ decideBefore: optional(instant),
309
+ creatorDid: ixoDid,
310
+ }),
311
+ object({
312
+ type: { const: "ixo.claims.update-collection-payments" },
313
+ collectionId,
314
+ adminAddress: account,
315
+ payments,
316
+ }),
317
+ object({
318
+ type: { const: "ixo.claims.create-collection" },
319
+ entityId: entityDid,
320
+ protocolId: ixoDid,
321
+ startDate: instant,
322
+ endDate: nullable(instant),
323
+ maxClaims: uint64Text,
324
+ state: collectionState,
325
+ reservations: enumeration("allow", "deny", "required"),
326
+ payments,
327
+ }),
328
+ object({
329
+ type: { const: "ixo.entity.create-account" },
330
+ entityId: entityDid,
331
+ name: {
332
+ ...string(1, 64),
333
+ pattern: "^[A-Za-z0-9](?:[A-Za-z0-9 _-]{0,62}[A-Za-z0-9])?$",
334
+ },
335
+ }),
336
+ object({
337
+ type: { const: "ixo.entity.update" },
338
+ entityId: entityDid,
339
+ startDate: optional(instant),
340
+ endDate: optional(nullable(instant)),
341
+ controllerDid: ixoDid,
342
+ }),
343
+ object({
344
+ type: { const: "ixo.entity.revoke-account-authz" },
345
+ entityId: entityDid,
346
+ granteeAddress: account,
347
+ permission: entityPermission,
348
+ }),
349
+ object({
350
+ type: { const: "ixo.entity.grant-account-authz" },
351
+ entityId: entityDid,
352
+ granteeAddress: account,
353
+ permission: entityPermission,
354
+ collectionId: optional(collectionId),
355
+ maxClaims: optional(claimPermissionCount),
356
+ reservationSeconds: optional(seconds),
357
+ decideBefore: optional(instant),
358
+ expiresAt: optional(instant),
359
+ }),
360
+ object({
361
+ type: { const: "ixo.entity.create" },
362
+ entityType: {
363
+ ...string(1, 65),
364
+ pattern: "^[a-z][a-z0-9_-]{0,31}(?:/[a-z][a-z0-9_-]{0,31})?$",
365
+ },
366
+ profile: optional(object({ serviceEndpoint: httpsLink, proof: chainText(1, 300) })),
367
+ protocolId: optional(ixoDid),
368
+ startDate: optional(instant),
369
+ endDate: optional(instant),
370
+ ownerDid: ixoDid,
371
+ }),
372
+ object({
373
+ type: { const: "ixo.iid.add-service" },
374
+ did: ixoDid,
375
+ service: object({ id: itemId, type: iidType, serviceEndpoint: link }),
376
+ }),
377
+ object({
378
+ type: { const: "ixo.iid.delete-service" },
379
+ did: ixoDid,
380
+ serviceId: removeId,
381
+ }),
382
+ object({
383
+ type: { const: "ixo.iid.add-linked-resource" },
384
+ did: ixoDid,
385
+ resource: object({
386
+ id: itemId,
387
+ type: iidType,
388
+ description: linkDescription,
389
+ mediaType: { ...string(3, 128), pattern: "^[a-z]+/[A-Za-z0-9.+-]{1,90}$" },
390
+ serviceEndpoint: link,
391
+ proof: chainText(0, 300),
392
+ encrypted: boolean,
393
+ right: linkRight,
394
+ }),
395
+ }),
396
+ object({
397
+ type: { const: "ixo.iid.delete-linked-resource" },
398
+ did: ixoDid,
399
+ resourceId: removeId,
400
+ }),
401
+ object({
402
+ type: { const: "ixo.iid.add-linked-claim" },
403
+ did: ixoDid,
404
+ claim: object({
405
+ id: chainText(1, 256),
406
+ type: iidType,
407
+ description: linkDescription,
408
+ serviceEndpoint: link,
409
+ proof: chainText(0, 300),
410
+ encrypted: boolean,
411
+ right: linkRight,
412
+ }),
413
+ }),
414
+ object({
415
+ type: { const: "ixo.iid.delete-linked-claim" },
416
+ did: ixoDid,
417
+ claimId: removeId,
418
+ }),
419
+ object({
420
+ type: { const: "ixo.iid.add-linked-entity" },
421
+ did: ixoDid,
422
+ entity: object({
423
+ id: linkedEntityId,
424
+ type: iidType,
425
+ relationship: { ...string(1, 64), pattern: "^[A-Za-z][A-Za-z0-9_-]{0,63}$" },
426
+ service: optional({
427
+ ...string(0, 233),
428
+ pattern:
429
+ "^(?:(?:(?:\\{id\\}|did:ixo:[A-Za-z0-9._:%-]{1,160})#)?[A-Za-z0-9._~:-]{1,64})?$",
430
+ }),
431
+ }),
432
+ }),
433
+ object({
434
+ type: { const: "ixo.iid.delete-linked-entity" },
435
+ did: ixoDid,
436
+ entityId: removeId,
437
+ }),
438
+ object({
439
+ type: { const: "ixo.iid.add-context" },
440
+ did: ixoDid,
441
+ context: object({ key: contextKey, val: ixoDidOrHttps }),
442
+ }),
443
+ object({
444
+ type: { const: "ixo.iid.delete-context" },
445
+ did: ixoDid,
446
+ key: removeId,
447
+ }),
448
+ ],
449
+ };
450
+ // 0.9.0 (wire level 7): DAO DAO group proposal steps. A 32-byte contract
451
+ // address (the Hub checks the checksum); a proposal id ≤ 2^53-1 (the
452
+ // numeric maximum, SHOWN_AS_IS text and `dao` ≠ `proposalModule` are the
453
+ // field parser's).
454
+ const contractAddress = {
455
+ ...string(62, 62),
456
+ pattern: "^ixo1[023456789acdefghjklmnpqrstuvwxyz]{58}$",
457
+ };
458
+ const groupProposalId = { ...string(1, 16), pattern: "^[1-9][0-9]{0,15}$" };
459
+ const branchOf = (type) =>
460
+ level6Messages.anyOf.find((branch) => branch.properties.type.const === type);
461
+ // CHAIN_TX_GROUP_ACTION_TYPES (index.js; a test keeps the two equal). A
462
+ // group's collection dates change names both dates (`endDate` may be null).
463
+ const groupActionTypes = [
464
+ "cosmos.bank.send",
465
+ "ixo.token.transfer",
466
+ "ixo.token.retire",
467
+ "cosmos.staking.delegate",
468
+ "cosmos.staking.undelegate",
469
+ "cosmos.staking.redelegate",
470
+ "cosmos.distribution.withdraw-rewards",
471
+ "cosmos.gov.vote",
472
+ "ixo.claims.update-collection-state",
473
+ "ixo.claims.update-collection-dates",
474
+ "ixo.claims.update-collection-quota",
475
+ "ixo.claims.create-collection",
476
+ "ixo.entity.create-account",
477
+ "ixo.entity.revoke-account-authz",
478
+ ];
479
+ const groupAction = {
480
+ anyOf: groupActionTypes.map((type) =>
481
+ type === "ixo.claims.update-collection-dates"
482
+ ? object({
483
+ type: { const: type },
484
+ collectionId,
485
+ adminAddress: account,
486
+ startDate: instant,
487
+ endDate: nullable(instant),
488
+ })
489
+ : branchOf(type),
490
+ ),
491
+ };
492
+ const groupTarget = { dao: contractAddress, proposalModule: contractAddress };
493
+ const groupMessages = {
494
+ anyOf: [
495
+ object({
496
+ type: { const: "daodao.proposal.vote" },
497
+ ...groupTarget,
498
+ proposalId: groupProposalId,
499
+ vote: enumeration("yes", "no", "abstain"),
500
+ rationale: optional(plainText(300)),
501
+ }),
502
+ object({
503
+ type: { const: "daodao.proposal.execute" },
504
+ ...groupTarget,
505
+ proposalId: groupProposalId,
506
+ }),
507
+ object({
508
+ type: { const: "daodao.proposal.close" },
509
+ ...groupTarget,
510
+ proposalId: groupProposalId,
511
+ }),
512
+ object({
513
+ type: { const: "daodao.proposal.create" },
514
+ ...groupTarget,
515
+ title: plainText(100),
516
+ description: plainText(300),
517
+ actions: { type: "array", items: groupAction, minItems: 0, maxItems: 4 },
518
+ }),
519
+ ],
520
+ };
521
+ // D5: one group step alone, or 1..8 messages of the other types.
522
+ const chainTxMessages = {
523
+ anyOf: [
524
+ { type: "array", items: groupMessages, minItems: 1, maxItems: 1 },
525
+ { type: "array", items: level6Messages, minItems: 1, maxItems: 8 },
136
526
  ],
137
527
  };
138
528
  const registry = {
@@ -224,7 +614,7 @@ const registry = {
224
614
  network: enumeration("ixo mainnet", "ixo testnet", "ixo devnet"),
225
615
  signer: account,
226
616
  memo: string(0, 256),
227
- messages: { type: "array", items: chainTxMessage, minItems: 1, maxItems: 8 },
617
+ messages: chainTxMessages,
228
618
  },
229
619
  "ixo.bid.submit.v1": {
230
620
  network,