Created
February 14, 2023 11:39
-
-
Save mrshiposha/29ab4a80e1eee3af27af50fde5d6db7f to your computer and use it in GitHub Desktop.
Cross-chain NFT transfer using XCM v3
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
vec![ | |
ClaimAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
ticket: Here, | |
}, | |
BuyExecution { | |
fees: FEE_AMOUNT, | |
weight: XCM_WEIGHT, | |
}, | |
InitiateReserveWithdraw { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
reserve: ParentThen(NFT_NATIVE_CHAIN_ID), | |
xcm: vec![ | |
DepositReserveAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
dest: ParentThen(SENDER_CHAIN), | |
xcm: vec![ | |
DepositAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
beneficiary: ORIGINAL_NFT_OWNER, | |
} | |
].into(), | |
} | |
].into() | |
} | |
] |
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
vec![ | |
InitiateReserveWithdraw { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
reserve: ParentThen(NFT_NATIVE_CHAIN_ID), | |
xcm: vec![ | |
BuyExecution { | |
fees: FEE_AMOUNT, | |
weight: XCM_WEIGHT, | |
}, | |
DepositReserveAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
dest: ParentThen(TARGET_CHAIN), | |
xcm: vec![ | |
SetAppendix(vec![ | |
ReportError { | |
destination: ParentThen(SENDER_CHAIN), | |
query_id: SENDER_QUERY_ID, | |
max_weight: SENDER_MAX_WEIGHT, | |
}, | |
].into()), | |
DepositAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
beneficiary: ParentThen(SENDER_CHAIN), // temporary location -- sovereign account | |
}, | |
].into(), | |
} | |
].into(), | |
} | |
] |
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
vec![ | |
BuyExecution { | |
fees: FEE_AMOUNT, | |
weight: XCM_WEIGHT, | |
}, | |
SetAppendix(vec![ | |
ReportError { | |
destination: ParentThen(SENDER_CHAIN), | |
query_id: SENDER_QUERY_ID, | |
max_weight: SENDER_MAX_WEIGHT, | |
}, | |
].into()), | |
SetErrorHandler(vec![ | |
RefundSurplus, | |
InitiateReserveWithdraw { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
reserve: ParentThen(NFT_NATIVE_CHAIN_ID), | |
xcm: vec![ | |
DepositReserveAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
dest: ParentThen(SENDER_CHAIN), | |
xcm: vec![ | |
DepositAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
beneficiary: ORIGINAL_NFT_OWNER, | |
} | |
].into(), | |
} | |
].into() | |
} | |
].into()), | |
Transact { | |
origin_type: OriginKind::SovereignAccount, | |
require_weight_at_most: WEIGHT, | |
call: APPLY_METADATA_EXTRINSIC, | |
}, | |
ExpectTransactStatus(Success), | |
WithdrawAsset(vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into()), | |
DepositAsset { | |
assets: vec![ | |
(ParentThen(NFT_NATIVE_CHAIN_ID), NFT_ID).into(), | |
].into(), | |
beneficiary: TARGET_OWNER, | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment