diff --git a/.gitignore b/.gitignore index 80989198..4336722e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ lerna-debug.log *node_modules/ result* *yarn-error.log +./node-ipc +app/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b1a78f5c..22f2bb27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:10.15.3-alpine as builder +FROM node:10.15.3-alpine as nodejs_builder RUN apk add --update python make g++ yarn RUN mkdir /application COPY package.json yarn.lock .yarnrc /application/ @@ -7,6 +7,7 @@ WORKDIR /application RUN mkdir /application/packages COPY tsconfig.json /application/ COPY packages/api-cardano-db-hasura /application/packages/api-cardano-db-hasura +COPY packages/api-cardano-node /application/packages/api-cardano-node COPY packages/api-genesis /application/packages/api-genesis COPY packages/server /application/packages/server COPY packages/util /application/packages/util @@ -14,39 +15,79 @@ COPY packages/util-dev /application/packages/util-dev RUN yarn --offline --frozen-lockfile --non-interactive RUN yarn build -FROM node:10.15.3-alpine as production_deps +FROM node:10.15.3-alpine as nodejs_production_deps RUN mkdir -p application/packages COPY package.json yarn.lock .yarnrc /application/ -COPY --from=builder /application/packages-cache /application/packages-cache +COPY --from=nodejs_builder /application/packages-cache /application/packages-cache WORKDIR /application/packages -RUN mkdir api-cardano-db-hasura api-genesis util server +RUN mkdir api-cardano-db-hasura api-cardano-node api-genesis util server COPY packages/api-cardano-db-hasura/package.json api-cardano-db-hasura/ +COPY packages/api-cardano-node/package.json api-cardano-node/ COPY packages/api-genesis/package.json api-genesis/ COPY packages/server/package.json server/ COPY packages/util/package.json util/ WORKDIR /application RUN yarn --production --offline --frozen-lockfile --non-interactive +FROM debian:buster-slim as cardano_haskell_builder +ARG CARDANO_NODE_TAG=1.15.1 +WORKDIR /build +RUN apt -yq update && apt -yq upgrade + +RUN apt install build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsodium-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 \ + -y +RUN wget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz && \ + tar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz && \ + rm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sig && \ + mv cabal /usr/local/bin/ +RUN cabal update +WORKDIR /app/ghc +RUN wget https://downloads.haskell.org/~ghc/8.6.5/ghc-8.6.5-x86_64-deb9-linux.tar.xz && \ + tar -xf ghc-8.6.5-x86_64-deb9-linux.tar.xz && \ + rm ghc-8.6.5-x86_64-deb9-linux.tar.xz +WORKDIR /app/ghc/ghc-8.6.5 +RUN ./configure +RUN make install +WORKDIR /app +RUN mkdir build +RUN git clone https://github.com/input-output-hk/cardano-node.git && \ + cd cardano-node && \ + git fetch --all --tags && \ + git checkout ${CARDANO_NODE_TAG} +WORKDIR /app/cardano-node +COPY config/cabal.project.local . +RUN cabal build cardano-cli && \ + mv ./dist-newstyle/build/x86_64-linux/ghc-8.6.5/cardano-cli-${CARDANO_NODE_TAG}/x/cardano-cli/build/cardano-cli/cardano-cli /usr/local/bin/ + FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.30 as downloader RUN apk add curl RUN curl --proto '=https' --tlsv1.2 -sSf -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | sh RUN hasura --skip-update-check update-cli --version v1.2.1 -FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.30 as server -RUN apk add nodejs +#FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.30 as server +#RUN apt add nodejs +FROM debian:buster-slim as server +RUN apt -yq update && apt -yq upgrade +RUN apt install nodejs -y RUN mkdir /application -COPY --from=builder /application/packages/api-cardano-db-hasura/dist /application/packages/api-cardano-db-hasura/dist -COPY --from=builder /application/packages/api-cardano-db-hasura/hasura/project /application/packages/api-cardano-db-hasura/hasura/project -COPY --from=builder /application/packages/api-cardano-db-hasura/package.json /application/packages/api-cardano-db-hasura/package.json -COPY --from=builder /application/packages/api-cardano-db-hasura/schema.graphql /application/packages/api-cardano-db-hasura/schema.graphql -COPY --from=builder /application/packages/api-genesis/dist /application/packages/api-genesis/dist -COPY --from=builder /application/packages/api-genesis/package.json /application/packages/api-genesis/package.json -COPY --from=builder /application/packages/api-genesis/schema.graphql /application/packages/api-genesis/schema.graphql -COPY --from=builder /application/packages/server/dist /application/packages/server/dist -COPY --from=builder /application/packages/server/package.json /application/packages/server/package.json -COPY --from=builder /application/packages/util/dist /application/packages/util/dist -COPY --from=builder /application/packages/util/package.json /application/packages/util/package.json -COPY --from=production_deps /application/node_modules /application/node_modules +COPY --from=cardano_haskell_builder /usr/lib /usr/lib +COPY --from=cardano_haskell_builder /etc /etc +COPY --from=cardano_haskell_builder /usr/local/bin/cardano-cli /usr/local/bin/cardano-cli +COPY --from=nodejs_builder /application/packages/api-cardano-db-hasura/dist /application/packages/api-cardano-db-hasura/dist +COPY --from=nodejs_builder /application/packages/api-cardano-db-hasura/hasura/project /application/packages/api-cardano-db-hasura/hasura/project +COPY --from=nodejs_builder /application/packages/api-cardano-db-hasura/package.json /application/packages/api-cardano-db-hasura/package.json +COPY --from=nodejs_builder /application/packages/api-cardano-db-hasura/schema.graphql /application/packages/api-cardano-db-hasura/schema.graphql +COPY --from=nodejs_builder /application/packages/api-cardano-node/dist /application/packages/api-cardano-node/dist +COPY --from=nodejs_builder /application/packages/api-cardano-node/package.json /application/packages/api-cardano-node/package.json +COPY --from=nodejs_builder /application/packages/api-cardano-node/schema.graphql /application/packages/api-cardano-node/schema.graphql +COPY --from=nodejs_builder /application/packages/api-genesis/dist /application/packages/api-genesis/dist +COPY --from=nodejs_builder /application/packages/api-genesis/package.json /application/packages/api-genesis/package.json +COPY --from=nodejs_builder /application/packages/api-genesis/schema.graphql /application/packages/api-genesis/schema.graphql +COPY --from=nodejs_builder /application/packages/server/dist /application/packages/server/dist +COPY --from=nodejs_builder /application/packages/server/package.json /application/packages/server/package.json +COPY --from=nodejs_builder /application/packages/util/dist /application/packages/util/dist +COPY --from=nodejs_builder /application/packages/util/package.json /application/packages/util/package.json +COPY --from=nodejs_production_deps /application/node_modules /application/node_modules COPY --from=downloader /usr/local/bin/hasura /usr/local/bin/hasura WORKDIR /application WORKDIR /application/packages/server/dist diff --git a/config/cabal.project.local b/config/cabal.project.local new file mode 100644 index 00000000..7a17003a --- /dev/null +++ b/config/cabal.project.local @@ -0,0 +1,2 @@ +package cardano-crypto-praos + flags: -external-libsodium-vrf \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 350595c8..e362ceee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -92,11 +92,13 @@ services: - CACHE_ENABLED=true - GENESIS_FILE_SHELLEY=/configuration/genesis_shelley.json - HASURA_URI=http://hasura:8080 + - CARDANO_NODE_SOCKET_PATH=/node-ipc/node.socket - POSTGRES_HOST=postgres - POSTGRES_PORT=5432 - POSTGRES_DB_FILE=/run/secrets/postgres_db - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password - POSTGRES_USER_FILE=/run/secrets/postgres_user + - CARDANO_MAGIC=42 expose: - 3100 ports: @@ -108,6 +110,7 @@ services: max-size: "200k" max-file: "10" volumes: + - node-ipc:/node-ipc - ./config/network/${NETWORK:-mainnet}:/configuration secrets: postgres_db: diff --git a/mk-addresses.sh b/mk-addresses.sh new file mode 100755 index 00000000..d0683ba7 --- /dev/null +++ b/mk-addresses.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -ex + +# +# In order to run the graphql tests you need some addresses set up on the testnet with funds +# Copy this file into the ./app directory and then run it from inside the graphql docker container. e.g. docker exec -t ./app/mk-addresses.sh +# You will then need to add some ada to the payment.addr using https://testnets.cardano.org/en/shelley/tools/faucet/ +# + +# All taken from https://github.com/input-output-hk/cardano-tutorials/blob/master/node-setup/020_keys_and_addresses.md + + +# build the stake address +cardano-cli shelley stake-address key-gen \ +--verification-key-file stake.vkey \ +--signing-key-file stake.skey + +cardano-cli shelley stake-address build \ +--stake-verification-key-file stake.vkey \ +--out-file stake.addr \ +--testnet-magic 42 + +# build the first payment address, this is the address that you will send payments from in the tests, it needs funds to be added +cardano-cli shelley address key-gen \ +--verification-key-file payment.vkey \ +--signing-key-file payment.skey + +cardano-cli shelley address build \ +--payment-verification-key-file payment.vkey \ +--stake-verification-key-file stake.vkey \ +--out-file payment.addr \ +--testnet-magic 42 + +# build the second payment address, this is the address that you will send payments to in the tests and it needs no funds +cardano-cli shelley address key-gen \ +--verification-key-file payment2.vkey \ +--signing-key-file payment2.skey + +cardano-cli shelley address build \ +--payment-verification-key-file payment2.vkey \ +--stake-verification-key-file stake.vkey \ +--out-file payment2.addr \ +--testnet-magic 42 + +# This is the address you need to add funds to using https://testnets.cardano.org/en/shelley/tools/faucet/ +cat payment.addr \ No newline at end of file diff --git a/package.json b/package.json index b5992d05..383dacb1 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ }, "homepage": "https://github.com/input-output-hk/cardano-graphql#README.md", "devDependencies": { + "@graphql-codegen/add": "^1.16.3", "@graphql-codegen/cli": "^1.15.2", "@graphql-codegen/typescript": "^1.15.2", "@graphql-codegen/typescript-graphql-files-modules": "^1.15.2", @@ -60,6 +61,7 @@ "apollo-link-http": "^1.5.17", "apollo-server-core": "^2.15.0", "apollo-server-testing": "^2.15.0", + "axios": "^0.19.2", "bignumber.js": "^9.0.0", "cross-fetch": "^3.0.4", "env-paths": "^2.2.0", diff --git a/packages-cache/@babel-runtime-7.10.5.tgz b/packages-cache/@babel-runtime-7.10.5.tgz new file mode 100644 index 00000000..6aa790d1 Binary files /dev/null and b/packages-cache/@babel-runtime-7.10.5.tgz differ diff --git a/packages-cache/@graphql-codegen-add-1.16.3.tgz b/packages-cache/@graphql-codegen-add-1.16.3.tgz new file mode 100644 index 00000000..d77a48a3 Binary files /dev/null and b/packages-cache/@graphql-codegen-add-1.16.3.tgz differ diff --git a/packages-cache/@graphql-codegen-plugin-helpers-1.16.3.tgz b/packages-cache/@graphql-codegen-plugin-helpers-1.16.3.tgz new file mode 100644 index 00000000..1764ea56 Binary files /dev/null and b/packages-cache/@graphql-codegen-plugin-helpers-1.16.3.tgz differ diff --git a/packages-cache/@graphql-tools-links-6.0.12.tgz b/packages-cache/@graphql-tools-links-6.0.12.tgz new file mode 100644 index 00000000..5f9576aa Binary files /dev/null and b/packages-cache/@graphql-tools-links-6.0.12.tgz differ diff --git a/packages-cache/@graphql-tools-load-files-6.0.12.tgz b/packages-cache/@graphql-tools-load-files-6.0.12.tgz new file mode 100644 index 00000000..d5feb01c Binary files /dev/null and b/packages-cache/@graphql-tools-load-files-6.0.12.tgz differ diff --git a/packages-cache/@graphql-tools-mock-6.0.12.tgz b/packages-cache/@graphql-tools-mock-6.0.12.tgz new file mode 100644 index 00000000..e1ca6511 Binary files /dev/null and b/packages-cache/@graphql-tools-mock-6.0.12.tgz differ diff --git a/packages-cache/@graphql-tools-module-loader-6.0.12.tgz b/packages-cache/@graphql-tools-module-loader-6.0.12.tgz new file mode 100644 index 00000000..b93a6091 Binary files /dev/null and b/packages-cache/@graphql-tools-module-loader-6.0.12.tgz differ diff --git a/packages-cache/@graphql-tools-resolvers-composition-6.0.12.tgz b/packages-cache/@graphql-tools-resolvers-composition-6.0.12.tgz new file mode 100644 index 00000000..60c7217e Binary files /dev/null and b/packages-cache/@graphql-tools-resolvers-composition-6.0.12.tgz differ diff --git a/packages-cache/@graphql-tools-stitch-6.0.12.tgz b/packages-cache/@graphql-tools-stitch-6.0.12.tgz new file mode 100644 index 00000000..cfca0beb Binary files /dev/null and b/packages-cache/@graphql-tools-stitch-6.0.12.tgz differ diff --git a/packages-cache/apollo-upload-client-13.0.0.tgz b/packages-cache/apollo-upload-client-13.0.0.tgz new file mode 100644 index 00000000..5f2968fb Binary files /dev/null and b/packages-cache/apollo-upload-client-13.0.0.tgz differ diff --git a/packages-cache/axios-0.19.2.tgz b/packages-cache/axios-0.19.2.tgz new file mode 100644 index 00000000..84cc0d0f Binary files /dev/null and b/packages-cache/axios-0.19.2.tgz differ diff --git a/packages-cache/cbor-5.0.2.tgz b/packages-cache/cbor-5.0.2.tgz new file mode 100644 index 00000000..0df6b0d1 Binary files /dev/null and b/packages-cache/cbor-5.0.2.tgz differ diff --git a/packages-cache/cbor-body-parser-1.0.2.tgz b/packages-cache/cbor-body-parser-1.0.2.tgz new file mode 100644 index 00000000..7edafd4a Binary files /dev/null and b/packages-cache/cbor-body-parser-1.0.2.tgz differ diff --git a/packages-cache/extract-files-8.1.0.tgz b/packages-cache/extract-files-8.1.0.tgz new file mode 100644 index 00000000..c6433bdf Binary files /dev/null and b/packages-cache/extract-files-8.1.0.tgz differ diff --git a/packages-cache/follow-redirects-1.5.10.tgz b/packages-cache/follow-redirects-1.5.10.tgz new file mode 100644 index 00000000..93a75427 Binary files /dev/null and b/packages-cache/follow-redirects-1.5.10.tgz differ diff --git a/packages-cache/fs-capacitor-6.2.0.tgz b/packages-cache/fs-capacitor-6.2.0.tgz new file mode 100644 index 00000000..9effeb14 Binary files /dev/null and b/packages-cache/fs-capacitor-6.2.0.tgz differ diff --git a/packages-cache/graphql-iso-date-3.6.1.tgz b/packages-cache/graphql-iso-date-3.6.1.tgz new file mode 100644 index 00000000..0535474e Binary files /dev/null and b/packages-cache/graphql-iso-date-3.6.1.tgz differ diff --git a/packages-cache/graphql-tools-6.0.12.tgz b/packages-cache/graphql-tools-6.0.12.tgz new file mode 100644 index 00000000..c98f5bed Binary files /dev/null and b/packages-cache/graphql-tools-6.0.12.tgz differ diff --git a/packages-cache/graphql-upload-11.0.0.tgz b/packages-cache/graphql-upload-11.0.0.tgz new file mode 100644 index 00000000..e33daed1 Binary files /dev/null and b/packages-cache/graphql-upload-11.0.0.tgz differ diff --git a/packages-cache/isobject-4.0.0.tgz b/packages-cache/isobject-4.0.0.tgz new file mode 100644 index 00000000..d3ee7dde Binary files /dev/null and b/packages-cache/isobject-4.0.0.tgz differ diff --git a/packages-cache/lodash-4.17.15.tgz b/packages-cache/lodash-4.17.15.tgz new file mode 100644 index 00000000..d0f7e90f Binary files /dev/null and b/packages-cache/lodash-4.17.15.tgz differ diff --git a/packages-cache/nofilter-1.0.3.tgz b/packages-cache/nofilter-1.0.3.tgz new file mode 100644 index 00000000..6eec4a8c Binary files /dev/null and b/packages-cache/nofilter-1.0.3.tgz differ diff --git a/packages/api-cardano-node/.gitignore b/packages/api-cardano-node/.gitignore new file mode 100644 index 00000000..1982b2b9 --- /dev/null +++ b/packages/api-cardano-node/.gitignore @@ -0,0 +1 @@ +src/graphql_types.ts diff --git a/packages/api-cardano-node/LICENSE b/packages/api-cardano-node/LICENSE new file mode 100644 index 00000000..31625f3f --- /dev/null +++ b/packages/api-cardano-node/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright © 2020 IOHK + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/api-cardano-node/NOTICE b/packages/api-cardano-node/NOTICE new file mode 100644 index 00000000..a9619c8b --- /dev/null +++ b/packages/api-cardano-node/NOTICE @@ -0,0 +1,5 @@ +Copyright 2020 IOHK + +Licensed under the Apache License, Version 2.0 (the "License”). You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. \ No newline at end of file diff --git a/packages/api-cardano-node/README.md b/packages/api-cardano-node/README.md new file mode 100644 index 00000000..6804cf67 --- /dev/null +++ b/packages/api-cardano-node/README.md @@ -0,0 +1,3 @@ +# Cardano GraphQL - API Cardano Node + +This API module interfaces with Cardano Node, via [Cardano CLI](https://hasura.io/). \ No newline at end of file diff --git a/packages/api-cardano-node/codegen.yml b/packages/api-cardano-node/codegen.yml new file mode 100644 index 00000000..0726e753 --- /dev/null +++ b/packages/api-cardano-node/codegen.yml @@ -0,0 +1,12 @@ +schema: ./schema.graphql +overwrite: true +generates: + ./src/graphql_types.ts: + config: + useIndexSignature: true + scalars: + Upload: "Promise" + plugins: + - add: 'import { FileUpload } from "graphql-upload";' + - typescript + - typescript-resolvers diff --git a/packages/api-cardano-node/package.json b/packages/api-cardano-node/package.json new file mode 100644 index 00000000..ec7bcb48 --- /dev/null +++ b/packages/api-cardano-node/package.json @@ -0,0 +1,57 @@ +{ + "name": "@cardano-graphql/api-cardano-node", + "version": "1.0.0", + "description": "Module for interfacing with Cardano Node", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "yarn codegen && tsc -b ./src", + "codegen": "graphql-codegen", + "cleanup": "shx rm -rf dist node_modules src/graphql_types.ts", + "lint": "eslint --ignore-path ../../.eslintignore \"**/*.ts\"", + "prepack": "yarn build", + "test": "yarn build && NODE_ENV=test jest -c ./test/jest.config.js graphql" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/input-output-hk/cardano-graphql.git" + }, + "author": "Rhys Bartels-Waller", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/input-output-hk/cardano-graphql/issues" + }, + "homepage": "https://github.com/input-output-hk/cardano-graphql/blob/master/packages/api-cardano-node/README.md", + "files": [ + "dist/*", + "!dist/__test__", + "!dist/**/*.test.*", + "hasura", + "LICENSE", + "NOTICE", + "schema.graphql" + ], + "dependencies": { + "@cardano-graphql/util": "1.0.0", + "@graphql-tools/delegate": "^6.0.10", + "@graphql-tools/schema": "^6.0.9", + "@graphql-tools/wrap": "^6.0.9", + "apollo-link": "^1.2.14", + "apollo-link-http": "^1.5.17", + "apollo-link-retry": "^2.2.16", + "apollo-server-errors": "^2.4.2", + "cross-fetch": "^3.0.4", + "form-data": "^3.0.0", + "graphql": "14.5.8", + "graphql-bigint": "^1.0.0", + "graphql-iso-date": "^3.6.1", + "graphql-tools": "^6.0.11", + "graphql-upload": "^11.0.0", + "p-retry": "^4.2.0", + "tmp-promise": "^3.0.2" + }, + "devDependencies": { + "@cardano-graphql/util-dev": "1.0.0", + "@graphql-codegen/add": "^1.16.0" + } +} diff --git a/packages/api-cardano-node/schema.graphql b/packages/api-cardano-node/schema.graphql new file mode 100644 index 00000000..8d40b964 --- /dev/null +++ b/packages/api-cardano-node/schema.graphql @@ -0,0 +1,25 @@ +schema { + mutation: Mutation + query: Query +} + +scalar Upload + +type Mutation { + # Submit a serialized transaction to the network + submitTransaction (file: Upload!): SubmitResponse! +} + +type Query { + node: NodeTip! +} + +type NodeTip { + hash: String! + number: Int! + slotNo: Int! +} + +type SubmitResponse { + id: String! +} \ No newline at end of file diff --git a/packages/api-cardano-node/src/.eslintrc.js b/packages/api-cardano-node/src/.eslintrc.js new file mode 100644 index 00000000..5605db3e --- /dev/null +++ b/packages/api-cardano-node/src/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + "extends": ["../../../.eslintrc.js"], + "parserOptions": { + "project": "./tsconfig.json", + "tsconfigRootDir": __dirname + } +} \ No newline at end of file diff --git a/packages/api-cardano-node/src/cli.ts b/packages/api-cardano-node/src/cli.ts new file mode 100644 index 00000000..dc62b793 --- /dev/null +++ b/packages/api-cardano-node/src/cli.ts @@ -0,0 +1,89 @@ +import { exec, execSync } from 'child_process' + +export type Address = String + +export interface Settings { + testnet: string + cardanoCli: string +} + +export type Tip = { + blockNo: number, + headerHash: String, + slotNo: number +} + +export type UTXO = { + TxHash: String, + TxIx: number, + Lovelace: number +} + +export class Client { + testnet: string + cardanoCli: string + + constructor (settings: Settings) { + this.testnet = settings.testnet + this.cardanoCli = settings.cardanoCli + } + + getTipSync (): Tip { + const stdout = execSync(`${this.cardanoCli} shelley query tip ${this.testnet}`).toString() + return JSON.parse(stdout) + } + + getTip (): Promise { + return new Promise((resolve, reject) => { + exec(`${this.cardanoCli} shelley query tip ${this.testnet}`, (error, stdout, stderr) => { + if (error) { + reject(error) + } else if (stderr.toString() !== '') { + reject(new Error(stderr.toString())) + } else { + resolve(JSON.parse(stdout)) + } + }) + }) + } + + /** + * Currently this CLI command does not return anything, if we want to get the id we need to check the UTXO after some time + * @param txBodyFile the path to the signed tx file + */ + submitTransactionSync (txBodyFile: String): string { + return execSync(`${this.cardanoCli} shelley transaction submit --tx-file ${txBodyFile} ${this.testnet}`).toString() + } + + /** + * Currently this CLI command does not return anything, if we want to get the id we need to check the UTXO after some time + * @param txBodyFile the path to the signed tx file + */ + submitTransaction (txBodyFile: String): Promise { + return new Promise((resolve, reject) => { + exec(`${this.cardanoCli} shelley transaction submit --tx-file ${txBodyFile} ${this.testnet}`, (error, stdout, stderr) => { + if (error) { + reject(error) + } else if (stderr.toString() !== '') { + reject(new Error(stderr.toString())) + } else { + resolve(stdout) + } + }) + }) + } + + getUTXO (address: Address): Array { + const stdout = execSync(`${this.cardanoCli} shelley query utxo --address ${address} --testnet-magic 42`).toString() + const rowToUtxo = function (row: string) { + const fields = row.trim().split(/\W+/) + return { + TxHash: fields[0], + TxIx: Number.parseInt(fields[1]), + Lovelace: Number.parseInt(fields[2]) + } + } + const utxos = stdout.trim().split('\n').slice(2).map(rowToUtxo) + return utxos + } +} diff --git a/packages/api-cardano-node/src/example_queries/submitTransaction.graphql b/packages/api-cardano-node/src/example_queries/submitTransaction.graphql new file mode 100644 index 00000000..2514a209 --- /dev/null +++ b/packages/api-cardano-node/src/example_queries/submitTransaction.graphql @@ -0,0 +1,5 @@ +mutation submitTransaction( + $file: Upload! +) { + submitTransaction(file: $file) +} \ No newline at end of file diff --git a/packages/api-cardano-node/src/executableSchema.ts b/packages/api-cardano-node/src/executableSchema.ts new file mode 100644 index 00000000..020119e2 --- /dev/null +++ b/packages/api-cardano-node/src/executableSchema.ts @@ -0,0 +1,35 @@ +import fs from 'fs' +import path from 'path' +import { makeExecutableSchema } from 'graphql-tools' +import { Resolvers } from './graphql_types' +import { saveReadStream, throwIfInvalidContentType } from './uploads' +import { Tip, Settings, Client } from './cli' + +export function buildSchema (settings: Settings) { + const client = new Client(settings) + return makeExecutableSchema({ + resolvers: { + Mutation: { + submitTransaction: async (_root, { file }, _context) => { + const fullFile = await file + const { createReadStream, mimetype } = fullFile + throwIfInvalidContentType(mimetype) + const txFile = await saveReadStream(createReadStream()) + return client.submitTransaction(txFile.path).then((stdout: String) => { + return { id: stdout } + }) + } + }, + Query: { + node: () => client.getTip().then((tip: Tip) => { + return { + hash: tip.headerHash.toString(), + number: tip.blockNo, + slotNo: tip.slotNo + } + }) + } + } as Resolvers, + typeDefs: fs.readFileSync(path.resolve(__dirname, '..', 'schema.graphql'), 'utf-8') + }) +} diff --git a/packages/api-cardano-node/src/index.ts b/packages/api-cardano-node/src/index.ts new file mode 100644 index 00000000..57a3bda0 --- /dev/null +++ b/packages/api-cardano-node/src/index.ts @@ -0,0 +1,3 @@ +export * from './executableSchema' +export * from './graphql_types' +export * from './cli' diff --git a/packages/api-cardano-node/src/tsconfig.json b/packages/api-cardano-node/src/tsconfig.json new file mode 100644 index 00000000..8e253db5 --- /dev/null +++ b/packages/api-cardano-node/src/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../dist/", + "rootDir": "." + }, + "references": [{ "path": "../../util/src" }] +} \ No newline at end of file diff --git a/packages/api-cardano-node/src/uploads.ts b/packages/api-cardano-node/src/uploads.ts new file mode 100644 index 00000000..6c8cd6b3 --- /dev/null +++ b/packages/api-cardano-node/src/uploads.ts @@ -0,0 +1,22 @@ +import { FileUpload } from 'graphql-upload' +import { UserInputError } from 'apollo-server-errors' +import tmp, { FileResult } from 'tmp-promise' +import fs, { ReadStream } from 'fs' + +export function throwIfInvalidContentType (mimetype: FileUpload['mimetype']): void { + const validContentType = 'application/cbor' + if (mimetype !== validContentType) { + throw new UserInputError(`Invalid content type ${mimetype}. Must be ${validContentType}`) + } +} + +export async function saveReadStream (readStream: ReadStream): Promise { + const fileResult = await tmp.file() + const writeStream = fs.createWriteStream(fileResult.path) + readStream.pipe(writeStream) + return new Promise((resolve) => { + readStream.on('end', () => { + resolve(fileResult) + }) + }) +} diff --git a/packages/api-cardano-node/test/.eslintrc.js b/packages/api-cardano-node/test/.eslintrc.js new file mode 100644 index 00000000..57d007c1 --- /dev/null +++ b/packages/api-cardano-node/test/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + "extends": ["../../../test/.eslintrc.js"], + "parserOptions": { + "project": "./tsconfig.json", + "tsconfigRootDir": __dirname + } +} diff --git a/packages/api-cardano-node/test/cli.test.ts b/packages/api-cardano-node/test/cli.test.ts new file mode 100644 index 00000000..d9d208e4 --- /dev/null +++ b/packages/api-cardano-node/test/cli.test.ts @@ -0,0 +1,29 @@ +/* eslint-disable quotes */ + +import fs from 'fs' +import { cleanTestData, createTransaction } from './transactionUtil' +import { execSync } from 'child_process' + +describe('CLI', () => { + it('submits a signed transaction to the network using CLI', () => { + const fromAddr = fs.readFileSync('../../app/payment.addr').toString().trim() + const toAddr = fs.readFileSync('../../app/payment2.addr').toString().trim() + const settings = { + timeLimit: 300, // I can't find out how to work this out but it seems if you set it to 30 it's too low + fromAddr, + toAddr, + signingKeyFile: '/app/payment.skey' + } + cleanTestData() + const { txSignedFile, client } = createTransaction(settings) + client.submitTransactionSync(txSignedFile) + // wait for some time to allow the tx to succeed + execSync(`sleep 10`) + // we check that the transaction has been successful by checking that the to address has it + const fromUTXOs = client.getUTXO(fromAddr).map(data => data.TxHash) + const toUTXOs = client.getUTXO(toAddr).map(data => data.TxHash) + const index = toUTXOs.findIndex(v => v === fromUTXOs[0]) + const toUTXO = toUTXOs[index] + expect(toUTXO).toBeDefined() + }) +}) diff --git a/packages/api-cardano-node/test/graphql.test.ts b/packages/api-cardano-node/test/graphql.test.ts new file mode 100644 index 00000000..a8c11888 --- /dev/null +++ b/packages/api-cardano-node/test/graphql.test.ts @@ -0,0 +1,62 @@ +/* eslint-disable quotes */ + +import fs from 'fs' +import util from '@cardano-graphql/util' +import utilDev from '@cardano-graphql/util-dev' +import { cleanTestData, createTransaction, getTransactionFileUpload } from './transactionUtil' +import FormData from 'form-data' +import fetch from 'node-fetch' +import { execSync } from 'child_process' + +describe('graphql', () => { + it('submits a signed transaction to the network using graphql', async () => { + const graphqlClient = await utilDev.createE2EClient() + const tip = await graphqlClient.query({ + query: util.getTip() + }) + expect(tip.data.node.hash).toBeDefined() + // FIXME: local files + const fromAddr = fs.readFileSync('../../app/payment.addr').toString().trim() + const toAddr = fs.readFileSync('../../app/payment2.addr').toString().trim() + const settings = { + timeLimit: 300, // I can't find out how to work this out but it seems if you set it to 30 it's too low + fromAddr, + toAddr, + signingKeyFile: '/app/payment.skey' + } + cleanTestData() + const { txSignedFile, client } = createTransaction(settings) + const fileContents = getTransactionFileUpload(txSignedFile) + const body = new FormData() + body.append( + 'operations', + JSON.stringify({ + variables: { + file: null + }, + query: `mutation($tx: Upload!){ + submitTransaction(file: $tx){ + id + } + }` + }) + ) + body.append('map', JSON.stringify({ 0: ['variables.tx'] })) + body.append('0', fileContents, { filename: 'tx', contentType: 'application/cbor' }) + + // Upload the file + const result = await fetch('http://localhost:3100/', { + method: 'POST', + body: body + }) + expect(result.status).toEqual(200) + // wait for some time to allow the tx to succeed + execSync(`sleep 10`) + // we check that the transaction has been successful by checking that the to address has it + const fromUTXOs = client.getUTXO(fromAddr).map(data => data.TxHash) + const toUTXOs = client.getUTXO(toAddr).map(data => data.TxHash) + const index = toUTXOs.findIndex(v => v === fromUTXOs[0]) + const toUTXO = toUTXOs[index] + expect(toUTXO).toBeDefined() + }) +}) diff --git a/packages/api-cardano-node/test/jest.config.js b/packages/api-cardano-node/test/jest.config.js new file mode 100644 index 00000000..412502a6 --- /dev/null +++ b/packages/api-cardano-node/test/jest.config.js @@ -0,0 +1,13 @@ +const { pathsToModuleNameMapper } = require('ts-jest/utils'); +const { compilerOptions } = require('./tsconfig'); + +module.exports = { + moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths), + preset: 'ts-jest', + transform: { + "^.+\\.test.ts?$": "ts-jest" + }, + verbose: true, + maxWorkers: 1, + testTimeout: 30000 +} diff --git a/packages/api-cardano-node/test/transactionUtil.ts b/packages/api-cardano-node/test/transactionUtil.ts new file mode 100644 index 00000000..6bb52891 --- /dev/null +++ b/packages/api-cardano-node/test/transactionUtil.ts @@ -0,0 +1,113 @@ +/* eslint-disable quotes */ + +import { execSync } from 'child_process' +import { Tip, Client, Address, UTXO } from '@src/cli' + +/** + * A lot of things in this file are set up so that you can run the tests either in the graphql docker container or + * locally by using docker exec. For example you can run `TEST_CMD_PREFIX='docker exec -t d429046f80f2' yarn test` + */ +const cmdPrefix = process.env.TEST_CMD_PREFIX +const cardanoCli = `${cmdPrefix} cardano-cli` +const rm = `${cmdPrefix} rm` +const cat = `${cmdPrefix} cat` +const testnet = `--testnet-magic ${process.env.CARDANO_MAGIC || '42'}` +const client = new Client({ testnet, cardanoCli }) + +interface ISlotRate { + rate: number +} + +type TxOut = { + address: Address, + change: number +} + +function txOutString (txOut: TxOut): String { + return txOut.address + '+' + txOut.change.toString() +} + +function txInString (utxo: UTXO): String { + return utxo.TxHash + '#' + utxo.TxIx.toString() +} + +function createProtocolParams (outFile: string) { + execSync(`${cardanoCli} shelley query protocol-parameters --testnet-magic 42 --out-file ${outFile}`).toString() +} + +function calculateTTL (tip: Tip, slotRate: ISlotRate, limit: number): number { + return tip.slotNo + (slotRate.rate * limit) +} + +function calculateChange (from: UTXO, amount: number, fee: number): number { + return from.Lovelace - amount - fee +} + +function buildTransaction (utxoIn: UTXO, from: TxOut, to: TxOut, ttl: number, fee: number, txOutFile: String) { + const txIn = txInString(utxoIn) + const txOutFrom = txOutString(from) + const txOutTo = txOutString(to) + execSync(`${cardanoCli} shelley transaction build-raw --tx-in ${txIn} --tx-out ${txOutFrom} --tx-out ${txOutTo} --ttl ${ttl} --fee ${fee} --out-file ${txOutFile}`).toString() +} + +function calculateFee (txBodyFile: String, protocolParamsFile: String): number { + const stdout = execSync(`${cardanoCli} shelley transaction calculate-min-fee --tx-body-file ${txBodyFile} --tx-in-count 1 --tx-out-count 2 --testnet-magic 42 --protocol-params-file ${protocolParamsFile} --witness-count 0 --byron-witness-count 0`).toString() + return Number.parseInt(stdout.replace('Lovelace', '').trim()) +} + +function signTransaction (txBodyFile: String, signingKeyFile: String, txOutFile: String) { + execSync(`${cardanoCli} shelley transaction sign --tx-body-file ${txBodyFile} --signing-key-file ${signingKeyFile} --testnet-magic 42 --out-file ${txOutFile}`).toString() +} + +type Settings = { + timeLimit: number + fromAddr: string + toAddr: string + signingKeyFile: string +} + +export type TestData = { + txSignedFile: string + client: Client +} + +/** + * We want to get rid of any data from previous tests to avoid confusion + */ +export function cleanTestData () { + execSync(`${rm} tx.signed || true`) + execSync(`${rm} tx.raw || true`) + execSync(`${rm} protocol.json || true`) + execSync(`${rm} tx-no-fee || true`) +} + +/** + * Create a new, signed transaction that can be submitted + * @param settings Test Settings + */ +export function createTransaction (settings: Settings): TestData { + const paymentAmount = 10 + const protocolFile = 'protocol.json' + createProtocolParams(protocolFile) + const tip = client.getTipSync() + const slotRate = { rate: 1 } // I don't currently know where to get this number from + const ttl = calculateTTL(tip, slotRate, settings.timeLimit) + const fromUtxo = client.getUTXO(settings.fromAddr)[0] + const balanceWithoutFee = calculateChange(fromUtxo, paymentAmount, 0) + const txOutFrom = { address: settings.fromAddr, change: balanceWithoutFee } + const txOutTo = { address: settings.toAddr, change: paymentAmount } + const txNoFeeFile = 'tx-no-fee.raw' + buildTransaction(fromUtxo, txOutFrom, txOutTo, ttl, 0, txNoFeeFile) + const fee = calculateFee(txNoFeeFile, protocolFile) + const txWithFeeFile = 'tx.raw' + const balanceWithFee = calculateChange(fromUtxo, paymentAmount, fee) + const txOutFromWithFee = { address: settings.fromAddr, change: balanceWithFee } + buildTransaction(fromUtxo, txOutFromWithFee, txOutTo, ttl, fee, txWithFeeFile) + const txSignedFile = 'tx.signed' + signTransaction(txWithFeeFile, settings.signingKeyFile, txSignedFile) + return { txSignedFile, client } +} + +export function getTransactionFileUpload (txFile: string): string { + return execSync(`${cat} ${txFile}`).toString() +} diff --git a/packages/api-cardano-node/test/tsconfig.json b/packages/api-cardano-node/test/tsconfig.json new file mode 100644 index 00000000..bfb01bd4 --- /dev/null +++ b/packages/api-cardano-node/test/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@src/*": ["../src/*"] + } + }, + "references": [ + { "path": "../src"}, + { "path": "../../util-dev/src"} + ] +} \ No newline at end of file diff --git a/packages/api-cardano-node/test/util.ts b/packages/api-cardano-node/test/util.ts new file mode 100644 index 00000000..a16f847f --- /dev/null +++ b/packages/api-cardano-node/test/util.ts @@ -0,0 +1,14 @@ +import utilDev from '@cardano-graphql/util-dev' +import { buildSchema } from '@src/executableSchema' + +export async function buildClient () { + if (process.env.TEST_MODE === 'e2e') { + return utilDev.createE2EClient() + } else { + const cardanoCli = process.env.CARDANO_CLI_CMD ? process.env.CARDANO_CLI_CMD : 'cardano-cli' + const testnet = `--testnet-magic ${process.env.CARDANO_MAGIC || '42'}` + const settings = { testnet, cardanoCli } + const schema = buildSchema(settings) + return utilDev.createIntegrationClient(schema) + } +} diff --git a/packages/server/package.json b/packages/server/package.json index 7fb53a1d..dd564bdc 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -25,12 +25,14 @@ "homepage": "https://github.com/input-output-hk/cardano-graphql/blob/master/packages/server/README.md", "dependencies": { "@cardano-graphql/api-cardano-db-hasura": "1.0.0", + "@cardano-graphql/api-cardano-node": "1.0.0", "@cardano-graphql/api-genesis": "1.0.0", "@graphql-tools/merge": "^6.0.10", "apollo-metrics": "^1.0.1", "apollo-server-core": "^2.14.3", "apollo-server-errors": "^2.4.1", "apollo-server-express": "^2.14.3", + "cbor-body-parser": "^1.0.2", "cors": "^2.8.5", "express": "^4.17.1", "graphql": "14.5.8", @@ -43,6 +45,7 @@ "@types/graphql-depth-limit": "^1.1.2", "@types/node": "^14.0.13", "shx": "^0.3.2", + "cbor-body-parser": "^1.0.2", "typescript": "^3.9.5" }, "directories": { diff --git a/packages/server/src/config.ts b/packages/server/src/config.ts index c25ef2d8..2add6944 100644 --- a/packages/server/src/config.ts +++ b/packages/server/src/config.ts @@ -6,6 +6,7 @@ export type Config = { allowedOrigins: CorsOptions['origin'] apiPort: number cacheEnabled: boolean + cardanoNodeSocketPath: string genesisFileByron: string genesisFileShelley: string hasuraUri: string @@ -14,6 +15,8 @@ export type Config = { queryDepthLimit: number tracing: boolean whitelistPath: string + testnet: string + cardanoCli: string } export async function getConfig (): Promise { @@ -22,6 +25,7 @@ export async function getConfig (): Promise { allowedOrigins, apiPort, cacheEnabled, + cardanoNodeSocketPath, genesisFileByron, genesisFileShelley, hasuraUri, @@ -29,9 +33,13 @@ export async function getConfig (): Promise { prometheusMetrics, queryDepthLimit, tracing, - whitelistPath + whitelistPath, + testnet, + cardanoCli } = filterAndTypecastEnvs(process.env) - + if (!cardanoNodeSocketPath) { + throw new MissingConfig('CARDANO_NODE_SOCKET_PATH env not set') + } if (!hasuraUri && !genesisFileShelley) { throw new MissingConfig('You have not provided configuration to load an API segment. Either set HASURA_URI or GENESIS_FILE_SHELLEY') } @@ -46,6 +54,7 @@ export async function getConfig (): Promise { allowedOrigins: allowedOrigins || true, apiPort: apiPort || 3100, cacheEnabled: cacheEnabled || false, + cardanoNodeSocketPath, genesisFileByron, genesisFileShelley, hasuraUri, @@ -53,7 +62,9 @@ export async function getConfig (): Promise { prometheusMetrics, queryDepthLimit: queryDepthLimit || 10, tracing, - whitelistPath + whitelistPath, + testnet, + cardanoCli } } @@ -63,6 +74,7 @@ function filterAndTypecastEnvs (env: any) { ALLOWED_ORIGINS, API_PORT, CACHE_ENABLED, + CARDANO_NODE_SOCKET_PATH, GENESIS_FILE_BYRON, GENESIS_FILE_SHELLEY, HASURA_URI, @@ -70,13 +82,16 @@ function filterAndTypecastEnvs (env: any) { PROMETHEUS_METRICS, QUERY_DEPTH_LIMIT, TRACING, - WHITELIST_PATH + WHITELIST_PATH, + CARDANO_CLI_CMD, + CARDANO_MAGIC } = env return { allowIntrospection: ALLOW_INTROSPECTION === 'true' ? true : undefined, allowedOrigins: ALLOWED_ORIGINS, apiPort: Number(API_PORT), cacheEnabled: CACHE_ENABLED === 'true' ? true : undefined, + cardanoNodeSocketPath: CARDANO_NODE_SOCKET_PATH, genesisFileByron: GENESIS_FILE_BYRON, genesisFileShelley: GENESIS_FILE_SHELLEY, hasuraUri: HASURA_URI, @@ -84,6 +99,8 @@ function filterAndTypecastEnvs (env: any) { prometheusMetrics: PROMETHEUS_METRICS === 'true' ? true : undefined, queryDepthLimit: Number(QUERY_DEPTH_LIMIT), tracing: TRACING === 'true' ? true : undefined, - whitelistPath: WHITELIST_PATH + whitelistPath: WHITELIST_PATH, + testnet: CARDANO_MAGIC ? `--testnet-magic ${CARDANO_MAGIC}` : '--mainnet', + cardanoCli: CARDANO_CLI_CMD || 'cardano-cli' } } diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index f63fe7b2..734d99a8 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -8,6 +8,7 @@ import { mergeSchemas } from '@graphql-tools/merge' import { PluginDefinition } from 'apollo-server-core' import { buildSchema as buildCardanoDbHasuraSchema, Db } from '@cardano-graphql/api-cardano-db-hasura' import { buildSchema as buildGenesisSchema } from '@cardano-graphql/api-genesis' +import { buildSchema as buildCardanoNodeSchema } from '@cardano-graphql/api-cardano-node' import { GraphQLSchema } from 'graphql' export * from './config' export { apolloServerPlugins } @@ -28,6 +29,10 @@ async function boot () { })) } + if(config.cardanoNodeSocketPath !== undefined) { + schemas.push(await buildCardanoNodeSchema(config)) + } + if (config.hasuraUri !== undefined) { const db = new Db(config.hasuraUri) await db.init() diff --git a/packages/server/src/tsconfig.json b/packages/server/src/tsconfig.json index 15ca3641..4f511602 100644 --- a/packages/server/src/tsconfig.json +++ b/packages/server/src/tsconfig.json @@ -6,6 +6,7 @@ }, "references": [ { "path": "../../api-cardano-db-hasura/src" }, - { "path": "../../api-genesis/src" } + { "path": "../../api-genesis/src" }, + { "path": "../../api-cardano-node/src" } ] } diff --git a/packages/util/src/index.ts b/packages/util/src/index.ts index 848e3d3f..05e71cc7 100644 --- a/packages/util/src/index.ts +++ b/packages/util/src/index.ts @@ -1,9 +1,11 @@ import { onFailedAttemptFor } from './onFailedAttemptFor' -import { loadQueryNode } from './queryNodeLoading' +import { loadQueryNode, getTip, submitTransaction } from './queryNodeLoading' import * as scalars from './scalars' export default { onFailedAttemptFor, loadQueryNode, + getTip, + submitTransaction, scalars } diff --git a/packages/util/src/queryNodeLoading.ts b/packages/util/src/queryNodeLoading.ts index 503c9c62..7958df65 100644 --- a/packages/util/src/queryNodeLoading.ts +++ b/packages/util/src/queryNodeLoading.ts @@ -7,3 +7,25 @@ import { DocumentNode } from 'graphql' export async function loadQueryNode (fileBasePath: string, name: string): Promise { return gql`${await fs.promises.readFile(path.join(fileBasePath, `${name}.graphql`))}` } + +export function getTip (): DocumentNode { + return gql` + query { + node { + hash + number + slotNo + } + } + ` +} + +export function submitTransaction (): DocumentNode { + return gql` + mutation($tx: Upload!){ + submitTransaction(file: $tx){ + id + } + } + ` +} diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 7a7d89e7..1f9449b2 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -6,6 +6,7 @@ STD_ARGS="--non-interactive --no-git-tag-version --sign-git-tag --new-version ${ yarn version ${STD_ARGS} --cwd ../ && \ yarn version ${STD_ARGS} --cwd ./packages/api-cardano-db-hasura && \ +yarn version ${STD_ARGS} --cwd ./packages/api-cardano-node && \ yarn version ${STD_ARGS} --cwd ./packages/api-genesis && \ yarn version ${STD_ARGS} --cwd ./packages/cli && \ yarn version ${STD_ARGS} --cwd ./packages/client-ts && \ diff --git a/scripts/publish_packages.sh b/scripts/publish_packages.sh index d57cb817..eb44c125 100755 --- a/scripts/publish_packages.sh +++ b/scripts/publish_packages.sh @@ -3,6 +3,7 @@ set -euo pipefail npm publish --cwd ./packages/api-cardano-db-hasura && \ +npm publish --cwd ./packages/api-cardano-node && \ npm publish --cwd ./packages/api-genesis && \ npm publish --cwd ./packages/cli && \ npm publish --cwd ./packages/client-ts && \ diff --git a/yarn.lock b/yarn.lock index 1bbe1247..eec85d66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -521,6 +521,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.9.2": + version "7.10.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.5.tgz#303d8bd440ecd5a491eae6117fd3367698674c5c" + integrity sha512-otddXKhdNn7d0ptoFRHtMLa8LqDxLYwTjB4nYgM1yy5N6gU/MUf8zqyyLltCH3yAVitBzmwK4us+DD0l/MauAg== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.10.4", "@babel/template@^7.3.3": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278" @@ -567,6 +574,14 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@graphql-codegen/add@^1.16.0", "@graphql-codegen/add@^1.16.3": + version "1.16.3" + resolved "https://registry.yarnpkg.com/@graphql-codegen/add/-/add-1.16.3.tgz#4b94d66646d4e4e1b5cad17119430423b7d31a11" + integrity sha512-UDJWHrBDifZ93pV/SaWf5L2gGKHE7/tLWQNHaT9iYmh7Fcel2XNyIJbwSQIOJQqrChzyUAqYBqrFOumXA9ipmQ== + dependencies: + "@graphql-codegen/plugin-helpers" "1.16.3" + tslib "~2.0.0" + "@graphql-codegen/cli@^1.15.2": version "1.16.2" resolved "https://registry.yarnpkg.com/@graphql-codegen/cli/-/cli-1.16.2.tgz#ff92e5e6813a404616d7504500be26ff88b7092d" @@ -642,6 +657,22 @@ tslib "~2.0.0" upper-case "2.0.1" +"@graphql-codegen/plugin-helpers@1.16.3": + version "1.16.3" + resolved "https://registry.yarnpkg.com/@graphql-codegen/plugin-helpers/-/plugin-helpers-1.16.3.tgz#84ce27449d454eeeb90f0040d6c8d2fd3fad967b" + integrity sha512-uhDOdY4KVtTGjnv8Ivr9C4OOcSIiD1cYsqFDll0Vv6F21/KM7N+zIMbHutnJ6BKWOJKzsn0DBBX0TNBJ32HCRA== + dependencies: + "@graphql-tools/utils" "^6.0.0" + camel-case "4.1.1" + common-tags "1.8.0" + constant-case "3.0.3" + import-from "3.0.0" + lower-case "2.0.1" + param-case "3.0.3" + pascal-case "3.1.1" + tslib "~2.0.0" + upper-case "2.0.1" + "@graphql-codegen/typescript-graphql-files-modules@^1.15.2": version "1.16.2" resolved "https://registry.yarnpkg.com/@graphql-codegen/typescript-graphql-files-modules/-/typescript-graphql-files-modules-1.16.2.tgz#3ac60a5ab9b55ab4f0e9daaf8b4cd8fa4e924a23" @@ -696,7 +727,7 @@ cross-fetch "3.0.5" tslib "~2.0.0" -"@graphql-tools/code-file-loader@^6.0.0": +"@graphql-tools/code-file-loader@6.0.12", "@graphql-tools/code-file-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/code-file-loader/-/code-file-loader-6.0.12.tgz#97721808d996f57b266d48980cc33a6ccbc0a9fc" integrity sha512-rr9+8ALI8rpZxXtYHbaYexgwKYUulWDRZAkTr1noPjutZR5712yOqyd1oV6s1aP3wMRZZ42m07jHiiGZOpEI6g== @@ -716,7 +747,7 @@ "@graphql-tools/utils" "6.0.12" tslib "~2.0.0" -"@graphql-tools/git-loader@^6.0.0": +"@graphql-tools/git-loader@6.0.12", "@graphql-tools/git-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/git-loader/-/git-loader-6.0.12.tgz#bbea61e06a517362649889498f6abdf7e82e9240" integrity sha512-zhBOiwPjlb7HFn8jAi8YwCOrM9uP4IJTH0IIAPQg/vRxLWD+JDUcD7fne5QNPWevTGWxyZ7vb+CsWb5JBUUDqg== @@ -725,7 +756,7 @@ "@graphql-tools/utils" "6.0.12" simple-git "2.11.0" -"@graphql-tools/github-loader@^6.0.0": +"@graphql-tools/github-loader@6.0.12", "@graphql-tools/github-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/github-loader/-/github-loader-6.0.12.tgz#f6a61811d68c66789fedc79a875ec0eb2f0cc81f" integrity sha512-KGVT+gZyLqyfRgoU/59UPEkg4c1HchVp4JARnYIBz3YHQBh50I+OckP/GjApMg2DBjJXtWuCFpZpoOcj9xOt6w== @@ -734,7 +765,7 @@ "@graphql-tools/utils" "6.0.12" cross-fetch "3.0.5" -"@graphql-tools/graphql-file-loader@^6.0.0": +"@graphql-tools/graphql-file-loader@6.0.12", "@graphql-tools/graphql-file-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/graphql-file-loader/-/graphql-file-loader-6.0.12.tgz#7c9d25d7208d520a973960940d36ec33dc1749b1" integrity sha512-DUoby0HXQ5fGR9U3tMN3V/6l1XdRzg2XF0kuZy/9TUEH9VBFKYT7PLEVb6ZKDh9xWe0OgHUjgpfJhjtcJwn+fw== @@ -764,7 +795,7 @@ fs-extra "9.0.1" resolve-from "5.0.0" -"@graphql-tools/json-file-loader@^6.0.0": +"@graphql-tools/json-file-loader@6.0.12", "@graphql-tools/json-file-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/json-file-loader/-/json-file-loader-6.0.12.tgz#5a66ead3b27664ec6321171eacb1ac54721b8468" integrity sha512-WLSqEfcHcu8LYMdtz3ipzu3CdlkhuHqvuCmCUt5Yq3SvLhWXu+39BLVS6FtfQdNAdM2Bl+C7YRrYYsDA9Rzeag== @@ -773,7 +804,28 @@ fs-extra "9.0.1" tslib "~2.0.0" -"@graphql-tools/load@^6.0.0": +"@graphql-tools/links@6.0.12": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@graphql-tools/links/-/links-6.0.12.tgz#3ec0195620b78de1defa9d16dbd54aeef15cc933" + integrity sha512-G2VwNUSPcz9c17VTS32b35sMjyKS/dwnMh/0DPZOpoc04Y4MnvNnxWEIy4LnKJ3RXXTB3LJuZivtTy7siyj4ug== + dependencies: + "@graphql-tools/utils" "6.0.12" + apollo-link "1.2.14" + apollo-upload-client "13.0.0" + cross-fetch "3.0.5" + form-data "3.0.0" + tslib "~2.0.0" + +"@graphql-tools/load-files@6.0.12": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@graphql-tools/load-files/-/load-files-6.0.12.tgz#58ee50302d55c2651fa602431db207ca8f329dad" + integrity sha512-6EEeE3xMhY34TFCew+kDBtF5JP0dIu7jWwQ96ZxJ56OhYuWxD+T3WHmtbqkgv3MIplPberSObjWiWol+uvZ0cA== + dependencies: + fs-extra "9.0.1" + globby "11.0.1" + unixify "1.0.0" + +"@graphql-tools/load@6.0.12", "@graphql-tools/load@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/load/-/load-6.0.12.tgz#3f40a5aae35d880e55fc52f797c861d868a47fdc" integrity sha512-BlGptzuY6+/SunejobN+P3RTxl5QKiMrIikttUZROrgObOBlkSFxsjW1cOw+HX2BL4dPUyN9usOKYoMxKHoWpA== @@ -797,6 +849,23 @@ "@graphql-tools/utils" "6.0.12" tslib "~2.0.0" +"@graphql-tools/mock@6.0.12": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@graphql-tools/mock/-/mock-6.0.12.tgz#3f140802d37f58b2d235b9ea1cc358945b2530cf" + integrity sha512-g4QEoUNusHAHRGRAl9p/jR06efcWoes48qsMq1bWuJJiSX4N6OepHzWVDZqDWD5RwuPVv8ugvVXLeSFRWZQDbQ== + dependencies: + "@graphql-tools/schema" "6.0.12" + "@graphql-tools/utils" "6.0.12" + tslib "~2.0.0" + +"@graphql-tools/module-loader@6.0.12": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@graphql-tools/module-loader/-/module-loader-6.0.12.tgz#a1338e6e2131a16bb1f8eaa3b67011ee0fe9340f" + integrity sha512-CAYdAlnNPyr+Ja2HKXunQbdWGkf/hoPh4KDLKOe1apL3n/518icmdBC2Sjs0SfEDOl0B9Q8hx19GgCGFn/WdVA== + dependencies: + "@graphql-tools/utils" "6.0.12" + tslib "~2.0.0" + "@graphql-tools/prisma-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/prisma-loader/-/prisma-loader-6.0.12.tgz#30b639236138a1db2c33a9a39a53abcc0be64e91" @@ -816,6 +885,14 @@ "@graphql-tools/utils" "6.0.12" relay-compiler "9.1.0" +"@graphql-tools/resolvers-composition@6.0.12": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@graphql-tools/resolvers-composition/-/resolvers-composition-6.0.12.tgz#d0ea3e9cc6e4d94ad4ce8b554622f541d954fd15" + integrity sha512-7b1Rbljh2WhZFgguEKuUzVQbysGIKaQSCQmGMm7eloZUhJ8TAtKhuoUoHl5r6LDacUngAeLe3HApCJjTGC2frA== + dependencies: + "@graphql-tools/utils" "6.0.12" + lodash "4.17.15" + "@graphql-tools/schema@6.0.12", "@graphql-tools/schema@^6.0.9": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-6.0.12.tgz#549ae14fa200cf7135e1d4f0b9e85db868cad6be" @@ -824,6 +901,18 @@ "@graphql-tools/utils" "6.0.12" tslib "~2.0.0" +"@graphql-tools/stitch@6.0.12": + version "6.0.12" + resolved "https://registry.yarnpkg.com/@graphql-tools/stitch/-/stitch-6.0.12.tgz#024e4a1035ad549677002a83191d1f993450695c" + integrity sha512-I+9l5Ws30Fn3nx0CIDUDMGP0nhexMEJyzfQn1t9DuOTy2QHPQ5YpaZ8hxv6y5+X23EJBU9AebqvNSvWNEO6XJQ== + dependencies: + "@graphql-tools/delegate" "6.0.12" + "@graphql-tools/merge" "6.0.12" + "@graphql-tools/schema" "6.0.12" + "@graphql-tools/utils" "6.0.12" + "@graphql-tools/wrap" "6.0.12" + tslib "~2.0.0" + "@graphql-tools/url-loader@6.0.12", "@graphql-tools/url-loader@^6.0.0": version "6.0.12" resolved "https://registry.yarnpkg.com/@graphql-tools/url-loader/-/url-loader-6.0.12.tgz#ea6e2e542ed0944efa8d3276c57e1979df095ecb" @@ -1937,7 +2026,7 @@ apollo-link-error@^1.0.3: apollo-link-http-common "^0.2.16" tslib "^1.9.3" -apollo-link-http-common@^0.2.16: +apollo-link-http-common@^0.2.14, apollo-link-http-common@^0.2.16: version "0.2.16" resolved "https://registry.yarnpkg.com/apollo-link-http-common/-/apollo-link-http-common-0.2.16.tgz#756749dafc732792c8ca0923f9a40564b7c59ecc" integrity sha512-2tIhOIrnaF4UbQHf7kjeQA/EmSorB7+HyJIIrUjJOKBgnXwuexi8aMecRlqTIDWcyVXCeqLhUnztMa6bOH/jTg== @@ -1964,7 +2053,7 @@ apollo-link-retry@^2.2.16: apollo-link "^1.2.14" tslib "^1.9.3" -apollo-link@^1.0.0, apollo-link@^1.0.6, apollo-link@^1.2.14: +apollo-link@1.2.14, apollo-link@^1.0.0, apollo-link@^1.0.6, apollo-link@^1.2.12, apollo-link@^1.2.14: version "1.2.14" resolved "https://registry.yarnpkg.com/apollo-link/-/apollo-link-1.2.14.tgz#3feda4b47f9ebba7f4160bef8b977ba725b684d9" integrity sha512-p67CMEFP7kOG1JZ0ZkYZwRDa369w5PIjtMjvrQd/HnIV8FRsHRqLqK+oAZQnFa1DDdZtOtHTi+aMIW6EatC2jg== @@ -2118,6 +2207,16 @@ apollo-tracing@^0.8.8: apollo-server-env "^2.4.3" graphql-extensions "^0.10.10" +apollo-upload-client@13.0.0: + version "13.0.0" + resolved "https://registry.yarnpkg.com/apollo-upload-client/-/apollo-upload-client-13.0.0.tgz#146d1ddd85d711fcac8ca97a72d3ca6787f2b71b" + integrity sha512-lJ9/bk1BH1lD15WhWRha2J3+LrXrPIX5LP5EwiOUHv8PCORp4EUrcujrA3rI5hZeZygrTX8bshcuMdpqpSrvtA== + dependencies: + "@babel/runtime" "^7.9.2" + apollo-link "^1.2.12" + apollo-link-http-common "^0.2.14" + extract-files "^8.0.0" + apollo-utilities@1.3.4, apollo-utilities@^1.0.1, apollo-utilities@^1.3.0, apollo-utilities@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/apollo-utilities/-/apollo-utilities-1.3.4.tgz#6129e438e8be201b6c55b0f13ce49d2c7175c9cf" @@ -2280,6 +2379,13 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2" integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA== +axios@^0.19.2: + version "0.19.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" + integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA== + dependencies: + follow-redirects "1.5.10" + babel-jest@^26.1.0: version "26.1.0" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.1.0.tgz#b20751185fc7569a0f135730584044d1cb934328" @@ -2457,7 +2563,7 @@ bluebird@^3.5.1: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== -body-parser@1.19.0, body-parser@^1.18.3: +body-parser@1.19.0, body-parser@^1.18.3, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== @@ -2626,6 +2732,22 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +cbor-body-parser@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cbor-body-parser/-/cbor-body-parser-1.0.2.tgz#d5221c6f28acd27f0ad60ea5617140469f37ec96" + integrity sha512-0PE2gB5mNdna6bHW0ZfBLV/7fH4/Fy+iw9EKVkBHa5QFncQsyjJoh7umPRi3TAYCnkEkIrHyOm5TtuikJOb2Tg== + dependencies: + body-parser "^1.19.0" + cbor "^5.0.2" + +cbor@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-5.0.2.tgz#aa8c3820280ebb9f3a45b2a4c66ac344294443de" + integrity sha512-6JiKVURxxO92FntzTJq54QdN/8fBaBwD7+nNyGIAi1HL9mBgU3YK6ULV8k7WTuT/EwfRsjy3MuqDKlkQMCmfXg== + dependencies: + bignumber.js "^9.0.0" + nofilter "^1.0.3" + chalk@4.1.0, chalk@^4.0.0, chalk@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" @@ -3084,7 +3206,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: dependencies: ms "2.0.0" -debug@3.1.0: +debug@3.1.0, debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -3836,6 +3958,11 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" +extract-files@^8.0.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/extract-files/-/extract-files-8.1.0.tgz#46a0690d0fe77411a2e3804852adeaa65cd59288" + integrity sha512-PTGtfthZK79WUMk+avLmwx3NGdU8+iVFXC2NMGxKsn0MnihOG2lvumj+AZo8CTwTrwjXDgZ5tztbRlEdRjBonQ== + extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -4031,6 +4158,13 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== + dependencies: + debug "=3.1.0" + for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -4041,7 +4175,7 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= -form-data@^3.0.0: +form-data@3.0.0, form-data@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682" integrity sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg== @@ -4081,6 +4215,11 @@ fs-capacitor@^2.0.4: resolved "https://registry.yarnpkg.com/fs-capacitor/-/fs-capacitor-2.0.4.tgz#5a22e72d40ae5078b4fe64fe4d08c0d3fc88ad3c" integrity sha512-8S4f4WsCryNw2mJJchi46YgB6CR5Ze+4L1h8ewl9tEpL4SJ3ZO+c/bS4BWhB8bK+O3TMqhuZarTitd0S0eh2pA== +fs-capacitor@^6.1.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/fs-capacitor/-/fs-capacitor-6.2.0.tgz#fa79ac6576629163cb84561995602d8999afb7f5" + integrity sha512-nKcE1UduoSKX27NSZlg879LdQc94OtbOsEmKMN2MBNudXREvijRKx2GEBsTMTfws+BrbkJoEuynbGSVRSpauvw== + fs-constants@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" @@ -4278,6 +4417,11 @@ graphql-extensions@^0.12.4: apollo-server-env "^2.4.5" apollo-server-types "^0.5.1" +graphql-iso-date@^3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/graphql-iso-date/-/graphql-iso-date-3.6.1.tgz#bd2d0dc886e0f954cbbbc496bbf1d480b57ffa96" + integrity sha512-AwFGIuYMJQXOEAgRlJlFL4H1ncFM8n8XmoVDTNypNOZyQ8LFDG2ppMFlsS862BSTCDcSUfHp8PD3/uJhv7t59Q== + graphql-request@^1.5.0: version "1.8.2" resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-1.8.2.tgz#398d10ae15c585676741bde3fc01d5ca948f8fbe" @@ -4320,6 +4464,44 @@ graphql-tools@^4.0.0: iterall "^1.1.3" uuid "^3.1.0" +graphql-tools@^6.0.11: + version "6.0.12" + resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-6.0.12.tgz#c644d91bb25823fbd44cc1912009d5faffd8841d" + integrity sha512-3KKyt4Z+YItCyzSw9W78ksSuGFYNkrZoaDK+rrsFNM0J0fvAvY1n5rPRKKV+fOC8f2FOPac6vF9fLMw5k7x2OQ== + dependencies: + "@graphql-tools/code-file-loader" "6.0.12" + "@graphql-tools/delegate" "6.0.12" + "@graphql-tools/git-loader" "6.0.12" + "@graphql-tools/github-loader" "6.0.12" + "@graphql-tools/graphql-file-loader" "6.0.12" + "@graphql-tools/graphql-tag-pluck" "6.0.12" + "@graphql-tools/import" "6.0.12" + "@graphql-tools/json-file-loader" "6.0.12" + "@graphql-tools/links" "6.0.12" + "@graphql-tools/load" "6.0.12" + "@graphql-tools/load-files" "6.0.12" + "@graphql-tools/merge" "6.0.12" + "@graphql-tools/mock" "6.0.12" + "@graphql-tools/module-loader" "6.0.12" + "@graphql-tools/relay-operation-optimizer" "6.0.12" + "@graphql-tools/resolvers-composition" "6.0.12" + "@graphql-tools/schema" "6.0.12" + "@graphql-tools/stitch" "6.0.12" + "@graphql-tools/url-loader" "6.0.12" + "@graphql-tools/utils" "6.0.12" + "@graphql-tools/wrap" "6.0.12" + +graphql-upload@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/graphql-upload/-/graphql-upload-11.0.0.tgz#24b245ff18f353bab6715e8a055db9fd73035e10" + integrity sha512-zsrDtu5gCbQFDWsNa5bMB4nf1LpKX9KDgh+f8oL1288ijV4RxeckhVozAjqjXAfRpxOHD1xOESsh6zq8SjdgjA== + dependencies: + busboy "^0.3.1" + fs-capacitor "^6.1.0" + http-errors "^1.7.3" + isobject "^4.0.0" + object-path "^0.11.4" + graphql-upload@^8.0.2: version "8.1.0" resolved "https://registry.yarnpkg.com/graphql-upload/-/graphql-upload-8.1.0.tgz#6d0ab662db5677a68bfb1f2c870ab2544c14939a" @@ -4913,6 +5095,11 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= +isobject@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" + integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== + isomorphic-fetch@^2.1.1, isomorphic-fetch@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" @@ -5758,6 +5945,11 @@ lodash.unionwith@^4.6.0: resolved "https://registry.yarnpkg.com/lodash.unionwith/-/lodash.unionwith-4.6.0.tgz#74d140b5ca8146e6c643c3724f5152538d9ac1f0" integrity sha1-dNFAtcqBRubGQ8NyT1FSU42awfA= +lodash@4.17.15: + version "4.17.15" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" + integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: version "4.17.19" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" @@ -6132,6 +6324,11 @@ node-notifier@^7.0.0: uuid "^7.0.3" which "^2.0.2" +nofilter@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-1.0.3.tgz#34e54b4cc9757de0cad38cc0d19462489b1b7f5d" + integrity sha512-FlUlqwRK6reQCaFLAhMcF+6VkVG2caYjKQY3YsRDTl4/SEch595Qb3oLjJRDr8dkHAAOVj2pOx3VknfnSgkE5g== + normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"