Skip to content

Commit 8e6bb21

Browse files
committed
fix: llms
1 parent 4f5ca32 commit 8e6bb21

26 files changed

+825
-4907
lines changed

.ai/categories/basics.md

Lines changed: 10 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,7 @@ Update your root parachain template's `Cargo.toml` file to include your custom p
403403
Make sure the `custom-pallet` is a member of the workspace:
404404

405405
```toml hl_lines="4" title="Cargo.toml"
406-
[workspace]
407-
default-members = ["pallets/template", "runtime"]
408-
members = [
409-
"node", "pallets/custom-pallet",
410-
"pallets/template",
411-
"runtime",
412-
]
406+
413407
```
414408

415409
???- code "./Cargo.toml"
@@ -2590,53 +2584,13 @@ To build the smart contract, follow the steps below:
25902584
6. Add the getter and setter functions:
25912585

25922586
```solidity
2593-
// SPDX-License-Identifier: MIT
2594-
pragma solidity ^0.8.28;
2595-
2596-
contract Storage {
2597-
// State variable to store our number
2598-
uint256 private number;
2599-
2600-
// Event to notify when the number changes
2601-
event NumberChanged(uint256 newNumber);
2602-
2603-
// Function to store a new number
2604-
function store(uint256 newNumber) public {
2605-
number = newNumber;
2606-
emit NumberChanged(newNumber);
2607-
}
2608-
2609-
// Function to retrieve the stored number
2610-
function retrieve() public view returns (uint256) {
2611-
return number;
2612-
}
2613-
}
2587+
26142588
```
26152589

26162590
??? code "Complete Storage.sol contract"
26172591

26182592
```solidity title="Storage.sol"
2619-
// SPDX-License-Identifier: MIT
2620-
pragma solidity ^0.8.28;
2621-
2622-
contract Storage {
2623-
// State variable to store our number
2624-
uint256 private number;
2625-
2626-
// Event to notify when the number changes
2627-
event NumberChanged(uint256 newNumber);
2628-
2629-
// Function to store a new number
2630-
function store(uint256 newNumber) public {
2631-
number = newNumber;
2632-
emit NumberChanged(newNumber);
2633-
}
2634-
2635-
// Function to retrieve the stored number
2636-
function retrieve() public view returns (uint256) {
2637-
return number;
2638-
}
2639-
}
2593+
26402594
```
26412595

26422596
## Understanding the Code
@@ -3274,23 +3228,7 @@ To create the ERC-20 contract, you can follow the steps below:
32743228
3. Now, paste the following ERC-20 contract code into the editor:
32753229

32763230
```solidity title="MyToken.sol"
3277-
// SPDX-License-Identifier: MIT
3278-
// Compatible with OpenZeppelin Contracts ^5.0.0
3279-
pragma solidity ^0.8.22;
3280-
3281-
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
3282-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
3283-
3284-
contract MyToken is ERC20, Ownable {
3285-
constructor(address initialOwner)
3286-
ERC20("MyToken", "MTK")
3287-
Ownable(initialOwner)
3288-
{}
3289-
3290-
function mint(address to, uint256 amount) public onlyOwner {
3291-
_mint(to, amount);
3292-
}
3293-
}
3231+
32943232
```
32953233

32963234
The key components of the code above are:
@@ -3608,26 +3546,7 @@ To create the NFT contract, you can follow the steps below:
36083546
3. Now, paste the following NFT contract code into the editor.
36093547

36103548
```solidity title="MyNFT.sol"
3611-
// SPDX-License-Identifier: MIT
3612-
// Compatible with OpenZeppelin Contracts ^5.0.0
3613-
pragma solidity ^0.8.22;
3614-
3615-
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
3616-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
3617-
3618-
contract MyToken is ERC721, Ownable {
3619-
uint256 private _nextTokenId;
3620-
3621-
constructor(address initialOwner)
3622-
ERC721("MyToken", "MTK")
3623-
Ownable(initialOwner)
3624-
{}
3625-
3626-
function safeMint(address to) public onlyOwner {
3627-
uint256 tokenId = _nextTokenId++;
3628-
_safeMint(to, tokenId);
3629-
}
3630-
}
3549+
36313550
```
36323551

