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

Question: Fetching Certificates for Device #2398

Open
devrajsinghrawat opened this issue May 12, 2021 · 6 comments
Open

Question: Fetching Certificates for Device #2398

devrajsinghrawat opened this issue May 12, 2021 · 6 comments

Comments

@devrajsinghrawat
Copy link

devrajsinghrawat commented May 12, 2021

When we need to fetch Certificates for Device , We are using the helper function from CertificateUtils

CertificateUtils.getAllOwnedCertificates(blockchainProperties)

where in blockchainProperties, we need to set the active user, which is a wallet instance, To get this wallet instance we need to pass the private keys

export interface IBlockchainProperties {
    web3: providers.FallbackProvider | providers.JsonRpcProvider;
    registry: Registry;
    issuer: Issuer;
    activeUser?: Signer;
}

So Is there any other way to fetch the Device certificate, without exposing the device private key?

@josipbagaric
Copy link
Contributor

Sure, the activeUser is an optional parameter (hence the question mark in activeUser?).

You should be able to get details about the certificate even without the activeUser property, but you won't be able to trigger actions such as .transfer(), .claim() etc. because they require sending a transaction to the blockchain.

@devrajsinghrawat
Copy link
Author

Hi @JosephBagaric many thanks for your reply ..

Agree that, we can get owned Certificate data without pk of active user.

But for transfer ,

We do need to the Certificate instane

Const [certificate] = await CertificateUtils.getAllOwnedCertificates(blockchainProperties);
this to get this instance we also need to set activeUser like you have mentioned

later this instance are being used for initiate transfer
await certificate.transfer(deviceOwnerWallet.address, totalVolume)

Now, is it possible if we can get this signing part using HCM and then send the signed transaction instead using raw PK.

@josipbagaric
Copy link
Contributor

josipbagaric commented May 27, 2021

activeUser is of type Signer, meaning that we support any Ethers.js compatible Signer module (private key, MetaMask, etc.). Doesn't have to be a raw PK.

There's currently no support to send a signed raw transaction to the Certificate facade to execute .transfer() or .claim().
It's only done through the Ethers.js Signer object.

Can you create a custom Signer module for HCM and use that? That should work.

@devrajsinghrawat
Copy link
Author

Do we have any direction for creating a custom Signer module and how that module will be integrated into Origin operations

@josipbagaric
Copy link
Contributor

josipbagaric commented May 27, 2021

Sure, probably you can just create a TypeScript implementation of the abstract Signer interface from ethers.js.
https://github.com/ethers-io/ethers.js/tree/master/packages/abstract-signer

Then just attach this Signer object to blockchainProperties.activeUser in Origin and it should work out-of-the-box.

I'm not familiar with HCM and how it works, so I can't help you on that part.

@devrajsinghrawat
Copy link
Author

Thanks @JosephBagaric for your prompt inputs .. Let me explore on this

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

No branches or pull requests

2 participants