@herd-labs/sdk 0.4.0 → 0.5.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/dist/index.d.ts +17 -17
- package/dist/index.js +17 -17
- package/dist/src/config.d.ts +4 -4
- package/dist/src/config.js +2 -2
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.js +7 -1
- package/dist/src/live/ActionsServiceLive.d.ts +3 -3
- package/dist/src/live/ActionsServiceLive.js +7 -7
- package/dist/src/live/AdaptersServiceLive.d.ts +3 -3
- package/dist/src/live/AdaptersServiceLive.js +4 -4
- package/dist/src/live/AgentSafesServiceLive.d.ts +3 -3
- package/dist/src/live/AgentSafesServiceLive.js +4 -4
- package/dist/src/live/AgentWalletsServiceLive.d.ts +2 -2
- package/dist/src/live/AgentWalletsServiceLive.js +3 -3
- package/dist/src/live/AgentWorkflowsServiceLive.d.ts +3 -3
- package/dist/src/live/AgentWorkflowsServiceLive.js +8 -8
- package/dist/src/live/AuthServiceLive.d.ts +3 -3
- package/dist/src/live/AuthServiceLive.js +5 -5
- package/dist/src/live/BookmarksServiceLive.d.ts +3 -3
- package/dist/src/live/BookmarksServiceLive.js +6 -6
- package/dist/src/live/CodeBlocksServiceLive.d.ts +3 -3
- package/dist/src/live/CodeBlocksServiceLive.js +7 -7
- package/dist/src/live/CollectionsServiceLive.d.ts +3 -3
- package/dist/src/live/CollectionsServiceLive.js +4 -4
- package/dist/src/live/ContractsServiceLive.d.ts +3 -3
- package/dist/src/live/ContractsServiceLive.js +6 -6
- package/dist/src/live/DocsServiceLive.d.ts +3 -3
- package/dist/src/live/DocsServiceLive.js +3 -3
- package/dist/src/live/GroupsServiceLive.d.ts +3 -3
- package/dist/src/live/GroupsServiceLive.js +7 -7
- package/dist/src/live/HalServiceLive.d.ts +3 -3
- package/dist/src/live/HalServiceLive.js +3 -3
- package/dist/src/live/TransactionsServiceLive.d.ts +3 -3
- package/dist/src/live/TransactionsServiceLive.js +4 -4
- package/dist/src/live/WalletsServiceLive.d.ts +3 -3
- package/dist/src/live/WalletsServiceLive.js +5 -5
- package/dist/src/live/http.d.ts +2 -2
- package/dist/src/live/http.js +2 -2
- package/dist/src/schemas/actions.d.ts +127 -59
- package/dist/src/schemas/actions.js +42 -42
- package/dist/src/schemas/adapters.d.ts +4 -4
- package/dist/src/schemas/adapters.js +3 -3
- package/dist/src/schemas/agent-wallets.d.ts +57 -37
- package/dist/src/schemas/agent-wallets.js +35 -35
- package/dist/src/schemas/agent-workflows.d.ts +35 -35
- package/dist/src/schemas/agent-workflows.js +19 -19
- package/dist/src/schemas/auth.d.ts +19 -19
- package/dist/src/schemas/auth.js +10 -10
- package/dist/src/schemas/bookmarks.d.ts +58 -36
- package/dist/src/schemas/bookmarks.js +34 -34
- package/dist/src/schemas/codeblocks.d.ts +89 -52
- package/dist/src/schemas/codeblocks.js +34 -34
- package/dist/src/schemas/collections.d.ts +76 -32
- package/dist/src/schemas/collections.js +23 -23
- package/dist/src/schemas/common.d.ts +8 -8
- package/dist/src/schemas/common.js +5 -5
- package/dist/src/schemas/contracts.d.ts +176 -61
- package/dist/src/schemas/contracts.js +47 -47
- package/dist/src/schemas/docs.d.ts +7 -7
- package/dist/src/schemas/docs.js +5 -5
- package/dist/src/schemas/groups.d.ts +27 -27
- package/dist/src/schemas/groups.js +16 -16
- package/dist/src/schemas/hal.d.ts +64 -18
- package/dist/src/schemas/hal.js +18 -18
- package/dist/src/schemas/transactions.d.ts +264 -56
- package/dist/src/schemas/transactions.js +50 -50
- package/dist/src/schemas/wallets.d.ts +434 -84
- package/dist/src/schemas/wallets.js +114 -69
- package/dist/src/services/ActionsService.d.ts +2 -2
- package/dist/src/services/AgentSafesService.d.ts +4 -4
- package/dist/src/services/AgentWalletsService.d.ts +2 -2
- package/dist/src/services/AgentWorkflowsService.d.ts +8 -8
- package/dist/src/services/AuthService.d.ts +3 -3
- package/dist/src/services/BookmarksService.d.ts +2 -2
- package/dist/src/services/ContractsService.d.ts +5 -5
- package/dist/src/services/GroupsService.d.ts +11 -11
- package/dist/src/services/TransactionsService.d.ts +4 -4
- package/dist/src/services/WalletsService.d.ts +4 -4
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { CodeBlocksService } from "../services/CodeBlocksService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient2 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/CodeBlocksServiceLive.d.ts
|
|
7
|
-
declare const CodeBlocksServiceLive: Layer.Layer<CodeBlocksService, never,
|
|
7
|
+
declare const CodeBlocksServiceLive: Layer.Layer<CodeBlocksService, never, HerdConfigService | effect_unstable_http_HttpClient2.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { CodeBlocksServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeBlockNotFoundError, ServiceError, ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CodeBlockExecuteResponseSchema, CodeBlocksSearchResponseSchema, CreateCodeBlockResponseSchema, CreateCodeVersionResponseSchema, PublishCodeBlockResponseSchema } from "../schemas/codeblocks.js";
|
|
3
3
|
import { CodeBlocksService } from "../services/CodeBlocksService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Array, Effect, Layer, Option, pipe } from "effect";
|
|
@@ -13,20 +13,20 @@ const mapNotFound = (id) => Effect.catch((error) => {
|
|
|
13
13
|
const CodeBlocksServiceLive = Layer.effect(CodeBlocksService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
-
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
17
|
-
createCode: (definitionId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
16
|
+
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCodeBlockResponseSchema)), Effect.mapError(ensureServiceError("Failed to create code block"))),
|
|
17
|
+
createCode: (definitionId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCodeVersionResponseSchema)), Effect.mapError(ensureServiceError("Failed to create code version")), mapNotFound(definitionId)),
|
|
18
18
|
delete: (definitionId) => pipe(client.del(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}`)), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to delete code block")), mapNotFound(definitionId)),
|
|
19
|
-
execute: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/execute`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
19
|
+
execute: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/execute`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CodeBlockExecuteResponseSchema)), Effect.mapError(ensureServiceError("Failed to execute code block")), mapNotFound(definitionId)),
|
|
20
20
|
get: (id) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions/query"), { body: jsonBody({
|
|
21
21
|
scope: "user",
|
|
22
22
|
limit: 1,
|
|
23
23
|
filters: { id }
|
|
24
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
24
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CodeBlocksSearchResponseSchema)), Effect.mapError(ensureServiceError("Failed to search code blocks")), Effect.flatMap((response) => pipe(Array.head(response.items), Option.match({
|
|
25
25
|
onNone: () => Effect.fail(new CodeBlockNotFoundError({ id })),
|
|
26
26
|
onSome: Effect.succeed
|
|
27
27
|
})))),
|
|
28
|
-
publishCode: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/publish`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
29
|
-
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
28
|
+
publishCode: (definitionId, codeId, params) => pipe(client.post(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}/publish`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(PublishCodeBlockResponseSchema)), Effect.mapError(ensureServiceError("Failed to publish code block")), mapNotFound(definitionId)),
|
|
29
|
+
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/code/definitions/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CodeBlocksSearchResponseSchema)), Effect.mapError(ensureServiceError("Failed to search code blocks"))),
|
|
30
30
|
updateCode: (definitionId, codeId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}/codes/${codeId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update code")), mapNotFound(definitionId)),
|
|
31
31
|
updateMetadata: (definitionId, params) => pipe(client.put(makeUrl(baseUrl, `/v1/actions/code/definitions/${definitionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update code block metadata")), mapNotFound(definitionId))
|
|
32
32
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { CollectionsService } from "../services/CollectionsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient0 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/CollectionsServiceLive.d.ts
|
|
7
|
-
declare const CollectionsServiceLive: Layer.Layer<CollectionsService, never,
|
|
7
|
+
declare const CollectionsServiceLive: Layer.Layer<CollectionsService, never, HerdConfigService | effect_unstable_http_HttpClient0.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { CollectionsServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CollectionNotFoundError, ServiceError, ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CollectionSchema, CollectionsSearchResponseSchema, CreateCollectionResponseSchema } from "../schemas/collections.js";
|
|
3
3
|
import { CollectionsService } from "../services/CollectionsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, pipe } from "effect";
|
|
@@ -13,9 +13,9 @@ const mapNotFound = (id) => Effect.catch((error) => {
|
|
|
13
13
|
const CollectionsServiceLive = Layer.effect(CollectionsService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
-
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
17
|
-
get: (collectionId) => pipe(client.get(makeUrl(baseUrl, `/v1/collections/${collectionId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
18
|
-
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
16
|
+
create: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateCollectionResponseSchema)), Effect.mapError(ensureServiceError("Failed to create collection"))),
|
|
17
|
+
get: (collectionId) => pipe(client.get(makeUrl(baseUrl, `/v1/collections/${collectionId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CollectionSchema)), Effect.mapError(ensureServiceError("Failed to get collection")), mapNotFound(collectionId)),
|
|
18
|
+
search: (params) => pipe(client.post(makeUrl(baseUrl, "/v1/collections/query"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CollectionsSearchResponseSchema)), Effect.mapError(ensureServiceError("Failed to search collections"))),
|
|
19
19
|
update: (collectionId, params) => pipe(client.patch(makeUrl(baseUrl, `/v1/collections/${collectionId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.asVoid, Effect.mapError(ensureServiceError("Failed to update collection")), mapNotFound(collectionId))
|
|
20
20
|
};
|
|
21
21
|
}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { ContractsService } from "../services/ContractsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient13 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/ContractsServiceLive.d.ts
|
|
7
|
-
declare const ContractsServiceLive: Layer.Layer<ContractsService, never,
|
|
7
|
+
declare const ContractsServiceLive: Layer.Layer<ContractsService, never, HerdConfigService | effect_unstable_http_HttpClient13.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ContractsServiceLive };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ContractDiffSchema, ContractMetadataSchema, GetContractCodeResponseSchema } from "../schemas/contracts.js";
|
|
3
|
+
import { DeployedContractsSchema } from "../schemas/wallets.js";
|
|
4
4
|
import { ContractsService } from "../services/ContractsService.js";
|
|
5
5
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
6
6
|
import { Effect, Layer, pipe } from "effect";
|
|
@@ -14,16 +14,16 @@ const ContractsServiceLive = Layer.effect(ContractsService, Effect.gen(function*
|
|
|
14
14
|
contractAddress: address,
|
|
15
15
|
blockchain,
|
|
16
16
|
...params
|
|
17
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
17
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ContractDiffSchema)), Effect.mapError(ensureServiceError("Failed to diff contract versions"))),
|
|
18
18
|
getContractCode: (blockchain, params) => pipe(client.post(makeUrl(baseUrl, "/v1/contracts/code/query"), { body: jsonBody({
|
|
19
19
|
blockchain,
|
|
20
20
|
...params
|
|
21
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
22
|
-
getDeployedContracts: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/created_contracts`, params)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
21
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(GetContractCodeResponseSchema)), Effect.mapError(ensureServiceError("Failed to get contract code"))),
|
|
22
|
+
getDeployedContracts: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/created_contracts`, params)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(DeployedContractsSchema)), Effect.mapError(ensureServiceError("Failed to get deployed contracts"))),
|
|
23
23
|
getMetadata: (address, blockchain) => pipe(client.post(makeUrl(baseUrl, "/v1/contracts/metadata_enriched"), { body: jsonBody({
|
|
24
24
|
contractAddress: address,
|
|
25
25
|
blockchain
|
|
26
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
26
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ContractMetadataSchema)), Effect.mapError(ensureServiceError("Failed to get contract metadata")))
|
|
27
27
|
};
|
|
28
28
|
}));
|
|
29
29
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { DocsService } from "../services/DocsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient10 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/DocsServiceLive.d.ts
|
|
7
|
-
declare const DocsServiceLive: Layer.Layer<DocsService, never,
|
|
7
|
+
declare const DocsServiceLive: Layer.Layer<DocsService, never, HerdConfigService | effect_unstable_http_HttpClient10.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { DocsServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocNotFoundError, ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DocContentSchema, DocEntrySchema } from "../schemas/docs.js";
|
|
3
3
|
import { DocsService } from "../services/DocsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, Schema, pipe } from "effect";
|
|
@@ -9,13 +9,13 @@ import { HttpClientResponse } from "effect/unstable/http";
|
|
|
9
9
|
const DocsServiceLive = Layer.effect(DocsService, Effect.gen(function* () {
|
|
10
10
|
const { baseUrl, client } = yield* authorizedClient;
|
|
11
11
|
return {
|
|
12
|
-
list: pipe(client.get(makeUrl(baseUrl, "/v1/docs")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Array(
|
|
12
|
+
list: pipe(client.get(makeUrl(baseUrl, "/v1/docs")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Array(DocEntrySchema))), Effect.mapError(ensureServiceError("Failed to list docs"))),
|
|
13
13
|
read: (docId) => Effect.gen(function* () {
|
|
14
14
|
const response = yield* pipe(client.get(makeUrl(baseUrl, `/v1/docs/${encodeURIComponent(docId)}`)), Effect.flatMap(checkStatus), Effect.mapError((error) => {
|
|
15
15
|
const wrapped = ensureServiceError("Failed to read doc")(error);
|
|
16
16
|
return wrapped.metadata["status"] === 404 ? new DocNotFoundError({ docId }) : wrapped;
|
|
17
17
|
}));
|
|
18
|
-
return yield* pipe(HttpClientResponse.schemaBodyJson(
|
|
18
|
+
return yield* pipe(HttpClientResponse.schemaBodyJson(DocContentSchema)(response), Effect.mapError((error) => ensureServiceError("Failed to parse doc content")(error)));
|
|
19
19
|
})
|
|
20
20
|
};
|
|
21
21
|
}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { GroupsService } from "../services/GroupsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient5 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/GroupsServiceLive.d.ts
|
|
7
|
-
declare const GroupsServiceLive: Layer.Layer<GroupsService, never,
|
|
7
|
+
declare const GroupsServiceLive: Layer.Layer<GroupsService, never, HerdConfigService | effect_unstable_http_HttpClient5.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { GroupsServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServiceError, ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CreateGroupResponseSchema, EditGroupMetadataResponseSchema, GroupDetailsSchema, ListGroupsResponseSchema, ProposalResponseSchema } from "../schemas/groups.js";
|
|
3
3
|
import { GroupNotFoundError, GroupsService } from "../services/GroupsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, pipe } from "effect";
|
|
@@ -13,12 +13,12 @@ const mapNotFound = (groupId) => Effect.catch((error) => {
|
|
|
13
13
|
const GroupsServiceLive = Layer.effect(GroupsService, Effect.gen(function* () {
|
|
14
14
|
const { baseUrl, client } = yield* authorizedClient;
|
|
15
15
|
return {
|
|
16
|
-
create: ({ params }) => pipe(client.post(makeUrl(baseUrl, "/v1/groups"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
17
|
-
editMetadata: ({ groupId, params }) => pipe(client.patch(makeUrl(baseUrl, `/v1/groups/${groupId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
18
|
-
get: ({ groupId }) => pipe(client.get(makeUrl(baseUrl, `/v1/groups/${groupId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
19
|
-
list: pipe(client.get(makeUrl(baseUrl, "/v1/groups")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
20
|
-
proposeMemberChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/member`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
21
|
-
proposeQuorumChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/quorum`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
16
|
+
create: ({ params }) => pipe(client.post(makeUrl(baseUrl, "/v1/groups"), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(CreateGroupResponseSchema)), Effect.mapError(ensureServiceError("Failed to create group"))),
|
|
17
|
+
editMetadata: ({ groupId, params }) => pipe(client.patch(makeUrl(baseUrl, `/v1/groups/${groupId}`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(EditGroupMetadataResponseSchema)), Effect.mapError(ensureServiceError("Failed to edit group metadata")), mapNotFound(groupId)),
|
|
18
|
+
get: ({ groupId }) => pipe(client.get(makeUrl(baseUrl, `/v1/groups/${groupId}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(GroupDetailsSchema)), Effect.mapError(ensureServiceError("Failed to get group")), mapNotFound(groupId)),
|
|
19
|
+
list: pipe(client.get(makeUrl(baseUrl, "/v1/groups")), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ListGroupsResponseSchema)), Effect.mapError(ensureServiceError("Failed to list groups"))),
|
|
20
|
+
proposeMemberChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/member`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ProposalResponseSchema)), Effect.mapError(ensureServiceError("Failed to propose member change")), mapNotFound(groupId)),
|
|
21
|
+
proposeQuorumChange: ({ groupId, params }) => pipe(client.post(makeUrl(baseUrl, `/v1/groups/${groupId}/proposals/quorum`), { body: jsonBody(params) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(ProposalResponseSchema)), Effect.mapError(ensureServiceError("Failed to propose quorum change")), mapNotFound(groupId))
|
|
22
22
|
};
|
|
23
23
|
}));
|
|
24
24
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { HalService } from "../services/HalService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient11 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/HalServiceLive.d.ts
|
|
7
|
-
declare const HalServiceLive: Layer.Layer<HalService, never,
|
|
7
|
+
declare const HalServiceLive: Layer.Layer<HalService, never, HerdConfigService | effect_unstable_http_HttpClient11.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { HalServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServiceError, SimulationError, ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { EvaluateExistingResponseSchema, EvaluateResponseSchema } from "../schemas/hal.js";
|
|
3
3
|
import { HalService } from "../services/HalService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, pipe } from "effect";
|
|
@@ -15,8 +15,8 @@ const mapSimulationError = Effect.catch((error) => {
|
|
|
15
15
|
});
|
|
16
16
|
const HalServiceLive = Layer.effect(HalService, Effect.gen(function* () {
|
|
17
17
|
const { baseUrl, client } = yield* authorizedClient;
|
|
18
|
-
const callEvaluate = (body) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/executions/evaluate"), { body: jsonBody(body) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
19
|
-
const callEvaluateExisting = (body) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/executions/evaluate/existing"), { body: jsonBody(body) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
18
|
+
const callEvaluate = (body) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/executions/evaluate"), { body: jsonBody(body) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(EvaluateResponseSchema)), Effect.mapError(ensureServiceError("Failed to evaluate expression")), mapSimulationError);
|
|
19
|
+
const callEvaluateExisting = (body) => pipe(client.post(makeUrl(baseUrl, "/v1/actions/executions/evaluate/existing"), { body: jsonBody(body) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(EvaluateExistingResponseSchema)), Effect.mapError(ensureServiceError("Failed to evaluate existing action")), mapSimulationError);
|
|
20
20
|
return {
|
|
21
21
|
evaluate: (params) => callEvaluate({
|
|
22
22
|
expression: params.expression,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { TransactionsService } from "../services/TransactionsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient12 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/TransactionsServiceLive.d.ts
|
|
7
|
-
declare const TransactionsServiceLive: Layer.Layer<TransactionsService, never,
|
|
7
|
+
declare const TransactionsServiceLive: Layer.Layer<TransactionsService, never, HerdConfigService | effect_unstable_http_HttpClient12.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { TransactionsServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { LatestEventTransactionsSchema, LatestFunctionTransactionsSchema, TransactionQueryResponseSchema } from "../schemas/transactions.js";
|
|
3
3
|
import { TransactionsService } from "../services/TransactionsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, Option, Record, pipe } from "effect";
|
|
@@ -31,15 +31,15 @@ const TransactionsServiceLive = Layer.effect(TransactionsService, Effect.gen(fun
|
|
|
31
31
|
name: filter.name,
|
|
32
32
|
signature: filter.signature
|
|
33
33
|
})
|
|
34
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
34
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(LatestEventTransactionsSchema)), Effect.mapError(ensureServiceError("Failed to get latest event transactions"))),
|
|
35
35
|
getLatestFunctionTransactions: (blockchain, address, filter, params) => pipe(client.get(makeUrl(baseUrl, `/v1/contracts/${blockchain}/${address}/latest_function_transactions`, {
|
|
36
36
|
...latestTxParamsToSnakeCaseQuery(params),
|
|
37
37
|
...toOptionalQuery({
|
|
38
38
|
name: filter.name,
|
|
39
39
|
signature: filter.signature
|
|
40
40
|
})
|
|
41
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
42
|
-
getTransaction: (blockchain, txHash) => pipe(client.get(makeUrl(baseUrl, `/v1/transactions/${blockchain}/${txHash}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
41
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(LatestFunctionTransactionsSchema)), Effect.mapError(ensureServiceError("Failed to get latest function transactions"))),
|
|
42
|
+
getTransaction: (blockchain, txHash) => pipe(client.get(makeUrl(baseUrl, `/v1/transactions/${blockchain}/${txHash}`)), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TransactionQueryResponseSchema)), Effect.mapError(ensureServiceError("Failed to get transaction")))
|
|
43
43
|
};
|
|
44
44
|
}));
|
|
45
45
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { WalletsService } from "../services/WalletsService.js";
|
|
3
3
|
import { Layer } from "effect";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_unstable_http_HttpClient9 from "effect/unstable/http/HttpClient";
|
|
5
5
|
|
|
6
6
|
//#region src/live/WalletsServiceLive.d.ts
|
|
7
|
-
declare const WalletsServiceLive: Layer.Layer<WalletsService, never,
|
|
7
|
+
declare const WalletsServiceLive: Layer.Layer<WalletsService, never, HerdConfigService | effect_unstable_http_HttpClient9.HttpClient>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { WalletsServiceLive };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureServiceError } from "../errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DeployedContractsSchema, TokenActivitySchema, TransactionActivitySchema, WalletOverviewSchema } from "../schemas/wallets.js";
|
|
3
3
|
import { WalletsService } from "../services/WalletsService.js";
|
|
4
4
|
import { authorizedClient, checkStatus, jsonBody, makeUrl } from "./http.js";
|
|
5
5
|
import { Effect, Layer, Option, Record, pipe } from "effect";
|
|
@@ -15,13 +15,13 @@ const WalletsServiceLive = Layer.effect(WalletsService, Effect.gen(function* ()
|
|
|
15
15
|
after_timestamp: params?.afterTimestamp,
|
|
16
16
|
before_blocknumber: params?.beforeBlocknumber,
|
|
17
17
|
after_blocknumber: params?.afterBlocknumber
|
|
18
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
18
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(DeployedContractsSchema)), Effect.mapError(ensureServiceError("Failed to get deployed contracts"))),
|
|
19
19
|
getOverview: (blockchain, address, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/overview`, {
|
|
20
20
|
before_timestamp: params?.beforeTimestamp,
|
|
21
21
|
after_timestamp: params?.afterTimestamp,
|
|
22
22
|
before_blocknumber: params?.beforeBlocknumber,
|
|
23
23
|
after_blocknumber: params?.afterBlocknumber
|
|
24
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
24
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(WalletOverviewSchema)), Effect.mapError(ensureServiceError("Failed to get wallet overview"))),
|
|
25
25
|
getTokenActivity: (blockchain, address, tokenAddress, params) => pipe(client.get(makeUrl(baseUrl, `/v1/wallets/${blockchain}/${address}/tokens/${tokenAddress}`, {
|
|
26
26
|
page: params?.page,
|
|
27
27
|
before_timestamp: params?.beforeTimestamp,
|
|
@@ -30,7 +30,7 @@ const WalletsServiceLive = Layer.effect(WalletsService, Effect.gen(function* ()
|
|
|
30
30
|
after_blocknumber: params?.afterBlocknumber,
|
|
31
31
|
from_address: params?.fromAddress,
|
|
32
32
|
to_address: params?.toAddress
|
|
33
|
-
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
33
|
+
})), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TokenActivitySchema)), Effect.mapError(ensureServiceError("Failed to get token activity"))),
|
|
34
34
|
getTransactions: (query) => {
|
|
35
35
|
const optionalFields = Record.getSomes(Record.map({
|
|
36
36
|
from_address: query.fromAddress,
|
|
@@ -45,7 +45,7 @@ const WalletsServiceLive = Layer.effect(WalletsService, Effect.gen(function* ()
|
|
|
45
45
|
blockchain: query.blockchain,
|
|
46
46
|
page: query.page ?? 1,
|
|
47
47
|
...optionalFields
|
|
48
|
-
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(
|
|
48
|
+
}) }), Effect.flatMap(checkStatus), Effect.flatMap(HttpClientResponse.schemaBodyJson(TransactionActivitySchema)), Effect.mapError(ensureServiceError("Failed to get wallet transactions")));
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
}));
|
package/dist/src/live/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { ServiceError } from "../errors.js";
|
|
3
3
|
import { Effect, Schema } from "effect";
|
|
4
4
|
import { HttpBody, HttpClient, HttpClientResponse, UrlParams } from "effect/unstable/http";
|
|
@@ -9,7 +9,7 @@ declare const makeUrl: (baseUrl: string, path: string, queryParams?: object) =>
|
|
|
9
9
|
declare const authorizedClient: Effect.Effect<{
|
|
10
10
|
baseUrl: string;
|
|
11
11
|
client: HttpClient.HttpClient.With<effect_unstable_http_HttpClientError0.HttpClientError, never>;
|
|
12
|
-
}, never,
|
|
12
|
+
}, never, HerdConfigService | HttpClient.HttpClient>;
|
|
13
13
|
declare const handleJsonResponse: <S extends Schema.Top>(schema: S) => (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<S["Type"], ServiceError, S["DecodingServices"]>;
|
|
14
14
|
declare const checkStatus: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<HttpClientResponse.HttpClientResponse, ServiceError>;
|
|
15
15
|
declare const jsonBody: (body: unknown) => HttpBody.HttpBody;
|
package/dist/src/live/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HerdConfigService } from "../config.js";
|
|
2
2
|
import { ServiceError } from "../errors.js";
|
|
3
3
|
import { Effect, Function, Result, pipe } from "effect";
|
|
4
4
|
import { HttpBody, HttpClient, HttpClientRequest, HttpClientResponse, UrlParams } from "effect/unstable/http";
|
|
@@ -13,7 +13,7 @@ const makeUrl = (baseUrl, path, queryParams) => {
|
|
|
13
13
|
return url.toString();
|
|
14
14
|
};
|
|
15
15
|
const authorizedClient = Effect.gen(function* () {
|
|
16
|
-
const config = yield*
|
|
16
|
+
const config = yield* HerdConfigService;
|
|
17
17
|
const client = yield* HttpClient.HttpClient;
|
|
18
18
|
const { baseUrl, authHeaders } = Result.match(config, {
|
|
19
19
|
onFailure: ({ baseUrl: innerBaseUrl, oauthAccessToken }) => ({
|