cyberia 3.0.3 → 3.2.5

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 (296) hide show
  1. package/{.env.production → .env.example} +20 -4
  2. package/.github/workflows/engine-cyberia.cd.yml +43 -10
  3. package/.github/workflows/engine-cyberia.ci.yml +48 -26
  4. package/.github/workflows/ghpkg.ci.yml +5 -5
  5. package/.github/workflows/gitlab.ci.yml +1 -1
  6. package/.github/workflows/hardhat.ci.yml +82 -0
  7. package/.github/workflows/npmpkg.ci.yml +60 -14
  8. package/.github/workflows/publish.ci.yml +26 -7
  9. package/.github/workflows/publish.cyberia.ci.yml +5 -5
  10. package/.github/workflows/pwa-microservices-template-page.cd.yml +6 -7
  11. package/.github/workflows/pwa-microservices-template-test.ci.yml +4 -4
  12. package/.github/workflows/release.cd.yml +14 -8
  13. package/.vscode/extensions.json +9 -8
  14. package/.vscode/settings.json +3 -2
  15. package/CHANGELOG.md +643 -1
  16. package/CLI-HELP.md +132 -57
  17. package/Dockerfile +4 -2
  18. package/README.md +347 -22
  19. package/WHITE-PAPER.md +1540 -0
  20. package/bin/build.js +21 -12
  21. package/bin/cyberia.js +2640 -106
  22. package/bin/deploy.js +258 -372
  23. package/bin/file.js +5 -1
  24. package/bin/index.js +2640 -106
  25. package/bin/vs.js +3 -3
  26. package/conf.js +169 -105
  27. package/deployment.yaml +236 -20
  28. package/hardhat/.env.example +31 -0
  29. package/hardhat/README.md +531 -0
  30. package/hardhat/WHITE-PAPER.md +1540 -0
  31. package/hardhat/contracts/ObjectLayerToken.sol +391 -0
  32. package/hardhat/deployments/.gitkeep +0 -0
  33. package/hardhat/deployments/hardhat-ObjectLayerToken.json +11 -0
  34. package/hardhat/hardhat.config.js +136 -0
  35. package/hardhat/ignition/modules/ObjectLayerToken.js +21 -0
  36. package/hardhat/networks/besu-object-layer.network.json +138 -0
  37. package/hardhat/package-lock.json +4323 -0
  38. package/hardhat/package.json +36 -0
  39. package/hardhat/scripts/deployObjectLayerToken.js +98 -0
  40. package/hardhat/test/ObjectLayerToken.js +592 -0
  41. package/hardhat/types/ethers-contracts/ObjectLayerToken.ts +690 -0
  42. package/hardhat/types/ethers-contracts/common.ts +92 -0
  43. package/hardhat/types/ethers-contracts/factories/ObjectLayerToken__factory.ts +1055 -0
  44. package/hardhat/types/ethers-contracts/factories/index.ts +4 -0
  45. package/hardhat/types/ethers-contracts/hardhat.d.ts +47 -0
  46. package/hardhat/types/ethers-contracts/index.ts +6 -0
  47. package/jsdoc.dd-cyberia.json +68 -0
  48. package/jsdoc.json +65 -49
  49. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +5 -4
  50. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +5 -4
  51. package/manifests/deployment/dd-cyberia-development/deployment.yaml +562 -0
  52. package/manifests/deployment/dd-cyberia-development/proxy.yaml +297 -0
  53. package/manifests/deployment/dd-cyberia-development/pv-pvc.yaml +132 -0
  54. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  55. package/manifests/deployment/dd-test-development/deployment.yaml +88 -74
  56. package/manifests/deployment/dd-test-development/proxy.yaml +13 -4
  57. package/manifests/deployment/playwright/deployment.yaml +1 -1
  58. package/manifests/pv-pvc-dd.yaml +1 -1
  59. package/nodemon.json +1 -1
  60. package/package.json +60 -48
  61. package/proxy.yaml +118 -10
  62. package/pv-pvc.yaml +132 -0
  63. package/scripts/k3s-node-setup.sh +1 -1
  64. package/scripts/ports-ls.sh +2 -0
  65. package/scripts/rhel-grpc-setup.sh +56 -0
  66. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +47 -1
  67. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +17 -2
  68. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +5 -0
  69. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +80 -7
  70. package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +93 -0
  71. package/src/api/cyberia-dialogue/cyberia-dialogue.model.js +36 -0
  72. package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +29 -0
  73. package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +51 -0
  74. package/src/api/cyberia-entity/cyberia-entity.controller.js +74 -0
  75. package/src/api/cyberia-entity/cyberia-entity.model.js +24 -0
  76. package/src/api/cyberia-entity/cyberia-entity.router.js +27 -0
  77. package/src/api/cyberia-entity/cyberia-entity.service.js +42 -0
  78. package/src/api/cyberia-instance/cyberia-fallback-world.js +368 -0
  79. package/src/api/cyberia-instance/cyberia-instance.controller.js +92 -0
  80. package/src/api/cyberia-instance/cyberia-instance.model.js +84 -0
  81. package/src/api/cyberia-instance/cyberia-instance.router.js +63 -0
  82. package/src/api/cyberia-instance/cyberia-instance.service.js +191 -0
  83. package/src/api/cyberia-instance/cyberia-portal-connector.js +486 -0
  84. package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +74 -0
  85. package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +413 -0
  86. package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +228 -0
  87. package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +27 -0
  88. package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +42 -0
  89. package/src/api/cyberia-map/cyberia-map.controller.js +79 -0
  90. package/src/api/cyberia-map/cyberia-map.model.js +30 -0
  91. package/src/api/cyberia-map/cyberia-map.router.js +40 -0
  92. package/src/api/cyberia-map/cyberia-map.service.js +74 -0
  93. package/src/api/document/document.service.js +1 -1
  94. package/src/api/file/file.controller.js +3 -1
  95. package/src/api/file/file.ref.json +18 -0
  96. package/src/api/file/file.service.js +28 -5
  97. package/src/api/ipfs/ipfs.controller.js +4 -25
  98. package/src/api/ipfs/ipfs.model.js +43 -34
  99. package/src/api/ipfs/ipfs.router.js +8 -13
  100. package/src/api/ipfs/ipfs.service.js +56 -104
  101. package/src/api/object-layer/README.md +347 -22
  102. package/src/api/object-layer/object-layer.controller.js +6 -2
  103. package/src/api/object-layer/object-layer.model.js +12 -8
  104. package/src/api/object-layer/object-layer.router.js +698 -42
  105. package/src/api/object-layer/object-layer.service.js +119 -37
  106. package/src/api/object-layer-render-frames/object-layer-render-frames.model.js +1 -2
  107. package/src/api/user/user.router.js +10 -5
  108. package/src/api/user/user.service.js +15 -14
  109. package/src/cli/baremetal.js +6 -10
  110. package/src/cli/cloud-init.js +0 -3
  111. package/src/cli/cluster.js +7 -7
  112. package/src/cli/db.js +723 -857
  113. package/src/cli/deploy.js +215 -105
  114. package/src/cli/env.js +34 -5
  115. package/src/cli/fs.js +5 -4
  116. package/src/cli/image.js +0 -3
  117. package/src/cli/index.js +83 -15
  118. package/src/cli/kubectl.js +211 -0
  119. package/src/cli/monitor.js +5 -6
  120. package/src/cli/release.js +284 -0
  121. package/src/cli/repository.js +708 -62
  122. package/src/cli/run.js +371 -151
  123. package/src/cli/secrets.js +73 -2
  124. package/src/cli/ssh.js +1 -1
  125. package/src/cli/test.js +3 -3
  126. package/src/client/Cryptokoyn.index.js +3 -4
  127. package/src/client/CyberiaPortal.index.js +3 -4
  128. package/src/client/Default.index.js +3 -4
  129. package/src/client/Itemledger.index.js +4 -963
  130. package/src/client/Underpost.index.js +3 -4
  131. package/src/client/components/core/AgGrid.js +20 -5
  132. package/src/client/components/core/Alert.js +2 -2
  133. package/src/client/components/core/AppStore.js +69 -0
  134. package/src/client/components/core/CalendarCore.js +2 -2
  135. package/src/client/components/core/Content.js +22 -3
  136. package/src/client/components/core/Docs.js +30 -6
  137. package/src/client/components/core/DropDown.js +137 -17
  138. package/src/client/components/core/FileExplorer.js +71 -4
  139. package/src/client/components/core/Input.js +1 -1
  140. package/src/client/components/core/Keyboard.js +2 -2
  141. package/src/client/components/core/LogIn.js +2 -2
  142. package/src/client/components/core/LogOut.js +2 -2
  143. package/src/client/components/core/Modal.js +20 -7
  144. package/src/client/components/core/Panel.js +0 -1
  145. package/src/client/components/core/PanelForm.js +19 -19
  146. package/src/client/components/core/RichText.js +1 -2
  147. package/src/client/components/core/SocketIo.js +82 -29
  148. package/src/client/components/core/SocketIoHandler.js +75 -0
  149. package/src/client/components/core/Stream.js +143 -95
  150. package/src/client/components/core/Webhook.js +40 -7
  151. package/src/client/components/cryptokoyn/AppStoreCryptokoyn.js +5 -0
  152. package/src/client/components/cryptokoyn/LogInCryptokoyn.js +3 -3
  153. package/src/client/components/cryptokoyn/LogOutCryptokoyn.js +2 -2
  154. package/src/client/components/cryptokoyn/MenuCryptokoyn.js +3 -3
  155. package/src/client/components/cryptokoyn/SocketIoCryptokoyn.js +3 -51
  156. package/src/client/components/cyberia/InstanceEngineCyberia.js +700 -0
  157. package/src/client/components/cyberia/MapEngineCyberia.js +1359 -2
  158. package/src/client/components/cyberia/ObjectLayerEngineModal.js +17 -6
  159. package/src/client/components/cyberia/ObjectLayerEngineViewer.js +92 -54
  160. package/src/client/components/cyberia-portal/AppStoreCyberiaPortal.js +5 -0
  161. package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +217 -30
  162. package/src/client/components/cyberia-portal/CssCyberiaPortal.js +44 -2
  163. package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +3 -4
  164. package/src/client/components/cyberia-portal/LogOutCyberiaPortal.js +2 -2
  165. package/src/client/components/cyberia-portal/MenuCyberiaPortal.js +104 -9
  166. package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +5 -0
  167. package/src/client/components/cyberia-portal/SocketIoCyberiaPortal.js +3 -49
  168. package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -0
  169. package/src/client/components/default/AppStoreDefault.js +5 -0
  170. package/src/client/components/default/LogInDefault.js +3 -3
  171. package/src/client/components/default/LogOutDefault.js +2 -2
  172. package/src/client/components/default/MenuDefault.js +5 -5
  173. package/src/client/components/default/SocketIoDefault.js +3 -51
  174. package/src/client/components/itemledger/AppStoreItemledger.js +5 -0
  175. package/src/client/components/itemledger/LogInItemledger.js +3 -3
  176. package/src/client/components/itemledger/LogOutItemledger.js +2 -2
  177. package/src/client/components/itemledger/MenuItemledger.js +3 -3
  178. package/src/client/components/itemledger/SocketIoItemledger.js +3 -51
  179. package/src/client/components/underpost/AppStoreUnderpost.js +5 -0
  180. package/src/client/components/underpost/CssUnderpost.js +59 -0
  181. package/src/client/components/underpost/LogInUnderpost.js +6 -3
  182. package/src/client/components/underpost/LogOutUnderpost.js +4 -2
  183. package/src/client/components/underpost/MenuUnderpost.js +104 -18
  184. package/src/client/components/underpost/RoutesUnderpost.js +2 -0
  185. package/src/client/components/underpost/SocketIoUnderpost.js +3 -51
  186. package/src/client/public/cryptokoyn/assets/logo/base-icon.png +0 -0
  187. package/src/client/public/cryptokoyn/browserconfig.xml +12 -0
  188. package/src/client/public/cryptokoyn/microdata.json +85 -0
  189. package/src/client/public/cryptokoyn/site.webmanifest +57 -0
  190. package/src/client/public/cryptokoyn/sitemap +3 -3
  191. package/src/client/public/default/sitemap +3 -3
  192. package/src/client/public/itemledger/browserconfig.xml +2 -2
  193. package/src/client/public/itemledger/manifest.webmanifest +4 -4
  194. package/src/client/public/itemledger/microdata.json +71 -0
  195. package/src/client/public/itemledger/sitemap +3 -3
  196. package/src/client/public/itemledger/yandex-browser-manifest.json +2 -2
  197. package/src/client/public/test/sitemap +3 -3
  198. package/src/client/services/core/core.service.js +20 -8
  199. package/src/client/services/cyberia-dialogue/cyberia-dialogue.service.js +105 -0
  200. package/src/client/services/cyberia-entity/cyberia-entity.management.js +57 -0
  201. package/src/client/services/cyberia-entity/cyberia-entity.service.js +105 -0
  202. package/src/client/services/cyberia-instance/cyberia-instance.management.js +194 -0
  203. package/src/client/services/cyberia-instance/cyberia-instance.service.js +122 -0
  204. package/src/client/services/cyberia-instance-conf/cyberia-instance-conf.service.js +105 -0
  205. package/src/client/services/cyberia-map/cyberia-map.management.js +193 -0
  206. package/src/client/services/cyberia-map/cyberia-map.service.js +126 -0
  207. package/src/client/services/instance/instance.management.js +2 -2
  208. package/src/client/services/ipfs/ipfs.service.js +3 -23
  209. package/src/client/services/object-layer/object-layer.management.js +3 -3
  210. package/src/client/services/object-layer/object-layer.service.js +21 -0
  211. package/src/client/services/user/user.management.js +2 -2
  212. package/src/client/ssr/body/404.js +15 -11
  213. package/src/client/ssr/body/500.js +15 -11
  214. package/src/client/ssr/body/SwaggerDarkMode.js +285 -0
  215. package/src/client/ssr/head/PwaItemledger.js +60 -0
  216. package/src/client/ssr/offline/NoNetworkConnection.js +11 -10
  217. package/src/client/ssr/pages/CyberiaServerMetrics.js +1 -1
  218. package/src/client/ssr/pages/Test.js +11 -10
  219. package/src/client.build.js +0 -3
  220. package/src/client.dev.js +0 -3
  221. package/src/db/DataBaseProvider.js +17 -2
  222. package/src/db/mariadb/MariaDB.js +14 -9
  223. package/src/db/mongo/MongooseDB.js +17 -1
  224. package/src/grpc/cyberia/OFF_CHAIN_ECONOMY.md +305 -0
  225. package/src/grpc/cyberia/README.md +326 -0
  226. package/src/grpc/cyberia/grpc-server.js +530 -0
  227. package/src/index.js +24 -1
  228. package/src/proxy.js +0 -3
  229. package/src/runtime/express/Dockerfile +4 -0
  230. package/src/runtime/express/Express.js +33 -10
  231. package/src/runtime/lampp/Dockerfile +13 -2
  232. package/src/runtime/lampp/Lampp.js +33 -17
  233. package/src/runtime/wp/Dockerfile +68 -0
  234. package/src/runtime/wp/Wp.js +639 -0
  235. package/src/server/auth.js +36 -15
  236. package/src/server/backup.js +39 -12
  237. package/src/server/besu-genesis-generator.js +1630 -0
  238. package/src/server/client-build-docs.js +133 -17
  239. package/src/server/client-build-live.js +9 -18
  240. package/src/server/client-build.js +229 -101
  241. package/src/server/client-dev-server.js +14 -13
  242. package/src/server/client-formatted.js +109 -57
  243. package/src/server/conf.js +391 -164
  244. package/src/server/cron.js +27 -24
  245. package/src/server/dns.js +29 -12
  246. package/src/server/downloader.js +0 -2
  247. package/src/server/ipfs-client.js +24 -1
  248. package/src/server/logger.js +27 -9
  249. package/src/server/object-layer.js +217 -103
  250. package/src/server/peer.js +8 -2
  251. package/src/server/process.js +1 -50
  252. package/src/server/proxy.js +4 -8
  253. package/src/server/runtime.js +30 -9
  254. package/src/server/semantic-layer-generator-floor.js +359 -0
  255. package/src/server/semantic-layer-generator-skin.js +1294 -0
  256. package/src/server/semantic-layer-generator.js +116 -555
  257. package/src/server/ssr.js +0 -3
  258. package/src/server/start.js +19 -12
  259. package/src/server/tls.js +0 -2
  260. package/src/server.js +0 -4
  261. package/src/ws/IoInterface.js +1 -10
  262. package/src/ws/IoServer.js +14 -33
  263. package/src/ws/core/channels/core.ws.chat.js +65 -20
  264. package/src/ws/core/channels/core.ws.mailer.js +113 -32
  265. package/src/ws/core/channels/core.ws.stream.js +90 -31
  266. package/src/ws/core/core.ws.connection.js +12 -33
  267. package/src/ws/core/core.ws.emit.js +10 -26
  268. package/src/ws/core/core.ws.server.js +25 -58
  269. package/src/ws/default/channels/default.ws.main.js +53 -12
  270. package/src/ws/default/default.ws.connection.js +26 -13
  271. package/src/ws/default/default.ws.server.js +30 -12
  272. package/.env.development +0 -43
  273. package/.env.test +0 -43
  274. package/hardhat/contracts/CryptoKoyn.sol +0 -59
  275. package/hardhat/contracts/ItemLedger.sol +0 -73
  276. package/hardhat/contracts/Lock.sol +0 -34
  277. package/hardhat/hardhat.config.cjs +0 -45
  278. package/hardhat/ignition/modules/Lock.js +0 -18
  279. package/hardhat/networks/cryptokoyn-itemledger.network.json +0 -29
  280. package/hardhat/scripts/deployCryptokoyn.cjs +0 -25
  281. package/hardhat/scripts/deployItemledger.cjs +0 -25
  282. package/hardhat/test/Lock.js +0 -126
  283. package/hardhat/white-paper.md +0 -581
  284. package/src/client/components/cryptokoyn/CommonCryptokoyn.js +0 -29
  285. package/src/client/components/cryptokoyn/ElementsCryptokoyn.js +0 -38
  286. package/src/client/components/cyberia-portal/ElementsCyberiaPortal.js +0 -38
  287. package/src/client/components/default/ElementsDefault.js +0 -38
  288. package/src/client/components/itemledger/CommonItemledger.js +0 -29
  289. package/src/client/components/itemledger/ElementsItemledger.js +0 -38
  290. package/src/client/components/underpost/CommonUnderpost.js +0 -29
  291. package/src/client/components/underpost/ElementsUnderpost.js +0 -38
  292. package/src/ws/core/management/core.ws.chat.js +0 -8
  293. package/src/ws/core/management/core.ws.mailer.js +0 -16
  294. package/src/ws/core/management/core.ws.stream.js +0 -8
  295. package/src/ws/default/management/default.ws.main.js +0 -8
  296. package/white-paper.md +0 -581
