@midnightntwrk/wallet-sdk-indexer-client 1.2.3
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 +86 -0
- package/dist/effect/Backpressure.d.ts +97 -0
- package/dist/effect/Backpressure.js +146 -0
- package/dist/effect/ConnectionHelper.d.ts +4 -0
- package/dist/effect/ConnectionHelper.js +41 -0
- package/dist/effect/HttpQueryClient.d.ts +4 -0
- package/dist/effect/HttpQueryClient.js +50 -0
- package/dist/effect/Query.d.ts +39 -0
- package/dist/effect/Query.js +47 -0
- package/dist/effect/QueryClient.d.ts +15 -0
- package/dist/effect/QueryClient.js +15 -0
- package/dist/effect/QueryRunner.d.ts +11 -0
- package/dist/effect/QueryRunner.js +23 -0
- package/dist/effect/Subscription.d.ts +25 -0
- package/dist/effect/Subscription.js +56 -0
- package/dist/effect/SubscriptionClient.d.ts +23 -0
- package/dist/effect/SubscriptionClient.js +15 -0
- package/dist/effect/WsSubscriptionClient.d.ts +4 -0
- package/dist/effect/WsSubscriptionClient.js +89 -0
- package/dist/effect/index.d.ts +8 -0
- package/dist/effect/index.js +20 -0
- package/dist/effect/test/backpressure.test.d.ts +1 -0
- package/dist/effect/test/backpressure.test.js +146 -0
- package/dist/effect/test/connectionHelper.test.d.ts +1 -0
- package/dist/effect/test/connectionHelper.test.js +34 -0
- package/dist/effect/test/httpQueryClient.spied.test.d.ts +1 -0
- package/dist/effect/test/httpQueryClient.spied.test.js +37 -0
- package/dist/effect/test/httpQueryClient.test.d.ts +1 -0
- package/dist/effect/test/httpQueryClient.test.js +32 -0
- package/dist/effect/test/queryRunner.spied.test.d.ts +1 -0
- package/dist/effect/test/queryRunner.spied.test.js +46 -0
- package/dist/effect/test/wsSubscriptionClient.spied.test.d.ts +1 -0
- package/dist/effect/test/wsSubscriptionClient.spied.test.js +37 -0
- package/dist/effect/test/wsSubscriptionClient.test.d.ts +1 -0
- package/dist/effect/test/wsSubscriptionClient.test.js +32 -0
- package/dist/graphql/generated/fragment-masking.d.ts +19 -0
- package/dist/graphql/generated/fragment-masking.js +16 -0
- package/dist/graphql/generated/gql.d.ts +61 -0
- package/dist/graphql/generated/gql.js +17 -0
- package/dist/graphql/generated/graphql.d.ts +1021 -0
- package/dist/graphql/generated/graphql.js +700 -0
- package/dist/graphql/generated/index.d.ts +2 -0
- package/dist/graphql/generated/index.js +2 -0
- package/dist/graphql/queries/BlockHash.d.ts +6 -0
- package/dist/graphql/queries/BlockHash.js +24 -0
- package/dist/graphql/queries/Connect.d.ts +6 -0
- package/dist/graphql/queries/Connect.js +19 -0
- package/dist/graphql/queries/Disconnect.d.ts +6 -0
- package/dist/graphql/queries/Disconnect.js +19 -0
- package/dist/graphql/queries/FetchTermsAndConditions.d.ts +6 -0
- package/dist/graphql/queries/FetchTermsAndConditions.js +26 -0
- package/dist/graphql/queries/TransactionHistoryDetail.d.ts +6 -0
- package/dist/graphql/queries/TransactionHistoryDetail.js +30 -0
- package/dist/graphql/queries/TransactionStatus.d.ts +6 -0
- package/dist/graphql/queries/TransactionStatus.js +34 -0
- package/dist/graphql/queries/index.d.ts +6 -0
- package/dist/graphql/queries/index.js +18 -0
- package/dist/graphql/queries/test/BlockHash.test.d.ts +1 -0
- package/dist/graphql/queries/test/BlockHash.test.js +84 -0
- package/dist/graphql/subscriptions/DustLedgerEvents.d.ts +6 -0
- package/dist/graphql/subscriptions/DustLedgerEvents.js +24 -0
- package/dist/graphql/subscriptions/ShieldedTransactions.d.ts +8 -0
- package/dist/graphql/subscriptions/ShieldedTransactions.js +54 -0
- package/dist/graphql/subscriptions/UnshieldedTransactions.d.ts +8 -0
- package/dist/graphql/subscriptions/UnshieldedTransactions.js +68 -0
- package/dist/graphql/subscriptions/ZswapEvents.d.ts +6 -0
- package/dist/graphql/subscriptions/ZswapEvents.js +24 -0
- package/dist/graphql/subscriptions/index.d.ts +4 -0
- package/dist/graphql/subscriptions/index.js +16 -0
- package/dist/graphql/subscriptions/test/ShieldedTransactions.test.d.ts +1 -0
- package/dist/graphql/subscriptions/test/ShieldedTransactions.test.js +55 -0
- package/dist/graphql/subscriptions/test/UnshieldedTransactions.test.d.ts +1 -0
- package/dist/graphql/subscriptions/test/UnshieldedTransactions.test.js +52 -0
- package/dist/graphql/subscriptions/test/ZswapEvents.test.d.ts +1 -0
- package/dist/graphql/subscriptions/test/ZswapEvents.test.js +50 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -0
- package/package.json +57 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// You may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { Effect, Stream } from 'effect';
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import { buildTestEnvironmentVariables, getComposeDirectory } from '@midnightntwrk/wallet-sdk-utilities/testing';
|
|
16
|
+
import { DockerComposeEnvironment, Wait } from 'testcontainers';
|
|
17
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
18
|
+
import { WsSubscriptionClient } from '../../../effect/index.js';
|
|
19
|
+
import { UnshieldedTransactions } from '../UnshieldedTransactions.js';
|
|
20
|
+
const timeout_minutes = (mins) => 1_000 * 60 * mins;
|
|
21
|
+
const ADDRESS = 'mn_addr_undeployed1rhqz8aq6t74ym2uq5gh53t9x02gducxnamtdvnjxfhelxwaf8ztqpmrwwj';
|
|
22
|
+
const environmentId = randomUUID();
|
|
23
|
+
const environmentVars = buildTestEnvironmentVariables(['APP_INFRA_SECRET'], {
|
|
24
|
+
additionalVars: {
|
|
25
|
+
TESTCONTAINERS_UID: environmentId,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const environment = new DockerComposeEnvironment(getComposeDirectory(), 'docker-compose.yml')
|
|
29
|
+
.withWaitStrategy(`node_${environmentId}`, Wait.forListeningPorts())
|
|
30
|
+
.withWaitStrategy(`indexer_${environmentId}`, Wait.forLogMessage(/block indexed/))
|
|
31
|
+
.withEnvironment(environmentVars);
|
|
32
|
+
describe('Wallet subscription', () => {
|
|
33
|
+
describe('with available Indexer Server', () => {
|
|
34
|
+
let startedEnvironment = undefined;
|
|
35
|
+
const getIndexerPort = () => startedEnvironment?.getContainer(`indexer_${environmentId}`).getMappedPort(8088) ?? 8088;
|
|
36
|
+
beforeAll(async () => {
|
|
37
|
+
startedEnvironment = await environment.up();
|
|
38
|
+
}, timeout_minutes(3));
|
|
39
|
+
afterAll(async () => {
|
|
40
|
+
await startedEnvironment?.down();
|
|
41
|
+
}, timeout_minutes(1));
|
|
42
|
+
it('should stream GraphQL subscription', async () => {
|
|
43
|
+
await Effect.gen(function* () {
|
|
44
|
+
const events = yield* UnshieldedTransactions.run({
|
|
45
|
+
address: ADDRESS,
|
|
46
|
+
transactionId: 0,
|
|
47
|
+
}).pipe(Stream.take(2), Stream.tap((data) => Effect.log(data.unshieldedTransactions.type)), Stream.runCollect);
|
|
48
|
+
expect(events).toHaveLength(2);
|
|
49
|
+
}).pipe(Effect.provide(WsSubscriptionClient.layer({ url: `ws://127.0.0.1:${getIndexerPort()}/api/v4/graphql/ws` })), Effect.scoped, Effect.runPromise);
|
|
50
|
+
}, timeout_minutes(1));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// You may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { Effect, Stream } from 'effect';
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import { buildTestEnvironmentVariables, getComposeDirectory } from '@midnightntwrk/wallet-sdk-utilities/testing';
|
|
16
|
+
import { DockerComposeEnvironment, Wait } from 'testcontainers';
|
|
17
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
18
|
+
import { WsSubscriptionClient } from '../../../effect/index.js';
|
|
19
|
+
import { ZswapEvents } from '../ZswapEvents.js';
|
|
20
|
+
const timeout_minutes = (mins) => 1_000 * 60 * mins;
|
|
21
|
+
const environmentId = randomUUID();
|
|
22
|
+
const environmentVars = buildTestEnvironmentVariables(['APP_INFRA_SECRET'], {
|
|
23
|
+
additionalVars: {
|
|
24
|
+
TESTCONTAINERS_UID: environmentId,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const environment = new DockerComposeEnvironment(getComposeDirectory(), 'docker-compose.yml')
|
|
28
|
+
.withWaitStrategy(`node_${environmentId}`, Wait.forListeningPorts())
|
|
29
|
+
.withWaitStrategy(`indexer_${environmentId}`, Wait.forLogMessage(/block indexed/))
|
|
30
|
+
.withEnvironment(environmentVars);
|
|
31
|
+
describe('ZSwap events subscription', () => {
|
|
32
|
+
describe('with available Indexer Server', () => {
|
|
33
|
+
let startedEnvironment = undefined;
|
|
34
|
+
const getIndexerPort = () => startedEnvironment?.getContainer(`indexer_${environmentId}`).getMappedPort(8088) ?? 8088;
|
|
35
|
+
beforeAll(async () => {
|
|
36
|
+
startedEnvironment = await environment.up();
|
|
37
|
+
}, timeout_minutes(3));
|
|
38
|
+
afterAll(async () => {
|
|
39
|
+
await startedEnvironment?.down();
|
|
40
|
+
}, timeout_minutes(1));
|
|
41
|
+
it('should stream GraphQL subscription', async () => {
|
|
42
|
+
await Effect.gen(function* () {
|
|
43
|
+
const events = yield* ZswapEvents.run({
|
|
44
|
+
id: 0,
|
|
45
|
+
}).pipe(Stream.take(2), Stream.tap((data) => Effect.log(`ID=${data.zswapLedgerEvents.id}, MAX_ID=${data.zswapLedgerEvents.maxId}`)), Stream.runCollect);
|
|
46
|
+
expect(events).toHaveLength(2);
|
|
47
|
+
}).pipe(Effect.provide(WsSubscriptionClient.layer({ url: `ws://127.0.0.1:${getIndexerPort()}/api/v4/graphql/ws` })), Effect.scoped, Effect.runPromise);
|
|
48
|
+
}, timeout_minutes(1));
|
|
49
|
+
});
|
|
50
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// You may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './graphql/queries/index.js';
|
|
14
|
+
export * from './graphql/subscriptions/index.js';
|
|
15
|
+
export * from './graphql/generated/graphql.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@midnightntwrk/wallet-sdk-indexer-client",
|
|
3
|
+
"version": "1.2.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"author": "Midnight Foundation",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"registry": "https://registry.npmjs.org/",
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/midnightntwrk/midnight-wallet.git",
|
|
19
|
+
"directory": "packages/indexer-client"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./effect": {
|
|
27
|
+
"types": "./dist/effect/index.d.ts",
|
|
28
|
+
"import": "./dist/effect/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@graphql-typed-document-node/core": "^3.2.0",
|
|
33
|
+
"@midnightntwrk/wallet-sdk-utilities": "^1.2.0",
|
|
34
|
+
"effect": "^3.19.19",
|
|
35
|
+
"graphql": "^16.13.0",
|
|
36
|
+
"graphql-http": "^1.22.4",
|
|
37
|
+
"graphql-ws": "^6.0.7"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@graphql-codegen/cli": "7.1.2",
|
|
41
|
+
"@graphql-codegen/client-preset": "6.0.1",
|
|
42
|
+
"@graphql-codegen/typescript": "6.0.2",
|
|
43
|
+
"@graphql-codegen/typescript-operations": "6.0.3"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"gql:codegen": "graphql-codegen --clean --config codegen.ts",
|
|
47
|
+
"typecheck": "tsc -b ./tsconfig.json --noEmit --force",
|
|
48
|
+
"format": "prettier --write \"**/*.{ts,js,json,yaml,yml,md}\"",
|
|
49
|
+
"format:check": "prettier --check \"**/*.{ts,js,json,yaml,yml,md}\"",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"lint": "eslint",
|
|
52
|
+
"dist": "tsc -b ./tsconfig.build.json",
|
|
53
|
+
"dist:publish": "tsc -b ./tsconfig.publish.json",
|
|
54
|
+
"clean": "rimraf --glob dist 'tsconfig.*.tsbuildinfo' && date +%s > .clean-timestamp",
|
|
55
|
+
"publint": "publint --strict"
|
|
56
|
+
}
|
|
57
|
+
}
|