Add a payments plugin to GQL server (#391)

* 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
This commit is contained in:
prathamesh0
2023-07-20 17:22:48 +05:30
committed by GitHub
parent 11930c0107
commit eec1965980
18 changed files with 369 additions and 34 deletions
+3 -3
View File
@@ -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": {
@@ -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",
+5 -3
View File
@@ -25,7 +25,8 @@ import {
EventWatcher,
GraphWatcherInterface,
Config,
P2PConfig
P2PConfig,
PaymentsManager
} from '@cerc-io/util';
import { TypeSource } from '@graphql-tools/utils';
import {
@@ -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
@@ -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);