@xyo-network/chain-sdk 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +57 -0
  3. package/babel.config.json +6 -0
  4. package/dist/browser/index-browser.mjs +170 -0
  5. package/dist/browser/index-browser.mjs.map +1 -0
  6. package/dist/neutral/index.mjs +311 -0
  7. package/dist/neutral/index.mjs.map +1 -0
  8. package/dist/node/index-node.mjs +330 -0
  9. package/dist/node/index-node.mjs.map +1 -0
  10. package/dist/types/index-browser.d.ts +2 -0
  11. package/dist/types/index-browser.d.ts.map +1 -0
  12. package/dist/types/index-node.d.ts +2 -0
  13. package/dist/types/index-node.d.ts.map +1 -0
  14. package/dist/types/index-shared.d.ts +9 -0
  15. package/dist/types/index-shared.d.ts.map +1 -0
  16. package/dist/types/index.d.ts +3 -0
  17. package/dist/types/index.d.ts.map +1 -0
  18. package/dist/types/orchestration/archivist/index.d.ts +2 -0
  19. package/dist/types/orchestration/archivist/index.d.ts.map +1 -0
  20. package/dist/types/orchestration/archivist/initArchivistSync.d.ts +16 -0
  21. package/dist/types/orchestration/archivist/initArchivistSync.d.ts.map +1 -0
  22. package/dist/types/orchestration/bridge.d.ts +3 -0
  23. package/dist/types/orchestration/bridge.d.ts.map +1 -0
  24. package/dist/types/orchestration/index.d.ts +4 -0
  25. package/dist/types/orchestration/index.d.ts.map +1 -0
  26. package/dist/types/orchestration/initBridgedModule.d.ts +13 -0
  27. package/dist/types/orchestration/initBridgedModule.d.ts.map +1 -0
  28. package/dist/types/test/evm/index.d.ts +3 -0
  29. package/dist/types/test/evm/index.d.ts.map +1 -0
  30. package/dist/types/test/evm/runGanache.d.ts +4 -0
  31. package/dist/types/test/evm/runGanache.d.ts.map +1 -0
  32. package/dist/types/test/evm/setup.d.ts +2 -0
  33. package/dist/types/test/evm/setup.d.ts.map +1 -0
  34. package/dist/types/test/evm/stakingContractUtils.d.ts +9 -0
  35. package/dist/types/test/evm/stakingContractUtils.d.ts.map +1 -0
  36. package/dist/types/test/globalSetup.d.ts +2 -0
  37. package/dist/types/test/globalSetup.d.ts.map +1 -0
  38. package/dist/types/test/index.d.ts +2 -0
  39. package/dist/types/test/index.d.ts.map +1 -0
  40. package/package.json +120 -0
  41. package/src/Layers.md +64 -0
  42. package/src/index-browser.ts +1 -0
  43. package/src/index-node.ts +1 -0
  44. package/src/index-shared.ts +8 -0
  45. package/src/index.ts +2 -0
  46. package/src/orchestration/archivist/index.ts +1 -0
  47. package/src/orchestration/archivist/initArchivistSync.ts +61 -0
  48. package/src/orchestration/bridge.ts +25 -0
  49. package/src/orchestration/index.ts +3 -0
  50. package/src/orchestration/initBridgedModule.ts +35 -0
  51. package/src/test/evm/index.ts +2 -0
  52. package/src/test/evm/runGanache.ts +41 -0
  53. package/src/test/evm/setup.ts +75 -0
  54. package/src/test/evm/stakingContractUtils.ts +109 -0
  55. package/src/test/globalSetup.ts +14 -0
  56. package/src/test/index.ts +1 -0
  57. package/xy.config.ts +10 -0
