diff --git a/.changeset/gold-pumpkins-poke.md b/.changeset/gold-pumpkins-poke.md new file mode 100644 index 00000000000..22708e1999d --- /dev/null +++ b/.changeset/gold-pumpkins-poke.md @@ -0,0 +1,5 @@ +--- +"@thirdweb-dev/service-utils": patch +--- + +chore: Allow optional includeUsage (default: true) diff --git a/packages/service-utils/src/core/api.ts b/packages/service-utils/src/core/api.ts index 69d414d784e..e605c89f578 100644 --- a/packages/service-utils/src/core/api.ts +++ b/packages/service-utils/src/core/api.ts @@ -20,6 +20,7 @@ export type CoreServiceConfig = { serviceApiKey: string; serviceAction?: string; useWalletAuth?: boolean; + includeUsage?: boolean; }; type Usage = { @@ -85,8 +86,8 @@ export async function fetchKeyMetadataFromApi( clientId: string, config: CoreServiceConfig, ): Promise { - const { apiUrl, serviceScope, serviceApiKey } = config; - const url = `${apiUrl}/v1/keys/use?clientId=${clientId}&scope=${serviceScope}&includeUsage=true`; + const { apiUrl, serviceScope, serviceApiKey, includeUsage = true } = config; + const url = `${apiUrl}/v1/keys/use?clientId=${clientId}&scope=${serviceScope}&includeUsage=${includeUsage}`; const response = await fetch(url, { method: "GET", headers: { @@ -111,10 +112,10 @@ export async function fetchAccountFromApi( config: CoreServiceConfig, useWalletAuth: boolean, ): Promise { - const { apiUrl, serviceApiKey } = config; + const { apiUrl, serviceApiKey, includeUsage = true } = config; const url = useWalletAuth - ? `${apiUrl}/v1/wallet/me?includeUsage=true` - : `${apiUrl}/v1/account/me?includeUsage=true`; + ? `${apiUrl}/v1/wallet/me?includeUsage=${includeUsage}` + : `${apiUrl}/v1/account/me?includeUsage=${includeUsage}`; const response = await fetch(url, { method: "GET", headers: {