wallet-agent-ai-radix 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.
Files changed (55) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +284 -0
  3. package/dist/agent.d.ts +2 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +158 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/cli/derive.d.ts +5 -0
  8. package/dist/cli/derive.d.ts.map +1 -0
  9. package/dist/cli/derive.js +78 -0
  10. package/dist/cli/derive.js.map +1 -0
  11. package/dist/cli/index.d.ts +2 -0
  12. package/dist/cli/index.d.ts.map +1 -0
  13. package/dist/cli/index.js +32 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/cli/init.d.ts +2 -0
  16. package/dist/cli/init.d.ts.map +1 -0
  17. package/dist/cli/init.js +171 -0
  18. package/dist/cli/init.js.map +1 -0
  19. package/dist/cli/recover.d.ts +2 -0
  20. package/dist/cli/recover.d.ts.map +1 -0
  21. package/dist/cli/recover.js +112 -0
  22. package/dist/cli/recover.js.map +1 -0
  23. package/dist/cli/unlock.d.ts +3 -0
  24. package/dist/cli/unlock.d.ts.map +1 -0
  25. package/dist/cli/unlock.js +70 -0
  26. package/dist/cli/unlock.js.map +1 -0
  27. package/dist/core/AGGRClient.d.ts +19 -0
  28. package/dist/core/AGGRClient.d.ts.map +1 -0
  29. package/dist/core/AGGRClient.js +103 -0
  30. package/dist/core/AGGRClient.js.map +1 -0
  31. package/dist/core/AgentWallet.d.ts +64 -0
  32. package/dist/core/AgentWallet.d.ts.map +1 -0
  33. package/dist/core/AgentWallet.js +658 -0
  34. package/dist/core/AgentWallet.js.map +1 -0
  35. package/dist/core/RadixClient.d.ts +15 -0
  36. package/dist/core/RadixClient.d.ts.map +1 -0
  37. package/dist/core/RadixClient.js +112 -0
  38. package/dist/core/RadixClient.js.map +1 -0
  39. package/dist/index.d.ts +7 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +29 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/keystore/Keystore.d.ts +17 -0
  44. package/dist/keystore/Keystore.d.ts.map +1 -0
  45. package/dist/keystore/Keystore.js +97 -0
  46. package/dist/keystore/Keystore.js.map +1 -0
  47. package/dist/tools/LangChainTools.d.ts +19 -0
  48. package/dist/tools/LangChainTools.d.ts.map +1 -0
  49. package/dist/tools/LangChainTools.js +613 -0
  50. package/dist/tools/LangChainTools.js.map +1 -0
  51. package/dist/types/index.d.ts +104 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/index.js +6 -0
  54. package/dist/types/index.js.map +1 -0
  55. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ For the full license text, see: https://www.gnu.org/licenses/gpl-3.0.txt
