@agenticocean/vault 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-registry.d.ts +18 -0
- package/dist/agent-registry.d.ts.map +1 -0
- package/dist/agent-registry.js +32 -0
- package/dist/agent-registry.js.map +1 -0
- package/dist/contract-reader.d.ts +20 -0
- package/dist/contract-reader.d.ts.map +1 -0
- package/dist/contract-reader.js +64 -0
- package/dist/contract-reader.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/reputation-registry.d.ts +14 -0
- package/dist/reputation-registry.d.ts.map +1 -0
- package/dist/reputation-registry.js +28 -0
- package/dist/reputation-registry.js.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/user-vault.d.ts +18 -0
- package/dist/user-vault.d.ts.map +1 -0
- package/dist/user-vault.js +33 -0
- package/dist/user-vault.js.map +1 -0
- package/dist/validation-registry.d.ts +12 -0
- package/dist/validation-registry.d.ts.map +1 -0
- package/dist/validation-registry.js +19 -0
- package/dist/validation-registry.js.map +1 -0
- package/dist/vault-factory.d.ts +16 -0
- package/dist/vault-factory.d.ts.map +1 -0
- package/dist/vault-factory.js +28 -0
- package/dist/vault-factory.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StellarClientConfig, AgentInfo, LoggerLike } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read-only client for the AgentRegistry contract.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AgentRegistry {
|
|
6
|
+
private reader;
|
|
7
|
+
private registryAddress;
|
|
8
|
+
constructor(registryAddress: string, config: StellarClientConfig, logger?: LoggerLike);
|
|
9
|
+
/** List active agents starting from startId, up to limit. */
|
|
10
|
+
listAgents(startId?: number, limit?: number): Promise<AgentInfo[]>;
|
|
11
|
+
/** Get a specific agent by ID. */
|
|
12
|
+
getAgent(agentId: number): Promise<AgentInfo | null>;
|
|
13
|
+
/** Get the agent ID registered by a given owner address. */
|
|
14
|
+
getAgentByOwner(owner: string): Promise<number | null>;
|
|
15
|
+
/** Get the total number of active agents. */
|
|
16
|
+
getAgentCount(): Promise<number>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=agent-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-registry.d.ts","sourceRoot":"","sources":["../src/agent-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7E;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,eAAe,CAAS;gBAEpB,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,UAAU;IAKrF,6DAA6D;IACvD,UAAU,CAAC,OAAO,GAAE,MAAU,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAS/E,kCAAkC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAQ1D,4DAA4D;IACtD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQ5D,6CAA6C;IACvC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAIvC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { nativeToScVal } from "@stellar/stellar-sdk";
|
|
2
|
+
import { ContractReader } from "./contract-reader.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only client for the AgentRegistry contract.
|
|
5
|
+
*/
|
|
6
|
+
export class AgentRegistry {
|
|
7
|
+
reader;
|
|
8
|
+
registryAddress;
|
|
9
|
+
constructor(registryAddress, config, logger) {
|
|
10
|
+
this.registryAddress = registryAddress;
|
|
11
|
+
this.reader = new ContractReader(config, logger);
|
|
12
|
+
}
|
|
13
|
+
/** List active agents starting from startId, up to limit. */
|
|
14
|
+
async listAgents(startId = 1, limit = 10) {
|
|
15
|
+
const result = await this.reader.readContractValue(this.registryAddress, "list_agents", [nativeToScVal(startId, { type: "u32" }), nativeToScVal(limit, { type: "u32" })]);
|
|
16
|
+
return result || [];
|
|
17
|
+
}
|
|
18
|
+
/** Get a specific agent by ID. */
|
|
19
|
+
async getAgent(agentId) {
|
|
20
|
+
return await this.reader.readContractValue(this.registryAddress, "get_agent", [nativeToScVal(agentId, { type: "u32" })]);
|
|
21
|
+
}
|
|
22
|
+
/** Get the agent ID registered by a given owner address. */
|
|
23
|
+
async getAgentByOwner(owner) {
|
|
24
|
+
return await this.reader.readContractValue(this.registryAddress, "get_agent_by_owner", [nativeToScVal(owner, { type: "address" })]);
|
|
25
|
+
}
|
|
26
|
+
/** Get the total number of active agents. */
|
|
27
|
+
async getAgentCount() {
|
|
28
|
+
const count = await this.reader.readContractValue(this.registryAddress, "agent_count");
|
|
29
|
+
return count || 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=agent-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-registry.js","sourceRoot":"","sources":["../src/agent-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAiB;IACvB,eAAe,CAAS;IAEhC,YAAY,eAAuB,EAAE,MAA2B,EAAE,MAAmB;QACnF,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,IA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ader that simulates read-only contract calls.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ContractReader {
|
|
6
|
+
private rpc;
|
|
7
|
+
private simulationSource;
|
|
8
|
+
private passphrase;
|
|
9
|
+
private log;
|
|
10
|
+
constructor(config: StellarClientConfig, logger?: LoggerLike);
|
|
11
|
+
/**
|
|
12
|
+
* Simulate a read-only contract call and return the decoded result.
|
|
13
|
+
*/
|
|
14
|
+
readContractValue(contractId: string, method: string, args?: any[]): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Recursively convert BigInt values to numbers for JSON serialization.
|
|
17
|
+
*/
|
|
18
|
+
private convertBigInts;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=contract-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-reader.d.ts","sourceRoot":"","sources":["../src/contract-reader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIlE;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,GAAG,CAAa;gBAEZ,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,UAAU;IAO5D;;OAEG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,EAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAwB3F;;OAEG;IACH,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Contract, scValToNative, TransactionBuilder } from "@stellar/stellar-sdk";
|
|
2
|
+
import { Server } from "@stellar/stellar-sdk/rpc";
|
|
3
|
+
const DEFAULT_SOURCE = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
4
|
+
/**
|
|
5
|
+
* Low-level contract reader that simulates read-only contract calls.
|
|
6
|
+
*/
|
|
7
|
+
export class ContractReader {
|
|
8
|
+
rpc;
|
|
9
|
+
simulationSource;
|
|
10
|
+
passphrase;
|
|
11
|
+
log;
|
|
12
|
+
constructor(config, logger) {
|
|
13
|
+
this.rpc = new Server(config.rpcUrl);
|
|
14
|
+
this.passphrase = config.networkPassphrase;
|
|
15
|
+
this.simulationSource = config.simulationSourceKey || DEFAULT_SOURCE;
|
|
16
|
+
this.log = logger ?? console;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Simulate a read-only contract call and return the decoded result.
|
|
20
|
+
*/
|
|
21
|
+
async readContractValue(contractId, method, args = []) {
|
|
22
|
+
try {
|
|
23
|
+
const contract = new Contract(contractId);
|
|
24
|
+
const account = await this.rpc.getAccount(this.simulationSource);
|
|
25
|
+
const tx = new TransactionBuilder(account, {
|
|
26
|
+
fee: "100",
|
|
27
|
+
networkPassphrase: this.passphrase,
|
|
28
|
+
})
|
|
29
|
+
.addOperation(contract.call(method, ...args))
|
|
30
|
+
.setTimeout(30)
|
|
31
|
+
.build();
|
|
32
|
+
const result = await this.rpc.simulateTransaction(tx);
|
|
33
|
+
if ("result" in result && result.result?.retval) {
|
|
34
|
+
const native = scValToNative(result.result.retval);
|
|
35
|
+
return this.convertBigInts(native);
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
this.log.error("Contract read failed", { contractId, method, error: err });
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Recursively convert BigInt values to numbers for JSON serialization.
|
|
46
|
+
*/
|
|
47
|
+
convertBigInts(obj) {
|
|
48
|
+
if (obj === null || obj === undefined)
|
|
49
|
+
return obj;
|
|
50
|
+
if (typeof obj === "bigint")
|
|
51
|
+
return Number(obj);
|
|
52
|
+
if (Array.isArray(obj))
|
|
53
|
+
return obj.map((item) => this.convertBigInts(item));
|
|
54
|
+
if (typeof obj === "object") {
|
|
55
|
+
const converted = {};
|
|
56
|
+
for (const key in obj) {
|
|
57
|
+
converted[key] = this.convertBigInts(obj[key]);
|
|
58
|
+
}
|
|
59
|
+
return converted;
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=contract-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-reader.js","sourceRoot":"","sources":["../src/contract-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,MAAM,cAAc,GAAG,0DAA0D,CAAC;AAElF;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,GAAG,CAAS;IACZ,gBAAgB,CAAS;IACzB,UAAU,CAAS;IACnB,GAAG,CAAa;IAExB,YAAY,MAA2B,EAAE,MAAmB;QAC1D,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAC3C,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,mBAAmB,IAAI,cAAc,CAAC;QACrE,IAAI,CAAC,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB,EAAE,MAAc,EAAE,OAAc,EAAE;QAC1E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,C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YAC5B,MAAM,SAAS,GAAQ,EAAE,CAAC;YAC1B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;gBACtB,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACjD,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { StellarClientConfig, AgentPolicy, AgentInfo, FeedbackSummary, Feedback, Validation, LoggerLike, } from "./types.js";
|
|
2
|
+
export { ContractReader } from "./contract-reader.js";
|
|
3
|
+
export { VaultFactory } from "./vault-factory.js";
|
|
4
|
+
export { UserVault } from "./user-vault.js";
|
|
5
|
+
export { AgentRegistry } from "./agent-registry.js";
|
|
6
|
+
export { ReputationRegistry } from "./reputation-registry.js";
|
|
7
|
+
export { ValidationRegistry } from "./validation-registry.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,eAAe,EACf,QAAQ,EACR,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ── Contract Reader ──
|
|
2
|
+
export { ContractReader } from "./contract-reader.js";
|
|
3
|
+
// ── Vault Factory ──
|
|
4
|
+
export { VaultFactory } from "./vault-factory.js";
|
|
5
|
+
// ── User Vault ──
|
|
6
|
+
export { UserVault } from "./user-vault.js";
|
|
7
|
+
// ── Agent Registry ──
|
|
8
|
+
export { AgentRegistry } from "./agent-registry.js";
|
|
9
|
+
// ── Reputation Registry ──
|
|
10
|
+
export { ReputationRegistry } from "./reputation-registry.js";
|
|
11
|
+
// ── Validation Registry ──
|
|
12
|
+
export { ValidationRegistry } from "./validation-registry.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,wBAAwB;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,sBAAsB;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,uBAAuB;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,4BAA4B;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,4BAA4B;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StellarClientConfig, FeedbackSummary, Feedback, LoggerLike } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read-only client for the ReputationRegistry contract.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ReputationRegistry {
|
|
6
|
+
private reader;
|
|
7
|
+
private reputationAddress;
|
|
8
|
+
constructor(reputationAddress: string, config: StellarClientConfig, logger?: LoggerLike);
|
|
9
|
+
/** Get the feedback summary for an agent. */
|
|
10
|
+
getSummary(agentId: number): Promise<FeedbackSummary>;
|
|
11
|
+
/** Get paginated feedback entries for an agent. */
|
|
12
|
+
getFeedback(agentId: number, offset?: number, limit?: number): Promise<Feedback[]>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=reputation-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reputation-registry.d.ts","sourceRoot":"","sources":["../src/reputation-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7F;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,UAAU;IAKvF,6CAA6C;IACvC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAS3D,mDAAmD;IAC7C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAYhG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { nativeToScVal } from "@stellar/stellar-sdk";
|
|
2
|
+
import { ContractReader } from "./contract-reader.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only client for the ReputationRegistry contract.
|
|
5
|
+
*/
|
|
6
|
+
export class ReputationRegistry {
|
|
7
|
+
reader;
|
|
8
|
+
reputationAddress;
|
|
9
|
+
constructor(reputationAddress, config, logger) {
|
|
10
|
+
this.reputationAddress = reputationAddress;
|
|
11
|
+
this.reader = new ContractReader(config, logger);
|
|
12
|
+
}
|
|
13
|
+
/** Get the feedback summary for an agent. */
|
|
14
|
+
async getSummary(agentId) {
|
|
15
|
+
const result = await this.reader.readContractValue(this.reputationAddress, "get_feedback_summary", [nativeToScVal(agentId, { type: "u32" })]);
|
|
16
|
+
return result || { total_reviews: 0, avg_score_x100: 0, category_counts: 0, total_score: 0 };
|
|
17
|
+
}
|
|
18
|
+
/** Get paginated feedback entries for an agent. */
|
|
19
|
+
async getFeedback(agentId, offset = 0, limit = 10) {
|
|
20
|
+
const result = await this.reader.readContractValue(this.reputationAddress, "get_feedback", [
|
|
21
|
+
nativeToScVal(agentId, { type: "u32" }),
|
|
22
|
+
nativeToScVal(offset, { type: "u32" }),
|
|
23
|
+
nativeToScVal(limit, { type: "u32" }),
|
|
24
|
+
]);
|
|
25
|
+
return result || [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=reputation-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reputation-registry.js","sourceRoot":"","sources":["../src/reputation-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAiB;IACvB,iBAAiB,CAAS;IAElC,YAAY,iBAAyB,EAAE,MAA2B,EAAE,MAAmB;QACrF,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChD,IAAI,CAAC,iBAAiB,EACtB,sBAAsB,EACtB,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAC1C,CAAC;QACF,OAAO,MAAM,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAC/F,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,SAAiB,CAAC,EAAE,QAAgB,EAAE;QACvE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChD,IAAI,CAAC,iBAAiB,EACtB,cAAc,EACd;YACE,aAAa,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YACvC,aAAa,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YACtC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;SACtC,CACF,CAAC;QACF,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface StellarClientConfig {
|
|
2
|
+
rpcUrl: string;
|
|
3
|
+
networkPassphrase: string;
|
|
4
|
+
/** Public key of a funded account used as source for read-only simulations. */
|
|
5
|
+
simulationSourceKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentPolicy {
|
|
8
|
+
agent_address: string;
|
|
9
|
+
daily_limit: string;
|
|
10
|
+
spent_today: string;
|
|
11
|
+
last_reset: number;
|
|
12
|
+
allowed_destinations: string[];
|
|
13
|
+
is_active: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface AgentInfo {
|
|
16
|
+
id: number;
|
|
17
|
+
owner: string;
|
|
18
|
+
name: string;
|
|
19
|
+
agent_uri: string;
|
|
20
|
+
vault_address: string;
|
|
21
|
+
agent_signer: string;
|
|
22
|
+
registered_at: number;
|
|
23
|
+
is_active: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface FeedbackSummary {
|
|
26
|
+
total_reviews: number;
|
|
27
|
+
total_score: number;
|
|
28
|
+
avg_score_x100: number;
|
|
29
|
+
}
|
|
30
|
+
export interface Feedback {
|
|
31
|
+
agent_id: number;
|
|
32
|
+
reviewer: string;
|
|
33
|
+
score: number;
|
|
34
|
+
category: string;
|
|
35
|
+
data_uri: string;
|
|
36
|
+
payment_proof_hash: string;
|
|
37
|
+
timestamp: number;
|
|
38
|
+
}
|
|
39
|
+
export interface Validation {
|
|
40
|
+
request_id: number;
|
|
41
|
+
agent_id: number;
|
|
42
|
+
validator: string;
|
|
43
|
+
request_uri: string;
|
|
44
|
+
data_hash: string;
|
|
45
|
+
status: "Pending" | "Completed" | "Failed";
|
|
46
|
+
success: boolean;
|
|
47
|
+
evidence_uri: string;
|
|
48
|
+
requested_at: number;
|
|
49
|
+
completed_at: number;
|
|
50
|
+
}
|
|
51
|
+
export interface LoggerLike {
|
|
52
|
+
info(message: string, ...args: any[]): void;
|
|
53
|
+
warn(message: string, ...args: any[]): void;
|
|
54
|
+
error(message: string, ...args: any[]): void;
|
|
55
|
+
debug(message: string, ...args: any[]): void;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAID,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;CACpB;AAID,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;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C;IAC7C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC9C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8BAA8B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StellarClientConfig, AgentPolicy, LoggerLike } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read-only client for a UserVault contract instance.
|
|
4
|
+
*/
|
|
5
|
+
export declare class UserVault {
|
|
6
|
+
private reader;
|
|
7
|
+
private vaultAddress;
|
|
8
|
+
constructor(vaultAddress: string, config: StellarClientConfig, logger?: LoggerLike);
|
|
9
|
+
/** Get the USDC balance of this vault (in stroops). */
|
|
10
|
+
getBalance(): Promise<string>;
|
|
11
|
+
/** Get the lifetime total USDC spent through agent_pay (in stroops). */
|
|
12
|
+
getTotalSpent(): Promise<string>;
|
|
13
|
+
/** Get the spending policy for a specific agent. */
|
|
14
|
+
getAgentPolicy(agentAddress: string): Promise<AgentPolicy | null>;
|
|
15
|
+
/** Get the remaining daily spending limit for an agent (in stroops). */
|
|
16
|
+
getRemainingLimit(agentAddress: string): Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=user-vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-vault.d.ts","sourceRoot":"","sources":["../src/user-vault.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/E;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,YAAY,CAAS;gBAEjB,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,UAAU;IAKlF,uDAAuD;IACjD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAKnC,wEAAwE;IAClE,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC,oDAAoD;IAC9C,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAQvE,wEAAwE;IAClE,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ/D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { nativeToScVal } from "@stellar/stellar-sdk";
|
|
2
|
+
import { ContractReader } from "./contract-reader.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only client for a UserVault contract instance.
|
|
5
|
+
*/
|
|
6
|
+
export class UserVault {
|
|
7
|
+
reader;
|
|
8
|
+
vaultAddress;
|
|
9
|
+
constructor(vaultAddress, config, logger) {
|
|
10
|
+
this.vaultAddress = vaultAddress;
|
|
11
|
+
this.reader = new ContractReader(config, logger);
|
|
12
|
+
}
|
|
13
|
+
/** Get the USDC balance of this vault (in stroops). */
|
|
14
|
+
async getBalance() {
|
|
15
|
+
const balance = await this.reader.readContractValue(this.vaultAddress, "balance");
|
|
16
|
+
return balance?.toString() || "0";
|
|
17
|
+
}
|
|
18
|
+
/** Get the lifetime total USDC spent through agent_pay (in stroops). */
|
|
19
|
+
async getTotalSpent() {
|
|
20
|
+
const total = await this.reader.readContractValue(this.vaultAddress, "total_spent");
|
|
21
|
+
return total?.toString() || "0";
|
|
22
|
+
}
|
|
23
|
+
/** Get the spending policy for a specific agent. */
|
|
24
|
+
async getAgentPolicy(agentAddress) {
|
|
25
|
+
return await this.reader.readContractValue(this.vaultAddress, "get_agent_policy", [nativeToScVal(agentAddress, { type: "address" })]);
|
|
26
|
+
}
|
|
27
|
+
/** Get the remaining daily spending limit for an agent (in stroops). */
|
|
28
|
+
async getRemainingLimit(agentAddress) {
|
|
29
|
+
const result = await this.reader.readContractValue(this.vaultAddress, "remaining_limit", [nativeToScVal(agentAddress, { type: "address" })]);
|
|
30
|
+
return result?.toString() || "0";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=user-vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-vault.js","sourceRoot":"","sources":["../src/user-vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,CAAiB;IACvB,YAAY,CAAS;IAE7B,YAAY,YAAoB,EAAE,MAA2B,EAAE,MAAmB;QAChF,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAClF,OAAO,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC;IACpC,CAAC;IAED,wEAAwE;IACxE,KAAK,CAAC,aAAa;QACjB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;QACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC;IAClC,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,cAAc,CAAC,YAAoB;QACvC,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CACxC,IAAI,CAAC,YAAY,EACjB,kBAAkB,EAClB,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CACnD,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,KAAK,CAAC,iBAAiB,CAAC,YAAoB;QAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChD,IAAI,CAAC,YAAY,EACjB,iBAAiB,EACjB,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CACnD,CAAC;QACF,OAAO,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StellarClientConfig, Validation, LoggerLike } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read-only client for the ValidationRegistry contract.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ValidationRegistry {
|
|
6
|
+
private reader;
|
|
7
|
+
private validationAddress;
|
|
8
|
+
constructor(validationAddress: string, config: StellarClientConfig, logger?: LoggerLike);
|
|
9
|
+
/** Get all validations for an agent. */
|
|
10
|
+
getValidations(agentId: number): Promise<Validation[]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=validation-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-registry.d.ts","sourceRoot":"","sources":["../src/validation-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9E;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,UAAU;IAKvF,wCAAwC;IAClC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAQ7D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { nativeToScVal } from "@stellar/stellar-sdk";
|
|
2
|
+
import { ContractReader } from "./contract-reader.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only client for the ValidationRegistry contract.
|
|
5
|
+
*/
|
|
6
|
+
export class ValidationRegistry {
|
|
7
|
+
reader;
|
|
8
|
+
validationAddress;
|
|
9
|
+
constructor(validationAddress, config, logger) {
|
|
10
|
+
this.validationAddress = validationAddress;
|
|
11
|
+
this.reader = new ContractReader(config, logger);
|
|
12
|
+
}
|
|
13
|
+
/** Get all validations for an agent. */
|
|
14
|
+
async getValidations(agentId) {
|
|
15
|
+
const result = await this.reader.readContractValue(this.validationAddress, "get_validations", [nativeToScVal(agentId, { type: "u32" })]);
|
|
16
|
+
return result || [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=validation-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-registry.js","sourceRoot":"","sources":["../src/validation-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAiB;IACvB,iBAAiB,CAAS;IAElC,YAAY,iBAAyB,EAAE,MAA2B,EAAE,MAAmB;QACrF,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,cAAc,CAAC,OAAe;QAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChD,IAAI,CAAC,iBAAiB,EACtB,iBAAiB,EACjB,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAC1C,CAAC;QACF,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StellarClientConfig, LoggerLike } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read-only client for the VaultFactory contract.
|
|
4
|
+
*/
|
|
5
|
+
export declare class VaultFactory {
|
|
6
|
+
private reader;
|
|
7
|
+
private factoryAddress;
|
|
8
|
+
constructor(factoryAddress: string, config: StellarClientConfig, logger?: LoggerLike);
|
|
9
|
+
/** Get the vault address for a given owner, or null if none exists. */
|
|
10
|
+
getVault(owner: string): Promise<string | null>;
|
|
11
|
+
/** Check whether an owner has a vault. */
|
|
12
|
+
hasVault(owner: string): Promise<boolean>;
|
|
13
|
+
/** Get the total number of vaults created. */
|
|
14
|
+
vaultCount(): Promise<number>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=vault-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-factory.d.ts","sourceRoot":"","sources":["../src/vault-factory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAElE;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,cAAc,CAAS;gBAEnB,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,UAAU;IAKpF,uEAAuE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQrD,0CAA0C;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/C,8CAA8C;IACxC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;CAIpC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { nativeToScVal } from "@stellar/stellar-sdk";
|
|
2
|
+
import { ContractReader } from "./contract-reader.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only client for the VaultFactory contract.
|
|
5
|
+
*/
|
|
6
|
+
export class VaultFactory {
|
|
7
|
+
reader;
|
|
8
|
+
factoryAddress;
|
|
9
|
+
constructor(factoryAddress, config, logger) {
|
|
10
|
+
this.factoryAddress = factoryAddress;
|
|
11
|
+
this.reader = new ContractReader(config, logger);
|
|
12
|
+
}
|
|
13
|
+
/** Get the vault address for a given owner, or null if none exists. */
|
|
14
|
+
async getVault(owner) {
|
|
15
|
+
return await this.reader.readContractValue(this.factoryAddress, "get_vault", [nativeToScVal(owner, { type: "address" })]);
|
|
16
|
+
}
|
|
17
|
+
/** Check whether an owner has a vault. */
|
|
18
|
+
async hasVault(owner) {
|
|
19
|
+
const vault = await this.getVault(owner);
|
|
20
|
+
return vault !== null;
|
|
21
|
+
}
|
|
22
|
+
/** Get the total number of vaults created. */
|
|
23
|
+
async vaultCount() {
|
|
24
|
+
const count = await this.reader.readContractValue(this.factoryAddress, "vault_count");
|
|
25
|
+
return count || 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=vault-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault-factory.js","sourceRoot":"","sources":["../src/vault-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,YAAY;IACf,MAAM,CAAiB;IACvB,cAAc,CAAS;IAE/B,YAAY,cAAsB,EAAE,MAA2B,EAAE,MAAmB;QAClF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,uEAAuE;IACvE,KAAK,CAAC,QAAQ,CAAC,KAAa;QAC1B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CACxC,IAAI,CAAC,cAAc,EACnB,WAAW,EACX,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAC5C,CAAC;IACJ,CAAC;IAED,0CAA0C;IAC1C,KAAK,CAAC,QAAQ,CAAC,KAAa;QAC1B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,KAAK,KAAK,IAAI,CAAC;IACxB,CAAC;IAED,8CAA8C;IAC9C,KAAK,CAAC,UAAU;QACd,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;QACtF,OAAO,KAAK,IAAI,CAAC,CAAC;IACpB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticocean/vault",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Smart vault and agent identity SDK for Stellar/Soroban",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"lint": "tsc --noEmit",
|
|
20
|
+
"clean": "rm -rf dist"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@stellar/stellar-sdk": "^13.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"typescript": "^5.7.0"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT"
|
|
32
|
+
}
|