@@ -0,0 +1,391 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Compatible with OpenZeppelin Contracts ^5.0.0
3
+ pragma solidity ^0.8.20;
4
+
5
+ import '@openzeppelin/contracts/token/ERC1155/ERC1155.sol';
6
+ import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol';
7
+ import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol';
8
+ import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol';
9
+ import '@openzeppelin/contracts/access/Ownable.sol';
10
+
11
+ /**
12
+ * @title ObjectLayerToken
13
+ * @dev A unified ERC-1155 multi-token contract for the Cyberia Online Object Layer ecosystem.
14
+ *
15
+ * A single ERC-1155 contract that represents both fungible and non-fungible tokens
16
+ * within the Object Layer paradigm.
17
+ *
18
+ * Token ID semantics:
19
+ * - Token ID 0 (CRYPTOKOYN): Fungible in-game currency.
20
+ * Minted with 18-decimal supply; divisible and stackable.
21
+ * - Token IDs >= 1: Object Layer item tokens. Each token ID is derived from
22
+ * `uint256(keccak256(abi.encodePacked(namespace, itemId)))`.
23
+ * - Supply of 1 → non-fungible (unique gear).
24
+ * - Supply > 1 → semi-fungible (stackable resources, consumables).
25
+ *
26
+ * Object Layer mapping:
27
+ * Each on-chain token ID corresponds to an off-chain ObjectLayer document whose
28
+ * `data.ledger` field references this contract:
29
+ * {
30
+ * "type": "ERC-1155",
31
+ * "address": "<this contract address>",
32
+ * "tokenId": "<uint256 token id>"
33
+ * }
34
+ *
35
+ * The token URI resolves to `ipfs://{metadataCid}/{tokenId}.json` where
36
+ * metadataCid is the IPFS CID stored in `data.render.metadataCid`.
37
+ *
38
+ * Features:
39
+ * - Mint / batch-mint (owner only) — register new Object Layer items on-chain.
40
+ * - Burn / batch-burn — holders can destroy tokens.
41
+ * - Pause / unpause — owner can freeze all transfers (emergency governance).
42
+ * - Supply tracking — on-chain total supply per token ID via ERC1155Supply.
43
+ * - On-chain item registry — maps token IDs to IPFS metadata CIDs and item identifiers.
44
+ *
45
+ * Designed for deployment on Hyperledger Besu (IBFT2/QBFT) private networks via Hardhat.
46
+ */
47
+ contract ObjectLayerToken is ERC1155, ERC1155Burnable, ERC1155Pausable, ERC1155Supply, Ownable {
48
+ // ──────────────────────────────────────────────────────────────────────
49
+ // Constants
50
+ // ──────────────────────────────────────────────────────────────────────
51
+
52
+ /**
53
+ * @dev Token ID 0 is the fungible in-game currency (CryptoKoyn / CKY equivalent).
54
+ */
55
+ uint256 public constant CRYPTOKOYN = 0;
56
+
57
+ /**
58
+ * @dev Initial fungible supply minted to the deployer (10 million with 18 decimals).
59
+ */
60
+ uint256 public constant INITIAL_CRYPTOKOYN_SUPPLY = 10_000_000 * 1e18;
61
+
62
+ // ──────────────────────────────────────────────────────────────────────
63
+ // State
64
+ // ──────────────────────────────────────────────────────────────────────
65
+
66
+ /**
67
+ * @dev Base URI prefix for token metadata (e.g. "ipfs://").
68
+ */
69
+ string private _baseTokenURI;
70
+
71
+ /**
72
+ * @dev Per-token-ID metadata CID override. When set, the full URI becomes
73
+ * `{_baseTokenURI}{_tokenCIDs[id]}`.
74
+ */
75
+ mapping(uint256 => string) private _tokenCIDs;
76
+
77
+ /**
78
+ * @dev Human-readable item identifier for each registered token ID.
79
+ * Maps tokenId → itemId string (e.g. "hatchet", "gold-ore").
80
+ */
81
+ mapping(uint256 => string) private _itemIds;
82
+
83
+ /**
84
+ * @dev Reverse lookup: keccak256(itemId) → tokenId. Used to prevent duplicate registrations.
85
+ */
86
+ mapping(bytes32 => uint256) private _itemIdToTokenId;
87
+
88
+ /**
89
+ * @dev Counter tracking the next sequential token ID for auto-registration.
90
+ * Starts at 1 because token ID 0 is reserved for CRYPTOKOYN.
91
+ */
92
+ uint256 private _nextTokenId;
93
+
94
+ // ──────────────────────────────────────────────────────────────────────
95
+ // Events
96
+ // ──────────────────────────────────────────────────────────────────────
97
+
98
+ /**
99
+ * @dev Emitted when a new Object Layer item is registered on-chain.
100
+ * @param tokenId The ERC-1155 token ID assigned to this item.
101
+ * @param itemId The human-readable item identifier (e.g. "hatchet").
102
+ * @param metadataCid The IPFS CID pointing to the item's metadata JSON.
103
+ * @param initialSupply The number of tokens minted in the registration transaction.
104
+ */
105
+ event ObjectLayerRegistered(uint256 indexed tokenId, string itemId, string metadataCid, uint256 initialSupply);
106
+
107
+ /**
108
+ * @dev Emitted when a token's metadata CID is updated.
109
+ * @param tokenId The ERC-1155 token ID whose metadata was updated.
110
+ * @param metadataCid The new IPFS CID.
111
+ */
112
+ event MetadataUpdated(uint256 indexed tokenId, string metadataCid);
113
+
114
+ // ──────────────────────────────────────────────────────────────────────
115
+ // Constructor
116
+ // ──────────────────────────────────────────────────────────────────────
117
+
118
+ /**
119
+ * @dev Deploys the contract, mints the initial CryptoKoyn supply to the deployer,
120
+ * and registers token ID 0 as the fungible currency.
121
+ * @param initialOwner The address that will own the contract and receive the initial supply.
122
+ * @param baseURI The base URI prefix for metadata resolution (e.g. "ipfs://").
123
+ */
124
+ constructor(address initialOwner, string memory baseURI) ERC1155(baseURI) Ownable(initialOwner) {
125
+ _baseTokenURI = baseURI;
126
+ _nextTokenId = 1;
127
+
128
+ // Register and mint the fungible currency token
129
+ _itemIds[CRYPTOKOYN] = 'cryptokoyn';
130
+ _itemIdToTokenId[keccak256(abi.encodePacked('cryptokoyn'))] = CRYPTOKOYN;
131
+ _mint(initialOwner, CRYPTOKOYN, INITIAL_CRYPTOKOYN_SUPPLY, '');
132
+
133
+ emit ObjectLayerRegistered(CRYPTOKOYN, 'cryptokoyn', '', INITIAL_CRYPTOKOYN_SUPPLY);
134
+ }
135
+
136
+ // ──────────────────────────────────────────────────────────────────────
137
+ // URI
138
+ // ──────────────────────────────────────────────────────────────────────
139
+
140
+ /**
141
+ * @dev Returns the metadata URI for a given token ID.
142
+ * If a per-token CID is set, returns `{baseURI}{cid}`.
143
+ * Otherwise falls back to the ERC-1155 default `{baseURI}{id}.json`.
144
+ * @param tokenId The token ID to query.
145
+ * @return The full metadata URI string.
146
+ */
147
+ function uri(uint256 tokenId) public view override returns (string memory) {
148
+ string memory tokenCid = _tokenCIDs[tokenId];
149
+ if (bytes(tokenCid).length > 0) {
150
+ return string(abi.encodePacked(_baseTokenURI, tokenCid));
151
+ }
152
+ return super.uri(tokenId);
153
+ }
154
+
155
+ /**
156
+ * @dev Updates the base URI prefix. Only callable by the owner.
157
+ * @param newBaseURI The new base URI string.
158
+ */
159
+ function setBaseURI(string calldata newBaseURI) external onlyOwner {
160
+ _baseTokenURI = newBaseURI;
161
+ _setURI(newBaseURI);
162
+ }
163
+
164
+ /**
165
+ * @dev Sets or updates the IPFS metadata CID for a specific token ID.
166
+ * Only callable by the owner.
167
+ * @param tokenId The token ID to update.
168
+ * @param metadataCid The new IPFS CID string.
169
+ */
170
+ function setTokenMetadataCID(uint256 tokenId, string calldata metadataCid) external onlyOwner {
171
+ _tokenCIDs[tokenId] = metadataCid;
172
+ emit MetadataUpdated(tokenId, metadataCid);
173
+ emit URI(uri(tokenId), tokenId);
174
+ }
175
+
176
+ // ──────────────────────────────────────────────────────────────────────
177
+ // Object Layer Registration
178
+ // ──────────────────────────────────────────────────────────────────────
179
+
180
+ /**
181
+ * @dev Computes the deterministic token ID for a given item identifier.
182
+ * @param itemId The human-readable item identifier string.
183
+ * @return The uint256 token ID derived from keccak256.
184
+ */
185
+ function computeTokenId(string calldata itemId) public pure returns (uint256) {
186
+ return uint256(keccak256(abi.encodePacked('cyberia.object-layer:', itemId)));
187
+ }
188
+
189
+ /**
190
+ * @dev Registers a new Object Layer item on-chain and mints the initial supply.
191
+ * The token ID is deterministically derived from the item identifier.
192
+ * Reverts if the item identifier has already been registered.
193
+ *
194
+ * For unique (non-fungible) items, set `initialSupply` to 1.
195
+ * For stackable (semi-fungible) items, set `initialSupply` > 1.
196
+ *
197
+ * @param to The address to receive the minted tokens.
198
+ * @param itemId The human-readable item identifier (e.g. "hatchet", "gold-ore").
199
+ * @param metadataCid The IPFS CID for the item's metadata JSON.
200
+ * @param initialSupply The number of tokens to mint.
201
+ * @param data Additional data forwarded to the ERC-1155 receiver hook.
202
+ * @return tokenId The assigned ERC-1155 token ID.
203
+ */
204
+ function registerObjectLayer(
205
+ address to,
206
+ string calldata itemId,
207
+ string calldata metadataCid,
208
+ uint256 initialSupply,
209
+ bytes calldata data
210
+ ) external onlyOwner returns (uint256 tokenId) {
211
+ bytes32 itemHash = keccak256(abi.encodePacked(itemId));
212
+ require(
213
+ (_itemIdToTokenId[itemHash] == 0 && bytes(_itemIds[0]).length > 0) || _itemIdToTokenId[itemHash] == 0,
214
+ 'ObjectLayerToken: item already registered'
215
+ );
216
+
217
+ tokenId = computeTokenId(itemId);
218
+
219
+ // Prevent collision with an existing different item at the same hash-derived ID
220
+ require(bytes(_itemIds[tokenId]).length == 0, 'ObjectLayerToken: token ID collision');
221
+
222
+ _itemIds[tokenId] = itemId;
223
+ _itemIdToTokenId[itemHash] = tokenId;
224
+
225
+ if (bytes(metadataCid).length > 0) {
226
+ _tokenCIDs[tokenId] = metadataCid;
227
+ }
228
+
229
+ if (initialSupply > 0) {
230
+ _mint(to, tokenId, initialSupply, data);
231
+ }
232
+
233
+ emit ObjectLayerRegistered(tokenId, itemId, metadataCid, initialSupply);
234
+ }
235
+
236
+ /**
237
+ * @dev Batch-registers multiple Object Layer items in a single transaction.
238
+ * @param to The address to receive all minted tokens.
239
+ * @param itemIds Array of human-readable item identifiers.
240
+ * @param metadataCids Array of IPFS CIDs for each item's metadata.
241
+ * @param supplies Array of initial supply amounts for each item.
242
+ * @param data Additional data forwarded to the ERC-1155 receiver hook.
243
+ * @return tokenIds Array of assigned ERC-1155 token IDs.
244
+ */
245
+ function batchRegisterObjectLayers(
246
+ address to,
247
+ string[] calldata itemIds,
248
+ string[] calldata metadataCids,
249
+ uint256[] calldata supplies,
250
+ bytes calldata data
251
+ ) external onlyOwner returns (uint256[] memory tokenIds) {
252
+ require(
253
+ itemIds.length == metadataCids.length && itemIds.length == supplies.length,
254
+ 'ObjectLayerToken: array length mismatch'
255
+ );
256
+
257
+ tokenIds = new uint256[](itemIds.length);
258
+ uint256[] memory mintIds = new uint256[](itemIds.length);
259
+ uint256[] memory mintAmounts = new uint256[](itemIds.length);
260
+
261
+ for (uint256 i = 0; i < itemIds.length; i++) {
262
+ uint256 tokenId = computeTokenId(itemIds[i]);
263
+
264
+ require(bytes(_itemIds[tokenId]).length == 0, 'ObjectLayerToken: item already registered or token ID collision');
265
+
266
+ bytes32 itemHash = keccak256(abi.encodePacked(itemIds[i]));
267
+ _itemIds[tokenId] = itemIds[i];
268
+ _itemIdToTokenId[itemHash] = tokenId;
269
+
270
+ if (bytes(metadataCids[i]).length > 0) {
271
+ _tokenCIDs[tokenId] = metadataCids[i];
272
+ }
273
+
274
+ tokenIds[i] = tokenId;
275
+ mintIds[i] = tokenId;
276
+ mintAmounts[i] = supplies[i];
277
+
278
+ emit ObjectLayerRegistered(tokenId, itemIds[i], metadataCids[i], supplies[i]);
279
+ }
280
+
281
+ _mintBatch(to, mintIds, mintAmounts, data);
282
+ }
283
+
284
+ // ──────────────────────────────────────────────────────────────────────
285
+ // Minting (additional supply for existing tokens)
286
+ // ──────────────────────────────────────────────────────────────────────
287
+
288
+ /**
289
+ * @dev Mints additional supply for an existing token ID. Only callable by the owner.
290
+ * @param to The address to receive the minted tokens.
291
+ * @param tokenId The token ID to mint.
292
+ * @param amount The number of tokens to mint.
293
+ * @param data Additional data forwarded to the ERC-1155 receiver hook.
294
+ */
295
+ function mint(address to, uint256 tokenId, uint256 amount, bytes calldata data) external onlyOwner {
296
+ _mint(to, tokenId, amount, data);
297
+ }
298
+
299
+ /**
300
+ * @dev Batch-mints additional supply for multiple existing token IDs.
301
+ * Only callable by the owner.
302
+ * @param to The address to receive all minted tokens.
303
+ * @param ids Array of token IDs.
304
+ * @param amounts Array of amounts to mint for each token ID.
305
+ * @param data Additional data forwarded to the ERC-1155 receiver hook.
306
+ */
307
+ function mintBatch(
308
+ address to,
309
+ uint256[] calldata ids,
310
+ uint256[] calldata amounts,
311
+ bytes calldata data
312
+ ) external onlyOwner {
313
+ _mintBatch(to, ids, amounts, data);
314
+ }
315
+
316
+ // ──────────────────────────────────────────────────────────────────────
317
+ // Pause / Unpause
318
+ // ──────────────────────────────────────────────────────────────────────
319
+
320
+ /**
321
+ * @dev Pauses all token transfers. Only callable by the owner.
322
+ * Used for emergency governance or maintenance windows.
323
+ */
324
+ function pause() external onlyOwner {
325
+ _pause();
326
+ }
327
+
328
+ /**
329
+ * @dev Unpauses all token transfers. Only callable by the owner.
330
+ */
331
+ function unpause() external onlyOwner {
332
+ _unpause();
333
+ }
334
+
335
+ // ──────────────────────────────────────────────────────────────────────
336
+ // Query helpers
337
+ // ──────────────────────────────────────────────────────────────────────
338
+
339
+ /**
340
+ * @dev Returns the item identifier for a given token ID.
341
+ * @param tokenId The token ID to look up.
342
+ * @return The human-readable item identifier string.
343
+ */
344
+ function getItemId(uint256 tokenId) external view returns (string memory) {
345
+ return _itemIds[tokenId];
346
+ }
347
+
348
+ /**
349
+ * @dev Returns the token ID for a given item identifier.
350
+ * @param itemId The human-readable item identifier.
351
+ * @return The ERC-1155 token ID (0 if not registered, but 0 is also CRYPTOKOYN).
352
+ */
353
+ function getTokenIdByItemId(string calldata itemId) external view returns (uint256) {
354
+ return _itemIdToTokenId[keccak256(abi.encodePacked(itemId))];
355
+ }
356
+
357
+ /**
358
+ * @dev Returns the IPFS metadata CID for a given token ID.
359
+ * @param tokenId The token ID to look up.
360
+ * @return The IPFS CID string (empty if not set).
361
+ */
362
+ function getMetadataCID(uint256 tokenId) external view returns (string memory) {
363
+ return _tokenCIDs[tokenId];
364
+ }
365
+
366
+ /**
367
+ * @dev Returns the next auto-incremented token ID (informational only;
368
+ * `registerObjectLayer` uses deterministic IDs from keccak256).
369
+ */
370
+ function nextTokenId() external view returns (uint256) {
371
+ return _nextTokenId;
372
+ }
373
+
374
+ // ──────────────────────────────────────────────────────────────────────
375
+ // Internal overrides required by Solidity
376
+ // ──────────────────────────────────────────────────────────────────────
377
+
378
+ /**
379
+ * @dev Hook that is called before any token transfer. Ensures both
380
+ * ERC1155Pausable (transfer-blocking when paused) and ERC1155Supply
381
+ * (total supply tracking) logic execute correctly.
382
+ */
383
+ function _update(
384
+ address from,
385
+ address to,
386
+ uint256[] memory ids,
387
+ uint256[] memory values
388
+ ) internal override(ERC1155, ERC1155Pausable, ERC1155Supply) {
389
+ super._update(from, to, ids, values);
390
+ }
391
+ }
File without changes
@@ -0,0 +1,11 @@
1
+ {
2
+ "network": "hardhat",
3
+ "chainId": "31337",
4
+ "contract": "ObjectLayerToken",
5
+ "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
6
+ "deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
7
+ "baseURI": "ipfs://",
8
+ "cryptokoynTokenId": "0",
9
+ "initialCryptokoynSupply": "10000000000000000000000000",
10
+ "timestamp": "2026-03-08T01:11:37.978Z"
11
+ }
@@ -0,0 +1,136 @@
1
+ // hardhat.config.js
2
+ // Hardhat configuration for the Cyberia Online Object Layer ERC-1155 ecosystem.
3
+ // Supports deployment to Hyperledger Besu (IBFT2/QBFT) private networks
4
+ // running on kubeadm-managed Kubernetes clusters (manifests/besu/).
5
+ //
6
+ // Compatible with: Hardhat 3.x + Ethers v6 + hardhat-toolbox-mocha-ethers
7
+
8
+ import { defineConfig } from 'hardhat/config';
9
+ import hardhatToolboxMochaEthers from '@nomicfoundation/hardhat-toolbox-mocha-ethers';
10
+ import dotenv from 'dotenv';
11
+ import fs from 'fs-extra';
12
+ import path from 'path';
13
+ import { fileURLToPath } from 'url';
14
+
15
+ dotenv.config();
16
+
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = path.dirname(__filename);
19
+
20
+ // ──────────────────────────────────────────────────────────────────────────────
21
+ // Helper: safely read a private key file, falling back to a dummy key for
22
+ // compilation-only workflows (tests on hardhat network, etc.).
23
+ // ──────────────────────────────────────────────────────────────────────────────
24
+ const DUMMY_PRIVATE_KEY = '0x' + 'ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
25
+
26
+ function readPrivateKey(relPath) {
27
+ try {
28
+ const abs = path.resolve(__dirname, relPath);
29
+ if (fs.existsSync(abs)) {
30
+ const raw = fs.readFileSync(abs, 'utf8').trim();
31
+ return raw.startsWith('0x') ? raw : `0x${raw}`;
32
+ }
33
+ } catch (_) {
34
+ // fall through
35
+ }
36
+ return DUMMY_PRIVATE_KEY;
37
+ }
38
+
39
+ // Read the coinbase private key used for Besu network deployments
40
+ const coinbaseKey = readPrivateKey('../engine-private/eth-networks/besu/coinbase');
41
+
42
+ // ──────────────────────────────────────────────────────────────────────────────
43
+ // Configuration
44
+ // ──────────────────────────────────────────────────────────────────────────────
45
+
46
+ /** @type import('hardhat/config').HardhatUserConfig */
47
+ const config = defineConfig({
48
+ plugins: [hardhatToolboxMochaEthers],
49
+
50
+ // ── Solidity ────────────────────────────────────────────────────────────────
51
+ solidity: {
52
+ version: '0.8.27',
53
+ settings: {
54
+ optimizer: {
55
+ enabled: true,
56
+ runs: 200,
57
+ },
58
+ evmVersion: 'cancun',
59
+ },
60
+ },
61
+
62
+ // ── Networks ────────────────────────────────────────────────────────────
63
+ //
64
+ // Hyperledger Besu private networks use IBFT2 or QBFT consensus.
65
+ // The RPC endpoints below correspond to the Kubernetes services defined in
66
+ // manifests/besu/ (deployed via `underpost cluster --besu` or `cyberia chain deploy`).
67
+ //
68
+ // Default to 'hardhat' for local testing; use 'besu-k8s' for kubeadm cluster deployments.
69
+ defaultNetwork: 'hardhat',
70
+
71
+ networks: {
72
+ // Local Hardhat in-process network (for testing)
73
+ hardhat: {
74
+ type: 'edr-simulated',
75
+ },
76
+
77
+ // ── Besu IBFT2 – direct RPC (e.g. port-forward or in-cluster access) ───
78
+ // Connects to the first validator JSON-RPC endpoint directly.
79
+ 'besu-ibft2': {
80
+ type: 'http',
81
+ url: process.env.BESU_IBFT2_RPC_URL || 'http://127.0.0.1:8545',
82
+ accounts: [coinbaseKey],
83
+ chainId: parseInt(process.env.BESU_IBFT2_CHAIN_ID || '777771', 10),
84
+ // Besu-specific: gas price is typically 0 on private permissioned networks
85
+ gasPrice: 0,
86
+ // Timeout for JSON-RPC requests (Besu can be slow on first blocks)
87
+ timeout: 120000,
88
+ },
89
+
90
+ // ── Besu QBFT – direct RPC (e.g. port-forward or in-cluster access) ────
91
+ 'besu-qbft': {
92
+ type: 'http',
93
+ url: process.env.BESU_QBFT_RPC_URL || 'http://127.0.0.1:8545',
94
+ accounts: [coinbaseKey],
95
+ chainId: parseInt(process.env.BESU_QBFT_CHAIN_ID || '777771', 10),
96
+ gasPrice: 0,
97
+ timeout: 120000,
98
+ },
99
+
100
+ // ── Besu – kubeadm cluster (NodePort) ───────────────────────────────────
101
+ // Use when deploying from outside the kubeadm cluster via the NodePort
102
+ // service (besu-rpc-nodeport → 30545) defined in manifests/besu/.
103
+ // This is the recommended network for the Cyberia Object Layer ecosystem.
104
+ 'besu-k8s': {
105
+ type: 'http',
106
+ url: process.env.BESU_K8S_RPC_URL || 'http://127.0.0.1:30545',
107
+ accounts: [coinbaseKey],
108
+ chainId: parseInt(process.env.BESU_K8S_CHAIN_ID || '777771', 10),
109
+ gasPrice: 0,
110
+ timeout: 180000,
111
+ },
112
+ },
113
+
114
+ // ── Paths ───────────────────────────────────────────────────────────────────
115
+ paths: {
116
+ sources: './contracts',
117
+ tests: './test',
118
+ cache: './cache',
119
+ artifacts: './artifacts',
120
+ },
121
+
122
+ // ── Gas Reporter ────────────────────────────────────────────────────────────
123
+ gasReporter: {
124
+ enabled: process.env.REPORT_GAS === 'true',
125
+ currency: 'USD',
126
+ outputFile: process.env.GAS_REPORT_FILE || undefined,
127
+ noColors: !!process.env.GAS_REPORT_FILE,
128
+ },
129
+
130
+ // ── Mocha (test runner) ─────────────────────────────────────────────────────
131
+ mocha: {
132
+ timeout: 60000,
133
+ },
134
+ });
135
+
136
+ export default config;
@@ -0,0 +1,21 @@
1
+ // Hardhat Ignition module for deploying the ObjectLayerToken (ERC-1155) contract.
2
+ // Learn more about Hardhat Ignition at https://hardhat.org/ignition
3
+ //
4
+ // Usage:
5
+ // npx hardhat ignition deploy ignition/modules/ObjectLayerToken.js --network besu-ibft2
6
+
7
+ import { buildModule } from '@nomicfoundation/ignition-core';
8
+
9
+ const DEFAULT_BASE_URI = 'ipfs://';
10
+
11
+ export default buildModule('ObjectLayerTokenModule', (m) => {
12
+ // The deployer account is used as the initial owner and receives the CryptoKoyn supply.
13
+ const initialOwner = m.getParameter('initialOwner', m.getAccount(0));
14
+ const baseURI = m.getParameter('baseURI', DEFAULT_BASE_URI);
15
+
16
+ // Deploy the unified ERC-1155 multi-token contract.
17
+ // Constructor: constructor(address initialOwner, string memory baseURI)
18
+ const objectLayerToken = m.contract('ObjectLayerToken', [initialOwner, baseURI]);
19
+
20
+ return { objectLayerToken };
21
+ });