@silvana-one/coordination 1.0.24 → 1.0.26
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/dist/node/agent.d.ts +43 -15
- package/dist/node/agent.js +129 -31
- package/dist/node/agent.js.map +1 -1
- package/dist/node/app_instance.d.ts +58 -0
- package/dist/node/app_instance.js +203 -0
- package/dist/node/app_instance.js.map +1 -0
- package/dist/node/build.d.ts +5 -0
- package/dist/node/build.js +21 -0
- package/dist/node/build.js.map +1 -0
- package/dist/node/execute.d.ts +1 -0
- package/dist/node/execute.js +10 -2
- package/dist/node/execute.js.map +1 -1
- package/dist/node/faucet.d.ts +34 -0
- package/dist/node/faucet.js +91 -0
- package/dist/node/faucet.js.map +1 -0
- package/dist/node/index.cjs +1087 -31
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +9 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/ipfs.d.ts +13 -0
- package/dist/node/ipfs.js +88 -0
- package/dist/node/ipfs.js.map +1 -0
- package/dist/node/job.d.ts +57 -0
- package/dist/node/job.js +168 -0
- package/dist/node/job.js.map +1 -0
- package/dist/node/package.d.ts +1 -0
- package/dist/node/package.js +6 -0
- package/dist/node/package.js.map +1 -0
- package/dist/node/public-key.d.ts +24 -0
- package/dist/node/public-key.js +44 -0
- package/dist/node/public-key.js.map +1 -0
- package/dist/node/publish.js.map +1 -1
- package/dist/node/test.d.ts +48 -0
- package/dist/node/test.js +278 -0
- package/dist/node/test.js.map +1 -0
- package/dist/node/upgrade.js +1 -12
- package/dist/node/upgrade.js.map +1 -1
- package/dist/node/walrus.d.ts +12 -0
- package/dist/node/walrus.js +73 -0
- package/dist/node/walrus.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsconfig.web.tsbuildinfo +1 -1
- package/dist/web/agent.d.ts +43 -15
- package/dist/web/agent.js +129 -31
- package/dist/web/agent.js.map +1 -1
- package/dist/web/app_instance.d.ts +58 -0
- package/dist/web/app_instance.js +203 -0
- package/dist/web/app_instance.js.map +1 -0
- package/dist/web/build.d.ts +5 -0
- package/dist/web/build.js +21 -0
- package/dist/web/build.js.map +1 -0
- package/dist/web/execute.d.ts +1 -0
- package/dist/web/execute.js +10 -2
- package/dist/web/execute.js.map +1 -1
- package/dist/web/faucet.d.ts +34 -0
- package/dist/web/faucet.js +91 -0
- package/dist/web/faucet.js.map +1 -0
- package/dist/web/index.d.ts +9 -0
- package/dist/web/index.js +9 -0
- package/dist/web/index.js.map +1 -1
- package/dist/web/ipfs.d.ts +13 -0
- package/dist/web/ipfs.js +88 -0
- package/dist/web/ipfs.js.map +1 -0
- package/dist/web/job.d.ts +57 -0
- package/dist/web/job.js +168 -0
- package/dist/web/job.js.map +1 -0
- package/dist/web/package.d.ts +1 -0
- package/dist/web/package.js +6 -0
- package/dist/web/package.js.map +1 -0
- package/dist/web/public-key.d.ts +24 -0
- package/dist/web/public-key.js +44 -0
- package/dist/web/public-key.js.map +1 -0
- package/dist/web/publish.js.map +1 -1
- package/dist/web/test.d.ts +48 -0
- package/dist/web/test.js +278 -0
- package/dist/web/test.js.map +1 -0
- package/dist/web/upgrade.js +1 -12
- package/dist/web/upgrade.js.map +1 -1
- package/dist/web/walrus.d.ts +12 -0
- package/dist/web/walrus.js +73 -0
- package/dist/web/walrus.js.map +1 -0
- package/package.json +7 -4
- package/src/agent.ts +204 -56
- package/src/app_instance.ts +264 -0
- package/src/build.ts +33 -0
- package/src/execute.ts +11 -2
- package/src/faucet.ts +145 -0
- package/src/index.ts +9 -0
- package/src/ipfs.ts +105 -0
- package/src/job.ts +223 -0
- package/src/package.ts +6 -0
- package/src/public-key.ts +66 -0
- package/src/publish.ts +0 -2
- package/src/test.ts +383 -0
- package/src/upgrade.ts +1 -18
- package/src/walrus.ts +96 -0
package/dist/node/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,27 +17,59 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// dist/node/index.js
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
AgentRegistry: () => AgentRegistry,
|
|
34
|
+
AppInstanceManager: () => AppInstanceManager,
|
|
35
|
+
JobManager: () => JobManager,
|
|
36
|
+
buildMovePackage: () => buildMovePackage,
|
|
24
37
|
buildPublishTx: () => buildPublishTx,
|
|
25
38
|
buildUpgradeTx: () => buildUpgradeTx,
|
|
26
39
|
convertFieldsToPublicKey: () => convertFieldsToPublicKey,
|
|
40
|
+
convertMinaPublicKey: () => convertMinaPublicKey,
|
|
41
|
+
convertMinaPublicKeyToFields: () => convertMinaPublicKeyToFields,
|
|
27
42
|
convertMinaSignatureFromBase58: () => convertMinaSignatureFromBase58,
|
|
28
43
|
convertMinaSignatureToBase58: () => convertMinaSignatureToBase58,
|
|
44
|
+
createTestApp: () => createTestApp,
|
|
45
|
+
createTestRegistry: () => createTestRegistry,
|
|
29
46
|
executeTx: () => executeTx,
|
|
30
47
|
fetchSuiDynamicField: () => fetchSuiDynamicField,
|
|
31
48
|
fetchSuiDynamicFieldsList: () => fetchSuiDynamicFieldsList,
|
|
32
49
|
fetchSuiObject: () => fetchSuiObject,
|
|
50
|
+
getIPFSUrl: () => getIPFSUrl,
|
|
51
|
+
getWalrusUrl: () => getWalrusUrl,
|
|
33
52
|
network: () => network,
|
|
53
|
+
publicKeyToU256: () => publicKeyToU256,
|
|
34
54
|
publishCodeToMVR: () => publishCodeToMVR,
|
|
35
55
|
publishToMVR: () => publishToMVR,
|
|
56
|
+
readFromIPFS: () => readFromIPFS,
|
|
57
|
+
readFromWalrus: () => readFromWalrus,
|
|
58
|
+
saveToIPFS: () => saveToIPFS,
|
|
59
|
+
saveToWalrus: () => saveToWalrus,
|
|
60
|
+
signFields: () => signFields,
|
|
61
|
+
silvanaFaucet: () => silvanaFaucet,
|
|
62
|
+
silvanaFaucetGetKey: () => silvanaFaucetGetKey,
|
|
63
|
+
silvanaFaucetPingKey: () => silvanaFaucetPingKey,
|
|
64
|
+
silvanaFaucetReturnKey: () => silvanaFaucetReturnKey,
|
|
65
|
+
silvanaRegistryPackage: () => silvanaRegistryPackage,
|
|
36
66
|
sleep: () => sleep,
|
|
37
67
|
suiClient: () => suiClient,
|
|
38
|
-
|
|
68
|
+
u256ToFields: () => u256ToFields,
|
|
69
|
+
u256ToPublicKey: () => u256ToPublicKey,
|
|
70
|
+
verifyFields: () => verifyFields,
|
|
71
|
+
waitTx: () => waitTx,
|
|
72
|
+
walrusDaemon: () => walrusDaemon
|
|
39
73
|
});
|
|
40
74
|
module.exports = __toCommonJS(index_exports);
|
|
41
75
|
|
|
@@ -413,10 +447,17 @@ async function executeTx(params) {
|
|
|
413
447
|
await releaseLock({ address, id: lockId });
|
|
414
448
|
}
|
|
415
449
|
if (executedTx?.effects?.status?.status === "failure") {
|
|
450
|
+
const errorMessage = executedTx?.effects?.status?.error || "Unknown error";
|
|
416
451
|
if (showErrors) {
|
|
417
|
-
console.log(`Errors for tx ${executedTx.digest}:`,
|
|
418
|
-
throw new Error(`tx execution failed: ${executedTx.digest}`);
|
|
452
|
+
console.log(`Errors for tx ${executedTx.digest}:`, errorMessage);
|
|
419
453
|
}
|
|
454
|
+
return {
|
|
455
|
+
tx: executedTx,
|
|
456
|
+
digest: executedTx.digest,
|
|
457
|
+
events: executedTx?.events?.[0]?.parsedJson,
|
|
458
|
+
executeTime: end - start,
|
|
459
|
+
error: errorMessage
|
|
460
|
+
};
|
|
420
461
|
}
|
|
421
462
|
return {
|
|
422
463
|
tx: executedTx,
|
|
@@ -504,8 +545,6 @@ async function buildUpgradeTx(params) {
|
|
|
504
545
|
tx.setGasOwner(address);
|
|
505
546
|
tx.setGasPayment(coins);
|
|
506
547
|
tx.setGasBudget(3e8);
|
|
507
|
-
console.time("sign");
|
|
508
|
-
console.timeEnd("sign");
|
|
509
548
|
return { tx };
|
|
510
549
|
}
|
|
511
550
|
|
|
@@ -614,6 +653,9 @@ async function fetchSuiDynamicField(params) {
|
|
|
614
653
|
}
|
|
615
654
|
}
|
|
616
655
|
|
|
656
|
+
// dist/node/package.js
|
|
657
|
+
var silvanaRegistryPackage = process.env.SILVANA_REGISTRY_PACKAGE ?? process.env.NEXT_PUBLIC_SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent";
|
|
658
|
+
|
|
617
659
|
// dist/node/agent.js
|
|
618
660
|
var AgentRegistry = class {
|
|
619
661
|
constructor(params) {
|
|
@@ -623,7 +665,7 @@ var AgentRegistry = class {
|
|
|
623
665
|
console.log("Creating agent registry", params.name);
|
|
624
666
|
const transaction = new import_transactions6.Transaction();
|
|
625
667
|
transaction.moveCall({
|
|
626
|
-
target:
|
|
668
|
+
target: `${silvanaRegistryPackage}::registry::create_registry`,
|
|
627
669
|
arguments: [transaction.pure.string(params.name)]
|
|
628
670
|
});
|
|
629
671
|
return transaction;
|
|
@@ -632,7 +674,7 @@ var AgentRegistry = class {
|
|
|
632
674
|
const { name, github, image, description, site } = params;
|
|
633
675
|
const tx = new import_transactions6.Transaction();
|
|
634
676
|
tx.moveCall({
|
|
635
|
-
target:
|
|
677
|
+
target: `${silvanaRegistryPackage}::registry::add_developer`,
|
|
636
678
|
arguments: [
|
|
637
679
|
tx.object(this.registry),
|
|
638
680
|
tx.pure.string(name),
|
|
@@ -649,7 +691,7 @@ var AgentRegistry = class {
|
|
|
649
691
|
const { name, github, image, description, site } = params;
|
|
650
692
|
const tx = new import_transactions6.Transaction();
|
|
651
693
|
tx.moveCall({
|
|
652
|
-
target:
|
|
694
|
+
target: `${silvanaRegistryPackage}::registry::update_developer`,
|
|
653
695
|
arguments: [
|
|
654
696
|
tx.object(this.registry),
|
|
655
697
|
tx.pure.string(name),
|
|
@@ -666,7 +708,7 @@ var AgentRegistry = class {
|
|
|
666
708
|
const { name, agentNames } = params;
|
|
667
709
|
const tx = new import_transactions6.Transaction();
|
|
668
710
|
tx.moveCall({
|
|
669
|
-
target:
|
|
711
|
+
target: `${silvanaRegistryPackage}::registry::remove_developer`,
|
|
670
712
|
arguments: [
|
|
671
713
|
tx.object(this.registry),
|
|
672
714
|
tx.pure.string(name),
|
|
@@ -677,10 +719,10 @@ var AgentRegistry = class {
|
|
|
677
719
|
return tx;
|
|
678
720
|
}
|
|
679
721
|
createAgent(params) {
|
|
680
|
-
const { developer, name, image, description, site,
|
|
722
|
+
const { developer, name, image, description, site, chains } = params;
|
|
681
723
|
const tx = new import_transactions6.Transaction();
|
|
682
724
|
tx.moveCall({
|
|
683
|
-
target:
|
|
725
|
+
target: `${silvanaRegistryPackage}::registry::add_agent`,
|
|
684
726
|
arguments: [
|
|
685
727
|
tx.object(this.registry),
|
|
686
728
|
tx.pure.string(developer),
|
|
@@ -688,11 +730,6 @@ var AgentRegistry = class {
|
|
|
688
730
|
tx.pure.option("string", image ?? null),
|
|
689
731
|
tx.pure.option("string", description ?? null),
|
|
690
732
|
tx.pure.option("string", site ?? null),
|
|
691
|
-
tx.pure.string(docker_image),
|
|
692
|
-
tx.pure.option("string", docker_sha256 ?? null),
|
|
693
|
-
tx.pure.u16(min_memory_gb),
|
|
694
|
-
tx.pure.u16(min_cpu_cores),
|
|
695
|
-
tx.pure.bool(supports_tee),
|
|
696
733
|
tx.pure.vector("string", chains),
|
|
697
734
|
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
698
735
|
]
|
|
@@ -700,10 +737,10 @@ var AgentRegistry = class {
|
|
|
700
737
|
return tx;
|
|
701
738
|
}
|
|
702
739
|
updateAgent(params) {
|
|
703
|
-
const { developer, name, image, description, site,
|
|
740
|
+
const { developer, name, image, description, site, chains } = params;
|
|
704
741
|
const tx = new import_transactions6.Transaction();
|
|
705
742
|
tx.moveCall({
|
|
706
|
-
target:
|
|
743
|
+
target: `${silvanaRegistryPackage}::registry::update_agent`,
|
|
707
744
|
arguments: [
|
|
708
745
|
tx.object(this.registry),
|
|
709
746
|
tx.pure.string(developer),
|
|
@@ -711,11 +748,6 @@ var AgentRegistry = class {
|
|
|
711
748
|
tx.pure.option("string", image ?? null),
|
|
712
749
|
tx.pure.option("string", description ?? null),
|
|
713
750
|
tx.pure.option("string", site ?? null),
|
|
714
|
-
tx.pure.string(docker_image),
|
|
715
|
-
tx.pure.option("string", docker_sha256 ?? null),
|
|
716
|
-
tx.pure.u16(min_memory_gb),
|
|
717
|
-
tx.pure.u16(min_cpu_cores),
|
|
718
|
-
tx.pure.bool(supports_tee),
|
|
719
751
|
tx.pure.vector("string", chains),
|
|
720
752
|
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
721
753
|
]
|
|
@@ -726,7 +758,91 @@ var AgentRegistry = class {
|
|
|
726
758
|
const { developer, agent } = params;
|
|
727
759
|
const tx = new import_transactions6.Transaction();
|
|
728
760
|
tx.moveCall({
|
|
729
|
-
target:
|
|
761
|
+
target: `${silvanaRegistryPackage}::registry::remove_agent`,
|
|
762
|
+
arguments: [
|
|
763
|
+
tx.object(this.registry),
|
|
764
|
+
tx.pure.string(developer),
|
|
765
|
+
tx.pure.string(agent),
|
|
766
|
+
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
767
|
+
]
|
|
768
|
+
});
|
|
769
|
+
return tx;
|
|
770
|
+
}
|
|
771
|
+
addAgentMethod(params) {
|
|
772
|
+
const { developer, agent, method, dockerImage, dockerSha256, minMemoryGb, minCpuCores, requiresTee } = params;
|
|
773
|
+
const tx = new import_transactions6.Transaction();
|
|
774
|
+
tx.moveCall({
|
|
775
|
+
target: `${silvanaRegistryPackage}::registry::add_method`,
|
|
776
|
+
arguments: [
|
|
777
|
+
tx.object(this.registry),
|
|
778
|
+
tx.pure.string(developer),
|
|
779
|
+
tx.pure.string(agent),
|
|
780
|
+
tx.pure.string(method),
|
|
781
|
+
tx.pure.string(dockerImage),
|
|
782
|
+
tx.pure.option("string", dockerSha256 ?? null),
|
|
783
|
+
tx.pure.u16(minMemoryGb),
|
|
784
|
+
tx.pure.u16(minCpuCores),
|
|
785
|
+
tx.pure.bool(requiresTee),
|
|
786
|
+
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
787
|
+
]
|
|
788
|
+
});
|
|
789
|
+
return tx;
|
|
790
|
+
}
|
|
791
|
+
updateAgentMethod(params) {
|
|
792
|
+
const { developer, agent, method, dockerImage, dockerSha256, minMemoryGb, minCpuCores, requiresTee } = params;
|
|
793
|
+
const tx = new import_transactions6.Transaction();
|
|
794
|
+
tx.moveCall({
|
|
795
|
+
target: `${silvanaRegistryPackage}::registry::update_method`,
|
|
796
|
+
arguments: [
|
|
797
|
+
tx.object(this.registry),
|
|
798
|
+
tx.pure.string(developer),
|
|
799
|
+
tx.pure.string(agent),
|
|
800
|
+
tx.pure.string(method),
|
|
801
|
+
tx.pure.string(dockerImage),
|
|
802
|
+
tx.pure.option("string", dockerSha256 ?? null),
|
|
803
|
+
tx.pure.u16(minMemoryGb),
|
|
804
|
+
tx.pure.u16(minCpuCores),
|
|
805
|
+
tx.pure.bool(requiresTee),
|
|
806
|
+
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
807
|
+
]
|
|
808
|
+
});
|
|
809
|
+
return tx;
|
|
810
|
+
}
|
|
811
|
+
removeAgentMethod(params) {
|
|
812
|
+
const { developer, agent, method } = params;
|
|
813
|
+
const tx = new import_transactions6.Transaction();
|
|
814
|
+
tx.moveCall({
|
|
815
|
+
target: `${silvanaRegistryPackage}::registry::remove_method`,
|
|
816
|
+
arguments: [
|
|
817
|
+
tx.object(this.registry),
|
|
818
|
+
tx.pure.string(developer),
|
|
819
|
+
tx.pure.string(agent),
|
|
820
|
+
tx.pure.string(method),
|
|
821
|
+
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
822
|
+
]
|
|
823
|
+
});
|
|
824
|
+
return tx;
|
|
825
|
+
}
|
|
826
|
+
setDefaultMethod(params) {
|
|
827
|
+
const { developer, agent, method } = params;
|
|
828
|
+
const tx = new import_transactions6.Transaction();
|
|
829
|
+
tx.moveCall({
|
|
830
|
+
target: `${silvanaRegistryPackage}::registry::set_default_method`,
|
|
831
|
+
arguments: [
|
|
832
|
+
tx.object(this.registry),
|
|
833
|
+
tx.pure.string(developer),
|
|
834
|
+
tx.pure.string(agent),
|
|
835
|
+
tx.pure.string(method),
|
|
836
|
+
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)
|
|
837
|
+
]
|
|
838
|
+
});
|
|
839
|
+
return tx;
|
|
840
|
+
}
|
|
841
|
+
removeDefaultMethod(params) {
|
|
842
|
+
const { developer, agent } = params;
|
|
843
|
+
const tx = new import_transactions6.Transaction();
|
|
844
|
+
tx.moveCall({
|
|
845
|
+
target: `${silvanaRegistryPackage}::registry::remove_default_method`,
|
|
730
846
|
arguments: [
|
|
731
847
|
tx.object(this.registry),
|
|
732
848
|
tx.pure.string(developer),
|
|
@@ -814,22 +930,48 @@ var AgentRegistry = class {
|
|
|
814
930
|
if (!agentObject) {
|
|
815
931
|
return void 0;
|
|
816
932
|
}
|
|
933
|
+
const methods = {};
|
|
934
|
+
const methodsData = agentObject?.methods?.fields?.contents;
|
|
935
|
+
if (methodsData && Array.isArray(methodsData)) {
|
|
936
|
+
for (const entry of methodsData) {
|
|
937
|
+
const key = entry?.fields?.key;
|
|
938
|
+
const value = entry?.fields?.value;
|
|
939
|
+
if (key && value) {
|
|
940
|
+
methods[key] = {
|
|
941
|
+
dockerImage: value.docker_image,
|
|
942
|
+
dockerSha256: value.docker_sha256 ?? void 0,
|
|
943
|
+
minMemoryGb: Number(value.min_memory_gb),
|
|
944
|
+
minCpuCores: Number(value.min_cpu_cores),
|
|
945
|
+
requiresTee: Boolean(value.requires_tee)
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
let defaultMethod;
|
|
951
|
+
const defaultMethodData = agentObject?.default_method;
|
|
952
|
+
if (defaultMethodData && typeof defaultMethodData === "object" && !Array.isArray(defaultMethodData)) {
|
|
953
|
+
defaultMethod = {
|
|
954
|
+
dockerImage: defaultMethodData.docker_image,
|
|
955
|
+
dockerSha256: defaultMethodData.docker_sha256 ?? void 0,
|
|
956
|
+
minMemoryGb: Number(defaultMethodData.min_memory_gb),
|
|
957
|
+
minCpuCores: Number(defaultMethodData.min_cpu_cores),
|
|
958
|
+
requiresTee: Boolean(defaultMethodData.requires_tee)
|
|
959
|
+
};
|
|
960
|
+
}
|
|
817
961
|
const agent = {
|
|
818
962
|
id: agentObject?.id?.id,
|
|
819
963
|
name: agentObject.name,
|
|
820
964
|
image: agentObject?.image ?? void 0,
|
|
821
965
|
description: agentObject?.description ?? void 0,
|
|
822
966
|
site: agentObject?.site ?? void 0,
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
minCpuCores: Number(agentObject.min_cpu_cores),
|
|
827
|
-
supportsTEE: Boolean(agentObject.supports_tee),
|
|
967
|
+
chains: agentObject?.chains ?? [],
|
|
968
|
+
methods,
|
|
969
|
+
defaultMethod,
|
|
828
970
|
createdAt: Number(agentObject.created_at),
|
|
829
971
|
updatedAt: Number(agentObject.updated_at),
|
|
830
972
|
version: Number(agentObject.version)
|
|
831
973
|
};
|
|
832
|
-
if (!agent.id || !agent.name
|
|
974
|
+
if (!agent.id || !agent.name) {
|
|
833
975
|
return void 0;
|
|
834
976
|
}
|
|
835
977
|
return agent;
|
|
@@ -906,22 +1048,936 @@ var AgentRegistry = class {
|
|
|
906
1048
|
}
|
|
907
1049
|
}
|
|
908
1050
|
};
|
|
1051
|
+
|
|
1052
|
+
// dist/node/build.js
|
|
1053
|
+
async function buildMovePackage(path) {
|
|
1054
|
+
const { execSync } = await import("child_process");
|
|
1055
|
+
let bytes = void 0;
|
|
1056
|
+
console.log("Running sui client publish command...");
|
|
1057
|
+
try {
|
|
1058
|
+
const output = execSync(`sui move build --dump-bytecode-as-base64 --ignore-chain --path ${path}`, {
|
|
1059
|
+
encoding: "utf-8"
|
|
1060
|
+
});
|
|
1061
|
+
bytes = JSON.parse(output);
|
|
1062
|
+
if (!bytes) {
|
|
1063
|
+
throw new Error("Error building package");
|
|
1064
|
+
}
|
|
1065
|
+
return bytes;
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
console.error("Error running command:", error);
|
|
1068
|
+
throw error;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// dist/node/walrus.js
|
|
1073
|
+
var walrusDaemon = process.env.NEXT_PUBLIC_WALRUS_DAEMON || process.env.WALRUS_DAEMON || "testnet";
|
|
1074
|
+
var daemon = walrusDaemon === "local" ? "local" : "testnet";
|
|
1075
|
+
var basePublisherUrl = daemon === "local" ? "http://127.0.0.1:31415" : "https://wal-publisher-testnet.staketab.org";
|
|
1076
|
+
var readerUrl = daemon === "local" ? "http://127.0.0.1:31415/v1/blobs/" : "https://wal-aggregator-testnet.staketab.org/v1/blobs/";
|
|
1077
|
+
var MIN_EPOCHS = 14;
|
|
1078
|
+
var MAX_EPOCHS = 53;
|
|
1079
|
+
async function saveToWalrus({ data, address, numEpochs = MIN_EPOCHS }) {
|
|
1080
|
+
let sendToParam = address ? `&send_object_to=${address}` : "";
|
|
1081
|
+
let epochs = numEpochs < MIN_EPOCHS ? MIN_EPOCHS : numEpochs > MAX_EPOCHS ? MAX_EPOCHS : numEpochs;
|
|
1082
|
+
console.log("Writing to Walrus");
|
|
1083
|
+
console.time("written");
|
|
1084
|
+
const response = await fetch(`${basePublisherUrl}/v1/blobs?epochs=${epochs}${sendToParam}`, {
|
|
1085
|
+
method: "PUT",
|
|
1086
|
+
body: data
|
|
1087
|
+
});
|
|
1088
|
+
console.timeEnd("written");
|
|
1089
|
+
if (response.status === 200) {
|
|
1090
|
+
const info = await response.json();
|
|
1091
|
+
const blobId = info?.newlyCreated?.blobObject?.blobId ?? info?.alreadyCertified?.blobId;
|
|
1092
|
+
console.log("Walrus blobId", blobId);
|
|
1093
|
+
return blobId;
|
|
1094
|
+
} else {
|
|
1095
|
+
console.error("saveToDA failed:", {
|
|
1096
|
+
statusText: response.statusText,
|
|
1097
|
+
status: response.status
|
|
1098
|
+
});
|
|
1099
|
+
return void 0;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
async function readFromWalrus({ blobId }) {
|
|
1103
|
+
if (!blobId) {
|
|
1104
|
+
throw new Error("blobId is not provided");
|
|
1105
|
+
}
|
|
1106
|
+
console.log("Reading walrus blob", blobId);
|
|
1107
|
+
console.time("read");
|
|
1108
|
+
const response = await fetch(`${readerUrl}${blobId}`);
|
|
1109
|
+
console.timeEnd("read");
|
|
1110
|
+
if (!response.ok) {
|
|
1111
|
+
console.error("readFromDA failed:", {
|
|
1112
|
+
statusText: response.statusText,
|
|
1113
|
+
status: response.status
|
|
1114
|
+
});
|
|
1115
|
+
return void 0;
|
|
1116
|
+
} else {
|
|
1117
|
+
const blob = await response.text();
|
|
1118
|
+
return blob;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
async function getWalrusUrl(params) {
|
|
1122
|
+
const { blobId } = params;
|
|
1123
|
+
if (!blobId) {
|
|
1124
|
+
throw new Error("blobId is not set");
|
|
1125
|
+
}
|
|
1126
|
+
const url = `${readerUrl}${blobId}`;
|
|
1127
|
+
return url;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
// dist/node/faucet.js
|
|
1131
|
+
var import_ed25519 = require("@mysten/sui/keypairs/ed25519");
|
|
1132
|
+
async function silvanaFaucet(params) {
|
|
1133
|
+
const { address, amount = 1 } = params;
|
|
1134
|
+
const response = await fetch(`${silvanaFaucetEndpoint()}/fund`, {
|
|
1135
|
+
method: "POST",
|
|
1136
|
+
headers: {
|
|
1137
|
+
"Content-Type": "application/json"
|
|
1138
|
+
},
|
|
1139
|
+
body: JSON.stringify({
|
|
1140
|
+
address,
|
|
1141
|
+
amount
|
|
1142
|
+
})
|
|
1143
|
+
});
|
|
1144
|
+
if (!response.ok) {
|
|
1145
|
+
throw new Error(`Failed to fund address: ${address} ${amount} ${response.status} ${response.statusText}`);
|
|
1146
|
+
}
|
|
1147
|
+
return response.json();
|
|
1148
|
+
}
|
|
1149
|
+
async function silvanaFaucetGetKey(params = {
|
|
1150
|
+
autoReturn: false
|
|
1151
|
+
}) {
|
|
1152
|
+
const response = await fetch(`${silvanaFaucetEndpoint()}/get_key`, {
|
|
1153
|
+
method: "POST",
|
|
1154
|
+
headers: {
|
|
1155
|
+
"Content-Type": "application/json"
|
|
1156
|
+
},
|
|
1157
|
+
body: JSON.stringify({
|
|
1158
|
+
auto_return: params.autoReturn
|
|
1159
|
+
})
|
|
1160
|
+
});
|
|
1161
|
+
if (!response.ok) {
|
|
1162
|
+
throw new Error(`Failed to get key: ${response.status} ${response.statusText}`);
|
|
1163
|
+
}
|
|
1164
|
+
return response.json();
|
|
1165
|
+
}
|
|
1166
|
+
async function silvanaFaucetPingKey(params) {
|
|
1167
|
+
const { address } = params;
|
|
1168
|
+
if (!address) {
|
|
1169
|
+
return {
|
|
1170
|
+
message: "Address is required",
|
|
1171
|
+
success: false
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
const response = await fetch(`${silvanaFaucetEndpoint()}/ping_key`, {
|
|
1175
|
+
method: "POST",
|
|
1176
|
+
headers: {
|
|
1177
|
+
"Content-Type": "application/json"
|
|
1178
|
+
},
|
|
1179
|
+
body: JSON.stringify({
|
|
1180
|
+
address
|
|
1181
|
+
})
|
|
1182
|
+
});
|
|
1183
|
+
if (!response.ok) {
|
|
1184
|
+
throw new Error(`Failed to return key: ${response.status} ${response.statusText}`);
|
|
1185
|
+
}
|
|
1186
|
+
return response.json();
|
|
1187
|
+
}
|
|
1188
|
+
async function silvanaFaucetReturnKey(params) {
|
|
1189
|
+
const address = params.address ?? (params.secretKey ? import_ed25519.Ed25519Keypair.fromSecretKey(params.secretKey).toSuiAddress() : void 0);
|
|
1190
|
+
if (!address) {
|
|
1191
|
+
return {
|
|
1192
|
+
message: "Address or secret key is required",
|
|
1193
|
+
success: false
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
const response = await fetch(`${silvanaFaucetEndpoint()}/return_key`, {
|
|
1197
|
+
method: "POST",
|
|
1198
|
+
headers: {
|
|
1199
|
+
"Content-Type": "application/json"
|
|
1200
|
+
},
|
|
1201
|
+
body: JSON.stringify({
|
|
1202
|
+
address
|
|
1203
|
+
})
|
|
1204
|
+
});
|
|
1205
|
+
if (!response.ok) {
|
|
1206
|
+
throw new Error(`Failed to return key: ${response.status} ${response.statusText}`);
|
|
1207
|
+
}
|
|
1208
|
+
return response.json();
|
|
1209
|
+
}
|
|
1210
|
+
function silvanaFaucetEndpoint() {
|
|
1211
|
+
const silvanaFaucetEndpoint2 = process.env.SILVANA_FAUCET_ENDPOINT;
|
|
1212
|
+
if (!silvanaFaucetEndpoint2) {
|
|
1213
|
+
throw new Error("SILVANA_FAUCET_ENDPOINT is not set");
|
|
1214
|
+
}
|
|
1215
|
+
return silvanaFaucetEndpoint2;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// dist/node/ipfs.js
|
|
1219
|
+
var import_pinata = require("pinata");
|
|
1220
|
+
var pinataJwt = process.env.PINATA_JWT;
|
|
1221
|
+
var pinataGateway = process.env.PINATA_GATEWAY_URL;
|
|
1222
|
+
var pinataGatewayKey = process.env.PINATA_GATEWAY_API_KEY;
|
|
1223
|
+
var pinata = new import_pinata.PinataSDK({
|
|
1224
|
+
pinataJwt,
|
|
1225
|
+
pinataGateway,
|
|
1226
|
+
pinataGatewayKey
|
|
1227
|
+
});
|
|
1228
|
+
async function saveToIPFS(params) {
|
|
1229
|
+
try {
|
|
1230
|
+
if (!pinataJwt || !pinataGateway || !pinataGatewayKey) {
|
|
1231
|
+
throw new Error("PINATA_JWT, PINATA_GATEWAY_URL, or PINATA_GATEWAY_API_KEY is not set");
|
|
1232
|
+
}
|
|
1233
|
+
const { data, filename, owner, days, description } = params;
|
|
1234
|
+
if (data === void 0 || data === null)
|
|
1235
|
+
throw new Error("data is not set");
|
|
1236
|
+
if (typeof data !== "string")
|
|
1237
|
+
throw new Error("data is not a string");
|
|
1238
|
+
if (data.length === 0)
|
|
1239
|
+
throw new Error("data is empty");
|
|
1240
|
+
const file = new File([data], filename ?? "da", {
|
|
1241
|
+
type: "text/plain"
|
|
1242
|
+
});
|
|
1243
|
+
const expiry = days ? Date.now() + days * 24 * 60 * 60 * 1e3 : void 0;
|
|
1244
|
+
const keyvalues = {
|
|
1245
|
+
app: "dex:devnet",
|
|
1246
|
+
owner: owner ?? "",
|
|
1247
|
+
expires: expiry ? new Date(expiry).toISOString() : "never",
|
|
1248
|
+
expiry: expiry ? expiry.toString() : "0",
|
|
1249
|
+
description: description ?? "",
|
|
1250
|
+
type: "text/plain",
|
|
1251
|
+
mime_type: "text/plain"
|
|
1252
|
+
};
|
|
1253
|
+
const upload = await pinata.upload.public.file(file, {
|
|
1254
|
+
metadata: {
|
|
1255
|
+
name: filename ?? "da",
|
|
1256
|
+
keyvalues
|
|
1257
|
+
}
|
|
1258
|
+
}).name(filename ?? "da");
|
|
1259
|
+
console.log("IPFS: ", upload.cid);
|
|
1260
|
+
return upload.cid;
|
|
1261
|
+
} catch (error) {
|
|
1262
|
+
console.error("Save to IPFS failed", error.message);
|
|
1263
|
+
return void 0;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
async function readFromIPFS(params) {
|
|
1267
|
+
const { blobId } = params;
|
|
1268
|
+
if (!blobId) {
|
|
1269
|
+
throw new Error("blobId is not set");
|
|
1270
|
+
}
|
|
1271
|
+
try {
|
|
1272
|
+
if (!pinataJwt || !pinataGateway || !pinataGatewayKey) {
|
|
1273
|
+
throw new Error("PINATA_JWT, PINATA_GATEWAY_URL, or PINATA_GATEWAY_API_KEY is not set");
|
|
1274
|
+
}
|
|
1275
|
+
const url = await getIPFSUrl({ blobId });
|
|
1276
|
+
const response = await fetch(url);
|
|
1277
|
+
if (!response.ok) {
|
|
1278
|
+
throw new Error("Failed to fetch from IPFS");
|
|
1279
|
+
}
|
|
1280
|
+
const data = await response.text();
|
|
1281
|
+
return data;
|
|
1282
|
+
} catch (error) {
|
|
1283
|
+
console.error("Read from IPFS failed", error);
|
|
1284
|
+
return void 0;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
async function getIPFSUrl(params) {
|
|
1288
|
+
const { blobId } = params;
|
|
1289
|
+
if (!blobId) {
|
|
1290
|
+
throw new Error("blobId is not set");
|
|
1291
|
+
}
|
|
1292
|
+
const gateway = process.env.PINATA_GATEWAY_URL ?? "https://gateway.pinata.cloud/ipfs/";
|
|
1293
|
+
const apiToken = process.env.PINATA_GATEWAY_API_KEY;
|
|
1294
|
+
const url = "https://" + gateway + "/ipfs/" + blobId + (apiToken ? "?pinataGatewayToken=" + apiToken : "");
|
|
1295
|
+
return url;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// dist/node/public-key.js
|
|
1299
|
+
var import_mina_signer = __toESM(require("mina-signer"), 1);
|
|
1300
|
+
var client = new import_mina_signer.default({
|
|
1301
|
+
network: "testnet"
|
|
1302
|
+
});
|
|
1303
|
+
function publicKeyToU256(publicKey) {
|
|
1304
|
+
const raw = client.publicKeyToRaw(publicKey);
|
|
1305
|
+
const swappedRaw = raw.match(/.{1,2}/g)?.reverse().join("") || "";
|
|
1306
|
+
const u256 = BigInt("0x" + swappedRaw);
|
|
1307
|
+
return u256;
|
|
1308
|
+
}
|
|
1309
|
+
var MAX_BIT = 2n ** 255n;
|
|
1310
|
+
function u256ToFields(u256) {
|
|
1311
|
+
const isOdd = (u256 & MAX_BIT) != 0n;
|
|
1312
|
+
const x = u256 - (isOdd ? MAX_BIT : 0n);
|
|
1313
|
+
return { x, isOdd };
|
|
1314
|
+
}
|
|
1315
|
+
function u256ToPublicKey(u256) {
|
|
1316
|
+
const { x, isOdd } = u256ToFields(u256);
|
|
1317
|
+
return convertFieldsToPublicKey({ x, isOdd });
|
|
1318
|
+
}
|
|
1319
|
+
function convertMinaPublicKey(publicKey) {
|
|
1320
|
+
const u256 = publicKeyToU256(publicKey);
|
|
1321
|
+
return u256ToFields(u256);
|
|
1322
|
+
}
|
|
1323
|
+
function convertMinaPublicKeyToFields(publicKey) {
|
|
1324
|
+
if (!publicKey)
|
|
1325
|
+
return [];
|
|
1326
|
+
const { x, isOdd } = convertMinaPublicKey(publicKey);
|
|
1327
|
+
return [x, isOdd ? 1n : 0n];
|
|
1328
|
+
}
|
|
1329
|
+
function signFields(params) {
|
|
1330
|
+
const { privateKey, fields } = params;
|
|
1331
|
+
const signedData = client.signFields(fields.map(BigInt), privateKey);
|
|
1332
|
+
return signedData;
|
|
1333
|
+
}
|
|
1334
|
+
function verifyFields(params) {
|
|
1335
|
+
const { publicKey, fields, signature } = params;
|
|
1336
|
+
return client.verifyFields({ data: fields, publicKey, signature });
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
// dist/node/job.js
|
|
1340
|
+
var import_transactions7 = require("@mysten/sui/transactions");
|
|
1341
|
+
var import_utils2 = require("@mysten/sui/utils");
|
|
1342
|
+
var JobManager = class {
|
|
1343
|
+
constructor(params) {
|
|
1344
|
+
this.jobs = params.jobs;
|
|
1345
|
+
}
|
|
1346
|
+
static createJobs(maxAttempts) {
|
|
1347
|
+
const tx = new import_transactions7.Transaction();
|
|
1348
|
+
tx.moveCall({
|
|
1349
|
+
target: `${silvanaRegistryPackage}::jobs::create_jobs`,
|
|
1350
|
+
arguments: [
|
|
1351
|
+
tx.pure.option("u8", maxAttempts ?? null)
|
|
1352
|
+
]
|
|
1353
|
+
});
|
|
1354
|
+
return tx;
|
|
1355
|
+
}
|
|
1356
|
+
createJob(params) {
|
|
1357
|
+
const { description, developer, agent, agentMethod, app, appInstance, appInstanceMethod, sequences, data } = params;
|
|
1358
|
+
const tx = new import_transactions7.Transaction();
|
|
1359
|
+
tx.moveCall({
|
|
1360
|
+
target: `${silvanaRegistryPackage}::jobs::create_job`,
|
|
1361
|
+
arguments: [
|
|
1362
|
+
tx.object(this.jobs),
|
|
1363
|
+
tx.pure.option("string", description ?? null),
|
|
1364
|
+
tx.pure.string(developer),
|
|
1365
|
+
tx.pure.string(agent),
|
|
1366
|
+
tx.pure.string(agentMethod),
|
|
1367
|
+
tx.pure.string(app),
|
|
1368
|
+
tx.pure.string(appInstance),
|
|
1369
|
+
tx.pure.string(appInstanceMethod),
|
|
1370
|
+
tx.pure.option("vector<u64>", sequences ?? null),
|
|
1371
|
+
tx.pure.vector("u8", Array.from(data)),
|
|
1372
|
+
tx.object(import_utils2.SUI_CLOCK_OBJECT_ID)
|
|
1373
|
+
]
|
|
1374
|
+
});
|
|
1375
|
+
return tx;
|
|
1376
|
+
}
|
|
1377
|
+
startJob(jobId) {
|
|
1378
|
+
const tx = new import_transactions7.Transaction();
|
|
1379
|
+
tx.moveCall({
|
|
1380
|
+
target: `${silvanaRegistryPackage}::jobs::start_job`,
|
|
1381
|
+
arguments: [
|
|
1382
|
+
tx.object(this.jobs),
|
|
1383
|
+
tx.pure.u64(jobId),
|
|
1384
|
+
tx.object(import_utils2.SUI_CLOCK_OBJECT_ID)
|
|
1385
|
+
]
|
|
1386
|
+
});
|
|
1387
|
+
return tx;
|
|
1388
|
+
}
|
|
1389
|
+
completeJob(jobId) {
|
|
1390
|
+
const tx = new import_transactions7.Transaction();
|
|
1391
|
+
tx.moveCall({
|
|
1392
|
+
target: `${silvanaRegistryPackage}::jobs::complete_job`,
|
|
1393
|
+
arguments: [
|
|
1394
|
+
tx.object(this.jobs),
|
|
1395
|
+
tx.pure.u64(jobId)
|
|
1396
|
+
]
|
|
1397
|
+
});
|
|
1398
|
+
return tx;
|
|
1399
|
+
}
|
|
1400
|
+
failJob(params) {
|
|
1401
|
+
const { jobId, error } = params;
|
|
1402
|
+
const tx = new import_transactions7.Transaction();
|
|
1403
|
+
tx.moveCall({
|
|
1404
|
+
target: `${silvanaRegistryPackage}::jobs::fail_job`,
|
|
1405
|
+
arguments: [
|
|
1406
|
+
tx.object(this.jobs),
|
|
1407
|
+
tx.pure.u64(jobId),
|
|
1408
|
+
tx.pure.string(error),
|
|
1409
|
+
tx.object(import_utils2.SUI_CLOCK_OBJECT_ID)
|
|
1410
|
+
]
|
|
1411
|
+
});
|
|
1412
|
+
return tx;
|
|
1413
|
+
}
|
|
1414
|
+
updateMaxAttempts(maxAttempts) {
|
|
1415
|
+
const tx = new import_transactions7.Transaction();
|
|
1416
|
+
tx.moveCall({
|
|
1417
|
+
target: `${silvanaRegistryPackage}::jobs::update_max_attempts`,
|
|
1418
|
+
arguments: [
|
|
1419
|
+
tx.object(this.jobs),
|
|
1420
|
+
tx.pure.u64(maxAttempts)
|
|
1421
|
+
]
|
|
1422
|
+
});
|
|
1423
|
+
return tx;
|
|
1424
|
+
}
|
|
1425
|
+
async getJob(jobId) {
|
|
1426
|
+
try {
|
|
1427
|
+
const jobsObject = await fetchSuiObject(this.jobs);
|
|
1428
|
+
if (!jobsObject)
|
|
1429
|
+
return void 0;
|
|
1430
|
+
const jobsTableId = jobsObject?.jobs?.fields?.id?.id;
|
|
1431
|
+
if (!jobsTableId)
|
|
1432
|
+
return void 0;
|
|
1433
|
+
const job = await fetchSuiDynamicField({
|
|
1434
|
+
parentID: jobsTableId,
|
|
1435
|
+
fieldName: "jobs",
|
|
1436
|
+
type: "u64",
|
|
1437
|
+
key: String(jobId)
|
|
1438
|
+
});
|
|
1439
|
+
if (!job)
|
|
1440
|
+
return void 0;
|
|
1441
|
+
const parseStatus = (status) => {
|
|
1442
|
+
if (status?.Pending !== void 0)
|
|
1443
|
+
return { type: "Pending" };
|
|
1444
|
+
if (status?.Running !== void 0)
|
|
1445
|
+
return { type: "Running" };
|
|
1446
|
+
if (status?.Failed !== void 0)
|
|
1447
|
+
return { type: "Failed", error: status.Failed };
|
|
1448
|
+
return { type: "Pending" };
|
|
1449
|
+
};
|
|
1450
|
+
return {
|
|
1451
|
+
id: job?.id?.id,
|
|
1452
|
+
jobId: Number(job.job_id),
|
|
1453
|
+
description: job?.description ?? void 0,
|
|
1454
|
+
developer: job.developer,
|
|
1455
|
+
agent: job.agent,
|
|
1456
|
+
agentMethod: job.agent_method,
|
|
1457
|
+
app: job.app,
|
|
1458
|
+
appInstance: job.app_instance,
|
|
1459
|
+
appInstanceMethod: job.app_instance_method,
|
|
1460
|
+
sequences: job?.sequences?.map((s) => Number(s)) ?? void 0,
|
|
1461
|
+
data: new Uint8Array(job.data),
|
|
1462
|
+
status: parseStatus(job.status),
|
|
1463
|
+
attempts: Number(job.attempts),
|
|
1464
|
+
createdAt: Number(job.created_at),
|
|
1465
|
+
updatedAt: Number(job.updated_at)
|
|
1466
|
+
};
|
|
1467
|
+
} catch (error) {
|
|
1468
|
+
console.error("Error fetching job:", error);
|
|
1469
|
+
return void 0;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
async getPendingJobs() {
|
|
1473
|
+
try {
|
|
1474
|
+
const jobsObject = await fetchSuiObject(this.jobs);
|
|
1475
|
+
if (!jobsObject)
|
|
1476
|
+
return [];
|
|
1477
|
+
const pendingJobs = jobsObject?.pending_jobs?.fields?.contents;
|
|
1478
|
+
if (!Array.isArray(pendingJobs))
|
|
1479
|
+
return [];
|
|
1480
|
+
return pendingJobs.map((id) => Number(id));
|
|
1481
|
+
} catch (error) {
|
|
1482
|
+
console.error("Error fetching pending jobs:", error);
|
|
1483
|
+
return [];
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
async getNextPendingJob() {
|
|
1487
|
+
const pendingJobs = await this.getPendingJobs();
|
|
1488
|
+
return pendingJobs.length > 0 ? pendingJobs[0] : void 0;
|
|
1489
|
+
}
|
|
1490
|
+
async getMaxAttempts() {
|
|
1491
|
+
try {
|
|
1492
|
+
const jobsObject = await fetchSuiObject(this.jobs);
|
|
1493
|
+
if (!jobsObject)
|
|
1494
|
+
return 3;
|
|
1495
|
+
return Number(jobsObject?.max_attempts ?? 3);
|
|
1496
|
+
} catch (error) {
|
|
1497
|
+
console.error("Error fetching max attempts:", error);
|
|
1498
|
+
return 3;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
// dist/node/app_instance.js
|
|
1504
|
+
var import_transactions8 = require("@mysten/sui/transactions");
|
|
1505
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
1506
|
+
var AppInstanceManager = class {
|
|
1507
|
+
constructor(params) {
|
|
1508
|
+
this.registry = params.registry;
|
|
1509
|
+
}
|
|
1510
|
+
// Note: update_method and remove_method functions are not available in the Move module
|
|
1511
|
+
// These would need to be implemented in app_instance.move if needed
|
|
1512
|
+
createAppJob(params) {
|
|
1513
|
+
const { appInstance, description, method, sequences, data } = params;
|
|
1514
|
+
console.log("createAppJob params:", {
|
|
1515
|
+
appInstance,
|
|
1516
|
+
description,
|
|
1517
|
+
method,
|
|
1518
|
+
sequences,
|
|
1519
|
+
data: data instanceof Uint8Array ? `Uint8Array(${data.length})` : typeof data,
|
|
1520
|
+
dataContent: data instanceof Uint8Array ? Array.from(data) : data
|
|
1521
|
+
});
|
|
1522
|
+
const tx = new import_transactions8.Transaction();
|
|
1523
|
+
tx.moveCall({
|
|
1524
|
+
target: `${silvanaRegistryPackage}::app_instance::create_app_job`,
|
|
1525
|
+
arguments: [
|
|
1526
|
+
tx.object(appInstance),
|
|
1527
|
+
tx.pure.string(method),
|
|
1528
|
+
tx.pure.option("string", description ?? null),
|
|
1529
|
+
tx.pure.option("vector<u64>", sequences ?? null),
|
|
1530
|
+
tx.pure.vector("u8", data),
|
|
1531
|
+
tx.object(import_utils3.SUI_CLOCK_OBJECT_ID)
|
|
1532
|
+
]
|
|
1533
|
+
});
|
|
1534
|
+
return tx;
|
|
1535
|
+
}
|
|
1536
|
+
startAppJob(params) {
|
|
1537
|
+
const { appInstance, jobId } = params;
|
|
1538
|
+
const tx = new import_transactions8.Transaction();
|
|
1539
|
+
tx.moveCall({
|
|
1540
|
+
target: `${silvanaRegistryPackage}::app_instance::start_app_job`,
|
|
1541
|
+
arguments: [
|
|
1542
|
+
tx.object(appInstance),
|
|
1543
|
+
tx.pure.u64(jobId),
|
|
1544
|
+
tx.object(import_utils3.SUI_CLOCK_OBJECT_ID)
|
|
1545
|
+
]
|
|
1546
|
+
});
|
|
1547
|
+
return tx;
|
|
1548
|
+
}
|
|
1549
|
+
completeAppJob(params) {
|
|
1550
|
+
const { appInstance, jobId } = params;
|
|
1551
|
+
const tx = new import_transactions8.Transaction();
|
|
1552
|
+
tx.moveCall({
|
|
1553
|
+
target: `${silvanaRegistryPackage}::app_instance::complete_app_job`,
|
|
1554
|
+
arguments: [
|
|
1555
|
+
tx.object(appInstance),
|
|
1556
|
+
tx.pure.u64(jobId),
|
|
1557
|
+
tx.object(import_utils3.SUI_CLOCK_OBJECT_ID)
|
|
1558
|
+
]
|
|
1559
|
+
});
|
|
1560
|
+
return tx;
|
|
1561
|
+
}
|
|
1562
|
+
failAppJob(params) {
|
|
1563
|
+
const { appInstance, jobId, error } = params;
|
|
1564
|
+
const tx = new import_transactions8.Transaction();
|
|
1565
|
+
tx.moveCall({
|
|
1566
|
+
target: `${silvanaRegistryPackage}::app_instance::fail_app_job`,
|
|
1567
|
+
arguments: [
|
|
1568
|
+
tx.object(appInstance),
|
|
1569
|
+
tx.pure.u64(jobId),
|
|
1570
|
+
tx.pure.string(error),
|
|
1571
|
+
tx.object(import_utils3.SUI_CLOCK_OBJECT_ID)
|
|
1572
|
+
]
|
|
1573
|
+
});
|
|
1574
|
+
return tx;
|
|
1575
|
+
}
|
|
1576
|
+
async getAppInstance(appInstanceId) {
|
|
1577
|
+
try {
|
|
1578
|
+
const appInstance = await fetchSuiObject(appInstanceId);
|
|
1579
|
+
if (!appInstance)
|
|
1580
|
+
return void 0;
|
|
1581
|
+
const fields = appInstance?.data?.content?.fields;
|
|
1582
|
+
if (!fields)
|
|
1583
|
+
return void 0;
|
|
1584
|
+
const methods = {};
|
|
1585
|
+
const methodsArray = fields?.methods?.fields?.contents;
|
|
1586
|
+
if (Array.isArray(methodsArray)) {
|
|
1587
|
+
for (const entry of methodsArray) {
|
|
1588
|
+
const key = entry?.fields?.key;
|
|
1589
|
+
const value = entry?.fields?.value;
|
|
1590
|
+
if (key && value) {
|
|
1591
|
+
const methodFields = value.fields || value;
|
|
1592
|
+
methods[key] = {
|
|
1593
|
+
description: methodFields.description ?? void 0,
|
|
1594
|
+
developer: methodFields.developer,
|
|
1595
|
+
agent: methodFields.agent,
|
|
1596
|
+
agentMethod: methodFields.agent_method || methodFields.agentMethod
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
return {
|
|
1602
|
+
id: fields?.id?.id,
|
|
1603
|
+
silvanaAppName: fields.silvana_app_name,
|
|
1604
|
+
description: fields?.description ?? void 0,
|
|
1605
|
+
metadata: fields?.metadata ?? void 0,
|
|
1606
|
+
methods,
|
|
1607
|
+
admin: fields.admin,
|
|
1608
|
+
sequence: Number(fields.sequence),
|
|
1609
|
+
blockNumber: Number(fields.block_number),
|
|
1610
|
+
previousBlockTimestamp: Number(fields.previous_block_timestamp),
|
|
1611
|
+
previousBlockLastSequence: Number(fields.previous_block_last_sequence),
|
|
1612
|
+
lastProvedBlockNumber: Number(fields.last_proved_block_number),
|
|
1613
|
+
isPaused: Boolean(fields.isPaused),
|
|
1614
|
+
jobsId: String(fields.jobs?.fields?.id?.id ?? ""),
|
|
1615
|
+
createdAt: Number(fields.created_at),
|
|
1616
|
+
updatedAt: Number(fields.updated_at)
|
|
1617
|
+
};
|
|
1618
|
+
} catch (error) {
|
|
1619
|
+
console.error("Error fetching app instance:", error);
|
|
1620
|
+
return void 0;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
async getAppJob(params) {
|
|
1624
|
+
try {
|
|
1625
|
+
const appInstanceObj = await fetchSuiObject(params.appInstance);
|
|
1626
|
+
if (!appInstanceObj)
|
|
1627
|
+
return void 0;
|
|
1628
|
+
const jobsTableId = appInstanceObj?.data?.content?.fields?.jobs?.fields?.jobs?.fields?.id?.id;
|
|
1629
|
+
if (!jobsTableId)
|
|
1630
|
+
return void 0;
|
|
1631
|
+
const job = await fetchSuiDynamicField({
|
|
1632
|
+
parentID: jobsTableId,
|
|
1633
|
+
fieldName: "jobs",
|
|
1634
|
+
type: "u64",
|
|
1635
|
+
key: String(params.jobId)
|
|
1636
|
+
});
|
|
1637
|
+
if (!job)
|
|
1638
|
+
return void 0;
|
|
1639
|
+
const parseStatus = (status) => {
|
|
1640
|
+
if (status?.variant === "Pending")
|
|
1641
|
+
return { type: "Pending" };
|
|
1642
|
+
if (status?.variant === "Running")
|
|
1643
|
+
return { type: "Running" };
|
|
1644
|
+
if (status?.variant === "Failed") {
|
|
1645
|
+
const error = status?.fields?.error || status?.fields?.[0] || "Unknown error";
|
|
1646
|
+
return { type: "Failed", error };
|
|
1647
|
+
}
|
|
1648
|
+
if (status?.Pending !== void 0)
|
|
1649
|
+
return { type: "Pending" };
|
|
1650
|
+
if (status?.Running !== void 0)
|
|
1651
|
+
return { type: "Running" };
|
|
1652
|
+
if (status?.Failed !== void 0)
|
|
1653
|
+
return { type: "Failed", error: status.Failed };
|
|
1654
|
+
return { type: "Pending" };
|
|
1655
|
+
};
|
|
1656
|
+
return {
|
|
1657
|
+
id: job?.id?.id,
|
|
1658
|
+
jobId: Number(job.job_id),
|
|
1659
|
+
description: job?.description ?? void 0,
|
|
1660
|
+
developer: job.developer,
|
|
1661
|
+
agent: job.agent,
|
|
1662
|
+
agentMethod: job.agent_method,
|
|
1663
|
+
app: job.app,
|
|
1664
|
+
appInstance: job.app_instance,
|
|
1665
|
+
appInstanceMethod: job.app_instance_method,
|
|
1666
|
+
sequences: job?.sequences?.map((s) => Number(s)) ?? void 0,
|
|
1667
|
+
data: new Uint8Array(job.data),
|
|
1668
|
+
status: parseStatus(job.status),
|
|
1669
|
+
attempts: Number(job.attempts),
|
|
1670
|
+
createdAt: Number(job.created_at),
|
|
1671
|
+
updatedAt: Number(job.updated_at)
|
|
1672
|
+
};
|
|
1673
|
+
} catch (error) {
|
|
1674
|
+
console.error("Error fetching app job:", error);
|
|
1675
|
+
return void 0;
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
async getAppPendingJobs(appInstance) {
|
|
1679
|
+
try {
|
|
1680
|
+
const appInstanceObj = await fetchSuiObject(appInstance);
|
|
1681
|
+
if (!appInstanceObj)
|
|
1682
|
+
return [];
|
|
1683
|
+
const pendingJobs = appInstanceObj?.data?.content?.fields?.jobs?.fields?.pending_jobs?.fields?.contents;
|
|
1684
|
+
if (!Array.isArray(pendingJobs))
|
|
1685
|
+
return [];
|
|
1686
|
+
return pendingJobs.map((id) => Number(id));
|
|
1687
|
+
} catch (error) {
|
|
1688
|
+
console.error("Error fetching app pending jobs:", error);
|
|
1689
|
+
return [];
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1694
|
+
// dist/node/test.js
|
|
1695
|
+
var import_ed255192 = require("@mysten/sui/keypairs/ed25519");
|
|
1696
|
+
var import_transactions9 = require("@mysten/sui/transactions");
|
|
1697
|
+
async function createTestRegistry(config = {}) {
|
|
1698
|
+
const registryName = config.registryName ?? "Test Silvana Registry";
|
|
1699
|
+
const developerName = config.developerName ?? "TestDev";
|
|
1700
|
+
const developerGithub = config.developerGithub ?? "testdev";
|
|
1701
|
+
const developerImage = config.developerImage;
|
|
1702
|
+
const developerDescription = config.developerDescription ?? "Test developer for automated testing";
|
|
1703
|
+
const developerSite = config.developerSite ?? "https://test.dev";
|
|
1704
|
+
const appName = config.appName ?? "TestApp";
|
|
1705
|
+
const appDescription = config.appDescription ?? "Test application for automated testing";
|
|
1706
|
+
const appImage = config.appImage;
|
|
1707
|
+
const appSite = config.appSite ?? "https://testapp.dev";
|
|
1708
|
+
const testAgentName = config.testAgentName ?? "TestAgent";
|
|
1709
|
+
const testAgentImage = config.testAgentImage;
|
|
1710
|
+
const testAgentChains = config.testAgentChains ?? ["sui-testnet", "sui-devnet"];
|
|
1711
|
+
const key = process.env.SUI_KEY;
|
|
1712
|
+
if (!key) {
|
|
1713
|
+
throw new Error("SUI_KEY is not set in environment");
|
|
1714
|
+
}
|
|
1715
|
+
const keyPair = import_ed255192.Ed25519Keypair.fromSecretKey(key);
|
|
1716
|
+
const address = keyPair.toSuiAddress();
|
|
1717
|
+
console.log("Creating test registry with sender address:", address);
|
|
1718
|
+
console.log("Chain:", process.env.SUI_CHAIN);
|
|
1719
|
+
console.log("Step 1: Creating registry...");
|
|
1720
|
+
const createRegistryTx = AgentRegistry.createAgentRegistry({
|
|
1721
|
+
name: registryName
|
|
1722
|
+
});
|
|
1723
|
+
createRegistryTx.setSender(address);
|
|
1724
|
+
createRegistryTx.setGasBudget(1e8);
|
|
1725
|
+
const registryResult = await executeTx({
|
|
1726
|
+
tx: createRegistryTx,
|
|
1727
|
+
keyPair
|
|
1728
|
+
});
|
|
1729
|
+
if (!registryResult) {
|
|
1730
|
+
throw new Error("Failed to create registry - no result");
|
|
1731
|
+
}
|
|
1732
|
+
if (registryResult.error) {
|
|
1733
|
+
throw new Error(`Failed to create registry: ${registryResult.error}`);
|
|
1734
|
+
}
|
|
1735
|
+
if (!registryResult.tx?.objectChanges) {
|
|
1736
|
+
throw new Error("Failed to create registry - no object changes");
|
|
1737
|
+
}
|
|
1738
|
+
const registryObject = registryResult.tx.objectChanges.find((obj) => obj.type === "created" && obj.objectType?.includes("::registry::SilvanaRegistry"));
|
|
1739
|
+
if (!registryObject || !("objectId" in registryObject)) {
|
|
1740
|
+
throw new Error("Failed to find created registry object");
|
|
1741
|
+
}
|
|
1742
|
+
const registryAddress = registryObject.objectId;
|
|
1743
|
+
console.log("Registry created with address:", registryAddress);
|
|
1744
|
+
if (registryResult.digest) {
|
|
1745
|
+
await waitTx(registryResult.digest);
|
|
1746
|
+
}
|
|
1747
|
+
const registry = new AgentRegistry({ registry: registryAddress });
|
|
1748
|
+
const appInstanceManager = new AppInstanceManager({ registry: registryAddress });
|
|
1749
|
+
console.log("Step 2: Creating developer...");
|
|
1750
|
+
const createDeveloperTx = registry.createDeveloper({
|
|
1751
|
+
name: developerName,
|
|
1752
|
+
github: developerGithub,
|
|
1753
|
+
image: developerImage,
|
|
1754
|
+
description: developerDescription,
|
|
1755
|
+
site: developerSite
|
|
1756
|
+
});
|
|
1757
|
+
createDeveloperTx.setSender(address);
|
|
1758
|
+
createDeveloperTx.setGasBudget(1e8);
|
|
1759
|
+
const developerResult = await executeTx({
|
|
1760
|
+
tx: createDeveloperTx,
|
|
1761
|
+
keyPair
|
|
1762
|
+
});
|
|
1763
|
+
if (!developerResult) {
|
|
1764
|
+
throw new Error("Failed to create developer - no result");
|
|
1765
|
+
}
|
|
1766
|
+
if (developerResult.error) {
|
|
1767
|
+
throw new Error(`Failed to create developer: ${developerResult.error}`);
|
|
1768
|
+
}
|
|
1769
|
+
if (developerResult.digest) {
|
|
1770
|
+
await waitTx(developerResult.digest);
|
|
1771
|
+
}
|
|
1772
|
+
console.log("Developer created:", developerName);
|
|
1773
|
+
console.log("Step 3: Creating app...");
|
|
1774
|
+
const createAppTx = new import_transactions9.Transaction();
|
|
1775
|
+
createAppTx.moveCall({
|
|
1776
|
+
target: `${process.env.SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent"}::registry::add_app`,
|
|
1777
|
+
arguments: [
|
|
1778
|
+
createAppTx.object(registryAddress),
|
|
1779
|
+
createAppTx.pure.string(appName),
|
|
1780
|
+
createAppTx.pure.option("string", appDescription),
|
|
1781
|
+
createAppTx.object("0x6")
|
|
1782
|
+
// SUI_CLOCK_OBJECT_ID
|
|
1783
|
+
]
|
|
1784
|
+
});
|
|
1785
|
+
createAppTx.setSender(address);
|
|
1786
|
+
createAppTx.setGasBudget(1e8);
|
|
1787
|
+
const appResult = await executeTx({
|
|
1788
|
+
tx: createAppTx,
|
|
1789
|
+
keyPair
|
|
1790
|
+
});
|
|
1791
|
+
if (!appResult) {
|
|
1792
|
+
throw new Error("Failed to create app - no result");
|
|
1793
|
+
}
|
|
1794
|
+
if (appResult.error) {
|
|
1795
|
+
throw new Error(`Failed to create app: ${appResult.error}`);
|
|
1796
|
+
}
|
|
1797
|
+
if (appResult.digest) {
|
|
1798
|
+
await waitTx(appResult.digest);
|
|
1799
|
+
}
|
|
1800
|
+
console.log("App created:", appName);
|
|
1801
|
+
let agentName;
|
|
1802
|
+
if (config.testAgentName && config.testAgentChains) {
|
|
1803
|
+
console.log("Step 4: Creating agent...");
|
|
1804
|
+
const createAgentTx = registry.createAgent({
|
|
1805
|
+
developer: developerName,
|
|
1806
|
+
name: testAgentName,
|
|
1807
|
+
image: testAgentImage,
|
|
1808
|
+
description: "Test agent for automated testing",
|
|
1809
|
+
chains: testAgentChains
|
|
1810
|
+
});
|
|
1811
|
+
createAgentTx.setSender(address);
|
|
1812
|
+
createAgentTx.setGasBudget(1e8);
|
|
1813
|
+
const agentResult = await executeTx({
|
|
1814
|
+
tx: createAgentTx,
|
|
1815
|
+
keyPair
|
|
1816
|
+
});
|
|
1817
|
+
if (!agentResult) {
|
|
1818
|
+
throw new Error("Failed to create agent - no result");
|
|
1819
|
+
}
|
|
1820
|
+
if (agentResult.error) {
|
|
1821
|
+
throw new Error(`Failed to create agent: ${agentResult.error}`);
|
|
1822
|
+
}
|
|
1823
|
+
if (agentResult.digest) {
|
|
1824
|
+
await waitTx(agentResult.digest);
|
|
1825
|
+
}
|
|
1826
|
+
agentName = testAgentName;
|
|
1827
|
+
console.log("Agent created:", testAgentName);
|
|
1828
|
+
}
|
|
1829
|
+
console.log("Test registry setup complete!");
|
|
1830
|
+
console.log("Registry address:", registryAddress);
|
|
1831
|
+
console.log("Developer:", developerName);
|
|
1832
|
+
console.log("App:", appName);
|
|
1833
|
+
if (agentName) {
|
|
1834
|
+
console.log("Agent:", agentName);
|
|
1835
|
+
}
|
|
1836
|
+
return {
|
|
1837
|
+
registryAddress,
|
|
1838
|
+
developerName,
|
|
1839
|
+
appName,
|
|
1840
|
+
agentName,
|
|
1841
|
+
registry,
|
|
1842
|
+
appInstanceManager,
|
|
1843
|
+
keyPair,
|
|
1844
|
+
address
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
async function createTestApp(registryAddress, appName = "test_app") {
|
|
1848
|
+
const key = process.env.SUI_KEY;
|
|
1849
|
+
if (!key) {
|
|
1850
|
+
throw new Error("SUI_KEY is not set in environment");
|
|
1851
|
+
}
|
|
1852
|
+
const keyPair = import_ed255192.Ed25519Keypair.fromSecretKey(key);
|
|
1853
|
+
const address = keyPair.toSuiAddress();
|
|
1854
|
+
console.log("Creating TestApp with AppInstance...");
|
|
1855
|
+
console.log("Registry address:", registryAddress);
|
|
1856
|
+
console.log("Sender address:", address);
|
|
1857
|
+
const createAppTx = new import_transactions9.Transaction();
|
|
1858
|
+
createAppTx.moveCall({
|
|
1859
|
+
target: `${process.env.SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent"}::registry::add_app`,
|
|
1860
|
+
arguments: [
|
|
1861
|
+
createAppTx.object(registryAddress),
|
|
1862
|
+
createAppTx.pure.string(appName),
|
|
1863
|
+
createAppTx.pure.option("string", "Test app for TestApp module"),
|
|
1864
|
+
createAppTx.object("0x6")
|
|
1865
|
+
// SUI_CLOCK_OBJECT_ID
|
|
1866
|
+
]
|
|
1867
|
+
});
|
|
1868
|
+
createAppTx.setSender(address);
|
|
1869
|
+
createAppTx.setGasBudget(1e8);
|
|
1870
|
+
const appResult = await executeTx({
|
|
1871
|
+
tx: createAppTx,
|
|
1872
|
+
keyPair,
|
|
1873
|
+
showErrors: false
|
|
1874
|
+
// Don't throw, we'll handle the error
|
|
1875
|
+
});
|
|
1876
|
+
if (appResult?.digest && !appResult.error) {
|
|
1877
|
+
await waitTx(appResult.digest);
|
|
1878
|
+
console.log("App created:", appName);
|
|
1879
|
+
} else if (appResult?.error?.includes("0) in command 0")) {
|
|
1880
|
+
console.log("App already exists, continuing:", appName);
|
|
1881
|
+
} else if (appResult?.error) {
|
|
1882
|
+
throw new Error(`Failed to create app for TestApp: ${appResult.error}`);
|
|
1883
|
+
}
|
|
1884
|
+
const tx = new import_transactions9.Transaction();
|
|
1885
|
+
tx.moveCall({
|
|
1886
|
+
target: `${process.env.SILVANA_REGISTRY_PACKAGE ?? "@silvana/agent"}::test_app::create_test_app`,
|
|
1887
|
+
arguments: [
|
|
1888
|
+
tx.object(registryAddress),
|
|
1889
|
+
tx.object("0x6")
|
|
1890
|
+
// SUI_CLOCK_OBJECT_ID
|
|
1891
|
+
]
|
|
1892
|
+
});
|
|
1893
|
+
tx.setSender(address);
|
|
1894
|
+
tx.setGasBudget(1e8);
|
|
1895
|
+
const result = await executeTx({
|
|
1896
|
+
tx,
|
|
1897
|
+
keyPair
|
|
1898
|
+
});
|
|
1899
|
+
if (!result) {
|
|
1900
|
+
throw new Error("Failed to create TestApp - no result");
|
|
1901
|
+
}
|
|
1902
|
+
if (result.error) {
|
|
1903
|
+
throw new Error(`Failed to create TestApp: ${result.error}`);
|
|
1904
|
+
}
|
|
1905
|
+
if (!result.tx) {
|
|
1906
|
+
throw new Error("Failed to create TestApp - no transaction result");
|
|
1907
|
+
}
|
|
1908
|
+
if (result.digest) {
|
|
1909
|
+
const confirmedTx = await waitTx(result.digest);
|
|
1910
|
+
result.tx = confirmedTx;
|
|
1911
|
+
}
|
|
1912
|
+
if (!result?.tx?.objectChanges) {
|
|
1913
|
+
throw new Error("Failed to create TestApp - no object changes");
|
|
1914
|
+
}
|
|
1915
|
+
const testAppObject = result.tx.objectChanges.find((obj) => obj.type === "created" && obj.objectType?.includes("::test_app::TestApp"));
|
|
1916
|
+
if (!testAppObject || !("objectId" in testAppObject)) {
|
|
1917
|
+
throw new Error("Failed to find created TestApp object");
|
|
1918
|
+
}
|
|
1919
|
+
const appInstanceObject = result.tx.objectChanges.find((obj) => obj.type === "created" && obj.objectType?.includes("::app_instance::AppInstance"));
|
|
1920
|
+
if (!appInstanceObject || !("objectId" in appInstanceObject)) {
|
|
1921
|
+
throw new Error("Failed to find created AppInstance object");
|
|
1922
|
+
}
|
|
1923
|
+
const testAppAddress = testAppObject.objectId;
|
|
1924
|
+
const appInstanceAddress = appInstanceObject.objectId;
|
|
1925
|
+
const appInstanceCapAddress = testAppAddress;
|
|
1926
|
+
console.log("TestApp created:", testAppAddress);
|
|
1927
|
+
console.log("AppInstance created:", appInstanceAddress);
|
|
1928
|
+
console.log("AppInstanceCap created:", appInstanceCapAddress);
|
|
1929
|
+
const appInstanceManager = new AppInstanceManager({ registry: registryAddress });
|
|
1930
|
+
return {
|
|
1931
|
+
testAppAddress,
|
|
1932
|
+
appInstanceAddress,
|
|
1933
|
+
appInstanceCapAddress,
|
|
1934
|
+
registryAddress,
|
|
1935
|
+
appName,
|
|
1936
|
+
keyPair,
|
|
1937
|
+
address,
|
|
1938
|
+
appInstanceManager
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
909
1941
|
// Annotate the CommonJS export names for ESM import in node:
|
|
910
1942
|
0 && (module.exports = {
|
|
911
1943
|
AgentRegistry,
|
|
1944
|
+
AppInstanceManager,
|
|
1945
|
+
JobManager,
|
|
1946
|
+
buildMovePackage,
|
|
912
1947
|
buildPublishTx,
|
|
913
1948
|
buildUpgradeTx,
|
|
914
1949
|
convertFieldsToPublicKey,
|
|
1950
|
+
convertMinaPublicKey,
|
|
1951
|
+
convertMinaPublicKeyToFields,
|
|
915
1952
|
convertMinaSignatureFromBase58,
|
|
916
1953
|
convertMinaSignatureToBase58,
|
|
1954
|
+
createTestApp,
|
|
1955
|
+
createTestRegistry,
|
|
917
1956
|
executeTx,
|
|
918
1957
|
fetchSuiDynamicField,
|
|
919
1958
|
fetchSuiDynamicFieldsList,
|
|
920
1959
|
fetchSuiObject,
|
|
1960
|
+
getIPFSUrl,
|
|
1961
|
+
getWalrusUrl,
|
|
921
1962
|
network,
|
|
1963
|
+
publicKeyToU256,
|
|
922
1964
|
publishCodeToMVR,
|
|
923
1965
|
publishToMVR,
|
|
1966
|
+
readFromIPFS,
|
|
1967
|
+
readFromWalrus,
|
|
1968
|
+
saveToIPFS,
|
|
1969
|
+
saveToWalrus,
|
|
1970
|
+
signFields,
|
|
1971
|
+
silvanaFaucet,
|
|
1972
|
+
silvanaFaucetGetKey,
|
|
1973
|
+
silvanaFaucetPingKey,
|
|
1974
|
+
silvanaFaucetReturnKey,
|
|
1975
|
+
silvanaRegistryPackage,
|
|
924
1976
|
sleep,
|
|
925
1977
|
suiClient,
|
|
926
|
-
|
|
1978
|
+
u256ToFields,
|
|
1979
|
+
u256ToPublicKey,
|
|
1980
|
+
verifyFields,
|
|
1981
|
+
waitTx,
|
|
1982
|
+
walrusDaemon
|
|
927
1983
|
});
|