Skip to content

Commit

Permalink
Add tips page + edit readme
Browse files Browse the repository at this point in the history
  • Loading branch information
atmoner committed Nov 5, 2023
1 parent 6df91f9 commit f3d5bd6
Show file tree
Hide file tree
Showing 18 changed files with 217 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

✨ Javascript example for cosmJs cosmos sdk

![App Screenshot](https://i.imgur.com/WikPlI6.png)
![CosmJs Examples](https://i.imgur.com/DANsWWJ.png)


## Installation
Expand Down
1 change: 1 addition & 0 deletions src/.vuepress/components/simpleConnect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
},
methods: {
async getClientNow() {
this.loaded = false
this.inLoading = true
try {
const mnemonic = await DirectSecp256k1HdWallet.generate(12)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default {
},
methods: {
async getBlockNow() {
this.loaded = false
this.inLoading = true
try {
const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmoshub')
Expand Down
1 change: 1 addition & 0 deletions src/.vuepress/components/simpleSign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default {
},
methods: {
async getSignNow() {
this.loaded = false
this.inLoading = true
const mnemonic = await DirectSecp256k1HdWallet.generate(12)
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic.secret.data)
Expand Down
82 changes: 82 additions & 0 deletions src/.vuepress/components/stargate/getBalance.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<div>
<button class="button" @click="getBalanceNow()">
<i v-if="!inLoading" class="fa fa-play" aria-hidden="true"></i>
<span v-if="!inLoading"> Try it</span>
<i v-if="inLoading" class="fa fa-spinner fa-spin" style="font-size:24px"></i>
</button>
</div>
<div v-if="loaded" class="language-javascript" data-ext="json">
<pre class="language-javascript"><code>{{ getBalance }}</code></pre>
</div>
<button v-if="loaded" class="buttonColse" @click="closeResulte()">
<i class="fa fa-times" aria-hidden="true"></i> Close result
</button>
</template>

<script>
import { StargateClient } from "@cosmjs/stargate"
export default {
data() {
return {
getBalance: '',
loaded: false,
inLoading: false
}
},
async mounted() {
},
methods: {
async getBalanceNow() {
this.inLoading = true
this.loaded = false
try {
const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmoshub')
const getBalance = await client.getBalance('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr', 'uatom')
this.getBalance = getBalance
this.loaded = true
this.inLoading = false
client.disconnect()
} catch (error) {
this.getBalance = "Error! Try again" + error
this.loaded = true
this.inLoading = false
}
},
closeResulte() {
this.loaded = false
}
}
}
</script>

<style>
.button {
display: block;
width: 100%;
border: none;
background-color: #343E51;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
text-align: center;
border-radius: 4px;
}
.buttonColse {
display: block;
width: 100%;
border: none;
background-color: #343E51;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
text-align: center;
border-radius: 4px;
}
</style>

76 changes: 76 additions & 0 deletions src/.vuepress/components/stargate/getBlock.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<template>
<div>
<button class="button" @click="getBlockNow()">
<i v-if="!inLoading" class="fa fa-play" aria-hidden="true"></i>
<span v-if="!inLoading"> Try it</span>
<i v-if="inLoading" class="fa fa-spinner fa-spin" style="font-size:24px"></i>
</button>
</div>
<div v-if="loaded" class="language-javascript" data-ext="json">
<pre class="language-javascript"><code>{{ getBlock }}</code></pre>
</div>
<button v-if="loaded" class="buttonColse" @click="closeResulte()">
<i class="fa fa-times" aria-hidden="true"></i> Close result
</button>
</template>

<script>
import { StargateClient } from "@cosmjs/stargate"
export default {
data() {
return {
getBlock: '',
loaded: false,
inLoading: false
}
},
async mounted() {
},
methods: {
async getBlockNow() {
this.inLoading = true
this.loaded = false
const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmoshub')
const getBlock = await client.getBlock()
console.log(getBlock.header)
this.getBlock = getBlock.header
this.loaded = true
this.inLoading = false
client.disconnect()
},
closeResulte() {
this.loaded = false
}
}
}
</script>

<style>
.button {
display: block;
width: 100%;
border: none;
background-color: #343E51;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
text-align: center;
border-radius: 4px;
}
.buttonColse {
display: block;
width: 100%;
border: none;
background-color: #343E51;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
text-align: center;
border-radius: 4px;
}
</style>

4 changes: 3 additions & 1 deletion src/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ export default defineUserConfig({
plugins: [
registerComponentsPlugin({
components: {
test: path.resolve(__dirname, './components/test.vue'),
simpleRpc: path.resolve(__dirname, './components/simpleRpc.vue'),
simpleSign: path.resolve(__dirname, './components/simpleSign.vue'),
simpleConnect: path.resolve(__dirname, './components/simpleConnect.vue'),
getBlock: path.resolve(__dirname, './components/stargate/getBlock.vue'),
getBalance: path.resolve(__dirname, './components/stargate/getBalance.vue'),
},
}),
]
Expand Down
3 changes: 2 additions & 1 deletion src/.vuepress/navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export default navbar([
"/",
"/stargate/",
"/query/",
"/broadcast/"
"/broadcast/",
"/tips/"
]);
7 changes: 7 additions & 0 deletions src/.vuepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export default sidebar({
prefix: "broadcast/",
link: "broadcast/",
children: "structure",
},
{
text: "Tips and tricks",
icon: "book",
prefix: "tips/",
link: "tips/",
children: "structure",
}
],
});
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ try {
console.log("Error! Try again")
}
```
<test />
<simpleRpc />

### Simple get signer

Expand Down
5 changes: 4 additions & 1 deletion src/broadcast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ index: false
copyright: false
---



::: info
This page will be completed soon
:::
6 changes: 4 additions & 2 deletions src/broadcast/authz.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
title: Authz tx
icon: file
order: 3
order: 2
copyright: false
---

# Authz tx

::: info
This page will be completed soon
:::

5 changes: 4 additions & 1 deletion src/broadcast/bank.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ title: Bank tx
icon: file
author: atmon3r
copyright: false
order: 1
---

# Bank tx


::: info
This page will be completed soon
:::
5 changes: 4 additions & 1 deletion src/broadcast/feegrant.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ copyright: false
---

# Feegrant tx


::: info
This page will be completed soon
:::
7 changes: 5 additions & 2 deletions src/broadcast/gov.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ icon: file
author: atmon3r
copyright: false
---
# Bank tx

# Gov tx

::: info
This page will be completed soon
:::
7 changes: 5 additions & 2 deletions src/broadcast/staking.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ icon: file
author: atmon3r
copyright: false
---
# Bank tx

# Staking tx

::: info
This page will be completed soon
:::
9 changes: 6 additions & 3 deletions src/stargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,27 @@ const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmos
const getBlock = await client.getBlock()
console.log(getBlock.header)
```
<getBlock />

### getBalance()

```js
const getBalance = await client.getBalance('your_address', 'uatom')
const getBalance = await client.getBalance('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr', 'uatom')
console.log(getBalance)
```
<getBalance />


### getAllBalances()

```js
const getAllBalances = await client.getAllBalances('your_address')
const getAllBalances = await client.getAllBalances('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr')
console.log(getAllBalances)
```

### getBalanceStaked()

```js
const getBalanceStaked = await client.getBalanceStaked('your_address')
const getBalanceStaked = await client.getBalanceStaked('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr')
console.log(getBalanceStaked)
```
10 changes: 10 additions & 0 deletions src/tips/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
home: false
title: Tips and trick
author: atmon3r
copyright: false
---

::: info
This page will be completed soon
:::

0 comments on commit f3d5bd6

Please sign in to comment.