Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APP] ICR FE Integration #2052

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"id": { "type": "string" },
"name": { "type": "string" },
"symbol": { "type": "string" },
"decimals": { "type": "number" }
"decimals": { "type": "number" },
"tokenId": { "type": "string" }
},
"required": ["id", "name", "symbol", "decimals"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@
"required": ["url", "caption"]
}
},
"hasSupply": { "type": "boolean" }
"hasSupply": { "type": "boolean" },
"tokenId": { "type": "string" },
"serialization": { "type": "string" }
},
"required": [
"key",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
"type": "string"
},
"projectID": { "examples": ["191"], "type": "string" },
"vintage": { "examples": ["2008"], "type": "string" }
"vintage": { "examples": ["2008"], "type": "string" },
"serialization": {
"examples": ["ICR-ISL-354-78040-14-R-0-2021"],
"type": "string"
}
},
"required": [
"country",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@
"id": { "type": "string" },
"name": { "type": "string" },
"symbol": { "type": "string" },
"decimals": { "type": "number" }
"decimals": { "type": "number" },
"tokenId": { "type": "string" }
},
"required": ["id", "name", "symbol", "decimals"]
},
Expand Down
4 changes: 4 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/types/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export type Asset = {
* @type number
*/
decimals: number;
/**
* @type string | undefined
*/
tokenId?: string;
};
/**
* @type string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ export type GetProjectsQueryResponse = {
* @type boolean
*/
hasSupply: boolean;
/**
* @type string | undefined
*/
tokenId?: string;
/**
* @type string | undefined
*/
serialization?: string;
}[];

export type GetProjectsQueryParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ export type GetProjectsIdQueryResponse = {
* @type boolean
*/
hasSupply: boolean;
/**
* @type string | undefined
*/
tokenId?: string;
/**
* @type string | undefined
*/
serialization?: string;
};

