@buildersgarden/siwa 0.0.16 → 0.0.17

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/README.md CHANGED
@@ -64,7 +64,7 @@ See [`references/security-model.md`](references/security-model.md) for the full
64
64
 
65
65
  ## References
66
66
 
67
- - [SKILL.md](SKILL.md) — Full skill documentation and API reference
67
+ - [skill.md](skill.md) — Full skill documentation and API reference
68
68
  - [ERC-8004 specification](https://github.com/builders-garden/ERC-8004)
69
69
  - [SIWA protocol spec](references/siwa-spec.md)
70
70
 
@@ -7,7 +7,7 @@
7
7
  * Dependencies:
8
8
  * npm install viem
9
9
  */
10
- import { type PublicClient } from 'viem';
10
+ import { type PublicClient, type Address, type Hex } from 'viem';
11
11
  import type { TransactionSigner } from './signer/index.js';
12
12
  /** Service endpoint types defined in ERC-8004 */
13
13
  export type ServiceType = 'web' | 'A2A' | 'MCP' | 'OASF' | 'ENS' | 'DID' | 'email';
@@ -73,6 +73,45 @@ export declare function getAgent(agentId: number, options: GetAgentOptions): Pro
73
73
  * @param options Reputation registry address, client, and optional filters
74
74
  */
75
75
  export declare function getReputation(agentId: number, options: GetReputationOptions): Promise<ReputationSummary>;
76
+ export interface EncodeRegisterAgentOptions {
77
+ /** The agent metadata URI (IPFS, HTTP, or data URL) */
78
+ agentURI: string;
79
+ /** The chain ID to register on */
80
+ chainId: number;
81
+ }
82
+ export interface EncodeRegisterAgentResult {
83
+ /** The registry contract address */
84
+ to: Address;
85
+ /** The ABI-encoded calldata for `register(agentURI)` */
86
+ data: Hex;
87
+ }
88
+ /**
89
+ * Encode the calldata for an ERC-8004 agent registration without sending it.
90
+ *
91
+ * Use this when your wallet provider handles transaction submission separately
92
+ * (e.g. Bankr's `/agent/submit`, or any ERC-4337 bundler).
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import { encodeRegisterAgent } from '@buildersgarden/siwa/registry';
97
+ *
98
+ * const { to, data } = encodeRegisterAgent({
99
+ * agentURI: 'data:application/json;base64,...',
100
+ * chainId: 84532,
101
+ * });
102
+ *
103
+ * // Submit via your provider (e.g. Bankr)
104
+ * await fetch('https://api.bankr.bot/agent/submit', {
105
+ * method: 'POST',
106
+ * headers: { 'Content-Type': 'application/json', 'X-API-Key': apiKey },
107
+ * body: JSON.stringify({
108
+ * transaction: { to, data, value: '0', chainId: 84532 },
109
+ * waitForConfirmation: true,
110
+ * }),
111
+ * });
112
+ * ```
113
+ */
114
+ export declare function encodeRegisterAgent(options: EncodeRegisterAgentOptions): EncodeRegisterAgentResult;
76
115
  export interface RegisterAgentOptions {
77
116
  /** The agent metadata URI (IPFS, HTTP, or data URL) */
78
117
  agentURI: string;
package/dist/registry.js CHANGED
@@ -156,6 +156,42 @@ export async function getReputation(agentId, options) {
156
156
  const score = Number(rawValue) / 10 ** decimals;
157
157
  return { count: Number(count), score, rawValue, decimals };
158
158
  }
159
+ /**
160
+ * Encode the calldata for an ERC-8004 agent registration without sending it.
161
+ *
162
+ * Use this when your wallet provider handles transaction submission separately
163
+ * (e.g. Bankr's `/agent/submit`, or any ERC-4337 bundler).
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * import { encodeRegisterAgent } from '@buildersgarden/siwa/registry';
168
+ *
169
+ * const { to, data } = encodeRegisterAgent({
170
+ * agentURI: 'data:application/json;base64,...',
171
+ * chainId: 84532,
172
+ * });
173
+ *
174
+ * // Submit via your provider (e.g. Bankr)
175
+ * await fetch('https://api.bankr.bot/agent/submit', {
176
+ * method: 'POST',
177
+ * headers: { 'Content-Type': 'application/json', 'X-API-Key': apiKey },
178
+ * body: JSON.stringify({
179
+ * transaction: { to, data, value: '0', chainId: 84532 },
180
+ * waitForConfirmation: true,
181
+ * }),
182
+ * });
183
+ * ```
184
+ */
185
+ export function encodeRegisterAgent(options) {
186
+ const { agentURI, chainId } = options;
187
+ const registryAddress = getRegistryAddress(chainId);
188
+ const data = encodeFunctionData({
189
+ abi: IDENTITY_REGISTRY_ABI,
190
+ functionName: 'register',
191
+ args: [agentURI],
192
+ });
193
+ return { to: registryAddress, data };
194
+ }
159
195
  /**
160
196
  * Register an agent on the ERC-8004 Identity Registry in a single call.
161
197
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildersgarden/siwa",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {