Skip to content

Instantly share code, notes, and snippets.

@mrshiposha
Created February 14, 2023 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrshiposha/29ab4a80e1eee3af27af50fde5d6db7f to your computer and use it in GitHub Desktop.
Save mrshiposha/29ab4a80e1eee3af27af50fde5d6db7f to your computer and use it in GitHub Desktop.
Cross-chain NFT transfer using XCM v3
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()
}
]
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(),
}
]
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