package/README.md ADDED
@@ -0,0 +1,284 @@
1
+ # AgentWallet for Radix
2
+
3
+ A programmable wallet designed for AI agents operating on the Radix network.
4
+ Secure, auditable, and easy to integrate with any agent framework.
5
+
6
+ ---
7
+
8
+ ## What is AgentWallet?
9
+
10
+ AgentWallet lets you give your AI agent the ability to handle payments and trading
11
+ on the Radix network — safely and autonomously — without giving it full control
12
+ over your funds.
13
+
14
+ The owner defines the rules. The agent operates within them. On-chain, always.
15
+
16
+ **The agent CAN:**
17
+ - ✓ Transfer XRD, HUSDC, HUSDT, HWBTC and HETH to approved addresses
18
+ - ✓ Swap tokens via AGGR (Astrolescent or your own private instance)
19
+ - ✓ Place conditional orders that execute automatically at a target price
20
+ - ✓ Check vault balance before operating
21
+
22
+ **The agent CANNOT:**
23
+ - ✗ Send funds to addresses not in the whitelist
24
+ - ✗ Spend more than the configured limit per operation
25
+ - ✗ Access funds beyond what the owner let him on contract
26
+ - ✗ Modify its own permissions
27
+
28
+ ---
29
+
30
+ ## How it works
31
+ Owner install the SDK for his agent → init it
32
+
33
+ Owner deploys PolicyVault → funds it → configures rules
34
+
35
+ Receives 2 badges: Agent session badge (AWB) and PolicyVault Owner badge (PVOB)
36
+
37
+ Agent calls wallet.transfer() / wallet.swap() / wallet.createConditionalOrder()
38
+
39
+ PolicyVault verifies: valid badge + within spend limit + destination in whitelist
40
+
41
+ Transaction executes on Radix — fully auditable on-chain
42
+
43
+ ---
44
+
45
+ ## Requirements
46
+
47
+ - Node.js 18 or higher
48
+ - A Radix wallet with XRD for the deployment fees.
49
+ - Your AI agent running on any framework (LangChain, AutoGen, CrewAI, etc.)
50
+
51
+ ---
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ npm install agent-wallet-radix
57
+ npx agent-wallet init
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Owner Setup (done once)
63
+
64
+ Before your agent can operate, you need to deploy and fund the PolicyVault.
65
+ This is a one-time setup done by the human owner.
66
+
67
+ ### Step 1 — Deploy the PolicyVault
68
+
69
+ Go to the deploy page and connect your Radix Wallet:
70
+
71
+ 👉 **https://wallet-agent-ai.github.io/**
72
+
73
+ Fill in:
74
+
75
+ - **Agent Name** — agent name
76
+
77
+ - **Notarized Account** — The agent notarized account created with the installation and init of these sdk
78
+
79
+ - **Max Per Tx** — maximum tokens the agent can send per operation (e.g. 100 XRD)
80
+
81
+ - **Multisig Threshold** — maximum tokens the agent and owner can spend together in a single tx
82
+
83
+ - **Daily Cap** — maximum tokens the agent can spend in a day
84
+
85
+ Click **Instantiate** and approve the transaction in your Radix Wallet.
86
+
87
+ You will receive:
88
+ - `POLICY_VAULT_ADDRESS` — PVOB the deployed component address
89
+ - `AGENT_BADGE_ADDRESS` — AWB the agent badge resource address
90
+ The PVOB go to your account , the AWB to the notarized account of the agent. The AWB cant be moved. Only burn.
91
+
92
+ Save both. You will need them in the next step.
93
+
94
+ ### Step 2 — Fund the PolicyVault
95
+
96
+ Send XRD and/or other tokens to your PolicyVault from your Radix Wallet.And some too to the Notarized Agent for fee only.
97
+ These acount need a 25 xrd min account for fees that normally never be used.
98
+ The agent can only spend what you autorized. No more.
99
+
100
+ ### Step 3 — Create your .env file
101
+
102
+ Create a `.env` file in your agent project
103
+ on the package come a example with the required
104
+
105
+ ```bash
106
+ # Required
107
+ NOTARIZER_ADDRESS=account_tdx....
108
+ POLICY_VAULT_ADDRESS=component_rdx1...
109
+
110
+ AGENT_BADGE_ADDRESS=resource_rdx1...
111
+ AGENT_BADGE_LOCAL_ID=#1#
112
+
113
+ Owner_ADDRESS=account_tdx....
114
+ OWNER_BADGE_ADDRESS=resource_rdx1...
115
+
116
+ NETWORK=mainnet
117
+
118
+ # Optional — only needed for token swaps and conditional orders
119
+ # Use Astrolescent (public) or your own AGGR instance (private)
120
+ #Need to ask @djtrebel for a api key on telegram
121
+ AGGR_ENDPOINT=https://api.astrolescent.com
122
+ AGGR_PARTNER_ID=XXXX
123
+ AGGR_TIMEOUT_MS=5000
124
+
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Agent Integration (3 lines of code)
130
+
131
+ ```typescript
132
+ import { AgentWallet, createAgentWalletTools } from "agentwallet-radix";
133
+
134
+ const wallet = new AgentWallet({
135
+ componentAddress: process.env.POLICY_VAULT_ADDRESS!,
136
+ badgeResourceAddress: process.env.AGENT_BADGE_ADDRESS!,
137
+ privateKey: process.env.AGENT_PRIVATE_KEY!,
138
+ network: "mainnet", // or "stokenet" for testing
139
+
140
+ // Optional — remove if you don't need trading
141
+ aggrConfig: {
142
+ endpoint: process.env.AGGR_ENDPOINT!,
143
+ partnerId: process.env.AGGR_PARTNER_ID!,
144
+ },
145
+ });
146
+
147
+ const tools = createAgentWalletTools(wallet);
148
+
149
+ // Pass tools to your agent — it will use them autonomously
150
+ ```
151
+
152
+ ### LangChain
153
+
154
+ ```typescript
155
+ import { AgentExecutor } from "langchain/agents";
156
+
157
+ const agent = new AgentExecutor({ llm, tools });
158
+ await agent.invoke({
159
+ input: "Pay 50 XRD to account_rdx1... for API invoice #42"
160
+ });
161
+ ```
162
+
163
+ ### OpenAI function calling
164
+
165
+ ```typescript
166
+ import OpenAI from "openai";
167
+
168
+ const openai = new OpenAI();
169
+
170
+ const response = await openai.chat.completions.create({
171
+ model: "gpt-4",
172
+ messages: [{ role: "user", content: "Check my vault balance" }],
173
+ tools: tools.map(t => ({
174
+ type: "function",
175
+ function: {
176
+ name: t.name,
177
+ description: t.description,
178
+ parameters: t.parameters,
179
+ }
180
+ })),
181
+ });
182
+ ```
183
+
184
+ ### AutoGen / CrewAI
185
+
186
+ ```typescript
187
+ // Any framework that supports function calling works the same way
188
+ // Pass the tools array to your agent executor
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Available Tools
194
+
195
+ | Tool | Description |
196
+ |---|---|
197
+ | `wallet_balance` | Check current vault balance for all assets |
198
+ | `wallet_transfer` | Transfer tokens to a whitelisted address |
199
+ | `wallet_swap` | Swap tokens via AGGR (requires aggrConfig) |
200
+ | `wallet_conditional_order` | Buy or sell automatically at a target price |
201
+
202
+ ---
203
+
204
+ ## Adding Custom Assets
205
+
206
+ Default assets: `XRD`, `HUSDC`, `HUSDT`, `HWBTC`, `HETH`
207
+
208
+ To add any additional token:
209
+
210
+ ```typescript
211
+ wallet.registerAsset("MYTOKEN", {
212
+ mainnet: "resource_rdx1t...",
213
+ stokenet: "resource_tdx_2_1t...",
214
+ });
215
+
216
+ // Now use it like any default asset
217
+ await wallet.transfer({
218
+ to: "account_rdx1...",
219
+ amount: 100,
220
+ asset: "MYTOKEN",
221
+ reason: "payment"
222
+ });
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Networks
228
+
229
+ | Network | Description |
230
+ |---|---|
231
+ | `mainnet` | Radix mainnet — real funds |
232
+ | `stokenet` | Radix testnet — for development and testing |
233
+ | `localnet` | Local resim simulator — for development without network |
234
+
235
+ ---
236
+
237
+ ## Security Model
238
+
239
+ AgentWallet uses a **PolicyVault** smart contract deployed on Radix.
240
+ Every transaction the agent attempts is verified on-chain before execution:
241
+
242
+ 1. **Badge check** — the agent must present a valid session badge (NFT)
243
+ 2. **Spend limit** — the amount must not exceed the configured maximum per operation
244
+ 3. **Whitelist** — the destination address must be in the approved list
245
+
246
+ If any check fails, the transaction is rejected by the Radix Engine — not by the SDK.
247
+ This means the rules are enforced at the protocol level, not in application code.
248
+
249
+ ---
250
+
251
+ ## AGGR Integration
252
+
253
+ AgentWallet supports both public and private AGGR instances for token swaps.
254
+ The integration is identical — only the endpoint URL changes
255
+ if you have your own aggr:
256
+
257
+ ```bash
258
+ # Public — Astrolescent
259
+ AGGR_ENDPOINT=https://api.astrolescent.com
260
+
261
+ # Private — your own instance
262
+ AGGR_ENDPOINT=http://your-server-ip:3001
263
+ ```
264
+
265
+ No code changes required. Just update your `.env` file.
266
+
267
+ ---
268
+
269
+ ## Support this project
270
+
271
+ If AgentWallet is useful to you, consider supporting development:
272
+
273
+ **Radix donation address:**
274
+ Welcome any donation on XRD or other HTOKENS.
275
+
276
+ account_rdx128m9tq6xhxtmyx9z25s2xudm9g5pzxrypygzwh7ml8sfst46q0t892
277
+ ---
278
+
279
+ ## License
280
+
281
+ GPL3
282
+ Owner: Luis Toro Teijeiro aka linuxx @linuxx_xrd on Telegram
283
+
284
+ Built on [Radix](https://radixdlt.com) · Powered by [Scrypto](https://docs.radixdlt.com/docs/scrypto)
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":""}
package/dist/agent.js ADDED
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const dotenv_1 = require("dotenv");
37
+ (0, dotenv_1.config)({ path: ".env.agent" });
38
+ const readline = __importStar(require("readline"));
39
+ const groq_1 = require("@langchain/groq");
40
+ const tools_1 = require("@langchain/core/tools");
41
+ const zod_1 = require("zod");
42
+ const AgentWallet_1 = require("./core/AgentWallet");
43
+ const prebuilt_1 = require("@langchain/langgraph/prebuilt");
44
+ const LangChainTools_1 = require("./tools/LangChainTools");
45
+ const unlock_1 = require("./cli/unlock");
46
+ // ─── Keystore ─────────────────────────────────────────────────────────────────
47
+ const privateKey = (0, unlock_1.unlockKeystore)();
48
+ const notarizerAddress = (0, unlock_1.getNotarizerAddress)();
49
+ console.log(`[Agent] Notarizer: ${notarizerAddress}`);
50
+ // ─── AgentWallet ──────────────────────────────────────────────────────────────
51
+ const wallet = new AgentWallet_1.AgentWallet({
52
+ network: "mainnet",
53
+ privateKey,
54
+ notarizerAddress,
55
+ componentAddress: process.env.COMPONENT_ADDRESS,
56
+ badgeResourceAddress: process.env.BADGE_RESOURCE_ADDRESS,
57
+ badgeLocalId: process.env.BADGE_LOCAL_ID ?? "#1#",
58
+ ownerBadgeAddress: process.env.OWNER_BADGE_ADDRESS,
59
+ aggrConfig: {
60
+ endpoint: "https://api.astrolescent.com",
61
+ partnerId: process.env.AGGR_PARTNER_ID ?? "agentwallet",
62
+ mockMode: false,
63
+ },
64
+ onLowFunds: (warnings) => warnings.forEach(w => console.log(`⚠️ ${w}`)),
65
+ onTransferApproved: (details) => console.log(`✅ Transfer approved:`, details),
66
+ onTransferRejected: (details) => console.log(`❌ Transfer rejected:`, details),
67
+ });
68
+ // ─── LangChain Tools ──────────────────────────────────────────────────────────
69
+ const agentWalletTools = (0, LangChainTools_1.createAgentWalletTools)(wallet);
70
+ const langchainTools = agentWalletTools.map(tool => new tools_1.DynamicStructuredTool({
71
+ name: tool.name,
72
+ description: tool.description,
73
+ schema: zod_1.z.object(Object.fromEntries(Object.entries(tool.parameters.properties ?? {}).map(([k, v]) => [
74
+ k,
75
+ v.type === "number" ? zod_1.z.number().describe(v.description ?? "") :
76
+ v.enum ? zod_1.z.enum(v.enum).describe(v.description ?? "") :
77
+ zod_1.z.string().describe(v.description ?? "")
78
+ ]))),
79
+ func: async (params) => tool.call(params),
80
+ }));
81
+ // ─── LLM ──────────────────────────────────────────────────────────────────────
82
+ const llm = new groq_1.ChatGroq({
83
+ apiKey: process.env.GROQ_API_KEY,
84
+ model: "openai/gpt-oss-120b",
85
+ temperature: 0,
86
+ });
87
+ // ─── Telegram ─────────────────────────────────────────────────────────────────
88
+ const TELEGRAM_API = `https://api.telegram.org/bot${process.env.TELEGRAM_TOKEN}`;
89
+ const CHAT_ID = process.env.TELEGRAM_CHAT_ID;
90
+ async function notify(text) {
91
+ await fetch(`${TELEGRAM_API}/sendMessage`, {
92
+ method: "POST",
93
+ headers: { "Content-Type": "application/json" },
94
+ body: JSON.stringify({ chat_id: CHAT_ID, text }),
95
+ });
96
+ }
97
+ // ─── Agent ────────────────────────────────────────────────────────────────────
98
+ const agent = (0, prebuilt_1.createReactAgent)({
99
+ llm,
100
+ tools: langchainTools,
101
+ prompt: `You are AgentWallet — an autonomous AI agent that manages a crypto wallet on the Radix blockchain.
102
+ You have access to tools to transfer tokens, swap assets, create conditional orders, and check balances.
103
+ Always check the balance and config before operating.
104
+ Be precise with amounts and addresses.
105
+ Always provide a reason for every transfer or swap.
106
+ If a transfer exceeds the multisig threshold, request owner approval automatically.`,
107
+ });
108
+ // ─── Main ─────────────────────────────────────────────────────────────────────
109
+ async function runInstruction(instruction) {
110
+ const result = await agent.invoke({
111
+ messages: [{ role: "user", content: instruction }]
112
+ });
113
+ const lastMessage = result.messages[result.messages.length - 1];
114
+ return typeof lastMessage.content === "string"
115
+ ? lastMessage.content
116
+ : JSON.stringify(lastMessage.content);
117
+ }
118
+ async function main() {
119
+ console.log("\n🤖 AgentWallet Agent ready — Mainnet");
120
+ console.log("Type your instructions in natural language. Type 'exit' to quit.\n");
121
+ await notify("🤖 AgentWallet Agent online — Mainnet. Ready for instructions.");
122
+ const rl = readline.createInterface({
123
+ input: process.stdin,
124
+ output: process.stdout,
125
+ });
126
+ const askQuestion = () => {
127
+ rl.question("👤 You: ", async (instruction) => {
128
+ if (!instruction.trim()) {
129
+ askQuestion();
130
+ return;
131
+ }
132
+ if (instruction.toLowerCase() === "exit") {
133
+ console.log("👋 Bye!");
134
+ await notify("🤖 Agent offline.");
135
+ rl.close();
136
+ return;
137
+ }
138
+ try {
139
+ await notify(`👤 ${instruction}`);
140
+ console.log("\n⏳ Processing...\n");
141
+ const output = await runInstruction(instruction);
142
+ console.log(`\n🤖 Agent: ${output}\n`);
143
+ await notify(`🤖 ${output}`);
144
+ }
145
+ catch (err) {
146
+ console.error(`❌ Error: ${err.message}`);
147
+ await notify(`❌ Error: ${err.message}`);
148
+ }
149
+ askQuestion();
150
+ });
151
+ };
152
+ askQuestion();
153
+ }
154
+ main().catch(async (err) => {
155
+ console.error(err);
156
+ await notify(`❌ Agent error: ${err.message}`);
157
+ });
158
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,IAAA,eAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAC/B,mDAAqC;AAErC,0CAA2C;AAC3C,iDAA8D;AAC9D,6BAAwB;AACxB,oDAAiD;AACjD,4DAAiE;AACjE,2DAAgE;AAChE,yCAAmE;AAGnE,iFAAiF;AACjF,MAAM,UAAU,GAAG,IAAA,uBAAc,GAAE,CAAC;AACpC,MAAM,gBAAgB,GAAG,IAAA,4BAAmB,GAAE,CAAC;AAC/C,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,EAAE,CAAC,CAAC;AAEtD,iFAAiF;AACjF,MAAM,MAAM,GAAG,IAAI,yBAAW,CAAC;IAC7B,OAAO,EAAE,SAAS;IAClB,UAAU;IACV,gBAAgB;IAChB,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAkB;IAChD,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAuB;IACzD,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,KAAK;IACjD,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAoB;IACnD,UAAU,EAAE;QACV,QAAQ,EAAE,8BAA8B;QACxC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa;QACvD,QAAQ,EAAE,KAAK;KAChB;IACD,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,C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M,MAAM,CAAC,YAAY,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1C,CAAC;YAED,WAAW,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,WAAW,EAAE,CAAC;AAChB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACzB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,MAAM,CAAC,kBAAkB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const HARDENED = 2147483648;
2
+ export declare const RADIX_PATH: number[];
3
+ export declare function slip10DeriveEd25519(seed: Uint8Array, path: number[]): Uint8Array;
4
+ export declare function derivePublicKey(privateKeyBytes: Uint8Array): Buffer;
5
+ //# sourceMappingURL=derive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/cli/derive.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,aAAa,CAAC;AACnC,eAAO,MAAM,UAAU,UAOtB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAahF;AAED,wBAAgB,eAAe,CAAC,eAAe,EAAE,UAAU,GAAG,MAAM,CAYnE"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.RADIX_PATH = exports.HARDENED = void 0;
37
+ exports.slip10DeriveEd25519 = slip10DeriveEd25519;
38
+ exports.derivePublicKey = derivePublicKey;
39
+ const hmac_js_1 = require("@noble/hashes/hmac.js");
40
+ const sha2_js_1 = require("@noble/hashes/sha2.js");
41
+ const crypto = __importStar(require("crypto"));
42
+ exports.HARDENED = 0x80000000;
43
+ exports.RADIX_PATH = [
44
+ 44 + exports.HARDENED,
45
+ 1022 + exports.HARDENED,
46
+ 1 + exports.HARDENED,
47
+ 525 + exports.HARDENED,
48
+ 1460 + exports.HARDENED,
49
+ 0 + exports.HARDENED,
50
+ ];
51
+ function slip10DeriveEd25519(seed, path) {
52
+ const I = (0, hmac_js_1.hmac)(sha2_js_1.sha512, Buffer.from("ed25519 seed"), seed);
53
+ let IL = I.slice(0, 32);
54
+ let IR = I.slice(32);
55
+ for (const index of path) {
56
+ const indexBuf = Buffer.alloc(4);
57
+ indexBuf.writeUInt32BE(index, 0);
58
+ const data = Buffer.concat([Buffer.alloc(1, 0), IL, indexBuf]);
59
+ const child = (0, hmac_js_1.hmac)(sha2_js_1.sha512, IR, data);
60
+ IL = child.slice(0, 32);
61
+ IR = child.slice(32);
62
+ }
63
+ return IL;
64
+ }
65
+ function derivePublicKey(privateKeyBytes) {
66
+ const privateKeyObj = crypto.createPrivateKey({
67
+ key: Buffer.concat([
68
+ Buffer.from("302e020100300506032b657004220420", "hex"),
69
+ privateKeyBytes,
70
+ ]),
71
+ format: "der",
72
+ type: "pkcs8",
73
+ });
74
+ const publicKeyObj = crypto.createPublicKey(privateKeyObj);
75
+ const publicKeyDer = publicKeyObj.export({ format: "der", type: "spki" });
76
+ return publicKeyDer.slice(-32);
77
+ }
78
+ //# sourceMappingURL=derive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive.js","sourceRoot":"","sources":["../../src/cli/derive.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,kDAaC;AAED,0CAYC;AAzCD,mDAA6C;AAC7C,mDAA+C;AAC/C,+CAAiC;AAEpB,QAAA,QAAQ,GAAG,UAAU,CAAC;AACtB,QAAA,UAAU,GAAG;IACxB,EAAE,GAAK,gBAAQ;IACf,IAAI,GAAG,gBAAQ;IACf,CAAC,GAAM,gBAAQ;IACf,GAAG,GAAI,gBAAQ;IACf,IAAI,GAAG,gBAAQ;IACf,CAAC,GAAM,gBAAQ;CAChB,CAAC;AAEF,SAAgB,mBAAmB,CAAC,IAAgB,EAAE,IAAc;IAClE,MAAM,CAAC,GAAG,IAAA,cAAI,EAAC,gBAAM,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1D,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxB,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrB,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjC,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,IAAA,cAAI,EAAC,gBAAM,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QACrC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxB,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAgB,eAAe,CAAC,eAA2B;IACzD,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC;YACtD,eAAe;SAChB,CAAC;QACF,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAW,CAAC;IACpF,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const init_1 = require("./init");
4
+ const recover_1 = require("./recover");
5
+ const unlock_1 = require("./unlock");
6
+ const command = process.argv[2];
7
+ switch (command) {
8
+ case "init":
9
+ (0, init_1.init)().catch(console.error);
10
+ break;
11
+ case "status":
12
+ try {
13
+ (0, unlock_1.unlockKeystore)();
14
+ console.log("✅ Keystore OK");
15
+ console.log("📍 Direction:", (0, unlock_1.getNotarizerAddress)());
16
+ }
17
+ catch (e) {
18
+ console.log(e.message);
19
+ }
20
+ break;
21
+ case "recover":
22
+ (0, recover_1.recover)().catch(console.error);
23
+ break;
24
+ default:
25
+ console.log(" recover — Recover wallet from 24 seeds + pass word");
26
+ console.log("Use: agent-wallet <comand>");
27
+ console.log("Comands:");
28
+ console.log(" init — Begin the wallet notarized");
29
+ console.log(" status — Verificate keystore and show direction");
30
+ break;
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AAAA,iCAA8B;AAC9B,uCAAoC;AACpC,qCAA+D;AAE/D,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEhC,QAAQ,OAAO,EAAE,CAAC;IAChB,KAAK,MAAM;QACT,IAAA,WAAI,GAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,MAAM;IACR,KAAK,QAAQ;QACX,IAAI,CAAC;YACH,IAAA,uBAAc,GAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAA,4BAAmB,GAAE,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QACD,MAAM;IACR,KAAK,SAAS;QACZ,IAAA,iBAAO,GAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,MAAM;IACT;QACG,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;QACpE,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;QAClE,MAAM;AACV,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function init(): Promise<void>;
2
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AA+BA,wBAAsB,IAAI,kBA6HzB"}