Skip to content

Commit 8e0ca48

Browse files
committed
♻️ Making API retro-compatible
1 parent 910d4c3 commit 8e0ca48

File tree

23 files changed

+259
-281
lines changed

23 files changed

+259
-281
lines changed

clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/ApplySystem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction ApplySystem(
100100
{
101101
BoltSystem = systemId.Program,
102102
Authority = authority,
103-
CpiAuth = WorldProgram.CpiAuthAddress,
104103
World = world,
105104
SessionToken = sessionToken,
106105
};
@@ -120,7 +119,6 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction ApplySystem(
120119
{
121120
BoltSystem = systemId.Program,
122121
Authority = authority,
123-
CpiAuth = WorldProgram.CpiAuthAddress,
124122
World = world,
125123
};
126124
if (hasSystemName)

clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/DestroyComponent.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ public static async Task<DestroyComponentInstruction> DestroyComponent(PublicKey
3636
Component = componentPda,
3737
ComponentProgram = componentProgram,
3838
ComponentProgramData = componentProgramData,
39-
CpiAuth = WorldProgram.CpiAuthAddress
4039
};
41-
var instruction = WorldProgram.DestroyComponent(destroyComponent, GetDiscriminator("global:destroy"));
40+
var instruction = WorldProgram.DestroyComponent(destroyComponent);
4241
return new DestroyComponentInstruction() {
4342
Instruction = instruction
4443
};
@@ -58,9 +57,8 @@ public static async Task<DestroyComponentInstruction> DestroyComponent(PublicKey
5857
Component = pda,
5958
ComponentProgram = component.Program,
6059
ComponentProgramData = componentProgramData,
61-
CpiAuth = WorldProgram.CpiAuthAddress
6260
};
63-
var instruction = WorldProgram.DestroyComponent(destroyComponent, component.GetMethodDiscriminator("destroy"));
61+
var instruction = WorldProgram.DestroyComponent(destroyComponent);
6462
return new DestroyComponentInstruction() {
6563
Instruction = instruction
6664
};

clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/InitializeComponent.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ public static async Task<InitializeComponentInstruction> InitializeComponent(Pub
3636
Data = componentPda,
3737
ComponentProgram = componentId,
3838
Authority = authority ?? new PublicKey(WorldProgram.ID),
39-
CpiAuth = WorldProgram.CpiAuthAddress
4039
};
41-
var instruction = WorldProgram.InitializeComponent(initializeComponent, GetDiscriminator("global:initialize"));
40+
var instruction = WorldProgram.InitializeComponent(initializeComponent);
4241
return new InitializeComponentInstruction() {
4342
Pda = componentPda,
4443
Instruction = instruction
@@ -65,9 +64,8 @@ public static async Task<InitializeComponentInstruction> InitializeComponent(Pub
6564
Data = componentPda,
6665
ComponentProgram = component.Program,
6766
Authority = authority ?? new PublicKey(WorldProgram.ID),
68-
CpiAuth = WorldProgram.CpiAuthAddress
6967
};
70-
var instruction = WorldProgram.InitializeComponent(initializeComponent, discriminator);
68+
var instruction = WorldProgram.InitializeComponentWithDiscriminator(initializeComponent, discriminator);
7169
return new InitializeComponentInstruction() {
7270
Pda = componentPda,
7371
Instruction = instruction

clients/csharp/Solana.Unity.Bolt/WorldProgram/Generated.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,25 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction InitializeComponent
506506
return new Solana.Unity.Rpc.Models.TransactionInstruction{Keys = keys, ProgramId = programId.KeyBytes, Data = resultData};
507507
}
508508

509+
public static Solana.Unity.Rpc.Models.TransactionInstruction InitializeComponentWithDiscriminator(InitializeComponentAccounts accounts, byte[] discriminator, PublicKey programId = null)
510+
{
511+
byte[] IX_INITIALIZE_COMPONENT_WITH_DISCRIMINATOR = new byte[] { 174, 196, 222, 15, 149, 54, 137, 23 };
512+
programId ??= new(ID);
513+
List<Solana.Unity.Rpc.Models.AccountMeta> keys = new()
514+
{Solana.Unity.Rpc.Models.AccountMeta.Writable(accounts.Payer, true), Solana.Unity.Rpc.Models.AccountMeta.Writable(accounts.Data, false), Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.Entity, false), Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.ComponentProgram, false), Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.Authority, false), Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.InstructionSysvarAccount, false), Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.SystemProgram, false)};
515+
byte[] _data = new byte[1200];
516+
int offset = 0;
517+
_data.WriteSpan(IX_INITIALIZE_COMPONENT_WITH_DISCRIMINATOR, offset);
518+
offset += 8;
519+
_data.WriteS32(discriminator.Length, offset);
520+
offset += 4;
521+
_data.WriteSpan(discriminator, offset);
522+
offset += discriminator.Length;
523+
byte[] resultData = new byte[offset];
524+
Array.Copy(_data, resultData, offset);
525+
return new Solana.Unity.Rpc.Models.TransactionInstruction{Keys = keys, ProgramId = programId.KeyBytes, Data = resultData};
526+
}
527+
509528
public static Solana.Unity.Rpc.Models.TransactionInstruction InitializeNewWorld(InitializeNewWorldAccounts accounts, PublicKey programId = null)
510529
{
511530
programId ??= new(ID);

clients/csharp/Solana.Unity.Bolt/WorldProgram/World.cs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction ApplySystem(
231231
var apply = new ApplyWithSessionAccounts() {
232232
BoltSystem = system,
233233
Authority = authority,
234-
CpiAuth = CpiAuthAddress,
235234
World = world,
236235
SessionToken = sessionToken,
237236
};
@@ -240,7 +239,6 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction ApplySystem(
240239
var apply = new ApplyAccounts() {
241240
BoltSystem = system,
242241
Authority = authority,
243-
CpiAuth = CpiAuthAddress,
244242
World = world,
245243
};
246244
instruction = Apply(apply, args, programId);
@@ -253,37 +251,14 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction ApplySystem(
253251
return instruction;
254252
}
255253

256-
public static Solana.Unity.Rpc.Models.TransactionInstruction Apply(ApplyAccounts accounts, byte[] args, PublicKey programId = null)
257-
{
258-
programId ??= new(ID);
259-
List<Solana.Unity.Rpc.Models.AccountMeta> keys = new()
260-
{
261-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.BoltSystem, false),
262-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.Authority, true),
263-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.CpiAuth, false),
264-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.World, false)
265-
};
266-
byte[] _data = new byte[1200];
267-
int offset = 0;
268-
_data.WriteSpan(IX_APPLY, offset);
269-
offset += 8;
270-
_data.WriteS32(args.Length, offset);
271-
offset += 4;
272-
_data.WriteSpan(args, offset);
273-
offset += args.Length;
274-
byte[] resultData = new byte[offset];
275-
Array.Copy(_data, resultData, offset);
276-
return new Solana.Unity.Rpc.Models.TransactionInstruction{Keys = keys, ProgramId = programId.KeyBytes, Data = resultData};
277-
}
278-
279254
public static Solana.Unity.Rpc.Models.TransactionInstruction ApplyWithDiscriminator(ApplyAccounts accounts, byte[] system_discriminator, byte[] args, PublicKey programId = null)
280255
{
281256
programId ??= new(ID);
282257
List<Solana.Unity.Rpc.Models.AccountMeta> keys = new()
283258
{
284259
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.BoltSystem, false),
285260
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.Authority, true),
286-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.CpiAuth, false),
261+
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.InstructionSysvarAccount, false),
287262
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.World, false)
288263
};
289264
byte[] _data = new byte[1200];
@@ -303,38 +278,14 @@ public static Solana.Unity.Rpc.Models.TransactionInstruction ApplyWithDiscrimina
303278
return new Solana.Unity.Rpc.Models.TransactionInstruction{Keys = keys, ProgramId = programId.KeyBytes, Data = resultData};
304279
}
305280

