From 3f3753382e0c18ad16e410af2ff3504c2208370d Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 9 Jan 2025 12:03:53 -0600 Subject: [PATCH 1/2] fix cors and requestData errors (#59) * fix cors and requestData errors * add support for static exports --- frontend/next.config.js | 30 ++++++++++++++++++++++++++++++ frontend/next.config.mjs | 14 -------------- frontend/package.json | 2 +- frontend/src/app/page.tsx | 7 +++---- 4 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 frontend/next.config.js diff --git a/frontend/next.config.js b/frontend/next.config.js new file mode 100644 index 0000000..ba002c4 --- /dev/null +++ b/frontend/next.config.js @@ -0,0 +1,30 @@ + + /** @type {import('next').NextConfig} */ +const nextConfig = { + output: 'export', + async headers() { + return [ + { + // matching all API routes + source: "/api/v1/:path*", + headers: [ + { key: "Access-Control-Allow-Credentials", value: "true" }, + { key: "Access-Control-Allow-Origin", value: "*" }, + { key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" }, + { key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }, + ] + } + ] + }, + async rewrites() { + return [ + { + source: '/api/v1/:path*', // Match all routes starting with /api/v1/ + destination: 'http://localhost:8080/api/v1/:path*', // Proxy to backend server + }, + ]; + }, +}; + +module.exports = nextConfig; + \ No newline at end of file diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 7aad706..e69de29 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -1,14 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = - { async rewrites() { - return [ - { - source: '/api/v1/:path*', - destination: 'http://localhost:8080/:path*' // Proxy to Backend - } - ] - }, - output: 'export' - }; - -export default nextConfig; diff --git a/frontend/package.json b/frontend/package.json index b878a44..ada05b4 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev -p 9000", + "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 2072f9b..3dd773b 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -32,14 +32,14 @@ export default function Home() { const onMint = async () => { const requestData = { - asset_name: 'WST', + asset_name: Buffer.from('WST', 'utf8').toString('hex'), // Convert "WST" to hex issuer: mintAccount, - amount: mintTokens, + quantity: mintTokens, }; try { const response = await axios.post( - 'http://localhost:9000/api/tx/programmable-token/issue', + '/api/v1/tx/programmable-token/issue', requestData, { headers: { @@ -47,7 +47,6 @@ export default function Home() { }, } ); - console.log('Mint response:', response.data); } catch (error) { console.error('Minting failed:', error); From f80df85c2f9fc09a3bf3db202151e712b83a6da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jann=20M=C3=BCller?= Date: Fri, 10 Jan 2025 08:05:38 +0100 Subject: [PATCH 2/2] Fix JSON for UTxODat (#63) --- .github/workflows/ci-linux.yaml | 5 ----- generated/openapi/schema.json | 12 ++++++------ src/lib/Wst/Offchain/Query.hs | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-linux.yaml b/.github/workflows/ci-linux.yaml index 77270ee..9a59375 100644 --- a/.github/workflows/ci-linux.yaml +++ b/.github/workflows/ci-linux.yaml @@ -41,8 +41,3 @@ jobs: cabal update cabal build -j all --enable-tests cabal test all - - name: check compiled scripts are consistent - # git diff --quiet implies --exit-code - run: | - cabal run export-smart-tokens - git diff --quiet diff --git a/generated/openapi/schema.json b/generated/openapi/schema.json index f08f0ad..e015260 100644 --- a/generated/openapi/schema.json +++ b/generated/openapi/schema.json @@ -179,20 +179,20 @@ }, "UTxODat_ConwayEra_ProgrammableLogicGlobalParams": { "properties": { - "atum": { + "datum": { "$ref": "#/components/schemas/ProgrammableLogicGlobalParams" }, - "n": { + "in": { "$ref": "#/components/schemas/TxIn" }, - "ut": { + "out": { "$ref": "#/components/schemas/TxOut" } }, "required": [ - "n", - "ut", - "atum" + "in", + "out", + "datum" ], "type": "object" }, diff --git a/src/lib/Wst/Offchain/Query.hs b/src/lib/Wst/Offchain/Query.hs index 4347e60..440d5c6 100644 --- a/src/lib/Wst/Offchain/Query.hs +++ b/src/lib/Wst/Offchain/Query.hs @@ -61,7 +61,7 @@ data UTxODat era a = -- | Aeson options for the UTxODat type. Used to derive JSON instances and ToSchema utxoDatOptions :: JSON.Options -utxoDatOptions = JSON.customJsonOptions 2 +utxoDatOptions = JSON.customJsonOptions 1 instance (C.IsCardanoEra era, ToJSON a) => ToJSON (UTxODat era a) where toJSON = JSON.genericToJSON utxoDatOptions