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.cjs
CHANGED
|
@@ -376,18 +376,6 @@ var veilix_devnet_default = {
|
|
|
376
376
|
]
|
|
377
377
|
}
|
|
378
378
|
},
|
|
379
|
-
{
|
|
380
|
-
name: "queue",
|
|
381
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
name: "slot_hashes",
|
|
385
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: "instructions",
|
|
389
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
390
|
-
},
|
|
391
379
|
{
|
|
392
380
|
name: "system_program",
|
|
393
381
|
address: "11111111111111111111111111111111"
|
|
@@ -744,18 +732,6 @@ var veilix_devnet_default = {
|
|
|
744
732
|
]
|
|
745
733
|
}
|
|
746
734
|
},
|
|
747
|
-
{
|
|
748
|
-
name: "queue",
|
|
749
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
name: "slot_hashes",
|
|
753
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
name: "instructions",
|
|
757
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
758
|
-
},
|
|
759
735
|
{
|
|
760
736
|
name: "mint"
|
|
761
737
|
},
|
|
@@ -2145,18 +2121,6 @@ var veilix_default = {
|
|
|
2145
2121
|
]
|
|
2146
2122
|
}
|
|
2147
2123
|
},
|
|
2148
|
-
{
|
|
2149
|
-
name: "queue",
|
|
2150
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
2151
|
-
},
|
|
2152
|
-
{
|
|
2153
|
-
name: "slot_hashes",
|
|
2154
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
2155
|
-
},
|
|
2156
|
-
{
|
|
2157
|
-
name: "instructions",
|
|
2158
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
2159
|
-
},
|
|
2160
2124
|
{
|
|
2161
2125
|
name: "system_program",
|
|
2162
2126
|
address: "11111111111111111111111111111111"
|
|
@@ -2513,18 +2477,6 @@ var veilix_default = {
|
|
|
2513
2477
|
]
|
|
2514
2478
|
}
|
|
2515
2479
|
},
|
|
2516
|
-
{
|
|
2517
|
-
name: "queue",
|
|
2518
|
-
address: "A43DyUGA7s8eXPxqEjJY6EBu1KKbNgfxF8h17VAHn13w"
|
|
2519
|
-
},
|
|
2520
|
-
{
|
|
2521
|
-
name: "slot_hashes",
|
|
2522
|
-
address: "SysvarS1otHashes111111111111111111111111111"
|
|
2523
|
-
},
|
|
2524
|
-
{
|
|
2525
|
-
name: "instructions",
|
|
2526
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
2527
|
-
},
|
|
2528
2480
|
{
|
|
2529
2481
|
name: "mint"
|
|
2530
2482
|
},
|
|
@@ -12601,52 +12553,6 @@ function formatNoteForDisplay(note, segmentLen = 8) {
|
|
|
12601
12553
|
(p) => p.length > segmentLen * 2 ? p.slice(0, segmentLen) + "\u2026" + p.slice(-segmentLen) : p
|
|
12602
12554
|
).join("-");
|
|
12603
12555
|
}
|
|
12604
|
-
async function readOracleGatewayUrls(queue) {
|
|
12605
|
-
const oracleKeys = await queue.fetchOracleKeys();
|
|
12606
|
-
if (oracleKeys.length === 0) return [];
|
|
12607
|
-
const rows = await sb__namespace.Oracle.loadMany(queue.program, oracleKeys);
|
|
12608
|
-
return rows.map(
|
|
12609
|
-
(row) => row ? buffer.Buffer.from(row.gatewayUri).toString("utf8").replace(/\0+$/, "").trim() : ""
|
|
12610
|
-
).filter((url) => url.length > 0);
|
|
12611
|
-
}
|
|
12612
|
-
async function firstHealthyGatewayUrl(urls) {
|
|
12613
|
-
try {
|
|
12614
|
-
return await Promise.any(
|
|
12615
|
-
urls.map(async (url) => {
|
|
12616
|
-
const response = await fetch(`${url.replace(/\/$/, "")}/gateway/api/v1/test`, {
|
|
12617
|
-
signal: AbortSignal.timeout(8e3)
|
|
12618
|
-
});
|
|
12619
|
-
if (!response.ok) {
|
|
12620
|
-
throw new Error(`gateway ${url} returned ${response.status}`);
|
|
12621
|
-
}
|
|
12622
|
-
return url;
|
|
12623
|
-
})
|
|
12624
|
-
);
|
|
12625
|
-
} catch (error) {
|
|
12626
|
-
const reason = error instanceof Error ? error.message : "unknown error";
|
|
12627
|
-
throw new Error(`veilix-sdk: no healthy Switchboard gateway (${reason})`);
|
|
12628
|
-
}
|
|
12629
|
-
}
|
|
12630
|
-
function crossbarForQueue(queue) {
|
|
12631
|
-
const client = new common.CrossbarClient("https://crossbar.switchboard.xyz");
|
|
12632
|
-
const fetchGateway = client.fetchGateway.bind(client);
|
|
12633
|
-
client.fetchGateway = async (network) => {
|
|
12634
|
-
try {
|
|
12635
|
-
return await fetchGateway(network);
|
|
12636
|
-
} catch (error) {
|
|
12637
|
-
const message = error instanceof Error ? error.message : "";
|
|
12638
|
-
if (!message.includes("No gateways available")) {
|
|
12639
|
-
throw error;
|
|
12640
|
-
}
|
|
12641
|
-
const urls = await readOracleGatewayUrls(queue);
|
|
12642
|
-
if (urls.length === 0) {
|
|
12643
|
-
throw error;
|
|
12644
|
-
}
|
|
12645
|
-
return new sb__namespace.Gateway(await firstHealthyGatewayUrl(urls));
|
|
12646
|
-
}
|
|
12647
|
-
};
|
|
12648
|
-
return client;
|
|
12649
|
-
}
|
|
12650
12556
|
function getRangeRiskScoreJob(address) {
|
|
12651
12557
|
return common.OracleJob.fromObject({
|
|
12652
12558
|
tasks: [
|
|
@@ -12675,7 +12581,7 @@ async function getOracleQuote(payer, addressToCheck) {
|
|
|
12675
12581
|
solanaRPCUrl: rpcUrl,
|
|
12676
12582
|
queueAddress: getDepositQueueAddress()
|
|
12677
12583
|
});
|
|
12678
|
-
const crossbarClient =
|
|
12584
|
+
const crossbarClient = common.CrossbarClient.default();
|
|
12679
12585
|
const feed = {
|
|
12680
12586
|
name: "Risk Score",
|
|
12681
12587
|
jobs: [getRangeRiskScoreJob(addressToCheck)],
|
|
@@ -12748,7 +12654,6 @@ async function buildDepositIx(senderPubkey, commitmentBytes, denominationLamport
|
|
|
12748
12654
|
[buffer.Buffer.from("commitment"), commitmentBuf],
|
|
12749
12655
|
getProgramId()
|
|
12750
12656
|
);
|
|
12751
|
-
const queueAccount = new web3_js.PublicKey(getDepositQueueAddress());
|
|
12752
12657
|
const remainingAccounts = [];
|
|
12753
12658
|
if (tempSigner) {
|
|
12754
12659
|
remainingAccounts.push({
|
|
@@ -12764,9 +12669,9 @@ async function buildDepositIx(senderPubkey, commitmentBytes, denominationLamport
|
|
|
12764
12669
|
pool: poolPDA,
|
|
12765
12670
|
treasury: treasuryPDA,
|
|
12766
12671
|
commitmentAccount: commitmentPDA,
|
|
12767
|
-
queue: queueAccount,
|
|
12768
|
-
slotHashes:
|
|
12769
|
-
instructions:
|
|
12672
|
+
// queue: queueAccount,
|
|
12673
|
+
// slotHashes: anchor.web3.SYSVAR_SLOT_HASHES_PUBKEY,
|
|
12674
|
+
// instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
12770
12675
|
systemProgram: anchor__namespace.web3.SystemProgram.programId
|
|
12771
12676
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
12772
12677
|
} else {
|
|
@@ -12873,8 +12778,6 @@ async function buildDepositTx({
|
|
|
12873
12778
|
}).instruction()
|
|
12874
12779
|
);
|
|
12875
12780
|
}
|
|
12876
|
-
const { sigVerifyIx } = await getOracleQuote(sender, sender.toBase58());
|
|
12877
|
-
ixs.unshift(sigVerifyIx);
|
|
12878
12781
|
const { blockhash } = await connection.getLatestBlockhash();
|
|
12879
12782
|
const depositMessage = new web3_js.TransactionMessage({
|
|
12880
12783
|
payerKey: sender,
|
|
@@ -13778,11 +13681,14 @@ async function executeVeilixTransfer(items, tempKeypair) {
|
|
|
13778
13681
|
const circuitArtifacts = await prepareWithdrawCircuitArtifacts();
|
|
13779
13682
|
try {
|
|
13780
13683
|
const extendBackupPdaNeeded = await isExtendBackupPdaNeeded2(senderPublicKey, allNotes.length);
|
|
13781
|
-
const [
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13684
|
+
const [depositInstructions, initNotesIx] = (
|
|
13685
|
+
//{ sigVerifyIx },
|
|
13686
|
+
await Promise.all([
|
|
13687
|
+
// getOracleQuote(senderPublicKey, senderPublicKey.toBase58()),
|
|
13688
|
+
buildDepositInstructionsForNotes2(senderPublicKey, allNotes, tempKeypair.publicKey),
|
|
13689
|
+
buildInitNotesInstructionIfNeeded2(senderPublicKey)
|
|
13690
|
+
])
|
|
13691
|
+
);
|
|
13786
13692
|
const indexedDeposits = prepared.map((item, index) => ({
|
|
13787
13693
|
item,
|
|
13788
13694
|
depositIx: depositInstructions[index]
|
|
@@ -13793,7 +13699,7 @@ async function executeVeilixTransfer(items, tempKeypair) {
|
|
|
13793
13699
|
Promise.all(
|
|
13794
13700
|
depositChunks.map(async (batch, batchIndex) => {
|
|
13795
13701
|
const instructions = [
|
|
13796
|
-
sigVerifyIx,
|
|
13702
|
+
// sigVerifyIx,
|
|
13797
13703
|
...batch.map((entry) => entry.depositIx)
|
|
13798
13704
|
];
|
|
13799
13705
|
instructions.map((ix) => {
|