@settlemint/sdk-blockscout 1.2.5 → 2.0.0
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 +10 -28
- package/dist/blockscout.cjs +1 -1
- package/dist/blockscout.cjs.map +1 -1
- package/dist/blockscout.d.cts +3 -32
- package/dist/blockscout.d.ts +3 -32
- package/dist/blockscout.mjs +1 -1
- package/dist/blockscout.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ For detailed information about using Blockscout with the SettleMint platform, ch
|
|
|
52
52
|
|
|
53
53
|
> **createBlockscoutClient**\<`Setup`\>(`options`, `clientOptions`?): `object`
|
|
54
54
|
|
|
55
|
-
Defined in: [sdk/blockscout/src/blockscout.ts:
|
|
55
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:70](https://github.com/settlemint/sdk/blob/v2.0.0/sdk/blockscout/src/blockscout.ts#L70)
|
|
56
56
|
|
|
57
57
|
Creates a Blockscout GraphQL client with proper type safety using gql.tada
|
|
58
58
|
|
|
@@ -66,7 +66,9 @@ Creates a Blockscout GraphQL client with proper type safety using gql.tada
|
|
|
66
66
|
|
|
67
67
|
| Parameter | Type | Description |
|
|
68
68
|
| ------ | ------ | ------ |
|
|
69
|
-
| `options` |
|
|
69
|
+
| `options` | \{ `accessToken`: `string`; `instance`: `string`; \} | Configuration options for the client |
|
|
70
|
+
| `options.accessToken` | `string` | - |
|
|
71
|
+
| `options.instance`? | `string` | - |
|
|
70
72
|
| `clientOptions`? | `RequestConfig` | Optional GraphQL client configuration options |
|
|
71
73
|
|
|
72
74
|
##### Returns
|
|
@@ -77,8 +79,8 @@ An object containing the GraphQL client and initialized gql.tada function
|
|
|
77
79
|
|
|
78
80
|
| Name | Type | Defined in |
|
|
79
81
|
| ------ | ------ | ------ |
|
|
80
|
-
| `client` | `GraphQLClient` | [sdk/blockscout/src/blockscout.ts:
|
|
81
|
-
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/blockscout/src/blockscout.ts:
|
|
82
|
+
| `client` | `GraphQLClient` | [sdk/blockscout/src/blockscout.ts:74](https://github.com/settlemint/sdk/blob/v2.0.0/sdk/blockscout/src/blockscout.ts#L74) |
|
|
83
|
+
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/blockscout/src/blockscout.ts:75](https://github.com/settlemint/sdk/blob/v2.0.0/sdk/blockscout/src/blockscout.ts#L75) |
|
|
82
84
|
|
|
83
85
|
##### Throws
|
|
84
86
|
|
|
@@ -90,7 +92,6 @@ Will throw an error if the options fail validation
|
|
|
90
92
|
import { createBlockscoutClient } from '@settlemint/sdk-blockscout';
|
|
91
93
|
import type { introspection } from "@schemas/blockscout-env";
|
|
92
94
|
|
|
93
|
-
// Server-side usage
|
|
94
95
|
const { client, graphql } = createBlockscoutClient<{
|
|
95
96
|
introspection: introspection;
|
|
96
97
|
disableMasking: true;
|
|
@@ -109,22 +110,6 @@ const { client, graphql } = createBlockscoutClient<{
|
|
|
109
110
|
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
110
111
|
});
|
|
111
112
|
|
|
112
|
-
// Browser-side usage
|
|
113
|
-
const { client, graphql } = createBlockscoutClient<{
|
|
114
|
-
introspection: introspection;
|
|
115
|
-
disableMasking: true;
|
|
116
|
-
scalars: {
|
|
117
|
-
AddressHash: string;
|
|
118
|
-
Data: string;
|
|
119
|
-
DateTime: string;
|
|
120
|
-
Decimal: string;
|
|
121
|
-
FullHash: string;
|
|
122
|
-
Json: string;
|
|
123
|
-
NonceHash: string;
|
|
124
|
-
Wei: string;
|
|
125
|
-
};
|
|
126
|
-
}>({});
|
|
127
|
-
|
|
128
113
|
// Making GraphQL queries
|
|
129
114
|
const query = graphql(`
|
|
130
115
|
query GetTransaction($hash: String!) {
|
|
@@ -148,7 +133,7 @@ const result = await client.request(query, {
|
|
|
148
133
|
|
|
149
134
|
> **ClientOptions** = `z.infer`\<*typeof* [`ClientOptionsSchema`](#clientoptionsschema)\>
|
|
150
135
|
|
|
151
|
-
Defined in: [sdk/blockscout/src/blockscout.ts:
|
|
136
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:23](https://github.com/settlemint/sdk/blob/v2.0.0/sdk/blockscout/src/blockscout.ts#L23)
|
|
152
137
|
|
|
153
138
|
Type definition for client options derived from the ClientOptionsSchema
|
|
154
139
|
|
|
@@ -158,7 +143,7 @@ Type definition for client options derived from the ClientOptionsSchema
|
|
|
158
143
|
|
|
159
144
|
> **RequestConfig** = `ConstructorParameters`\<*typeof* `GraphQLClient`\>\[`1`\]
|
|
160
145
|
|
|
161
|
-
Defined in: [sdk/blockscout/src/blockscout.ts:10](https://github.com/settlemint/sdk/blob/
|
|
146
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:10](https://github.com/settlemint/sdk/blob/v2.0.0/sdk/blockscout/src/blockscout.ts#L10)
|
|
162
147
|
|
|
163
148
|
Type definition for GraphQL client configuration options
|
|
164
149
|
|
|
@@ -166,14 +151,11 @@ Type definition for GraphQL client configuration options
|
|
|
166
151
|
|
|
167
152
|
#### ClientOptionsSchema
|
|
168
153
|
|
|
169
|
-
> `const` **ClientOptionsSchema**: `
|
|
154
|
+
> `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodString`; `instance`: `ZodUnion`\<\[`ZodString`, `ZodString`\]\>; \}, `"strip"`, `ZodTypeAny`, \{ `accessToken`: `string`; `instance`: `string`; \}, \{ `accessToken`: `string`; `instance`: `string`; \}\>
|
|
170
155
|
|
|
171
|
-
Defined in: [sdk/blockscout/src/blockscout.ts:
|
|
156
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:15](https://github.com/settlemint/sdk/blob/v2.0.0/sdk/blockscout/src/blockscout.ts#L15)
|
|
172
157
|
|
|
173
158
|
Schema for validating client options for the Blockscout client.
|
|
174
|
-
Defines two possible runtime configurations:
|
|
175
|
-
1. Server-side with instance URL and access token
|
|
176
|
-
2. Browser-side with no additional configuration needed
|
|
177
159
|
|
|
178
160
|
## Contributing
|
|
179
161
|
|
package/dist/blockscout.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
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"),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});
|
|
2
2
|
//# sourceMappingURL=blockscout.cjs.map
|
package/dist/blockscout.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blockscout.ts"],"sourcesContent":["import {
|
|
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\";\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 *\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 *\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,eAyFlBF,EAA6B,oBA/EhBG,EAAsB,IAAE,OAAO,CAC1C,SAAU,kBACV,YAAa,8BACf,CAAC,EAoDM,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_zod","ClientOptionsSchema","createBlockscoutClient","options","clientOptions","validatedOptions","graphql","fullUrl"]}
|
package/dist/blockscout.d.cts
CHANGED
|
@@ -9,29 +9,17 @@ import { z } from 'zod';
|
|
|
9
9
|
type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
|
|
10
10
|
/**
|
|
11
11
|
* Schema for validating client options for the Blockscout client.
|
|
12
|
-
* Defines two possible runtime configurations:
|
|
13
|
-
* 1. Server-side with instance URL and access token
|
|
14
|
-
* 2. Browser-side with no additional configuration needed
|
|
15
12
|
*/
|
|
16
|
-
declare const ClientOptionsSchema: z.
|
|
13
|
+
declare const ClientOptionsSchema: z.ZodObject<{
|
|
17
14
|
instance: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
18
|
-
runtime: z.ZodLiteral<"server">;
|
|
19
15
|
accessToken: z.ZodString;
|
|
20
16
|
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
runtime: "server";
|
|
22
17
|
instance: string;
|
|
23
18
|
accessToken: string;
|
|
24
19
|
}, {
|
|
25
|
-
runtime: "server";
|
|
26
20
|
instance: string;
|
|
27
21
|
accessToken: string;
|
|
28
|
-
}
|
|
29
|
-
runtime: z.ZodLiteral<"browser">;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
runtime: "browser";
|
|
32
|
-
}, {
|
|
33
|
-
runtime: "browser";
|
|
34
|
-
}>]>;
|
|
22
|
+
}>;
|
|
35
23
|
/**
|
|
36
24
|
* Type definition for client options derived from the ClientOptionsSchema
|
|
37
25
|
*/
|
|
@@ -47,7 +35,6 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
47
35
|
* import { createBlockscoutClient } from '@settlemint/sdk-blockscout';
|
|
48
36
|
* import type { introspection } from "@schemas/blockscout-env";
|
|
49
37
|
*
|
|
50
|
-
* // Server-side usage
|
|
51
38
|
* const { client, graphql } = createBlockscoutClient<{
|
|
52
39
|
* introspection: introspection;
|
|
53
40
|
* disableMasking: true;
|
|
@@ -66,22 +53,6 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
66
53
|
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
67
54
|
* });
|
|
68
55
|
*
|
|
69
|
-
* // Browser-side usage
|
|
70
|
-
* const { client, graphql } = createBlockscoutClient<{
|
|
71
|
-
* introspection: introspection;
|
|
72
|
-
* disableMasking: true;
|
|
73
|
-
* scalars: {
|
|
74
|
-
* AddressHash: string;
|
|
75
|
-
* Data: string;
|
|
76
|
-
* DateTime: string;
|
|
77
|
-
* Decimal: string;
|
|
78
|
-
* FullHash: string;
|
|
79
|
-
* Json: string;
|
|
80
|
-
* NonceHash: string;
|
|
81
|
-
* Wei: string;
|
|
82
|
-
* };
|
|
83
|
-
* }>({});
|
|
84
|
-
*
|
|
85
56
|
* // Making GraphQL queries
|
|
86
57
|
* const query = graphql(`
|
|
87
58
|
* query GetTransaction($hash: String!) {
|
|
@@ -98,7 +69,7 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
98
69
|
* hash: "0x123abc..."
|
|
99
70
|
* });
|
|
100
71
|
*/
|
|
101
|
-
declare function createBlockscoutClient<const Setup extends AbstractSetupSchema>(options:
|
|
72
|
+
declare function createBlockscoutClient<const Setup extends AbstractSetupSchema>(options: ClientOptions, clientOptions?: RequestConfig): {
|
|
102
73
|
client: GraphQLClient;
|
|
103
74
|
graphql: initGraphQLTada<Setup>;
|
|
104
75
|
};
|
package/dist/blockscout.d.ts
CHANGED
|
@@ -9,29 +9,17 @@ import { z } from 'zod';
|
|
|
9
9
|
type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
|
|
10
10
|
/**
|
|
11
11
|
* Schema for validating client options for the Blockscout client.
|
|
12
|
-
* Defines two possible runtime configurations:
|
|
13
|
-
* 1. Server-side with instance URL and access token
|
|
14
|
-
* 2. Browser-side with no additional configuration needed
|
|
15
12
|
*/
|
|
16
|
-
declare const ClientOptionsSchema: z.
|
|
13
|
+
declare const ClientOptionsSchema: z.ZodObject<{
|
|
17
14
|
instance: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
18
|
-
runtime: z.ZodLiteral<"server">;
|
|
19
15
|
accessToken: z.ZodString;
|
|
20
16
|
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
runtime: "server";
|
|
22
17
|
instance: string;
|
|
23
18
|
accessToken: string;
|
|
24
19
|
}, {
|
|
25
|
-
runtime: "server";
|
|
26
20
|
instance: string;
|
|
27
21
|
accessToken: string;
|
|
28
|
-
}
|
|
29
|
-
runtime: z.ZodLiteral<"browser">;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
runtime: "browser";
|
|
32
|
-
}, {
|
|
33
|
-
runtime: "browser";
|
|
34
|
-
}>]>;
|
|
22
|
+
}>;
|
|
35
23
|
/**
|
|
36
24
|
* Type definition for client options derived from the ClientOptionsSchema
|
|
37
25
|
*/
|
|
@@ -47,7 +35,6 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
47
35
|
* import { createBlockscoutClient } from '@settlemint/sdk-blockscout';
|
|
48
36
|
* import type { introspection } from "@schemas/blockscout-env";
|
|
49
37
|
*
|
|
50
|
-
* // Server-side usage
|
|
51
38
|
* const { client, graphql } = createBlockscoutClient<{
|
|
52
39
|
* introspection: introspection;
|
|
53
40
|
* disableMasking: true;
|
|
@@ -66,22 +53,6 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
66
53
|
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
67
54
|
* });
|
|
68
55
|
*
|
|
69
|
-
* // Browser-side usage
|
|
70
|
-
* const { client, graphql } = createBlockscoutClient<{
|
|
71
|
-
* introspection: introspection;
|
|
72
|
-
* disableMasking: true;
|
|
73
|
-
* scalars: {
|
|
74
|
-
* AddressHash: string;
|
|
75
|
-
* Data: string;
|
|
76
|
-
* DateTime: string;
|
|
77
|
-
* Decimal: string;
|
|
78
|
-
* FullHash: string;
|
|
79
|
-
* Json: string;
|
|
80
|
-
* NonceHash: string;
|
|
81
|
-
* Wei: string;
|
|
82
|
-
* };
|
|
83
|
-
* }>({});
|
|
84
|
-
*
|
|
85
56
|
* // Making GraphQL queries
|
|
86
57
|
* const query = graphql(`
|
|
87
58
|
* query GetTransaction($hash: String!) {
|
|
@@ -98,7 +69,7 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
98
69
|
* hash: "0x123abc..."
|
|
99
70
|
* });
|
|
100
71
|
*/
|
|
101
|
-
declare function createBlockscoutClient<const Setup extends AbstractSetupSchema>(options:
|
|
72
|
+
declare function createBlockscoutClient<const Setup extends AbstractSetupSchema>(options: ClientOptions, clientOptions?: RequestConfig): {
|
|
102
73
|
client: GraphQLClient;
|
|
103
74
|
graphql: initGraphQLTada<Setup>;
|
|
104
75
|
};
|
package/dist/blockscout.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
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";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};
|
|
2
2
|
//# sourceMappingURL=blockscout.mjs.map
|
package/dist/blockscout.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blockscout.ts"],"sourcesContent":["import {
|
|
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\";\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 *\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 *\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,MAyFlB,OAAS,gBAAAC,MAAoB,WA/EtB,IAAMC,EAAsBF,EAAE,OAAO,CAC1C,SAAUJ,EACV,YAAaD,CACf,CAAC,EAoDM,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"]}
|
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": "
|
|
4
|
+
"version": "2.0.0",
|
|
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": "
|
|
55
|
+
"@settlemint/sdk-utils": "2.0.0",
|
|
56
56
|
"graphql-request": "^7",
|
|
57
57
|
"zod": "^3"
|
|
58
58
|
},
|