Skip to content

Commit

Permalink
feat: set bech32 prefix without changing source code (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 authored May 6, 2024
1 parent ac71d7b commit 82c81a2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality

- name: Build
run: make build
run: make build BECH32_PREFIX=rol

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm |
# Copy the remaining files
COPY . .

RUN make build
RUN make build BECH32_PREFIX=rol

FROM ubuntu:latest

Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
PROJECT_NAME=rollapp-wasm
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
ifndef BECH32_PREFIX
$(error BECH32_PREFIX is not set)
endif

# don't override user values
ifeq (,$(VERSION))
Expand All @@ -27,9 +30,8 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk \
-X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)


-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) \
-X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix=$(BECH32_PREFIX)

BUILD_FLAGS := -ldflags '$(ldflags)'

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ It uses Cosmos-SDK's [simapp](https://github.com/cosmos/cosmos-sdk/tree/main/sim
Build and install the ```rollapp-wasm``` binary:

```shell
make install
export BECH32_PREFIX=rol
make install BECH32_PREFIX=$BECH32_PREFIX
```

### Initial configuration
Expand All @@ -33,6 +34,7 @@ export the following variables:

```shell
export EXECUTABLE="rollapp-wasm"
export BECH32_PREFIX="rol"
export ROLLAPP_CHAIN_ID="rollappwasm_1234-1"
export KEY_NAME_ROLLAPP="rol-user"
export BASE_DENOM="awsm"
Expand Down
6 changes: 3 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ import (
)

const (
AccountAddressPrefix = "rol"
Name = "rollapp-wasm"
Name = "rollapp-wasm"
)

var (
kvstorekeys = []string{
AccountAddressPrefix string
kvstorekeys = []string{
authtypes.StoreKey, authzkeeper.StoreKey,
feegrant.StoreKey, banktypes.StoreKey,
stakingtypes.StoreKey, seqtypes.StoreKey,
Expand Down
18 changes: 16 additions & 2 deletions scripts/ibc/setup_ibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jq --arg key "$RELAYER_KEY_FOR_ROLLAPP" '.value.key = $key' $ROLLAPP_IBC_CONF_FI
jq --arg chain "$ROLLAPP_CHAIN_ID" '.value."chain-id" = $chain' $ROLLAPP_IBC_CONF_FILE >"$tmp" && mv "$tmp" $ROLLAPP_IBC_CONF_FILE
jq --arg rpc "$ROLLAPP_RPC_FOR_RELAYER" '.value."rpc-addr" = $rpc' $ROLLAPP_IBC_CONF_FILE >"$tmp" && mv "$tmp" $ROLLAPP_IBC_CONF_FILE
jq --arg denom "0.0$BASE_DENOM" '.value."gas-prices" = $denom' $ROLLAPP_IBC_CONF_FILE >"$tmp" && mv "$tmp" $ROLLAPP_IBC_CONF_FILE
jq --arg bech "$BECH32_PREFIX" '.value["account-prefix"] = $bech' "$ROLLAPP_IBC_CONF_FILE" >"$tmp" && mv "$tmp" "$ROLLAPP_IBC_CONF_FILE"

jq --arg key "$RELAYER_KEY_FOR_HUB" '.value.key = $key' $HUB_IBC_CONF_FILE >"$tmp" && mv "$tmp" $HUB_IBC_CONF_FILE
jq --arg chain "$SETTLEMENT_CHAIN_ID" '.value."chain-id" = $chain' $HUB_IBC_CONF_FILE >"$tmp" && mv "$tmp" $HUB_IBC_CONF_FILE
Expand All @@ -76,8 +77,21 @@ RLY_HUB_ADDR=$(rly keys show "$SETTLEMENT_CHAIN_ID")
RLY_ROLLAPP_ADDR=$(rly keys show "$ROLLAPP_CHAIN_ID")

echo '# -------------------------------- funding for rly account ------------------------------- #'
$SETTLEMENT_EXECUTABLE tx bank send $SETTLEMENT_KEY_NAME_GENESIS "$(rly keys show "$SETTLEMENT_CHAIN_ID")" 1000000000000000000000${SETTLEMENT_BASE_DENOM} --keyring-backend test --broadcast-mode block --fees 20000000000000${SETTLEMENT_BASE_DENOM} -y
$EXECUTABLE tx bank send $ROLLAPP_KEY_NAME_GENESIS "$(rly keys show "$ROLLAPP_CHAIN_ID")" 1000000000000000000000$BASE_DENOM --keyring-backend test --broadcast-mode block -y --node "$ROLLAPP_RPC_FOR_RELAYER"
DYM_BALANCE=$(${SETTLEMENT_EXECUTABLE} q bank balances ${RLY_HUB_ADDR} -o json | jq -r '.balances[0].amount')

if [ "$(echo "$DYM_BALANCE >= 100000000000000000000" | bc)" -eq 1 ]; then
echo "${RLY_HUB_ADDR} already funded"
else
"$SETTLEMENT_EXECUTABLE" tx bank send "$SETTLEMENT_KEY_NAME_GENESIS" "$RLY_HUB_ADDR" 100dym --keyring-backend test --broadcast-mode block --fees 1dym --node "$SETTLEMENT_RPC_FOR_RELAYER" -y
fi

RA_BALANCE=$(${EXECUTABLE} q bank balances ${RLY_ROLLAPP_ADDR} -o json | jq -r '.balances[0].amount')

if [ "$(echo "$RA_BALANCE >= 100000000000000000000" | bc)" -eq 1 ]; then
echo "${RLY_ROLLAPP_ADDR} already funded"
else
"$EXECUTABLE" tx bank send "$KEY_NAME_ROLLAPP" "$RLY_ROLLAPP_ADDR" 100000000000000000000"$BASE_DENOM" --keyring-backend test --broadcast-mode block -y --fees 4000000000$BASE_DENOM
fi

echo "# ------------------------------- balance of rly account on hub [$RLY_HUB_ADDR]------------------------------ #"
$SETTLEMENT_EXECUTABLE q bank balances "$(rly keys show "$SETTLEMENT_CHAIN_ID")"
Expand Down

0 comments on commit 82c81a2

Please sign in to comment.