-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
import { getSchemaUID } from '@ethereum-attestation-service/eas-sdk'; | ||
import { getSchemaUID, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk'; | ||
|
||
export const NULL_EAS_REF_UID = '0x0000000000000000000000000000000000000000000000000000000000000000'; | ||
|
||
export const NULL_EVM_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
|
||
// This allows us to encode the schemaId and name of a name schema attestation | ||
// Obtained from https://github.com/ethereum-attestation-service/eas-contracts/blob/558250dae4cb434859b1ac3b6d32833c6448be21/deploy/scripts/000004-name-initial-schemas.ts#L10C1-L11C1 | ||
export const NAME_SCHEMA_UID = getSchemaUID('bytes32 schemaId,string name', NULL_EVM_ADDRESS, true); | ||
export const NAME_SCHEMA_UID = getSchemaUID('bytes32 schemaId,string name', NULL_EVM_ADDRESS, true) as `0x${string}`; | ||
|
||
export type NameSchemaAttestation = { | ||
schemaId: `0x${string}`; | ||
name: string; | ||
}; | ||
|
||
export function encodeNameSchemaAttestation({ name, schemaId }: NameSchemaAttestation): `0x${string}` { | ||
const encoder = new SchemaEncoder(NAME_SCHEMA_UID); | ||
|
||
return encoder.encodeData([ | ||
{ name: 'schemaId', type: 'bytes32', value: schemaId }, | ||
{ name: 'name', type: 'string', value: name } | ||
]) as `0x${string}`; | ||
} |