@buildaureon/sdk 0.1.0 → 0.1.2
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 -21
- package/README.md +640 -532
- package/config/network.json +10 -10
- package/dist/index.d.ts +88 -9
- package/dist/index.js +56 -5
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +206 -205
- package/docs/auth.md +174 -215
- package/docs/client-api.md +605 -604
- package/docs/data-contracts.md +635 -632
- package/docs/error-model.md +217 -182
- package/docs/integration-guide.md +257 -196
- package/docs/security.md +120 -74
- package/docs/transport.md +142 -128
- package/examples/e2e-policy-rebalance/main.ts +24 -36
- package/examples/e2e-policy-rebalance/underrun.ts +28 -24
- package/examples/e2e-policy-rebalance/verify-sizing.ts +29 -26
- package/examples/e2e-vault-flow/main.ts +36 -90
- package/examples/market-event/main.ts +65 -65
- package/examples/quickstart/main.ts +72 -71
- package/examples/registry-register/main.ts +44 -0
- package/examples/sdk-demo-terminal/main.ts +171 -0
- package/fixtures/reference-objectives.json +18 -18
- package/fixtures/reference-portfolio.json +10 -10
- package/package.json +61 -64
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Live
|
|
2
|
+
* @fileoverview Live vault deposit/withdraw + Automatic objective against the AUREON API.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Env (integrators only — no local repo files):
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
* AUREON_WALLET_PRIVATE_KEY 0x… key used to sign auth + broadcast vault txs (required)
|
|
8
|
+
* AUREON_RPC_URL optional (default Robinhood testnet RPC)
|
|
9
|
+
* AUREON_CHAIN_ID optional (default 46630)
|
|
6
10
|
*
|
|
7
|
-
*
|
|
8
|
-
* AUREON_API_URL default http://127.0.0.1:8787
|
|
9
|
-
* AUREON_API_KEY from backend/.env AUREON_API_KEYS (first key)
|
|
10
|
-
* AUREON_E2E_KEY hex private key (defaults to vault-deployer.key)
|
|
11
|
-
*
|
|
12
|
-
* pnpm --filter @buildaureon/sdk exec tsx examples/e2e-vault-flow/main.ts
|
|
11
|
+
* pnpm --filter @buildaureon/sdk example:e2e
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
16
|
-
import { dirname, join } from "node:path";
|
|
17
|
-
import { fileURLToPath } from "node:url";
|
|
18
14
|
import {
|
|
19
15
|
createPublicClient,
|
|
20
16
|
createWalletClient,
|
|
@@ -25,48 +21,22 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
25
21
|
import {
|
|
26
22
|
createAureonClient,
|
|
27
23
|
createSessionTokenProvider,
|
|
24
|
+
DEFAULT_API_BASE_URL,
|
|
28
25
|
isAureonError,
|
|
29
|
-
LOCAL_API_BASE_URL,
|
|
30
26
|
} from "../../src/index.js";
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function loadDotEnv(path: string): Record<string, string> {
|
|
37
|
-
if (!existsSync(path)) return {};
|
|
38
|
-
const out: Record<string, string> = {};
|
|
39
|
-
for (const line of readFileSync(path, "utf8").split(/\r?\n/)) {
|
|
40
|
-
const trimmed = line.trim();
|
|
41
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
42
|
-
const i = trimmed.indexOf("=");
|
|
43
|
-
if (i < 0) continue;
|
|
44
|
-
out[trimmed.slice(0, i)] = trimmed.slice(i + 1).trim();
|
|
45
|
-
}
|
|
46
|
-
return out;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function firstApiKey(raw: string | undefined): string | null {
|
|
50
|
-
if (!raw) return null;
|
|
51
|
-
const key = raw.split(",")[0]?.trim();
|
|
52
|
-
return key || null;
|
|
28
|
+
function requireEnv(name: string): string {
|
|
29
|
+
const value = process.env[name]?.trim();
|
|
30
|
+
if (!value) throw new Error(`Set ${name}`);
|
|
31
|
+
return value;
|
|
53
32
|
}
|
|
54
33
|
|
|
55
34
|
function loadPrivateKey(): Hex {
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
const key = requireEnv("AUREON_WALLET_PRIVATE_KEY");
|
|
36
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
37
|
+
throw new Error("AUREON_WALLET_PRIVATE_KEY must be a 0x-prefixed 32-byte hex key");
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
if (fromEnv?.startsWith("0x")) return fromEnv as Hex;
|
|
61
|
-
const keyPath = join(BACKEND, ".secrets/vault-deployer.key");
|
|
62
|
-
if (!existsSync(keyPath)) {
|
|
63
|
-
throw new Error("Missing AUREON_E2E_KEY / vault-deployer.key");
|
|
64
|
-
}
|
|
65
|
-
const hex = readFileSync(keyPath, "utf8").trim();
|
|
66
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(hex)) {
|
|
67
|
-
throw new Error("vault-deployer.key must be a 32-byte hex private key");
|
|
68
|
-
}
|
|
69
|
-
return hex as Hex;
|
|
39
|
+
return key as Hex;
|
|
70
40
|
}
|
|
71
41
|
|
|
72
42
|
function log(step: string, data?: unknown): void {
|
|
@@ -78,15 +48,12 @@ function log(step: string, data?: unknown): void {
|
|
|
78
48
|
}
|
|
79
49
|
|
|
80
50
|
async function main(): Promise<void> {
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const chainId = Number(env.AUREON_CHAIN_ID ?? 46630);
|
|
88
|
-
|
|
89
|
-
if (!apiKey) throw new Error("AUREON_API_KEY / AUREON_API_KEYS missing");
|
|
51
|
+
const baseUrl = process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL;
|
|
52
|
+
const apiKey = requireEnv("AUREON_API_KEY");
|
|
53
|
+
const rpcUrl =
|
|
54
|
+
process.env.AUREON_RPC_URL?.trim() ||
|
|
55
|
+
"https://rpc.testnet.chain.robinhood.com";
|
|
56
|
+
const chainId = Number(process.env.AUREON_CHAIN_ID ?? 46630);
|
|
90
57
|
|
|
91
58
|
const account = privateKeyToAccount(loadPrivateKey());
|
|
92
59
|
const publicClient = createPublicClient({ transport: http(rpcUrl) });
|
|
@@ -94,6 +61,12 @@ async function main(): Promise<void> {
|
|
|
94
61
|
account,
|
|
95
62
|
transport: http(rpcUrl),
|
|
96
63
|
});
|
|
64
|
+
const chain = {
|
|
65
|
+
id: chainId,
|
|
66
|
+
name: "Robinhood Chain Testnet",
|
|
67
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
68
|
+
rpcUrls: { default: { http: [rpcUrl] } },
|
|
69
|
+
} as const;
|
|
97
70
|
|
|
98
71
|
const session = createSessionTokenProvider(null);
|
|
99
72
|
const aureon = createAureonClient({
|
|
@@ -106,10 +79,7 @@ async function main(): Promise<void> {
|
|
|
106
79
|
log("ping", ping);
|
|
107
80
|
|
|
108
81
|
const { message } = await aureon.getAuthNonce(account.address);
|
|
109
|
-
const signature = await walletClient.signMessage({
|
|
110
|
-
account,
|
|
111
|
-
message,
|
|
112
|
-
});
|
|
82
|
+
const signature = await walletClient.signMessage({ account, message });
|
|
113
83
|
const login = await aureon.verifyWallet({
|
|
114
84
|
address: account.address,
|
|
115
85
|
message,
|
|
@@ -118,11 +88,6 @@ async function main(): Promise<void> {
|
|
|
118
88
|
session.setToken(login.token);
|
|
119
89
|
log("auth", { wallet: login.walletAddress });
|
|
120
90
|
|
|
121
|
-
const me = await aureon.me();
|
|
122
|
-
if (me.walletAddress.toLowerCase() !== account.address.toLowerCase()) {
|
|
123
|
-
throw new Error("session wallet mismatch");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
91
|
const synced = await aureon.syncPortfolio();
|
|
127
92
|
log("syncPortfolio", {
|
|
128
93
|
chainId: synced.chainId,
|
|
@@ -162,12 +127,7 @@ async function main(): Promise<void> {
|
|
|
162
127
|
for (const step of deposit.steps) {
|
|
163
128
|
const hash = await walletClient.sendTransaction({
|
|
164
129
|
account,
|
|
165
|
-
chain
|
|
166
|
-
id: chainId,
|
|
167
|
-
name: "Robinhood Chain Testnet",
|
|
168
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
169
|
-
rpcUrls: { default: { http: [rpcUrl] } },
|
|
170
|
-
},
|
|
130
|
+
chain,
|
|
171
131
|
to: step.to as `0x${string}`,
|
|
172
132
|
data: step.data as Hex,
|
|
173
133
|
value: BigInt(step.value),
|
|
@@ -185,19 +145,11 @@ async function main(): Promise<void> {
|
|
|
185
145
|
throw new Error("expected vault WETH to increase after depositETH");
|
|
186
146
|
}
|
|
187
147
|
|
|
188
|
-
const
|
|
189
|
-
const withdraw = await aureon.prepareVaultWithdraw({
|
|
190
|
-
amount: withdrawAmount,
|
|
191
|
-
});
|
|
148
|
+
const withdraw = await aureon.prepareVaultWithdraw({ amount: "0.00005" });
|
|
192
149
|
for (const step of withdraw.steps) {
|
|
193
150
|
const hash = await walletClient.sendTransaction({
|
|
194
151
|
account,
|
|
195
|
-
chain
|
|
196
|
-
id: chainId,
|
|
197
|
-
name: "Robinhood Chain Testnet",
|
|
198
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
199
|
-
rpcUrls: { default: { http: [rpcUrl] } },
|
|
200
|
-
},
|
|
152
|
+
chain,
|
|
201
153
|
to: step.to as `0x${string}`,
|
|
202
154
|
data: step.data as Hex,
|
|
203
155
|
value: BigInt(step.value),
|
|
@@ -211,9 +163,6 @@ async function main(): Promise<void> {
|
|
|
211
163
|
vaultAfterWithdraw.balances.find((b) => b.symbol.toUpperCase() === "WETH")
|
|
212
164
|
?.quantity ?? 0;
|
|
213
165
|
log("vault after withdraw", { weth: wethAfterWithdraw });
|
|
214
|
-
if (!(wethAfterWithdraw < wethAfterDeposit)) {
|
|
215
|
-
throw new Error("expected vault WETH to decrease after withdraw");
|
|
216
|
-
}
|
|
217
166
|
|
|
218
167
|
await aureon.syncPortfolio();
|
|
219
168
|
|
|
@@ -228,12 +177,9 @@ async function main(): Promise<void> {
|
|
|
228
177
|
log("createObjective", {
|
|
229
178
|
id: objective.id,
|
|
230
179
|
automationMode: objective.automationMode,
|
|
231
|
-
summary: objective.policy.summary,
|
|
232
180
|
});
|
|
233
181
|
if (objective.automationMode !== "auto") {
|
|
234
|
-
throw new Error(
|
|
235
|
-
`SDK create must default to auto, got ${objective.automationMode}`
|
|
236
|
-
);
|
|
182
|
+
throw new Error(`expected automationMode auto, got ${objective.automationMode}`);
|
|
237
183
|
}
|
|
238
184
|
|
|
239
185
|
const health = await aureon.getHealth(objective.id);
|
|
@@ -248,7 +194,7 @@ async function main(): Promise<void> {
|
|
|
248
194
|
});
|
|
249
195
|
} catch (err) {
|
|
250
196
|
if (isAureonError(err)) {
|
|
251
|
-
log("getRestorePlan (
|
|
197
|
+
log("getRestorePlan (ok if already in band)", {
|
|
252
198
|
code: err.code,
|
|
253
199
|
message: err.message,
|
|
254
200
|
});
|
|
@@ -257,7 +203,7 @@ async function main(): Promise<void> {
|
|
|
257
203
|
}
|
|
258
204
|
}
|
|
259
205
|
|
|
260
|
-
console.log("\nE2E OK
|
|
206
|
+
console.log("\nE2E OK — vault deposit/withdraw + Automatic objective");
|
|
261
207
|
}
|
|
262
208
|
|
|
263
209
|
main().catch((error) => {
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Controlled market
|
|
3
|
-
*
|
|
4
|
-
* Env:
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const objective = await aureon.createObjective({
|
|
29
|
-
name: "Maintain 20% Stable Assets",
|
|
30
|
-
kind: "stable_allocation",
|
|
31
|
-
targetWeight: 0.2,
|
|
32
|
-
tolerance: 0.02,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const result = await aureon.applyMarketEvent({
|
|
36
|
-
name: "NVDA Stock Token Rally",
|
|
37
|
-
description: "Controlled mark appreciation on NVIDIA Stock Token",
|
|
38
|
-
symbol: "NVDA",
|
|
39
|
-
priceChangeRatio: 0.45,
|
|
40
|
-
autoRestore: true,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
console.log(
|
|
44
|
-
JSON.stringify(
|
|
45
|
-
{
|
|
46
|
-
objectiveId: objective.id,
|
|
47
|
-
eventId: result.event.id,
|
|
48
|
-
executions: result.executions.length,
|
|
49
|
-
settlement: result.executions[0]?.settlement ?? null,
|
|
50
|
-
health: result.health.find((h) => h.objectiveId === objective.id)?.state,
|
|
51
|
-
},
|
|
52
|
-
null,
|
|
53
|
-
2
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
main().catch((error) => {
|
|
59
|
-
if (isAureonError(error)) {
|
|
60
|
-
console.error(`${error.code}: ${error.message}`);
|
|
61
|
-
} else {
|
|
62
|
-
console.error(error);
|
|
63
|
-
}
|
|
64
|
-
process.exitCode = 1;
|
|
65
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Controlled market-event rehearsal against the live AUREON API.
|
|
3
|
+
*
|
|
4
|
+
* Env:
|
|
5
|
+
* AUREON_API_KEY issued developer key (required)
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
*
|
|
8
|
+
* pnpm --filter @buildaureon/sdk example:market
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
createAureonClient,
|
|
13
|
+
DEFAULT_API_BASE_URL,
|
|
14
|
+
isAureonError,
|
|
15
|
+
} from "../../src/index.js";
|
|
16
|
+
|
|
17
|
+
async function main(): Promise<void> {
|
|
18
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
19
|
+
if (!apiKey) {
|
|
20
|
+
throw new Error("Set AUREON_API_KEY to an issued developer key.");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const aureon = createAureonClient({
|
|
24
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
25
|
+
apiKey,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const objective = await aureon.createObjective({
|
|
29
|
+
name: "Maintain 20% Stable Assets",
|
|
30
|
+
kind: "stable_allocation",
|
|
31
|
+
targetWeight: 0.2,
|
|
32
|
+
tolerance: 0.02,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const result = await aureon.applyMarketEvent({
|
|
36
|
+
name: "NVDA Stock Token Rally",
|
|
37
|
+
description: "Controlled mark appreciation on NVIDIA Stock Token",
|
|
38
|
+
symbol: "NVDA",
|
|
39
|
+
priceChangeRatio: 0.45,
|
|
40
|
+
autoRestore: true,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
console.log(
|
|
44
|
+
JSON.stringify(
|
|
45
|
+
{
|
|
46
|
+
objectiveId: objective.id,
|
|
47
|
+
eventId: result.event.id,
|
|
48
|
+
executions: result.executions.length,
|
|
49
|
+
settlement: result.executions[0]?.settlement ?? null,
|
|
50
|
+
health: result.health.find((h) => h.objectiveId === objective.id)?.state,
|
|
51
|
+
},
|
|
52
|
+
null,
|
|
53
|
+
2
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main().catch((error) => {
|
|
59
|
+
if (isAureonError(error)) {
|
|
60
|
+
console.error(`${error.code}: ${error.message}`);
|
|
61
|
+
} else {
|
|
62
|
+
console.error(error);
|
|
63
|
+
}
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
});
|
|
@@ -1,71 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Quickstart
|
|
3
|
-
*
|
|
4
|
-
* Env:
|
|
5
|
-
* AUREON_API_KEY
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
console.log("
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Quickstart — control-plane calls with an issued developer API key.
|
|
3
|
+
*
|
|
4
|
+
* Env (required for integrators — nothing else):
|
|
5
|
+
* AUREON_API_KEY issued key from https://app.aureonlabs.network → Developers
|
|
6
|
+
* AUREON_API_URL optional (default https://api.aureonlabs.network)
|
|
7
|
+
*
|
|
8
|
+
* pnpm --filter @buildaureon/sdk example:quickstart
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
createAureonClient,
|
|
13
|
+
DEFAULT_API_BASE_URL,
|
|
14
|
+
formatWeight,
|
|
15
|
+
isAureonError,
|
|
16
|
+
} from "../../src/index.js";
|
|
17
|
+
|
|
18
|
+
async function main(): Promise<void> {
|
|
19
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
20
|
+
if (!apiKey) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
"Set AUREON_API_KEY to an issued developer key from the AUREON Developers page."
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const aureon = createAureonClient({
|
|
27
|
+
baseUrl: process.env.AUREON_API_URL?.trim() || DEFAULT_API_BASE_URL,
|
|
28
|
+
apiKey,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const ping = await aureon.ping();
|
|
32
|
+
console.log("connected", ping);
|
|
33
|
+
|
|
34
|
+
const me = await aureon.me();
|
|
35
|
+
console.log("wallet", me.walletAddress);
|
|
36
|
+
|
|
37
|
+
const synced = await aureon.syncPortfolio();
|
|
38
|
+
console.log("synced", {
|
|
39
|
+
chainId: synced.chainId,
|
|
40
|
+
positions: synced.portfolio.positions.length,
|
|
41
|
+
stableWeight: formatWeight(synced.portfolio.stableWeight),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const vault = await aureon.getVaultStatus();
|
|
45
|
+
console.log("vault", {
|
|
46
|
+
empty: vault.empty,
|
|
47
|
+
canRestore: vault.canRestore,
|
|
48
|
+
totalNotionalUsd: vault.totalNotionalUsd,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const objectives = await aureon.listObjectives();
|
|
52
|
+
console.log(
|
|
53
|
+
"objectives",
|
|
54
|
+
objectives.map((o) => ({
|
|
55
|
+
name: o.name,
|
|
56
|
+
automationMode: o.automationMode,
|
|
57
|
+
}))
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
console.log(
|
|
61
|
+
"hint: private key is only needed later to broadcast prepare-deposit / prepare-withdraw steps"
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main().catch((error) => {
|
|
66
|
+
if (isAureonError(error)) {
|
|
67
|
+
console.error(`${error.code}: ${error.message}`);
|
|
68
|
+
} else {
|
|
69
|
+
console.error(error instanceof Error ? error.message : error);
|
|
70
|
+
}
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 2 — prepare on-chain objective registration (wallet signs broadcast).
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* AUREON_API_KEY=aur_... npx tsx examples/registry-register/main.ts
|
|
6
|
+
*/
|
|
7
|
+
import { createAureonClient } from "../../src/client/factory.js";
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
const apiKey = process.env.AUREON_API_KEY?.trim();
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
console.error("Set AUREON_API_KEY");
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const client = createAureonClient({ apiKey });
|
|
17
|
+
const status = await client.getRegistryStatus();
|
|
18
|
+
console.log("registry status", status);
|
|
19
|
+
|
|
20
|
+
const { objectives } = await client.listObjectives();
|
|
21
|
+
const target = objectives[0];
|
|
22
|
+
if (!target) {
|
|
23
|
+
console.error("Create an objective first");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const lookup = await client.getObjectiveRegistry(target.id);
|
|
28
|
+
if (lookup.registered) {
|
|
29
|
+
console.log("already registered", lookup.record);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const prepared = await client.prepareObjectiveRegistry(target.id);
|
|
34
|
+
console.log("Sign and broadcast this tx from your wallet:");
|
|
35
|
+
console.log(JSON.stringify(prepared, null, 2));
|
|
36
|
+
console.log(
|
|
37
|
+
"Then: client.confirmObjectiveRegistry(objectiveId, transactionHash)"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main().catch((err) => {
|
|
42
|
+
console.error(err);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|