36333552
The key components of the code above are:
@@ -9254,8 +9173,7 @@ The [`XcmRouter`](https://paritytech.github.io/polkadot-sdk/master/pallet_xcm/pa
92549173
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.
92559174

92569175
```rust
9257-
pub type PriceForChildParachainDelivery =
9258-
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, Dmp>;
9176+
92599177
```
92609178

92619179
For more details about XCM transport protocols, see the [XCM Channels](/develop/interoperability/xcm-channels/){target=\_blank} page.
@@ -10381,95 +10299,25 @@ The `xcm-emulator` provides macros for defining a mocked testing environment. Ch
1038110299
- **[`decl_test_relay_chains`](https://github.com/paritytech/polkadot-sdk/blob/polkadot-stable2506-2/cumulus/xcm/xcm-emulator/src/lib.rs#L361){target=\_blank}**: Defines runtime and configuration for the relay chains. Example:
1038210300

1038310301
```rust
10384-
decl_test_relay_chains! {
10385-
#[api_version(13)]
10386-
pub struct Westend {
10387-
genesis = genesis::genesis(),
10388-
on_init = (),
10389-
runtime = westend_runtime,
10390-
core = {
10391-
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter,
10392-
},
10393-
pallets = {
10394-
XcmPallet: westend_runtime::XcmPallet,
10395-
Sudo: westend_runtime::Sudo,
10396-
Balances: westend_runtime::Balances,
10397-
Treasury: westend_runtime::Treasury,
10398-
AssetRate: westend_runtime::AssetRate,
10399-
Hrmp: westend_runtime::Hrmp,
10400-
Identity: westend_runtime::Identity,
10401-
IdentityMigrator: westend_runtime::IdentityMigrator,
10402-
}
10403-
},
10404-
}
10302+
1040510303
```
1040610304

1040710305
- **[`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:
1040810306

1040910307
```rust
10410-
decl_test_parachains! {
10411-
pub struct AssetHubWestend {
10412-
genesis = genesis::genesis(),
10413-
on_init = {
10414-
asset_hub_westend_runtime::AuraExt::on_initialize(1);
10415-
},
10416-
runtime = asset_hub_westend_runtime,
10417-
core = {
10418-
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
10419-
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
10420-
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
10421-
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
10422-
DigestProvider: (),
10423-
},
10424-
pallets = {
10425-
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
10426-
Balances: asset_hub_westend_runtime::Balances,
10427-
Assets: asset_hub_westend_runtime::Assets,
10428-
ForeignAssets: asset_hub_westend_runtime::ForeignAssets,
10429-
PoolAssets: asset_hub_westend_runtime::PoolAssets,
10430-
AssetConversion: asset_hub_westend_runtime::AssetConversion,
10431-
SnowbridgeSystemFrontend: asset_hub_westend_runtime::SnowbridgeSystemFrontend,
10432-
Revive: asset_hub_westend_runtime::Revive,
10433-
}
10434-
},
10435-
}
10308+
1043610309
```
1043710310

1043810311
- **[`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:
1043910312

1044010313
```rust
10441-
decl_test_bridges! {
10442-
pub struct RococoWestendMockBridge {
10443-
source = BridgeHubRococoPara,
10444-
target = BridgeHubWestendPara,
10445-
handler = RococoWestendMessageHandler
10446-
},
10447-
pub struct WestendRococoMockBridge {
10448-
source = BridgeHubWestendPara,
10449-
target = BridgeHubRococoPara,
10450-
handler = WestendRococoMessageHandler
10451-
}
10452-
}
10314+
1045310315
```
1045410316

1045510317
- **[`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:
1045610318

1045710319
```rust
10458-
decl_test_networks! {
10459-
pub struct WestendMockNet {
10460-
relay_chain = Westend,
10461-
parachains = vec![
10462-
AssetHubWestend,
10463-
BridgeHubWestend,
10464-
CollectivesWestend,
10465-
CoretimeWestend,
10466-
PeopleWestend,
10467-
PenpalA,
10468-
PenpalB,
10469-
],
10470-
bridge = ()
10471-
},
10472-
}
10320+
1047310321
```
1047410322

1047510323
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](/parachains/customize-runtime/pallet-development/pallet-testing/){target=\_blank} article.

0 commit comments

Comments
 (0)