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

multitoken transfer and query #359

Merged
merged 7 commits into from
Oct 13, 2022
Merged

multitoken transfer and query #359

merged 7 commits into from
Oct 13, 2022

Conversation

yito88
Copy link
Member

@yito88 yito88 commented Aug 20, 2022

closes #132

split #297 which has lots IBC related changes

based on #442

@yito88
Copy link
Member Author

yito88 commented Aug 20, 2022

pls update wasm

Comment on lines 146 to 173
match token::is_any_multitoken_balance_key(&key) {
Some((sub_prefix, o)) if *o == owner => {
writeln!(
w,
"{} with {}: {}",
currency_code, sub_prefix, balance
)
.unwrap();
found_any = true;
}
Some(_) => {}
None => {
if let Some(o) =
token::is_any_token_balance_key(&key)
{
if *o == owner {
writeln!(
w,
"{}: {}",
currency_code, balance
)
.unwrap();
found_any = true;
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block exists three times identically. Maybe use a helper func

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added print_balances func.

// token, balance, owner
return None;
}
match key.get_at(len - 2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use ? and I think it will simplify the code a bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I tried to use a delimiter to simplify it.

Some(DbKeySeg::StringSeg(balance))
if balance == BALANCE_STORAGE_KEY =>
{
match key.segments.last() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, ? should tighten this up

@yito88 yito88 mentioned this pull request Aug 21, 2022
@yito88 yito88 requested a review from batconjurer August 23, 2022 10:56
);
None
}
Err(_) => None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we ignore the error here now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question!
query_storage_prefix is called for the balance read.
The error message frequently appears when the validity predicate is read even though we want to read just Amount.
I think it is more readable without the error message.

batconjurer
batconjurer previously approved these changes Aug 25, 2022
@yito88 yito88 mentioned this pull request Aug 29, 2022
5 tasks
@james-chf
Copy link
Contributor

I am testing this out now with the Ethereum bridge multitoken functionality. I think there is some code/terminology we can standardize or share between IBC multitoken and Ethereum bridge multitoken, that can be a later PR/issue though. Specifically I'd suggest we use a similar sort of terminology to https://eips.ethereum.org/EIPS/eip-1155#abstract.

@james-chf
Copy link
Contributor

I tried out namadac balance and namadac transfer for ERC20 multitokens and it works well with it, lgtm!

For ERC20 tokens, checking balances will look like:

namadac balance \
 	--token atest1v9hx7w36g42ysgzzwf5kgem9ypqkgerjv4ehxgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq8f99ew \
 	--sub-prefix ERC20/0x6b175474e89094c44da98b954eedeac495271d0f

Transfers will look like

namadac transfer \
 	--token atest1v9hx7w36g42ysgzzwf5kgem9ypqkgerjv4ehxgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq8f99ew \
 	--sub-prefix ERC20/0x6b175474e89094c44da98b954eedeac495271d0f
 	--source "${VALIDATOR_ADDR}" \
 	--target "${RECEIVER_ADDR}" \
 	--amount 10

james-chf
james-chf previously approved these changes Sep 1, 2022
@tzemanovic
Copy link
Member

pls update wasm

@juped juped merged commit 2370b61 into main Oct 13, 2022
juped added a commit that referenced this pull request Oct 13, 2022
Draft drifted somewhat over this release cycle. We can clear this up
with a merge-and-delete.

* draft: (373 commits)
  changelog: add #452
  feat: rocksdb use jemalloc
  feat: update rocksdb version
  [ci] wasm checksums update
  changelog: add #501
  fix e2e tests
  fix e2e tests
  Misc refactoring
  Uses `end_epoch` in `query_proposal_result`
  Refactors governance e2e tests
  [ci] wasm checksums update
  changelog: #503
  [ci] wasm checksums update
  remove unfinished lazy_set, lazy_hashset and lazy_hashmap for now
  ledger/storage/lazy: update lazy_set for updated trait LazyCollection
  Fixes specs
  [ci] wasm checksums update
  fix display proposal result in cli
  fix proposal_submission e2e test
  [misc] rebase
  ledger/storage/lazy: remove unused error cases
  WIP: Nested LazyMap validation and testing
  WIP: validation for lazy_map
  WIP: StateMachine tests for lazy_vec validation
  update wasm checksums
  changelog: add #500
  remove intent gossiper, matchmaker and their deps
  Adds `max_proposal_period` governance parameter
  Removes `max_proposal_fund_transfer` parameter
  Use proposal `end_epoch` instead of `start_epoch` for voting power
  Skip tx whitelist for proposal code
  Rename `Treasury` to `SlashFund`
  fmt and fix clippy
  Speeds up testing
  Fixes `safe_exit` call only if `force` is not set
  [misc]: remove logs
  [fix]: votes accumulation
  Fixes test artifacts folder persistence
  Fixes e2e tests
  [fix]: e2e test
  [fix]: e2e test
  [misc]: clippy, fmt
  [fix]: error println
  [feat]: vote transaction validation
  [fix]: governance vp author address, proposal submission validation
  [fix]: bad validation condition
  [fix]: clippy, fmt
  [fix]: clippy, fmt
  [misc]: clippy, fmt
  [feat]: added total votes to query
  [fix]: governance overflow, proposal validation
  fixup! Merge branch 'yuji/multitoken' (#359)
  fixup! rustdoc: fix more broken links
  fixup! Sync with 'main'
  rustdoc: fix more broken links
  fixup! Sync with 'main'
  [ci] wasm checksums update
  changelog: add #359
  change the balance format
  update a test wasm
  remove an error message
  [ci skip] wasm checksums update
  multitoken transfer and query
  post-conditions for Transition::Update + some comments
  quick bug and documentation fix
  update after rebase on #458, #465
  storage/lazy_vec: add state machine test for lazy vec API
  storage/lazy_vec/validation: disallow unrecognized keys matching prefix
  impl LazyCollection trait for all the collections + refactor
  storage_api/collections/lazy: allow nested lazy collections in LazyMap
  add lazy_vec validation
  fix clippy
  storage_api/collections/lazy: add basic tests and missing methods
  cargo test test_lazy_vec_basics
  update lazy for explicit lifetime in StorageRead trait
  storage: add `Key::last` method, impl KeySeg for all ints
  Switch to use storage::KeySeg and add LazySet
  add lazy map without hashing
  refactored lazy collections, replaced hasher, added iter
  fmt && clippy
  add fn get_elem_key_by_hash to LazyMap
  lazy hash map first commit
  add lazy set (WIP), make LazyVec.get public
  add lazy vector
  create lazy data structures for storage access
  rustdoc: resolve ambiguous link
  changelog: add #465
  fixup! Merge branch 'namada/tomas/sorted-prefix-iter' (#458)
  [ci skip] wasm checksums update
  ledger: use storage_api::Error in VpEnv and TxEnv instead of generic
  [ci skip] wasm checksums update
  changelog: add #458
  tests: extend prefix iter tests for reverse order
  add support for rev_iter_prefix in storage and VP and tx envs
  test/vm_host_env: check prefix iter order in tx and VP
  shared/storage/key: add support for int/uint keys that maintain order
  deps: replace hex with data-encoding
  update wasm checksums
  changelog: add #380
  changelog: add #384
  ...
@juped juped deleted the yuji/multitoken branch October 13, 2022 06:51
phy-chain pushed a commit to phy-chain/namada that referenced this pull request Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

anomac transfer should support multitoken transfers
5 participants