@ottochain/sdk 2.2.5 → 2.3.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.
Files changed (82) hide show
  1. package/dist/cjs/apps/contracts/state-machines/contract-agreement.js +54 -6
  2. package/dist/cjs/apps/contracts/state-machines/contract-escrow.js +72 -8
  3. package/dist/cjs/apps/contracts/state-machines/contract-universal.js +36 -4
  4. package/dist/cjs/apps/governance/state-machines/dao-multisig.js +27 -3
  5. package/dist/cjs/apps/governance/state-machines/dao-reputation.js +27 -3
  6. package/dist/cjs/apps/governance/state-machines/dao-single.js +27 -3
  7. package/dist/cjs/apps/governance/state-machines/dao-token.js +36 -4
  8. package/dist/cjs/apps/governance/state-machines/governance-simple.js +36 -4
  9. package/dist/cjs/apps/governance/state-machines/governance-universal.js +27 -3
  10. package/dist/cjs/apps/identity/state-machines/identity-agent.js +54 -6
  11. package/dist/cjs/apps/identity/state-machines/identity-oracle.js +45 -5
  12. package/dist/cjs/apps/identity/state-machines/identity-universal.js +27 -3
  13. package/dist/cjs/apps/markets/state-machines/market-auction.js +30 -6
  14. package/dist/cjs/apps/markets/state-machines/market-crowdfund.js +25 -5
  15. package/dist/cjs/apps/markets/state-machines/market-group-buy.js +29 -5
  16. package/dist/cjs/apps/markets/state-machines/market-prediction.js +40 -8
  17. package/dist/cjs/apps/markets/state-machines/market-universal.js +45 -5
  18. package/dist/cjs/generated/ottochain/v1/common.js +1722 -1
  19. package/dist/cjs/generated/ottochain/v1/fiber.js +352 -2
  20. package/dist/cjs/generated/ottochain/v1/messages.js +775 -3
  21. package/dist/cjs/generated/ottochain/v1/records.js +350 -3
  22. package/dist/cjs/index.js +5 -1
  23. package/dist/cjs/ottochain/genesis-manifest.js +193 -0
  24. package/dist/cjs/ottochain/index.js +5 -1
  25. package/dist/cjs/ottochain/types.js +4 -0
  26. package/dist/esm/apps/contracts/state-machines/contract-agreement.js +54 -6
  27. package/dist/esm/apps/contracts/state-machines/contract-escrow.js +72 -8
  28. package/dist/esm/apps/contracts/state-machines/contract-universal.js +36 -4
  29. package/dist/esm/apps/governance/state-machines/dao-multisig.js +27 -3
  30. package/dist/esm/apps/governance/state-machines/dao-reputation.js +27 -3
  31. package/dist/esm/apps/governance/state-machines/dao-single.js +27 -3
  32. package/dist/esm/apps/governance/state-machines/dao-token.js +36 -4
  33. package/dist/esm/apps/governance/state-machines/governance-simple.js +36 -4
  34. package/dist/esm/apps/governance/state-machines/governance-universal.js +27 -3
  35. package/dist/esm/apps/identity/state-machines/identity-agent.js +54 -6
  36. package/dist/esm/apps/identity/state-machines/identity-oracle.js +45 -5
  37. package/dist/esm/apps/identity/state-machines/identity-universal.js +27 -3
  38. package/dist/esm/apps/markets/state-machines/market-auction.js +30 -6
  39. package/dist/esm/apps/markets/state-machines/market-crowdfund.js +25 -5
  40. package/dist/esm/apps/markets/state-machines/market-group-buy.js +29 -5
  41. package/dist/esm/apps/markets/state-machines/market-prediction.js +40 -8
  42. package/dist/esm/apps/markets/state-machines/market-universal.js +45 -5
  43. package/dist/esm/generated/ottochain/v1/common.js +1718 -0
  44. package/dist/esm/generated/ottochain/v1/fiber.js +351 -1
  45. package/dist/esm/generated/ottochain/v1/messages.js +774 -2
  46. package/dist/esm/generated/ottochain/v1/records.js +349 -2
  47. package/dist/esm/index.js +2 -0
  48. package/dist/esm/ottochain/genesis-manifest.js +189 -0
  49. package/dist/esm/ottochain/index.js +2 -0
  50. package/dist/esm/ottochain/types.js +4 -0
  51. package/dist/types/apps/contracts/index.d.ts +90 -18
  52. package/dist/types/apps/contracts/state-machines/contract-agreement.d.ts +30 -6
  53. package/dist/types/apps/contracts/state-machines/contract-escrow.d.ts +40 -8
  54. package/dist/types/apps/contracts/state-machines/contract-universal.d.ts +20 -4
  55. package/dist/types/apps/governance/index.d.ts +114 -33
  56. package/dist/types/apps/governance/state-machines/dao-multisig.d.ts +15 -3
  57. package/dist/types/apps/governance/state-machines/dao-reputation.d.ts +15 -3
  58. package/dist/types/apps/governance/state-machines/dao-single.d.ts +15 -3
  59. package/dist/types/apps/governance/state-machines/dao-token.d.ts +20 -4
  60. package/dist/types/apps/governance/state-machines/governance-simple.d.ts +20 -4
  61. package/dist/types/apps/governance/state-machines/governance-universal.d.ts +15 -3
  62. package/dist/types/apps/identity/index.d.ts +71 -6
  63. package/dist/types/apps/identity/state-machines/identity-agent.d.ts +30 -0
  64. package/dist/types/apps/identity/state-machines/identity-oracle.d.ts +25 -0
  65. package/dist/types/apps/identity/state-machines/identity-universal.d.ts +15 -0
  66. package/dist/types/apps/markets/index.d.ts +80 -5
  67. package/dist/types/apps/markets/state-machines/market-auction.d.ts +12 -0
  68. package/dist/types/apps/markets/state-machines/market-crowdfund.d.ts +10 -0
  69. package/dist/types/apps/markets/state-machines/market-group-buy.d.ts +14 -0
  70. package/dist/types/apps/markets/state-machines/market-prediction.d.ts +16 -0
  71. package/dist/types/apps/markets/state-machines/market-universal.d.ts +25 -5
  72. package/dist/types/generated/ottochain/v1/common.d.ts +228 -0
  73. package/dist/types/generated/ottochain/v1/fiber.d.ts +32 -1
  74. package/dist/types/generated/ottochain/v1/messages.d.ts +84 -0
  75. package/dist/types/generated/ottochain/v1/records.d.ts +34 -0
  76. package/dist/types/index.d.ts +3 -1
  77. package/dist/types/ottochain/genesis-manifest.d.ts +130 -0
  78. package/dist/types/ottochain/index.d.ts +3 -1
  79. package/dist/types/ottochain/types.d.ts +288 -2
  80. package/dist/types/schema/fiber-app.d.ts +40 -1
  81. package/dist/types/validation.d.ts +17 -17
  82. package/package.json +30 -27
