Skip to content

Commit

Permalink
Implement bridges pot currency swap accounts inititialization (#716)
Browse files Browse the repository at this point in the history
* Initial basic implementation

* Inline implementations

* Docs and refactoring

* Handle all bridges initial balances cases

* Fix basic test

* Properly handle edge cases

* Improve tests

* Add initialization_fails_treasury_insufficient_balance test

* Update features snapshot

* Add weight value calculation

* Add runtime-upgrade logic

* Add runtime upgrade test

* Check is balanced before applying initialization

* Fix try-runtime feature related code

* Rename pallet in mock

* Use runtime_lock and externalities logic as shared components

* More explicit mocks usage in tests

* Use a struct type for address/balance pair in tests

* Rename version mocks

* Add initialization idempotence test

* Add initializer version storage

* Add verify_balanced call

* Edit docs

Co-authored-by: MOZGIII <[email protected]>

* Twice immediate reinvocation  idempotency

Co-authored-by: MOZGIII <[email protected]>

* Add transfer with creating account to test

* Make is_balanced fn public

* Fix typos

Co-authored-by: MOZGIII <[email protected]>

* Improve docs and debug_assert for make_native_bridge_balance_be

* Improve docs and debug_assert for make_evm_bridge_balance_be

* Improve assert messages

* Proportionally equal natve and evm total issuances

* Fix is_balanced logic to calculate different swappable balances

* Rename pallet

* Use a helper function to calculate required bridges minimum balances

* Fix pallet renaming in tests

* Fix pallet renaming in features snapshot

* Return test

* Add docs for tests

---------

Co-authored-by: MOZGIII <[email protected]>
  • Loading branch information
dmitrylavrenov and MOZGIII authored Aug 15, 2023
1 parent 6eb73e7 commit 2721b2b
Show file tree
Hide file tree
Showing 10 changed files with 1,307 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "pallet-balanced-currency-swap-bridges-initializer"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
frame-support = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }
frame-system = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
sp-std = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }
sp-tracing = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }

[dev-dependencies]
pallet-pot = { version = "0.1", path = "../pallet-pot", default-features = false }

pallet-balances = { git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }
sp-core = { git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" }

[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-pot/std",
"scale-info/std",
"sp-std/std",
"sp-tracing/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-pot/try-runtime",
]
Loading

0 comments on commit 2721b2b

Please sign in to comment.