@settlemint/sdk-blockscout 2.3.2-pref75df5f → 2.3.2-prf6c4f06f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,7 +50,7 @@ The SettleMint Blockscout SDK provides a seamless way to interact with Blockscou
50
50
 
51
51
  > **createBlockscoutClient**\<`Setup`\>(`options`, `clientOptions?`): `object`
52
52
 
53
- Defined in: [sdk/blockscout/src/blockscout.ts:75](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L75)
53
+ Defined in: [sdk/blockscout/src/blockscout.ts:76](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L76)
54
54
 
55
55
  Creates a Blockscout GraphQL client with proper type safety using gql.tada
56
56
 
@@ -64,8 +64,8 @@ Creates a Blockscout GraphQL client with proper type safety using gql.tada
64
64
 
65
65
  | Parameter | Type | Description |
66
66
  | ------ | ------ | ------ |
67
- | `options` | \{ `accessToken`: `string`; `instance`: `string`; \} | Configuration options for the client |
68
- | `options.accessToken` | `string` | - |
67
+ | `options` | \{ `accessToken?`: `string`; `instance`: `string`; \} | Configuration options for the client |
68
+ | `options.accessToken?` | `string` | - |
69
69
  | `options.instance?` | `string` | - |
70
70
  | `clientOptions?` | `RequestConfig` | Optional GraphQL client configuration options |
71
71
 
@@ -77,8 +77,8 @@ An object containing the GraphQL client and initialized gql.tada function
77
77
 
78
78
  | Name | Type | Defined in |
79
79
  | ------ | ------ | ------ |
