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

feat: added combobox, get documentstore, validate documentstore #38

Closed
wants to merge 15 commits into from

Conversation

ChenRen93
Copy link
Contributor

@ChenRen93 ChenRen93 commented Jul 8, 2021

Added combo box for document store input
Retrieve all the documents store created by the wallet
Validate if the document store belongs to the wallet

Closes #34 , Closes #36

@netlify
Copy link

netlify bot commented Jul 8, 2021

✔️ Deploy Preview for new-admin-opencerts ready!

🔨 Explore the source changes: 4ce9ee1

🔍 Inspect the deploy log: https://app.netlify.com/sites/new-admin-opencerts/deploys/611ca65fe168d900079e4b77

😎 Browse the preview: https://deploy-preview-38--new-admin-opencerts.netlify.app/

src/components/common/text-input.tsx Outdated Show resolved Hide resolved
src/components/util/document-store.tsx Outdated Show resolved Hide resolved
src/components/util/document-store.tsx Show resolved Hide resolved
src/components/util/document-store.tsx Outdated Show resolved Hide resolved
src/components/util/document-store.tsx Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2021

This pull request introduces 2 alerts when merging f2576a6 into 5395197 - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class


export const isDocumentStore = async (documentStoreAddress: string): Promise<boolean> => {
const documentStoreArray = await getDocumentStores();
documentStoreArray.filter((documentStore) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should only allow document stores we retrieved. What if we missed some?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you didn't address this ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I not using isDocumentStore to validate the contract anymore, thus removing the function. I using isValidContract() located in common.tsx. The function checks if the address is a contract using getCode that get blockTag block height, If the address is not a contract, the result return is 0x

Reference
https://docs.ethers.io/v5/single-page/#/v5/api/providers/provider/-%23-Provider-getCode

@@ -0,0 +1,39 @@
import { connectWallet, getWalletNetwork } from "./wallet";

export const getDocumentStores = async (): Promise<Array<Record<string, unknown>>> => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you test? It doesn't look like it work at all for me.

My wallet: https://ropsten.etherscan.io/address/0xB26B4941941C51a4885E5B7D3A1B861E54405f90

the document store retrieved
image

All the document stores are less than 63 days old + I didn't create that many in the last 2 months

Copy link
Contributor Author

@ChenRen93 ChenRen93 Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i found 100 contract creation log for "0xB26B4941941C51a4885E5B7D3A1B861E54405f90" wallet
https://ropsten.etherscan.io/txs?a=0xB26B4941941C51a4885E5B7D3A1B861E54405f90&f=5&p=1

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you search 0xcae (first in the screenshot) You wont find it in the link you shared. I also can't find a document store:

image

You can try with my wallet if you want. The information are shared in a spreadsheet

Copy link
Contributor Author

@ChenRen93 ChenRen93 Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found the issue. fixed. The logs topic is only capturing address "0xc84b0719a82626417c40f3168513dfabdb6a9079". i have change it to get logs based on the wallet address

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I have no document store anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2021-08-18 at 1 01 29 PM

mmm weirdly it works for mine.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see some doc store, but I can't find https://ropsten.etherscan.io/address/0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3

what about u ?

Copy link
Contributor Author

@ChenRen93 ChenRen93 Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3 seems to be a very different from the current contract, it is using the older contract version.

Based on my checks, it is currently retrieving the contracts that are of the current version, this feature will cause an issue if there is an upgrade on the upcoming/future contracts refactoring. i believe it is not worth continuing the feature of getting a document store as there isn't a simpler way to retrieve the past document store.

If u are okay with it, I will remove the retrieval of the document store and combo box but keep the document store validation just by checking the hashes length. This MR is getting huge, it will be preferable if i could get this merged into master before I change it to the localStorage implementation.

};

return (
<Creatable
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't use arrows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do u mean by can't use arrows

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to navigate with arrows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. The issue is cause useEffect continuous looping recreating the dropdown. I have fixed it by running useEffect only once

@@ -41,6 +41,7 @@
"@types/node": "^15.12.2",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the other comments but overall I don't think it's worth continuing on this. Doesn't look like a simple way t do what I suggested unless you want to dig further.

We can keep the part that verifies it's a valid address

Let me know what you think.

@lgtm-com
Copy link

lgtm-com bot commented Jul 22, 2021

This pull request introduces 1 alert when merging c896eaa into 4e6761b - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@@ -1,13 +1,15 @@
import React, { Dispatch, FunctionComponent, useState } from "react";
import { TextInput } from "./common/text-input";
declare let window: any;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. dont put ts definitions in ts code
  2. you completely delete all the provided typings :)

@@ -41,7 +41,7 @@ export const Header: FunctionComponent = () => {
getWalletDetails();
}
}
});
}, []);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u should remove the listeners

getDocumentStoreList();
}
}
}, []);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove listeners

@ChenRen93 ChenRen93 closed this Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect valid document store List all deployed document store
2 participants