Skip to content

Commit

Permalink
Remove redundant exception handling (#251)
Browse files Browse the repository at this point in the history
* Remove redundant exception handling

* Update config.yml

---------

Co-authored-by: Alessio Onori <[email protected]>
  • Loading branch information
vovacha and ironoa authored Aug 28, 2024
1 parent 39ded68 commit 4d3309b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
- checkout
- setup_remote_docker:
docker_layer_caching: true
version: 20.10.7
- run:
command: |
/scripts/build-image.sh web3f/polkadot-watcher-transaction .
Expand Down
4 changes: 2 additions & 2 deletions charts/polkadot-watcher-transaction/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: Polkadot Watcher
name: polkadot-watcher-transaction
version: v1.4.0
appVersion: v1.4.0
version: v1.4.1
appVersion: v1.4.1
apiVersion: v2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-watcher-transaction",
"version": "1.4.0",
"version": "1.4.1",
"description": "Monitor events on Polkadot networks, specifically transactions",
"repository": "[email protected]:w3f/polkadot-watcher-csv-exporter.git",
"author": "W3F Infrastructure Team <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const parachainNames = {
"2119": "Bajun Network",
"2239": "Acurast",
"2241": "krest",
"2281": "Kreivo",
"3339": "Curio",
"3344": "Xode"
}
Expand Down
16 changes: 4 additions & 12 deletions src/transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,18 @@ function extractTransferInfoFromXcmEvent(event: XcmSentEvent, chainInfo: ChainIn
destination = depositRA.dest;
}
}
if (!beneficiaryInstruction) {
throw new Error(`XCM. No beneficiary instructions found. Block: ${blockNumber}`);
}
const destinationAddress = getLocation(beneficiaryInstruction.beneficiary, chainInfo, blockNumber)
const destinationAddress = getLocation(beneficiaryInstruction?.beneficiary, chainInfo, blockNumber)
// 3. Get assets information
const assetInstruction = findInstruction(message, 'ReserveAssetDeposited') ||
findInstruction(message, 'ReceiveTeleportedAsset');
findInstruction(message, 'ReceiveTeleportedAsset') || [];

if (!assetInstruction) {
throw new Error(`XCM. No assets instructions found. Block: ${blockNumber}`);
}
const destChain = getLocation(destination, chainInfo, blockNumber)
const transfers = getTokenAmountFromAsset(
assetInstruction,
chainInfo,
blockNumber
)
if (transfers.length === 0) {
throw new Error(`XCM. No assets found inside of instruction. Block: ${blockNumber}`);
}

// TODO: AssetHub monitoring. The list of assets should be returned instead.
const [token, amount] = transfers[0]
return {
Expand Down Expand Up @@ -159,7 +151,7 @@ function getTokenAmountFromAsset(assets: StagingXcmV4Asset[], chainInfo: ChainIn
}
result.push([token, amount])
}
return result
return result.length > 0 ? result : [['Unknown', 'Unknown']]
}

export const isBalancesTransferEvent = (event: Event): boolean => {
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Balance, Event, CodecHash, EventRecord } from '@polkadot/types/interfac
import { DeriveAccountRegistration } from '@polkadot/api-derive/accounts/types';
import { StagingXcmV4Location, StagingXcmV4Xcm, StagingXcmV4Asset } from '@polkadot/types/lookup';
import { TypeRegistry } from '@polkadot/types';
import { string } from 'yaml/dist/schema/common/string';


export type ChainId = 'polkadot' | 'kusama'
Expand Down
17 changes: 17 additions & 0 deletions test/integration/xcmData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ export const xcmTests = {
token: "KSM",
amount: "0.0250"
},
{
description: "Pallet XCM. Call send. Unknown asset instruction",
link: "https://kusama.subscan.io/event?extrinsic=24673667-2",
messageId: "0xf10ffef1fc2e8cf440808ce6684d556ad01b0f96ce90f7a266c87a2f30873c94",
block: 24673667,
eventIndex: 54,
origin: {
address: "HCksmaxivAsisGDkWtm5dhdAt3Ti2e5P2Gt7JXZYFiEHMSH",
chain: "Kusama"
},
destination: {
address: "HCksmaxivAsisGDkWtm5dhdAt3Ti2e5P2Gt7JXZYFiEHMSH",
chain: "Kreivo"
},
token: "Unknown",
amount: "Unknown"
},
],
polkadot: [
{
Expand Down

0 comments on commit 4d3309b

Please sign in to comment.