Skip to content

Commit

Permalink
Merge branch 'eshaben/xcm-overhaul' of github.com:PureStake/moonbeam-…
Browse files Browse the repository at this point in the history
…docs into eshaben/xcm-overhaul
  • Loading branch information
albertov19 committed Dec 14, 2023
2 parents 338522b + f269f7e commit d30dcae
Show file tree
Hide file tree
Showing 134 changed files with 2,822 additions and 867 deletions.
1 change: 1 addition & 0 deletions .github/pull-request-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Please explain the changes this PR addresses here.

### Checklist

- [ ] I have added a label to this PR 🏷️
- [ ] If this requires translations for the `moonbeam-docs-cn` repo, I have created a ticket for the translations in Jira
- [ ] If pages have been moved around, I have created an additional PR in `moonbeam-mkdocs` to update redirects
- [ ] If pages have been moved around, I have run the `move-pages.py` script to move the pages and update the image paths on the chinese repo
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract PausableBox is Initializable, PausableUpgradeable, OwnableUpgradeable {
uint256 private value;

// Emitted when the stored value changes
event ValueChanged(uint256 newValue);

// Initialize
function initialize() initializer public {
__Ownable_init(_msgSender());
__Pausable_init_unchained();
}

// Stores a new value in the contract
function store(uint256 newValue) whenNotPaused public {
value = newValue;
emit ValueChanged(newValue);
}

// Reads the last stored value
function retrieve() public view returns (uint256) {
return value;
}

function pause() public onlyOwner {
_pause();
}

function unpause() public onlyOwner {
_unpause();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { Web3 } = require('web3');
const contractFile = require('./compile');

// 2. Add the Web3 provider logic here:
// 2. Add the Web3 provider logic
const providerRPC = {
development: 'http://localhost:9944',
moonbase: 'https://rpc.api.moonbase.moonbeam.network',
Expand All @@ -26,13 +26,13 @@ const deploy = async () => {
// 6. Create contract instance
const incrementer = new web3.eth.Contract(abi);

// 7. Create constructor tx
// 7. Create constructor transaction
const incrementerTx = incrementer.deploy({
data: bytecode,
arguments: [5],
});

// 8. Sign transacation and send
// 8. Sign transaction with PK
const createTransaction = await web3.eth.accounts.signTransaction(
{
data: incrementerTx.encodeABI(),
Expand All @@ -43,7 +43,7 @@ const deploy = async () => {
accountFrom.privateKey
);

// 9. Send tx and wait for receipt
// 9. Send transaction and wait for receipt
const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 1. Import Web3js and the contract abi
// 1. Import Web3js and the contract ABI
const { Web3 } = require('web3');
const { abi } = require('./compile');

// 2. Add the Web3 provider logic here:
// 2. Add the Web3 provider logic
const providerRPC = {
development: 'http://localhost:9944',
moonbase: 'https://rpc.api.moonbase.moonbeam.network',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// 1. Import Web3js and the contract abi
// 1. Import Web3js and the contract ABI
const { Web3 } = require('web3');
const { abi } = require('./compile');

// 2. Add the Web3 provider logic here:
// 2. Add the Web3 provider logic
const providerRPC = {
development: 'http://localhost:9944',
moonbase: 'https://rpc.api.moonbase.moonbeam.network',
};
const web3 = new Web3(providerRPC.moonbase); //Change to correct network
const web3 = new Web3(providerRPC.moonbase); // Change to correct network

// 3. Create variables
const accountFrom = {
Expand All @@ -20,7 +20,7 @@ const _value = 3;
// 4. Create contract instance
const incrementer = new web3.eth.Contract(abi, contractAddress);

// 5. Build increment tx
// 5. Build increment transaction
const incrementTx = incrementer.methods.increment(_value);

// 6. Create increment function
Expand All @@ -29,7 +29,7 @@ const increment = async () => {
`Calling the increment by ${_value} function in contract at address: ${contractAddress}`
);

// 7. Prepare and Sign Tx with PK
// 7. Sign transaction with PK
const createTransaction = await web3.eth.accounts.signTransaction(
{
to: contractAddress,
Expand All @@ -41,7 +41,7 @@ const increment = async () => {
accountFrom.privateKey
);

// 8. Send Tx and Wait for Receipt
// 8. Send transaction and wait for receipt
const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction
);
Expand Down
10 changes: 5 additions & 5 deletions .snippets/code/builders/build/eth-api/libraries/web3-js/reset.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 1. Import Web3js and the contract abi
// 1. Import Web3js and the contract ABI
const { Web3 } = require('web3');
const { abi } = require('./compile');

// 2. Add the Web3 provider logic here:
// 2. Add the Web3 provider logic
const providerRPC = {
development: 'http://localhost:9944',
moonbase: 'https://rpc.api.moonbase.moonbeam.network',
Expand All @@ -19,14 +19,14 @@ const contractAddress = 'INSERT_CONTRACT_ADDRESS';
// 4. Create contract instance
const incrementer = new web3.eth.Contract(abi, contractAddress);

// 5. Build reset tx
// 5. Build reset transaction
const resetTx = incrementer.methods.reset();

// 6. Create reset function
const reset = async () => {
console.log(`Calling the reset function in contract at address: ${contractAddress}`);

// 7. Prepare and sign tx with PK
// 7. Sign transaction with PK
const createTransaction = await web3.eth.accounts.signTransaction(
{
to: contractAddress,
Expand All @@ -38,7 +38,7 @@ const reset = async () => {
accountFrom.privateKey
);

// 8. Send tx and wait for receipt
// 8. Send transaction and wait for receipt
const createReceipt = await web3.eth.sendSignedTransaction(createTransaction.rawTransaction);
console.log(`Tx successful with hash: ${createReceipt.transactionHash}`);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Web3 } = require('web3');

// 1. Add the Web3 provider logic here:
// 1. Add the Web3 provider logic
const providerRPC = {
development: 'http://localhost:9944',
moonbase: 'https://rpc.api.moonbase.moonbeam.network',
Expand All @@ -20,7 +20,7 @@ const send = async () => {
`Attempting to send transaction from ${accountFrom.address} to ${addressTo}`
);

// 4. Prepare and sign tx with PK
// 4. Sign transaction with PK
const createTransaction = await web3.eth.accounts.signTransaction(
{
gas: 21000,
Expand All @@ -32,7 +32,7 @@ const send = async () => {
accountFrom.privateKey
);

// 5. Send tx and wait for receipt
// 5. Send transaction and wait for receipt
const createReceipt = await web3.eth.sendSignedTransaction(
createTransaction.rawTransaction
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# 1. Add import
from web3 import Web3

# 1. Add the Web3 provider logic here:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiPromise, WsProvider } from '@polkadot/api';

const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network');

const main = async () => {
const polkadotApi = await ApiPromise.create({
provider: wsProvider,
});

const balances = await polkadotApi.query.balances.account('INSERT_ADDRESS');
console.log(balances.toHuman());
};

main();
14 changes: 14 additions & 0 deletions .snippets/code/builders/get-started/eth-compare/balances/locks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiPromise, WsProvider } from '@polkadot/api';

const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network');

const main = async () => {
const polkadotApi = await ApiPromise.create({
provider: wsProvider,
});

const locks = await polkadotApi.query.balances.locks('INSERT_ADDRESS');
console.log(locks.toHuman());
};

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ParticleNetwork } from '@particle-network/auth';
import { Moonbeam } from '@particle-network/chains';
import { ParticleProvider } from '@particle-network/provider';
import { SmartAccount } from '@particle-network/aa';

// Project ID, Client Key, and App ID from https://dashboard.particle.network
const config = {
projectId: process.env.REACT_APP_PROJECT_ID,
clientKey: process.env.REACT_APP_CLIENT_KEY,
appId: process.env.REACT_APP_APP_ID,
};

const particle = new ParticleNetwork({
...config,
chainName: Moonbeam.name,
chainId: Moonbeam.id,
wallet: { displayWalletEntry: true },
});

// If using ERC-4337 AA
const provider = new ParticleProvider(particle.auth);
const smartAccount = new SmartAccount(provider, {
...config,
aaOptions: {
accountContracts: {
SIMPLE: [
{
version: '1.0.0',
chainIds: [Moonbeam.id],
},
],
},
},
});

// Sets wallet UI to use AA mode
particle.setERC4337({
name: 'SIMPLE',
version: '1.0.0',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ParticleNetwork } from '@particle-network/auth';
import { Moonbeam } from '@particle-network/chains';

// Project ID, Client Key, and App ID from https://dashboard.particle.network
const config = {
projectId: process.env.REACT_APP_PROJECT_ID,
clientKey: process.env.REACT_APP_CLIENT_KEY,
appId: process.env.REACT_APP_APP_ID,
};

const particle = new ParticleNetwork({
...config,
chainName: Moonbeam.name,
chainId: Moonbeam.id,
wallet: { displayWalletEntry: true },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ParticleNetwork } from '@particle-network/auth';
import { Moonbeam } from '@particle-network/chains';
import { ParticleProvider } from '@particle-network/provider';
import { SmartAccount, AAWrapProvider } from '@particle-network/aa';
import { ethers } from 'ethers';

// Project ID, Client Key, and App ID from https://dashboard.particle.network
const config = {
projectId: process.env.REACT_APP_PROJECT_ID,
clientKey: process.env.REACT_APP_CLIENT_KEY,
appId: process.env.REACT_APP_APP_ID,
};

const particle = new ParticleNetwork({
...config,
chainName: Moonbeam.name,
chainId: Moonbeam.id,
wallet: { displayWalletEntry: true },
});

// If using ERC-4337 AA
const provider = new ParticleProvider(particle.auth);
const smartAccount = new SmartAccount(provider, {
...config,
aaOptions: {
accountContracts: {
SIMPLE: [
{
version: '1.0.0',
chainIds: [Moonbeam.id],
},
],
},
},
});

// Sets wallet UI to use AA mode
particle.setERC4337({
name: 'SIMPLE',
version: '1.0.0',
});

// Uses custom EIP-1193 AA provider
const wrapProvider = new AAWrapProvider(smartAccount);
const customProvider = new ethers.BrowserProvider(wrapProvider);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ParticleNetwork } from '@particle-network/auth';
import { Moonbeam } from '@particle-network/chains';
import { ParticleProvider } from '@particle-network/provider';
import { SmartAccount, AAWrapProvider } from '@particle-network/aa';
import { Web3 } from 'web3';

// Project ID, Client Key, and App ID from https://dashboard.particle.network
const config = {
projectId: process.env.REACT_APP_PROJECT_ID,
clientKey: process.env.REACT_APP_CLIENT_KEY,
appId: process.env.REACT_APP_APP_ID,
};

const particle = new ParticleNetwork({
...config,
chainName: Moonbeam.name,
chainId: Moonbeam.id,
wallet: { displayWalletEntry: true },
});

// If using ERC-4337 AA
const provider = new ParticleProvider(particle.auth);
const smartAccount = new SmartAccount(provider, {
...config,
aaOptions: {
accountContracts: {
SIMPLE: [
{
version: '1.0.0',
chainIds: [Moonbeam.id],
},
],
},
},
});

// Sets wallet UI to use AA mode
particle.setERC4337({
name: 'SIMPLE',
version: '1.0.0',
});

// Uses custom EIP-1193 AA provider
const wrapProvider = new AAWrapProvider(smartAccount);
const customProvider = new Web3(wrapProvider);
Loading

0 comments on commit d30dcae

Please sign in to comment.