@ixo/action-protocol 0.8.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -1,5 +1,173 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1
4
+
5
+ A patch release: two inputs are widened, nothing is narrowed, and the wire
6
+ level stays 7 (no new type, field or code).
7
+
8
+ - **Recipients may be contracts.** `cosmos.bank.send` `toAddress` and
9
+ `ixo.token.transfer` `recipient` (top level and inside a group proposal's
10
+ `actions`) accept a 32-byte `ixo1…` contract address (58 characters after
11
+ `ixo1`, e.g. a group's treasury) as well as a 20-byte account address
12
+ (`chainTxIssue`, `parseChainTxOperation`, the JSON schema). Signer and
13
+ identity fields (`signer`, `adminAddress`, `agentAddress`,
14
+ `granteeAddress`, DIDs) still take 20-byte accounts only. The Hub checks
15
+ the checksum. A Hub on 0.9.0 refuses such an address with the field
16
+ reason (`invalid_message: messages[i].toAddress`); a runtime should send
17
+ one only once it knows the Hub is on 0.9.1.
18
+ - **A vote's review step may list the proposal's actions** (`actions`,
19
+ optional on `daodao.proposal.vote`; the carry-out rules: at most 10, each
20
+ of a level-6 type or `type: null` for one the page cannot explain, the
21
+ step's `riskLevel` at least each action's). Display only: only the Hub's
22
+ own review page parses the view, and a vote step without `actions` (a
23
+ 0.9.0 Hub) still parses.
24
+
25
+ ## 0.9.0
26
+
27
+ Four `ixo.chain.tx.v1` message types for groups (DAO DAO v2.0.3 groups with
28
+ single-choice proposals). Every existing shape is unchanged. The Hub offers
29
+ and accepts them only from callers that declare `?version=7` (wire level 7 =
30
+ level 6 + these 4 types; the envelope tags stay `ixo.auth-capabilities/2` /
31
+ `ixo.auth-outcome/2`), because every 0.6.0-0.8.0 parser refuses a
32
+ capabilities document, review step or receipt that names a type it does not
33
+ know. Design record: `docs/dao-actions-design.md`.
34
+
35
+ - `CHAIN_TX_MESSAGE_TYPES` (frozen) appends the four below (37). New
36
+ `CHAIN_TX_LEVEL6_MESSAGE_TYPES` (frozen, exactly the 33 of 0.8.0),
37
+ `CHAIN_TX_GROUP_MESSAGE_TYPES` (the four) and `CHAIN_TX_LEVEL7 = 7`.
38
+ `chainTxMessageTypesForLevel(level)`: none below 4, the four 0.6.0 types
39
+ at 4 and 5, the 33 at 6, all 37 from 7. The Hub must refuse a create whose
40
+ messages are not in the caller's list with `400 protocol_version_required`,
41
+ before `chainTxIssue` (which accepts all 37).
42
+ - The person signs each of them directly. `dao` is the group's own contract
43
+ and `proposalModule` the group's proposal list the step acts on (a group
44
+ may have several; the Hub proves it is an enabled part of `dao` and works
45
+ out where new proposals are handed in from it):
46
+ - `daodao.proposal.vote` (`dao`, `proposalModule`, `proposalId`, `vote`
47
+ `yes` | `no` | `abstain`, `rationale?`): casts the person's vote on a
48
+ group proposal, with an optional reason published alongside it.
49
+ - `daodao.proposal.execute` (`dao`, `proposalModule`, `proposalId`):
50
+ carries out a proposal that passed: the group's own account then does
51
+ what the proposal says.
52
+ - `daodao.proposal.close` (`dao`, `proposalModule`, `proposalId`): closes
53
+ a proposal that did not pass (its deposit may go to the group rather than
54
+ back to the person who proposed it; the review says which).
55
+ - `daodao.proposal.create` (`dao`, `proposalModule`, `title`,
56
+ `description`, `actions`): asks the group to vote on a new proposal. The
57
+ Hub adds the group's deposit, if it has one, from the person's wallet.
58
+ `actions` (0..4, `CHAIN_TX_MAX_GROUP_ACTIONS`; `[]` = asks for
59
+ agreement only) is what the group's own account does if it passes. Each
60
+ action is exactly a top-level message of one of
61
+ `CHAIN_TX_GROUP_ACTION_TYPES` (frozen, 14): `cosmos.bank.send`,
62
+ `ixo.token.transfer`, `ixo.token.retire`, the four staking and rewards
63
+ types, `cosmos.gov.vote`, `ixo.claims.update-collection-state`,
64
+ `ixo.claims.update-collection-dates`,
65
+ `ixo.claims.update-collection-quota`, `ixo.claims.create-collection`,
66
+ `ixo.entity.create-account` and `ixo.entity.revoke-account-authz`, with
67
+ the same keys and field rules. None of them has a field naming the
68
+ person: the Hub makes the group the actor of each. A dates change in a
69
+ proposal must give both `startDate` and `endDate` (`null` = no end): a
70
+ date left out would be read now and be stale when the group carries it
71
+ out. Everything else is refused by type (claims and disputes need the
72
+ person's own identity, entity create a relayer, identity document links
73
+ the document's own keys, and payments, grants and entity updates are
74
+ written whole from what the Hub reads now).
75
+ - Field rules (`chainTxIssue` names the first bad field, nested ones by path,
76
+ e.g. `invalid_message: messages[0].actions[2].toAddress`):
77
+ - `dao`, `proposalModule`: a 32-byte contract address, `ixo1` + 58 bech32
78
+ characters (the Hub checks the checksum);
79
+ - `proposalId`: decimal text without leading zeros, 1..9007199254740991
80
+ (the Hub writes it as a JSON number, so nothing beyond the safe integer
81
+ range);
82
+ - `title` 1..100, `description` 1..300, `rationale` 1..300: plain text
83
+ and SHOWN_AS_IS (the 0.8.0 rule: exactly what the review page shows, no
84
+ links, no hidden characters, single spaces, one line).
85
+ - One card, one group step: an operation holding a group step holds no
86
+ other message. Otherwise `invalid_operation: messages` (the shape refusal
87
+ used for 0 or 9 messages). Each group step depends on a chain of reads and
88
+ a new proposal's id must be unambiguous on the receipt.
89
+ - Review display (`parseChainTxDisplay`): `daodao.proposal.create` and
90
+ `daodao.proposal.execute` steps carry `actions` (required, `[]` for none;
91
+ refused on every other step): the group's actions in plain words, each
92
+ `{type, title (≤ 60), whatItDoes (≤ 160), facts (≤ 12, the step fact
93
+ shape), riskLevel, cannotUndo}`. On create: the operation's own actions, in
94
+ order and of the same types (`parseReviewView` checks). On carry-out: the
95
+ passed proposal's stored actions, at most 10
96
+ (`CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS`), each of a level-6 type or `type:
97
+ null` for one the page cannot explain. A step's `riskLevel` is at least
98
+ each of its actions'. A `daodao.proposal.create` step may carry
99
+ `proposalPrefix` (1-4 capital letters; refused on every other step): the
100
+ proposal list's prefix, so a result names the new proposal as the cards
101
+ do ("proposal A4" from the receipt's `proposalId` "4").
102
+ - Receipts (`parseChainTxReceipt`): on a succeeded receipt (included, code
103
+ 0) a `daodao.proposal.create` step is `{type, proposalId}` (the new
104
+ proposal's id, or `null` when the Hub could not read it from the
105
+ transaction; never guessed) and a `daodao.proposal.execute` step is `{type,
106
+ groupActions}` (`"done"`, `"failed"`, or `"unknown"` when the Hub found no
107
+ proof either way in the transaction's events; the transaction succeeds
108
+ even when the group's actions fail, so code 0 alone does not say they
109
+ happened, and nothing reads `"unknown"` as done).
110
+ Every other step, and every step of a receipt that did not succeed, stays
111
+ `{type}`; `receiptFitsStatus` refuses either key outside `succeeded`.
112
+ - Capabilities accept the 37 types; the shape and `maxMessages` are
113
+ unchanged. The action types a proposal may hold are this package's
114
+ constant, not a capability.
115
+ - Refusal codes (`CHAIN_TX_REFUSAL_CODES`, appended; `parseChainTxRefusal`
116
+ also reads nested fields such as `actions[1].validatorAddress`). Reused:
117
+ `proposal_not_found`, `proposal_not_open` (voting has ended),
118
+ `chain_data_too_large` (the stored proposal is too large to show). New:
119
+ `group_not_supported` (`dao` / `proposalModule`: a group set up in a way a
120
+ card does not support yet: other contract versions, multiple choice, an
121
+ approval step), `not_in_group` (that proposal list is not an active part
122
+ of the group), `group_paused` (carrying out a proposal with actions while
123
+ the group is paused), `no_voting_power` (the person had no vote
124
+ when the proposal started), `already_voted` (and the group does not allow
125
+ changing votes), `same_vote` (field `vote`), `not_a_member` (`proposalId`
126
+ on carry-out, `dao` on create), `proposal_not_passed`,
127
+ `proposal_not_rejected` (only proposals that did not pass can be closed),
128
+ `group_actions_would_fail` (carried out now, the group's actions would fail
129
+ and the proposal would be marked failed for good), `deposit_not_supported`
130
+ (the deposit is in a token a card cannot pay), `proposal_too_large` (field
131
+ `description`), `not_for_groups` (`actions[<j>].type`), `not_group_owned`
132
+ (`actions[<j>].entityId`: the group does not own that entity),
133
+ `group_not_found` (`dao` / `proposalModule`: no contract at that address,
134
+ or another kind of group contract, e.g. the two addresses swapped),
135
+ `list_disabled` (`proposalModule`: the group switched that proposal list
136
+ off, so nothing in it can be carried out), `closes_too_soon`
137
+ (`proposalId`: voting closes before the card could be signed),
138
+ `group_inactive` (`dao`: the group is not taking new proposals right
139
+ now), `deposit_changed` (`dao`: the group's deposit changed while the
140
+ card was being made; ask again). A nested
141
+ action's own refusals keep their codes under its path, e.g.
142
+ `messages[0].actions[1].validatorAddress: validator_not_found`.
143
+ `chainTxIssue` itself still never adds a code: a type a group cannot use is
144
+ the shape refusal `messages[0].actions[<j>].type`.
145
+ - Bounds this package chose where the design left them open: `dao` and
146
+ `proposalModule` must differ (field `proposalModule`); `rationale` may be
147
+ left out but not `null`.
148
+ - New exports: `CHAIN_TX_LEVEL6_MESSAGE_TYPES`, `CHAIN_TX_GROUP_MESSAGE_TYPES`,
149
+ `CHAIN_TX_LEVEL7`, `CHAIN_TX_GROUP_ACTION_TYPES`,
150
+ `CHAIN_TX_MAX_GROUP_ACTIONS`, `CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS`,
151
+ `CHAIN_TX_GROUP_VOTE_OPTIONS`, `CHAIN_TX_GROUP_ACTION_RESULTS`; types
152
+ `ChainTxGroupMessageType`, `ChainTxGroupMessage`, `ChainTxLevel6Message`
153
+ (the 0.8.0 `ChainTxMessage`, which now also holds the group members),
154
+ `ChainTxGroupActionType`, `ChainTxGroupAction`, `ChainTxGroupVoteOption`,
155
+ `ChainTxGroupActionResult`, `ChainTxGroupActionDisplay`,
156
+ `ChainTxReceiptStep`.
157
+ - The operation JSON schema has one branch per group type, a nested action
158
+ schema built from the 14 allowed branches (dates with both keys
159
+ required), and `messages` is either one group step or 1..8 other
160
+ messages. The `ixo.chain.tx.v1` branch grows from 29 711 to 41 872
161
+ characters of JSON (the whole operation schema from 38 829 to 50 990).
162
+ The numeric proposal id maximum, SHOWN_AS_IS and `dao` ≠ `proposalModule`
163
+ are the field parser's.
164
+ - Rollout order (as 0.8.0): Hub and website on 0.9.0 (nothing changes for
165
+ callers at levels 1-6; a Hub before 0.9.0 answers `?version=7` with
166
+ `400 invalid_request`; an oracle reading a group card at level 4-6 gets
167
+ `receipt: null` and `outcome: null`), then gateways on 0.9.0 (a 0.8.0
168
+ gateway cannot parse a receipt with a group step and drops the outcome),
169
+ then runtimes on `?version=7`.
170
+
3
171
  ## 0.8.0
4
172
 
5
173
  29 more message types for `ixo.chain.tx.v1` cards. Every existing shape is
package/README.md CHANGED
@@ -32,6 +32,10 @@ Callers declare the envelope version they parse with `?version=2` on
32
32
  (`chainTxMessageTypesForLevel(6)`). Callers at levels 4 and 5 see and may
33
33
  create only the four 0.6.0 types (`CHAIN_TX_LEVEL4_MESSAGE_TYPES`); a
34
34
  `POST` naming a newer type answers `400 protocol_version_required`.
35
+ - `?version=7` (0.9.0): level 6 plus the four group types
36
+ (`CHAIN_TX_GROUP_MESSAGE_TYPES`, `chainTxMessageTypesForLevel(7)`).
37
+ Callers at level 6 see the 33 (`CHAIN_TX_LEVEL6_MESSAGE_TYPES`) and get
38
+ `400 protocol_version_required` for a group type.
35
39
 
36
40
  ## Applications and claims (`ixo.bid.submit.v1`, `ixo.claim.submit.v1`, 0.7.0)
37
41
 
@@ -110,6 +114,17 @@ identity document links (add or remove a service, linked resource, linked
110
114
  claim, linked entity or context). `CHANGELOG.md` 0.8.0 lists each type and
111
115
  its keys; `index.d.ts` `ChainTxMessage` has the exact shapes and rules.
112
116
 
117
+ Level 7 (0.9.0) adds four group types (DAO DAO v2.0.3 groups, single-choice
118
+ proposals): `daodao.proposal.vote`, `daodao.proposal.execute` (carry out a
119
+ passed proposal), `daodao.proposal.close` (close one that did not pass) and
120
+ `daodao.proposal.create` (a new proposal with 0..4 `actions` the group's
121
+ own account does if it passes, each a top-level message of one of
122
+ `CHAIN_TX_GROUP_ACTION_TYPES`). A card with a group step holds only that
123
+ step. Create and carry-out steps show the group's `actions` on the review
124
+ display; a succeeded receipt names a new proposal's `proposalId` and says
125
+ whether a carry-out's `groupActions` were `done` or `failed` (the
126
+ transaction succeeds either way). `CHANGELOG.md` 0.9.0 has the rules.
127
+
113
128
  - Authorization: the Hub wraps each message that runs under the collection
