-
Notifications
You must be signed in to change notification settings - Fork 36
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
base: main
Are you sure you want to change the base?
v0.0.1 adapter for non-merklized onchain issuer #284
Conversation
import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core'; | ||
import { Options } from '@iden3/js-jsonld-merklization'; | ||
|
||
const interfaceDetection = '0x01ffc9a7'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.../onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts
Outdated
Show resolved
Hide resolved
* @param merklizationOptions Optional settings for merklization. | ||
*/ | ||
constructor( | ||
url: string, |
There was a problem hiding this comment.
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 }
There was a problem hiding this comment.
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.
.../onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts
Outdated
Show resolved
Hide resolved
.../onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts
Show resolved
Hide resolved
...ockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/types/NonMerklizedIssuerBase.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,56 @@ | |||
{ |
There was a problem hiding this comment.
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?
There was a problem hiding this 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 = { |
There was a problem hiding this comment.
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 | ||
] & { |
There was a problem hiding this comment.
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. */ |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2fe0eb5
to
1b7ed93
Compare
schema.$metadata.uris['jsonLdContext'] | ||
]; | ||
r.context.push(schema.$metadata.uris['jsonLdContext']); | ||
r.expiration = !r.expiration || r.expiration == 0 ? undefined : r.expiration * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.expiration = !r.expiration || r.expiration == 0 ? undefined : r.expiration * 1000; | |
r.expiration = r.expiration ? r.expiration * 1000 : undefined; |
There was a problem hiding this comment.
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()}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.id = r.id ? r.id : `urn:${uuid.v4()}`; | |
r.id = r.id ?? `urn:${uuid.v4()}`; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'
.../onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts
Show resolved
Hide resolved
if (onchainDisplayMethod.id === '' && onchainDisplayMethod._type === '') { | ||
return undefined; | ||
} | ||
switch (onchainDisplayMethod._type) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.