MCPcopy Create free account
hub / github.com/VanishMax/foton / createClient

Function createClient

packages/api/src/client.ts:12–34  ·  view source on GitHub ↗
(options?: CreateClientOptions)

Source from the content-addressed store, hash-verified

10}
11
12export const createClient = (options?: CreateClientOptions): RpcClient => {
13 const { api = 'mainnet', authToken } = options || {};
14
15 let baseUrl: string;
16 if (typeof api === 'object') {
17 baseUrl = api.url;
18 } else {
19 baseUrl = CHAIN_API_MAP[api];
20 }
21
22 const openapiClient = createOpenapiClient<paths>({ baseUrl });
23
24 if (authToken) {
25 openapiClient.use({
26 onRequest: ({ request }) => {
27 request.headers.set('X-API-Key', authToken);
28 return request;
29 },
30 });
31 }
32
33 return adaptClientRpc(openapiClient);
34};

Callers 1

createPublicClientFunction · 0.90

Calls 1

adaptClientRpcFunction · 0.85

Tested by

no test coverage detected