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

Commit

Permalink
feat(sdk): batch sign notes for withdraw proof
Browse files Browse the repository at this point in the history
  • Loading branch information
LeilaWang committed Feb 20, 2020
1 parent ec8b548 commit 6e35486
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
11 changes: 9 additions & 2 deletions packages/extension/src/ui/apis/asset/confidentialTransferFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export default async function confidentialTransferFrom({
proof,
signature = '0x',
spender,
isGSNAvailable,
}) {
const proofData = proof.encodeABI(assetAddress);
const response = await ConnectionService.sendTransaction({
const transactionData = {
contract: 'AccountRegistry',
method: 'confidentialTransferFrom',
data: [
Expand All @@ -24,7 +25,13 @@ export default async function confidentialTransferFrom({
spender,
signature,
],
});
};
const response = isGSNAvailable
? await ConnectionService.sendTransaction(transactionData)
: await ConnectionService.post({
action: 'metamask.send',
data: transactionData,
});

return {
...response,
Expand Down
4 changes: 3 additions & 1 deletion packages/extension/src/ui/pages/Withdraw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ const Withdraw = ({
proxyContract,
} = gsnConfig;
const steps = isGSNAvailable ? withdrawSteps.gsn : withdrawSteps.metamask;
const sender = isGSNAvailable ? proxyContract : currentAddress;
const sender = proxyContract;
const asset = await makeAsset(assetAddress);

return {
steps,
retryWithMetaMaskStep: withdrawSteps.metamask.slice(-1)[0],
assetAddress,
asset,
currentAddress,
Expand All @@ -43,6 +44,7 @@ const Withdraw = ({
spender: sender,
sender,
numberOfInputNotes,
isGSNAvailable,
};
};

Expand Down
16 changes: 3 additions & 13 deletions packages/extension/src/ui/steps/withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,13 @@ const stepSignNotes = {
tasks: [
{
type: 'sign',
run: apis.note.signNotes,
run: apis.note.signProof,
},
],
autoStart: true,
submitTextKey: 'transaction.sign.submit',
};

const stepSignNotesForGSN = {
...stepSignNotes,
tasks: [
{
type: 'sign',
run: apis.note.signProof,
},
],
};

const stepConfirm = {
name: 'confirm',
blockStyle: 'collapsed',
Expand Down Expand Up @@ -65,7 +55,7 @@ const stepSend = {
{
titleKey: 'withdraw.send.step',
type: 'sign',
run: apis.asset.confidentialTransfer,
run: apis.asset.confidentialTransferFrom,
},
{
titleKey: 'transaction.confirmed',
Expand Down Expand Up @@ -105,7 +95,7 @@ const stepSendViaGSN = {
export default {
gsn: [
stepApprove,
stepSignNotesForGSN,
stepSignNotes,
stepConfirmViaGSN,
stepSendViaGSN,
],
Expand Down

0 comments on commit 6e35486

Please sign in to comment.