Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance deleting grace Period contracts UX #487

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/playground/src/weblets/tf_contracts_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
</v-btn>
</template>
</weblet-layout>

<v-dialog width="70%" v-model="deletingDialog">
<v-card>
<v-card-title class="text-h5"> Are you sure you want to delete the following contracts? </v-card-title>
<v-card-title class="text-h5 mt-2"> Are you sure you want to delete the following contracts? </v-card-title>
Mahmoud-Emad marked this conversation as resolved.
Show resolved Hide resolved
<v-alert class="ma-4" type="warning" variant="tonal">Deleting contracts may take a while to complete.</v-alert>
<v-card-text>
<v-chip class="ma-1" color="primary" label v-for="c in selectedContracts" :key="c.contractId">
{{ c.contractId }}
Expand Down Expand Up @@ -121,6 +121,9 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar variant="tonal" color="error" v-model="snackbar" :timeout="5000">
Failed to delete some keys, You don't have enough tokens
</v-snackbar>
</template>

<script lang="ts" setup>
Expand Down Expand Up @@ -204,7 +207,7 @@ async function contractLockDetails(contractId: number) {
});
loading.value = false;
}

const snackbar = ref(false);
const deletingDialog = ref(false);
const contractStateDialog = ref(false);
const deleting = ref(false);
Expand All @@ -223,7 +226,13 @@ async function onDelete() {
contracts.value = contracts.value!.filter(c => !selectedContracts.value.includes(c));
selectedContracts.value = [];
} catch (e) {
layout.value.setStatus("failed", normalizeError(e, `Failed to delete some of the selected contracts.`));
if ((e as Error).message.includes("Inability to pay some fees")) {
Mahmoud-Emad marked this conversation as resolved.
Show resolved Hide resolved
contracts.value = contracts.value!.filter(c => !selectedContracts.value.includes(c));
selectedContracts.value = [];
snackbar.value = true;
} else {
layout.value.setStatus("failed", normalizeError(e, `Failed to delete some of the selected contracts.`));
}
}
deleting.value = false;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/tfchain_client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ class Client extends QueryClient {
try {
const nonce = await this.api.rpc.system.accountNextIndex(this.address);
if (this.keypair) {
extrinsic.signAndSend(this.keypair, { nonce }, callback);
await extrinsic.signAndSend(this.keypair, { nonce }, callback);
} else if (this.extSigner) {
extrinsic.signAndSend(this.address, { nonce, signer: this.extSigner.signer }, callback);
await extrinsic.signAndSend(this.address, { nonce, signer: this.extSigner.signer }, callback);
}
} catch (e) {
reject(e);
Expand All @@ -335,7 +335,7 @@ class Client extends QueryClient {
section = resultSections[0];
throw Error(
`Failed to apply ${JSON.stringify(extrinsic.method.toHuman())} due to error: ${
Object.keys(this.api.errors[section])[+e]
Object.keys(this.api.errors[section])[+e] ?? e
}`,
);
});
Expand Down