diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 8bb19c3ca6..5e9625800a 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -369,5 +369,5 @@ declare module '@solana/web3.js' { // === src/util/testnet.js === declare export function testnetChannelEndpoint(channel?: string): string; - declare export var SOL_LAMPORTS: number; + declare export var LAMPORTS_PER_SOL: number; } diff --git a/web3.js/src/index.js b/web3.js/src/index.js index 6629409a3b..56e7374941 100644 --- a/web3.js/src/index.js +++ b/web3.js/src/index.js @@ -20,4 +20,4 @@ export { export {testnetChannelEndpoint} from './util/testnet'; // There are 2^34 lamports in one SOL -export const SOL_LAMPORTS = 17179869184; +export const LAMPORTS_PER_SOL = 17179869184; diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.js index 8cbfea656e..d4c6f77f56 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.js @@ -4,7 +4,7 @@ import { Connection, SystemProgram, sendAndConfirmTransaction, - SOL_LAMPORTS, + LAMPORTS_PER_SOL, } from '../src'; import {DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND} from '../src/timing'; import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch'; @@ -53,8 +53,8 @@ test('get program accounts', async () => { const account0 = new Account(); const account1 = new Account(); const programId = new Account(); - await connection.requestAirdrop(account0.publicKey, SOL_LAMPORTS); - await connection.requestAirdrop(account1.publicKey, 0.5 * SOL_LAMPORTS); + await connection.requestAirdrop(account0.publicKey, LAMPORTS_PER_SOL); + await connection.requestAirdrop(account1.publicKey, 0.5 * LAMPORTS_PER_SOL); let transaction = SystemProgram.assign( account0.publicKey, @@ -79,11 +79,11 @@ test('get program accounts', async () => { ]).toEqual(expect.arrayContaining([element[0]])); if (element[0] == account0.publicKey) { expect(element[1].lamports).toBe( - SOL_LAMPORTS - feeCalculator.lamportsPerSignature, + LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature, ); } else { expect(element[1].lamports).toBe( - 0.5 * SOL_LAMPORTS - feeCalculator.lamportsPerSignature, + 0.5 * LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature, ); } }); @@ -784,8 +784,8 @@ test('multi-instruction transaction', async () => { const accountTo = new Account(); const connection = new Connection(url, 'recent'); - await connection.requestAirdrop(accountFrom.publicKey, SOL_LAMPORTS); - expect(await connection.getBalance(accountFrom.publicKey)).toBe(SOL_LAMPORTS); + await connection.requestAirdrop(accountFrom.publicKey, LAMPORTS_PER_SOL); + expect(await connection.getBalance(accountFrom.publicKey)).toBe(LAMPORTS_PER_SOL); await connection.requestAirdrop(accountTo.publicKey, 21); expect(await connection.getBalance(accountTo.publicKey)).toBe(21); @@ -818,11 +818,11 @@ test('multi-instruction transaction', async () => { Ok: null, }); - // accountFrom may have less than SOL_LAMPORTS due to transaction fees + // accountFrom may have less than LAMPORTS_PER_SOL due to transaction fees expect(await connection.getBalance(accountFrom.publicKey)).toBeGreaterThan(0); expect( await connection.getBalance(accountFrom.publicKey), - ).toBeLessThanOrEqual(SOL_LAMPORTS); + ).toBeLessThanOrEqual(LAMPORTS_PER_SOL); expect(await connection.getBalance(accountTo.publicKey)).toBe(21); }); @@ -849,7 +849,7 @@ test('account change notification', async () => { 1, ); - await connection.requestAirdrop(owner.publicKey, SOL_LAMPORTS); + await connection.requestAirdrop(owner.publicKey, LAMPORTS_PER_SOL); try { let transaction = SystemProgram.transfer( owner.publicKey, @@ -913,7 +913,7 @@ test('program account change notification', async () => { }, ); - await connection.requestAirdrop(owner.publicKey, SOL_LAMPORTS); + await connection.requestAirdrop(owner.publicKey, LAMPORTS_PER_SOL); try { let transaction = SystemProgram.transfer( owner.publicKey, diff --git a/web3.js/test/transaction-payer.test.js b/web3.js/test/transaction-payer.test.js index d488682a13..f8d707cad7 100644 --- a/web3.js/test/transaction-payer.test.js +++ b/web3.js/test/transaction-payer.test.js @@ -1,5 +1,5 @@ // @flow -import {Account, Connection, SystemProgram, SOL_LAMPORTS} from '../src'; +import {Account, Connection, SystemProgram, LAMPORTS_PER_SOL} from '../src'; import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch'; import {mockGetRecentBlockhash} from './mockrpc/get-recent-blockhash'; import {url} from './url'; @@ -22,7 +22,7 @@ test('transaction-payer', async () => { method: 'requestAirdrop', params: [ accountPayer.publicKey.toBase58(), - SOL_LAMPORTS, + LAMPORTS_PER_SOL, {commitment: 'recent'}, ], }, @@ -32,7 +32,7 @@ test('transaction-payer', async () => { '0WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', }, ]); - await connection.requestAirdrop(accountPayer.publicKey, SOL_LAMPORTS); + await connection.requestAirdrop(accountPayer.publicKey, LAMPORTS_PER_SOL); mockRpc.push([ url, @@ -147,7 +147,7 @@ test('transaction-payer', async () => { // (exact amount less depends on the current cluster fees) const balance = await connection.getBalance(accountPayer.publicKey); expect(balance).toBeGreaterThan(0); - expect(balance).toBeLessThanOrEqual(SOL_LAMPORTS); + expect(balance).toBeLessThanOrEqual(LAMPORTS_PER_SOL); // accountFrom should have exactly 2, since it didn't pay for the transaction mockRpc.push([