306-
public static Solana.Unity.Rpc.Models.TransactionInstruction ApplyWithSession(ApplyWithSessionAccounts accounts, byte[] args, PublicKey programId = null)
307-
{
308-
programId ??= new(ID);
309-
List<Solana.Unity.Rpc.Models.AccountMeta> keys = new()
310-
{
311-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.BoltSystem, false),
312-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.Authority, true),
313-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.CpiAuth, false),
314-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.World, false),
315-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.SessionToken, false)
316-
};
317-
byte[] _data = new byte[1200];
318-
int offset = 0;
319-
_data.WriteSpan(IX_APPLY_WITH_SESSION, offset);
320-
offset += 8;
321-
_data.WriteS32(args.Length, offset);
322-
offset += 4;
323-
_data.WriteSpan(args, offset);
324-
offset += args.Length;
325-
byte[] resultData = new byte[offset];
326-
Array.Copy(_data, resultData, offset);
327-
return new Solana.Unity.Rpc.Models.TransactionInstruction{Keys = keys, ProgramId = programId.KeyBytes, Data = resultData};
328-
}
329-
330281
public static Solana.Unity.Rpc.Models.TransactionInstruction ApplyWithSessionAndDiscriminator(ApplyWithSessionAccounts accounts, byte[] system_discriminator, byte[] args, PublicKey programId = null)
331282
{
332283
programId ??= new(ID);
333284
List<Solana.Unity.Rpc.Models.AccountMeta> keys = new()
334285
{
335286
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.BoltSystem, false),
336287
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.Authority, true),
337-
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.CpiAuth, false),
288+
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.InstructionSysvarAccount, false),
338289
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.World, false),
339290
Solana.Unity.Rpc.Models.AccountMeta.ReadOnly(accounts.SessionToken, false)
340291
};

