Skip to content

Commit

Permalink
Merge pull request #5 from atmoner/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
atmoner authored Nov 5, 2023
2 parents c1addf1 + f3d5bd6 commit 46a56c7
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 40 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
3 changes: 2 additions & 1 deletion 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 All @@ -43,7 +44,7 @@ export default {
this.getClient = client
this.loaded = true
this.inLoading = false
client.disconnect();
client.disconnect()
} catch (error) {
this.getClient = "Error! Try again"
this.loaded = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ export default {
},
methods: {
async getBlockNow() {
this.loaded = false
this.inLoading = true
try {
const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmoshub')
const getBlock = await client.getBlock()
this.getBlock = getBlock.header
this.loaded = true
this.inLoading = false
client.disconnect();
client.disconnect()
} catch (error) {
this.getBlock = "Error! Try again"
this.loaded = true
Expand Down
5 changes: 3 additions & 2 deletions src/.vuepress/components/simpleSign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ 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)
const client = await SigningStargateClient.connectWithSigner('https://rpc.cosmos.directory/cosmoshub', wallet)
const accounts = await wallet.getAccounts();
const accounts = await wallet.getAccounts()
this.getSign = accounts
this.loaded = true
this.inLoading = false
client.disconnect();
client.disconnect()
},
closeResulte() {
this.loaded = false
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",
}
],
});
58 changes: 37 additions & 21 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ try {
const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmoshub')
const getBlock = await client.getBlock()
console.log(getBlock.header)
client.disconnect()
} catch (e) {
console.log("Error! Try again")
}
```
<test />
<simpleRpc />

### Simple get signer

Expand Down Expand Up @@ -89,15 +90,21 @@ import { SigningStargateClient, GasPrice } from "@cosmjs/stargate"
const mnemonic = await DirectSecp256k1HdWallet.generate(12)
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic.secret.data)

const client = await SigningStargateClient.connectWithSigner(
'https://rpc.cosmos.directory/cosmoshub',
wallet,
{
gasPrice: GasPrice.fromString('0.0025uatom'),
}
)
try {
const client = await SigningStargateClient.connectWithSigner(
'https://rpc.cosmos.directory/cosmoshub',
wallet,
{
gasPrice: GasPrice.fromString('0.0025uatom'),
}
)
console.log(client)
client.disconnect()
} catch (e) {
console.log("Error! Try again")
}


console.log(client)
```

@tab offline signer
Expand All @@ -106,18 +113,27 @@ console.log(client)
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"
import { SigningStargateClient, GasPrice } from "@cosmjs/stargate"

const chainId = "cosmoshub-4"
await window.keplr.enable(chainId)
const offlineSigner = await window.getOfflineSignerAuto(chainId)
const client = await SigningStargateClient.connectWithSigner(
'https://rpc.cosmos.directory/cosmoshub',
offlineSigner,
{
gasPrice: GasPrice.fromString('0.0025uatom'),
}
)

console.log(client)

try {
const chainId = "cosmoshub-4"
await window.keplr.enable(chainId)
const offlineSigner = await window.getOfflineSignerAuto(chainId)
const client = await SigningStargateClient.connectWithSigner(
'https://rpc.cosmos.directory/cosmoshub',
offlineSigner,
{
gasPrice: GasPrice.fromString('0.0025uatom'),
}
)

console.log(client)
client.disconnect()
} catch (e) {
console.log("Error! Try again")
}



```
:::

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
:::
Loading

0 comments on commit 46a56c7

Please sign in to comment.