@bankofai/8004-sdk 1.0.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/LICENSE +21 -0
- package/README.md +125 -0
- package/dist/core/agent.d.ts +27 -0
- package/dist/core/agent.js +177 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/chains.d.ts +88 -0
- package/dist/core/chains.js +499 -0
- package/dist/core/chains.js.map +1 -0
- package/dist/core/contracts.d.ts +6 -0
- package/dist/core/contracts.js +18 -0
- package/dist/core/contracts.js.map +1 -0
- package/dist/core/indexer.d.ts +10 -0
- package/dist/core/indexer.js +25 -0
- package/dist/core/indexer.js.map +1 -0
- package/dist/core/sdk.d.ts +58 -0
- package/dist/core/sdk.js +240 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/subgraph-client.d.ts +9 -0
- package/dist/core/subgraph-client.js +99 -0
- package/dist/core/subgraph-client.js.map +1 -0
- package/dist/core/transaction-handle.d.ts +11 -0
- package/dist/core/transaction-handle.js +16 -0
- package/dist/core/transaction-handle.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/models/types.d.ts +126 -0
- package/dist/models/types.js +2 -0
- package/dist/models/types.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BankOfAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# BankOfAI 8004 SDK (TypeScript)
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for agent identity, discovery, trust, and reputation based on 8004.
|
|
4
|
+
|
|
5
|
+
This SDK provides a unified API for registration, wallet binding, feedback/reputation, and validation workflows.
|
|
6
|
+
|
|
7
|
+
## What Does This SDK Do?
|
|
8
|
+
|
|
9
|
+
BankOfAI 8004 SDK enables you to:
|
|
10
|
+
|
|
11
|
+
- Create and manage on-chain agent identities
|
|
12
|
+
- Register agent card URIs on-chain (`agent.register()`)
|
|
13
|
+
- Configure MCP/A2A endpoints, skills/domains, trust flags, metadata, and status
|
|
14
|
+
- Manage verified wallet binding (`agent.getWallet()`, `agent.setWallet()`, `agent.unsetWallet()`)
|
|
15
|
+
- Submit and read feedback (`giveFeedback()`, `getFeedback()`, `getReputationSummary()`)
|
|
16
|
+
- Run validation request/response flows (`validationRequest()`, `validationResponse()`, `getValidationStatus()`)
|
|
17
|
+
|
|
18
|
+
Package import:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { SDK } from "@bankofai/8004-sdk";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
### Prerequisites
|
|
27
|
+
|
|
28
|
+
- Node.js `>=20`
|
|
29
|
+
- npm
|
|
30
|
+
- Funded private key for write operations
|
|
31
|
+
- RPC endpoint
|
|
32
|
+
|
|
33
|
+
### Install from Source (Local)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/bankofai/8004-sdk.git
|
|
37
|
+
cd 8004-sdk/ts
|
|
38
|
+
npm install
|
|
39
|
+
npm run build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { SDK } from "@bankofai/8004-sdk";
|
|
46
|
+
|
|
47
|
+
const sdk = new SDK({
|
|
48
|
+
network: "<NETWORK_ID>", // e.g. eip155:97 or nile
|
|
49
|
+
rpcUrl: "<RPC_URL>",
|
|
50
|
+
signer: "<PRIVATE_KEY>",
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const agent = sdk.createAgent({
|
|
54
|
+
name: "My AI Agent",
|
|
55
|
+
description: "Demo agent",
|
|
56
|
+
image: "https://example.com/agent.png",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
agent.setMCP("https://mcp.example.com/");
|
|
60
|
+
agent.setA2A("https://a2a.example.com/.well-known/agent-card.json");
|
|
61
|
+
agent.setTrust({ reputation: true, cryptoEconomic: true });
|
|
62
|
+
agent.setMetadata({ version: "1.0.0" });
|
|
63
|
+
agent.setActive(true);
|
|
64
|
+
|
|
65
|
+
const tx = await agent.register("https://example.com/agent-card.json");
|
|
66
|
+
const mined = await tx.waitConfirmed({ timeoutMs: 180_000 });
|
|
67
|
+
console.log(mined.result.agentId, mined.result.agentURI);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Core Flows
|
|
71
|
+
|
|
72
|
+
### Wallet Management
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const wallet = await agent.getWallet();
|
|
76
|
+
const setTx = await agent.setWallet("<NEW_WALLET_ADDRESS>");
|
|
77
|
+
if (setTx) await setTx.waitConfirmed({ timeoutMs: 180_000 });
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Feedback and Reputation
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const fbTx = await sdk.giveFeedback({ agentId: "<AGENT_ID>", value: 88 });
|
|
84
|
+
const fb = await fbTx.waitConfirmed({ timeoutMs: 180_000 });
|
|
85
|
+
const summary = await sdk.getReputationSummary("<AGENT_ID>");
|
|
86
|
+
console.log(fb.result, summary);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Validation
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const reqTx = await sdk.validationRequest({
|
|
93
|
+
validatorAddress: "<VALIDATOR_ADDRESS>",
|
|
94
|
+
agentId: "<AGENT_ID>",
|
|
95
|
+
requestURI: "ipfs://QmRequest",
|
|
96
|
+
});
|
|
97
|
+
const req = await reqTx.waitConfirmed({ timeoutMs: 180_000 });
|
|
98
|
+
|
|
99
|
+
const respTx = await sdk.validationResponse({
|
|
100
|
+
requestHash: req.result.requestHash,
|
|
101
|
+
response: 95,
|
|
102
|
+
});
|
|
103
|
+
await respTx.waitConfirmed({ timeoutMs: 180_000 });
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Search and Indexing
|
|
107
|
+
|
|
108
|
+
- `searchAgents()` / `getAgent()` APIs exist in the SDK.
|
|
109
|
+
- Current release does **not** enable subgraph URL integration by default.
|
|
110
|
+
- Full subgraph-backed search support is planned in a future update.
|
|
111
|
+
|
|
112
|
+
## Examples
|
|
113
|
+
|
|
114
|
+
Chain-specific runnable scripts are in `ts/examples/`.
|
|
115
|
+
See `ts/examples/README.md` for full usage.
|
|
116
|
+
|
|
117
|
+
## Notes
|
|
118
|
+
|
|
119
|
+
- Package name: `@bankofai/8004-sdk`
|
|
120
|
+
- ESM package (`"type": "module"`)
|
|
121
|
+
- Contracts reject self-feedback; use a separate reviewer wallet
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RegistrationFile, RegistrationResult, SetWalletOptions } from "../models/types.js";
|
|
2
|
+
import type { SDK } from "./sdk.js";
|
|
3
|
+
import { TransactionHandle } from "./transaction-handle.js";
|
|
4
|
+
export declare class Agent {
|
|
5
|
+
private readonly sdk;
|
|
6
|
+
private readonly registrationFile;
|
|
7
|
+
constructor(sdk: SDK, registrationFile: RegistrationFile);
|
|
8
|
+
get agentId(): string | undefined;
|
|
9
|
+
setMCP(endpoint: string, version?: string): this;
|
|
10
|
+
setA2A(endpoint: string, version?: string): this;
|
|
11
|
+
addSkill(skill: string): this;
|
|
12
|
+
addDomain(domain: string): this;
|
|
13
|
+
setTrust(input: {
|
|
14
|
+
reputation?: boolean;
|
|
15
|
+
cryptoEconomic?: boolean;
|
|
16
|
+
teeAttestation?: boolean;
|
|
17
|
+
}): this;
|
|
18
|
+
setMetadata(kv: Record<string, unknown>): this;
|
|
19
|
+
setActive(active: boolean): this;
|
|
20
|
+
setX402Support(enabled: boolean): this;
|
|
21
|
+
register(agentURI: string): Promise<TransactionHandle<RegistrationResult>>;
|
|
22
|
+
getWallet(): Promise<string | undefined>;
|
|
23
|
+
setWallet(newWallet: string, options?: SetWalletOptions): Promise<TransactionHandle<Agent> | undefined>;
|
|
24
|
+
unsetWallet(): Promise<TransactionHandle<Agent> | undefined>;
|
|
25
|
+
toJSON(): RegistrationFile;
|
|
26
|
+
private touch;
|
|
27
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { recoverTypedDataAddress } from "viem";
|
|
2
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
3
|
+
import { TransactionHandle } from "./transaction-handle.js";
|
|
4
|
+
export class Agent {
|
|
5
|
+
sdk;
|
|
6
|
+
registrationFile;
|
|
7
|
+
constructor(sdk, registrationFile) {
|
|
8
|
+
this.sdk = sdk;
|
|
9
|
+
this.registrationFile = registrationFile;
|
|
10
|
+
}
|
|
11
|
+
get agentId() {
|
|
12
|
+
return this.registrationFile.agentId;
|
|
13
|
+
}
|
|
14
|
+
setMCP(endpoint, version = "2025-06-18") {
|
|
15
|
+
this.registrationFile.endpoints = this.registrationFile.endpoints.filter((e) => e.name !== "MCP");
|
|
16
|
+
this.registrationFile.endpoints.push({ name: "MCP", endpoint, version });
|
|
17
|
+
return this.touch();
|
|
18
|
+
}
|
|
19
|
+
setA2A(endpoint, version = "0.3.0") {
|
|
20
|
+
this.registrationFile.endpoints = this.registrationFile.endpoints.filter((e) => e.name !== "A2A");
|
|
21
|
+
this.registrationFile.endpoints.push({ name: "A2A", endpoint, version });
|
|
22
|
+
return this.touch();
|
|
23
|
+
}
|
|
24
|
+
addSkill(skill) {
|
|
25
|
+
if (!this.registrationFile.tags.includes(skill))
|
|
26
|
+
this.registrationFile.tags.push(skill);
|
|
27
|
+
return this.touch();
|
|
28
|
+
}
|
|
29
|
+
addDomain(domain) {
|
|
30
|
+
if (!this.registrationFile.tags.includes(domain))
|
|
31
|
+
this.registrationFile.tags.push(domain);
|
|
32
|
+
return this.touch();
|
|
33
|
+
}
|
|
34
|
+
setTrust(input) {
|
|
35
|
+
const trust = [];
|
|
36
|
+
if (input.reputation)
|
|
37
|
+
trust.push("reputation");
|
|
38
|
+
if (input.cryptoEconomic)
|
|
39
|
+
trust.push("crypto-economic");
|
|
40
|
+
if (input.teeAttestation)
|
|
41
|
+
trust.push("tee-attestation");
|
|
42
|
+
this.registrationFile.supportedTrust = trust;
|
|
43
|
+
return this.touch();
|
|
44
|
+
}
|
|
45
|
+
setMetadata(kv) {
|
|
46
|
+
this.registrationFile.metadata = { ...this.registrationFile.metadata, ...kv };
|
|
47
|
+
return this.touch();
|
|
48
|
+
}
|
|
49
|
+
setActive(active) {
|
|
50
|
+
this.registrationFile.active = active;
|
|
51
|
+
return this.touch();
|
|
52
|
+
}
|
|
53
|
+
setX402Support(enabled) {
|
|
54
|
+
this.registrationFile.x402support = enabled;
|
|
55
|
+
return this.touch();
|
|
56
|
+
}
|
|
57
|
+
async register(agentURI) {
|
|
58
|
+
const tx = await this.sdk.submitRegister(agentURI);
|
|
59
|
+
return new TransactionHandle(tx.txHash, this.sdk.chain, async (receipt) => {
|
|
60
|
+
const parsed = this.sdk.chain.parseRegisteredAgentId(receipt);
|
|
61
|
+
const resolved = {
|
|
62
|
+
agentURI,
|
|
63
|
+
agentId: parsed ? `${this.sdk.chainId}:${parsed}` : undefined,
|
|
64
|
+
};
|
|
65
|
+
this.registrationFile.agentURI = agentURI;
|
|
66
|
+
this.registrationFile.agentId = resolved.agentId;
|
|
67
|
+
this.touch();
|
|
68
|
+
return resolved;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async getWallet() {
|
|
72
|
+
if (!this.registrationFile.agentId)
|
|
73
|
+
throw new Error("Agent must be registered first");
|
|
74
|
+
return this.sdk.getAgentWallet(this.registrationFile.agentId);
|
|
75
|
+
}
|
|
76
|
+
async setWallet(newWallet, options = {}) {
|
|
77
|
+
if (!this.registrationFile.agentId)
|
|
78
|
+
throw new Error("Agent must be registered first");
|
|
79
|
+
const agentTokenId = BigInt(this.registrationFile.agentId.split(":").pop());
|
|
80
|
+
const addrEvm = this.sdk.chain.toEvmAddress(newWallet);
|
|
81
|
+
const addrChain = this.sdk.chain.toChainAddress(newWallet);
|
|
82
|
+
const currentWallet = await this.getWallet().catch(() => undefined);
|
|
83
|
+
if (currentWallet && this.sdk.chain.addressEqual(currentWallet, addrChain)) {
|
|
84
|
+
this.registrationFile.walletAddress = addrChain;
|
|
85
|
+
this.registrationFile.walletChainId = this.sdk.chainId;
|
|
86
|
+
this.touch();
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const ownerChain = await this.sdk.chain.ownerOf(this.sdk.identityRegistry, this.sdk.identityRegistryAbi, agentTokenId);
|
|
90
|
+
const ownerEvm = this.sdk.chain.toEvmAddress(ownerChain);
|
|
91
|
+
const verifyingContract = this.sdk.chain.toEvmAddress(this.sdk.identityRegistry);
|
|
92
|
+
const chainId = this.sdk.getTypedDataChainId();
|
|
93
|
+
const deadline = BigInt(options.deadline ?? (Math.floor(Date.now() / 1000) + 60));
|
|
94
|
+
const domain = {
|
|
95
|
+
name: "ERC8004IdentityRegistry",
|
|
96
|
+
version: "1",
|
|
97
|
+
chainId,
|
|
98
|
+
verifyingContract,
|
|
99
|
+
};
|
|
100
|
+
const types = {
|
|
101
|
+
AgentWalletSet: [
|
|
102
|
+
{ name: "agentId", type: "uint256" },
|
|
103
|
+
{ name: "newWallet", type: "address" },
|
|
104
|
+
{ name: "owner", type: "address" },
|
|
105
|
+
{ name: "deadline", type: "uint256" },
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
const message = {
|
|
109
|
+
agentId: agentTokenId,
|
|
110
|
+
newWallet: addrEvm,
|
|
111
|
+
owner: ownerEvm,
|
|
112
|
+
deadline,
|
|
113
|
+
};
|
|
114
|
+
let signature = options.signature;
|
|
115
|
+
if (!signature) {
|
|
116
|
+
const signerKey = ((options.newWalletSigner ?? this.sdk.signer) || "").trim();
|
|
117
|
+
if (!signerKey) {
|
|
118
|
+
throw new Error("New wallet signature is required. Provide options.newWalletSigner or options.signature.");
|
|
119
|
+
}
|
|
120
|
+
const normalizedKey = (signerKey.startsWith("0x") ? signerKey : `0x${signerKey}`);
|
|
121
|
+
const account = privateKeyToAccount(normalizedKey);
|
|
122
|
+
if (account.address.toLowerCase() !== addrEvm.toLowerCase()) {
|
|
123
|
+
throw new Error(`newWalletSigner address (${account.address}) does not match newWallet (${addrEvm}).`);
|
|
124
|
+
}
|
|
125
|
+
signature = await account.signTypedData({
|
|
126
|
+
domain,
|
|
127
|
+
types,
|
|
128
|
+
primaryType: "AgentWalletSet",
|
|
129
|
+
message,
|
|
130
|
+
});
|
|
131
|
+
const recovered = await recoverTypedDataAddress({
|
|
132
|
+
domain,
|
|
133
|
+
types,
|
|
134
|
+
primaryType: "AgentWalletSet",
|
|
135
|
+
message,
|
|
136
|
+
signature,
|
|
137
|
+
});
|
|
138
|
+
if (recovered.toLowerCase() !== addrEvm.toLowerCase()) {
|
|
139
|
+
throw new Error(`Signature verification failed: recovered ${recovered}, expected ${addrEvm}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const txHash = await this.sdk.chain.setAgentWallet(this.sdk.identityRegistry, this.sdk.identityRegistryAbi, agentTokenId, addrChain, deadline, signature);
|
|
143
|
+
return new TransactionHandle(txHash, this.sdk.chain, async () => {
|
|
144
|
+
this.registrationFile.walletAddress = addrChain;
|
|
145
|
+
this.registrationFile.walletChainId = this.sdk.chainId;
|
|
146
|
+
this.touch();
|
|
147
|
+
return this;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async unsetWallet() {
|
|
151
|
+
if (!this.registrationFile.agentId)
|
|
152
|
+
throw new Error("Agent must be registered first");
|
|
153
|
+
const agentTokenId = BigInt(this.registrationFile.agentId.split(":").pop());
|
|
154
|
+
const currentWallet = await this.getWallet().catch(() => undefined);
|
|
155
|
+
if (!currentWallet) {
|
|
156
|
+
this.registrationFile.walletAddress = undefined;
|
|
157
|
+
this.registrationFile.walletChainId = undefined;
|
|
158
|
+
this.touch();
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const txHash = await this.sdk.chain.unsetAgentWallet(this.sdk.identityRegistry, this.sdk.identityRegistryAbi, agentTokenId);
|
|
162
|
+
return new TransactionHandle(txHash, this.sdk.chain, async () => {
|
|
163
|
+
this.registrationFile.walletAddress = undefined;
|
|
164
|
+
this.registrationFile.walletChainId = undefined;
|
|
165
|
+
this.touch();
|
|
166
|
+
return this;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
toJSON() {
|
|
170
|
+
return { ...this.registrationFile };
|
|
171
|
+
}
|
|
172
|
+
touch() {
|
|
173
|
+
this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
|
|
174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C,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type Abi, type Hex } from "viem";
|
|
2
|
+
import type { ChainContracts, ChainType, TxWaitOptions } from "../models/types.js";
|
|
3
|
+
export interface ChainAdapter {
|
|
4
|
+
readonly chainType: ChainType;
|
|
5
|
+
readonly rpcUrl: string;
|
|
6
|
+
readonly signerAddress?: string;
|
|
7
|
+
registerAgent(identityRegistry: string, abi: Abi, agentURI: string): Promise<string>;
|
|
8
|
+
getAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
9
|
+
ownerOf(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
10
|
+
setAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint, newWallet: string, deadline: bigint, signature: Hex): Promise<string>;
|
|
11
|
+
unsetAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
12
|
+
giveFeedback(reputationRegistry: string, abi: Abi, agentId: bigint, value: bigint, valueDecimals: number, tag1: string, tag2: string, endpoint: string, feedbackURI: string, feedbackHash: Hex): Promise<string>;
|
|
13
|
+
readFeedback(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddress: string, feedbackIndex: bigint): Promise<readonly [bigint, number, string, string, boolean]>;
|
|
14
|
+
getSummary(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddresses: string[], tag1: string, tag2: string): Promise<readonly [bigint, bigint, number]>;
|
|
15
|
+
getClients(reputationRegistry: string, abi: Abi, agentId: bigint): Promise<string[]>;
|
|
16
|
+
getLastIndex(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddress: string): Promise<bigint>;
|
|
17
|
+
validationRequest(validationRegistry: string, abi: Abi, validatorAddress: string, agentId: bigint, requestURI: string, requestHash: Hex): Promise<string>;
|
|
18
|
+
validationResponse(validationRegistry: string, abi: Abi, requestHash: Hex, response: number, responseURI: string, responseHash: Hex, tag: string): Promise<string>;
|
|
19
|
+
getValidationStatus(validationRegistry: string, abi: Abi, requestHash: Hex): Promise<readonly [string, bigint, number, Hex, string, bigint]>;
|
|
20
|
+
waitForTransaction(txHash: string, opts?: TxWaitOptions): Promise<unknown>;
|
|
21
|
+
parseRegisteredAgentId(receipt: unknown): string | undefined;
|
|
22
|
+
toEvmAddress(address: string): string;
|
|
23
|
+
toChainAddress(address: string): string;
|
|
24
|
+
addressEqual(a: string, b: string): boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare class EvmAdapter implements ChainAdapter {
|
|
27
|
+
readonly chainType: ChainType;
|
|
28
|
+
readonly rpcUrl: string;
|
|
29
|
+
readonly signerAddress?: string;
|
|
30
|
+
private readonly publicClient;
|
|
31
|
+
private readonly walletClient?;
|
|
32
|
+
constructor(rpcUrl: string, chainId: number, signer?: string);
|
|
33
|
+
registerAgent(identityRegistry: string, abi: Abi, agentURI: string): Promise<string>;
|
|
34
|
+
getAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
35
|
+
ownerOf(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
36
|
+
setAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint, newWallet: string, deadline: bigint, signature: Hex): Promise<string>;
|
|
37
|
+
unsetAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
38
|
+
giveFeedback(reputationRegistry: string, abi: Abi, agentId: bigint, value: bigint, valueDecimals: number, tag1: string, tag2: string, endpoint: string, feedbackURI: string, feedbackHash: Hex): Promise<string>;
|
|
39
|
+
readFeedback(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddress: string, feedbackIndex: bigint): Promise<readonly [bigint, number, string, string, boolean]>;
|
|
40
|
+
getSummary(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddresses: string[], tag1: string, tag2: string): Promise<readonly [bigint, bigint, number]>;
|
|
41
|
+
getClients(reputationRegistry: string, abi: Abi, agentId: bigint): Promise<string[]>;
|
|
42
|
+
getLastIndex(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddress: string): Promise<bigint>;
|
|
43
|
+
validationRequest(validationRegistry: string, abi: Abi, validatorAddress: string, agentId: bigint, requestURI: string, requestHash: Hex): Promise<string>;
|
|
44
|
+
validationResponse(validationRegistry: string, abi: Abi, requestHash: Hex, response: number, responseURI: string, responseHash: Hex, tag: string): Promise<string>;
|
|
45
|
+
getValidationStatus(validationRegistry: string, _abi: Abi, requestHash: Hex): Promise<readonly [string, bigint, number, Hex, string, bigint]>;
|
|
46
|
+
waitForTransaction(txHash: string, opts?: TxWaitOptions): Promise<unknown>;
|
|
47
|
+
parseRegisteredAgentId(receipt: unknown): string | undefined;
|
|
48
|
+
toEvmAddress(address: string): string;
|
|
49
|
+
toChainAddress(address: string): string;
|
|
50
|
+
addressEqual(a: string, b: string): boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare class TronAdapter implements ChainAdapter {
|
|
53
|
+
readonly chainType: ChainType;
|
|
54
|
+
readonly rpcUrl: string;
|
|
55
|
+
readonly signerAddress?: string;
|
|
56
|
+
private readonly tronWeb;
|
|
57
|
+
private readonly feeLimit;
|
|
58
|
+
private readonly readCaller;
|
|
59
|
+
constructor(rpcUrl: string, signer?: string, feeLimit?: number);
|
|
60
|
+
private pickMethod;
|
|
61
|
+
private toBigIntSafe;
|
|
62
|
+
private getValidationStatusViaConstantCall;
|
|
63
|
+
registerAgent(identityRegistry: string, abi: Abi, agentURI: string): Promise<string>;
|
|
64
|
+
getAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
65
|
+
ownerOf(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
66
|
+
setAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint, newWallet: string, deadline: bigint, signature: Hex): Promise<string>;
|
|
67
|
+
unsetAgentWallet(identityRegistry: string, abi: Abi, agentId: bigint): Promise<string>;
|
|
68
|
+
giveFeedback(reputationRegistry: string, abi: Abi, agentId: bigint, value: bigint, valueDecimals: number, tag1: string, tag2: string, endpoint: string, feedbackURI: string, feedbackHash: Hex): Promise<string>;
|
|
69
|
+
readFeedback(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddress: string, feedbackIndex: bigint): Promise<readonly [bigint, number, string, string, boolean]>;
|
|
70
|
+
getSummary(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddresses: string[], tag1: string, tag2: string): Promise<readonly [bigint, bigint, number]>;
|
|
71
|
+
getClients(reputationRegistry: string, abi: Abi, agentId: bigint): Promise<string[]>;
|
|
72
|
+
getLastIndex(reputationRegistry: string, abi: Abi, agentId: bigint, clientAddress: string): Promise<bigint>;
|
|
73
|
+
validationRequest(validationRegistry: string, abi: Abi, validatorAddress: string, agentId: bigint, requestURI: string, requestHash: Hex): Promise<string>;
|
|
74
|
+
validationResponse(validationRegistry: string, abi: Abi, requestHash: Hex, response: number, responseURI: string, responseHash: Hex, tag: string): Promise<string>;
|
|
75
|
+
getValidationStatus(validationRegistry: string, abi: Abi, requestHash: Hex): Promise<readonly [string, bigint, number, Hex, string, bigint]>;
|
|
76
|
+
waitForTransaction(txHash: string, opts?: TxWaitOptions): Promise<unknown>;
|
|
77
|
+
parseRegisteredAgentId(receipt: unknown): string | undefined;
|
|
78
|
+
toEvmAddress(address: string): string;
|
|
79
|
+
toChainAddress(address: string): string;
|
|
80
|
+
addressEqual(a: string, b: string): boolean;
|
|
81
|
+
}
|
|
82
|
+
export declare function resolveChainFromConfig(chainsJson: any, network: string, chainId?: number, rpcUrl?: string): {
|
|
83
|
+
chainType: ChainType;
|
|
84
|
+
resolvedNetwork: string;
|
|
85
|
+
resolvedChainId: number;
|
|
86
|
+
rpcUrl: string;
|
|
87
|
+
contracts: ChainContracts;
|
|
88
|
+
};
|