Skip to content

Commit b3c2584

Browse files
committed
Project Updated
1 parent 599f430 commit b3c2584

File tree

3 files changed

+14
-54
lines changed

3 files changed

+14
-54
lines changed

Ethereum/ethscriptions/schema.graphql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ type Inscription @entity {
22
id: ID!
33
block: Int!
44
creator: String!
5-
data: String! @index
6-
isEsip6: Boolean! @index
5+
data: String!
76
}
Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,24 @@
1-
// import { TypeormDatabase } from "@subsquid/typeorm-store";
2-
// import { Inscription } from "./model";
3-
// import { processor } from "./processor";
4-
import assert from "assert";
51
import { Inscription } from "../types";
62
import { isValidDataUri, hexToUTF8 } from "./utils";
73
import { EthereumTransaction } from "@subql/types-ethereum";
84

95
export async function handleTransaction(
106
tx: EthereumTransaction
117
): Promise<void> {
12-
logger.warn(tx.hash);
13-
const knownInscriptionsArray: Inscription[] | undefined =
14-
await Inscription.getByIsEsip6(false);
15-
assert(knownInscriptionsArray);
16-
const knownInscriptions: Map<string, Inscription> = new Map(
17-
knownInscriptionsArray.map((c) => [c.data, c])
18-
);
19-
const newUniqueInscriptions: Map<string, Inscription> = new Map();
20-
const inscriptions: Inscription[] = [];
218
if (tx.to) {
22-
//is unique or has rule=esip6
23-
9+
if (!tx.input) {
10+
return;
11+
}
12+
let inscription: Inscription;
2413
const decodedData = hexToUTF8(tx.input);
25-
//console.log(decodedData);
2614
if (isValidDataUri(decodedData)) {
27-
if (decodedData.includes("rule=esip6")) {
28-
inscriptions.push(
29-
Inscription.create({
30-
id: tx.hash,
31-
data: decodedData,
32-
block: tx.blockNumber,
33-
creator: tx.from,
34-
isEsip6: true,
35-
})
36-
);
37-
} else if (
38-
!knownInscriptions.has(decodedData) &&
39-
!newUniqueInscriptions.has(decodedData)
40-
) {
41-
//console.log("new");
42-
newUniqueInscriptions.set(
43-
decodedData,
44-
Inscription.create({
45-
id: tx.hash,
46-
data: decodedData,
47-
block: tx.blockNumber,
48-
creator: tx.from,
49-
isEsip6: false,
50-
})
51-
);
52-
}
53-
//checkuniquesness
15+
inscription = Inscription.create({
16+
id: tx.hash,
17+
data: decodedData,
18+
block: tx.blockNumber,
19+
creator: tx.from,
20+
});
21+
inscription.save();
5422
}
5523
}
56-
inscriptions.map(async (inscription) => await inscription.save());
57-
if (newUniqueInscriptions.size > 0) {
58-
newUniqueInscriptions.forEach(async (value, key) => {
59-
await value.save();
60-
});
61-
}
6224
}

Ethereum/ethscriptions/src/mappings/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function hexToUTF8(hexString: string) {
1+
export function hexToUTF8(hexString: string): string {
22
if (hexString.indexOf("0x") === 0) {
33
hexString = hexString.slice(2);
44
}
@@ -15,8 +15,7 @@ export function hexToUTF8(hexString: string) {
1515
);
1616
bytes[index] = byte;
1717
}
18-
19-
let result = new TextDecoder().decode(bytes);
18+
let result = String.fromCharCode.apply(null, Array.from(bytes));
2019
return result.replace(/\0/g, "");
2120
}
2221

0 commit comments

Comments
 (0)