80
- | `client` | `GraphQLClient` | [sdk/blockscout/src/blockscout.ts:79](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L79) |
81
- | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/blockscout/src/blockscout.ts:80](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L80) |
80
+ | `client` | `GraphQLClient` | [sdk/blockscout/src/blockscout.ts:80](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L80) |
81
+ | `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/blockscout/src/blockscout.ts:81](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L81) |
82
82
 
83
83
  ##### Throws
84
84
 
@@ -136,7 +136,7 @@ const result = await client.request(query, {
136
136
 
137
137
  > **ClientOptions** = `z.infer`\<*typeof* [`ClientOptionsSchema`](#clientoptionsschema)\>
138
138
 
139
- Defined in: [sdk/blockscout/src/blockscout.ts:23](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L23)
139
+ Defined in: [sdk/blockscout/src/blockscout.ts:24](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L24)
140
140
 
141
141
  Type definition for client options derived from the ClientOptionsSchema
142
142
 
@@ -146,7 +146,7 @@ Type definition for client options derived from the ClientOptionsSchema
146
146
 
147
147
  > **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
148
148
 
149
- Defined in: [sdk/blockscout/src/blockscout.ts:10](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L10)
149
+ Defined in: [sdk/blockscout/src/blockscout.ts:11](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L11)
150
150
 
151
151
  Type definition for GraphQL client configuration options
152
152
 
@@ -154,9 +154,9 @@ Type definition for GraphQL client configuration options
154
154
 
155
155
  #### ClientOptionsSchema
156
156
 
157
- > `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodString`; `instance`: `ZodUnion`\<readonly \[`ZodString`, `ZodString`\]\>; \}, `$strip`\>
157
+ > `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodOptional`\<`ZodString`\>; `instance`: `ZodUnion`\<readonly \[`ZodString`, `ZodString`\]\>; \}, `$strip`\>
158
158
 
159
- Defined in: [sdk/blockscout/src/blockscout.ts:15](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L15)
159
+ Defined in: [sdk/blockscout/src/blockscout.ts:16](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/blockscout/src/blockscout.ts#L16)
160
160
 
161
161
  Schema for validating client options for the Blockscout client.
162
162
 
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},d=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of u(e))!S.call(t,n)&&n!==r&&p(t,n,{get:()=>e[n],enumerable:!(a=h(e,n))||a.enumerable});return t};var g=t=>d(p({},"__esModule",{value:!0}),t);var O={};C(O,{ClientOptionsSchema:()=>m,createBlockscoutClient:()=>x,readFragment:()=>f.readFragment});module.exports=g(O);var i=require("@settlemint/sdk-utils/runtime"),o=require("@settlemint/sdk-utils/validation"),s=require("gql.tada"),c=require("graphql-request"),l=require("zod/v4"),f=require("gql.tada"),m=l.z.object({instance:o.UrlOrPathSchema,accessToken:o.ApplicationAccessTokenSchema});function x(t,e){(0,i.ensureServer)();let r=(0,o.validate)(m,t),a=(0,s.initGraphQLTada)(),n=new URL(r.instance).toString();return{client:new c.GraphQLClient(n,{...e,headers:{...e?.headers??{},"x-auth-token":r.accessToken}}),graphql:a}}0&&(module.exports={ClientOptionsSchema,createBlockscoutClient,readFragment});
1
+ "use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},g=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of S(e))!d.call(t,o)&&o!==r&&p(t,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return t};var x=t=>g(p({},"__esModule",{value:!0}),t);var y={};C(y,{ClientOptionsSchema:()=>f,createBlockscoutClient:()=>O,readFragment:()=>h.readFragment});module.exports=x(y);var i=require("@settlemint/sdk-utils/http"),s=require("@settlemint/sdk-utils/runtime"),a=require("@settlemint/sdk-utils/validation"),c=require("gql.tada"),l=require("graphql-request"),m=require("zod/v4"),h=require("gql.tada"),f=m.z.object({instance:a.UrlOrPathSchema,accessToken:a.ApplicationAccessTokenSchema.optional()});function O(t,e){(0,s.ensureServer)();let r=(0,a.validate)(f,t),n=(0,c.initGraphQLTada)(),o=new URL(r.instance).toString();return{client:new l.GraphQLClient(o,{...e,headers:(0,i.appendHeaders)(e?.headers,{"x-auth-token":r.accessToken})}),graphql:n}}0&&(module.exports={ClientOptionsSchema,createBlockscoutClient,readFragment});
2
2
  //# sourceMappingURL=blockscout.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/blockscout.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Blockscout client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Blockscout GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @returns An object containing the GraphQL client and initialized gql.tada function\n * @throws Will throw an error if the options fail validation\n * @example\n * import { createBlockscoutClient } from '@settlemint/sdk-blockscout';\n * import type { introspection } from \"@schemas/blockscout-env\";\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createBlockscoutClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * AddressHash: string;\n * Data: string;\n * DateTime: string;\n * Decimal: string;\n * FullHash: string;\n * Json: string;\n * NonceHash: string;\n * Wei: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * }, {\n * fetch: requestLogger(logger, \"blockscout\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetTransaction($hash: String!) {\n * transaction(hash: $hash) {\n * hash\n * blockNumber\n * value\n * gasUsed\n * }\n * }\n * `);\n *\n * const result = await client.request(query, {\n * hash: \"0x123abc...\"\n * });\n */\nexport function createBlockscoutClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: {\n ...(clientOptions?.headers ?? {}),\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,2BAAAC,EAAA,iDAAAC,EAAAJ,GAAA,IAAAK,EAA6B,yCAC7BC,EAAwE,4CACxEC,EAA0D,oBAC1DC,EAA8B,2BAC9BC,EAAkB,kBA8FlBF,EAA6B,oBApFhBG,EAAsB,IAAE,OAAO,CAC1C,SAAU,kBACV,YAAa,8BACf,CAAC,EAyDM,SAASC,EACdC,EACAC,EAIA,IACA,gBAAa,EACb,IAAMC,KAAmB,YAASJ,EAAqBE,CAAO,EACxDG,KAAU,mBAAuB,EACjCC,EAAU,IAAI,IAAIF,EAAiB,QAAQ,EAAE,SAAS,EAE5D,MAAO,CACL,OAAQ,IAAI,gBAAcE,EAAS,CACjC,GAAGH,EACH,QAAS,CACP,GAAIA,GAAe,SAAW,CAAC,EAC/B,eAAgBC,EAAiB,WACnC,CACF,CAAC,EACD,QAAAC,CACF,CACF","names":["blockscout_exports","__export","ClientOptionsSchema","createBlockscoutClient","__toCommonJS","import_runtime","import_validation","import_gql","import_graphql_request","import_v4","ClientOptionsSchema","createBlockscoutClient","options","clientOptions","validatedOptions","graphql","fullUrl"]}
1
+ {"version":3,"sources":["../src/blockscout.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Blockscout client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema.optional(),\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Blockscout GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @returns An object containing the GraphQL client and initialized gql.tada function\n * @throws Will throw an error if the options fail validation\n * @example\n * import { createBlockscoutClient } from '@settlemint/sdk-blockscout';\n * import type { introspection } from \"@schemas/blockscout-env\";\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createBlockscoutClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * AddressHash: string;\n * Data: string;\n * DateTime: string;\n * Decimal: string;\n * FullHash: string;\n * Json: string;\n * NonceHash: string;\n * Wei: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * }, {\n * fetch: requestLogger(logger, \"blockscout\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetTransaction($hash: String!) {\n * transaction(hash: $hash) {\n * hash\n * blockNumber\n * value\n * gasUsed\n * }\n * }\n * `);\n *\n * const result = await client.request(query, {\n * hash: \"0x123abc...\"\n * });\n */\nexport function createBlockscoutClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,2BAAAC,EAAA,iDAAAC,EAAAJ,GAAA,IAAAK,EAA8B,sCAC9BC,EAA6B,yCAC7BC,EAAwE,4CACxEC,EAA0D,oBAC1DC,EAA8B,2BAC9BC,EAAkB,kBA2FlBF,EAA6B,oBAjFhBG,EAAsB,IAAE,OAAO,CAC1C,SAAU,kBACV,YAAa,+BAA6B,SAAS,CACrD,CAAC,EAyDM,SAASC,EACdC,EACAC,EAIA,IACA,gBAAa,EACb,IAAMC,KAAmB,YAASJ,EAAqBE,CAAO,EACxDG,KAAU,mBAAuB,EACjCC,EAAU,IAAI,IAAIF,EAAiB,QAAQ,EAAE,SAAS,EAE5D,MAAO,CACL,OAAQ,IAAI,gBAAcE,EAAS,CACjC,GAAGH,EACH,WAAS,iBAAcA,GAAe,QAAS,CAAE,eAAgBC,EAAiB,WAAY,CAAC,CACjG,CAAC,EACD,QAAAC,CACF,CACF","names":["blockscout_exports","__export","ClientOptionsSchema","createBlockscoutClient","__toCommonJS","import_http","import_runtime","import_validation","import_gql","import_graphql_request","import_v4","ClientOptionsSchema","createBlockscoutClient","options","clientOptions","validatedOptions","graphql","fullUrl"]}
@@ -12,7 +12,7 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
12
12
  */
13
13
  declare const ClientOptionsSchema: z.ZodObject<{
14
14
  instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
15
- accessToken: z.ZodString;
15
+ accessToken: z.ZodOptional<z.ZodString>;
16
16
  }, z.core.$strip>;
17
17
  /**
18
18
  * Type definition for client options derived from the ClientOptionsSchema
@@ -12,7 +12,7 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
12
12
  */
13
13
  declare const ClientOptionsSchema: z.ZodObject<{
14
14
  instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
15
- accessToken: z.ZodString;
15
+ accessToken: z.ZodOptional<z.ZodString>;
16
16
  }, z.core.$strip>;
17
17
  /**
18
18
  * Type definition for client options derived from the ClientOptionsSchema
@@ -1,2 +1,2 @@
1
- import{ensureServer as a}from"@settlemint/sdk-utils/runtime";import{ApplicationAccessTokenSchema as p,UrlOrPathSchema as i,validate as s}from"@settlemint/sdk-utils/validation";import{initGraphQLTada as c}from"gql.tada";import{GraphQLClient as l}from"graphql-request";import{z as m}from"zod/v4";import{readFragment as q}from"gql.tada";var f=m.object({instance:i,accessToken:p});function O(r,e){a();let t=s(f,r),n=c(),o=new URL(t.instance).toString();return{client:new l(o,{...e,headers:{...e?.headers??{},"x-auth-token":t.accessToken}}),graphql:n}}export{f as ClientOptionsSchema,O as createBlockscoutClient,q as readFragment};
1
+ import{appendHeaders as n}from"@settlemint/sdk-utils/http";import{ensureServer as p}from"@settlemint/sdk-utils/runtime";import{ApplicationAccessTokenSchema as i,UrlOrPathSchema as s,validate as c}from"@settlemint/sdk-utils/validation";import{initGraphQLTada as l}from"gql.tada";import{GraphQLClient as m}from"graphql-request";import{z as f}from"zod/v4";import{readFragment as Q}from"gql.tada";var h=f.object({instance:s,accessToken:i.optional()});function L(r,e){p();let t=c(h,r),o=l(),a=new URL(t.instance).toString();return{client:new m(a,{...e,headers:n(e?.headers,{"x-auth-token":t.accessToken})}),graphql:o}}export{h as ClientOptionsSchema,L as createBlockscoutClient,Q as readFragment};
2
2
  //# sourceMappingURL=blockscout.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/blockscout.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Blockscout client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Blockscout GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @returns An object containing the GraphQL client and initialized gql.tada function\n * @throws Will throw an error if the options fail validation\n * @example\n * import { createBlockscoutClient } from '@settlemint/sdk-blockscout';\n * import type { introspection } from \"@schemas/blockscout-env\";\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createBlockscoutClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * AddressHash: string;\n * Data: string;\n * DateTime: string;\n * Decimal: string;\n * FullHash: string;\n * Json: string;\n * NonceHash: string;\n * Wei: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * }, {\n * fetch: requestLogger(logger, \"blockscout\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetTransaction($hash: String!) {\n * transaction(hash: $hash) {\n * hash\n * blockNumber\n * value\n * gasUsed\n * }\n * }\n * `);\n *\n * const result = await client.request(query, {\n * hash: \"0x123abc...\"\n * });\n */\nexport function createBlockscoutClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: {\n ...(clientOptions?.headers ?? {}),\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":"AAAA,OAAS,gBAAAA,MAAoB,gCAC7B,OAAS,gCAAAC,EAA8B,mBAAAC,EAAiB,YAAAC,MAAgB,mCACxE,OAAmC,mBAAAC,MAAuB,WAC1D,OAAS,iBAAAC,MAAqB,kBAC9B,OAAS,KAAAC,MAAS,SA8FlB,OAAS,gBAAAC,MAAoB,WApFtB,IAAMC,EAAsBF,EAAE,OAAO,CAC1C,SAAUJ,EACV,YAAaD,CACf,CAAC,EAyDM,SAASQ,EACdC,EACAC,EAIA,CACAX,EAAa,EACb,IAAMY,EAAmBT,EAASK,EAAqBE,CAAO,EACxDG,EAAUT,EAAuB,EACjCU,EAAU,IAAI,IAAIF,EAAiB,QAAQ,EAAE,SAAS,EAE5D,MAAO,CACL,OAAQ,IAAIP,EAAcS,EAAS,CACjC,GAAGH,EACH,QAAS,CACP,GAAIA,GAAe,SAAW,CAAC,EAC/B,eAAgBC,EAAiB,WACnC,CACF,CAAC,EACD,QAAAC,CACF,CACF","names":["ensureServer","ApplicationAccessTokenSchema","UrlOrPathSchema","validate","initGraphQLTada","GraphQLClient","z","readFragment","ClientOptionsSchema","createBlockscoutClient","options","clientOptions","validatedOptions","graphql","fullUrl"]}
1
+ {"version":3,"sources":["../src/blockscout.ts"],"sourcesContent":["import { appendHeaders } from \"@settlemint/sdk-utils/http\";\nimport { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from \"@settlemint/sdk-utils/validation\";\nimport { type AbstractSetupSchema, initGraphQLTada } from \"gql.tada\";\nimport { GraphQLClient } from \"graphql-request\";\nimport { z } from \"zod/v4\";\n\n/**\n * Type definition for GraphQL client configuration options\n */\nexport type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];\n\n/**\n * Schema for validating client options for the Blockscout client.\n */\nexport const ClientOptionsSchema = z.object({\n instance: UrlOrPathSchema,\n accessToken: ApplicationAccessTokenSchema.optional(),\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Creates a Blockscout GraphQL client with proper type safety using gql.tada\n *\n * @param options - Configuration options for the client\n * @param clientOptions - Optional GraphQL client configuration options\n * @returns An object containing the GraphQL client and initialized gql.tada function\n * @throws Will throw an error if the options fail validation\n * @example\n * import { createBlockscoutClient } from '@settlemint/sdk-blockscout';\n * import type { introspection } from \"@schemas/blockscout-env\";\n * import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';\n *\n * const logger = createLogger();\n *\n * const { client, graphql } = createBlockscoutClient<{\n * introspection: introspection;\n * disableMasking: true;\n * scalars: {\n * AddressHash: string;\n * Data: string;\n * DateTime: string;\n * Decimal: string;\n * FullHash: string;\n * Json: string;\n * NonceHash: string;\n * Wei: string;\n * };\n * }>({\n * instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * }, {\n * fetch: requestLogger(logger, \"blockscout\", fetch) as typeof fetch,\n * });\n *\n * // Making GraphQL queries\n * const query = graphql(`\n * query GetTransaction($hash: String!) {\n * transaction(hash: $hash) {\n * hash\n * blockNumber\n * value\n * gasUsed\n * }\n * }\n * `);\n *\n * const result = await client.request(query, {\n * hash: \"0x123abc...\"\n * });\n */\nexport function createBlockscoutClient<const Setup extends AbstractSetupSchema>(\n options: ClientOptions,\n clientOptions?: RequestConfig,\n): {\n client: GraphQLClient;\n graphql: initGraphQLTada<Setup>;\n} {\n ensureServer();\n const validatedOptions = validate(ClientOptionsSchema, options);\n const graphql = initGraphQLTada<Setup>();\n const fullUrl = new URL(validatedOptions.instance).toString();\n\n return {\n client: new GraphQLClient(fullUrl, {\n ...clientOptions,\n headers: appendHeaders(clientOptions?.headers, { \"x-auth-token\": validatedOptions.accessToken }),\n }),\n graphql,\n };\n}\n\nexport { readFragment } from \"gql.tada\";\nexport type { FragmentOf, ResultOf, VariablesOf } from \"gql.tada\";\n"],"mappings":"AAAA,OAAS,iBAAAA,MAAqB,6BAC9B,OAAS,gBAAAC,MAAoB,gCAC7B,OAAS,gCAAAC,EAA8B,mBAAAC,EAAiB,YAAAC,MAAgB,mCACxE,OAAmC,mBAAAC,MAAuB,WAC1D,OAAS,iBAAAC,MAAqB,kBAC9B,OAAS,KAAAC,MAAS,SA2FlB,OAAS,gBAAAC,MAAoB,WAjFtB,IAAMC,EAAsBF,EAAE,OAAO,CAC1C,SAAUJ,EACV,YAAaD,EAA6B,SAAS,CACrD,CAAC,EAyDM,SAASQ,EACdC,EACAC,EAIA,CACAX,EAAa,EACb,IAAMY,EAAmBT,EAASK,EAAqBE,CAAO,EACxDG,EAAUT,EAAuB,EACjCU,EAAU,IAAI,IAAIF,EAAiB,QAAQ,EAAE,SAAS,EAE5D,MAAO,CACL,OAAQ,IAAIP,EAAcS,EAAS,CACjC,GAAGH,EACH,QAASZ,EAAcY,GAAe,QAAS,CAAE,eAAgBC,EAAiB,WAAY,CAAC,CACjG,CAAC,EACD,QAAAC,CACF,CACF","names":["appendHeaders","ensureServer","ApplicationAccessTokenSchema","UrlOrPathSchema","validate","initGraphQLTada","GraphQLClient","z","readFragment","ClientOptionsSchema","createBlockscoutClient","options","clientOptions","validatedOptions","graphql","fullUrl"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@settlemint/sdk-blockscout",
3
3
  "description": "Blockscout integration module for SettleMint SDK, enabling blockchain explorer and analytics functionality",
4
- "version": "2.3.2-pref75df5f",
4
+ "version": "2.3.2-prf6c4f06f",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "FSL-1.1-MIT",
@@ -52,7 +52,7 @@
52
52
  "devDependencies": {},
53
53
  "dependencies": {
54
54
  "gql.tada": "^1",
55
- "@settlemint/sdk-utils": "2.3.2-pref75df5f",
55
+ "@settlemint/sdk-utils": "2.3.2-prf6c4f06f",
56
56
  "graphql-request": "^7",
57
57
  "zod": "^3.25.0"
58
58
  },