-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Weights, RefTime, ProofSize, RocksDB changes (#1001)
* rev * rev * ref time / 4 * rev * rev * check in commit * rev * curr status * rev * rev * format tables * rev * add * rev * rev * rev * rev * Update learn/core-concepts/tx-fees.md Co-authored-by: albertov19 <[email protected]> * rev * rev * rev * rev --------- Co-authored-by: albertov19 <[email protected]>
- Loading branch information
1 parent
361a832
commit 1630fdb
Showing
10 changed files
with
262 additions
and
78 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ilders/interoperability/xcm/core-concepts/weights-fees/query-acceptable-payment-assets.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,16 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
// Construct API provider | ||
const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); | ||
const api = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
const allowedAssets = | ||
await api.call.xcmPaymentApi.queryAcceptablePaymentAssets(4); | ||
console.log(allowedAssets); | ||
|
||
// Disconnect the API | ||
await api.disconnect(); | ||
}; | ||
|
||
main(); |
49 changes: 49 additions & 0 deletions
49
.snippets/code/builders/interoperability/xcm/core-concepts/weights-fees/query-xcm-weight.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,49 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
// Construct API provider | ||
const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); | ||
const api = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
const amountToSend = BigInt(1 * 10 ** 12); // Sending 1 token (assuming 12 decimal places) | ||
const assetMultiLocation = { | ||
parents: 0, | ||
interior: { X1: { PalletInstance: 3 } }, | ||
}; // The asset's location (adjust PalletInstance as needed) | ||
const recipientAccount = '0x1234567890abcdef1234567890abcdef12345678'; // The recipient's account on the destination chain | ||
|
||
// 2. XCM Destination (e.g., Parachain ID 2000) | ||
const dest = { V3: { parents: 1, interior: { X1: { Parachain: 2000 } } } }; | ||
|
||
// 3. XCM Instruction 1: Withdraw the asset from the sender | ||
const instr1 = { | ||
WithdrawAsset: [ | ||
{ | ||
id: { Concrete: assetMultiLocation }, | ||
fun: { Fungible: amountToSend }, | ||
}, | ||
], | ||
}; | ||
|
||
// 4. XCM Instruction 2: Deposit the asset into the recipient's account on the destination chain | ||
const instr2 = { | ||
DepositAsset: { | ||
assets: { Wild: 'All' }, // Sending all withdrawn assets (in this case, 1 token) | ||
beneficiary: { | ||
parents: 0, | ||
interior: { X1: { AccountKey20: { key: recipientAccount } } }, | ||
}, | ||
}, | ||
}; | ||
|
||
// 5. Build the XCM Message | ||
const message = { V3: [instr1, instr2] }; | ||
|
||
const theWeight = await api.call.xcmPaymentApi.queryXcmWeight(message); | ||
console.log(theWeight); | ||
|
||
// Disconnect the API | ||
await api.disconnect(); | ||
}; | ||
|
||
main(); |
26 changes: 26 additions & 0 deletions
26
...uilders/interoperability/xcm/core-concepts/weights-fees/weight-to-asset-fee-conversion.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,26 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
|
||
const main = async () => { | ||
// Construct API provider | ||
const wsProvider = new WsProvider('INSERT_WSS_ENDPOINT'); | ||
const api = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
const fee = await api.call.xcmPaymentApi.queryWeightToAssetFee( | ||
{ | ||
refTime: 10_000_000_000n, | ||
proofSize: 0n, | ||
}, | ||
{ | ||
V3: { | ||
Concrete: { parents: 1, interior: 'Here' }, | ||
}, | ||
} | ||
); | ||
|
||
console.log(fee); | ||
|
||
// Disconnect the API | ||
await api.disconnect(); | ||
}; | ||
|
||
main(); |
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
114 changes: 83 additions & 31 deletions
114
builders/interoperability/xcm/core-concepts/weights-fees.md
Large diffs are not rendered by default.
Oops, something went wrong.
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