-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into nhussein11/tutorial…
…s-substrate-acquire-a-testnet-slot
- Loading branch information
Showing
61 changed files
with
1,534 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
echo "Running Prettier on .snippets/code/**/*.{js,json,html}" | ||
npx prettier --write .snippets/code/**/*.{js,json,html} | ||
|
||
echo "Running Taplo to format TOML files" | ||
npx taplo fmt .snippets/code/**/*.toml | ||
|
||
echo "Adding formatted files back to the commit..." | ||
git add .snippets/code/**/*.{js,json,html,toml} |
24 changes: 24 additions & 0 deletions
24
...evelop/application-devs/tooling/asset-transfer-api/overview/localParachainTx.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div id="termynal" data-termynal> | ||
<span data-ty="input"><span class="file-path"></span>ts-node localParachainTx.ts</span> | ||
<br> | ||
<span data-ty>Call data:</span> | ||
<span data-ty>{</span> | ||
<span data-ty> "origin": "moonbeam",</span> | ||
<span data-ty> "dest": "moonbeam",</span> | ||
<span data-ty> "direction": "local",</span> | ||
<span data-ty> "xcmVersion": null,</span> | ||
<span data-ty> "method": "balances::transferKeepAlive",</span> | ||
<span data-ty> "format": "call",</span> | ||
<span data-ty> "tx": "0x0a03f977814e90da44bfa03b6295a0616a897441acec821a0600"</span> | ||
<span data-ty>}</span> | ||
<span data-ty></span> | ||
<span data-ty>Decoded tx:</span> | ||
<span data-ty>{</span> | ||
<span data-ty> "args": {</span> | ||
<span data-ty> "dest": "0xF977814e90dA44bFA03b6295A0616a897441aceC",</span> | ||
<span data-ty> "value": "1,000,000,000,000,000,000"</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "method": "transferKeepAlive",</span> | ||
<span data-ty> "section": "balances"</span> | ||
<span data-ty>}</span> | ||
</div> |
37 changes: 37 additions & 0 deletions
37
...ets/code/develop/application-devs/tooling/asset-transfer-api/overview/localParachainTx.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
AssetTransferApi, | ||
constructApiPromise, | ||
} from "@substrate/asset-transfer-api"; | ||
|
||
async function main() { | ||
const { api, specName, safeXcmVersion } = await constructApiPromise( | ||
"wss://wss.api.moonbeam.network" | ||
); | ||
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion); | ||
|
||
let callInfo; | ||
try { | ||
callInfo = await assetApi.createTransferTransaction( | ||
"2004", | ||
"0xF977814e90dA44bFA03b6295A0616a897441aceC", | ||
[], | ||
["1000000000000000000"], | ||
{ | ||
format: "call", | ||
keepAlive: true, | ||
} | ||
); | ||
|
||
console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`); | ||
} catch (e) { | ||
console.error(e); | ||
throw Error(e as string); | ||
} | ||
|
||
const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call"); | ||
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`); | ||
} | ||
|
||
main() | ||
.catch((err) => console.error(err)) | ||
.finally(() => process.exit()); |
87 changes: 87 additions & 0 deletions
87
...code/develop/application-devs/tooling/asset-transfer-api/overview/paraToPara.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<div id='termynal' data-termynal> | ||
<span data-ty='input'><span class='file-path'></span>ts-node paraToPara.ts</span> | ||
|
||
<br> | ||
<span data-ty>Call data:</span> | ||
<span data-ty>{</span> | ||
<span data-ty> "origin": "moonriver",</span> | ||
<span data-ty> "dest": "bifrost",</span> | ||
<span data-ty> "direction": "ParaToPara",</span> | ||
<span data-ty> "xcmVersion": 2,</span> | ||
<span data-ty> "method": "transferMultiassets",</span> | ||
<span data-ty> "format": "call",</span> | ||
<span data-ty> "tx": "0x6a05010800010200451f06080101000700e40b540200010200451f0608010a0002093d000000000001010200451f0100c4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a06300"</span> | ||
<span data-ty>}</span> | ||
<span data-ty></span> | ||
<span data-ty>Decoded tx:</span> | ||
<span data-ty>{</span> | ||
<span data-ty> "args": {</span> | ||
<span data-ty> "assets": {</span> | ||
<span data-ty> "V2": [</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "id": {</span> | ||
<span data-ty> "Concrete": {</span> | ||
<span data-ty> "parents": "1",</span> | ||
<span data-ty> "interior": {</span> | ||
<span data-ty> "X2": [</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "Parachain": "2,001"</span> | ||
<span data-ty> },</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "GeneralKey": "0x0101"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> ]</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "fun": {</span> | ||
<span data-ty> "Fungible": "10,000,000,000"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "id": {</span> | ||
<span data-ty> "Concrete": {</span> | ||
<span data-ty> "parents": "1",</span> | ||
<span data-ty> "interior": {</span> | ||
<span data-ty> "X2": [</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "Parachain": "2,001"</span> | ||
<span data-ty> },</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "GeneralKey": "0x010a"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> ]</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "fun": {</span> | ||
<span data-ty> "Fungible": "1,000,000"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> ]</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "fee_item": "0",</span> | ||
<span data-ty> "dest": {</span> | ||
<span data-ty> "V2": {</span> | ||
<span data-ty> "parents": "1",</span> | ||
<span data-ty> "interior": {</span> | ||
<span data-ty> "X2": [</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "Parachain": "2,001"</span> | ||
<span data-ty> },</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "AccountId32": {</span> | ||
<span data-ty> "network": "Any",</span> | ||
<span data-ty> "id": "0xc4db7bcb733e117c0b34ac96354b10d47e84a006b9e7e66a229d174e8ff2a063"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> ]</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "dest_weight_limit": "Unlimited"</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "method": "transferMultiassets",</span> | ||
<span data-ty> "section": "xTokens"</span> | ||
<span data-ty>}</span> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
.snippets/code/develop/application-devs/tooling/asset-transfer-api/overview/paraToPara.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
AssetTransferApi, | ||
constructApiPromise, | ||
} from "@substrate/asset-transfer-api"; | ||
|
||
async function main() { | ||
const { api, specName, safeXcmVersion } = await constructApiPromise( | ||
"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"], | ||
{ | ||
format: "call", | ||
xcmVersion: safeXcmVersion, | ||
} | ||
); | ||
|
||
console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`); | ||
} catch (e) { | ||
console.error(e); | ||
throw Error(e as string); | ||
} | ||
|
||
const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call"); | ||
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`); | ||
} | ||
|
||
main() | ||
.catch((err) => console.error(err)) | ||
.finally(() => process.exit()); |
62 changes: 62 additions & 0 deletions
62
...e/develop/application-devs/tooling/asset-transfer-api/overview/relayToSystem.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<div id="termynal" data-termynal> | ||
<span data-ty="input"><span class="file-path"></span>ts-node relayToSystem.ts</span> | ||
<br> | ||
<span data-ty>Call data:</span> | ||
<span data-ty>{</span> | ||
<span data-ty> "origin": "westend",</span> | ||
<span data-ty> "dest": "westmint",</span> | ||
<span data-ty> "direction": "RelayToSystem",</span> | ||
<span data-ty> "xcmVersion": 3,</span> | ||
<span data-ty> "method": "transferAssets",</span> | ||
<span data-ty> "format": "call",</span> | ||
<span data-ty> "tx": "0x630b03000100a10f03000101006c0c32faf970eacb2d4d8e538ac0dab3642492561a1be6f241c645876c056c1d030400000000070010a5d4e80000000000"</span> | ||
<span data-ty>}</span> | ||
<span data-ty></span> | ||
<span data-ty>Decoded tx:</span> | ||
<span data-ty>{</span> | ||
<span data-ty> "args": {</span> | ||
<span data-ty> "dest": {</span> | ||
<span data-ty> "V3": {</span> | ||
<span data-ty> "parents": "0",</span> | ||
<span data-ty> "interior": {</span> | ||
<span data-ty> "X1": {</span> | ||
<span data-ty> "Parachain": "1,000"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "beneficiary": {</span> | ||
<span data-ty> "V3": {</span> | ||
<span data-ty> "parents": "0",</span> | ||
<span data-ty> "interior": {</span> | ||
<span data-ty> "X1": {</span> | ||
<span data-ty> "AccountId32": {</span> | ||
<span data-ty> "network": null,</span> | ||
<span data-ty> "id": "0x6c0c32faf970eacb2d4d8e538ac0dab3642492561a1be6f241c645876c056c1d"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "assets": {</span> | ||
<span data-ty> "V3": [</span> | ||
<span data-ty> {</span> | ||
<span data-ty> "id": {</span> | ||
<span data-ty> "Concrete": {</span> | ||
<span data-ty> "parents": "0",</span> | ||
<span data-ty> "interior": "Here"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "fun": {</span> | ||
<span data-ty> "Fungible": "1,000,000,000,000"</span> | ||
<span data-ty> }</span> | ||
<span data-ty> }</span> | ||
<span data-ty> ]</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "fee_asset_item": "0",</span> | ||
<span data-ty> "weight_limit": "Unlimited"</span> | ||
<span data-ty> },</span> | ||
<span data-ty> "method": "transferAssets",</span> | ||
<span data-ty> "section": "xcmPallet"</span> | ||
<span data-ty>}</span> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
.snippets/code/develop/application-devs/tooling/asset-transfer-api/overview/relayToSystem.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
AssetTransferApi, | ||
constructApiPromise, | ||
} from "@substrate/asset-transfer-api"; | ||
|
||
async function main() { | ||
const { api, specName, safeXcmVersion } = await constructApiPromise( | ||
"wss://westend-rpc.polkadot.io" | ||
); | ||
const assetApi = new AssetTransferApi(api, specName, safeXcmVersion); | ||
let callInfo; | ||
try { | ||
callInfo = await assetApi.createTransferTransaction( | ||
"1000", | ||
"5EWNeodpcQ6iYibJ3jmWVe85nsok1EDG8Kk3aFg8ZzpfY1qX", | ||
["WND"], | ||
["1000000000000"], | ||
{ | ||
format: "call", | ||
xcmVersion: safeXcmVersion, | ||
} | ||
); | ||
|
||
console.log(`Call data:\n${JSON.stringify(callInfo, null, 4)}`); | ||
} catch (e) { | ||
console.error(e); | ||
throw Error(e as string); | ||
} | ||
|
||
const decoded = assetApi.decodeExtrinsic(callInfo.tx, "call"); | ||
console.log(`\nDecoded tx:\n${JSON.stringify(JSON.parse(decoded), null, 4)}`); | ||
} | ||
|
||
main() | ||
.catch((err) => console.error(err)) | ||
.finally(() => process.exit()); |
Oops, something went wrong.