diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts index abc70c5d8..7cfff99fb 100644 --- a/web3.js/module.d.ts +++ b/web3.js/module.d.ts @@ -651,6 +651,7 @@ declare module '@solana/web3.js' { static load( connection: Connection, payer: Account, + program: Account, elfBytes: Buffer | Uint8Array | Array, ): Promise; } diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 7ee0b6645..7a8b1ce4b 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -662,6 +662,7 @@ declare module '@solana/web3.js' { static load( connection: Connection, payer: Account, + program: Account, elfBytes: Buffer | Uint8Array | Array, ): Promise; } diff --git a/web3.js/src/bpf-loader.js b/web3.js/src/bpf-loader.js index aeea178ab..e016bd1ac 100644 --- a/web3.js/src/bpf-loader.js +++ b/web3.js/src/bpf-loader.js @@ -30,15 +30,16 @@ export class BpfLoader { * Load a BPF program * * @param connection The connection to use - * @param owner User account to load the program into + * @param payer Account that will pay program loading fees + * @param program Account to load the program into * @param elfBytes The entire ELF containing the BPF program */ static load( connection: Connection, payer: Account, + program: Account, elf: Buffer | Uint8Array | Array, ): Promise { - const program = new Account(); return Loader.load(connection, payer, program, BpfLoader.programId, elf); } } diff --git a/web3.js/test/bpf-loader.test.js b/web3.js/test/bpf-loader.test.js index 795a88e1f..84087f7ab 100644 --- a/web3.js/test/bpf-loader.test.js +++ b/web3.js/test/bpf-loader.test.js @@ -7,6 +7,7 @@ import { BpfLoader, Transaction, sendAndConfirmTransaction, + Account, } from '../src'; import {mockRpcEnabled} from './__mocks__/node-fetch'; import {url} from './url'; @@ -37,7 +38,8 @@ test('load BPF C program', async () => { ); const from = await newAccountWithLamports(connection, fees + balanceNeeded); - const programId = await BpfLoader.load(connection, from, data); + const program = new Account(); + const programId = await BpfLoader.load(connection, from, program, data); const transaction = new Transaction().add({ keys: [{pubkey: from.publicKey, isSigner: true, isWritable: true}], programId, @@ -65,7 +67,8 @@ test('load BPF Rust program', async () => { ); const from = await newAccountWithLamports(connection, fees + balanceNeeded); - const programId = await BpfLoader.load(connection, from, data); + const program = new Account(); + const programId = await BpfLoader.load(connection, from, program, data); const transaction = new Transaction().add({ keys: [{pubkey: from.publicKey, isSigner: true, isWritable: true}], programId,