@@ -20,12 +20,18 @@ public class DelegateComponentInstruction {
2020 }
2121
2222 public static async Task < DelegateComponentInstruction > DelegateComponent ( PublicKey payer , PublicKey entity , PublicKey componentId , string seed = "" ) {
23- var account = WorldProgram . FindComponentPda ( componentId , entity , seed ) ;
24- var bufferPda = WorldProgram . FindBufferPda ( account , componentId ) ;
25- var delegationRecord = WorldProgram . FindDelegationProgramPda ( "delegation" , account ) ;
26- var delegationMetadata = WorldProgram . FindDelegationProgramPda ( "delegation-metadata" , account ) ;
23+ var componentPda = WorldProgram . FindComponentPda ( componentId , entity , seed ) ;
24+ var componentBuffer = WorldProgram . FindBufferPda ( componentPda ) ;
2725
28- byte [ ] discriminator = new byte [ ] { 90 , 147 , 75 , 178 , 85 , 88 , 4 , 137 } ;
26+ var componentDelegationRecord = WorldProgram . FindDelegationProgramPda ( "delegation" , componentPda ) ;
27+ var componentDelegationMetadata = WorldProgram . FindDelegationProgramPda ( "delegation-metadata" , componentPda ) ;
28+
29+ var worldProgram = new PublicKey ( WorldProgram . ID ) ;
30+ var bufferDelegationRecord = WorldProgram . FindDelegationProgramPda ( "delegation" , componentBuffer ) ;
31+ var bufferDelegationMetadata = WorldProgram . FindDelegationProgramPda ( "delegation-metadata" , componentBuffer ) ;
32+ var bufferBuffer = WorldProgram . FindBufferPda ( componentBuffer , worldProgram ) ;
33+
34+ byte [ ] discriminator = new byte [ ] { 191 , 212 , 179 , 193 , 178 , 94 , 119 , 93 } ;
2935 uint commitFrequencyMs = 0 ;
3036 byte [ ] commitFrequencyBytes = BitConverter . GetBytes ( commitFrequencyMs ) ;
3137 if ( ! BitConverter . IsLittleEndian ) Array . Reverse ( commitFrequencyBytes ) ;
@@ -38,22 +44,27 @@ public static async Task<DelegateComponentInstruction> DelegateComponent(PublicK
3844 Array . Copy ( validator , 0 , data , discriminator . Length + commitFrequencyBytes . Length , validator . Length ) ;
3945
4046 TransactionInstruction instruction = new TransactionInstruction ( ) {
41- ProgramId = componentId ,
47+ ProgramId = new PublicKey ( WorldProgram . ID ) ,
4248 Keys = new List < AccountMeta > ( ) {
43- AccountMeta . ReadOnly ( payer , true ) ,
44- AccountMeta . ReadOnly ( entity , false ) ,
45- AccountMeta . Writable ( account , false ) ,
49+ AccountMeta . Writable ( payer , true ) ,
50+ AccountMeta . Writable ( componentPda , false ) ,
51+ AccountMeta . Writable ( componentBuffer , false ) ,
4652 AccountMeta . ReadOnly ( componentId , false ) ,
47- AccountMeta . Writable ( bufferPda , false ) ,
48- AccountMeta . Writable ( delegationRecord , false ) ,
49- AccountMeta . Writable ( delegationMetadata , false ) ,
53+ AccountMeta . Writable ( WorldProgram . FindBufferPda ( componentPda , componentId ) , false ) ,
54+ AccountMeta . Writable ( componentDelegationRecord , false ) ,
55+ AccountMeta . Writable ( componentDelegationMetadata , false ) ,
5056 AccountMeta . ReadOnly ( WorldProgram . DelegationProgram , false ) ,
5157 AccountMeta . ReadOnly ( SystemProgram . ProgramIdKey , false ) ,
58+ AccountMeta . ReadOnly ( entity , false ) ,
59+ AccountMeta . ReadOnly ( worldProgram , false ) ,
60+ AccountMeta . Writable ( bufferBuffer , false ) ,
61+ AccountMeta . Writable ( bufferDelegationRecord , false ) ,
62+ AccountMeta . Writable ( bufferDelegationMetadata , false ) ,
5263 } ,
5364 Data = data ,
5465 } ;
5566 return new DelegateComponentInstruction ( ) {
56- Pda = WorldProgram . FindDelegationProgramPda ( seed , entity ) ,
67+ Pda = componentPda ,
5768 Instruction = instruction ,
5869 } ;
5970 }
0 commit comments