fix(wallet): ensures legacy v1 modals handle JsonRpcError vs

JsonRpcResult
This commit is contained in:
Ben Kremer 2023-04-05 15:12:26 +02:00
parent c128875314
commit c699860663
3 changed files with 39 additions and 15 deletions

View File

@ -32,16 +32,24 @@ export default function LegacySessionSendTransactionModal() {
// Handle approve action
async function onApprove() {
if (requestEvent) {
const { result } = await approveEIP155Request({
const response = await approveEIP155Request({
id,
topic: '',
params: { request: { method, params }, chainId: '1' }
})
legacySignClient.approveRequest({
id,
result
})
if ('error' in response) {
legacySignClient.rejectRequest({
id,
error: response.error
})
} else {
legacySignClient.approveRequest({
id,
result: response.result
})
}
ModalStore.close()
}
}

View File

@ -28,16 +28,24 @@ export default function LegacySessionSignModal() {
// Handle approve action (logic varies based on request method)
async function onApprove() {
if (requestEvent) {
const { result } = await approveEIP155Request({
const response = await approveEIP155Request({
id,
topic: '',
params: { request: { method, params }, chainId: '1' }
})
legacySignClient.approveRequest({
id,
result
})
if ('error' in response) {
legacySignClient.rejectRequest({
id,
error: response.error
})
} else {
legacySignClient.approveRequest({
id,
result: response.result
})
}
ModalStore.close()
}
}

View File

@ -29,16 +29,24 @@ export default function LegacySessionSignTypedDataModal() {
// Handle approve action (logic varies based on request method)
async function onApprove() {
if (requestEvent) {
const { result } = await approveEIP155Request({
const response = await approveEIP155Request({
id,
topic: '',
params: { request: { method, params }, chainId: '1' }
})
legacySignClient.approveRequest({
id,
result
})
if ('error' in response) {
legacySignClient.rejectRequest({
id,
error: response.error
})
} else {
legacySignClient.approveRequest({
id,
result: response.result
})
}
ModalStore.close()
}
}