diff --git a/js/src/instructions.ts b/js/src/instructions.ts index 4c3f8a6..19440ba 100644 --- a/js/src/instructions.ts +++ b/js/src/instructions.ts @@ -58,15 +58,10 @@ export function createCreateInstruction( vestingTokenAccountKey: PublicKey, sourceTokenAccountOwnerKey: PublicKey, sourceTokenAccountKey: PublicKey, - mintAddress: PublicKey, schedule: CreateSchedule, seeds: Array, ): TransactionInstruction { - let buffers = [ - Buffer.from(Int8Array.from([1]).buffer), - Buffer.concat(seeds), - mintAddress.toBuffer(), - ]; + let buffers = [Buffer.from(Int8Array.from([1]).buffer), Buffer.concat(seeds)]; buffers.push(schedule.toBuffer()); diff --git a/js/src/main.ts b/js/src/main.ts index c3f03b5..78e2164 100644 --- a/js/src/main.ts +++ b/js/src/main.ts @@ -24,7 +24,11 @@ import bs58 from 'bs58'; * TODO: replace with mainnet ID */ export const TOKEN_VESTING_PROGRAM_ID = new PublicKey( - '3F15CLnQjHqMCHLn2g7vuDULiRuJDiEMSZQXMoVVUGtA', + 'HGhyAuNiYRa6oN55eGGP1MYGVve7epwT8WX6qbWxgYxM', +); + +export const TOKEN_MINT = new PublicKey( + 'EWMA3o2kHLpsVYvmjtvYRywHrXD84sLxFb42seUShxAD', ); /** @@ -46,13 +50,12 @@ export async function create( seedWord: Buffer | Uint8Array, payer: PublicKey, possibleSourceTokenPubkey: PublicKey | null, - mintAddress: PublicKey, schedule: CreateSchedule, ): Promise> { // If no source token account was given, use the associated source account if (possibleSourceTokenPubkey == null) { possibleSourceTokenPubkey = await getAssociatedTokenAddress( - mintAddress, + TOKEN_MINT, payer, true, ); @@ -66,7 +69,7 @@ export async function create( ); const vestingTokenAccountKey = await getAssociatedTokenAddress( - mintAddress, + TOKEN_MINT, vestingAccountKey, true, ); @@ -97,7 +100,7 @@ export async function create( payer, vestingTokenAccountKey, vestingAccountKey, - mintAddress, + TOKEN_MINT, ), createCreateInstruction( programId, @@ -107,7 +110,6 @@ export async function create( vestingTokenAccountKey, payer, possibleSourceTokenPubkey, - mintAddress, schedule, [seedWord], ), @@ -127,7 +129,6 @@ export async function unlock( connection: Connection, programId: PublicKey, seedWord: Buffer | Uint8Array, - mintAddress: PublicKey, ): Promise> { seedWord = seedWord.slice(0, 31); const [vestingAccountKey, bump] = await PublicKey.findProgramAddress( @@ -137,7 +138,7 @@ export async function unlock( seedWord = Buffer.from(seedWord.toString('hex') + bump.toString(16), 'hex'); const vestingTokenAccountKey = await getAssociatedTokenAddress( - mintAddress, + TOKEN_MINT, vestingAccountKey, true, ); @@ -171,7 +172,6 @@ export async function initializeUnlock( connection: Connection, programId: PublicKey, seedWord: Buffer | Uint8Array, - mintAddress: PublicKey, ): Promise> { seedWord = seedWord.slice(0, 31); const [vestingAccountKey, bump] = await PublicKey.findProgramAddress( @@ -181,7 +181,7 @@ export async function initializeUnlock( seedWord = Buffer.from(seedWord.toString('hex') + bump.toString(16), 'hex'); const vestingTokenAccountKey = await getAssociatedTokenAddress( - mintAddress, + TOKEN_MINT, vestingAccountKey, true, ); diff --git a/js/src/state.ts b/js/src/state.ts index b9b5bca..35f589c 100644 --- a/js/src/state.ts +++ b/js/src/state.ts @@ -45,26 +45,18 @@ export class Schedule { export class VestingScheduleHeader { destinationAddress!: PublicKey; - mintAddress!: PublicKey; isInitialized!: boolean; - constructor( - destinationAddress: PublicKey, - mintAddress: PublicKey, - isInitialized: boolean, - ) { + constructor(destinationAddress: PublicKey, isInitialized: boolean) { this.destinationAddress = destinationAddress; - this.mintAddress = mintAddress; this.isInitialized = isInitialized; } static fromBuffer(buf: Buffer): VestingScheduleHeader { const destinationAddress = new PublicKey(buf.slice(0, 32)); - const mintAddress = new PublicKey(buf.slice(32, 64)); - const isInitialized = buf[64] == 1; + const isInitialized = buf[32] == 1; const header: VestingScheduleHeader = { destinationAddress, - mintAddress, isInitialized, }; return header; @@ -73,29 +65,19 @@ export class VestingScheduleHeader { export class ContractInfo { destinationAddress!: PublicKey; - mintAddress!: PublicKey; schedule!: Schedule; - constructor( - destinationAddress: PublicKey, - mintAddress: PublicKey, - schedule: Schedule, - ) { + constructor(destinationAddress: PublicKey, schedule: Schedule) { this.destinationAddress = destinationAddress; - this.mintAddress = mintAddress; this.schedule = schedule; } static fromBuffer(buf: Buffer): ContractInfo | undefined { - const header = VestingScheduleHeader.fromBuffer(buf.slice(0, 65)); + const header = VestingScheduleHeader.fromBuffer(buf.slice(0, 33)); if (!header.isInitialized) { return undefined; } - const schedule = Schedule.fromBuffer(buf.slice(65, 81)); - return new ContractInfo( - header.destinationAddress, - header.mintAddress, - schedule, - ); + const schedule = Schedule.fromBuffer(buf.slice(33, 49)); + return new ContractInfo(header.destinationAddress, schedule); } }