114
129
  admin's authorization in
115
130
  `/cosmos.authz.v1beta1.MsgExec {grantee: signer, msgs: [inner]}` (one
@@ -151,7 +166,8 @@ its keys; `index.d.ts` `ChainTxMessage` has the exact shapes and rules.
151
166
  `expired_not_included` (never included), plus a plain `message` for the
152
167
  first two.
153
168
  - Receipt `ixo.chain.tx.v1`: `chainId`, `txHash`, `height`, `code`, `steps`
154
- (`[{type}]` in order). A `failed` receipt always has a `reason`:
169
+ (`[{type}]` in order; on a succeeded receipt a group create step adds
170
+ `proposalId` and a carry-out step `groupActions`). A `failed` receipt always has a `reason`:
155
171
  `check_tx_rejected` (never included; CheckTx code), `expired_not_included`
156
172
  (never included; code null) or `tx_failed` (included with code != 0), and
157
173
  may carry a plain `message` (≤ 240) to show the person.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ixo/action-protocol",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Shared wire contract between IXO Auth Hub, oracle runtimes and channel gateways for reviewed action cards (operations, capabilities, outcomes, receipts).",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/index.d.ts CHANGED
@@ -333,10 +333,45 @@ export type ChainTxLevel6MessageType =
333
333
  | "ixo.iid.delete-linked-entity"
334
334
  | "ixo.iid.add-context"
335
335
  | "ixo.iid.delete-context";
336
- /** 0.6.0: one card kind for every chain transaction (0.8.0: 33 types). */
336
+ /** 0.9.0: the four DAO DAO group types wire level 7 adds. */
337
+ export type ChainTxGroupMessageType =
338
+ | "daodao.proposal.vote"
339
+ | "daodao.proposal.execute"
340
+ | "daodao.proposal.close"
341
+ | "daodao.proposal.create";
342
+ /** 0.6.0: one card kind for every chain transaction (0.8.0: 33 types; 0.9.0: 37). */
337
343
  export type ChainTxMessageType =
338
344
  | ChainTxLevel4MessageType
339
- | ChainTxLevel6MessageType;
345
+ | ChainTxLevel6MessageType
346
+ | ChainTxGroupMessageType;
347
+ /**
348
+ * 0.9.0 D11: what a group's own account may do in a proposal
349
+ * (`CHAIN_TX_GROUP_ACTION_TYPES`).
350
+ */
351
+ export type ChainTxGroupActionType =
352
+ | "cosmos.bank.send"
353
+ | "ixo.token.transfer"
354
+ | "ixo.token.retire"
355
+ | "cosmos.staking.delegate"
356
+ | "cosmos.staking.undelegate"
357
+ | "cosmos.staking.redelegate"
358
+ | "cosmos.distribution.withdraw-rewards"
359
+ | "cosmos.gov.vote"
360
+ | "ixo.claims.update-collection-state"
361
+ | "ixo.claims.update-collection-dates"
362
+ | "ixo.claims.update-collection-quota"
363
+ | "ixo.claims.create-collection"
364
+ | "ixo.entity.create-account"
365
+ | "ixo.entity.revoke-account-authz";
366
+ /** `daodao.proposal.vote` `vote` (single choice). */
367
+ export type ChainTxGroupVoteOption = "yes" | "no" | "abstain";
368
+ /** Receipt `groupActions` of a carry-out. */
369
+ /**
370
+ * `"unknown"`: the transaction succeeded but the Hub found no proof either
371
+ * way in its events (the proposal list's own `action=execute` event for
372
+ * this proposal); never read as done.
373
+ */
374
+ export type ChainTxGroupActionResult = "done" | "failed" | "unknown";
340
375
  /*
341
376
  * 0.8.0 shared rules (`chainTxIssue` names the first bad field, nested
342
377
  * fields by path, e.g. `messages[0].payments.approval.amount[1].denom`):
@@ -435,9 +470,13 @@ export type ChainTxIidRemoveId = string;
435
470
  * - claim ids, token ids and verification proofs: ^[A-Za-z0-9:._/-]+$;
436
471
  * - collectionId: a uint64 without leading zeros.
437
472
  */
438
- export type ChainTxMessage =
473
+ export type ChainTxLevel6Message =
439
474
  | {
440
475
  type: "cosmos.bank.send";
476
+ /**
477
+ * A 20-byte `ixo1…` account or (0.9.1) a 32-byte `ixo1…` contract
478
+ * address, e.g. a group's treasury; the Hub checks the checksum.
479
+ */
441
480
  toAddress: string;
442
481
  /** ^[1-9][0-9]*$ */
443
482
  amountBaseUnits: string;
@@ -485,6 +524,7 @@ export type ChainTxMessage =
485
524
  }
486
525
  | {
487
526
  type: "ixo.token.transfer";
527
+ /** A 20-byte account or (0.9.1) a 32-byte contract address, as `toAddress`. */
488
528
  recipient: string;
489
529
  /** 1..32 lines; id 1..128 of ^[A-Za-z0-9:._/-]+$, amount ^[1-9][0-9]*$ */
490
530
  tokens: Array<{ id: string; amount: string }>;
@@ -784,6 +824,77 @@ export type ChainTxMessage =
784
824
  };
785
825
  }
