From 7b203da5fbd622588dbcb31196f42d256c03fd21 Mon Sep 17 00:00:00 2001
From: mtyszczak <mateusz.tyszczak@gmail.com>
Date: Thu, 13 Mar 2025 13:33:57 +0100
Subject: [PATCH] Allow broadcasting signed transaction

---
 .../utilcards/ConfirmAccountUpdateCard.vue         |  1 +
 .../utilcards/ConfirmCreateAccountCard.vue         |  1 +
 src/components/utilcards/SignTransactionCard.vue   | 14 +++++++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/components/utilcards/ConfirmAccountUpdateCard.vue b/src/components/utilcards/ConfirmAccountUpdateCard.vue
index 44755b9..8a1bc9e 100644
--- a/src/components/utilcards/ConfirmAccountUpdateCard.vue
+++ b/src/components/utilcards/ConfirmAccountUpdateCard.vue
@@ -87,6 +87,7 @@ const updateAuthority = async() => {
           <Input id="updateAuthority_ownerKey" placeholder="Nothing to add" v-model="ownerKey" class="my-2" />
         </div>
         <Button class="my-2" @click="updateAuthority">Update Authority</Button>
+        <p>Note: By clicking the above button, the transaction will be created, signed, and broadcasted immediately to the mainnet chain</p>
       </div>
     </CardContent>
   </Card>
diff --git a/src/components/utilcards/ConfirmCreateAccountCard.vue b/src/components/utilcards/ConfirmCreateAccountCard.vue
index be55531..26b178e 100644
--- a/src/components/utilcards/ConfirmCreateAccountCard.vue
+++ b/src/components/utilcards/ConfirmCreateAccountCard.vue
@@ -168,6 +168,7 @@ const createAccount = async() => {
           </div>
         </RadioGroup>
         <Button @click="createAccount">Create account</Button>
+        <p>Note: By clicking the above button, the transaction will be created, signed, and broadcasted immediately to the mainnet chain</p>
       </div>
     </CardContent>
   </Card>
diff --git a/src/components/utilcards/SignTransactionCard.vue b/src/components/utilcards/SignTransactionCard.vue
index b5b1c20..8f8f2ae 100644
--- a/src/components/utilcards/SignTransactionCard.vue
+++ b/src/components/utilcards/SignTransactionCard.vue
@@ -36,6 +36,15 @@ const sign = async () => {
   outputData.value = await wallet.value!.signTransaction(tx, authorityLevel);
 };
 
+const broadcast = async () => {
+  const wax = await getWax();
+
+  const tx = wax.createTransactionFromJson(inputData.value);
+  tx.sign(outputData.value);
+
+  wax.broadcast(tx);
+};
+
 onMounted(() => {
   inputData.value = decodeURIComponent(atob(router.currentRoute.value.query.data as string ?? ''));
 });
@@ -55,7 +64,10 @@ onMounted(() => {
       <div class="my-4 space-x-4">
         <Button :disabled="!hasWallet" @click="sign">Sign transaction</Button>
       </div>
-      <Textarea v-model="outputData" placeholder="Signed Transaction output" copy-enabled class="my-4" disabled/>
+      <Textarea v-model="outputData" placeholder="Signature" copy-enabled class="my-4" disabled/>
+      <div class="my-4 space-x-4">
+        <Button :disabled="!outputData" @click="broadcast">Broadcast signed transaction</Button>
+      </div>
     </CardContent>
   </Card>
 </template>
\ No newline at end of file
-- 
GitLab