@streamr/cli-tools 0.0.1-tatum.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/.eslintignore +2 -0
- package/.eslintrc +6 -0
- package/LICENSE +661 -0
- package/OLD_CHANGELOG.md +141 -0
- package/README.md +225 -0
- package/bin/streamr-governance-vote.ts +51 -0
- package/bin/streamr-governance.ts +10 -0
- package/bin/streamr-mock-data-generate.ts +40 -0
- package/bin/streamr-mock-data.ts +10 -0
- package/bin/streamr-storage-node-add-stream.ts +12 -0
- package/bin/streamr-storage-node-list-streams.ts +20 -0
- package/bin/streamr-storage-node-list.ts +22 -0
- package/bin/streamr-storage-node-remove-stream.ts +12 -0
- package/bin/streamr-storage-node.ts +13 -0
- package/bin/streamr-stream-create.ts +29 -0
- package/bin/streamr-stream-grant-permission.ts +9 -0
- package/bin/streamr-stream-publish.ts +66 -0
- package/bin/streamr-stream-resend-from.ts +32 -0
- package/bin/streamr-stream-resend-last.ts +30 -0
- package/bin/streamr-stream-resend-range.ts +38 -0
- package/bin/streamr-stream-resend.ts +11 -0
- package/bin/streamr-stream-revoke-permission.ts +9 -0
- package/bin/streamr-stream-search.ts +61 -0
- package/bin/streamr-stream-show.ts +28 -0
- package/bin/streamr-stream-subscribe.ts +40 -0
- package/bin/streamr-stream.ts +17 -0
- package/bin/streamr-wallet-whoami.ts +10 -0
- package/bin/streamr-wallet.ts +10 -0
- package/bin/streamr.ts +14 -0
- package/dist/bin/streamr-governance-vote.d.ts +2 -0
- package/dist/bin/streamr-governance-vote.js +52 -0
- package/dist/bin/streamr-governance-vote.js.map +1 -0
- package/dist/bin/streamr-governance.d.ts +2 -0
- package/dist/bin/streamr-governance.js +15 -0
- package/dist/bin/streamr-governance.js.map +1 -0
- package/dist/bin/streamr-mock-data-generate.d.ts +2 -0
- package/dist/bin/streamr-mock-data-generate.js +40 -0
- package/dist/bin/streamr-mock-data-generate.js.map +1 -0
- package/dist/bin/streamr-mock-data.d.ts +2 -0
- package/dist/bin/streamr-mock-data.js +15 -0
- package/dist/bin/streamr-mock-data.js.map +1 -0
- package/dist/bin/streamr-storage-node-add-stream.d.ts +2 -0
- package/dist/bin/streamr-storage-node-add-stream.js +13 -0
- package/dist/bin/streamr-storage-node-add-stream.js.map +1 -0
- package/dist/bin/streamr-storage-node-list-streams.d.ts +2 -0
- package/dist/bin/streamr-storage-node-list-streams.js +24 -0
- package/dist/bin/streamr-storage-node-list-streams.js.map +1 -0
- package/dist/bin/streamr-storage-node-list.d.ts +2 -0
- package/dist/bin/streamr-storage-node-list.js +22 -0
- package/dist/bin/streamr-storage-node-list.js.map +1 -0
- package/dist/bin/streamr-storage-node-remove-stream.d.ts +2 -0
- package/dist/bin/streamr-storage-node-remove-stream.js +13 -0
- package/dist/bin/streamr-storage-node-remove-stream.js.map +1 -0
- package/dist/bin/streamr-storage-node.d.ts +2 -0
- package/dist/bin/streamr-storage-node.js +18 -0
- package/dist/bin/streamr-storage-node.js.map +1 -0
- package/dist/bin/streamr-stream-create.d.ts +2 -0
- package/dist/bin/streamr-stream-create.js +23 -0
- package/dist/bin/streamr-stream-create.js.map +1 -0
- package/dist/bin/streamr-stream-grant-permission.d.ts +2 -0
- package/dist/bin/streamr-stream-grant-permission.js +7 -0
- package/dist/bin/streamr-stream-grant-permission.js.map +1 -0
- package/dist/bin/streamr-stream-publish.d.ts +2 -0
- package/dist/bin/streamr-stream-publish.js +59 -0
- package/dist/bin/streamr-stream-publish.js.map +1 -0
- package/dist/bin/streamr-stream-resend-from.d.ts +2 -0
- package/dist/bin/streamr-stream-resend-from.js +27 -0
- package/dist/bin/streamr-stream-resend-from.js.map +1 -0
- package/dist/bin/streamr-stream-resend-last.d.ts +2 -0
- package/dist/bin/streamr-stream-resend-last.js +26 -0
- package/dist/bin/streamr-stream-resend-last.js.map +1 -0
- package/dist/bin/streamr-stream-resend-range.d.ts +2 -0
- package/dist/bin/streamr-stream-resend-range.js +33 -0
- package/dist/bin/streamr-stream-resend-range.js.map +1 -0
- package/dist/bin/streamr-stream-resend.d.ts +2 -0
- package/dist/bin/streamr-stream-resend.js +13 -0
- package/dist/bin/streamr-stream-resend.js.map +1 -0
- package/dist/bin/streamr-stream-revoke-permission.d.ts +2 -0
- package/dist/bin/streamr-stream-revoke-permission.js +7 -0
- package/dist/bin/streamr-stream-revoke-permission.js.map +1 -0
- package/dist/bin/streamr-stream-search.d.ts +2 -0
- package/dist/bin/streamr-stream-search.js +42 -0
- package/dist/bin/streamr-stream-search.js.map +1 -0
- package/dist/bin/streamr-stream-show.d.ts +2 -0
- package/dist/bin/streamr-stream-show.js +25 -0
- package/dist/bin/streamr-stream-show.js.map +1 -0
- package/dist/bin/streamr-stream-subscribe.d.ts +2 -0
- package/dist/bin/streamr-stream-subscribe.js +37 -0
- package/dist/bin/streamr-stream-subscribe.js.map +1 -0
- package/dist/bin/streamr-stream.d.ts +2 -0
- package/dist/bin/streamr-stream.js +22 -0
- package/dist/bin/streamr-stream.js.map +1 -0
- package/dist/bin/streamr-wallet-whoami.d.ts +2 -0
- package/dist/bin/streamr-wallet-whoami.js +11 -0
- package/dist/bin/streamr-wallet-whoami.js.map +1 -0
- package/dist/bin/streamr-wallet.d.ts +2 -0
- package/dist/bin/streamr-wallet.js +15 -0
- package/dist/bin/streamr-wallet.js.map +1 -0
- package/dist/bin/streamr.d.ts +2 -0
- package/dist/bin/streamr.js +19 -0
- package/dist/bin/streamr.js.map +1 -0
- package/dist/package.json +45 -0
- package/dist/src/client.d.ts +4 -0
- package/dist/src/client.js +36 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/command.d.ts +13 -0
- package/dist/src/command.js +45 -0
- package/dist/src/command.js.map +1 -0
- package/dist/src/common.d.ts +6 -0
- package/dist/src/common.js +32 -0
- package/dist/src/common.js.map +1 -0
- package/dist/src/config.d.ts +6 -0
- package/dist/src/config.js +58 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/logLevel.d.ts +1 -0
- package/dist/src/logLevel.js +11 -0
- package/dist/src/logLevel.js.map +1 -0
- package/dist/src/permission.d.ts +5 -0
- package/dist/src/permission.js +53 -0
- package/dist/src/permission.js.map +1 -0
- package/dist/src/resend.d.ts +3 -0
- package/dist/src/resend.js +32 -0
- package/dist/src/resend.js.map +1 -0
- package/package.json +45 -0
- package/src/client.ts +35 -0
- package/src/command.ts +51 -0
- package/src/common.ts +25 -0
- package/src/config.ts +56 -0
- package/src/logLevel.ts +9 -0
- package/src/permission.ts +53 -0
- package/src/resend.ts +37 -0
- package/test/mock-data.test.ts +19 -0
- package/test/storage-node.test.ts +32 -0
- package/test/stream-create.test.ts +26 -0
- package/test/stream-permission.test.ts +29 -0
- package/test/stream-publish-subscribe.test.ts +86 -0
- package/test/stream-resend.test.ts +66 -0
- package/test/stream-search.test.ts +24 -0
- package/test/stream-show.test.ts +31 -0
- package/test/utils.ts +85 -0
- package/test/wallet.test.ts +11 -0
- package/tsconfig.json +16 -0
package/OLD_CHANGELOG.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Old Changelog
|
|
2
|
+
|
|
3
|
+
Versions before 7.0.0 and below are collected into this file. Changelogs for
|
|
4
|
+
newer versions of the cli-tool are available at the root-level CHANGELOG.md
|
|
5
|
+
file.
|
|
6
|
+
|
|
7
|
+
## [6.1.1] - 2022-11-03
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Fix `streamr governance vote` command
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [6.1.0] - 2022-10-31
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Add command `streamr governance vote` for casting votes on Streamr governance proposals
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [6.0.0] - 2022-02-23
|
|
22
|
+
|
|
23
|
+
- Add new command `stream wallet whoami` to display Ethereum address
|
|
24
|
+
- (Breaking) `stream create` argument is a stream ID, not a name
|
|
25
|
+
- Support path notation when defining a stream ID
|
|
26
|
+
- (Breaking) Remove `misc get-session-token` command
|
|
27
|
+
- (Breaking) Change permission names and arguments:
|
|
28
|
+
- renamed `--operation` to `--permission` in `stream list`
|
|
29
|
+
- the data format of `permissions` returned by `--include-permissions` of `stream show`
|
|
30
|
+
- enum values updated for all commands: `subscribe`, `publish`, `edit`, `delete` and `grant`
|
|
31
|
+
- (Breaking) Remove `lastUpdated` and `name` columns from `stream list` output
|
|
32
|
+
- (Breaking) Modify configuration management:
|
|
33
|
+
- can read config from `~/.streamr/config/default.json`
|
|
34
|
+
- `--config` argument added
|
|
35
|
+
- `--stg`, `--http-url` and `--ws-url` arguments removed
|
|
36
|
+
- (Breaking) Rename `--config` argument to `--stream-config` in `stream create`
|
|
37
|
+
- (Breaking) Remove `stream list` command
|
|
38
|
+
- Add `stream search` command
|
|
39
|
+
- (Breaking) Rename `--partition-key` argument to `--partition-key-field` in `stream publish`
|
|
40
|
+
- Bump dependency streamr-client to 6.1.0
|
|
41
|
+
- Bump dependency commander to 8.3.0
|
|
42
|
+
|
|
43
|
+
## 5.0.1 - 2021-06-04
|
|
44
|
+
|
|
45
|
+
- Add permission commands: `stream grant-permission` and `stream revoke-permission`
|
|
46
|
+
- Remove `typescript` and `ts-node` as run-time dependencies
|
|
47
|
+
- (Breaking) Remove `--msg-chain-id` parameter from `stream resend from`
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## [5.0.0] - 2021-05-05
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
- Add storage node commands under `streamr storage-node`
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- (Breaking) Commands are divided to subcommands: most of the existing command are under `streamr stream`, and `generate` command under `streamr mock-data`
|
|
57
|
+
- `streamr subscribe` is now `streamr stream subscribe`
|
|
58
|
+
- `streamr publish` is now `streamr stream publish`
|
|
59
|
+
- `streamr list` is now `streamr stream list`
|
|
60
|
+
- `streamr show` is now `streamr stream show`
|
|
61
|
+
- `streamr create` is now `streamr stream create`
|
|
62
|
+
- `streamr resend` is now `streamr stream resend`
|
|
63
|
+
- `streamr generate` is now `streamr mock-data generate`
|
|
64
|
+
- Fixed examples of --private-key in README
|
|
65
|
+
- Internal implementation was converted to TypeScript
|
|
66
|
+
- Bump dependency streamr-client to 5.2.1
|
|
67
|
+
- Bump dependency commander to 7.2.0
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## [4.1.1] - 2021-02-11
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
- Bump dependency streamr-client to 5.0.0-beta.6
|
|
74
|
+
- Bump dependency commander to ^6.1.0
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## [4.1.0] - 2020-10-12
|
|
78
|
+
|
|
79
|
+
### Changed
|
|
80
|
+
- Bump dependency streamr-client to ^4.1.1.
|
|
81
|
+
- Turn option `--privateKey` into `--private-key` for consistency.
|
|
82
|
+
- Turn `--apiKey` into `--api-key` for consistency.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## [4.0.0] - 2020-06-18
|
|
86
|
+
|
|
87
|
+
### Added
|
|
88
|
+
|
|
89
|
+
- Ethereum authentication with `--privateKey <key>`. This also enables message signing when publishing messages.
|
|
90
|
+
|
|
91
|
+
### Changed
|
|
92
|
+
|
|
93
|
+
- (Breaking) Rename command `listen` to `subscribe`.
|
|
94
|
+
- (Breaking) API key is now given with `--apiKey <key>`. API keys are deprecated. Option `--privateKey` should be preferred.
|
|
95
|
+
|
|
96
|
+
## [3.1.1] - 2020-04-16
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
|
|
100
|
+
- Add `--subscribe` flag to commands `streamr resend from` and `streamr resend last`. This causes the command to resend and subscribe.
|
|
101
|
+
|
|
102
|
+
### Changed
|
|
103
|
+
|
|
104
|
+
- Bump dependency streamr-client to ^3.1.3.
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## [3.1.0] - 2019-12-12
|
|
108
|
+
|
|
109
|
+
### Added
|
|
110
|
+
|
|
111
|
+
- Add `--disable-ordering` flag to command `streamr listen` for disabling
|
|
112
|
+
ordering and gap filling.
|
|
113
|
+
- Add `--disable-ordering` flag to commands `streamr resend *` to disabling
|
|
114
|
+
ordering and gap filling.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
## [3.0.1] - 2019-10-14
|
|
118
|
+
|
|
119
|
+
### Added
|
|
120
|
+
|
|
121
|
+
- Start keeping a CHANGELOG.md.
|
|
122
|
+
|
|
123
|
+
### Changed
|
|
124
|
+
- Bump dependency streamr-client to ^2.2.7.
|
|
125
|
+
- Bump dependency commander to ^4.0.1.
|
|
126
|
+
- Re-organize README.md and a few touches to Developing section paragraphs.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
[Unreleased]: https://github.com/streamr-dev/network/compare/cli-tools%2fv8.3.1...HEAD
|
|
130
|
+
[8.3.1]: https://github.com/streamr-dev/network/compare/cli-tools%2fv7.0.0...cli-tools%2fv8.3.1
|
|
131
|
+
[7.0.0]: https://github.com/streamr-dev/network/compare/cli-tools%2fv6.1.1...cli-tools%2fv7.0.0
|
|
132
|
+
[6.1.1]: https://github.com/streamr-dev/network/compare/cli-tools%2fv6.1.0...cli-tools%2fv6.1.1
|
|
133
|
+
[6.1.0]: https://github.com/streamr-dev/network/compare/cli-tools%2fv6.0.0...cli-tools%2fv6.1.0
|
|
134
|
+
[6.0.0]: https://github.com/streamr-dev/network/compare/cli-tools%2fv5.0.1...cli-tools%2fv6.0.0
|
|
135
|
+
[5.0.0]: https://github.com/streamr-dev/cli-tools/compare/v4.1.1...v5.0.0
|
|
136
|
+
[4.1.1]: https://github.com/streamr-dev/cli-tools/compare/v4.1.0...v4.1.1
|
|
137
|
+
[4.1.0]: https://github.com/streamr-dev/cli-tools/compare/v4.0.0...v4.1.0
|
|
138
|
+
[4.0.0]: https://github.com/streamr-dev/cli-tools/compare/v3.1.1...v4.0.0
|
|
139
|
+
[3.1.1]: https://github.com/streamr-dev/cli-tools/compare/v3.1.0...v3.1.1
|
|
140
|
+
[3.1.0]: https://github.com/streamr-dev/cli-tools/compare/v3.0.1...v3.1.0
|
|
141
|
+
[3.0.1]: https://github.com/streamr-dev/cli-tools/compare/v3.0.0...v3.0.1
|
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://streamr.network">
|
|
3
|
+
<img alt="Streamr" src="https://raw.githubusercontent.com/streamr-dev/network-monorepo/main/packages/client/readme-header.png" width="1320" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# @streamr/cli-tools
|
|
8
|
+
|
|
9
|
+
Command line tool for interacting with [Streamr](https://streamr.network).
|
|
10
|
+
|
|
11
|
+
See [Changelog](CHANGELOG.md) for version information and changes.
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
- [Install](#install)
|
|
15
|
+
- [Use](#use)
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
```
|
|
19
|
+
npm install -g @streamr/cli-tools
|
|
20
|
+
```
|
|
21
|
+
Node.js `16.13.x` is the minimum required version. Node.js `18.12.x`, NPM `8.x` and later versions are recommended.
|
|
22
|
+
|
|
23
|
+
## Use
|
|
24
|
+
All commands follow pattern `streamr <command> <subcommand>`, e.g.
|
|
25
|
+
```
|
|
26
|
+
streamr stream subscribe
|
|
27
|
+
streamr mock-data generate
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
To get a list of all commands simply run `streamr`. To list subcommands run e.g. `streamr stream`
|
|
31
|
+
|
|
32
|
+
Run `streamr <command> <subcommand> --help` to get more information about a a command, its options, and so forth.
|
|
33
|
+
|
|
34
|
+
If there is a stream parameter in a command, it can be defined as a full id (e.g. `0x1234567890123456789012345678901234567890/foo/bar`) or a path (e.g. `/foo/bar`). If path notation is used, the stream ID is made by prefixing the authenticated Ethereum address (`--private-key <key>`) to the path.
|
|
35
|
+
|
|
36
|
+
### Subscribe
|
|
37
|
+
Used to subscribe to a stream and output real-time JSON objects to stdout line-by-line.
|
|
38
|
+
|
|
39
|
+
For example, to subscribe to a public stream such as the tram demo do
|
|
40
|
+
```
|
|
41
|
+
streamr stream subscribe streamr.eth/demos/helsinki-trams
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
To subscribe to a private stream and authenticate with an Ethereum private key:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
streamr stream subscribe streamId --private-key <key>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To subscribe to a particular [stream partition](https://streamr.network/docs/streams/partitioning), use the partition flag:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
streamr stream subscribe streamId -p <partition_number>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Publish
|
|
57
|
+
Used to publish events to a stream from stdin line-by-line. Each line should be a valid JSON object.
|
|
58
|
+
|
|
59
|
+
Example of use:
|
|
60
|
+
```
|
|
61
|
+
streamr stream publish <streamId> --private-key <key>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Generate
|
|
66
|
+
Generate random JSON objects to stdout line-by-line.
|
|
67
|
+
|
|
68
|
+
Useful for generating test data to be published to a stream with `publish`, e.g.:
|
|
69
|
+
```
|
|
70
|
+
streamr mock-data generate | streamr stream publish <streamId> --private-key <key>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Search
|
|
74
|
+
Query a list of streams by a search term and/or permissions. E.g.:
|
|
75
|
+
```
|
|
76
|
+
streamr stream search foobar --user 0x1234567890123456789012345678901234567890
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Search term
|
|
80
|
+
A search term query searchers over the stream id field. E.g:
|
|
81
|
+
```
|
|
82
|
+
streamr stream search foobar
|
|
83
|
+
```
|
|
84
|
+
It could find these streams:
|
|
85
|
+
```
|
|
86
|
+
0x1234567890123456789012345678901234567890/abc/foobar/1
|
|
87
|
+
foobar.eth/lorem-ipsum
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Permission
|
|
91
|
+
A permission query searches over stream permissions. You can either query by direct permissions (which are explicitly granted to a user), or by all permissions (including public permissions, which apply to all users).
|
|
92
|
+
|
|
93
|
+
E.g. all streams where a user has some direct permission:
|
|
94
|
+
```
|
|
95
|
+
streamr stream search --user 0x1234567890123456789012345678901234567890
|
|
96
|
+
```
|
|
97
|
+
All streams accessible by a user:
|
|
98
|
+
```
|
|
99
|
+
streamr stream search --user 0x1234567890123456789012345678901234567890 --public
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The argument of the `--user` option can be omitted. In that case, it defaults to the authenticated user (specified by `--private-key`).
|
|
103
|
+
|
|
104
|
+
It is also possible to filter by specific permissions by using `--all` and `--any`. E.g. if you want to find the streams you can subscribe to:
|
|
105
|
+
```
|
|
106
|
+
streamr stream search --user --public --all subscribe --private-key <key>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
If more than one permission is needed, specify the permissions in a comma-separated list (e.g. `--all subscribe,publish`). It returns streams where _all_ listed permissions are granted. If just _any_ of the permissions is required, use `--any` instead of `--all`. Please prefer `--all` to `--any` when possible as it has better query performance.
|
|
110
|
+
|
|
111
|
+
### Show
|
|
112
|
+
Show detailed information about a specific stream
|
|
113
|
+
```
|
|
114
|
+
streamr stream show <streamId> --private-key <key>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Create
|
|
118
|
+
Create a new stream
|
|
119
|
+
```
|
|
120
|
+
streamr stream create <streamId> --private-key <key>
|
|
121
|
+
```
|
|
122
|
+
E.g.
|
|
123
|
+
```
|
|
124
|
+
streamr stream create /foo/bar
|
|
125
|
+
streamr stream create 0x1234567890123456789012345678901234567890/foobar
|
|
126
|
+
streamr stream create yourdomain.ens/foobar
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### Resend
|
|
131
|
+
Request a resend of historical data printed as JSON objects to stdout line-by-line.
|
|
132
|
+
|
|
133
|
+
For example, to fetch the 10 latest messages of a public stream such as the tram demo do
|
|
134
|
+
```
|
|
135
|
+
streamr stream resend last 10 streamr.eth/demos/helsinki-trams
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
To fetch data starting from a particular date-time
|
|
140
|
+
```
|
|
141
|
+
streamr stream resend from 2019-05-10T17:00:00 <streamId> --private-key <key>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
To fetch data between two date-times
|
|
145
|
+
```
|
|
146
|
+
streamr stream resend range 2019-05-10T17:00:00 2019-05-11T21:00:00 <streamId> --private-key <key>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Vote
|
|
150
|
+
|
|
151
|
+
The CLI tool can be used to vote on Streamr governance proposals as an alternative to doing it manually in the [voting UI](https://vote.streamr.network). This is useful if you have tokens in a large number of wallets (for example due to staking) and you therefore prefer to cast your votes programmatically.
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
streamr governance vote <proposalId> <choiceId> --private-key <key>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The easiest way to find the `proposalId` is to click on a proposal in the [voting UI](https://vote.streamr.network) and then look at the browser URL. The URL has the form `https://vote.streamr.network/#/proposal/<proposalId>`, i.e. the last part of the URL is the `proposalId`. It starts with `0x...`.
|
|
158
|
+
|
|
159
|
+
The `choiceId` is just a sequence number. You can again use the UI to check what the choices are. The first option from the top is `1`, the next one is `2`, and so on. For example:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
streamr governance vote 0x2109759e060ba5a37d70be00522e00da77397f838c01c12f74c8d834ad4f4b0c 1 --private-key <key>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
You must pass either the `--private-key` or `--config` option.
|
|
166
|
+
|
|
167
|
+
### Configuration
|
|
168
|
+
|
|
169
|
+
User can specify environment and authentication details with the following command line arguments:
|
|
170
|
+
- `--private-key <key>`, e.g. `--private-key 0x1234567890123456789012345678901234567890123456789012345678901234`
|
|
171
|
+
- `--config <file>`, e.g. `--config foobar.json`
|
|
172
|
+
- `--dev` use the pre-defined [development environment](https://github.com/streamr-dev/streamr-docker-dev)
|
|
173
|
+
|
|
174
|
+
The `--config` argument tries to read a configuration file from the current working directory (either without a file extension, or with `.json` extension added). It also tries to read it from `~/.streamr/config/${id}.json` dotfile.
|
|
175
|
+
|
|
176
|
+
If no `--config` argument is specified, default settings are read from `~/.streamr/config/default.json`, if that file exists.
|
|
177
|
+
|
|
178
|
+
The configuration file is a JSON. It has one root-level property `client`, which contains any configuration properties for the [streamr-client-javascript](https://github.com/streamr-dev/network-monorepo/blob/main/packages/client/) client. Example:
|
|
179
|
+
```
|
|
180
|
+
{
|
|
181
|
+
"client": {
|
|
182
|
+
"auth": {
|
|
183
|
+
"privateKey": ...
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Examples: Piping with subscribe and publish
|
|
190
|
+
|
|
191
|
+
You can use the piping facilities of your *nix operating system with commands `publish` and `subscribe` to achieve some
|
|
192
|
+
useful operations. Below is a list of some ideas.
|
|
193
|
+
|
|
194
|
+
#### Subscribing to a stream from any programming language
|
|
195
|
+
You can pipe the line-by-line JSON objects output by `subscribe` to
|
|
196
|
+
your program written in any language. Just make the program read JSON objects
|
|
197
|
+
from stdin.
|
|
198
|
+
```
|
|
199
|
+
streamr stream subscribe streamr.eth/demos/helsinki-trams | ruby calculate-average-speed.rb
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Publishing to a stream from any programming language
|
|
203
|
+
If your program produces JSON objects to stdout (line-by-line), you can
|
|
204
|
+
redirect it to command `publish` to publish the JSON objects to a stream.
|
|
205
|
+
```
|
|
206
|
+
python printSensorReadingsAsJson.py | streamr stream publish <streamId> --private-key <key>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Transforming streams
|
|
210
|
+
You can also subscribe to a stream, apply a transformation, and then pipe the
|
|
211
|
+
transformed output into another stream.
|
|
212
|
+
```
|
|
213
|
+
streamr stream subscribe <sourceStream> | ./calculateMovingAverages | streamr stream publish <destinationStream> --private-key <key>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Same rules apply here as before. Your program should accept line-by-line JSON
|
|
217
|
+
objects via stdin and output JSON objects to stdout line-by-line.
|
|
218
|
+
|
|
219
|
+
#### Copying a production stream into development environment
|
|
220
|
+
If you have a working stream in production that you'd also like to use in your
|
|
221
|
+
development environment, you can combine the `subscribe` and `publish` commands to effectively copy
|
|
222
|
+
the real-time events.
|
|
223
|
+
```
|
|
224
|
+
streamr stream subscribe streamr.eth/demos/helsinki-trams | streamr stream publish --dev <streamId> --private-key <key>
|
|
225
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createCommand } from '../src/command'
|
|
3
|
+
import { getClientConfig } from '../src/client'
|
|
4
|
+
import snapshot from '@snapshot-labs/snapshot.js'
|
|
5
|
+
import { Wallet } from '@ethersproject/wallet'
|
|
6
|
+
import { PrivateKeyAuthConfig } from 'streamr-client'
|
|
7
|
+
|
|
8
|
+
const hub = 'https://hub.snapshot.org'
|
|
9
|
+
const snapshotClient = new snapshot.Client712(hub)
|
|
10
|
+
|
|
11
|
+
const vote = async (privateKey: string, proposal: string, choice: number) => {
|
|
12
|
+
const wallet = new Wallet(privateKey)
|
|
13
|
+
try {
|
|
14
|
+
console.log(`Wallet ${wallet.address} voting for choice ${choice} on proposal ${proposal}...`)
|
|
15
|
+
await snapshotClient.vote(wallet, wallet.address, {
|
|
16
|
+
space: 'streamr.eth',
|
|
17
|
+
proposal,
|
|
18
|
+
type: 'single-choice', // support only this type for now
|
|
19
|
+
choice,
|
|
20
|
+
app: 'cli-tool'
|
|
21
|
+
})
|
|
22
|
+
console.log(`Wallet ${wallet.address} successfully voted for choice ${choice} on proposal ${proposal}`)
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(err)
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
createCommand()
|
|
30
|
+
.description('vote on a Streamr governance proposal')
|
|
31
|
+
.arguments('<proposalId> <choiceId>')
|
|
32
|
+
.option('--private-key <key>', 'use an Ethereum private key to authenticate')
|
|
33
|
+
.option('--config <file>', 'read connection and authentication settings from a config file')
|
|
34
|
+
.action(async (proposalId: string, choiceId: string, options, command) => {
|
|
35
|
+
const config = getClientConfig(options)
|
|
36
|
+
if (!config.auth || !(config.auth as PrivateKeyAuthConfig).privateKey) {
|
|
37
|
+
console.error('You must pass a private key either via --private-key or via a config file using --config')
|
|
38
|
+
command.help()
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const choiceIdAsNumber = parseInt(choiceId)
|
|
43
|
+
if (Number.isNaN(choiceIdAsNumber) || choiceIdAsNumber <= 0) {
|
|
44
|
+
console.error(`Invalid choice number: ${choiceId}. The first choice is 1, second is 2, and so on.`)
|
|
45
|
+
command.help()
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await vote((config.auth as PrivateKeyAuthConfig).privateKey, proposalId, choiceIdAsNumber)
|
|
50
|
+
})
|
|
51
|
+
.parseAsync()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander'
|
|
3
|
+
import pkg from '../package.json'
|
|
4
|
+
|
|
5
|
+
program
|
|
6
|
+
.version(pkg.version)
|
|
7
|
+
.usage('<command> [<args>]')
|
|
8
|
+
.description('governance subcommands')
|
|
9
|
+
.command('vote', 'votes on a governance proposal')
|
|
10
|
+
.parse()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import pkg from '../package.json'
|
|
3
|
+
import { createFnParseInt } from '../src/common'
|
|
4
|
+
import { createCommand, Options as BaseOptions } from '../src/command'
|
|
5
|
+
import { randomString } from '@streamr/utils'
|
|
6
|
+
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
rate: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function genArray<T>(size: number, elementFn: () => T): T[] {
|
|
12
|
+
const arr = []
|
|
13
|
+
for (let i = 0; i < size; ++i) {
|
|
14
|
+
arr.push(elementFn())
|
|
15
|
+
}
|
|
16
|
+
return arr
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const generate = (rate: number): void => {
|
|
20
|
+
setInterval(() => {
|
|
21
|
+
console.info(JSON.stringify({
|
|
22
|
+
someText: randomString(64),
|
|
23
|
+
aNumber: Math.random() * 10000,
|
|
24
|
+
bNumber: Math.random(),
|
|
25
|
+
yesOrNo: Math.random() > 0.5,
|
|
26
|
+
arrayOfStrings: genArray(Math.floor(Math.random() * 20), () => randomString(8)),
|
|
27
|
+
arrayOfIntegers: genArray(Math.floor(Math.random() * 10), () => Math.floor(Math.random() * 100))
|
|
28
|
+
|
|
29
|
+
}))
|
|
30
|
+
}, rate)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
createCommand()
|
|
34
|
+
.description('generate and print semi-random JSON data to stdout')
|
|
35
|
+
.option('-r, --rate <n>', 'rate in milliseconds', createFnParseInt('--rate'), 500)
|
|
36
|
+
.version(pkg.version)
|
|
37
|
+
.action((options: Options) => {
|
|
38
|
+
generate(options.rate)
|
|
39
|
+
})
|
|
40
|
+
.parse()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import StreamrClient from 'streamr-client'
|
|
4
|
+
import { createClientCommand } from '../src/command'
|
|
5
|
+
|
|
6
|
+
createClientCommand(async (client: StreamrClient, storageNodeAddress: string, streamId: string) => {
|
|
7
|
+
const stream = await client.getStream(streamId)
|
|
8
|
+
await stream.addToStorageNode(storageNodeAddress)
|
|
9
|
+
})
|
|
10
|
+
.arguments('<storageNodeAddress> <streamId>')
|
|
11
|
+
.description('add stream to a storage node')
|
|
12
|
+
.parseAsync()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import EasyTable from 'easy-table'
|
|
4
|
+
import StreamrClient from 'streamr-client'
|
|
5
|
+
import { createClientCommand } from '../src/command'
|
|
6
|
+
|
|
7
|
+
createClientCommand((async (client: StreamrClient, storageNodeAddress: string) => {
|
|
8
|
+
const { streams } = await client.getStoredStreams(storageNodeAddress)
|
|
9
|
+
if (streams.length > 0) {
|
|
10
|
+
console.info(EasyTable.print(streams.map((stream) => {
|
|
11
|
+
return {
|
|
12
|
+
id: stream.id,
|
|
13
|
+
partitions: stream.getMetadata().partitions
|
|
14
|
+
}
|
|
15
|
+
})))
|
|
16
|
+
}
|
|
17
|
+
}))
|
|
18
|
+
.arguments('<storageNodeAddress>')
|
|
19
|
+
.description('list stream parts in a storage node')
|
|
20
|
+
.parseAsync()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import { StreamrClient } from 'streamr-client'
|
|
4
|
+
import EasyTable from 'easy-table'
|
|
5
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
6
|
+
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
stream?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
createClientCommand(async (client: StreamrClient, options: Options) => {
|
|
12
|
+
const streamId = options.stream
|
|
13
|
+
const addresses = await client.getStorageNodes(streamId)
|
|
14
|
+
if (addresses.length > 0) {
|
|
15
|
+
console.info(EasyTable.print(addresses.map((address: string) => ({
|
|
16
|
+
address
|
|
17
|
+
}))))
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.description('fetch a list of storage nodes')
|
|
21
|
+
.option('-s, --stream <streamId>', 'only storage nodes which store the given stream (needs authentication)')
|
|
22
|
+
.parseAsync()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import StreamrClient from 'streamr-client'
|
|
4
|
+
import { createClientCommand } from '../src/command'
|
|
5
|
+
|
|
6
|
+
createClientCommand(async (client: StreamrClient, storageNodeAddress: string, streamId: string) => {
|
|
7
|
+
const stream = await client.getStream(streamId)
|
|
8
|
+
await stream.removeFromStorageNode(storageNodeAddress)
|
|
9
|
+
})
|
|
10
|
+
.arguments('<storageNodeAddress> <streamId>')
|
|
11
|
+
.description('remove stream from a storage node')
|
|
12
|
+
.parseAsync()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander'
|
|
3
|
+
import pkg from '../package.json'
|
|
4
|
+
|
|
5
|
+
program
|
|
6
|
+
.version(pkg.version)
|
|
7
|
+
.usage('<command> [<args>]')
|
|
8
|
+
.description('storage node subcommands')
|
|
9
|
+
.command('list', 'list storage nodes')
|
|
10
|
+
.command('add-stream', 'add stream')
|
|
11
|
+
.command('remove-stream', 'remove stream')
|
|
12
|
+
.command('list-streams', 'list stream in a storage node')
|
|
13
|
+
.parse()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import StreamrClient from 'streamr-client'
|
|
4
|
+
import { createFnParseInt } from '../src/common'
|
|
5
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
6
|
+
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
description?: string
|
|
9
|
+
streamConfig?: any
|
|
10
|
+
partitions?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
createClientCommand(async (client: StreamrClient, streamIdOrPath: string, options: Options) => {
|
|
14
|
+
const body: any = {
|
|
15
|
+
id: streamIdOrPath,
|
|
16
|
+
description: options.description,
|
|
17
|
+
config: options.streamConfig,
|
|
18
|
+
partitions: options.partitions
|
|
19
|
+
}
|
|
20
|
+
const stream = await client.createStream(body)
|
|
21
|
+
console.info(JSON.stringify({ id: stream.id, ...stream.getMetadata() }, null, 2))
|
|
22
|
+
})
|
|
23
|
+
.arguments('<streamId>')
|
|
24
|
+
.description('create a new stream')
|
|
25
|
+
.option('-d, --description <description>', 'define a description')
|
|
26
|
+
.option('-c, --stream-config <config>', 'define a configuration as JSON', (s: string) => JSON.parse(s))
|
|
27
|
+
.option('-p, --partitions <count>', 'define a partition count',
|
|
28
|
+
createFnParseInt('--partitions'))
|
|
29
|
+
.parseAsync()
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import { PermissionAssignment, Stream } from 'streamr-client'
|
|
4
|
+
import { runModifyPermissionsCommand } from '../src/permission'
|
|
5
|
+
|
|
6
|
+
runModifyPermissionsCommand(
|
|
7
|
+
(stream: Stream, assigment: PermissionAssignment) => stream.grantPermissions(assigment),
|
|
8
|
+
'grant'
|
|
9
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../src/logLevel'
|
|
3
|
+
import { Writable } from 'stream'
|
|
4
|
+
import { StreamrClient } from 'streamr-client'
|
|
5
|
+
import { wait } from '@streamr/utils'
|
|
6
|
+
import es from 'event-stream'
|
|
7
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
8
|
+
|
|
9
|
+
interface Options extends BaseOptions {
|
|
10
|
+
partitionKeyField?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const publishStream = (
|
|
14
|
+
stream: string,
|
|
15
|
+
partitionKeyField: string | undefined,
|
|
16
|
+
client: StreamrClient
|
|
17
|
+
): Writable => {
|
|
18
|
+
const writable = new Writable({
|
|
19
|
+
objectMode: true,
|
|
20
|
+
write: (data: any, _: any, done: any) => {
|
|
21
|
+
let json = null
|
|
22
|
+
// ignore newlines, etc
|
|
23
|
+
if (!data || String(data).trim() === '') {
|
|
24
|
+
done()
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
json = JSON.parse(data)
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error(data.toString())
|
|
31
|
+
done(e)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
const partitionKey = (partitionKeyField !== undefined) ? json[partitionKeyField] : undefined
|
|
35
|
+
client.publish(stream, json, { partitionKey }).then(
|
|
36
|
+
() => done(),
|
|
37
|
+
(err) => done(err)
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
return writable
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
createClientCommand(async (client: StreamrClient, streamId: string, options: Options) => {
|
|
45
|
+
const ps = publishStream(streamId, options.partitionKeyField, client)
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
process.stdin
|
|
48
|
+
.pipe(es.split())
|
|
49
|
+
.pipe(ps)
|
|
50
|
+
.once('finish', async () => {
|
|
51
|
+
// We need to wait some time because the client.publish() may resolve the promise
|
|
52
|
+
// before the node has propagated the message. That may happend if the node
|
|
53
|
+
// has not yet connected to Tracker when client.publish() is called. In that case
|
|
54
|
+
// the message is put to the propagation queue (activeTaskStore.add call in
|
|
55
|
+
// network Propagation.ts:59) and the client.publish() promise resolves immeditatelly.
|
|
56
|
+
// TODO Remove this wait when NET-604 has been resolved
|
|
57
|
+
await wait(2000)
|
|
58
|
+
resolve(undefined)
|
|
59
|
+
})
|
|
60
|
+
.once('error', (err: any) => reject(err) )
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
.arguments('<streamId>')
|
|
64
|
+
.description('publish to a stream by reading JSON messages from stdin line-by-line')
|
|
65
|
+
.option('-k, --partition-key-field <string>', 'field name in each message to use for assigning the message to a stream partition')
|
|
66
|
+
.parseAsync()
|