package/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ [![logo][]](https://xylabs.com)
2
+
3
+ # @xylabs/api-xyo-chain-nodejs
4
+
5
+ [![main-build][]][main-build-link]
6
+ [![prod-deploy][]][prod-deploy-link]
7
+ [![beta-deploy][]][beta-deploy-link]
8
+
9
+ [![codacy-badge][]][codacy-link]
10
+ [![codeclimate-badge][]][codeclimate-link]
11
+ [![codeclimate-coverage-badge][]][codeclimate-coverage-link]
12
+
13
+ ## Table of Contents
14
+
15
+ - [@xylabs/api-xyo-chain-nodejs](#xylabsapi-xyo-chain-nodejs)
16
+ - [Table of Contents](#table-of-contents)
17
+ - [Description](#description)
18
+ - [Deploy](#deploy)
19
+ - [Maintainers](#maintainers)
20
+ - [License](#license)
21
+ - [Credits](#credits)
22
+
23
+ ## Description
24
+
25
+ Api/implementation of XYO Chain API Node
26
+
27
+ ## Deploy
28
+
29
+ Pushing to the `prod` branch deploys to Production
30
+
31
+ Pushing to the `beta` branch deploys to Beta
32
+
33
+ ## Maintainers
34
+
35
+ - [Arie Trouw](https://github.com/arietrouw) [arietrouw.com](https://arietrouw.com)
36
+
37
+ ## License
38
+
39
+ See the [LICENSE](LICENSE) file for license details
40
+
41
+ ## Credits
42
+
43
+ [Made with 🔥 and ❄️ by XY Labs](https://xylabs.com)
44
+
45
+ [logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
46
+ [main-build]: https://github.com/xylabs/api-xyo-chain-nodejs/actions/workflows/build-main.yml/badge.svg
47
+ [main-build-link]: https://github.com/xylabs/api-xyo-chain-nodejs/actions/workflows/build-main.yml
48
+ [prod-deploy]: https://github.com/xylabs/api-xyo-chain-nodejs/actions/workflows/deploy-prod.yml/badge.svg
49
+ [prod-deploy-link]: https://github.com/xylabs/api-xyo-chain-nodejs/actions/workflows/deploy-prod.yml
50
+ [beta-deploy]: https://github.com/xylabs/api-xyo-chain-nodejs/actions/workflows/deploy-beta.yml/badge.svg
51
+ [beta-deploy-link]: https://github.com/xylabs/api-xyo-chain-nodejs/actions/workflows/deploy-beta.yml
52
+ [codacy-badge]: https://app.codacy.com/project/badge/Grade/14640dade84b44a69e7b9daafd07be46
53
+ [codacy-link]: https://www.codacy.com/gh/xylabs/api-xyo-chain-nodejs/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/api-xylabs-import-nodejs&utm_campaign=Badge_Grade
54
+ [codeclimate-badge]: https://api.codeclimate.com/v1/badges/dc0bb5770f231f22f826/maintainability
55
+ [codeclimate-link]: https://codeclimate.com/github/xylabs/api-xyo-chain-nodejs/maintainability
56
+ [codeclimate-coverage-badge]: https://api.codeclimate.com/v1/badges/dc0bb5770f231f22f826/test_coverage
57
+ [codeclimate-coverage-link]: https://codeclimate.com/github/xylabs/api-xyo-chain-nodejs/test_coverage
@@ -0,0 +1,6 @@
1
+ {
2
+ "presets": [
3
+ ["@babel/preset-env", { "modules": false, "targets": { "node": "current" } }],
4
+ "@babel/preset-typescript"
5
+ ]
6
+ }
@@ -0,0 +1,170 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+
20
+ // src/index-browser.ts
21
+ var index_browser_exports = {};
22
+ __export(index_browser_exports, {
23
+ initArchivistSync: () => initArchivistSync,
24
+ initBridge: () => initBridge,
25
+ initBridgedArchivistModule: () => initBridgedArchivistModule,
26
+ initBridgedModule: () => initBridgedModule
27
+ });
28
+
29
+ // src/index-shared.ts
30
+ var index_shared_exports = {};
31
+ __export(index_shared_exports, {
32
+ initArchivistSync: () => initArchivistSync,
33
+ initBridge: () => initBridge,
34
+ initBridgedArchivistModule: () => initBridgedArchivistModule,
35
+ initBridgedModule: () => initBridgedModule
36
+ });
37
+
38
+ // src/orchestration/archivist/initArchivistSync.ts
39
+ import { ArchivistSyncDiviner } from "@xyo-network/chain-modules";
40
+ import { spanAsync } from "@xyo-network/chain-utils";
41
+ import { DivinerConfigSchema } from "@xyo-network/diviner-model";
42
+ import { MemoryNode } from "@xyo-network/node-memory";
43
+ import { MemorySentinel } from "@xyo-network/sentinel-memory";
44
+ import { SentinelConfigSchema } from "@xyo-network/sentinel-model";
45
+ var initArchivistSync = /* @__PURE__ */ __name(async (name, inArchivist, outArchivist, frequency = 1e3, traceProvider) => {
46
+ const tracer = traceProvider?.getTracer(`archivist-sync-diviner [${name}]`);
47
+ return await spanAsync(`initArchivistSync [${name}]`, async () => {
48
+ const node = await MemoryNode.create({
49
+ account: "random"
50
+ });
51
+ const finalizedArchivistSyncDiviner = await ArchivistSyncDiviner.create({
52
+ account: "random",
53
+ inArchivist,
54
+ outArchivist,
55
+ tracer,
56
+ config: {
57
+ schema: DivinerConfigSchema,
58
+ name
59
+ }
60
+ });
61
+ await node.register(finalizedArchivistSyncDiviner);
62
+ await node.attach(finalizedArchivistSyncDiviner.address);
63
+ const sentinel = await MemorySentinel.create({
64
+ account: "random",
65
+ config: {
66
+ name,
67
+ schema: SentinelConfigSchema,
68
+ tasks: [
69
+ {
70
+ required: true,
71
+ mod: finalizedArchivistSyncDiviner.address,
72
+ endPoint: "divine"
73
+ }
74
+ ],
75
+ automations: [
76
+ {
77
+ frequency,
78
+ frequencyUnits: "millis",
79
+ schema: "network.xyo.automation.interval",
80
+ start: Date.now(),
81
+ type: "interval"
82
+ }
83
+ ]
84
+ }
85
+ });
86
+ await node.register(sentinel);
87
+ await node.attach(sentinel.address);
88
+ return node;
89
+ }, tracer);
90
+ }, "initArchivistSync");
91
+
92
+ // src/orchestration/bridge.ts
93
+ import { HttpBridge, HttpBridgeConfigSchema } from "@xyo-network/bridge-http";
94
+ import { Mutex } from "async-mutex";
95
+ var initMutex = new Mutex();
96
+ var bridgeSingletonMap = /* @__PURE__ */ new Map();
97
+ var initBridge = /* @__PURE__ */ __name(async (nodeUrl) => {
98
+ return await initMutex.runExclusive(async () => {
99
+ const existing = bridgeSingletonMap.get(nodeUrl);
100
+ if (existing) return existing;
101
+ const bridge = await HttpBridge.create({
102
+ account: "random",
103
+ config: {
104
+ name: "HttpBridge",
105
+ client: {
106
+ url: nodeUrl,
107
+ discoverRoots: "start"
108
+ },
109
+ schema: HttpBridgeConfigSchema,
110
+ security: {
111
+ allowAnonymous: true
112
+ }
113
+ }
114
+ });
115
+ await bridge.start();
116
+ bridgeSingletonMap.set(nodeUrl, bridge);
117
+ return bridge;
118
+ });
119
+ }, "initBridge");
120
+
121
+ // src/orchestration/initBridgedModule.ts
122
+ import { assertEx } from "@xylabs/assert";
123
+ import { asAttachableArchivistInstance } from "@xyo-network/archivist-model";
124
+ import { asAttachableModuleInstance } from "@xyo-network/module-model";
125
+ import { Mutex as Mutex2 } from "async-mutex";
126
+ var initMutex2 = new Mutex2();
127
+ var bridgedModuleDictionary = {};
128
+ var initBridgedModule = /* @__PURE__ */ __name(async ({ bridge, moduleName }) => {
129
+ return await initMutex2.runExclusive(async () => {
130
+ const existing = bridgedModuleDictionary?.[bridge.address]?.[moduleName];
131
+ if (existing) return existing;
132
+ const mod = assertEx(await bridge.resolve(moduleName), () => `Error: Could not resolve ${moduleName}`);
133
+ const moduleInstance = assertEx(asAttachableModuleInstance(mod), () => `Error: Could not convert ${moduleName} to attachable module instance`);
134
+ bridgedModuleDictionary[bridge.address] = bridgedModuleDictionary[bridge.address] || {};
135
+ bridgedModuleDictionary[bridge.address][moduleName] = moduleInstance;
136
+ return moduleInstance;
137
+ });
138
+ }, "initBridgedModule");
139
+ var initBridgedArchivistModule = /* @__PURE__ */ __name(async ({ bridge, moduleName }) => {
140
+ return assertEx(asAttachableArchivistInstance(await initBridgedModule({
141
+ bridge,
142
+ moduleName
143
+ })), () => `Error: Could not convert ${moduleName} to attachable archivist instance`);
144
+ }, "initBridgedArchivistModule");
145
+
146
+ // src/index-shared.ts
147
+ __reExport(index_shared_exports, chain_ethereum_star);
148
+ __reExport(index_shared_exports, chain_model_star);
149
+ __reExport(index_shared_exports, chain_modules_star);
150
+ __reExport(index_shared_exports, chain_protocol_star);
151
+ __reExport(index_shared_exports, chain_services_star);
152
+ __reExport(index_shared_exports, chain_utils_star);
153
+ __reExport(index_shared_exports, chain_validation_star);
154
+ import * as chain_ethereum_star from "@xyo-network/chain-ethereum";
155
+ import * as chain_model_star from "@xyo-network/chain-model";
156
+ import * as chain_modules_star from "@xyo-network/chain-modules";
157
+ import * as chain_protocol_star from "@xyo-network/chain-protocol";
158
+ import * as chain_services_star from "@xyo-network/chain-services";
159
+ import * as chain_utils_star from "@xyo-network/chain-utils";
160
+ import * as chain_validation_star from "@xyo-network/chain-validation";
161
+
162
+ // src/index-browser.ts
163
+ __reExport(index_browser_exports, index_shared_exports);
164
+ export {
165
+ initArchivistSync,
166
+ initBridge,
167
+ initBridgedArchivistModule,
168
+ initBridgedModule
169
+ };
170
+ //# sourceMappingURL=index-browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index-browser.ts","../../src/index-shared.ts","../../src/orchestration/archivist/initArchivistSync.ts","../../src/orchestration/bridge.ts","../../src/orchestration/initBridgedModule.ts"],"sourcesContent":["export * from './index-shared.ts'\n","export * from './orchestration/index.ts'\nexport * from '@xyo-network/chain-ethereum'\nexport * from '@xyo-network/chain-model'\nexport * from '@xyo-network/chain-modules'\nexport * from '@xyo-network/chain-protocol'\nexport * from '@xyo-network/chain-services'\nexport * from '@xyo-network/chain-utils'\nexport * from '@xyo-network/chain-validation'","import { TracerProvider } from '@opentelemetry/api'\nimport { ArchivistSyncDiviner } from '@xyo-network/chain-modules'\nimport { spanAsync } from '@xyo-network/chain-utils'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\nimport { MemoryNode } from '@xyo-network/node-memory'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\n\nexport const initArchivistSync = async (\n name: ModuleIdentifier,\n inArchivist: ArchivistInstance,\n outArchivist: ArchivistInstance,\n frequency = 1000,\n traceProvider?: TracerProvider,\n) => {\n const tracer = traceProvider?.getTracer(`archivist-sync-diviner [${name}]`)\n return await spanAsync(`initArchivistSync [${name}]`, async () => {\n const node = await MemoryNode.create({ account: 'random' })\n const finalizedArchivistSyncDiviner = await ArchivistSyncDiviner.create({\n account: 'random',\n inArchivist,\n outArchivist,\n tracer,\n config: { schema: DivinerConfigSchema, name },\n })\n\n await node.register(finalizedArchivistSyncDiviner)\n await node.attach(finalizedArchivistSyncDiviner.address)\n\n const sentinel = await MemorySentinel.create({\n account: 'random',\n config: {\n name,\n schema: SentinelConfigSchema,\n tasks: [\n {\n required: true,\n mod: finalizedArchivistSyncDiviner.address,\n endPoint: 'divine',\n },\n ],\n automations: [\n {\n frequency,\n frequencyUnits: 'millis',\n schema: 'network.xyo.automation.interval',\n start: Date.now(),\n type: 'interval',\n },\n ],\n },\n })\n\n await node.register(sentinel)\n await node.attach(sentinel.address)\n\n return node\n }, tracer)\n}\n","import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'\nimport { AttachableBridgeInstance } from '@xyo-network/bridge-model'\nimport { Mutex } from 'async-mutex'\n\nconst initMutex = new Mutex()\nconst bridgeSingletonMap = new Map<string, AttachableBridgeInstance>()\n\nexport const initBridge = async (nodeUrl: string): Promise<AttachableBridgeInstance> => {\n return await initMutex.runExclusive(async () => {\n const existing = bridgeSingletonMap.get(nodeUrl)\n if (existing) return existing\n const bridge = await HttpBridge.create({\n account: 'random',\n config: {\n name: 'HttpBridge',\n client: { url: nodeUrl, discoverRoots: 'start' },\n schema: HttpBridgeConfigSchema,\n security: { allowAnonymous: true },\n },\n })\n await bridge.start()\n bridgeSingletonMap.set(nodeUrl, bridge)\n return bridge\n })\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Initializable } from '@xyo-network/chain-model'\nimport { Address } from '@xylabs/hex'\nimport { asAttachableArchivistInstance, AttachableArchivistInstance } from '@xyo-network/archivist-model'\nimport { BridgeInstance } from '@xyo-network/bridge-model'\nimport {\n asAttachableModuleInstance, AttachableModuleInstance, ModuleIdentifier,\n} from '@xyo-network/module-model'\nimport { Mutex } from 'async-mutex'\n\nconst initMutex = new Mutex()\nconst bridgedModuleDictionary: Record<Address, Record<ModuleIdentifier, AttachableModuleInstance>> = {}\n\nexport const initBridgedModule: Initializable<\n { bridge: BridgeInstance; moduleName: ModuleIdentifier }, AttachableModuleInstance\n> = async ({ bridge, moduleName }): Promise<AttachableModuleInstance> => {\n return await initMutex.runExclusive(async () => {\n const existing = bridgedModuleDictionary?.[bridge.address]?.[moduleName]\n if (existing) return existing\n const mod = assertEx(await bridge.resolve(moduleName), () => `Error: Could not resolve ${moduleName}`)\n const moduleInstance = assertEx(asAttachableModuleInstance(mod), () => `Error: Could not convert ${moduleName} to attachable module instance`)\n bridgedModuleDictionary[bridge.address] = bridgedModuleDictionary[bridge.address] || {}\n bridgedModuleDictionary[bridge.address][moduleName] = moduleInstance\n return moduleInstance\n })\n}\n\nexport const initBridgedArchivistModule: Initializable<\n { bridge: BridgeInstance; moduleName: ModuleIdentifier }, AttachableArchivistInstance\n> = async ({ bridge, moduleName }): Promise<AttachableArchivistInstance> => {\n return assertEx(\n asAttachableArchivistInstance(await initBridgedModule({ bridge, moduleName })),\n () => `Error: Could not convert ${moduleName} to attachable archivist instance`,\n )\n}\n"],"mappings":"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","names":["ArchivistSyncDiviner","spanAsync","DivinerConfigSchema","MemoryNode","MemorySentinel","SentinelConfigSchema","initArchivistSync","name","inArchivist","outArchivist","frequency","traceProvider","tracer","getTracer","spanAsync","node","MemoryNode","create","account","finalizedArchivistSyncDiviner","ArchivistSyncDiviner","config","schema","DivinerConfigSchema","register","attach","address","sentinel","MemorySentinel","SentinelConfigSchema","tasks","required","mod","endPoint","automations","frequencyUnits","start","Date","now","type","HttpBridge","HttpBridgeConfigSchema","Mutex","initMutex","Mutex","bridgeSingletonMap","Map","initBridge","nodeUrl","runExclusive","existing","get","bridge","HttpBridge","create","account","config","name","client","url","discoverRoots","schema","HttpBridgeConfigSchema","security","allowAnonymous","start","set","assertEx","asAttachableArchivistInstance","asAttachableModuleInstance","Mutex","initMutex","Mutex","bridgedModuleDictionary","initBridgedModule","bridge","moduleName","runExclusive","existing","address","mod","assertEx","resolve","moduleInstance","asAttachableModuleInstance","initBridgedArchivistModule","asAttachableArchivistInstance"]}