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

Imporved "generate proof" prompt wording #36

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/rarimo/rarime.git"
},
"source": {
"shasum": "i0ljRZ0cephpKn1+G77icrHnm0Gh4soRcJ9b6xpQaXA=",
"shasum": "SoQrve5CiMg2IUvWl9jr5WgRraS5PZl3vCYK3prr/vY=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
40 changes: 13 additions & 27 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,38 +260,27 @@ export const onRpcRequest = async ({
);
}

const vc = credentials[0];

const res = await snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Create proof'),

divider(),
heading('Generate a Zero-knowledge proof?'),
ihordiachenko marked this conversation as resolved.
Show resolved Hide resolved

text('Credential types'),
divider(),

...credentials.reduce((acc: TextField[], cred) => {
return [
...acc,

...cred.type.reduce((credAcc: TextField[], type) => {
return credAcc.concat([text(`${type}\n`)]);
}, []),
];
}, []),
text('**Credential**'),
text(`${vc.type?.[1]}\n`),

divider(),
text('Requirements'),
text('**Query**'),

...credentials.reduce((acc: TextField[], cred) => {
return [
...acc,

...Object.keys(cred.credentialSubject).reduce(
...(query.credentialSubject
? Object.keys(query.credentialSubject).reduce(
(accSubj: TextField[], fieldName) => {
const fieldOperators = cred.credentialSubject?.[fieldName];
const fieldOperators = query.credentialSubject?.[fieldName];

const isString = typeof fieldOperators === 'string';
const isNumber = typeof fieldOperators === 'number';
Expand All @@ -315,23 +304,20 @@ export const onRpcRequest = async ({
return accSubj.concat(textField);
},
[],
),
];
}, []),
)
: []),

divider(),

...(circuitId
? [divider(), text('Proof type'), text(circuitId)]
: []),
...(circuitId ? [text('**ZK Circuit**'), text(circuitId)] : []),
]),
},
});

if (res) {
const identity = await Identity.create(identityStorage.privateKeyHex);

const zkpGen = new ZkpGen(identity, createProofRequest, credentials[0]);
const zkpGen = new ZkpGen(identity, createProofRequest, vc);

// ================ LOAD STATE DETAILS =====================

Expand Down
Loading