diff --git a/cosmwasm/schema/plastic-credit-marketplace.json b/cosmwasm/schema/plastic-credit-marketplace.json index e2680b05..668d8c6e 100644 --- a/cosmwasm/schema/plastic-credit-marketplace.json +++ b/cosmwasm/schema/plastic-credit-marketplace.json @@ -436,6 +436,37 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "price" + ], + "properties": { + "price": { + "type": "object", + "required": [ + "denom", + "number_of_credits_to_buy", + "owner" + ], + "properties": { + "denom": { + "type": "string" + }, + "number_of_credits_to_buy": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "owner": { + "$ref": "#/definitions/Addr" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ], "definitions": { @@ -647,6 +678,45 @@ "type": "string" } } + }, + "price": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PriceResponse", + "type": "object", + "required": [ + "fee", + "total_price" + ], + "properties": { + "fee": { + "$ref": "#/definitions/Coin" + }, + "total_price": { + "$ref": "#/definitions/Coin" + } + }, + "additionalProperties": false, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } } } } diff --git a/frontend/empowerjs/package.json b/frontend/empowerjs/package.json index 885c2158..e48836ab 100644 --- a/frontend/empowerjs/package.json +++ b/frontend/empowerjs/package.json @@ -1,6 +1,6 @@ { "name": "@empower-plastic/empowerjs", - "version": "0.0.19", + "version": "0.0.20", "description": "Typescript types for EmpowerChain", "author": "empower ", "homepage": "https://github.com/EmpowerPlastic/empowerchain/tree/main/frontend/empowerjs#readme", diff --git a/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.client.ts b/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.client.ts index f39e9d33..69f03b3b 100644 --- a/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.client.ts +++ b/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.client.ts @@ -6,7 +6,7 @@ import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; import { StdFee } from "@cosmjs/amino"; -import { InstantiateMsg, ExecuteMsg, Uint64, Addr, Uint128, Decimal, Coin, Share, QueryMsg, Config, ListingResponse, Listing, ListingsResponse } from "./PlasticCreditMarketplace.types"; +import { InstantiateMsg, ExecuteMsg, Uint64, Addr, Uint128, Decimal, Coin, Share, QueryMsg, Config, ListingResponse, Listing, ListingsResponse, PriceResponse } from "./PlasticCreditMarketplace.types"; export interface PlasticCreditMarketplaceReadOnlyInterface { contractAddress: string; listings: ({ @@ -24,6 +24,15 @@ export interface PlasticCreditMarketplaceReadOnlyInterface { owner: Addr; }) => Promise; feeSplitConfig: () => Promise; + price: ({ + denom, + numberOfCreditsToBuy, + owner + }: { + denom: string; + numberOfCreditsToBuy: number; + owner: Addr; + }) => Promise; } export class PlasticCreditMarketplaceQueryClient implements PlasticCreditMarketplaceReadOnlyInterface { client: CosmWasmClient; @@ -35,6 +44,7 @@ export class PlasticCreditMarketplaceQueryClient implements PlasticCreditMarketp this.listings = this.listings.bind(this); this.listing = this.listing.bind(this); this.feeSplitConfig = this.feeSplitConfig.bind(this); + this.price = this.price.bind(this); } listings = async ({ @@ -70,6 +80,23 @@ export class PlasticCreditMarketplaceQueryClient implements PlasticCreditMarketp fee_split_config: {} }); }; + price = async ({ + denom, + numberOfCreditsToBuy, + owner + }: { + denom: string; + numberOfCreditsToBuy: number; + owner: Addr; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + price: { + denom, + number_of_credits_to_buy: numberOfCreditsToBuy, + owner + } + }); + }; } export interface PlasticCreditMarketplaceInterface extends PlasticCreditMarketplaceReadOnlyInterface { contractAddress: string; diff --git a/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.types.ts b/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.types.ts index a019e4cb..bc1689e4 100644 --- a/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.types.ts +++ b/frontend/empowerjs/src/plastic-credit-marketplace/PlasticCreditMarketplace.types.ts @@ -89,6 +89,12 @@ export type QueryMsg = { }; } | { fee_split_config: {}; +} | { + price: { + denom: string; + number_of_credits_to_buy: number; + owner: Addr; + }; }; export interface Config { fee_percentage: Decimal; @@ -106,4 +112,8 @@ export interface Listing { } export interface ListingsResponse { listings: Listing[]; +} +export interface PriceResponse { + fee: Coin; + total_price: Coin; } \ No newline at end of file diff --git a/frontend/marketplace/.env.development b/frontend/marketplace/.env.development index 93019993..4f219cf0 100644 --- a/frontend/marketplace/.env.development +++ b/frontend/marketplace/.env.development @@ -14,5 +14,5 @@ VITE_ROLLBAR_ACCESS_TOKEN="0791c0b34f844b61aba669c0ad4469d5" VITE_GOOGLE_MAPS_API_KEY="AIzaSyBezM4SJJO5t2bS5j2CPOdWJm_kHsdN4n0" VITE_LOGTO_ENDPOINT="https://h3cwf8.logto.app/" VITE_LOGTO_APP_ID="ilv0vuqy1u4zi05nyesgc" -VITE_PC_BACKEND_ENDPOINT="https://pc-backend-public-qa-xv5zwi25ya-ew.a.run.app" +VITE_PC_BACKEND_ENDPOINT="https://api.qa.empower.eco/api/v1/pc-backend-public" diff --git a/frontend/marketplace/package-lock.json b/frontend/marketplace/package-lock.json index f3665672..e04f0299 100644 --- a/frontend/marketplace/package-lock.json +++ b/frontend/marketplace/package-lock.json @@ -51,7 +51,7 @@ "prettier": "^3.1.0", "tailwindcss": "^3.3.5", "typescript": "~5.3.3", - "vite": "^5.0.10", + "vite": "^5.0.12", "vitest": "^0.34.6", "vue-tsc": "^1.8.25" }, @@ -7644,9 +7644,9 @@ } }, "node_modules/vite": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.10.tgz", - "integrity": "sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz", + "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==", "dev": true, "dependencies": { "esbuild": "^0.19.3", diff --git a/frontend/marketplace/package.json b/frontend/marketplace/package.json index f4a49a98..cf4538fa 100644 --- a/frontend/marketplace/package.json +++ b/frontend/marketplace/package.json @@ -58,7 +58,7 @@ "prettier": "^3.1.0", "tailwindcss": "^3.3.5", "typescript": "~5.3.3", - "vite": "^5.0.10", + "vite": "^5.0.12", "vitest": "^0.34.6", "vue-tsc": "^1.8.25" }, diff --git a/frontend/marketplace/src/pages/AuctionPaymentSuccessful.vue b/frontend/marketplace/src/pages/AuctionPaymentSuccessful.vue index fda42468..c4f57e00 100644 --- a/frontend/marketplace/src/pages/AuctionPaymentSuccessful.vue +++ b/frontend/marketplace/src/pages/AuctionPaymentSuccessful.vue @@ -94,8 +94,8 @@ onMounted(async () => { v-if="auctionStatus === PaymentStatus.COMPLETE" class="font-Inter text-white text-title18" > - Your plastic credit purchase was successful and Plastic Credit Offset - Certificate has been generated for you. + Your plastic credit purchase was successful and a Plastic Credit + Offset Certificate has been generated for you. { See your plastic creditsSee your certificates diff --git a/frontend/marketplace/src/pdfGenerator/pdfGenerator.ts b/frontend/marketplace/src/pdfGenerator/pdfGenerator.ts index e435c9f3..34c132aa 100644 --- a/frontend/marketplace/src/pdfGenerator/pdfGenerator.ts +++ b/frontend/marketplace/src/pdfGenerator/pdfGenerator.ts @@ -7,6 +7,7 @@ import { leaf1, horizontalLeafs, verticalLeafs, + greenLogo, } from "../pdfGenerator/AssetsBase64"; import { addTextWithSpacing, @@ -79,9 +80,48 @@ export const generatePDF = ( creditData, applicantDataDescription, ); + addFinalPage(doc); doc.save("certificate.pdf"); }; +const addFinalPage = (doc: IjsPDF) => { + doc.addPage("a4", "portrait"); + addGrayPadding(doc); + doc.addImage(verticalLeafs, "png", 0, 0, 210, 297); + doc.addImage(leaf1, "png", 30, 23, 10, 8); + + doc.setFontSize(12); + doc.setTextColor(35, 31, 32); + doc.setFont("Open Sans", "normal"); + + doc.text( + ` + This certificate is issued by Empower. + + Blockchain technology ensures the transparency and integrity of this certificate. + Each transaction is recorded on a decentralized and immutable ledger, providing a + clear audit trail. This guarantees that each credit is unique, cannot be + double-counted, and its environmental impact is accurately represented. + + Read more at https://www.empower.eco + `, + doc.internal.pageSize.width / 2, + doc.internal.pageSize.height / 2 - 72, + { + align: "center", + }, + ); + + doc.addImage( + greenLogo, + "png", + doc.internal.pageSize.width / 2 - 5, + 60, + 10, + 10, + ); +}; + const addGrayPadding = (doc: IjsPDF) => { const paddingInMM = 10.58; const pageWidth = doc.internal.pageSize.getWidth(); @@ -99,10 +139,12 @@ const addGreenRectanglePage1 = (doc: IjsPDF) => { doc.setFillColor(219, 231, 214); - const x = 40; - const y = 60; + const x = 80.58; + const y = 56; + const paddingToTheLeft = 80.58; + const paddingToTheRight = 10.58; - const rectWidth = pageWidth; + const rectWidth = pageWidth - paddingToTheLeft - paddingToTheRight; const rectHeight = 90; doc.rect(x, y, rectWidth, rectHeight, "F"); @@ -143,14 +185,34 @@ const addCertificateHolderPage1 = ( addTextWithSpacing(doc, "PROUDLY PRESENTED TO", 142, 75, 0.5); const name = certificateData.retiringEntityName || "N/A"; - const yPos = 95; + const yPos = 91; const { xPos, fontSize } = calculateTextProperties(name); doc.setFontSize(fontSize); doc.setTextColor(88, 185, 71); - doc.setFont("Open Sans", "bold"); + doc.setFont("Open Sans", "normal"); doc.text(name, xPos, yPos); + + doc.setFontSize(10); + doc.setTextColor(35, 31, 32); + const logoWidth = 5; + doc.text( + "Certificate issued by Empower", + doc.internal.pageSize.width / 2 + 35 - logoWidth - 4, + doc.internal.pageSize.height - 12, + { + align: "center", + }, + ); + doc.addImage( + greenLogo, + "png", + doc.internal.pageSize.width / 2 + 35 + 10 + logoWidth, + doc.internal.pageSize.height - 17, + logoWidth, + logoWidth, + ); }; const addHorizontalLongLinePage1 = (doc: IjsPDF) => { @@ -198,15 +260,19 @@ const addCirularImagePage1 = ( ID: string, qrCodeUrl: string | undefined, ) => { - doc.addImage(circular, "png", 160, 155, 40, 40); + const startY = 151; + const textY = startY + 20; + const qrY = startY + 9; + + doc.addImage(circular, "png", 160, startY, 40, 40); doc.setFontSize(15); doc.setTextColor(0, 0, 0); doc.setFont("Open Sans", "bold"); - doc.text(ID, 174, 175); + doc.text(ID, 174, textY); doc.setTextColor(88, 185, 71); doc.setFontSize(12); if (qrCodeUrl) { - doc.addImage(qrCodeUrl, "svg", 168, 164, 23, 23); + doc.addImage(qrCodeUrl, "svg", 168, qrY, 23, 23); } };