@@ -6,6 +6,7 @@
6
6
  /* eslint-disable */
7
7
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
8
  import { Value } from "../../google/protobuf/struct.js";
9
+ import { RegistryEntry, SchemaBinding } from "./common.js";
9
10
  import { AccessControlPolicy, EventReceipt, FiberLogEntry, FiberStatus, fiberStatusFromJSON, fiberStatusToJSON, fiberStatusToNumber, ScriptInvocation, StateMachineDefinition, } from "./fiber.js";
10
11
  export const protobufPackage = "ottochain.v1";
11
12
  function createBaseStateMachineFiberRecord() {
@@ -24,6 +25,7 @@ function createBaseStateMachineFiberRecord() {
24
25
  lastReceipt: undefined,
25
26
  parentFiberId: undefined,
26
27
  childFiberIds: [],
28
+ schemaBinding: undefined,
27
29
  };
28
30
  }
29
31
  export const StateMachineFiberRecord = {
@@ -70,6 +72,9 @@ export const StateMachineFiberRecord = {
70
72
  for (const v of message.childFiberIds) {
71
73
  writer.uint32(114).string(v);
72
74
  }
75
+ if (message.schemaBinding !== undefined) {
76
+ SchemaBinding.encode(message.schemaBinding, writer.uint32(122).fork()).join();
77
+ }
73
78
  return writer;
74
79
  },
75
80
  decode(input, length) {
@@ -177,6 +182,13 @@ export const StateMachineFiberRecord = {
177
182
  message.childFiberIds.push(reader.string());
178
183
  continue;
179
184
  }
185
+ case 15: {
186
+ if (tag !== 122) {
187
+ break;
188
+ }
189
+ message.schemaBinding = SchemaBinding.decode(reader, reader.uint32());
190
+ continue;
191
+ }
180
192
  }
181
193
  if ((tag & 7) === 4 || tag === 0) {
182
194
  break;
@@ -245,6 +257,11 @@ export const StateMachineFiberRecord = {
245
257
  : globalThis.Array.isArray(object?.child_fiber_ids)
246
258
  ? object.child_fiber_ids.map((e) => globalThis.String(e))
247
259
  : [],
260
+ schemaBinding: isSet(object.schemaBinding)
261
+ ? SchemaBinding.fromJSON(object.schemaBinding)
262
+ : isSet(object.schema_binding)
263
+ ? SchemaBinding.fromJSON(object.schema_binding)
264
+ : undefined,
248
265
  };
249
266
  },
250
267
  toJSON(message) {
@@ -291,6 +308,9 @@ export const StateMachineFiberRecord = {
291
308
  if (message.childFiberIds?.length) {
292
309
  obj.childFiberIds = message.childFiberIds;
293
310
  }
311
+ if (message.schemaBinding !== undefined) {
312
+ obj.schemaBinding = SchemaBinding.toJSON(message.schemaBinding);
313
+ }
294
314
  return obj;
295
315
  },
296
316
  create(base) {
@@ -316,6 +336,9 @@ export const StateMachineFiberRecord = {
316
336
  : undefined;
317
337
  message.parentFiberId = object.parentFiberId ?? undefined;
318
338
  message.childFiberIds = object.childFiberIds?.map((e) => e) || [];
339
+ message.schemaBinding = (object.schemaBinding !== undefined && object.schemaBinding !== null)
340
+ ? SchemaBinding.fromPartial(object.schemaBinding)
341
+ : undefined;
319
342
  return message;
320
343
  },
321
344
  };
@@ -670,7 +693,7 @@ export const FiberCommit = {
670
693
  },
671
694
  };
672
695
  function createBaseOnChainState() {
673
- return { fiberCommits: {}, latestLogs: {} };
696
+ return { fiberCommits: {}, latestLogs: {}, registryCommits: {} };
674
697
  }
675
698
  export const OnChainState = {
676
699
  encode(message, writer = new BinaryWriter()) {
@@ -680,6 +703,9 @@ export const OnChainState = {
680
703
  globalThis.Object.entries(message.latestLogs).forEach(([key, value]) => {
681
704
  OnChainState_LatestLogsEntry.encode({ key: key, value }, writer.uint32(18).fork()).join();
682
705
  });
706
+ globalThis.Object.entries(message.registryCommits).forEach(([key, value]) => {
707
+ OnChainState_RegistryCommitsEntry.encode({ key: key, value }, writer.uint32(26).fork()).join();
708
+ });
683
709
  return writer;
684
710
  },
685
711
  decode(input, length) {
@@ -709,6 +735,16 @@ export const OnChainState = {
709
735
  }
710
736
  continue;
711
737
  }
738
+ case 3: {
739
+ if (tag !== 26) {
740
+ break;
741
+ }
742
+ const entry3 = OnChainState_RegistryCommitsEntry.decode(reader, reader.uint32());
743
+ if (entry3.value !== undefined) {
744
+ message.registryCommits[entry3.key] = entry3.value;
745
+ }
746
+ continue;
747
+ }
712
748
  }
713
749
  if ((tag & 7) === 4 || tag === 0) {
714
750
  break;
@@ -741,6 +777,17 @@ export const OnChainState = {
741
777
  return acc;
742
778
  }, {})
743
779
  : {},
780
+ registryCommits: isObject(object.registryCommits)
781
+ ? globalThis.Object.entries(object.registryCommits).reduce((acc, [key, value]) => {
782
+ acc[key] = globalThis.String(value);
783
+ return acc;
784
+ }, {})
785
+ : isObject(object.registry_commits)
786
+ ? globalThis.Object.entries(object.registry_commits).reduce((acc, [key, value]) => {
787
+ acc[key] = globalThis.String(value);
788
+ return acc;
789
+ }, {})
790
+ : {},
744
791
  };
745
792
  },
