-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polkadot XCM Pallet Documentation (#1022)
* update * edit * rev * run grammarly * run prettier * revisions * rev
- Loading branch information
1 parent
9261932
commit dfcb153
Showing
24 changed files
with
497 additions
and
27 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
4 changes: 2 additions & 2 deletions
4
...e/builders/ethereum/precompiles/utility/relay-data-verifier/web3py-relay-data-verifier.py
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
15 changes: 15 additions & 0 deletions
15
.snippets/code/builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/asset-traps.js
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,15 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://wss.api.moonbeam.network'), | ||
}); | ||
|
||
const hash = | ||
'0x166f82439fd2b25b28b82224e82ad9f26f2da26b8257e047182a6a7031accc9a'; | ||
const trapCount = await api.query.polkadotXcm.assetTraps(hash); | ||
|
||
console.log('Trap count:', trapCount.toNumber()); | ||
}; | ||
|
||
main(); |
24 changes: 24 additions & 0 deletions
24
...pets/code/builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/check-xcm-version.js
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 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://wss.api.moonbase.moonbeam.network'), | ||
}); | ||
|
||
const testLocation = { | ||
V4: { | ||
parents: 1, | ||
interior: 'Here', | ||
}, | ||
}; | ||
|
||
const supportedVersion = await api.query.polkadotXcm.supportedVersion( | ||
4, // Testing XCM v4 | ||
testLocation | ||
); | ||
|
||
console.log('Location:', JSON.stringify(testLocation, null, 2)); | ||
console.log('Supported Version:', supportedVersion.toHuman()); | ||
}; | ||
|
||
main(); |
40 changes: 40 additions & 0 deletions
40
...builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/destination-beneficiary-fee.js
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,40 @@ | ||
// dest | ||
{ | ||
V3: { | ||
parents: 1, | ||
interior: 'Here' | ||
} | ||
}, | ||
// beneficiary | ||
{ | ||
V3: { | ||
parents: 0, | ||
interior: { | ||
X1: { | ||
AccountId32: { | ||
id: Array.from(beneficiaryRaw), | ||
network: null | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
// assets | ||
{ | ||
V3: [ | ||
{ | ||
id: { | ||
Concrete: { | ||
parents: 1, | ||
interior: 'Here' | ||
} | ||
}, | ||
fun: { | ||
Fungible: '1000000000000' | ||
} | ||
} | ||
] | ||
}, | ||
0, // feeAssetItem | ||
'Unlimited' // weightLimit | ||
); |
11 changes: 11 additions & 0 deletions
11
.snippets/code/builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/pallet-version.js
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 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://wss.api.moonbase.moonbeam.network'), | ||
}); | ||
const palletVersion = await api.query.polkadotXcm.palletVersion(); | ||
console.log("The pallet version is " + palletVersion); | ||
}; | ||
|
||
main(); |
13 changes: 13 additions & 0 deletions
13
.snippets/code/builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/query-counter.js
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,13 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://wss.api.moonbeam.network'), | ||
}); | ||
|
||
const queryIndex = await api.query.polkadotXcm.queryCounter(); | ||
|
||
console.log('Query Index:', queryIndex.toNumber()); | ||
}; | ||
|
||
main(); |
13 changes: 13 additions & 0 deletions
13
...ppets/code/builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/safe-xcm-version.js
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,13 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
const api = await ApiPromise.create({ | ||
provider: new WsProvider('wss://wss.api.moonbeam.network'), | ||
}); | ||
|
||
const safeVersion = await api.query.polkadotXcm.safeXcmVersion(); | ||
|
||
console.log('Safe XCM Version:', safeVersion.toHuman()); | ||
}; | ||
|
||
main(); |
77 changes: 77 additions & 0 deletions
77
.snippets/code/builders/interoperability/xcm/xc20/send-xc20s/polkadot-xcm/send-xcm.js
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,77 @@ | ||
import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'; | ||
import { BN } from '@polkadot/util'; | ||
import { decodeAddress } from '@polkadot/util-crypto'; | ||
|
||
const main = async () => { | ||
// Setup provider and API | ||
const wsProvider = new WsProvider('wss://wss.api.moonbase.moonbeam.network'); | ||
const api = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
// Setup account with ethereum format | ||
const keyring = new Keyring({ type: 'ethereum' }); | ||
const account = keyring.addFromUri('INSERT_PRIVATE_KEY'); | ||
|
||
// Convert the SS58 address to raw bytes | ||
const beneficiaryRaw = decodeAddress('INSERT_DESTINATION_ADDRESS'); | ||
|
||
try { | ||
// Create the transaction | ||
const tx = api.tx.polkadotXcm.transferAssets( | ||
// dest | ||
{ | ||
V3: { | ||
parents: 1, | ||
interior: 'Here', | ||
}, | ||
}, | ||
// beneficiary | ||
{ | ||
V3: { | ||
parents: 0, | ||
interior: { | ||
X1: { | ||
AccountId32: { | ||
id: Array.from(beneficiaryRaw), | ||
network: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
// assets | ||
{ | ||
V3: [ | ||
{ | ||
id: { | ||
Concrete: { | ||
parents: 1, | ||
interior: 'Here', | ||
}, | ||
}, | ||
fun: { | ||
Fungible: '1000000000000', | ||
}, | ||
}, | ||
], | ||
}, | ||
0, // feeAssetItem | ||
'Unlimited' // weightLimit | ||
); | ||
|
||
// Sign and send the transaction, displaying the transaction hash | ||
const unsub = await tx.signAndSend(account, ({ status, events }) => { | ||
if (status.isInBlock) { | ||
console.log(`Transaction included in blockHash ${status.asInBlock}`); | ||
} else if (status.isFinalized) { | ||
console.log(`Transaction finalized in blockHash ${status.asFinalized}`); | ||
unsub(); | ||
process.exit(0); | ||
} | ||
}); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
main().catch(console.error); |
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
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
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
2 changes: 1 addition & 1 deletion
2
...ext/builders/interoperability/xcm/calculate-multilocation-derivative-account.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
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
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
Oops, something went wrong.