export type GetProjectsIdQueryParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export type GetPurchasesQueryResponse = {
* @type string
*/
vintage: string;
/**
* @type string | undefined
*/
serialization?: string;
};
};
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export type GetPurchasesIdQueryResponse = {
* @type string
*/
vintage: string;
/**
* @type string | undefined
*/
serialization?: string;
};
};
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ export type GetUsersWalletorhandleQueryResponse = {
* @type number
*/
decimals: number;
/**
* @type string | undefined
*/
tokenId?: string;
};
/**
* @type string
Expand Down
8 changes: 8 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/types/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,12 @@ export type Project = {
* @type boolean
*/
hasSupply: boolean;
/**
* @type string | undefined
*/
tokenId?: string;
/**
* @type string | undefined
*/
serialization?: string;
};
4 changes: 4 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/types/Purchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export type Purchase = {
* @type string
*/
vintage: string;
/**
* @type string | undefined
*/
serialization?: string;
};
};
/**
Expand Down
4 changes: 4 additions & 0 deletions carbonmark/.generated/carbonmark-api-sdk/types/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export type User = {
* @type number
*/
decimals: number;
/**
* @type string | undefined
*/
tokenId?: string;
};
/**
* @type string
Expand Down
51 changes: 48 additions & 3 deletions carbonmark/.generated/carbonmark-api.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.3",
"info": {
"title": "Carbonmark REST API",
"description": "\nWelcome to the API Reference docs for **version 5.2.1** of the Carbonmark REST API.\n\nUse this API to view assets, prices, supply, activity and more.\n\nLooking for the latest version? Visit our [GitHub Releases page](https://github.com/KlimaDAO/klimadao/releases).\n\n## Quick start\nBe sure to prefix a version number, otherwise your application will be exposed to breaking changes.\n\n~~~ts\nconst res = await fetch(\"https://v5.2.1.api.carbonmark.com/projects\");\nconst projects = await res.json();\n~~~\n\nFor a developer guides and example implementations, or to learn more about Carbonmark and Digital Carbon Market, view our product knowledge base at <a href=\"https://docs.carbonmark.com\">docs.carbonmark.com</a>.\n## \n",
"description": "\nWelcome to the API Reference docs for **version 5.3.0** of the Carbonmark REST API.\n\nUse this API to view assets, prices, supply, activity and more.\n\nLooking for the latest version? Visit our [GitHub Releases page](https://github.com/KlimaDAO/klimadao/releases).\n\n## Quick start\nBe sure to prefix a version number, otherwise your application will be exposed to breaking changes.\n\n~~~ts\nconst res = await fetch(\"https://v5.3.0.api.carbonmark.com/projects\");\nconst projects = await res.json();\n~~~\n\nFor a developer guides and example implementations, or to learn more about Carbonmark and Digital Carbon Market, view our product knowledge base at <a href=\"https://docs.carbonmark.com\">docs.carbonmark.com</a>.\n## \n",
"termsOfService": "https://www.carbonmark.com/blog/terms-of-use",
"contact": {
"name": "Support",
Expand All @@ -12,7 +12,7 @@
"name": "MIT",
"url": "https://github.com/KlimaDAO/klimadao/blob/main/LICENSE"
},
"version": "5.2.1"
"version": "5.3.0"
},
"components": {
"schemas": {
Expand Down Expand Up @@ -488,6 +488,12 @@
},
"hasSupply": {
"type": "boolean"
},
"tokenId": {
"type": "string"
},
"serialization": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -1010,6 +1016,12 @@
"2008"
],
"type": "string"
},
"serialization": {
"examples": [
"ICR-ISL-354-78040-14-R-0-2021"
],
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -1460,6 +1472,9 @@
},
"decimals": {
"type": "number"
},
"tokenId": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -1508,6 +1523,9 @@
},
"decimals": {
"type": "number"
},
"tokenId": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -2592,6 +2610,12 @@
},
"hasSupply": {
"type": "boolean"
},
"tokenId": {
"type": "string"
},
"serialization": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -2720,6 +2744,12 @@
"2008"
],
"type": "string"
},
"serialization": {
"examples": [
"ICR-ISL-354-78040-14-R-0-2021"
],
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -3760,6 +3790,12 @@
},
"hasSupply": {
"type": "boolean"
},
"tokenId": {
"type": "string"
},
"serialization": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -3895,6 +3931,12 @@
"2008"
],
"type": "string"
},
"serialization": {
"examples": [
"ICR-ISL-354-78040-14-R-0-2021"
],
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -4411,6 +4453,9 @@
},
"decimals": {
"type": "number"
},
"tokenId": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -4791,7 +4836,7 @@
},
"servers": [
{
"url": "https://v5.2.1.api.carbonmark.com"
"url": "https://v5.3.0.api.carbonmark.com"
}
],
"externalDocs": {
Expand Down
4 changes: 4 additions & 0 deletions carbonmark/components/Activities/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export const Activity = (props: Props) => {
transactionString = <EastIcon />;
}

const shouldDisplayActivity = amountA !== amountB;
if (!shouldDisplayActivity) {
return null;
}
return (
<div key={props.activity.id} className={styles.activity}>
{project && (
Expand Down
11 changes: 9 additions & 2 deletions carbonmark/components/AssetDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { cx } from "@emotion/css";
import { Anchor } from "@klimadao/lib/components";
import { PoolToken } from "@klimadao/lib/constants";
import { useWeb3 } from "@klimadao/lib/utils";
import { t } from "@lingui/macro";
import LaunchIcon from "@mui/icons-material/Launch";
import { Accordion } from "components/Accordion";
import { Text } from "components/Text";
import { getPolygonScanBaseUrl } from "lib/createUrls";
import { formatToTonnes } from "lib/formatNumbers";
import { getPoolTokenType } from "lib/getPoolData";
import { carbonTokenInfoMap } from "lib/getTokenInfo";
Expand All @@ -20,11 +22,11 @@ type TotalValuesProps = {
project: Project;
actionLabel: string;
availableLabel: string;
polyscanUrl: string;
};

export const AssetDetails: FC<TotalValuesProps> = (props) => {
const { locale } = useRouter();
const { networkLabel } = useWeb3();
const tokenType = getPoolTokenType(
props.price.poolName.toUpperCase() as Uppercase<PoolToken>
);
Expand Down Expand Up @@ -55,7 +57,12 @@ export const AssetDetails: FC<TotalValuesProps> = (props) => {
</Text>
</div>
<div className={styles.totalsText}>
<Anchor className={styles.iconAndText} href={props.polyscanUrl}>
<Anchor
className={styles.iconAndText}
href={`${getPolygonScanBaseUrl(networkLabel)}/address/${
props.price.projectTokenAddress
}`}
>
<Text className={styles.externalLink} t="body2">
{t`View on PolygonScan`} <LaunchIcon />
</Text>
Expand Down
10 changes: 10 additions & 0 deletions carbonmark/components/CreateListing/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InputField } from "components/shared/Form/InputField";
import { Text } from "components/Text";
import { MINIMUM_TONNE_PRICE } from "lib/constants";
import { Asset } from "lib/types/carbonmark.types";
import { validateIcrAmount } from "lib/validateIcrAmount";
import { useRouter } from "next/router";
import { FC } from "react";
import { SubmitHandler, useForm } from "react-hook-form";
Expand All @@ -14,6 +15,7 @@ export type FormValues = {
amount: string;
unitPrice: string;
tokenAddress: string;
tokenId?: string;
};

type Props = {
Expand All @@ -24,6 +26,7 @@ type Props = {

const defaultValues: FormValues = {
tokenAddress: "",
tokenId: "",
amount: "",
unitPrice: "",
};
Expand All @@ -39,7 +42,9 @@ export const CreateListingForm: FC<Props> = (props) => {
tokenAddress:
props.values?.tokenAddress.toLowerCase() ||
props.assets[0].token.id.toLowerCase(),
tokenId: props.values?.tokenId || props.assets[0].token.tokenId,
},
mode: "onChange",
});

const selectedAddress = watch("tokenAddress");
Expand All @@ -61,6 +66,7 @@ export const CreateListingForm: FC<Props> = (props) => {
<ProjectTokenDropDown
onTokenSelect={(asset) => {
setValue("tokenAddress", asset.token.id.toLowerCase());
setValue("tokenId", asset.token.tokenId);
}}
assets={props.assets}
selectedAsset={selectedAsset}
Expand Down Expand Up @@ -92,6 +98,10 @@ export const CreateListingForm: FC<Props> = (props) => {
value: Number(selectedAsset.amount),
message: t`Balance exceeded`,
},
validate: {
isWholeNumber: (value) =>
validateIcrAmount(value, selectedAsset.id),
},
}),
}}
label={t`Quantity`}
Expand Down
Loading