diff --git a/src/eas/constants/attestation.constants.ts b/src/eas/constants/attestation.constants.ts index 6e67637..bc36e75 100644 --- a/src/eas/constants/attestation.constants.ts +++ b/src/eas/constants/attestation.constants.ts @@ -7,16 +7,16 @@ export const REVOKE_TYPED_SIGNATURE = export const ATTEST_PRIMARY_TYPE = 'Attest' export const REVOKE_PRIMARY_TYPE = 'Revoke' export const ATTEST_TYPE = [ - { name: 'attester', type: 'address' }, + // { name: 'attester', type: 'address' }, { name: 'schema', type: 'bytes32' }, { name: 'recipient', type: 'address' }, { name: 'expirationTime', type: 'uint64' }, { name: 'revocable', type: 'bool' }, { name: 'refUID', type: 'bytes32' }, { name: 'data', type: 'bytes' }, - { name: 'value', type: 'uint256' }, + // { name: 'value', type: 'uint256' }, { name: 'nonce', type: 'uint256' }, - { name: 'deadline', type: 'uint64' }, + // { name: 'deadline', type: 'uint64' }, ] export const REVOKE_TYPE = [ { name: 'revoker', type: 'address' }, diff --git a/src/eas/constants/sepolia.constants.ts b/src/eas/constants/sepolia.constants.ts deleted file mode 100644 index f07851e..0000000 --- a/src/eas/constants/sepolia.constants.ts +++ /dev/null @@ -1,766 +0,0 @@ -import { Abi } from 'viem' -export const SCHEMA_UUID = - '0x85e90e3e16d319578888790af3284fea8bca549305071531e7478e3e0b5e7d6d' - -export const EAS_SEPOLIA_CONTRACT_ADDRESS = - '0xC2679fBD37d54388Ce493F1DB75320D236e1815e' -export const EAS_SEPOLIA_CONTRACT_ABI: Abi = [ - { - inputs: [ - { - internalType: 'contract ISchemaRegistry', - name: 'registry', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { inputs: [], name: 'AccessDenied', type: 'error' }, - { inputs: [], name: 'AlreadyRevoked', type: 'error' }, - { inputs: [], name: 'AlreadyRevokedOffchain', type: 'error' }, - { inputs: [], name: 'AlreadyTimestamped', type: 'error' }, - { inputs: [], name: 'InsufficientValue', type: 'error' }, - { inputs: [], name: 'InvalidAttestation', type: 'error' }, - { inputs: [], name: 'InvalidAttestations', type: 'error' }, - { inputs: [], name: 'InvalidExpirationTime', type: 'error' }, - { inputs: [], name: 'InvalidLength', type: 'error' }, - { inputs: [], name: 'InvalidOffset', type: 'error' }, - { inputs: [], name: 'InvalidRegistry', type: 'error' }, - { inputs: [], name: 'InvalidRevocation', type: 'error' }, - { inputs: [], name: 'InvalidRevocations', type: 'error' }, - { inputs: [], name: 'InvalidSchema', type: 'error' }, - { inputs: [], name: 'InvalidSignature', type: 'error' }, - { inputs: [], name: 'InvalidVerifier', type: 'error' }, - { inputs: [], name: 'Irrevocable', type: 'error' }, - { inputs: [], name: 'NotFound', type: 'error' }, - { inputs: [], name: 'NotPayable', type: 'error' }, - { inputs: [], name: 'WrongSchema', type: 'error' }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'attester', - type: 'address', - }, - { - indexed: false, - internalType: 'bytes32', - name: 'uid', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - ], - name: 'Attested', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'attester', - type: 'address', - }, - { - indexed: false, - internalType: 'bytes32', - name: 'uid', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - ], - name: 'Revoked', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'revoker', - type: 'address', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'data', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'uint64', - name: 'timestamp', - type: 'uint64', - }, - ], - name: 'RevokedOffchain', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'data', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'uint64', - name: 'timestamp', - type: 'uint64', - }, - ], - name: 'Timestamped', - type: 'event', - }, - { - inputs: [], - name: 'VERSION', - outputs: [{ internalType: 'string', name: '', type: 'string' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - internalType: 'uint64', - name: 'expirationTime', - type: 'uint64', - }, - { - internalType: 'bool', - name: 'revocable', - type: 'bool', - }, - { - internalType: 'bytes32', - name: 'refUID', - type: 'bytes32', - }, - { - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct AttestationRequestData', - name: 'data', - type: 'tuple', - }, - ], - internalType: 'struct AttestationRequest', - name: 'request', - type: 'tuple', - }, - ], - name: 'attest', - outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - internalType: 'uint64', - name: 'expirationTime', - type: 'uint64', - }, - { - internalType: 'bool', - name: 'revocable', - type: 'bool', - }, - { - internalType: 'bytes32', - name: 'refUID', - type: 'bytes32', - }, - { - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct AttestationRequestData', - name: 'data', - type: 'tuple', - }, - { - components: [ - { internalType: 'uint8', name: 'v', type: 'uint8' }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32', - }, - ], - internalType: 'struct EIP712Signature', - name: 'signature', - type: 'tuple', - }, - { - internalType: 'address', - name: 'attester', - type: 'address', - }, - ], - internalType: 'struct DelegatedAttestationRequest', - name: 'delegatedRequest', - type: 'tuple', - }, - ], - name: 'attestByDelegation', - outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [], - name: 'getAttestTypeHash', - outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], - stateMutability: 'pure', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes32', name: 'uid', type: 'bytes32' }], - name: 'getAttestation', - outputs: [ - { - components: [ - { internalType: 'bytes32', name: 'uid', type: 'bytes32' }, - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { internalType: 'uint64', name: 'time', type: 'uint64' }, - { - internalType: 'uint64', - name: 'expirationTime', - type: 'uint64', - }, - { - internalType: 'uint64', - name: 'revocationTime', - type: 'uint64', - }, - { - internalType: 'bytes32', - name: 'refUID', - type: 'bytes32', - }, - { - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - internalType: 'address', - name: 'attester', - type: 'address', - }, - { internalType: 'bool', name: 'revocable', type: 'bool' }, - { internalType: 'bytes', name: 'data', type: 'bytes' }, - ], - internalType: 'struct Attestation', - name: '', - type: 'tuple', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getDomainSeparator', - outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'address', name: 'account', type: 'address' }], - name: 'getNonce', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { internalType: 'address', name: 'revoker', type: 'address' }, - { internalType: 'bytes32', name: 'data', type: 'bytes32' }, - ], - name: 'getRevokeOffchain', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getRevokeTypeHash', - outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], - stateMutability: 'pure', - type: 'function', - }, - { - inputs: [], - name: 'getSchemaRegistry', - outputs: [ - { - internalType: 'contract ISchemaRegistry', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes32', name: 'data', type: 'bytes32' }], - name: 'getTimestamp', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes32', name: 'uid', type: 'bytes32' }], - name: 'isAttestationValid', - outputs: [{ internalType: 'bool', name: '', type: 'bool' }], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - internalType: 'uint64', - name: 'expirationTime', - type: 'uint64', - }, - { - internalType: 'bool', - name: 'revocable', - type: 'bool', - }, - { - internalType: 'bytes32', - name: 'refUID', - type: 'bytes32', - }, - { - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct AttestationRequestData[]', - name: 'data', - type: 'tuple[]', - }, - ], - internalType: 'struct MultiAttestationRequest[]', - name: 'multiRequests', - type: 'tuple[]', - }, - ], - name: 'multiAttest', - outputs: [{ internalType: 'bytes32[]', name: '', type: 'bytes32[]' }], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - internalType: 'uint64', - name: 'expirationTime', - type: 'uint64', - }, - { - internalType: 'bool', - name: 'revocable', - type: 'bool', - }, - { - internalType: 'bytes32', - name: 'refUID', - type: 'bytes32', - }, - { - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct AttestationRequestData[]', - name: 'data', - type: 'tuple[]', - }, - { - components: [ - { internalType: 'uint8', name: 'v', type: 'uint8' }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32', - }, - ], - internalType: 'struct EIP712Signature[]', - name: 'signatures', - type: 'tuple[]', - }, - { - internalType: 'address', - name: 'attester', - type: 'address', - }, - ], - internalType: 'struct MultiDelegatedAttestationRequest[]', - name: 'multiDelegatedRequests', - type: 'tuple[]', - }, - ], - name: 'multiAttestByDelegation', - outputs: [{ internalType: 'bytes32[]', name: '', type: 'bytes32[]' }], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'bytes32', - name: 'uid', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct RevocationRequestData[]', - name: 'data', - type: 'tuple[]', - }, - ], - internalType: 'struct MultiRevocationRequest[]', - name: 'multiRequests', - type: 'tuple[]', - }, - ], - name: 'multiRevoke', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'bytes32', - name: 'uid', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct RevocationRequestData[]', - name: 'data', - type: 'tuple[]', - }, - { - components: [ - { internalType: 'uint8', name: 'v', type: 'uint8' }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32', - }, - ], - internalType: 'struct EIP712Signature[]', - name: 'signatures', - type: 'tuple[]', - }, - { - internalType: 'address', - name: 'revoker', - type: 'address', - }, - ], - internalType: 'struct MultiDelegatedRevocationRequest[]', - name: 'multiDelegatedRequests', - type: 'tuple[]', - }, - ], - name: 'multiRevokeByDelegation', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32[]', name: 'data', type: 'bytes32[]' }, - ], - name: 'multiRevokeOffchain', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { internalType: 'bytes32[]', name: 'data', type: 'bytes32[]' }, - ], - name: 'multiTimestamp', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'bytes32', - name: 'uid', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct RevocationRequestData', - name: 'data', - type: 'tuple', - }, - ], - internalType: 'struct RevocationRequest', - name: 'request', - type: 'tuple', - }, - ], - name: 'revoke', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [ - { - components: [ - { - internalType: 'bytes32', - name: 'schema', - type: 'bytes32', - }, - { - components: [ - { - internalType: 'bytes32', - name: 'uid', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - internalType: 'struct RevocationRequestData', - name: 'data', - type: 'tuple', - }, - { - components: [ - { internalType: 'uint8', name: 'v', type: 'uint8' }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32', - }, - ], - internalType: 'struct EIP712Signature', - name: 'signature', - type: 'tuple', - }, - { - internalType: 'address', - name: 'revoker', - type: 'address', - }, - ], - internalType: 'struct DelegatedRevocationRequest', - name: 'delegatedRequest', - type: 'tuple', - }, - ], - name: 'revokeByDelegation', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes32', name: 'data', type: 'bytes32' }], - name: 'revokeOffchain', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [{ internalType: 'bytes32', name: 'data', type: 'bytes32' }], - name: 'timestamp', - outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }], - stateMutability: 'nonpayable', - type: 'function', - }, -] diff --git a/src/eas/eas.service.ts b/src/eas/eas.service.ts index 4107b7b..82c1925 100644 --- a/src/eas/eas.service.ts +++ b/src/eas/eas.service.ts @@ -15,9 +15,9 @@ import { import { privateKeyToAccount, Account } from 'viem/accounts' import { SUPPORTED_CHAINS } from '../shared/constants/chain.constants' import { - IAttestationRequestData, - IDelegatedAttestationRequest, - IDelegatedAttestationMessage, + AttestationRequestData, + DelegatedAttestationRequest, + DelegatedAttestationMessage, } from './interfaces/attestation.interfaces' import { NO_EXPIRATION, @@ -92,6 +92,7 @@ export class EasService { if (!eas) { throw new Error(`EAS contract not found for chain ID: ${chainId}`) } + console.log('VERSION', await eas.read.VERSION()) return { name: 'EAS', version: await eas.read.VERSION(), @@ -111,8 +112,8 @@ export class EasService { createAttestationRequestData( data: EncodeAbiParametersReturnType, recipient: Address - ): IAttestationRequestData { - const requestData: IAttestationRequestData = { + ): AttestationRequestData { + return { data, recipient, expirationTime: NO_EXPIRATION, @@ -120,43 +121,49 @@ export class EasService { revocable: true, value: NO_EXPIRATION, } - return requestData } createDelegatedAttestationRequest( - requestData: IAttestationRequestData, + requestData: AttestationRequestData, chainId: SupportedChainId, signature: '0x${string}' - ): IDelegatedAttestationRequest { + ): DelegatedAttestationRequest { const { r, s, v } = parseSignature(signature) - const request: IDelegatedAttestationRequest = { + return { signature: { r, s, v: Number(v) }, attester: this.attester.address, schema: this.getSchemaUUID(chainId), data: requestData, - deadline: 0n, + // deadline: 0n, } - return request } createAttestationMessage( - requestData: IAttestationRequestData, + requestData: AttestationRequestData, chainId: SupportedChainId, nonce: any - ): IDelegatedAttestationMessage { - const message: IDelegatedAttestationMessage = { + ): DelegatedAttestationMessage { + return { ...requestData, schema: this.getSchemaUUID(chainId), attester: this.attester.address, deadline: NO_EXPIRATION, nonce, } - return message } async signAttestationMessage( - message: IDelegatedAttestationMessage, + message: DelegatedAttestationMessage, domain: any ) { + // const signature = await this.attester.signTypedData({ + // domain, + // { + + // } + // primaryType: ATTEST_PRIMARY_TYPE, + // message, + // }) + // return signature const signature = await this.attester.signTypedData({ domain, types: { @@ -171,7 +178,7 @@ export class EasService { { name: 'data', type: 'bytes' }, { name: 'value', type: 'uint256' }, { name: 'nonce', type: 'uint256' }, - { name: 'deadline', type: 'uint64' }, + // { name: 'deadline', type: 'uint64' }, ], }, primaryType: ATTEST_PRIMARY_TYPE, diff --git a/src/eas/interfaces/attestation.interfaces.ts b/src/eas/interfaces/attestation.interfaces.ts index a0a9532..6cf0577 100644 --- a/src/eas/interfaces/attestation.interfaces.ts +++ b/src/eas/interfaces/attestation.interfaces.ts @@ -1,30 +1,77 @@ import { Address } from 'viem' -export interface IAttestationRequestData { +// export interface IAttestationRequestData { +// recipient: Address +// data: Address +// expirationTime: bigint +// revocable: boolean +// refUID: Address +// value: bigint +// } + +// export interface IDelegatedAttestationMessage extends IAttestationRequestData { +// schema: Address +// attester: Address +// deadline: bigint +// nonce: bigint +// } + +// export interface IAttestationRequest { +// schema: Address +// data: IAttestationRequestData +// } + +// export interface IDelegatedAttestationRequest extends IAttestationRequest { +// signature: { r: Address; s: Address; v: number } +// attester: Address +// deadline: bigint +// } + +export interface TypedData { + name: string + type: + | 'bool' + | 'uint8' + | 'uint16' + | 'uint32' + | 'uint64' + | 'uint128' + | 'uint256' + | 'address' + | 'string' + | 'bytes' + | 'bytes32' +} + +export interface EIP712Signature { + v: number + r: Address + s: Address +} +export interface AttestationRequestData { recipient: Address - data: Address expirationTime: bigint revocable: boolean refUID: Address + data: Address value: bigint } -export interface IDelegatedAttestationMessage extends IAttestationRequestData { +export interface AttestationRequest { schema: Address - attester: Address - deadline: bigint - nonce: bigint + data: AttestationRequestData } -export interface IAttestationRequest { - schema: Address - data: IAttestationRequestData +export interface DelegatedAttestationRequest extends AttestationRequest { + signature: EIP712Signature + attester: Address } -export interface IDelegatedAttestationRequest extends IAttestationRequest { - signature: { r: Address; s: Address; v: number } +export interface DelegatedAttestationMessage extends AttestationRequestData { + schema: Address attester: Address deadline: bigint + nonce: bigint } export interface TypedData { diff --git a/src/linking/dto/link-identities.dto.ts b/src/linking/dto/link-identities.dto.ts index bca96d4..f43d8a9 100644 --- a/src/linking/dto/link-identities.dto.ts +++ b/src/linking/dto/link-identities.dto.ts @@ -12,7 +12,7 @@ export class LinkIdentitiesDto { }) @IsString() @IsNotEmpty() - @JwtProvider(AUTH_PROVIDERS.SIWE) + @JwtProvider(AUTH_PROVIDERS.GOOGLE) readonly siweJwt: string @ApiProperty({ diff --git a/src/linking/linking.controller.ts b/src/linking/linking.controller.ts index 3e91c0e..c40fbad 100644 --- a/src/linking/linking.controller.ts +++ b/src/linking/linking.controller.ts @@ -6,6 +6,17 @@ import { EasService } from '../eas/eas.service' import { LitService } from 'src/lit/lit.service' import { keccak256, toHex } from 'viem' import { DataUtilsService } from 'src/utils/data-utils.service' +import { generatePrivateKey, privateKeyToAddress } from 'viem/accounts' +import { + createPublicClient, + http, + createWalletClient, + BaseError, + ContractFunctionRevertedError, +} from 'viem' +import { privateKeyToAccount } from 'viem/accounts' +import { sepolia } from 'viem/chains' +import { SUPPORTED_CHAINS } from 'src/shared/constants/chain.constants' @ApiTags(`Linking`) @Controller(`linking`) @@ -25,8 +36,11 @@ export class LinkingController { }) @HttpCode(HttpStatus.OK) async linkIdentities(@Body() linkIdentitiesDto: LinkIdentitiesDto) { - const { chainId, anyJwt, siweJwt } = linkIdentitiesDto - const siweJwtPayload = await this.authService.validateToken(siweJwt) + const { chainId, anyJwt } = linkIdentitiesDto + // const siweJwtPayload = await this.authService.validateToken(siweJwt) + const pk = generatePrivateKey() + const account = privateKeyToAccount(pk) + const add = privateKeyToAddress(pk) const anyJwtPayload = await this.authService.validateToken(anyJwt) const secret = await this.litService.encrypt( chainId, @@ -34,7 +48,8 @@ export class LinkingController { id: anyJwtPayload.sub, provider: anyJwtPayload.provider, }, - siweJwtPayload.sub as '0x${string}' + // siweJwtPayload.sub as '0x${string}' + add ) const delegatedAttestationRequest = await this.easService.getDelegatedAttestationRequest( @@ -44,11 +59,62 @@ export class LinkingController { anyJwtPayload.provider, secret, ], - siweJwtPayload.sub as '0x${string}' + // siweJwtPayload.sub as '0x${string}' + add ) - return this.dataUtilsService.formatBigIntValues( - delegatedAttestationRequest - ) + const walletClient = createWalletClient({ + chain: sepolia, + transport: http(), + }) + + const publicClient = createPublicClient({ + chain: sepolia, + transport: http(), + }) + + console.log('delegatedAttestationRequest', delegatedAttestationRequest) + + const data = { + signature: delegatedAttestationRequest.signature, + data: { + ...delegatedAttestationRequest.data, + value: 0n, + }, + schema: delegatedAttestationRequest.schema, + attester: delegatedAttestationRequest.attester, + deadline: 0n, + } + try { + console.log('sim') + const { request } = await publicClient.simulateContract({ + address: SUPPORTED_CHAINS[0] + .easContractAddress as `0x${string}`, + abi: SUPPORTED_CHAINS[0].easContractAbi, + functionName: 'attestByDelegation', + args: [data], + account, + }) + console.log('request', request) + const hash = await walletClient.writeContract(request) + + console.log('hash', hash) + } catch (err) { + console.log(err) + if (err instanceof BaseError) { + const revertError = err.walk( + (err) => err instanceof ContractFunctionRevertedError + ) + if (revertError instanceof ContractFunctionRevertedError) { + const errorName = revertError.data?.errorName ?? '' + // do something with `errorName` + console.log('errorName', errorName) + } + } + } + // return this.dataUtilsService.formatBigIntValues( + // delegatedAttestationRequest + // ) + return '1' } } diff --git a/src/shared/constants/chain.constants.ts b/src/shared/constants/chain.constants.ts index f672e89..71b2099 100644 --- a/src/shared/constants/chain.constants.ts +++ b/src/shared/constants/chain.constants.ts @@ -5,6 +5,7 @@ export const SUPPORTED_CHAINS = [ '0x85e90e3e16d319578888790af3284fea8bca549305071531e7478e3e0b5e7d6d', easContractAddress: '0xC2679fBD37d54388Ce493F1DB75320D236e1815e', + // easContractAddress: '0x9C9d17bEE150E4eCDf3b99baFA62c08Cb30E82BC', easContractAbi: [ { @@ -845,6 +846,455 @@ export const SUPPORTED_CHAINS = [ }, ], + // easContractAbi: [ + // { + // inputs: [ + // { + // internalType: 'contract IEAS', + // name: 'eas', + // type: 'address', + // }, + // { internalType: 'string', name: 'name', type: 'string' }, + // ], + // stateMutability: 'nonpayable', + // type: 'constructor', + // }, + // { inputs: [], name: 'AccessDenied', type: 'error' }, + // { inputs: [], name: 'DeadlineExpired', type: 'error' }, + // { inputs: [], name: 'InvalidEAS', type: 'error' }, + // { inputs: [], name: 'InvalidLength', type: 'error' }, + // { inputs: [], name: 'InvalidShortString', type: 'error' }, + // { inputs: [], name: 'InvalidSignature', type: 'error' }, + // { inputs: [], name: 'NotFound', type: 'error' }, + // { + // inputs: [ + // { internalType: 'string', name: 'str', type: 'string' }, + // ], + // name: 'StringTooLong', + // type: 'error', + // }, + // { inputs: [], name: 'UsedSignature', type: 'error' }, + // { + // anonymous: false, + // inputs: [], + // name: 'EIP712DomainChanged', + // type: 'event', + // }, + // { + // inputs: [ + // { + // components: [ + // { + // internalType: 'bytes32', + // name: 'schema', + // type: 'bytes32', + // }, + // { + // components: [ + // { + // internalType: 'address', + // name: 'recipient', + // type: 'address', + // }, + // { + // internalType: 'uint64', + // name: 'expirationTime', + // type: 'uint64', + // }, + // { + // internalType: 'bool', + // name: 'revocable', + // type: 'bool', + // }, + // { + // internalType: 'bytes32', + // name: 'refUID', + // type: 'bytes32', + // }, + // { + // internalType: 'bytes', + // name: 'data', + // type: 'bytes', + // }, + // { + // internalType: 'uint256', + // name: 'value', + // type: 'uint256', + // }, + // ], + // internalType: 'struct AttestationRequestData', + // name: 'data', + // type: 'tuple', + // }, + // { + // components: [ + // { + // internalType: 'uint8', + // name: 'v', + // type: 'uint8', + // }, + // { + // internalType: 'bytes32', + // name: 'r', + // type: 'bytes32', + // }, + // { + // internalType: 'bytes32', + // name: 's', + // type: 'bytes32', + // }, + // ], + // internalType: 'struct Signature', + // name: 'signature', + // type: 'tuple', + // }, + // { + // internalType: 'address', + // name: 'attester', + // type: 'address', + // }, + // { + // internalType: 'uint64', + // name: 'deadline', + // type: 'uint64', + // }, + // ], + // internalType: 'struct DelegatedProxyAttestationRequest', + // name: 'delegatedRequest', + // type: 'tuple', + // }, + // ], + // name: 'attestByDelegation', + // outputs: [ + // { internalType: 'bytes32', name: '', type: 'bytes32' }, + // ], + // stateMutability: 'payable', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'eip712Domain', + // outputs: [ + // { internalType: 'bytes1', name: 'fields', type: 'bytes1' }, + // { internalType: 'string', name: 'name', type: 'string' }, + // { internalType: 'string', name: 'version', type: 'string' }, + // { + // internalType: 'uint256', + // name: 'chainId', + // type: 'uint256', + // }, + // { + // internalType: 'address', + // name: 'verifyingContract', + // type: 'address', + // }, + // { internalType: 'bytes32', name: 'salt', type: 'bytes32' }, + // { + // internalType: 'uint256[]', + // name: 'extensions', + // type: 'uint256[]', + // }, + // ], + // stateMutability: 'view', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'getAttestTypeHash', + // outputs: [ + // { internalType: 'bytes32', name: '', type: 'bytes32' }, + // ], + // stateMutability: 'pure', + // type: 'function', + // }, + // { + // inputs: [ + // { internalType: 'bytes32', name: 'uid', type: 'bytes32' }, + // ], + // name: 'getAttester', + // outputs: [ + // { internalType: 'address', name: '', type: 'address' }, + // ], + // stateMutability: 'view', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'getDomainSeparator', + // outputs: [ + // { internalType: 'bytes32', name: '', type: 'bytes32' }, + // ], + // stateMutability: 'view', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'getEAS', + // outputs: [ + // { + // internalType: 'contract IEAS', + // name: '', + // type: 'address', + // }, + // ], + // stateMutability: 'view', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'getName', + // outputs: [{ internalType: 'string', name: '', type: 'string' }], + // stateMutability: 'view', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'getRevokeTypeHash', + // outputs: [ + // { internalType: 'bytes32', name: '', type: 'bytes32' }, + // ], + // stateMutability: 'pure', + // type: 'function', + // }, + // { + // inputs: [ + // { + // components: [ + // { + // internalType: 'bytes32', + // name: 'schema', + // type: 'bytes32', + // }, + // { + // components: [ + // { + // internalType: 'address', + // name: 'recipient', + // type: 'address', + // }, + // { + // internalType: 'uint64', + // name: 'expirationTime', + // type: 'uint64', + // }, + // { + // internalType: 'bool', + // name: 'revocable', + // type: 'bool', + // }, + // { + // internalType: 'bytes32', + // name: 'refUID', + // type: 'bytes32', + // }, + // { + // internalType: 'bytes', + // name: 'data', + // type: 'bytes', + // }, + // { + // internalType: 'uint256', + // name: 'value', + // type: 'uint256', + // }, + // ], + // internalType: 'struct AttestationRequestData[]', + // name: 'data', + // type: 'tuple[]', + // }, + // { + // components: [ + // { + // internalType: 'uint8', + // name: 'v', + // type: 'uint8', + // }, + // { + // internalType: 'bytes32', + // name: 'r', + // type: 'bytes32', + // }, + // { + // internalType: 'bytes32', + // name: 's', + // type: 'bytes32', + // }, + // ], + // internalType: 'struct Signature[]', + // name: 'signatures', + // type: 'tuple[]', + // }, + // { + // internalType: 'address', + // name: 'attester', + // type: 'address', + // }, + // { + // internalType: 'uint64', + // name: 'deadline', + // type: 'uint64', + // }, + // ], + // internalType: + // 'struct MultiDelegatedProxyAttestationRequest[]', + // name: 'multiDelegatedRequests', + // type: 'tuple[]', + // }, + // ], + // name: 'multiAttestByDelegation', + // outputs: [ + // { internalType: 'bytes32[]', name: '', type: 'bytes32[]' }, + // ], + // stateMutability: 'payable', + // type: 'function', + // }, + // { + // inputs: [ + // { + // components: [ + // { + // internalType: 'bytes32', + // name: 'schema', + // type: 'bytes32', + // }, + // { + // components: [ + // { + // internalType: 'bytes32', + // name: 'uid', + // type: 'bytes32', + // }, + // { + // internalType: 'uint256', + // name: 'value', + // type: 'uint256', + // }, + // ], + // internalType: 'struct RevocationRequestData[]', + // name: 'data', + // type: 'tuple[]', + // }, + // { + // components: [ + // { + // internalType: 'uint8', + // name: 'v', + // type: 'uint8', + // }, + // { + // internalType: 'bytes32', + // name: 'r', + // type: 'bytes32', + // }, + // { + // internalType: 'bytes32', + // name: 's', + // type: 'bytes32', + // }, + // ], + // internalType: 'struct Signature[]', + // name: 'signatures', + // type: 'tuple[]', + // }, + // { + // internalType: 'address', + // name: 'revoker', + // type: 'address', + // }, + // { + // internalType: 'uint64', + // name: 'deadline', + // type: 'uint64', + // }, + // ], + // internalType: + // 'struct MultiDelegatedProxyRevocationRequest[]', + // name: 'multiDelegatedRequests', + // type: 'tuple[]', + // }, + // ], + // name: 'multiRevokeByDelegation', + // outputs: [], + // stateMutability: 'payable', + // type: 'function', + // }, + // { + // inputs: [ + // { + // components: [ + // { + // internalType: 'bytes32', + // name: 'schema', + // type: 'bytes32', + // }, + // { + // components: [ + // { + // internalType: 'bytes32', + // name: 'uid', + // type: 'bytes32', + // }, + // { + // internalType: 'uint256', + // name: 'value', + // type: 'uint256', + // }, + // ], + // internalType: 'struct RevocationRequestData', + // name: 'data', + // type: 'tuple', + // }, + // { + // components: [ + // { + // internalType: 'uint8', + // name: 'v', + // type: 'uint8', + // }, + // { + // internalType: 'bytes32', + // name: 'r', + // type: 'bytes32', + // }, + // { + // internalType: 'bytes32', + // name: 's', + // type: 'bytes32', + // }, + // ], + // internalType: 'struct Signature', + // name: 'signature', + // type: 'tuple', + // }, + // { + // internalType: 'address', + // name: 'revoker', + // type: 'address', + // }, + // { + // internalType: 'uint64', + // name: 'deadline', + // type: 'uint64', + // }, + // ], + // internalType: 'struct DelegatedProxyRevocationRequest', + // name: 'delegatedRequest', + // type: 'tuple', + // }, + // ], + // name: 'revokeByDelegation', + // outputs: [], + // stateMutability: 'payable', + // type: 'function', + // }, + // { + // inputs: [], + // name: 'version', + // outputs: [{ internalType: 'string', name: '', type: 'string' }], + // stateMutability: 'view', + // type: 'function', + // }, + // ], permissionManagerContractAddress: '0x787aeDd9Fb3e16EeF5b00C0F35f105daD2A1aA15',