746
793
  toJSON(message) {
@@ -763,6 +810,15 @@ export const OnChainState = {
763
810
  });
764
811
  }
765
812
  }
813
+ if (message.registryCommits) {
814
+ const entries = globalThis.Object.entries(message.registryCommits);
815
+ if (entries.length > 0) {
816
+ obj.registryCommits = {};
817
+ entries.forEach(([k, v]) => {
818
+ obj.registryCommits[k] = v;
819
+ });
820
+ }
821
+ }
766
822
  return obj;
767
823
  },
768
824
  create(base) {
@@ -782,6 +838,12 @@ export const OnChainState = {
782
838
  }
783
839
  return acc;
784
840
  }, {});
841
+ message.registryCommits = globalThis.Object.entries(object.registryCommits ?? {}).reduce((acc, [key, value]) => {
842
+ if (value !== undefined) {
843
+ acc[key] = globalThis.String(value);
844
+ }
845
+ return acc;
846
+ }, {});
785
847
  return message;
786
848
  },
787
849
  };
@@ -925,6 +987,74 @@ export const OnChainState_LatestLogsEntry = {
925
987
  return message;
926
988
  },
927
989
  };
990
+ function createBaseOnChainState_RegistryCommitsEntry() {
991
+ return { key: "", value: "" };
992
+ }
993
+ export const OnChainState_RegistryCommitsEntry = {
994
+ encode(message, writer = new BinaryWriter()) {
995
+ if (message.key !== "") {
996
+ writer.uint32(10).string(message.key);
997
+ }
998
+ if (message.value !== "") {
999
+ writer.uint32(18).string(message.value);
1000
+ }
1001
+ return writer;
1002
+ },
1003
+ decode(input, length) {
1004
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1005
+ const end = length === undefined ? reader.len : reader.pos + length;
1006
+ const message = createBaseOnChainState_RegistryCommitsEntry();
1007
+ while (reader.pos < end) {
1008
+ const tag = reader.uint32();
1009
+ switch (tag >>> 3) {
1010
+ case 1: {
1011
+ if (tag !== 10) {
1012
+ break;
1013
+ }
1014
+ message.key = reader.string();
1015
+ continue;
1016
+ }
1017
+ case 2: {
1018
+ if (tag !== 18) {
1019
+ break;
1020
+ }
1021
+ message.value = reader.string();
1022
+ continue;
1023
+ }
1024
+ }
1025
+ if ((tag & 7) === 4 || tag === 0) {
1026
+ break;
1027
+ }
1028
+ reader.skip(tag & 7);
1029
+ }
1030
+ return message;
1031
+ },
1032
+ fromJSON(object) {
1033
+ return {
1034
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
1035
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
1036
+ };
1037
+ },
1038
+ toJSON(message) {
1039
+ const obj = {};
1040
+ if (message.key !== "") {
1041
+ obj.key = message.key;
1042
+ }
1043
+ if (message.value !== "") {
1044
+ obj.value = message.value;
1045
+ }
1046
+ return obj;
1047
+ },
1048
+ create(base) {
1049
+ return OnChainState_RegistryCommitsEntry.fromPartial(base ?? {});
1050
+ },
1051
+ fromPartial(object) {
1052
+ const message = createBaseOnChainState_RegistryCommitsEntry();
1053
+ message.key = object.key ?? "";
1054
+ message.value = object.value ?? "";
1055
+ return message;
1056
+ },
1057
+ };
928
1058
  function createBaseFiberLogEntryList() {
929
1059
  return { entries: [] };
930
1060
  }
