@ixo/action-protocol 0.9.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,27 @@
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
+
3
25
  ## 0.9.0
4
26
 
5
27
  Four `ixo.chain.tx.v1` message types for groups (DAO DAO v2.0.3 groups with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ixo/action-protocol",
3
- "version": "0.9.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
@@ -473,6 +473,10 @@ export type ChainTxIidRemoveId = string;
473
473
  export type ChainTxLevel6Message =
474
474
  | {
475
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
+ */
476
480
  toAddress: string;
477
481
  /** ^[1-9][0-9]*$ */
478
482
  amountBaseUnits: string;
@@ -520,6 +524,7 @@ export type ChainTxLevel6Message =
520
524
  }
521
525
  | {
522
526
  type: "ixo.token.transfer";
527
+ /** A 20-byte account or (0.9.1) a 32-byte contract address, as `toAddress`. */
523
528
  recipient: string;
524
529
  /** 1..32 lines; id 1..128 of ^[A-Za-z0-9:._/-]+$, amount ^[1-9][0-9]*$ */
525
530
  tokens: Array<{ id: string; amount: string }>;
@@ -925,7 +930,9 @@ export type ChainTxStep = {
925
930
  /**
926
931
  * 0.9.0 D13: required on `daodao.proposal.create` (its 0..4 actions, in
927
932
  * 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
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
929
936
  * `riskLevel` is at least each action's.
930
937
  */
931
938
  actions?: ChainTxGroupActionDisplay[];
package/src/index.js CHANGED
@@ -2020,6 +2020,12 @@ const ANY_DID = new RegExp(`^did:[a-z0-9]+:${DID_TAIL}$`);
2020
2020
  // The Hub's isIxoAddress: canonical lowercase bech32 with exactly 20 data
2021
2021
  // bytes (32 payload + 6 checksum characters). The Hub also checks the checksum.
2022
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})$/;
2023
2029
  const BASE_UNITS = /^[1-9][0-9]{0,77}$/;
2024
2030
  // A uint64 without leading zeros (checked against UINT64_MAX below).
2025
2031
  const COLLECTION_ID = /^(0|[1-9][0-9]{0,19})$/;
@@ -2731,7 +2737,7 @@ function chainTxMessageField(m) {
2731
2737
  if (Object.hasOwn(CHAIN_TX_GROUP_FIELDS, m.type))
2732
2738
  return CHAIN_TX_GROUP_FIELDS[m.type](m);
2733
2739
  if (m.type === "cosmos.bank.send") {
2734
- if (!isMatch(m.toAddress, ACCOUNT_ADDRESS)) return "toAddress";
2740
+ if (!isMatch(m.toAddress, RECIPIENT_ADDRESS, 62)) return "toAddress";
2735
2741
  if (!isMatch(m.amountBaseUnits, BASE_UNITS, 78)) return "amountBaseUnits";
2736
2742
  if (m.denom !== undefined && !isMatch(m.denom, DENOM, 128)) return "denom";
2737
2743
  return null;
@@ -2764,7 +2770,7 @@ function chainTxMessageField(m) {
2764
2770
  return null;
2765
2771
  }
2766
2772
  // ixo.token.transfer
2767
- if (!isMatch(m.recipient, ACCOUNT_ADDRESS)) return "recipient";
2773
+ if (!isMatch(m.recipient, RECIPIENT_ADDRESS, 62)) return "recipient";
2768
2774
  return tokenLinesField(m.tokens);
2769
2775
  }
2770
2776
 
@@ -2957,12 +2963,19 @@ function parseChainTxFact(fact) {
2957
2963
  * 0.9.0 D13: what the group's own account would do, on create (its 0..4
2958
2964
  * actions, in order) and carry-out (the passed proposal's stored actions,
2959
2965
  * 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.
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.
2962
2970
  */
2963
2971
  function parseGroupActionsDisplay(step, stepRisk) {
2964
2972
  const create = step.type === "daodao.proposal.create";
2965
- if (!create && step.type !== "daodao.proposal.execute") {
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
+ ) {
2966
2979
  if (step.actions !== undefined) fail("view.chainTx.step.actions");
2967
2980
  return;
2968
2981
  }
@@ -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),
@@ -186,7 +192,7 @@ const level6Messages = {
186
192
  anyOf: [
187
193
  object({
188
194
  type: { const: "cosmos.bank.send" },
189
- toAddress: account,
195
+ toAddress: recipient,
190
196
  amountBaseUnits: baseUnits,
191
197
  denom: optional({ ...string(3, 128), pattern: "^[a-zA-Z][a-zA-Z0-9/:._-]{2,127}$" }),
192
198
  }),
@@ -215,7 +221,7 @@ const level6Messages = {
215
221
  }),
216
222
  object({
217
223
  type: { const: "ixo.token.transfer" },
218
- recipient: account,
224
+ recipient,
219
225
  tokens: {
220
226
  type: "array",
221
227
  items: object({ id: chainText(1, 128), amount: baseUnits }),