Pallet: Atomic Swap (#6349)

* Init atomic swap pallet

* Implement module swap operations

* Add successful swap test

* Bump node spec_version

* Fix storage name

* Add ProofLimit parameter to prevent proof size being too large

* Add missing events

* Basic weight support

* Add basic docs

* Mark swap on claim

This handles the additional case if `repatriate_reserved` fails.

* Add additional expire handler

* Update frame/atomic-swap/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Add docs on ProofLimit

* Fix test

* Return Ok(()) even when the transfer fails

Because we need to mark the swap as claimed no matter what.

* Remove retry logic

It's overkill. Swap is about something being executed, not necessarily successful.
Although there should be logic (reserve and unreserve) to make it so that both parties *believes*
that the execution is successful.

* succeed -> succeeded

* Add docs on duration -- revealer should use duration shorter than counterparty

* Missing trait type

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Wei Tang
2020-06-18 09:42:31 +02:00
committed by GitHub
parent f05ae63afa
commit bd5ad9fd6d
6 changed files with 460 additions and 2 deletions
+39
View File
@@ -0,0 +1,39 @@
[package]
name = "pallet-atomic-swap"
version = "2.0.0-rc3"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME atomic swap pallet"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
serde = { version = "1.0.101", optional = true }
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
frame-support = { version = "2.0.0-rc3", default-features = false, path = "../support" }
frame-system = { version = "2.0.0-rc3", default-features = false, path = "../system" }
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/runtime" }
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/std" }
sp-io = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/io" }
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/core" }
[dev-dependencies]
pallet-balances = { version = "2.0.0-rc3", default-features = false, path = "../balances" }
[features]
default = ["std"]
std = [
"serde",
"codec/std",
"frame-support/std",
"frame-system/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
"sp-core/std",
"pallet-balances/std",
]