Skip to content

Commit

Permalink
Apply improvements (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
abefernan committed Oct 27, 2021
1 parent 7e7ab39 commit ab1655d
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 54 deletions.
159 changes: 106 additions & 53 deletions src/App/pages/DocumentationPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { isMobile } from "react-device-detect";
import {
ContentWrapper,
PageWrapper,
ReferenceList,
RequirementList,
StyledItemGroup,
StyledMenu,
StyledMenuItem,
Expand All @@ -21,22 +23,60 @@ export default function DocumentationPage(): JSX.Element | null {
<StyledSubmenu key="sub1" icon={undefined} title="Introduction">
<StyledItemGroup key="g1" title="Smart Contracts">
<StyledMenuItem key="1">
<a href="#installation">Installation</a>
<a href="#requirements">Hardware Requirements</a>
</StyledMenuItem>
<StyledMenuItem key="2">
<a href="#environment">Setting Up the Environment</a>
<a href="#installation">Installation</a>
</StyledMenuItem>
<StyledMenuItem key="3">
<a href="#compiling">Optimizing the Compilation</a>
<a href="#environment">Setting Up the Environment</a>
</StyledMenuItem>
<StyledMenuItem key="4">
<a href="#compiling">Optimizing the Compilation</a>
</StyledMenuItem>
<StyledMenuItem key="5">
<a href="#uploading">Uploading and Verifying</a>
</StyledMenuItem>
</StyledItemGroup>
</StyledSubmenu>
</StyledMenu>
)}
<ContentWrapper isMobile={isMobile}>
<Title id="requirements">Hardware Requirements</Title>
<Text>For deploying smart contracts. We tested successfully with the following Architecture:</Text>
<RequirementList>
<li>Ubuntu 20.04 LTS</li>
<li>go version 1.16.5 [1]</li>
<li>Installed packages make and build-essential [2] [3]</li>
<li>2 or more CPU cores Intel or AMD chipset</li>
<li>At least 40GB of disk storage</li>
<li>At least 4GB of memory (RAM)</li>
</RequirementList>
<ReferenceList>
<li>
<a href="https://github.com/golang/go/wiki/Ubuntu" target="_blank" rel="noopener noreferrer">
https://github.com/golang/go/wiki/Ubuntu
</a>
</li>
<li>
<a href="https://packages.ubuntu.com/focal/make" target="_blank" rel="noopener noreferrer">
https://packages.ubuntu.com/focal/make
</a>
</li>
<li>
<a
href="https://packages.ubuntu.com/focal/build-essential"
target="_blank"
rel="noopener noreferrer"
>
https://packages.ubuntu.com/focal/build-essential
</a>
</li>
</ReferenceList>
<Text>
You can use a physical infrastructure (baremetal) or wellknown cloud providers like: DigitalOcean,
AWS, Google Cloud Platform, among others
</Text>
<Title id="installation">Installation</Title>
<Text>
In this section, we will gear up your workhorse for developing, deploying and, enjoying smart
Expand Down Expand Up @@ -70,12 +110,12 @@ export default function DocumentationPage(): JSX.Element | null {
</Text>
<CopyBlock
text={`
rustup default stable
cargo version
rustup update stable
rustup default stable
cargo version
rustup update stable
rustup target list --installed
rustup target add wasm32-unknown-unknown
rustup target list --installed
rustup target add wasm32-unknown-unknown
`}
language={"shell"}
showLineNumbers={false}
Expand All @@ -93,18 +133,31 @@ export default function DocumentationPage(): JSX.Element | null {
</Text>
<CopyBlock
text={`
git clone https://github.com/CosmWasm/wasmd.git
cd wasmd
# replace the v0.18.0 with the most stable version on https://github.com/CosmWasm/wasmd/releases
git checkout v0.18.0
make install
go install -mod=readonly
-ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=tgrade -X github.com/CosmWasm/wasmd/app.Bech32Prefix=tgrade"
# Get wasmd v0.18,0 ( that is the version we verified and tested)
wget https://github.com/CosmWasm/wasmd/archive/refs/tags/v0.18.0.tar.gz
tar xzvf v0.18.0.tar.gz
cd wasmd-0.18.0
# Run GO install for the upcoming binary,
# all those flags option will made wasmd available to run tgarde addresses
go install -mod=readonly -ldflags \\
"-X github.com/cosmos/cosmos-sdk/version.Name=tgrade \\
-X github.com/cosmos/cosmos-sdk/version.AppName=tgrade \\
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=tgrade" \\
./cmd/wasmd
# Build the binary
go build -mod=readonly -ldflags \\
"-X github.com/cosmos/cosmos-sdk/version.Name=tgrade \\
-X github.com/cosmos/cosmos-sdk/version.AppName=tgrade \\
-X github.com/CosmWasm/wasmd/app.Bech32Prefix=tgrade" \\
-o build/wasmd ./cmd/wasmd
# Move the binary to an executable path
sudo mv build/wasmd /usr/local/bin
# verify the installation
wasmd version
# verify the installation
wasmd version
`}
language={"shell"}
showLineNumbers={false}
Expand Down Expand Up @@ -147,7 +200,7 @@ export default function DocumentationPage(): JSX.Element | null {
</Text>
<Text>First, source the testnet-2 network configurations to the shell:</Text>
<CopyBlock
text={` source <(curl -sSL https://gist.githubusercontent.com/orkunkl/773e1798dc04ac7d06f468a778e90db6/raw/747290af38420138c1179ec3ce7d89f28e3accca/testnet-2_defaults.env)`}
text={`source <(curl -sSL https://gist.githubusercontent.com/orkunkl/773e1798dc04ac7d06f468a778e90db6/raw/747290af38420138c1179ec3ce7d89f28e3accca/testnet-2_defaults.env)`}
language={"shell"}
showLineNumbers={false}
theme={monokai}
Expand All @@ -156,16 +209,16 @@ export default function DocumentationPage(): JSX.Element | null {
<Text>Setup the client:</Text>
<CopyBlock
text={`
# add wallets for testing
wasmd keys add wallet
>
{
"name": "wallet",
"type": "local",
"address": "tgrade13nt9rxj7v2ly096hm8qsyfjzg5pr7vn5saqd50",
"pubkey": "tgradepub1addwnpepqf4n9afaefugnfztg7udk50duwr4n8p7pwcjlm9tuumtlux5vud6qvfgp9g",
"mnemonic": "hobby bunker rotate piano satoshi planet network verify else market spring toward pledge turkey tip slim word jaguar congress thumb flag project chalk inspire"
}
# add wallets for testing
wasmd keys add wallet
>
{
"name": "wallet",
"type": "local",
"address": "tgrade13nt9rxj7v2ly096hm8qsyfjzg5pr7vn5saqd50",
"pubkey": "tgradepub1addwnpepqf4n9afaefugnfztg7udk50duwr4n8p7pwcjlm9tuumtlux5vud6qvfgp9g",
"mnemonic": "hobby bunker rotate piano satoshi planet network verify else market spring toward pledge turkey tip slim word jaguar congress thumb flag project chalk inspire"
}
`}
language={"shell"}
showLineNumbers={false}
Expand All @@ -174,7 +227,7 @@ export default function DocumentationPage(): JSX.Element | null {
/>
<Text>You need some tokens in your address to interact. Requesting tokens from faucet:</Text>
<CopyBlock
text={` JSON=$(jq -n --arg addr $(wasmd keys show -a wallet) '{"denom":"utgd","address":$addr}') && curl -X POST --header "Content-Type: application/json" --data "$JSON" https://faucet.testnet-2.tgrade.io/credit`}
text={`JSON=$(jq -n --arg addr $(wasmd keys show -a wallet) '{"denom":"utgd","address":$addr}') && curl -X POST --header "Content-Type: application/json" --data "$JSON" https://faucet.testnet-2.tgrade.io/credit`}
language={"shell"}
showLineNumbers={false}
theme={monokai}
Expand All @@ -184,13 +237,13 @@ export default function DocumentationPage(): JSX.Element | null {
<Text>Export wasmd variables for setting up node endpoint and transaction configuration:</Text>
<CopyBlock
text={`
# bash
export NODE="--node $RPC"
export TXFLAG="\${NODE} --chain-id \${CHAIN_ID} --gas-prices 0.001utgd --gas auto --gas-adjustment 1.3"
# bash
export NODE="--node $RPC"
export TXFLAG="\${NODE} --chain-id \${CHAIN_ID} --gas-prices 0.001utgd --gas auto --gas-adjustment 1.3"
# zsh
export NODE=(--node $RPC)
export TXFLAG=($NODE --chain-id $CHAIN_ID --gas-prices 0.001utgd --gas auto --gas-adjustment 1.3)
# zsh
export NODE=(--node $RPC)
export TXFLAG=($NODE --chain-id $CHAIN_ID --gas-prices 0.001utgd --gas auto --gas-adjustment 1.3)
`}
language={"shell"}
showLineNumbers={false}
Expand All @@ -201,7 +254,7 @@ export default function DocumentationPage(): JSX.Element | null {
If command above throws error, this means your shell is different. If no errors, try running this:
</Text>
<CopyBlock
text={` wasmd query bank total $NODE`}
text={`wasmd query bank total $NODE`}
language={"shell"}
showLineNumbers={false}
theme={monokai}
Expand All @@ -221,10 +274,10 @@ export default function DocumentationPage(): JSX.Element | null {
</Text>
<CopyBlock
text={`
docker run --rm -v "$(pwd)":/code
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry
cosmwasm/rust-optimizer:0.11.5
docker run --rm -v "$(pwd)":/code \\
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \\
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \\
cosmwasm/rust-optimizer:0.11.5
`}
language={"shell"}
showLineNumbers={false}
Expand All @@ -239,22 +292,22 @@ export default function DocumentationPage(): JSX.Element | null {
</Text>
<CopyBlock
text={`
# see how many codes we have now
wasmd query wasm list-code $NODE
# see how many codes we have now
wasmd query wasm list-code $NODE
# gas is huge due to wasm size... but auto-zipping reduced this from 1.8M to around 600k
# you can see the code in the result
RES=$(wasmd tx wasm store artifacts/mycontract.wasm --from wallet $TXFLAG -y)
# gas is huge due to wasm size... but auto-zipping reduced this from 1.8M to around 600k
# you can see the code in the result
RES=$(wasmd tx wasm store artifacts/mycontract.wasm --from wallet $TXFLAG -y)
# you can also get the code this way
CODE_ID=$(echo $RES | jq -r '.logs[0].events[-1].attributes[0].value')
# you can also get the code this way
CODE_ID=$(echo $RES | jq -r '.logs[0].events[-1].attributes[0].value')
# no contracts yet, this should return an empty list
wasmd query wasm list-contract-by-code $CODE_ID $NODE --output json
# no contracts yet, this should return an empty list
wasmd query wasm list-contract-by-code $CODE_ID $NODE --output json
# you can also download the wasm from the chain and check that the diff between them is empty
wasmd query wasm code $CODE_ID $NODE download.wasm
diff artifacts/mycontract.wasm download.wasm
# you can also download the wasm from the chain and check that the diff between them is empty
wasmd query wasm code $CODE_ID $NODE download.wasm
diff artifacts/mycontract.wasm download.wasm
`}
language={"shell"}
showLineNumbers={false}
Expand Down
25 changes: 24 additions & 1 deletion src/App/pages/DocumentationPage/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,35 @@ export const ContentWrapper = styled.div<StyledProps>`
flex-direction: column;
justify-content: flex-start;
margin-left: ${(props) => (props.isMobile ? "5px" : "245px")};
padding: ${(props) => (props.isMobile ? "5px" : "50")};
padding: ${(props) => (props.isMobile ? "5px" : "50px")};
& div {
margin-bottom: 25px;
}
`;

export const RequirementList = styled.ul`
&[class] {
margin: var(--s-2);
list-style-type: "- ";
}
`;

export const ReferenceList = styled.ol`
&[class] {
margin: var(--s-2) 0;
counter-reset: bracket-counter;
& li {
counter-increment: bracket-counter;
&::before {
content: "[" counter(bracket-counter) "] ";
}
}
}
`;

export const StyledMenuItem = styled(Menu.Item)`
color: #fff;
& .ant-menu-item-active {
Expand Down

0 comments on commit ab1655d

Please sign in to comment.