@magicblock-labs/ephemeral-rollups-kit 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/lib/__test__/connection.test.js +20 -1
  2. package/lib/__test__/connection.test.js.map +1 -1
  3. package/lib/__test__/instructions.test.d.ts +2 -0
  4. package/lib/__test__/instructions.test.d.ts.map +1 -0
  5. package/lib/__test__/instructions.test.js +424 -0
  6. package/lib/__test__/instructions.test.js.map +1 -0
  7. package/lib/connection.d.ts +4 -1
  8. package/lib/connection.d.ts.map +1 -1
  9. package/lib/connection.js +8 -0
  10. package/lib/connection.js.map +1 -1
  11. package/lib/index.d.ts +1 -1
  12. package/lib/index.d.ts.map +1 -1
  13. package/lib/index.js +1 -1
  14. package/lib/index.js.map +1 -1
  15. package/lib/instructions/delegation-program/closeEphemeralBalance.d.ts +7 -0
  16. package/lib/instructions/delegation-program/closeEphemeralBalance.d.ts.map +1 -0
  17. package/lib/instructions/delegation-program/closeEphemeralBalance.js +43 -0
  18. package/lib/instructions/delegation-program/closeEphemeralBalance.js.map +1 -0
  19. package/lib/instructions/delegation-program/delegate.d.ts +14 -0
  20. package/lib/instructions/delegation-program/delegate.d.ts.map +1 -0
  21. package/lib/instructions/delegation-program/delegate.js +67 -0
  22. package/lib/instructions/delegation-program/delegate.js.map +1 -0
  23. package/lib/instructions/delegation-program/index.d.ts +4 -0
  24. package/lib/instructions/delegation-program/index.d.ts.map +1 -0
  25. package/lib/instructions/delegation-program/index.js +10 -0
  26. package/lib/instructions/delegation-program/index.js.map +1 -0
  27. package/lib/instructions/delegation-program/topUpEphemeralBalance.d.ts +8 -0
  28. package/lib/instructions/delegation-program/topUpEphemeralBalance.d.ts.map +1 -0
  29. package/lib/instructions/delegation-program/topUpEphemeralBalance.js +38 -0
  30. package/lib/instructions/delegation-program/topUpEphemeralBalance.js.map +1 -0
  31. package/lib/instructions/index.d.ts +3 -0
  32. package/lib/instructions/index.d.ts.map +1 -0
  33. package/lib/instructions/index.js +19 -0
  34. package/lib/instructions/index.js.map +1 -0
  35. package/lib/instructions/magic-program/index.d.ts +3 -0
  36. package/lib/instructions/magic-program/index.d.ts.map +1 -0
  37. package/lib/instructions/magic-program/index.js +8 -0
  38. package/lib/instructions/magic-program/index.js.map +1 -0
  39. package/lib/instructions/magic-program/scheduleCommit.d.ts +3 -0
  40. package/lib/instructions/magic-program/scheduleCommit.d.ts.map +1 -0
  41. package/lib/instructions/magic-program/scheduleCommit.js +24 -0
  42. package/lib/instructions/magic-program/scheduleCommit.js.map +1 -0
  43. package/lib/instructions/magic-program/scheduleCommitAndUndelegate.d.ts +3 -0
  44. package/lib/instructions/magic-program/scheduleCommitAndUndelegate.d.ts.map +1 -0
  45. package/lib/instructions/magic-program/scheduleCommitAndUndelegate.js +24 -0
  46. package/lib/instructions/magic-program/scheduleCommitAndUndelegate.js.map +1 -0
  47. package/lib/pda.d.ts +6 -0
  48. package/lib/pda.d.ts.map +1 -1
  49. package/lib/pda.js +66 -0
  50. package/lib/pda.js.map +1 -1
  51. package/package.json +1 -2
  52. package/lib/instructions/delegate.d.ts +0 -25
  53. package/lib/instructions/delegate.d.ts.map +0 -1
  54. package/lib/instructions/delegate.js +0 -108
  55. package/lib/instructions/delegate.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
package/lib/index.js CHANGED
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants.js"), exports);
18
- __exportStar(require("./instructions/delegate.js"), exports);
18
+ __exportStar(require("./instructions/index.js"), exports);
19
19
  __exportStar(require("./pda.js"), exports);
20
20
  __exportStar(require("./utils.js"), exports);
