git.delta.rocks / unique-network / refs/commits / b3ebe07cdd5d

difftreelog

Karura

str-mv2022-01-17parent: #de5ac2f.patch.diff
in: master

3 files changed

modifiedREADME.mddiffbeforeafterboth
333*/333*/
334334
335```335```
336
337
338## Karura token transfer
339
340To get started, you need to open the hrmr channel.
341Next, we need to register our asset in Karura.
342
343assetRegistry -> registerForeignAsset(location, metadata)
344location:
345 V0(X2(Parent, Parachain(PARA_ID)))
346metadata:
347 name OPL
348 symbol OPL
349 decimals 15
350minimalBalance 1
351
352Next, we can send tokens of our chain:
353polkadotXcm -> reserveTransferAssets
354dest:
355 V0(X2(Parent, Parachain(KARURA_PARA_ID)))
356beneficiary:
357 X1(AccountId(Any, ACCOUNT))
358assets:
359 V1(Concrete(0,Here), Fungible(AMOUNT))
360feeAssetItem:
361 0
362weightLimit:
363 Limit
364
365
366The result will be displayed in ChainState
367tokens -> accounts
336368
modifiedlaunch-config.jsondiffbeforeafterboth
9 "rpcPort": 9843,9 "rpcPort": 9843,
10 "port": 30444,10 "port": 30444,
11 "flags": [11 "flags": [
12 "-lparachain::candidate_validation=debug"12 "-lparachain::candidate_validation=debug",
13 "-lxcm=trace"
13 ]14 ]
14 },15 },
15 {16 {
18 "rpcPort": 9854,19 "rpcPort": 9854,
19 "port": 30555,20 "port": 30555,
20 "flags": [21 "flags": [
21 "-lparachain::candidate_validation=debug"22 "-lparachain::candidate_validation=debug",
23 "-lxcm=trace"
22 ]24 ]
23 },25 },
24 {26 {
67 "flags": [69 "flags": [
68 "--rpc-cors=all",70 "--rpc-cors=all",
69 "--unsafe-rpc-external",71 "--unsafe-rpc-external",
70 "--unsafe-ws-external"72 "--unsafe-ws-external",
73 "-lxcm=trace"
71 ]74 ]
72 },75 },
73 {76 {
78 "flags": [81 "flags": [
79 "--rpc-cors=all",82 "--rpc-cors=all",
80 "--unsafe-rpc-external",83 "--unsafe-rpc-external",
81 "--unsafe-ws-external"84 "--unsafe-ws-external",
85 "-lxcm=trace"
82 ]86 ]
83 }87 }
84 ]88 ]
85 }89 },
90 {
91 "bin": "../Acala/target/release/acala",
92 "id": "2000",
93 "chain": "karura-dev",
94 "balance": "1000000000000000000000",
95 "nodes": [
96 {
97 "wsPort": 9988,
98 "port": 31200,
99 "name": "alice",
100 "flags": [
101 "--rpc-cors=all",
102 "--unsafe-rpc-external",
103 "--unsafe-ws-external",
104 "-lxcm=trace"
105 ]
106 }
107 ]
108 }
86 ],109 ],
87 "simpleParachains": [],110 "simpleParachains": [],
88 "hrmpChannels": [],111 "hrmpChannels": [
112 {
113 "sender": 2000,
114 "recipient": 1000,
115 "maxCapacity": 8,
116 "maxMessageSize": 512
117 },
118 {
119 "sender": 1000,
120 "recipient": 2000,
121 "maxCapacity": 8,
122 "maxMessageSize": 512
123 }
124 ],
89 "finalization": false125 "finalization": false
90}126}
modifiedruntime/src/lib.rsdiffbeforeafterboth
82use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};82use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};
83use xcm_builder::{83use xcm_builder::{
84 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,84 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
85 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,85 EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset,
86 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,86 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,
87 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,87 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
88 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,88 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
89};89};
90use xcm_executor::{Config, XcmExecutor};90use xcm_executor::{Config, XcmExecutor};
91
92use xcm::latest::{
93// Xcm,
94 AssetId::{Concrete},
95 Fungibility::Fungible as XcmFungible,
96 MultiAsset
97};
98use xcm_executor::traits::MatchesFungible;
99use sp_runtime::traits::CheckedConversion;
91100
92// mod chain_extension;101// mod chain_extension;
93// use crate::chain_extension::{NFTExtension, Imbalance};102// use crate::chain_extension::{NFTExtension, Imbalance};
617);626);
627
628
629pub struct OnlySelfCurrency;
630impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
631 fn matches_fungible(a: &MultiAsset) -> Option<B> {
632 match (&a.id, &a.fun) {
633 (Concrete(_), XcmFungible(ref amount)) =>
634 CheckedConversion::checked_from(*amount),
635 _ => None,
636 }
637 }
638}
618639
619/// Means for transacting assets on this chain.640/// Means for transacting assets on this chain.
620pub type LocalAssetTransactor = CurrencyAdapter<641pub type LocalAssetTransactor = CurrencyAdapter<
621 // Use this currency:642 // Use this currency:
622 Balances,643 Balances,
623 // Use this currency when it is a fungible asset matching the given location or name:644 // Use this currency when it is a fungible asset matching the given location or name:
624 IsConcrete<RelayLocation>,645 OnlySelfCurrency,
625 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:646 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
626 LocationToAccountId,647 LocationToAccountId,
627 // Our chain's account ID type (we can't get away without mentioning it explicitly):648 // Our chain's account ID type (we can't get away without mentioning it explicitly):