Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/cosmwasm types #5

Open
wants to merge 152 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
5f6fe6f
add deprecation to specific struct & fns
iboss-ptk Nov 14, 2022
b8bb07c
use transformer parse and append option as macro
iboss-ptk Nov 15, 2022
660ba88
update deps to osmosis v13.0.0-rc4
iboss-ptk Nov 29, 2022
d2f5e09
twap example
iboss-ptk Nov 11, 2022
fb79d48
update to osmosis v13.0.0-rc5
iboss-ptk Dec 1, 2022
819a8cc
update to v13.1.1
iboss-ptk Dec 8, 2022
1917ebb
Merge pull request #62 from osmosis-labs/osmosis-v13
iboss-ptk Dec 8, 2022
41a7778
fix wrong NulError report
iboss-ptk Dec 9, 2022
5221273
update deps
iboss-ptk Dec 9, 2022
52b564b
bump to v0.13.2
iboss-ptk Dec 9, 2022
9d7a711
test gh workflow
iboss-ptk Dec 13, 2022
5640195
update workflows
iboss-ptk Dec 13, 2022
59c7b59
make version choice
iboss-ptk Dec 13, 2022
0bba18a
run proto build on workflow
iboss-ptk Dec 13, 2022
b8789e0
checkout before run
iboss-ptk Dec 13, 2022
3c17a1e
[workflow] remove ls
iboss-ptk Dec 13, 2022
6c217d9
[workflow] setup cargo cache
iboss-ptk Dec 13, 2022
abe3c8a
rebuild with 7568297
iboss-ptk Dec 13, 2022
02d4ea4
rebuild with 28234a5
iboss-ptk Dec 13, 2022
dff6413
update script to be more robust
iboss-ptk Dec 13, 2022
e3efadd
rebuild with 4176b28
iboss-ptk Dec 13, 2022
f36896a
[workdlow][debug] cat main.rs
iboss-ptk Dec 13, 2022
e334878
[workdlow][debug] ignore sigint on tee
iboss-ptk Dec 13, 2022
596aa7a
[workdlow][debug] remove cat
iboss-ptk Dec 13, 2022
8f8b8aa
[workdlow][debug] diff
iboss-ptk Dec 13, 2022
2809fcb
[workdlow][debug] sed -i
iboss-ptk Dec 13, 2022
6b34be0
[workdlow][debug] add git config for bot
iboss-ptk Dec 13, 2022
f925bd8
[workflow] rename and add workflow call
iboss-ptk Dec 14, 2022
6f9c0fb
[workflow] check updates
iboss-ptk Dec 14, 2022
3753963
[workflow] add fix
iboss-ptk Dec 14, 2022
5a6f081
fix
iboss-ptk Dec 14, 2022
b54797b
fix2
iboss-ptk Dec 14, 2022
4537949
clone via shell
iboss-ptk Dec 14, 2022
1a2502a
fix
iboss-ptk Dec 14, 2022
13420ce
try check using submodule
iboss-ptk Dec 14, 2022
357fd04
specific for main build
iboss-ptk Dec 14, 2022
7cd204b
check
iboss-ptk Dec 14, 2022
75b460d
follow doc
iboss-ptk Dec 14, 2022
4465b92
fix
iboss-ptk Dec 14, 2022
15cae9e
fix
iboss-ptk Dec 14, 2022
2244240
change cron from 5mins to 1 hr
iboss-ptk Dec 14, 2022
6d1b34f
[workflow] test dynamic matrix
iboss-ptk Dec 15, 2022
b18b06b
[workflow] fix output scope
iboss-ptk Dec 15, 2022
2870626
[workflow] update from deprecated set-output
iboss-ptk Dec 15, 2022
08e2c2f
[workflow] checks for new stuffs after latest tag
iboss-ptk Dec 15, 2022
1594ae7
[workflow] checkout before run
iboss-ptk Dec 15, 2022
188450f
[workflow] init submodule
iboss-ptk Dec 15, 2022
cc40037
[workflow] cd back to root before commit
iboss-ptk Dec 15, 2022
97c5724
[workflow] check diff before trying to commit
iboss-ptk Dec 15, 2022
6540d2a
Update README.md
iboss-ptk Dec 15, 2022
6188054
rebuild with 4176b28
github-actions[bot] Dec 16, 2022
353bb09
Merge pull request #63 from osmosis-labs/autobuild-main
iboss-ptk Dec 16, 2022
65ae368
ensure endblock is being called even when execution fail
iboss-ptk Dec 16, 2022
68708f2
Merge pull request #64 from osmosis-labs/endblock-on-error
iboss-ptk Dec 16, 2022
18037e9
Update README.md according to #40
iboss-ptk Dec 16, 2022
3c8c03d
Update latest osmosis tag timestamp to 1671225434
github-actions[bot] Dec 20, 2022
dd9a914
Update latest osmosis tag timestamp to 1671655935
github-actions[bot] Dec 22, 2022
454e48d
Update latest osmosis tag timestamp to 1671721476
github-actions[bot] Dec 23, 2022
d012f4a
Update latest osmosis tag timestamp to 1671818502
github-actions[bot] Dec 24, 2022
08c6041
Update latest osmosis tag timestamp to 1672566788
github-actions[bot] Jan 2, 2023
c49a0dc
update rebuild osmosis testing
iboss-ptk Jan 3, 2023
e3de116
rebuild with 1c6c3c0
iboss-ptk Jan 3, 2023
9de55ef
rebuild with 1c6c3c0
iboss-ptk Jan 3, 2023
17cb0a4
getting the right version
iboss-ptk Jan 3, 2023
b5daf06
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
c088f63
update gh action go version to 1.19
iboss-ptk Jan 3, 2023
a4362ab
fix yaml
iboss-ptk Jan 3, 2023
74dd491
remove latest tag timestamp to reset workflow
iboss-ptk Jan 3, 2023
df9148a
trick update timestamp
iboss-ptk Jan 3, 2023
bf9c31f
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
7654b3d
update script
iboss-ptk Jan 3, 2023
9a9e1f7
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
f49dad6
Update latest osmosis tag timestamp to 1672715714
iboss-ptk Jan 3, 2023
60212d6
make latest osmosis tag older
iboss-ptk Jan 3, 2023
7dfa536
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
4526063
fitler only 13++ or main
iboss-ptk Jan 3, 2023
2ea8a7f
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
0704d8e
no strip origin
iboss-ptk Jan 3, 2023
1e81669
>= latest
iboss-ptk Jan 3, 2023
0e8c77f
Update latest osmosis tag timestamp to 1672715714
iboss-ptk Jan 3, 2023
24b0631
older timestamp
iboss-ptk Jan 3, 2023
c1524f3
remove exit
iboss-ptk Jan 3, 2023
4cc6c93
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
2ac211b
add origin main
iboss-ptk Jan 3, 2023
de39063
older lastest tag
iboss-ptk Jan 3, 2023
6ada002
Update latest osmosis tag timestamp to 1672706303
github-actions[bot] Jan 3, 2023
23bd438
rebuild with 1c6c3c0
github-actions[bot] Jan 3, 2023
ed138de
make geometric twap works
iboss-ptk Jan 3, 2023
5f2493a
go get from libosmosistesting
iboss-ptk Jan 3, 2023
abd689d
rebuild with 1c6c3c0
github-actions[bot] Jan 5, 2023
6d89b60
Update latest osmosis tag timestamp to 1673105747
github-actions[bot] Jan 8, 2023
ff71e58
Update latest osmosis tag timestamp to 1673367355
github-actions[bot] Jan 11, 2023
902ff9a
Update README.md
iboss-ptk Jan 11, 2023
730c9f0
Update latest osmosis tag timestamp to 1673450503
github-actions[bot] Jan 12, 2023
d24284c
Update latest osmosis tag timestamp to 1673513119
github-actions[bot] Jan 13, 2023
5510df0
Update latest osmosis tag timestamp to 1673367355
github-actions[bot] Jan 15, 2023
23fde0e
add authz
iboss-ptk Jan 16, 2023
72b27d7
add mod authz
iboss-ptk Jan 17, 2023
3aae799
Update latest osmosis tag timestamp to 1673971085
github-actions[bot] Jan 18, 2023
5d8891e
add ID alias
iboss-ptk Jan 18, 2023
5b2705d
update osmosis versionc
iboss-ptk Jan 27, 2023
718577d
alias PertiodLock ID
iboss-ptk Jan 27, 2023
6ce540b
update with new lockup params
iboss-ptk Feb 8, 2023
b96cc52
alias id
iboss-ptk Feb 8, 2023
73a92b1
Update latest osmosis tag timestamp to 1675945037
github-actions[bot] Feb 10, 2023
1b67225
Fix: typos
omahs Feb 11, 2023
bbbbb63
Fix: typos
omahs Feb 11, 2023
0631b2b
Fix: typos
omahs Feb 11, 2023
2e9ee09
Fix: typos
omahs Feb 11, 2023
b83ccc8
Fix: typo
omahs Feb 11, 2023
2cdb18f
Fix: typos
omahs Feb 11, 2023
504c506
Merge pull request #66 from omahs/patch-1
iboss-ptk Feb 13, 2023
e55c3ae
Update latest osmosis tag timestamp to 1676473083
github-actions[bot] Feb 16, 2023
63e5468
Update latest osmosis tag timestamp to 1676918026
github-actions[bot] Feb 21, 2023
e3c402b
add alias ID and exclude abci
iboss-ptk Feb 24, 2023
14be9fb
Merge pull request #67 from osmosis-labs/authz
iboss-ptk Feb 24, 2023
4a76e19
Update latest osmosis tag timestamp to 1677246806
github-actions[bot] Feb 25, 2023
aa044b3
Update latest osmosis tag timestamp to 1677626706
github-actions[bot] Mar 1, 2023
09077b6
Update latest osmosis tag timestamp to 1677686162
github-actions[bot] Mar 2, 2023
5a7d651
Update latest osmosis tag timestamp to 1677874810
github-actions[bot] Mar 5, 2023
1b71d4e
add additional field test
iboss-ptk Mar 6, 2023
bda281b
Merge pull request #69 from osmosis-labs/additional-field-tests
iboss-ptk Mar 6, 2023
681a6d0
Update latest osmosis tag timestamp to 1678137645
github-actions[bot] Mar 7, 2023
0aeaafe
Update latest osmosis tag timestamp to 1678220834
github-actions[bot] Mar 8, 2023
8d65c6a
use buf to perform generation instead of pure prost
iboss-ptk Mar 10, 2023
8d6f6fb
install buf on github action
iboss-ptk Mar 10, 2023
b95c82c
add proper name to generate code step
iboss-ptk Mar 10, 2023
de0617e
remove osmosis-testing updates
iboss-ptk Mar 10, 2023
19873fe
Merge pull request #71 from osmosis-labs/buf-replacement
iboss-ptk Mar 10, 2023
a6f3e52
Update latest osmosis tag timestamp to 1678471069
github-actions[bot] Mar 11, 2023
355861f
remove private imports
larry0x Mar 14, 2023
9e3ee07
Merge pull request #72 from larry0x/bump-to-latest
iboss-ptk Mar 15, 2023
c939447
rebuild with 3ffb10f
github-actions[bot] Mar 28, 2023
6841a23
rebuild with 3ffb10f
iboss-ptk Mar 10, 2023
765f391
rebuild with a55bbb9
github-actions[bot] Apr 5, 2023
7616cb6
feat: Generate types for cosmwasm
apollo-sturdy Mar 29, 2023
cae052d
add utils for converting cosmwasm coins/osmosis std coins
iboss-ptk Apr 10, 2023
421a509
Merge pull request #78 from osmosis-labs/coins-conversion
iboss-ptk Apr 10, 2023
d6bfba3
Remove osmosis testing
iboss-ptk Apr 10, 2023
61b0879
update v0.15.1
iboss-ptk Apr 10, 2023
895526d
bump version and add main back
iboss-ptk Apr 10, 2023
3d53e6a
rebuild with 087a97b
github-actions[bot] Apr 11, 2023
4a5ca9a
add alias generation for all _id fields
iboss-ptk Apr 12, 2023
fc08232
rebuild with b01fd3e
iboss-ptk Apr 12, 2023
b49394b
bump version to 0.15.2
iboss-ptk Apr 12, 2023
6447b50
update main with new generator logic
iboss-ptk Apr 12, 2023
e3043a8
Update latest osmosis tag timestamp to 1681930256
github-actions[bot] Apr 20, 2023
f726d5f
Update latest osmosis tag timestamp to 1682002311
github-actions[bot] Apr 21, 2023
b0860d0
Update latest osmosis tag timestamp to 1682524082
github-actions[bot] Apr 27, 2023
a139d47
Update latest osmosis tag timestamp to 1682958492
github-actions[bot] May 2, 2023
36170cc
fix: Fix repeated names in type url
apollo-sturdy May 12, 2023
9bb297a
Merge pull request #6 from osmosis-labs/main
apollo-sturdy May 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/schedule-check-and-dispatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: schedule check and dispatch
on:
workflow_dispatch:
name: manula trigger
schedule:
- cron: "* 1 * * *"

