Skip to content

Commit

Permalink
Merge pull request #6 from mymiracle0118/audit
Browse files Browse the repository at this point in the history
readme update
  • Loading branch information
mymiracle0118 authored Apr 20, 2024
2 parents 0722061 + 42d7013 commit 46e7796
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 69 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ optimize:
test:
cargo unit-test

WALLET=nibi10rdtquh3jl44hg00x0plzeawuclqqet0he4692
WALLET=nibi1uds8m92jzp465px8xjmuj4jmhcd5h2wsh404cl
AIRDROP_CONTRACT=nibi1hc3cl36mnty08e34cp6gy4rnej378w7qhrxjxxzq3jdm04qa5w5seqwemv
CODE_ID=436
WALLET_NAME=jarvis

make-wallet:
@nibid keys add wallet ${WALLET_NAME}
@nibid keys add ${WALLET_NAME}

show-wallet:
@nibid keys show -a ${WALLET}
Expand Down
120 changes: 53 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,71 @@
# CosmWasm Starter Pack
# Jarvis Airdrop

This is a template to build smart contracts in Rust to run inside a
[Cosmos SDK](https://github.com/cosmos/cosmos-sdk) module on all chains that enable it.
To understand the framework better, please read the overview in the
[cosmwasm repo](https://github.com/CosmWasm/cosmwasm/blob/master/README.md),
and dig into the [cosmwasm docs](https://www.cosmwasm.com).
This assumes you understand the theory and just want to get coding.
This is a airdrop contract.

## Creating a new repo from template
## Clone the repository

Assuming you have a recent version of Rust and Cargo installed
(via [rustup](https://rustup.rs/)),
then the following should get you a new repo to start a contract:
* `git clone [email protected]:mymiracle0118/jarvis-coswasm-nft-airdrop.git`
* `cd jarvis-coswasm-nft-airdrop`

Install [cargo-generate](https://github.com/ashleygwilliams/cargo-generate) and cargo-run-script.
Unless you did that before, run this line now:
## Environments for test on linux

```sh
cargo install cargo-generate --features vendored-openssl
cargo install cargo-run-script
```
* Install nibid
`curl -s https://get.nibiru.fi/! | bash`
* Set network config

Now, use it to create your new contract.
Go to the folder in which you want to place it and run:
`Testnet config` \
RPC_URL="https://rpc.testnet-1.nibiru.fi:443" \
nibid config node $RPC_URL \
nibid config chain-id nibiru-testnet-1 \
nibid config broadcast-mode sync \
nibid config # Prints your new config to verify correctness

**Latest**
`Mainnet config` \
RPC_URL="https://rpc.nibiru.fi:443" \
nibid config node $RPC_URL \
nibid config chain-id cataclysm-1 \
nibid config broadcast-mode sync \
nibid config # Prints your new config to verify correctness

```sh
cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME
```
## Wallet config
If you are already created wallet by using nibid, you dont need to try these commands but you have to save the values to makefile.

For cloning minimal code repo:
`make make-wallet` # create wallet named `jarvis`. And save wallet name to `WALLET_NAME` in makefile. default is 'jarvis'. you dont need change
`make show-wallet` # show your pub key of created wallet. And save pub key to `WALLET_ADDRESS` in makefile.
`make get-balance` # get balance of your wallet. you need to have some amount nibi in your wallet for test. you can send nibi to this wallet

```sh
cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME -d minimal=true
```
## Contract Deploy

You will now have a new folder called `PROJECT_NAME` (I hope you changed that to something else)
containing a simple working contract and build system that you can customize.
### Upload & Deploy contract
* `make upload-testnet` # upload wasm file on nibiru chain and get code_id by analyzing tx_hash. `.logs[0].events[1].attributes[1].value`. save it *CODE_ID* in makefile

## Create a Repo
* `make instantiage` # before using this command, you can change *instantiate.json* for your requirements and instantiate with `CODE_ID`. Save contract_address in `NFT_CONTRACT` of makefile. Contract address maybe is in `.logs[0].events[1].attributes[0].value` of tx

### !Confirm all variables are correct in makefile.
WALLET= # your wallet pub key
WALLET_NAME= # your wallet name, default is 'jarvis'
CODE_ID= # uploaded code_id
AIRDROP_CONTRACT= # deployed contract address

After generating, you have a initialized local git repo, but no commits, and no remote.
Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below).
Then run the following:
### Test
you can use these all commands. to use \
first, you can change related json file in commands folder for your requirements \
second, run this command by using make. `make command_name` \
in addition, you need to call set-functions before using get-functions

```sh
# this is needed to create a valid Cargo.lock file (see below)
cargo check
git branch -M main
git add .
git commit -m 'Initial Commit'
git remote add origin YOUR-GIT-URL
git push -u origin main
```
get-nft-contract-address:
$(eval GET_NFT_CONTRACT_ADDRESS := $$(shell cat ./commands/get_nft_contract_addr.json))
@nibid query wasm contract-state smart ${AIRDROP_CONTRACT} '$(GET_NFT_CONTRACT_ADDRESS)'

## CI Support
get-all-nfts:
$(eval GET_ALL_NFTS := $$(shell cat ./commands/get_all_nfts.json))
@nibid query wasm contract-state smart ${AIRDROP_CONTRACT} '$(GET_ALL_NFTS)'

We have template configurations for both [GitHub Actions](.github/workflows/Basic.yml)
and [Circle CI](.circleci/config.yml) in the generated project, so you can
get up and running with CI right away.
exe-set-nft-contract-addr:
$(eval SET_NFT_CONTRACT_ADDR := $$(shell cat ./commands/set_nft_contract_addr.json))
@nibid tx wasm execute ${AIRDROP_CONTRACT} '$(SET_NFT_CONTRACT_ADDR)' --from ${WALLET} --gas auto --gas-adjustment 1.5 --gas-prices 0.025unibi --yes

One note is that the CI runs all `cargo` commands
with `--locked` to ensure it uses the exact same versions as you have locally. This also means
you must have an up-to-date `Cargo.lock` file, which is not auto-generated.
The first time you set up the project (or after adding any dep), you should ensure the
`Cargo.lock` file is updated, so the CI will test properly. This can be done simply by
running `cargo check` or `cargo unit-test`.
exe-send-nfts:
$(eval SEND_NFTS := $$(shell cat ./commands/send_nfts.json))
@nibid tx wasm execute ${AIRDROP_CONTRACT} '$(SEND_NFTS)' --from ${WALLET} --gas auto --gas-adjustment 1.5 --gas-prices 0.025unibi --yes

## Using your project

Once you have your custom repo, you should check out [Developing](./Developing.md) to explain
more on how to run tests and develop code. Or go through the
[online tutorial](https://docs.cosmwasm.com/) to get a better feel
of how to develop.

[Publishing](./Publishing.md) contains useful information on how to publish your contract
to the world, once you are ready to deploy it on a running blockchain. And
[Importing](./Importing.md) contains information about pulling in other contracts or crates
that have been published.

Please replace this README file with information about your specific project. You can keep
the `Developing.md` and `Publishing.md` files as useful references, but please set some
proper description in the README.

0 comments on commit 46e7796

Please sign in to comment.