-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Handle proxy added and removed event, #919 * Save known heights, #919 * Handle removeProxies call, #919 * Improve removeProxies handling, #919 * Handle PureCreated event, #919 * Handle killPure call, #919 * Handle announce created and removed, #919 * Handle rejectAnnouncement call, #919 * Handle ProxyExecuted event, #919 * Scan known heights first if set, #919 * Add code to clean scanned business, #919 * Handle addProxy call without event, #919 * Mark known height for addProxy call, #919 * Adapt proxy storage, #919 * Handle removeProxy call without event, #919 * Handle AnonymousCreated event, #919 * Handle killAnonymous call, #919 * Revert yarn.lock change * Update yarn.lock * re-create lock file * Revert "re-create lock file" This reverts commit 5da8b8e. * ci: bump version * try back to yarn classic * try yarn 3.6.4 * Init proxy type and resolvers for graphql server, #919 * Add graphql query for proxy timeline, #919 * Add graphql query for proxy calls, #919 * Add graphql query for proxy announcements, #919 * Guard proxy differences log, #919 * Add proxy prefix to announcement queries, #919 * Add proxy scan height to query, #919 * Save proxy executed event data, #919 --------- Co-authored-by: 2nthony <[email protected]>
- Loading branch information
1 parent
187a715
commit 4cc2070
Showing
70 changed files
with
4,141 additions
and
1,835 deletions.
There are no files selected for viewing
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
418 changes: 209 additions & 209 deletions
418
backend/.yarn/releases/yarn-3.6.0.cjs → backend/.yarn/releases/yarn-3.6.4.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
yarnPath: .yarn/releases/yarn-3.6.0.cjs | ||
yarnPath: .yarn/releases/yarn-3.6.4.cjs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,5 @@ | |
"devDependencies": { | ||
"eslint": "^8.31.0" | ||
}, | ||
"packageManager": "[email protected].0" | ||
"packageManager": "[email protected].4" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const { emptyFn } = require("@osn/scan-common/src/utils/emptyFn"); | ||
const { | ||
Modules, | ||
ProxyMethods, | ||
MultisigMethods, | ||
UtilityMethods, | ||
} = require("@osn/scan-common/src/consts"); | ||
const { calcMultisigAddress } = require("@osn/scan-common/src/utils/multisig"); | ||
|
||
function findAuthorFromProxy(proxyCall, author, checkFn) { | ||
const real = proxyCall.args[0].toString(); | ||
const innerCall = proxyCall.args[2]; | ||
return findCallAuthor(innerCall, real, checkFn); | ||
} | ||
|
||
function findAuthorFromMultisig(multisigCall, author, checkFn) { | ||
const innerCall = multisigCall.args[3]; | ||
const threshold = multisigCall.args[0].toNumber(); | ||
const otherSignatories = multisigCall.args[1].toJSON(); | ||
const multisigAddr = calcMultisigAddress( | ||
[author, ...otherSignatories], | ||
threshold, | ||
multisigCall.registry.chainSS58, | ||
); | ||
|
||
return findCallAuthor(innerCall, multisigAddr, checkFn); | ||
} | ||
|
||
function findAuthorFromBatch(batchCall, author, checkFn) { | ||
for (const innerCall of batchCall.args[0]) { | ||
const real = findCallAuthor(innerCall, author, checkFn); | ||
if (real) { | ||
return real; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
function findCallAuthor(call, author, checkFn = emptyFn) { | ||
if (checkFn(call)) { | ||
return author; | ||
} | ||
|
||
const { section, method } = call; | ||
if (Modules.Proxy === section && ProxyMethods.proxy === method) { | ||
return findAuthorFromProxy(...arguments); | ||
} else if ( | ||
[Modules.Multisig, Modules.Utility].includes(section) && | ||
MultisigMethods.asMulti === method | ||
) { | ||
return findAuthorFromMultisig(...arguments); | ||
} else if ( | ||
Modules.Utility === section && | ||
[ | ||
UtilityMethods.batch, | ||
UtilityMethods.batchAll, | ||
UtilityMethods.forceBatch, | ||
].includes(method) | ||
) { | ||
return findAuthorFromBatch(...arguments); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
module.exports = { | ||
findTargetCallAuthor: findCallAuthor, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
...require("./findTargetCallAuthor"), | ||
}; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
PORT=7100 | ||
|
||
MONGO_VESTING_SCAN_URL=mongodb://127.0.0.1:27017 | ||
MONGO_VESTING_SCAN_NAME=prod-statescan-polkadot-vesting | ||
MONGO_VESTING_SCAN_NAME=prod-statescan-polkadot-vesting-1 | ||
|
||
MONGO_PALLET_ASSET_SCAN_URL=mongodb://127.0.0.1:27017 | ||
MONGO_PALLET_ASSET_SCAN_NAME=prod-statescan-statemint-assets | ||
MONGO_PALLET_ASSET_SCAN_NAME=prod-statescan-statemint-assets-1 | ||
|
||
MONGO_MULTISIG_SCAN_URL=mongodb://127.0.0.1:27017 | ||
MONGO_MULTISIG_SCAN_NAME=prod-statescan-polkadot-multisig | ||
MONGO_MULTISIG_SCAN_NAME=prod-statescan-polkadot-multisig-1 | ||
|
||
MONGO_IDENTITY_SCAN_URL=mongodb://127.0.0.1:27017 | ||
MONGO_IDENTITY_SCAN_NAME=prod-statescan-polkadot-identity | ||
|
||
MONGO_PALLET_RECOVERY_SCAN_URL=mongodb://127.0.0.1:27017 | ||
MONGO_PALLET_RECOVERY_SCAN_NAME=prod-statescan-kusama-recovery-1 | ||
|
||
MONGO_PROXY_SCAN_URL=mongodb://127.0.0.1:27017 | ||
MONGO_PROXY_SCAN_NAME=prod-statescan-polkadot-proxy-1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,5 @@ | |
"devDependencies": { | ||
"eslint-plugin-jest": "^27.2.1", | ||
"jest": "^28.1.3" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { typeDefs } = require("./types"); | ||
const resolverFunctions = require("./resolvers"); | ||
|
||
const resolvers = { | ||
Query: { | ||
...resolverFunctions, | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
resolvers, | ||
typeDefs, | ||
}; |
18 changes: 18 additions & 0 deletions
18
backend/packages/graphql-server/src/schema/proxy/resolvers/announcement.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { | ||
palletProxy: { getAnnouncementCol }, | ||
} = require("@statescan/mongo"); | ||
const { normalizeAnnouncement } = require("./common"); | ||
|
||
async function announcement(_, _args) { | ||
const { announcementId } = _args; | ||
const col = await getAnnouncementCol(); | ||
const announcement = await col.findOne( | ||
{ announcementId }, | ||
{ projection: { _id: 0 } }, | ||
); | ||
return normalizeAnnouncement(announcement); | ||
} | ||
|
||
module.exports = { | ||
proxyAnnouncement: announcement, | ||
}; |
16 changes: 16 additions & 0 deletions
16
backend/packages/graphql-server/src/schema/proxy/resolvers/announcementTimeline.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { | ||
palletProxy: { getAnnouncementTimelineCol }, | ||
} = require("@statescan/mongo"); | ||
|
||
async function announcementTimeline(_, _args) { | ||
const { announcementId } = _args; | ||
const col = await getAnnouncementTimelineCol(); | ||
return await col | ||
.find({ announcementId }, { projection: { _id: 0 } }) | ||
.sort({ "indexer.blockHeight": 1 }) | ||
.toArray(); | ||
} | ||
|
||
module.exports = { | ||
proxyAnnouncementTimeline: announcementTimeline, | ||
}; |
49 changes: 49 additions & 0 deletions
49
backend/packages/graphql-server/src/schema/proxy/resolvers/announcements.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { | ||
palletProxy: { getAnnouncementCol }, | ||
} = require("@statescan/mongo"); | ||
const isNil = require("lodash.isnil"); | ||
const isEmpty = require("lodash.isempty"); | ||
const { normalizeAnnouncement } = require("./common"); | ||
|
||
async function announcements(_, _args) { | ||
const { delegator, delegatee, isFinal, offset, limit } = _args; | ||
if (parseInt(limit) > 100) { | ||
throw new Error("Over max page size 100"); | ||
} | ||
|
||
let q = {}; | ||
if (delegator) { | ||
Object.assign(q, { real: delegator }); | ||
} | ||
if (delegatee) { | ||
Object.assign(q, { delegate: delegatee }); | ||
} | ||
if (!isNil(isFinal)) { | ||
Object.assign(q, { isFinal }); | ||
} | ||
|
||
const col = await getAnnouncementCol(); | ||
const items = await col | ||
.find(q, { projection: { _id: 0 } }) | ||
.sort({ "indexer.blockHeight": -1 }) | ||
.skip(offset) | ||
.limit(limit) | ||
.toArray(); | ||
let total; | ||
if (isEmpty(q)) { | ||
total = await col.estimatedDocumentCount(); | ||
} else { | ||
total = await col.countDocuments(q); | ||
} | ||
|
||
return { | ||
items: items.map(normalizeAnnouncement), | ||
offset, | ||
limit, | ||
total, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
proxyAnnouncements: announcements, | ||
}; |
28 changes: 28 additions & 0 deletions
28
backend/packages/graphql-server/src/schema/proxy/resolvers/common.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function normalizeAnnouncement(item = {}) { | ||
if (!item) { | ||
return item; | ||
} | ||
|
||
return { | ||
...item, | ||
delegator: item.real, | ||
delegatee: item.delegate, | ||
}; | ||
} | ||
|
||
function normalizeProxyCall(item = {}) { | ||
if (!item) { | ||
return item; | ||
} | ||
|
||
return { | ||
...item, | ||
delegator: item.real, | ||
delegatee: item.delegate, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
normalizeAnnouncement, | ||
normalizeProxyCall, | ||
}; |
10 changes: 10 additions & 0 deletions
10
backend/packages/graphql-server/src/schema/proxy/resolvers/index.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
...require("./proxies"), | ||
...require("./proxy"), | ||
...require("./proxyTimeline"), | ||
...require("./proxyCalls"), | ||
...require("./announcements"), | ||
...require("./announcement"), | ||
...require("./announcementTimeline"), | ||
...require("./proxyScanHeight"), | ||
}; |
Oops, something went wrong.