diff --git a/packages/nextjs/app/debug/_components/contract/utilsDisplay.tsx b/packages/nextjs/app/debug/_components/contract/utilsDisplay.tsx index 15229f3..1a7762e 100644 --- a/packages/nextjs/app/debug/_components/contract/utilsDisplay.tsx +++ b/packages/nextjs/app/debug/_components/contract/utilsDisplay.tsx @@ -24,7 +24,7 @@ type DisplayContent = export const displayTxResult = ( displayContent: DisplayContent | DisplayContent[], asText: boolean, - functionOutputs: readonly AbiOutput[] = [], + functionOutputs: readonly AbiOutput[] = [] ): string | ReactElement | number => { if (displayContent == null) { return ""; @@ -32,6 +32,7 @@ export const displayTxResult = ( if (functionOutputs != null && functionOutputs.length != 0) { const type = functionOutputs[0].type; const parsedParam = parseParamWithType(type, displayContent, true); + console.log(parsedParam); if (typeof parsedParam === "bigint") { const asNumber = Number(parsedParam); diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index 42ff57e..4bee82d 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -124,9 +124,9 @@ const deployedContracts = { }, ], }, - AttestationRegistry: { + AttestationRegistry: { address: - "0x0415e94910dadd0a9be94dff4e5c762c4ccc034a66ebf424cb011ef885af0f41", + "0x043a0fcd4152f67425ca045f81babfdf9d8a0ed7a3e4dda1f1a5bfc094a8d5da", abi: [ { type: "impl", @@ -166,10 +166,64 @@ const deployedContracts = { }, ], }, + { + type: "struct", + name: "contracts::AttestationRegistry::Attestation", + members: [ + { + name: "uid", + type: "core::integer::u128", + }, + { + name: "schema_uid", + type: "core::integer::u128", + }, + { + name: "time", + type: "core::integer::u64", + }, + { + name: "recipient", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "attester", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "data", + type: "core::byte_array::ByteArray", + }, + { + name: "revocable", + type: "core::bool", + }, + { + name: "revocation_time", + type: "core::integer::u64", + }, + ], + }, { type: "interface", name: "contracts::AttestationRegistry::IAttestationRegistry", items: [ + { + type: "function", + name: "get_attestation", + inputs: [ + { + name: "attestation_uid", + type: "core::integer::u128", + }, + ], + outputs: [ + { + type: "contracts::AttestationRegistry::Attestation", + }, + ], + state_mutability: "view", + }, { type: "function", name: "attest", @@ -348,10 +402,64 @@ const deployedContracts = { }, ], }, + { + type: "struct", + name: "contracts::AttestationRegistry::Attestation", + members: [ + { + name: "uid", + type: "core::integer::u128", + }, + { + name: "schema_uid", + type: "core::integer::u128", + }, + { + name: "time", + type: "core::integer::u64", + }, + { + name: "recipient", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "attester", + type: "core::starknet::contract_address::ContractAddress", + }, + { + name: "data", + type: "core::byte_array::ByteArray", + }, + { + name: "revocable", + type: "core::bool", + }, + { + name: "revocation_time", + type: "core::integer::u64", + }, + ], + }, { type: "interface", name: "contracts::AttestationRegistry::IAttestationRegistry", items: [ + { + type: "function", + name: "get_attestation", + inputs: [ + { + name: "attestation_uid", + type: "core::integer::u128", + }, + ], + outputs: [ + { + type: "contracts::AttestationRegistry::Attestation", + }, + ], + state_mutability: "view", + }, { type: "function", name: "attest", diff --git a/packages/snfoundry/contracts/src/AttestationRegistry.cairo b/packages/snfoundry/contracts/src/AttestationRegistry.cairo index b88e343..15bae40 100644 --- a/packages/snfoundry/contracts/src/AttestationRegistry.cairo +++ b/packages/snfoundry/contracts/src/AttestationRegistry.cairo @@ -3,7 +3,7 @@ use super::SchemaRegistry::{ISchemaRegistry, ISchemaRegistryDispatcher}; #[starknet::interface] pub trait IAttestationRegistry { - // fn get_attestation(self: @TContractState, attestation_uid: u128) -> (u128, u128, u64, ContractAddress, ContractAddress, ByteArray, bool, u64); + fn get_attestation(self: @TContractState, attestation_uid: u128) -> Attestation; fn attest( ref self: TContractState, schema_uid: u128, @@ -101,11 +101,20 @@ mod AttestationRegistry { #[abi(embed_v0)] impl AttestationRegistryImpl of IAttestationRegistry { - // fn get_attestation(self: @ContractState, attestation_uid: u128) -> (u128, u128, u64, ContractAddress, ContractAddress, ByteArray, bool, u64) { - // let data = self.db.read(attestation_uid); - // (data.uid, data.schema_uid, data.time, data.recipient, data.attester, data.data, data.revocable, data.revocation_time) - // } - + fn get_attestation(self: @ContractState, attestation_uid: u128) -> Attestation { + let data = self.db.read(attestation_uid); + Attestation { + uid: data.uid, + schema_uid: data.schema_uid, + time: data.time, + recipient: data.recipient, + attester: data.attester, + data: data.data, + revocable: data.revocable, + revocation_time: data.revocation_time, + } + } + fn attest( ref self: ContractState, schema_uid: u128,