veilix-sdk 0.0.6 → 0.0.8
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/circuits/paths.cjs.map +1 -1
- package/dist/circuits/paths.js.map +1 -1
- package/dist/index.cjs +13 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -107
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +13 -107
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +13 -107
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -350,18 +350,6 @@ var veilix_devnet_default = {
|
|
|
350
350
|
]
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
|
-
{
|
|
354
|
-
name: "queue",
|
|
355
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
name: "slot_hashes",
|
|
359
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
name: "instructions",
|
|
363
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
364
|
-
},
|
|
365
353
|
{
|
|
366
354
|
name: "system_program",
|
|
367
355
|
address: "11111111111111111111111111111111"
|
|
@@ -718,18 +706,6 @@ var veilix_devnet_default = {
|
|
|
718
706
|
]
|
|
719
707
|
}
|
|
720
708
|
},
|
|
721
|
-
{
|
|
722
|
-
name: "queue",
|
|
723
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
name: "slot_hashes",
|
|
727
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
name: "instructions",
|
|
731
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
732
|
-
},
|
|
733
709
|
{
|
|
734
710
|
name: "mint"
|
|
735
711
|
},
|
|
@@ -2119,18 +2095,6 @@ var veilix_default = {
|
|
|
2119
2095
|
]
|
|
2120
2096
|
}
|
|
2121
2097
|
},
|
|
2122
|
-
{
|
|
2123
|
-
name: "queue",
|
|
2124
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
2125
|
-
},
|
|
2126
|
-
{
|
|
2127
|
-
name: "slot_hashes",
|
|
2128
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
2129
|
-
},
|
|
2130
|
-
{
|
|
2131
|
-
name: "instructions",
|
|
2132
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
2133
|
-
},
|
|
2134
2098
|
{
|
|
2135
2099
|
name: "system_program",
|
|
2136
2100
|
address: "11111111111111111111111111111111"
|
|
@@ -2487,18 +2451,6 @@ var veilix_default = {
|
|
|
2487
2451
|
]
|
|
2488
2452
|
}
|
|
2489
2453
|
},
|
|
2490
|
-
{
|
|
2491
|
-
name: "queue",
|
|
2492
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
2493
|
-
},
|
|
2494
|
-
{
|
|
2495
|
-
name: "slot_hashes",
|
|
2496
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
2497
|
-
},
|
|
2498
|
-
{
|
|
2499
|
-
name: "instructions",
|
|
2500
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
2501
|
-
},
|
|
2502
2454
|
{
|
|
2503
2455
|
name: "mint"
|
|
2504
2456
|
},
|
|
@@ -12575,52 +12527,6 @@ function formatNoteForDisplay(note, segmentLen = 8) {
|
|
|
12575
12527
|
(p) => p.length > segmentLen * 2 ? p.slice(0, segmentLen) + "\u2026" + p.slice(-segmentLen) : p
|
|
12576
12528
|
).join("-");
|
|
12577
12529
|
}
|
|
12578
|
-
async function readOracleGatewayUrls(queue) {
|
|
12579
|
-
const oracleKeys = await queue.fetchOracleKeys();
|
|
12580
|
-
if (oracleKeys.length === 0) return [];
|
|
12581
|
-
const rows = await sb.Oracle.loadMany(queue.program, oracleKeys);
|
|
12582
|
-
return rows.map(
|
|
12583
|
-
(row) => row ? Buffer.from(row.gatewayUri).toString("utf8").replace(/\0+$/, "").trim() : ""
|
|
12584
|
-
).filter((url) => url.length > 0);
|
|
12585
|
-
}
|
|
12586
|
-
async function firstHealthyGatewayUrl(urls) {
|
|
12587
|
-
try {
|
|
12588
|
-
return await Promise.any(
|
|
12589
|
-
urls.map(async (url) => {
|
|
12590
|
-
const response = await fetch(`${url.replace(/\/$/, "")}/gateway/api/v1/test`, {
|
|
12591
|
-
signal: AbortSignal.timeout(8e3)
|
|
12592
|
-
});
|
|
12593
|
-
if (!response.ok) {
|
|
12594
|
-
throw new Error(`gateway ${url} returned ${response.status}`);
|
|
12595
|
-
}
|
|
12596
|
-
return url;
|
|
12597
|
-
})
|
|
12598
|
-
);
|
|
12599
|
-
} catch (error) {
|
|
12600
|
-
const reason = error instanceof Error ? error.message : "unknown error";
|
|
12601
|
-
throw new Error(`veilix-sdk: no healthy Switchboard gateway (${reason})`);
|
|
12602
|
-
}
|
|
12603
|
-
}
|
|
12604
|
-
function crossbarForQueue(queue) {
|
|
12605
|
-
const client = new CrossbarClient("https://crossbar.switchboard.xyz");
|
|
12606
|
-
const fetchGateway = client.fetchGateway.bind(client);
|
|
12607
|
-
client.fetchGateway = async (network) => {
|
|
12608
|
-
try {
|
|
12609
|
-
return await fetchGateway(network);
|
|
12610
|
-
} catch (error) {
|
|
12611
|
-
const message = error instanceof Error ? error.message : "";
|
|
12612
|
-
if (!message.includes("No gateways available")) {
|
|
12613
|
-
throw error;
|
|
12614
|
-
}
|
|
12615
|
-
const urls = await readOracleGatewayUrls(queue);
|
|
12616
|
-
if (urls.length === 0) {
|
|
12617
|
-
throw error;
|
|
12618
|
-
}
|
|
12619
|
-
return new sb.Gateway(await firstHealthyGatewayUrl(urls));
|
|
12620
|
-
}
|
|
12621
|
-
};
|
|
12622
|
-
return client;
|
|
12623
|
-
}
|
|
12624
12530
|
function getRangeRiskScoreJob(address) {
|
|
12625
12531
|
return OracleJob.fromObject({
|
|
12626
12532
|
tasks: [
|
|
@@ -12649,7 +12555,7 @@ async function getOracleQuote(payer, addressToCheck) {
|
|
|
12649
12555
|
solanaRPCUrl: rpcUrl,
|
|
12650
12556
|
queueAddress: getDepositQueueAddress()
|
|
12651
12557
|
});
|
|
12652
|
-
const crossbarClient =
|
|
12558
|
+
const crossbarClient = CrossbarClient.default();
|
|
12653
12559
|
const feed = {
|
|
12654
12560
|
name: "Risk Score",
|
|
12655
12561
|
jobs: [getRangeRiskScoreJob(addressToCheck)],
|
|
@@ -12722,7 +12628,6 @@ async function buildDepositIx(senderPubkey, commitmentBytes, denominationLamport
|
|
|
12722
12628
|
[Buffer.from("commitment"), commitmentBuf],
|
|
12723
12629
|
getProgramId()
|
|
12724
12630
|
);
|
|
12725
|
-
const queueAccount = new PublicKey(getDepositQueueAddress());
|
|
12726
12631
|
const remainingAccounts = [];
|
|
12727
12632
|
if (tempSigner) {
|
|
12728
12633
|
remainingAccounts.push({
|
|
@@ -12738,9 +12643,9 @@ async function buildDepositIx(senderPubkey, commitmentBytes, denominationLamport
|
|
|
12738
12643
|
pool: poolPDA,
|
|
12739
12644
|
treasury: treasuryPDA,
|
|
12740
12645
|
commitmentAccount: commitmentPDA,
|
|
12741
|
-
queue: queueAccount,
|
|
12742
|
-
slotHashes: anchor.web3.SYSVAR_SLOT_HASHES_PUBKEY,
|
|
12743
|
-
instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
12646
|
+
// queue: queueAccount,
|
|
12647
|
+
// slotHashes: anchor.web3.SYSVAR_SLOT_HASHES_PUBKEY,
|
|
12648
|
+
// instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
12744
12649
|
systemProgram: anchor.web3.SystemProgram.programId
|
|
12745
12650
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
12746
12651
|
} else {
|
|
@@ -12847,8 +12752,6 @@ async function buildDepositTx({
|
|
|
12847
12752
|
}).instruction()
|
|
12848
12753
|
);
|
|
12849
12754
|
}
|
|
12850
|
-
const { sigVerifyIx } = await getOracleQuote(sender, sender.toBase58());
|
|
12851
|
-
ixs.unshift(sigVerifyIx);
|
|
12852
12755
|
const { blockhash } = await connection.getLatestBlockhash();
|
|
12853
12756
|
const depositMessage = new TransactionMessage({
|
|
12854
12757
|
payerKey: sender,
|
|
@@ -13752,11 +13655,14 @@ async function executeVeilixTransfer(items, tempKeypair) {
|
|
|
13752
13655
|
const circuitArtifacts = await prepareWithdrawCircuitArtifacts();
|
|
13753
13656
|
try {
|
|
13754
13657
|
const extendBackupPdaNeeded = await isExtendBackupPdaNeeded2(senderPublicKey, allNotes.length);
|
|
13755
|
-
const [
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13658
|
+
const [depositInstructions, initNotesIx] = (
|
|
13659
|
+
//{ sigVerifyIx },
|
|
13660
|
+
await Promise.all([
|
|
13661
|
+
// getOracleQuote(senderPublicKey, senderPublicKey.toBase58()),
|
|
13662
|
+
buildDepositInstructionsForNotes2(senderPublicKey, allNotes, tempKeypair.publicKey),
|
|
13663
|
+
buildInitNotesInstructionIfNeeded2(senderPublicKey)
|
|
13664
|
+
])
|
|
13665
|
+
);
|
|
13760
13666
|
const indexedDeposits = prepared.map((item, index) => ({
|
|
13761
13667
|
item,
|
|
13762
13668
|
depositIx: depositInstructions[index]
|
|
@@ -13767,7 +13673,7 @@ async function executeVeilixTransfer(items, tempKeypair) {
|
|
|
13767
13673
|
Promise.all(
|
|
13768
13674
|
depositChunks.map(async (batch, batchIndex) => {
|
|
13769
13675
|
const instructions = [
|
|
13770
|
-
sigVerifyIx,
|
|
13676
|
+
// sigVerifyIx,
|
|
13771
13677
|
...batch.map((entry) => entry.depositIx)
|
|
13772
13678
|
];
|
|
13773
13679
|
instructions.map((ix) => {
|