diff --git a/components/atoms/VerifyNode.js b/components/atoms/VerifyNode.js
index f8bf093..691cc24 100644
--- a/components/atoms/VerifyNode.js
+++ b/components/atoms/VerifyNode.js
@@ -19,7 +19,11 @@ const getWeb3SignatureFaucetContents = (hoprAddress, ethAddress) => ({
ethAddress,
});
-const getWeb3SignatureVerifyContents = (hoprAddress, hoprSignature, ethAddress) => ({
+const getWeb3SignatureVerifyContents = (
+ hoprAddress,
+ hoprSignature,
+ ethAddress
+) => ({
hoprAddress,
hoprSignature,
ethAddress,
@@ -160,7 +164,11 @@ export const VerifyNode = ({ idx, copyCodeToClipboard }) => {
};
const signSignature = async (hoprAddress, hoprSignature, ethAddress) => {
- const message = getWeb3SignatureVerifyContents(hoprAddress, hoprSignature, ethAddress);
+ const message = getWeb3SignatureVerifyContents(
+ hoprAddress,
+ hoprSignature,
+ ethAddress
+ );
const signature = await library
.getSigner()
._signTypedData(
@@ -338,16 +346,15 @@ export const VerifyNode = ({ idx, copyCodeToClipboard }) => {
Now, copy your Ethereum address (the one you want your NFT rewards to
go to and you can use for signing, usually your MetaMask one) and go
to the admin interface of your HOPR node. Using the command “sign”,
- sign your copied address and paste the result here. e.g. “sign
- {' '}{account}”
+ sign your copied address and paste the result here. e.g. “sign{" "}
+ {account}”
Copy and paste the contents of the sign function in the following text
- field and click on “Verify node for rewards”. If valid, your node
- will then be shown as verified in our network with your Ethereum
- address.
+ field and click on “Verify node for rewards”. If valid, your node will
+ then be shown as verified in our network with your Ethereum address.
diff --git a/constants/ceramic.js b/constants/ceramic.js
index 4d1a770..736b0a1 100644
--- a/constants/ceramic.js
+++ b/constants/ceramic.js
@@ -4,4 +4,4 @@ export const CERAMIC_IDX_ALIASES = {
alias1: "basicProfile",
};
export const CERAMIC_IDX_HOPR_NAMESPACE = 'hopr-wildhorn'
-export const CERAMIC_TILE_ID = 'kjzl6cwe1jw1468n6gtygg5kdg0j69treni29fruvwxvatff9ebb4p4q995fv4i'
\ No newline at end of file
+export const OLD_CERAMIC_TILE_ID = 'kjzl6cwe1jw1468n6gtygg5kdg0j69treni29fruvwxvatff9ebb4p4q995fv4i'
\ No newline at end of file
diff --git a/pages/api/sign/get/[address].js b/pages/api/sign/get/[address].js
index 2050e58..8a46647 100644
--- a/pages/api/sign/get/[address].js
+++ b/pages/api/sign/get/[address].js
@@ -5,7 +5,7 @@ import CeramicClient from "@ceramicnetwork/http-client";
import { TileDocument } from "@ceramicnetwork/stream-tile";
import {
CERAMIC_API_URL,
- CERAMIC_TILE_ID,
+ OLD_CERAMIC_TILE_ID
} from "../../../../constants/ceramic";
import { utils } from "ethers";
@@ -16,19 +16,29 @@ const secretKey = Uint8Array.from(
const provider = new Ed25519Provider(secretKey);
const did = new DID({ provider, resolver: KeyResolver.getResolver() });
const client = new CeramicClient(CERAMIC_API_URL);
-const tileId = CERAMIC_TILE_ID;
+
+const filterPerAddress = (records, address) => Object.keys(records.content).filter(hoprNode => records.content[hoprNode] == address);
export default async (req, res) => {
const { address } = req.query;
await did.authenticate();
client.setDID(did);
- const records = await TileDocument.load(client, tileId);
- const addressRecords = Object.keys(records.content).filter(hoprNode => records.content[hoprNode] == address);
+ const oldRecords = await TileDocument.load(client, OLD_CERAMIC_TILE_ID);
+ const records = await TileDocument.create(
+ client,
+ null,
+ { deterministic: true, family: "hopr-wildhorn", tags: [address] },
+ { anchor: false, publish: false }
+ );
+
+ const addressRecords = filterPerAddress(records, address);
+ const oldAddressRecords = filterPerAddress(oldRecords, address);
return res.status(200).json({
status: "ok",
- tileId,
+ tileId: records.id.toString(),
records: addressRecords,
+ oldRecords: oldAddressRecords
});
};
diff --git a/pages/api/sign/get/all.js b/pages/api/sign/get/all.js
index c4bc1d0..424dd5b 100644
--- a/pages/api/sign/get/all.js
+++ b/pages/api/sign/get/all.js
@@ -5,7 +5,7 @@ import CeramicClient from "@ceramicnetwork/http-client";
import { TileDocument } from "@ceramicnetwork/stream-tile";
import {
CERAMIC_API_URL,
- CERAMIC_TILE_ID,
+ OLD_CERAMIC_TILE_ID,
} from "../../../../constants/ceramic";
import { utils } from "ethers";
@@ -16,28 +16,24 @@ const secretKey = Uint8Array.from(
const provider = new Ed25519Provider(secretKey);
const did = new DID({ provider, resolver: KeyResolver.getResolver() });
const client = new CeramicClient(CERAMIC_API_URL);
-const tileId = CERAMIC_TILE_ID;
export default async (req, res) => {
const { flattened } = req.query;
await did.authenticate();
client.setDID(did);
- const records = await TileDocument.load(client, tileId);
-
- if (flattened) {
- const ethAddress = Object.values(records.content);
- const correspondingHoprNode = Object.keys(records.content);
- return res.status(200).json({
- status: "ok",
- ethAddress,
- correspondingHoprNode
- })
- }
+ const oldRecords = await TileDocument.load(client, OLD_CERAMIC_TILE_ID) || {};
+ const records = await TileDocument.create(
+ client,
+ null,
+ { deterministic: true, family: "hopr-wildhorn", tags: ["hopr-dashboard"] },
+ { anchor: false, publish: false }
+ );
return res.status(200).json({
status: "ok",
- tileId,
+ tileId: records.id.toString(),
records: records.content,
+ oldRecords: oldRecords.content
});
};
diff --git a/pages/api/sign/verify/[address].js b/pages/api/sign/verify/[address].js
index 4beade6..40d2c3f 100644
--- a/pages/api/sign/verify/[address].js
+++ b/pages/api/sign/verify/[address].js
@@ -9,11 +9,10 @@ import {
} from "../../../../constants/hopr";
import {
CERAMIC_API_URL,
- CERAMIC_TILE_ID,
} from "../../../../constants/ceramic";
import { verifySignatureFromPeerId } from "@hoprnet/hopr-utils";
-import { utils} from "ethers";
+import { utils } from "ethers";
// NB: HOPR Node sign messages using the prefix to avoid having
// the nodes sign any generic data which could be used maliciously
@@ -28,7 +27,6 @@ const secretKey = Uint8Array.from(
const provider = new Ed25519Provider(secretKey);
const did = new DID({ provider, resolver: KeyResolver.getResolver() });
const client = new CeramicClient(CERAMIC_API_URL);
-const tileId = CERAMIC_TILE_ID;
export default async (req, res) => {
const { address } = req.query;
@@ -54,16 +52,31 @@ export default async (req, res) => {
);
if (isAddressOwnerOfNode) {
-
await did.authenticate();
client.setDID(did);
- const docs = await TileDocument.load(client, tileId);
+ const docs = await TileDocument.create(client, null, {
+ deterministic: true,
+ tags: [ethAddress],
+ family: "hopr-wildhorn",
+ });
+
const mutatedDoc = Object.assign({}, docs.content, {
[hoprAddress]: ethAddress,
});
await docs.update(mutatedDoc);
+ const dashboard = await TileDocument.create(client, null, {
+ deterministic: true,
+ tags: ["hopr-dashboard"],
+ family: "hopr-wildhorn",
+ });
+
+ const mutatedDashboard = Object.assign({}, dashboard.content, {
+ [docs.id.toString()]: ethAddress,
+ });
+ await dashboard.update(mutatedDashboard);
+
return res.status(200).json({
status: "ok",
tile: docs.id.toString(),
diff --git a/pages/nfts.js b/pages/nfts.js
index 8fcbb57..d755bff 100644
--- a/pages/nfts.js
+++ b/pages/nfts.js
@@ -80,12 +80,12 @@ const dataTable = [
];
export default function HoprAllocation() {
- const { account, library } = useEthers();
+ const { account } = useEthers();
const [records, setRecords] = useState([]);
useEffect(() => {
const loadRecords = async () => {
- const response = await (await fetch(`/api/sign/get/${account}`)).json();
- setRecords(response.records);
+ const { records, oldRecords } = await (await fetch(`/api/sign/get/${account}`)).json();
+ setRecords(oldRecords.concat(records));
};
account && loadRecords();
}, [account]);