From e926fc0b2dae81a1538ed6901ef34e3b3e8b3d53 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 31 Oct 2023 09:12:41 +0000 Subject: [PATCH 01/74] Update changelogs and bump versions [skip ci] --- .changeset/clean-pianos-hide.md | 2 -- .changeset/cuddly-pens-tell.md | 2 -- .changeset/curly-balloons-talk.md | 2 -- .changeset/dull-badgers-type.md | 2 -- .changeset/forty-turkeys-doubt.md | 5 --- .changeset/grumpy-flowers-hear.md | 2 -- .changeset/happy-ravens-learn.md | 2 -- .changeset/heavy-mangos-retire.md | 2 -- .changeset/hungry-knives-refuse.md | 17 ---------- .changeset/kind-students-promise.md | 5 --- .changeset/mean-radios-train.md | 7 ----- .changeset/quick-planes-poke.md | 2 -- .changeset/quiet-turtles-talk.md | 5 --- .changeset/rude-icons-film.md | 2 -- .changeset/silver-colts-remember.md | 5 --- .changeset/slow-schools-compete.md | 5 --- .changeset/soft-mice-heal.md | 5 --- .changeset/three-toys-reply.md | 8 ----- .changeset/tiny-starfishes-mix.md | 5 --- .changeset/wicked-bananas-sit.md | 31 ------------------- packages/apps/docs/CHANGELOG.md | 15 +++++++++ packages/apps/docs/package.json | 2 +- packages/apps/graph-client/CHANGELOG.md | 13 ++++++++ packages/apps/graph-client/package.json | 2 +- packages/apps/graph/CHANGELOG.md | 15 +++++++++ packages/apps/graph/package.json | 2 +- packages/apps/immutable-records/CHANGELOG.md | 12 +++++++ packages/apps/immutable-records/package.json | 2 +- .../libs/chainweb-node-client/CHANGELOG.md | 10 ++++++ .../libs/chainweb-node-client/package.json | 2 +- .../libs/chainweb-stream-client/CHANGELOG.md | 6 ++++ .../libs/chainweb-stream-client/package.json | 2 +- packages/libs/chainwebjs/CHANGELOG.md | 6 ++++ packages/libs/chainwebjs/package.json | 2 +- packages/libs/client-examples/CHANGELOG.md | 13 ++++++++ packages/libs/client-examples/package.json | 2 +- packages/libs/client-utils/CHANGELOG.md | 13 ++++++++ packages/libs/client-utils/package.json | 2 +- packages/libs/client/CHANGELOG.md | 12 +++++++ packages/libs/client/package.json | 2 +- packages/libs/cryptography-utils/CHANGELOG.md | 6 ++++ packages/libs/cryptography-utils/package.json | 2 +- packages/libs/kadena.js/CHANGELOG.md | 12 +++++++ packages/libs/kadena.js/package.json | 2 +- packages/libs/pactjs-generator/CHANGELOG.md | 6 ++++ packages/libs/pactjs-generator/package.json | 2 +- packages/libs/pactjs/CHANGELOG.md | 6 ++++ packages/libs/pactjs/package.json | 2 +- packages/libs/react-components/CHANGELOG.md | 6 ++++ packages/libs/react-components/package.json | 2 +- packages/libs/react-ui/CHANGELOG.md | 7 +++++ packages/libs/react-ui/package.json | 2 +- packages/libs/types/CHANGELOG.md | 6 ++++ packages/libs/types/package.json | 2 +- packages/tools/cookbook/CHANGELOG.md | 12 +++++++ packages/tools/cookbook/package.json | 2 +- packages/tools/e2e-tests/CHANGELOG.md | 7 +++++ packages/tools/e2e-tests/package.json | 2 +- packages/tools/eslint-config/CHANGELOG.md | 9 ++++++ packages/tools/eslint-config/package.json | 2 +- packages/tools/eslint-plugin/CHANGELOG.md | 6 ++++ packages/tools/eslint-plugin/package.json | 2 +- packages/tools/kda-cli/CHANGELOG.md | 9 ++++++ packages/tools/kda-cli/package.json | 2 +- packages/tools/lint-package/CHANGELOG.md | 6 ++++ packages/tools/lint-package/package.json | 2 +- packages/tools/markdown/CHANGELOG.md | 6 ++++ packages/tools/markdown/package.json | 2 +- packages/tools/pactjs-cli/CHANGELOG.md | 13 ++++++++ packages/tools/pactjs-cli/package.json | 2 +- packages/tools/scripts/CHANGELOG.md | 6 ++++ packages/tools/scripts/package.json | 2 +- packages/tools/shared-config/CHANGELOG.md | 6 ++++ packages/tools/shared-config/package.json | 2 +- 74 files changed, 271 insertions(+), 143 deletions(-) delete mode 100644 .changeset/clean-pianos-hide.md delete mode 100644 .changeset/cuddly-pens-tell.md delete mode 100644 .changeset/curly-balloons-talk.md delete mode 100644 .changeset/dull-badgers-type.md delete mode 100644 .changeset/forty-turkeys-doubt.md delete mode 100644 .changeset/grumpy-flowers-hear.md delete mode 100644 .changeset/happy-ravens-learn.md delete mode 100644 .changeset/heavy-mangos-retire.md delete mode 100644 .changeset/hungry-knives-refuse.md delete mode 100644 .changeset/kind-students-promise.md delete mode 100644 .changeset/mean-radios-train.md delete mode 100644 .changeset/quick-planes-poke.md delete mode 100644 .changeset/quiet-turtles-talk.md delete mode 100644 .changeset/rude-icons-film.md delete mode 100644 .changeset/silver-colts-remember.md delete mode 100644 .changeset/slow-schools-compete.md delete mode 100644 .changeset/soft-mice-heal.md delete mode 100644 .changeset/three-toys-reply.md delete mode 100644 .changeset/tiny-starfishes-mix.md delete mode 100644 .changeset/wicked-bananas-sit.md create mode 100644 packages/tools/e2e-tests/CHANGELOG.md diff --git a/.changeset/clean-pianos-hide.md b/.changeset/clean-pianos-hide.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/clean-pianos-hide.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/cuddly-pens-tell.md b/.changeset/cuddly-pens-tell.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/cuddly-pens-tell.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/curly-balloons-talk.md b/.changeset/curly-balloons-talk.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/curly-balloons-talk.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/dull-badgers-type.md b/.changeset/dull-badgers-type.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/dull-badgers-type.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/forty-turkeys-doubt.md b/.changeset/forty-turkeys-doubt.md deleted file mode 100644 index 4c3daa09af..0000000000 --- a/.changeset/forty-turkeys-doubt.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph-client': patch ---- - -Changed the transaction overview page to display signer related information diff --git a/.changeset/grumpy-flowers-hear.md b/.changeset/grumpy-flowers-hear.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/grumpy-flowers-hear.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/happy-ravens-learn.md b/.changeset/happy-ravens-learn.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/happy-ravens-learn.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/heavy-mangos-retire.md b/.changeset/heavy-mangos-retire.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/heavy-mangos-retire.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/hungry-knives-refuse.md b/.changeset/hungry-knives-refuse.md deleted file mode 100644 index 39324dfb79..0000000000 --- a/.changeset/hungry-knives-refuse.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'@kadena/chainweb-stream-client': none -'@kadena/chainweb-node-client': none -'@kadena/cryptography-utils': none -'@kadena/pactjs-generator': none -'@kadena-dev/shared-config': none -'@kadena/client-utils': none -'@kadena/pactjs-cli': none -'@kadena/chainwebjs': none -'kadena.js': none -'@kadena/react-ui': none -'@kadena/kda-cli': none -'@kadena/client': none -'@kadena/pactjs': none ---- - -Re-add coverage + initial thresholds diff --git a/.changeset/kind-students-promise.md b/.changeset/kind-students-promise.md deleted file mode 100644 index b025817bbc..0000000000 --- a/.changeset/kind-students-promise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/pactjs-cli': minor ---- - -add option to store modules parse tree to dist diff --git a/.changeset/mean-radios-train.md b/.changeset/mean-radios-train.md deleted file mode 100644 index 1aedbe9d97..0000000000 --- a/.changeset/mean-radios-train.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@kadena-dev/eslint-config': none -'@kadena-dev/eslint-plugin': none -'@kadena-dev/shared-config': none ---- - -Add repository urls where missing diff --git a/.changeset/quick-planes-poke.md b/.changeset/quick-planes-poke.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/quick-planes-poke.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/quiet-turtles-talk.md b/.changeset/quiet-turtles-talk.md deleted file mode 100644 index 6019973460..0000000000 --- a/.changeset/quiet-turtles-talk.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph-client': patch ---- - -Apply formatting to all json's and code in client diff --git a/.changeset/rude-icons-film.md b/.changeset/rude-icons-film.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/rude-icons-film.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/silver-colts-remember.md b/.changeset/silver-colts-remember.md deleted file mode 100644 index 1e945f247e..0000000000 --- a/.changeset/silver-colts-remember.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph': patch ---- - -Added pactQuery and pactQueries for arbitrary PACT code execution diff --git a/.changeset/slow-schools-compete.md b/.changeset/slow-schools-compete.md deleted file mode 100644 index c26dc56990..0000000000 --- a/.changeset/slow-schools-compete.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/react-ui': patch ---- - -Fixed the KodeMono font diff --git a/.changeset/soft-mice-heal.md b/.changeset/soft-mice-heal.md deleted file mode 100644 index 832ee1631f..0000000000 --- a/.changeset/soft-mice-heal.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/docs': minor ---- - -next/prev navigation fix diff --git a/.changeset/three-toys-reply.md b/.changeset/three-toys-reply.md deleted file mode 100644 index e4a66851b7..0000000000 --- a/.changeset/three-toys-reply.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -'@kadena/chainweb-node-client': none -'@kadena/pactjs-cli': none -'@kadena/chainwebjs': none -'@kadena/client': none ---- - -Migrate from MSW 1.3.2 → 2.0.0 diff --git a/.changeset/tiny-starfishes-mix.md b/.changeset/tiny-starfishes-mix.md deleted file mode 100644 index 6b26363f55..0000000000 --- a/.changeset/tiny-starfishes-mix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph': patch ---- - -Added signer object and signer fields on transactions (graph) diff --git a/.changeset/wicked-bananas-sit.md b/.changeset/wicked-bananas-sit.md deleted file mode 100644 index 8da8453994..0000000000 --- a/.changeset/wicked-bananas-sit.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -'@kadena/docs': patch -'@kadena/graph': patch -'@kadena/graph-client': patch -'@kadena/immutable-records': patch -'@kadena/chainweb-node-client': patch -'@kadena/chainweb-stream-client': patch -'@kadena/chainwebjs': patch -'@kadena/client': patch -'@kadena/client-examples': patch -'@kadena/client-utils': patch -'@kadena/cryptography-utils': patch -'kadena.js': patch -'@kadena/pactjs': patch -'@kadena/pactjs-generator': patch -'@kadena/react-components': patch -'@kadena/react-ui': patch -'@kadena/types': patch -'@kadena/cookbook': patch -'@kadena-dev/e2e-tests': patch -'@kadena-dev/eslint-config': patch -'@kadena-dev/eslint-plugin': patch -'@kadena/kda-cli': patch -'@kadena-dev/lint-package': patch -'@kadena-dev/markdown': patch -'@kadena/pactjs-cli': patch -'@kadena-dev/scripts': patch -'@kadena-dev/shared-config': patch ---- - -No auto-globals for vitest specs diff --git a/packages/apps/docs/CHANGELOG.md b/packages/apps/docs/CHANGELOG.md index 050ada8cd0..083c7b2e0f 100644 --- a/packages/apps/docs/CHANGELOG.md +++ b/packages/apps/docs/CHANGELOG.md @@ -1,6 +1,21 @@ # @kadena/docs +## 0.5.0 + +### Minor Changes + +- 7544606f2: next/prev navigation fix + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [fa98adaa8] +- Updated dependencies [fa6b84e22] + - @kadena/react-ui@0.2.1 + ## 0.4.1 + - fix the next/prev page navigation ## 0.4.0 diff --git a/packages/apps/docs/package.json b/packages/apps/docs/package.json index 9a76e2d5c9..5da2a959d6 100644 --- a/packages/apps/docs/package.json +++ b/packages/apps/docs/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/docs", - "version": "0.4.1", + "version": "0.5.0", "private": true, "scripts": { "7d": "npx 7d pinecone-create-index --index kda-docs --environment asia-northeast1-gcp", diff --git a/packages/apps/graph-client/CHANGELOG.md b/packages/apps/graph-client/CHANGELOG.md index 57892145c2..f1caf6840e 100644 --- a/packages/apps/graph-client/CHANGELOG.md +++ b/packages/apps/graph-client/CHANGELOG.md @@ -1,5 +1,18 @@ # @kadena/graph-client +## 0.1.3 + +### Patch Changes + +- 96e321d8a: Changed the transaction overview page to display signer related + information +- bcac940f7: Apply formatting to all json's and code in client +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [fa98adaa8] +- Updated dependencies [fa6b84e22] + - @kadena/react-ui@0.2.1 + ## 0.1.2 ### Patch Changes diff --git a/packages/apps/graph-client/package.json b/packages/apps/graph-client/package.json index e89712aac5..00537ffb91 100644 --- a/packages/apps/graph-client/package.json +++ b/packages/apps/graph-client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/graph-client", - "version": "0.1.2", + "version": "0.1.3", "private": true, "scripts": { "build": "pnpm run generate:sdk && next build", diff --git a/packages/apps/graph/CHANGELOG.md b/packages/apps/graph/CHANGELOG.md index 37be1332bc..2e8d8f9f8b 100644 --- a/packages/apps/graph/CHANGELOG.md +++ b/packages/apps/graph/CHANGELOG.md @@ -1,5 +1,20 @@ # @kadena/graph +## 1.0.2 + +### Patch Changes + +- 18a8f5574: Added pactQuery and pactQueries for arbitrary PACT code execution +- b348a6899: Added signer object and signer fields on transactions (graph) +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/chainweb-node-client@0.5.1 + - @kadena/cryptography-utils@0.4.1 + - @kadena/client@1.6.0 + - @kadena/pactjs@0.4.1 + ## 1.0.1 ### Patch Changes diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index 65dd78e16a..27e33b2589 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/graph", - "version": "1.0.1", + "version": "1.0.2", "private": true, "description": "", "keywords": [], diff --git a/packages/apps/immutable-records/CHANGELOG.md b/packages/apps/immutable-records/CHANGELOG.md index 90ac6becca..eda79171f3 100644 --- a/packages/apps/immutable-records/CHANGELOG.md +++ b/packages/apps/immutable-records/CHANGELOG.md @@ -1,5 +1,17 @@ # @kadena/immutable-records +## 0.1.3 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [fa98adaa8] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/react-ui@0.2.1 + - @kadena/client@1.6.0 + ## 0.1.2 ### Patch Changes diff --git a/packages/apps/immutable-records/package.json b/packages/apps/immutable-records/package.json index fa95075097..78d44a0969 100644 --- a/packages/apps/immutable-records/package.json +++ b/packages/apps/immutable-records/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/immutable-records", - "version": "0.1.2", + "version": "0.1.3", "private": true, "scripts": { "build": "next build", diff --git a/packages/libs/chainweb-node-client/CHANGELOG.md b/packages/libs/chainweb-node-client/CHANGELOG.md index 76b2697c9d..f05e3fb349 100644 --- a/packages/libs/chainweb-node-client/CHANGELOG.md +++ b/packages/libs/chainweb-node-client/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log - @kadena/chainweb-node-client +## 0.5.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [fa6b84e22] + - @kadena/cryptography-utils@0.4.1 + - @kadena/pactjs@0.4.1 + ## 0.5.0 ### Minor Changes diff --git a/packages/libs/chainweb-node-client/package.json b/packages/libs/chainweb-node-client/package.json index 88fa2fb2f0..257aac0fcc 100644 --- a/packages/libs/chainweb-node-client/package.json +++ b/packages/libs/chainweb-node-client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/chainweb-node-client", - "version": "0.5.0", + "version": "0.5.1", "description": "Typed JavaScript wrapper with fetch to call chainweb-node API endpoints", "keywords": [], "repository": { diff --git a/packages/libs/chainweb-stream-client/CHANGELOG.md b/packages/libs/chainweb-stream-client/CHANGELOG.md index 3e3cc0a240..313fede862 100644 --- a/packages/libs/chainweb-stream-client/CHANGELOG.md +++ b/packages/libs/chainweb-stream-client/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/chainweb-stream-client +## 0.2.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.2.0 ### Minor Changes diff --git a/packages/libs/chainweb-stream-client/package.json b/packages/libs/chainweb-stream-client/package.json index 6afbd03ec8..a46204e0bd 100644 --- a/packages/libs/chainweb-stream-client/package.json +++ b/packages/libs/chainweb-stream-client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/chainweb-stream-client", - "version": "0.2.0", + "version": "0.2.1", "description": "Chainweb-stream client for browsers and node.js", "keywords": [], "repository": { diff --git a/packages/libs/chainwebjs/CHANGELOG.md b/packages/libs/chainwebjs/CHANGELOG.md index ee01860cab..1dd1207fb0 100644 --- a/packages/libs/chainwebjs/CHANGELOG.md +++ b/packages/libs/chainwebjs/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/chainwebjs +## 0.1.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.1.0 ### Minor Changes diff --git a/packages/libs/chainwebjs/package.json b/packages/libs/chainwebjs/package.json index 243105f917..a2be1b7a7b 100644 --- a/packages/libs/chainwebjs/package.json +++ b/packages/libs/chainwebjs/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/chainwebjs", - "version": "0.1.0", + "version": "0.1.1", "description": "Javascript (Typescript) bindings for the Kadena Chainweb API", "keywords": [ "chainweb", diff --git a/packages/libs/client-examples/CHANGELOG.md b/packages/libs/client-examples/CHANGELOG.md index 706748408e..044cd376d7 100644 --- a/packages/libs/client-examples/CHANGELOG.md +++ b/packages/libs/client-examples/CHANGELOG.md @@ -1,5 +1,18 @@ # @kadena/client-examples +## 0.0.6 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/chainweb-node-client@0.5.1 + - @kadena/client-utils@0.0.3 + - @kadena/client@1.6.0 + - @kadena/pactjs@0.4.1 + ## 0.0.5 ### Patch Changes diff --git a/packages/libs/client-examples/package.json b/packages/libs/client-examples/package.json index 3322d3a4f6..1eb08bc6df 100644 --- a/packages/libs/client-examples/package.json +++ b/packages/libs/client-examples/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client-examples", - "version": "0.0.5", + "version": "0.0.6", "private": true, "description": "Test project to verify pactjs-cli and pactjs-generator", "repository": { diff --git a/packages/libs/client-utils/CHANGELOG.md b/packages/libs/client-utils/CHANGELOG.md index b838d4bc0c..18eb7bc04f 100644 --- a/packages/libs/client-utils/CHANGELOG.md +++ b/packages/libs/client-utils/CHANGELOG.md @@ -1,5 +1,18 @@ # @kadena/client-utils +## 0.0.3 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/chainweb-node-client@0.5.1 + - @kadena/cryptography-utils@0.4.1 + - @kadena/client@1.6.0 + - @kadena/types@0.5.1 + ## 0.0.2 ### Patch Changes diff --git a/packages/libs/client-utils/package.json b/packages/libs/client-utils/package.json index d88e9a0a8c..98cc96773c 100644 --- a/packages/libs/client-utils/package.json +++ b/packages/libs/client-utils/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client-utils", - "version": "0.0.2", + "version": "0.0.3", "description": "Utility functions build as a wrapper around @kadena/client", "repository": { "type": "git", diff --git a/packages/libs/client/CHANGELOG.md b/packages/libs/client/CHANGELOG.md index 2c5acf712f..b8084022b1 100644 --- a/packages/libs/client/CHANGELOG.md +++ b/packages/libs/client/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log - @kadena/client +## 1.6.0 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/chainweb-node-client@0.5.1 + - @kadena/cryptography-utils@0.4.1 + - @kadena/pactjs@0.4.1 + ## 1.5.0 ### Minor Changes diff --git a/packages/libs/client/package.json b/packages/libs/client/package.json index ddfb2bdb2f..65de6a2f8f 100644 --- a/packages/libs/client/package.json +++ b/packages/libs/client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client", - "version": "1.5.0", + "version": "1.6.0", "description": "Core library for building Pact expressions to send to the blockchain in js. Makes use of .kadena/pactjs-generated", "repository": { "type": "git", diff --git a/packages/libs/cryptography-utils/CHANGELOG.md b/packages/libs/cryptography-utils/CHANGELOG.md index 4ae20f4b6c..83347edb68 100644 --- a/packages/libs/cryptography-utils/CHANGELOG.md +++ b/packages/libs/cryptography-utils/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/cryptography-utils +## 0.4.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.4.0 ### Minor Changes diff --git a/packages/libs/cryptography-utils/package.json b/packages/libs/cryptography-utils/package.json index b106a919c9..14d13e4a1d 100644 --- a/packages/libs/cryptography-utils/package.json +++ b/packages/libs/cryptography-utils/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/cryptography-utils", - "version": "0.4.0", + "version": "0.4.1", "description": "Collection of Kadena cryptography utility functions", "keywords": [], "repository": { diff --git a/packages/libs/kadena.js/CHANGELOG.md b/packages/libs/kadena.js/CHANGELOG.md index 1962f9c1fc..00eaa3c844 100644 --- a/packages/libs/kadena.js/CHANGELOG.md +++ b/packages/libs/kadena.js/CHANGELOG.md @@ -1,5 +1,17 @@ # kadena.js +## 0.0.3 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/chainweb-node-client@0.5.1 + - @kadena/cryptography-utils@0.4.1 + - @kadena/pactjs@0.4.1 + ## 0.0.2 ### Patch Changes diff --git a/packages/libs/kadena.js/package.json b/packages/libs/kadena.js/package.json index 41dd7dca22..f3ac817e48 100644 --- a/packages/libs/kadena.js/package.json +++ b/packages/libs/kadena.js/package.json @@ -1,6 +1,6 @@ { "name": "kadena.js", - "version": "0.0.2", + "version": "0.0.3", "private": true, "description": "A practical util library for JavaScript programmers who are building on the Kadena blockchain", "keywords": [ diff --git a/packages/libs/pactjs-generator/CHANGELOG.md b/packages/libs/pactjs-generator/CHANGELOG.md index cfdb843932..12f8ac7765 100644 --- a/packages/libs/pactjs-generator/CHANGELOG.md +++ b/packages/libs/pactjs-generator/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/pactjs-generator +## 1.6.0 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 1.5.0 ### Minor Changes diff --git a/packages/libs/pactjs-generator/package.json b/packages/libs/pactjs-generator/package.json index 324d521c1c..9bad43b5b7 100644 --- a/packages/libs/pactjs-generator/package.json +++ b/packages/libs/pactjs-generator/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs-generator", - "version": "1.5.0", + "version": "1.6.0", "description": "Generates TypeScript definitions of Pact contracts, for use in @kadena/pactjs", "repository": { "type": "git", diff --git a/packages/libs/pactjs/CHANGELOG.md b/packages/libs/pactjs/CHANGELOG.md index e8f7480df4..32fcff6cf9 100644 --- a/packages/libs/pactjs/CHANGELOG.md +++ b/packages/libs/pactjs/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/pactjs +## 0.4.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.4.0 ### Minor Changes diff --git a/packages/libs/pactjs/package.json b/packages/libs/pactjs/package.json index 7da7344e1b..c43565288c 100644 --- a/packages/libs/pactjs/package.json +++ b/packages/libs/pactjs/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs", - "version": "0.4.0", + "version": "0.4.1", "description": "Collection of utility functions pactjs related", "keywords": [], "repository": { diff --git a/packages/libs/react-components/CHANGELOG.md b/packages/libs/react-components/CHANGELOG.md index 55c474659a..2418061ade 100644 --- a/packages/libs/react-components/CHANGELOG.md +++ b/packages/libs/react-components/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena/react-components +## 0.1.2 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.1.1 ### Patch Changes diff --git a/packages/libs/react-components/package.json b/packages/libs/react-components/package.json index 8a2d46d901..7e33526935 100644 --- a/packages/libs/react-components/package.json +++ b/packages/libs/react-components/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/react-components", - "version": "0.1.1", + "version": "0.1.2", "private": true, "description": "A react component library built on Kadena's Design System", "license": "ISC", diff --git a/packages/libs/react-ui/CHANGELOG.md b/packages/libs/react-ui/CHANGELOG.md index 6137a7ebed..eb63e38c56 100644 --- a/packages/libs/react-ui/CHANGELOG.md +++ b/packages/libs/react-ui/CHANGELOG.md @@ -1,5 +1,12 @@ # @kadena/react-ui +## 0.2.1 + +### Patch Changes + +- fa98adaa8: Fixed the KodeMono font +- fa6b84e22: No auto-globals for vitest specs + ## 0.2.0 ### Minor Changes diff --git a/packages/libs/react-ui/package.json b/packages/libs/react-ui/package.json index 04d36993ca..56b10c5839 100644 --- a/packages/libs/react-ui/package.json +++ b/packages/libs/react-ui/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/react-ui", - "version": "0.2.0", + "version": "0.2.1", "private": true, "description": "A react component library built on Kadena's Design System", "license": "ISC", diff --git a/packages/libs/types/CHANGELOG.md b/packages/libs/types/CHANGELOG.md index dbaf361dec..29b05558b0 100644 --- a/packages/libs/types/CHANGELOG.md +++ b/packages/libs/types/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/types +## 0.5.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.5.0 ### Minor Changes diff --git a/packages/libs/types/package.json b/packages/libs/types/package.json index accd25a884..867eddc249 100644 --- a/packages/libs/types/package.json +++ b/packages/libs/types/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/types", - "version": "0.5.0", + "version": "0.5.1", "description": "", "keywords": [], "repository": { diff --git a/packages/tools/cookbook/CHANGELOG.md b/packages/tools/cookbook/CHANGELOG.md index 82da3632a3..0fe4f34d9d 100644 --- a/packages/tools/cookbook/CHANGELOG.md +++ b/packages/tools/cookbook/CHANGELOG.md @@ -1,5 +1,17 @@ # @kadena/cookbook +## 0.0.5 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [d15a6231f] +- Updated dependencies [fa6b84e22] + - @kadena/chainweb-node-client@0.5.1 + - @kadena/cryptography-utils@0.4.1 + - @kadena/client@1.6.0 + ## 0.0.4 ### Patch Changes diff --git a/packages/tools/cookbook/package.json b/packages/tools/cookbook/package.json index 905c897473..4c4d6b2184 100644 --- a/packages/tools/cookbook/package.json +++ b/packages/tools/cookbook/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/cookbook", - "version": "0.0.4", + "version": "0.0.5", "private": true, "description": "Demonstrates common use cases for @kadena/client and @kadena/pact-cli for smart contracts", "keywords": [], diff --git a/packages/tools/e2e-tests/CHANGELOG.md b/packages/tools/e2e-tests/CHANGELOG.md new file mode 100644 index 0000000000..269a0ae0b7 --- /dev/null +++ b/packages/tools/e2e-tests/CHANGELOG.md @@ -0,0 +1,7 @@ +# @kadena-dev/e2e-tests + +## 0.0.2 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs diff --git a/packages/tools/e2e-tests/package.json b/packages/tools/e2e-tests/package.json index 3d6aa7ddae..70f4bb6b60 100644 --- a/packages/tools/e2e-tests/package.json +++ b/packages/tools/e2e-tests/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/e2e-tests", - "version": "0.0.1", + "version": "0.0.2", "private": true, "scripts": { "format": "pnpm run --sequential /^format:.*/", diff --git a/packages/tools/eslint-config/CHANGELOG.md b/packages/tools/eslint-config/CHANGELOG.md index 1226bbc788..92f1fc95a2 100644 --- a/packages/tools/eslint-config/CHANGELOG.md +++ b/packages/tools/eslint-config/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log - @kadena-dev/eslint-config +## 1.0.2 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1907e5ef2] +- Updated dependencies [fa6b84e22] + - @kadena-dev/eslint-plugin@0.0.8 + ## 1.0.1 ### Patch Changes diff --git a/packages/tools/eslint-config/package.json b/packages/tools/eslint-config/package.json index a636a5c5c5..c903f86307 100644 --- a/packages/tools/eslint-config/package.json +++ b/packages/tools/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/eslint-config", - "version": "1.0.1", + "version": "1.0.2", "description": "Kadena monorepo eslint-config", "repository": { "type": "git", diff --git a/packages/tools/eslint-plugin/CHANGELOG.md b/packages/tools/eslint-plugin/CHANGELOG.md index 10812575d3..473646b75e 100644 --- a/packages/tools/eslint-plugin/CHANGELOG.md +++ b/packages/tools/eslint-plugin/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena-dev/eslint-plugin +## 0.0.8 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.0.7 ### Patch Changes diff --git a/packages/tools/eslint-plugin/package.json b/packages/tools/eslint-plugin/package.json index 4794981e26..266c4a73d3 100644 --- a/packages/tools/eslint-plugin/package.json +++ b/packages/tools/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/eslint-plugin", - "version": "0.0.7", + "version": "0.0.8", "repository": { "type": "git", "url": "https://github.com/kadena-community/kadena.js.git", diff --git a/packages/tools/kda-cli/CHANGELOG.md b/packages/tools/kda-cli/CHANGELOG.md index bb624bf79f..67ca636ad5 100644 --- a/packages/tools/kda-cli/CHANGELOG.md +++ b/packages/tools/kda-cli/CHANGELOG.md @@ -1,5 +1,14 @@ # @kadena/kda-cli +## 0.0.3 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [fa6b84e22] + - @kadena/cryptography-utils@0.4.1 + ## 0.0.2 ### Patch Changes diff --git a/packages/tools/kda-cli/package.json b/packages/tools/kda-cli/package.json index f27257a8b6..93b2cd048c 100644 --- a/packages/tools/kda-cli/package.json +++ b/packages/tools/kda-cli/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/kda-cli", - "version": "0.0.2", + "version": "0.0.3", "private": true, "description": "CLI tool to assist development on the kadena blockchain", "keywords": [ diff --git a/packages/tools/lint-package/CHANGELOG.md b/packages/tools/lint-package/CHANGELOG.md index c1dc75d803..e495f47439 100644 --- a/packages/tools/lint-package/CHANGELOG.md +++ b/packages/tools/lint-package/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena-dev/lint-package +## 0.1.2 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.1.1 ### Patch Changes diff --git a/packages/tools/lint-package/package.json b/packages/tools/lint-package/package.json index 19eb750596..1e363c3380 100644 --- a/packages/tools/lint-package/package.json +++ b/packages/tools/lint-package/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/lint-package", - "version": "0.1.1", + "version": "0.1.2", "private": true, "description": "Linter for monorepo packages", "repository": { diff --git a/packages/tools/markdown/CHANGELOG.md b/packages/tools/markdown/CHANGELOG.md index c4ffa1a24a..bbf4a5cea0 100644 --- a/packages/tools/markdown/CHANGELOG.md +++ b/packages/tools/markdown/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena-dev/markdown +## 1.0.2 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 1.0.1 ### Patch Changes diff --git a/packages/tools/markdown/package.json b/packages/tools/markdown/package.json index 39e4f3155f..ecb2ad56de 100644 --- a/packages/tools/markdown/package.json +++ b/packages/tools/markdown/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/markdown", - "version": "1.0.1", + "version": "1.0.2", "private": true, "description": "Kadena monorepo Remark plugins", "license": "MIT", diff --git a/packages/tools/pactjs-cli/CHANGELOG.md b/packages/tools/pactjs-cli/CHANGELOG.md index e59d53e478..97adbc37a6 100644 --- a/packages/tools/pactjs-cli/CHANGELOG.md +++ b/packages/tools/pactjs-cli/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log - @kadena/pactjs-cli +## 1.6.0 + +### Minor Changes + +- e62a9505e: add option to store modules parse tree to dist + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs +- Updated dependencies [1d7d88081] +- Updated dependencies [fa6b84e22] + - @kadena/pactjs-generator@1.6.0 + ## 1.5.0 ### Patch Changes diff --git a/packages/tools/pactjs-cli/package.json b/packages/tools/pactjs-cli/package.json index fe1cd2dcac..805cef364d 100644 --- a/packages/tools/pactjs-cli/package.json +++ b/packages/tools/pactjs-cli/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs-cli", - "version": "1.5.0", + "version": "1.6.0", "description": "CLI tool accompanying @kadena/pactjs-core and @kadena/pactjs-client to generate TypeScript definitions and Pact client", "repository": { "type": "git", diff --git a/packages/tools/scripts/CHANGELOG.md b/packages/tools/scripts/CHANGELOG.md index b496f59acb..0d57db76ea 100644 --- a/packages/tools/scripts/CHANGELOG.md +++ b/packages/tools/scripts/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena-dev/scripts +## 0.0.2 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.0.1 ### Patch Changes diff --git a/packages/tools/scripts/package.json b/packages/tools/scripts/package.json index b6b12ca8a7..dcd95da8e5 100644 --- a/packages/tools/scripts/package.json +++ b/packages/tools/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/scripts", - "version": "0.0.1", + "version": "0.0.2", "private": true, "description": "Changesets tools", "license": "ISC", diff --git a/packages/tools/shared-config/CHANGELOG.md b/packages/tools/shared-config/CHANGELOG.md index da7b537bea..aba136dce2 100644 --- a/packages/tools/shared-config/CHANGELOG.md +++ b/packages/tools/shared-config/CHANGELOG.md @@ -1,5 +1,11 @@ # @kadena-dev/heft-rig +## 1.0.1 + +### Patch Changes + +- fa6b84e22: No auto-globals for vitest specs + ## 0.1.1 ### Patch Changes diff --git a/packages/tools/shared-config/package.json b/packages/tools/shared-config/package.json index 0c62d352df..8ad09ebed2 100644 --- a/packages/tools/shared-config/package.json +++ b/packages/tools/shared-config/package.json @@ -1,6 +1,6 @@ { "name": "@kadena-dev/shared-config", - "version": "1.0.0", + "version": "1.0.1", "description": "Shared configurations", "repository": { "type": "git", From 0beb710881ecc2ae17d352fa72f653743e99a972 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Wed, 1 Nov 2023 14:03:25 +0100 Subject: [PATCH 02/74] [@kadena/graph] POC normalized error handling --- .../graph/src/graph/objects/ModuleAccount.ts | 79 +++++++++++-------- .../apps/graph/src/services/node-service.ts | 32 +++++--- packages/apps/graph/src/utils/errors.ts | 73 +++++++++++++++++ 3 files changed, 141 insertions(+), 43 deletions(-) create mode 100644 packages/apps/graph/src/utils/errors.ts diff --git a/packages/apps/graph/src/graph/objects/ModuleAccount.ts b/packages/apps/graph/src/graph/objects/ModuleAccount.ts index 97e00284c6..a9e74c549e 100644 --- a/packages/apps/graph/src/graph/objects/ModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ModuleAccount.ts @@ -1,4 +1,5 @@ import { prismaClient } from '../../db/prismaClient'; +import { isRowNotFoundError, normalizeError } from '../../utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; import type { ChainModuleAccount } from '../types/graphql-types'; @@ -33,7 +34,11 @@ export default builder.objectType('ModuleAccount', { transactions: [], transfers: [], }); - } catch (e) {} + } catch (error) { + if (!isRowNotFoundError(error)) { + throw normalizeError(error); + } + } } return chainAccounts; @@ -53,7 +58,11 @@ export default builder.objectType('ModuleAccount', { }); totalBalance += accountDetails.balance; - } catch (e) {} + } catch (error) { + if (!isRowNotFoundError(error)) { + throw normalizeError(error); + } + } } return totalBalance; @@ -62,43 +71,51 @@ export default builder.objectType('ModuleAccount', { transactions: t.prismaConnection({ type: 'Transaction', cursor: 'blockHash_requestKey', - resolve: (query, parent) => { - return prismaClient.transaction.findMany({ - ...query, - where: { - senderAccount: parent.accountName, - events: { - some: { - moduleName: parent.moduleName, + resolve: async (query, parent) => { + try { + return await prismaClient.transaction.findMany({ + ...query, + where: { + senderAccount: parent.accountName, + events: { + some: { + moduleName: parent.moduleName, + }, }, }, - }, - orderBy: { - height: 'desc', - }, - }); + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), transfers: t.prismaConnection({ type: 'Transfer', cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey', resolve: async (query, parent) => { - return prismaClient.transfer.findMany({ - ...query, - where: { - OR: [ - { - senderAccount: parent.accountName, - }, - { - receiverAccount: parent.accountName, - }, - ], - }, - orderBy: { - height: 'desc', - }, - }); + try { + return await prismaClient.transfer.findMany({ + ...query, + where: { + OR: [ + { + senderAccount: parent.accountName, + }, + { + receiverAccount: parent.accountName, + }, + ], + }, + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index e6e96ce8b7..7a756cb583 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -1,7 +1,18 @@ -import type { ChainId, IClient } from '@kadena/client'; +import type { ChainId, IClient, ICommandResult } from '@kadena/client'; import { Pact, createClient } from '@kadena/client'; import { dotenv } from '../utils/dotenv'; +export class PactCommandError extends Error { + public commandResult: ICommandResult; + public pactError: any; + + constructor(message: string, commandResult: ICommandResult, pactError: any) { + super(message); + this.commandResult = commandResult; + this.pactError = pactError; + } +} + // eslint-disable-next-line @typescript-eslint/consistent-type-definitions export type ChainModuleAccountDetails = { account: string; @@ -12,7 +23,7 @@ export type ChainModuleAccountDetails = { }; }; -function getClient(chainId: string): IClient { +function getClient(chainId: ChainId): IClient { return createClient( `http://${dotenv.NETWORK_HOST}/chainweb/0.0/${dotenv.NETWORK_ID}/chain/${chainId}/pact`, ); @@ -23,12 +34,9 @@ export async function getAccountDetails( accountName: string, chainId: string, ): Promise { - const commandResult = await getClient(chainId).dirtyRead( + const commandResult = await getClient(chainId as ChainId).dirtyRead( Pact.builder - .execution( - // @ts-ignore - Pact.modules[module].details(accountName), - ) + .execution(Pact.modules[module as 'fungible-v2'].details(accountName)) .setMeta({ chainId: chainId as ChainId, }) @@ -37,11 +45,11 @@ export async function getAccountDetails( ); if (commandResult.result.status !== 'success') { - const error = { - message: 'Failed with error', - result: JSON.stringify(commandResult), - }; - throw error; + throw new PactCommandError( + 'Pact Command failed with error', + commandResult, + commandResult.result.error, + ); } const result = commandResult.result.data as unknown as any; diff --git a/packages/apps/graph/src/utils/errors.ts b/packages/apps/graph/src/utils/errors.ts new file mode 100644 index 0000000000..9a721f14d6 --- /dev/null +++ b/packages/apps/graph/src/utils/errors.ts @@ -0,0 +1,73 @@ +import type { ICommandResult } from '@kadena/chainweb-node-client'; +import { PrismaClientInitializationError } from '@prisma/client/runtime/library'; +import { GraphQLError } from 'graphql'; +import { PactCommandError } from '../services/node-service'; + +/** + * Checks what type of error it is and returns a normalized GraphQLError with the correct type, message and a description that clearly translates to the user what the error means. + */ +export function normalizeError(error: any): GraphQLError { + if (error instanceof PrismaClientInitializationError) { + return new GraphQLError('Prisma Client Initialization Error', { + extensions: { + type: error.name, + message: error.message, + description: + 'Prisma Client failed to initialize. Are you sure the database is running and reachable?', + data: error.stack, + }, + }); + } + + if (error instanceof PactCommandError) { + let description: string | undefined; + + if (error.pactError.message.includes('with-read: row not found')) { + description = + 'The requested resource (account, e.g.) was most likely not found.'; + } else if (error.pactError.message.startsWith('Cannot resolve')) { + description = + 'The requested module or function was most likely not found.'; + } + + return new GraphQLError('Chainweb Node Command Failure', { + extensions: { + type: error.pactError.type, + message: error.pactError.message, + description, + data: error.commandResult, + }, + }); + } + + if (error.type === 'system' && error.code === 'ECONNREFUSED') { + return new GraphQLError('Chainweb Node Connection Refused', { + extensions: { + type: error.type, + message: error.message, + description: + 'Chainweb Node connection refused. Are you sure the Chainweb Node is running and reachable?', + data: error.stack, + }, + }); + } + + return new GraphQLError('Unknown error occured.', { + extensions: { + type: 'UnknownError', + message: error.message, + description: 'An unknown error occured. Check the logs for more details.', + data: error.stack, + }, + }); +} + +/** + * Checks if the error is a row not found error. An example case is when we loop over all chainIds to get the account details for a module account. If the module account does not exist on a chain, we get a row not found error. We want to ignore this error and continue with the next chainId. + */ +export function isRowNotFoundError(error: any): boolean { + return ( + error instanceof PactCommandError && + error.pactError?.message?.includes('with-read: row not found') + ); +} From acdd58e8062c75a9aaef0c1190a68381f8c0e204 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Thu, 2 Nov 2023 16:03:08 +0100 Subject: [PATCH 03/74] Error logging adding in all queries --- packages/apps/graph/generated-schema.graphql | 4 +- .../apps/graph/src/graph/Query/account.ts | 2 +- packages/apps/graph/src/graph/Query/block.ts | 28 +++--- .../graph/src/graph/Query/blocksFromHeight.ts | 47 +++++----- .../graph/src/graph/Query/chainAccount.ts | 46 ++++++---- .../src/graph/Query/completedBlockHeights.ts | 71 ++++++++------- .../graph/src/graph/Query/lastBlockHeight.ts | 62 +++---------- .../graph/Query/maximumConfirmationDepth.ts | 4 +- .../apps/graph/src/graph/Query/pactQuery.ts | 54 ++++-------- .../graph/src/graph/Query/transactions.ts | 43 +++++---- .../apps/graph/src/graph/Query/transfers.ts | 45 +++++----- .../src/graph/data-loaders/account-details.ts | 2 +- .../apps/graph/src/graph/objects/Block.ts | 88 ++++++++++++------- .../src/graph/objects/ChainModuleAccount.ts | 79 +++++++++-------- .../apps/graph/src/graph/objects/Event.ts | 40 +++++---- .../apps/graph/src/graph/objects/MinerKey.ts | 20 +++-- .../graph/src/graph/objects/ModuleAccount.ts | 50 +++++------ .../apps/graph/src/graph/objects/Signer.ts | 2 +- .../graph/src/graph/objects/Transaction.ts | 77 +++++++++------- .../apps/graph/src/graph/objects/Transfer.ts | 41 +++++---- packages/apps/graph/src/index.ts | 17 ++-- .../apps/graph/src/services/node-service.ts | 43 +++++++-- packages/apps/graph/tsconfig.json | 5 +- 23 files changed, 463 insertions(+), 407 deletions(-) diff --git a/packages/apps/graph/generated-schema.graphql b/packages/apps/graph/generated-schema.graphql index 23d70535d9..0615bc02b4 100644 --- a/packages/apps/graph/generated-schema.graphql +++ b/packages/apps/graph/generated-schema.graphql @@ -150,9 +150,9 @@ scalar PositiveFloat type Query { account(accountName: String!, moduleName: String!): ModuleAccount! - block(hash: String!): Block! + block(hash: String!): Block blocksFromHeight(chainIds: [Int!], startHeight: Int!): [Block!]! - chainAccount(accountName: String!, chainId: String!, moduleName: String!): ChainModuleAccount! + chainAccount(accountName: String!, chainId: String!, moduleName: String!): ChainModuleAccount completedBlockHeights(chainIds: [String!], completedHeights: Boolean, heightCount: Int): [Block!]! lastBlockHeight: BigInt maximumConfirmationDepth: Int! diff --git a/packages/apps/graph/src/graph/Query/account.ts b/packages/apps/graph/src/graph/Query/account.ts index 116da141b2..61b25bbf04 100644 --- a/packages/apps/graph/src/graph/Query/account.ts +++ b/packages/apps/graph/src/graph/Query/account.ts @@ -8,7 +8,7 @@ builder.queryField('account', (t) => { moduleName: t.arg.string({ required: true }), }, type: Account, - resolve: async (parent, args) => { + resolve(__parent, args) { return { id: `Account:${args.accountName}`, accountName: args.accountName, diff --git a/packages/apps/graph/src/graph/Query/block.ts b/packages/apps/graph/src/graph/Query/block.ts index 3bea592ea3..ca11e3121e 100644 --- a/packages/apps/graph/src/graph/Query/block.ts +++ b/packages/apps/graph/src/graph/Query/block.ts @@ -1,6 +1,7 @@ +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; -import { prismaClient } from '../../db/prismaClient'; import { builder } from '../builder'; import Block from '../objects/Block'; @@ -11,23 +12,24 @@ builder.queryField('block', (t) => { args: { hash: t.arg.string({ required: true }), }, - type: Block, + nullable: true, + async resolve(__query, __parent, args) { + try { + log('searching for block with hash:', args.hash); - resolve: async (__query, __parent, { hash }) => { - log('searching for block with hash:', hash); + const block = await prismaClient.block.findUnique({ + where: { + hash: args.hash, + }, + }); - const block = await prismaClient.block.findUnique({ - where: { - hash, - }, - }); + log(`block with hash '${args.hash}' ${block ? '' : 'not'} found`); - log('found block', block); - if (!block) { - throw new Error(`Block not found for hash: ${hash}`); + return block; + } catch (error) { + throw normalizeError(error); } - return block; }, }); }); diff --git a/packages/apps/graph/src/graph/Query/blocksFromHeight.ts b/packages/apps/graph/src/graph/Query/blocksFromHeight.ts index aac1e2f356..e6eef0dee4 100644 --- a/packages/apps/graph/src/graph/Query/blocksFromHeight.ts +++ b/packages/apps/graph/src/graph/Query/blocksFromHeight.ts @@ -1,7 +1,8 @@ +import { prismaClient } from '@/db/prismaClient'; +import { dotenv } from '@/utils/dotenv'; +import { normalizeError } from '@/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; -import { prismaClient } from '../../db/prismaClient'; -import { dotenv } from '../../utils/dotenv'; import { builder } from '../builder'; import Block from '../objects/Block'; @@ -13,36 +14,38 @@ builder.queryField('blocksFromHeight', (t) => { startHeight: t.arg.int({ required: true }), chainIds: t.arg.intList({ required: false }), }, - type: [Block], - - resolve: async ( + async resolve( __query, __parent, { startHeight, chainIds = Array.from(new Array(dotenv.CHAIN_COUNT)).map((__, i) => i), }, - ) => { - const blocksFromHeight = await prismaClient.block.findMany({ - where: { - AND: [ - { - height: { - gte: startHeight, + ) { + try { + const blocksFromHeight = await prismaClient.block.findMany({ + where: { + AND: [ + { + height: { + gte: startHeight, + }, }, - }, - { - chainId: { - in: chainIds as number[], + { + chainId: { + in: chainIds as number[], + }, }, - }, - ], - }, - }); + ], + }, + }); - log("found '%s' blocks", blocksFromHeight.length); - return blocksFromHeight; + log("found '%s' blocks", blocksFromHeight.length); + return blocksFromHeight; + } catch (error) { + throw normalizeError(error); + } }, }); }); diff --git a/packages/apps/graph/src/graph/Query/chainAccount.ts b/packages/apps/graph/src/graph/Query/chainAccount.ts index 753cf6bc5f..6c42a1fc54 100644 --- a/packages/apps/graph/src/graph/Query/chainAccount.ts +++ b/packages/apps/graph/src/graph/Query/chainAccount.ts @@ -1,4 +1,5 @@ -import { getAccountDetails } from '../../services/node-service'; +import { getAccountDetails } from '@/services/node-service'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; import ChainModuleAccount from '../objects/ChainModuleAccount'; @@ -10,25 +11,32 @@ builder.queryField('chainAccount', (t) => { chainId: t.arg.string({ required: true }), }, type: ChainModuleAccount, - resolve: async (parent, args) => { - const accountDetails = await getAccountDetails( - args.moduleName, - args.accountName, - args.chainId, - ); + nullable: true, + async resolve(__parent, args) { + try { + const accountDetails = await getAccountDetails( + args.moduleName, + args.accountName, + args.chainId, + ); - return { - chainId: args.chainId, - accountName: args.accountName, - moduleName: args.moduleName, - guard: { - keys: accountDetails.guard.keys, - predicate: accountDetails.guard.pred, - }, - balance: accountDetails.balance, - transactions: [], - transfers: [], - }; + return accountDetails + ? { + chainId: args.chainId, + accountName: args.accountName, + moduleName: args.moduleName, + guard: { + keys: accountDetails.guard.keys, + predicate: accountDetails.guard.pred, + }, + balance: accountDetails.balance, + transactions: [], + transfers: [], + } + : null; + } catch (error) { + throw normalizeError(error); + } }, }); }); diff --git a/packages/apps/graph/src/graph/Query/completedBlockHeights.ts b/packages/apps/graph/src/graph/Query/completedBlockHeights.ts index 14ec7cd317..fb73ea21f3 100644 --- a/packages/apps/graph/src/graph/Query/completedBlockHeights.ts +++ b/packages/apps/graph/src/graph/Query/completedBlockHeights.ts @@ -1,7 +1,8 @@ +import { prismaClient } from '@/db/prismaClient'; +import { dotenv } from '@/utils/dotenv'; +import { normalizeError } from '@/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; -import { prismaClient } from '../../db/prismaClient'; -import { dotenv } from '../../utils/dotenv'; import { builder } from '../builder'; import Block from '../objects/Block'; @@ -17,13 +18,14 @@ builder.queryField('completedBlockHeights', (t) => { type: [Block], - resolve: async ( + async resolve( __query, __parent, { completedHeights: onlyCompleted = false, heightCount = 3 }, - ) => { - if (onlyCompleted === true) { - const completedHeights = (await prismaClient.$queryRaw` + ) { + try { + if (onlyCompleted === true) { + const completedHeights = (await prismaClient.$queryRaw` SELECT height FROM blocks b GROUP BY height @@ -33,36 +35,36 @@ builder.queryField('completedBlockHeights', (t) => { LIMIT ${heightCount} `) as { height: number }[]; - log("found '%s' blocks", completedHeights.length); + log("found '%s' blocks", completedHeights.length); - if (completedHeights.length > 0) { - return prismaClient.block.findMany({ - where: { - AND: [ - { - OR: [ - { - height: { - in: completedHeights.map((h) => h.height), + if (completedHeights.length > 0) { + return prismaClient.block.findMany({ + where: { + AND: [ + { + OR: [ + { + height: { + in: completedHeights.map((h) => h.height), + }, }, - }, - { - height: { - gt: completedHeights[0].height, + { + height: { + gt: completedHeights[0].height, + }, }, - }, - ], - }, - ], - }, - }); + ], + }, + ], + }, + }); + } } - } - return prismaClient.block.findMany({ - where: { - height: { - in: await prismaClient.$queryRaw` + return prismaClient.block.findMany({ + where: { + height: { + in: await prismaClient.$queryRaw` SELECT height, COUNT(*) FROM blocks b GROUP BY height @@ -71,9 +73,12 @@ builder.queryField('completedBlockHeights', (t) => { ORDER BY height DESC LIMIT ${heightCount} `, + }, }, - }, - }); + }); + } catch (error) { + throw normalizeError(error); + } }, }); }); diff --git a/packages/apps/graph/src/graph/Query/lastBlockHeight.ts b/packages/apps/graph/src/graph/Query/lastBlockHeight.ts index 4fcb0f8307..6e73726d77 100644 --- a/packages/apps/graph/src/graph/Query/lastBlockHeight.ts +++ b/packages/apps/graph/src/graph/Query/lastBlockHeight.ts @@ -1,63 +1,29 @@ -// schema: createSchema({ -// typeDefs: [ -// BigIntTypeDefinition, -// DateTypeDefinition, -// PositiveFloatTypeDefinition, -// loadFileAsString('./schema.graphql'), -// ], -import { PrismaClient } from '@prisma/client'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; const log: Debugger = _debug('graph:Query:lastBlockHeight'); -// resolvers: { -// Query: { -// hello: (_, args) => { -// return { -// id: '1', -// name: 'hello', -// }; -// }, -// lastBlockHeight: async (parent, args, context) => { -// const lastBlock = await context.prisma.blocks.findFirst({ -// orderBy: { -// height: 'desc', -// }, -// }); -// return lastBlock?.height; -// }, -// }, - -// Block: { -// chainid: (parent) => BigInt(parent.chainid), -// height: (parent) => BigInt(parent.height), -// }, - -// Subscription: { -// newBlocks: { -// subscribe: () => pubsub.subscribe('NEW_BLOCKS'), -// resolve: (payload) => payload, -// }, -// }, -// }, -// }), - builder.queryField('lastBlockHeight', (t) => { return t.field({ type: 'BigInt', nullable: true, - resolve: async () => { - const lastBlock = await new PrismaClient().block.findFirst({ - orderBy: { - height: 'desc', - }, - }); + async resolve() { + try { + const lastBlock = await prismaClient.block.findFirst({ + orderBy: { + height: 'desc', + }, + }); - log('lastBlock found:', lastBlock?.height); + log('lastBlock found:', lastBlock?.height); - return lastBlock?.height; + return lastBlock?.height; + } catch (error) { + throw normalizeError(error); + } }, }); }); diff --git a/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts b/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts index e9eae58e7d..d9aa26a8fb 100644 --- a/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts +++ b/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts @@ -1,11 +1,11 @@ -import { dotenv } from '../../utils/dotenv'; +import { dotenv } from '@/utils/dotenv'; import { builder } from '../builder'; builder.queryField('maximumConfirmationDepth', (t) => { return t.field({ type: 'Int', nullable: false, - resolve: async () => { + async resolve() { return dotenv.MAX_BLOCK_DEPTH; }, }); diff --git a/packages/apps/graph/src/graph/Query/pactQuery.ts b/packages/apps/graph/src/graph/Query/pactQuery.ts index 77aca97b6e..f272335f96 100644 --- a/packages/apps/graph/src/graph/Query/pactQuery.ts +++ b/packages/apps/graph/src/graph/Query/pactQuery.ts @@ -1,7 +1,5 @@ -import type { ChainId } from '@kadena/client'; -import { Pact } from '@kadena/client'; -import { devnetConfig } from '../../scripts/devnet/config'; -import { dirtyRead } from '../../scripts/devnet/helper'; +import { sendRawQuery } from '@/services/node-service'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; const PactQuery = builder.inputType('PactQuery', { @@ -17,26 +15,14 @@ builder.queryField('pactQueries', (t) => { args: { pactQuery: t.arg({ type: [PactQuery], required: true }), }, - resolve: async (parent, args, context, info) => { - const result = args.pactQuery.map(async (query) => { - const transaction = Pact.builder - .execution(query.code) - .setMeta({ - chainId: query.chainId as ChainId, - }) - .setNetworkId(devnetConfig.NETWORK_ID) - .createTransaction(); - - const response = await dirtyRead(transaction); - - if (response.result.status === 'failure') { - return String(response.result.status); - } - - return JSON.stringify(response.result.data); - }); - - return result; + async resolve(__parent, args) { + try { + return args.pactQuery.map(async (query) => + sendRawQuery(query.code, query.chainId), + ); + } catch (error) { + throw normalizeError(error); + } }, }); }); @@ -47,22 +33,12 @@ builder.queryField('pactQuery', (t) => { args: { pactQuery: t.arg({ type: PactQuery, required: true }), }, - resolve: async (parent, args, context, info) => { - const transaction = Pact.builder - .execution(args.pactQuery.code) - .setMeta({ - chainId: args.pactQuery.chainId as ChainId, - }) - .setNetworkId(devnetConfig.NETWORK_ID) - .createTransaction(); - - const response = await dirtyRead(transaction); - - if (response.result.status === 'failure') { - return String(response.result.status); + async resolve(__parent, args) { + try { + return sendRawQuery(args.pactQuery.code, args.pactQuery.chainId); + } catch (error) { + throw normalizeError(error); } - - return JSON.stringify(response.result.data); }, }); }); diff --git a/packages/apps/graph/src/graph/Query/transactions.ts b/packages/apps/graph/src/graph/Query/transactions.ts index bf8642b245..34979567e8 100644 --- a/packages/apps/graph/src/graph/Query/transactions.ts +++ b/packages/apps/graph/src/graph/Query/transactions.ts @@ -1,5 +1,6 @@ +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import type { Prisma } from '@prisma/client'; -import { prismaClient } from '../../db/prismaClient'; import { builder } from '../builder'; builder.queryField('transactions', (t) => { @@ -12,25 +13,31 @@ builder.queryField('transactions', (t) => { }, type: 'Transaction', cursor: 'blockHash_requestKey', - - totalCount(parent, args, context, info) { - return prismaClient.transaction.count({ - where: generateTransactionFilter(args), - }); + async totalCount(__parent, args) { + try { + return await prismaClient.transaction.count({ + where: generateTransactionFilter(args), + }); + } catch (error) { + throw normalizeError(error); + } }, + async resolve(query, __parent, args) { + try { + const whereFilter = generateTransactionFilter(args); - resolve: (query, parent, args) => { - const whereFilter = generateTransactionFilter(args); - - return prismaClient.transaction.findMany({ - ...query, - where: { - ...whereFilter, - }, - orderBy: { - height: 'desc', - }, - }); + return await prismaClient.transaction.findMany({ + ...query, + where: { + ...whereFilter, + }, + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }); }); diff --git a/packages/apps/graph/src/graph/Query/transfers.ts b/packages/apps/graph/src/graph/Query/transfers.ts index abf0670cf9..7695cbc78a 100644 --- a/packages/apps/graph/src/graph/Query/transfers.ts +++ b/packages/apps/graph/src/graph/Query/transfers.ts @@ -1,4 +1,5 @@ -import { prismaClient } from '../../db/prismaClient'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; builder.queryField('transfers', (t) => { @@ -10,25 +11,29 @@ builder.queryField('transfers', (t) => { }, type: 'Transfer', cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey', - resolve: async (query, parent, args) => { - return prismaClient.transfer.findMany({ - ...query, - where: { - OR: [ - { - senderAccount: args.accountName, - }, - { - receiverAccount: args.accountName, - }, - ], - moduleName: args.moduleName, - ...(args.chainId && { chainId: parseInt(args.chainId) }), - }, - orderBy: { - height: 'desc', - }, - }); + async resolve(query, __parent, args) { + try { + return await prismaClient.transfer.findMany({ + ...query, + where: { + OR: [ + { + senderAccount: args.accountName, + }, + { + receiverAccount: args.accountName, + }, + ], + moduleName: args.moduleName, + ...(args.chainId && { chainId: parseInt(args.chainId) }), + }, + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }); }); diff --git a/packages/apps/graph/src/graph/data-loaders/account-details.ts b/packages/apps/graph/src/graph/data-loaders/account-details.ts index c26a657613..5e3482b622 100644 --- a/packages/apps/graph/src/graph/data-loaders/account-details.ts +++ b/packages/apps/graph/src/graph/data-loaders/account-details.ts @@ -1,5 +1,5 @@ +import { getAccountDetails } from '@/services/node-service'; import DataLoader from 'dataloader'; -import { getAccountDetails } from '../../services/node-service'; interface AccountDetailsKey { moduleName: string; diff --git a/packages/apps/graph/src/graph/objects/Block.ts b/packages/apps/graph/src/graph/objects/Block.ts index f9f7d62611..13d6327c38 100644 --- a/packages/apps/graph/src/graph/objects/Block.ts +++ b/packages/apps/graph/src/graph/objects/Block.ts @@ -1,5 +1,6 @@ -import { prismaClient } from '../../db/prismaClient'; -import { dotenv } from '../../utils/dotenv'; +import { prismaClient } from '@/db/prismaClient'; +import { dotenv } from '@/utils/dotenv'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Block', { @@ -20,18 +21,21 @@ export default builder.prismaNode('Block', { parent: t.prismaField({ type: 'Block', nullable: true, - resolve(query, parent, args, context, info) { - return prismaClient.block.findUnique({ - where: { - hash: parent.parentBlockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.block.findUnique({ + where: { + hash: parent.parentBlockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), - parentHash: t.string({ nullable: true, - resolve: (parent, args, context, info) => { + resolve(parent) { // Access the parent block's hash from the parent object return parent.parentBlockHash; }, @@ -41,41 +45,57 @@ export default builder.prismaNode('Block', { transactions: t.prismaConnection({ type: 'Transaction', cursor: 'blockHash_requestKey', - async totalCount(parent, args, context, info) { - return prismaClient.transaction.count({ - where: { - blockHash: parent.hash, - }, - }); + async totalCount(parent) { + try { + return await prismaClient.transaction.count({ + where: { + blockHash: parent.hash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, - resolve: (query, parent, args, context, info) => { - return prismaClient.transaction.findMany({ - ...query, - where: { - blockHash: parent.hash, - }, - orderBy: { - height: 'desc', - }, - }); + async resolve(query, parent) { + try { + return await prismaClient.transaction.findMany({ + ...query, + where: { + blockHash: parent.hash, + }, + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), minerKeys: t.prismaField({ type: ['MinerKey'], nullable: true, - resolve(query, parent, args, context, info) { - return prismaClient.minerKey.findMany({ - where: { - blockHash: parent.hash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.minerKey.findMany({ + where: { + blockHash: parent.hash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), confirmationDepth: t.int({ - resolve: async (parent, args, context, info) => { - return getConfirmationDepth(parent.hash); + async resolve(parent) { + try { + return await getConfirmationDepth(parent.hash); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts b/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts index d17488d1d8..01461d5fb5 100644 --- a/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts @@ -1,4 +1,5 @@ -import { prismaClient } from '../../db/prismaClient'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; @@ -9,7 +10,7 @@ export default builder.objectType('ChainModuleAccount', { moduleName: t.exposeString('moduleName'), guard: t.field({ type: 'Guard', - resolve: async (parent, args) => { + async resolve(parent) { const accountDetails = await accountDetailsLoader.load({ moduleName: parent.moduleName, accountName: parent.accountName, @@ -26,46 +27,54 @@ export default builder.objectType('ChainModuleAccount', { transactions: t.prismaConnection({ type: 'Transaction', cursor: 'blockHash_requestKey', - resolve: (query, parent) => { - return prismaClient.transaction.findMany({ - ...query, - where: { - senderAccount: parent.accountName, - events: { - some: { - moduleName: parent.moduleName, + async resolve(query, parent) { + try { + return await prismaClient.transaction.findMany({ + ...query, + where: { + senderAccount: parent.accountName, + events: { + some: { + moduleName: parent.moduleName, + }, }, + chainId: parseInt(parent.chainId), }, - chainId: parseInt(parent.chainId), - }, - orderBy: { - height: 'desc', - }, - }); + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), transfers: t.prismaConnection({ type: 'Transfer', cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey', - resolve: async (query, parent) => { - return prismaClient.transfer.findMany({ - ...query, - where: { - OR: [ - { - senderAccount: parent.accountName, - }, - { - receiverAccount: parent.accountName, - }, - ], - moduleName: parent.moduleName, - chainId: parseInt(parent.chainId), - }, - orderBy: { - height: 'desc', - }, - }); + async resolve(query, parent) { + try { + return await prismaClient.transfer.findMany({ + ...query, + where: { + OR: [ + { + senderAccount: parent.accountName, + }, + { + receiverAccount: parent.accountName, + }, + ], + moduleName: parent.moduleName, + chainId: parseInt(parent.chainId), + }, + orderBy: { + height: 'desc', + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/graph/objects/Event.ts b/packages/apps/graph/src/graph/objects/Event.ts index 4feb47ef87..0fc7ae5de5 100644 --- a/packages/apps/graph/src/graph/objects/Event.ts +++ b/packages/apps/graph/src/graph/objects/Event.ts @@ -1,4 +1,5 @@ -import { prismaClient } from '../../db/prismaClient'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Event', { @@ -18,28 +19,35 @@ export default builder.prismaNode('Event', { transaction: t.prismaField({ type: 'Transaction', nullable: true, - resolve(query, parent, args, context, info) { - return prismaClient.transaction.findUnique({ - where: { - blockHash_requestKey: { - blockHash: parent.blockHash, - requestKey: parent.requestKey, + async resolve(__query, parent) { + try { + return await prismaClient.transaction.findUnique({ + where: { + blockHash_requestKey: { + blockHash: parent.blockHash, + requestKey: parent.requestKey, + }, }, - }, - }); + }); + } catch (error) { + throw normalizeError(error); + } }, }), block: t.prismaField({ type: 'Block', nullable: false, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.block.findUniqueOrThrow({ - where: { - hash: parent.blockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.block.findUniqueOrThrow({ + where: { + hash: parent.blockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/graph/objects/MinerKey.ts b/packages/apps/graph/src/graph/objects/MinerKey.ts index 31b44ec27d..edc5dfa888 100644 --- a/packages/apps/graph/src/graph/objects/MinerKey.ts +++ b/packages/apps/graph/src/graph/objects/MinerKey.ts @@ -1,4 +1,5 @@ -import { prismaClient } from '../../db/prismaClient'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('MinerKey', { @@ -12,13 +13,16 @@ export default builder.prismaNode('MinerKey', { block: t.prismaField({ type: 'Block', nullable: false, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.block.findUniqueOrThrow({ - where: { - hash: parent.blockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.block.findUniqueOrThrow({ + where: { + hash: parent.blockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/graph/objects/ModuleAccount.ts b/packages/apps/graph/src/graph/objects/ModuleAccount.ts index a9e74c549e..50e0f9be12 100644 --- a/packages/apps/graph/src/graph/objects/ModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ModuleAccount.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '../../db/prismaClient'; -import { isRowNotFoundError, normalizeError } from '../../utils/errors'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; import type { ChainModuleAccount } from '../types/graphql-types'; @@ -11,7 +11,7 @@ export default builder.objectType('ModuleAccount', { moduleName: t.exposeString('moduleName'), chainAccounts: t.field({ type: ['ChainModuleAccount'], - resolve: async (parent) => { + async resolve(parent) { const chainAccounts: ChainModuleAccount[] = []; for (let i = 0; i < 20; i++) { @@ -22,22 +22,22 @@ export default builder.objectType('ModuleAccount', { chainId: i.toString(), }); - chainAccounts.push({ - chainId: i.toString(), - accountName: parent.accountName, - moduleName: parent.moduleName, - guard: { - keys: accountDetails.guard.keys, - predicate: accountDetails.guard.pred, - }, - balance: accountDetails.balance, - transactions: [], - transfers: [], - }); - } catch (error) { - if (!isRowNotFoundError(error)) { - throw normalizeError(error); + if (accountDetails !== null) { + chainAccounts.push({ + chainId: i.toString(), + accountName: parent.accountName, + moduleName: parent.moduleName, + guard: { + keys: accountDetails.guard.keys, + predicate: accountDetails.guard.pred, + }, + balance: accountDetails.balance, + transactions: [], + transfers: [], + }); } + } catch (error) { + throw normalizeError(error); } } @@ -46,7 +46,7 @@ export default builder.objectType('ModuleAccount', { }), totalBalance: t.field({ type: 'Decimal', - resolve: async (parent) => { + async resolve(parent) { let totalBalance = 0; for (let i = 0; i < 20; i++) { @@ -57,11 +57,11 @@ export default builder.objectType('ModuleAccount', { chainId: i.toString(), }); - totalBalance += accountDetails.balance; - } catch (error) { - if (!isRowNotFoundError(error)) { - throw normalizeError(error); + if (accountDetails !== null) { + totalBalance += accountDetails.balance; } + } catch (error) { + throw normalizeError(error); } } @@ -71,7 +71,7 @@ export default builder.objectType('ModuleAccount', { transactions: t.prismaConnection({ type: 'Transaction', cursor: 'blockHash_requestKey', - resolve: async (query, parent) => { + async resolve(query, parent) { try { return await prismaClient.transaction.findMany({ ...query, @@ -95,7 +95,7 @@ export default builder.objectType('ModuleAccount', { transfers: t.prismaConnection({ type: 'Transfer', cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey', - resolve: async (query, parent) => { + async resolve(query, parent) { try { return await prismaClient.transfer.findMany({ ...query, diff --git a/packages/apps/graph/src/graph/objects/Signer.ts b/packages/apps/graph/src/graph/objects/Signer.ts index a758008f65..35b4d43fe5 100644 --- a/packages/apps/graph/src/graph/objects/Signer.ts +++ b/packages/apps/graph/src/graph/objects/Signer.ts @@ -1,4 +1,4 @@ -import { nullishOrEmpty } from '../../utils/nullishOrEmpty'; +import { nullishOrEmpty } from '@/utils/nullishOrEmpty'; import { builder } from '../builder'; export default builder.prismaNode('Signer', { diff --git a/packages/apps/graph/src/graph/objects/Transaction.ts b/packages/apps/graph/src/graph/objects/Transaction.ts index 7a4106dea9..a32f1c9083 100644 --- a/packages/apps/graph/src/graph/objects/Transaction.ts +++ b/packages/apps/graph/src/graph/objects/Transaction.ts @@ -1,5 +1,6 @@ -import { prismaClient } from '../../db/prismaClient'; -import { nullishOrEmpty } from '../../utils/nullishOrEmpty'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; +import { nullishOrEmpty } from '@/utils/nullishOrEmpty'; import { builder } from '../builder'; export default builder.prismaNode('Transaction', { @@ -73,54 +74,66 @@ export default builder.prismaNode('Transaction', { block: t.prismaField({ type: 'Block', nullable: true, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.block.findUnique({ - where: { - hash: parent.blockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.block.findUnique({ + where: { + hash: parent.blockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), events: t.prismaField({ type: ['Event'], nullable: true, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.event.findMany({ - where: { - requestKey: parent.requestKey, - blockHash: parent.blockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.event.findMany({ + where: { + requestKey: parent.requestKey, + blockHash: parent.blockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), transfers: t.prismaField({ type: ['Transfer'], nullable: true, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.transfer.findMany({ - where: { - requestKey: parent.requestKey, - blockHash: parent.blockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.transfer.findMany({ + where: { + requestKey: parent.requestKey, + blockHash: parent.blockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), signers: t.prismaField({ type: ['Signer'], nullable: true, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.signer.findMany({ - where: { - requestKey: parent.requestKey, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.signer.findMany({ + where: { + requestKey: parent.requestKey, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/graph/objects/Transfer.ts b/packages/apps/graph/src/graph/objects/Transfer.ts index 66db0e91de..43d11f7d5c 100644 --- a/packages/apps/graph/src/graph/objects/Transfer.ts +++ b/packages/apps/graph/src/graph/objects/Transfer.ts @@ -1,4 +1,5 @@ -import { prismaClient } from '../../db/prismaClient'; +import { prismaClient } from '@/db/prismaClient'; +import { normalizeError } from '@/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Transfer', { @@ -19,29 +20,35 @@ export default builder.prismaNode('Transfer', { // relations blocks: t.prismaField({ type: ['Block'], - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.block.findMany({ - where: { - hash: parent.blockHash, - }, - }); + async resolve(__query, parent) { + try { + return await prismaClient.block.findMany({ + where: { + hash: parent.blockHash, + }, + }); + } catch (error) { + throw normalizeError(error); + } }, }), transaction: t.prismaField({ type: 'Transaction', nullable: true, - // eslint-disable-next-line @typescript-eslint/typedef - resolve(query, parent, args, context, info) { - return prismaClient.transaction.findUnique({ - where: { - blockHash_requestKey: { - blockHash: parent.blockHash, - requestKey: parent.requestKey, + async resolve(__query, parent) { + try { + return await prismaClient.transaction.findUnique({ + where: { + blockHash_requestKey: { + blockHash: parent.blockHash, + requestKey: parent.requestKey, + }, }, - }, - }); + }); + } catch (error) { + throw normalizeError(error); + } }, }), }), diff --git a/packages/apps/graph/src/index.ts b/packages/apps/graph/src/index.ts index 0f0397c3bd..03e1747c00 100644 --- a/packages/apps/graph/src/index.ts +++ b/packages/apps/graph/src/index.ts @@ -5,19 +5,12 @@ import './graph'; import { builder } from './graph/builder'; import { writeSchema } from './utils/write-schema'; -// eslint-disable-next-line @rushstack/typedef-var -const schema = builder.toSchema(); - -// eslint-disable-next-line @rushstack/typedef-var -const yoga = createYoga({ - schema, -}); - -// eslint-disable-next-line @rushstack/typedef-var -const server = createServer(yoga); - writeSchema(); -server.listen(4000, () => { +createServer( + createYoga({ + schema: builder.toSchema(), + }), +).listen(4000, () => { console.info('Server is running on http://localhost:4000/graphql'); }); diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index 7a756cb583..38e713abab 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -1,6 +1,6 @@ +import { dotenv } from '@/utils/dotenv'; import type { ChainId, IClient, ICommandResult } from '@kadena/client'; import { Pact, createClient } from '@kadena/client'; -import { dotenv } from '../utils/dotenv'; export class PactCommandError extends Error { public commandResult: ICommandResult; @@ -33,23 +33,32 @@ export async function getAccountDetails( module: string, accountName: string, chainId: string, -): Promise { +): Promise { const commandResult = await getClient(chainId as ChainId).dirtyRead( Pact.builder .execution(Pact.modules[module as 'fungible-v2'].details(accountName)) .setMeta({ chainId: chainId as ChainId, }) - .setNetworkId(dotenv.NETWORK_ID as string) + .setNetworkId(dotenv.NETWORK_ID) .createTransaction(), ); if (commandResult.result.status !== 'success') { - throw new PactCommandError( - 'Pact Command failed with error', - commandResult, - commandResult.result.error, - ); + // If the account does not exist on a chain, we get a row not found error. + if ( + (commandResult.result.error as any).message?.includes( + 'with-read: row not found', + ) + ) { + return null; + } else { + throw new PactCommandError( + 'Pact Command failed with error', + commandResult, + commandResult.result.error, + ); + } } const result = commandResult.result.data as unknown as any; @@ -60,3 +69,21 @@ export async function getAccountDetails( return result as ChainModuleAccountDetails; } + +export async function sendRawQuery(code: string, chainId: string) { + const commandResult = await getClient(chainId as ChainId).dirtyRead( + Pact.builder + .execution(code) + .setMeta({ + chainId: chainId as ChainId, + }) + .setNetworkId(dotenv.NETWORK_ID) + .createTransaction(), + ); + + if (commandResult.result.status === 'failure') { + return String(commandResult.result.status); + } + + return JSON.stringify(commandResult.result.data); +} diff --git a/packages/apps/graph/tsconfig.json b/packages/apps/graph/tsconfig.json index b7be4301aa..f89234a021 100644 --- a/packages/apps/graph/tsconfig.json +++ b/packages/apps/graph/tsconfig.json @@ -2,6 +2,9 @@ "extends": "./node_modules/@kadena-dev/shared-config/tsconfig-base.json", "compilerOptions": { "types": [".kadena/pactjs-generated", "node"], - "target": "ES2020" + "target": "ES2020", + "paths": { + "@/*": ["./src/*"] + } } } From 41120f4c47b9de9cfd5f07f2dd0d46c71a94c934 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Thu, 2 Nov 2023 16:38:53 +0100 Subject: [PATCH 04/74] PactQuery fixed and module aliases fixed --- packages/apps/graph/package.json | 4 +++ packages/apps/graph/src/graph/Query/block.ts | 4 +-- .../graph/src/graph/Query/blocksFromHeight.ts | 6 ++-- .../graph/src/graph/Query/chainAccount.ts | 4 +-- .../src/graph/Query/completedBlockHeights.ts | 6 ++-- .../graph/src/graph/Query/lastBlockHeight.ts | 4 +-- .../graph/Query/maximumConfirmationDepth.ts | 2 +- .../apps/graph/src/graph/Query/pactQuery.ts | 10 +++---- .../graph/src/graph/Query/transactions.ts | 4 +-- .../apps/graph/src/graph/Query/transfers.ts | 4 +-- .../src/graph/data-loaders/account-details.ts | 2 +- .../apps/graph/src/graph/objects/Block.ts | 6 ++-- .../src/graph/objects/ChainModuleAccount.ts | 4 +-- .../apps/graph/src/graph/objects/Event.ts | 4 +-- .../apps/graph/src/graph/objects/MinerKey.ts | 4 +-- .../graph/src/graph/objects/ModuleAccount.ts | 4 +-- .../apps/graph/src/graph/objects/Signer.ts | 2 +- .../graph/src/graph/objects/Transaction.ts | 6 ++-- .../apps/graph/src/graph/objects/Transfer.ts | 4 +-- packages/apps/graph/src/index.ts | 1 + .../apps/graph/src/services/node-service.ts | 30 +++++++++---------- packages/apps/graph/src/utils/errors.ts | 16 +++++++--- packages/apps/graph/tsconfig.json | 2 +- pnpm-lock.yaml | 19 ++++++++---- 24 files changed, 86 insertions(+), 66 deletions(-) diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index 65dd78e16a..581ea0aa0b 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -48,6 +48,7 @@ "graphql-scalars": "~1.22.2", "graphql-yoga": "~4.0.4", "json-bigint-patch": "~0.0.8", + "module-alias": "^2.2.3", "prisma": "^5.1.1", "seedrandom": "~3.0.5" }, @@ -65,5 +66,8 @@ "prettier": "~3.0.3", "ts-node": "~10.8.2", "typescript": "5.2.2" + }, + "_moduleAliases": { + "@src": "src" } } diff --git a/packages/apps/graph/src/graph/Query/block.ts b/packages/apps/graph/src/graph/Query/block.ts index ca11e3121e..ab7dbd3033 100644 --- a/packages/apps/graph/src/graph/Query/block.ts +++ b/packages/apps/graph/src/graph/Query/block.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/blocksFromHeight.ts b/packages/apps/graph/src/graph/Query/blocksFromHeight.ts index e6eef0dee4..4486928334 100644 --- a/packages/apps/graph/src/graph/Query/blocksFromHeight.ts +++ b/packages/apps/graph/src/graph/Query/blocksFromHeight.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@/db/prismaClient'; -import { dotenv } from '@/utils/dotenv'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { dotenv } from '@src/utils/dotenv'; +import { normalizeError } from '@src/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/chainAccount.ts b/packages/apps/graph/src/graph/Query/chainAccount.ts index 6c42a1fc54..0f636419e1 100644 --- a/packages/apps/graph/src/graph/Query/chainAccount.ts +++ b/packages/apps/graph/src/graph/Query/chainAccount.ts @@ -1,5 +1,5 @@ -import { getAccountDetails } from '@/services/node-service'; -import { normalizeError } from '@/utils/errors'; +import { getAccountDetails } from '@src/services/node-service'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; import ChainModuleAccount from '../objects/ChainModuleAccount'; diff --git a/packages/apps/graph/src/graph/Query/completedBlockHeights.ts b/packages/apps/graph/src/graph/Query/completedBlockHeights.ts index fb73ea21f3..6be0abb80e 100644 --- a/packages/apps/graph/src/graph/Query/completedBlockHeights.ts +++ b/packages/apps/graph/src/graph/Query/completedBlockHeights.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@/db/prismaClient'; -import { dotenv } from '@/utils/dotenv'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { dotenv } from '@src/utils/dotenv'; +import { normalizeError } from '@src/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/lastBlockHeight.ts b/packages/apps/graph/src/graph/Query/lastBlockHeight.ts index 6e73726d77..9af3989c46 100644 --- a/packages/apps/graph/src/graph/Query/lastBlockHeight.ts +++ b/packages/apps/graph/src/graph/Query/lastBlockHeight.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts b/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts index d9aa26a8fb..c202ccb640 100644 --- a/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts +++ b/packages/apps/graph/src/graph/Query/maximumConfirmationDepth.ts @@ -1,4 +1,4 @@ -import { dotenv } from '@/utils/dotenv'; +import { dotenv } from '@src/utils/dotenv'; import { builder } from '../builder'; builder.queryField('maximumConfirmationDepth', (t) => { diff --git a/packages/apps/graph/src/graph/Query/pactQuery.ts b/packages/apps/graph/src/graph/Query/pactQuery.ts index f272335f96..5529a8254b 100644 --- a/packages/apps/graph/src/graph/Query/pactQuery.ts +++ b/packages/apps/graph/src/graph/Query/pactQuery.ts @@ -1,5 +1,5 @@ -import { sendRawQuery } from '@/services/node-service'; -import { normalizeError } from '@/utils/errors'; +import { sendRawQuery } from '@src/services/node-service'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; const PactQuery = builder.inputType('PactQuery', { @@ -17,8 +17,8 @@ builder.queryField('pactQueries', (t) => { }, async resolve(__parent, args) { try { - return args.pactQuery.map(async (query) => - sendRawQuery(query.code, query.chainId), + return args.pactQuery.map( + async (query) => await sendRawQuery(query.code, query.chainId), ); } catch (error) { throw normalizeError(error); @@ -35,7 +35,7 @@ builder.queryField('pactQuery', (t) => { }, async resolve(__parent, args) { try { - return sendRawQuery(args.pactQuery.code, args.pactQuery.chainId); + return await sendRawQuery(args.pactQuery.code, args.pactQuery.chainId); } catch (error) { throw normalizeError(error); } diff --git a/packages/apps/graph/src/graph/Query/transactions.ts b/packages/apps/graph/src/graph/Query/transactions.ts index 34979567e8..784bf764ba 100644 --- a/packages/apps/graph/src/graph/Query/transactions.ts +++ b/packages/apps/graph/src/graph/Query/transactions.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; import type { Prisma } from '@prisma/client'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; builder.queryField('transactions', (t) => { diff --git a/packages/apps/graph/src/graph/Query/transfers.ts b/packages/apps/graph/src/graph/Query/transfers.ts index 7695cbc78a..f9794811a4 100644 --- a/packages/apps/graph/src/graph/Query/transfers.ts +++ b/packages/apps/graph/src/graph/Query/transfers.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; builder.queryField('transfers', (t) => { diff --git a/packages/apps/graph/src/graph/data-loaders/account-details.ts b/packages/apps/graph/src/graph/data-loaders/account-details.ts index 5e3482b622..76be78910a 100644 --- a/packages/apps/graph/src/graph/data-loaders/account-details.ts +++ b/packages/apps/graph/src/graph/data-loaders/account-details.ts @@ -1,4 +1,4 @@ -import { getAccountDetails } from '@/services/node-service'; +import { getAccountDetails } from '@src/services/node-service'; import DataLoader from 'dataloader'; interface AccountDetailsKey { diff --git a/packages/apps/graph/src/graph/objects/Block.ts b/packages/apps/graph/src/graph/objects/Block.ts index 13d6327c38..ba24d68644 100644 --- a/packages/apps/graph/src/graph/objects/Block.ts +++ b/packages/apps/graph/src/graph/objects/Block.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@/db/prismaClient'; -import { dotenv } from '@/utils/dotenv'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { dotenv } from '@src/utils/dotenv'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Block', { diff --git a/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts b/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts index 01461d5fb5..ca0d442b69 100644 --- a/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; diff --git a/packages/apps/graph/src/graph/objects/Event.ts b/packages/apps/graph/src/graph/objects/Event.ts index 0fc7ae5de5..f6b914dbe5 100644 --- a/packages/apps/graph/src/graph/objects/Event.ts +++ b/packages/apps/graph/src/graph/objects/Event.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Event', { diff --git a/packages/apps/graph/src/graph/objects/MinerKey.ts b/packages/apps/graph/src/graph/objects/MinerKey.ts index edc5dfa888..4f7fc8880d 100644 --- a/packages/apps/graph/src/graph/objects/MinerKey.ts +++ b/packages/apps/graph/src/graph/objects/MinerKey.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('MinerKey', { diff --git a/packages/apps/graph/src/graph/objects/ModuleAccount.ts b/packages/apps/graph/src/graph/objects/ModuleAccount.ts index 50e0f9be12..6f1b6f797d 100644 --- a/packages/apps/graph/src/graph/objects/ModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ModuleAccount.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; import type { ChainModuleAccount } from '../types/graphql-types'; diff --git a/packages/apps/graph/src/graph/objects/Signer.ts b/packages/apps/graph/src/graph/objects/Signer.ts index 35b4d43fe5..76ddb84477 100644 --- a/packages/apps/graph/src/graph/objects/Signer.ts +++ b/packages/apps/graph/src/graph/objects/Signer.ts @@ -1,4 +1,4 @@ -import { nullishOrEmpty } from '@/utils/nullishOrEmpty'; +import { nullishOrEmpty } from '@src/utils/nullishOrEmpty'; import { builder } from '../builder'; export default builder.prismaNode('Signer', { diff --git a/packages/apps/graph/src/graph/objects/Transaction.ts b/packages/apps/graph/src/graph/objects/Transaction.ts index a32f1c9083..a05c16326f 100644 --- a/packages/apps/graph/src/graph/objects/Transaction.ts +++ b/packages/apps/graph/src/graph/objects/Transaction.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; -import { nullishOrEmpty } from '@/utils/nullishOrEmpty'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; +import { nullishOrEmpty } from '@src/utils/nullishOrEmpty'; import { builder } from '../builder'; export default builder.prismaNode('Transaction', { diff --git a/packages/apps/graph/src/graph/objects/Transfer.ts b/packages/apps/graph/src/graph/objects/Transfer.ts index 43d11f7d5c..1b96e0dff7 100644 --- a/packages/apps/graph/src/graph/objects/Transfer.ts +++ b/packages/apps/graph/src/graph/objects/Transfer.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@/db/prismaClient'; -import { normalizeError } from '@/utils/errors'; +import { prismaClient } from '@src/db/prismaClient'; +import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Transfer', { diff --git a/packages/apps/graph/src/index.ts b/packages/apps/graph/src/index.ts index 03e1747c00..e1d473738a 100644 --- a/packages/apps/graph/src/index.ts +++ b/packages/apps/graph/src/index.ts @@ -1,3 +1,4 @@ +require('module-alias/register'); import { createYoga } from 'graphql-yoga'; import 'json-bigint-patch'; import { createServer } from 'node:http'; diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index 38e713abab..16e7b29d45 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -1,12 +1,12 @@ -import { dotenv } from '@/utils/dotenv'; import type { ChainId, IClient, ICommandResult } from '@kadena/client'; import { Pact, createClient } from '@kadena/client'; +import { dotenv } from '@src/utils/dotenv'; export class PactCommandError extends Error { public commandResult: ICommandResult; public pactError: any; - constructor(message: string, commandResult: ICommandResult, pactError: any) { + constructor(message: string, commandResult: ICommandResult, pactError?: any) { super(message); this.commandResult = commandResult; this.pactError = pactError; @@ -71,19 +71,19 @@ export async function getAccountDetails( } export async function sendRawQuery(code: string, chainId: string) { - const commandResult = await getClient(chainId as ChainId).dirtyRead( - Pact.builder - .execution(code) - .setMeta({ - chainId: chainId as ChainId, - }) - .setNetworkId(dotenv.NETWORK_ID) - .createTransaction(), - ); + try { + const commandResult = await getClient(chainId as ChainId).dirtyRead( + Pact.builder + .execution(code) + .setMeta({ + chainId: chainId as ChainId, + }) + .setNetworkId(dotenv.NETWORK_ID) + .createTransaction(), + ); - if (commandResult.result.status === 'failure') { - return String(commandResult.result.status); + return JSON.stringify(commandResult.result); + } catch (error) { + throw new PactCommandError('Pact Command failed with error', error); } - - return JSON.stringify(commandResult.result.data); } diff --git a/packages/apps/graph/src/utils/errors.ts b/packages/apps/graph/src/utils/errors.ts index 9a721f14d6..a12ffbffad 100644 --- a/packages/apps/graph/src/utils/errors.ts +++ b/packages/apps/graph/src/utils/errors.ts @@ -22,18 +22,26 @@ export function normalizeError(error: any): GraphQLError { if (error instanceof PactCommandError) { let description: string | undefined; - if (error.pactError.message.includes('with-read: row not found')) { + if (error.pactError?.message.includes('with-read: row not found')) { description = 'The requested resource (account, e.g.) was most likely not found.'; - } else if (error.pactError.message.startsWith('Cannot resolve')) { + } else if (error.pactError?.message.startsWith('Cannot resolve')) { description = 'The requested module or function was most likely not found.'; + } else if ( + (error.commandResult as any).message.includes('Failed reading: mzero') + ) { + description = + 'Empty code was most likely sent to the Chainweb Node. Please check your arguments.'; } return new GraphQLError('Chainweb Node Command Failure', { extensions: { - type: error.pactError.type, - message: error.pactError.message, + type: error.pactError?.type || 'UnknownType', + message: + error.pactError?.message || + (error.commandResult as any).message || + error.message, description, data: error.commandResult, }, diff --git a/packages/apps/graph/tsconfig.json b/packages/apps/graph/tsconfig.json index f89234a021..c7143423e9 100644 --- a/packages/apps/graph/tsconfig.json +++ b/packages/apps/graph/tsconfig.json @@ -4,7 +4,7 @@ "types": [".kadena/pactjs-generated", "node"], "target": "ES2020", "paths": { - "@/*": ["./src/*"] + "@src/*": ["./src/*"] } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad3df10ffa..d9f1e34fe4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -330,6 +330,9 @@ importers: json-bigint-patch: specifier: ~0.0.8 version: 0.0.8 + module-alias: + specifier: ^2.2.3 + version: 2.2.3 prisma: specifier: ^5.1.1 version: 5.1.1 @@ -10834,7 +10837,7 @@ packages: chalk: 4.1.2 debug: 4.3.4(supports-color@5.5.0) loader-utils: 2.0.4 - webpack: 5.88.2(webpack-cli@4.9.2) + webpack: 5.88.2(@swc/core@1.3.80)(esbuild@0.18.20) transitivePeerDependencies: - '@types/node' - less @@ -14460,7 +14463,7 @@ packages: eslint: 8.45.0 eslint-import-resolver-node: 0.3.7 eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-plugin-import@2.27.5)(eslint@8.45.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.23.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.59.11)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) eslint-plugin-jsx-a11y: 6.7.1(eslint@8.45.0) eslint-plugin-react: 7.31.11(eslint@8.45.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.45.0) @@ -14509,6 +14512,7 @@ packages: - eslint-import-resolver-node - eslint-import-resolver-webpack - supports-color + dev: false /eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.59.11)(eslint-plugin-import@2.27.5)(eslint@8.45.0): resolution: {integrity: sha512-TdJqPHs2lW5J9Zpe17DZNQuDnox4xo2o+0tE7Pggain9Rbc19ik8kFtXdxZ250FVx2kF4vlt2RSf4qlUpG7bhw==} @@ -14532,7 +14536,6 @@ packages: - eslint-import-resolver-node - eslint-import-resolver-webpack - supports-color - dev: true /eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-plugin-import@2.27.5)(eslint@8.45.0): resolution: {integrity: sha512-TdJqPHs2lW5J9Zpe17DZNQuDnox4xo2o+0tE7Pggain9Rbc19ik8kFtXdxZ250FVx2kF4vlt2RSf4qlUpG7bhw==} @@ -14545,7 +14548,7 @@ packages: enhanced-resolve: 5.15.0 eslint: 8.45.0 eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.23.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.59.11)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0) get-tsconfig: 4.6.2 globby: 13.2.2 is-core-module: 2.12.1 @@ -14585,6 +14588,7 @@ packages: eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.23.0)(eslint-plugin-import@2.27.5)(eslint@8.45.0) transitivePeerDependencies: - supports-color + dev: false /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.59.11)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} @@ -14614,7 +14618,6 @@ packages: eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.59.11)(eslint-plugin-import@2.27.5)(eslint@8.45.0) transitivePeerDependencies: - supports-color - dev: true /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} @@ -14676,6 +14679,7 @@ packages: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color + dev: false /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.59.11)(eslint-import-resolver-typescript@3.5.5)(eslint@8.45.0): resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} @@ -14708,7 +14712,6 @@ packages: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - dev: true /eslint-plugin-jsx-a11y@6.7.1(eslint@8.45.0): resolution: {integrity: sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==} @@ -19746,6 +19749,10 @@ packages: resolution: {integrity: sha512-HdKewQEREEJgsWnErClfbFoVebze6rGazxFLU/XUyrII8dORfVszN1V0BMRnQSzcgsNNtkX8DHj3nC6cdWE9YQ==} dev: false + /module-alias@2.2.3: + resolution: {integrity: sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q==} + dev: false + /moo@0.5.1: resolution: {integrity: sha512-I1mnb5xn4fO80BH9BLcF0yLypy2UKl+Cb01Fu0hJRkJjlCRtxZMWkTdAtDd5ZqCOxtCkhmRwyI57vWT+1iZ67w==} dev: false From 2910a20afec479c91afe6be9f7ef6ebb970f190b Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Fri, 3 Nov 2023 10:43:17 +0100 Subject: [PATCH 05/74] Implement generic error box with proper error emssages --- .../src/components/error-box/error-box.tsx | 43 +++++++++++++++++++ .../account/overview/[module]/[account].tsx | 22 ++++++---- .../overview/[module]/[account]/[chain].tsx | 13 ++---- .../transactions/[module]/[account].tsx | 13 ++---- .../account/transfers/[module]/[account].tsx | 20 ++------- .../src/pages/block/overview/[hash].tsx | 11 +---- .../src/pages/block/transactions/[hash].tsx | 13 ++---- .../graph-client/src/pages/event/[key].tsx | 13 +----- .../src/pages/transactions/[key].tsx | 11 +---- .../src/pages/transactions/index.tsx | 13 ++---- 10 files changed, 77 insertions(+), 95 deletions(-) create mode 100644 packages/apps/graph-client/src/components/error-box/error-box.tsx diff --git a/packages/apps/graph-client/src/components/error-box/error-box.tsx b/packages/apps/graph-client/src/components/error-box/error-box.tsx new file mode 100644 index 0000000000..39ce447807 --- /dev/null +++ b/packages/apps/graph-client/src/components/error-box/error-box.tsx @@ -0,0 +1,43 @@ +import { ApolloError } from '@apollo/client'; +import { Box, Notification } from '@kadena/react-ui'; +import React from 'react'; + +interface IErrorBoxProps { + error: ApolloError; +} + +export const ErrorBox = (props: IErrorBoxProps): JSX.Element => { + const { error } = props; + + let errorTitle = 'Unknown Error Occured'; + let errorMessage = error.message; + let errorExtra; + + if (error.graphQLErrors.length > 0) { + const mainError = error.graphQLErrors[0]; + + if (mainError.extensions) { + errorTitle = (mainError.extensions.message as string) ?? errorTitle; + errorMessage = + (mainError.extensions.description as string) ?? errorMessage; + + if (!mainError.extensions.description) { + errorExtra = JSON.stringify(mainError.extensions.data); + } + } + } + + return ( + + {errorTitle} + + {errorMessage} + {errorExtra !== undefined && ( + <> + + {errorExtra} + + )} + + ); +}; diff --git a/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx b/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx index 139f9b8946..40482723ea 100644 --- a/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx +++ b/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx @@ -1,6 +1,7 @@ import { useGetAccountQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import { ChainModuleAccountTable } from '@components/chain-module-account-table/chain-module-account-table'; import { CompactTransactionsTable } from '@components/compact-transactions-table/compact-transactions-table'; import { CompactTransfersTable } from '@components/compact-transfers-table/compact-transfers-table'; @@ -39,15 +40,18 @@ const Account: React.FC = () => { Retrieving account information... )} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } + {accountQuery?.account && + accountQuery?.account?.totalBalance === 0 && + accountQuery?.account?.chainAccounts.length === 0 && ( + <> + + We could not find any data on this account. Please check the + module and account name. + + + + )} {accountQuery?.account && (
diff --git a/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx b/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx index 14ef457f39..2da1aa1020 100644 --- a/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx +++ b/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx @@ -1,10 +1,11 @@ import { useGetChainAccountQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import { CompactTransactionsTable } from '@components/compact-transactions-table/compact-transactions-table'; import { CompactTransfersTable } from '@components/compact-transfers-table/compact-transfers-table'; import routes from '@constants/routes'; -import { Box, Breadcrumbs, Grid, Notification, Table } from '@kadena/react-ui'; +import { Box, Breadcrumbs, Grid, Table } from '@kadena/react-ui'; import { useRouter } from 'next/router'; import React from 'react'; @@ -46,15 +47,7 @@ const ChainAccount: React.FC = () => { Retrieving account information...
)} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {chainAccountQuery?.chainAccount && (
diff --git a/packages/apps/graph-client/src/pages/account/transactions/[module]/[account].tsx b/packages/apps/graph-client/src/pages/account/transactions/[module]/[account].tsx index f519facfe4..8b2bb0bff1 100644 --- a/packages/apps/graph-client/src/pages/account/transactions/[module]/[account].tsx +++ b/packages/apps/graph-client/src/pages/account/transactions/[module]/[account].tsx @@ -1,9 +1,10 @@ import { useGetTransactionsQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import { ExtendedTransactionsTable } from '@/components/extended-transactions-table/extended-transactions-table'; import routes from '@/constants/routes'; -import { Box, Breadcrumbs, Notification } from '@kadena/react-ui'; +import { Box, Breadcrumbs } from '@kadena/react-ui'; import { useRouter } from 'next/router'; import React from 'react'; @@ -42,15 +43,7 @@ const AccountTransactions: React.FC = () => { Retrieving transactions...
)} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {data?.transactions && ( { Retrieving transfers... )} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {data?.transfers && ( <> diff --git a/packages/apps/graph-client/src/pages/block/overview/[hash].tsx b/packages/apps/graph-client/src/pages/block/overview/[hash].tsx index 30eb6a85ef..8ce1edf070 100644 --- a/packages/apps/graph-client/src/pages/block/overview/[hash].tsx +++ b/packages/apps/graph-client/src/pages/block/overview/[hash].tsx @@ -4,6 +4,7 @@ import { } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import { CompactTransactionsTable } from '@components/compact-transactions-table/compact-transactions-table'; import { Text } from '@components/text'; import routes from '@constants/routes'; @@ -49,15 +50,7 @@ const Block: React.FC = () => { )} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {data?.block && (
diff --git a/packages/apps/graph-client/src/pages/block/transactions/[hash].tsx b/packages/apps/graph-client/src/pages/block/transactions/[hash].tsx index 544208d1da..941474910b 100644 --- a/packages/apps/graph-client/src/pages/block/transactions/[hash].tsx +++ b/packages/apps/graph-client/src/pages/block/transactions/[hash].tsx @@ -1,9 +1,10 @@ import { useGetTransactionsQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import { ExtendedTransactionsTable } from '@/components/extended-transactions-table/extended-transactions-table'; import routes from '@/constants/routes'; -import { Box, Breadcrumbs, Notification } from '@kadena/react-ui'; +import { Box, Breadcrumbs } from '@kadena/react-ui'; import { useRouter } from 'next/router'; import React from 'react'; @@ -34,15 +35,7 @@ const BlockTransactions: React.FC = () => { Retrieving transactions...
)} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {data?.transactions && ( { )} - {error && ( - - Unknown error: -
-
- {error.message} -
-
- Check if the Graph server is running. -
- )} + {error && } {eventSubscription?.event && (
diff --git a/packages/apps/graph-client/src/pages/transactions/[key].tsx b/packages/apps/graph-client/src/pages/transactions/[key].tsx index f7362d27ad..b634eef7d6 100644 --- a/packages/apps/graph-client/src/pages/transactions/[key].tsx +++ b/packages/apps/graph-client/src/pages/transactions/[key].tsx @@ -1,6 +1,7 @@ import { useGetTransactionByRequestKeySubscription } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import routes from '@/constants/routes'; import { formatCode, formatLisp } from '@/utils/formatter'; import { Box, Breadcrumbs, Link, Notification, Table } from '@kadena/react-ui'; @@ -36,15 +37,7 @@ const RequestKey: React.FC = () => { Waiting for request key...
)} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {transactionSubscription?.transaction && (
{/* center content inside the div */} diff --git a/packages/apps/graph-client/src/pages/transactions/index.tsx b/packages/apps/graph-client/src/pages/transactions/index.tsx index 36f6862043..f5aae3a0c7 100644 --- a/packages/apps/graph-client/src/pages/transactions/index.tsx +++ b/packages/apps/graph-client/src/pages/transactions/index.tsx @@ -1,8 +1,9 @@ -import { Box, Breadcrumbs, Notification } from '@kadena/react-ui'; +import { Box, Breadcrumbs } from '@kadena/react-ui'; import { useGetTransactionsQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import { ExtendedTransactionsTable } from '@/components/extended-transactions-table/extended-transactions-table'; import routes from '@/constants/routes'; import React from 'react'; @@ -27,15 +28,7 @@ const Transactions: React.FC = () => { Retrieving transactions...
)} - {error && ( - - Unknown error: - - {error.message} - - Check if the Graph server is running. - - )} + {error && } {data?.transactions && ( Date: Fri, 3 Nov 2023 14:09:35 +0100 Subject: [PATCH 06/74] update react-ui codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9aa33df064..74a1ab5158 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -15,7 +15,7 @@ /packages/libs/client-utils @alber70g @javadkh2 /packages/libs/kadena.js @alber70g /packages/libs/pactjs-generator @alber70g @javadkh2 -/packages/libs/react-ui @eileenmguo @sstraatemans +/packages/libs/react-ui @eileenmguo @sstraatemans @salamaashoush /packages/libs/types @alber70g /packages/tools/eslint-config @alber70g /packages/tools/eslint-plugin @alber70g From 497e2a9b4380b506d8ce699a6931eb1c6b27e4bd Mon Sep 17 00:00:00 2001 From: Jesse van Muijden Date: Fri, 3 Nov 2023 12:13:50 -0400 Subject: [PATCH 07/74] feat(docs): refactor voting dapp tutorial gas station implementation --- .changeset/spotty-suits-explode.md | 5 +++ .../election-dapp-tutorial/09-gas-station.md | 35 ++++++------------- 2 files changed, 16 insertions(+), 24 deletions(-) create mode 100644 .changeset/spotty-suits-explode.md diff --git a/.changeset/spotty-suits-explode.md b/.changeset/spotty-suits-explode.md new file mode 100644 index 0000000000..b0131bba44 --- /dev/null +++ b/.changeset/spotty-suits-explode.md @@ -0,0 +1,5 @@ +--- +'@kadena/docs': patch +--- + +refactor voting dapp tutorial gas station implementation diff --git a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md index 1e8234f6da..bc22c8a921 100644 --- a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md +++ b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md @@ -214,12 +214,9 @@ The test will now fail with `Error: found unimplemented member while resolving model constraints: create-gas-payer-guard`. Indeed, there is a function `create-gas-payer-guard` defined in the `gas-payer-v1` interface that still needs to be implemented. The documentation inside is a bit cryptic, but it suggests -to require something like the `GAS_PAYER` capability without the parameters. You can use -the `GAS` capability from the `coin` module here. After all, in Chainweaver's module explorer -you can find that this capability is documented as `Magic capability to protect gas buy and redeem`. -Sounds legit! Implement `create-gas-payer-guard` as follows, using the built-in functions -`create-user-guard` and `require-capability`. You can use `GAS` directly if you load the -`coin` module in the `election-gas-station` module. +to require something like the `GAS_PAYER` capability without the parameters. To achieve this, +you can leverage the built-in function `create-capability-guard` and pass the `ALLOW_GAS` +capability into it. The function will return a guard that requires the respective capability. ```pact (namespace 'n_fd020525c953aa002f20fb81a920982b175cdf1a) @@ -231,8 +228,6 @@ Sounds legit! Implement `create-gas-payer-guard` as follows, using the built-in (implements gas-payer-v1) - (use coin) - (defcap GAS_PAYER:bool ( user:string limit:integer @@ -244,11 +239,7 @@ Sounds legit! Implement `create-gas-payer-guard` as follows, using the built-in (defcap ALLOW_GAS () true) (defun create-gas-payer-guard:guard () - (create-user-guard (gas-payer-guard)) - ) - - (defun gas-payer-guard () - (require-capability (GAS)) + (create-capability-guard (ALLOW_GAS)) ) ) ``` @@ -300,16 +291,12 @@ function change the line `.addSigner(accountKey(account))` into the following. ```pact .addSigner(accountKey(account), (withCapability) => [ withCapability(`${NAMESPACE}.election-gas-station.GAS_PAYER`, account, { int: 0 }, { decimal: '0.0' }), - withCapability('coin.GAS'), ]) ``` -This scopes the signature of the account that votes to two capabilities. The `coin.GAS` capability is used -in the `create-gas-payer-guard` function of the `election-gas-station` module. The voter account name and -zero (unlimited) limits for the amount of gas and the gas price are passed into the -`${NAMESPACE}.election-gas-station.GAS_PAYER` capability. - -Also, change the `senderAccount` in the transaction's metadata to `'election-gas-station'`. +This scopes the signature of the account that votes to the `GAS_PAYER` capability. The voter account name and +zero (unlimited) limits for the amount of gas and the gas price are passed as arguments. Also, change the +`senderAccount` in the transaction's metadata to `'election-gas-station'`. Return to the election website and try to vote again with the voter account. The transaction will still fail with the error: `Failure: Tx Failed: Insufficient funds`. Apparently, the gas station does not work as it is @@ -319,8 +306,8 @@ Otherwise, the transaction will still fail due to insufficient funds in the gas ## Create and fund the gas station account -The `coin` module is already imported inside the `election-gas-station` module. You can use it to create the -`election-gas-station` account in a function called `init`, as follows. +You can use the `create-account` function of the `coin` module to create the +`election-gas-station` account in a function called `init` in the `election-gas-station` module, as follows. ```pact (defconst GAS_STATION_ACCOUNT "election-gas-station") @@ -430,10 +417,10 @@ The `caps` field in the signature passed to `env-sigs` is an empty array. As a c signature of the transaction is not scoped to any capability and the signer automatically approves all capabilities required for the function execution. In the `vote` function of `frontend/src/repositories/vote/DevnetVoteRepository.ts` you scoped the signature of the -transaction to two gas related capabilities, but not to the `ACCOUNT-OWNER` capability. When +transaction to the `GAS_PAYER` capability, but not to the `ACCOUNT-OWNER` capability. When you sign for some capabilities but not all capabilities required for execution of a transaction, the execution will fail at the point where a capability is required that you did not sign for. -Therefore, you need to add a third capability to the array passed to `addSigners` in +Therefore, you need to add a second capability to the array passed to `addSigners` in the `vote` function in `frontend/src/repositories/vote/DevnetVoteRepository.ts`. ```typescript From 6ac3be20523ae470c3321f4c903a6e75d3535af0 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 11:12:04 +0100 Subject: [PATCH 08/74] Throw error on not success for pact queries --- .../apps/graph/src/services/node-service.ts | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index 16e7b29d45..ad3c4f3574 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -71,19 +71,23 @@ export async function getAccountDetails( } export async function sendRawQuery(code: string, chainId: string) { - try { - const commandResult = await getClient(chainId as ChainId).dirtyRead( - Pact.builder - .execution(code) - .setMeta({ - chainId: chainId as ChainId, - }) - .setNetworkId(dotenv.NETWORK_ID) - .createTransaction(), - ); + const commandResult = await getClient(chainId as ChainId).dirtyRead( + Pact.builder + .execution(code) + .setMeta({ + chainId: chainId as ChainId, + }) + .setNetworkId(dotenv.NETWORK_ID) + .createTransaction(), + ); - return JSON.stringify(commandResult.result); - } catch (error) { - throw new PactCommandError('Pact Command failed with error', error); + if (commandResult.result.status !== 'success') { + throw new PactCommandError( + 'Pact Command failed with error', + commandResult, + commandResult.result.error, + ); } + + return JSON.stringify(commandResult.result.data); } From 38c5839945764478c4685beff19dfd7b38bd7a35 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 11:18:48 +0100 Subject: [PATCH 09/74] changed file --- .../apps/graph/src/services/node-service.ts | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index ad3c4f3574..e19a075c40 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -13,6 +13,12 @@ export class PactCommandError extends Error { } } +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions +export type CommandData = { + key: string; + value: string; +}; + // eslint-disable-next-line @typescript-eslint/consistent-type-definitions export type ChainModuleAccountDetails = { account: string; @@ -70,15 +76,26 @@ export async function getAccountDetails( return result as ChainModuleAccountDetails; } -export async function sendRawQuery(code: string, chainId: string) { +export async function sendRawQuery( + code: string, + chainId: string, + data?: CommandData[], +) { + const commandBuilder = Pact.builder + .execution(code) + .setMeta({ + chainId: chainId as ChainId, + }) + .setNetworkId(dotenv.NETWORK_ID); + + if (data) { + data.forEach((data) => { + commandBuilder.addData(data.key, data.value); + }); + } + const commandResult = await getClient(chainId as ChainId).dirtyRead( - Pact.builder - .execution(code) - .setMeta({ - chainId: chainId as ChainId, - }) - .setNetworkId(dotenv.NETWORK_ID) - .createTransaction(), + commandBuilder.createTransaction(), ); if (commandResult.result.status !== 'success') { From f2419e7544ec599a7a30d6a6c5bad80ae7072cc4 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 11:21:34 +0100 Subject: [PATCH 10/74] linting --- packages/apps/graph/src/graph/Query/pactQuery.ts | 3 ++- packages/apps/graph/src/services/node-service.ts | 2 +- packages/apps/graph/src/utils/errors.ts | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apps/graph/src/graph/Query/pactQuery.ts b/packages/apps/graph/src/graph/Query/pactQuery.ts index b8751e5358..2493a68ed9 100644 --- a/packages/apps/graph/src/graph/Query/pactQuery.ts +++ b/packages/apps/graph/src/graph/Query/pactQuery.ts @@ -1,4 +1,5 @@ -import { CommandData, sendRawQuery } from '@src/services/node-service'; +import type { CommandData } from '@src/services/node-service'; +import { sendRawQuery } from '@src/services/node-service'; import { normalizeError } from '@src/utils/errors'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index e19a075c40..2d0b828925 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -80,7 +80,7 @@ export async function sendRawQuery( code: string, chainId: string, data?: CommandData[], -) { +): Promise { const commandBuilder = Pact.builder .execution(code) .setMeta({ diff --git a/packages/apps/graph/src/utils/errors.ts b/packages/apps/graph/src/utils/errors.ts index a12ffbffad..717c764fbe 100644 --- a/packages/apps/graph/src/utils/errors.ts +++ b/packages/apps/graph/src/utils/errors.ts @@ -1,4 +1,3 @@ -import type { ICommandResult } from '@kadena/chainweb-node-client'; import { PrismaClientInitializationError } from '@prisma/client/runtime/library'; import { GraphQLError } from 'graphql'; import { PactCommandError } from '../services/node-service'; From 6e4895050b111b9ff092fb826506a85ccd7dfcdd Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 11:22:29 +0100 Subject: [PATCH 11/74] Changeste added --- .changeset/violet-chairs-yawn.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/violet-chairs-yawn.md diff --git a/.changeset/violet-chairs-yawn.md b/.changeset/violet-chairs-yawn.md new file mode 100644 index 0000000000..cc6002cd22 --- /dev/null +++ b/.changeset/violet-chairs-yawn.md @@ -0,0 +1,6 @@ +--- +'@kadena/graph-client': patch +'@kadena/graph': patch +--- + +Added proper error logging for the graph and client From 4961719f1dc44c9afb04df231de95bab2a39a056 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 11:36:41 +0100 Subject: [PATCH 12/74] linting --- .../graph-client/src/components/error-box/error-box.tsx | 2 +- .../graph-client/src/pages/block/overview/[hash].tsx | 9 +-------- packages/apps/graph-client/src/pages/event/[key].tsx | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/apps/graph-client/src/components/error-box/error-box.tsx b/packages/apps/graph-client/src/components/error-box/error-box.tsx index 39ce447807..18765a69d3 100644 --- a/packages/apps/graph-client/src/components/error-box/error-box.tsx +++ b/packages/apps/graph-client/src/components/error-box/error-box.tsx @@ -1,4 +1,4 @@ -import { ApolloError } from '@apollo/client'; +import type { ApolloError } from '@apollo/client'; import { Box, Notification } from '@kadena/react-ui'; import React from 'react'; diff --git a/packages/apps/graph-client/src/pages/block/overview/[hash].tsx b/packages/apps/graph-client/src/pages/block/overview/[hash].tsx index fc12652f80..fbb260825b 100644 --- a/packages/apps/graph-client/src/pages/block/overview/[hash].tsx +++ b/packages/apps/graph-client/src/pages/block/overview/[hash].tsx @@ -8,14 +8,7 @@ import { ErrorBox } from '@/components/error-box/error-box'; import { CompactTransactionsTable } from '@components/compact-transactions-table/compact-transactions-table'; import { Text } from '@components/text'; import routes from '@constants/routes'; -import { - Accordion, - Box, - Breadcrumbs, - Link, - Notification, - Table, -} from '@kadena/react-ui'; +import { Accordion, Box, Breadcrumbs, Link, Table } from '@kadena/react-ui'; import { useRouter } from 'next/router'; import React from 'react'; diff --git a/packages/apps/graph-client/src/pages/event/[key].tsx b/packages/apps/graph-client/src/pages/event/[key].tsx index ff1f8c0349..2f562eb07a 100644 --- a/packages/apps/graph-client/src/pages/event/[key].tsx +++ b/packages/apps/graph-client/src/pages/event/[key].tsx @@ -4,7 +4,7 @@ import { mainStyle } from '@/components/Common/main/styles.css'; import { ErrorBox } from '@/components/error-box/error-box'; import { formatCode } from '@/utils/formatter'; import routes from '@constants/routes'; -import { Box, Breadcrumbs, Notification, Table } from '@kadena/react-ui'; +import { Box, Breadcrumbs, Table } from '@kadena/react-ui'; import { useRouter } from 'next/router'; import React from 'react'; From 1c6c83ce6c4d4e64bd3f485d5dd0f8b0e59be843 Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Mon, 6 Nov 2023 12:03:13 +0100 Subject: [PATCH 13/74] fix(client): correct pred function for keysets --- .../libs/client-utils/src/coin/create-account.ts | 2 +- packages/libs/client-utils/src/coin/rotate.ts | 2 +- .../libs/client-utils/src/coin/transfer-create.ts | 2 +- .../client-utils/src/coin/transfer-crosschain.ts | 2 +- .../libs/client/src/composePactCommand/README.md | 14 +++++++------- .../client/src/composePactCommand/utils/addData.ts | 2 +- .../utils/tests/addKeyset.test.ts | 4 ++-- .../createTransactionBuilder.ts | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/libs/client-utils/src/coin/create-account.ts b/packages/libs/client-utils/src/coin/create-account.ts index 1248b54440..708d46dc96 100644 --- a/packages/libs/client-utils/src/coin/create-account.ts +++ b/packages/libs/client-utils/src/coin/create-account.ts @@ -15,7 +15,7 @@ interface ICreateAccountCommandInput { account: string; keyset: { keys: string[]; - pred: 'keys-all' | 'keys-two' | 'keys-one'; + pred: 'keys-all' | 'keys-2' | 'keys-any'; }; gasPayer: { account: string; publicKeys: string[] }; chainId: ChainId; diff --git a/packages/libs/client-utils/src/coin/rotate.ts b/packages/libs/client-utils/src/coin/rotate.ts index 6eed44ae3f..dd17f93762 100644 --- a/packages/libs/client-utils/src/coin/rotate.ts +++ b/packages/libs/client-utils/src/coin/rotate.ts @@ -15,7 +15,7 @@ interface IRotateCommandInput { account: { account: string; publicKeys: string[] }; newguard: { keys: string[]; - pred: 'keys-all' | 'keys-two' | 'keys-one'; + pred: 'keys-all' | 'keys-2' | 'keys-any'; }; gasPayer: { account: string; publicKeys: string[] }; chainId: ChainId; diff --git a/packages/libs/client-utils/src/coin/transfer-create.ts b/packages/libs/client-utils/src/coin/transfer-create.ts index 047da1b355..336ae0b073 100644 --- a/packages/libs/client-utils/src/coin/transfer-create.ts +++ b/packages/libs/client-utils/src/coin/transfer-create.ts @@ -17,7 +17,7 @@ interface ICreateTransferInput { account: string; keyset: { keys: string[]; - pred: 'keys-all' | 'keys-two' | 'keys-one'; + pred: 'keys-all' | 'keys-2' | 'keys-any'; }; }; amount: string; diff --git a/packages/libs/client-utils/src/coin/transfer-crosschain.ts b/packages/libs/client-utils/src/coin/transfer-crosschain.ts index 38d926d0a9..385be494e9 100644 --- a/packages/libs/client-utils/src/coin/transfer-crosschain.ts +++ b/packages/libs/client-utils/src/coin/transfer-crosschain.ts @@ -17,7 +17,7 @@ interface ICrossChainInput { account: string; keyset: { keys: string[]; - pred: 'keys-all' | 'keys-two' | 'keys-one'; + pred: 'keys-all' | 'keys-2' | 'keys-any'; }; }; amount: string; diff --git a/packages/libs/client/src/composePactCommand/README.md b/packages/libs/client/src/composePactCommand/README.md index 099a39d3eb..a6805a3a6e 100644 --- a/packages/libs/client/src/composePactCommand/README.md +++ b/packages/libs/client/src/composePactCommand/README.md @@ -166,11 +166,11 @@ const command = { add keyset to the data part -| parameter | type | description | -| ------------- | ------------------------------------------------ | -------------------------------------------- | -| name | string | name of the keyset | -| pred | "keys-all" \| "keys-one" \| "keys-two" \| string | type of pred | -| ...publicKeys | string[] | list of the public keys to add to the keyset | +| parameter | type | description | +| ------------- | ---------------------------------------------- | -------------------------------------------- | +| name | string | name of the keyset | +| pred | "keys-all" \| "keys-any" \| "keys-2" \| string | type of pred | +| ...publicKeys | string[] | list of the public keys to add to the keyset |
examples @@ -180,7 +180,7 @@ const command = composePactCommand( execution( coin.transfer(readKeyset("senderKey"), "bob", { decimal: "1.1" }) ), - addKeyset("senderKey","keys-one", "the_public_key") + addKeyset("senderKey","keys-any", "the_public_key") )() // @@ -190,7 +190,7 @@ const command = { data: { senderKey: { publicKeys: ['the_public_key'], - pred: "keys-one" + pred: "keys-any" } } } diff --git a/packages/libs/client/src/composePactCommand/utils/addData.ts b/packages/libs/client/src/composePactCommand/utils/addData.ts index c28145a69d..271fb3d532 100644 --- a/packages/libs/client/src/composePactCommand/utils/addData.ts +++ b/packages/libs/client/src/composePactCommand/utils/addData.ts @@ -62,7 +62,7 @@ export const addData: ( }; export interface IAddKeyset { - ( + ( key: TKey, pred: PRED, ...publicKeys: string[] diff --git a/packages/libs/client/src/composePactCommand/utils/tests/addKeyset.test.ts b/packages/libs/client/src/composePactCommand/utils/tests/addKeyset.test.ts index 021772e13d..e5db84d5c0 100644 --- a/packages/libs/client/src/composePactCommand/utils/tests/addKeyset.test.ts +++ b/packages/libs/client/src/composePactCommand/utils/tests/addKeyset.test.ts @@ -3,13 +3,13 @@ import { addKeyset } from '../addKeyset'; describe('addKeyset', () => { it('returns keyset data format', () => { - expect(addKeyset('test', 'keys-one', 'p1', 'p2')({})).toEqual({ + expect(addKeyset('test', 'keys-any', 'p1', 'p2')({})).toEqual({ payload: { exec: { data: { test: { keys: ['p1', 'p2'], - pred: 'keys-one', + pred: 'keys-any', }, }, }, diff --git a/packages/libs/client/src/createTransactionBuilder/createTransactionBuilder.ts b/packages/libs/client/src/createTransactionBuilder/createTransactionBuilder.ts index d66cee4db7..96a18c4e3d 100644 --- a/packages/libs/client/src/createTransactionBuilder/createTransactionBuilder.ts +++ b/packages/libs/client/src/createTransactionBuilder/createTransactionBuilder.ts @@ -58,7 +58,7 @@ interface ISetNonce { } interface IAddKeyset { - ( + ( key: TKey, pred: PRED, ...publicKeys: string[] From 445fb2c7d864f592090578896781e851b2b7a5de Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Mon, 6 Nov 2023 12:05:38 +0100 Subject: [PATCH 14/74] chore: changeset --- .changeset/pretty-balloons-love.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/pretty-balloons-love.md diff --git a/.changeset/pretty-balloons-love.md b/.changeset/pretty-balloons-love.md new file mode 100644 index 0000000000..df5603bc3a --- /dev/null +++ b/.changeset/pretty-balloons-love.md @@ -0,0 +1,6 @@ +--- +'@kadena/client': patch +'@kadena/client-utils': patch +--- + +Fix pred type for keysets From cfcc5482e4062e5aae2487cb6eca03b90f66d070 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 13:48:32 +0100 Subject: [PATCH 15/74] Altered module aliases and the import of it --- packages/apps/graph/package.json | 4 +++- packages/apps/graph/src/graph/Query/block.ts | 4 ++-- packages/apps/graph/src/graph/Query/blocksFromHeight.ts | 6 +++--- packages/apps/graph/src/graph/Query/chainAccount.ts | 4 ++-- .../apps/graph/src/graph/Query/completedBlockHeights.ts | 6 +++--- packages/apps/graph/src/graph/Query/lastBlockHeight.ts | 4 ++-- packages/apps/graph/src/graph/Query/pactQuery.ts | 6 +++--- packages/apps/graph/src/graph/Query/transactions.ts | 4 ++-- packages/apps/graph/src/graph/Query/transfers.ts | 4 ++-- .../apps/graph/src/graph/data-loaders/account-details.ts | 2 +- packages/apps/graph/src/graph/objects/Block.ts | 6 +++--- packages/apps/graph/src/graph/objects/ChainModuleAccount.ts | 4 ++-- packages/apps/graph/src/graph/objects/Event.ts | 4 ++-- packages/apps/graph/src/graph/objects/MinerKey.ts | 4 ++-- packages/apps/graph/src/graph/objects/ModuleAccount.ts | 4 ++-- packages/apps/graph/src/graph/objects/Signer.ts | 2 +- packages/apps/graph/src/graph/objects/Transaction.ts | 6 +++--- packages/apps/graph/src/graph/objects/Transfer.ts | 4 ++-- packages/apps/graph/src/index.ts | 2 +- packages/apps/graph/src/services/node-service.ts | 2 +- packages/apps/graph/tsconfig.json | 4 +++- 21 files changed, 45 insertions(+), 41 deletions(-) diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index 581ea0aa0b..541b3ef9dd 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -68,6 +68,8 @@ "typescript": "5.2.2" }, "_moduleAliases": { - "@src": "src" + "@db": "src/db", + "@services": "src/services", + "@utils": "src/utils" } } diff --git a/packages/apps/graph/src/graph/Query/block.ts b/packages/apps/graph/src/graph/Query/block.ts index ab7dbd3033..8ab0f83260 100644 --- a/packages/apps/graph/src/graph/Query/block.ts +++ b/packages/apps/graph/src/graph/Query/block.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/blocksFromHeight.ts b/packages/apps/graph/src/graph/Query/blocksFromHeight.ts index 4486928334..7312ffe0fc 100644 --- a/packages/apps/graph/src/graph/Query/blocksFromHeight.ts +++ b/packages/apps/graph/src/graph/Query/blocksFromHeight.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { dotenv } from '@src/utils/dotenv'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { dotenv } from '@utils/dotenv'; +import { normalizeError } from '@utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/chainAccount.ts b/packages/apps/graph/src/graph/Query/chainAccount.ts index 0f636419e1..2ea1f94352 100644 --- a/packages/apps/graph/src/graph/Query/chainAccount.ts +++ b/packages/apps/graph/src/graph/Query/chainAccount.ts @@ -1,5 +1,5 @@ -import { getAccountDetails } from '@src/services/node-service'; -import { normalizeError } from '@src/utils/errors'; +import { getAccountDetails } from '@services/node-service'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; import ChainModuleAccount from '../objects/ChainModuleAccount'; diff --git a/packages/apps/graph/src/graph/Query/completedBlockHeights.ts b/packages/apps/graph/src/graph/Query/completedBlockHeights.ts index 6be0abb80e..7b5418cb6d 100644 --- a/packages/apps/graph/src/graph/Query/completedBlockHeights.ts +++ b/packages/apps/graph/src/graph/Query/completedBlockHeights.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { dotenv } from '@src/utils/dotenv'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { dotenv } from '@utils/dotenv'; +import { normalizeError } from '@utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/lastBlockHeight.ts b/packages/apps/graph/src/graph/Query/lastBlockHeight.ts index 9af3989c46..488ff3d341 100644 --- a/packages/apps/graph/src/graph/Query/lastBlockHeight.ts +++ b/packages/apps/graph/src/graph/Query/lastBlockHeight.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import type { Debugger } from 'debug'; import _debug from 'debug'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Query/pactQuery.ts b/packages/apps/graph/src/graph/Query/pactQuery.ts index 2493a68ed9..6f3bc88011 100644 --- a/packages/apps/graph/src/graph/Query/pactQuery.ts +++ b/packages/apps/graph/src/graph/Query/pactQuery.ts @@ -1,6 +1,6 @@ -import type { CommandData } from '@src/services/node-service'; -import { sendRawQuery } from '@src/services/node-service'; -import { normalizeError } from '@src/utils/errors'; +import type { CommandData } from '@services/node-service'; +import { sendRawQuery } from '@services/node-service'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; const PactData = builder.inputType('PactQueryData', { diff --git a/packages/apps/graph/src/graph/Query/transactions.ts b/packages/apps/graph/src/graph/Query/transactions.ts index 784bf764ba..79017b7a8c 100644 --- a/packages/apps/graph/src/graph/Query/transactions.ts +++ b/packages/apps/graph/src/graph/Query/transactions.ts @@ -1,6 +1,6 @@ +import { prismaClient } from '@db/prismaClient'; import type { Prisma } from '@prisma/client'; -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; builder.queryField('transactions', (t) => { diff --git a/packages/apps/graph/src/graph/Query/transfers.ts b/packages/apps/graph/src/graph/Query/transfers.ts index f9794811a4..e8af1b671a 100644 --- a/packages/apps/graph/src/graph/Query/transfers.ts +++ b/packages/apps/graph/src/graph/Query/transfers.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; builder.queryField('transfers', (t) => { diff --git a/packages/apps/graph/src/graph/data-loaders/account-details.ts b/packages/apps/graph/src/graph/data-loaders/account-details.ts index 76be78910a..d6b84866bb 100644 --- a/packages/apps/graph/src/graph/data-loaders/account-details.ts +++ b/packages/apps/graph/src/graph/data-loaders/account-details.ts @@ -1,4 +1,4 @@ -import { getAccountDetails } from '@src/services/node-service'; +import { getAccountDetails } from '@services/node-service'; import DataLoader from 'dataloader'; interface AccountDetailsKey { diff --git a/packages/apps/graph/src/graph/objects/Block.ts b/packages/apps/graph/src/graph/objects/Block.ts index ba24d68644..89b850be33 100644 --- a/packages/apps/graph/src/graph/objects/Block.ts +++ b/packages/apps/graph/src/graph/objects/Block.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { dotenv } from '@src/utils/dotenv'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { dotenv } from '@utils/dotenv'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Block', { diff --git a/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts b/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts index ca0d442b69..b2b8184c56 100644 --- a/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ChainModuleAccount.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; diff --git a/packages/apps/graph/src/graph/objects/Event.ts b/packages/apps/graph/src/graph/objects/Event.ts index f6b914dbe5..2087bd35cc 100644 --- a/packages/apps/graph/src/graph/objects/Event.ts +++ b/packages/apps/graph/src/graph/objects/Event.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Event', { diff --git a/packages/apps/graph/src/graph/objects/MinerKey.ts b/packages/apps/graph/src/graph/objects/MinerKey.ts index 4f7fc8880d..0be53d37a0 100644 --- a/packages/apps/graph/src/graph/objects/MinerKey.ts +++ b/packages/apps/graph/src/graph/objects/MinerKey.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('MinerKey', { diff --git a/packages/apps/graph/src/graph/objects/ModuleAccount.ts b/packages/apps/graph/src/graph/objects/ModuleAccount.ts index 6f1b6f797d..d9b48faa01 100644 --- a/packages/apps/graph/src/graph/objects/ModuleAccount.ts +++ b/packages/apps/graph/src/graph/objects/ModuleAccount.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; import { accountDetailsLoader } from '../data-loaders/account-details'; import type { ChainModuleAccount } from '../types/graphql-types'; diff --git a/packages/apps/graph/src/graph/objects/Signer.ts b/packages/apps/graph/src/graph/objects/Signer.ts index 76ddb84477..1686656231 100644 --- a/packages/apps/graph/src/graph/objects/Signer.ts +++ b/packages/apps/graph/src/graph/objects/Signer.ts @@ -1,4 +1,4 @@ -import { nullishOrEmpty } from '@src/utils/nullishOrEmpty'; +import { nullishOrEmpty } from '@utils/nullishOrEmpty'; import { builder } from '../builder'; export default builder.prismaNode('Signer', { diff --git a/packages/apps/graph/src/graph/objects/Transaction.ts b/packages/apps/graph/src/graph/objects/Transaction.ts index a05c16326f..3779e46c34 100644 --- a/packages/apps/graph/src/graph/objects/Transaction.ts +++ b/packages/apps/graph/src/graph/objects/Transaction.ts @@ -1,6 +1,6 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; -import { nullishOrEmpty } from '@src/utils/nullishOrEmpty'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; +import { nullishOrEmpty } from '@utils/nullishOrEmpty'; import { builder } from '../builder'; export default builder.prismaNode('Transaction', { diff --git a/packages/apps/graph/src/graph/objects/Transfer.ts b/packages/apps/graph/src/graph/objects/Transfer.ts index 1b96e0dff7..9a13cf00d8 100644 --- a/packages/apps/graph/src/graph/objects/Transfer.ts +++ b/packages/apps/graph/src/graph/objects/Transfer.ts @@ -1,5 +1,5 @@ -import { prismaClient } from '@src/db/prismaClient'; -import { normalizeError } from '@src/utils/errors'; +import { prismaClient } from '@db/prismaClient'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; export default builder.prismaNode('Transfer', { diff --git a/packages/apps/graph/src/index.ts b/packages/apps/graph/src/index.ts index e1d473738a..a25daae205 100644 --- a/packages/apps/graph/src/index.ts +++ b/packages/apps/graph/src/index.ts @@ -1,6 +1,6 @@ -require('module-alias/register'); import { createYoga } from 'graphql-yoga'; import 'json-bigint-patch'; +import 'module-alias/register'; import { createServer } from 'node:http'; import './graph'; import { builder } from './graph/builder'; diff --git a/packages/apps/graph/src/services/node-service.ts b/packages/apps/graph/src/services/node-service.ts index 2d0b828925..0fc6f835c6 100644 --- a/packages/apps/graph/src/services/node-service.ts +++ b/packages/apps/graph/src/services/node-service.ts @@ -1,6 +1,6 @@ import type { ChainId, IClient, ICommandResult } from '@kadena/client'; import { Pact, createClient } from '@kadena/client'; -import { dotenv } from '@src/utils/dotenv'; +import { dotenv } from '@utils/dotenv'; export class PactCommandError extends Error { public commandResult: ICommandResult; diff --git a/packages/apps/graph/tsconfig.json b/packages/apps/graph/tsconfig.json index c7143423e9..1acc14abc7 100644 --- a/packages/apps/graph/tsconfig.json +++ b/packages/apps/graph/tsconfig.json @@ -4,7 +4,9 @@ "types": [".kadena/pactjs-generated", "node"], "target": "ES2020", "paths": { - "@src/*": ["./src/*"] + "@db/*": ["./src/db/*"], + "@services/*": ["./src/services/*"], + "@utils/*": ["./src/utils/*"] } } } From 518333387075c1c1b8ab3b79b171f734b99938ef Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:15:03 +0100 Subject: [PATCH 16/74] file restructuring scipts / devnet --- packages/apps/graph/package.json | 2 +- .../graph/src/{scripts => }/devnet/config.ts | 0 .../{scripts => }/devnet/create-principal.ts | 0 .../devnet/crosschain-transfer.ts | 0 .../src/{scripts => }/devnet/get-balance.ts | 0 .../graph/src/{scripts => }/devnet/helper.ts | 0 .../src/{scripts => }/devnet/safe-transfer.ts | 0 .../devnet => devnet/simulation}/file.ts | 2 +- .../devnet => devnet/simulation}/index.ts | 4 ++-- .../devnet => devnet/simulation}/simulate.ts | 18 +++++++++--------- .../graph/src/{scripts => }/devnet/transfer.ts | 0 .../apps/graph/src/graph/Query/pactQuery.ts | 4 ++-- 12 files changed, 15 insertions(+), 15 deletions(-) rename packages/apps/graph/src/{scripts => }/devnet/config.ts (100%) rename packages/apps/graph/src/{scripts => }/devnet/create-principal.ts (100%) rename packages/apps/graph/src/{scripts => }/devnet/crosschain-transfer.ts (100%) rename packages/apps/graph/src/{scripts => }/devnet/get-balance.ts (100%) rename packages/apps/graph/src/{scripts => }/devnet/helper.ts (100%) rename packages/apps/graph/src/{scripts => }/devnet/safe-transfer.ts (100%) rename packages/apps/graph/src/{scripts/devnet => devnet/simulation}/file.ts (96%) rename packages/apps/graph/src/{scripts/devnet => devnet/simulation}/index.ts (94%) rename packages/apps/graph/src/{scripts/devnet => devnet/simulation}/simulate.ts (94%) rename packages/apps/graph/src/{scripts => }/devnet/transfer.ts (100%) diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index 65dd78e16a..5fb4e5b0cb 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -24,7 +24,7 @@ "prisma:generate": "prisma generate", "prisma:pull": "prisma db pull", "prisma:studio": "prisma studio", - "simulate": "ts-node -T src/scripts/devnet/index.ts traffic", + "simulate": "ts-node -T src/devnet/simulation/index.ts traffic", "start": "npx ts-node-dev --respawn --no-notify --exit-child src/index.ts", "start:generate": "pnpm run prisma:generate && npx ts-node-dev --respawn --no-notify --exit-child src/index.ts", "test": "echo \"no test specified\"" diff --git a/packages/apps/graph/src/scripts/devnet/config.ts b/packages/apps/graph/src/devnet/config.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/config.ts rename to packages/apps/graph/src/devnet/config.ts diff --git a/packages/apps/graph/src/scripts/devnet/create-principal.ts b/packages/apps/graph/src/devnet/create-principal.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/create-principal.ts rename to packages/apps/graph/src/devnet/create-principal.ts diff --git a/packages/apps/graph/src/scripts/devnet/crosschain-transfer.ts b/packages/apps/graph/src/devnet/crosschain-transfer.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/crosschain-transfer.ts rename to packages/apps/graph/src/devnet/crosschain-transfer.ts diff --git a/packages/apps/graph/src/scripts/devnet/get-balance.ts b/packages/apps/graph/src/devnet/get-balance.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/get-balance.ts rename to packages/apps/graph/src/devnet/get-balance.ts diff --git a/packages/apps/graph/src/scripts/devnet/helper.ts b/packages/apps/graph/src/devnet/helper.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/helper.ts rename to packages/apps/graph/src/devnet/helper.ts diff --git a/packages/apps/graph/src/scripts/devnet/safe-transfer.ts b/packages/apps/graph/src/devnet/safe-transfer.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/safe-transfer.ts rename to packages/apps/graph/src/devnet/safe-transfer.ts diff --git a/packages/apps/graph/src/scripts/devnet/file.ts b/packages/apps/graph/src/devnet/simulation/file.ts similarity index 96% rename from packages/apps/graph/src/scripts/devnet/file.ts rename to packages/apps/graph/src/devnet/simulation/file.ts index e4f8ecc1b5..97fce3161c 100644 --- a/packages/apps/graph/src/scripts/devnet/file.ts +++ b/packages/apps/graph/src/devnet/simulation/file.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import { devnetConfig } from './config'; +import { devnetConfig } from '../config'; export interface IFileData { timestamp: number; diff --git a/packages/apps/graph/src/scripts/devnet/index.ts b/packages/apps/graph/src/devnet/simulation/index.ts similarity index 94% rename from packages/apps/graph/src/scripts/devnet/index.ts rename to packages/apps/graph/src/devnet/simulation/index.ts index 0c493d458c..80f5285b8a 100644 --- a/packages/apps/graph/src/scripts/devnet/index.ts +++ b/packages/apps/graph/src/devnet/simulation/index.ts @@ -1,7 +1,7 @@ import { Command, Option } from 'commander'; -import { generateKeyPair, logger } from './helper'; +import { generateKeyPair, logger } from '../helper'; +import { transfer } from '../transfer'; import { simulate } from './simulate'; -import { transfer } from './transfer'; const program: Command = new Command(); program diff --git a/packages/apps/graph/src/scripts/devnet/simulate.ts b/packages/apps/graph/src/devnet/simulation/simulate.ts similarity index 94% rename from packages/apps/graph/src/scripts/devnet/simulate.ts rename to packages/apps/graph/src/devnet/simulation/simulate.ts index 9fbe73f989..04356b0b6f 100644 --- a/packages/apps/graph/src/scripts/devnet/simulate.ts +++ b/packages/apps/graph/src/devnet/simulation/simulate.ts @@ -1,10 +1,8 @@ import type { ChainId } from '@kadena/client'; -import { devnetConfig } from './config'; -import { crossChainTransfer } from './crosschain-transfer'; -import type { TransferType } from './file'; -import { appendToFile, createFile } from './file'; -import { getBalance } from './get-balance'; -import type { IAccount } from './helper'; +import { devnetConfig } from '../config'; +import { crossChainTransfer } from '../crosschain-transfer'; +import { getBalance } from '../get-balance'; +import type { IAccount } from '../helper'; import { generateKeyPair, getRandomNumber, @@ -12,9 +10,11 @@ import { isEqualChainAccounts, logger, seedRandom, -} from './helper'; -import { safeTransfer } from './safe-transfer'; -import { transfer } from './transfer'; +} from '../helper'; +import { safeTransfer } from '../safe-transfer'; +import { transfer } from '../transfer'; +import type { TransferType } from './file'; +import { appendToFile, createFile } from './file'; const simualtionTransferOptions: TransferType[] = [ 'xchaintransfer', diff --git a/packages/apps/graph/src/scripts/devnet/transfer.ts b/packages/apps/graph/src/devnet/transfer.ts similarity index 100% rename from packages/apps/graph/src/scripts/devnet/transfer.ts rename to packages/apps/graph/src/devnet/transfer.ts diff --git a/packages/apps/graph/src/graph/Query/pactQuery.ts b/packages/apps/graph/src/graph/Query/pactQuery.ts index 5f1356b5b7..1fb2a4cce6 100644 --- a/packages/apps/graph/src/graph/Query/pactQuery.ts +++ b/packages/apps/graph/src/graph/Query/pactQuery.ts @@ -1,7 +1,7 @@ import type { ChainId } from '@kadena/client'; import { Pact } from '@kadena/client'; -import { devnetConfig } from '../../scripts/devnet/config'; -import { dirtyRead } from '../../scripts/devnet/helper'; +import { devnetConfig } from '../../devnet/config'; +import { dirtyRead } from '../../devnet/helper'; import { builder } from '../builder'; const PactData = builder.inputType('PactQueryData', { From 1d36f9e9497510588e3cfca635bed6692f183cf6 Mon Sep 17 00:00:00 2001 From: Maarten van den Hoven Date: Mon, 6 Nov 2023 14:16:35 +0100 Subject: [PATCH 17/74] Used stronger types for transactions and transfers --- .../compact-transactions-table.tsx | 16 ++++++++-------- .../compact-transfers-table.tsx | 9 +++++---- .../account/overview/[module]/[account].tsx | 14 ++++++++++++-- .../overview/[module]/[account]/[chain].tsx | 14 ++++++++++++-- .../src/pages/block/overview/[hash].tsx | 5 ++++- packages/apps/graph-client/src/pages/index.tsx | 3 ++- 6 files changed, 43 insertions(+), 18 deletions(-) diff --git a/packages/apps/graph-client/src/components/compact-transactions-table/compact-transactions-table.tsx b/packages/apps/graph-client/src/components/compact-transactions-table/compact-transactions-table.tsx index 8d11ba01ad..f277321b7f 100644 --- a/packages/apps/graph-client/src/components/compact-transactions-table/compact-transactions-table.tsx +++ b/packages/apps/graph-client/src/components/compact-transactions-table/compact-transactions-table.tsx @@ -1,8 +1,8 @@ import type { - GetAccountQuery, - GetBlockFromHashQuery, - GetChainAccountQuery, - GetTransactionsQuery, + BlockTransactionsConnection, + ChainModuleAccountTransactionsConnection, + ModuleAccountTransactionsConnection, + QueryTransactionsConnection, } from '@/__generated__/sdk'; import routes from '@constants/routes'; import { Box, Button, ContentHeader, Link, Table } from '@kadena/react-ui'; @@ -13,10 +13,10 @@ interface ICompactTransactionsTableProps { viewAllHref?: string; description?: string; transactions: - | GetAccountQuery['account']['transactions'] - | GetChainAccountQuery['chainAccount']['transactions'] - | GetBlockFromHashQuery['block']['transactions'] - | GetTransactionsQuery['transactions']; + | ModuleAccountTransactionsConnection + | ChainModuleAccountTransactionsConnection + | BlockTransactionsConnection + | QueryTransactionsConnection; } export const CompactTransactionsTable = ( diff --git a/packages/apps/graph-client/src/components/compact-transfers-table/compact-transfers-table.tsx b/packages/apps/graph-client/src/components/compact-transfers-table/compact-transfers-table.tsx index a3b16f6b9d..48de49461f 100644 --- a/packages/apps/graph-client/src/components/compact-transfers-table/compact-transfers-table.tsx +++ b/packages/apps/graph-client/src/components/compact-transfers-table/compact-transfers-table.tsx @@ -1,6 +1,6 @@ import type { - GetAccountQuery, - GetChainAccountQuery, + ChainModuleAccountTransfersConnection, + ModuleAccountTransfersConnection, } from '@/__generated__/sdk'; import routes from '@constants/routes'; import { Box, Button, ContentHeader, Link, Table } from '@kadena/react-ui'; @@ -12,8 +12,9 @@ interface ICompactTransfersTableProps { accountName: string; chainId?: string; transfers: - | GetAccountQuery['account']['transfers'] - | GetChainAccountQuery['chainAccount']['transfers']; + | ModuleAccountTransfersConnection + | ChainModuleAccountTransfersConnection; + description?: string; } diff --git a/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx b/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx index 40482723ea..fe1ec9a1e8 100644 --- a/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx +++ b/packages/apps/graph-client/src/pages/account/overview/[module]/[account].tsx @@ -1,3 +1,7 @@ +import type { + ModuleAccountTransactionsConnection, + ModuleAccountTransfersConnection, +} from '@/__generated__/sdk'; import { useGetAccountQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; @@ -89,7 +93,10 @@ const Account: React.FC = () => { description="All transfers from or to this account" moduleName={router.query.module as string} accountName={router.query.account as string} - transfers={accountQuery.account.transfers} + transfers={ + accountQuery.account + .transfers as ModuleAccountTransfersConnection + } /> @@ -97,7 +104,10 @@ const Account: React.FC = () => { viewAllHref={`${routes.ACCOUNT_TRANSACTIONS}/${ router.query.module as string }/${router.query.account as string}`} - transactions={accountQuery.account.transactions} + transactions={ + accountQuery.account + .transactions as ModuleAccountTransactionsConnection + } /> diff --git a/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx b/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx index 2da1aa1020..6dc1482cab 100644 --- a/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx +++ b/packages/apps/graph-client/src/pages/account/overview/[module]/[account]/[chain].tsx @@ -1,3 +1,7 @@ +import type { + ChainModuleAccountTransactionsConnection, + ChainModuleAccountTransfersConnection, +} from '@/__generated__/sdk'; import { useGetChainAccountQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; @@ -109,7 +113,10 @@ const ChainAccount: React.FC = () => { moduleName={router.query.module as string} accountName={router.query.account as string} chainId={router.query.chain as string} - transfers={chainAccountQuery.chainAccount.transfers} + transfers={ + chainAccountQuery.chainAccount + .transfers as ChainModuleAccountTransfersConnection + } /> @@ -119,7 +126,10 @@ const ChainAccount: React.FC = () => { }/${router.query.account as string}?chain=${ router.query.chain as string }`} - transactions={chainAccountQuery.chainAccount.transactions} + transactions={ + chainAccountQuery.chainAccount + .transactions as ChainModuleAccountTransactionsConnection + } /> diff --git a/packages/apps/graph-client/src/pages/block/overview/[hash].tsx b/packages/apps/graph-client/src/pages/block/overview/[hash].tsx index fbb260825b..03cefe6c4b 100644 --- a/packages/apps/graph-client/src/pages/block/overview/[hash].tsx +++ b/packages/apps/graph-client/src/pages/block/overview/[hash].tsx @@ -1,3 +1,4 @@ +import type { BlockTransactionsConnection } from '@/__generated__/sdk'; import { useGetBlockFromHashQuery, useGetGraphConfigurationQuery, @@ -211,7 +212,9 @@ const Block: React.FC = () => { {data.block.transactions.totalCount > 0 && ( )} diff --git a/packages/apps/graph-client/src/pages/index.tsx b/packages/apps/graph-client/src/pages/index.tsx index 0a649430a6..e0a7fe7e92 100644 --- a/packages/apps/graph-client/src/pages/index.tsx +++ b/packages/apps/graph-client/src/pages/index.tsx @@ -1,5 +1,6 @@ import { Box } from '@kadena/react-ui'; +import type { QueryTransactionsConnection } from '@/__generated__/sdk'; import { useGetBlocksSubscription, useGetRecentHeightsQuery, @@ -71,7 +72,7 @@ const Home: React.FC = () => {
From 3dda3023118e7e69888775b0e51a805e226eb4f8 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:23:55 +0100 Subject: [PATCH 18/74] changes in graph, added query and necessary functions --- packages/apps/graph/generated-schema.graphql | 8 +++ packages/apps/graph/src/devnet/helper.ts | 5 ++ packages/apps/graph/src/devnet/transfer.ts | 33 +++++++++++- .../graph/src/graph/Query/gasLimitEstimate.ts | 53 +++++++++++++++++++ packages/apps/graph/src/graph/index.ts | 1 + 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 packages/apps/graph/src/graph/Query/gasLimitEstimate.ts diff --git a/packages/apps/graph/generated-schema.graphql b/packages/apps/graph/generated-schema.graphql index f5b03a97b4..527638dd12 100644 --- a/packages/apps/graph/generated-schema.graphql +++ b/packages/apps/graph/generated-schema.graphql @@ -150,6 +150,12 @@ input PactQueryData { value: String! } +input PactTransaction { + cmd: String! + hash: String + sigs: [String!] +} + type PageInfo { endCursor: String hasNextPage: Boolean! @@ -166,6 +172,8 @@ type Query { blocksFromHeight(chainIds: [Int!], startHeight: Int!): [Block!]! chainAccount(accountName: String!, chainId: String!, moduleName: String!): ChainModuleAccount! completedBlockHeights(chainIds: [String!], completedHeights: Boolean, heightCount: Int): [Block!]! + gasLimitEstimate(transaction: PactTransaction!): Int! + gasLimitEstimates(transactions: [PactTransaction!]!): [Int!]! graphConfiguration: GraphConfiguration! lastBlockHeight: BigInt node(id: ID!): Node diff --git a/packages/apps/graph/src/devnet/helper.ts b/packages/apps/graph/src/devnet/helper.ts index d6ba81ec45..bc9a3fc836 100644 --- a/packages/apps/graph/src/devnet/helper.ts +++ b/packages/apps/graph/src/devnet/helper.ts @@ -53,6 +53,11 @@ export const pollStatus = ( export const dirtyRead = (tx: IUnsignedCommand): Promise => getClient().dirtyRead(tx); +export const localReadForGasEstimation = ( + tx: IUnsignedCommand, +): Promise => + getClient().local(tx, { preflight: true, signatureVerification: false }); + export const signTransaction = (keyPairs: IKeyPair[]) => (tx: IUnsignedCommand): IUnsignedCommand | ICommand => { diff --git a/packages/apps/graph/src/devnet/transfer.ts b/packages/apps/graph/src/devnet/transfer.ts index 85327e774b..b2cf7ba551 100644 --- a/packages/apps/graph/src/devnet/transfer.ts +++ b/packages/apps/graph/src/devnet/transfer.ts @@ -1,11 +1,13 @@ -import type { ChainId, ICommandResult } from '@kadena/client'; +import type { ChainId, ICommandResult, IUnsignedCommand } from '@kadena/client'; import { Pact } from '@kadena/client'; +import { hash as hashFunction } from '@kadena/cryptography-utils'; import { PactNumber } from '@kadena/pactjs'; import { devnetConfig } from './config'; import type { IAccount } from './helper'; import { inspect, listen, + localReadForGasEstimation, logger, sender00, signAndAssertTransaction, @@ -67,3 +69,32 @@ export async function transfer({ return result; } } +export const localReadTransfer = async ({ + cmd, + hash = undefined, + sigs = [], +}: { + cmd: string; + hash?: string | undefined | null; + sigs?: string[] | undefined | null; +}): Promise => { + if (!hash) { + hash = hashFunction(cmd); + } + + let existingSigs: IUnsignedCommand['sigs'] = []; + + if (sigs && sigs?.length > 0) { + existingSigs = sigs.map((sig) => ({ + sig: sig, + })); + } + + const transaction: IUnsignedCommand = { + cmd, + hash, + sigs: existingSigs, + }; + + return await localReadForGasEstimation(transaction); +}; diff --git a/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts b/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts new file mode 100644 index 0000000000..f7fea2bd76 --- /dev/null +++ b/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts @@ -0,0 +1,53 @@ +import { localReadTransfer } from '../../devnet/transfer'; +import { builder } from '../builder'; + +const PactTransaction = builder.inputType('PactTransaction', { + fields: (t) => ({ + cmd: t.field({ type: 'String', required: true }), + hash: t.field({ type: 'String' }), + sigs: t.field({ type: ['String'] }), + }), +}); + +builder.queryField('gasLimitEstimate', (t) => { + return t.field({ + type: 'Int', + args: { + transaction: t.arg({ type: PactTransaction, required: true }), + }, + resolve: async (parent, args, context, info) => { + if (args.transaction.cmd.includes(`\\`)) { + args.transaction.cmd = args.transaction.cmd.replace(/\\\\/g, '\\'); + } + + const result = await localReadTransfer({ + cmd: args.transaction.cmd, + hash: args.transaction.hash, + sigs: args.transaction.sigs, + }); + return result.gas; + }, + }); +}); + +builder.queryField('gasLimitEstimates', (t) => { + return t.field({ + type: ['Int'], + args: { + transactions: t.arg({ type: [PactTransaction], required: true }), + }, + resolve: async (parent, args, context, info) => { + return args.transactions.map(async (transaction) => { + if (transaction.cmd.includes('//')) { + transaction.cmd = transaction.cmd.replace(/\/\//g, '/'); + } + const result = await localReadTransfer({ + cmd: transaction.cmd, + hash: transaction.hash, + sigs: transaction.sigs, + }); + return result.gas; + }); + }, + }); +}); diff --git a/packages/apps/graph/src/graph/index.ts b/packages/apps/graph/src/graph/index.ts index a823d2d5e3..b8bee9a594 100644 --- a/packages/apps/graph/src/graph/index.ts +++ b/packages/apps/graph/src/graph/index.ts @@ -3,6 +3,7 @@ import './Query/block'; import './Query/blocksFromHeight'; import './Query/chainAccount'; import './Query/completedBlockHeights'; +import './Query/gasLimitEstimate'; import './Query/graphConfiguration'; import './Query/lastBlockHeight'; import './Query/pactQuery'; From 74d71809fe85ca92f04936f75ad52b51d8c2b308 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:28:43 +0100 Subject: [PATCH 19/74] adjustment of header component to incorportate gas estimation arguments --- .../Common/Layout/Header/Header.tsx | 92 +++++++++++++++++-- .../apps/graph-client/src/constants/routes.ts | 1 + 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/packages/apps/graph-client/src/components/Common/Layout/Header/Header.tsx b/packages/apps/graph-client/src/components/Common/Layout/Header/Header.tsx index d6b89edb24..2439c01da4 100644 --- a/packages/apps/graph-client/src/components/Common/Layout/Header/Header.tsx +++ b/packages/apps/graph-client/src/components/Common/Layout/Header/Header.tsx @@ -17,7 +17,9 @@ const Header: FC = (props) => { const [searchType, setSearchType] = useState('request-key'); const [searchField, setSearchField] = useState(''); - const [moduleField, setModuleField] = useState('coin'); + const [secondSearchField, setSecondSearchField] = useState(''); + const [thirdSearchField, setThirdSearchField] = useState(''); + const [gridColumns, setGridColumns] = useState(3); const [defaultHashOption, setDefaultHashOption] = useState('request-key'); @@ -26,6 +28,7 @@ const Header: FC = (props) => { account: 'Account', event: 'Event Name', block: 'Block Hash', + gasEstimation: 'Cmd', }; const searchTypePlaceholders: Record = { @@ -33,6 +36,25 @@ const Header: FC = (props) => { account: 'k:1234...', event: 'coin.TRANSFER', block: 'CA9orP2yM...', + gasEstimation: 'cmd', + }; + + const secondSearchTypeLabels: Record = { + account: 'Module', + gasEstimation: 'Hash', + }; + + const secondSearchFieldPlaceholders: Record = { + account: 'coin', + gasEstimation: 'hash', + }; + + const thirdSeachTypeLabels: Record = { + gasEstimation: 'Signatures', + }; + + const thirdSearchFieldPlaceholders: Record = { + gasEstimation: 'sigs', }; const search = (): void => { @@ -43,7 +65,7 @@ const Header: FC = (props) => { break; case 'account': // eslint-disable-next-line @typescript-eslint/no-floating-promises - router.push(`${routes.ACCOUNT}/${moduleField}/${searchField}`); + router.push(`${routes.ACCOUNT}/${secondSearchField}/${searchField}`); break; case 'event': // eslint-disable-next-line @typescript-eslint/no-floating-promises @@ -53,6 +75,16 @@ const Header: FC = (props) => { // eslint-disable-next-line @typescript-eslint/no-floating-promises router.push(`${routes.BLOCK_OVERVIEW}/${searchField}`); break; + case 'gasEstimation': + // eslint-disable-next-line @typescript-eslint/no-floating-promises + router.push({ + pathname: `${routes.GAS_ESTIMATION}`, + query: { + cmd: searchField, + hash: secondSearchField, + sigs: thirdSearchField, + }, + }); } }; @@ -68,6 +100,10 @@ const Header: FC = (props) => { setSearchField(event.target.value); const fieldValue = event.target.value; + if (searchType === 'gasEstimation') { + return; + } + if ( fieldValue.startsWith('k:') || fieldValue.startsWith('w:') || @@ -92,9 +128,22 @@ const Header: FC = (props) => { setSearchType(event.target.value); if (event.target.value === 'request-key') { setDefaultHashOption('request-key'); + setGridColumns(3); } if (event.target.value === 'block') { setDefaultHashOption('block'); + setGridColumns(3); + } + if (event.target.value === 'event') { + setGridColumns(3); + } + if (event.target.value === 'account') { + setSecondSearchField('coin'); + setGridColumns(4); + } + if (event.target.value === 'gasEstimation') { + setSecondSearchField(''); + setGridColumns(5); } }; @@ -115,7 +164,7 @@ const Header: FC = (props) => { {title} - + + = (props) => { /> - {searchType.startsWith('account') && ( + + {(searchType.startsWith('account') || + searchType.startsWith('gas')) && ( + + + setSecondSearchField(event.target.value)} + onKeyDown={handleKeyPress} + /> + + + )} + + {searchType.startsWith('gas') && ( - + setModuleField(event.target.value)} + id="third-search-field" + value={thirdSearchField} + placeholder={thirdSearchFieldPlaceholders[searchType]} + onChange={(event) => setThirdSearchField(event.target.value)} + onKeyDown={handleKeyPress} /> diff --git a/packages/apps/graph-client/src/constants/routes.ts b/packages/apps/graph-client/src/constants/routes.ts index d29d70bc2a..0fb5af9473 100644 --- a/packages/apps/graph-client/src/constants/routes.ts +++ b/packages/apps/graph-client/src/constants/routes.ts @@ -7,4 +7,5 @@ export default { EVENT: '/event', BLOCK_OVERVIEW: '/block/overview', BLOCK_TRANSACTIONS: '/block/transactions', + GAS_ESTIMATION: '/gas/estimation', } as const; From eefce501ea05e0088bc412a3ac8689cf585929fe Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:28:52 +0100 Subject: [PATCH 20/74] gas estimation page and query --- .../graph-client/src/graphql/queries.graph.ts | 7 +- .../src/pages/gas/estimation/index.tsx | 66 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 packages/apps/graph-client/src/pages/gas/estimation/index.tsx diff --git a/packages/apps/graph-client/src/graphql/queries.graph.ts b/packages/apps/graph-client/src/graphql/queries.graph.ts index 48d8dfeb81..392b5ad9db 100644 --- a/packages/apps/graph-client/src/graphql/queries.graph.ts +++ b/packages/apps/graph-client/src/graphql/queries.graph.ts @@ -53,7 +53,7 @@ export const getLastBlock: DocumentNode = gql` } `; -export const getGraphAndChainwebData: DocumentNode = gql` +export const getGraphConfiguration: DocumentNode = gql` query getGraphConfiguration { graphConfiguration { maximumConfirmationDepth @@ -224,3 +224,8 @@ export const getTransfers: DocumentNode = gql` } } `; +export const estimateGasLimit: DocumentNode = gql` + query estimateGasLimit($transaction: PactTransaction!) { + gasLimitEstimate(transaction: $transaction) + } +`; diff --git a/packages/apps/graph-client/src/pages/gas/estimation/index.tsx b/packages/apps/graph-client/src/pages/gas/estimation/index.tsx new file mode 100644 index 0000000000..fc187fec72 --- /dev/null +++ b/packages/apps/graph-client/src/pages/gas/estimation/index.tsx @@ -0,0 +1,66 @@ +import { useEstimateGasLimitQuery } from '@/__generated__/sdk'; +import Loader from '@/components/Common/loader/loader'; +import { mainStyle } from '@/components/Common/main/styles.css'; +import routes from '@/constants/routes'; +import { formatCode } from '@/utils/formatter'; +import { Box, Breadcrumbs, Table } from '@kadena/react-ui'; +import { useRouter } from 'next/router'; +import React from 'react'; + +const GasEstimation: React.FC = () => { + const router = useRouter(); + const { cmd, hash, sigs } = router.query; + + const cmdString = cmd as string; + const hashString = hash as string; + const sigsString = sigs as string; + const sigsArray = sigsString ? sigsString.split(',') : []; + + const { loading, data, error } = useEstimateGasLimitQuery({ + variables: { + transaction: { cmd: cmdString, hash: hashString, sigs: sigsArray }, + }, + }); + + return ( +
+ + Home + Gas Estimation + + + + +
+
+ {loading && ( +
+ Waiting for gas estimation... +
+ )} +
+ + + + + Label + Value + + + + + Cmd + {cmdString} + + + Gas Estimate + {data?.gasLimitEstimate} + + + +
+
+ ); +}; + +export default GasEstimation; From 83f96cd42687f03767965c36c9852af201734f2d Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:29:36 +0100 Subject: [PATCH 21/74] lint fixes --- packages/apps/graph-client/src/pages/gas/estimation/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/apps/graph-client/src/pages/gas/estimation/index.tsx b/packages/apps/graph-client/src/pages/gas/estimation/index.tsx index fc187fec72..0f1a638a91 100644 --- a/packages/apps/graph-client/src/pages/gas/estimation/index.tsx +++ b/packages/apps/graph-client/src/pages/gas/estimation/index.tsx @@ -2,7 +2,6 @@ import { useEstimateGasLimitQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; import routes from '@/constants/routes'; -import { formatCode } from '@/utils/formatter'; import { Box, Breadcrumbs, Table } from '@kadena/react-ui'; import { useRouter } from 'next/router'; import React from 'react'; @@ -16,7 +15,7 @@ const GasEstimation: React.FC = () => { const sigsString = sigs as string; const sigsArray = sigsString ? sigsString.split(',') : []; - const { loading, data, error } = useEstimateGasLimitQuery({ + const { loading, data } = useEstimateGasLimitQuery({ variables: { transaction: { cmd: cmdString, hash: hashString, sigs: sigsArray }, }, From 110e2b810c27baf3708f7db5a8eee6e899f68685 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:32:25 +0100 Subject: [PATCH 22/74] added error box --- .../src/pages/gas/estimation/index.tsx | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/apps/graph-client/src/pages/gas/estimation/index.tsx b/packages/apps/graph-client/src/pages/gas/estimation/index.tsx index 0f1a638a91..e837b1f3f0 100644 --- a/packages/apps/graph-client/src/pages/gas/estimation/index.tsx +++ b/packages/apps/graph-client/src/pages/gas/estimation/index.tsx @@ -1,6 +1,7 @@ import { useEstimateGasLimitQuery } from '@/__generated__/sdk'; import Loader from '@/components/Common/loader/loader'; import { mainStyle } from '@/components/Common/main/styles.css'; +import { ErrorBox } from '@/components/error-box/error-box'; import routes from '@/constants/routes'; import { Box, Breadcrumbs, Table } from '@kadena/react-ui'; import { useRouter } from 'next/router'; @@ -15,7 +16,7 @@ const GasEstimation: React.FC = () => { const sigsString = sigs as string; const sigsArray = sigsString ? sigsString.split(',') : []; - const { loading, data } = useEstimateGasLimitQuery({ + const { loading, data, error } = useEstimateGasLimitQuery({ variables: { transaction: { cmd: cmdString, hash: hashString, sigs: sigsArray }, }, @@ -37,26 +38,26 @@ const GasEstimation: React.FC = () => { Waiting for gas estimation...
)} + {error && } + + + + Label + Value + + + + + Cmd + {cmdString} + + + Gas Estimate + {data?.gasLimitEstimate} + + + - - - - - Label - Value - - - - - Cmd - {cmdString} - - - Gas Estimate - {data?.gasLimitEstimate} - - - ); From ee73db48efa80903299dfca146a490a41293d2c4 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:46:30 +0100 Subject: [PATCH 23/74] update remaining files to use modue-alias (graph) --- packages/apps/graph/package.json | 3 ++- packages/apps/graph/src/graph/Query/gasLimitEstimate.ts | 2 +- packages/apps/graph/src/graph/Query/graphConfiguration.ts | 5 ++--- .../apps/graph/src/graph/Query/transactionByPublicKey.ts | 2 +- packages/apps/graph/src/graph/Subscription/event.ts | 4 ++-- packages/apps/graph/src/graph/Subscription/newBlocks.ts | 6 +++--- packages/apps/graph/src/graph/Subscription/transaction.ts | 2 +- packages/apps/graph/src/services/BlocksService/index.ts | 2 +- packages/apps/graph/src/utils/errors.ts | 2 +- packages/apps/graph/tsconfig.json | 3 ++- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index 277d24f874..7b29a2cd3b 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -70,6 +70,7 @@ "_moduleAliases": { "@db": "src/db", "@services": "src/services", - "@utils": "src/utils" + "@utils": "src/utils", + "@devnet": "src/devnet" } } diff --git a/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts b/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts index f7fea2bd76..9f51050f91 100644 --- a/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts +++ b/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts @@ -1,4 +1,4 @@ -import { localReadTransfer } from '../../devnet/transfer'; +import { localReadTransfer } from '@devnet/transfer'; import { builder } from '../builder'; const PactTransaction = builder.inputType('PactTransaction', { diff --git a/packages/apps/graph/src/graph/Query/graphConfiguration.ts b/packages/apps/graph/src/graph/Query/graphConfiguration.ts index 3f030a00ea..d8f8f43ab8 100644 --- a/packages/apps/graph/src/graph/Query/graphConfiguration.ts +++ b/packages/apps/graph/src/graph/Query/graphConfiguration.ts @@ -1,7 +1,6 @@ -import { prismaClient } from '../../db/prismaClient'; -import { dotenv } from '../../utils/dotenv'; +import { prismaClient } from '@db/prismaClient'; +import { dotenv } from '@utils/dotenv'; import { builder } from '../builder'; - const getMinimumBlockHeight = async (): Promise => { const lowestBlock = await prismaClient.block.findFirst({ orderBy: { diff --git a/packages/apps/graph/src/graph/Query/transactionByPublicKey.ts b/packages/apps/graph/src/graph/Query/transactionByPublicKey.ts index 9fe533d171..e6bdba1cee 100644 --- a/packages/apps/graph/src/graph/Query/transactionByPublicKey.ts +++ b/packages/apps/graph/src/graph/Query/transactionByPublicKey.ts @@ -1,4 +1,4 @@ -import { prismaClient } from '../../db/prismaClient'; +import { prismaClient } from '@db/prismaClient'; import { builder } from '../builder'; builder.queryField('transactionsByPublicKey', (t) => { diff --git a/packages/apps/graph/src/graph/Subscription/event.ts b/packages/apps/graph/src/graph/Subscription/event.ts index 508839eeb2..e7cd7d56fb 100644 --- a/packages/apps/graph/src/graph/Subscription/event.ts +++ b/packages/apps/graph/src/graph/Subscription/event.ts @@ -1,8 +1,8 @@ +import { prismaClient } from '@db/prismaClient'; import type { Event } from '@prisma/client'; +import { nullishOrEmpty } from '@utils/nullishOrEmpty'; import type { Debugger } from 'debug'; import _debug from 'debug'; -import { prismaClient } from '../../db/prismaClient'; -import { nullishOrEmpty } from '../../utils/nullishOrEmpty'; import type { IContext } from '../builder'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Subscription/newBlocks.ts b/packages/apps/graph/src/graph/Subscription/newBlocks.ts index e4f5a82256..cd96e1d17e 100644 --- a/packages/apps/graph/src/graph/Subscription/newBlocks.ts +++ b/packages/apps/graph/src/graph/Subscription/newBlocks.ts @@ -1,9 +1,9 @@ +import { prismaClient } from '@db/prismaClient'; import type { Block } from '@prisma/client'; +import { dotenv } from '@utils/dotenv'; +import { nullishOrEmpty } from '@utils/nullishOrEmpty'; import type { Debugger } from 'debug'; import _debug from 'debug'; -import { prismaClient } from '../../db/prismaClient'; -import { dotenv } from '../../utils/dotenv'; -import { nullishOrEmpty } from '../../utils/nullishOrEmpty'; import type { IContext } from '../builder'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/graph/Subscription/transaction.ts b/packages/apps/graph/src/graph/Subscription/transaction.ts index ae2ffc4841..c8a276d3fb 100644 --- a/packages/apps/graph/src/graph/Subscription/transaction.ts +++ b/packages/apps/graph/src/graph/Subscription/transaction.ts @@ -1,7 +1,7 @@ +import { prismaClient } from '@db/prismaClient'; import type { Transaction } from '@prisma/client'; import type { Debugger } from 'debug'; import _debug from 'debug'; -import { prismaClient } from '../../db/prismaClient'; import type { IContext } from '../builder'; import { builder } from '../builder'; diff --git a/packages/apps/graph/src/services/BlocksService/index.ts b/packages/apps/graph/src/services/BlocksService/index.ts index 4c98d94df1..5bf5161bc0 100644 --- a/packages/apps/graph/src/services/BlocksService/index.ts +++ b/packages/apps/graph/src/services/BlocksService/index.ts @@ -1,4 +1,4 @@ -import { pubsub } from '../../utils/pubsub'; +import { pubsub } from '@utils/pubsub'; import { getBlocks } from './lastBlock/BlocksService'; const blocksProvider: ReturnType = getBlocks( diff --git a/packages/apps/graph/src/utils/errors.ts b/packages/apps/graph/src/utils/errors.ts index 717c764fbe..0d6ee5c3c7 100644 --- a/packages/apps/graph/src/utils/errors.ts +++ b/packages/apps/graph/src/utils/errors.ts @@ -1,6 +1,6 @@ import { PrismaClientInitializationError } from '@prisma/client/runtime/library'; +import { PactCommandError } from '@services/node-service'; import { GraphQLError } from 'graphql'; -import { PactCommandError } from '../services/node-service'; /** * Checks what type of error it is and returns a normalized GraphQLError with the correct type, message and a description that clearly translates to the user what the error means. diff --git a/packages/apps/graph/tsconfig.json b/packages/apps/graph/tsconfig.json index 1acc14abc7..154cab0c04 100644 --- a/packages/apps/graph/tsconfig.json +++ b/packages/apps/graph/tsconfig.json @@ -6,7 +6,8 @@ "paths": { "@db/*": ["./src/db/*"], "@services/*": ["./src/services/*"], - "@utils/*": ["./src/utils/*"] + "@utils/*": ["./src/utils/*"], + "@devnet/*": ["./src/devnet/*"] } } } From 9208d446ee9b3c942871b07f9d47b315c5ea3e0b Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 14:58:44 +0100 Subject: [PATCH 24/74] surround statement by try catch --- .../graph/src/graph/Query/gasLimitEstimate.ts | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts b/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts index 9f51050f91..818abeefb6 100644 --- a/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts +++ b/packages/apps/graph/src/graph/Query/gasLimitEstimate.ts @@ -1,4 +1,5 @@ import { localReadTransfer } from '@devnet/transfer'; +import { normalizeError } from '@utils/errors'; import { builder } from '../builder'; const PactTransaction = builder.inputType('PactTransaction', { @@ -16,16 +17,20 @@ builder.queryField('gasLimitEstimate', (t) => { transaction: t.arg({ type: PactTransaction, required: true }), }, resolve: async (parent, args, context, info) => { - if (args.transaction.cmd.includes(`\\`)) { - args.transaction.cmd = args.transaction.cmd.replace(/\\\\/g, '\\'); - } + try { + if (args.transaction.cmd.includes(`\\`)) { + args.transaction.cmd = args.transaction.cmd.replace(/\\\\/g, '\\'); + } - const result = await localReadTransfer({ - cmd: args.transaction.cmd, - hash: args.transaction.hash, - sigs: args.transaction.sigs, - }); - return result.gas; + const result = await localReadTransfer({ + cmd: args.transaction.cmd, + hash: args.transaction.hash, + sigs: args.transaction.sigs, + }); + return result.gas; + } catch (error) { + throw normalizeError(error); + } }, }); }); @@ -37,17 +42,21 @@ builder.queryField('gasLimitEstimates', (t) => { transactions: t.arg({ type: [PactTransaction], required: true }), }, resolve: async (parent, args, context, info) => { - return args.transactions.map(async (transaction) => { - if (transaction.cmd.includes('//')) { - transaction.cmd = transaction.cmd.replace(/\/\//g, '/'); - } - const result = await localReadTransfer({ - cmd: transaction.cmd, - hash: transaction.hash, - sigs: transaction.sigs, + try { + return args.transactions.map(async (transaction) => { + if (transaction.cmd.includes('//')) { + transaction.cmd = transaction.cmd.replace(/\/\//g, '/'); + } + const result = await localReadTransfer({ + cmd: transaction.cmd, + hash: transaction.hash, + sigs: transaction.sigs, + }); + return result.gas; }); - return result.gas; - }); + } catch (error) { + throw normalizeError(error); + } }, }); }); From 6992cd08beb6b44b57276db0dba56b98f74cf7d6 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 15:05:11 +0100 Subject: [PATCH 25/74] changeset files --- .changeset/curly-pumas-love.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/curly-pumas-love.md diff --git a/.changeset/curly-pumas-love.md b/.changeset/curly-pumas-love.md new file mode 100644 index 0000000000..b3794e6dfc --- /dev/null +++ b/.changeset/curly-pumas-love.md @@ -0,0 +1,5 @@ +--- +'@kadena/graph': patch +--- + +Added gas estimation query and adjusted folder structure for devnet files From 36aae8163780f3f85a9878bb8f6e33550551b782 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 15:05:23 +0100 Subject: [PATCH 26/74] changeset file pt2 --- .changeset/twelve-donkeys-occur.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/twelve-donkeys-occur.md diff --git a/.changeset/twelve-donkeys-occur.md b/.changeset/twelve-donkeys-occur.md new file mode 100644 index 0000000000..685c78d73c --- /dev/null +++ b/.changeset/twelve-donkeys-occur.md @@ -0,0 +1,6 @@ +--- +'@kadena/graph-client': patch +--- + +Created gas estimation page and ajusted header component to incorporate option +for gas. Also added necessary graph references to consume the endpoint From af4f7a2e0c5864e567410a1864d318c2447ebc7a Mon Sep 17 00:00:00 2001 From: Eileen Guo Date: Mon, 6 Nov 2023 15:48:33 +0100 Subject: [PATCH 27/74] add overflow prop --- .../src/components/Layout/Box/Box.stories.tsx | 18 ++++++++++++++---- .../react-ui/src/components/Layout/Box/Box.tsx | 3 +++ .../components/Layout/Grid/Grid.stories.tsx | 8 ++++++++ .../src/components/Layout/Grid/GridRoot.tsx | 3 +++ .../components/Layout/Stack/Stack.stories.tsx | 8 ++++++++ .../src/components/Layout/Stack/Stack.tsx | 3 +++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/libs/react-ui/src/components/Layout/Box/Box.stories.tsx b/packages/libs/react-ui/src/components/Layout/Box/Box.stories.tsx index be809bbe73..17ced46c2c 100644 --- a/packages/libs/react-ui/src/components/Layout/Box/Box.stories.tsx +++ b/packages/libs/react-ui/src/components/Layout/Box/Box.stories.tsx @@ -3,7 +3,7 @@ import { Box } from '@components/Layout/Box'; import type { Meta, StoryObj } from '@storybook/react'; import { vars } from '@theme/vars.css'; import React from 'react'; -import { containerClass, itemClass } from '../stories.css'; +import { componentClass, containerClass, itemClass } from '../stories.css'; const spaceOptions: (keyof typeof vars.sizes | undefined)[] = [ undefined, @@ -17,6 +17,7 @@ const dimensionOptions: string[] = ['100%', 'min-content', 'max-content']; const meta: Meta = { title: 'Layout/Box', + component: Box, parameters: { docs: { description: { @@ -27,6 +28,13 @@ const meta: Meta = { }, }, argTypes: { + overflow: { + options: ['hidden', 'visible', 'scroll', 'auto'], + control: { + type: 'select', + }, + description: 'Overflow css property.', + }, width: { options: [...spaceOptions, ...dimensionOptions, ...contentWidthOptions], control: { @@ -218,7 +226,7 @@ export const Primary: Story = { marginBottom, marginLeft, marginRight, - padding = '$6', + padding, paddingX, paddingY, paddingTop, @@ -231,6 +239,7 @@ export const Primary: Story = { height, minHeight, maxHeight, + overflow, }) => (
- Box Content +
Box Content
), diff --git a/packages/libs/react-ui/src/components/Layout/Box/Box.tsx b/packages/libs/react-ui/src/components/Layout/Box/Box.tsx index 2bceabf6de..2345886e4f 100644 --- a/packages/libs/react-ui/src/components/Layout/Box/Box.tsx +++ b/packages/libs/react-ui/src/components/Layout/Box/Box.tsx @@ -22,6 +22,7 @@ export interface IBoxProps | 'maxWidth' | 'minHeight' | 'minWidth' + | 'overflow' | 'padding' | 'paddingBottom' | 'paddingLeft' @@ -54,6 +55,7 @@ export const Box = ({ maxWidth, minHeight, minWidth, + overflow, padding, paddingBottom, paddingLeft, @@ -81,6 +83,7 @@ export const Box = ({ maxWidth, minHeight, minWidth, + overflow, padding, paddingBottom, paddingLeft, diff --git a/packages/libs/react-ui/src/components/Layout/Grid/Grid.stories.tsx b/packages/libs/react-ui/src/components/Layout/Grid/Grid.stories.tsx index d2e55b0362..ce0f0b4b0e 100644 --- a/packages/libs/react-ui/src/components/Layout/Grid/Grid.stories.tsx +++ b/packages/libs/react-ui/src/components/Layout/Grid/Grid.stories.tsx @@ -35,6 +35,13 @@ const meta: Meta = { }, component: Grid.Root, argTypes: { + overflow: { + options: ['hidden', 'visible', 'scroll', 'auto'], + control: { + type: 'select', + }, + description: 'Overflow css property.', + }, gap: { options: Object.keys(gapVariants) as (keyof typeof gapVariants)[], control: { type: 'select' }, @@ -249,6 +256,7 @@ const defaultArgs: Record = { paddingBottom: undefined, paddingLeft: undefined, paddingRight: undefined, + overflow: undefined, }; export const GridRoot: Story = { diff --git a/packages/libs/react-ui/src/components/Layout/Grid/GridRoot.tsx b/packages/libs/react-ui/src/components/Layout/Grid/GridRoot.tsx index 72fbb88b94..59d5df5cf6 100644 --- a/packages/libs/react-ui/src/components/Layout/Grid/GridRoot.tsx +++ b/packages/libs/react-ui/src/components/Layout/Grid/GridRoot.tsx @@ -25,6 +25,7 @@ export interface IGridRootProps | 'maxWidth' | 'minHeight' | 'minWidth' + | 'overflow' | 'padding' | 'paddingBottom' | 'paddingLeft' @@ -71,6 +72,7 @@ export const GridRoot: FC = ({ maxWidth, minHeight, minWidth, + overflow, padding, paddingBottom, paddingLeft, @@ -97,6 +99,7 @@ export const GridRoot: FC = ({ maxWidth, minHeight, minWidth, + overflow, padding, paddingBottom, paddingLeft, diff --git a/packages/libs/react-ui/src/components/Layout/Stack/Stack.stories.tsx b/packages/libs/react-ui/src/components/Layout/Stack/Stack.stories.tsx index eb82d3e04b..a751c31791 100644 --- a/packages/libs/react-ui/src/components/Layout/Stack/Stack.stories.tsx +++ b/packages/libs/react-ui/src/components/Layout/Stack/Stack.stories.tsx @@ -31,6 +31,13 @@ const meta: Meta = { }, }, argTypes: { + overflow: { + options: ['hidden', 'visible', 'scroll', 'auto'], + control: { + type: 'select', + }, + description: 'Overflow css property', + }, width: { options: [...spaceOptions, ...dimensionOptions, ...contentWidthOptions], control: { @@ -263,6 +270,7 @@ const defaultArgs: Record = { paddingBottom: undefined, paddingLeft: undefined, paddingRight: undefined, + overflow: undefined, }; export const Horizontal: Story = { diff --git a/packages/libs/react-ui/src/components/Layout/Stack/Stack.tsx b/packages/libs/react-ui/src/components/Layout/Stack/Stack.tsx index 53e8ef7da5..836b2fdda3 100644 --- a/packages/libs/react-ui/src/components/Layout/Stack/Stack.tsx +++ b/packages/libs/react-ui/src/components/Layout/Stack/Stack.tsx @@ -23,6 +23,7 @@ export interface IStackProps | 'maxWidth' | 'minHeight' | 'minWidth' + | 'overflow' | 'padding' | 'paddingBottom' | 'paddingLeft' @@ -59,6 +60,7 @@ export const Stack = ({ maxWidth, minHeight, minWidth, + overflow, padding, paddingBottom, paddingLeft, @@ -92,6 +94,7 @@ export const Stack = ({ maxWidth, minHeight, minWidth, + overflow, padding, paddingBottom, paddingLeft, From 3cf97cab468e91cb83fb90daeedf296347128a83 Mon Sep 17 00:00:00 2001 From: Nil Amrutlal Date: Mon, 6 Nov 2023 16:45:41 +0100 Subject: [PATCH 28/74] remove logger.info from simulate --- packages/apps/graph/src/devnet/simulation/simulate.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/apps/graph/src/devnet/simulation/simulate.ts b/packages/apps/graph/src/devnet/simulation/simulate.ts index 04356b0b6f..2d7290764d 100644 --- a/packages/apps/graph/src/devnet/simulation/simulate.ts +++ b/packages/apps/graph/src/devnet/simulation/simulate.ts @@ -180,8 +180,6 @@ export async function simulate({ accounts.push(nextAccount); } - logger.info(accounts); - await new Promise((resolve) => setTimeout(resolve, transferInterval)); } counter++; From 2f48dca5b5cf625b94a5ac62b05b3eef3d32258f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 6 Nov 2023 15:54:08 +0000 Subject: [PATCH 29/74] Update changelogs and bump versions [skip ci] --- .changeset/cyan-elephants-fly.md | 6 --- .changeset/friendly-cherries-sparkle.md | 5 -- .changeset/good-poets-listen.md | 2 - .changeset/lovely-jobs-jam.md | 5 -- .changeset/pretty-balloons-love.md | 6 --- .changeset/shaggy-zebras-dance.md | 5 -- .changeset/sharp-llamas-battle.md | 2 - .changeset/slow-humans-swim.md | 2 - .changeset/smart-tables-begin.md | 5 -- .changeset/strange-bees-talk.md | 6 --- .changeset/strong-students-speak.md | 5 -- .changeset/sweet-years-love.md | 2 - .changeset/ten-pans-knock.md | 5 -- .changeset/two-jeans-watch.md | 7 --- .changeset/violet-chairs-yawn.md | 6 --- .changeset/weak-coats-peel.md | 6 --- .changeset/wise-pianos-judge.md | 5 -- packages.json | 56 ++++++++++---------- packages/apps/docs/CHANGELOG.md | 14 +++++ packages/apps/docs/package.json | 2 +- packages/apps/graph-client/CHANGELOG.md | 13 +++++ packages/apps/graph-client/package.json | 2 +- packages/apps/graph/CHANGELOG.md | 12 +++++ packages/apps/graph/package.json | 2 +- packages/apps/immutable-records/CHANGELOG.md | 12 +++++ packages/apps/immutable-records/package.json | 2 +- packages/libs/client-examples/CHANGELOG.md | 9 ++++ packages/libs/client-examples/package.json | 2 +- packages/libs/client-utils/CHANGELOG.md | 10 ++++ packages/libs/client-utils/package.json | 2 +- packages/libs/client/CHANGELOG.md | 6 +++ packages/libs/client/package.json | 2 +- packages/libs/pactjs-generator/CHANGELOG.md | 2 + packages/libs/pactjs-generator/package.json | 2 +- packages/libs/react-ui/CHANGELOG.md | 15 ++++++ packages/libs/react-ui/package.json | 2 +- packages/tools/cookbook/CHANGELOG.md | 7 +++ packages/tools/cookbook/package.json | 2 +- packages/tools/pactjs-cli/CHANGELOG.md | 6 +++ packages/tools/pactjs-cli/package.json | 2 +- 40 files changed, 145 insertions(+), 119 deletions(-) delete mode 100644 .changeset/cyan-elephants-fly.md delete mode 100644 .changeset/friendly-cherries-sparkle.md delete mode 100644 .changeset/good-poets-listen.md delete mode 100644 .changeset/lovely-jobs-jam.md delete mode 100644 .changeset/pretty-balloons-love.md delete mode 100644 .changeset/shaggy-zebras-dance.md delete mode 100644 .changeset/sharp-llamas-battle.md delete mode 100644 .changeset/slow-humans-swim.md delete mode 100644 .changeset/smart-tables-begin.md delete mode 100644 .changeset/strange-bees-talk.md delete mode 100644 .changeset/strong-students-speak.md delete mode 100644 .changeset/sweet-years-love.md delete mode 100644 .changeset/ten-pans-knock.md delete mode 100644 .changeset/two-jeans-watch.md delete mode 100644 .changeset/violet-chairs-yawn.md delete mode 100644 .changeset/weak-coats-peel.md delete mode 100644 .changeset/wise-pianos-judge.md diff --git a/.changeset/cyan-elephants-fly.md b/.changeset/cyan-elephants-fly.md deleted file mode 100644 index 5d5c27995e..0000000000 --- a/.changeset/cyan-elephants-fly.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@kadena/client-utils': patch ---- - -change the sign event that happens for continuation transaction from "sign" to -"sign-continuation" diff --git a/.changeset/friendly-cherries-sparkle.md b/.changeset/friendly-cherries-sparkle.md deleted file mode 100644 index 6c6ef703cb..0000000000 --- a/.changeset/friendly-cherries-sparkle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/react-ui': minor ---- - -Exported the Textarea and TextareaField components diff --git a/.changeset/good-poets-listen.md b/.changeset/good-poets-listen.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/good-poets-listen.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/lovely-jobs-jam.md b/.changeset/lovely-jobs-jam.md deleted file mode 100644 index 0b68c508dc..0000000000 --- a/.changeset/lovely-jobs-jam.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/docs': minor ---- - -import docs from external repos diff --git a/.changeset/pretty-balloons-love.md b/.changeset/pretty-balloons-love.md deleted file mode 100644 index df5603bc3a..0000000000 --- a/.changeset/pretty-balloons-love.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@kadena/client': patch -'@kadena/client-utils': patch ---- - -Fix pred type for keysets diff --git a/.changeset/shaggy-zebras-dance.md b/.changeset/shaggy-zebras-dance.md deleted file mode 100644 index d74374b145..0000000000 --- a/.changeset/shaggy-zebras-dance.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph': patch ---- - -Added query to get transactions by public key diff --git a/.changeset/sharp-llamas-battle.md b/.changeset/sharp-llamas-battle.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/sharp-llamas-battle.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/slow-humans-swim.md b/.changeset/slow-humans-swim.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/slow-humans-swim.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/smart-tables-begin.md b/.changeset/smart-tables-begin.md deleted file mode 100644 index 9be3c5175e..0000000000 --- a/.changeset/smart-tables-begin.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/react-ui': patch ---- - -Exported MaskOptions type diff --git a/.changeset/strange-bees-talk.md b/.changeset/strange-bees-talk.md deleted file mode 100644 index 973eca84bf..0000000000 --- a/.changeset/strange-bees-talk.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@kadena/react-ui': minor ---- - -Add new width, height, and className properties to sprinkles and update Box, Stack and Grid -components to use them diff --git a/.changeset/strong-students-speak.md b/.changeset/strong-students-speak.md deleted file mode 100644 index 14cd050ba3..0000000000 --- a/.changeset/strong-students-speak.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph': patch ---- - -Added endpoint for graph and chainweb-data general info diff --git a/.changeset/sweet-years-love.md b/.changeset/sweet-years-love.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/sweet-years-love.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/ten-pans-knock.md b/.changeset/ten-pans-knock.md deleted file mode 100644 index 709e9c7a9e..0000000000 --- a/.changeset/ten-pans-knock.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph': patch ---- - -Updated simulate command to now incorporate safe-transfers diff --git a/.changeset/two-jeans-watch.md b/.changeset/two-jeans-watch.md deleted file mode 100644 index 67ff714883..0000000000 --- a/.changeset/two-jeans-watch.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@kadena/react-ui': minor ---- - -Corrected `Tag` background color -Extracted `maskValue` string utility function from `MaskedValue` component -Accept ReactNode as `children` prop for `Tag` component diff --git a/.changeset/violet-chairs-yawn.md b/.changeset/violet-chairs-yawn.md deleted file mode 100644 index cc6002cd22..0000000000 --- a/.changeset/violet-chairs-yawn.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@kadena/graph-client': patch -'@kadena/graph': patch ---- - -Added proper error logging for the graph and client diff --git a/.changeset/weak-coats-peel.md b/.changeset/weak-coats-peel.md deleted file mode 100644 index 9ae757f09c..0000000000 --- a/.changeset/weak-coats-peel.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@kadena/graph-client': patch ---- - -Changed queries to adjust to new endpoint for getting graph and chainweb-data -info diff --git a/.changeset/wise-pianos-judge.md b/.changeset/wise-pianos-judge.md deleted file mode 100644 index e5020c07c3..0000000000 --- a/.changeset/wise-pianos-judge.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@kadena/graph': patch ---- - -Added PactData as optional argument to PactQueries diff --git a/packages.json b/packages.json index 2def1e0cc7..f45888b097 100644 --- a/packages.json +++ b/packages.json @@ -7,73 +7,73 @@ }, { "name": "@kadena/chainweb-node-client", - "version": "0.5.0", + "version": "0.5.1", "private": false, "path": "packages/libs/chainweb-node-client" }, { "name": "@kadena/chainweb-stream-client", - "version": "0.2.0", + "version": "0.2.1", "private": false, "path": "packages/libs/chainweb-stream-client" }, { "name": "@kadena/chainwebjs", - "version": "0.1.0", + "version": "0.1.1", "private": false, "path": "packages/libs/chainwebjs" }, { "name": "@kadena/client", - "version": "1.5.0", + "version": "1.6.1", "private": false, "path": "packages/libs/client" }, { "name": "@kadena/client-examples", - "version": "0.0.5", + "version": "0.0.7", "private": true, "path": "packages/libs/client-examples" }, { "name": "@kadena/client-utils", - "version": "0.0.2", + "version": "0.0.4", "private": false, "path": "packages/libs/client-utils" }, { "name": "@kadena/cookbook", - "version": "0.0.4", + "version": "0.0.6", "private": true, "path": "packages/tools/cookbook" }, { "name": "@kadena/cryptography-utils", - "version": "0.4.0", + "version": "0.4.1", "private": false, "path": "packages/libs/cryptography-utils" }, { "name": "@kadena/docs", - "version": "0.4.1", + "version": "0.6.0", "private": true, "path": "packages/apps/docs" }, { "name": "@kadena/graph", - "version": "1.0.1", + "version": "1.0.3", "private": true, "path": "packages/apps/graph" }, { "name": "@kadena/graph-client", - "version": "0.1.2", + "version": "0.1.4", "private": true, "path": "packages/apps/graph-client" }, { "name": "@kadena/immutable-records", - "version": "0.1.2", + "version": "0.1.4", "private": true, "path": "packages/apps/immutable-records" }, @@ -85,37 +85,37 @@ }, { "name": "@kadena/kda-cli", - "version": "0.0.2", + "version": "0.0.3", "private": true, "path": "packages/tools/kda-cli" }, { "name": "@kadena/pactjs", - "version": "0.4.0", + "version": "0.4.1", "private": false, "path": "packages/libs/pactjs" }, { "name": "@kadena/pactjs-cli", - "version": "1.5.0", + "version": "1.6.1", "private": false, "path": "packages/tools/pactjs-cli" }, { "name": "@kadena/pactjs-generator", - "version": "1.5.0", + "version": "1.6.1", "private": false, "path": "packages/libs/pactjs-generator" }, { "name": "@kadena/react-components", - "version": "0.1.1", + "version": "0.1.2", "private": true, "path": "packages/libs/react-components" }, { "name": "@kadena/react-ui", - "version": "0.2.0", + "version": "0.3.0", "private": true, "path": "packages/libs/react-ui" }, @@ -127,56 +127,56 @@ }, { "name": "@kadena/types", - "version": "0.5.0", + "version": "0.5.1", "private": false, "path": "packages/libs/types" }, { "name": "@kadena-dev/e2e-tests", - "version": "0.0.1", + "version": "0.0.2", "private": true, "path": "packages/tools/e2e-tests" }, { "name": "@kadena-dev/eslint-config", - "version": "1.0.1", + "version": "1.0.2", "private": false, "path": "packages/tools/eslint-config" }, { "name": "@kadena-dev/eslint-plugin", - "version": "0.0.7", + "version": "0.0.8", "private": false, "path": "packages/tools/eslint-plugin" }, { "name": "@kadena-dev/lint-package", - "version": "0.1.1", + "version": "0.1.2", "private": true, "path": "packages/tools/lint-package" }, { "name": "@kadena-dev/markdown", - "version": "1.0.1", + "version": "1.0.2", "private": true, "path": "packages/tools/markdown" }, { "name": "@kadena-dev/scripts", - "version": "0.0.1", + "version": "0.0.2", "private": true, "path": "packages/tools/scripts" }, { "name": "@kadena-dev/shared-config", - "version": "1.0.0", + "version": "1.0.1", "private": false, "path": "packages/tools/shared-config" }, { "name": "kadena.js", - "version": "0.0.2", + "version": "0.0.3", "private": true, "path": "packages/libs/kadena.js" } -] +] \ No newline at end of file diff --git a/packages/apps/docs/CHANGELOG.md b/packages/apps/docs/CHANGELOG.md index 083c7b2e0f..a5dc5c5157 100644 --- a/packages/apps/docs/CHANGELOG.md +++ b/packages/apps/docs/CHANGELOG.md @@ -1,5 +1,19 @@ # @kadena/docs +## 0.6.0 + +### Minor Changes + +- d03a5b762: import docs from external repos + +### Patch Changes + +- Updated dependencies [11747cde4] +- Updated dependencies [6491589b5] +- Updated dependencies [8a719c647] +- Updated dependencies [df7044cac] + - @kadena/react-ui@0.3.0 + ## 0.5.0 ### Minor Changes diff --git a/packages/apps/docs/package.json b/packages/apps/docs/package.json index 5da2a959d6..f56de6e151 100644 --- a/packages/apps/docs/package.json +++ b/packages/apps/docs/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/docs", - "version": "0.5.0", + "version": "0.6.0", "private": true, "scripts": { "7d": "npx 7d pinecone-create-index --index kda-docs --environment asia-northeast1-gcp", diff --git a/packages/apps/graph-client/CHANGELOG.md b/packages/apps/graph-client/CHANGELOG.md index f1caf6840e..15365df027 100644 --- a/packages/apps/graph-client/CHANGELOG.md +++ b/packages/apps/graph-client/CHANGELOG.md @@ -1,5 +1,18 @@ # @kadena/graph-client +## 0.1.4 + +### Patch Changes + +- 6e4895050: Added proper error logging for the graph and client +- 39a870cea: Changed queries to adjust to new endpoint for getting graph and + chainweb-data info +- Updated dependencies [11747cde4] +- Updated dependencies [6491589b5] +- Updated dependencies [8a719c647] +- Updated dependencies [df7044cac] + - @kadena/react-ui@0.3.0 + ## 0.1.3 ### Patch Changes diff --git a/packages/apps/graph-client/package.json b/packages/apps/graph-client/package.json index 00537ffb91..5cc856a00e 100644 --- a/packages/apps/graph-client/package.json +++ b/packages/apps/graph-client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/graph-client", - "version": "0.1.3", + "version": "0.1.4", "private": true, "scripts": { "build": "pnpm run generate:sdk && next build", diff --git a/packages/apps/graph/CHANGELOG.md b/packages/apps/graph/CHANGELOG.md index 2e8d8f9f8b..562e35fa2d 100644 --- a/packages/apps/graph/CHANGELOG.md +++ b/packages/apps/graph/CHANGELOG.md @@ -1,5 +1,17 @@ # @kadena/graph +## 1.0.3 + +### Patch Changes + +- 2e18fe50c: Added query to get transactions by public key +- 39a870cea: Added endpoint for graph and chainweb-data general info +- aced46632: Updated simulate command to now incorporate safe-transfers +- 6e4895050: Added proper error logging for the graph and client +- 9de5d550c: Added PactData as optional argument to PactQueries +- Updated dependencies [445fb2c7d] + - @kadena/client@1.6.1 + ## 1.0.2 ### Patch Changes diff --git a/packages/apps/graph/package.json b/packages/apps/graph/package.json index b3180f97f4..113950700f 100644 --- a/packages/apps/graph/package.json +++ b/packages/apps/graph/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/graph", - "version": "1.0.2", + "version": "1.0.3", "private": true, "description": "", "keywords": [], diff --git a/packages/apps/immutable-records/CHANGELOG.md b/packages/apps/immutable-records/CHANGELOG.md index eda79171f3..66d5e0b704 100644 --- a/packages/apps/immutable-records/CHANGELOG.md +++ b/packages/apps/immutable-records/CHANGELOG.md @@ -1,5 +1,17 @@ # @kadena/immutable-records +## 0.1.4 + +### Patch Changes + +- Updated dependencies [11747cde4] +- Updated dependencies [445fb2c7d] +- Updated dependencies [6491589b5] +- Updated dependencies [8a719c647] +- Updated dependencies [df7044cac] + - @kadena/react-ui@0.3.0 + - @kadena/client@1.6.1 + ## 0.1.3 ### Patch Changes diff --git a/packages/apps/immutable-records/package.json b/packages/apps/immutable-records/package.json index 78d44a0969..c994172ebc 100644 --- a/packages/apps/immutable-records/package.json +++ b/packages/apps/immutable-records/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/immutable-records", - "version": "0.1.3", + "version": "0.1.4", "private": true, "scripts": { "build": "next build", diff --git a/packages/libs/client-examples/CHANGELOG.md b/packages/libs/client-examples/CHANGELOG.md index 044cd376d7..6c29f7f4e0 100644 --- a/packages/libs/client-examples/CHANGELOG.md +++ b/packages/libs/client-examples/CHANGELOG.md @@ -1,5 +1,14 @@ # @kadena/client-examples +## 0.0.7 + +### Patch Changes + +- Updated dependencies [7a0b62119] +- Updated dependencies [445fb2c7d] + - @kadena/client-utils@0.0.4 + - @kadena/client@1.6.1 + ## 0.0.6 ### Patch Changes diff --git a/packages/libs/client-examples/package.json b/packages/libs/client-examples/package.json index 1eb08bc6df..f28549294d 100644 --- a/packages/libs/client-examples/package.json +++ b/packages/libs/client-examples/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client-examples", - "version": "0.0.6", + "version": "0.0.7", "private": true, "description": "Test project to verify pactjs-cli and pactjs-generator", "repository": { diff --git a/packages/libs/client-utils/CHANGELOG.md b/packages/libs/client-utils/CHANGELOG.md index 18eb7bc04f..4f83442e9d 100644 --- a/packages/libs/client-utils/CHANGELOG.md +++ b/packages/libs/client-utils/CHANGELOG.md @@ -1,5 +1,15 @@ # @kadena/client-utils +## 0.0.4 + +### Patch Changes + +- 7a0b62119: change the sign event that happens for continuation transaction + from "sign" to "sign-continuation" +- 445fb2c7d: Fix pred type for keysets +- Updated dependencies [445fb2c7d] + - @kadena/client@1.6.1 + ## 0.0.3 ### Patch Changes diff --git a/packages/libs/client-utils/package.json b/packages/libs/client-utils/package.json index f04c36160a..531cc26aa1 100644 --- a/packages/libs/client-utils/package.json +++ b/packages/libs/client-utils/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client-utils", - "version": "0.0.3", + "version": "0.0.4", "description": "Utility functions build as a wrapper around @kadena/client", "repository": { "type": "git", diff --git a/packages/libs/client/CHANGELOG.md b/packages/libs/client/CHANGELOG.md index 837edb2d2c..bfb88ba673 100644 --- a/packages/libs/client/CHANGELOG.md +++ b/packages/libs/client/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/client +## 1.6.1 + +### Patch Changes + +- 445fb2c7d: Fix pred type for keysets + ## 1.6.0 ### Patch Changes diff --git a/packages/libs/client/package.json b/packages/libs/client/package.json index 6750d76557..29a7f10cfc 100644 --- a/packages/libs/client/package.json +++ b/packages/libs/client/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/client", - "version": "1.6.0", + "version": "1.6.1", "description": "Core library for building Pact expressions to send to the blockchain in js. Makes use of .kadena/pactjs-generated", "repository": { "type": "git", diff --git a/packages/libs/pactjs-generator/CHANGELOG.md b/packages/libs/pactjs-generator/CHANGELOG.md index 12f8ac7765..fae8f80766 100644 --- a/packages/libs/pactjs-generator/CHANGELOG.md +++ b/packages/libs/pactjs-generator/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log - @kadena/pactjs-generator +## 1.6.1 + ## 1.6.0 ### Patch Changes diff --git a/packages/libs/pactjs-generator/package.json b/packages/libs/pactjs-generator/package.json index fad77e5bb7..734b5b6ee2 100644 --- a/packages/libs/pactjs-generator/package.json +++ b/packages/libs/pactjs-generator/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs-generator", - "version": "1.6.0", + "version": "1.6.1", "description": "Generates TypeScript definitions of Pact contracts, for use in @kadena/pactjs", "repository": { "type": "git", diff --git a/packages/libs/react-ui/CHANGELOG.md b/packages/libs/react-ui/CHANGELOG.md index eb63e38c56..db44de9a82 100644 --- a/packages/libs/react-ui/CHANGELOG.md +++ b/packages/libs/react-ui/CHANGELOG.md @@ -1,5 +1,20 @@ # @kadena/react-ui +## 0.3.0 + +### Minor Changes + +- 11747cde4: Exported the Textarea and TextareaField components +- 8a719c647: Add new width, height, and className properties to sprinkles and + update Box, Stack and Grid components to use them +- df7044cac: Corrected `Tag` background color Extracted `maskValue` string + utility function from `MaskedValue` component Accept ReactNode as `children` + prop for `Tag` component + +### Patch Changes + +- 6491589b5: Exported MaskOptions type + ## 0.2.1 ### Patch Changes diff --git a/packages/libs/react-ui/package.json b/packages/libs/react-ui/package.json index 56b10c5839..7cb9a372fe 100644 --- a/packages/libs/react-ui/package.json +++ b/packages/libs/react-ui/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/react-ui", - "version": "0.2.1", + "version": "0.3.0", "private": true, "description": "A react component library built on Kadena's Design System", "license": "ISC", diff --git a/packages/tools/cookbook/CHANGELOG.md b/packages/tools/cookbook/CHANGELOG.md index 0fe4f34d9d..6eed3ca0b2 100644 --- a/packages/tools/cookbook/CHANGELOG.md +++ b/packages/tools/cookbook/CHANGELOG.md @@ -1,5 +1,12 @@ # @kadena/cookbook +## 0.0.6 + +### Patch Changes + +- Updated dependencies [445fb2c7d] + - @kadena/client@1.6.1 + ## 0.0.5 ### Patch Changes diff --git a/packages/tools/cookbook/package.json b/packages/tools/cookbook/package.json index 4c4d6b2184..e141cc94c2 100644 --- a/packages/tools/cookbook/package.json +++ b/packages/tools/cookbook/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/cookbook", - "version": "0.0.5", + "version": "0.0.6", "private": true, "description": "Demonstrates common use cases for @kadena/client and @kadena/pact-cli for smart contracts", "keywords": [], diff --git a/packages/tools/pactjs-cli/CHANGELOG.md b/packages/tools/pactjs-cli/CHANGELOG.md index 97adbc37a6..035996ae54 100644 --- a/packages/tools/pactjs-cli/CHANGELOG.md +++ b/packages/tools/pactjs-cli/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @kadena/pactjs-cli +## 1.6.1 + +### Patch Changes + +- @kadena/pactjs-generator@1.6.1 + ## 1.6.0 ### Minor Changes diff --git a/packages/tools/pactjs-cli/package.json b/packages/tools/pactjs-cli/package.json index 827683f58f..1088427be6 100644 --- a/packages/tools/pactjs-cli/package.json +++ b/packages/tools/pactjs-cli/package.json @@ -1,6 +1,6 @@ { "name": "@kadena/pactjs-cli", - "version": "1.6.0", + "version": "1.6.1", "description": "CLI tool accompanying @kadena/pactjs-core and @kadena/pactjs-client to generate TypeScript definitions and Pact client", "repository": { "type": "git", From ee107ce51b60a57b180d162d6c6438dfa153f342 Mon Sep 17 00:00:00 2001 From: Eileen Guo Date: Mon, 6 Nov 2023 17:40:52 +0100 Subject: [PATCH 30/74] add changeset --- .changeset/five-rockets-beg.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/five-rockets-beg.md diff --git a/.changeset/five-rockets-beg.md b/.changeset/five-rockets-beg.md new file mode 100644 index 0000000000..0b9646f1b5 --- /dev/null +++ b/.changeset/five-rockets-beg.md @@ -0,0 +1,5 @@ +--- +'@kadena/react-ui': patch +--- + +Added overflow prop to the Box, Stack, and Grid components From d2ba20a8d0540c59675bf839f4c86cc3cca6d403 Mon Sep 17 00:00:00 2001 From: Mohamed Ismail Date: Tue, 7 Nov 2023 08:48:50 +0100 Subject: [PATCH 31/74] fix(docs): add legacy docs redirects (#1185) --- .changeset/kind-suns-sparkle.md | 2 ++ packages/apps/docs/redirects.mjs | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .changeset/kind-suns-sparkle.md diff --git a/.changeset/kind-suns-sparkle.md b/.changeset/kind-suns-sparkle.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/kind-suns-sparkle.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/docs/redirects.mjs b/packages/apps/docs/redirects.mjs index 786c85cc44..4f3f3a325d 100644 --- a/packages/apps/docs/redirects.mjs +++ b/packages/apps/docs/redirects.mjs @@ -1,12 +1,27 @@ const redirectsConfig = [ { - source: '/basics/kda/what-is-kda', - destination: '/kadena/kda/', + source: '/exchanges', + destination: '/kadena/exchanges', permanent: true, }, { - source: '/exchanges', - destination: '/kadena/exchange', + source: '/kda/what-is-kda', + destination: '/kadena/kda', + permanent: true, + }, + { + source: '/faq/faq', + destination: '/kadena/support', + permanent: true, + }, + { + source: '/whitepapers/overview', + destination: '/kadena/whitepapers', + permanent: true, + }, + { + source: '/basics/kda/what-is-kda', + destination: '/kadena/kda/', permanent: true, }, { From 09351c0cb2ab893044f31a3fb6a64bfbafd8238a Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 10:48:09 +0100 Subject: [PATCH 32/74] [test] default to vitest run, instead of auto watch. --- package.json | 2 +- packages/apps/tools/package.json | 2 +- packages/libs/bootstrap-lib/package.json | 2 +- packages/libs/chainweb-node-client/package.json | 2 +- packages/libs/chainweb-stream-client/package.json | 2 +- packages/libs/chainwebjs/package.json | 2 +- packages/libs/client-utils/package.json | 2 +- packages/libs/client/package.json | 2 +- packages/libs/cryptography-utils/package.json | 2 +- packages/libs/kadena.js/package.json | 2 +- packages/libs/pactjs-generator/package.json | 2 +- packages/libs/pactjs/package.json | 2 +- packages/libs/react-ui/package.json | 2 +- packages/tools/kda-cli/package.json | 2 +- packages/tools/pactjs-cli/package.json | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 9e2725436a..a0d55d297a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint": "syncpack list-mismatches && prettier . \"!packages\" --cache --check", "publish": "changeset publish", "select": "git checkout .changeset/config.json && tsx --no-warnings ./packages/tools/scripts/publish-set.ts", - "test": "turbo run test -- run --coverage", + "test": "turbo run test", "test:e2e": "turbo run test:e2e", "test:integration": "turbo run test:integration", "version": "changeset version && pnpm run format:pkgs" diff --git a/packages/apps/tools/package.json b/packages/apps/tools/package.json index 197c711cf6..4d4c39421f 100644 --- a/packages/apps/tools/package.json +++ b/packages/apps/tools/package.json @@ -17,7 +17,7 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .ts,.tsx", "start": "next start", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@hookform/resolvers": "~3.1.1", diff --git a/packages/libs/bootstrap-lib/package.json b/packages/libs/bootstrap-lib/package.json index 61ad02b39a..f80a6fede2 100644 --- a/packages/libs/bootstrap-lib/package.json +++ b/packages/libs/bootstrap-lib/package.json @@ -40,7 +40,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@kadena/cryptography-utils": "workspace:*", diff --git a/packages/libs/chainweb-node-client/package.json b/packages/libs/chainweb-node-client/package.json index 257aac0fcc..30234d7366 100644 --- a/packages/libs/chainweb-node-client/package.json +++ b/packages/libs/chainweb-node-client/package.json @@ -41,7 +41,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@kadena/cryptography-utils": "workspace:*", diff --git a/packages/libs/chainweb-stream-client/package.json b/packages/libs/chainweb-stream-client/package.json index a46204e0bd..5d5f7227f8 100644 --- a/packages/libs/chainweb-stream-client/package.json +++ b/packages/libs/chainweb-stream-client/package.json @@ -33,7 +33,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "eventemitter2": "~6.4.9", diff --git a/packages/libs/chainwebjs/package.json b/packages/libs/chainwebjs/package.json index a2be1b7a7b..00770bef8d 100644 --- a/packages/libs/chainwebjs/package.json +++ b/packages/libs/chainwebjs/package.json @@ -57,7 +57,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "base64url": "^3.0.1", diff --git a/packages/libs/client-utils/package.json b/packages/libs/client-utils/package.json index 531cc26aa1..ec1635b15d 100644 --- a/packages/libs/client-utils/package.json +++ b/packages/libs/client-utils/package.json @@ -52,7 +52,7 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", "pactjs:generate:contract": "pactjs contract-generate --contract coin --api https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact", - "test": "vitest", + "test": "vitest run", "test:integration": "vitest run -c ./vitest.integration.config.ts" }, "dependencies": { diff --git a/packages/libs/client/package.json b/packages/libs/client/package.json index 29a7f10cfc..e58f13be0a 100644 --- a/packages/libs/client/package.json +++ b/packages/libs/client/package.json @@ -38,7 +38,7 @@ "pactjs:generate:contract": "pactjs contract-generate --file contracts/coin.contract.pact", "pactjs:retrieve:contract": "pactjs retrieve-contract --out contracts/coin.contract.pact --module coin", "start": "ts-node --transpile-only src/index.ts", - "test": "vitest", + "test": "vitest run", "test:integration": "vitest run -c ./vitest.integration.config.ts" }, "dependencies": { diff --git a/packages/libs/cryptography-utils/package.json b/packages/libs/cryptography-utils/package.json index 14d13e4a1d..83a23d2c25 100644 --- a/packages/libs/cryptography-utils/package.json +++ b/packages/libs/cryptography-utils/package.json @@ -39,7 +39,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "blakejs": "^1.2.1", diff --git a/packages/libs/kadena.js/package.json b/packages/libs/kadena.js/package.json index f3ac817e48..58132c0eae 100644 --- a/packages/libs/kadena.js/package.json +++ b/packages/libs/kadena.js/package.json @@ -54,7 +54,7 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", "serve-coverage": "python -m SimpleHTTPServer", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@kadena/chainweb-node-client": "workspace:*", diff --git a/packages/libs/pactjs-generator/package.json b/packages/libs/pactjs-generator/package.json index 734b5b6ee2..4103dc2882 100644 --- a/packages/libs/pactjs-generator/package.json +++ b/packages/libs/pactjs-generator/package.json @@ -34,7 +34,7 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", "start": "ts-node --transpile-only src/index.ts", - "test": "vitest", + "test": "vitest run", "util:lexer-grammar:watch": "concurrently --kill-others npm:build:*:watch # npm:test:grammar:watch" }, "dependencies": { diff --git a/packages/libs/pactjs/package.json b/packages/libs/pactjs/package.json index c43565288c..8559047d0e 100644 --- a/packages/libs/pactjs/package.json +++ b/packages/libs/pactjs/package.json @@ -39,7 +39,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "bignumber.js": "^9.1.2" diff --git a/packages/libs/react-ui/package.json b/packages/libs/react-ui/package.json index 7cb9a372fe..829e5babf7 100644 --- a/packages/libs/react-ui/package.json +++ b/packages/libs/react-ui/package.json @@ -39,7 +39,7 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts,.tsx", "storybook": "storybook dev -p 6006", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@kadena/fonts": "~0.0.1", diff --git a/packages/tools/kda-cli/package.json b/packages/tools/kda-cli/package.json index 93b2cd048c..06471634b5 100644 --- a/packages/tools/kda-cli/package.json +++ b/packages/tools/kda-cli/package.json @@ -32,7 +32,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts,.tsx", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@inkjs/ui": "^1.0.0", diff --git a/packages/tools/pactjs-cli/package.json b/packages/tools/pactjs-cli/package.json index 1088427be6..8ca5a79161 100644 --- a/packages/tools/pactjs-cli/package.json +++ b/packages/tools/pactjs-cli/package.json @@ -31,7 +31,7 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest" + "test": "vitest run" }, "dependencies": { "@kadena/pactjs-generator": "workspace:*", From 5073a1bb233d95a9bb44a7000cb033244c2e9928 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:31:38 +0100 Subject: [PATCH 33/74] [test] Fully depend on shared vitest config for chainwebjs --- packages/libs/chainwebjs/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/libs/chainwebjs/vitest.config.ts b/packages/libs/chainwebjs/vitest.config.ts index 7a7fbbe122..a1a5d34292 100644 --- a/packages/libs/chainwebjs/vitest.config.ts +++ b/packages/libs/chainwebjs/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 90, - functions: 90, - branches: 90, - statements: 90, - }, - }, - }), -); +export default defineConfig(baseConfig); From 93b0e565e283af6d03bee051ba89e6249a709112 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:34:47 +0100 Subject: [PATCH 34/74] [test] enable coverage by default. --- packages/tools/shared-config/vitest.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/tools/shared-config/vitest.config.js b/packages/tools/shared-config/vitest.config.js index 5cce9512b8..9b9a391164 100644 --- a/packages/tools/shared-config/vitest.config.js +++ b/packages/tools/shared-config/vitest.config.js @@ -7,8 +7,12 @@ module.exports = defineConfig({ include: ['src/**/*.{test,spec}.{ts,tsx}'], globals: false, coverage: { - enabled: false, // It's enabled in CI (root package.json) + enabled: true, provider: 'v8', + lines: 90, + functions: 90, + branches: 90, + statements: 90, thresholdAutoUpdate: false, // Should be enabled? Too precise though, annoying in CI if missed by 0.01% }, }, From f1fc855e96ace0b0553cd44ea7bd2460d52e3537 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:40:00 +0100 Subject: [PATCH 35/74] [test] depend on shared vitest config for pactjs-cli. --- .../utils/tests/retrieveContractFromChain.test.ts | 14 ++++++++++++++ packages/tools/pactjs-cli/vitest.config.ts | 8 ++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/tools/pactjs-cli/src/utils/tests/retrieveContractFromChain.test.ts b/packages/tools/pactjs-cli/src/utils/tests/retrieveContractFromChain.test.ts index df49172be8..c88264098f 100644 --- a/packages/tools/pactjs-cli/src/utils/tests/retrieveContractFromChain.test.ts +++ b/packages/tools/pactjs-cli/src/utils/tests/retrieveContractFromChain.test.ts @@ -8,6 +8,10 @@ const httpHandlers = [ 'https://api.chainweb.com/chainweb/0.0/mainnet01/chain/8/pact/api/v1/local', () => HttpResponse.json({ result: { data: { code: 'some pactCode' } } }), ), + http.post( + 'https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact/api/v1/local', + () => HttpResponse.text('hello world!'), + ), ]; const server = setupServer(...httpHandlers); @@ -26,4 +30,14 @@ describe('retrieveContractFromChain', () => { expect(result).toBe('some pactCode'); }); + it('Undefined result if unable to return JSON.', async () => { + const result = await retrieveContractFromChain( + 'free.crankk01', + 'https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact', + 0, + 'mainnet', + ); + + expect(result).toBe(undefined); + }); }); diff --git a/packages/tools/pactjs-cli/vitest.config.ts b/packages/tools/pactjs-cli/vitest.config.ts index bfaebe3ce6..a1a5d34292 100644 --- a/packages/tools/pactjs-cli/vitest.config.ts +++ b/packages/tools/pactjs-cli/vitest.config.ts @@ -1,8 +1,4 @@ +import baseConfig from '@kadena-dev/shared-config/vitest.config'; import { defineConfig } from 'vitest/config'; -export default defineConfig({ - test: { - include: ['src/**/*.test.ts'], - globals: true, - }, -}); +export default defineConfig(baseConfig); From c518952e4b0dc9d92b830bd119542c9fda92fb78 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:44:28 +0100 Subject: [PATCH 36/74] [test] depend on shared vitest config for kda-cli --- packages/tools/kda-cli/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/tools/kda-cli/vitest.config.ts b/packages/tools/kda-cli/vitest.config.ts index 7a7fbbe122..a1a5d34292 100644 --- a/packages/tools/kda-cli/vitest.config.ts +++ b/packages/tools/kda-cli/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 90, - functions: 90, - branches: 90, - statements: 90, - }, - }, - }), -); +export default defineConfig(baseConfig); From 4a41944a993e894e2212f14883a1ea48b4acdb9f Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:53:06 +0100 Subject: [PATCH 37/74] [test] Enable threshold auto update for react-ui --- packages/libs/react-ui/vitest.config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/libs/react-ui/vitest.config.ts b/packages/libs/react-ui/vitest.config.ts index 985cac34f6..b3c05287b7 100644 --- a/packages/libs/react-ui/vitest.config.ts +++ b/packages/libs/react-ui/vitest.config.ts @@ -10,10 +10,12 @@ export default mergeConfig( setupFiles: ['vitest.setup.ts'], environment: 'happy-dom', coverage: { + provider: 'v8', lines: 50, functions: 30, branches: 80, statements: 50, + thresholdAutoUpdate: true, }, }, }), From 9bedf415f47ff73f2c228becadabde9e983d08e1 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:54:38 +0100 Subject: [PATCH 38/74] [test] Depend on shared config for pactjs-generator. --- packages/libs/pactjs-generator/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/libs/pactjs-generator/vitest.config.ts b/packages/libs/pactjs-generator/vitest.config.ts index 7a7fbbe122..a1a5d34292 100644 --- a/packages/libs/pactjs-generator/vitest.config.ts +++ b/packages/libs/pactjs-generator/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 90, - functions: 90, - branches: 90, - statements: 90, - }, - }, - }), -); +export default defineConfig(baseConfig); From 6b1e694565e216a9a38a6b89e17db4fe579f8844 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:55:56 +0100 Subject: [PATCH 39/74] [test] Depend on shared config for pactjs --- packages/libs/pactjs/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/libs/pactjs/vitest.config.ts b/packages/libs/pactjs/vitest.config.ts index 7a7fbbe122..a1a5d34292 100644 --- a/packages/libs/pactjs/vitest.config.ts +++ b/packages/libs/pactjs/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 90, - functions: 90, - branches: 90, - statements: 90, - }, - }, - }), -); +export default defineConfig(baseConfig); From 59baa934cf6dc07ecf7494318c9aac0c2734f25c Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:57:27 +0100 Subject: [PATCH 40/74] [test] Depend on shared config for kadenajs --- packages/libs/kadena.js/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/libs/kadena.js/vitest.config.ts b/packages/libs/kadena.js/vitest.config.ts index 7a7fbbe122..a1a5d34292 100644 --- a/packages/libs/kadena.js/vitest.config.ts +++ b/packages/libs/kadena.js/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 90, - functions: 90, - branches: 90, - statements: 90, - }, - }, - }), -); +export default defineConfig(baseConfig); From 2e93f3ace15711c033f8b33fba76b3b0e66d6c88 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 11:58:25 +0100 Subject: [PATCH 41/74] [test] Depend on shared vitest config for cryptography-utils --- .../libs/cryptography-utils/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/libs/cryptography-utils/vitest.config.ts b/packages/libs/cryptography-utils/vitest.config.ts index 7a7fbbe122..a1a5d34292 100644 --- a/packages/libs/cryptography-utils/vitest.config.ts +++ b/packages/libs/cryptography-utils/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 90, - functions: 90, - branches: 90, - statements: 90, - }, - }, - }), -); +export default defineConfig(baseConfig); From 50d62a6e9e52f38edffc28104238ea82713bb965 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:13:30 +0100 Subject: [PATCH 42/74] [test] Depend on shared vitest config for client-utils --- packages/libs/client-utils/vitest.config.ts | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/libs/client-utils/vitest.config.ts b/packages/libs/client-utils/vitest.config.ts index 12784dbad1..afbb16c2b3 100644 --- a/packages/libs/client-utils/vitest.config.ts +++ b/packages/libs/client-utils/vitest.config.ts @@ -1,9 +1,19 @@ -import { defineConfig } from 'vitest/config'; +import baseConfig from '@kadena-dev/shared-config/vitest.config'; +import { defineConfig, mergeConfig } from 'vitest/config'; -export default defineConfig({ - test: { - include: ['src/**/*.test.ts'], - exclude: ['src/**/*.int.test.ts'], - threads: false, // To prevent error in tests using jsdom environment: Module did not self-register: canvas.node - }, -}); +export default mergeConfig( + baseConfig, + defineConfig({ + test: { + exclude: ['src/**/*.int.test.ts'], + coverage: { + provider: 'v8', + lines: 70.22, + functions: 40, + branches: 75, + statements: 70.22, + thresholdAutoUpdate: true, + }, + }, + }), +); From 7b247bc85aa06a0b49a3bd22ffcab4051bda6f8b Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:17:52 +0100 Subject: [PATCH 43/74] [test] Depend on shared vitest config for client-utils --- packages/libs/client-utils/vitest.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/libs/client-utils/vitest.config.ts b/packages/libs/client-utils/vitest.config.ts index afbb16c2b3..58f1556bed 100644 --- a/packages/libs/client-utils/vitest.config.ts +++ b/packages/libs/client-utils/vitest.config.ts @@ -5,6 +5,7 @@ export default mergeConfig( baseConfig, defineConfig({ test: { + threads: false, // To prevent error in tests using jsdom environment: Module did not self-register: canvas.node exclude: ['src/**/*.int.test.ts'], coverage: { provider: 'v8', From ea96a8aa7ff1f2d894057a7ad7ad1d12ce157519 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:21:01 +0100 Subject: [PATCH 44/74] [test] Depend on shared vitest config for kadena/client and enable threshold updater. --- packages/libs/client/vitest.config.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/libs/client/vitest.config.ts b/packages/libs/client/vitest.config.ts index 12784dbad1..158bf19d09 100644 --- a/packages/libs/client/vitest.config.ts +++ b/packages/libs/client/vitest.config.ts @@ -1,9 +1,20 @@ -import { defineConfig } from 'vitest/config'; +import baseConfig from '@kadena-dev/shared-config/vitest.config'; +import { defineConfig, mergeConfig } from 'vitest/config'; -export default defineConfig({ - test: { - include: ['src/**/*.test.ts'], - exclude: ['src/**/*.int.test.ts'], - threads: false, // To prevent error in tests using jsdom environment: Module did not self-register: canvas.node - }, -}); +export default mergeConfig( + baseConfig, + defineConfig({ + test: { + threads: false, // To prevent error in tests using jsdom environment: Module did not self-register: canvas.node + exclude: ['src/**/*.int.test.ts'], + coverage: { + provider: 'v8', + lines: 92.61, + functions: 86.48, + branches: 95.45, + statements: 92.61, + thresholdAutoUpdate: true, + }, + }, + }), +); From 134129b0e68de4472625927e37daef939731907a Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:23:05 +0100 Subject: [PATCH 45/74] [test] Depend on shared vitest config for chainweb stream client and enable threshold updater. --- packages/libs/chainweb-stream-client/vitest.config.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/libs/chainweb-stream-client/vitest.config.ts b/packages/libs/chainweb-stream-client/vitest.config.ts index ac384d4467..bb3751e377 100644 --- a/packages/libs/chainweb-stream-client/vitest.config.ts +++ b/packages/libs/chainweb-stream-client/vitest.config.ts @@ -6,10 +6,12 @@ export default mergeConfig( defineConfig({ test: { coverage: { - lines: 90, - functions: 50, - branches: 70, - statements: 90, + provider: 'v8', + lines: 92.21, + functions: 60, + branches: 80, + statements: 92.21, + thresholdAutoUpdate: true, }, }, }), From 5ce427b1fe04bc840b3b8b6dbe2503fc57a0d95c Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:24:38 +0100 Subject: [PATCH 46/74] [test] Depend on shared vitest config for chainweb-node-client and enable threshold updater. --- packages/libs/chainweb-node-client/vitest.config.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/libs/chainweb-node-client/vitest.config.ts b/packages/libs/chainweb-node-client/vitest.config.ts index a116be2290..cca6268269 100644 --- a/packages/libs/chainweb-node-client/vitest.config.ts +++ b/packages/libs/chainweb-node-client/vitest.config.ts @@ -6,10 +6,12 @@ export default mergeConfig( defineConfig({ test: { coverage: { - lines: 90, - functions: 90, - branches: 80, - statements: 90, + provider: 'v8', + lines: 98.45, + functions: 100, + branches: 84.84, + statements: 98.45, + thresholdAutoUpdate: true, }, }, }), From 8f24dbe08fe5f476b81cda4c1effb37754418932 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:25:56 +0100 Subject: [PATCH 47/74] [test] Depend on shared vitest config for bootstrap lib and enable threshold updater. --- packages/libs/bootstrap-lib/vitest.config.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/libs/bootstrap-lib/vitest.config.ts b/packages/libs/bootstrap-lib/vitest.config.ts index 0920295023..a1a5d34292 100644 --- a/packages/libs/bootstrap-lib/vitest.config.ts +++ b/packages/libs/bootstrap-lib/vitest.config.ts @@ -1,16 +1,4 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig, mergeConfig } from 'vitest/config'; +import { defineConfig } from 'vitest/config'; -export default mergeConfig( - baseConfig, - defineConfig({ - test: { - coverage: { - lines: 100, - functions: 100, - branches: 100, - statements: 100, - }, - }, - }), -); +export default defineConfig(baseConfig); From e6b3040e6bd099a3d85dca104062e2b4316907fe Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:28:47 +0100 Subject: [PATCH 48/74] [test] Depend on shared vitest config for Tools.kadena.io and enable threshold updater. --- packages/apps/tools/vitest.config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/apps/tools/vitest.config.ts b/packages/apps/tools/vitest.config.ts index 6656d67be6..4721809e10 100644 --- a/packages/apps/tools/vitest.config.ts +++ b/packages/apps/tools/vitest.config.ts @@ -11,10 +11,12 @@ export default mergeConfig( environment: 'happy-dom', threads: false, coverage: { + provider: 'v8', lines: 70, functions: 40, - branches: 80, + branches: 70.51, statements: 70, + thresholdAutoUpdate: true, }, }, }), From 942ec22a0c3c90c44ca6d0d635274376b5f65e00 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:43:57 +0100 Subject: [PATCH 49/74] [test] update coverage requirements for tools --- packages/apps/tools/vitest.config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/apps/tools/vitest.config.ts b/packages/apps/tools/vitest.config.ts index 4721809e10..c2f471f4db 100644 --- a/packages/apps/tools/vitest.config.ts +++ b/packages/apps/tools/vitest.config.ts @@ -12,10 +12,10 @@ export default mergeConfig( threads: false, coverage: { provider: 'v8', - lines: 70, - functions: 40, + lines: 73.76, + functions: 40.27, branches: 70.51, - statements: 70, + statements: 73.76, thresholdAutoUpdate: true, }, }, From 93af63802c49aa3e73930eecc7bbfd1a7e14cd6b Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:44:09 +0100 Subject: [PATCH 50/74] [test] update coverage requirements for react-ui --- packages/libs/react-ui/vitest.config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/libs/react-ui/vitest.config.ts b/packages/libs/react-ui/vitest.config.ts index b3c05287b7..8b7426b6f1 100644 --- a/packages/libs/react-ui/vitest.config.ts +++ b/packages/libs/react-ui/vitest.config.ts @@ -11,10 +11,10 @@ export default mergeConfig( environment: 'happy-dom', coverage: { provider: 'v8', - lines: 50, - functions: 30, - branches: 80, - statements: 50, + lines: 55.24, + functions: 32.72, + branches: 88.38, + statements: 55.24, thresholdAutoUpdate: true, }, }, From 2c52897c84d222b882facca218bd00346fc95a3b Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:44:26 +0100 Subject: [PATCH 51/74] [test] remove thresholdAutoUpdate from shared config --- packages/tools/shared-config/vitest.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/tools/shared-config/vitest.config.js b/packages/tools/shared-config/vitest.config.js index 9b9a391164..b7e89f5bbe 100644 --- a/packages/tools/shared-config/vitest.config.js +++ b/packages/tools/shared-config/vitest.config.js @@ -13,7 +13,6 @@ module.exports = defineConfig({ functions: 90, branches: 90, statements: 90, - thresholdAutoUpdate: false, // Should be enabled? Too precise though, annoying in CI if missed by 0.01% }, }, }); From 4a99b8f391e491a9c197a8c57d8892c417da5b45 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 12:48:46 +0100 Subject: [PATCH 52/74] [test] add test:watch script to all packages that use vitest --- packages/apps/tools/package.json | 3 ++- packages/libs/bootstrap-lib/package.json | 3 ++- packages/libs/chainweb-node-client/package.json | 3 ++- packages/libs/chainweb-stream-client/package.json | 3 ++- packages/libs/chainwebjs/package.json | 3 ++- packages/libs/client-utils/package.json | 1 + packages/libs/client/package.json | 1 + packages/libs/cryptography-utils/package.json | 3 ++- packages/libs/kadena.js/package.json | 3 ++- packages/libs/pactjs-generator/package.json | 1 + packages/libs/pactjs/package.json | 3 ++- packages/libs/react-ui/package.json | 3 ++- packages/tools/kda-cli/package.json | 3 ++- packages/tools/pactjs-cli/package.json | 3 ++- 14 files changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/apps/tools/package.json b/packages/apps/tools/package.json index 4d4c39421f..47cb4d1dca 100644 --- a/packages/apps/tools/package.json +++ b/packages/apps/tools/package.json @@ -17,7 +17,8 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .ts,.tsx", "start": "next start", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@hookform/resolvers": "~3.1.1", diff --git a/packages/libs/bootstrap-lib/package.json b/packages/libs/bootstrap-lib/package.json index f80a6fede2..867652e379 100644 --- a/packages/libs/bootstrap-lib/package.json +++ b/packages/libs/bootstrap-lib/package.json @@ -40,7 +40,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@kadena/cryptography-utils": "workspace:*", diff --git a/packages/libs/chainweb-node-client/package.json b/packages/libs/chainweb-node-client/package.json index 30234d7366..f4c9253ac0 100644 --- a/packages/libs/chainweb-node-client/package.json +++ b/packages/libs/chainweb-node-client/package.json @@ -41,7 +41,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@kadena/cryptography-utils": "workspace:*", diff --git a/packages/libs/chainweb-stream-client/package.json b/packages/libs/chainweb-stream-client/package.json index 5d5f7227f8..854c25e1d6 100644 --- a/packages/libs/chainweb-stream-client/package.json +++ b/packages/libs/chainweb-stream-client/package.json @@ -33,7 +33,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "eventemitter2": "~6.4.9", diff --git a/packages/libs/chainwebjs/package.json b/packages/libs/chainwebjs/package.json index 00770bef8d..59a2834925 100644 --- a/packages/libs/chainwebjs/package.json +++ b/packages/libs/chainwebjs/package.json @@ -57,7 +57,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "base64url": "^3.0.1", diff --git a/packages/libs/client-utils/package.json b/packages/libs/client-utils/package.json index ec1635b15d..54382a74a6 100644 --- a/packages/libs/client-utils/package.json +++ b/packages/libs/client-utils/package.json @@ -53,6 +53,7 @@ "lint:src": "eslint src --ext .js,.ts", "pactjs:generate:contract": "pactjs contract-generate --contract coin --api https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact", "test": "vitest run", + "test:watch": "vitest", "test:integration": "vitest run -c ./vitest.integration.config.ts" }, "dependencies": { diff --git a/packages/libs/client/package.json b/packages/libs/client/package.json index e58f13be0a..8c68a2445f 100644 --- a/packages/libs/client/package.json +++ b/packages/libs/client/package.json @@ -39,6 +39,7 @@ "pactjs:retrieve:contract": "pactjs retrieve-contract --out contracts/coin.contract.pact --module coin", "start": "ts-node --transpile-only src/index.ts", "test": "vitest run", + "test:watch": "vitest", "test:integration": "vitest run -c ./vitest.integration.config.ts" }, "dependencies": { diff --git a/packages/libs/cryptography-utils/package.json b/packages/libs/cryptography-utils/package.json index 83a23d2c25..1e372b4f0e 100644 --- a/packages/libs/cryptography-utils/package.json +++ b/packages/libs/cryptography-utils/package.json @@ -39,7 +39,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "blakejs": "^1.2.1", diff --git a/packages/libs/kadena.js/package.json b/packages/libs/kadena.js/package.json index 58132c0eae..e93b904afe 100644 --- a/packages/libs/kadena.js/package.json +++ b/packages/libs/kadena.js/package.json @@ -54,7 +54,8 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", "serve-coverage": "python -m SimpleHTTPServer", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@kadena/chainweb-node-client": "workspace:*", diff --git a/packages/libs/pactjs-generator/package.json b/packages/libs/pactjs-generator/package.json index 4103dc2882..f7a5bdd44c 100644 --- a/packages/libs/pactjs-generator/package.json +++ b/packages/libs/pactjs-generator/package.json @@ -35,6 +35,7 @@ "lint:src": "eslint src --ext .js,.ts", "start": "ts-node --transpile-only src/index.ts", "test": "vitest run", + "test:watch": "vitest", "util:lexer-grammar:watch": "concurrently --kill-others npm:build:*:watch # npm:test:grammar:watch" }, "dependencies": { diff --git a/packages/libs/pactjs/package.json b/packages/libs/pactjs/package.json index 8559047d0e..d5b40b4bc5 100644 --- a/packages/libs/pactjs/package.json +++ b/packages/libs/pactjs/package.json @@ -39,7 +39,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "bignumber.js": "^9.1.2" diff --git a/packages/libs/react-ui/package.json b/packages/libs/react-ui/package.json index 829e5babf7..e55735dd90 100644 --- a/packages/libs/react-ui/package.json +++ b/packages/libs/react-ui/package.json @@ -39,7 +39,8 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts,.tsx", "storybook": "storybook dev -p 6006", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@kadena/fonts": "~0.0.1", diff --git a/packages/tools/kda-cli/package.json b/packages/tools/kda-cli/package.json index 06471634b5..d146a36daf 100644 --- a/packages/tools/kda-cli/package.json +++ b/packages/tools/kda-cli/package.json @@ -32,7 +32,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts,.tsx", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@inkjs/ui": "^1.0.0", diff --git a/packages/tools/pactjs-cli/package.json b/packages/tools/pactjs-cli/package.json index 8ca5a79161..7898229e65 100644 --- a/packages/tools/pactjs-cli/package.json +++ b/packages/tools/pactjs-cli/package.json @@ -31,7 +31,8 @@ "lint:fmt": "prettier . --cache --check", "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", - "test": "vitest run" + "test": "vitest run", + "test:watch": "vitest" }, "dependencies": { "@kadena/pactjs-generator": "workspace:*", From 6de44fd95a9c523f1462c0fc6c568ae37a266969 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 13:44:22 +0100 Subject: [PATCH 53/74] [test] Ignore coverage folder while running prettier --- packages/apps/tools/.prettierignore | 1 + packages/libs/bootstrap-lib/.prettierignore | 1 + packages/libs/chainweb-node-client/.prettierignore | 1 + packages/libs/chainweb-stream-client/.prettierignore | 1 + packages/libs/chainwebjs/.prettierignore | 1 + packages/libs/client-utils/.prettierignore | 1 + packages/libs/client/.prettierignore | 1 + packages/libs/cryptography-utils/.prettierignore | 1 + packages/libs/pactjs-generator/.prettierignore | 1 + packages/libs/pactjs/.prettierignore | 1 + packages/libs/react-ui/.prettierignore | 1 + packages/tools/kda-cli/.prettierignore | 1 + packages/tools/pactjs-cli/.prettierignore | 1 + 13 files changed, 13 insertions(+) diff --git a/packages/apps/tools/.prettierignore b/packages/apps/tools/.prettierignore index 406fa0c4bc..0be1ffaae7 100644 --- a/packages/apps/tools/.prettierignore +++ b/packages/apps/tools/.prettierignore @@ -1,3 +1,4 @@ .next **/*.md +coverage tsdoc-metadata.json diff --git a/packages/libs/bootstrap-lib/.prettierignore b/packages/libs/bootstrap-lib/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/bootstrap-lib/.prettierignore +++ b/packages/libs/bootstrap-lib/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/chainweb-node-client/.prettierignore b/packages/libs/chainweb-node-client/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/chainweb-node-client/.prettierignore +++ b/packages/libs/chainweb-node-client/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/chainweb-stream-client/.prettierignore b/packages/libs/chainweb-stream-client/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/chainweb-stream-client/.prettierignore +++ b/packages/libs/chainweb-stream-client/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/chainwebjs/.prettierignore b/packages/libs/chainwebjs/.prettierignore index c009d92878..d8025d03ca 100644 --- a/packages/libs/chainwebjs/.prettierignore +++ b/packages/libs/chainwebjs/.prettierignore @@ -3,4 +3,5 @@ etc lib temp **/*.md +coverage tsdoc-metadata.json diff --git a/packages/libs/client-utils/.prettierignore b/packages/libs/client-utils/.prettierignore index c009d92878..d8025d03ca 100644 --- a/packages/libs/client-utils/.prettierignore +++ b/packages/libs/client-utils/.prettierignore @@ -3,4 +3,5 @@ etc lib temp **/*.md +coverage tsdoc-metadata.json diff --git a/packages/libs/client/.prettierignore b/packages/libs/client/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/client/.prettierignore +++ b/packages/libs/client/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/cryptography-utils/.prettierignore b/packages/libs/cryptography-utils/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/cryptography-utils/.prettierignore +++ b/packages/libs/cryptography-utils/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/pactjs-generator/.prettierignore b/packages/libs/pactjs-generator/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/pactjs-generator/.prettierignore +++ b/packages/libs/pactjs-generator/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/pactjs/.prettierignore b/packages/libs/pactjs/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/libs/pactjs/.prettierignore +++ b/packages/libs/pactjs/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/libs/react-ui/.prettierignore b/packages/libs/react-ui/.prettierignore index d8fec4ca1c..1a6fbb8cc6 100644 --- a/packages/libs/react-ui/.prettierignore +++ b/packages/libs/react-ui/.prettierignore @@ -2,4 +2,5 @@ dist etc lib **/*.md +coverage tsdoc-metadata.json diff --git a/packages/tools/kda-cli/.prettierignore b/packages/tools/kda-cli/.prettierignore index 9d070da86a..10f168b853 100644 --- a/packages/tools/kda-cli/.prettierignore +++ b/packages/tools/kda-cli/.prettierignore @@ -3,5 +3,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json diff --git a/packages/tools/pactjs-cli/.prettierignore b/packages/tools/pactjs-cli/.prettierignore index c009d92878..1c1bf93482 100644 --- a/packages/tools/pactjs-cli/.prettierignore +++ b/packages/tools/pactjs-cli/.prettierignore @@ -2,5 +2,6 @@ dist etc lib temp +coverage **/*.md tsdoc-metadata.json From 7c8888df31136d2e7d62883b16198d777d9ff883 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 13:44:33 +0100 Subject: [PATCH 54/74] [test] formatting of package.json --- packages/libs/client-utils/package.json | 4 ++-- packages/libs/client/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/libs/client-utils/package.json b/packages/libs/client-utils/package.json index 54382a74a6..ea2608bb7e 100644 --- a/packages/libs/client-utils/package.json +++ b/packages/libs/client-utils/package.json @@ -53,8 +53,8 @@ "lint:src": "eslint src --ext .js,.ts", "pactjs:generate:contract": "pactjs contract-generate --contract coin --api https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact", "test": "vitest run", - "test:watch": "vitest", - "test:integration": "vitest run -c ./vitest.integration.config.ts" + "test:integration": "vitest run -c ./vitest.integration.config.ts", + "test:watch": "vitest" }, "dependencies": { "@kadena/chainweb-node-client": "workspace:*", diff --git a/packages/libs/client/package.json b/packages/libs/client/package.json index 8c68a2445f..755ac65054 100644 --- a/packages/libs/client/package.json +++ b/packages/libs/client/package.json @@ -39,8 +39,8 @@ "pactjs:retrieve:contract": "pactjs retrieve-contract --out contracts/coin.contract.pact --module coin", "start": "ts-node --transpile-only src/index.ts", "test": "vitest run", - "test:watch": "vitest", - "test:integration": "vitest run -c ./vitest.integration.config.ts" + "test:integration": "vitest run -c ./vitest.integration.config.ts", + "test:watch": "vitest" }, "dependencies": { "@kadena/chainweb-node-client": "workspace:*", From e777340f3593216c7ce0f0a39db76d2dae528391 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 15:34:35 +0100 Subject: [PATCH 55/74] [test] exclude tests for coverage calculation --- packages/libs/chainwebjs/vitest.config.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/libs/chainwebjs/vitest.config.ts b/packages/libs/chainwebjs/vitest.config.ts index a1a5d34292..de36fffcb1 100644 --- a/packages/libs/chainwebjs/vitest.config.ts +++ b/packages/libs/chainwebjs/vitest.config.ts @@ -1,4 +1,14 @@ import baseConfig from '@kadena-dev/shared-config/vitest.config'; -import { defineConfig } from 'vitest/config'; +import { defineConfig, mergeConfig } from 'vitest/config'; -export default defineConfig(baseConfig); +export default mergeConfig( + baseConfig, + defineConfig({ + test: { + coverage: { + provider: 'v8', + exclude: ['src/tests/**'], // This packages uses a non standard location for tests, explicitly ignoring them for code coverage + }, + }, + }), +); From 01a66f7a92adfeed311baca6740d0ab83e8a7f1a Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 16:27:56 +0100 Subject: [PATCH 56/74] [test] disable turbo cache temporarily. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a0d55d297a..d0503776ef 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "Kadena JS monorepo", "license": "ISC", "scripts": { - "build": "turbo run build", + "build": "turbo run build --force", "format": "pnpm run /^format:.*/", "format:md": "remark *.md docs/*.md -o --use @kadena-dev/markdown", "format:pkgs": "tsx packages/tools/scripts/generate-packages-json.ts", @@ -15,7 +15,7 @@ "lint": "syncpack list-mismatches && prettier . \"!packages\" --cache --check", "publish": "changeset publish", "select": "git checkout .changeset/config.json && tsx --no-warnings ./packages/tools/scripts/publish-set.ts", - "test": "turbo run test", + "test": "turbo run test --force", "test:e2e": "turbo run test:e2e", "test:integration": "turbo run test:integration", "version": "changeset version && pnpm run format:pkgs" From baff90e9377f3048a989330962da630c4a0f4ef1 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Fri, 3 Nov 2023 16:55:14 +0100 Subject: [PATCH 57/74] [test] increase coverage for react-ui --- packages/libs/react-ui/vitest.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/libs/react-ui/vitest.config.ts b/packages/libs/react-ui/vitest.config.ts index 8b7426b6f1..f9718284e1 100644 --- a/packages/libs/react-ui/vitest.config.ts +++ b/packages/libs/react-ui/vitest.config.ts @@ -11,10 +11,10 @@ export default mergeConfig( environment: 'happy-dom', coverage: { provider: 'v8', - lines: 55.24, + lines: 55.58, functions: 32.72, branches: 88.38, - statements: 55.24, + statements: 55.58, thresholdAutoUpdate: true, }, }, From 9eda18f7bcee1432fc371df55aa548a31f11361f Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Mon, 6 Nov 2023 10:15:19 +0100 Subject: [PATCH 58/74] [test] disable caching to see if the coverage difference is caused by remote caching --- .github/workflows/ci.yml | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e098b85d53..67b47aee2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,9 @@ jobs: name: Ubuntu/Node.js v18 runs-on: ubuntu-latest - env: - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} +# env: +# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} +# TURBO_TEAM: ${{ secrets.TURBO_TEAM }} steps: - uses: actions/checkout@v4 @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 18 - cache: 'pnpm' +# cache: 'pnpm' - name: Install dependencies run: pnpm install diff --git a/package.json b/package.json index d0503776ef..393fb882e1 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "lint": "syncpack list-mismatches && prettier . \"!packages\" --cache --check", "publish": "changeset publish", "select": "git checkout .changeset/config.json && tsx --no-warnings ./packages/tools/scripts/publish-set.ts", - "test": "turbo run test --force", + "test": "turbo run test", "test:e2e": "turbo run test:e2e", "test:integration": "turbo run test:integration", "version": "changeset version && pnpm run format:pkgs" From 705b8327ee3cb63690bc6355416805da2992e76f Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Mon, 6 Nov 2023 10:33:07 +0100 Subject: [PATCH 59/74] [test] Formatting --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67b47aee2d..cd83bab469 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,9 @@ jobs: name: Ubuntu/Node.js v18 runs-on: ubuntu-latest -# env: -# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} -# TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + # env: + # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + # TURBO_TEAM: ${{ secrets.TURBO_TEAM }} steps: - uses: actions/checkout@v4 @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 18 -# cache: 'pnpm' + # cache: 'pnpm' - name: Install dependencies run: pnpm install From 3e5bc73d8e98e196d188948f3a0b399fbf135c1a Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Mon, 6 Nov 2023 11:04:37 +0100 Subject: [PATCH 60/74] [test] There appear to be subtle difference in code coverage in CI as well as locally. Removing thresholdAutoUpdate for react-ui, for now. --- .github/workflows/ci.yml | 8 ++++---- packages/libs/react-ui/vitest.config.ts | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd83bab469..e098b85d53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,9 @@ jobs: name: Ubuntu/Node.js v18 runs-on: ubuntu-latest - # env: - # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - # TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} steps: - uses: actions/checkout@v4 @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 18 - # cache: 'pnpm' + cache: 'pnpm' - name: Install dependencies run: pnpm install diff --git a/packages/libs/react-ui/vitest.config.ts b/packages/libs/react-ui/vitest.config.ts index f9718284e1..1d1b0fde09 100644 --- a/packages/libs/react-ui/vitest.config.ts +++ b/packages/libs/react-ui/vitest.config.ts @@ -11,11 +11,10 @@ export default mergeConfig( environment: 'happy-dom', coverage: { provider: 'v8', - lines: 55.58, - functions: 32.72, - branches: 88.38, - statements: 55.58, - thresholdAutoUpdate: true, + lines: 55, + functions: 32, + branches: 88, + statements: 55, }, }, }), From 11a0d97c452c946cf08bd817565628bf7a85b0fb Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Tue, 7 Nov 2023 10:01:08 +0100 Subject: [PATCH 61/74] [Chore] Formatting --- packages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.json b/packages.json index f45888b097..602ceeb862 100644 --- a/packages.json +++ b/packages.json @@ -179,4 +179,4 @@ "private": true, "path": "packages/libs/kadena.js" } -] \ No newline at end of file +] From 472b8010b4619130ee840beaaa6a18e4a916e478 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Tue, 7 Nov 2023 10:14:31 +0100 Subject: [PATCH 62/74] [Chore] empty changeset --- .changeset/proud-experts-argue.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/proud-experts-argue.md diff --git a/.changeset/proud-experts-argue.md b/.changeset/proud-experts-argue.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/proud-experts-argue.md @@ -0,0 +1,2 @@ +--- +--- From af020b0c153f057c919bf2e51894dc8223b18b6e Mon Sep 17 00:00:00 2001 From: Jesse van Muijden Date: Tue, 7 Nov 2023 10:14:22 -0400 Subject: [PATCH 63/74] chore(docs): fix errors in election dapp tutorial --- .changeset/tall-dancers-pay.md | 5 +++++ .../build/guides/election-dapp-tutorial/04-namespaces.md | 4 ++-- .../pages/build/guides/election-dapp-tutorial/05-keysets.md | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/tall-dancers-pay.md diff --git a/.changeset/tall-dancers-pay.md b/.changeset/tall-dancers-pay.md new file mode 100644 index 0000000000..254dffea46 --- /dev/null +++ b/.changeset/tall-dancers-pay.md @@ -0,0 +1,5 @@ +--- +'@kadena/docs': patch +--- + +fix small errors in election dapp tutorial diff --git a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/04-namespaces.md b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/04-namespaces.md index ddde49dbc3..bcc6d37a87 100644 --- a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/04-namespaces.md +++ b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/04-namespaces.md @@ -14,8 +14,8 @@ After you have completed this entire tutorial, you may want to deploy your elect smart contract to Testnet. Many others like you would perhaps like to do the same. If everyone would deploy Pact modules with the same name to the same network, however, it would become impossible to distinguish your Pact module from all the others. Therefore, -it is not allowed to -deploy a Pact module with a name that already exists on the chain you are deploying to +it is not allowed to deploy a Pact module with a name that is already used by someone +else on the chain you are deploying to and your deployment transaction will fail with an error if you try. Fortunately, Kadena offers a solution to this problem by introducing namespaces. You can create your own unique namespace on the blockchain and you get to decide who can update the diff --git a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/05-keysets.md b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/05-keysets.md index bfdf23761a..2b8cefc26a 100644 --- a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/05-keysets.md +++ b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/05-keysets.md @@ -189,7 +189,7 @@ file and run it. ```pact (env-data - { 'admin-key : + { 'admin-keyset : { 'keys : [ 'other-public-key ] , 'pred : 'keys-all } @@ -268,6 +268,10 @@ the statement `(namespace ns-name)`. Finally, you need to add a signature for th to succeed. ```pact +(begin-tx) + (load "root/ns.pact") +(commit-tx) + (env-sigs [{ 'key : "368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca" , 'caps : [] From f4b866ed5ab4a5ede8ddb7b966fa5c8aa54af6d0 Mon Sep 17 00:00:00 2001 From: Jesse van Muijden Date: Tue, 7 Nov 2023 18:12:40 -0400 Subject: [PATCH 64/74] feat(docs): use principal account for gas station --- .../election-dapp-tutorial/09-gas-station.md | 79 +++++++++++++++---- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md index bc22c8a921..603c7f2080 100644 --- a/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md +++ b/packages/apps/docs/src/pages/build/guides/election-dapp-tutorial/09-gas-station.md @@ -47,6 +47,7 @@ that can pay the gas fee for every voting transaction, allowing all citizens to ## Recommended reading * [The First Crypto Gas Station is Now on Kadena’s Blockchain](/blogchain/2020/the-first-crypto-gas-station-is-now-on-kadenas-blockchain-2020-08-06) + * [Introducing Kadena Account Protocols (KIP-0012)](/blogchain/2021/introducing-kadena-account-protocols-kip-0012-2021-09-27) ## Get the code @@ -296,7 +297,8 @@ function change the line `.addSigner(accountKey(account))` into the following. This scopes the signature of the account that votes to the `GAS_PAYER` capability. The voter account name and zero (unlimited) limits for the amount of gas and the gas price are passed as arguments. Also, change the -`senderAccount` in the transaction's metadata to `'election-gas-station'`. +`senderAccount` in the transaction's metadata to `'election-gas-station'`, to indicate that the election +gas station account will pay the gas fee of the transaction instead of the voter account. Return to the election website and try to vote again with the voter account. The transaction will still fail with the error: `Failure: Tx Failed: Insufficient funds`. Apparently, the gas station does not work as it is @@ -304,14 +306,40 @@ supposed to, yet. The reason is that the gas station module attempts to pay for but this account does not exist. It has to be created first. It also needs to have a positive KDA balance. Otherwise, the transaction will still fail due to insufficient funds in the gas station account. -## Create and fund the gas station account +## Create the gas station account -You can use the `create-account` function of the `coin` module to create the -`election-gas-station` account in a function called `init` in the `election-gas-station` module, as follows. +Actually, `election-gas-station` is not the most ideal name for the gas station account. As explained in the +recommended reading, it is more secure to use a principal account name. Whereas your admin and voter accounts +are guarded by a keyset, the gas station account will be guarded by the `ALLOW_GAS` capability. The gas station +account is thus an example of a capability guarded account. The built-in Pact function `create-pincipal` can +automatically create an account name based on a capability guard for you if you pass the capability guard as +the first and only argument into it. The resulting account name will be prefixed with the `c:` of `capability`. +Define the gas station account name as a constant at the bottom of the `election-gas-station` module in the +`./pact/election-gas-station.pact` file. ```pact -(defconst GAS_STATION_ACCOUNT "election-gas-station") +(defconst GAS_STATION_ACCOUNT (create-principal (create-gas-payer-guard))) +``` + +Update the `./pact/election-gas-station.repl` file as follows to print out the capability guarded gas station +account name when you run the file. + +```pact +(load "setup.repl") +(begin-tx "Load election gas station module") + (load "root/gas-payer-v1.pact") + (load "election-gas-station.pact") + [GAS_STATION_ACCOUNT] +(commit-tx) +``` + +In the `./pact/election-gas-station.pact` file, you can use the `create-account` function of the +`coin` module to create the gas station account in a function called `init` in the `election-gas-station` +module, as follows. The first argument of the function is the account name you just defined and the second +argument is the guard for the account. + +```pact (defun init () (coin.create-account GAS_STATION_ACCOUNT (create-gas-payer-guard)) ) @@ -344,11 +372,12 @@ in the `./snippets` folder of your project. Replace `k:account` with your admin npm run deploy-gas-station:devnet -- k:account upgrade init ``` -Verify that the `election-gas-station` account now exists with a 0 KDA balance on Devnet by running the -following script. +Verify that the gas station account now exists with a 0 KDA balance on Devnet by running the +following script. Replace `c:account` with the actual gas station account name that you printed by running +`./pact/election-gas-station.repl`. ```bash -npm run coin-details:devnet -- election-gas-station +npm run coin-details:devnet -- c:account ``` If everything went well, you should see output similar to this. @@ -356,16 +385,28 @@ If everything went well, you should see output similar to this. ```bash { guard: { - args: [], - fun: 'n_fd020525c953aa002f20fb81a920982b175cdf1a.election-gas-station.gas-payer-guard' + cgPactId: null, + cgArgs: [], + cgName: 'n_fd020525c953aa002f20fb81a920982b175cdf1a.election-gas-station.ALLOW_GAS' }, balance: 0, - account: 'election-gas-station' + account: 'c:Jjn2uym_xGD32ojhWdPjB5mgIbDwgXRRvkWmFl5n4gg' } ``` +The account details show the capability guard that guards the gas station account and was used to generate +the `c:` account name. Notice how the `ALLOW_GAS` capability is prefixed with the module name as well as your +principal namespace. Since the principal namespace is based on your admin keyset, and the principal account +of the gas station is based on a capability including that principal namespace, it can be concluded that the +gas station account name you created is unique to your admin account. This makes it impossible for someone else +with a different keyset to squat your gas station account on another chain. That is how principal accounts in +principal namespaces provide better security than vanity account names in the `free` namespace. + +## Fund the gas station account + Execute the `./transfer.ts` snippet by running the following command to transfer 1 KDA from your admin -account to the gas station account. Replace `k:account` with your admin account. The transaction +account to the gas station account. Replace `k:account` with your admin account and replace `c:account` +with the actual account name of your gas station. The transaction inside this file is similar to `./transfer-create.ts`, except that it does not use the special `sender00` account, but your own election admin account to transfer KDA from. Therefore, the transaction needs to be signed with Chainweaver instead of a private key. Also, the `transfer` function of the @@ -373,14 +414,14 @@ needs to be signed with Chainweaver instead of a private key. Also, the `transfe blockchain and will not create the account if it does not exist like `transfer-create` would. ```bash -npm run transfer:devnet -- k:account election-gas-station 1 +npm run transfer:devnet -- k:account c:account 1 ``` -Verify that the `election-gas-station` account now has a 1 KDA balance on Devnet by running the -following script again. +Verify that the election gasstation account now has a 1 KDA balance on Devnet by running the +following script again. Replace `c:account` with the actual account name of your gas station. ```bash -npm run coin-details:devnet -- election-gas-station +npm run coin-details:devnet -- c:account ``` Now, everything should be set to allow voters to vote for free, because the `election-gas-station` @@ -388,7 +429,11 @@ account can pay the gas fee charged for the voting transaction. ## Vote again -Return to the election website, set the account to your voter account and vote for one of the +Open the file `frontend/src/repositories/vote/DevnetVoteRepository.ts` and in the `vote` +function change the value of `senderAccount` from `election-gas-station` to the `c:account` of the gas +station that you created. + +Vist the election website in your browser, set the account to your voter account and vote for one of the candidates in the list. Unfortunately, the transaction still fails but this time with a different error: `Keyset failure`. This error occurs because the signature is not scoped to the `ACCOUNT-OWNER` capability used in `./pact/election.repl`. When you created this capability From bc3c40ab9be2b11adf998529410c83b89c8ea0e4 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 12:51:21 +0100 Subject: [PATCH 65/74] [fix] make sure workflow is triggered on push to main as well --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8e22c5a42..b86ff79371 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,9 @@ name: Release on: workflow_dispatch: + push: + branches: + - main concurrency: ${{ github.workflow }}-${{ github.ref }} From 6612ef9e5b5b2632d72a5390db90d0af849aefb5 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 13:02:30 +0100 Subject: [PATCH 66/74] [chore] add workflow to support manual publishing. --- .github/workflows/manual-release.yml | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/manual-release.yml diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml new file mode 100644 index 0000000000..acc4d54657 --- /dev/null +++ b/.github/workflows/manual-release.yml @@ -0,0 +1,60 @@ +name: Release + +# Taken from: https://github.com/changesets/action#with-publishing + +on: + workflow_dispatch: + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Changelog PR or Release + if: ${{ github.repository_owner == 'kadena-community' }} + runs-on: ubuntu-latest + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + + steps: + - uses: actions/checkout@v4 + with: + show-progress: false + + - name: Setup Node.js 18 + uses: actions/setup-node@v3 + + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Lint monorepo root + run: pnpm run lint + + - name: Build, lint, test all packages + run: pnpm turbo lint build test + + - name: Create Release PR or Publish + id: changesets + uses: changesets/action@v1 + with: + # Note: pnpm install after versioning is necessary to refresh lockfile + publish: pnpm run publish + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_ACTION_GITHUB_TOKEN }} + # Needs r+w access for packages of both orgs to publish to npm + NPM_TOKEN: ${{ secrets.RELEASE_ACTION_NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true + + - name: Output (debug) + if: steps.changesets.outputs.published == 'true' + # Do something more interesting when a publish happens. + run: echo ${{ steps.changesets.outputs.publishedPackages }} From e72db068837514dcabcb6a90617fbb8058639cb3 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 13:12:57 +0100 Subject: [PATCH 67/74] [chore] Only run workflow on main branch --- .github/workflows/manual-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index acc4d54657..57d3452c74 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -10,7 +10,7 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: name: Changelog PR or Release - if: ${{ github.repository_owner == 'kadena-community' }} + if: ${{ github.repository_owner == 'kadena-community' && github.ref == 'refs/heads/main'}} runs-on: ubuntu-latest env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} From d605d06b04d224640ac5018285ce996ce6508dca Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 13:13:40 +0100 Subject: [PATCH 68/74] [chore] Rename step to better reflect reality. --- .github/workflows/manual-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index 57d3452c74..a163ab1306 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -42,7 +42,7 @@ jobs: - name: Build, lint, test all packages run: pnpm turbo lint build test - - name: Create Release PR or Publish + - name: Manually publish packages id: changesets uses: changesets/action@v1 with: From e093b17758e81846c2d513460a35a974dc8b61ec Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 13:14:27 +0100 Subject: [PATCH 69/74] [chore] Rename step to better reflect reality. --- .github/workflows/manual-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index a163ab1306..9f416818ed 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -42,7 +42,7 @@ jobs: - name: Build, lint, test all packages run: pnpm turbo lint build test - - name: Manually publish packages + - name: Publish unpublished packages id: changesets uses: changesets/action@v1 with: From 53dfe6ebf02b4448e63296dc258a9742b968ef1b Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 13:17:25 +0100 Subject: [PATCH 70/74] [chore] Rename step to better reflect reality. --- .github/workflows/manual-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index 9f416818ed..3a677db223 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -10,7 +10,9 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: name: Changelog PR or Release - if: ${{ github.repository_owner == 'kadena-community' && github.ref == 'refs/heads/main'}} + if: + ${{ github.repository_owner == 'kadena-community' && github.ref == + 'refs/heads/main'}} runs-on: ubuntu-latest env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} From 86797f73bd9f5fe6d633b7881631e7a205bc07f0 Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Wed, 8 Nov 2023 13:26:47 +0100 Subject: [PATCH 71/74] chore(monorepo): change workflow name --- .github/workflows/manual-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index 3a677db223..aff06e1746 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -9,7 +9,7 @@ concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: release: - name: Changelog PR or Release + name: Publish unpublished packages if: ${{ github.repository_owner == 'kadena-community' && github.ref == 'refs/heads/main'}} From 372788b81c4110d94447a1bd076bf64bfb352fe9 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Wed, 8 Nov 2023 13:27:48 +0100 Subject: [PATCH 72/74] [chore] Rename workflow --- .github/workflows/manual-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index aff06e1746..bc76384a8b 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -1,4 +1,4 @@ -name: Release +name: Manual Release # Taken from: https://github.com/changesets/action#with-publishing From ec8e0b3e499e75ab70ba7c47ef188d6c8475dc31 Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Wed, 8 Nov 2023 13:38:16 +0100 Subject: [PATCH 73/74] chore(monorepo): use custom command instead of changeset-action --- .github/workflows/manual-release.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index bc76384a8b..d072c4623f 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -44,12 +44,9 @@ jobs: - name: Build, lint, test all packages run: pnpm turbo lint build test - - name: Publish unpublished packages + - name: Build, lint, test all packages id: changesets - uses: changesets/action@v1 - with: - # Note: pnpm install after versioning is necessary to refresh lockfile - publish: pnpm run publish + run: pnpm publish env: GITHUB_TOKEN: ${{ secrets.RELEASE_ACTION_GITHUB_TOKEN }} # Needs r+w access for packages of both orgs to publish to npm From 20bd7b050a3c1e16a6a193adeddb5b7ae9a25920 Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Wed, 8 Nov 2023 13:41:13 +0100 Subject: [PATCH 74/74] chore(monorepo): use pnpm RUN publish, as pnpm publish is a native command of pnpm --- .github/workflows/manual-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manual-release.yml b/.github/workflows/manual-release.yml index d072c4623f..b4ae1668fe 100644 --- a/.github/workflows/manual-release.yml +++ b/.github/workflows/manual-release.yml @@ -46,7 +46,7 @@ jobs: - name: Build, lint, test all packages id: changesets - run: pnpm publish + run: pnpm run publish env: GITHUB_TOKEN: ${{ secrets.RELEASE_ACTION_GITHUB_TOKEN }} # Needs r+w access for packages of both orgs to publish to npm