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.
- package/{.env.production → .env.example} +20 -4
- package/.github/workflows/engine-cyberia.cd.yml +43 -10
- package/.github/workflows/engine-cyberia.ci.yml +48 -26
- package/.github/workflows/ghpkg.ci.yml +5 -5
- package/.github/workflows/gitlab.ci.yml +1 -1
- package/.github/workflows/hardhat.ci.yml +82 -0
- package/.github/workflows/npmpkg.ci.yml +60 -14
- package/.github/workflows/publish.ci.yml +26 -7
- package/.github/workflows/publish.cyberia.ci.yml +5 -5
- package/.github/workflows/pwa-microservices-template-page.cd.yml +6 -7
- package/.github/workflows/pwa-microservices-template-test.ci.yml +4 -4
- package/.github/workflows/release.cd.yml +14 -8
- package/.vscode/extensions.json +9 -8
- package/.vscode/settings.json +3 -2
- package/CHANGELOG.md +643 -1
- package/CLI-HELP.md +132 -57
- package/Dockerfile +4 -2
- package/README.md +347 -22
- package/WHITE-PAPER.md +1540 -0
- package/bin/build.js +21 -12
- package/bin/cyberia.js +2640 -106
- package/bin/deploy.js +258 -372
- package/bin/file.js +5 -1
- package/bin/index.js +2640 -106
- package/bin/vs.js +3 -3
- package/conf.js +169 -105
- package/deployment.yaml +236 -20
- package/hardhat/.env.example +31 -0
- package/hardhat/README.md +531 -0
- package/hardhat/WHITE-PAPER.md +1540 -0
- package/hardhat/contracts/ObjectLayerToken.sol +391 -0
- package/hardhat/deployments/.gitkeep +0 -0
- package/hardhat/deployments/hardhat-ObjectLayerToken.json +11 -0
- package/hardhat/hardhat.config.js +136 -0
- package/hardhat/ignition/modules/ObjectLayerToken.js +21 -0
- package/hardhat/networks/besu-object-layer.network.json +138 -0
- package/hardhat/package-lock.json +4323 -0
- package/hardhat/package.json +36 -0
- package/hardhat/scripts/deployObjectLayerToken.js +98 -0
- package/hardhat/test/ObjectLayerToken.js +592 -0
- package/hardhat/types/ethers-contracts/ObjectLayerToken.ts +690 -0
- package/hardhat/types/ethers-contracts/common.ts +92 -0
- package/hardhat/types/ethers-contracts/factories/ObjectLayerToken__factory.ts +1055 -0
- package/hardhat/types/ethers-contracts/factories/index.ts +4 -0
- package/hardhat/types/ethers-contracts/hardhat.d.ts +47 -0
- package/hardhat/types/ethers-contracts/index.ts +6 -0
- package/jsdoc.dd-cyberia.json +68 -0
- package/jsdoc.json +65 -49
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +5 -4
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +5 -4
- package/manifests/deployment/dd-cyberia-development/deployment.yaml +562 -0
- package/manifests/deployment/dd-cyberia-development/proxy.yaml +297 -0
- package/manifests/deployment/dd-cyberia-development/pv-pvc.yaml +132 -0
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +88 -74
- package/manifests/deployment/dd-test-development/proxy.yaml +13 -4
- package/manifests/deployment/playwright/deployment.yaml +1 -1
- package/manifests/pv-pvc-dd.yaml +1 -1
- package/nodemon.json +1 -1
- package/package.json +60 -48
- package/proxy.yaml +118 -10
- package/pv-pvc.yaml +132 -0
- package/scripts/k3s-node-setup.sh +1 -1
- package/scripts/ports-ls.sh +2 -0
- package/scripts/rhel-grpc-setup.sh +56 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +47 -1
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +17 -2
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +5 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +80 -7
- package/src/api/cyberia-dialogue/cyberia-dialogue.controller.js +93 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.model.js +36 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +29 -0
- package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +51 -0
- package/src/api/cyberia-entity/cyberia-entity.controller.js +74 -0
- package/src/api/cyberia-entity/cyberia-entity.model.js +24 -0
- package/src/api/cyberia-entity/cyberia-entity.router.js +27 -0
- package/src/api/cyberia-entity/cyberia-entity.service.js +42 -0
- package/src/api/cyberia-instance/cyberia-fallback-world.js +368 -0
- package/src/api/cyberia-instance/cyberia-instance.controller.js +92 -0
- package/src/api/cyberia-instance/cyberia-instance.model.js +84 -0
- package/src/api/cyberia-instance/cyberia-instance.router.js +63 -0
- package/src/api/cyberia-instance/cyberia-instance.service.js +191 -0
- package/src/api/cyberia-instance/cyberia-portal-connector.js +486 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.controller.js +74 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +413 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +228 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +27 -0
- package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +42 -0
- package/src/api/cyberia-map/cyberia-map.controller.js +79 -0
- package/src/api/cyberia-map/cyberia-map.model.js +30 -0
- package/src/api/cyberia-map/cyberia-map.router.js +40 -0
- package/src/api/cyberia-map/cyberia-map.service.js +74 -0
- package/src/api/document/document.service.js +1 -1
- package/src/api/file/file.controller.js +3 -1
- package/src/api/file/file.ref.json +18 -0
- package/src/api/file/file.service.js +28 -5
- package/src/api/ipfs/ipfs.controller.js +4 -25
- package/src/api/ipfs/ipfs.model.js +43 -34
- package/src/api/ipfs/ipfs.router.js +8 -13
- package/src/api/ipfs/ipfs.service.js +56 -104
- package/src/api/object-layer/README.md +347 -22
- package/src/api/object-layer/object-layer.controller.js +6 -2
- package/src/api/object-layer/object-layer.model.js +12 -8
- package/src/api/object-layer/object-layer.router.js +698 -42
- package/src/api/object-layer/object-layer.service.js +119 -37
- package/src/api/object-layer-render-frames/object-layer-render-frames.model.js +1 -2
- package/src/api/user/user.router.js +10 -5
- package/src/api/user/user.service.js +15 -14
- package/src/cli/baremetal.js +6 -10
- package/src/cli/cloud-init.js +0 -3
- package/src/cli/cluster.js +7 -7
- package/src/cli/db.js +723 -857
- package/src/cli/deploy.js +215 -105
- package/src/cli/env.js +34 -5
- package/src/cli/fs.js +5 -4
- package/src/cli/image.js +0 -3
- package/src/cli/index.js +83 -15
- package/src/cli/kubectl.js +211 -0
- package/src/cli/monitor.js +5 -6
- package/src/cli/release.js +284 -0
- package/src/cli/repository.js +708 -62
- package/src/cli/run.js +371 -151
- package/src/cli/secrets.js +73 -2
- package/src/cli/ssh.js +1 -1
- package/src/cli/test.js +3 -3
- package/src/client/Cryptokoyn.index.js +3 -4
- package/src/client/CyberiaPortal.index.js +3 -4
- package/src/client/Default.index.js +3 -4
- package/src/client/Itemledger.index.js +4 -963
- package/src/client/Underpost.index.js +3 -4
- package/src/client/components/core/AgGrid.js +20 -5
- package/src/client/components/core/Alert.js +2 -2
- package/src/client/components/core/AppStore.js +69 -0
- package/src/client/components/core/CalendarCore.js +2 -2
- package/src/client/components/core/Content.js +22 -3
- package/src/client/components/core/Docs.js +30 -6
- package/src/client/components/core/DropDown.js +137 -17
- package/src/client/components/core/FileExplorer.js +71 -4
- package/src/client/components/core/Input.js +1 -1
- package/src/client/components/core/Keyboard.js +2 -2
- package/src/client/components/core/LogIn.js +2 -2
- package/src/client/components/core/LogOut.js +2 -2
- package/src/client/components/core/Modal.js +20 -7
- package/src/client/components/core/Panel.js +0 -1
- package/src/client/components/core/PanelForm.js +19 -19
- package/src/client/components/core/RichText.js +1 -2
- package/src/client/components/core/SocketIo.js +82 -29
- package/src/client/components/core/SocketIoHandler.js +75 -0
- package/src/client/components/core/Stream.js +143 -95
- package/src/client/components/core/Webhook.js +40 -7
- package/src/client/components/cryptokoyn/AppStoreCryptokoyn.js +5 -0
- package/src/client/components/cryptokoyn/LogInCryptokoyn.js +3 -3
- package/src/client/components/cryptokoyn/LogOutCryptokoyn.js +2 -2
- package/src/client/components/cryptokoyn/MenuCryptokoyn.js +3 -3
- package/src/client/components/cryptokoyn/SocketIoCryptokoyn.js +3 -51
- package/src/client/components/cyberia/InstanceEngineCyberia.js +700 -0
- package/src/client/components/cyberia/MapEngineCyberia.js +1359 -2
- package/src/client/components/cyberia/ObjectLayerEngineModal.js +17 -6
- package/src/client/components/cyberia/ObjectLayerEngineViewer.js +92 -54
- package/src/client/components/cyberia-portal/AppStoreCyberiaPortal.js +5 -0
- package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +217 -30
- package/src/client/components/cyberia-portal/CssCyberiaPortal.js +44 -2
- package/src/client/components/cyberia-portal/LogInCyberiaPortal.js +3 -4
- package/src/client/components/cyberia-portal/LogOutCyberiaPortal.js +2 -2
- package/src/client/components/cyberia-portal/MenuCyberiaPortal.js +104 -9
- package/src/client/components/cyberia-portal/RoutesCyberiaPortal.js +5 -0
- package/src/client/components/cyberia-portal/SocketIoCyberiaPortal.js +3 -49
- package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +4 -0
- package/src/client/components/default/AppStoreDefault.js +5 -0
- package/src/client/components/default/LogInDefault.js +3 -3
- package/src/client/components/default/LogOutDefault.js +2 -2
- package/src/client/components/default/MenuDefault.js +5 -5
- package/src/client/components/default/SocketIoDefault.js +3 -51
- package/src/client/components/itemledger/AppStoreItemledger.js +5 -0
- package/src/client/components/itemledger/LogInItemledger.js +3 -3
- package/src/client/components/itemledger/LogOutItemledger.js +2 -2
- package/src/client/components/itemledger/MenuItemledger.js +3 -3
- package/src/client/components/itemledger/SocketIoItemledger.js +3 -51
- package/src/client/components/underpost/AppStoreUnderpost.js +5 -0
- package/src/client/components/underpost/CssUnderpost.js +59 -0
- package/src/client/components/underpost/LogInUnderpost.js +6 -3
- package/src/client/components/underpost/LogOutUnderpost.js +4 -2
- package/src/client/components/underpost/MenuUnderpost.js +104 -18
- package/src/client/components/underpost/RoutesUnderpost.js +2 -0
- package/src/client/components/underpost/SocketIoUnderpost.js +3 -51
- package/src/client/public/cryptokoyn/assets/logo/base-icon.png +0 -0
- package/src/client/public/cryptokoyn/browserconfig.xml +12 -0
- package/src/client/public/cryptokoyn/microdata.json +85 -0
- package/src/client/public/cryptokoyn/site.webmanifest +57 -0
- package/src/client/public/cryptokoyn/sitemap +3 -3
- package/src/client/public/default/sitemap +3 -3
- package/src/client/public/itemledger/browserconfig.xml +2 -2
- package/src/client/public/itemledger/manifest.webmanifest +4 -4
- package/src/client/public/itemledger/microdata.json +71 -0
- package/src/client/public/itemledger/sitemap +3 -3
- package/src/client/public/itemledger/yandex-browser-manifest.json +2 -2
- package/src/client/public/test/sitemap +3 -3
- package/src/client/services/core/core.service.js +20 -8
- package/src/client/services/cyberia-dialogue/cyberia-dialogue.service.js +105 -0
- package/src/client/services/cyberia-entity/cyberia-entity.management.js +57 -0
- package/src/client/services/cyberia-entity/cyberia-entity.service.js +105 -0
- package/src/client/services/cyberia-instance/cyberia-instance.management.js +194 -0
- package/src/client/services/cyberia-instance/cyberia-instance.service.js +122 -0
- package/src/client/services/cyberia-instance-conf/cyberia-instance-conf.service.js +105 -0
- package/src/client/services/cyberia-map/cyberia-map.management.js +193 -0
- package/src/client/services/cyberia-map/cyberia-map.service.js +126 -0
- package/src/client/services/instance/instance.management.js +2 -2
- package/src/client/services/ipfs/ipfs.service.js +3 -23
- package/src/client/services/object-layer/object-layer.management.js +3 -3
- package/src/client/services/object-layer/object-layer.service.js +21 -0
- package/src/client/services/user/user.management.js +2 -2
- package/src/client/ssr/body/404.js +15 -11
- package/src/client/ssr/body/500.js +15 -11
- package/src/client/ssr/body/SwaggerDarkMode.js +285 -0
- package/src/client/ssr/head/PwaItemledger.js +60 -0
- package/src/client/ssr/offline/NoNetworkConnection.js +11 -10
- package/src/client/ssr/pages/CyberiaServerMetrics.js +1 -1
- package/src/client/ssr/pages/Test.js +11 -10
- package/src/client.build.js +0 -3
- package/src/client.dev.js +0 -3
- package/src/db/DataBaseProvider.js +17 -2
- package/src/db/mariadb/MariaDB.js +14 -9
- package/src/db/mongo/MongooseDB.js +17 -1
- package/src/grpc/cyberia/OFF_CHAIN_ECONOMY.md +305 -0
- package/src/grpc/cyberia/README.md +326 -0
- package/src/grpc/cyberia/grpc-server.js +530 -0
- package/src/index.js +24 -1
- package/src/proxy.js +0 -3
- package/src/runtime/express/Dockerfile +4 -0
- package/src/runtime/express/Express.js +33 -10
- package/src/runtime/lampp/Dockerfile +13 -2
- package/src/runtime/lampp/Lampp.js +33 -17
- package/src/runtime/wp/Dockerfile +68 -0
- package/src/runtime/wp/Wp.js +639 -0
- package/src/server/auth.js +36 -15
- package/src/server/backup.js +39 -12
- package/src/server/besu-genesis-generator.js +1630 -0
- package/src/server/client-build-docs.js +133 -17
- package/src/server/client-build-live.js +9 -18
- package/src/server/client-build.js +229 -101
- package/src/server/client-dev-server.js +14 -13
- package/src/server/client-formatted.js +109 -57
- package/src/server/conf.js +391 -164
- package/src/server/cron.js +27 -24
- package/src/server/dns.js +29 -12
- package/src/server/downloader.js +0 -2
- package/src/server/ipfs-client.js +24 -1
- package/src/server/logger.js +27 -9
- package/src/server/object-layer.js +217 -103
- package/src/server/peer.js +8 -2
- package/src/server/process.js +1 -50
- package/src/server/proxy.js +4 -8
- package/src/server/runtime.js +30 -9
- package/src/server/semantic-layer-generator-floor.js +359 -0
- package/src/server/semantic-layer-generator-skin.js +1294 -0
- package/src/server/semantic-layer-generator.js +116 -555
- package/src/server/ssr.js +0 -3
- package/src/server/start.js +19 -12
- package/src/server/tls.js +0 -2
- package/src/server.js +0 -4
- package/src/ws/IoInterface.js +1 -10
- package/src/ws/IoServer.js +14 -33
- package/src/ws/core/channels/core.ws.chat.js +65 -20
- package/src/ws/core/channels/core.ws.mailer.js +113 -32
- package/src/ws/core/channels/core.ws.stream.js +90 -31
- package/src/ws/core/core.ws.connection.js +12 -33
- package/src/ws/core/core.ws.emit.js +10 -26
- package/src/ws/core/core.ws.server.js +25 -58
- package/src/ws/default/channels/default.ws.main.js +53 -12
- package/src/ws/default/default.ws.connection.js +26 -13
- package/src/ws/default/default.ws.server.js +30 -12
- package/.env.development +0 -43
- package/.env.test +0 -43
- package/hardhat/contracts/CryptoKoyn.sol +0 -59
- package/hardhat/contracts/ItemLedger.sol +0 -73
- package/hardhat/contracts/Lock.sol +0 -34
- package/hardhat/hardhat.config.cjs +0 -45
- package/hardhat/ignition/modules/Lock.js +0 -18
- package/hardhat/networks/cryptokoyn-itemledger.network.json +0 -29
- package/hardhat/scripts/deployCryptokoyn.cjs +0 -25
- package/hardhat/scripts/deployItemledger.cjs +0 -25
- package/hardhat/test/Lock.js +0 -126
- package/hardhat/white-paper.md +0 -581
- package/src/client/components/cryptokoyn/CommonCryptokoyn.js +0 -29
- package/src/client/components/cryptokoyn/ElementsCryptokoyn.js +0 -38
- package/src/client/components/cyberia-portal/ElementsCyberiaPortal.js +0 -38
- package/src/client/components/default/ElementsDefault.js +0 -38
- package/src/client/components/itemledger/CommonItemledger.js +0 -29
- package/src/client/components/itemledger/ElementsItemledger.js +0 -38
- package/src/client/components/underpost/CommonUnderpost.js +0 -29
- package/src/client/components/underpost/ElementsUnderpost.js +0 -38
- package/src/ws/core/management/core.ws.chat.js +0 -8
- package/src/ws/core/management/core.ws.mailer.js +0 -16
- package/src/ws/core/management/core.ws.stream.js +0 -8
- package/src/ws/default/management/default.ws.main.js +0 -8
- package/white-paper.md +0 -581
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @module ws/core.ws.emit
|
|
4
|
-
* @namespace CoreWsEmitter
|
|
2
|
+
* Standardized WebSocket message emission.
|
|
3
|
+
* @module ws/core/core.ws.emit
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
import { loggerFactory } from '../../server/logger.js';
|
|
8
|
-
import { Socket } from 'socket.io';
|
|
9
7
|
|
|
10
8
|
const logger = loggerFactory(import.meta);
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* @class CoreWsEmitter
|
|
14
|
-
* @
|
|
15
|
-
* @memberof CoreWsEmitter
|
|
16
|
-
* @classdesc Provides a static utility method for safely emitting messages over a WebSocket connection.
|
|
12
|
+
* @classdesc Provides a static utility for safely emitting JSON-serialized messages over Socket.IO.
|
|
17
13
|
*/
|
|
18
14
|
class CoreWsEmitter {
|
|
19
15
|
/**
|
|
20
|
-
* Emits a payload to a
|
|
21
|
-
* The payload is automatically JSON stringified.
|
|
16
|
+
* Emits a JSON-stringified payload to a client on a given channel.
|
|
22
17
|
*
|
|
23
18
|
* @static
|
|
24
|
-
* @param {string}
|
|
25
|
-
* @param {Socket
|
|
26
|
-
* @param {Object}
|
|
19
|
+
* @param {string} channel - The channel/event name to emit on.
|
|
20
|
+
* @param {import('socket.io').Socket} client - The Socket.IO socket to emit to.
|
|
21
|
+
* @param {Object} payload - The data object to send.
|
|
27
22
|
* @returns {void}
|
|
28
23
|
*/
|
|
29
24
|
static emit(channel = '', client = {}, payload = {}) {
|
|
@@ -31,23 +26,12 @@ class CoreWsEmitter {
|
|
|
31
26
|
if (client && typeof client.emit === 'function') {
|
|
32
27
|
client.emit(channel, JSON.stringify(payload));
|
|
33
28
|
} else {
|
|
34
|
-
logger.error('Invalid client: Cannot emit message.', { channel,
|
|
29
|
+
logger.error('Invalid client: Cannot emit message.', { channel, payload });
|
|
35
30
|
}
|
|
36
31
|
} catch (error) {
|
|
37
|
-
logger.error(error, { channel,
|
|
32
|
+
logger.error(error, { channel, payload, stack: error.stack });
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
* Backward compatibility export for the `emit` function.
|
|
44
|
-
* @memberof CoreWsEmitter
|
|
45
|
-
* @function CoreWsEmit
|
|
46
|
-
* @param {string} [channel=''] - The name of the channel/event to emit on.
|
|
47
|
-
* @param {Socket | Object} [client={}] - The Socket.IO client/socket object.
|
|
48
|
-
* @param {Object} [payload={}] - The data object to send.
|
|
49
|
-
* @returns {void}
|
|
50
|
-
*/
|
|
51
|
-
const CoreWsEmit = CoreWsEmitter.emit;
|
|
52
|
-
|
|
53
|
-
export { CoreWsEmitter, CoreWsEmit };
|
|
37
|
+
export { CoreWsEmitter };
|
|
@@ -1,76 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @module ws/core.ws.server
|
|
4
|
-
* @namespace CoreWsServer
|
|
2
|
+
* Core WebSocket server factory — initializes channels and creates the Socket.IO server.
|
|
3
|
+
* @module ws/core/core.ws.server
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
'use strict';
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import http from 'http'; // Added for JSDoc type hinting
|
|
15
|
-
|
|
16
|
-
// https://socket.io/docs/v3/
|
|
8
|
+
import { IoServer } from '../IoServer.js';
|
|
9
|
+
import { CoreWsConnectionHandler } from './core.ws.connection.js';
|
|
10
|
+
import { CoreWsChatChannel } from './channels/core.ws.chat.js';
|
|
11
|
+
import { CoreWsMailerChannel } from './channels/core.ws.mailer.js';
|
|
12
|
+
import { CoreWsStreamChannel } from './channels/core.ws.stream.js';
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
|
-
* @class
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
* @classdesc Manages the creation and initialization of the main WebSocket server,
|
|
23
|
-
* including setting up the management instances for all channels.
|
|
15
|
+
* @class CoreWsServer
|
|
16
|
+
* @classdesc Creates the core WebSocket server, initializing all channel state
|
|
17
|
+
* before attaching the connection handler.
|
|
24
18
|
*/
|
|
25
|
-
class
|
|
19
|
+
class CoreWsServer {
|
|
26
20
|
/**
|
|
27
|
-
* Initializes channel
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @param {
|
|
32
|
-
* @
|
|
33
|
-
* @param {string} options.host - The host address.
|
|
34
|
-
* @param {string} options.path - The base path for the API.
|
|
35
|
-
* @returns {Promise<Object>} The result object from IoServer creation.
|
|
21
|
+
* Initializes channel state and creates the Socket.IO server.
|
|
22
|
+
* @param {import('http').Server} httpServer
|
|
23
|
+
* @param {Object} options
|
|
24
|
+
* @param {string} options.host
|
|
25
|
+
* @param {string} options.path
|
|
26
|
+
* @returns {{ options: import('socket.io').ServerOptions, ioServer: import('socket.io').Server, meta: ImportMeta }}
|
|
36
27
|
*/
|
|
37
|
-
static
|
|
28
|
+
static create(httpServer, options) {
|
|
38
29
|
const { host, path } = options;
|
|
39
|
-
if (!host || !path) {
|
|
40
|
-
throw new Error('Host and path must be provided in server options.');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Create a unique identifier for this server instance's management context
|
|
44
30
|
const wsManagementId = `${host}${path}`;
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
CoreWsStreamManagement.instance(wsManagementId);
|
|
32
|
+
CoreWsChatChannel.init(wsManagementId);
|
|
33
|
+
CoreWsMailerChannel.init(wsManagementId);
|
|
34
|
+
CoreWsStreamChannel.init(wsManagementId);
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
return IoServerClass.create(httpServer, options, (socket) => CoreWsConnection(socket, wsManagementId));
|
|
36
|
+
return IoServer.create(httpServer, options, (socket) => CoreWsConnectionHandler.handle(socket, wsManagementId));
|
|
53
37
|
}
|
|
54
38
|
}
|
|
55
39
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
* @memberof CoreWsServer
|
|
59
|
-
* @function createIoServer
|
|
60
|
-
* @param {http.Server} httpServer - The HTTP server instance.
|
|
61
|
-
* @param {Object} options - Configuration options.
|
|
62
|
-
* @returns {Promise<Object>} The server creation result.
|
|
63
|
-
*/
|
|
64
|
-
const createIoServer = CoreWsServerClass.create;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Backward compatibility alias.
|
|
68
|
-
* @memberof CoreWsServer
|
|
69
|
-
* @function CoreWsServer
|
|
70
|
-
* @param {import('http').Server} httpServer - The HTTP server instance.
|
|
71
|
-
* @param {Object} options - Configuration options.
|
|
72
|
-
* @returns {Promise<Object>} The server creation result.
|
|
73
|
-
*/
|
|
74
|
-
const CoreWsServer = createIoServer;
|
|
40
|
+
/** Required by Express.js dynamic import: `const { createIoServer } = await import(...)` */
|
|
41
|
+
const createIoServer = CoreWsServer.create.bind(CoreWsServer);
|
|
75
42
|
|
|
76
|
-
export {
|
|
43
|
+
export { CoreWsServer, createIoServer };
|
|
@@ -1,16 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Default "main" WebSocket channel — minimal no-op channel.
|
|
3
|
+
* @module ws/default/channels/default.ws.main
|
|
4
|
+
*/
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
const logger = loggerFactory(import.meta);
|
|
6
|
+
import { IoChannel } from '../../IoInterface.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
8
|
+
/**
|
|
9
|
+
* @class DefaultWsMainChannel
|
|
10
|
+
* @classdesc Provides a no-op main channel for the default WebSocket server.
|
|
11
|
+
*/
|
|
12
|
+
class DefaultWsMainChannel {
|
|
13
|
+
/** @type {Object.<string, Object>} Per-instance state keyed by wsManagementId. */
|
|
14
|
+
static #state = {};
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
/** @type {IoChannel} */
|
|
17
|
+
static #io = new IoChannel({ channel: 'main' });
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
/** @returns {Object.<string, import('socket.io').Socket>} Connected sockets map. */
|
|
20
|
+
static get client() {
|
|
21
|
+
return this.#io.client;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** @returns {string} Channel name. */
|
|
25
|
+
static get channel() {
|
|
26
|
+
return this.#io.channel;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Initializes state for a server instance.
|
|
31
|
+
* @param {string} wsManagementId
|
|
32
|
+
*/
|
|
33
|
+
static init(wsManagementId) {
|
|
34
|
+
this.#state[wsManagementId] = {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Registers a socket connection.
|
|
39
|
+
* @param {import('socket.io').Socket} socket
|
|
40
|
+
* @param {string} wsManagementId
|
|
41
|
+
*/
|
|
42
|
+
static connection(socket, wsManagementId) {
|
|
43
|
+
return this.#io.connection(socket, wsManagementId);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handles socket disconnection.
|
|
48
|
+
* @param {import('socket.io').Socket} socket
|
|
49
|
+
* @param {string} reason
|
|
50
|
+
* @param {string} wsManagementId
|
|
51
|
+
*/
|
|
52
|
+
static disconnect(socket, reason, wsManagementId) {
|
|
53
|
+
return this.#io.disconnect(socket, reason, wsManagementId);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { DefaultWsMainChannel };
|
|
@@ -1,22 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default WebSocket connection handler — wires sockets to the main channel.
|
|
3
|
+
* @module ws/default/default.ws.connection
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import { loggerFactory } from '../../server/logger.js';
|
|
2
7
|
import { DefaultWsMainChannel } from './channels/default.ws.main.js';
|
|
3
8
|
|
|
4
9
|
const logger = loggerFactory(import.meta);
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @class DefaultWsConnectionHandler
|
|
13
|
+
* @classdesc Subscribes a new socket to the default main channel
|
|
14
|
+
* and delegates disconnect events.
|
|
15
|
+
*/
|
|
16
|
+
class DefaultWsConnectionHandler {
|
|
17
|
+
/**
|
|
18
|
+
* Handles a new WebSocket connection.
|
|
19
|
+
* @param {import('socket.io').Socket} socket
|
|
20
|
+
* @param {string} wsManagementId
|
|
21
|
+
*/
|
|
22
|
+
static handle(socket, wsManagementId) {
|
|
23
|
+
logger.info(`DefaultWsConnection ${socket.id}`);
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
DefaultWsMainChannel.connection(socket, wsManagementId);
|
|
14
26
|
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
socket.on('disconnect', (reason) => {
|
|
28
|
+
logger.info(`DefaultWsConnection ${socket.id} due to reason: ${reason}`);
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
30
|
+
DefaultWsMainChannel.disconnect(socket, reason, wsManagementId);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
21
34
|
|
|
22
|
-
export {
|
|
35
|
+
export { DefaultWsConnectionHandler };
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default WebSocket server factory — initializes the main channel and creates the Socket.IO server.
|
|
3
|
+
* @module ws/default/default.ws.server
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
'use strict';
|
|
2
7
|
|
|
3
8
|
import { IoServer } from '../IoServer.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
// https://socket.io/docs/v3/
|
|
9
|
+
import { DefaultWsConnectionHandler } from './default.ws.connection.js';
|
|
10
|
+
import { DefaultWsMainChannel } from './channels/default.ws.main.js';
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @class DefaultWsServer
|
|
14
|
+
* @classdesc Creates the default WebSocket server with a single main channel.
|
|
15
|
+
*/
|
|
16
|
+
class DefaultWsServer {
|
|
17
|
+
/**
|
|
18
|
+
* Initializes the main channel and creates the Socket.IO server.
|
|
19
|
+
* @param {import('http').Server} httpServer
|
|
20
|
+
* @param {Object} options
|
|
21
|
+
* @param {string} options.host
|
|
22
|
+
* @param {string} options.path
|
|
23
|
+
* @returns {{ options: import('socket.io').ServerOptions, ioServer: import('socket.io').Server, meta: ImportMeta }}
|
|
24
|
+
*/
|
|
25
|
+
static create(httpServer, options) {
|
|
26
|
+
const { host, path } = options;
|
|
27
|
+
const wsManagementId = `${host}${path}`;
|
|
12
28
|
|
|
13
|
-
|
|
29
|
+
DefaultWsMainChannel.init(wsManagementId);
|
|
14
30
|
|
|
15
|
-
|
|
16
|
-
}
|
|
31
|
+
return IoServer.create(httpServer, options, (socket) => DefaultWsConnectionHandler.handle(socket, wsManagementId));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
17
34
|
|
|
18
|
-
const
|
|
35
|
+
/** Required by Express.js dynamic import: `const { createIoServer } = await import(...)` */
|
|
36
|
+
const createIoServer = DefaultWsServer.create.bind(DefaultWsServer);
|
|
19
37
|
|
|
20
|
-
export {
|
|
38
|
+
export { DefaultWsServer, createIoServer };
|
package/.env.development
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
DEPLOY_ID=dd-default
|
|
2
|
-
NODE_ENV=development
|
|
3
|
-
PORT=4000
|
|
4
|
-
JWT_SECRET=test
|
|
5
|
-
REFRESH_EXPIRE_MINUTES=5
|
|
6
|
-
ACCESS_EXPIRE_MINUTES=1440
|
|
7
|
-
NODE_OPTIONS=--max-old-space-size=8192
|
|
8
|
-
TIME_ZONE=changethis
|
|
9
|
-
GITHUB_TOKEN=changethis
|
|
10
|
-
GITHUB_USERNAME=changethis
|
|
11
|
-
GITHUB_BACKUP_REPO=changethis
|
|
12
|
-
GITHUB_DNS_REPO=changethis
|
|
13
|
-
DEFAULT_DEPLOY_ID=dd-default
|
|
14
|
-
DEFAULT_DEPLOY_HOST=default.net
|
|
15
|
-
DEFAULT_DEPLOY_PATH=/
|
|
16
|
-
MARIADB_HOST=changethis
|
|
17
|
-
MARIADB_USER=changethis
|
|
18
|
-
MARIADB_PASSWORD=changethis
|
|
19
|
-
CLOUDINARY_CLOUD_NAME=changethis
|
|
20
|
-
CLOUDINARY_API_KEY=changethis
|
|
21
|
-
CLOUDINARY_API_SECRET=changethis
|
|
22
|
-
CLOUDINARY_PASSWORD=changethis
|
|
23
|
-
CLOUDINARY_EMAIL=admin@default.net
|
|
24
|
-
DB_PG_MAAS_NAME=changethis
|
|
25
|
-
DB_PG_MAAS_PASS=changethis
|
|
26
|
-
DB_PG_MAAS_USER=changethis
|
|
27
|
-
DB_PG_MAAS_HOST=127.0.0.1
|
|
28
|
-
DB_PG_MAAS_PORT=5432
|
|
29
|
-
MAAS_ADMIN_USERNAME=changethis
|
|
30
|
-
MAAS_API_KEY=changethis
|
|
31
|
-
MAAS_ADMIN_EMAIL=admin@default.net
|
|
32
|
-
MAAS_ADMIN_PASS=changethis
|
|
33
|
-
TFTP_ROOT=changethis
|
|
34
|
-
NETMASK=255.255.255.0
|
|
35
|
-
MAAS_DNS=8.8.8.8
|
|
36
|
-
MAAS_NTP_SERVER=changethis
|
|
37
|
-
NFS_EXPORT_PATH=changethis
|
|
38
|
-
NVIDIA_API_KEY=changethis
|
|
39
|
-
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
40
|
-
DEFAULT_ADMIN_PASSWORD=changethis
|
|
41
|
-
DEFAULT_SSH_PORT=22
|
|
42
|
-
BASE_API=api
|
|
43
|
-
DEV_PROXY_PORT_OFFSET=200
|
package/.env.test
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
DEPLOY_ID=dd-default
|
|
2
|
-
NODE_ENV=test
|
|
3
|
-
PORT=5000
|
|
4
|
-
JWT_SECRET=test
|
|
5
|
-
REFRESH_EXPIRE_MINUTES=5
|
|
6
|
-
ACCESS_EXPIRE_MINUTES=1440
|
|
7
|
-
NODE_OPTIONS=--max-old-space-size=8192
|
|
8
|
-
TIME_ZONE=changethis
|
|
9
|
-
GITHUB_TOKEN=changethis
|
|
10
|
-
GITHUB_USERNAME=changethis
|
|
11
|
-
GITHUB_BACKUP_REPO=changethis
|
|
12
|
-
GITHUB_DNS_REPO=changethis
|
|
13
|
-
DEFAULT_DEPLOY_ID=dd-default
|
|
14
|
-
DEFAULT_DEPLOY_HOST=default.net
|
|
15
|
-
DEFAULT_DEPLOY_PATH=/
|
|
16
|
-
MARIADB_HOST=changethis
|
|
17
|
-
MARIADB_USER=changethis
|
|
18
|
-
MARIADB_PASSWORD=changethis
|
|
19
|
-
CLOUDINARY_CLOUD_NAME=changethis
|
|
20
|
-
CLOUDINARY_API_KEY=changethis
|
|
21
|
-
CLOUDINARY_API_SECRET=changethis
|
|
22
|
-
CLOUDINARY_PASSWORD=changethis
|
|
23
|
-
CLOUDINARY_EMAIL=admin@default.net
|
|
24
|
-
DB_PG_MAAS_NAME=changethis
|
|
25
|
-
DB_PG_MAAS_PASS=changethis
|
|
26
|
-
DB_PG_MAAS_USER=changethis
|
|
27
|
-
DB_PG_MAAS_HOST=127.0.0.1
|
|
28
|
-
DB_PG_MAAS_PORT=5432
|
|
29
|
-
MAAS_ADMIN_USERNAME=changethis
|
|
30
|
-
MAAS_API_KEY=changethis
|
|
31
|
-
MAAS_ADMIN_EMAIL=admin@default.net
|
|
32
|
-
MAAS_ADMIN_PASS=changethis
|
|
33
|
-
TFTP_ROOT=changethis
|
|
34
|
-
NETMASK=255.255.255.0
|
|
35
|
-
MAAS_DNS=8.8.8.8
|
|
36
|
-
MAAS_NTP_SERVER=changethis
|
|
37
|
-
NFS_EXPORT_PATH=changethis
|
|
38
|
-
NVIDIA_API_KEY=changethis
|
|
39
|
-
DEFAULT_ADMIN_EMAIL=admin@default.net
|
|
40
|
-
DEFAULT_ADMIN_PASSWORD=changethis
|
|
41
|
-
DEFAULT_SSH_PORT=22
|
|
42
|
-
BASE_API=api
|
|
43
|
-
DEV_PROXY_PORT_OFFSET=200
|
|
@@ -1,59 +0,0 @@
|
|
|
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/ERC20/ERC20.sol';
|
|
6
|
-
import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol';
|
|
7
|
-
import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol';
|
|
8
|
-
import '@openzeppelin/contracts/access/Ownable.sol';
|
|
9
|
-
import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @title CryptoKoyn Token
|
|
13
|
-
* @dev An ERC20 token with minting, burning, pausing, and permit functionalities.
|
|
14
|
-
*/
|
|
15
|
-
contract CryptoKoyn is ERC20, ERC20Burnable, ERC20Pausable, Ownable, ERC20Permit {
|
|
16
|
-
/**
|
|
17
|
-
* @dev Constructs a new CryptoKoyn token.
|
|
18
|
-
* @param initialOwner The initial owner of the token.
|
|
19
|
-
*/
|
|
20
|
-
constructor(address initialOwner) ERC20('CryptoKoyn', 'CKY') Ownable(initialOwner) ERC20Permit('CryptoKoyn') {
|
|
21
|
-
_mint(msg.sender, 10000000 * 10 ** decimals());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @dev Pauses all token transfers.
|
|
26
|
-
* @dev Only the owner can call this function.
|
|
27
|
-
*/
|
|
28
|
-
function pause() public onlyOwner {
|
|
29
|
-
_pause();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @dev Unpauses all token transfers.
|
|
34
|
-
* @dev Only the owner can call this function.
|
|
35
|
-
*/
|
|
36
|
-
function unpause() public onlyOwner {
|
|
37
|
-
_unpause();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @dev Mints new tokens.
|
|
42
|
-
* @param to The recipient of the minted tokens.
|
|
43
|
-
* @param amount The amount of tokens to mint.
|
|
44
|
-
* @dev Only the owner can call this function.
|
|
45
|
-
*/
|
|
46
|
-
function mint(address to, uint256 amount) public onlyOwner {
|
|
47
|
-
_mint(to, amount);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @dev Overrides the `_update` function to ensure proper token transfer handling.
|
|
52
|
-
* @param from The sender of the tokens.
|
|
53
|
-
* @param to The recipient of the tokens.
|
|
54
|
-
* @param value The amount of tokens to transfer.
|
|
55
|
-
*/
|
|
56
|
-
function _update(address from, address to, uint256 value) internal override(ERC20, ERC20Pausable) {
|
|
57
|
-
super._update(from, to, value);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
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/ERC721/ERC721.sol';
|
|
6
|
-
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
|
|
7
|
-
import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol';
|
|
8
|
-
import '@openzeppelin/contracts/access/Ownable.sol';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @title ItemLedger
|
|
12
|
-
* @dev An ERC721 token contract for managing items, with minting and burning capabilities.
|
|
13
|
-
*/
|
|
14
|
-
contract ItemLedger is ERC721, ERC721Enumerable, ERC721Burnable, Ownable {
|
|
15
|
-
/**
|
|
16
|
-
* @dev Constructs a new ItemLedger contract.
|
|
17
|
-
* @param initialOwner The initial owner of the contract.
|
|
18
|
-
*/
|
|
19
|
-
constructor(address initialOwner) ERC721('ItemLedger', 'IL') Ownable(initialOwner) {}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @dev Sets the base URI for token URIs.
|
|
23
|
-
*/
|
|
24
|
-
function _baseURI() internal pure override returns (string memory) {
|
|
25
|
-
return 'IL';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @dev Mints a new NFT to a specified address.
|
|
30
|
-
* @param to The address to mint the NFT to.
|
|
31
|
-
* @param tokenId The ID of the token to be minted.
|
|
32
|
-
* @dev Only the owner can call this function.
|
|
33
|
-
*/
|
|
34
|
-
function safeMint(address to, uint256 tokenId) public onlyOwner {
|
|
35
|
-
_safeMint(to, tokenId);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// The following functions are overrides required by Solidity.
|
|
39
|
-
// They ensure proper interaction with the inherited ERC721 and ERC721Enumerable contracts.
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @dev Overrides the `_update` function to ensure proper token ownership updates.
|
|
43
|
-
* @param to The new owner of the token.
|
|
44
|
-
* @param tokenId The ID of the token.
|
|
45
|
-
* @param auth The authorized address for the transfer.
|
|
46
|
-
* @return The address of the previous owner.
|
|
47
|
-
*/
|
|
48
|
-
function _update(
|
|
49
|
-
address to,
|
|
50
|
-
uint256 tokenId,
|
|
51
|
-
address auth
|
|
52
|
-
) internal override(ERC721, ERC721Enumerable) returns (address) {
|
|
53
|
-
return super._update(to, tokenId, auth);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @dev Overrides the `_increaseBalance` function to ensure proper token balance updates.
|
|
58
|
-
* @param account The account to increase the balance of.
|
|
59
|
-
* @param value The amount to increase the balance by.
|
|
60
|
-
*/
|
|
61
|
-
function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) {
|
|
62
|
-
super._increaseBalance(account, value);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @dev Overrides the `supportsInterface` function to ensure proper interface checks.
|
|
67
|
-
* @param interfaceId The interface ID to check.
|
|
68
|
-
* @return True if the contract implements the interface, false otherwise.
|
|
69
|
-
*/
|
|
70
|
-
function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) {
|
|
71
|
-
return super.supportsInterface(interfaceId);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
-
pragma solidity ^0.8.27;
|
|
3
|
-
|
|
4
|
-
// Uncomment this line to use console.log
|
|
5
|
-
// import "hardhat/console.sol";
|
|
6
|
-
|
|
7
|
-
contract Lock {
|
|
8
|
-
uint public unlockTime;
|
|
9
|
-
address payable public owner;
|
|
10
|
-
|
|
11
|
-
event Withdrawal(uint amount, uint when);
|
|
12
|
-
|
|
13
|
-
constructor(uint _unlockTime) payable {
|
|
14
|
-
require(
|
|
15
|
-
block.timestamp < _unlockTime,
|
|
16
|
-
"Unlock time should be in the future"
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
unlockTime = _unlockTime;
|
|
20
|
-
owner = payable(msg.sender);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function withdraw() public {
|
|
24
|
-
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
|
|
25
|
-
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);
|
|
26
|
-
|
|
27
|
-
require(block.timestamp >= unlockTime, "You can't withdraw yet");
|
|
28
|
-
require(msg.sender == owner, "You aren't the owner");
|
|
29
|
-
|
|
30
|
-
emit Withdrawal(address(this).balance, block.timestamp);
|
|
31
|
-
|
|
32
|
-
owner.transfer(address(this).balance);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// hardhat.config.js
|
|
2
|
-
require('@nomiclabs/hardhat-waffle');
|
|
3
|
-
require('@nomiclabs/hardhat-ethers');
|
|
4
|
-
require('@nomiclabs/hardhat-etherscan');
|
|
5
|
-
require('dotenv').config();
|
|
6
|
-
const fs = require('fs-extra');
|
|
7
|
-
|
|
8
|
-
/** @type import('hardhat/config').HardhatUserConfig */
|
|
9
|
-
module.exports = {
|
|
10
|
-
defaultNetwork: 'cryptokoyn-itemledger',
|
|
11
|
-
networks: {
|
|
12
|
-
hardhat: {},
|
|
13
|
-
'cryptokoyn-itemledger': {
|
|
14
|
-
// url: 'https://cryptokoyn.net/rpc/mainnet',
|
|
15
|
-
// url: 'https://itemledger.com/rpc/mainnet',
|
|
16
|
-
url: 'http://127.0.0.1:8545',
|
|
17
|
-
accounts: [fs.readFileSync(`../engine-private/eth-networks/cryptokoyn-itemledger/coinbase`, 'utf8')], // process.env.ETH_PRIVATE_KEY
|
|
18
|
-
chainId: 777771,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
// etherscan: {
|
|
22
|
-
// apiKey: "YOUR_ETHERSCAN_API_KEY", // Replace with your Etherscan API key
|
|
23
|
-
// },
|
|
24
|
-
// vanar: {
|
|
25
|
-
// apiKey: "YOUR_VANAR_API_KEY", // Replace with your VANAR API key
|
|
26
|
-
// },
|
|
27
|
-
solidity: {
|
|
28
|
-
version: '0.8.27',
|
|
29
|
-
settings: {
|
|
30
|
-
optimizer: {
|
|
31
|
-
enabled: true,
|
|
32
|
-
runs: 200,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
paths: {
|
|
37
|
-
sources: './contracts',
|
|
38
|
-
tests: './test',
|
|
39
|
-
cache: './cache',
|
|
40
|
-
artifacts: './artifacts',
|
|
41
|
-
},
|
|
42
|
-
mocha: {
|
|
43
|
-
timeout: 40000,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// This setup uses Hardhat Ignition to manage smart contract deployments.
|
|
2
|
-
// Learn more about it at https://hardhat.org/ignition
|
|
3
|
-
|
|
4
|
-
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");
|
|
5
|
-
|
|
6
|
-
const JAN_1ST_2030 = 1893456000;
|
|
7
|
-
const ONE_GWEI = 1_000_000_000n;
|
|
8
|
-
|
|
9
|
-
module.exports = buildModule("LockModule", (m) => {
|
|
10
|
-
const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
|
|
11
|
-
const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);
|
|
12
|
-
|
|
13
|
-
const lock = m.contract("Lock", [unlockTime], {
|
|
14
|
-
value: lockedAmount,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return { lock };
|
|
18
|
-
});
|