accounts.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getDelegationAccounts = exports.DELEGATION_PROGRAM_ID = void 0;
  4. var web3_js_1 = require("@solana/web3.js");
  5. var SEED_BUFFER_PDA = "buffer";
  6. var SEED_DELEGATION_PDA = "delegation";
  7. var DELEGATED_ACCOUNT_SEEDS = "account-seeds";
  8. var SEED_COMMIT_STATE_RECORD_PDA = "commit-state-record";
  9. var SEED_STATE_DIFF_PDA = "state-diff";
  10. exports.DELEGATION_PROGRAM_ID = "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh";
  11. function getDelegationAccounts(accountToDelegate, ownerProgram, ownedBuffer) {
  12. if (ownedBuffer === void 0) {
  13. ownedBuffer = true;
  14. }
  15. var pdaBytes = accountToDelegate.toBytes();
  16. var delegationPda = web3_js_1.PublicKey.findProgramAddressSync(
  17. [Buffer.from(SEED_DELEGATION_PDA), pdaBytes],
  18. new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
  19. )[0];
  20. var delegatedAccountSeedsPda = web3_js_1.PublicKey.findProgramAddressSync(
  21. [Buffer.from(DELEGATED_ACCOUNT_SEEDS), pdaBytes],
  22. new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
  23. )[0];
  24. var bufferPda = web3_js_1.PublicKey.findProgramAddressSync(
  25. [Buffer.from(SEED_BUFFER_PDA), pdaBytes],
  26. ownedBuffer
  27. ? new web3_js_1.PublicKey(ownerProgram)
  28. : new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
  29. )[0];
  30. var commitStateRecordPda = web3_js_1.PublicKey.findProgramAddressSync(
  31. [Buffer.from(SEED_COMMIT_STATE_RECORD_PDA), pdaBytes],
  32. new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
  33. )[0];
  34. var commitStatePda = web3_js_1.PublicKey.findProgramAddressSync(
  35. [Buffer.from(SEED_STATE_DIFF_PDA), pdaBytes],
  36. new web3_js_1.PublicKey(exports.DELEGATION_PROGRAM_ID)
  37. )[0];
  38. return {
  39. delegationPda: delegationPda,
  40. delegatedAccountSeedsPda: delegatedAccountSeedsPda,
  41. bufferPda: bufferPda,
  42. commitStateRecordPda: commitStateRecordPda,
  43. commitStatePda: commitStatePda,
  44. };
  45. }
  46. exports.getDelegationAccounts = getDelegationAccounts;
  47. //# sourceMappingURL=accounts.js.map