MCPcopy Index your code
hub / github.com/subquery/subql / getSignerOrProvider

Function getSignerOrProvider

packages/cli/src/controller/network/constants.ts:62–86  ·  view source on GitHub ↗
(
  network: SQNetworks,
  logger: Logger,
  rpcUrl?: string,
  allowNewWalletConnect = false
)

Source from the content-addressed store, hash-verified

60}
61
62export async function getSignerOrProvider(
63 network: SQNetworks,
64 logger: Logger,
65 rpcUrl?: string,
66 allowNewWalletConnect = false
67): Promise<Signer | Provider> {
68 const provider = await getRpcProvider(network, rpcUrl);
69 const privateKey = process.env.SUBQL_PRIVATE_KEY;
70 if (privateKey) {
71 return new Wallet(privateKey, provider);
72 }
73
74 const signer = walletConnectSigner.getInstance(provider, logger, allowNewWalletConnect);
75
76 // Will return wallet connect if there is an existing connection, otherwise the provider
77 try {
78 await signer.getAddress();
79 return signer;
80 } catch (e: any) {
81 if (e === NO_EXISTING_CONN_ERROR) {
82 return provider;
83 }
84 throw e;
85 }
86}
87
88export function isSigner(signerOrProvider: Signer | Provider): signerOrProvider is Signer {
89 return typeof (signerOrProvider as Signer).getAddress === 'function';

Callers 14

connectWalletAdapterFunction · 0.90
removeApiKeyAdapterFunction · 0.90
createApiKeyAdapterFunction · 0.90
disconnectWalletAdapterFunction · 0.90
createDeploymentAdapterFunction · 0.90
createProjectAdapterFunction · 0.90
createFlexPlanAdapterFunction · 0.90
listApiKeysAdapterFunction · 0.90
listFlexPlansAdapterFunction · 0.90

Calls 3

getRpcProviderFunction · 0.85
getInstanceMethod · 0.80
getAddressMethod · 0.80

Tested by

no test coverage detected