@@ -981,7 +1111,7 @@ export const FiberLogEntryList = {
981
1111
  },
982
1112
  };
983
1113
  function createBaseCalculatedState() {
984
- return { stateMachines: {}, scripts: {} };
1114
+ return { stateMachines: {}, scripts: {}, registryEntries: {}, reverseNames: {} };
985
1115
  }
986
1116
  export const CalculatedState = {
987
1117
  encode(message, writer = new BinaryWriter()) {
@@ -991,6 +1121,12 @@ export const CalculatedState = {
991
1121
  globalThis.Object.entries(message.scripts).forEach(([key, value]) => {
992
1122
  CalculatedState_ScriptsEntry.encode({ key: key, value }, writer.uint32(18).fork()).join();
993
1123
  });
1124
+ globalThis.Object.entries(message.registryEntries).forEach(([key, value]) => {
1125
+ CalculatedState_RegistryEntriesEntry.encode({ key: key, value }, writer.uint32(26).fork()).join();
1126
+ });
1127
+ globalThis.Object.entries(message.reverseNames).forEach(([key, value]) => {
1128
+ CalculatedState_ReverseNamesEntry.encode({ key: key, value }, writer.uint32(34).fork()).join();
1129
+ });
994
1130
  return writer;
995
1131
  },
996
1132
  decode(input, length) {
@@ -1020,6 +1156,26 @@ export const CalculatedState = {
1020
1156
  }
1021
1157
  continue;
1022
1158
  }
1159
+ case 3: {
1160
+ if (tag !== 26) {
1161
+ break;
1162
+ }
1163
+ const entry3 = CalculatedState_RegistryEntriesEntry.decode(reader, reader.uint32());
1164
+ if (entry3.value !== undefined) {
1165
+ message.registryEntries[entry3.key] = entry3.value;
1166
+ }
1167
+ continue;
1168
+ }
1169
+ case 4: {
1170
+ if (tag !== 34) {
1171
+ break;
1172
+ }
1173
+ const entry4 = CalculatedState_ReverseNamesEntry.decode(reader, reader.uint32());
1174
+ if (entry4.value !== undefined) {
1175
+ message.reverseNames[entry4.key] = entry4.value;
1176
+ }
1177
+ continue;
1178
+ }
1023
1179
  }
1024
1180
  if ((tag & 7) === 4 || tag === 0) {
1025
1181
  break;
@@ -1047,6 +1203,28 @@ export const CalculatedState = {
1047
1203
  return acc;
1048
1204
  }, {})
1049
1205
  : {},
1206
+ registryEntries: isObject(object.registry)
1207
+ ? globalThis.Object.entries(object.registry).reduce((acc, [key, value]) => {
1208
+ acc[key] = RegistryEntry.fromJSON(value);
1209
+ return acc;
1210
+ }, {})
1211
+ : isObject(object.registry_entries)
1212
+ ? globalThis.Object.entries(object.registry_entries).reduce((acc, [key, value]) => {
1213
+ acc[key] = RegistryEntry.fromJSON(value);
1214
+ return acc;
1215
+ }, {})
1216
+ : {},
1217
+ reverseNames: isObject(object.reverseNames)
1218
+ ? globalThis.Object.entries(object.reverseNames).reduce((acc, [key, value]) => {
1219
+ acc[key] = globalThis.String(value);
1220
+ return acc;
1221
+ }, {})
1222
+ : isObject(object.reverse_names)
1223
+ ? globalThis.Object.entries(object.reverse_names).reduce((acc, [key, value]) => {
1224
+ acc[key] = globalThis.String(value);
1225
+ return acc;
1226
+ }, {})
1227
+ : {},
1050
1228
  };
