Skip to content

Commit ef5588d

Browse files
feat: add optional baseUrl parameter to client configurations (#20)
* feat: add optional baseUrl parameter to client configurations - Updated GelatoSmartAccountClientConfig, GelatoBundlerClientConfig, and GelatoEvmRelayerClientConfig to include an optional baseUrl parameter. - Adjusted client creation functions to utilize baseUrl if provided, falling back to default API endpoints otherwise. * Update src/bundler/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update src/relayer/evm/index.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent f34d026 commit ef5588d

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

.changeset/nine-bags-roll.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@gelatocloud/gasless": patch
3+
---
4+
5+
add ability to pass a custom baseUrl

src/account/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ export type GelatoSmartAccountClient = Pick<
3030
export type GelatoSmartAccountClientConfig = {
3131
apiKey: string;
3232
account: SmartAccount<GelatoSmartAccountImplementation>;
33+
baseUrl?: string;
3334
};
3435

3536
export const createGelatoSmartAccountClient = async (
3637
parameters: GelatoSmartAccountClientConfig
3738
): Promise<GelatoSmartAccountClient> => {
38-
const { account, apiKey } = parameters;
39+
const { account, apiKey, baseUrl } = parameters;
3940

4041
const client = createGelatoEvmRelayerClient({
4142
apiKey,
43+
baseUrl,
4244
testnet: account.chain.testnet ?? false
4345
});
4446

src/bundler/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ export type GelatoBundlerClientConfig = Omit<BundlerClientConfig, 'transport' |
4040
client: Client<Transport, Chain>;
4141
payment?: Payment;
4242
apiKey: string;
43+
baseUrl?: string;
4344
};
4445

4546
export const createGelatoBundlerClient = async (
4647
parameters: GelatoBundlerClientConfig
4748
): Promise<GelatoBundlerClient> => {
48-
const { client: client_, payment, apiKey } = parameters;
49+
const { client: client_, payment, apiKey, baseUrl } = parameters;
4950

5051
// TODO: can just use prod endpoint in the future
51-
const base = client_.chain.testnet ? GELATO_STAGING_API : GELATO_PROD_API;
52+
const base = baseUrl || (client_.chain.testnet ? GELATO_STAGING_API : GELATO_PROD_API);
5253

5354
let endpoint = `${base}/rpc/${client_.chain.id}`;
5455

src/relayer/evm/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ export type GelatoEvmRelayerClient = {
4545
export type GelatoEvmRelayerClientConfig = {
4646
apiKey: string;
4747
testnet: boolean;
48+
baseUrl?: string;
4849
};
4950

5051
// TODO: the testnet/mainnet separation won't be necessary in the future
5152
export const createGelatoEvmRelayerClient = (
5253
parameters: GelatoEvmRelayerClientConfig
5354
): GelatoEvmRelayerClient => {
54-
const { apiKey, testnet } = parameters;
55+
const { apiKey, testnet, baseUrl } = parameters;
5556

5657
const config: HttpTransportConfig = {
5758
fetchOptions: {
@@ -62,7 +63,7 @@ export const createGelatoEvmRelayerClient = (
6263
};
6364

6465
// TODO: can just use prod endpoint in the future
65-
const base = testnet ? GELATO_STAGING_API : GELATO_PROD_API;
66+
const base = baseUrl || (testnet ? GELATO_STAGING_API : GELATO_PROD_API);
6667

6768
const client = http(`${base}/rpc`, config)({});
6869

0 commit comments

Comments
 (0)