21
21
  __exportStar(require("./resolver.js"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,6DAA2C;AAC3C,2CAAyB;AACzB,6CAA2B;AAC3B,gDAA8B;AAC9B,kDAAgC;AAChC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,0DAAwC;AACxC,2CAAyB;AACzB,6CAA2B;AAC3B,gDAA8B;AAC9B,kDAAgC;AAChC,oDAAkC"}
@@ -0,0 +1,7 @@
1
+ import { Address, Instruction } from "@solana/kit";
2
+ export interface CloseEphemeralBalanceInstructionArgs {
3
+ index?: number;
4
+ }
5
+ export declare function createCloseEscrowInstruction(escrow: Address, escrowAuthority: Address, index?: number): Instruction;
6
+ export declare function serializeCloseEphemeralBalanceInstructionData(args?: CloseEphemeralBalanceInstructionArgs): [Uint8Array];
7
+ //# sourceMappingURL=closeEphemeralBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closeEphemeralBalance.d.ts","sourceRoot":"","sources":["../../../src/instructions/delegation-program/closeEphemeralBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAA4B,MAAM,aAAa,CAAC;AAO7E,MAAM,WAAW,oCAAoC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,MAAM,GACb,WAAW,CAyBb;AAED,wBAAgB,6CAA6C,CAC3D,IAAI,CAAC,EAAE,oCAAoC,GAC1C,CAAC,UAAU,CAAC,CAed"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCloseEscrowInstruction = createCloseEscrowInstruction;
4
+ exports.serializeCloseEphemeralBalanceInstructionData = serializeCloseEphemeralBalanceInstructionData;
5
+ const kit_1 = require("@solana/kit");
6
+ const system_1 = require("@solana-program/system");
7
+ const constants_1 = require("../../constants");
8
+ function createCloseEscrowInstruction(escrow, escrowAuthority, index) {
9
+ const [instructionData] = serializeCloseEphemeralBalanceInstructionData({
10
+ index: index ?? 255,
11
+ });
12
+ const accounts_ = [
13
+ {
14
+ address: escrowAuthority,
15
+ role: kit_1.AccountRole.READONLY_SIGNER,
16
+ },
17
+ {
18
+ address: escrow,
19
+ role: kit_1.AccountRole.WRITABLE,
20
+ },
21
+ {
22
+ address: system_1.SYSTEM_PROGRAM_ADDRESS,
23
+ role: kit_1.AccountRole.READONLY,
24
+ },
25
+ ];
26
+ return {
27
+ accounts: accounts_,
28
+ data: instructionData,
29
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
30
+ };
31
+ }
32
+ function serializeCloseEphemeralBalanceInstructionData(args) {
33
+ const discriminator = [11, 0, 0, 0, 0, 0, 0, 0];
34
+ const buffer = new ArrayBuffer(9);
35
+ const view = new DataView(buffer);
36
+ let offset = 0;
37
+ for (let i = 0; i < 8; i++) {
38
+ view.setUint8(offset++, discriminator[i]);
39
+ }
40
+ view.setUint8(offset, args?.index ?? 255);
41
+ return [new Uint8Array(buffer, 0, 9)];
42
+ }
43
+ //# sourceMappingURL=closeEphemeralBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closeEphemeralBalance.js","sourceRoot":"","sources":["../../../src/instructions/delegation-program/closeEphemeralBalance.ts"],"names":[],"mappings":";;AAeA,oEA6BC;AAED,sGAiBC;AA/DD,qCAA6E;AAC7E,mDAAgE;AAChE,+CAAwD;AAaxD,SAAgB,4BAA4B,CAC1C,MAAe,EACf,eAAwB,EACxB,KAAc;IAEd,MAAM,CAAC,eAAe,CAAC,GAAG,6CAA6C,CAAC;QACtE,KAAK,EAAE,KAAK,IAAI,GAAG;KACpB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAkB;QAC/B;YACE,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,iBAAW,CAAC,eAAe;SAClC;QACD;YACE,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,iBAAW,CAAC,QAAQ;SAC3B;QACD;YACE,OAAO,EAAE,+BAAsB;YAC/B,IAAI,EAAE,iBAAW,CAAC,QAAQ;SAC3B;KACF,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,eAAe;QACrB,cAAc,EAAE,iCAAqB;KACtC,CAAC;AACJ,CAAC;AAED,SAAgB,6CAA6C,CAC3D,IAA2C;IAE3C,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IAGf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAGD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;IAE1C,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Address, Instruction } from "@solana/kit";
2
+ export interface DelegateInstructionArgs {
3
+ commitFrequencyMs?: number;
4
+ seeds?: Uint8Array[];
5
+ validator?: Address | null;
6
+ }
7
+ export declare function createDelegateInstruction(accounts: {
8
+ payer: Address;
9
+ delegatedAccount: Address;
10
+ ownerProgram: Address;
11
+ validator?: Address;
12
+ }, args?: DelegateInstructionArgs): Promise<Instruction>;
13
+ export declare function serializeDelegateInstructionData(args?: DelegateInstructionArgs): [Uint8Array];
14
+ //# sourceMappingURL=delegate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../../src/instructions/delegation-program/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,WAAW,EAIZ,MAAM,aAAa,CAAC;AAYrB,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5B;AAMD,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE;IACR,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,EACD,IAAI,CAAC,EAAE,uBAAuB,GAC7B,OAAO,CAAC,WAAW,CAAC,CAiCtB;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,CAAC,EAAE,uBAAuB,GAC7B,CAAC,UAAU,CAAC,CA2Cd"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDelegateInstruction = createDelegateInstruction;
4
+ exports.serializeDelegateInstructionData = serializeDelegateInstructionData;
5
+ const kit_1 = require("@solana/kit");
6
+ const system_1 = require("@solana-program/system");
7
+ const constants_1 = require("../../constants");
8
+ const pda_1 = require("../../pda");
9
+ async function createDelegateInstruction(accounts, args) {
10
+ const delegateBuffer = await (0, pda_1.delegateBufferPdaFromDelegatedAccountAndOwnerProgram)(accounts.delegatedAccount, accounts.ownerProgram);
11
+ const delegationRecord = await (0, pda_1.delegationRecordPdaFromDelegatedAccount)(accounts.delegatedAccount);
12
+ const delegationMetadata = await (0, pda_1.delegationMetadataPdaFromDelegatedAccount)(accounts.delegatedAccount);
13
+ const accountsMeta = [
14
+ { address: accounts.payer, role: kit_1.AccountRole.WRITABLE_SIGNER },
15
+ { address: accounts.delegatedAccount, role: kit_1.AccountRole.WRITABLE_SIGNER },
16
+ { address: accounts.ownerProgram, role: kit_1.AccountRole.READONLY },
17
+ { address: delegateBuffer, role: kit_1.AccountRole.WRITABLE },
18
+ { address: delegationRecord, role: kit_1.AccountRole.WRITABLE },
19
+ { address: delegationMetadata, role: kit_1.AccountRole.WRITABLE },
20
+ { address: system_1.SYSTEM_PROGRAM_ADDRESS, role: kit_1.AccountRole.READONLY },
21
+ ];
22
+ const [instructionData] = serializeDelegateInstructionData({
23
+ validator: accounts.validator,
24
+ ...args,
25
+ });
26
+ return {
27
+ accounts: accountsMeta,
28
+ data: instructionData,
29
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
30
+ };
31
+ }
32
+ function serializeDelegateInstructionData(args) {
33
+ const delegateInstructionDiscriminator = [0, 0, 0, 0, 0, 0, 0, 0];
34
+ const commitFrequencyMs = args?.commitFrequencyMs ?? 0xffffffff;
35
+ const seeds = args?.seeds ?? [];
36
+ const validator = args?.validator;
37
+ let offset = 0;
38
+ const buffer = new ArrayBuffer(1024);
39
+ const view = new DataView(buffer);
40
+ for (let i = 0; i < 8; i++) {
41
+ view.setUint8(offset++, delegateInstructionDiscriminator[i]);
42
+ }
43
+ view.setUint32(offset, commitFrequencyMs, true);
44
+ offset += 4;
45
+ view.setUint32(offset, seeds.length, true);
46
+ offset += 4;
47
+ for (const seed of seeds) {
48
+ view.setUint32(offset, seed.length, true);
49
+ offset += 4;
50
+ const seedBytes = new Uint8Array(buffer, offset, seed.length);
51
+ seedBytes.set(seed);
52
+ offset += seed.length;
53
+ }
54
+ if (validator) {
55
+ view.setUint8(offset++, 1);
56
+ const validatorBytes = new Uint8Array(buffer, offset, 32);
57
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
58
+ const addressBytes = addressEncoder.encode(validator);
59
+ validatorBytes.set(addressBytes);
60
+ offset += 32;
61
+ }
62
+ else {
63
+ view.setUint8(offset++, 0);
64
+ }
65
+ return [new Uint8Array(buffer, 0, offset)];
66
+ }
67
+ //# sourceMappingURL=delegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../../src/instructions/delegation-program/delegate.ts"],"names":[],"mappings":";;AA4BA,8DAyCC;AAED,4EA6CC;AApHD,qCAMqB;AACrB,mDAAgE;AAChE,+CAAwD;AACxD,mCAImB;AAeZ,KAAK,UAAU,yBAAyB,CAC7C,QAKC,EACD,IAA8B;IAE9B,MAAM,cAAc,GAClB,MAAM,IAAA,0DAAoD,EACxD,QAAQ,CAAC,gBAAgB,EACzB,QAAQ,CAAC,YAAY,CACtB,CAAC;IACJ,MAAM,gBAAgB,GAAG,MAAM,IAAA,6CAAuC,EACpE,QAAQ,CAAC,gBAAgB,CAC1B,CAAC;IACF,MAAM,kBAAkB,GAAG,MAAM,IAAA,+CAAyC,EACxE,QAAQ,CAAC,gBAAgB,CAC1B,CAAC;IAEF,MAAM,YAAY,GAAkB;QAClC,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EA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Q,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createDelegateInstruction, type DelegateInstructionArgs, } from "./delegate";
2
+ export { createTopUpEscrowInstruction } from "./topUpEphemeralBalance";
3
+ export { createCloseEscrowInstruction } from "./closeEphemeralBalance";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/instructions/delegation-program/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCloseEscrowInstruction = exports.createTopUpEscrowInstruction = exports.createDelegateInstruction = void 0;
4
+ var delegate_1 = require("./delegate");
5
+ Object.defineProperty(exports, "createDelegateInstruction", { enumerable: true, get: function () { return delegate_1.createDelegateInstruction; } });
6
+ var topUpEphemeralBalance_1 = require("./topUpEphemeralBalance");
7
+ Object.defineProperty(exports, "createTopUpEscrowInstruction", { enumerable: true, get: function () { return topUpEphemeralBalance_1.createTopUpEscrowInstruction; } });
8
+ var closeEphemeralBalance_1 = require("./closeEphemeralBalance");
9
+ Object.defineProperty(exports, "createCloseEscrowInstruction", { enumerable: true, get: function () { return closeEphemeralBalance_1.createCloseEscrowInstruction; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instructions/delegation-program/index.ts"],"names":[],"mappings":";;;AAAA,uCAGoB;AAFlB,qHAAA,yBAAyB,OAAA;AAG3B,iEAAuE;AAA9D,qIAAA,4BAA4B,OAAA;AACrC,iEAAuE;AAA9D,qIAAA,4BAA4B,OAAA"}
@@ -0,0 +1,8 @@
1
+ import { Address, Instruction } from "@solana/kit";
2
+ export interface TopUpEphemeralBalanceInstructionArgs {
3
+ amount: bigint;
4
+ index?: number;
5
+ }
6
+ export declare function createTopUpEscrowInstruction(escrow: Address, escrowAuthority: Address, payer: Address, amount: number, index?: number): Instruction;
7
+ export declare function serializeTopUpEphemeralBalanceInstructionData(args: TopUpEphemeralBalanceInstructionArgs): [Uint8Array];
8
+ //# sourceMappingURL=topUpEphemeralBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topUpEphemeralBalance.d.ts","sourceRoot":"","sources":["../../../src/instructions/delegation-program/topUpEphemeralBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAA4B,MAAM,aAAa,CAAC;AAO7E,MAAM,WAAW,oCAAoC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,WAAW,CAkBb;AAED,wBAAgB,6CAA6C,CAC3D,IAAI,EAAE,oCAAoC,GACzC,CAAC,UAAU,CAAC,CAmBd"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTopUpEscrowInstruction = createTopUpEscrowInstruction;
4
+ exports.serializeTopUpEphemeralBalanceInstructionData = serializeTopUpEphemeralBalanceInstructionData;
5
+ const kit_1 = require("@solana/kit");
6
+ const system_1 = require("@solana-program/system");
7
+ const constants_1 = require("../../constants");
8
+ function createTopUpEscrowInstruction(escrow, escrowAuthority, payer, amount, index) {
9
+ const accounts = [
10
+ { address: payer, role: kit_1.AccountRole.WRITABLE_SIGNER },
11
+ { address: escrowAuthority, role: kit_1.AccountRole.READONLY },
12
+ { address: escrow, role: kit_1.AccountRole.WRITABLE },
13
+ { address: system_1.SYSTEM_PROGRAM_ADDRESS, role: kit_1.AccountRole.READONLY },
14
+ ];
15
+ const [instructionData] = serializeTopUpEphemeralBalanceInstructionData({
16
+ amount: BigInt(amount),
17
+ index: index ?? 255,
18
+ });
19
+ return {
20
+ accounts,
21
+ data: instructionData,
22
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
23
+ };
24
+ }
25
+ function serializeTopUpEphemeralBalanceInstructionData(args) {
26
+ const discriminator = [9, 0, 0, 0, 0, 0, 0, 0];
27
+ const buffer = new ArrayBuffer(17);
28
+ const view = new DataView(buffer);
29
+ let offset = 0;
30
+ for (let i = 0; i < 8; i++) {
31
+ view.setUint8(offset++, discriminator[i]);
32
+ }
33
+ view.setBigUint64(offset, args.amount, true);
34
+ offset += 8;
35
+ view.setUint8(offset, args.index ?? 255);
36
+ return [new Uint8Array(buffer, 0, 17)];
37
+ }
38
+ //# sourceMappingURL=topUpEphemeralBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topUpEphemeralBalance.js","sourceRoot":"","sources":["../../../src/instructions/delegation-program/topUpEphemeralBalance.ts"],"names":[],"mappings":";;AAgBA,oEAwBC;AAED,sGAqBC;AA/DD,qCAA6E;AAC7E,mDAAgE;AAChE,+CAAwD;AAcxD,SAAgB,4BAA4B,CAC1C,MAAe,EACf,eAAwB,EACxB,KAAc,EACd,MAAc,EACd,KAAc;IAEd,MAAM,QAAQ,GAAkB;QAC9B,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAW,CAAC,eAAe,EAAE;QACrD,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAW,CAAC,QAAQ,EAAE;QACxD,EAAE,OAAO,EAAE,MAAM,EA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";
2
+ export * from "./magic-program";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./delegation-program"), exports);
18
+ __exportStar(require("./magic-program"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/instructions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC"}
@@ -0,0 +1,3 @@
1
+ export { createCommitInstruction } from "./scheduleCommit";
2
+ export { createCommitAndUndelegateInstruction } from "./scheduleCommitAndUndelegate";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/instructions/magic-program/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCommitAndUndelegateInstruction = exports.createCommitInstruction = void 0;
4
+ var scheduleCommit_1 = require("./scheduleCommit");
5
+ Object.defineProperty(exports, "createCommitInstruction", { enumerable: true, get: function () { return scheduleCommit_1.createCommitInstruction; } });
6
+ var scheduleCommitAndUndelegate_1 = require("./scheduleCommitAndUndelegate");
7
+ Object.defineProperty(exports, "createCommitAndUndelegateInstruction", { enumerable: true, get: function () { return scheduleCommitAndUndelegate_1.createCommitAndUndelegateInstruction; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instructions/magic-program/index.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AAAlD,yHAAA,uBAAuB,OAAA;AAChC,6EAAqF;AAA5E,mJAAA,oCAAoC,OAAA"}
@@ -0,0 +1,3 @@
1
+ import { Address, Instruction } from "@solana/kit";
2
+ export declare function createCommitInstruction(payer: Address, accountsToCommit: Address[]): Instruction;
3
+ //# sourceMappingURL=scheduleCommit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleCommit.d.ts","sourceRoot":"","sources":["../../../src/instructions/magic-program/scheduleCommit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAYnD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,gBAAgB,EAAE,OAAO,EAAE,GAC1B,WAAW,CAoBb"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCommitInstruction = createCommitInstruction;
4
+ const instructions_1 = require("@solana/instructions");
5
+ const constants_1 = require("../../constants");
6
+ function createCommitInstruction(payer, accountsToCommit) {
7
+ const accounts = [
8
+ { address: payer, role: instructions_1.AccountRole.WRITABLE_SIGNER },
9
+ { address: constants_1.MAGIC_CONTEXT_ID, role: instructions_1.AccountRole.WRITABLE },
10
+ ...accountsToCommit.map((account) => ({
11
+ address: account,
12
+ role: instructions_1.AccountRole.READONLY,
13
+ })),
14
+ ];
15
+ const data = new Uint8Array(4);
16
+ const view = new DataView(data.buffer);
17
+ view.setUint32(0, 1, true);
18
+ return {
19
+ accounts,
20
+ programAddress: constants_1.MAGIC_PROGRAM_ID,
21
+ data,
22
+ };
23
+ }
24
+ //# sourceMappingURL=scheduleCommit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleCommit.js","sourceRoot":"","sources":["../../../src/instructions/magic-program/scheduleCommit.ts"],"names":[],"mappings":";;AAYA,0DAuBC;AAlCD,uDAAmD;AACnD,+CAAqE;AAUrE,SAAgB,uBAAuB,CACrC,KAAc,EACd,gBAA2B;IAE3B,MAAM,QAAQ,GAAG;QACf,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,0BAAW,CAAC,eAAe,EAAE;QACrD,EAAE,OAAO,EAAE,4BAAgB,EAAE,IAAI,EAAE,0BAAW,CAAC,QAAQ,EAAE;QACzD,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACpC,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,0BAAW,CAAC,QAAQ;SAC3B,CAAC,CAAC;KACK,CAAC;IAGX,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAE3B,OAAO;QACL,QAAQ;QACR,cAAc,EAAE,4BAAgB;QAChC,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Address, Instruction } from "@solana/kit";
2
+ export declare function createCommitAndUndelegateInstruction(payer: Address, accountsToCommitAndUndelegate: Address[]): Instruction;
3
+ //# sourceMappingURL=scheduleCommitAndUndelegate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleCommitAndUndelegate.d.ts","sourceRoot":"","sources":["../../../src/instructions/magic-program/scheduleCommitAndUndelegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAanD,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,OAAO,EACd,6BAA6B,EAAE,OAAO,EAAE,GACvC,WAAW,CAoBb"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCommitAndUndelegateInstruction = createCommitAndUndelegateInstruction;
4
+ const instructions_1 = require("@solana/instructions");
5
+ const constants_1 = require("../../constants");
6
+ function createCommitAndUndelegateInstruction(payer, accountsToCommitAndUndelegate) {
7
+ const accounts = [
8
+ { address: payer, role: instructions_1.AccountRole.WRITABLE_SIGNER },
9
+ { address: constants_1.MAGIC_CONTEXT_ID, role: instructions_1.AccountRole.WRITABLE },
10
+ ...accountsToCommitAndUndelegate.map((account) => ({
11
+ address: account,
12
+ role: instructions_1.AccountRole.READONLY,
13
+ })),
14
+ ];
15
+ const data = new Uint8Array(4);
16
+ const view = new DataView(data.buffer);
17
+ view.setUint32(0, 2, true);
18
+ return {
19
+ accounts,
20
+ programAddress: constants_1.MAGIC_PROGRAM_ID,
21
+ data,
22
+ };
23
+ }
24
+ //# sourceMappingURL=scheduleCommitAndUndelegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleCommitAndUndelegate.js","sourceRoot":"","sources":["../../../src/instructions/magic-program/scheduleCommitAndUndelegate.ts"],"names":[],"mappings":";;AAaA,oFAuBC;AAnCD,uDAAmD;AACnD,+CAAqE;AAWrE,SAAgB,oCAAoC,CAClD,KAAc,EACd,6BAAwC;IAExC,MAAM,QAAQ,GAAG;QACf,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,0BAAW,CAAC,eAAe,EAAE;QACrD,EAAE,OAAO,EAAE,4BAAgB,EAAE,IAAI,EAAE,0BAAW,CAAC,QAAQ,EAAE;QACzD,GAAG,6BAA6B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACjD,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,0BAAW,CAAC,QAAQ;SAC3B,CAAC,CAAC;KACK,CAAC;IAGX,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAE3B,OAAO;QACL,QAAQ;QACR,cAAc,EAAE,4BAAgB;QAChC,IAAI;KACL,CAAC;AACJ,CAAC"}
package/lib/pda.d.ts CHANGED
@@ -2,4 +2,10 @@ import { Address } from "@solana/kit";
2
2
  export declare function delegationRecordPdaFromDelegatedAccount(delegatedAccount: Address): Promise<Address<string>>;
3
3
  export declare function delegationMetadataPdaFromDelegatedAccount(delegatedAccount: Address): Promise<Address<string>>;
4
4
  export declare function delegateBufferPdaFromDelegatedAccountAndOwnerProgram(delegatedAccount: Address, ownerProgramId: Address): Promise<Address<string>>;
5
+ export declare function escrowPdaFromEscrowAuthority(escrowAuthority: Address, index?: number): Promise<Address<string>>;
6
+ export declare function commitStatePdaFromDelegatedAccount(delegatedAccount: Address): Promise<Address<string>>;
7
+ export declare function commitRecordPdaFromDelegatedAccount(delegatedAccount: Address): Promise<Address<string>>;
8
+ export declare function undelegateBufferPdaFromDelegatedAccount(delegatedAccount: Address): Promise<Address<string>>;
9
+ export declare function feesVaultPda(): Promise<Address<string>>;
10
+ export declare function validatorFeesVaultPdaFromValidator(validator: Address): Promise<Address<string>>;
5
11
  //# sourceMappingURL=pda.d.ts.map
package/lib/pda.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pda.d.ts","sourceRoot":"","sources":["../src/pda.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAGR,MAAM,aAAa,CAAC;AAGrB,wBAAsB,uCAAuC,CAC3D,gBAAgB,EAAE,OAAO,4BAQ1B;AAED,wBAAsB,yCAAyC,CAC7D,gBAAgB,EAAE,OAAO,4BAY1B;AAED,wBAAsB,oDAAoD,CACxE,gBAAgB,EAAE,OAAO,EACzB,cAAc,EAAE,OAAO,4BAQxB"}
1
+ {"version":3,"file":"pda.d.ts","sourceRoot":"","sources":["../src/pda.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAGR,MAAM,aAAa,CAAC;AAGrB,wBAAsB,uCAAuC,CAC3D,gBAAgB,EAAE,OAAO,4BAQ1B;AAED,wBAAsB,yCAAyC,CAC7D,gBAAgB,EAAE,OAAO,4BAY1B;AAED,wBAAsB,oDAAoD,CACxE,gBAAgB,EAAE,OAAO,EACzB,cAAc,EAAE,OAAO,4BAQxB;AASD,wBAAsB,4BAA4B,CAChD,eAAe,EAAE,OAAO,EACxB,KAAK,GAAE,MAAY,4BAepB;AAED,wBAAsB,kCAAkC,CACtD,gBAAgB,EAAE,OAAO,4BAQ1B;AAED,wBAAsB,mCAAmC,CACvD,gBAAgB,EAAE,OAAO,4BAW1B;AAED,wBAAsB,uCAAuC,CAC3D,gBAAgB,EAAE,OAAO,4BAW1B;AAED,wBAAsB,YAAY,6BAMjC;AAED,wBAAsB,kCAAkC,CAAC,SAAS,EAAE,OAAO,4BAO1E"}
package/lib/pda.js CHANGED
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.delegationRecordPdaFromDelegatedAccount = delegationRecordPdaFromDelegatedAccount;
4
4
  exports.delegationMetadataPdaFromDelegatedAccount = delegationMetadataPdaFromDelegatedAccount;
5
5
  exports.delegateBufferPdaFromDelegatedAccountAndOwnerProgram = delegateBufferPdaFromDelegatedAccountAndOwnerProgram;
6
+ exports.escrowPdaFromEscrowAuthority = escrowPdaFromEscrowAuthority;
7
+ exports.commitStatePdaFromDelegatedAccount = commitStatePdaFromDelegatedAccount;
8
+ exports.commitRecordPdaFromDelegatedAccount = commitRecordPdaFromDelegatedAccount;
9
+ exports.undelegateBufferPdaFromDelegatedAccount = undelegateBufferPdaFromDelegatedAccount;
10
+ exports.feesVaultPda = feesVaultPda;
11
+ exports.validatorFeesVaultPdaFromValidator = validatorFeesVaultPdaFromValidator;
6
12
  const kit_1 = require("@solana/kit");
7
13
  const constants_1 = require("./constants");
8
14
  async function delegationRecordPdaFromDelegatedAccount(delegatedAccount) {
@@ -32,4 +38,64 @@ async function delegateBufferPdaFromDelegatedAccountAndOwnerProgram(delegatedAcc
32
38
  });
33
39
  return delegateBufferPda;
34
40
  }
41
+ async function escrowPdaFromEscrowAuthority(escrowAuthority, index = 255) {
42
+ if (index < 0 || index > 255) {
43
+ throw new Error("Index must be between 0 and 255");
44
+ }
45
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
46
+ const [escrowPda] = await (0, kit_1.getProgramDerivedAddress)({
47
+ programAddress: escrowAuthority,
48
+ seeds: [
49
+ Buffer.from("balance"),
50
+ addressEncoder.encode(escrowAuthority),
51
+ Buffer.from([index]),
52
+ ],
53
+ });
54
+ return escrowPda;
55
+ }
56
+ async function commitStatePdaFromDelegatedAccount(delegatedAccount) {
57
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
58
+ const [commitStatePda] = await (0, kit_1.getProgramDerivedAddress)({
59
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
60
+ seeds: [Buffer.from("state-diff"), addressEncoder.encode(delegatedAccount)],
61
+ });
62
+ return commitStatePda;
63
+ }
64
+ async function commitRecordPdaFromDelegatedAccount(delegatedAccount) {
65
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
66
+ const [commitRecordPda] = await (0, kit_1.getProgramDerivedAddress)({
67
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
68
+ seeds: [
69
+ Buffer.from("commit-state-record"),
70
+ addressEncoder.encode(delegatedAccount),
71
+ ],
72
+ });
73
+ return commitRecordPda;
74
+ }
75
+ async function undelegateBufferPdaFromDelegatedAccount(delegatedAccount) {
76
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
77
+ const [undelegateBufferPda] = await (0, kit_1.getProgramDerivedAddress)({
78
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
79
+ seeds: [
80
+ Buffer.from("undelegate-buffer"),
81
+ addressEncoder.encode(delegatedAccount),
82
+ ],
83
+ });
84
+ return undelegateBufferPda;
85
+ }
86
+ async function feesVaultPda() {
87
+ const [feesVault] = await (0, kit_1.getProgramDerivedAddress)({
88
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
89
+ seeds: [Buffer.from("fees-vault")],
90
+ });
91
+ return feesVault;
92
+ }
93
+ async function validatorFeesVaultPdaFromValidator(validator) {
94
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
95
+ const [validatorFeesVault] = await (0, kit_1.getProgramDerivedAddress)({
96
+ programAddress: constants_1.DELEGATION_PROGRAM_ID,
97
+ seeds: [Buffer.from("v-fees-vault"), addressEncoder.encode(validator)],
98
+ });
99
+ return validatorFeesVault;
100
+ }
35
101
  //# sourceMappingURL=pda.js.map
package/lib/pda.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pda.js","sourceRoot":"","sources":["../src/pda.ts"],"names":[],"mappings":";;AAOA,0FASC;AAED,8FAaC;AAED,oHAUC;AA3CD,qCAIqB;AACrB,2CAAoD;AAE7C,KAAK,UAAU,uCAAuC,CAC3D,gBAAyB;IAEzB,MAAM,cAAc,GAAG,IAAA,uBAAiB,GAAE,CAAC;IAC3C,MAAM,CAAC,mBAAmB,CAAC,GAAG,MAAM,IAAA,8BAAwB,EAAC;QAC3D,cAAc,EAAE,iCAAqB;QACrC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,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BAAmB,CAAC;AAC7B,CAAC;AAEM,KAAK,UAAU,YAAY;IAChC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,IAAA,8BAAwB,EAAC;QACjD,cAAc,EAAE,iCAAqB;QACrC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACnC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAEM,KAAK,UAAU,kCAAkC,CAAC,SAAkB;IACzE,MAAM,cAAc,GAAG,IAAA,uBAAiB,GAAE,CAAC;IAC3C,MAAM,CAAC,kBAAkB,CAAC,GAAG,MAAM,IAAA,8BAAwB,EAAC;QAC1D,cAAc,EAAE,iCAAqB;QACrC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;KACvE,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicblock-labs/ephemeral-rollups-kit",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "author": "MagicBlock Labs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -41,7 +41,6 @@
41
41
  "vitest": "^3.2.4"
42
42
  },
43
43
  "dependencies": {
44
- "@metaplex-foundation/beet": "^0.7.2",
45
44
  "@phala/dcap-qvl-web": "^0.2.7",
46
45
  "@solana-program/system": "^0.9.0",
47
46
  "@solana/kit": "^4.0.0",
@@ -1,25 +0,0 @@
1
- import * as beet from "@metaplex-foundation/beet";
2
- import { AccountMeta, Address, Instruction } from "@solana/kit";
3
- export declare const delegateStruct: beet.FixableBeetArgsStruct<{
4
- instructionDiscriminator: number[];
5
- commit_frequency_ms: beet.bignum;
6
- seeds: number[][];
7
- validator?: beet.COption<Uint8Array>;
8
- }>;
9
- export declare const delegateInstructionDiscriminator: number[];
10
- interface DelegateAccountArgs {
11
- commit_frequency_ms: number;
12
- seeds: Uint8Array[][];
13
- validator?: Address;
14
- }
15
- export declare function createDelegateInstruction(accountsInput: {
16
- payer: Address;
17
- delegatedAccount: Address;
18
- ownerProgram: Address;
19
- delegationRecord?: Address;
20
- delegationMetadata?: Address;
21
- systemProgram?: Address;
22
- validator?: Address;
23
- }, args?: DelegateAccountArgs, programId?: Address<"DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh">): Promise<Instruction<string, readonly (import("@solana/kit").AccountLookupMeta<string, string> | AccountMeta<string>)[]>>;
24
- export {};
25
- //# sourceMappingURL=delegate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/instructions/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;AAS7E,eAAO,MAAM,cAAc;8BACC,MAAM,EAAE;yBACb,IAAI,CAAC,MAAM;WACzB,MAAM,EAAE,EAAE;gBACL,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;EASrC,CAAC;AACF,eAAO,MAAM,gCAAgC,UAA2B,CAAC;AAGzE,UAAU,mBAAmB;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,yBAAyB,CAC7C,aAAa,EAAE;IACb,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,EACD,IAAI,CAAC,EAAE,mBAAmB,EAC1B,SAAS,0DAAwB,4HAyElC"}