Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest subquery changes #42

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cc71349
update docker-compose
Douglasacost Nov 8, 2023
48c642e
use npm
Douglasacost Nov 8, 2023
78f2a8a
Add .prettierrc configuration file
Douglasacost Nov 18, 2023
455dbbb
Update log level and disable historical in
Douglasacost Nov 18, 2023
54af4ad
Update dependencies and remove unused code
Douglasacost Nov 18, 2023
64f8390
Refactor collection and item creation logic
Douglasacost Nov 18, 2023
9ed9c27
Delete allocation handler and
Douglasacost Nov 18, 2023
ea76cfd
Fix checkIfExtrinsicExecuteSuccess function call
Douglasacost Nov 18, 2023
202f1b2
Fix bug in login functionality
Douglasacost Nov 18, 2023
06e0985
Update mappings and entities for Pot and
Douglasacost Nov 18, 2023
c33ad74
Add isReward field to BalanceTransfer model
Douglasacost Nov 18, 2023
dbc5a02
Refactor account balance handling and sponsorship functionality
Douglasacost Nov 21, 2023
b8c0778
Update TREASURY_ACCOUNT in
Douglasacost Nov 26, 2023
5bf64cf
Update Pot and Account Quota Fields
Douglasacost Nov 26, 2023
e7a4e45
Add skipTransactions option to runner and remove calls handlers
Douglasacost Nov 26, 2023
7742414
Update dependencies in package.json
Douglasacost Nov 29, 2023
5dfb954
Update dependencies and fix data type conversion
Douglasacost Dec 19, 2023
9c491df
Add feeQuotaBalance and reserveQuotaBalance to AccountPotBalance
Douglasacost Jan 7, 2024
051cea1
Add dependencies and update configuration***
Douglasacost Feb 19, 2024
8bb86e8
Refactor code to improve performance and readability
Douglasacost Mar 22, 2024
7864b7b
Update .gitignore and package.json
Apr 22, 2024
d46e445
Update dwellir rpc name
Apr 29, 2024
1c632e9
Update npm dependencies and configuration
Douglasacost May 23, 2024
979ce71
Merge branch 'feat/composed-index' of github.com:NodleCode/subquery i…
Douglasacost May 28, 2024
5d3fc1c
Update network configuration with new chainId and endpoint. Added new…
Douglasacost May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update npm dependencies and configuration
Douglasacost committed May 23, 2024
commit 1c632e9db951612b3c4d7f4673ca30ca5029becd
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -21,9 +21,9 @@
"devDependencies": {
"@polkadot/api": "^10",
"@subql/cli": "^4.2.4",
"@subql/node": "^3.4.4",
"@subql/node": "^4.4.1",
"@subql/testing": "^2.1.0",
"@subql/types": "^3.3.0",
"@subql/types": "^3.6.0",
"@types/node-fetch": "^2.6.11",
"typescript": "^4.1.3"
},
6 changes: 3 additions & 3 deletions project.yaml
Original file line number Diff line number Diff line change
@@ -16,13 +16,13 @@ repository: https://github.com/NodleCode/subquery.git
schema:
file: ./schema.graphql
network:
chainId: "0x97da7ede98d7bad4e36b4d734b6055425a3be036da2a332ea5a7037656427a21"
endpoint: "wss://eden-rpc.dwellir.com:443/928f1361-a903-4360-b8ca-4fd786d7214c"
chainId: "0xd9d12d9139d020f658d4469fa5c02e331195227da62567d7bf9bbd1abaf77522"
endpoint: "https://node-6957502816543653888.lh.onfinality.io/jsonrpc?apikey=09b04494-3139-4b57-a5d1-e1c4c18748ce"
chaintypes:
file: ./dist/chaintypes.js
dataSources:
- kind: substrate/Runtime
startBlock: 3783563
startBlock: 1
mapping:
file: ./dist/index.js
handlers:
1 change: 0 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ type Item @entity @compositeIndexes(fields: [["owner", "itemId"]]) {
collectionItemKey: String! @index
collection: Collection!
metadataCid: String
payloadCid: String @index
isBurned: Boolean!
createdAt: BigInt @index
updatedAt: BigInt @index
26 changes: 25 additions & 1 deletion src/mappings/mappingBalancesHandlers.ts
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ const getEntityByTxType = (event: SubstrateEvent) => {

export async function handleBalancesTransferEvent(event: SubstrateEvent) {
const [from, to, amount] = event.event.data
let receiver: string

if (!from || !to) {
logger.error(
@@ -67,12 +68,35 @@ export async function handleBalancesTransferEvent(event: SubstrateEvent) {
return
}

const otherEvents = event.extrinsic?.events?.findIndex(
(item) => item.event.method === 'ContractEmitted'
)

let idWithProposal: string
if (otherEvents && otherEvents !== -1) {
logger.info('ContractEmitted event found')
const payloadDataAddress =
event.extrinsic?.extrinsic?.args[4]?.toString()

const hexReceiver = payloadDataAddress?.split('x')?.pop()
if (hexReceiver) {
logger.info('Receiver address found in payload ' + hexReceiver)
const rawReceiver = Buffer.from(hexReceiver, 'hex').toString()
logger.info('Receiver address in raw format ' + rawReceiver)
receiver = '0x' + rawReceiver.split('x').pop()
logger.info('Receiver address in polkadot format ' + receiver)
}

idWithProposal = `${event.block?.block?.header?.number?.toNumber()}-${event.idx}`
}

let records = getEntityByTxType(event)

records.forEach(record => {
record.id = idWithProposal || `${event.block.block.header.number.toNumber()}-${event.idx}`
record.blockNumber = event.block.block.header.number.toBigInt()
record.from = from.toString()
record.to = to.toString()
record.to = receiver || to.toString()
record.amount = (amount as Balance).toBigInt()
if (event.extrinsic) {
record.txHash = event.extrinsic.extrinsic.hash.toString()
51 changes: 8 additions & 43 deletions src/mappings/mappingUniquesHandlers.ts
Original file line number Diff line number Diff line change
@@ -2,25 +2,7 @@ import { Item } from './../types/models/Item'
import { Balance } from '@polkadot/types/interfaces/runtime'
import { ensureCollection, ensureItem } from './../helpers/verifyUnique'
import { SubstrateEvent } from '@subql/types'
import fetch from 'node-fetch'
import { Collection, UniquesTransfer } from '../types/models'

const fetchMetadata = async (cid: string, gateways: string[]): Promise<any> => {
if (gateways.length === 0) {
return null
}

const gateway = gateways[0]
const url = `https://${gateway}/ipfs/${cid}`

try {
const res = await fetch(url)
return await res.json()
} catch (err) {
logger.error(err)
return fetchMetadata(cid, gateways.slice(1))
}
}
import { UniquesTransfer } from '../types/models'

export async function handleUniquesTransferEvent(event: SubstrateEvent) {
logger.debug(
@@ -108,18 +90,6 @@ export const handleUniquesMetadataSetEvent = async (event: SubstrateEvent) => {

item.metadataCid = data.toHuman()!.toString()

if (item.metadataCid) {
const metadata = await fetchMetadata(item.metadataCid, [
'pinning.infura-ipfs.io',
'nodle-web-wallet.infura-ipfs.io',
'cloudflare-ipfs.com'
]);

if (metadata) {
item.payloadCid = metadata.content || metadata.image || ''
}
}

return item.save()
}

@@ -239,19 +209,14 @@ export const handleUniquesCreatedEvent = async (event: SubstrateEvent) => {

const timestamp = event.extrinsic!.block.timestamp
const collectionIdAsNumber = Number(collectionId.toString())

const id = `${collectionIdAsNumber}-${blockNumber}-${event.idx}`

logger.warn('Creating new collection', collectionIdAsNumber)

const collection = new Collection(
id,
collectionIdAsNumber,
'',
'',
'',
false
)

const collection = await ensureCollection({
collectionId,
blockNumber,
idx: event.idx,
timestamp: event.extrinsic!.block.timestamp,
})

collection.createdAt = BigInt(timestamp.getTime())
collection.issuer = creator.toString()