Skip to content

Commit

Permalink
Fix killAnonymous business handling, #919
Browse files Browse the repository at this point in the history
  • Loading branch information
wliyongfeng committed Aug 22, 2024
1 parent 6ec6c28 commit 21052ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/packages/pallet-proxy-scan/src/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
(async () => {
await initPalletProxyScanDb();
await subscribeFinalizedHeight();
const blockHeights = [4561159];
const blockHeights = [7314534, 11790556];

const api = await getApi();
for (const height of blockHeights) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ async function queryPureCreatedEvent(height, extIndex) {
});
}

async function getPureProxyOn(pure, height) {
async function getPureProxyOn(pure, delegatee, type, delay, height) {
const blockHash = await getBlockHash(height);
const { proxies } = await queryAllProxiesOf(pure, blockHash);
if (proxies.length <= 0) {
return null;
}

return proxies[0];
return proxies.find(
(p) =>
p.delegate === delegatee && p.proxyType === type && p.delay === delay,
);
}

async function handleKillPure(call, signer, extrinsicIndexer) {
Expand All @@ -60,9 +59,15 @@ async function handleKillPure(call, signer, extrinsicIndexer) {
}

const pure = createdEvent.event.data[0].toString();
const proxy = await getPureProxyOn(pure, extrinsicIndexer.blockHeight - 1);
const { delegate, proxyType, delay } = proxy || {};
if (!proxy || delegate !== spawner || proxyType !== proxyTypeArg) {
const delay = createdEvent.event.data[3].toNumber();
const proxy = await getPureProxyOn(
pure,
spawner,
proxyTypeArg,
delay,
extrinsicIndexer.blockHeight - 1,
);
if (!proxy) {
// check there is proxy on previous height block
return;
}
Expand All @@ -75,7 +80,7 @@ async function handleKillPure(call, signer, extrinsicIndexer) {
return;
}

const proxyId = generateProxyId(pure, delegate, proxyType, delay);
const proxyId = generateProxyId(pure, spawner, proxyTypeArg, delay);
await markProxyRemoved(proxyId, extrinsicIndexer);

const timelineCol = await getProxyTimelineCol();
Expand Down

0 comments on commit 21052ed

Please sign in to comment.