@ixo/action-protocol 0.8.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.
- package/CHANGELOG.md +146 -0
- package/README.md +17 -1
- package/package.json +1 -1
- package/src/index.d.ts +260 -10
- package/src/index.js +293 -18
- package/src/operation-schema.js +81 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,151 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
Four `ixo.chain.tx.v1` message types for groups (DAO DAO v2.0.3 groups with
|
|
6
|
+
single-choice proposals). Every existing shape is unchanged. The Hub offers
|
|
7
|
+
and accepts them only from callers that declare `?version=7` (wire level 7 =
|
|
8
|
+
level 6 + these 4 types; the envelope tags stay `ixo.auth-capabilities/2` /
|
|
9
|
+
`ixo.auth-outcome/2`), because every 0.6.0-0.8.0 parser refuses a
|
|
10
|
+
capabilities document, review step or receipt that names a type it does not
|
|
11
|
+
know. Design record: `docs/dao-actions-design.md`.
|
|
12
|
+
|
|
13
|
+
- `CHAIN_TX_MESSAGE_TYPES` (frozen) appends the four below (37). New
|
|
14
|
+
`CHAIN_TX_LEVEL6_MESSAGE_TYPES` (frozen, exactly the 33 of 0.8.0),
|
|
15
|
+
`CHAIN_TX_GROUP_MESSAGE_TYPES` (the four) and `CHAIN_TX_LEVEL7 = 7`.
|
|
16
|
+
`chainTxMessageTypesForLevel(level)`: none below 4, the four 0.6.0 types
|
|
17
|
+
at 4 and 5, the 33 at 6, all 37 from 7. The Hub must refuse a create whose
|
|
18
|
+
messages are not in the caller's list with `400 protocol_version_required`,
|
|
19
|
+
before `chainTxIssue` (which accepts all 37).
|
|
20
|
+
- The person signs each of them directly. `dao` is the group's own contract
|
|
21
|
+
and `proposalModule` the group's proposal list the step acts on (a group
|
|
22
|
+
may have several; the Hub proves it is an enabled part of `dao` and works
|
|
23
|
+
out where new proposals are handed in from it):
|
|
24
|
+
- `daodao.proposal.vote` (`dao`, `proposalModule`, `proposalId`, `vote`
|
|
25
|
+
`yes` | `no` | `abstain`, `rationale?`): casts the person's vote on a
|
|
26
|
+
group proposal, with an optional reason published alongside it.
|
|
27
|
+
- `daodao.proposal.execute` (`dao`, `proposalModule`, `proposalId`):
|
|
28
|
+
carries out a proposal that passed: the group's own account then does
|
|
29
|
+
what the proposal says.
|
|
30
|
+
- `daodao.proposal.close` (`dao`, `proposalModule`, `proposalId`): closes
|
|
31
|
+
a proposal that did not pass (its deposit may go to the group rather than
|
|
32
|
+
back to the person who proposed it; the review says which).
|
|
33
|
+
- `daodao.proposal.create` (`dao`, `proposalModule`, `title`,
|
|
34
|
+
`description`, `actions`): asks the group to vote on a new proposal. The
|
|
35
|
+
Hub adds the group's deposit, if it has one, from the person's wallet.
|
|
36
|
+
`actions` (0..4, `CHAIN_TX_MAX_GROUP_ACTIONS`; `[]` = asks for
|
|
37
|
+
agreement only) is what the group's own account does if it passes. Each
|
|
38
|
+
action is exactly a top-level message of one of
|
|
39
|
+
`CHAIN_TX_GROUP_ACTION_TYPES` (frozen, 14): `cosmos.bank.send`,
|
|
40
|
+
`ixo.token.transfer`, `ixo.token.retire`, the four staking and rewards
|
|
41
|
+
types, `cosmos.gov.vote`, `ixo.claims.update-collection-state`,
|
|
42
|
+
`ixo.claims.update-collection-dates`,
|
|
43
|
+
`ixo.claims.update-collection-quota`, `ixo.claims.create-collection`,
|
|
44
|
+
`ixo.entity.create-account` and `ixo.entity.revoke-account-authz`, with
|
|
45
|
+
the same keys and field rules. None of them has a field naming the
|
|
46
|
+
person: the Hub makes the group the actor of each. A dates change in a
|
|
47
|
+
proposal must give both `startDate` and `endDate` (`null` = no end): a
|
|
48
|
+
date left out would be read now and be stale when the group carries it
|
|
49
|
+
out. Everything else is refused by type (claims and disputes need the
|
|
50
|
+
person's own identity, entity create a relayer, identity document links
|
|
51
|
+
the document's own keys, and payments, grants and entity updates are
|
|
52
|
+
written whole from what the Hub reads now).
|
|
53
|
+
- Field rules (`chainTxIssue` names the first bad field, nested ones by path,
|
|
54
|
+
e.g. `invalid_message: messages[0].actions[2].toAddress`):
|
|
55
|
+
- `dao`, `proposalModule`: a 32-byte contract address, `ixo1` + 58 bech32
|
|
56
|
+
characters (the Hub checks the checksum);
|
|
57
|
+
- `proposalId`: decimal text without leading zeros, 1..9007199254740991
|
|
58
|
+
(the Hub writes it as a JSON number, so nothing beyond the safe integer
|
|
59
|
+
range);
|
|
60
|
+
- `title` 1..100, `description` 1..300, `rationale` 1..300: plain text
|
|
61
|
+
and SHOWN_AS_IS (the 0.8.0 rule: exactly what the review page shows, no
|
|
62
|
+
links, no hidden characters, single spaces, one line).
|
|
63
|
+
- One card, one group step: an operation holding a group step holds no
|
|
64
|
+
other message. Otherwise `invalid_operation: messages` (the shape refusal
|
|
65
|
+
used for 0 or 9 messages). Each group step depends on a chain of reads and
|
|
66
|
+
a new proposal's id must be unambiguous on the receipt.
|
|
67
|
+
- Review display (`parseChainTxDisplay`): `daodao.proposal.create` and
|
|
68
|
+
`daodao.proposal.execute` steps carry `actions` (required, `[]` for none;
|
|
69
|
+
refused on every other step): the group's actions in plain words, each
|
|
70
|
+
`{type, title (≤ 60), whatItDoes (≤ 160), facts (≤ 12, the step fact
|
|
71
|
+
shape), riskLevel, cannotUndo}`. On create: the operation's own actions, in
|
|
72
|
+
order and of the same types (`parseReviewView` checks). On carry-out: the
|
|
73
|
+
passed proposal's stored actions, at most 10
|
|
74
|
+
(`CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS`), each of a level-6 type or `type:
|
|
75
|
+
null` for one the page cannot explain. A step's `riskLevel` is at least
|
|
76
|
+
each of its actions'. A `daodao.proposal.create` step may carry
|
|
77
|
+
`proposalPrefix` (1-4 capital letters; refused on every other step): the
|
|
78
|
+
proposal list's prefix, so a result names the new proposal as the cards
|
|
79
|
+
do ("proposal A4" from the receipt's `proposalId` "4").
|
|
80
|
+
- Receipts (`parseChainTxReceipt`): on a succeeded receipt (included, code
|
|
81
|
+
0) a `daodao.proposal.create` step is `{type, proposalId}` (the new
|
|
82
|
+
proposal's id, or `null` when the Hub could not read it from the
|
|
83
|
+
transaction; never guessed) and a `daodao.proposal.execute` step is `{type,
|
|
84
|
+
groupActions}` (`"done"`, `"failed"`, or `"unknown"` when the Hub found no
|
|
85
|
+
proof either way in the transaction's events; the transaction succeeds
|
|
86
|
+
even when the group's actions fail, so code 0 alone does not say they
|
|
87
|
+
happened, and nothing reads `"unknown"` as done).
|
|
88
|
+
Every other step, and every step of a receipt that did not succeed, stays
|
|
89
|
+
`{type}`; `receiptFitsStatus` refuses either key outside `succeeded`.
|
|
90
|
+
- Capabilities accept the 37 types; the shape and `maxMessages` are
|
|
91
|
+
unchanged. The action types a proposal may hold are this package's
|
|
92
|
+
constant, not a capability.
|
|
93
|
+
- Refusal codes (`CHAIN_TX_REFUSAL_CODES`, appended; `parseChainTxRefusal`
|
|
94
|
+
also reads nested fields such as `actions[1].validatorAddress`). Reused:
|
|
95
|
+
`proposal_not_found`, `proposal_not_open` (voting has ended),
|
|
96
|
+
`chain_data_too_large` (the stored proposal is too large to show). New:
|
|
97
|
+
`group_not_supported` (`dao` / `proposalModule`: a group set up in a way a
|
|
98
|
+
card does not support yet: other contract versions, multiple choice, an
|
|
99
|
+
approval step), `not_in_group` (that proposal list is not an active part
|
|
100
|
+
of the group), `group_paused` (carrying out a proposal with actions while
|
|
101
|
+
the group is paused), `no_voting_power` (the person had no vote
|
|
102
|
+
when the proposal started), `already_voted` (and the group does not allow
|
|
103
|
+
changing votes), `same_vote` (field `vote`), `not_a_member` (`proposalId`
|
|
104
|
+
on carry-out, `dao` on create), `proposal_not_passed`,
|
|
105
|
+
`proposal_not_rejected` (only proposals that did not pass can be closed),
|
|
106
|
+
`group_actions_would_fail` (carried out now, the group's actions would fail
|
|
107
|
+
and the proposal would be marked failed for good), `deposit_not_supported`
|
|
108
|
+
(the deposit is in a token a card cannot pay), `proposal_too_large` (field
|
|
109
|
+
`description`), `not_for_groups` (`actions[<j>].type`), `not_group_owned`
|
|
110
|
+
(`actions[<j>].entityId`: the group does not own that entity),
|
|
111
|
+
`group_not_found` (`dao` / `proposalModule`: no contract at that address,
|
|
112
|
+
or another kind of group contract, e.g. the two addresses swapped),
|
|
113
|
+
`list_disabled` (`proposalModule`: the group switched that proposal list
|
|
114
|
+
off, so nothing in it can be carried out), `closes_too_soon`
|
|
115
|
+
(`proposalId`: voting closes before the card could be signed),
|
|
116
|
+
`group_inactive` (`dao`: the group is not taking new proposals right
|
|
117
|
+
now), `deposit_changed` (`dao`: the group's deposit changed while the
|
|
118
|
+
card was being made; ask again). A nested
|
|
119
|
+
action's own refusals keep their codes under its path, e.g.
|
|
120
|
+
`messages[0].actions[1].validatorAddress: validator_not_found`.
|
|
121
|
+
`chainTxIssue` itself still never adds a code: a type a group cannot use is
|
|
122
|
+
the shape refusal `messages[0].actions[<j>].type`.
|
|
123
|
+
- Bounds this package chose where the design left them open: `dao` and
|
|
124
|
+
`proposalModule` must differ (field `proposalModule`); `rationale` may be
|
|
125
|
+
left out but not `null`.
|
|
126
|
+
- New exports: `CHAIN_TX_LEVEL6_MESSAGE_TYPES`, `CHAIN_TX_GROUP_MESSAGE_TYPES`,
|
|
127
|
+
`CHAIN_TX_LEVEL7`, `CHAIN_TX_GROUP_ACTION_TYPES`,
|
|
128
|
+
`CHAIN_TX_MAX_GROUP_ACTIONS`, `CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS`,
|
|
129
|
+
`CHAIN_TX_GROUP_VOTE_OPTIONS`, `CHAIN_TX_GROUP_ACTION_RESULTS`; types
|
|
130
|
+
`ChainTxGroupMessageType`, `ChainTxGroupMessage`, `ChainTxLevel6Message`
|
|
131
|
+
(the 0.8.0 `ChainTxMessage`, which now also holds the group members),
|
|
132
|
+
`ChainTxGroupActionType`, `ChainTxGroupAction`, `ChainTxGroupVoteOption`,
|
|
133
|
+
`ChainTxGroupActionResult`, `ChainTxGroupActionDisplay`,
|
|
134
|
+
`ChainTxReceiptStep`.
|
|
135
|
+
- The operation JSON schema has one branch per group type, a nested action
|
|
136
|
+
schema built from the 14 allowed branches (dates with both keys
|
|
137
|
+
required), and `messages` is either one group step or 1..8 other
|
|
138
|
+
messages. The `ixo.chain.tx.v1` branch grows from 29 711 to 41 872
|
|
139
|
+
characters of JSON (the whole operation schema from 38 829 to 50 990).
|
|
140
|
+
The numeric proposal id maximum, SHOWN_AS_IS and `dao` ≠ `proposalModule`
|
|
141
|
+
are the field parser's.
|
|
142
|
+
- Rollout order (as 0.8.0): Hub and website on 0.9.0 (nothing changes for
|
|
143
|
+
callers at levels 1-6; a Hub before 0.9.0 answers `?version=7` with
|
|
144
|
+
`400 invalid_request`; an oracle reading a group card at level 4-6 gets
|
|
145
|
+
`receipt: null` and `outcome: null`), then gateways on 0.9.0 (a 0.8.0
|
|
146
|
+
gateway cannot parse a receipt with a group step and drops the outcome),
|
|
147
|
+
then runtimes on `?version=7`.
|
|
148
|
+
|
|
3
149
|
## 0.8.0
|
|
4
150
|
|
|
5
151
|
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
|
|
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.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
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,7 +470,7 @@ 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
|
|
473
|
+
export type ChainTxLevel6Message =
|
|
439
474
|
| {
|
|
440
475
|
type: "cosmos.bank.send";
|
|
441
476
|
toAddress: string;
|
|
@@ -784,6 +819,77 @@ export type ChainTxMessage =
|
|
|
784
819
|
};
|
|
785
820
|
}
|
|
786
821
|
| { type: "ixo.iid.delete-context"; did: string; key: ChainTxIidRemoveId };
|
|
822
|
+
/**
|
|
823
|
+
* 0.9.0 D11: one action a group's own account does if a proposal passes:
|
|
824
|
+
* exactly a top-level message of a `ChainTxGroupActionType` (same keys and
|
|
825
|
+
* rules; none names the person, and the Hub sets every signer field to the
|
|
826
|
+
* group). A collection dates change names both dates (`endDate` may be
|
|
827
|
+
* null), because a date left out would be read when the card is made and be
|
|
828
|
+
* stale when the group carries it out.
|
|
829
|
+
*/
|
|
830
|
+
export type ChainTxGroupAction =
|
|
831
|
+
| Exclude<
|
|
832
|
+
Extract<ChainTxLevel6Message, { type: ChainTxGroupActionType }>,
|
|
833
|
+
{ type: "ixo.claims.update-collection-dates" }
|
|
834
|
+
>
|
|
835
|
+
| {
|
|
836
|
+
type: "ixo.claims.update-collection-dates";
|
|
837
|
+
collectionId: string;
|
|
838
|
+
adminAddress: string;
|
|
839
|
+
/** INSTANT */
|
|
840
|
+
startDate: string;
|
|
841
|
+
/** INSTANT after `startDate`, or null = no end date. */
|
|
842
|
+
endDate: string | null;
|
|
843
|
+
};
|
|
844
|
+
/*
|
|
845
|
+
* 0.9.0 (wire level 7) group rules, DAO DAO v2.0.3 single-choice proposals:
|
|
846
|
+
* - CONTRACT_ADDRESS (`dao`, `proposalModule`): a 32-byte contract address,
|
|
847
|
+
* `ixo1` + 58 bech32 characters (the Hub checks the checksum); `dao` is the
|
|
848
|
+
* group's core contract, `proposalModule` one of its proposal lists (a
|
|
849
|
+
* different contract). The Hub derives the proposal intake from it (D17).
|
|
850
|
+
* - PROPOSAL_ID: decimal text without leading zeros, 1..9007199254740991
|
|
851
|
+
* (the Hub writes it as a JSON number, D16).
|
|
852
|
+
* - Text (`title` ≤ 100, `description` ≤ 300, `rationale` ≤ 300):
|
|
853
|
+
* PLAIN_TEXT and SHOWN_AS_IS (published on chain, shown whole).
|
|
854
|
+
* - A card with a group step holds exactly that one message (D5), else
|
|
855
|
+
* `invalid_operation: messages`.
|
|
856
|
+
*/
|
|
857
|
+
export type ChainTxGroupMessage =
|
|
858
|
+
| {
|
|
859
|
+
/** Casts the person's vote on a group proposal. */
|
|
860
|
+
type: "daodao.proposal.vote";
|
|
861
|
+
dao: string;
|
|
862
|
+
proposalModule: string;
|
|
863
|
+
proposalId: string;
|
|
864
|
+
vote: ChainTxGroupVoteOption;
|
|
865
|
+
/** Published with the vote. */
|
|
866
|
+
rationale?: string;
|
|
867
|
+
}
|
|
868
|
+
| {
|
|
869
|
+
/** Carries out a passed proposal: the group's own account does its actions. */
|
|
870
|
+
type: "daodao.proposal.execute";
|
|
871
|
+
dao: string;
|
|
872
|
+
proposalModule: string;
|
|
873
|
+
proposalId: string;
|
|
874
|
+
}
|
|
875
|
+
| {
|
|
876
|
+
/** Closes a proposal that did not pass. */
|
|
877
|
+
type: "daodao.proposal.close";
|
|
878
|
+
dao: string;
|
|
879
|
+
proposalModule: string;
|
|
880
|
+
proposalId: string;
|
|
881
|
+
}
|
|
882
|
+
| {
|
|
883
|
+
/** Asks the group to vote on a new proposal (the Hub adds any deposit). */
|
|
884
|
+
type: "daodao.proposal.create";
|
|
885
|
+
dao: string;
|
|
886
|
+
proposalModule: string;
|
|
887
|
+
title: string;
|
|
888
|
+
description: string;
|
|
889
|
+
/** 0..4 (`CHAIN_TX_MAX_GROUP_ACTIONS`); [] = a text-only proposal. */
|
|
890
|
+
actions: ChainTxGroupAction[];
|
|
891
|
+
};
|
|
892
|
+
export type ChainTxMessage = ChainTxLevel6Message | ChainTxGroupMessage;
|
|
787
893
|
export type ChainTxOperation = {
|
|
788
894
|
kind: "ixo.chain.tx.v1";
|
|
789
895
|
/** Must equal the Hub RPC's chain id at prepare. */
|
|
@@ -816,6 +922,36 @@ export type ChainTxStep = {
|
|
|
816
922
|
cannotUndo: boolean;
|
|
817
923
|
/** cosmos.bank.send steps: the bank-send display (verified/unverified token rules). */
|
|
818
924
|
transfer?: TransferDisplay;
|
|
925
|
+
/**
|
|
926
|
+
* 0.9.0 D13: required on `daodao.proposal.create` (its 0..4 actions, in
|
|
927
|
+
* order) and `daodao.proposal.execute` (the passed proposal's actions, at
|
|
928
|
+
* most 10 shown); `[]` for none. Absent on every other step. The step's
|
|
929
|
+
* `riskLevel` is at least each action's.
|
|
930
|
+
*/
|
|
931
|
+
actions?: ChainTxGroupActionDisplay[];
|
|
932
|
+
/**
|
|
933
|
+
* 0.9.0, `daodao.proposal.create` only: the proposal list's prefix (1-4
|
|
934
|
+
* capital letters), so the result names the new proposal as the cards do
|
|
935
|
+
* ("proposal A4" from the receipt's `proposalId` "4"). Absent when the
|
|
936
|
+
* list has none (the plain number is the label).
|
|
937
|
+
*/
|
|
938
|
+
proposalPrefix?: string;
|
|
939
|
+
};
|
|
940
|
+
/** 0.9.0: one action the group's own account would do, in plain words. */
|
|
941
|
+
export type ChainTxGroupActionDisplay = {
|
|
942
|
+
/**
|
|
943
|
+
* create: the wire action's type (a `ChainTxGroupActionType`); execute:
|
|
944
|
+
* a level-6 type, or null for an action the page cannot explain.
|
|
945
|
+
*/
|
|
946
|
+
type: ChainTxLevel4MessageType | ChainTxLevel6MessageType | null;
|
|
947
|
+
/** ≤ 60, plain words. */
|
|
948
|
+
title: string;
|
|
949
|
+
/** One sentence, ≤ 160. */
|
|
950
|
+
whatItDoes: string;
|
|
951
|
+
/** ≤ 12. */
|
|
952
|
+
facts: ChainTxFact[];
|
|
953
|
+
riskLevel: ChainTxRiskLevel;
|
|
954
|
+
cannotUndo: boolean;
|
|
819
955
|
};
|
|
820
956
|
export type ChainTxDisplay = {
|
|
821
957
|
/** The highest step risk. */
|
|
@@ -857,8 +993,24 @@ export type ChainTxReceipt = {
|
|
|
857
993
|
/** ≤ 240, plain words for the person; only with a `reason`. */
|
|
858
994
|
message?: string;
|
|
859
995
|
/** The approved messages' types, in order. */
|
|
860
|
-
steps:
|
|
996
|
+
steps: ChainTxReceiptStep[];
|
|
861
997
|
};
|
|
998
|
+
/**
|
|
999
|
+
* 0.9.0: on a succeeded receipt (included, code 0) a `daodao.proposal.create`
|
|
1000
|
+
* step has `proposalId` (PROPOSAL_ID, or null when the Hub could not read
|
|
1001
|
+
* it; never guessed) and a `daodao.proposal.execute` step has `groupActions`
|
|
1002
|
+
* (whether the group's actions ran: tx code 0 alone does not say so). Both
|
|
1003
|
+
* are absent on every other receipt.
|
|
1004
|
+
*/
|
|
1005
|
+
export type ChainTxReceiptStep =
|
|
1006
|
+
| {
|
|
1007
|
+
type: Exclude<
|
|
1008
|
+
ChainTxMessageType,
|
|
1009
|
+
"daodao.proposal.create" | "daodao.proposal.execute"
|
|
1010
|
+
>;
|
|
1011
|
+
}
|
|
1012
|
+
| { type: "daodao.proposal.create"; proposalId?: string | null }
|
|
1013
|
+
| { type: "daodao.proposal.execute"; groupActions?: ChainTxGroupActionResult };
|
|
862
1014
|
export type ChainTxCapabilities = {
|
|
863
1015
|
messageTypes: ChainTxMessageType[];
|
|
864
1016
|
maxMessages: number;
|
|
@@ -871,9 +1023,53 @@ export declare const CHAIN_TX_LEVEL4_MESSAGE_TYPES: readonly [
|
|
|
871
1023
|
"ixo.claims.evaluate",
|
|
872
1024
|
"ixo.token.transfer",
|
|
873
1025
|
];
|
|
1026
|
+
/** 0.9.0: the 33 types of wire level 6 (the four, then the 29 of 0.8.0), frozen. */
|
|
1027
|
+
export declare const CHAIN_TX_LEVEL6_MESSAGE_TYPES: readonly [
|
|
1028
|
+
"cosmos.bank.send",
|
|
1029
|
+
"ixo.claims.submit",
|
|
1030
|
+
"ixo.claims.evaluate",
|
|
1031
|
+
"ixo.token.transfer",
|
|
1032
|
+
"ixo.token.retire",
|
|
1033
|
+
"cosmos.staking.delegate",
|
|
1034
|
+
"cosmos.staking.undelegate",
|
|
1035
|
+
"cosmos.staking.redelegate",
|
|
1036
|
+
"cosmos.distribution.withdraw-rewards",
|
|
1037
|
+
"cosmos.gov.vote",
|
|
1038
|
+
"ixo.claims.claim-intent",
|
|
1039
|
+
"ixo.claims.dispute",
|
|
1040
|
+
"ixo.claims.update-collection-state",
|
|
1041
|
+
"ixo.claims.update-collection-dates",
|
|
1042
|
+
"ixo.claims.update-collection-quota",
|
|
1043
|
+
"ixo.claims.create-claim-authorization",
|
|
1044
|
+
"ixo.claims.update-collection-payments",
|
|
1045
|
+
"ixo.claims.create-collection",
|
|
1046
|
+
"ixo.entity.create-account",
|
|
1047
|
+
"ixo.entity.update",
|
|
1048
|
+
"ixo.entity.revoke-account-authz",
|
|
1049
|
+
"ixo.entity.grant-account-authz",
|
|
1050
|
+
"ixo.entity.create",
|
|
1051
|
+
"ixo.iid.add-service",
|
|
1052
|
+
"ixo.iid.delete-service",
|
|
1053
|
+
"ixo.iid.add-linked-resource",
|
|
1054
|
+
"ixo.iid.delete-linked-resource",
|
|
1055
|
+
"ixo.iid.add-linked-claim",
|
|
1056
|
+
"ixo.iid.delete-linked-claim",
|
|
1057
|
+
"ixo.iid.add-linked-entity",
|
|
1058
|
+
"ixo.iid.delete-linked-entity",
|
|
1059
|
+
"ixo.iid.add-context",
|
|
1060
|
+
"ixo.iid.delete-context",
|
|
1061
|
+
];
|
|
1062
|
+
/** 0.9.0: the four group types of wire level 7, frozen. */
|
|
1063
|
+
export declare const CHAIN_TX_GROUP_MESSAGE_TYPES: readonly [
|
|
1064
|
+
"daodao.proposal.vote",
|
|
1065
|
+
"daodao.proposal.execute",
|
|
1066
|
+
"daodao.proposal.close",
|
|
1067
|
+
"daodao.proposal.create",
|
|
1068
|
+
];
|
|
874
1069
|
/**
|
|
875
|
-
* Every type this package parses (the
|
|
876
|
-
* What a caller may see or create:
|
|
1070
|
+
* Every type this package parses (the 33 of level 6, then the four group
|
|
1071
|
+
* types of 0.9.0), frozen. What a caller may see or create:
|
|
1072
|
+
* `chainTxMessageTypesForLevel(level)`.
|
|
877
1073
|
*/
|
|
878
1074
|
export declare const CHAIN_TX_MESSAGE_TYPES: readonly [
|
|
879
1075
|
"cosmos.bank.send",
|
|
@@ -909,18 +1105,32 @@ export declare const CHAIN_TX_MESSAGE_TYPES: readonly [
|
|
|
909
1105
|
"ixo.iid.delete-linked-entity",
|
|
910
1106
|
"ixo.iid.add-context",
|
|
911
1107
|
"ixo.iid.delete-context",
|
|
1108
|
+
"daodao.proposal.vote",
|
|
1109
|
+
"daodao.proposal.execute",
|
|
1110
|
+
"daodao.proposal.close",
|
|
1111
|
+
"daodao.proposal.create",
|
|
912
1112
|
];
|
|
913
1113
|
/** The wire level that adds the 29 types of 0.8.0. */
|
|
914
1114
|
export declare const CHAIN_TX_LEVEL6: 6;
|
|
1115
|
+
/** The wire level that adds the four group types of 0.9.0. */
|
|
1116
|
+
export declare const CHAIN_TX_LEVEL7: 7;
|
|
915
1117
|
/**
|
|
916
1118
|
* The chain tx message types a caller at wire `level` (a positive integer)
|
|
917
1119
|
* may see and create: none below 4, `CHAIN_TX_LEVEL4_MESSAGE_TYPES` at 4
|
|
918
|
-
* and 5, `
|
|
919
|
-
* non-integer or a level below 1.
|
|
1120
|
+
* and 5, `CHAIN_TX_LEVEL6_MESSAGE_TYPES` at 6, `CHAIN_TX_MESSAGE_TYPES`
|
|
1121
|
+
* from 7. Throws `TypeError` on a non-integer or a level below 1.
|
|
920
1122
|
*/
|
|
921
1123
|
export declare function chainTxMessageTypesForLevel(
|
|
922
1124
|
level: number,
|
|
923
1125
|
): readonly ChainTxMessageType[];
|
|
1126
|
+
/** 0.9.0 D11: the action types a group proposal may hold, frozen. */
|
|
1127
|
+
export declare const CHAIN_TX_GROUP_ACTION_TYPES: readonly ChainTxGroupActionType[];
|
|
1128
|
+
/** 0.9.0 D12: actions per new proposal. */
|
|
1129
|
+
export declare const CHAIN_TX_MAX_GROUP_ACTIONS: 4;
|
|
1130
|
+
/** 0.9.0: actions shown on a carry-out step. */
|
|
1131
|
+
export declare const CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS: 10;
|
|
1132
|
+
export declare const CHAIN_TX_GROUP_VOTE_OPTIONS: readonly ChainTxGroupVoteOption[];
|
|
1133
|
+
export declare const CHAIN_TX_GROUP_ACTION_RESULTS: readonly ChainTxGroupActionResult[];
|
|
924
1134
|
export declare const CHAIN_TX_VOTE_OPTIONS: readonly ChainTxVoteOption[];
|
|
925
1135
|
export declare const CHAIN_TX_DISPUTE_REASONS: readonly ChainTxDisputeReason[];
|
|
926
1136
|
export declare const CHAIN_TX_COLLECTION_STATES: readonly ChainTxCollectionState[];
|
|
@@ -977,12 +1187,52 @@ export type ChainTxRefusalCode =
|
|
|
977
1187
|
| "already_exists"
|
|
978
1188
|
| "invalid_did"
|
|
979
1189
|
| "not_available"
|
|
980
|
-
| "chain_data_too_large"
|
|
1190
|
+
| "chain_data_too_large"
|
|
1191
|
+
// 0.9.0 groups (nested proposal actions use their own codes under
|
|
1192
|
+
// `actions[<j>]`, e.g. `actions[1].validatorAddress: validator_not_found`).
|
|
1193
|
+
/** `dao`/`proposalModule`: another contract version, multiple choice, an approval step. */
|
|
1194
|
+
| "group_not_supported"
|
|
1195
|
+
/** `proposalModule`: not an enabled proposal list of this group. */
|
|
1196
|
+
| "not_in_group"
|
|
1197
|
+
/** `dao`: the group is paused (carrying out a proposal with actions). */
|
|
1198
|
+
| "group_paused"
|
|
1199
|
+
/** `proposalId`: the person had no vote when the proposal started. */
|
|
1200
|
+
| "no_voting_power"
|
|
1201
|
+
/** `proposalId`: already voted, and the group doesn't allow changing votes. */
|
|
1202
|
+
| "already_voted"
|
|
1203
|
+
/** `vote`: already voted this way. */
|
|
1204
|
+
| "same_vote"
|
|
1205
|
+
/** `proposalId` (carry out) / `dao` (create): members only. */
|
|
1206
|
+
| "not_a_member"
|
|
1207
|
+
/** `proposalId`: it hasn't passed (yet, or at all). */
|
|
1208
|
+
| "proposal_not_passed"
|
|
1209
|
+
/** `proposalId`: only proposals that did not pass can be closed. */
|
|
1210
|
+
| "proposal_not_rejected"
|
|
1211
|
+
/** `proposalId`: run now, the group's actions would fail and the proposal be marked failed for good. */
|
|
1212
|
+
| "group_actions_would_fail"
|
|
1213
|
+
/** `dao`: the deposit is in a token a card can't pay. */
|
|
1214
|
+
| "deposit_not_supported"
|
|
1215
|
+
/** `description`: over the group's proposal size limit. */
|
|
1216
|
+
| "proposal_too_large"
|
|
1217
|
+
/** `actions[<j>].type`: the group can't do this kind of action through a card. */
|
|
1218
|
+
| "not_for_groups"
|
|
1219
|
+
/** `actions[<j>].entityId`: the group doesn't own this entity. */
|
|
1220
|
+
| "not_group_owned"
|
|
1221
|
+
/** `dao`/`proposalModule`: no contract there, or another kind of group contract (e.g. the two swapped). */
|
|
1222
|
+
| "group_not_found"
|
|
1223
|
+
/** `proposalModule`: the group has switched this proposal list off (nothing in it can be carried out). */
|
|
1224
|
+
| "list_disabled"
|
|
1225
|
+
/** `proposalId`: voting closes before the card could be signed. */
|
|
1226
|
+
| "closes_too_soon"
|
|
1227
|
+
/** `dao`: the group is not taking new proposals right now. */
|
|
1228
|
+
| "group_inactive"
|
|
1229
|
+
/** `dao`: the group's deposit changed while the card was being made. */
|
|
1230
|
+
| "deposit_changed";
|
|
981
1231
|
export declare const CHAIN_TX_REFUSAL_CODES: readonly ChainTxRefusalCode[];
|
|
982
1232
|
export type ChainTxRefusal = {
|
|
983
1233
|
/** The message index (0..7). */
|
|
984
1234
|
index: number;
|
|
985
|
-
/** The field or path, e.g. `validatorAddress`, `payments.approval`. */
|
|
1235
|
+
/** The field or path, e.g. `validatorAddress`, `payments.approval`, `actions[1].toAddress`. */
|
|
986
1236
|
field: string;
|
|
987
1237
|
/** Null when the reason has no code, or one this package does not know. */
|
|
988
1238
|
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) =>
|
|
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
|
-
*
|
|
1727
|
-
* types of 0.8.0
|
|
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
|
|
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,
|
|
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
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
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}))?$/;
|
|
@@ -2076,6 +2170,26 @@ const CHAIN_TX_MESSAGE_KEYS = {
|
|
|
2076
2170
|
"ixo.iid.delete-linked-entity": ["type", "did", "entityId"],
|
|
2077
2171
|
"ixo.iid.add-context": ["type", "did", "context"],
|
|
2078
2172
|
"ixo.iid.delete-context": ["type", "did", "key"],
|
|
2173
|
+
// 0.9.0 (wire level 7). The person is the sender; the Hub derives the
|
|
2174
|
+
// proposal intake from `proposalModule` (D17).
|
|
2175
|
+
"daodao.proposal.vote": [
|
|
2176
|
+
"type",
|
|
2177
|
+
"dao",
|
|
2178
|
+
"proposalModule",
|
|
2179
|
+
"proposalId",
|
|
2180
|
+
"vote",
|
|
2181
|
+
"rationale",
|
|
2182
|
+
],
|
|
2183
|
+
"daodao.proposal.execute": ["type", "dao", "proposalModule", "proposalId"],
|
|
2184
|
+
"daodao.proposal.close": ["type", "dao", "proposalModule", "proposalId"],
|
|
2185
|
+
"daodao.proposal.create": [
|
|
2186
|
+
"type",
|
|
2187
|
+
"dao",
|
|
2188
|
+
"proposalModule",
|
|
2189
|
+
"title",
|
|
2190
|
+
"description",
|
|
2191
|
+
"actions",
|
|
2192
|
+
],
|
|
2079
2193
|
};
|
|
2080
2194
|
// 0.8.0 wire patterns (the JSON schema in operation-schema.js mirrors them).
|
|
2081
2195
|
// A validator operator address: `ixovaloper1` + 38 bech32 characters (20
|
|
@@ -2132,6 +2246,12 @@ const SERVICE_REF =
|
|
|
2132
2246
|
const LINKED_ENTITY_ADDRESS =
|
|
2133
2247
|
/^(?:\{id\}#)?ixo1(?:[023456789acdefghjklmnpqrstuvwxyz]{38}|[023456789acdefghjklmnpqrstuvwxyz]{58})$/;
|
|
2134
2248
|
const CLAIM_PERMISSIONS = ["file-claims", "check-claims"];
|
|
2249
|
+
// 0.9.0: a 32-byte contract address (`ixo1` + 58 bech32 characters); the
|
|
2250
|
+
// Hub also checks the checksum.
|
|
2251
|
+
const CONTRACT_ADDRESS = /^ixo1[023456789acdefghjklmnpqrstuvwxyz]{58}$/;
|
|
2252
|
+
// D16: a group proposal id, decimal without leading zeros, 1..2^53-1 (the
|
|
2253
|
+
// Hub writes it as a JSON number; checked numerically below).
|
|
2254
|
+
const GROUP_PROPOSAL_ID = /^[1-9][0-9]{0,15}$/;
|
|
2135
2255
|
const plain = (value) =>
|
|
2136
2256
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2137
2257
|
const isText = (value, min = 1, max = 200) =>
|
|
@@ -2158,6 +2278,10 @@ const isPlainText = (value, max) =>
|
|
|
2158
2278
|
*/
|
|
2159
2279
|
const isShownAsIs = (value) =>
|
|
2160
2280
|
typeof value === "string" && sanitizePublishedText(value) === value;
|
|
2281
|
+
/** PROPOSAL_ID: a group proposal id (D16). */
|
|
2282
|
+
const isGroupProposalId = (value) =>
|
|
2283
|
+
isMatch(value, GROUP_PROPOSAL_ID, 16) &&
|
|
2284
|
+
BigInt(value) <= BigInt(Number.MAX_SAFE_INTEGER);
|
|
2161
2285
|
/**
|
|
2162
2286
|
* INSTANT: a real calendar instant whose UTC time a protobuf Timestamp can
|
|
2163
2287
|
* hold the way the Hub encodes it (1970-01-01T00:00:00Z .. year 9999).
|
|
@@ -2504,6 +2628,70 @@ const CHAIN_TX_LEVEL6_FIELDS = {
|
|
|
2504
2628
|
"ixo.iid.delete-context": (m) =>
|
|
2505
2629
|
iidDidField(m) ?? (removeIdRule(m.key) ? null : "key"),
|
|
2506
2630
|
};
|
|
2631
|
+
/** 0.9.0: the first bad field of each group type (relative), or null. */
|
|
2632
|
+
const CHAIN_TX_GROUP_FIELDS = {
|
|
2633
|
+
"daodao.proposal.vote": (m) => {
|
|
2634
|
+
const target = groupProposalField(m);
|
|
2635
|
+
if (target) return target;
|
|
2636
|
+
if (!CHAIN_TX_GROUP_VOTE_OPTIONS.includes(m.vote)) return "vote";
|
|
2637
|
+
if (m.rationale !== undefined && !isGroupText(m.rationale, 300))
|
|
2638
|
+
return "rationale";
|
|
2639
|
+
return null;
|
|
2640
|
+
},
|
|
2641
|
+
"daodao.proposal.execute": (m) => groupProposalField(m),
|
|
2642
|
+
"daodao.proposal.close": (m) => groupProposalField(m),
|
|
2643
|
+
"daodao.proposal.create": (m) => {
|
|
2644
|
+
const target = groupTargetField(m);
|
|
2645
|
+
if (target) return target;
|
|
2646
|
+
if (!isGroupText(m.title, 100)) return "title";
|
|
2647
|
+
if (!isGroupText(m.description, 300)) return "description";
|
|
2648
|
+
return groupActionsField(m.actions);
|
|
2649
|
+
},
|
|
2650
|
+
};
|
|
2651
|
+
/** D14/D15: proposal text and vote reasons are PLAIN_TEXT and SHOWN_AS_IS. */
|
|
2652
|
+
const isGroupText = (value, max) => isPlainText(value, max) && isShownAsIs(value);
|
|
2653
|
+
/** `dao` (the group's core) and `proposalModule` (D17), two different contracts. */
|
|
2654
|
+
function groupTargetField(m) {
|
|
2655
|
+
if (!isMatch(m.dao, CONTRACT_ADDRESS, 62)) return "dao";
|
|
2656
|
+
if (!isMatch(m.proposalModule, CONTRACT_ADDRESS, 62) || m.proposalModule === m.dao)
|
|
2657
|
+
return "proposalModule";
|
|
2658
|
+
return null;
|
|
2659
|
+
}
|
|
2660
|
+
function groupProposalField(m) {
|
|
2661
|
+
return groupTargetField(m) ?? (isGroupProposalId(m.proposalId) ? null : "proposalId");
|
|
2662
|
+
}
|
|
2663
|
+
/**
|
|
2664
|
+
* D11/D12: 0..4 actions the group's own account does if the proposal
|
|
2665
|
+
* passes, each exactly a top-level message of a `CHAIN_TX_GROUP_ACTION_TYPES`
|
|
2666
|
+
* type (same keys, same field rules; none of them has a field naming the
|
|
2667
|
+
* person, the Hub sets every signer field to `dao`). Paths are
|
|
2668
|
+
* `actions[<j>].<field>`.
|
|
2669
|
+
*/
|
|
2670
|
+
function groupActionsField(actions) {
|
|
2671
|
+
if (!Array.isArray(actions) || actions.length > CHAIN_TX_MAX_GROUP_ACTIONS)
|
|
2672
|
+
return "actions";
|
|
2673
|
+
for (const [j, action] of actions.entries()) {
|
|
2674
|
+
const at = `actions[${j}]`;
|
|
2675
|
+
if (!plain(action)) return at;
|
|
2676
|
+
if (!CHAIN_TX_GROUP_ACTION_TYPES.includes(action.type)) return `${at}.type`;
|
|
2677
|
+
const unknown = unknownKey(action, CHAIN_TX_MESSAGE_KEYS[action.type], at);
|
|
2678
|
+
if (unknown) return unknown;
|
|
2679
|
+
const field = chainTxMessageField(action) ?? groupActionRuleField(action);
|
|
2680
|
+
if (field) return `${at}.${field}`;
|
|
2681
|
+
}
|
|
2682
|
+
return null;
|
|
2683
|
+
}
|
|
2684
|
+
/**
|
|
2685
|
+
* The rule a group action adds to its type's: a collection dates change
|
|
2686
|
+
* names both dates (`endDate` may be null), because a date left out would be
|
|
2687
|
+
* filled from a read that is stale when the group carries it out (D11).
|
|
2688
|
+
*/
|
|
2689
|
+
function groupActionRuleField(action) {
|
|
2690
|
+
if (action.type !== "ixo.claims.update-collection-dates") return null;
|
|
2691
|
+
if (action.startDate === undefined) return "startDate";
|
|
2692
|
+
if (action.endDate === undefined) return "endDate";
|
|
2693
|
+
return null;
|
|
2694
|
+
}
|
|
2507
2695
|
function stakeField(m) {
|
|
2508
2696
|
if (!isMatch(m.validatorAddress, VALOPER_ADDRESS, 49)) return "validatorAddress";
|
|
2509
2697
|
if (!isMatch(m.amountBaseUnits, BASE_UNITS, 78)) return "amountBaseUnits";
|
|
@@ -2540,6 +2728,8 @@ function iidDidField(m) {
|
|
|
2540
2728
|
function chainTxMessageField(m) {
|
|
2541
2729
|
if (Object.hasOwn(CHAIN_TX_LEVEL6_FIELDS, m.type))
|
|
2542
2730
|
return CHAIN_TX_LEVEL6_FIELDS[m.type](m);
|
|
2731
|
+
if (Object.hasOwn(CHAIN_TX_GROUP_FIELDS, m.type))
|
|
2732
|
+
return CHAIN_TX_GROUP_FIELDS[m.type](m);
|
|
2543
2733
|
if (m.type === "cosmos.bank.send") {
|
|
2544
2734
|
if (!isMatch(m.toAddress, ACCOUNT_ADDRESS)) return "toAddress";
|
|
2545
2735
|
if (!isMatch(m.amountBaseUnits, BASE_UNITS, 78)) return "amountBaseUnits";
|
|
@@ -2600,6 +2790,14 @@ function chainTxField(op) {
|
|
|
2600
2790
|
op.messages.length > CHAIN_TX_MAX_MESSAGES
|
|
2601
2791
|
)
|
|
2602
2792
|
return "messages";
|
|
2793
|
+
// 0.9.0 D5: a card with a group step holds exactly that one message.
|
|
2794
|
+
if (
|
|
2795
|
+
op.messages.length > 1 &&
|
|
2796
|
+
op.messages.some(
|
|
2797
|
+
(m) => plain(m) && CHAIN_TX_GROUP_MESSAGE_TYPES.includes(m.type),
|
|
2798
|
+
)
|
|
2799
|
+
)
|
|
2800
|
+
return "messages";
|
|
2603
2801
|
for (const [i, m] of op.messages.entries()) {
|
|
2604
2802
|
const at = `messages[${i}]`;
|
|
2605
2803
|
if (!plain(m)) return at;
|
|
@@ -2703,6 +2901,8 @@ export function parseChainTxDisplay(input) {
|
|
|
2703
2901
|
"riskLevel",
|
|
2704
2902
|
"cannotUndo",
|
|
2705
2903
|
"transfer",
|
|
2904
|
+
"actions",
|
|
2905
|
+
"proposalPrefix",
|
|
2706
2906
|
],
|
|
2707
2907
|
"view.chainTx.step",
|
|
2708
2908
|
);
|
|
@@ -2712,14 +2912,7 @@ export function parseChainTxDisplay(input) {
|
|
|
2712
2912
|
str(step.whatItDoes, "view.chainTx.step.whatItDoes", 1, 160);
|
|
2713
2913
|
if (!Array.isArray(step.facts) || step.facts.length > 40)
|
|
2714
2914
|
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
|
-
}
|
|
2915
|
+
for (const fact of step.facts) parseChainTxFact(fact);
|
|
2723
2916
|
const risk = CHAIN_TX_RISK_LEVELS.indexOf(step.riskLevel);
|
|
2724
2917
|
if (risk < 0) fail("view.chainTx.step.riskLevel");
|
|
2725
2918
|
highest = Math.max(highest, risk);
|
|
@@ -2728,6 +2921,14 @@ export function parseChainTxDisplay(input) {
|
|
|
2728
2921
|
if (step.type !== "cosmos.bank.send") fail("view.chainTx.step.transfer");
|
|
2729
2922
|
parseTransferDisplay(step.transfer);
|
|
2730
2923
|
}
|
|
2924
|
+
parseGroupActionsDisplay(step, risk);
|
|
2925
|
+
// A new proposal's list prefix (1-4 capital letters), so the result can
|
|
2926
|
+
// name it as the cards do ("proposal A4"); absent when the list has none.
|
|
2927
|
+
if (step.proposalPrefix !== undefined) {
|
|
2928
|
+
if (step.type !== "daodao.proposal.create")
|
|
2929
|
+
fail("view.chainTx.step.proposalPrefix");
|
|
2930
|
+
pattern(step.proposalPrefix, /^[A-Z]{1,4}$/, "view.chainTx.step.proposalPrefix");
|
|
2931
|
+
}
|
|
2731
2932
|
}
|
|
2732
2933
|
if (CHAIN_TX_RISK_LEVELS[highest] !== d.riskLevel)
|
|
2733
2934
|
fail("view.chainTx.riskLevel");
|
|
@@ -2743,6 +2944,56 @@ export function parseChainTxDisplay(input) {
|
|
|
2743
2944
|
return d;
|
|
2744
2945
|
}
|
|
2745
2946
|
|
|
2947
|
+
function parseChainTxFact(fact) {
|
|
2948
|
+
object(fact, "view.chainTx.fact");
|
|
2949
|
+
exact(fact, ["label", "value", "technical"], "view.chainTx.fact");
|
|
2950
|
+
str(fact.label, "view.chainTx.fact.label", 1, 60);
|
|
2951
|
+
str(fact.value, "view.chainTx.fact.value", 1, 300);
|
|
2952
|
+
if (fact.technical !== undefined && typeof fact.technical !== "boolean")
|
|
2953
|
+
fail("view.chainTx.fact.technical");
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
/**
|
|
2957
|
+
* 0.9.0 D13: what the group's own account would do, on create (its 0..4
|
|
2958
|
+
* actions, in order) and carry-out (the passed proposal's stored actions,
|
|
2959
|
+
* at most 10 shown; `type: null` for one the page cannot explain). Required
|
|
2960
|
+
* on those two step types (`[]` for none), refused on every other. The
|
|
2961
|
+
* step's risk is at least each action's.
|
|
2962
|
+
*/
|
|
2963
|
+
function parseGroupActionsDisplay(step, stepRisk) {
|
|
2964
|
+
const create = step.type === "daodao.proposal.create";
|
|
2965
|
+
if (!create && step.type !== "daodao.proposal.execute") {
|
|
2966
|
+
if (step.actions !== undefined) fail("view.chainTx.step.actions");
|
|
2967
|
+
return;
|
|
2968
|
+
}
|
|
2969
|
+
const max = create ? CHAIN_TX_MAX_GROUP_ACTIONS : CHAIN_TX_MAX_SHOWN_GROUP_ACTIONS;
|
|
2970
|
+
if (!Array.isArray(step.actions) || step.actions.length > max)
|
|
2971
|
+
fail("view.chainTx.step.actions");
|
|
2972
|
+
for (const action of step.actions) {
|
|
2973
|
+
object(action, "view.chainTx.action");
|
|
2974
|
+
exact(
|
|
2975
|
+
action,
|
|
2976
|
+
["type", "title", "whatItDoes", "facts", "riskLevel", "cannotUndo"],
|
|
2977
|
+
"view.chainTx.action",
|
|
2978
|
+
);
|
|
2979
|
+
if (
|
|
2980
|
+
action.type === null
|
|
2981
|
+
? create
|
|
2982
|
+
: !(create ? CHAIN_TX_GROUP_ACTION_TYPES : CHAIN_TX_LEVEL6_MESSAGE_TYPES).includes(action.type)
|
|
2983
|
+
)
|
|
2984
|
+
fail("view.chainTx.action.type");
|
|
2985
|
+
str(action.title, "view.chainTx.action.title", 1, 60);
|
|
2986
|
+
str(action.whatItDoes, "view.chainTx.action.whatItDoes", 1, 160);
|
|
2987
|
+
if (!Array.isArray(action.facts) || action.facts.length > 12)
|
|
2988
|
+
fail("view.chainTx.action.facts");
|
|
2989
|
+
for (const fact of action.facts) parseChainTxFact(fact);
|
|
2990
|
+
const risk = CHAIN_TX_RISK_LEVELS.indexOf(action.riskLevel);
|
|
2991
|
+
if (risk < 0 || risk > stepRisk) fail("view.chainTx.action.riskLevel");
|
|
2992
|
+
if (typeof action.cannotUndo !== "boolean")
|
|
2993
|
+
fail("view.chainTx.action.cannotUndo");
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2746
2997
|
function parseChainTxReceipt(r) {
|
|
2747
2998
|
exact(
|
|
2748
2999
|
r,
|
|
@@ -2791,13 +3042,37 @@ function parseChainTxReceipt(r) {
|
|
|
2791
3042
|
r.steps.length > CHAIN_TX_MAX_MESSAGES
|
|
2792
3043
|
)
|
|
2793
3044
|
fail("receipt.steps");
|
|
3045
|
+
// 0.9.0: on a succeeded receipt (included, code 0) a new proposal names its
|
|
3046
|
+
// id (null when the Hub could not read it; never guessed) and a carry-out
|
|
3047
|
+
// says whether the group's actions ran. Absent on every other receipt.
|
|
3048
|
+
const succeeded = r.code === 0 && r.height !== null && !("reason" in r);
|
|
2794
3049
|
for (const step of r.steps) {
|
|
2795
3050
|
object(step, "receipt.step");
|
|
2796
|
-
|
|
3051
|
+
const result =
|
|
3052
|
+
succeeded && Object.hasOwn(CHAIN_TX_RECEIPT_STEP_RESULT, step.type)
|
|
3053
|
+
? CHAIN_TX_RECEIPT_STEP_RESULT[step.type]
|
|
3054
|
+
: undefined;
|
|
3055
|
+
exact(step, result ? ["type", result] : ["type"], "receipt.step");
|
|
2797
3056
|
if (!CHAIN_TX_MESSAGE_TYPES.includes(step.type)) fail("receipt.step.type");
|
|
3057
|
+
if (
|
|
3058
|
+
result === "proposalId" &&
|
|
3059
|
+
(!("proposalId" in step) ||
|
|
3060
|
+
(step.proposalId !== null && !isGroupProposalId(step.proposalId)))
|
|
3061
|
+
)
|
|
3062
|
+
fail("receipt.step.proposalId");
|
|
3063
|
+
if (
|
|
3064
|
+
result === "groupActions" &&
|
|
3065
|
+
!CHAIN_TX_GROUP_ACTION_RESULTS.includes(step.groupActions)
|
|
3066
|
+
)
|
|
3067
|
+
fail("receipt.step.groupActions");
|
|
2798
3068
|
}
|
|
2799
3069
|
return r;
|
|
2800
3070
|
}
|
|
3071
|
+
/** 0.9.0: the one key a succeeded receipt step adds, per type (D8, D9). */
|
|
3072
|
+
const CHAIN_TX_RECEIPT_STEP_RESULT = {
|
|
3073
|
+
"daodao.proposal.create": "proposalId",
|
|
3074
|
+
"daodao.proposal.execute": "groupActions",
|
|
3075
|
+
};
|
|
2801
3076
|
|
|
2802
3077
|
export * from "./outcome-signature.js";
|
|
2803
3078
|
|
package/src/operation-schema.js
CHANGED
|
@@ -181,7 +181,8 @@ const entityPermission = enumeration(
|
|
|
181
181
|
const ixoDidOrHttps = {
|
|
182
182
|
anyOf: [httpsLink, { ...ixoDid, maxLength: 300 }],
|
|
183
183
|
};
|
|
184
|
-
|
|
184
|
+
// The 33 message branches of wire level 6, in CHAIN_TX_MESSAGE_TYPES order.
|
|
185
|
+
const level6Messages = {
|
|
185
186
|
anyOf: [
|
|
186
187
|
object({
|
|
187
188
|
type: { const: "cosmos.bank.send" },
|
|
@@ -446,6 +447,84 @@ const chainTxMessage = {
|
|
|
446
447
|
}),
|
|
447
448
|
],
|
|
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 },
|
|
526
|
+
],
|
|
527
|
+
};
|
|
449
528
|
const registry = {
|
|
450
529
|
"form.submit.v1": {
|
|
451
530
|
formId: string(1, 120),
|
|
@@ -535,7 +614,7 @@ const registry = {
|
|
|
535
614
|
network: enumeration("ixo mainnet", "ixo testnet", "ixo devnet"),
|
|
536
615
|
signer: account,
|
|
537
616
|
memo: string(0, 256),
|
|
538
|
-
messages:
|
|
617
|
+
messages: chainTxMessages,
|
|
539
618
|
},
|
|
540
619
|
"ixo.bid.submit.v1": {
|
|
541
620
|
network,
|