File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed
backend/native/backpack-api/src/routes/graphql/providers/solana Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -59,16 +59,11 @@ export class SolanaRpc implements BlockchainDataProvider {
59
59
readonly #connection: Connection ;
60
60
readonly #mpl: Metaplex ;
61
61
62
- constructor ( { context, customRpc, tokenList } : SolanaRpcProviderSettings ) {
63
- const rpcUrl =
64
- context ?. network . rpc ??
65
- customRpc ??
66
- `https://rpc.helius.xyz/?api-key=${ HELIUS_API_KEY } ` ;
67
-
68
- this . #connection = new Connection ( rpcUrl , "confirmed" ) ;
62
+ constructor ( opts : SolanaRpcProviderSettings ) {
63
+ this . #connection = new Connection ( this . _getRpcUrl ( opts ) , "confirmed" ) ;
69
64
this . #mpl = Metaplex . make ( this . #connection) ;
70
- this . ctx = context ;
71
- this . tokenList = tokenList ?? SolanaTokenList ;
65
+ this . ctx = opts . context ;
66
+ this . tokenList = opts . tokenList ?? SolanaTokenList ;
72
67
}
73
68
74
69
/**
@@ -431,4 +426,20 @@ export class SolanaRpc implements BlockchainDataProvider {
431
426
filters ?. before !== undefined
432
427
) ;
433
428
}
429
+
430
+ /**
431
+ * Return the target RPC endpoint that should be used based on context.
432
+ * @private
433
+ * @param {SolanaRpcProviderSettings } settings
434
+ * @returns {string }
435
+ * @memberof SolanaRpc
436
+ */
437
+ private _getRpcUrl ( {
438
+ context,
439
+ customRpc,
440
+ } : SolanaRpcProviderSettings ) : string {
441
+ return context ?. network . rpc ?? customRpc ?? context ?. network . devnet
442
+ ? `https://rpc-devnet.helius.xyz/?api-key=${ HELIUS_API_KEY } `
443
+ : "https://rpc-proxy.backpack.workers.dev" ;
444
+ }
434
445
}
You can’t perform that action at this time.
0 commit comments