Skip to content

Commit

Permalink
Add a payments plugin to GQL server (#391)
Browse files Browse the repository at this point in the history
* Add a custom payments plugin in server process

* Fix voucher channel read in voucher subscription

* Use voucher hash and signature for payment authentication

* Use a LRU hash map for storing received vouchers

* Avoid hoisting level types to resolve build errors

* Upgrade ts-nitro packages

* Add payments related logs

* Upgrade package versions

* Always allow latestBlock query

* Upgrade ts-nitro packages
  • Loading branch information
prathamesh0 authored Jul 20, 2023
1 parent 11930c0 commit eec1965
Show file tree
Hide file tree
Showing 18 changed files with 369 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.2.46",
"version": "0.2.47",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"packages/*"
],
"nohoist": [
"**/@graphprotocol/graph-ts"
"**/@graphprotocol/graph-ts",
"**/@types/level"
]
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/cache",
"version": "0.2.46",
"version": "0.2.47",
"description": "Generic object cache",
"main": "dist/index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/cli",
"version": "0.2.46",
"version": "0.2.47",
"main": "dist/index.js",
"license": "AGPL-3.0",
"scripts": {
Expand All @@ -11,8 +11,8 @@
"chat": "DEBUG='vulcanize:*, laconic:*' node dist/chat.js"
},
"dependencies": {
"@cerc-io/peer": "^0.2.46",
"@cerc-io/util": "^0.2.46",
"@cerc-io/peer": "^0.2.47",
"@cerc-io/util": "^0.2.47",
"@ethersproject/providers": "^5.4.4",
"@graphql-tools/utils": "^9.1.1",
"@ipld/dag-cbor": "^8.0.0",
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
EventWatcher,
GraphWatcherInterface,
Config,
P2PConfig
P2PConfig,
PaymentsManager
} from '@cerc-io/util';
import { TypeSource } from '@graphql-tools/utils';
import {
Expand Down Expand Up @@ -111,7 +112,8 @@ export class ServerCmd {
async exec (
createResolvers: (indexer: IndexerInterface, eventWatcher: EventWatcher) => Promise<any>,
typeDefs: TypeSource,
parseLibp2pMessage?: (peerId: string, data: any) => void
parseLibp2pMessage?: (peerId: string, data: any) => void,
paymentsManager?: PaymentsManager
): Promise<{
app: Application,
server: ApolloServer
Expand All @@ -136,7 +138,7 @@ export class ServerCmd {

// Create an Express app
const app: Application = express();
const server = await createAndStartServer(app, typeDefs, resolvers, config.server);
const server = await createAndStartServer(app, typeDefs, resolvers, config.server, paymentsManager);

await startGQLMetricsServer(config);

Expand Down
4 changes: 2 additions & 2 deletions packages/codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/codegen",
"version": "0.2.46",
"version": "0.2.47",
"description": "Code generator",
"private": true,
"main": "index.js",
Expand All @@ -20,7 +20,7 @@
},
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@cerc-io/util": "^0.2.46",
"@cerc-io/util": "^0.2.47",
"@graphql-tools/load-files": "^6.5.2",
"@poanet/solidity-flattener": "https://github.com/vulcanize/solidity-flattener.git",
"@solidity-parser/parser": "^0.13.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/codegen/src/templates/package-template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.46",
"@cerc-io/ipld-eth-client": "^0.2.46",
"@cerc-io/solidity-mapper": "^0.2.46",
"@cerc-io/util": "^0.2.46",
"@cerc-io/cli": "^0.2.47",
"@cerc-io/ipld-eth-client": "^0.2.47",
"@cerc-io/solidity-mapper": "^0.2.47",
"@cerc-io/util": "^0.2.47",
{{#if (subgraphPath)}}
"@cerc-io/graph-node": "^0.2.46",
"@cerc-io/graph-node": "^0.2.47",
{{/if}}
"@ethersproject/providers": "^5.4.4",
"apollo-type-bigint": "^0.1.3",
Expand Down
10 changes: 5 additions & 5 deletions packages/graph-node/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@cerc-io/graph-node",
"version": "0.2.46",
"version": "0.2.47",
"main": "dist/index.js",
"license": "AGPL-3.0",
"devDependencies": {
"@cerc-io/solidity-mapper": "^0.2.46",
"@cerc-io/solidity-mapper": "^0.2.47",
"@ethersproject/providers": "^5.4.4",
"@graphprotocol/graph-ts": "^0.22.0",
"@nomiclabs/hardhat-ethers": "^2.0.2",
Expand Down Expand Up @@ -51,9 +51,9 @@
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/assemblyscript": "0.19.10-watcher-ts-0.1.2",
"@cerc-io/cache": "^0.2.46",
"@cerc-io/ipld-eth-client": "^0.2.46",
"@cerc-io/util": "^0.2.46",
"@cerc-io/cache": "^0.2.47",
"@cerc-io/ipld-eth-client": "^0.2.47",
"@cerc-io/util": "^0.2.47",
"@types/json-diff": "^0.5.2",
"@types/yargs": "^17.0.0",
"bn.js": "^4.11.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/ipld-eth-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/ipld-eth-client",
"version": "0.2.46",
"version": "0.2.47",
"description": "IPLD ETH Client",
"main": "dist/index.js",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.7.1",
"@cerc-io/cache": "^0.2.46",
"@cerc-io/cache": "^0.2.47",
"cross-fetch": "^3.1.4",
"debug": "^4.3.1",
"ethers": "^5.4.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/peer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/peer",
"version": "0.2.46",
"version": "0.2.47",
"description": "libp2p module",
"main": "dist/index.js",
"exports": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/solidity-mapper/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@cerc-io/solidity-mapper",
"version": "0.2.46",
"version": "0.2.47",
"main": "dist/index.js",
"license": "AGPL-3.0",
"devDependencies": {
"@cerc-io/ipld-eth-client": "^0.2.46",
"@cerc-io/ipld-eth-client": "^0.2.47",
"@ethersproject/abi": "^5.3.0",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/test",
"version": "0.2.46",
"version": "0.2.47",
"main": "dist/index.js",
"license": "AGPL-3.0",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/tracing-client",
"version": "0.2.46",
"version": "0.2.47",
"description": "ETH VM tracing client",
"main": "dist/index.js",
"scripts": {
Expand Down
12 changes: 8 additions & 4 deletions packages/util/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "@cerc-io/util",
"version": "0.2.46",
"version": "0.2.47",
"main": "dist/index.js",
"license": "AGPL-3.0",
"dependencies": {
"@apollo/utils.keyvaluecache": "^1.0.1",
"@cerc-io/solidity-mapper": "^0.2.46",
"@cerc-io/nitro-client": "^0.1.3",
"@cerc-io/nitro-util": "^0.1.3",
"@cerc-io/solidity-mapper": "^0.2.47",
"@cerc-io/ts-channel": "1.0.3-ts-nitro-0.1.1",
"@ethersproject/providers": "^5.4.4",
"@graphql-tools/schema": "^9.0.10",
"@graphql-tools/utils": "^9.1.1",
Expand All @@ -26,6 +29,7 @@
"js-yaml": "^4.1.0",
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"lru-cache": "^10.0.0",
"multiformats": "^9.4.8",
"pg": "^8.5.1",
"pg-boss": "^6.1.0",
Expand All @@ -37,8 +41,8 @@
"yargs": "^17.0.1"
},
"devDependencies": {
"@cerc-io/cache": "^0.2.46",
"@cerc-io/ipld-eth-client": "^0.2.46",
"@cerc-io/cache": "^0.2.47",
"@cerc-io/ipld-eth-client": "^0.2.47",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@types/express": "^4.17.14",
"@types/fs-extra": "^9.0.11",
Expand Down
1 change: 1 addition & 0 deletions packages/util/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export * from './graph/database';
export * from './graph/utils';
export * from './graph/state-utils';
export * from './graph/types';
export * from './payments';
Loading

0 comments on commit eec1965

Please sign in to comment.