Skip to content

Instantly share code, notes, and snippets.

View sgerodes's full-sized avatar

sgerodes sgerodes

View GitHub Profile
@sgerodes
sgerodes / extend-trial-jetbrains-windows.bat
Created February 7, 2024 10:30 — forked from rjescobar/extend-trial-jetbrains-windows.bat
JetBrains IDE trial reset windows
REM Delete eval folder with licence key and options.xml which contains a reference to it
for %%I in ("WebStorm", "IntelliJ", "CLion", "Rider", "GoLand", "PhpStorm", "Resharper", "PyCharm") do (
for /d %%a in ("%USERPROFILE%\.%%I*") do (
rd /s /q "%%a/config/eval"
del /q "%%a\config\options\other.xml"
)
)
REM Delete registry key and jetbrains folder (not sure if needet but however)
rmdir /s /q "%APPDATA%\JetBrains"
use crate::{mock::*, Error, Event};
use frame_support::{assert_noop, assert_ok};
use crate::{Config, Pallet};
use sp_runtime::traits::AccountIdConversion;
use frame_support::traits::fungibles::Mutate;
use crate::mock::{new_test_ext, Test};
#[cfg(test)]
// Look at `../interface/` to better understand this API.
impl<T: Config> pba_interface::DexInterface for Pallet<T> {
type AccountId = T::AccountId;
type AssetId = <T::Fungibles as fungibles::Inspect<Self::AccountId>>::AssetId;
type AssetBalance = <T::Fungibles as fungibles::Inspect<Self::AccountId>>::Balance;
fn setup_account(_who: Self::AccountId) -> DispatchResult {
unimplemented!()
}
# FRAME Assignment Instructions
This assignment is a project covering the material you've learned about writing Substrate runtimes with FRAME.
To complete this project, **select one of the following challenges**, and implement the runtime described using FRAME.
The [pallets included](./pallets/) may be used as a base to work in for the option you select.
## Main Challenges
These are the same challenges we have used for the previous academies. We have reviewed and graded many of these projects, and many students have be successful with these projects.
//! # FRAME-less Runtime
//!
//! Welcome to the `FRAME-less` exercise, the fourth edition.
//!
//! > This assignment is based on Joshy's experiment years ago to explore building a Substrate
//! > runtime using pure Rust. If you learn something new in this exercise, attribute it to his
//! > work.
//!
//! Parts of this assignment resembles the `mini_substrate` section of the pre-course material. It
//! is recommended to re-familiarize yourself with that if you have done it. Nonetheless, everything
@sgerodes
sgerodes / gist:97c5c37d2cbf98f561264e4f6728d703
Created January 17, 2024 14:20
Asignment 3, What to ttest
# test ideas
//! - Only signed extrinsics are accepted, so you will learn signature verification.
//! - Basic calls for testing/learning, mainly represented in [`shared::RuntimeCall::System`].
//! - Basic currency system.
//! - Basic staking/reserving system.
//! - Nonce system, to prevent replay attacks and similar issues.
//! - Tipping, which is there to mimic transaction fee payment.
//! Checks that must happen in apply phase are those that are mandatory to make sure a blockchain is
//! sound and safe. These include:
use super::*;
fn empty_wallet() -> Wallet {
Wallet::new(vec![].into_iter())
}
pub fn wallet_with_alice() -> Wallet {
Wallet::new(vec![Address::Alice].into_iter())
}
@sgerodes
sgerodes / gist:aef60ce1dd2dda681c45c59d6b9357e0
Last active January 13, 2024 05:05
PBA assignment 2 tests
use super::*;
use super::test_utils::*;
pub fn wallet_with_alice() -> Wallet {
Wallet::new(vec![Address::Alice].into_iter())
}
mod tests {
use super::*;
Share any code fast
@sgerodes
sgerodes / sort_10.sol
Created August 3, 2023 09:34
Solidity sort 10 in the most gas efficient way
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.18;
contract Level_2_Solution {
function solution(uint256[10] calldata unsortedArray)
external pure returns (uint256[10] memory) {
uint256[10] memory sortedArray = unsortedArray;
if(sortedArray[0] > sortedArray[8]) {
(sortedArray[0], sortedArray[8]) = (sortedArray[8], sortedArray[0]);