sodazone / ocelloids-services

Ocelloids Service Layer
https://ocelloids.net
Apache License 2.0
9 stars 3 forks source link

Support XCM TRAPPED Notification #22

Closed XY-Wang closed 7 months ago

XY-Wang commented 7 months ago

Notify when assets gets trapped on XCM execution on intermediate or final destination. Event type should be configurable in the subscription.

XY-Wang commented 7 months ago

Instead of emitting another notification event, the AssetsTrap information, if applicable, are available in the waypoints.assetsTrap field.

⚠️ Currently we are only capturing asset traps on receiving chain, since on origin chain we only listen for successful sent events.

XY-Wang commented 7 months ago

Example notification message with asset trapped info:

{
    "type": "xcm.received",
    "subscriptionId": "moonbeam-transfers",
    "legs": [
        {
            "from": "2004",
            "to": "0"
        }
    ],
    "waypoint": {
        "chainId": "0",
        "blockNumber": "19554532",
        "blockHash": "0x532240e123300d4e68e165047af5dc3335675c18ea4b61aa0d1d944aa6e78cf7",
        "event": {
            "eventId": "19554532-6",
            "blockPosition": 6,
            "blockNumber": "19,554,532",
            "blockHash": "0x532240e123300d4e68e165047af5dc3335675c18ea4b61aa0d1d944aa6e78cf7",
            "method": "Processed",
            "section": "messageQueue",
            "index": "0x6401",
            "data": {
                "id": "0x7285df8407405d93e5c499ae80ca3fcb880709f2327da9263e8f2abd0a8ef541",
                "origin": {
                    "Ump": {
                        "Para": "2,004"
                    }
                },
                "weightUsed": {
                    "refTime": "2,546,546,981",
                    "proofSize": "128,289"
                },
                "success": true
            }
        },
        "outcome": "Success",
        "error": null,
        "assetsTrapped": {
            "event": {
                "eventId": "19554532-5",
                "blockPosition": 5,
                "blockNumber": "19,554,532",
                "blockHash": "0x532240e123300d4e68e165047af5dc3335675c18ea4b61aa0d1d944aa6e78cf7",
                "method": "AssetsTrapped",
                "section": "xcmPallet",
                "index": "0x630b",
                "data": {
                    "hash_": "0x6a435f674dd1e9e8a0a11e8adf17674f59210a8991f45f2ed0985ba8d9a5a6a0",
                    "origin": {
                        "parents": "0",
                        "interior": {
                            "X1": {
                                "Parachain": "2,004"
                            }
                        }
                    },
                    "assets": {
                        "V3": [
                            {
                                "id": {
                                    "Concrete": {
                                        "parents": "0",
                                        "interior": "Here"
                                    }
                                },
                                "fun": {
                                    "Fungible": "931,635,208"
                                }
                            }
                        ]
                    }
                }
            },
            "assets": {
                "V3": [
                    {
                        "id": {
                            "Concrete": {
                                "parents": "0",
                                "interior": "Here"
                            }
                        },
                        "fun": {
                            "Fungible": "931,635,208"
                        }
                    }
                ]
            },
            "hash": "0x6a435f674dd1e9e8a0a11e8adf17674f59210a8991f45f2ed0985ba8d9a5a6a0"
        },
        "legIndex": 0
    },
    "origin": {
        "chainId": "2004",
        "blockHash": "0xd46f01ffe32963823e870e27f75fc76c5863055f172380df5cc44a37482a1dd4",
        "blockNumber": "5554101",
        "extrinsicId": "5554101-19",
        "event": {
            "extrinsicId": "5554101-19",
            "extrinsicPosition": 2,
            "extrinsic": {
                "extrinsicId": "5554101-19",
                "blockNumber": "5,554,101",
                "blockHash": "0xd46f01ffe32963823e870e27f75fc76c5863055f172380df5cc44a37482a1dd4",
                "position": 19,
                "extraSigners": [],
                "isSigned": false,
                "method": {
                    "args": {
                        "transaction": {
                            "EIP1559": {
                                "chainId": "1,284",
                                "nonce": "117",
                                "maxPriorityFeePerGas": "0",
                                "maxFeePerGas": "550,606,818,726",
                                "gasLimit": "10,000,000",
                                "action": {
                                    "Call": "0x3b23f0675ffc45153eca239664ccaefc5e816b9c"
                                },
                                "value": "0",
                                "input": "0x79292235000000000000000000000000000000000000000000000000000000000000054d000000000000000000000000000000000000000000000000000000000000004092bd3f2458616fa5b5fd5ff200c095f1c19bf8a0acba0284bc87895be40da62b92bd3f2458616fa5b5fd5ff200c095f1c19bf8a0acba0284bc87895be40da62b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ac0b5ec8cad72000000000000000000000000000000000000000000000000000cad5c674a3abd000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000004c0000000000000000000000000000000000000000000000000000cad5c674a3abd0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000001dc6e71d54000000000000000000000000000000000000000000000000000000000000054f0000000000000000000000000000000000000000000000000000e5bd11f87d09000000000000000000000000000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000003566155ea2b900000000000000000000000000000000000000000000000000000000000005510000000000000000000000000000000000000000000000000000153874888890000000000000000000000000000000000000000000000000000000000000055200000000000000000000000000000000000000000000000000000824eef999c10000000000000000000000000000000000000000000000000000000000000553000000000000000000000000000000000000000000000000000025d03ab7061700000000000000000000000000000000000000000000000000000000000005540000000000000000000000000000000000000000000000000000233b2e4fcd8f000000000000000000000000000000000000000000000000000000000000055c0000000000000000000000000000000000000000000000000000094cf9f1ab32000000000000000000000000000000000000000000000000000000000000055d0000000000000000000000000000000000000000000000000000006a168c4521000000000000000000000000000000000000000000000000000000000000056300000000000000000000000000000000000000000000000000000bd45d11bacb00000000000000000000000000000000000000000000000000000000000005650000000000000000000000000000000000000000000000000000124837b395e10000000000000000000000000000000000000000000000000000000000000566000000000000000000000000000000000000000000000000000038bde6f0224600000000000000000000000000000000000000000000000000000000000005670000000000000000000000000000000000000000000000000000093f86d9a46b00000000000000000000000000000000000000000000000000000000000005680000000000000000000000000000000000000000000000000000012bace9528e00000000000000000000000000000000000000000000000000000000000005690000000000000000000000000000000000000000000000000000000000000000",
                                "accessList": [],
                                "oddYParity": false,
                                "r": "0x14e23f65793b465e88a00f7d7e05dcd4208c3d5e7e4b9922cd093671e595e1a4",
                                "s": "0x78eea41e0231aede55244a16a426da5b733f207b0ecc6b5da00e1acda4e95ccd"
                            }
                        }
                    },
                    "method": "transact",
                    "section": "ethereum"
                }
            },
            "eventId": "5554101-172",
            "blockPosition": 172,
            "blockNumber": "5,554,101",
            "blockHash": "0xd46f01ffe32963823e870e27f75fc76c5863055f172380df5cc44a37482a1dd4",
            "method": "UpwardMessageSent",
            "section": "parachainSystem",
            "index": "0x0106",
            "data": {
                "messageHash": "0x7285df8407405d93e5c499ae80ca3fcb880709f2327da9263e8f2abd0a8ef541"
            }
        },
        "outcome": "Success",
        "error": null
    },
    "destination": {
        "chainId": "0",
        "blockNumber": "19554532",
        "blockHash": "0x532240e123300d4e68e165047af5dc3335675c18ea4b61aa0d1d944aa6e78cf7",
        "event": {
            "eventId": "19554532-6",
            "blockPosition": 6,
            "blockNumber": "19,554,532",
            "blockHash": "0x532240e123300d4e68e165047af5dc3335675c18ea4b61aa0d1d944aa6e78cf7",
            "method": "Processed",
            "section": "messageQueue",
            "index": "0x6401",
            "data": {
                "id": "0x7285df8407405d93e5c499ae80ca3fcb880709f2327da9263e8f2abd0a8ef541",
                "origin": {
                    "Ump": {
                        "Para": "2,004"
                    }
                },
                "weightUsed": {
                    "refTime": "2,546,546,981",
                    "proofSize": "128,289"
                },
                "success": true
            }
        },
        "outcome": "Success",
        "error": null,
        "assetsTrapped": {
            "event": {
                "eventId": "19554532-5",
                "blockPosition": 5,
                "blockNumber": "19,554,532",
                "blockHash": "0x532240e123300d4e68e165047af5dc3335675c18ea4b61aa0d1d944aa6e78cf7",
                "method": "AssetsTrapped",
                "section": "xcmPallet",
                "index": "0x630b",
                "data": {
                    "hash_": "0x6a435f674dd1e9e8a0a11e8adf17674f59210a8991f45f2ed0985ba8d9a5a6a0",
                    "origin": {
                        "parents": "0",
                        "interior": {
                            "X1": {
                                "Parachain": "2,004"
                            }
                        }
                    },
                    "assets": {
                        "V3": [
                            {
                                "id": {
                                    "Concrete": {
                                        "parents": "0",
                                        "interior": "Here"
                                    }
                                },
                                "fun": {
                                    "Fungible": "931,635,208"
                                }
                            }
                        ]
                    }
                }
            },
            "assets": {
                "V3": [
                    {
                        "id": {
                            "Concrete": {
                                "parents": "0",
                                "interior": "Here"
                            }
                        },
                        "fun": {
                            "Fungible": "931,635,208"
                        }
                    }
                ]
            },
            "hash": "0x6a435f674dd1e9e8a0a11e8adf17674f59210a8991f45f2ed0985ba8d9a5a6a0"
        }
    },
    "messageHash": "0x7285df8407405d93e5c499ae80ca3fcb880709f2327da9263e8f2abd0a8ef541",
    "messageData": "0x0101030c00040000000003426e9243130000000003426e92430107c125de2f0202000c00060107c1c70d7d0102000800441a0105001a01020007020b9d88e3c98a01",
    "instructions": {
        "V3": [
            {
                "WithdrawAsset": [
                    {
                        "id": {
                            "Concrete": {
                                "parents": "0",
                                "interior": "Here"
                            }
                        },
                        "fun": {
                            "Fungible": "1,133,669,954"
                        }
                    }
                ]
            },
            {
                "BuyExecution": {
                    "fees": {
                        "id": {
                            "Concrete": {
                                "parents": "0",
                                "interior": "Here"
                            }
                        },
                        "fun": {
                            "Fungible": "1,133,669,954"
                        }
                    },
                    "weightLimit": {
                        "Limited": {
                            "refTime": "9,393,022,401",
                            "proofSize": "196,608"
                        }
                    }
                }
            },
            {
                "Transact": {
                    "originKind": "SovereignAccount",
                    "requireWeightAtMost": {
                        "refTime": "6,393,022,401",
                        "proofSize": "131,072"
                    },
                    "call": {
                        "encoded": "0x1a0105001a01020007020b9d88e3c98a01"
                    }
                }
            }
        ]
    },
    "sender": "0x0000000000000000000000000000000000000000"
}