1051
1229
  },
1052
1230
  toJSON(message) {
@@ -1069,6 +1247,24 @@ export const CalculatedState = {
1069
1247
  });
1070
1248
  }
1071
1249
  }
1250
+ if (message.registryEntries) {
1251
+ const entries = globalThis.Object.entries(message.registryEntries);
1252
+ if (entries.length > 0) {
1253
+ obj.registry = {};
1254
+ entries.forEach(([k, v]) => {
1255
+ obj.registry[k] = RegistryEntry.toJSON(v);
1256
+ });
1257
+ }
1258
+ }
1259
+ if (message.reverseNames) {
1260
+ const entries = globalThis.Object.entries(message.reverseNames);
1261
+ if (entries.length > 0) {
1262
+ obj.reverseNames = {};
1263
+ entries.forEach(([k, v]) => {
1264
+ obj.reverseNames[k] = v;
1265
+ });
1266
+ }
1267
+ }
1072
1268
  return obj;
1073
1269
  },
1074
1270
  create(base) {
@@ -1089,6 +1285,19 @@ export const CalculatedState = {
1089
1285
  }
1090
1286
  return acc;
1091
1287
  }, {});
1288
+ message.registryEntries = globalThis.Object.entries(object.registryEntries ?? {})
1289
+ .reduce((acc, [key, value]) => {
1290
+ if (value !== undefined) {
1291
+ acc[key] = RegistryEntry.fromPartial(value);
1292
+ }
1293
+ return acc;
1294
+ }, {});
1295
+ message.reverseNames = globalThis.Object.entries(object.reverseNames ?? {}).reduce((acc, [key, value]) => {
1296
+ if (value !== undefined) {
1297
+ acc[key] = globalThis.String(value);
1298
+ }
1299
+ return acc;
1300
+ }, {});
1092
1301
  return message;
1093
1302
  },
1094
1303
  };
@@ -1232,6 +1441,144 @@ export const CalculatedState_ScriptsEntry = {
1232
1441
  return message;
1233
1442
  },
1234
1443
  };
