diff --git a/README.md b/README.md index ba6a5bd..cc4ad29 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/.vuepress/components/simpleConnect.vue b/src/.vuepress/components/simpleConnect.vue index 9ccb8cb..061727a 100644 --- a/src/.vuepress/components/simpleConnect.vue +++ b/src/.vuepress/components/simpleConnect.vue @@ -28,6 +28,7 @@ export default { }, methods: { async getClientNow() { + this.loaded = false this.inLoading = true try { const mnemonic = await DirectSecp256k1HdWallet.generate(12) @@ -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 diff --git a/src/.vuepress/components/test.vue b/src/.vuepress/components/simpleRpc.vue similarity index 97% rename from src/.vuepress/components/test.vue rename to src/.vuepress/components/simpleRpc.vue index d6f0ce5..3e6c9e2 100644 --- a/src/.vuepress/components/test.vue +++ b/src/.vuepress/components/simpleRpc.vue @@ -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') @@ -37,7 +38,7 @@ export default { this.getBlock = getBlock.header this.loaded = true this.inLoading = false - client.disconnect(); + client.disconnect() } catch (error) { this.getBlock = "Error! Try again" this.loaded = true diff --git a/src/.vuepress/components/simpleSign.vue b/src/.vuepress/components/simpleSign.vue index bfc4719..b6963f1 100644 --- a/src/.vuepress/components/simpleSign.vue +++ b/src/.vuepress/components/simpleSign.vue @@ -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 diff --git a/src/.vuepress/components/stargate/getBalance.vue b/src/.vuepress/components/stargate/getBalance.vue new file mode 100644 index 0000000..f09dd8e --- /dev/null +++ b/src/.vuepress/components/stargate/getBalance.vue @@ -0,0 +1,82 @@ + + + + + + diff --git a/src/.vuepress/components/stargate/getBlock.vue b/src/.vuepress/components/stargate/getBlock.vue new file mode 100644 index 0000000..4cc40a4 --- /dev/null +++ b/src/.vuepress/components/stargate/getBlock.vue @@ -0,0 +1,76 @@ + + + + + + diff --git a/src/.vuepress/config.ts b/src/.vuepress/config.ts index 0969361..e6845c1 100644 --- a/src/.vuepress/config.ts +++ b/src/.vuepress/config.ts @@ -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'), }, }), ] diff --git a/src/.vuepress/navbar.ts b/src/.vuepress/navbar.ts index 27b41d3..81d5bce 100644 --- a/src/.vuepress/navbar.ts +++ b/src/.vuepress/navbar.ts @@ -4,5 +4,6 @@ export default navbar([ "/", "/stargate/", "/query/", - "/broadcast/" + "/broadcast/", + "/tips/" ]); diff --git a/src/.vuepress/sidebar.ts b/src/.vuepress/sidebar.ts index b715fff..b9edeb6 100644 --- a/src/.vuepress/sidebar.ts +++ b/src/.vuepress/sidebar.ts @@ -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", } ], }); diff --git a/src/README.md b/src/README.md index 002c9be..ab0cc05 100644 --- a/src/README.md +++ b/src/README.md @@ -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") } ``` - + ### Simple get signer @@ -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 @@ -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") +} + + + ``` ::: diff --git a/src/broadcast/README.md b/src/broadcast/README.md index 439ce18..7614d82 100644 --- a/src/broadcast/README.md +++ b/src/broadcast/README.md @@ -9,4 +9,7 @@ index: false copyright: false --- - \ No newline at end of file + +::: info +This page will be completed soon +::: \ No newline at end of file diff --git a/src/broadcast/authz.md b/src/broadcast/authz.md index cc70b0d..db1d77a 100644 --- a/src/broadcast/authz.md +++ b/src/broadcast/authz.md @@ -1,10 +1,12 @@ --- title: Authz tx icon: file -order: 3 +order: 2 copyright: false --- # Authz tx - +::: info +This page will be completed soon +::: \ No newline at end of file diff --git a/src/broadcast/bank.md b/src/broadcast/bank.md index e6b4f4b..4b60688 100644 --- a/src/broadcast/bank.md +++ b/src/broadcast/bank.md @@ -3,8 +3,11 @@ title: Bank tx icon: file author: atmon3r copyright: false +order: 1 --- # Bank tx - \ No newline at end of file +::: info +This page will be completed soon +::: \ No newline at end of file diff --git a/src/broadcast/feegrant.md b/src/broadcast/feegrant.md index bbab075..5bb93fa 100644 --- a/src/broadcast/feegrant.md +++ b/src/broadcast/feegrant.md @@ -6,4 +6,7 @@ copyright: false --- # Feegrant tx - \ No newline at end of file + +::: info +This page will be completed soon +::: \ No newline at end of file diff --git a/src/broadcast/gov.md b/src/broadcast/gov.md index ba2f097..db38170 100644 --- a/src/broadcast/gov.md +++ b/src/broadcast/gov.md @@ -4,5 +4,8 @@ icon: file author: atmon3r copyright: false --- -# Bank tx - \ No newline at end of file +# Gov tx + +::: info +This page will be completed soon +::: \ No newline at end of file diff --git a/src/broadcast/staking.md b/src/broadcast/staking.md index 239a6a3..5c3d12c 100644 --- a/src/broadcast/staking.md +++ b/src/broadcast/staking.md @@ -4,5 +4,8 @@ icon: file author: atmon3r copyright: false --- -# Bank tx - \ No newline at end of file +# Staking tx + +::: info +This page will be completed soon +::: \ No newline at end of file diff --git a/src/stargate/README.md b/src/stargate/README.md index 0ed2c4a..2f8d81f 100644 --- a/src/stargate/README.md +++ b/src/stargate/README.md @@ -40,24 +40,27 @@ const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmos const getBlock = await client.getBlock() console.log(getBlock.header) ``` + ### getBalance() ```js -const getBalance = await client.getBalance('your_address', 'uatom') +const getBalance = await client.getBalance('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr', 'uatom') console.log(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) ``` diff --git a/src/tips/README.md b/src/tips/README.md new file mode 100644 index 0000000..00f1052 --- /dev/null +++ b/src/tips/README.md @@ -0,0 +1,10 @@ +--- +home: false +title: Tips and trick +author: atmon3r +copyright: false +--- + +::: info +This page will be completed soon +::: \ No newline at end of file