-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: set up remark handler * chore: improved logging * chore: improved ethHandlers error handling and logging * fix: ns2 config (#274) * fix: ff1 config (#275) * fix: ns2 config * fix: ff1 config * chore: improved logging * chore: export automation * fix: fix last contract selection for FF1 * fix: improve pool initialisation * feat: add remark handlers * feat: add signer address to attestations --------- Co-authored-by: Filippo Fontana <[email protected]>
- Loading branch information
Showing
10 changed files
with
691 additions
and
412 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
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
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,30 @@ | ||
import { SubstrateEvent } from '@subql/types' | ||
import { errorHandler } from '../../helpers/errorHandler' | ||
import { RemarkEvent } from '../../helpers/types' | ||
import { AttestationService } from '../services/attestationService' | ||
import { AccountService } from '../services/accountService' | ||
|
||
export const handleRemark = errorHandler(_handleRemark) | ||
async function _handleRemark(event: SubstrateEvent<RemarkEvent>) { | ||
const [remarks, _call] = event.event.data | ||
if (!event.extrinsic) throw new Error('Missing event extrinsic!') | ||
const account = await AccountService.getOrInit(event.extrinsic.extrinsic.signer.toHex()) | ||
logger.info(`Remark event fired for ${event.hash.toString()} at block ${event.block.block.header.number.toNumber()}`) | ||
const namedRemarks = remarks.filter((remark) => remark.isNamed) | ||
|
||
for (const namedRemark of namedRemarks) { | ||
const namedRemarkData = namedRemark.asNamed.toUtf8() | ||
const [type, poolId, attestationData] = namedRemarkData.split(':') | ||
logger.info(`Named remark with data: ${namedRemarkData}`) | ||
if (type === 'attestation') { | ||
const attestation = await AttestationService.init( | ||
poolId, | ||
event.hash.toString(), | ||
event.block.timestamp!, | ||
account.id, | ||
attestationData | ||
) | ||
await attestation.save() | ||
} | ||
} | ||
} |
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,11 @@ | ||
import { Attestation } from '../../types/models/Attestation' | ||
|
||
export class AttestationService extends Attestation { | ||
static init(poolId: string, hash: string, timestamp: Date, accountId: string, data: string) { | ||
const id = `${poolId}-${hash}` | ||
logger.info(`Initialising new attestation ${id} with data: ${data}`) | ||
const attestation = new this(id, poolId, timestamp, accountId) | ||
attestation.data = data | ||
return attestation | ||
} | ||
} |
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
Oops, something went wrong.