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

v0.0.1 adapter for non-merklized onchain issuer #284

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

ilya-korotya
Copy link
Contributor

No description provided.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core';
import { Options } from '@iden3/js-jsonld-merklization';

const interfaceDetection = '0x01ffc9a7';
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's do it as enum, maybe it makes sence to extend existing one and move to common file

see export enum FunctionSignatures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My main idea was not to export this class to the user. The entry point to the onchain issuer should be only one OnchainIssuer class that decides on the type of OnchainIssuer and creates an instance of the required adapter. If we consider this adapter as some kind of hidden functionality, then it makes no sense to put these variables in the public enum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to enum, but not to common enum: FunctionSignatures

* @param merklizationOptions Optional settings for merklization.
*/
constructor(
url: string,
Copy link
Collaborator

@vmidyllic vmidyllic Nov 18, 2024

Choose a reason for hiding this comment

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

should we pass eth config here, so it will be possible to init this storage separately and still connect to contract?

otherwise rename to rpcUrl.
Also leave a possibility to options object
e.g.

new Adapter(address, options: { configs: EthConfigurationConfig[] / rpcUrl : .. , merklizationOptions, issuerDID }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adapter will not be exported to the end user. The user should use the OnchainIssuer class as an entry point to determine which adapter should be used.

src/storage/blockchain/onchain-issuer.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,56 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

you put a lot of testdata here.. is it really needed?

Copy link
Collaborator

@vmidyllic vmidyllic left a comment

Choose a reason for hiding this comment

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

why this file is not in abi folder

} from './common';

export declare namespace SmtLib {
export type ProofStruct = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have such struct - StateProof

auxExistence: boolean,
auxIndex: bigint,
auxValue: bigint
] & {
Copy link
Collaborator

Choose a reason for hiding this comment

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

& StateProof

@@ -0,0 +1,617 @@
/* Autogenerated file. Do not edit manually. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this autogenerated file in sdk ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest removing all autogenerated files and keeping only the .abi files with functions that are actively used in our services. This will simplify the PR, making it easier to review, and ensure alignment with our standard approach to interacting with Smart Contracts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We need types for the onchain issuer(s) because it is difficult to manage inline structures, arrays with inline structures, etc.
We decided to move the automatically generated code to https://github.com/iden3/contracts-abi/tree/main/onchain-non-merklized-issuer-base/v0/js and reuse it.

@ilya-korotya ilya-korotya force-pushed the feature/onchain-non-merklized-credential-converter branch from 2fe0eb5 to 1b7ed93 Compare November 21, 2024 08:22
schema.$metadata.uris['jsonLdContext']
];
r.context.push(schema.$metadata.uris['jsonLdContext']);
r.expiration = !r.expiration || r.expiration == 0 ? undefined : r.expiration * 1000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
r.expiration = !r.expiration || r.expiration == 0 ? undefined : r.expiration * 1000;
r.expiration = r.expiration ? r.expiration * 1000 : undefined;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

];
r.context.push(schema.$metadata.uris['jsonLdContext']);
r.expiration = !r.expiration || r.expiration == 0 ? undefined : r.expiration * 1000;
r.id = r.id ? r.id : `urn:${uuid.v4()}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
r.id = r.id ? r.id : `urn:${uuid.v4()}`;
r.id = r.id ?? `urn:${uuid.v4()}`;

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 tested this on a browser console and there is a result:

const foo = ""; foo ?? console.log(1);
returns: '' - empty string
const foo = ""; foo ? console.log(2) : console.log(1);
returns 1;

I expect with user pass empty string for the id field, we need generate uuid.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case replace ?? to || for example a = ''; b = '1'; a = a || b; // '1'

src/credentials/credential-wallet.ts Show resolved Hide resolved
if (onchainDisplayMethod.id === '' && onchainDisplayMethod._type === '') {
return undefined;
}
switch (onchainDisplayMethod._type) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add default behavior to switch clause

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

package.json Show resolved Hide resolved
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.

4 participants