jobs:
populate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3

- id: set-matrix
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
./scripts/check-updates.sh

call-update-and-rebuild:
needs: populate-matrix
strategy:
matrix: ${{fromJson(needs.populate-matrix.outputs.matrix)}}
uses: ./.github/workflows/update-and-rebuild.yaml
with:
osmosis_rev: ${{ matrix.target }}
60 changes: 60 additions & 0 deletions .github/workflows/update-and-rebuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: update and rebuild
on:
workflow_dispatch:
name: update and rebuild
inputs:
osmosis_rev:
description: "osmosis revision"
required: true
type: string

workflow_call:
inputs:
osmosis_rev:
required: true
type: string

env:
CARGO_TERM_COLORS: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ">=1.19.0"

- name: Install buf
run: |
GO111MODULE=on go install github.com/bufbuild/buf/cmd/[email protected]

- name: Checkout
uses: actions/checkout@v3

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Generate code
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

# buf is installed in GOPATH
export PATH=${PATH}:`go env GOPATH`/bin

./scripts/update-and-rebuild.sh "$OSMOSIS_REV"

env:
OSMOSIS_REV: ${{ inputs.osmosis_rev }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
debug/
target/
artifacts/
!packages/osmosis-testing/libosmosistesting/artifacts

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
[submodule "dependencies/osmosis"]
path = dependencies/osmosis
url = https://github.com/osmosis-labs/osmosis.git
branch = v13.x
branch = v13.x
[submodule "wasmd"]
path = dependencies/wasmd
url = https://github.com/CosmWasm/wasmd.git
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> :information_desk_person: If you want to use latest update from osmosis' main branch, checkout `autobuild-main` branch.

# osmosis-rust

Rust libraries for Osmosis. The following table shows every published crates maintained in this repository:
Expand All @@ -6,4 +8,9 @@ Rust libraries for Osmosis. The following table shows every published crates mai
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| [osmosis-std](packages/osmosis-std) | Osmosis's proto-generated types and helpers for interacting with the appchain. Compatible with CosmWasm contract. | [![osmosis-std on crates.io](https://img.shields.io/crates/v/osmosis-std.svg)](https://crates.io/crates/osmosis-std) | [![Docs](https://docs.rs/osmosis-std/badge.svg)](https://docs.rs/osmosis-std) |
| [osmosis-std-derive](packages/osmosis-std-derive) | Procedural macro for augmenting proto-generated types to create better developer ergonomics. Internally used by `osmosis-std` | [![osmosis-std-derive on crates.io](https://img.shields.io/crates/v/osmosis-std-derive.svg)](https://crates.io/crates/osmosis-std-derive) | [![Docs](https://docs.rs/osmosis-std-derive/badge.svg)](https://docs.rs/osmosis-std-derive) |
| [osmosis-testing](packages/osmosis-testing) | CosmWasm x Osmosis integration testing library that, unlike `cw-multi-test`, it allows you to test your cosmwasm contract against real chain's logic instead of mocks. | [![osmosis-testing on crates.io](https://img.shields.io/crates/v/osmosis-testing.svg)](https://crates.io/crates/osmosis-testing) | [![Docs](https://docs.rs/osmosis-testing/badge.svg)](https://docs.rs/osmosis-testing) |
| [osmosis-testing]()(🚩DEPRECATED IN FAVOR OF [`osmosis-test-tube`](https://github.com/osmosis-labs/test-tube/tree/main/packages/osmosis-test-tube)) | CosmWasm x Osmosis integration testing library that, unlike `cw-multi-test`, it allows you to test your cosmwasm contract against real chain's logic instead of mocks. | [![osmosis-testing on crates.io](https://img.shields.io/crates/v/osmosis-testing.svg)](https://crates.io/crates/osmosis-testing) | [![Docs](https://docs.rs/osmosis-testing/badge.svg)](https://docs.rs/osmosis-testing) |


---

This repo also contains [`proto-build`](./packages/proto-build) package which is used for autogenrating rust types from proto.
2 changes: 1 addition & 1 deletion dependencies/osmosis
Submodule osmosis updated 1194 files
1 change: 1 addition & 0 deletions dependencies/wasmd
Submodule wasmd added at a347ac
4 changes: 2 additions & 2 deletions examples/cosmwasm/contracts/osmosis-stargate/Developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ reproducible build process, so third parties can verify that the uploaded Wasm
code did indeed come from the claimed rust code.

To solve both these issues, we have produced `rust-optimizer`, a docker image to
produce an extremely small build output in a consistent manner. The suggest way
produce an extremely small build output in a consistent manner. The suggested way
to run it is this:

```sh
Expand All @@ -85,7 +85,7 @@ docker run --rm -v "$(pwd)":/code \
cosmwasm/rust-optimizer-arm64:0.12.6
```

We must mount the contract code to `/code`. You can use a absolute path instead
We must mount the contract code to `/code`. You can use an absolute path instead
of `$(pwd)` if you don't want to `cd` to the directory first. The other two
volumes are nice for speedup. Mounting `/code/target` in particular is useful
to avoid docker overwriting your local dev files with root permissions.
Expand Down
4 changes: 2 additions & 2 deletions examples/cosmwasm/contracts/osmosis-stargate/Importing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ any uploaded contract.

## Reviewing

Once you have done the quick programatic checks, it is good to give at least a quick
look through the code. A glance at `examples/schema.rs` to make sure it is outputing
Once you have done the quick programmatic checks, it is good to give at least a quick
look through the code. A glance at `examples/schema.rs` to make sure it is outputting
all relevant structs from `contract.rs`, and also ensure `src/lib.rs` is just the
default wrapper (nothing funny going on there). After this point, we can dive into
the contract code itself. Check the flows for the execute methods, any invariants and
Expand Down
4 changes: 2 additions & 2 deletions examples/cosmwasm/contracts/osmosis-stargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ containing a simple working contract and build system that you can customize.

## Create a Repo

After generating, you have a initialized local git repo, but no commits, and no remote.
After generating, you have an 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:

Expand Down Expand Up @@ -96,5 +96,5 @@ to the world, once you are ready to deploy it on a running blockchain. And
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 referenced, but please set some
the `Developing.md` and `Publishing.md` files as useful references, but please set some
proper description in the README.
17 changes: 17 additions & 0 deletions osmosis-rust.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"folders": [
{
"path": "."
},
{
"path": "packages/osmosis-std"
},
{
"path": "packages/osmosis-std-derive"
},
{
"path": "packages/proto-build"
}
],
"settings": {}
}
2 changes: 1 addition & 1 deletion packages/osmosis-std-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description = "Procedural macro for osmosis-std"
edition = "2021"
license = "MIT OR Apache-2.0"
name = "osmosis-std-derive"
version = "0.12.0"
version = "0.15.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
10 changes: 6 additions & 4 deletions packages/osmosis-std-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
}).into()
}

fn get_type_url(attrs: &Vec<syn::Attribute>) -> proc_macro2::TokenStream {
fn get_type_url(attrs: &[syn::Attribute]) -> proc_macro2::TokenStream {
let proto_message = get_attr("proto_message", attrs).and_then(|a| a.parse_meta().ok());

if let Some(syn::Meta::List(meta)) = proto_message.clone() {
Expand All @@ -146,7 +146,7 @@ fn get_type_url(attrs: &Vec<syn::Attribute>) -> proc_macro2::TokenStream {
}
}

fn get_query_attrs<F>(attrs: &Vec<syn::Attribute>, f: F) -> proc_macro2::TokenStream
fn get_query_attrs<F>(attrs: &[syn::Attribute], f: F) -> proc_macro2::TokenStream
where
F: FnMut(&Vec<TokenTree>) -> Option<proc_macro2::TokenStream>,
{
Expand Down Expand Up @@ -185,8 +185,10 @@ where
}
}

fn get_attr<'a>(attr_ident: &str, attrs: &'a Vec<syn::Attribute>) -> Option<&'a syn::Attribute> {
attrs.iter().find(|&attr| attr.path.segments.len() == 1 && attr.path.segments[0].ident == attr_ident)
fn get_attr<'a>(attr_ident: &str, attrs: &'a [syn::Attribute]) -> Option<&'a syn::Attribute> {
attrs
.iter()
.find(|&attr| attr.path.segments.len() == 1 && attr.path.segments[0].ident == attr_ident)
}

