Pass back didAutoApprove flag in sign transaction response
This commit is contained in:
parent
2ce2dc8859
commit
e24db3dfde
|
@ -119,10 +119,10 @@ export default function PopupPage({ opener }) {
|
||||||
? [bs58.decode(request.params.message)]
|
? [bs58.decode(request.params.message)]
|
||||||
: request.params.messages.map((m) => bs58.decode(m));
|
: request.params.messages.map((m) => bs58.decode(m));
|
||||||
|
|
||||||
async function onApprove() {
|
async function onApprove(didAutoApprove) {
|
||||||
setRequests((requests) => requests.slice(1));
|
setRequests((requests) => requests.slice(1));
|
||||||
if (request.method === 'signTransaction') {
|
if (request.method === 'signTransaction') {
|
||||||
sendSignature(messages[0]);
|
sendSignature(messages[0], didAutoApprove);
|
||||||
} else {
|
} else {
|
||||||
sendAllSignatures(messages);
|
sendAllSignatures(messages);
|
||||||
}
|
}
|
||||||
|
@ -131,17 +131,18 @@ export default function PopupPage({ opener }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendSignature(message) {
|
async function sendSignature(message, didAutoApprove) {
|
||||||
postMessage({
|
postMessage({
|
||||||
result: {
|
result: {
|
||||||
signature: await wallet.createSignature(message),
|
signature: await wallet.createSignature(message),
|
||||||
publicKey: wallet.publicKey.toBase58(),
|
publicKey: wallet.publicKey.toBase58(),
|
||||||
|
didAutoApprove,
|
||||||
},
|
},
|
||||||
id: request.id,
|
id: request.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendAllSignatures(messages) {
|
async function sendAllSignatures(messages, didAutoApprove) {
|
||||||
const signatures = await Promise.all(
|
const signatures = await Promise.all(
|
||||||
messages.map((m) => wallet.createSignature(m)),
|
messages.map((m) => wallet.createSignature(m)),
|
||||||
);
|
);
|
||||||
|
@ -149,6 +150,7 @@ export default function PopupPage({ opener }) {
|
||||||
result: {
|
result: {
|
||||||
signatures,
|
signatures,
|
||||||
publicKey: wallet.publicKey.toBase58(),
|
publicKey: wallet.publicKey.toBase58(),
|
||||||
|
didAutoApprove,
|
||||||
},
|
},
|
||||||
id: request.id,
|
id: request.id,
|
||||||
});
|
});
|
||||||
|
@ -435,8 +437,10 @@ function ApproveSignatureForm({
|
||||||
};
|
};
|
||||||
}, [publicKeys, txInstructions, wallet]);
|
}, [publicKeys, txInstructions, wallet]);
|
||||||
|
|
||||||
|
const didAutoApprove = validator.safe && autoApprove;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (validator.safe && autoApprove) {
|
if (didAutoApprove) {
|
||||||
console.log('Auto approving safe transaction');
|
console.log('Auto approving safe transaction');
|
||||||
onApprove();
|
onApprove();
|
||||||
} else {
|
} else {
|
||||||
|
@ -596,7 +600,7 @@ function ApproveSignatureForm({
|
||||||
className={classes.approveButton}
|
className={classes.approveButton}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={onApprove}
|
onClick={() => onApprove(didAutoApprove)}
|
||||||
>
|
>
|
||||||
Approve{isMultiTx ? ' All' : ''}
|
Approve{isMultiTx ? ' All' : ''}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Reference in New Issue