Skip to content

Commit

Permalink
fix: decoupling from substrate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nhussein11 committed Oct 2, 2024
1 parent 9b22d91 commit 510ab2d
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion);

let callInfo;
try {
callInfo = await assetApi.createTransferTransaction(
"2004",
"0xF977814e90dA44bFA03b6295A0616a897441aceC",
'2004',
'0xF977814e90dA44bFA03b6295A0616a897441aceC',
[],
["1000000000000000000"],
['1000000000000000000'],
{
format: "call",
format: 'call',
keepAlive: true,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand All @@ -28,7 +28,7 @@ async function main() {
throw Error(e as string);
}

const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call");
const decoded = assetApi.decodeExtrinsic(callInfo.tx, 'call');
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://moonriver.public.blastapi.io"
'wss://moonriver.public.blastapi.io',
);
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion);
let callInfo;
try {
callInfo = await assetApi.createTransferTransaction(
"2001",
"0xc4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a063",
["vMOVR", "72145018963825376852137222787619937732"],
["1000000", "10000000000"],
'2001',
'0xc4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a063',
['vMOVR', '72145018963825376852137222787619937732'],
['1000000', '10000000000'],
{
format: "call",
format: 'call',
xcmVersion: safeXcmVersion,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand All @@ -27,7 +27,7 @@ async function main() {
throw Error(e as string);
}

const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call");
const decoded = assetApi.decodeExtrinsic(callInfo.tx, 'call');
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://westend-rpc.polkadot.io"
'wss://westend-rpc.polkadot.io',
);
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion);
let callInfo;
try {
callInfo = await assetApi.createTransferTransaction(
"1000",
"5EWNeodpcQ6iYibJ3jmWVe85nsok1EDG8Kk3aFg8ZzpfY1qX",
["WND"],
["1000000000000"],
'1000',
'5EWNeodpcQ6iYibJ3jmWVe85nsok1EDG8Kk3aFg8ZzpfY1qX',
['WND'],
['1000000000000'],
{
format: "call",
format: 'call',
xcmVersion: safeXcmVersion,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand All @@ -27,7 +27,7 @@ async function main() {
throw Error(e as string);
}

const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call");
const decoded = assetApi.decodeExtrinsic(callInfo.tx, 'call');
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"INSERT_WEBSOCKET_URL"
'INSERT_WEBSOCKET_URL',
);

const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://westend-rpc.polkadot.io"
'wss://westend-rpc.polkadot.io',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

Expand All @@ -15,12 +15,12 @@ async function main() {
[
`{"parents":"0","interior":{"X2":[{"PalletInstance":"50"},{"GeneralIndex":"1984"}]}}`,
],
["1000000000000"],
"0xf5d5714c084c112843aca74f8c498da06cc5a2d63153b825189baa51043b1f0b",
['1000000000000'],
'0xf5d5714c084c112843aca74f8c498da06cc5a2d63153b825189baa51043b1f0b',
{
format: "call",
format: 'call',
xcmVersion: 2,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

let callInfo;
try {
callInfo = await assetsApi.createTransferTransaction(
"2004",
"0xF977814e90dA44bFA03b6295A0616a897441aceC",
'2004',
'0xF977814e90dA44bFA03b6295A0616a897441aceC',
[],
["1000000000000000000"],
['1000000000000000000'],
{
format: "call",
format: 'call',
keepAlive: true,
}
},
);

console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

const encodedExt = "0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600";
const encodedExt = '0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600';

try {
const decodedExt = assetsApi.decodeExtrinsic(encodedExt, "call");
const decodedExt = assetsApi.decodeExtrinsic(encodedExt, 'call');
console.log(
`Decoded tx:\n ${JSON.stringify(JSON.parse(decodedExt), null, 4)}`
`Decoded tx:\n ${JSON.stringify(JSON.parse(decodedExt), null, 4)}`,
);
} catch (e) {
console.error(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
AssetTransferApi,
constructApiPromise,
} from "@substrate/asset-transfer-api";
} from '@substrate/asset-transfer-api';

async function main() {
const { api, specName, safeXcmVersion } = await constructApiPromise(
"wss://wss.api.moonbeam.network"
'wss://wss.api.moonbeam.network',
);
const assetsApi = new AssetTransferApi(api, specName, safeXcmVersion);

const encodedExt = "0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600";
const encodedExt = '0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600';

try {
const decodedExt = await assetsApi.fetchFeeInfo(encodedExt, "call");
const decodedExt = await assetsApi.fetchFeeInfo(encodedExt, 'call');
console.log(`Fee info:\n${JSON.stringify(decodedExt, null, 4)}`);
} catch (e) {
console.error(e);
Expand All @@ -22,4 +22,4 @@ async function main() {

main()
.catch((err) => console.error(err))
.finally(() => process.exit());
.finally(() => process.exit());
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Format = "payload" | "call" | "submittable";
export type Format = 'payload' | 'call' | 'submittable';
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ If command-line help is displayed, the node is ready to configure.
## Relay Chain Configuration
Every Substrate-based chain requires a [chain specification](https://docs.substrate.io/build/chain-spec/){target=\_blank}. The relay chain's chain specification provides the same configuration settings as the chain specification for other networks. Many of the chain specification file settings are critical for network operations. For example, the chain specification identifies peers participating in the network, keys for validators, bootnode addresses, and other information.
Every Substrate-based chain requires a [chain specification](TODO:update-path){target=\_blank}. The relay chain's chain specification provides the same configuration settings as the chain specification for other networks. Many of the chain specification file settings are critical for network operations. For example, the chain specification identifies peers participating in the network, keys for validators, bootnode addresses, and other information.

### Sample Chain Configuration

Expand Down

0 comments on commit 510ab2d

Please sign in to comment.