Skip to content

Commit 7ed669a

Browse files
authored
feat: add logs provider package (#2580)
1 parent 9060305 commit 7ed669a

File tree

8 files changed

+141
-0
lines changed

8 files changed

+141
-0
lines changed

packages/logs-provider/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

packages/logs-provider/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @substrate/ws-provider

packages/logs-provider/package.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "@substrate/logs-provider",
3+
"version": "0.0.6",
4+
"author": "Parity Technologies (https://github.com/paritytech)",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/paritytech/substrate-connect.git"
8+
},
9+
"license": "MIT",
10+
"type": "module",
11+
"main": "./dist/commonjs/index.js",
12+
"types": "./dist/commonjs/index.d.ts",
13+
"module": "./dist/esm/index.js",
14+
"exports": {
15+
"./package.json": "./package.json",
16+
".": {
17+
"import": {
18+
"@substrate-connect/source": "./src/index.ts",
19+
"types": "./dist/esm/index.d.ts",
20+
"default": "./dist/esm/index.js"
21+
},
22+
"require": {
23+
"types": "./dist/commonjs/index.d.ts",
24+
"default": "./dist/commonjs/index.js"
25+
}
26+
}
27+
},
28+
"files": [
29+
"dist"
30+
],
31+
"tshy": {
32+
"project": "./tsconfig.build.json",
33+
"exports": {
34+
"./package.json": "./package.json",
35+
".": "./src/index.ts"
36+
},
37+
"sourceDialects": [
38+
"@substrate-connect/source"
39+
]
40+
},
41+
"scripts": {
42+
"deep-clean": "npm run clean && rimraf dist node_modules",
43+
"clean": "rimraf dist .tshy .tshy-build",
44+
"build": "npm run clean && tshy",
45+
"typecheck": "tsc --noEmit",
46+
"dev": "pnpm build --watch",
47+
"lint": "prettier --check README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\""
48+
},
49+
"prettier": {
50+
"printWidth": 80,
51+
"semi": false,
52+
"trailingComma": "all"
53+
},
54+
"dependencies": {
55+
"@polkadot-api/logs-provider": "0.0.6"
56+
},
57+
"devDependencies": {
58+
"typescript": "5.6.2",
59+
"vitest": "^2.1.4"
60+
},
61+
"peerDependencies": {}
62+
}

packages/logs-provider/src/mod.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {
2+
withLogsRecorder as _withLogsRecorder,
3+
logsProvider as _logsProvider,
4+
type LogsProviderOptions as _LogsProviderOptions,
5+
} from "@polkadot-api/logs-provider"
6+
7+
export type JsonRpcProvider = Parameters<typeof _withLogsRecorder>[1]
8+
export type LogsProviderOptions = Readonly<_LogsProviderOptions>
9+
10+
export const makeLogsProvider =
11+
(options: Partial<LogsProviderOptions> = {}) =>
12+
(rawLogs: ReadonlyArray<string>): JsonRpcProvider => {
13+
return _logsProvider([...rawLogs], options)
14+
}
15+
16+
export const withLogsRecorder =
17+
(persistLog: (log: string) => void) =>
18+
(input: JsonRpcProvider): JsonRpcProvider => {
19+
return _withLogsRecorder(persistLog, input)
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.build.json",
3+
"include": ["src"]
4+
}

packages/logs-provider/tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"include": ["src", "tests"]
4+
}

packages/logs-provider/tsup.config.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { defineConfig } from "tsup"
2+
3+
export default defineConfig([
4+
{
5+
entry: {
6+
index: "src/mod.ts",
7+
},
8+
outDir: "dist/esm",
9+
format: ["esm"],
10+
dts: true,
11+
sourcemap: true,
12+
clean: true,
13+
tsconfig: "./tsconfig.build.json",
14+
noExternal: ["@polkadot-api/ws-provider"],
15+
external: [
16+
"@polkadot-api/json-rpc-provider-proxy",
17+
"@polkadot-api/json-rpc-provider",
18+
],
19+
},
20+
{
21+
entry: {
22+
index: "src/mod.ts",
23+
},
24+
outDir: "dist/commonjs",
25+
format: ["cjs"],
26+
dts: true,
27+
sourcemap: true,
28+
clean: true,
29+
tsconfig: "./tsconfig.build.json",
30+
noExternal: ["@polkadot-api/ws-provider"],
31+
external: [
32+
"@polkadot-api/json-rpc-provider-proxy",
33+
"@polkadot-api/json-rpc-provider",
34+
],
35+
},
36+
])

pnpm-lock.yaml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)