@settlemint/sdk-blockscout 2.3.2 → 2.3.3-pr94c5517e
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 +9 -9
- package/dist/blockscout.cjs +111 -1
- package/dist/blockscout.cjs.map +1 -1
- package/dist/blockscout.d.cts +14 -9
- package/dist/blockscout.d.ts +14 -9
- package/dist/blockscout.js +82 -0
- package/dist/blockscout.js.map +1 -0
- package/package.json +6 -6
- package/dist/blockscout.mjs +0 -2
- package/dist/blockscout.mjs.map +0 -1
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:
|
|
53
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:76](https://github.com/settlemint/sdk/blob/v2.3.3/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
|
|
68
|
-
| `options.accessToken
|
|
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:
|
|
81
|
-
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/blockscout/src/blockscout.ts:
|
|
80
|
+
| `client` | `GraphQLClient` | [sdk/blockscout/src/blockscout.ts:80](https://github.com/settlemint/sdk/blob/v2.3.3/sdk/blockscout/src/blockscout.ts#L80) |
|
|
81
|
+
| `graphql` | `initGraphQLTada`\<`Setup`\> | [sdk/blockscout/src/blockscout.ts:81](https://github.com/settlemint/sdk/blob/v2.3.3/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:
|
|
139
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:24](https://github.com/settlemint/sdk/blob/v2.3.3/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:
|
|
149
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:11](https://github.com/settlemint/sdk/blob/v2.3.3/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
|
|
157
|
+
> `const` **ClientOptionsSchema**: `ZodObject`\<\{ `accessToken`: `ZodOptional`\<`ZodString`\>; `instance`: `ZodUnion`\<readonly \[`ZodString`, `ZodString`\]\>; \}, `$strip`\>
|
|
158
158
|
|
|
159
|
-
Defined in: [sdk/blockscout/src/blockscout.ts:
|
|
159
|
+
Defined in: [sdk/blockscout/src/blockscout.ts:16](https://github.com/settlemint/sdk/blob/v2.3.3/sdk/blockscout/src/blockscout.ts#L16)
|
|
160
160
|
|
|
161
161
|
Schema for validating client options for the Blockscout client.
|
|
162
162
|
|
package/dist/blockscout.cjs
CHANGED
|
@@ -1,2 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
const __settlemint_sdk_utils_http = __toESM(require("@settlemint/sdk-utils/http"));
|
|
25
|
+
const __settlemint_sdk_utils_runtime = __toESM(require("@settlemint/sdk-utils/runtime"));
|
|
26
|
+
const __settlemint_sdk_utils_validation = __toESM(require("@settlemint/sdk-utils/validation"));
|
|
27
|
+
const gql_tada = __toESM(require("gql.tada"));
|
|
28
|
+
const graphql_request = __toESM(require("graphql-request"));
|
|
29
|
+
const zod_v4 = __toESM(require("zod/v4"));
|
|
30
|
+
|
|
31
|
+
//#region src/blockscout.ts
|
|
32
|
+
/**
|
|
33
|
+
* Schema for validating client options for the Blockscout client.
|
|
34
|
+
*/
|
|
35
|
+
const ClientOptionsSchema = zod_v4.z.object({
|
|
36
|
+
instance: __settlemint_sdk_utils_validation.UrlOrPathSchema,
|
|
37
|
+
accessToken: __settlemint_sdk_utils_validation.ApplicationAccessTokenSchema.optional()
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Blockscout GraphQL client with proper type safety using gql.tada
|
|
41
|
+
*
|
|
42
|
+
* @param options - Configuration options for the client
|
|
43
|
+
* @param clientOptions - Optional GraphQL client configuration options
|
|
44
|
+
* @returns An object containing the GraphQL client and initialized gql.tada function
|
|
45
|
+
* @throws Will throw an error if the options fail validation
|
|
46
|
+
* @example
|
|
47
|
+
* import { createBlockscoutClient } from '@settlemint/sdk-blockscout';
|
|
48
|
+
* import type { introspection } from "@schemas/blockscout-env";
|
|
49
|
+
* import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';
|
|
50
|
+
*
|
|
51
|
+
* const logger = createLogger();
|
|
52
|
+
*
|
|
53
|
+
* const { client, graphql } = createBlockscoutClient<{
|
|
54
|
+
* introspection: introspection;
|
|
55
|
+
* disableMasking: true;
|
|
56
|
+
* scalars: {
|
|
57
|
+
* AddressHash: string;
|
|
58
|
+
* Data: string;
|
|
59
|
+
* DateTime: string;
|
|
60
|
+
* Decimal: string;
|
|
61
|
+
* FullHash: string;
|
|
62
|
+
* Json: string;
|
|
63
|
+
* NonceHash: string;
|
|
64
|
+
* Wei: string;
|
|
65
|
+
* };
|
|
66
|
+
* }>({
|
|
67
|
+
* instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT,
|
|
68
|
+
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
69
|
+
* }, {
|
|
70
|
+
* fetch: requestLogger(logger, "blockscout", fetch) as typeof fetch,
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Making GraphQL queries
|
|
74
|
+
* const query = graphql(`
|
|
75
|
+
* query GetTransaction($hash: String!) {
|
|
76
|
+
* transaction(hash: $hash) {
|
|
77
|
+
* hash
|
|
78
|
+
* blockNumber
|
|
79
|
+
* value
|
|
80
|
+
* gasUsed
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
* `);
|
|
84
|
+
*
|
|
85
|
+
* const result = await client.request(query, {
|
|
86
|
+
* hash: "0x123abc..."
|
|
87
|
+
* });
|
|
88
|
+
*/
|
|
89
|
+
function createBlockscoutClient(options, clientOptions) {
|
|
90
|
+
(0, __settlemint_sdk_utils_runtime.ensureServer)();
|
|
91
|
+
const validatedOptions = (0, __settlemint_sdk_utils_validation.validate)(ClientOptionsSchema, options);
|
|
92
|
+
const graphql = (0, gql_tada.initGraphQLTada)();
|
|
93
|
+
const fullUrl = new URL(validatedOptions.instance).toString();
|
|
94
|
+
return {
|
|
95
|
+
client: new graphql_request.GraphQLClient(fullUrl, {
|
|
96
|
+
...clientOptions,
|
|
97
|
+
headers: (0, __settlemint_sdk_utils_http.appendHeaders)(clientOptions?.headers, { "x-auth-token": validatedOptions.accessToken })
|
|
98
|
+
}),
|
|
99
|
+
graphql
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
exports.ClientOptionsSchema = ClientOptionsSchema;
|
|
105
|
+
exports.createBlockscoutClient = createBlockscoutClient;
|
|
106
|
+
Object.defineProperty(exports, 'readFragment', {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () {
|
|
109
|
+
return gql_tada.readFragment;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
2
112
|
//# sourceMappingURL=blockscout.cjs.map
|
package/dist/blockscout.cjs.map
CHANGED
|
@@ -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:
|
|
1
|
+
{"version":3,"file":"blockscout.cjs","names":["UrlOrPathSchema","options: ClientOptions","clientOptions?: RequestConfig","GraphQLClient"],"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,sBAAsB,SAAE,OAAO;CAC1C,UAAUA;CACV,aAAa,+DAA6B,UAAU;AACrD,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDF,SAAgB,uBACdC,SACAC,eAIA;AACA,mDAAc;CACd,MAAM,mBAAmB,gDAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,+BAAwB;CACxC,MAAM,UAAU,IAAI,IAAI,iBAAiB,UAAU,UAAU;AAE7D,QAAO;EACL,QAAQ,IAAIC,8BAAc,SAAS;GACjC,GAAG;GACH,SAAS,+CAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
|
package/dist/blockscout.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { AbstractSetupSchema, initGraphQLTada } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { z } from 'zod/v4';
|
|
1
|
+
import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
|
|
2
|
+
import { GraphQLClient } from "graphql-request";
|
|
3
|
+
import { z } from "zod/v4";
|
|
5
4
|
|
|
5
|
+
//#region src/blockscout.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Type definition for GraphQL client configuration options
|
|
8
|
+
*/
|
|
6
9
|
/**
|
|
7
10
|
* Type definition for GraphQL client configuration options
|
|
8
11
|
*/
|
|
@@ -11,8 +14,8 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
|
|
|
11
14
|
* Schema for validating client options for the Blockscout client.
|
|
12
15
|
*/
|
|
13
16
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
18
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
16
19
|
}, z.core.$strip>;
|
|
17
20
|
/**
|
|
18
21
|
* Type definition for client options derived from the ClientOptionsSchema
|
|
@@ -69,8 +72,10 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
69
72
|
* });
|
|
70
73
|
*/
|
|
71
74
|
declare function createBlockscoutClient<const Setup extends AbstractSetupSchema>(options: ClientOptions, clientOptions?: RequestConfig): {
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
client: GraphQLClient;
|
|
76
|
+
graphql: initGraphQLTada<Setup>;
|
|
74
77
|
};
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ClientOptions, ClientOptionsSchema, FragmentOf, RequestConfig, ResultOf, VariablesOf, createBlockscoutClient, readFragment };
|
|
81
|
+
//# sourceMappingURL=blockscout.d.cts.map
|
package/dist/blockscout.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { AbstractSetupSchema, initGraphQLTada } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { z } from 'zod/v4';
|
|
1
|
+
import { AbstractSetupSchema, FragmentOf, ResultOf, VariablesOf, initGraphQLTada, readFragment } from "gql.tada";
|
|
2
|
+
import { GraphQLClient } from "graphql-request";
|
|
3
|
+
import { z } from "zod/v4";
|
|
5
4
|
|
|
5
|
+
//#region src/blockscout.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Type definition for GraphQL client configuration options
|
|
8
|
+
*/
|
|
6
9
|
/**
|
|
7
10
|
* Type definition for GraphQL client configuration options
|
|
8
11
|
*/
|
|
@@ -11,8 +14,8 @@ type RequestConfig = ConstructorParameters<typeof GraphQLClient>[1];
|
|
|
11
14
|
* Schema for validating client options for the Blockscout client.
|
|
12
15
|
*/
|
|
13
16
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
instance: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
18
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
16
19
|
}, z.core.$strip>;
|
|
17
20
|
/**
|
|
18
21
|
* Type definition for client options derived from the ClientOptionsSchema
|
|
@@ -69,8 +72,10 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
69
72
|
* });
|
|
70
73
|
*/
|
|
71
74
|
declare function createBlockscoutClient<const Setup extends AbstractSetupSchema>(options: ClientOptions, clientOptions?: RequestConfig): {
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
client: GraphQLClient;
|
|
76
|
+
graphql: initGraphQLTada<Setup>;
|
|
74
77
|
};
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ClientOptions, ClientOptionsSchema, FragmentOf, RequestConfig, ResultOf, VariablesOf, createBlockscoutClient, readFragment };
|
|
81
|
+
//# sourceMappingURL=blockscout.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { appendHeaders } from "@settlemint/sdk-utils/http";
|
|
2
|
+
import { ensureServer } from "@settlemint/sdk-utils/runtime";
|
|
3
|
+
import { ApplicationAccessTokenSchema, UrlOrPathSchema, validate } from "@settlemint/sdk-utils/validation";
|
|
4
|
+
import { initGraphQLTada, readFragment } from "gql.tada";
|
|
5
|
+
import { GraphQLClient } from "graphql-request";
|
|
6
|
+
import { z } from "zod/v4";
|
|
7
|
+
|
|
8
|
+
//#region src/blockscout.ts
|
|
9
|
+
/**
|
|
10
|
+
* Schema for validating client options for the Blockscout client.
|
|
11
|
+
*/
|
|
12
|
+
const ClientOptionsSchema = z.object({
|
|
13
|
+
instance: UrlOrPathSchema,
|
|
14
|
+
accessToken: ApplicationAccessTokenSchema.optional()
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Blockscout GraphQL client with proper type safety using gql.tada
|
|
18
|
+
*
|
|
19
|
+
* @param options - Configuration options for the client
|
|
20
|
+
* @param clientOptions - Optional GraphQL client configuration options
|
|
21
|
+
* @returns An object containing the GraphQL client and initialized gql.tada function
|
|
22
|
+
* @throws Will throw an error if the options fail validation
|
|
23
|
+
* @example
|
|
24
|
+
* import { createBlockscoutClient } from '@settlemint/sdk-blockscout';
|
|
25
|
+
* import type { introspection } from "@schemas/blockscout-env";
|
|
26
|
+
* import { createLogger, requestLogger } from '@settlemint/sdk-utils/logging';
|
|
27
|
+
*
|
|
28
|
+
* const logger = createLogger();
|
|
29
|
+
*
|
|
30
|
+
* const { client, graphql } = createBlockscoutClient<{
|
|
31
|
+
* introspection: introspection;
|
|
32
|
+
* disableMasking: true;
|
|
33
|
+
* scalars: {
|
|
34
|
+
* AddressHash: string;
|
|
35
|
+
* Data: string;
|
|
36
|
+
* DateTime: string;
|
|
37
|
+
* Decimal: string;
|
|
38
|
+
* FullHash: string;
|
|
39
|
+
* Json: string;
|
|
40
|
+
* NonceHash: string;
|
|
41
|
+
* Wei: string;
|
|
42
|
+
* };
|
|
43
|
+
* }>({
|
|
44
|
+
* instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT,
|
|
45
|
+
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
46
|
+
* }, {
|
|
47
|
+
* fetch: requestLogger(logger, "blockscout", fetch) as typeof fetch,
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Making GraphQL queries
|
|
51
|
+
* const query = graphql(`
|
|
52
|
+
* query GetTransaction($hash: String!) {
|
|
53
|
+
* transaction(hash: $hash) {
|
|
54
|
+
* hash
|
|
55
|
+
* blockNumber
|
|
56
|
+
* value
|
|
57
|
+
* gasUsed
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* `);
|
|
61
|
+
*
|
|
62
|
+
* const result = await client.request(query, {
|
|
63
|
+
* hash: "0x123abc..."
|
|
64
|
+
* });
|
|
65
|
+
*/
|
|
66
|
+
function createBlockscoutClient(options, clientOptions) {
|
|
67
|
+
ensureServer();
|
|
68
|
+
const validatedOptions = validate(ClientOptionsSchema, options);
|
|
69
|
+
const graphql = initGraphQLTada();
|
|
70
|
+
const fullUrl = new URL(validatedOptions.instance).toString();
|
|
71
|
+
return {
|
|
72
|
+
client: new GraphQLClient(fullUrl, {
|
|
73
|
+
...clientOptions,
|
|
74
|
+
headers: appendHeaders(clientOptions?.headers, { "x-auth-token": validatedOptions.accessToken })
|
|
75
|
+
}),
|
|
76
|
+
graphql
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export { ClientOptionsSchema, createBlockscoutClient, readFragment };
|
|
82
|
+
//# sourceMappingURL=blockscout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockscout.js","names":["options: ClientOptions","clientOptions?: RequestConfig"],"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":";;;;;;;;;;;AAeA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,UAAU;CACV,aAAa,6BAA6B,UAAU;AACrD,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDF,SAAgB,uBACdA,SACAC,eAIA;AACA,eAAc;CACd,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;CAC/D,MAAM,UAAU,iBAAwB;CACxC,MAAM,UAAU,IAAI,IAAI,iBAAiB,UAAU,UAAU;AAE7D,QAAO;EACL,QAAQ,IAAI,cAAc,SAAS;GACjC,GAAG;GACH,SAAS,cAAc,eAAe,SAAS,EAAE,gBAAgB,iBAAiB,YAAa,EAAC;EACjG;EACD;CACD;AACF"}
|
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.
|
|
4
|
+
"version": "2.3.3-pr94c5517e",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": ["dist"],
|
|
24
24
|
"main": "./dist/blockscout.cjs",
|
|
25
|
-
"module": "./dist/blockscout.
|
|
25
|
+
"module": "./dist/blockscout.js",
|
|
26
26
|
"types": "./dist/blockscout.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
"./package.json": "./package.json",
|
|
29
29
|
".": {
|
|
30
30
|
"import": {
|
|
31
31
|
"types": "./dist/blockscout.d.ts",
|
|
32
|
-
"default": "./dist/blockscout.
|
|
32
|
+
"default": "./dist/blockscout.js"
|
|
33
33
|
},
|
|
34
34
|
"require": {
|
|
35
35
|
"types": "./dist/blockscout.d.cts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build": "
|
|
42
|
-
"dev": "
|
|
41
|
+
"build": "tsdown",
|
|
42
|
+
"dev": "tsdown --watch",
|
|
43
43
|
"publint": "publint run --strict",
|
|
44
44
|
"attw": "attw --pack .",
|
|
45
45
|
"test": "bun test",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"gql.tada": "^1",
|
|
55
|
-
"@settlemint/sdk-utils": "2.3.
|
|
55
|
+
"@settlemint/sdk-utils": "2.3.3-pr94c5517e",
|
|
56
56
|
"graphql-request": "^7",
|
|
57
57
|
"zod": "^3.25.0"
|
|
58
58
|
},
|
package/dist/blockscout.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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};
|
|
2
|
-
//# sourceMappingURL=blockscout.mjs.map
|
package/dist/blockscout.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|