1444
+ function createBaseCalculatedState_RegistryEntriesEntry() {
1445
+ return { key: "", value: undefined };
1446
+ }
1447
+ export const CalculatedState_RegistryEntriesEntry = {
1448
+ encode(message, writer = new BinaryWriter()) {
1449
+ if (message.key !== "") {
1450
+ writer.uint32(10).string(message.key);
1451
+ }
1452
+ if (message.value !== undefined) {
1453
+ RegistryEntry.encode(message.value, writer.uint32(18).fork()).join();
1454
+ }
1455
+ return writer;
1456
+ },
1457
+ decode(input, length) {
1458
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1459
+ const end = length === undefined ? reader.len : reader.pos + length;
1460
+ const message = createBaseCalculatedState_RegistryEntriesEntry();
1461
+ while (reader.pos < end) {
1462
+ const tag = reader.uint32();
1463
+ switch (tag >>> 3) {
1464
+ case 1: {
1465
+ if (tag !== 10) {
1466
+ break;
1467
+ }
1468
+ message.key = reader.string();
1469
+ continue;
1470
+ }
1471
+ case 2: {
1472
+ if (tag !== 18) {
1473
+ break;
1474
+ }
1475
+ message.value = RegistryEntry.decode(reader, reader.uint32());
1476
+ continue;
1477
+ }
1478
+ }
1479
+ if ((tag & 7) === 4 || tag === 0) {
1480
+ break;
1481
+ }
1482
+ reader.skip(tag & 7);
1483
+ }
1484
+ return message;
1485
+ },
1486
+ fromJSON(object) {
1487
+ return {
1488
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
1489
+ value: isSet(object.value) ? RegistryEntry.fromJSON(object.value) : undefined,
1490
+ };
1491
+ },
1492
+ toJSON(message) {
1493
+ const obj = {};
1494
+ if (message.key !== "") {
1495
+ obj.key = message.key;
1496
+ }
1497
+ if (message.value !== undefined) {
1498
+ obj.value = RegistryEntry.toJSON(message.value);
1499
+ }
1500
+ return obj;
1501
+ },
1502
+ create(base) {
1503
+ return CalculatedState_RegistryEntriesEntry.fromPartial(base ?? {});
1504
+ },
1505
+ fromPartial(object) {
1506
+ const message = createBaseCalculatedState_RegistryEntriesEntry();
1507
+ message.key = object.key ?? "";
1508
+ message.value = (object.value !== undefined && object.value !== null)
1509
+ ? RegistryEntry.fromPartial(object.value)
1510
+ : undefined;
1511
+ return message;
1512
+ },
1513
+ };
1514
+ function createBaseCalculatedState_ReverseNamesEntry() {
1515
+ return { key: "", value: "" };
1516
+ }
1517
+ export const CalculatedState_ReverseNamesEntry = {
1518
+ encode(message, writer = new BinaryWriter()) {
1519
+ if (message.key !== "") {
1520
+ writer.uint32(10).string(message.key);
1521
+ }
1522
+ if (message.value !== "") {
1523
+ writer.uint32(18).string(message.value);
1524
+ }
1525
+ return writer;
1526
+ },
1527
+ decode(input, length) {
1528
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1529
+ const end = length === undefined ? reader.len : reader.pos + length;
1530
+ const message = createBaseCalculatedState_ReverseNamesEntry();
1531
+ while (reader.pos < end) {
1532
+ const tag = reader.uint32();
1533
+ switch (tag >>> 3) {
1534
+ case 1: {
1535
+ if (tag !== 10) {
1536
+ break;
1537
+ }
1538
+ message.key = reader.string();
1539
+ continue;
1540
+ }
1541
+ case 2: {
1542
+ if (tag !== 18) {
1543
+ break;
1544
+ }
1545
+ message.value = reader.string();
1546
+ continue;
1547
+ }
1548
+ }
1549
+ if ((tag & 7) === 4 || tag === 0) {
1550
+ break;
1551
+ }
1552
+ reader.skip(tag & 7);
1553
+ }
1554
+ return message;
1555
+ },
1556
+ fromJSON(object) {
1557
+ return {
1558
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
1559
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
1560
+ };
1561
+ },
1562
+ toJSON(message) {
1563
+ const obj = {};
1564
+ if (message.key !== "") {
1565
+ obj.key = message.key;
1566
+ }
1567
+ if (message.value !== "") {
1568
+ obj.value = message.value;
1569
+ }
1570
+ return obj;
1571
+ },
1572
+ create(base) {
1573
+ return CalculatedState_ReverseNamesEntry.fromPartial(base ?? {});
1574
+ },
1575
+ fromPartial(object) {
1576
+ const message = createBaseCalculatedState_ReverseNamesEntry();
1577
+ message.key = object.key ?? "";
1578
+ message.value = object.value ?? "";
1579
+ return message;
1580
+ },
1581
+ };
1235
1582
  function longToNumber(int64) {
1236
1583
  const num = globalThis.Number(int64.toString());
1237
1584
  if (num > globalThis.Number.MAX_SAFE_INTEGER) {
package/dist/esm/index.js CHANGED
@@ -30,6 +30,8 @@ export * from './types.js';
30
30
  export * from './ottochain/transaction.js';
31
31
  export { normalizeCreateStateMachine, normalizeTransitionStateMachine, normalizeArchiveStateMachine, normalizeMessage } from './ottochain/normalize.js';
32
32
  export { dropNulls } from './ottochain/drop-nulls.js';
33
+ // ─── Genesis manifest exporter (std-app pre-registration content) ─────────────
34
+ export { buildGenesisManifest, GENESIS_MANIFEST_VERSION } from './ottochain/genesis-manifest.js';
33
35
  // ─── Generated protobuf types (canonical definitions) ────────────────────────
34
36
  export * from './generated/index.js';
35
37
  // ─── Custom error classes ─────────────────────────────────────────────────────
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Genesis Manifest Exporter
3
+ *
4
+ * The ottochain metagraph can boot from a NON-EMPTY genesis: a set of standard
5
+ * packages pre-registered in the registry before any user transaction. This SDK
6
+ * is the source of truth for those std apps (their proto schemas + JSON-Logic
7
+ * state-machine definitions), so it is also the source of truth for the
8
+ * *genesis manifest* — the per-app CONTENT the chain needs to pre-register each
9
+ * package at genesis.
10
+ *
11
+ * DESIGN — content, not consensus hashes:
12
+ * The manifest ships CONTENT only: the `schemaShape` (the typed, proto-faithful
13
+ * projection of the app's state message) and the `definition` (the JSON-Logic
14
+ * `StateMachineDefinition`, verbatim — the same object the chain decodes for any
15
+ * fiber). The CHAIN computes the consensus values itself from this content:
16
+ * - `logicHash` = `StateMachineDefinition.computeDigest(definition)`
17
+ * - `schemaHash` = commitment over the FileDescriptorSet (off-chain/Bridge)
18
+ * We deliberately do NOT replicate the chain's canonical hashing here, so there
19
+ * is ZERO hash-parity risk. No advisory hashes are emitted (see HONESTY notes in
20
+ * the PR description); add them later only if an off-chain consumer needs them,
21
+ * clearly marked advisory.
22
+ *
23
+ * NAMING — the reserved `std` label:
24
+ * Each package is named `std.<app>.package`. `RegistryName` reserves the `std`
25
+ * label in-protocol (`RegistryName.isReserved`), so ordinary user registrations
26
+ * of `std.*` are rejected — only the privileged genesis path may claim them.
27
+ * That is exactly the point: users cannot squat the standard names.
28
+ *
29
+ * SCHEMA SHAPES — chain-verified ground truth:
30
+ * The three `stateMessage` shapes are reproduced verbatim from the chain's own
31
+ * conformance suite (`StandardAppsConformanceSuite`, the `identity` / `proposal`
32
+ * / `market` `MessageShape` vals), which proves the on-chain shape validator and
33
+ * the conformance gate accept them. `commands` is left EMPTY for this first cut —
34
+ * the conformance suite itself models all three apps with `SortedMap.empty`
35
+ * commands, and the proto `*Request` messages are transaction-layer DTOs that do
36
+ * not map cleanly onto the universal state machines' free-form JSON-Logic event
37
+ * payloads. Deriving per-event command shapes is a flagged follow-up.
38
+ *
39
+ * The JSON shape emitted here is built to deserialize against the chain's circe
40
+ * codecs (`SchemaShape` / `FieldShape` / `MessageShape` and
41
+ * `StateMachineDefinition`), whose magnolia config is camelCase with defaults.
42
+ *
43
+ * @packageDocumentation
44
+ */
45
+ import { identityUniversalDef } from '../apps/identity/state-machines/identity-universal.js';
46
+ import { govUniversalDef } from '../apps/governance/state-machines/governance-universal.js';
47
+ import { marketUniversalDef } from '../apps/markets/state-machines/market-universal.js';
48
+ import { toProtoDefinition } from '../schema/fiber-app.js';
49
+ /** Manifest schema version. Bump on any breaking change to the shape. */
50
+ export const GENESIS_MANIFEST_VERSION = 1;
51
+ // ─── Chain-verified state-message shapes ──────────────────────────────────────
52
+ // Reproduced VERBATIM from ottochain
53
+ // modules/shared-data/.../StandardAppsConformanceSuite.scala — the `identity`,
54
+ // `proposal`, and `market` MessageShape vals. Keep these byte-for-byte in step
55
+ // with that suite; it is what guarantees the chain accepts them.
56
+ /** Helper: a FieldShape with the two boolean defaults made explicit. */
57
+ function field(name, number, typeName, repeated = false, optional = false) {
58
+ return { name, number, typeName, repeated, optional };
59
+ }
60
+ /** ottochain.apps.identity.v1.Identity */
61
+ const identityStateMessage = {
62
+ typeName: 'ottochain.apps.identity.v1.Identity',
63
+ fields: [
64
+ field('id', 1, 'string'),
65
+ field('address', 2, 'string'),
66
+ field('public_key', 3, 'string'),
67
+ field('display_name', 4, 'string'),
68
+ field('identity_type', 5, 'ottochain.apps.identity.v1.IdentityType'),
69
+ field('state', 6, 'ottochain.apps.identity.v1.IdentityState'),
70
+ field('reputation', 7, 'ottochain.apps.identity.v1.Reputation'),
71
+ field('stake', 8, 'int64'),
72
+ field('domains', 9, 'string', true),
73
+ field('platform_links', 10, 'ottochain.apps.identity.v1.PlatformLink', true),
74
+ field('penalty_history', 11, 'ottochain.apps.identity.v1.PenaltyEvent', true),
75
+ field('created_at', 12, 'google.protobuf.Timestamp'),
76
+ field('updated_at', 13, 'google.protobuf.Timestamp'),
77
+ ],
78
+ };
79
+ /** ottochain.apps.governance.v1.Proposal */
80
+ const governanceStateMessage = {
81
+ typeName: 'ottochain.apps.governance.v1.Proposal',
82
+ fields: [
83
+ field('id', 1, 'string'),
84
+ field('title', 2, 'string'),
85
+ field('description', 3, 'string'),
86
+ field('action_type', 4, 'string'),
87
+ field('payload', 5, 'google.protobuf.Struct'),
88
+ field('proposer', 6, 'string'),
89
+ field('proposed_at', 7, 'google.protobuf.Timestamp'),
90
+ field('deadline', 8, 'google.protobuf.Timestamp'),
91
+ field('queued_at', 9, 'google.protobuf.Timestamp'),
92
+ field('executable_at', 10, 'google.protobuf.Timestamp'),
93
+ ],
94
+ };
95
+ /** ottochain.apps.markets.v1.Market */
96
+ const marketStateMessage = {
97
+ typeName: 'ottochain.apps.markets.v1.Market',
98
+ fields: [
99
+ field('id', 1, 'string'),
100
+ field('market_type', 2, 'ottochain.apps.markets.v1.MarketType'),
101
+ field('creator', 3, 'string'),
102
+ field('title', 4, 'string'),
103
+ field('terms', 5, 'google.protobuf.Struct'),
104
+ field('deadline', 6, 'google.protobuf.Timestamp'),
105
+ field('threshold', 7, 'int64'),
106
+ field('commitments', 8, 'ottochain.apps.markets.v1.Commitment', true),
107
+ field('oracles', 9, 'string', true),
108
+ field('quorum', 10, 'int32'),
109
+ field('resolutions', 11, 'ottochain.apps.markets.v1.Resolution', true),
110
+ field('status', 12, 'ottochain.apps.markets.v1.MarketState'),
111
+ field('created_at', 13, 'google.protobuf.Timestamp'),
112
+ field('updated_at', 14, 'google.protobuf.Timestamp'),
113
+ ],
114
+ };
115
+ // ─── Definition projection (single source of truth = the exported defs) ───────
116
+ /**
117
+ * Project a `FiberAppDefinition` into the chain's wire `StateMachineDefinition`,
118
+ * matching the `json-archive/*.json` convention exactly:
119
+ * - states carry explicit `metadata: null`,
120
+ * - transitions carry explicit `dependencies: []`,
121
+ * - the TypeScript-only `FiberAppMetadata` is stripped (`metadata: null`).
122
+ *
123
+ * Built on the shared `toProtoDefinition` projector so the manifest never drifts
124
+ * from the SDK's own exported app definitions. The chain decodes `dependencies:
125
+ * []` / `metadata: null` identically to their absent forms (its codecs use
126
+ * defaults), so this is consensus-equivalent to the archives while staying
127
+ * byte-identical to the checked-in `json-archive/*.json` files.
128
+ */
129
+ function toWireDefinition(def) {
130
+ const proto = toProtoDefinition(def);
131
+ const states = {};
132
+ for (const [key, st] of Object.entries(proto.states)) {
133
+ states[key] = { id: st.id, isFinal: st.isFinal, metadata: null };
134
+ }
135
+ return {
136
+ states,
137
+ initialState: proto.initialState,
138
+ transitions: proto.transitions.map((t) => ({
139
+ from: t.from,
140
+ to: t.to,
141
+ eventName: t.eventName,
142
+ guard: t.guard,
143
+ effect: t.effect,
144
+ dependencies: t.dependencies ?? [],
145
+ })),
146
+ // Strip FiberAppMetadata — the chain's `metadata` is `Option[JsonLogicValue]`.
147
+ metadata: null,
148
+ };
149
+ }
150
+ // ─── Builder ──────────────────────────────────────────────────────────────────
151
+ /**
152
+ * Assemble the genesis manifest for the standard apps.
153
+ *
154
+ * Covers THREE apps in this first cut — identity, governance, markets (all the
155
+ * `universal` variant). The other std apps (contracts, oracles, corporate) and
156
+ * non-universal variants are a flagged follow-up.
157
+ *
158
+ * @returns a `GenesisManifest` whose JSON deserializes against the chain's circe
159
+ * codecs. Hashes are intentionally absent — the chain derives them.
160
+ */
161
+ export function buildGenesisManifest() {
162
+ const packages = [
163
+ {
164
+ name: 'std.identity.package',
165
+ semver: '1.0.0',
166
+ strict: false,
167
+ metadata: {},
168
+ schemaShape: { stateMessage: identityStateMessage, commands: {} },
169
+ definition: toWireDefinition(identityUniversalDef),
170
+ },
171
+ {
172
+ name: 'std.governance.package',
173
+ semver: '1.0.0',
174
+ strict: false,
175
+ metadata: {},
176
+ schemaShape: { stateMessage: governanceStateMessage, commands: {} },
177
+ definition: toWireDefinition(govUniversalDef),
178
+ },
179
+ {
180
+ name: 'std.markets.package',
181
+ semver: '1.0.0',
182
+ strict: false,
183
+ metadata: {},
184
+ schemaShape: { stateMessage: marketStateMessage, commands: {} },
185
+ definition: toWireDefinition(marketUniversalDef),
186
+ },
187
+ ];
188
+ return { version: GENESIS_MANIFEST_VERSION, packages };
189
+ }