clients/typescript/src/generated/idl/world.json

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@
159159
"signer": true
160160
},
161161
{
162-
"name": "cpi_auth"
162+
"name": "instruction_sysvar_account",
163+
"address": "Sysvar1nstructions1111111111111111111111111"
163164
},
164165
{
165166
"name": "world"
@@ -235,7 +236,8 @@
235236
"signer": true
236237
},
237238
{
238-
"name": "cpi_auth"
239+
"name": "instruction_sysvar_account",
240+
"address": "Sysvar1nstructions1111111111111111111111111"
239241
},
240242
{
241243
"name": "world"
@@ -331,6 +333,52 @@
331333
"address": "11111111111111111111111111111111"
332334
}
333335
],
336+
"args": []
337+
},
338+
{
339+
"name": "destroy_component_with_discriminator",
340+
"discriminator": [
341+
71,
342+
25,
343+
153,
344+
201,
345+
108,
346+
92,
347+
114,
348+
125
349+
],
350+
"accounts": [
351+
{
352+
"name": "authority",
353+
"writable": true,
354+
"signer": true
355+
},
356+
{
357+
"name": "receiver",
358+
"writable": true
359+
},
360+
{
361+
"name": "component_program"
362+
},
363+
{
364+
"name": "component_program_data"
365+
},
366+
{
367+
"name": "entity"
368+
},
369+
{
370+
"name": "component",
371+
"writable": true
372+
},
373+
{
374+
"name": "instruction_sysvar_account",
375+
"address": "Sysvar1nstructions1111111111111111111111111"
376+
},
377+
{
378+
"name": "system_program",
379+
"address": "11111111111111111111111111111111"
380+
}
381+
],
334382
"args": [
335383
{
336384
"name": "discriminator",
@@ -378,6 +426,48 @@
378426
"address": "11111111111111111111111111111111"
379427
}
380428
],
429+
"args": []
430+
},
431+
{
432+
"name": "initialize_component_with_discriminator",
433+
"discriminator": [
434+
174,
435+
196,
436+
222,
437+
15,
438+
149,
439+
54,
440+
137,
441+
23
442+
],
443+
"accounts": [
444+
{
445+
"name": "payer",
446+
"writable": true,
447+
"signer": true
448+
},
449+
{
450+
"name": "data",
451+
"writable": true
452+
},
453+
{
454+
"name": "entity"
455+
},
456+
{
457+
"name": "component_program"
458+
},
459+
{
460+
"name": "authority"
461+
},
462+
{
463+
"name": "instruction_sysvar_account",
464+
"address": "Sysvar1nstructions1111111111111111111111111"
465+
},
466+
{
467+
"name": "system_program",
468+
"address": "11111111111111111111111111111111"
469+
}
470+
],
381471
"args": [
382472
{
383473
"name": "discriminator",

0 commit comments

Comments
 (0)