Skip to content

Commit ec6c614

Browse files
eshabennhussein11
andcommitted
Update the layout of the JSON RPC page (#383)
* reformat the json rpc api page * Apply suggestions from code review Co-authored-by: Nicolás Hussein <[email protected]> --------- Co-authored-by: Nicolás Hussein <[email protected]>
1 parent 8ef08ce commit ec6c614

File tree

8 files changed

+445
-362
lines changed

8 files changed

+445
-362
lines changed

.snippets/code/develop/smart-contracts/evm-toolkit/ethers-js/checkStorage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const interactWithStorageContract = async (
2828
contractAddress,
2929
mnemonic,
3030
providerConfig,
31-
numberToSet
31+
numberToSet,
3232
) => {
3333
try {
3434
console.log(`Setting new number in Storage contract: ${numberToSet}`);
@@ -79,5 +79,5 @@ interactWithStorageContract(
7979
contractAddress,
8080
mnemonic,
8181
providerConfig,
82-
newNumber
82+
newNumber,
8383
);

.snippets/code/develop/smart-contracts/evm-toolkit/ethers-js/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const compileContract = async (solidityFilePath, outputDir) => {
3030
const bytecodePath = join(outputDir, `${name}.polkavm`);
3131
writeFileSync(
3232
bytecodePath,
33-
Buffer.from(contract.evm.bytecode.object, 'hex')
33+
Buffer.from(contract.evm.bytecode.object, 'hex'),
3434
);
3535
console.log(`Bytecode saved to ${bytecodePath}`);
3636
}

.snippets/code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ const createProvider = (rpcUrl, chainId, chainName) => {
1717
const getAbi = (contractName) => {
1818
try {
1919
return JSON.parse(
20-
readFileSync(join(codegenDir, `${contractName}.json`), 'utf8')
20+
readFileSync(join(codegenDir, `${contractName}.json`), 'utf8'),
2121
);
2222
} catch (error) {
2323
console.error(
2424
`Could not find ABI for contract ${contractName}:`,
25-
error.message
25+
error.message,
2626
);
2727
throw error;
2828
}
@@ -32,12 +32,12 @@ const getAbi = (contractName) => {
3232
const getByteCode = (contractName) => {
3333
try {
3434
return `0x${readFileSync(
35-
join(codegenDir, `${contractName}.polkavm`)
35+
join(codegenDir, `${contractName}.polkavm`),
3636
).toString('hex')}`;
3737
} catch (error) {
3838
console.error(
3939
`Could not find bytecode for contract ${contractName}:`,
40-
error.message
40+
error.message,
4141
);
4242
throw error;
4343
}
@@ -51,7 +51,7 @@ const deployContract = async (contractName, mnemonic, providerConfig) => {
5151
const provider = createProvider(
5252
providerConfig.rpc,
5353
providerConfig.chainId,
54-
providerConfig.name
54+
providerConfig.name,
5555
);
5656
const walletMnemonic = ethers.Wallet.fromPhrase(mnemonic);
5757
const wallet = walletMnemonic.connect(provider);
@@ -60,7 +60,7 @@ const deployContract = async (contractName, mnemonic, providerConfig) => {
6060
const factory = new ethers.ContractFactory(
6161
getAbi(contractName),
6262
getByteCode(contractName),
63-
wallet
63+
wallet,
6464
);
6565
const contract = await factory.deploy();
6666
await contract.waitForDeployment();

.snippets/code/develop/smart-contracts/evm-toolkit/ethers-js/fetchLastBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const main = async () => {
2020
const provider = createProvider(
2121
PROVIDER_RPC.rpc,
2222
PROVIDER_RPC.chainId,
23-
PROVIDER_RPC.name
23+
PROVIDER_RPC.name,
2424
);
2525
const latestBlock = await provider.getBlockNumber();
2626
console.log(`Latest block: ${latestBlock}`);
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { JsonRpcProvider } from 'ethers';
22

33
const provider = new JsonRpcProvider(
4-
'https://westend-asset-hub-eth-rpc.polkadot.io'
4+
'https://westend-asset-hub-eth-rpc.polkadot.io',
55
);

.snippets/code/tutorials/interoperability/xcm-transfers/from-relaychain-to-parachain/reserve-backed-transfer.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import { Binary } from 'polkadot-api';
2525

2626
// Create Polkadot client using WebSocket provider for Polkadot chain
2727
const polkadotClient = createClient(
28-
withPolkadotSdkCompat(getWsProvider('ws://127.0.0.1:8001'))
28+
withPolkadotSdkCompat(getWsProvider('ws://127.0.0.1:8001')),
2929
);
3030
const dotApi = polkadotClient.getTypedApi(dot);
3131

3232
// Create Astar client using WebSocket provider for Astar chain
3333
const astarClient = createClient(
34-
withPolkadotSdkCompat(getWsProvider('ws://localhost:8000'))
34+
withPolkadotSdkCompat(getWsProvider('ws://localhost:8000')),
3535
);
3636
const astarApi = astarClient.getTypedApi(astar);
3737

@@ -42,7 +42,7 @@ const aliceKeyPair = derive('//Alice');
4242
const alice = getPolkadotSigner(
4343
aliceKeyPair.publicKey,
4444
'Sr25519',
45-
aliceKeyPair.sign
45+
aliceKeyPair.sign,
4646
);
4747

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

@@ -65,7 +65,7 @@ const tx = dotApi.tx.XcmPallet.limited_reserve_transfer_assets({
6565
dest: XcmVersionedLocation.V3({
6666
parents: 0,
6767
interior: XcmV3Junctions.X1(
68-
XcmV3Junction.Parachain(2006) // Destination is the Astar parachain
68+
XcmV3Junction.Parachain(2006), // Destination is the Astar parachain
6969
),
7070
}),
7171
beneficiary: XcmVersionedLocation.V3({
@@ -75,7 +75,7 @@ const tx = dotApi.tx.XcmPallet.limited_reserve_transfer_assets({
7575
// Beneficiary address on Astar
7676
network: undefined,
7777
id: idBenef,
78-
})
78+
}),
7979
),
8080
}),
8181
assets: XcmVersionedAssets.V3([
@@ -110,7 +110,7 @@ await new Promise((resolve) => setTimeout(resolve, 20000));
110110
// Fetch asset balance of recipient (Dave) after transaction
111111
assetMetadata = await astarApi.query.Assets.Account.getValue(
112112
polkadotAssetId,
113-
daveAddress
113+
daveAddress,
114114
);
115115
console.log('Asset balance after tx:', assetMetadata?.balance ?? 0);
116116

.snippets/code/tutorials/polkadot-sdk/testing/spawn-basic-chain/connect-to-alice-01.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function main() {
1212
]);
1313

1414
console.log(
15-
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`
15+
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`,
1616
);
1717
}
1818

0 commit comments

Comments
 (0)