Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 1db5b30

Browse files
authored
Export public types, update DU config (#210)
Export parameters/return types for objects which are publicly available to the JS-client users. Updated getDataUnionMainnetAddress and getDataUnionSidechainAddress in Contracts.ts to support new DataUnion addresses. BREAKING CHANGE: - moved DataUnion related StreamrClient options into a new dataUnion block: factoryMainnetAddress, - factorySidechainAddress, minimumWithdrawTokenWei - renamed payForSignatureTransport to freeWithdraw and reversed the value - new required options in that block: templateMainnetAddress, templateSidechainAddress
1 parent 9ccd610 commit 1db5b30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+503
-230
lines changed

.babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
plugins: [
2525
"add-module-exports",
2626
['@babel/plugin-transform-runtime', {
27-
corejs: false,
27+
corejs: 3,
2828
helpers: true,
2929
regenerator: false
3030
}],

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ test/legacy/**
66
src/shim/**
77
test/unit/StubbedStreamrClient.js
88
streamr-docker-dev/**
9+
vendor/**
10+
test/exports/**

.github/workflows/nodejs.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ jobs:
4848
run: npm ci
4949
- name: npm run eslint
5050
run: npm run eslint
51-
- name: test-types
52-
run: npm run test-types
5351

5452
test:
5553
name: Test Unit using Node ${{ matrix.node-version }}
@@ -107,7 +105,7 @@ jobs:
107105
- name: npm ci
108106
run: npm ci
109107
- name: Start Streamr Docker Stack
110-
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.2
108+
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.3
111109
with:
112110
services-to-start: "mysql redis engine-and-editor cassandra parity-node0 parity-sidechain-node0 bridge broker-node-storage-1 nginx smtp"
113111
- name: Run Test
@@ -129,7 +127,7 @@ jobs:
129127
- name: npm ci
130128
run: npm ci
131129
- name: Start Streamr Docker Stack
132-
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.2
130+
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.3
133131
with:
134132
services-to-start: "mysql redis engine-and-editor cassandra parity-node0 parity-sidechain-node0 bridge broker-node-storage-1 nginx smtp"
135133
- uses: nick-invision/retry@v2
@@ -140,6 +138,26 @@ jobs:
140138
retry_on: error
141139
command: npm run test-flakey || echo "::warning::Flakey Tests Failed"
142140

141+
test-exports:
142+
name: Test Exports using Node 14.x
143+
runs-on: ubuntu-latest
144+
needs: build
145+
steps:
146+
- uses: actions/checkout@v2
147+
- uses: actions/setup-node@v2
148+
with:
149+
node-version: "14.x"
150+
- uses: actions/download-artifact@v2
151+
with:
152+
name: build
153+
path: dist
154+
- name: npm ci
155+
run: npm ci
156+
- name: test-types
157+
run: npm run test-types
158+
- name: npm run test-exports
159+
run: npm run test-exports
160+
143161
browser:
144162
name: Test Browser using Node 14.x
145163
runs-on: ubuntu-latest
@@ -156,7 +174,7 @@ jobs:
156174
- name: npm ci
157175
run: npm ci
158176
- name: Start Streamr Docker Stack
159-
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.2
177+
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.3
160178
with:
161179
services-to-start: "mysql redis engine-and-editor cassandra parity-node0 parity-sidechain-node0 bridge broker-node-storage-1 nginx smtp"
162180

@@ -186,7 +204,7 @@ jobs:
186204
name: build
187205
path: dist
188206
- name: Start Streamr Docker Stack
189-
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.2
207+
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.3
190208
with:
191209
services-to-start: "mysql redis engine-and-editor cassandra parity-node0 parity-sidechain-node0 bridge broker-node-storage-1 nginx smtp"
192210
- name: npm ci
@@ -233,17 +251,20 @@ jobs:
233251
name: build
234252
path: dist
235253
- name: Start Streamr Docker Stack
236-
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.2
254+
uses: streamr-dev/streamr-docker-dev-action@v1.0.0-alpha.3
237255
with:
238256
services-to-start: "mysql redis engine-and-editor cassandra parity-node0 parity-sidechain-node0 bridge broker-node-storage-1 nginx smtp"
239257
- name: npm ci
240258
run: npm ci
241259
- name: npm link
242-
run: npm link
260+
run: cd dist && npm link
243261
- uses: actions/checkout@v2
244262
with:
245263
repository: streamr-dev/streamr-client-testing
246264
path: streamr-client-testing
265+
- uses: actions/setup-java@v1
266+
with:
267+
java-version: '8'
247268
- name: setup-client-testing
248269
working-directory: streamr-client-testing
249270
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ examples/webpack/dist/*
4040
reports
4141
tests_outputbenchmarks.txt
4242
tests_output
43+
test/exports/dist
44+
test/exports/package-lock.json
45+
vendor

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ const client = new StreamrClient({
4343
})
4444
```
4545

46-
When using Node.js remember to require the library with:
46+
When using Node.js remember to import the library with:
4747

4848
```js
49-
const StreamrClient = require('streamr-client')
49+
import { StreamrClient } from 'streamr-client';
5050
```
5151

5252
### Subscribing to real-time events in a stream
@@ -329,11 +329,15 @@ This library provides functions for working with Data Unions. To get a DataUnion
329329
TODO: All `options`-parameters should be documented (see TypeScript interfaces for the definitions)
330330

331331
These DataUnion-specific options are used from `StreamrClient` options:
332-
| Property | Default | Description |
333-
| :----------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
334-
| tokenAddress | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU |
335-
| factoryMainnetAddress | TODO | Data Union factory that creates a new Data Union |
336-
| minimumWithdrawTokenWei | 1000000 | Threshold value set in AMB configs, smallest token amount that can pass over the bridge |
332+
| Property | Default | Description |
333+
| :---------------------------------- | :----------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
334+
| tokenAddress | 0x0Cf0Ee637<br>88A0849fE52<br>97F3407f701<br>E122cC023 | Token used by the DU |
335+
| dataUnion.minimumWithdrawTokenWei | 1000000 | Threshold value set in AMB configs, smallest token amount that can pass over the bridge |
336+
| dataUnion.freeWithdraw | false | true = someone else pays for the gas when transporting the withdraw tx to mainnet; false = client does the transport as self-service and pays the mainnet gas costs |
337+
| dataUnion.factoryMainnetAddress | TODO | Data Union factory that creates a new Data Union |
338+
| dataUnion.factorySidechainAddress | TODO | |
339+
| dataUnion.templateMainnetAddress | TODO | |
340+
| dataUnion.templateSidechainAddress | TODO | |
337341

338342

339343
### Admin Functions

copy-package.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const fs = require('fs')
2+
// eslint-disable-next-line
3+
const pkg = Object.assign({}, require('./package.json'))
4+
5+
delete pkg.scripts
6+
7+
try {
8+
fs.mkdirSync('./dist/')
9+
} catch (err) {
10+
if (err.code !== 'EEXIST') {
11+
throw err
12+
}
13+
}
14+
15+
fs.writeFileSync('./dist/package.json', JSON.stringify(pkg, null, 2))

examples/node/node-example-produce.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const StreamrClient = require('streamr-client')
1+
import { StreamrClient } from 'streamr-client';
22

33
// Create the client and supply either an API key or an Ethereum private key to authenticate
44
const client = new StreamrClient({

examples/node/node-example-subscribe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const StreamrClient = require('streamr-client')
1+
import { StreamrClient } from 'streamr-client';
22

33
// Create the client and supply either an API key or an Ethereum private key to authenticate
44
const client = new StreamrClient({

package-lock.json

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)