Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
feat(sdk): return signature as well as proof with returnproof flag
Browse files Browse the repository at this point in the history
  • Loading branch information
joeandrews committed Jul 6, 2020
1 parent 107084e commit c5eedba
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ export default async function prove(query, connection) {
data: {
args,
},
sender,
} = query;
const {
proofType,
returnProof,
} = args;

let returnData = {};
if (!returnProof) {
if (sender === 'WEB_CLIENT') {
returnData = await triggerProofUi(query, connection);
} else {
switch (proofType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const fetchOutputNotes = ({ proofData }) => {
const fetchOutputNotes = ({
proofData,
proof,
signature,
signature2,
}) => {
const {
outputNotes,
remainderNote,
Expand All @@ -18,16 +23,28 @@ const fetchOutputNotes = ({ proofData }) => {
noteHash,
value,
})),
proof,
signature,
signature2,

};
};

const returnProof = ({ proof, signature, signature2 }) => ({
proof,
signature,
signature2,
});

export default {
DEPOSIT_PROOF: [
fetchOutputNotes,
returnProof,
],
WITHDRAW_PROOF: [],
TRANSFER_PROOF: [
fetchOutputNotes,
returnProof,
],
CREATE_NOTE_FROM_BALANCE_PROOF: [
(data) => {
Expand Down
11 changes: 5 additions & 6 deletions packages/extension/src/client/apis/ZkAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export default class ZkAsset {
success,
outputNotes,
proofData,
...rest
} = await ConnectionService.query(
'constructProof',
{
Expand All @@ -447,14 +448,12 @@ export default class ZkAsset {
},
);

let proof;
if (proofData) {
proof = proofData
? await recoverJoinSplitProof(proofData)
: null;
}
const proof = proofData
? await recoverJoinSplitProof(rest.proof)
: null;

return {
...rest,
success,
outputNotes,
proof,
Expand Down
8 changes: 7 additions & 1 deletion packages/extension/src/ui/pages/Send.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Send = ({
numberOfOutputNotes,
inputNoteHashes,
userAccess,
returnProof,
}) => {
const fetchInitialData = async () => {
const gsnConfig = await getGSNConfig();
Expand All @@ -31,7 +32,10 @@ const Send = ({
const {
address: currentAddress,
} = currentAccount;
const steps = isGSNAvailable ? sendSteps.gsn : sendSteps.metamask;
let steps = isGSNAvailable ? sendSteps.gsn : sendSteps.metamask;
if (returnProof) {
steps = sendSteps.returnProof;
}
const sender = proxyContract;

const asset = await makeAsset(assetAddress);
Expand Down Expand Up @@ -77,13 +81,15 @@ Send.propTypes = {
numberOfOutputNotes: PropTypes.number,
inputNoteHashes: PropTypes.arrayOf(PropTypes.string),
userAccess: PropTypes.arrayOf(PropTypes.string),
returnProof: PropTypes.bool,
};

Send.defaultProps = {
numberOfInputNotes: emptyIntValue,
numberOfOutputNotes: emptyIntValue,
inputNoteHashes: [],
userAccess: [],
returnProof: false,
};

export default Send;
4 changes: 4 additions & 0 deletions packages/extension/src/ui/steps/createNoteFromBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const stepSendViaGSN = {
};

export default {
returnProof: {
stepApprove,
stepSign,
},
gsn: [
stepApprove,
stepSign,
Expand Down
4 changes: 4 additions & 0 deletions packages/extension/src/ui/steps/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const stepSendViaGSN = {
};

export default {
returnProof: [
stepApprove,
stepSignNotes,
],
gsn: [
stepApprove,
stepSignNotes,
Expand Down
4 changes: 4 additions & 0 deletions packages/extension/src/ui/steps/withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const stepSendViaGSN = {
};

export default {
returnProof: [
stepApprove,
stepSignNotes,
],
gsn: [
stepApprove,
stepSignNotes,
Expand Down

0 comments on commit c5eedba

Please sign in to comment.