-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<robo-layout-section> | ||
<robo-section offset="x2" width="narrow"> | ||
<h3>The-Rise-of-Humanoids</h3> | ||
</robo-section> | ||
|
||
<template v-if="RobonomicsProvider.isReady"> | ||
<robonomics-launch /> | ||
</template> | ||
<template v-else>...</template> | ||
</robo-layout-section> | ||
</template> | ||
|
||
<script setup> | ||
import { inject } from "vue"; | ||
import RobonomicsLaunch from "./RobonomicsLaunch.vue"; | ||
const RobonomicsProvider = inject("RobonomicsProvider"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<template> | ||
<robo-section offset="x2" width="narrow"> | ||
<robo-section offset="x3"> | ||
<robo-select | ||
block | ||
:values="commands.map((item) => item.value)" | ||
:options="commands.map((item) => item.name)" | ||
v-model="parameter" | ||
/> | ||
<robo-button @click="send" block :loading="proccess">Send</robo-button> | ||
<robo-text weight="bold" v-if="result">{{ result }}</robo-text> | ||
<robo-text highlight="error" v-if="error">{{ error }}</robo-text> | ||
</robo-section> | ||
</robo-section> | ||
</template> | ||
|
||
<script> | ||
import { ref, inject } from "vue"; | ||
import * as config from "./config"; | ||
export default { | ||
setup() { | ||
const RobonomicsProvider = inject("RobonomicsProvider"); | ||
const proccess = ref(false); | ||
const result = ref(null); | ||
const error = ref(null); | ||
const commands = ref(config.listOfCommands); | ||
const parameter = ref(config.listOfCommands[0].value); | ||
const unsubscribe = ref(null); | ||
const send = async () => { | ||
error.value = ""; | ||
result.value = ""; | ||
proccess.value = true; | ||
try { | ||
const txs = [ | ||
RobonomicsProvider.instance.value.api.tx.balances.transfer( | ||
config.robot, | ||
config.price | ||
), | ||
RobonomicsProvider.instance.value.launch.send( | ||
config.robot, | ||
parameter.value | ||
) | ||
]; | ||
const tx = RobonomicsProvider.instance.value.api.tx.utility.batch(txs); | ||
const resultTx = | ||
await RobonomicsProvider.instance.value.accountManager.signAndSend( | ||
tx | ||
); | ||
console.log("saved", resultTx); | ||
result.value = `${resultTx.blockNumber}-${resultTx.txIndex}`; | ||
} catch (error) { | ||
console.log(error); | ||
error.value = error.message; | ||
} | ||
proccess.value = false; | ||
}; | ||
return { | ||
proccess, | ||
result, | ||
error, | ||
commands, | ||
parameter, | ||
unsubscribe, | ||
send | ||
}; | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const price = 1_000_000_000; | ||
export const robot = "4GzMLepDF5nKTWDM6XpB3CrBcFmwgazcVFAD3ZBNAjKT6hQJ"; | ||
export const listOfCommands = [ | ||
{ | ||
name: "A", | ||
value: "0x0000000000000000000000000000000000000000000000000000000000000001" | ||
}, | ||
{ | ||
name: "B", | ||
value: "0x0000000000000000000000000000000000000000000000000000000000000002" | ||
}, | ||
{ | ||
name: "C", | ||
value: "0x0000000000000000000000000000000000000000000000000000000000000003" | ||
} | ||
]; |