786
826
  | { type: "ixo.iid.delete-context"; did: string; key: ChainTxIidRemoveId };
827
+ /**
828
+ * 0.9.0 D11: one action a group's own account does if a proposal passes:
829
+ * exactly a top-level message of a `ChainTxGroupActionType` (same keys and
830
+ * rules; none names the person, and the Hub sets every signer field to the
831
+ * group). A collection dates change names both dates (`endDate` may be
832
+ * null), because a date left out would be read when the card is made and be
833
+ * stale when the group carries it out.
834
+ */
835
+ export type ChainTxGroupAction =
836
+ | Exclude<
837
+ Extract<ChainTxLevel6Message, { type: ChainTxGroupActionType }>,
838
+ { type: "ixo.claims.update-collection-dates" }
839
+ >
840
+ | {
841
+ type: "ixo.claims.update-collection-dates";
842
+ collectionId: string;
843
+ adminAddress: string;
844
+ /** INSTANT */
845
+ startDate: string;
846
+ /** INSTANT after `startDate`, or null = no end date. */
847
+ endDate: string | null;
848
+ };
849
+ /*
850
+ * 0.9.0 (wire level 7) group rules, DAO DAO v2.0.3 single-choice proposals:
851
+ * - CONTRACT_ADDRESS (`dao`, `proposalModule`): a 32-byte contract address,
852
+ * `ixo1` + 58 bech32 characters (the Hub checks the checksum); `dao` is the
853
+ * group's core contract, `proposalModule` one of its proposal lists (a
854
+ * different contract). The Hub derives the proposal intake from it (D17).
855
+ * - PROPOSAL_ID: decimal text without leading zeros, 1..9007199254740991
856
+ * (the Hub writes it as a JSON number, D16).
857
+ * - Text (`title` ≤ 100, `description` ≤ 300, `rationale` ≤ 300):
858
+ * PLAIN_TEXT and SHOWN_AS_IS (published on chain, shown whole).
859
+ * - A card with a group step holds exactly that one message (D5), else
860
+ * `invalid_operation: messages`.
861
+ */
862
+ export type ChainTxGroupMessage =
863
+ | {
864
+ /** Casts the person's vote on a group proposal. */
865
+ type: "daodao.proposal.vote";
866
+ dao: string;
867
+ proposalModule: string;
868
+ proposalId: string;
869
+ vote: ChainTxGroupVoteOption;
870
+ /** Published with the vote. */
871
+ rationale?: string;
872
+ }
873
+ | {
874
+ /** Carries out a passed proposal: the group's own account does its actions. */
875
+ type: "daodao.proposal.execute";
876
+ dao: string;
877
+ proposalModule: string;
878
+ proposalId: string;
879
+ }
880
+ | {
881
+ /** Closes a proposal that did not pass. */
882
+ type: "daodao.proposal.close";
883
+ dao: string;
884
+ proposalModule: string;
885
+ proposalId: string;
886
+ }
887
+ | {
888
+ /** Asks the group to vote on a new proposal (the Hub adds any deposit). */
889
+ type: "daodao.proposal.create";
890
+ dao: string;
891
+ proposalModule: string;
892
+ title: string;
893
+ description: string;
894
+ /** 0..4 (`CHAIN_TX_MAX_GROUP_ACTIONS`); [] = a text-only proposal. */
895
+ actions: ChainTxGroupAction[];
896
+ };
897
+ export type ChainTxMessage = ChainTxLevel6Message | ChainTxGroupMessage;
787
898
  export type ChainTxOperation = {
788
899
  kind: "ixo.chain.tx.v1";
789
900
  /** Must equal the Hub RPC's chain id at prepare. */
@@ -816,6 +927,38 @@ export type ChainTxStep = {
816
927
  cannotUndo: boolean;
817
928
  /** cosmos.bank.send steps: the bank-send display (verified/unverified token rules). */
818
929
  transfer?: TransferDisplay;
930
+ /**
931
+ * 0.9.0 D13: required on `daodao.proposal.create` (its 0..4 actions, in
932
+ * order) and `daodao.proposal.execute` (the passed proposal's actions, at
933
+ * most 10 shown); `[]` for none. 0.9.1: optional on
934
+ * `daodao.proposal.vote` (the proposal's stored actions, as on carry-out),
935
+ * so voters see what it would do. Absent on every other step. The step's
936
+ * `riskLevel` is at least each action's.
937
+ */
938
+ actions?: ChainTxGroupActionDisplay[];
939
+ /**
940
+ * 0.9.0, `daodao.proposal.create` only: the proposal list's prefix (1-4
941
+ * capital letters), so the result names the new proposal as the cards do
942
+ * ("proposal A4" from the receipt's `proposalId` "4"). Absent when the
943
+ * list has none (the plain number is the label).
944
+ */
945
+ proposalPrefix?: string;
946
+ };
947
+ /** 0.9.0: one action the group's own account would do, in plain words. */
948
+ export type ChainTxGroupActionDisplay = {
949
+ /**
950
+ * create: the wire action's type (a `ChainTxGroupActionType`); execute:
951
+ * a level-6 type, or null for an action the page cannot explain.
952
+ */
953
+ type: ChainTxLevel4MessageType | ChainTxLevel6MessageType | null;
954
+ /** ≤ 60, plain words. */
955
+ title: string;
956
+ /** One sentence, ≤ 160. */
957
+ whatItDoes: string;
958
+ /** ≤ 12. */
959
+ facts: ChainTxFact[];
960
+ riskLevel: ChainTxRiskLevel;
961
+ cannotUndo: boolean;
819
962
  };
820
963
  export type ChainTxDisplay = {
821
964
  /** The highest step risk. */
@@ -857,8 +1000,24 @@ export type ChainTxReceipt = {
857
1000
  /** ≤ 240, plain words for the person; only with a `reason`. */
858
1001
  message?: string;
859
1002
  /** The approved messages' types, in order. */
860
- steps: Array<{ type: ChainTxMessageType }>;
1003
+ steps: ChainTxReceiptStep[];
861
1004
  };
1005
+ /**
1006
+ * 0.9.0: on a succeeded receipt (included, code 0) a `daodao.proposal.create`
1007
+ * step has `proposalId` (PROPOSAL_ID, or null when the Hub could not read
1008
+ * it; never guessed) and a `daodao.proposal.execute` step has `groupActions`
1009
+ * (whether the group's actions ran: tx code 0 alone does not say so). Both
1010
+ * are absent on every other receipt.
1011
+ */
1012
+ export type ChainTxReceiptStep =
1013
+ | {
1014
+ type: Exclude<
1015
+ ChainTxMessageType,
1016
+ "daodao.proposal.create" | "daodao.proposal.execute"
1017
+ >;
1018
+ }
1019
+ | { type: "daodao.proposal.create"; proposalId?: string | null }
1020
+ | { type: "daodao.proposal.execute"; groupActions?: ChainTxGroupActionResult };
862
1021
  export type ChainTxCapabilities = {
863
1022
  messageTypes: ChainTxMessageType[];
864
1023
  maxMessages: number;
@@ -871,9 +1030,53 @@ export declare const CHAIN_TX_LEVEL4_MESSAGE_TYPES: readonly [
871
1030
  "ixo.claims.evaluate",
872
1031
  "ixo.token.transfer",
873
1032
  ];
1033
+ /** 0.9.0: the 33 types of wire level 6 (the four, then the 29 of 0.8.0), frozen. */
1034
+ export declare const CHAIN_TX_LEVEL6_MESSAGE_TYPES: readonly [
1035
+ "cosmos.bank.send",
1036
+ "ixo.claims.submit",
1037
+ "ixo.claims.evaluate",
1038
+ "ixo.token.transfer",
1039
+ "ixo.token.retire",
1040
+ "cosmos.staking.delegate",
1041
+ "cosmos.staking.undelegate",
1042
+ "cosmos.staking.redelegate",
1043
+ "cosmos.distribution.withdraw-rewards",
1044
+ "cosmos.gov.vote",
1045
+ "ixo.claims.claim-intent",
1046
+ "ixo.claims.dispute",
1047
+ "ixo.claims.update-collection-state",
1048
+ "ixo.claims.update-collection-dates",
1049
+ "ixo.claims.update-collection-quota",
1050
+ "ixo.claims.create-claim-authorization",
1051
+ "ixo.claims.update-collection-payments",
1052
+ "ixo.claims.create-collection",
1053
+ "ixo.entity.create-account",
1054
+ "ixo.entity.update",
1055
+ "ixo.entity.revoke-account-authz",
1056
+ "ixo.entity.grant-account-authz",
1057
+ "ixo.entity.create",
1058
+ "ixo.iid.add-service",
1059
+ "ixo.iid.delete-service",
1060
+ "ixo.iid.add-linked-resource",
1061
+ "ixo.iid.delete-linked-resource",
1062
+ "ixo.iid.add-linked-claim",
1063
+ "ixo.iid.delete-linked-claim",
1064
+ "ixo.iid.add-linked-entity",
1065
+ "ixo.iid.delete-linked-entity",
1066
+ "ixo.iid.add-context",
1067
+ "ixo.iid.delete-context",
1068
+ ];
1069
+ /** 0.9.0: the four group types of wire level 7, frozen. */
1070
+ export declare const CHAIN_TX_GROUP_MESSAGE_TYPES: readonly [
1071
+ "daodao.proposal.vote",
1072
+ "daodao.proposal.execute",
1073
+ "daodao.proposal.close",
1074
+ "daodao.proposal.create",
1075
+ ];
874
1076
  /**
875
- * Every type this package parses (the four, then the 29 of 0.8.0), frozen.
876
- * What a caller may see or create: `chainTxMessageTypesForLevel(level)`.
1077
+ * Every type this package parses (the 33 of level 6, then the four group
1078
+ * types of 0.9.0), frozen. What a caller may see or create:
1079
+ * `chainTxMessageTypesForLevel(level)`.
877
1080
  */
878
1081
  export declare const CHAIN_TX_MESSAGE_TYPES: readonly [
879
1082
  "cosmos.bank.send",
@@ -909,18 +1112,32 @@ export declare const CHAIN_TX_MESSAGE_TYPES: readonly [
909
1112
  "ixo.iid.delete-linked-entity",
910
1113
  "ixo.iid.add-context",
911
1114
  "ixo.iid.delete-context",
1115
+ "daodao.proposal.vote",
1116
+ "daodao.proposal.execute",
1117
+ "daodao.proposal.close",
1118
+ "daodao.proposal.create",
912
1119
  ];
913
1120
  /** The wire level that adds the 29 types of 0.8.0. */
914
1121
  export declare const CHAIN_TX_LEVEL6: 6;
1122
+ /** The wire level that adds the four group types of 0.9.0. */
1123
+ export declare const CHAIN_TX_LEVEL7: 7;
915
1124
  /**
916
1125
  * The chain tx message types a caller at wire `level` (a positive integer)
917
1126
  * may see and create: none below 4, `CHAIN_TX_LEVEL4_MESSAGE_TYPES` at 4
918
- * and 5, `CHAIN_TX_MESSAGE_TYPES` from 6. Throws `TypeError` on a
919
- * non-integer or a level below 1.
1127
+ * and 5, `CHAIN_TX_LEVEL6_MESSAGE_TYPES` at 6, `CHAIN_TX_MESSAGE_TYPES`
1128
+ * from 7. Throws `TypeError` on a non-integer or a level below 1.
920
1129
  */
921
1130
  export declare function chainTxMessageTypesForLevel(
922
1131
  level: number,
923
1132
  ): readonly ChainTxMessageType[];
1133
+ /** 0.9.0 D11: the action types a group proposal may hold, frozen. */
1134
+ export declare const CHAIN_TX_GROUP_ACTION_TYPES: readonly ChainTxGroupActionType[];
1135
+ /** 0.9.0 D12: actions per new proposal. */
1136
+ export declare const CHAIN_TX_MAX_GROUP_ACTIONS: 4;
1137
+ /** 0.9.0: actions shown on a carry-out step. */
1138
+ export declare const CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS: 10;
1139
+ export declare const CHAIN_TX_GROUP_VOTE_OPTIONS: readonly ChainTxGroupVoteOption[];
1140
+ export declare const CHAIN_TX_GROUP_ACTION_RESULTS: readonly ChainTxGroupActionResult[];
924
1141
  export declare const CHAIN_TX_VOTE_OPTIONS: readonly ChainTxVoteOption[];
925
1142
  export declare const CHAIN_TX_DISPUTE_REASONS: readonly ChainTxDisputeReason[];
926
1143
  export declare const CHAIN_TX_COLLECTION_STATES: readonly ChainTxCollectionState[];
@@ -977,12 +1194,52 @@ export type ChainTxRefusalCode =
977
1194
  | "already_exists"
978
1195
  | "invalid_did"
979
1196
  | "not_available"
980
- | "chain_data_too_large";
1197
+ | "chain_data_too_large"
1198
+ // 0.9.0 groups (nested proposal actions use their own codes under
1199
+ // `actions[<j>]`, e.g. `actions[1].validatorAddress: validator_not_found`).
1200
+ /** `dao`/`proposalModule`: another contract version, multiple choice, an approval step. */
1201
+ | "group_not_supported"
1202
+ /** `proposalModule`: not an enabled proposal list of this group. */
1203
+ | "not_in_group"
1204
+ /** `dao`: the group is paused (carrying out a proposal with actions). */
1205
+ | "group_paused"
1206
+ /** `proposalId`: the person had no vote when the proposal started. */
1207
+ | "no_voting_power"
1208
+ /** `proposalId`: already voted, and the group doesn't allow changing votes. */
1209
+ | "already_voted"
1210
+ /** `vote`: already voted this way. */
1211
+ | "same_vote"
1212
+ /** `proposalId` (carry out) / `dao` (create): members only. */
1213
+ | "not_a_member"
1214
+ /** `proposalId`: it hasn't passed (yet, or at all). */
1215
+ | "proposal_not_passed"
1216
+ /** `proposalId`: only proposals that did not pass can be closed. */
1217
+ | "proposal_not_rejected"
1218
+ /** `proposalId`: run now, the group's actions would fail and the proposal be marked failed for good. */
1219
+ | "group_actions_would_fail"
1220
+ /** `dao`: the deposit is in a token a card can't pay. */
1221
+ | "deposit_not_supported"
1222
+ /** `description`: over the group's proposal size limit. */
1223
+ | "proposal_too_large"
1224
+ /** `actions[<j>].type`: the group can't do this kind of action through a card. */
1225
+ | "not_for_groups"
1226
+ /** `actions[<j>].entityId`: the group doesn't own this entity. */
1227
+ | "not_group_owned"
1228
+ /** `dao`/`proposalModule`: no contract there, or another kind of group contract (e.g. the two swapped). */
1229
+ | "group_not_found"
1230
+ /** `proposalModule`: the group has switched this proposal list off (nothing in it can be carried out). */
1231
+ | "list_disabled"
1232
+ /** `proposalId`: voting closes before the card could be signed. */
1233
+ | "closes_too_soon"
1234
+ /** `dao`: the group is not taking new proposals right now. */
1235
+ | "group_inactive"
1236
+ /** `dao`: the group's deposit changed while the card was being made. */
1237
+ | "deposit_changed";
981
1238
  export declare const CHAIN_TX_REFUSAL_CODES: readonly ChainTxRefusalCode[];
982
1239
  export type ChainTxRefusal = {
983
1240
  /** The message index (0..7). */
984
1241
  index: number;
985
- /** The field or path, e.g. `validatorAddress`, `payments.approval`. */
1242
+ /** The field or path, e.g. `validatorAddress`, `payments.approval`, `actions[1].toAddress`. */
986
1243
  field: string;
987
1244
  /** Null when the reason has no code, or one this package does not know. */
988
1245
  code: ChainTxRefusalCode | null;
package/src/index.js CHANGED
@@ -499,7 +499,15 @@ export function parseReviewView(input) {
499
499
  display.signer !== view.operation.signer ||
500
500
  display.steps.length !== view.operation.messages.length ||
501
501
  display.steps.some(
502
- (step, i) => step.type !== view.operation.messages[i].type,
502
+ (step, i) =>
503
+ step.type !== view.operation.messages[i].type ||
504
+ // 0.9.0: a new proposal's step shows exactly its actions, in order.
505
+ (step.type === "daodao.proposal.create" &&
506
+ (step.actions.length !== view.operation.messages[i].actions.length ||
507
+ step.actions.some(
508
+ (action, j) =>
509
+ action.type !== view.operation.messages[i].actions[j].type,
510
+ ))),
503
511
  )
504
512
  )
505
513
  fail("view.chainTx");
@@ -1618,6 +1626,12 @@ function receiptFitsStatus(receipt, status) {
1618
1626
  // 0.6.0: a chain tx receipt succeeds only included with code 0; a failure
1619
1627
  // always names its reason (tx_failed = included with code != 0).
1620
1628
  if (receipt.kind === CHAIN_TX_KIND) {
1629
+ // 0.9.0: a proposal id or group result belongs to a succeeded receipt only.
1630
+ if (
1631
+ status !== "succeeded" &&
1632
+ receipt.steps.some((step) => "proposalId" in step || "groupActions" in step)
1633
+ )
1634
+ return false;
1621
1635
  if (status === "succeeded")
1622
1636
  return (
1623
1637
  receipt.code === 0 && receipt.height !== null && !("reason" in receipt)
@@ -1723,11 +1737,10 @@ export const CHAIN_TX_LEVEL4_MESSAGE_TYPES = Object.freeze([
1723
1737
  "ixo.token.transfer",
1724
1738
  ]);
1725
1739
  /**
1726
- * Every message type this package parses: the level-4 types, then the 29
1727
- * types of 0.8.0 (wire level 6). What a caller may see or create is
1728
- * `chainTxMessageTypesForLevel(level)`, never this list.
1740
+ * 0.9.0: the 33 message types wire level 6 may see: the level-4 types, then
1741
+ * the 29 types of 0.8.0.
1729
1742
  */
1730
- export const CHAIN_TX_MESSAGE_TYPES = Object.freeze([
1743
+ export const CHAIN_TX_LEVEL6_MESSAGE_TYPES = Object.freeze([
1731
1744
  ...CHAIN_TX_LEVEL4_MESSAGE_TYPES,
1732
1745
  "ixo.token.retire",
1733
1746
  "cosmos.staking.delegate",
@@ -1759,21 +1772,76 @@ export const CHAIN_TX_MESSAGE_TYPES = Object.freeze([
1759
1772
  "ixo.iid.add-context",
1760
1773
  "ixo.iid.delete-context",
1761
1774
  ]);
1775
+ /**
1776
+ * 0.9.0 (wire level 7): steps on a DAO DAO group's single-choice proposals
1777
+ * (contracts v2.0.3). The person signs; a card holding one holds nothing
1778
+ * else (D5).
1779
+ */
1780
+ export const CHAIN_TX_GROUP_MESSAGE_TYPES = Object.freeze([
1781
+ "daodao.proposal.vote",
1782
+ "daodao.proposal.execute",
1783
+ "daodao.proposal.close",
1784
+ "daodao.proposal.create",
1785
+ ]);
1786
+ /**
1787
+ * Every message type this package parses: the 33 types of wire level 6,
1788
+ * then the four group types of 0.9.0 (wire level 7). What a caller may see
1789
+ * or create is `chainTxMessageTypesForLevel(level)`, never this list.
1790
+ */
1791
+ export const CHAIN_TX_MESSAGE_TYPES = Object.freeze([
1792
+ ...CHAIN_TX_LEVEL6_MESSAGE_TYPES,
1793
+ ...CHAIN_TX_GROUP_MESSAGE_TYPES,
1794
+ ]);
1762
1795
  /** The wire level that adds the 29 types of 0.8.0. */
1763
1796
  export const CHAIN_TX_LEVEL6 = 6;
1797
+ /** The wire level that adds the four group types of 0.9.0. */
1798
+ export const CHAIN_TX_LEVEL7 = 7;
1764
1799
  const NO_CHAIN_TX_TYPES = Object.freeze([]);
1765
1800
  /**
1766
1801
  * The chain tx message types a caller at wire `level` may see in
1767
1802
  * capabilities and create: none below 4 (no chain tx), the four 0.6.0 types
1768
- * at 4 and 5, all 33 from 6. One rule for the Hub, runtimes and tests.
1803
+ * at 4 and 5, the 33 at 6, all 37 from 7. One rule for the Hub, runtimes and
1804
+ * tests.
1769
1805
  */
1770
1806
  export function chainTxMessageTypesForLevel(level) {
1771
1807
  if (!Number.isSafeInteger(level) || level < 1) fail("level");
1772
1808
  if (level < 4) return NO_CHAIN_TX_TYPES;
1773
- return level < CHAIN_TX_LEVEL6
1774
- ? CHAIN_TX_LEVEL4_MESSAGE_TYPES
1775
- : CHAIN_TX_MESSAGE_TYPES;
1809
+ if (level < CHAIN_TX_LEVEL6) return CHAIN_TX_LEVEL4_MESSAGE_TYPES;
1810
+ if (level < CHAIN_TX_LEVEL7) return CHAIN_TX_LEVEL6_MESSAGE_TYPES;
1811
+ return CHAIN_TX_MESSAGE_TYPES;
1776
1812
  }
1813
+ /**
1814
+ * 0.9.0 D11: what a group's own account may do in a proposal
1815
+ * (`daodao.proposal.create` `actions`): every signer field of these can be
1816
+ * the group's address, and none writes a value read from chain at propose
1817
+ * time (it runs days later). The person's own identity (claims, disputes),
1818
+ * a relayer (entity create), an identity document's keys (iid) and whole
1819
+ * writes from reads (payments, grants, entity update) are left out.
1820
+ */
1821
+ export const CHAIN_TX_GROUP_ACTION_TYPES = Object.freeze([
1822
+ "cosmos.bank.send",
1823
+ "ixo.token.transfer",
1824
+ "ixo.token.retire",
1825
+ "cosmos.staking.delegate",
1826
+ "cosmos.staking.undelegate",
1827
+ "cosmos.staking.redelegate",
1828
+ "cosmos.distribution.withdraw-rewards",
1829
+ "cosmos.gov.vote",
1830
+ "ixo.claims.update-collection-state",
1831
+ "ixo.claims.update-collection-dates",
1832
+ "ixo.claims.update-collection-quota",
1833
+ "ixo.claims.create-collection",
1834
+ "ixo.entity.create-account",
1835
+ "ixo.entity.revoke-account-authz",
1836
+ ]);
1837
+ /** D12: at most this many actions in a new proposal. */
1838
+ export const CHAIN_TX_MAX_GROUP_ACTIONS = 4;
1839
+ /** 0.9.0 §7: at most this many of a passed proposal's actions on a carry-out step. */
1840
+ export const CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS = 10;
1841
+ /** `daodao.proposal.vote` `vote` (single choice: no veto option). */
1842
+ export const CHAIN_TX_GROUP_VOTE_OPTIONS = Object.freeze(["yes", "no", "abstain"]);
1843
+ /** Receipt `groupActions` of a carry-out: whether the group's actions ran (D8). */
1844
+ export const CHAIN_TX_GROUP_ACTION_RESULTS = Object.freeze(["done", "failed", "unknown"]);
1777
1845
  export const CHAIN_TX_MAX_MESSAGES = 8;
1778
1846
  export const CHAIN_TX_MAX_TOKEN_LINES = 32;
1779
1847
  /** `check_tx_rejected`/`expired_not_included`: never included; `tx_failed`: included with code != 0. */
@@ -1894,6 +1962,32 @@ export const CHAIN_TX_REFUSAL_CODES = Object.freeze([
1894
1962
  // The card as a whole.
1895
1963
  "not_available",
1896
1964
  "chain_data_too_large",
1965
+ // 0.9.0 groups (`proposal_not_found`, `proposal_not_open` and
1966
+ // `chain_data_too_large` above are reused). Nested proposal actions use
1967
+ // their own codes under `actions[<j>]`, e.g.
1968
+ // `messages[0].actions[1].validatorAddress: validator_not_found`.
1969
+ "group_not_supported",
1970
+ "not_in_group",
1971
+ "group_paused",
1972
+ "no_voting_power",
1973
+ "already_voted",
1974
+ "same_vote",
1975
+ "not_a_member",
1976
+ "proposal_not_passed",
1977
+ "proposal_not_rejected",
1978
+ "group_actions_would_fail",
1979
+ "deposit_not_supported",
1980
+ "proposal_too_large",
1981
+ "not_for_groups",
1982
+ "not_group_owned",
1983
+ // 0.9.0 review fixes (appended): a fixable wrong address, a switched-off
1984
+ // proposal list, voting that closes inside the signing window, a group
1985
+ // not taking proposals, a deposit that changed while the card was made.
1986
+ "group_not_found",
1987
+ "list_disabled",
1988
+ "closes_too_soon",
1989
+ "group_inactive",
1990
+ "deposit_changed",
1897
1991
  ]);
1898
1992
  const CHAIN_TX_REFUSAL =
1899
1993
  /^invalid_message: messages\[(\d)\]\.([A-Za-z][A-Za-z0-9_.[\]]{0,99})(?:: ([a-z_]{1,64}))?$/;
@@ -1926,6 +2020,12 @@ const ANY_DID = new RegExp(`^did:[a-z0-9]+:${DID_TAIL}$`);
1926
2020
  // The Hub's isIxoAddress: canonical lowercase bech32 with exactly 20 data
1927
2021
  // bytes (32 payload + 6 checksum characters). The Hub also checks the checksum.
1928
2022
  const ACCOUNT_ADDRESS = /^ixo1[023456789acdefghjklmnpqrstuvwxyz]{38}$/;
2023
+ // 0.9.1: who receives coins or impact tokens (`cosmos.bank.send` toAddress,
2024
+ // `ixo.token.transfer` recipient, also inside a group's actions): a 20-byte
2025
+ // account or a 32-byte contract address (a group's treasury, an app). Never
2026
+ // a signer or identity field. The Hub also checks the checksum.
2027
+ const RECIPIENT_ADDRESS =
2028
+ /^ixo1(?:[023456789acdefghjklmnpqrstuvwxyz]{38}|[023456789acdefghjklmnpqrstuvwxyz]{58})$/;
1929
2029
  const BASE_UNITS = /^[1-9][0-9]{0,77}$/;
1930
2030
  // A uint64 without leading zeros (checked against UINT64_MAX below).
1931
2031
  const COLLECTION_ID = /^(0|[1-9][0-9]{0,19})$/;
@@ -2076,6 +2176,26 @@ const CHAIN_TX_MESSAGE_KEYS = {
2076
2176
  "ixo.iid.delete-linked-entity": ["type", "did", "entityId"],
2077
2177
  "ixo.iid.add-context": ["type", "did", "context"],
2078
2178
  "ixo.iid.delete-context": ["type", "did", "key"],
2179
+ // 0.9.0 (wire level 7). The person is the sender; the Hub derives the
2180
+ // proposal intake from `proposalModule` (D17).
2181
+ "daodao.proposal.vote": [
2182
+ "type",
2183
+ "dao",
2184
+ "proposalModule",
2185
+ "proposalId",
2186
+ "vote",
2187
+ "rationale",
2188
+ ],
2189
+ "daodao.proposal.execute": ["type", "dao", "proposalModule", "proposalId"],
2190
+ "daodao.proposal.close": ["type", "dao", "proposalModule", "proposalId"],
2191
+ "daodao.proposal.create": [
2192
+ "type",
2193
+ "dao",
2194
+ "proposalModule",
2195
+ "title",
2196
+ "description",
2197
+ "actions",
2198
+ ],
2079
2199
  };
2080
2200
  // 0.8.0 wire patterns (the JSON schema in operation-schema.js mirrors them).
2081
2201
  // A validator operator address: `ixovaloper1` + 38 bech32 characters (20
@@ -2132,6 +2252,12 @@ const SERVICE_REF =
2132
2252
  const LINKED_ENTITY_ADDRESS =
2133
2253
  /^(?:\{id\}#)?ixo1(?:[023456789acdefghjklmnpqrstuvwxyz]{38}|[023456789acdefghjklmnpqrstuvwxyz]{58})$/;
2134
2254
  const CLAIM_PERMISSIONS = ["file-claims", "check-claims"];
2255
+ // 0.9.0: a 32-byte contract address (`ixo1` + 58 bech32 characters); the
2256
+ // Hub also checks the checksum.
2257
+ const CONTRACT_ADDRESS = /^ixo1[023456789acdefghjklmnpqrstuvwxyz]{58}$/;
2258
+ // D16: a group proposal id, decimal without leading zeros, 1..2^53-1 (the
2259
+ // Hub writes it as a JSON number; checked numerically below).
2260
+ const GROUP_PROPOSAL_ID = /^[1-9][0-9]{0,15}$/;
2135
2261
  const plain = (value) =>
2136
2262
  value !== null && typeof value === "object" && !Array.isArray(value);
2137
2263
  const isText = (value, min = 1, max = 200) =>
@@ -2158,6 +2284,10 @@ const isPlainText = (value, max) =>
2158
2284
  */
2159
2285
  const isShownAsIs = (value) =>
2160
2286
  typeof value === "string" && sanitizePublishedText(value) === value;
2287
+ /** PROPOSAL_ID: a group proposal id (D16). */
2288
+ const isGroupProposalId = (value) =>
2289
+ isMatch(value, GROUP_PROPOSAL_ID, 16) &&
2290
+ BigInt(value) <= BigInt(Number.MAX_SAFE_INTEGER);
2161
2291
  /**
2162
2292
  * INSTANT: a real calendar instant whose UTC time a protobuf Timestamp can
2163
2293
  * hold the way the Hub encodes it (1970-01-01T00:00:00Z .. year 9999).
@@ -2504,6 +2634,70 @@ const CHAIN_TX_LEVEL6_FIELDS = {
2504
2634
  "ixo.iid.delete-context": (m) =>
2505
2635
  iidDidField(m) ?? (removeIdRule(m.key) ? null : "key"),
2506
2636
  };
2637
+ /** 0.9.0: the first bad field of each group type (relative), or null. */
2638
+ const CHAIN_TX_GROUP_FIELDS = {
2639
+ "daodao.proposal.vote": (m) => {
2640
+ const target = groupProposalField(m);
2641
+ if (target) return target;
2642
+ if (!CHAIN_TX_GROUP_VOTE_OPTIONS.includes(m.vote)) return "vote";
2643
+ if (m.rationale !== undefined && !isGroupText(m.rationale, 300))
2644
+ return "rationale";
2645
+ return null;
2646
+ },
2647
+ "daodao.proposal.execute": (m) => groupProposalField(m),
2648
+ "daodao.proposal.close": (m) => groupProposalField(m),
2649
+ "daodao.proposal.create": (m) => {
2650
+ const target = groupTargetField(m);
2651
+ if (target) return target;
2652
+ if (!isGroupText(m.title, 100)) return "title";
2653
+ if (!isGroupText(m.description, 300)) return "description";
2654
+ return groupActionsField(m.actions);
2655
+ },
2656
+ };
2657
+ /** D14/D15: proposal text and vote reasons are PLAIN_TEXT and SHOWN_AS_IS. */
2658
+ const isGroupText = (value, max) => isPlainText(value, max) && isShownAsIs(value);
2659
+ /** `dao` (the group's core) and `proposalModule` (D17), two different contracts. */
2660
+ function groupTargetField(m) {
2661
+ if (!isMatch(m.dao, CONTRACT_ADDRESS, 62)) return "dao";
2662
+ if (!isMatch(m.proposalModule, CONTRACT_ADDRESS, 62) || m.proposalModule === m.dao)
2663
+ return "proposalModule";
2664
+ return null;
2665
+ }
2666
+ function groupProposalField(m) {
2667
+ return groupTargetField(m) ?? (isGroupProposalId(m.proposalId) ? null : "proposalId");
2668
+ }
2669
+ /**
2670
+ * D11/D12: 0..4 actions the group's own account does if the proposal
2671
+ * passes, each exactly a top-level message of a `CHAIN_TX_GROUP_ACTION_TYPES`
2672
+ * type (same keys, same field rules; none of them has a field naming the
2673
+ * person, the Hub sets every signer field to `dao`). Paths are
2674
+ * `actions[<j>].<field>`.
2675
+ */
2676
+ function groupActionsField(actions) {
2677
+ if (!Array.isArray(actions) || actions.length > CHAIN_TX_MAX_GROUP_ACTIONS)
2678
+ return "actions";
2679
+ for (const [j, action] of actions.entries()) {
2680
+ const at = `actions[${j}]`;
2681
+ if (!plain(action)) return at;
2682
+ if (!CHAIN_TX_GROUP_ACTION_TYPES.includes(action.type)) return `${at}.type`;
2683
+ const unknown = unknownKey(action, CHAIN_TX_MESSAGE_KEYS[action.type], at);
2684
+ if (unknown) return unknown;
2685
+ const field = chainTxMessageField(action) ?? groupActionRuleField(action);
2686
+ if (field) return `${at}.${field}`;
2687
+ }
2688
+ return null;
2689
+ }
2690
+ /**
2691
+ * The rule a group action adds to its type's: a collection dates change
2692
+ * names both dates (`endDate` may be null), because a date left out would be
2693
+ * filled from a read that is stale when the group carries it out (D11).
2694
+ */
2695
+ function groupActionRuleField(action) {
2696
+ if (action.type !== "ixo.claims.update-collection-dates") return null;
2697
+ if (action.startDate === undefined) return "startDate";
2698
+ if (action.endDate === undefined) return "endDate";
2699
+ return null;
2700
+ }
2507
2701
  function stakeField(m) {
2508
2702
  if (!isMatch(m.validatorAddress, VALOPER_ADDRESS, 49)) return "validatorAddress";
2509
2703
  if (!isMatch(m.amountBaseUnits, BASE_UNITS, 78)) return "amountBaseUnits";
@@ -2540,8 +2734,10 @@ function iidDidField(m) {
2540
2734
  function chainTxMessageField(m) {
2541
2735
  if (Object.hasOwn(CHAIN_TX_LEVEL6_FIELDS, m.type))
2542
2736
  return CHAIN_TX_LEVEL6_FIELDS[m.type](m);
2737
+ if (Object.hasOwn(CHAIN_TX_GROUP_FIELDS, m.type))
2738
+ return CHAIN_TX_GROUP_FIELDS[m.type](m);
2543
2739
  if (m.type === "cosmos.bank.send") {
2544
- if (!isMatch(m.toAddress, ACCOUNT_ADDRESS)) return "toAddress";
2740
+ if (!isMatch(m.toAddress, RECIPIENT_ADDRESS, 62)) return "toAddress";
2545
2741
  if (!isMatch(m.amountBaseUnits, BASE_UNITS, 78)) return "amountBaseUnits";
2546
2742
  if (m.denom !== undefined && !isMatch(m.denom, DENOM, 128)) return "denom";
2547
2743
  return null;
@@ -2574,7 +2770,7 @@ function chainTxMessageField(m) {
2574
2770
  return null;
2575
2771
  }
2576
2772
  // ixo.token.transfer
2577
- if (!isMatch(m.recipient, ACCOUNT_ADDRESS)) return "recipient";
2773
+ if (!isMatch(m.recipient, RECIPIENT_ADDRESS, 62)) return "recipient";
2578
2774
  return tokenLinesField(m.tokens);
2579
2775
  }
2580
2776
 
@@ -2600,6 +2796,14 @@ function chainTxField(op) {
2600
2796
  op.messages.length > CHAIN_TX_MAX_MESSAGES
2601
2797
  )
2602
2798
  return "messages";
2799
+ // 0.9.0 D5: a card with a group step holds exactly that one message.
2800
+ if (
2801
+ op.messages.length > 1 &&
2802
+ op.messages.some(
2803
+ (m) => plain(m) && CHAIN_TX_GROUP_MESSAGE_TYPES.includes(m.type),
2804
+ )
2805
+ )
2806
+ return "messages";
2603
2807
  for (const [i, m] of op.messages.entries()) {
2604
2808
  const at = `messages[${i}]`;
2605
2809
  if (!plain(m)) return at;
@@ -2703,6 +2907,8 @@ export function parseChainTxDisplay(input) {
2703
2907
  "riskLevel",
2704
2908
  "cannotUndo",
2705
2909
  "transfer",
2910
+ "actions",
2911
+ "proposalPrefix",
2706
2912
  ],
2707
2913
  "view.chainTx.step",
2708
2914
  );
@@ -2712,14 +2918,7 @@ export function parseChainTxDisplay(input) {
2712
2918
  str(step.whatItDoes, "view.chainTx.step.whatItDoes", 1, 160);
2713
2919
  if (!Array.isArray(step.facts) || step.facts.length > 40)
2714
2920
  fail("view.chainTx.step.facts");
2715
- for (const fact of step.facts) {
2716
- object(fact, "view.chainTx.fact");
2717
- exact(fact, ["label", "value", "technical"], "view.chainTx.fact");
2718
- str(fact.label, "view.chainTx.fact.label", 1, 60);
2719
- str(fact.value, "view.chainTx.fact.value", 1, 300);
2720
- if (fact.technical !== undefined && typeof fact.technical !== "boolean")
2721
- fail("view.chainTx.fact.technical");
2722
- }
2921
+ for (const fact of step.facts) parseChainTxFact(fact);
2723
2922
  const risk = CHAIN_TX_RISK_LEVELS.indexOf(step.riskLevel);
2724
2923
  if (risk < 0) fail("view.chainTx.step.riskLevel");
2725
2924
  highest = Math.max(highest, risk);
@@ -2728,6 +2927,14 @@ export function parseChainTxDisplay(input) {
2728
2927
  if (step.type !== "cosmos.bank.send") fail("view.chainTx.step.transfer");
2729
2928
  parseTransferDisplay(step.transfer);
2730
2929
  }
2930
+ parseGroupActionsDisplay(step, risk);
2931
+ // A new proposal's list prefix (1-4 capital letters), so the result can
2932
+ // name it as the cards do ("proposal A4"); absent when the list has none.
2933
+ if (step.proposalPrefix !== undefined) {
2934
+ if (step.type !== "daodao.proposal.create")
2935
+ fail("view.chainTx.step.proposalPrefix");
2936
+ pattern(step.proposalPrefix, /^[A-Z]{1,4}$/, "view.chainTx.step.proposalPrefix");
2937
+ }
2731
2938
  }
2732
2939
  if (CHAIN_TX_RISK_LEVELS[highest] !== d.riskLevel)
2733
2940
  fail("view.chainTx.riskLevel");
@@ -2743,6 +2950,63 @@ export function parseChainTxDisplay(input) {
2743
2950
  return d;
2744
2951
  }
2745
2952
 
2953
+ function parseChainTxFact(fact) {
2954
+ object(fact, "view.chainTx.fact");
2955
+ exact(fact, ["label", "value", "technical"], "view.chainTx.fact");
2956
+ str(fact.label, "view.chainTx.fact.label", 1, 60);
2957
+ str(fact.value, "view.chainTx.fact.value", 1, 300);
2958
+ if (fact.technical !== undefined && typeof fact.technical !== "boolean")
2959
+ fail("view.chainTx.fact.technical");
2960
+ }
2961
+
2962
+ /**
2963
+ * 0.9.0 D13: what the group's own account would do, on create (its 0..4
2964
+ * actions, in order) and carry-out (the passed proposal's stored actions,
2965
+ * at most 10 shown; `type: null` for one the page cannot explain). Required
2966
+ * on those two step types (`[]` for none). 0.9.1: optional on a vote (the
2967
+ * proposal's stored actions, as on carry-out), so voters see what it would
2968
+ * do; refused on every other step. The step's risk is at least each
2969
+ * action's.
2970
+ */
2971
+ function parseGroupActionsDisplay(step, stepRisk) {
2972
+ const create = step.type === "daodao.proposal.create";
2973
+ if (step.type === "daodao.proposal.vote" && step.actions === undefined) return;
2974
+ if (
2975
+ !create &&
2976
+ step.type !== "daodao.proposal.execute" &&
2977
+ step.type !== "daodao.proposal.vote"
2978
+ ) {
2979
+ if (step.actions !== undefined) fail("view.chainTx.step.actions");
2980
+ return;
2981
+ }
2982
+ const max = create ? CHAIN_TX_MAX_GROUP_ACTIONS : CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS;
2983
+ if (!Array.isArray(step.actions) || step.actions.length > max)
2984
+ fail("view.chainTx.step.actions");
2985
+ for (const action of step.actions) {
2986
+ object(action, "view.chainTx.action");
2987
+ exact(
2988
+ action,
2989
+ ["type", "title", "whatItDoes", "facts", "riskLevel", "cannotUndo"],
2990
+ "view.chainTx.action",
2991
+ );
2992
+ if (
2993
+ action.type === null
2994
+ ? create
2995
+ : !(create ? CHAIN_TX_GROUP_ACTION_TYPES : CHAIN_TX_LEVEL6_MESSAGE_TYPES).includes(action.type)
2996
+ )
2997
+ fail("view.chainTx.action.type");
2998
+ str(action.title, "view.chainTx.action.title", 1, 60);
2999
+ str(action.whatItDoes, "view.chainTx.action.whatItDoes", 1, 160);
3000
+ if (!Array.isArray(action.facts) || action.facts.length > 12)
3001
+ fail("view.chainTx.action.facts");
3002
+ for (const fact of action.facts) parseChainTxFact(fact);
3003
+ const risk = CHAIN_TX_RISK_LEVELS.indexOf(action.riskLevel);
3004
+ if (risk < 0 || risk > stepRisk) fail("view.chainTx.action.riskLevel");
3005
+ if (typeof action.cannotUndo !== "boolean")
3006
+ fail("view.chainTx.action.cannotUndo");
3007
+ }
3008
+ }
3009
+
2746
3010
  function parseChainTxReceipt(r) {
2747
3011
  exact(
2748
3012
  r,
@@ -2791,13 +3055,37 @@ function parseChainTxReceipt(r) {
2791
3055
  r.steps.length > CHAIN_TX_MAX_MESSAGES
2792
3056
  )
2793
3057
  fail("receipt.steps");
3058
+ // 0.9.0: on a succeeded receipt (included, code 0) a new proposal names its
3059
+ // id (null when the Hub could not read it; never guessed) and a carry-out
3060
+ // says whether the group's actions ran. Absent on every other receipt.
3061
+ const succeeded = r.code === 0 && r.height !== null && !("reason" in r);
2794
3062
  for (const step of r.steps) {
2795
3063
  object(step, "receipt.step");
2796
- exact(step, ["type"], "receipt.step");
3064
+ const result =
3065
+ succeeded && Object.hasOwn(CHAIN_TX_RECEIPT_STEP_RESULT, step.type)
3066
+ ? CHAIN_TX_RECEIPT_STEP_RESULT[step.type]
3067
+ : undefined;
3068
+ exact(step, result ? ["type", result] : ["type"], "receipt.step");
2797
3069
  if (!CHAIN_TX_MESSAGE_TYPES.includes(step.type)) fail("receipt.step.type");
3070
+ if (
3071
+ result === "proposalId" &&
3072
+ (!("proposalId" in step) ||
3073
+ (step.proposalId !== null && !isGroupProposalId(step.proposalId)))
3074
+ )
3075
+ fail("receipt.step.proposalId");
3076
+ if (
3077
+ result === "groupActions" &&
3078
+ !CHAIN_TX_GROUP_ACTION_RESULTS.includes(step.groupActions)
3079
+ )
3080
+ fail("receipt.step.groupActions");
2798
3081
  }
2799
3082
  return r;
2800
3083
  }
3084
+ /** 0.9.0: the one key a succeeded receipt step adds, per type (D8, D9). */
3085
+ const CHAIN_TX_RECEIPT_STEP_RESULT = {
3086
+ "daodao.proposal.create": "proposalId",
3087
+ "daodao.proposal.execute": "groupActions",
3088
+ };
2801
3089
 
2802
3090
  export * from "./outcome-signature.js";
2803
3091
 
@@ -87,6 +87,12 @@ const anyDid = { ...string(7, 200), pattern: `^did:[a-z0-9]+:${didTail}$` };
87
87
  const collectionId = { ...string(1, 20), pattern: "^(0|[1-9][0-9]{0,19})$" };
88
88
  // A 20-byte ixo account address (the Hub also checks the bech32 checksum).
89
89
  const account = { ...string(42, 42), pattern: "^ixo1[023456789acdefghjklmnpqrstuvwxyz]{38}$" };
90
+ // 0.9.1: who receives coins or impact tokens: a 20-byte account or a 32-byte
91
+ // contract address (a group's treasury, an app); never a signer or identity.
92
+ const recipient = {
93
+ ...string(42, 62),
94
+ pattern: "^ixo1(?:[023456789acdefghjklmnpqrstuvwxyz]{38}|[023456789acdefghjklmnpqrstuvwxyz]{58})$",
95
+ };
90
96
  // Claim ids, impact token ids and verification proofs.
91
97
  const chainText = (min, max) => ({
92
98
  ...string(min, max),
@@ -181,11 +187,12 @@ const entityPermission = enumeration(
181
187
  const ixoDidOrHttps = {
182
188
  anyOf: [httpsLink, { ...ixoDid, maxLength: 300 }],
183
189
  };
184
- const chainTxMessage = {
190
+ // The 33 message branches of wire level 6, in CHAIN_TX_MESSAGE_TYPES order.
191
+ const level6Messages = {
185
192
  anyOf: [
186
193
  object({
187
194
  type: { const: "cosmos.bank.send" },
188
- toAddress: account,
195
+ toAddress: recipient,
189
196
  amountBaseUnits: baseUnits,
190
197
  denom: optional({ ...string(3, 128), pattern: "^[a-zA-Z][a-zA-Z0-9/:._-]{2,127}$" }),
191
198
  }),
@@ -214,7 +221,7 @@ const chainTxMessage = {
214
221
  }),
215
222
  object({
216
223
  type: { const: "ixo.token.transfer" },
217
- recipient: account,
224
+ recipient,
218
225
  tokens: {
219
226
  type: "array",
220
227
  items: object({ id: chainText(1, 128), amount: baseUnits }),
@@ -446,6 +453,84 @@ const chainTxMessage = {
446
453
  }),
447
454
  ],
448
455
  };
456
+ // 0.9.0 (wire level 7): DAO DAO group proposal steps. A 32-byte contract
457
+ // address (the Hub checks the checksum); a proposal id ≤ 2^53-1 (the
458
+ // numeric maximum, SHOWN_AS_IS text and `dao` ≠ `proposalModule` are the
459
+ // field parser's).
460
+ const contractAddress = {
461
+ ...string(62, 62),
462
+ pattern: "^ixo1[023456789acdefghjklmnpqrstuvwxyz]{58}$",
463
+ };
464
+ const groupProposalId = { ...string(1, 16), pattern: "^[1-9][0-9]{0,15}$" };
465
+ const branchOf = (type) =>
466
+ level6Messages.anyOf.find((branch) => branch.properties.type.const === type);
467
+ // CHAIN_TX_GROUP_ACTION_TYPES (index.js; a test keeps the two equal). A
468
+ // group's collection dates change names both dates (`endDate` may be null).
469
+ const groupActionTypes = [
470
+ "cosmos.bank.send",
471
+ "ixo.token.transfer",
472
+ "ixo.token.retire",
473
+ "cosmos.staking.delegate",
474
+ "cosmos.staking.undelegate",
475
+ "cosmos.staking.redelegate",
476
+ "cosmos.distribution.withdraw-rewards",
477
+ "cosmos.gov.vote",
478
+ "ixo.claims.update-collection-state",
479
+ "ixo.claims.update-collection-dates",
480
+ "ixo.claims.update-collection-quota",
481
+ "ixo.claims.create-collection",
482
+ "ixo.entity.create-account",
483
+ "ixo.entity.revoke-account-authz",
484
+ ];
485
+ const groupAction = {
486
+ anyOf: groupActionTypes.map((type) =>
487
+ type === "ixo.claims.update-collection-dates"
488
+ ? object({
489
+ type: { const: type },
490
+ collectionId,
491
+ adminAddress: account,
492
+ startDate: instant,
493
+ endDate: nullable(instant),
494
+ })
495
+ : branchOf(type),
496
+ ),
497
+ };
498
+ const groupTarget = { dao: contractAddress, proposalModule: contractAddress };
499
+ const groupMessages = {
500
+ anyOf: [
501
+ object({
502
+ type: { const: "daodao.proposal.vote" },
503
+ ...groupTarget,
504
+ proposalId: groupProposalId,
505
+ vote: enumeration("yes", "no", "abstain"),
506
+ rationale: optional(plainText(300)),
507
+ }),
508
+ object({
509
+ type: { const: "daodao.proposal.execute" },
510
+ ...groupTarget,
511
+ proposalId: groupProposalId,
512
+ }),
513
+ object({
514
+ type: { const: "daodao.proposal.close" },
515
+ ...groupTarget,
516
+ proposalId: groupProposalId,
517
+ }),
518
+ object({
519
+ type: { const: "daodao.proposal.create" },
520
+ ...groupTarget,
521
+ title: plainText(100),
522
+ description: plainText(300),
523
+ actions: { type: "array", items: groupAction, minItems: 0, maxItems: 4 },
524
+ }),
525
+ ],
526
+ };
527
+ // D5: one group step alone, or 1..8 messages of the other types.
528
+ const chainTxMessages = {
529
+ anyOf: [
530
+ { type: "array", items: groupMessages, minItems: 1, maxItems: 1 },
531
+ { type: "array", items: level6Messages, minItems: 1, maxItems: 8 },
532
+ ],
533
+ };
449
534
  const registry = {
450
535
  "form.submit.v1": {
451
536
  formId: string(1, 120),
@@ -535,7 +620,7 @@ const registry = {
535
620
  network: enumeration("ixo mainnet", "ixo testnet", "ixo devnet"),
536
621
  signer: account,
537
622
  memo: string(0, 256),
538
- messages: { type: "array", items: chainTxMessage, minItems: 1, maxItems: 8 },
623
+ messages: chainTxMessages,
539
624
  },
540
625
  "ixo.bid.submit.v1": {
541
626
  network,