Skip to content

Commit

Permalink
Fix/assets cando testnet addr version (paritytech#133)
Browse files Browse the repository at this point in the history
* fix bug for assets `AssetRestriction` judge

```rust
pub fn can_do(id: &AssetId, limit: AssetRestriction) -> bool {
        Self::asset_restrictions_of(id).contains(limit)
    }
```
to
```rust
    pub fn can_do(id: &AssetId, limit: AssetRestriction) -> bool {
        !Self::asset_restrictions_of(id).contains(limit)
    }
```

* change chainx testnet addr version from 42 to 45
  • Loading branch information
atenjin committed Jul 6, 2020
1 parent 18aa916 commit 1678d44
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ fn pcx() -> (AssetId, AssetInfo, AssetRestrictions) {
AssetRestriction::Deposit
| AssetRestriction::Withdraw
| AssetRestriction::DestroyWithdrawal
| AssetRestriction::DestroyFree
| AssetRestriction::Move,
| AssetRestriction::DestroyFree,
)
}

Expand Down
4 changes: 2 additions & 2 deletions polkadotjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
"Negative": "Balance"
}
},
"Compact": "u32",
"BTCCompact": "u32",
"BTCHeader": {
"version": "u32",
"previous_header_hash": "H256",
"merkle_root_hash": "H256",
"time": "u32",
"bits": "Compact",
"bits": "BTCCompact",
"once": "u32"
},
"BTCHeaderInfo": {
Expand Down
2 changes: 1 addition & 1 deletion xpallets/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<T: Trait> Module<T> {
}

pub fn can_do(id: &AssetId, limit: AssetRestriction) -> bool {
Self::asset_restrictions_of(id).contains(limit)
!Self::asset_restrictions_of(id).contains(limit)
}

// can do wrapper
Expand Down
12 changes: 6 additions & 6 deletions xpallets/bridge/bitcoin/src/tests/lockup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ fn test_normal() {
)
.unwrap();
assert_eq!(xpallet_assets::register_asset(asset, true, true), Ok(()));
let mut props: BTreeMap<xpallet_assets::AssetRestriction, bool> = BTreeMap::new();
props.insert(xpallet_assets::AssetRestriction::Move, false);
props.insert(xpallet_assets::AssetRestriction::Transfer, false);
props.insert(xpallet_assets::AssetRestriction::Withdraw, false);
props.insert(xpallet_assets::AssetRestriction::DestroyWithdrawal, false);
xpallet_assets::set_asset_limit_props(XBridgeOfBTCLockup::ASSET_ID, props).unwrap();
// let mut props: BTreeMap<xpallet_assets::AssetRestriction, bool> = BTreeMap::new();
// props.insert(xpallet_assets::AssetRestriction::Move, false);
// props.insert(xpallet_assets::AssetRestriction::Transfer, false);
// props.insert(xpallet_assets::AssetRestriction::Withdraw, false);
// props.insert(xpallet_assets::AssetRestriction::DestroyWithdrawal, false);
// xpallet_assets::set_asset_limit_props(XBridgeOfBTCLockup::ASSET_ID, props).unwrap();

let public = hex!("fa6efb5db13089b4712305e39d0a16867c6822e3b1f4c4619937ae8a21961030")
.unchecked_into();
Expand Down
6 changes: 2 additions & 4 deletions xpallets/mining/asset/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ fn pcx() -> (AssetId, AssetInfo, AssetRestrictions) {
AssetRestriction::Deposit
| AssetRestriction::Withdraw
| AssetRestriction::DestroyWithdrawal
| AssetRestriction::DestroyFree
| AssetRestriction::Move,
| AssetRestriction::DestroyFree,
)
}

Expand All @@ -172,8 +171,7 @@ pub(crate) fn btc() -> (AssetId, AssetInfo, AssetRestrictions) {
AssetRestriction::Deposit
| AssetRestriction::Withdraw
| AssetRestriction::DestroyWithdrawal
| AssetRestriction::DestroyFree
| AssetRestriction::Move,
| AssetRestriction::DestroyFree,
)
}

Expand Down
3 changes: 1 addition & 2 deletions xpallets/mining/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ fn pcx() -> (AssetId, AssetInfo, AssetRestrictions) {
AssetRestriction::Deposit
| AssetRestriction::Withdraw
| AssetRestriction::DestroyWithdrawal
| AssetRestriction::DestroyFree
| AssetRestriction::Move,
| AssetRestriction::DestroyFree,
)
}

Expand Down
4 changes: 2 additions & 2 deletions xpallets/protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod assets_def {
// e.g. USDT not int SLIP44, thus we use `0x01000000 | id` to extend AssetId for containing
// there assets. The AssetId in this part is decided by ChainX.
// For example, we agree on pointing 0x01 as the USDT, thus USDT AssetId is `0x01000000|0x01`
// 2. derived token on ChainX for the cross chain token.
// 3. derived token on ChainX for the cross chain token.
// ChainX would derived some special token which just on ChainX and it is not real cross
// assets but also have some relationship to source chain assets. Thus we use some
// particular prefix to distinguish with base token.
Expand Down Expand Up @@ -85,6 +85,6 @@ pub mod network {
}
}
pub const MAINNET_ADDR_VER: AddrVersion = 44;
pub const TESTNET_ADDR_VER: AddrVersion = 42;
pub const TESTNET_ADDR_VER: AddrVersion = 45;
}
pub use network::*;

0 comments on commit 1678d44

Please sign in to comment.