Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions circuits/one/client/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {

const RPC_URL = process.env.RPC_URL || "https://api.devnet.solana.com";

const WS_URL =
process.env.WS_URL ||
RPC_URL.replace("https://", "wss://").replace("http://", "ws://");

// NOTE: This is a devnet example program ID. For production, deploy your own
// verifier via `sunspot deploy` and set PROGRAM_ID environment variable.
const PROGRAM_ID =
Expand Down Expand Up @@ -64,6 +68,7 @@ async function main() {

const sig = await verifyOnChain(instructionData, {
rpcUrl: RPC_URL,
wsUrl: WS_URL,
programId: address(PROGRAM_ID),
walletPath,
});
Expand Down
12 changes: 7 additions & 5 deletions circuits/smt_exclusion/client/test-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ import {

const RPC_URL = process.env.RPC_URL || "https://api.devnet.solana.com";

const WS_URL =
process.env.WS_URL ||
RPC_URL.replace("https://", "wss://").replace("http://", "ws://");

const ZK_VERIFIER_PROGRAM_ID = address(
process.env.ZK_VERIFIER_PROGRAM_ID ||
"548u4SFWZMaRWZQqdyAgm66z7VRYtNHHF2sr7JTBXbwN"
Expand Down Expand Up @@ -121,11 +125,9 @@ interface RpcContext {
sendAndConfirm: ReturnType<typeof sendAndConfirmTransactionFactory>;
}

function createRpcContext(rpcUrl: string): RpcContext {
function createRpcContext(rpcUrl: string, wsUrl: string): RpcContext {
const rpc = createSolanaRpc(rpcUrl);
const rpcSubscriptions = createSolanaRpcSubscriptions(
rpcUrl.replace("https://", "wss://").replace("http://", "ws://")
);
const rpcSubscriptions = createSolanaRpcSubscriptions(wsUrl);
const sendAndConfirm = sendAndConfirmTransactionFactory({
rpc,
rpcSubscriptions,
Expand Down Expand Up @@ -294,7 +296,7 @@ async function main() {

await initPoseidon();

const ctx = createRpcContext(RPC_URL);
const ctx = createRpcContext(RPC_URL, WS_URL);
console.log(`RPC: ${RPC_URL}`);
console.log(`ZK Verifier: ${ZK_VERIFIER_PROGRAM_ID}`);
console.log(`Exclusion Program: ${EXCLUSION_PROGRAM_ID}\n`);
Expand Down
5 changes: 5 additions & 0 deletions circuits/smt_exclusion/client/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import {

const RPC_URL = process.env.RPC_URL || "https://api.devnet.solana.com";

const WS_URL =
process.env.WS_URL ||
RPC_URL.replace("https://", "wss://").replace("http://", "ws://");

// NOTE: This is a devnet example program ID. For production, deploy your own
// verifier via `sunspot deploy` and set PROGRAM_ID environment variable.
const PROGRAM_ID =
Expand Down Expand Up @@ -108,6 +112,7 @@ async function main() {

const sig = await verifyOnChain(instructionData, {
rpcUrl: RPC_URL,
wsUrl: WS_URL,
programId,
walletPath,
});
Expand Down
5 changes: 5 additions & 0 deletions circuits/verify_signer/client/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {

const RPC_URL = process.env.RPC_URL || "https://api.devnet.solana.com";

const WS_URL =
process.env.WS_URL ||
RPC_URL.replace("https://", "wss://").replace("http://", "ws://");

// NOTE: This is a devnet example program ID. For production, deploy your own
// verifier via `sunspot deploy` and set PROGRAM_ID environment variable.
const PROGRAM_ID =
Expand Down Expand Up @@ -102,6 +106,7 @@ async function main() {

const sig = await verifyOnChain(instructionData, {
rpcUrl: RPC_URL,
wsUrl: WS_URL,
programId,
walletPath,
});
Expand Down
5 changes: 2 additions & 3 deletions lib/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import fs from "fs";

export interface VerifyConfig {
rpcUrl: string;
wsUrl: string;
programId: Address;
walletPath: string;
computeUnits?: number;
Expand All @@ -41,9 +42,7 @@ export async function verifyOnChain(
console.log(`Program: ${config.programId}`);

const rpc = createSolanaRpc(config.rpcUrl);
const rpcSubscriptions = createSolanaRpcSubscriptions(
config.rpcUrl.replace("https://", "wss://").replace("http://", "ws://")
);
const rpcSubscriptions = createSolanaRpcSubscriptions(config.wsUrl);
console.log(`RPC: ${config.rpcUrl}\n`);

const balanceResult = await rpc.getBalance(wallet.address).send();
Expand Down