Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document "Remix IDE" for asset hub smart contracts #309

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
758a800
add github workflows (#297)
UtkarshBhardwaj007 Jan 8, 2025
4ebcb3a
Update pos-consensus.md (#298)
ottovlotto Jan 8, 2025
c5894fd
add license header to code files (#292)
UtkarshBhardwaj007 Jan 8, 2025
0d1d63b
Update CODEOWNERS
albertov19 Jan 8, 2025
99e38c3
Pallet Benchmarking Tutorial (#291)
0xLucca Jan 9, 2025
8a81681
add rust toolchain information (#296)
UtkarshBhardwaj007 Jan 9, 2025
ded6daf
[FIX] - Adding `npm install` to contributing.md (#256)
nhussein11 Jan 10, 2025
65ef1d9
fix: boilerplate clean up
nhussein11 Jan 14, 2025
51ffe56
fix: desc updated
nhussein11 Jan 14, 2025
7382162
docs: update Remix IDE guide with enhanced instructions and code snip…
nhussein11 Jan 15, 2025
6d99c9a
fix: remix page completed
nhussein11 Jan 16, 2025
61193ed
docs: fix formatting
nhussein11 Jan 17, 2025
68d33c8
add: conclusion
nhussein11 Jan 17, 2025
fe8ed22
feat: add Counter contract and update Remix documentation with code s…
nhussein11 Jan 17, 2025
9bd83b1
fix: adding deployment logging
nhussein11 Jan 20, 2025
7a77fd8
docs: update wording
nhussein11 Jan 20, 2025
a3c3f95
Merge branch 'staging-ah-smart-contracts' into 273-document-remix-for…
nhussein11 Jan 20, 2025
af8f3b6
refactor: update to destiny structure
nhussein11 Jan 20, 2025
9925e9a
Apply suggestions from code review
nhussein11 Jan 20, 2025
d4c4d93
docs: fix formatting and indentation in Remix documentation
nhussein11 Jan 20, 2025
4a6e5a4
Apply suggestions from code review
nhussein11 Jan 23, 2025
3a3a4a8
fix: remove frontier reference
nhussein11 Jan 23, 2025
6d75250
docs: clarify remix interface components
nhussein11 Jan 23, 2025
51f480b
fix: list items
nhussein11 Jan 23, 2025
0b42aba
fix: adding explanation for remix buttons
nhussein11 Jan 23, 2025
8060fc0
Apply suggestions from code review
nhussein11 Jan 23, 2025
ef135b2
Update .CONTRIBUTING.md
nhussein11 Jan 23, 2025
70307e4
fix: updating title for SEO
nhussein11 Jan 23, 2025
6af1197
docs: moving counter contract above img
nhussein11 Jan 23, 2025
15eb785
fix: feedback applied
nhussein11 Jan 23, 2025
69b380d
docs: adding cards
nhussein11 Jan 24, 2025
bf58529
Update develop/smart-contracts/evm-toolkit/dev-environments/remix.md
nhussein11 Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions .CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ This guide covers how to contribute to the documentation, including serving a lo

## Contents

- [Viewing Site Locally](#view-site-locally)
- [Clone Repositories](#clone-repositories)
- [Install Dependencies and Serve Site](#install-dependencies)
- [Adding New Pages](#adding-new-pages)
- [Creating a Subdirectory](#creating-a-subdirectory)
- [Example `.pages` File](#example-pages-file)
- [Example `index.md` File](#example-indexmd-file)
- [Adding Pages to Existing Subdirectory](#adding-pages-to-existing-subdirectory)
- [Modifying Existing Pages](#modifying-existing-pages)
- [Adding Code and Text Snippets](#adding-code-and-text-snippets)
- [Adding Images](#adding-images)
- [Optimizing for SEO](#search-enging-optimization-seo)
- [Tools for Editing](#tools-for-editing)
- [Contribute to the Polkadot Developer Docs](#contribute-to-the-polkadot-developer-docs)
- [Contents](#contents)
- [Viewing Site Locally](#viewing-site-locally)
- [Clone Repositories](#clone-repositories)
- [Install Dependencies and Serve Site](#install-dependencies-and-serve-site)
- [Adding New Pages](#adding-new-pages)
- [Creating a New Section](#creating-a-new-section)
- [Example `.pages` File](#example-pages-file)
- [Example `index.md` File](#example-indexmd-file)
- [Adding Pages to Existing Section](#adding-pages-to-existing-section)
- [Modifying Existing Pages](#modifying-existing-pages)
- [Adding Code and Text Snippets](#adding-code-and-text-snippets)
- [Adding Images](#adding-images)
- [Search Engine Optimization (SEO)](#search-engine-optimization-seo)
- [Tools for Editing](#tools-for-editing)

## Viewing Site Locally

Expand Down Expand Up @@ -66,7 +68,13 @@ To set up the structure, follow these steps:

This command will install all dependencies listed in the `requirements.txt` file.

2. In the `polkadot-mkdocs` folder (which should be the current one), you can build the site by running:
2. Switch to the `polkadot-docs` directory and use [npm](https://docs.npmjs.com/about-npm) to install dependencies:

```bash
cd polkadot-docs && npm install
```

3. Navigate back to the `polkadot-mkdocs` folder, then build the site:

```bash
mkdocs serve
Expand Down
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Request reviews from the formatting team for all PRs
* @polkadot-developers/docs-formatting-team

# Request reviews from the content team for all PRs
* @polkadot-developers/docs-content-team
1 change: 1 addition & 0 deletions .github/env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-11-19-v202411281558"
104 changes: 104 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Checks

on:
push:
branches:
- main
paths:
- '.snippets/code/**'
- '.github/workflows/**'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '.snippets/code/**'
- '.github/workflows/**'
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
preflight:
uses: ./.github/workflows/reusable-preflight.yml

fmt:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- name: Cargo fmt
working-directory: .snippets/code
run: cargo +nightly fmt --all -- --check

clippy:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- name: Clippy check
working-directory: .snippets/code
run: |
cargo clippy --all-targets --locked --workspace --quiet
cargo clippy --all-targets --all-features --locked --workspace --quiet

test:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [preflight]
container:
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- uses: actions/checkout@v4
- name: Run tests
working-directory: .snippets/code
run: cargo test

check-fail-ci:
runs-on: ubuntu-latest
container:
image: "paritytech/tools:latest"
options: --user root
steps:
- uses: actions/checkout@v4
- name: Check
working-directory: .snippets/code
run: |
set +e
rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "$ASSERT_REGEX was found, exiting with 1";
exit 1;
else
echo "No $ASSERT_REGEX was found, exiting with 0";
exit 0;
fi
env:
ASSERT_REGEX: "FAIL-CI"
GIT_DEPTH: 1

confirm-checks:
runs-on: ubuntu-latest
name: All checks passed
needs:
- fmt
- clippy
- test
- check-fail-ci
if: always() && !cancelled()
steps:
- run: |
tee resultfile <<< '${{ toJSON(needs) }}'
FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l)
if [ $FAILURES -gt 0 ]; then
echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY
exit 1
else
echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY
fi
48 changes: 48 additions & 0 deletions .github/workflows/reusable-preflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Preflight

on:
workflow_call:
outputs:
changes_rust:
value: ${{ jobs.preflight.outputs.changes_rust }}
changes_currentWorkflow:
value: ${{ jobs.preflight.outputs.changes_currentWorkflow }}
IMAGE:
value: ${{ jobs.preflight.outputs.IMAGE }}
description: "CI image"

jobs:
preflight:
runs-on: ubuntu-latest
outputs:
changes_rust: ${{ steps.set_changes.outputs.rust_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }}
changes_currentWorkflow: ${{ steps.set_changes.outputs.currentWorkflow_any_changed }}
IMAGE: ${{ steps.set_image.outputs.IMAGE }}

steps:
- uses: actions/checkout@v4

- name: Current file
id: current_file
shell: bash
run: |
echo "currentWorkflowFile=$(echo ${{ github.workflow_ref }} | sed -nE "s/.*(\.github\/workflows\/[a-zA-Z0-9_-]*\.y[a]?ml)@refs.*/\1/p")" >> $GITHUB_OUTPUT
echo "currentActionDir=$(echo ${{ github.action_path }} | sed -nE "s/.*(\.github\/actions\/[a-zA-Z0-9_-]*)/\1/p")" >> $GITHUB_OUTPUT

- name: Set changes
id: set_changes
uses: tj-actions/changed-files@v45
with:
files_yaml: |
rust:
- '.snippets/code/**/*'
- '!.github/**/*'
- '!docs/**/*'
currentWorkflow:
- '${{ steps.current_file.outputs.currentWorkflowFile }}'
- '.github/workflows/reusable-preflight.yml'

- name: Set image
id: set_image
shell: bash
run: cat .github/env >> $GITHUB_OUTPUT
25 changes: 25 additions & 0 deletions .snippets/code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Polkadot Developer Docs Code Snippets

## Project Setup

This project requires specific versions of Rust and Cargo.

### Rust Toolchains

The project uses the following Rust toolchains:

- **Stable:** `1.81.0` (for building)
- **Nightly:** `1.85.0-nightly` (for formatting and linting)

To install the required toolchains, install `rustup` and run:

```bash
rustup toolchain install 1.81.0
rustup toolchain install nightly-2024-12-15
```

## Disclaimer

### License

All code examples or related software provided in this repository are available under the [MIT-0 License](https://opensource.org/license/mit-0).
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Counter {
int256 private count;

function increment() public {
count += 1;
}

function decrement() public {
count -= 1;
}

function getCount() public view returns (int256) {
return count;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider(
'https://westend-asset-hub-eth-rpc.polkadot.io',
'https://westend-asset-hub-eth-rpc.polkadot.io'
);
7 changes: 7 additions & 0 deletions .snippets/code/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[toolchain]
channel = "1.81.0"
components = ["rustfmt", "clippy"]

[toolchain.nightly]
channel = "1.85.0-nightly"
components = ["rustfmt", "clippy"]
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import { Binary } from 'polkadot-api';

// Create Polkadot client using WebSocket provider for Polkadot chain
const polkadotClient = createClient(
withPolkadotSdkCompat(getWsProvider('ws://127.0.0.1:8001')),
withPolkadotSdkCompat(getWsProvider('ws://127.0.0.1:8001'))
);
const dotApi = polkadotClient.getTypedApi(dot);

// Create Astar client using WebSocket provider for Astar chain
const astarClient = createClient(
withPolkadotSdkCompat(getWsProvider('ws://localhost:8000')),
withPolkadotSdkCompat(getWsProvider('ws://localhost:8000'))
);
const astarApi = astarClient.getTypedApi(astar);

Expand All @@ -42,7 +42,7 @@ const aliceKeyPair = derive('//Alice');
const alice = getPolkadotSigner(
aliceKeyPair.publicKey,
'Sr25519',
aliceKeyPair.sign,
aliceKeyPair.sign
);

// Define recipient (Dave) address on Astar chain
Expand All @@ -56,7 +56,7 @@ const polkadotAssetId = 340282366920938463463374607431768211455n;
// Fetch asset balance of recipient (Dave) before transaction
let assetMetadata = await astarApi.query.Assets.Account.getValue(
polkadotAssetId,
daveAddress,
daveAddress
);
console.log('Asset balance before tx:', assetMetadata?.balance ?? 0);

Expand All @@ -65,7 +65,7 @@ const tx = dotApi.tx.XcmPallet.limited_reserve_transfer_assets({
dest: XcmVersionedLocation.V3({
parents: 0,
interior: XcmV3Junctions.X1(
XcmV3Junction.Parachain(2006), // Destination is the Astar parachain
XcmV3Junction.Parachain(2006) // Destination is the Astar parachain
),
}),
beneficiary: XcmVersionedLocation.V3({
Expand All @@ -75,7 +75,7 @@ const tx = dotApi.tx.XcmPallet.limited_reserve_transfer_assets({
// Beneficiary address on Astar
network: undefined,
id: idBenef,
}),
})
),
}),
assets: XcmVersionedAssets.V3([
Expand Down Expand Up @@ -110,7 +110,7 @@ await new Promise((resolve) => setTimeout(resolve, 20000));
// Fetch asset balance of recipient (Dave) after transaction
assetMetadata = await astarApi.query.Assets.Account.getValue(
polkadotAssetId,
daveAddress,
daveAddress
);
console.log('Asset balance after tx:', assetMetadata?.balance ?? 0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
// This file is part of 'custom-pallet'.

// SPDX-License-Identifier: MIT-0

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
// This file is part of 'custom-pallet'.

// SPDX-License-Identifier: MIT-0

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use custom_pallet::{self, *};
use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types, traits::ConstU32};
use frame_system::RawOrigin;
Expand Down
Loading
Loading