You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -140,7 +140,7 @@ First, you'll update the runtime's `Cargo.toml` file to include the Utility pall
140
140
1. Open the `runtime/Cargo.toml` file and locate the `[dependencies]` section. Add pallet-utility as one of the features for the `polkadot-sdk` dependency with the following line:
141
141
142
142
```toml hl_lines="4" title="runtime/Cargo.toml"
143
-
[dependencies]
143
+
144
144
...
145
145
polkadot-sdk = { workspace = true, features = [
146
146
"pallet-utility",
@@ -287,63 +287,13 @@ Update your root parachain template's `Cargo.toml` file to include your custom p
287
287
Make sure the `custom-pallet` is a member of the workspace:
@@ -1684,53 +1634,13 @@ To build the smart contract, follow the steps below:
1684
1634
6. Add the getter and setter functions:
1685
1635
1686
1636
```solidity
1687
-
// SPDX-License-Identifier: MIT
1688
-
pragma solidity ^0.8.28;
1689
-
1690
-
contract Storage {
1691
-
// State variable to store our number
1692
-
uint256 private number;
1693
-
1694
-
// Event to notify when the number changes
1695
-
event NumberChanged(uint256 newNumber);
1696
-
1697
-
// Function to store a new number
1698
-
function store(uint256 newNumber) public {
1699
-
number = newNumber;
1700
-
emit NumberChanged(newNumber);
1701
-
}
1702
-
1703
-
// Function to retrieve the stored number
1704
-
function retrieve() public view returns (uint256) {
1705
-
return number;
1706
-
}
1707
-
}
1637
+
1708
1638
```
1709
1639
1710
1640
??? code "Complete Storage.sol contract"
1711
1641
1712
1642
```solidity title="Storage.sol"
1713
-
// SPDX-License-Identifier: MIT
1714
-
pragma solidity ^0.8.28;
1715
-
1716
-
contract Storage {
1717
-
// State variable to store our number
1718
-
uint256 private number;
1719
-
1720
-
// Event to notify when the number changes
1721
-
event NumberChanged(uint256 newNumber);
1722
-
1723
-
// Function to store a new number
1724
-
function store(uint256 newNumber) public {
1725
-
number = newNumber;
1726
-
emit NumberChanged(newNumber);
1727
-
}
1728
-
1729
-
// Function to retrieve the stored number
1730
-
function retrieve() public view returns (uint256) {
1731
-
return number;
1732
-
}
1733
-
}
1643
+
1734
1644
```
1735
1645
1736
1646
## Understanding the Code
@@ -5018,16 +4928,7 @@ The [`Account` data type](https://paritytech.github.io/polkadot-sdk/master/frame
5018
4928
The code snippet below shows how accounts are defined:
5019
4929
5020
4930
```rs
5021
-
/// The full account information for a particular account ID.
5022
-
#[pallet::storage]
5023
-
#[pallet::getter(fn account)]
5024
-
pub type Account<T: Config> = StorageMap<
5025
-
_,
5026
-
Blake2_128Concat,
5027
-
T::AccountId,
5028
-
AccountInfo<T::Nonce, T::AccountData>,
5029
-
ValueQuery,
5030
-
>;
4931
+
5031
4932
```
5032
4933
5033
4934
The preceding code block defines a storage map named `Account`. The `StorageMap` is a type of on-chain storage that maps keys to values. In the `Account` map, the key is an account ID, and the value is the account's information. Here, `T` represents the generic parameter for the runtime configuration, which is defined by the pallet's configuration trait (`Config`).
@@ -5051,24 +4952,7 @@ For a detailed explanation of storage maps, see the [`StorageMap`](https://parit
5051
4952
The `AccountInfo` structure is another key element within the [System pallet](https://paritytech.github.io/polkadot-sdk/master/src/frame_system/lib.rs.html){target=\_blank}, providing more granular details about each account's state. This structure tracks vital data, such as the number of transactions and the account’s relationships with other modules.
/// The number of transactions this account has sent.
5058
-
pub nonce: Nonce,
5059
-
/// The number of other modules that currently depend on this account's existence. The account
5060
-
/// cannot be reaped until this is zero.
5061
-
pub consumers: RefCount,
5062
-
/// The number of other modules that allow this account to exist. The account may not be reaped
5063
-
/// until this and `sufficients` are both zero.
5064
-
pub providers: RefCount,
5065
-
/// The number of modules that allow this account to exist for their own purposes only. The
5066
-
/// account may not be reaped until this and `providers` are both zero.
5067
-
pub sufficients: RefCount,
5068
-
/// The additional data that belongs to this account. Used to store the balance(s) in a lot of
5069
-
/// chains.
5070
-
pub data: AccountData,
5071
-
}
4955
+
5072
4956
```
5073
4957
5074
4958
The `AccountInfo` structure includes the following components:
@@ -5779,8 +5663,7 @@ The [`XcmRouter`](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/pa
5779
5663
For instance, the Kusama network employs the [`ChildParachainRouter`](https://paritytech.github.io/polkadot-sdk/master/polkadot_runtime_common/xcm_sender/struct.ChildParachainRouter.html){target=\_blank}, which restricts routing to [Downward Message Passing (DMP)](https://wiki.polkadot.com/learn/learn-xcm-transport/#dmp-downward-message-passing){target=\_blank} from the relay chain to parachains, ensuring secure and controlled communication.
For more details about XCM transport protocols, see the [XCM Channels](/develop/interoperability/xcm-channels/){target=\_blank} page.
@@ -6602,69 +6485,19 @@ The `xcm-emulator` provides macros for defining a mocked testing environment. Ch
6602
6485
- **[`decl_test_parachains`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L596){target=\_blank}**: Defines runtime and configuration for parachains. Example:
- **[`decl_test_bridges`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L1221){target=\_blank}**: Creates bridges between chains, specifying the source, target, and message handler. Example:
6634
6492
6635
6493
```rust
6636
-
decl_test_bridges! {
6637
-
pub struct RococoWestendMockBridge {
6638
-
source = BridgeHubRococoPara,
6639
-
target = BridgeHubWestendPara,
6640
-
handler = RococoWestendMessageHandler
6641
-
},
6642
-
pub struct WestendRococoMockBridge {
6643
-
source = BridgeHubWestendPara,
6644
-
target = BridgeHubRococoPara,
6645
-
handler = WestendRococoMessageHandler
6646
-
}
6647
-
}
6494
+
6648
6495
```
6649
6496
6650
6497
- **[`decl_test_networks`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L958){target=\_blank}**: Defines a testing network with relay chains, parachains, and bridges, implementing message transport and processing logic. Example:
6651
6498
6652
6499
```rust
6653
-
decl_test_networks! {
6654
-
pub struct WestendMockNet {
6655
-
relay_chain = Westend,
6656
-
parachains = vec![
6657
-
AssetHubWestend,
6658
-
BridgeHubWestend,
6659
-
CollectivesWestend,
6660
-
CoretimeWestend,
6661
-
PeopleWestend,
6662
-
PenpalA,
6663
-
PenpalB,
6664
-
],
6665
-
bridge = ()
6666
-
},
6667
-
}
6500
+
6668
6501
```
6669
6502
6670
6503
By leveraging these macros, developers can customize their testing networks by defining relay chains and parachains tailored to their needs. For guidance on implementing a mock runtime for a Polkadot SDK-based chain, refer to the [Pallet Testing](/develop/parachains/testing/pallet-testing/){target=\_blank} article.
0 commit comments