Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteenkamp89 committed Mar 31, 2024
1 parent 8bf005c commit 7f5adef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
8 changes: 0 additions & 8 deletions src/plugins/oSnap/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,6 @@ watch(
}
);
watch(
newPluginData,
plugin => {
update(plugin);
},
{ deep: true }
);
onMounted(async () => {
isLoading.value = true;
safes.value = await createOsnapEnabledSafes();
Expand Down
42 changes: 22 additions & 20 deletions src/plugins/oSnap/components/TransactionBuilder/SafeImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { isAddress } from '@ethersproject/address';
const props = defineProps<{
transaction: SafeImportTransaction;
network: Network;
setTransactionAsInvalid(): void;
}>();
const emit = defineEmits<{
updateTransaction: [transaction: SafeImportTransaction];
}>();
const transaction = ref<SafeImportTransaction>(props.transaction);
const isValueValid = ref(true);
const isToValid = computed(() => {
Expand All @@ -25,20 +25,23 @@ const isToValid = computed(() => {
});
function updateFinalTransaction(tx: Partial<SafeImportTransaction>) {
emit('updateTransaction', {
...props.transaction,
const _tx = {
...transaction.value,
...tx
});
};
transaction.value = _tx;
formatTransaction();
}
function updateParams(paramsToUpdate: SafeImportTransaction['parameters']) {
emit('updateTransaction', {
...props.transaction,
const tx = {
...transaction.value,
parameters: {
...props.transaction?.parameters,
...transaction.value?.parameters,
...paramsToUpdate
}
});
};
updateFinalTransaction(tx);
}
function updateValue(newValue: string) {
Expand All @@ -54,34 +57,33 @@ function updateValue(newValue: string) {
} catch (error) {
isValueValid.value = false;
} finally {
updateTransaction();
formatTransaction();
}
}
function updateTransaction() {
function formatTransaction() {
try {
if (!props.transaction) {
throw new Error('No Transaction selected');
}
if (!isValueValid.value) {
throw new Error('"Value" field is invalid');
}
if (!isToValid.value) {
throw new Error('"To" field is invalid');
}
// attempt to finalize and format
const tx = createSafeImportTransaction(props.transaction);
const tx = createSafeImportTransaction(transaction.value);
console.log(tx);
emit('updateTransaction', tx);
} catch (error) {
console.error(error);
props.setTransactionAsInvalid();
} catch {
emit('updateTransaction', {
...transaction.value,
isValid: false
});
}
}
onMounted(updateTransaction);
onMounted(formatTransaction);
watch(isToValid, formatTransaction);
watch(isValueValid, formatTransaction);
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { cloneDeep } from 'lodash';
import {
ContractInteractionTransaction,
TransferNftTransaction,
Expand Down Expand Up @@ -113,7 +112,6 @@ function setTransactionAsInvalid() {
v-if="transaction.type === 'safeImport'"
:transaction="transaction as SafeImportTransaction"
:network="network"
:setTransactionAsInvalid="setTransactionAsInvalid"
@update-transaction="updateTransaction"
/>
</div>
Expand Down

0 comments on commit 7f5adef

Please sign in to comment.