import { Connection, Keypair, PublicKey } from '@solana/web3.js'; import { BN, Program } from '@staratlas/anchor'; import { AsyncSigner, buildSendAndCheck } from '@staratlas/data-source'; import { PermissionType, PlayerProfile, PlayerProfileIDL, ProfilePermissions, } from '@staratlas/player-profile'; import { readFileSync } from 'node:fs'; import path from 'path'; export const TREE_MAX_DEPTH = 5; export const TREE_CANOPY_DEPTH = 5; export const TREE_MAX_BUFFER_SIZE = 8; export type CreateProfileKeysInput = { key: PublicKey | AsyncSigner; expireTime: BN | null; permissions: PermissionType; scope: PublicKey; }[]; export const createProfile = async ( program: Program, profileId: AsyncSigner, funder: AsyncSigner, keys: CreateProfileKeysInput, connection: Connection, authAuthority?: AsyncSigner, walletSigner?: AsyncSigner, keyThreshold = 1, ) => { if (authAuthority) { keys.unshift({ key: authAuthority, expireTime: null, permissions: ProfilePermissions.all(), scope: program.programId, }); } const createix = PlayerProfile.createProfile( program, profileId, keys, keyThreshold, ); await buildSendAndCheck([createix], walletSigner || funder, connection); }; export const TREE_OWNER = Keypair.fromSecretKey( Buffer.from( JSON.parse( readFileSync(path.resolve(__dirname, './tree_owner-keypair.json'), { encoding: 'utf-8', }), ), ), );