Skip to content

Commit

Permalink
fix: Fix the type of the version field in Attestation at the SDK level (
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls authored Jan 18, 2024
1 parent be384e4 commit a18905f
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 51 deletions.
2 changes: 1 addition & 1 deletion explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@tanstack/react-table": "^8.10.7",
"@verax-attestation-registry/verax-sdk": "1.1.0",
"@verax-attestation-registry/verax-sdk": "1.1.1",
"@wagmi/core": "^1.4.7",
"abitype": "^0.10.3",
"class-variance-authority": "^0.7.0",
Expand Down
60 changes: 29 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@verax-attestation-registry/verax-sdk",
"version": "1.1.1",
"version": "1.1.2",
"description": "Verax Attestation Registry SDK to interact with the subgraph and the contracts",
"keywords": [
"linea-attestation-registry",
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/dataMapper/AttestationDataMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export default class AttestationDataMapper extends BaseDataMapper<
attestation.expirationDate = Number(attestation.expirationDate);
attestation.revocationDate = Number(attestation.revocationDate);

attestation.version = Number(attestation.version);

// Check if data is stored offchain
if (attestation.schemaId === Constants.OFFCHAIN_DATA_SCHEMA_ID) {
attestation.offchainData = {
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/integration/Attestation.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("AttestationDataMapper", () => {
expect(result?.attestedDate).toEqual(1695398083);
expect(result?.expirationDate).toEqual(1793835110);
expect(result?.revocationDate).toEqual(0);
expect(result?.version).toEqual("8");
expect(result?.version).toEqual(8);
expect(result?.revoked).toBeFalsy();
expect(result?.subject).toEqual("0xcb859f99f84ab770a50380680be94ad9331bcec5");
expect(result?.attestationData).toEqual("0x0000000000000000000000000000000000000000000000000000000000000004");
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@lens-protocol/widgets-react": "^2.1.0",
"@verax-attestation-registry/verax-sdk": "1.1.0",
"@verax-attestation-registry/verax-sdk": "1.1.1",
"@wagmi/core": "^1.4.7",
"@web3modal/wagmi": "^3.5.0",
"axios": "^1.6.1",
Expand Down
21 changes: 13 additions & 8 deletions website/src/components/CreatePortal.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import { type FunctionComponent, useState } from "react";
import { VeraxSdk } from "@verax-attestation-registry/verax-sdk";
import { useAccount } from "wagmi";
import { Address } from "@wagmi/core";
import { Hex } from "viem";

export type SDKDemoProps = {
veraxSdk: VeraxSdk;
getTxHash: (hash: Address) => void;
getTxHash: (hash: Hex) => void;
};

const CreatePortal: FunctionComponent<SDKDemoProps> = ({ veraxSdk, getTxHash }) => {
const [txHash, setTxHash] = useState<string>("");
const [txHash, setTxHash] = useState<Hex>();
const [error, setError] = useState<string>("");

const { isConnected } = useAccount();

const createPortal = async () => {
try {
const hash = await veraxSdk.portal.deployDefaultPortal(
const receipt = await veraxSdk.portal.deployDefaultPortal(
[],
"Tutorial Portal",
"This Portal is used for the tutorial",
true,
"Verax Tutorial",
);
setTxHash(hash);
getTxHash(hash);

if (receipt.transactionHash) {
setTxHash(receipt.transactionHash);
getTxHash(receipt.transactionHash);
} else {
setError(`Oops, something went wrong!`);
}
} catch (e) {
console.log(e);
if (e instanceof Error) {
Expand All @@ -35,10 +40,10 @@ const CreatePortal: FunctionComponent<SDKDemoProps> = ({ veraxSdk, getTxHash })

return (
<>
<button onClick={createPortal} disabled={!isConnected && txHash !== ""}>
<button onClick={createPortal} disabled={!isConnected || !txHash}>
Send transaction
</button>
{txHash !== "" && <p>{`Transaction with hash ${txHash} sent!`}</p>}
{txHash && <p>{`Transaction with hash ${txHash} sent!`}</p>}
{error !== "" && <p style={{ color: "red" }}>{error}</p>}
</>
);
Expand Down
13 changes: 9 additions & 4 deletions website/src/components/CreateSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { type FunctionComponent, useEffect, useState } from "react";
import { VeraxSdk } from "@verax-attestation-registry/verax-sdk";
import { useAccount } from "wagmi";
import { Address } from "@wagmi/core";
import { Hex } from "viem";

export type SDKDemoProps = {
veraxSdk: VeraxSdk;
getTxHash: (hash: Address) => void;
getTxHash: (hash: Hex) => void;
getSchemaId: (schemaId: Address) => void;
};

Expand Down Expand Up @@ -35,14 +36,18 @@ const CreateSchema: FunctionComponent<SDKDemoProps> = ({ veraxSdk, getTxHash, ge

const createSchema = async () => {
try {
const hash = await veraxSdk.schema.create(
const receipt = await veraxSdk.schema.create(
"Tutorial Schema",
"This Schema is used for the tutorial",
"https://ver.ax/#/tutorials",
SCHEMA,
);
setTxHash(hash);
getTxHash(hash);
if (receipt.transactionHash) {
setTxHash(receipt.transactionHash);
getTxHash(receipt.transactionHash);
} else {
setError(`Oops, something went wrong!`);
}
} catch (e) {
console.log(e);
if (e instanceof Error) {
Expand Down
13 changes: 9 additions & 4 deletions website/src/components/IssueAttestation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { type FunctionComponent, useState } from "react";
import { VeraxSdk } from "@verax-attestation-registry/verax-sdk";
import { useAccount } from "wagmi";
import { Address } from "@wagmi/core";
import { Hex } from "viem";

export type SDKDemoProps = {
veraxSdk: VeraxSdk;
getTxHash: (hash: Address) => void;
getTxHash: (hash: Hex) => void;
schemaId: Address;
portalId: Address;
};
Expand All @@ -19,7 +20,7 @@ const IssueAttestation: FunctionComponent<SDKDemoProps> = ({ veraxSdk, getTxHash
const issueAttestation = async () => {
if (address) {
try {
const hash = await veraxSdk.portal.attest(
const receipt = await veraxSdk.portal.attest(
portalId,
{
schemaId,
Expand All @@ -29,8 +30,12 @@ const IssueAttestation: FunctionComponent<SDKDemoProps> = ({ veraxSdk, getTxHash
},
[],
);
setTxHash(hash);
getTxHash(hash);
if (receipt.transactionHash) {
setTxHash(receipt.transactionHash);
getTxHash(receipt.transactionHash);
} else {
setError(`Oops, something went wrong!`);
}
} catch (e) {
console.log(e);
if (e instanceof Error) {
Expand Down

0 comments on commit a18905f

Please sign in to comment.