@agentbadge/hedera-core 0.1.15
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/catalog.d.ts +13 -0
- package/dist/catalog.js +231 -0
- package/dist/chain-adapter.d.ts +62 -0
- package/dist/chain-adapter.js +1 -0
- package/dist/datahub.client.d.ts +58 -0
- package/dist/datahub.client.js +356 -0
- package/dist/did.d.ts +7 -0
- package/dist/did.js +33 -0
- package/dist/hedera-chain-adapter-instance.d.ts +2 -0
- package/dist/hedera-chain-adapter-instance.js +10 -0
- package/dist/hedera-chain-adapter.d.ts +18 -0
- package/dist/hedera-chain-adapter.js +121 -0
- package/dist/hedera.service.d.ts +52 -0
- package/dist/hedera.service.js +415 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +261 -0
- package/dist/mirror.service.d.ts +34 -0
- package/dist/mirror.service.js +187 -0
- package/dist/mock-hedera.service.d.ts +69 -0
- package/dist/mock-hedera.service.js +195 -0
- package/dist/mock-mirror.service.d.ts +22 -0
- package/dist/mock-mirror.service.js +72 -0
- package/dist/mock-settle.d.ts +1 -0
- package/dist/mock-settle.js +6 -0
- package/dist/services-index.d.ts +84 -0
- package/dist/services-index.js +133 -0
- package/dist/signing.d.ts +5 -0
- package/dist/signing.js +17 -0
- package/dist/types.d.ts +215 -0
- package/dist/types.js +56 -0
- package/package.json +44 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
export type Tier = "bronze" | "silver" | "gold" | "platinum";
|
|
2
|
+
export declare const TIER_PRICES_HBAR: Record<Tier, number>;
|
|
3
|
+
export type Capability = "api_call" | "payment" | "data_provide" | "data_consume" | "orchestration";
|
|
4
|
+
export interface PassportMetadata {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
image: string;
|
|
8
|
+
attributes: NftAttribute[];
|
|
9
|
+
did: string;
|
|
10
|
+
tier: Tier;
|
|
11
|
+
capabilities: Capability[];
|
|
12
|
+
accountId: string;
|
|
13
|
+
issuedAt: number;
|
|
14
|
+
endpoint: string;
|
|
15
|
+
version: number;
|
|
16
|
+
issuer: string;
|
|
17
|
+
skills?: string[];
|
|
18
|
+
webmcp?: {
|
|
19
|
+
toolsAvailable: string[];
|
|
20
|
+
discoveryUrl: string;
|
|
21
|
+
complianceScore: number;
|
|
22
|
+
lastScanned: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface NftAttribute {
|
|
26
|
+
trait_type: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AuditMessage {
|
|
30
|
+
type: "passport_issued" | "tier_upgraded" | "passport_revoked" | "agent_registered" | "agent_deregistered";
|
|
31
|
+
did: string;
|
|
32
|
+
tokenId: string;
|
|
33
|
+
serial: number;
|
|
34
|
+
timestamp: number;
|
|
35
|
+
tier?: Tier;
|
|
36
|
+
oldTier?: Tier;
|
|
37
|
+
newTier?: Tier;
|
|
38
|
+
reason?: string;
|
|
39
|
+
txHash?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface NftInfo {
|
|
42
|
+
token_id: string;
|
|
43
|
+
serial_number: number;
|
|
44
|
+
account_id: string;
|
|
45
|
+
metadata: string;
|
|
46
|
+
deleted: boolean;
|
|
47
|
+
created_timestamp: string;
|
|
48
|
+
}
|
|
49
|
+
export interface MintResult {
|
|
50
|
+
tokenId: string;
|
|
51
|
+
serial: number;
|
|
52
|
+
}
|
|
53
|
+
export interface HcsMessageReceipt {
|
|
54
|
+
txId: string;
|
|
55
|
+
consensusTimestamp: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface TopicResult {
|
|
58
|
+
topicId: string;
|
|
59
|
+
}
|
|
60
|
+
export interface TopicMessage {
|
|
61
|
+
consensus_timestamp: string;
|
|
62
|
+
message: string;
|
|
63
|
+
sequence_number: number;
|
|
64
|
+
running_hash: string;
|
|
65
|
+
chunk_info?: unknown;
|
|
66
|
+
transaction_id?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface DirectoryMessage {
|
|
69
|
+
type: "agent_register";
|
|
70
|
+
did: string;
|
|
71
|
+
tokenId: string;
|
|
72
|
+
serial: number;
|
|
73
|
+
accountId: string;
|
|
74
|
+
name: string;
|
|
75
|
+
capabilities: string[];
|
|
76
|
+
endpoint: string;
|
|
77
|
+
tier: string;
|
|
78
|
+
timestamp: number;
|
|
79
|
+
}
|
|
80
|
+
export interface A2AMessage {
|
|
81
|
+
type: "a2a_message";
|
|
82
|
+
from: string;
|
|
83
|
+
to: string;
|
|
84
|
+
body: string;
|
|
85
|
+
contentType: string;
|
|
86
|
+
timestamp: number;
|
|
87
|
+
}
|
|
88
|
+
export interface CachedA2AMessage extends A2AMessage {
|
|
89
|
+
txId: string;
|
|
90
|
+
consensusTimestamp: string;
|
|
91
|
+
}
|
|
92
|
+
export declare function isValidA2AMessage(obj: unknown): boolean;
|
|
93
|
+
export interface TaskPostedMessage {
|
|
94
|
+
type: "task_posted";
|
|
95
|
+
taskId: string;
|
|
96
|
+
posterDid: string;
|
|
97
|
+
title: string;
|
|
98
|
+
description: string;
|
|
99
|
+
priceHbar: number;
|
|
100
|
+
capabilities: string[];
|
|
101
|
+
deadline?: number;
|
|
102
|
+
timestamp: number;
|
|
103
|
+
}
|
|
104
|
+
export interface TaskClaimedMessage {
|
|
105
|
+
type: "task_claimed";
|
|
106
|
+
taskId: string;
|
|
107
|
+
claimerDid: string;
|
|
108
|
+
timestamp: number;
|
|
109
|
+
}
|
|
110
|
+
export interface TaskDeliveredMessage {
|
|
111
|
+
type: "task_delivered";
|
|
112
|
+
taskId: string;
|
|
113
|
+
resultIpfs?: string;
|
|
114
|
+
resultBody?: string;
|
|
115
|
+
timestamp: number;
|
|
116
|
+
}
|
|
117
|
+
export interface TaskCompletedMessage {
|
|
118
|
+
type: "task_completed";
|
|
119
|
+
taskId: string;
|
|
120
|
+
paymentTxId: string;
|
|
121
|
+
timestamp: number;
|
|
122
|
+
}
|
|
123
|
+
export interface TaskVerificationFailedMessage {
|
|
124
|
+
type: "task_verification_failed";
|
|
125
|
+
taskId: string;
|
|
126
|
+
claimerDid: string;
|
|
127
|
+
report: string;
|
|
128
|
+
timestamp: number;
|
|
129
|
+
}
|
|
130
|
+
export interface TaskEscrowCreatedMessage {
|
|
131
|
+
type: "task_escrow_created";
|
|
132
|
+
taskId: string;
|
|
133
|
+
scheduleId: string;
|
|
134
|
+
amountHbar: number;
|
|
135
|
+
timestamp: number;
|
|
136
|
+
}
|
|
137
|
+
export interface TaskEscrowFailedMessage {
|
|
138
|
+
type: "task_escrow_failed";
|
|
139
|
+
taskId: string;
|
|
140
|
+
reason: string;
|
|
141
|
+
timestamp: number;
|
|
142
|
+
}
|
|
143
|
+
export interface TaskCancelledMessage {
|
|
144
|
+
type: "task_cancelled";
|
|
145
|
+
taskId: string;
|
|
146
|
+
scheduleId?: string;
|
|
147
|
+
timestamp: number;
|
|
148
|
+
}
|
|
149
|
+
export interface TaskRewardIncreasedMessage {
|
|
150
|
+
type: "task_reward_increased";
|
|
151
|
+
taskId: string;
|
|
152
|
+
oldPriceHbar: number;
|
|
153
|
+
newPriceHbar: number;
|
|
154
|
+
newScheduleId: string;
|
|
155
|
+
timestamp: number;
|
|
156
|
+
}
|
|
157
|
+
export type TaskMessage = TaskPostedMessage | TaskClaimedMessage | TaskDeliveredMessage | TaskCompletedMessage | TaskVerificationFailedMessage | TaskEscrowCreatedMessage | TaskEscrowFailedMessage | TaskCancelledMessage | TaskRewardIncreasedMessage;
|
|
158
|
+
export interface TaskMessageWithTx {
|
|
159
|
+
message: TaskMessage;
|
|
160
|
+
txId?: string;
|
|
161
|
+
}
|
|
162
|
+
export declare function isValidTaskMessage(obj: unknown): boolean;
|
|
163
|
+
export type MarketTaskMessage = TaskMessage;
|
|
164
|
+
export interface CachedMarketTask {
|
|
165
|
+
taskId: string;
|
|
166
|
+
posterDid: string;
|
|
167
|
+
title: string;
|
|
168
|
+
description: string;
|
|
169
|
+
priceHbar: number;
|
|
170
|
+
capabilities: string[];
|
|
171
|
+
deadline?: number;
|
|
172
|
+
status: "posted" | "claiming" | "claimed" | "delivering" | "delivered" | "completing" | "completed" | "cancelling" | "cancelled";
|
|
173
|
+
claimerDid?: string;
|
|
174
|
+
resultBody?: string;
|
|
175
|
+
resultIpfs?: string;
|
|
176
|
+
paymentTxId?: string;
|
|
177
|
+
txId: string;
|
|
178
|
+
claimTxId?: string;
|
|
179
|
+
deliverTxId?: string;
|
|
180
|
+
completedTxId?: string;
|
|
181
|
+
consensusTimestamp: string;
|
|
182
|
+
createdAt: number;
|
|
183
|
+
scheduleId?: string;
|
|
184
|
+
scheduleTxId?: string;
|
|
185
|
+
escrowStatus?: "pending" | "released" | "cancelled" | "expired" | "reclaimed";
|
|
186
|
+
verifierType?: string;
|
|
187
|
+
verificationAttempts?: number;
|
|
188
|
+
verificationReport?: string;
|
|
189
|
+
transitionalSince?: number;
|
|
190
|
+
lastError?: string;
|
|
191
|
+
}
|
|
192
|
+
export interface HFSUploadResult {
|
|
193
|
+
fileId: string;
|
|
194
|
+
txId: string;
|
|
195
|
+
}
|
|
196
|
+
export interface GlossaryTermConfig {
|
|
197
|
+
id: string;
|
|
198
|
+
name: string;
|
|
199
|
+
description: string;
|
|
200
|
+
category: "cardiovascular" | "endocrine" | "general" | "demographic";
|
|
201
|
+
relatedDatasets: string[];
|
|
202
|
+
}
|
|
203
|
+
export interface CreatePassportTokenParams {
|
|
204
|
+
tokenName: string;
|
|
205
|
+
tokenSymbol: string;
|
|
206
|
+
treasuryAccountId: string;
|
|
207
|
+
maxSupply: number;
|
|
208
|
+
adminKey: Uint8Array;
|
|
209
|
+
supplyKey: Uint8Array;
|
|
210
|
+
metadataKey: Uint8Array;
|
|
211
|
+
wipeKey: Uint8Array;
|
|
212
|
+
freezeKey: Uint8Array;
|
|
213
|
+
pauseKey: Uint8Array;
|
|
214
|
+
kycKey: Uint8Array;
|
|
215
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const TIER_PRICES_HBAR = {
|
|
2
|
+
bronze: 10,
|
|
3
|
+
silver: 50,
|
|
4
|
+
gold: 200,
|
|
5
|
+
platinum: 500,
|
|
6
|
+
};
|
|
7
|
+
export function isValidA2AMessage(obj) {
|
|
8
|
+
if (typeof obj !== "object" || obj === null)
|
|
9
|
+
return false;
|
|
10
|
+
const o = obj;
|
|
11
|
+
return (o.type === "a2a_message" &&
|
|
12
|
+
typeof o.from === "string" &&
|
|
13
|
+
typeof o.to === "string" &&
|
|
14
|
+
typeof o.body === "string" &&
|
|
15
|
+
typeof o.contentType === "string" &&
|
|
16
|
+
typeof o.timestamp === "number");
|
|
17
|
+
}
|
|
18
|
+
export function isValidTaskMessage(obj) {
|
|
19
|
+
if (typeof obj !== "object" || obj === null)
|
|
20
|
+
return false;
|
|
21
|
+
const o = obj;
|
|
22
|
+
if (typeof o.taskId !== "string" || typeof o.timestamp !== "number")
|
|
23
|
+
return false;
|
|
24
|
+
switch (o.type) {
|
|
25
|
+
case "task_posted":
|
|
26
|
+
return (typeof o.posterDid === "string" &&
|
|
27
|
+
typeof o.title === "string" &&
|
|
28
|
+
typeof o.description === "string" &&
|
|
29
|
+
typeof o.priceHbar === "number" &&
|
|
30
|
+
Array.isArray(o.capabilities) &&
|
|
31
|
+
o.capabilities.every((c) => typeof c === "string"));
|
|
32
|
+
case "task_claimed":
|
|
33
|
+
return typeof o.claimerDid === "string";
|
|
34
|
+
case "task_delivered":
|
|
35
|
+
return ((o.resultIpfs === undefined || typeof o.resultIpfs === "string") &&
|
|
36
|
+
(o.resultBody === undefined || typeof o.resultBody === "string"));
|
|
37
|
+
case "task_completed":
|
|
38
|
+
return typeof o.paymentTxId === "string";
|
|
39
|
+
case "task_verification_failed":
|
|
40
|
+
return (typeof o.claimerDid === "string" &&
|
|
41
|
+
typeof o.report === "string");
|
|
42
|
+
case "task_escrow_created":
|
|
43
|
+
return (typeof o.scheduleId === "string" &&
|
|
44
|
+
typeof o.amountHbar === "number");
|
|
45
|
+
case "task_escrow_failed":
|
|
46
|
+
return typeof o.reason === "string";
|
|
47
|
+
case "task_cancelled":
|
|
48
|
+
return (o.scheduleId === undefined || typeof o.scheduleId === "string");
|
|
49
|
+
case "task_reward_increased":
|
|
50
|
+
return (typeof o.oldPriceHbar === "number" &&
|
|
51
|
+
typeof o.newPriceHbar === "number" &&
|
|
52
|
+
typeof o.newScheduleId === "string");
|
|
53
|
+
default:
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentbadge/hedera-core",
|
|
3
|
+
"version": "0.1.15",
|
|
4
|
+
"description": "Hedera blockchain operations for AgentBadge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"author": "AgentBadge",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"hedera",
|
|
15
|
+
"blockchain",
|
|
16
|
+
"hts",
|
|
17
|
+
"hcs",
|
|
18
|
+
"agent"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc && esbuild dist/index.js --bundle --minify --format=esm --outfile=dist/index.min.js --allow-overwrite --external:@hashgraph/sdk --external:long && mv dist/index.min.js dist/index.js",
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"test:coverage": "vitest run --coverage"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@hashgraph/sdk": "^2.55.0",
|
|
35
|
+
"long": "^5.2.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
39
|
+
"bun-types": "^1.3.14",
|
|
40
|
+
"esbuild": "^0.21.0",
|
|
41
|
+
"typescript": "^5.9.0",
|
|
42
|
+
"vitest": "^2.1.0"
|
|
43
|
+
}
|
|
44
|
+
}
|