@blockrun/clawrouter 0.12.2 → 0.12.3
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/cli.js +26 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.js +46 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -843,7 +843,7 @@ async function sweepSolanaWallet(oldKeyBytes, newKeyBytes, rpcUrl) {
|
|
|
843
843
|
};
|
|
844
844
|
}
|
|
845
845
|
let usdcBalance = 0n;
|
|
846
|
-
|
|
846
|
+
const oldTokenAccounts = [];
|
|
847
847
|
try {
|
|
848
848
|
const response = await rpc.getTokenAccountsByOwner(
|
|
849
849
|
solAddress2(oldAddress),
|
|
@@ -856,7 +856,7 @@ async function sweepSolanaWallet(oldKeyBytes, newKeyBytes, rpcUrl) {
|
|
|
856
856
|
const amount = BigInt(parsed.parsed.info.tokenAmount.amount);
|
|
857
857
|
if (amount > 0n) {
|
|
858
858
|
usdcBalance += amount;
|
|
859
|
-
|
|
859
|
+
oldTokenAccounts.push({ pubkey: account.pubkey, amount });
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
862
|
}
|
|
@@ -887,13 +887,6 @@ async function sweepSolanaWallet(oldKeyBytes, newKeyBytes, rpcUrl) {
|
|
|
887
887
|
usdcBalance
|
|
888
888
|
};
|
|
889
889
|
}
|
|
890
|
-
if (!oldTokenAccount) {
|
|
891
|
-
return {
|
|
892
|
-
error: "Could not find USDC token account in old wallet.",
|
|
893
|
-
oldAddress,
|
|
894
|
-
newAddress
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
890
|
try {
|
|
898
891
|
const newAta = await getAssociatedTokenAddress(solAddress2(newAddress), mint);
|
|
899
892
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
@@ -904,19 +897,21 @@ async function sweepSolanaWallet(oldKeyBytes, newKeyBytes, rpcUrl) {
|
|
|
904
897
|
solAddress2(newAddress),
|
|
905
898
|
mint
|
|
906
899
|
);
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
900
|
+
const transferIxs = oldTokenAccounts.map(
|
|
901
|
+
(acct) => buildTokenTransferInstruction(
|
|
902
|
+
solAddress2(acct.pubkey),
|
|
903
|
+
newAta,
|
|
904
|
+
oldSigner.address,
|
|
905
|
+
// old wallet authorizes the token transfer
|
|
906
|
+
acct.amount
|
|
907
|
+
)
|
|
913
908
|
);
|
|
914
909
|
const txMessage = pipe(
|
|
915
910
|
createTransactionMessage({ version: 0 }),
|
|
916
911
|
(msg) => setTransactionMessageFeePayer(newSigner.address, msg),
|
|
917
912
|
// new wallet pays gas
|
|
918
913
|
(msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg),
|
|
919
|
-
(msg) => appendTransactionMessageInstructions([createAtaIx,
|
|
914
|
+
(msg) => appendTransactionMessageInstructions([createAtaIx, ...transferIxs], msg)
|
|
920
915
|
);
|
|
921
916
|
const signedTx = await signTransactionMessageWithSigners(txMessage);
|
|
922
917
|
const txSignature = getSignatureFromTransaction(signedTx);
|
|
@@ -3289,9 +3284,15 @@ import { openSync, readSync, closeSync, fstatSync } from "fs";
|
|
|
3289
3284
|
async function readTextFile(filePath) {
|
|
3290
3285
|
const fh = await open(filePath, "r");
|
|
3291
3286
|
try {
|
|
3292
|
-
const
|
|
3293
|
-
|
|
3294
|
-
|
|
3287
|
+
const size = (await fh.stat()).size;
|
|
3288
|
+
const buf = Buffer.alloc(size);
|
|
3289
|
+
let offset = 0;
|
|
3290
|
+
while (offset < size) {
|
|
3291
|
+
const { bytesRead } = await fh.read(buf, offset, size - offset, offset);
|
|
3292
|
+
if (bytesRead === 0) break;
|
|
3293
|
+
offset += bytesRead;
|
|
3294
|
+
}
|
|
3295
|
+
return buf.subarray(0, offset).toString("utf-8");
|
|
3295
3296
|
} finally {
|
|
3296
3297
|
await fh.close();
|
|
3297
3298
|
}
|
|
@@ -3299,9 +3300,15 @@ async function readTextFile(filePath) {
|
|
|
3299
3300
|
function readTextFileSync(filePath) {
|
|
3300
3301
|
const fd = openSync(filePath, "r");
|
|
3301
3302
|
try {
|
|
3302
|
-
const
|
|
3303
|
-
|
|
3304
|
-
|
|
3303
|
+
const size = fstatSync(fd).size;
|
|
3304
|
+
const buf = Buffer.alloc(size);
|
|
3305
|
+
let offset = 0;
|
|
3306
|
+
while (offset < size) {
|
|
3307
|
+
const bytesRead = readSync(fd, buf, offset, size - offset, offset);
|
|
3308
|
+
if (bytesRead === 0) break;
|
|
3309
|
+
offset += bytesRead;
|
|
3310
|
+
}
|
|
3311
|
+
return buf.subarray(0, offset).toString("utf-8");
|
|
3305
3312
|
} finally {
|
|
3306
3313
|
closeSync(fd);
|
|
3307
3314
|
}
|
|
@@ -3328,18 +3335,23 @@ async function parseLogFile(filePath) {
|
|
|
3328
3335
|
try {
|
|
3329
3336
|
const content = await readTextFile(filePath);
|
|
3330
3337
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3338
|
+
const entries = [];
|
|
3339
|
+
for (const line of lines) {
|
|
3340
|
+
try {
|
|
3341
|
+
const entry = JSON.parse(line);
|
|
3342
|
+
entries.push({
|
|
3343
|
+
timestamp: entry.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3344
|
+
model: entry.model || "unknown",
|
|
3345
|
+
tier: entry.tier || "UNKNOWN",
|
|
3346
|
+
cost: entry.cost || 0,
|
|
3347
|
+
baselineCost: entry.baselineCost || entry.cost || 0,
|
|
3348
|
+
savings: entry.savings || 0,
|
|
3349
|
+
latencyMs: entry.latencyMs || 0
|
|
3350
|
+
});
|
|
3351
|
+
} catch {
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
return entries;
|
|
3343
3355
|
} catch {
|
|
3344
3356
|
return [];
|
|
3345
3357
|
}
|