Skip to content

Commit

Permalink
Fix account all script for evm address, #925
Browse files Browse the repository at this point in the history
  • Loading branch information
wliyongfeng committed Jul 9, 2024
1 parent 2dc40eb commit 015fe88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 2 additions & 7 deletions backend/packages/account-scan/src/scripts/all/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { normalizeEntry } = require("./nomalize");
const { queryEntries } = require("./entries");
const { u8aToHex } = require("@polkadot/util");
const {
chain: { getApi, disconnect },
chain: { disconnect },
env: { currentChain },
} = require("@osn/scan-common");
const {
Expand All @@ -25,13 +25,8 @@ async function main() {
let startKey = null;
let entries = await queryEntries(startKey, queryCount);

const api = await getApi();
const ss58Format = api.registry.chainSS58;

while (entries.length > 0) {
const normalizedAccounts = entries.map((entry) =>
normalizeEntry(entry, ss58Format),
);
const normalizedAccounts = entries.map((entry) => normalizeEntry(entry));
await bulkUpdateAccounts(normalizedAccounts);
console.log(`${entries.length} accounts saved!`);

Expand Down
6 changes: 2 additions & 4 deletions backend/packages/account-scan/src/scripts/all/nomalize.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const { normalizeData } = require("../../utils/normalizeAccountData");
const { encodeAddress } = require("@polkadot/util-crypto");

function normalizeEntry([key, value], ss58Format) {
const pubKeyU8a = key.slice(48);
const address = encodeAddress(pubKeyU8a, ss58Format);
function normalizeEntry([key, value]) {
const address = key.args[0].toString();
const detail = value.toJSON();
const data = normalizeData(detail.data);

Expand Down

0 comments on commit 015fe88

Please sign in to comment.