diff --git a/web3.js/src/index.ts b/web3.js/src/index.ts index b0676f0f33..2ac89f9635 100644 --- a/web3.js/src/index.ts +++ b/web3.js/src/index.ts @@ -1,25 +1,19 @@ export * from './account'; -export * from './address-lookup-table-program'; export * from './blockhash'; export * from './bpf-loader-deprecated'; export * from './bpf-loader'; -export * from './compute-budget'; export * from './connection'; export * from './epoch-schedule'; -export * from './ed25519-program'; export * from './fee-calculator'; export * from './keypair'; export * from './loader'; export * from './message'; export * from './nonce-account'; +export * from './programs'; export * from './publickey'; -export * from './stake-program'; -export * from './system-program'; -export * from './secp256k1-program'; export * from './transaction'; export * from './validator-info'; export * from './vote-account'; -export * from './vote-program'; export * from './sysvar'; export * from './errors'; export * from './util/borsh-schema'; diff --git a/web3.js/src/loader.ts b/web3.js/src/loader.ts index 6e3781a304..003d6d9d8f 100644 --- a/web3.js/src/loader.ts +++ b/web3.js/src/loader.ts @@ -8,7 +8,7 @@ import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction'; import {sleep} from './util/sleep'; import type {Connection} from './connection'; import type {Signer} from './keypair'; -import {SystemProgram} from './system-program'; +import {SystemProgram} from './programs/system'; import {IInstructionInputData} from './instruction'; // Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the diff --git a/web3.js/src/address-lookup-table-program.ts b/web3.js/src/programs/address-lookup-table.ts similarity index 97% rename from web3.js/src/address-lookup-table-program.ts rename to web3.js/src/programs/address-lookup-table.ts index b245161a5e..dda4dcd158 100644 --- a/web3.js/src/address-lookup-table-program.ts +++ b/web3.js/src/programs/address-lookup-table.ts @@ -1,12 +1,12 @@ import {toBufferLE} from 'bigint-buffer'; import * as BufferLayout from '@solana/buffer-layout'; -import * as Layout from './layout'; -import {PublicKey} from './publickey'; -import * as bigintLayout from './util/bigint'; -import {SystemProgram} from './system-program'; -import {TransactionInstruction} from './transaction'; -import {decodeData, encodeData, IInstructionInputData} from './instruction'; +import * as Layout from '../layout'; +import {PublicKey} from '../publickey'; +import * as bigintLayout from '../util/bigint'; +import {SystemProgram} from './system'; +import {TransactionInstruction} from '../transaction'; +import {decodeData, encodeData, IInstructionInputData} from '../instruction'; export type CreateLookupTableParams = { /** Account used to derive and control the new address lookup table. */ diff --git a/web3.js/src/compute-budget.ts b/web3.js/src/programs/compute-budget.ts similarity index 97% rename from web3.js/src/compute-budget.ts rename to web3.js/src/programs/compute-budget.ts index bd4ab3d632..0059133fb0 100644 --- a/web3.js/src/compute-budget.ts +++ b/web3.js/src/programs/compute-budget.ts @@ -5,10 +5,10 @@ import { decodeData, InstructionType, IInstructionInputData, -} from './instruction'; -import {PublicKey} from './publickey'; -import {TransactionInstruction} from './transaction'; -import {u64} from './util/bigint'; +} from '../instruction'; +import {PublicKey} from '../publickey'; +import {TransactionInstruction} from '../transaction'; +import {u64} from '../util/bigint'; /** * Compute Budget Instruction class diff --git a/web3.js/src/ed25519-program.ts b/web3.js/src/programs/ed25519.ts similarity index 96% rename from web3.js/src/ed25519-program.ts rename to web3.js/src/programs/ed25519.ts index 4e201a8319..6953c06035 100644 --- a/web3.js/src/ed25519-program.ts +++ b/web3.js/src/programs/ed25519.ts @@ -2,10 +2,10 @@ import {Buffer} from 'buffer'; import * as BufferLayout from '@solana/buffer-layout'; import nacl from 'tweetnacl'; -import {Keypair} from './keypair'; -import {PublicKey} from './publickey'; -import {TransactionInstruction} from './transaction'; -import assert from './util/assert'; +import {Keypair} from '../keypair'; +import {PublicKey} from '../publickey'; +import {TransactionInstruction} from '../transaction'; +import assert from '../util/assert'; const PRIVATE_KEY_BYTES = 64; const PUBLIC_KEY_BYTES = 32; diff --git a/web3.js/src/programs/index.ts b/web3.js/src/programs/index.ts new file mode 100644 index 0000000000..f2dc21fcb2 --- /dev/null +++ b/web3.js/src/programs/index.ts @@ -0,0 +1,7 @@ +export * from './address-lookup-table'; +export * from './compute-budget'; +export * from './ed25519'; +export * from './secp256k1'; +export * from './stake'; +export * from './system'; +export * from './vote'; diff --git a/web3.js/src/secp256k1-program.ts b/web3.js/src/programs/secp256k1.ts similarity index 97% rename from web3.js/src/secp256k1-program.ts rename to web3.js/src/programs/secp256k1.ts index 0df5e40b41..f3654e0a08 100644 --- a/web3.js/src/secp256k1-program.ts +++ b/web3.js/src/programs/secp256k1.ts @@ -3,10 +3,10 @@ import * as BufferLayout from '@solana/buffer-layout'; import secp256k1 from 'secp256k1'; import sha3 from 'js-sha3'; -import {PublicKey} from './publickey'; -import {TransactionInstruction} from './transaction'; -import assert from './util/assert'; -import {toBuffer} from './util/to-buffer'; +import {PublicKey} from '../publickey'; +import {TransactionInstruction} from '../transaction'; +import assert from '../util/assert'; +import {toBuffer} from '../util/to-buffer'; const {publicKeyCreate, ecdsaSign} = secp256k1; diff --git a/web3.js/src/stake-program.ts b/web3.js/src/programs/stake.ts similarity index 98% rename from web3.js/src/stake-program.ts rename to web3.js/src/programs/stake.ts index cbfe850d12..315a8bc29d 100644 --- a/web3.js/src/stake-program.ts +++ b/web3.js/src/programs/stake.ts @@ -5,17 +5,17 @@ import { decodeData, InstructionType, IInstructionInputData, -} from './instruction'; -import * as Layout from './layout'; -import {PublicKey} from './publickey'; -import {SystemProgram} from './system-program'; +} from '../instruction'; +import * as Layout from '../layout'; +import {PublicKey} from '../publickey'; +import {SystemProgram} from './system'; import { SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, -} from './sysvar'; -import {Transaction, TransactionInstruction} from './transaction'; -import {toBuffer} from './util/to-buffer'; +} from '../sysvar'; +import {Transaction, TransactionInstruction} from '../transaction'; +import {toBuffer} from '../util/to-buffer'; /** * Address of the stake config account which configures the rate diff --git a/web3.js/src/system-program.ts b/web3.js/src/programs/system.ts similarity index 98% rename from web3.js/src/system-program.ts rename to web3.js/src/programs/system.ts index 89e0b4c82b..0e90573f98 100644 --- a/web3.js/src/system-program.ts +++ b/web3.js/src/programs/system.ts @@ -5,14 +5,14 @@ import { decodeData, InstructionType, IInstructionInputData, -} from './instruction'; -import * as Layout from './layout'; -import {NONCE_ACCOUNT_LENGTH} from './nonce-account'; -import {PublicKey} from './publickey'; -import {SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY} from './sysvar'; -import {Transaction, TransactionInstruction} from './transaction'; -import {toBuffer} from './util/to-buffer'; -import {u64} from './util/bigint'; +} from '../instruction'; +import * as Layout from '../layout'; +import {NONCE_ACCOUNT_LENGTH} from '../nonce-account'; +import {PublicKey} from '../publickey'; +import {SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY} from '../sysvar'; +import {Transaction, TransactionInstruction} from '../transaction'; +import {toBuffer} from '../util/to-buffer'; +import {u64} from '../util/bigint'; /** * Create account system transaction params diff --git a/web3.js/src/vote-program.ts b/web3.js/src/programs/vote.ts similarity index 97% rename from web3.js/src/vote-program.ts rename to web3.js/src/programs/vote.ts index 3e33d0ba68..e6660c966b 100644 --- a/web3.js/src/vote-program.ts +++ b/web3.js/src/programs/vote.ts @@ -5,13 +5,13 @@ import { decodeData, InstructionType, IInstructionInputData, -} from './instruction'; -import * as Layout from './layout'; -import {PublicKey} from './publickey'; -import {SystemProgram} from './system-program'; -import {SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY} from './sysvar'; -import {Transaction, TransactionInstruction} from './transaction'; -import {toBuffer} from './util/to-buffer'; +} from '../instruction'; +import * as Layout from '../layout'; +import {PublicKey} from '../publickey'; +import {SystemProgram} from './system'; +import {SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY} from '../sysvar'; +import {Transaction, TransactionInstruction} from '../transaction'; +import {toBuffer} from '../util/to-buffer'; /** * Vote account info diff --git a/web3.js/test/address-lookup-table-program.test.ts b/web3.js/test/program-tests/address-lookup-table.test.ts similarity index 98% rename from web3.js/test/address-lookup-table-program.test.ts rename to web3.js/test/program-tests/address-lookup-table.test.ts index 3102f34dde..0c9d07c03a 100644 --- a/web3.js/test/address-lookup-table-program.test.ts +++ b/web3.js/test/program-tests/address-lookup-table.test.ts @@ -8,10 +8,10 @@ import { AddressLookupTableInstruction, Connection, sendAndConfirmTransaction, -} from '../src'; -import {sleep} from '../src/util/sleep'; -import {helpers} from './mocks/rpc-http'; -import {url} from './url'; +} from '../../src'; +import {sleep} from '../../src/util/sleep'; +import {helpers} from '../mocks/rpc-http'; +import {url} from '../url'; use(chaiAsPromised); diff --git a/web3.js/test/compute-budget.test.ts b/web3.js/test/program-tests/compute-budget.test.ts similarity index 98% rename from web3.js/test/compute-budget.test.ts rename to web3.js/test/program-tests/compute-budget.test.ts index 0f387e4c22..c3ae529026 100644 --- a/web3.js/test/compute-budget.test.ts +++ b/web3.js/test/program-tests/compute-budget.test.ts @@ -9,9 +9,9 @@ import { ComputeBudgetProgram, ComputeBudgetInstruction, sendAndConfirmTransaction, -} from '../src'; -import {helpers} from './mocks/rpc-http'; -import {url} from './url'; +} from '../../src'; +import {helpers} from '../mocks/rpc-http'; +import {url} from '../url'; use(chaiAsPromised); diff --git a/web3.js/test/ed25519-program.test.ts b/web3.js/test/program-tests/ed25519.test.ts similarity index 96% rename from web3.js/test/ed25519-program.test.ts rename to web3.js/test/program-tests/ed25519.test.ts index a2598f782b..3f4d2c6051 100644 --- a/web3.js/test/ed25519-program.test.ts +++ b/web3.js/test/program-tests/ed25519.test.ts @@ -8,8 +8,8 @@ import { LAMPORTS_PER_SOL, Transaction, Ed25519Program, -} from '../src'; -import {url} from './url'; +} from '../../src'; +import {url} from '../url'; if (process.env.TEST_LIVE) { describe('ed25519', () => { diff --git a/web3.js/test/secp256k1-program.test.ts b/web3.js/test/program-tests/secp256k1.test.ts similarity index 98% rename from web3.js/test/secp256k1-program.test.ts rename to web3.js/test/program-tests/secp256k1.test.ts index 8db59ebc34..b2def5e2dd 100644 --- a/web3.js/test/secp256k1-program.test.ts +++ b/web3.js/test/program-tests/secp256k1.test.ts @@ -9,8 +9,8 @@ import { LAMPORTS_PER_SOL, Transaction, Secp256k1Program, -} from '../src'; -import {url} from './url'; +} from '../../src'; +import {url} from '../url'; const randomPrivateKey = () => { let privateKey; diff --git a/web3.js/test/stake-program.test.ts b/web3.js/test/program-tests/stake.test.ts similarity index 99% rename from web3.js/test/stake-program.test.ts rename to web3.js/test/program-tests/stake.test.ts index 381ac20ff4..15c7625a2b 100644 --- a/web3.js/test/stake-program.test.ts +++ b/web3.js/test/program-tests/stake.test.ts @@ -14,9 +14,9 @@ import { StakeProgram, SystemInstruction, Transaction, -} from '../src'; -import {helpers} from './mocks/rpc-http'; -import {url} from './url'; +} from '../../src'; +import {helpers} from '../mocks/rpc-http'; +import {url} from '../url'; use(chaiAsPromised); diff --git a/web3.js/test/system-program.test.ts b/web3.js/test/program-tests/system.test.ts similarity index 99% rename from web3.js/test/system-program.test.ts rename to web3.js/test/program-tests/system.test.ts index b85344c006..708865286e 100644 --- a/web3.js/test/system-program.test.ts +++ b/web3.js/test/program-tests/system.test.ts @@ -12,11 +12,11 @@ import { TransactionInstruction, sendAndConfirmTransaction, LAMPORTS_PER_SOL, -} from '../src'; -import {NONCE_ACCOUNT_LENGTH} from '../src/nonce-account'; -import {sleep} from '../src/util/sleep'; -import {helpers} from './mocks/rpc-http'; -import {url} from './url'; +} from '../../src'; +import {NONCE_ACCOUNT_LENGTH} from '../../src/nonce-account'; +import {sleep} from '../../src/util/sleep'; +import {helpers} from '../mocks/rpc-http'; +import {url} from '../url'; describe('SystemProgram', () => { it('createAccount', () => { diff --git a/web3.js/test/vote-program.test.ts b/web3.js/test/program-tests/vote.test.ts similarity index 98% rename from web3.js/test/vote-program.test.ts rename to web3.js/test/program-tests/vote.test.ts index aab52b07f0..596e6e401b 100644 --- a/web3.js/test/vote-program.test.ts +++ b/web3.js/test/program-tests/vote.test.ts @@ -11,9 +11,9 @@ import { sendAndConfirmTransaction, SystemInstruction, Connection, -} from '../src'; -import {helpers} from './mocks/rpc-http'; -import {url} from './url'; +} from '../../src'; +import {helpers} from '../mocks/rpc-http'; +import {url} from '../url'; use(chaiAsPromised); diff --git a/web3.js/test/transaction.test.ts b/web3.js/test/transaction.test.ts index bcd648bbc7..273d87ac06 100644 --- a/web3.js/test/transaction.test.ts +++ b/web3.js/test/transaction.test.ts @@ -7,8 +7,7 @@ import {Connection} from '../src/connection'; import {Keypair} from '../src/keypair'; import {PublicKey} from '../src/publickey'; import {Transaction, TransactionInstruction} from '../src/transaction'; -import {StakeProgram} from '../src/stake-program'; -import {SystemProgram} from '../src/system-program'; +import {StakeProgram, SystemProgram} from '../src/programs'; import {Message} from '../src/message'; import invariant from '../src/util/assert'; import {toBuffer} from '../src/util/to-buffer';