diff --git a/contracts/programs/contract-reader-interface/src/lib.rs b/contracts/programs/contract-reader-interface/src/lib.rs index bc114ba83..ff30cdffa 100644 --- a/contracts/programs/contract-reader-interface/src/lib.rs +++ b/contracts/programs/contract-reader-interface/src/lib.rs @@ -107,15 +107,21 @@ pub mod contract_reader_interface { Ok(()) } - pub fn create_event(_ctx: Context, str_data: TestStructData) -> Result<()> { + pub fn createevent(_ctx: Context, data: TestStructData) -> Result<()> { emit!(TestEvent { - data: str_data, + data: data, }); Ok(()) } } +#[derive(Accounts)] +pub struct Events<'info> { + pub signer: Signer<'info>, + pub system_program: Program<'info, System>, +} + #[derive(Accounts)] #[instruction(test_idx: u64)] pub struct Initialize<'info> { diff --git a/integration-tests/relayinterface/chain_components_test.go b/integration-tests/relayinterface/chain_components_test.go index c512a56fa..719f1c431 100644 --- a/integration-tests/relayinterface/chain_components_test.go +++ b/integration-tests/relayinterface/chain_components_test.go @@ -102,7 +102,7 @@ func DisableTests(it *SolanaChainComponentsInterfaceTester[*testing.T]) { ContractReaderGetLatestValueWithFilteringForEvent, // query key not implemented yet // ContractReaderQueryKeyNotFound, - ContractReaderQueryKeyReturnsData, + // ContractReaderQueryKeyReturnsData, ContractReaderQueryKeyReturnsDataAsValuesDotValue, ContractReaderQueryKeyCanFilterWithValueComparator, ContractReaderQueryKeyCanLimitResultsWithCursor, @@ -797,7 +797,6 @@ func (it *SolanaChainComponentsInterfaceTester[T]) buildContractReaderConfig(t T pdaStructDataPrefix := []byte("struct_data") pdaStructDataPrefix = binary.LittleEndian.AppendUint64(pdaStructDataPrefix, idx) testStruct := CreateTestStruct(0, it) - locator := commoncodec.ElementExtractorLocationFirst uint64ReadDef := config.ReadDefinition{ ChainSpecificName: "DataAccount", ReadType: config.Account, @@ -983,20 +982,7 @@ func (it *SolanaChainComponentsInterfaceTester[T]) buildContractReaderConfig(t T ChainSpecificName: "TestEvent", ReadType: config.Event, OutputModifications: commoncodec.ModifiersConfig{ - &commoncodec.ElementExtractorModifierConfig{ - Extractions: map[string]*commoncodec.ElementExtractorLocation{"Data": &locator}, - }, - &commoncodec.HardCodeModifierConfig{ - OnChainValues: map[string]any{ - "DifferentField": copy(make([]byte, 32), []byte(testStruct.DifferentField)), - "NestedDynamicStruct.Inner.S": copy(make([]byte, 32), []byte(testStruct.NestedDynamicStruct.Inner.S)), - }, - OffChainValues: map[string]any{ - "ExtraField": AnyExtraValue, - "DifferentField": testStruct.DifferentField, - "NestedDynamicStruct.Inner.S": testStruct.NestedDynamicStruct.Inner.S, - }, - }, + &commoncodec.PropertyExtractorConfig{FieldName: "Data"}, &commoncodec.AddressBytesToStringModifierConfig{ Fields: []string{"AccountStruct.AccountStr"}, }, @@ -1362,6 +1348,47 @@ func (it *SolanaChainComponentsInterfaceTester[T]) buildContractWriterConfig(t T }, DebugIDLocation: "", }, + MethodTriggeringEvent: { + FromAddress: fromAddress, + InputModifications: []commoncodec.ModifierConfig{ + &commoncodec.PropertyExtractorConfig{FieldName: "Data"}, + &commoncodec.AddressBytesToStringModifierConfig{ + Fields: []string{"AccountStruct.AccountStr"}, + }, + &commoncodec.HardCodeModifierConfig{ + OnChainValues: map[string]any{ + "Padding0": []byte{}, + "Padding1": []byte{}, + "Padding2": []byte{}, + "NestedDynamicStruct.Padding": []byte{}, + "NestedStaticStruct.Padding": []byte{}, + "DifferentField": copy(make([]byte, 32), []byte(testStruct.DifferentField)), + "NestedDynamicStruct.Inner.S": copy(make([]byte, 32), []byte(testStruct.NestedDynamicStruct.Inner.S)), + }, + OffChainValues: map[string]any{ + "DifferentField": testStruct.DifferentField, + "NestedDynamicStruct.Inner.S": testStruct.NestedDynamicStruct.Inner.S, + }, + }, + }, + ChainSpecificName: "createevent", + LookupTables: chainwriter.LookupTables{}, + Accounts: []chainwriter.Lookup{ + {AccountConstant: &chainwriter.AccountConstant{ + Name: "Signer", + Address: fromAddress, + IsSigner: true, + IsWritable: true, + }}, + {AccountConstant: &chainwriter.AccountConstant{ + Name: "SystemProgram", + Address: solana.SystemProgramID.String(), + IsWritable: false, + IsSigner: false, + }}, + }, + DebugIDLocation: "", + }, }, }, AnySecondContractName: {