Skip to content

Commit

Permalink
Switch networking to @polkadot/rpc-provider and support for `author…
Browse files Browse the repository at this point in the history
…_submitAndWatchExtrinsic` for trusted calls (#116)

* add rpc-provider

* remove unnecessary modules from rpc-provider

* yarn lock

* remove rpc provider again

* Functional WIP of working RPC provider

* simplify the websocket worker some more

* Revert "remove rpc provider again"

This reverts commit 1815e0c.

* submitAndWatch WIP

* [websocketIntegriteeWorker] close ws after tests

* [websocketIntegriteeWorker] extract resultToRpcReturnValue

* [websocketIntegriteeWorker] trustedCall fire&forget works

* [websocketIntegriteeWorker] submitAndCallback architecture seems to work, but we don't get an update

* [websocketIntegriteeWorker] improve logging

* implement getters with the new api

* fix tests by resolving shard vs mrenclave ambiguity

* properly reject upon priority error

* fix tests in old integriteeWorker

* update localDocker network with shard

* move rpc-provider to worker

* integrate local rpc-provider

* close websockets after test in old worker implementation

* able to run test with local rpc-provider

* [rpc-provider] add debug logs

* successfully implement `author_submitAndWatchExtrinsic`

* merge the websocketWorker back into the worker

* fix tests by resolving shard vs mrenclave ambiguity

* merge the integritee websocket worker back into the original one

* remove obsolete sendTrustedCall method

* remove legacy code and encointer code

* delete tests in rpc-provider that don't run

* allow passing the websocket implementation into the rpc-provider.

* remove old IWorker interface

* remove unnecessary stuff from rpc-provider

* make websocket a dev-dep

* remove unnecessary promised map dependency

* extract generic top to worker base implementation

* simplify callback code

* aggregate callback result in TrustedCallResult

* improve callback code

* fix code peculiarities

* add comment about tests and skip them again for the ci

* remove unnecessary dependency

* add comment about websocket in rpc-provider

* better comment

* better type for submitAndWatch

* v0.15.3-alpha.0

* v0.16.0-alpha.0

* resolve promise if status is invalid

* Revert "[rpc-provider] add debug logs"

This reverts commit 6215133.

* downgrade a log
  • Loading branch information
clangenb authored Oct 26, 2024
1 parent b2ab02e commit fda06bc
Show file tree
Hide file tree
Showing 40 changed files with 1,666 additions and 686 deletions.
Binary file removed .yarn/cache/chnl-npm-1.2.0-0147cf365c-78044132c0.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ The worker uses the webcrypto api if it is run in the browser. This library is o
defined if you access the webpage with `localhost` in firefox. It is not available
on `127.0.0.1` or `0.0.0.0` due to browser security policies.

## Testing
Use the below command to only execute a particular test suite.

**Note:** The worker tests are skipped by default, as they need a running setup.

```bash
// execute worker tests
yarn test --runTestsByPath packages/worker-api/src/integriteeWorker.spec.ts
```

```bash
yarn add @encointer/node-api @encointer/worker-api
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"publishConfig": {
"directory": "build"
},
"version": "0.15.2"
"version": "0.16.0-alpha.0"
}
4 changes: 2 additions & 2 deletions packages/node-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
},
"sideEffects": false,
"type": "module",
"version": "0.15.2",
"version": "0.16.0-alpha.0",
"main": "index.js",
"dependencies": {
"@encointer/types": "^0.15.2",
"@encointer/types": "^0.16.0-alpha.0",
"@polkadot/api": "^11.2.1",
"tslib": "^2.6.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"sideEffects": false,
"type": "module",
"version": "0.15.2",
"version": "0.16.0-alpha.0",
"main": "index.js",
"scripts": {
"generate:defs": "node --experimental-specifier-resolution=node --loader ts-node/esm ../../node_modules/.bin/polkadot-types-from-defs --package @encointer/types/interfaces --input ./src/interfaces",
Expand Down
2 changes: 1 addition & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"sideEffects": false,
"type": "module",
"types": "./index.d.ts",
"version": "0.15.2",
"version": "0.16.0-alpha.0",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.9",
Expand Down
18 changes: 10 additions & 8 deletions packages/worker-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,28 @@
"sideEffects": false,
"type": "module",
"types": "./index.d.ts",
"version": "0.15.2",
"version": "0.16.0-alpha.0",
"main": "index.js",
"dependencies": {
"@encointer/node-api": "^0.15.2",
"@encointer/types": "^0.15.2",
"@encointer/util": "^0.15.2",
"@encointer/node-api": "^0.16.0-alpha.0",
"@encointer/types": "^0.16.0-alpha.0",
"@encointer/util": "^0.16.0-alpha.0",
"@peculiar/webcrypto": "^1.4.6",
"@polkadot/api": "^11.2.1",
"@polkadot/keyring": "^12.6.2",
"@polkadot/types": "^11.2.1",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@polkadot/wasm-crypto": "^7.3.2",
"@polkadot/x-global": "^12.6.2",
"@polkadot/x-ws": "^12.6.2",
"bs58": "^4.0.1",
"promised-map": "^1.0.0",
"websocket": "^1.0.34",
"websocket-as-promised": "^2.0.1"
"eventemitter3": "^5.0.1",
"tslib": "^2.6.2"
},
"devDependencies": {
"@types/bs58": "^4.0.4"
"@types/bs58": "^4.0.4",
"websocket": "^1.0.34"
},
"peerDependencies": {
"@polkadot/x-randomvalues": "^12.3.2"
Expand Down
132 changes: 0 additions & 132 deletions packages/worker-api/src/encointerWorker.spec.ts

This file was deleted.

107 changes: 0 additions & 107 deletions packages/worker-api/src/encointerWorker.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/worker-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { Worker } from './worker.js';
export { EncointerWorker } from './encointerWorker.js';
export { IntegriteeWorker } from './integriteeWorker.js';

export * from './interface.js';
Loading

0 comments on commit fda06bc

Please sign in to comment.