diff --git a/web3.js/src/bpf-loader.js b/web3.js/src/bpf-loader.js index db2a69d90a..be890cc7ac 100644 --- a/web3.js/src/bpf-loader.js +++ b/web3.js/src/bpf-loader.js @@ -37,7 +37,7 @@ export class BpfLoader { const transaction = SystemProgram.createAccount( owner.publicKey, programAccount.publicKey, - 1, + 1 + Math.ceil(elf.length / Loader.chunkSize) + 1, elf.length, BpfLoader.programId, ); diff --git a/web3.js/src/loader.js b/web3.js/src/loader.js index 06019cde17..b2167434f7 100644 --- a/web3.js/src/loader.js +++ b/web3.js/src/loader.js @@ -23,6 +23,14 @@ export class Loader { */ programId: PublicKey; + + /** + * Amount of program data placed in each load Transaction + */ + static get chunkSize(): number { + return 256; + } + /** * @param connection The connection to use * @param programId Public key that identifies the loader @@ -50,7 +58,7 @@ export class Loader { ), ]); - const chunkSize = 256; + const chunkSize = Loader.chunkSize; let offset = 0; let array = data; let transactions = []; diff --git a/web3.js/src/native-loader.js b/web3.js/src/native-loader.js index e44d042307..ac51e00a3f 100644 --- a/web3.js/src/native-loader.js +++ b/web3.js/src/native-loader.js @@ -40,7 +40,7 @@ export class NativeLoader { const transaction = SystemProgram.createAccount( owner.publicKey, programAccount.publicKey, - 1, + 1 + 1 + 1, bytes.length + 1, NativeLoader.programId, ); diff --git a/web3.js/src/token-program.js b/web3.js/src/token-program.js index 3a47a2ecb6..7a4907befd 100644 --- a/web3.js/src/token-program.js +++ b/web3.js/src/token-program.js @@ -240,6 +240,7 @@ export class Token { programId, userdata, }); + transaction.fee = 0; // TODO: Batch with the `SystemProgram.createAccount` and remove this line await sendAndConfirmTransaction(connection, transaction, tokenAccount); return [token, initialAccountPublicKey]; @@ -294,7 +295,7 @@ export class Token { programId: this.programId, userdata, }); - + transaction.fee = 0; // TODO: Batch with the `SystemProgram.createAccount` and remove this line await sendAndConfirmTransaction(this.connection, transaction, tokenAccount); return tokenAccount.publicKey; diff --git a/web3.js/src/transaction.js b/web3.js/src/transaction.js index 39f4ea55aa..00916f940b 100644 --- a/web3.js/src/transaction.js +++ b/web3.js/src/transaction.js @@ -108,7 +108,7 @@ export class Transaction { /** * Fee for this transaction */ - fee: number = 0; + fee: number = 1; /** * Construct an empty Transaction diff --git a/web3.js/test/bpf-loader.test.js b/web3.js/test/bpf-loader.test.js index b815dea031..68a25ab04e 100644 --- a/web3.js/test/bpf-loader.test.js +++ b/web3.js/test/bpf-loader.test.js @@ -24,7 +24,7 @@ test('load BPF program', async () => { } const connection = new Connection(url); - const from = await newAccountWithTokens(connection); + const from = await newAccountWithTokens(connection, 1024); const data = await fs.readFile('test/fixtures/noop/noop.o'); const programId = await BpfLoader.load(connection, from, data); const transaction = new Transaction().add({ diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.js index 14e4560fc5..bd4499f475 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.js @@ -353,6 +353,7 @@ test('transaction', async () => { accountTo.publicKey, 10, ); + transaction.fee = 0; const signature = await connection.sendTransaction(transaction, accountFrom); mockRpc.push([ @@ -447,7 +448,7 @@ test('multi-instruction transaction', async () => { accountTo.publicKey, 10, ).add(SystemProgram.move(accountTo.publicKey, accountFrom.publicKey, 10)); - + transaction.fee = 0; const signature = await connection.sendTransaction( transaction, accountFrom, @@ -496,6 +497,7 @@ test('account change notification', async () => { 3, BpfLoader.programId, ); + transaction.fee = 0; await sendAndConfirmTransaction(connection, transaction, owner); const loader = new Loader(connection, BpfLoader.programId); diff --git a/web3.js/test/native-loader.test.js b/web3.js/test/native-loader.test.js index 0eeb23c086..95ce48902e 100644 --- a/web3.js/test/native-loader.test.js +++ b/web3.js/test/native-loader.test.js @@ -22,7 +22,7 @@ test('load native program', async () => { } const connection = new Connection(url); - const from = await newAccountWithTokens(connection); + const from = await newAccountWithTokens(connection, 1024); const programId = await NativeLoader.load(connection, from, 'noop'); const transaction = new Transaction().add({ keys: [from.publicKey], diff --git a/web3.js/test/token-program.test.js b/web3.js/test/token-program.test.js index 2713babe02..bdd9149ba5 100644 --- a/web3.js/test/token-program.test.js +++ b/web3.js/test/token-program.test.js @@ -50,7 +50,7 @@ test('create new token', async () => { const connection = new Connection(url); connection._disableLastIdCaching = mockRpcEnabled; - initialOwner = await newAccountWithTokens(connection); + initialOwner = await newAccountWithTokens(connection, 1024); { // mock SystemProgram.createAccount transaction for Token.createNewToken()