fn proto_message_attr_error<T: quote::ToTokens>(tokens: T) -> proc_macro2::TokenStream {
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ description = "Standard library for Osmosis with CosmWasm support included"
edition = "2021"
license = "MIT OR Apache-2.0"
name = "osmosis-std"
version = "0.12.0"
version = "0.15.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = {version = "0.4.22", default-features = false}
cosmwasm-std = {version = "1.1.2", features = ["stargate"]}
osmosis-std-derive = {version = "0.12.0", path = "../osmosis-std-derive"}
osmosis-std-derive = {version = "0.15.2", path = "../osmosis-std-derive"}
prost = {version = "0.11.0", default-features = false, features = ["prost-derive"]}
prost-types = {version = "0.11.1", default-features = false}
schemars = "0.8.8"
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use osmosis_std::types::osmosis::tokenfactory::v1beta1::MsgCreateDenom;
pub fn try_create_denom(env: Env, subdenom: String) -> Result<Response, ContractError> {
let sender = env.contract.address.into();

// construct message and convet them into cosmos message
// construct message and convert them into cosmos message
// (notice `CosmosMsg` type and `.into()`)
let msg_create_denom: CosmosMsg = MsgCreateDenom { sender, subdenom }.into();

Expand All @@ -35,7 +35,7 @@ pub fn try_create_denom(env: Env, subdenom: String) -> Result<Response, Contract

## Querying Osmosis' module

Each module has their own querier that derived from protobuf service definition that can be found [here](https://github.com/osmosis-labs/osmosis/tree/v12.1.0/proto/osmosis).
Each module has its own querier that derived from protobuf service definition that can be found [here](https://github.com/osmosis-labs/osmosis/tree/v12.1.0/proto/osmosis).

To avoid non-determinism in stargate queries, only some of them are whitelisted, you can find the list [here](https://github.com/osmosis-labs/osmosis/blob/v12.1.0/wasmbinding/stargate_whitelist.go).

Expand Down
2 changes: 2 additions & 0 deletions packages/osmosis-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ pub const OSMOSISD_VERSION: &str = include_str!("types/OSMOSIS_COMMIT");
mod serde;
pub mod shim;
pub mod types;

pub use shim::{cosmwasm_to_proto_coins, try_proto_to_cosmwasm_coins};
43 changes: 42 additions & 1 deletion packages/osmosis-std/src/shim.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use ::serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
use chrono::{DateTime, NaiveDateTime, Utc};
use cosmwasm_std::StdResult;
use serde::de;
use serde::de::Visitor;

use std::fmt;
use std::str::FromStr;

use prost::Message;

use std::iter::FromIterator;
#[derive(Clone, PartialEq, Eq, ::prost::Message, schemars::JsonSchema)]
pub struct Timestamp {
/// Represents seconds of UTC time since Unix epoch
Expand Down Expand Up @@ -341,3 +342,43 @@ impl TryFrom<crate::types::cosmos::base::v1beta1::Coin> for cosmwasm_std::Coin {
})
}
}

/// Convert a list of `Coin` from osmosis proto generated proto `Coin` type to cosmwasm `Coin` type
pub fn try_proto_to_cosmwasm_coins(
coins: impl IntoIterator<Item = crate::types::cosmos::base::v1beta1::Coin>,
) -> StdResult<Vec<cosmwasm_std::Coin>> {
coins.into_iter().map(|c| c.try_into()).collect()
}

/// Convert a list of `Coin` from cosmwasm `Coin` type to osmosis proto generated proto `Coin` type
pub fn cosmwasm_to_proto_coins(
coins: impl IntoIterator<Item = cosmwasm_std::Coin>,
) -> Vec<crate::types::cosmos::base::v1beta1::Coin> {
coins.into_iter().map(|c| c.into()).collect()
}

#[cfg(test)]
mod tests {
use cosmwasm_std::Uint128;

use super::*;

#[test]
fn test_coins_conversion() {
let coins = vec![
cosmwasm_std::Coin {
denom: "uatom".to_string(),
amount: Uint128::new(100),
},
cosmwasm_std::Coin {
denom: "uosmo".to_string(),
amount: Uint128::new(200),
},
];

let proto_coins = cosmwasm_to_proto_coins(coins.clone());
let cosmwasm_coins = try_proto_to_cosmwasm_coins(proto_coins).unwrap();

assert_eq!(coins, cosmwasm_coins);
}
}
2 changes: 1 addition & 1 deletion packages/osmosis-std/src/types/OSMOSIS_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v13.0.0-rc2
origin/main
Loading