Skip to content

Commit

Permalink
[WIP] Create subpackages for internal-ish code
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Mar 20, 2024
1 parent 7ed7506 commit 2f890a3
Show file tree
Hide file tree
Showing 567 changed files with 1,289 additions and 1,307 deletions.
2 changes: 1 addition & 1 deletion packages/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"scripts": {
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node ../../node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
"prepublishOnly": "pnpm pkg delete devDependencies",
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag ${PUBLISH_TAG:-preview} --access public --no-git-checks",
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
SolanaRpcResponse,
} from '@solana/rpc-types';

import type { GetAccountInfoApi, GetMultipleAccountsApi, JsonParsedDataResponse } from '../rpc-api';
import type { GetAccountInfoApi, GetMultipleAccountsApi, JsonParsedDataResponse } from '../rpc-api.js';

export type Base64RpcAccount = AccountInfoBase & AccountInfoWithBase64EncodedData;
export type Base58RpcAccount = AccountInfoBase & (AccountInfoWithBase58Bytes | AccountInfoWithBase58EncodedData);
Expand Down
8 changes: 4 additions & 4 deletions packages/accounts/src/__tests__/decode-account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
SolanaError,
} from '@solana/errors';

import { Account, EncodedAccount } from '../account';
import { assertAccountDecoded, assertAccountsDecoded, decodeAccount } from '../decode-account';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account';
import { getMockDecoder } from './__setup__';
import { Account, EncodedAccount } from '../account.js';
import { assertAccountDecoded, assertAccountsDecoded, decodeAccount } from '../decode-account.js';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account.js';
import { getMockDecoder } from './__setup__.js';

describe('decodeAccount', () => {
it('decodes the account data of an existing encoded account', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/accounts/src/__tests__/fetch-account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
fetchEncodedAccounts,
fetchJsonParsedAccount,
fetchJsonParsedAccounts,
} from '../fetch-account';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account';
import { Base64RpcAccount, getMockRpc, JsonParsedRpcAccount } from './__setup__';
} from '../fetch-account.js';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account.js';
import { Base64RpcAccount, getMockRpc, JsonParsedRpcAccount } from './__setup__.js';

describe('fetchEncodedAccount', () => {
it('fetches and parses an existing base64-encoded account from an RPC', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts/src/__tests__/maybe-account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
SolanaError,
} from '@solana/errors';

import { assertAccountExists, assertAccountsExist, MaybeEncodedAccount } from '../maybe-account';
import { assertAccountExists, assertAccountsExist, MaybeEncodedAccount } from '../maybe-account.js';

describe('assertAccountExists', () => {
it('fails if the provided MaybeAccount does not exist', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/accounts/src/__tests__/parse-account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import '@solana/test-matchers/toBeFrozenObject';
import type { Address } from '@solana/addresses';
import { lamports } from '@solana/rpc-types';

import { Account, EncodedAccount } from '../account';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account';
import { parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount } from '../parse-account';
import { Base58RpcAccount, Base64RpcAccount, JsonParsedRpcAccount } from './__setup__';
import { Account, EncodedAccount } from '../account.js';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account.js';
import { parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount } from '../parse-account.js';
import { Base58RpcAccount, Base64RpcAccount, JsonParsedRpcAccount } from './__setup__.js';

describe('parseBase64RpcAccount', () => {
it('parses an encoded account with base64 data', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Address } from '@solana/addresses';
import { Decoder } from '@solana/codecs-core';

import { Account, EncodedAccount } from '../account';
import { assertAccountDecoded, assertAccountsDecoded, decodeAccount } from '../decode-account';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account';
import { Account, EncodedAccount } from '../account.js';
import { assertAccountDecoded, assertAccountsDecoded, decodeAccount } from '../decode-account.js';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account.js';

type MockData = { foo: 42 };
type MockDataDecoder = Decoder<MockData>;
Expand Down
6 changes: 3 additions & 3 deletions packages/accounts/src/__typetests__/fetch-account-typetest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
fetchEncodedAccounts,
fetchJsonParsedAccount,
fetchJsonParsedAccounts,
} from '../fetch-account';
import type { MaybeAccount, MaybeEncodedAccount } from '../maybe-account';
import type { GetAccountInfoApi, GetMultipleAccountsApi } from '../rpc-api';
} from '../fetch-account.js';
import type { MaybeAccount, MaybeEncodedAccount } from '../maybe-account.js';
import type { GetAccountInfoApi, GetMultipleAccountsApi } from '../rpc-api.js';

const rpc = {} as Rpc<GetAccountInfoApi & GetMultipleAccountsApi>;
const address = '1111' as Address<'1111'>;
Expand Down
4 changes: 2 additions & 2 deletions packages/accounts/src/__typetests__/maybe-account-typetest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from '@solana/addresses';

import { Account } from '../account';
import { assertAccountExists, assertAccountsExist, MaybeAccount } from '../maybe-account';
import { Account } from '../account.js';
import { assertAccountExists, assertAccountsExist, MaybeAccount } from '../maybe-account.js';

type MockData = { foo: 42 };

Expand Down
6 changes: 3 additions & 3 deletions packages/accounts/src/__typetests__/parse-account-typetest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Address } from '@solana/addresses';

import { Base58RpcAccount, Base64RpcAccount, JsonParsedRpcAccount } from '../__tests__/__setup__';
import { Account, EncodedAccount } from '../account';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account';
import { parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount } from '../parse-account';
import { Account, EncodedAccount } from '../account.js';
import { MaybeAccount, MaybeEncodedAccount } from '../maybe-account.js';
import { parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount } from '../parse-account.js';

const address = '1111' as Address<'1111'>;
type MyData = { mint: Address; token: Address };
Expand Down
4 changes: 2 additions & 2 deletions packages/accounts/src/decode-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
SolanaError,
} from '@solana/errors';

import type { Account, EncodedAccount } from './account';
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account';
import type { Account, EncodedAccount } from './account.js';
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account.js';

/** Decodes the data of a given account using the provided decoder. */
export function decodeAccount<TData extends object, TAddress extends string = string>(
Expand Down
6 changes: 3 additions & 3 deletions packages/accounts/src/fetch-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Address } from '@solana/addresses';
import type { Rpc } from '@solana/rpc-spec';
import type { Commitment, Slot } from '@solana/rpc-types';

import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account';
import { parseBase64RpcAccount, parseJsonRpcAccount } from './parse-account';
import type { GetAccountInfoApi, GetMultipleAccountsApi } from './rpc-api';
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account.js';
import { parseBase64RpcAccount, parseJsonRpcAccount } from './parse-account.js';
import type { GetAccountInfoApi, GetMultipleAccountsApi } from './rpc-api/index.js';

/** Optional configuration for fetching a singular account. */
export type FetchAccountConfig = {
Expand Down
10 changes: 5 additions & 5 deletions packages/accounts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './account';
export * from './decode-account';
export * from './fetch-account';
export * from './maybe-account';
export * from './parse-account';
export * from './account.js';
export * from './decode-account.js';
export * from './fetch-account.js';
export * from './maybe-account.js';
export * from './parse-account.js';
2 changes: 1 addition & 1 deletion packages/accounts/src/maybe-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SolanaError,
} from '@solana/errors';

import { Account } from './account';
import { Account } from './account.js';

/** Defines a Solana account that may or may not exist after having tried to fetch it. */
export type MaybeAccount<TData extends Uint8Array | object, TAddress extends string = string> =
Expand Down
6 changes: 3 additions & 3 deletions packages/accounts/src/parse-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import type {
AccountInfoWithBase64EncodedData,
} from '@solana/rpc-types';

import type { Account, BaseAccount, EncodedAccount } from './account';
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account';
import type { JsonParsedDataResponse } from './rpc-api';
import type { Account, BaseAccount, EncodedAccount } from './account.js';
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account.js';
import type { JsonParsedDataResponse } from './rpc-api/index.js';

type Base64EncodedRpcAccount = AccountInfoBase & AccountInfoWithBase64EncodedData;

Expand Down
6 changes: 3 additions & 3 deletions packages/accounts/src/rpc-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './common';
export * from './getAccountInfo';
export * from './getMultipleAccounts';
export * from './common.js';
export * from './getAccountInfo.js';
export * from './getMultipleAccounts.js';
2 changes: 1 addition & 1 deletion packages/addresses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"scripts": {
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node ../../node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
"prepublishOnly": "pnpm pkg delete devDependencies",
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag ${PUBLISH_TAG:-preview} --access public --no-git-checks",
Expand Down
2 changes: 1 addition & 1 deletion packages/addresses/src/__tests__/address-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SolanaError,
} from '@solana/errors';

import { Address, getAddressCodec, getAddressComparator } from '../address';
import { Address, getAddressCodec, getAddressComparator } from '../address.js';

jest.mock('@solana/codecs-strings', () => ({
...jest.requireActual('@solana/codecs-strings'),
Expand Down
2 changes: 1 addition & 1 deletion packages/addresses/src/__tests__/coercions-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SolanaError,
} from '@solana/errors';

import { Address, address } from '../address';
import { Address, address } from '../address.js';

describe('coercions', () => {
describe('address', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/addresses/src/__tests__/curve-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compressedPointBytesAreOnCurve } from '../curve';
import { compressedPointBytesAreOnCurve } from '../curve.js';

const OFF_CURVE_KEY_BYTES = [
new Uint8Array([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
SolanaError,
} from '@solana/errors';

import { Address } from '../address';
import { createAddressWithSeed, getProgramDerivedAddress } from '../program-derived-address';
import { Address } from '../address.js';
import { createAddressWithSeed, getProgramDerivedAddress } from '../program-derived-address.js';

describe('getProgramDerivedAddress()', () => {
it('fatals when supplied more than 16 seeds', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/addresses/src/__tests__/public-key-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getAddressFromPublicKey } from '../public-key';
import { getAddressFromPublicKey } from '../public-key.js';

// Corresponds to address `DcESq8KFcdTdpjWtr2DoGcvu5McM3VJoBetgM1X1vVct`
const MOCK_PUBLIC_KEY_BYTES = new Uint8Array([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Address, address } from '../address';
import { Address, address } from '../address.js';

address('555555555555555555555555') satisfies Address<'555555555555555555555555'>;
2 changes: 1 addition & 1 deletion packages/addresses/src/curve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pointIsOnCurve } from './vendor/noble/ed25519';
import { pointIsOnCurve } from './vendor/noble/ed25519.js';

function byteToHex(byte: number): string {
const hexString = byte.toString(16);
Expand Down
6 changes: 3 additions & 3 deletions packages/addresses/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './address';
export * from './program-derived-address';
export * from './public-key';
export * from './address.js';
export * from './program-derived-address.js';
export * from './public-key.js';
4 changes: 2 additions & 2 deletions packages/addresses/src/program-derived-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
SolanaError,
} from '@solana/errors';

import { Address, assertIsAddress, getAddressCodec, isAddress } from './address';
import { compressedPointBytesAreOnCurve } from './curve';
import { Address, assertIsAddress, getAddressCodec, isAddress } from './address.js';
import { compressedPointBytesAreOnCurve } from './curve.js';

/**
* An address derived from a program address and a set of seeds.
Expand Down
2 changes: 1 addition & 1 deletion packages/addresses/src/public-key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertKeyExporterIsAvailable } from '@solana/assertions';
import { SOLANA_ERROR__ADDRESSES__INVALID_ED25519_PUBLIC_KEY, SolanaError } from '@solana/errors';

import { Address, getAddressDecoder } from './address';
import { Address, getAddressDecoder } from './address.js';

export async function getAddressFromPublicKey(publicKey: CryptoKey): Promise<Address> {
await assertKeyExporterIsAvailable();
Expand Down
2 changes: 1 addition & 1 deletion packages/assertions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"scripts": {
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node ../../node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
"prepublishOnly": "pnpm pkg delete devDependencies",
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag ${PUBLISH_TAG:-preview} --access public --no-git-checks",
Expand Down
2 changes: 1 addition & 1 deletion packages/assertions/src/__tests__/subtle-crypto-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
assertKeyExporterIsAvailable,
assertSigningCapabilityIsAvailable,
assertVerificationCapabilityIsAvailable,
} from '../subtle-crypto';
} from '../subtle-crypto.js';

describe('assertDigestCapabilityIsAvailable()', () => {
it('resolves to `undefined` without throwing', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/assertions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './subtle-crypto';
export * from './subtle-crypto.js';
50 changes: 0 additions & 50 deletions packages/build-scripts/add-js-extension-to-types.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion packages/build-scripts/getBaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getBaseConfig(platform: Platform, formats: Format[], _options: O
__REACTNATIVE__: `${platform === 'native'}`,
__VERSION__: `"${env.npm_package_version}"`,
},
entry: [`./src/index.ts`],
entry: ['./src/index.ts', './src/__internal.ts'],
esbuildOptions(options, context) {
const { format } = context;
options.minify = format === 'iife' && !isDebugBuild;
Expand Down Expand Up @@ -70,6 +70,7 @@ export function getBaseConfig(platform: Platform, formats: Format[], _options: O
platform: platform === 'node' ? 'node' : 'browser',
pure: ['process'],
sourcemap: format !== 'iife' || isDebugBuild,
splitting: false,
treeshake: true,
},
),
Expand Down
1 change: 0 additions & 1 deletion packages/build-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.0.0",
"private": true,
"files": [
"add-js-extension-to-types.mjs",
"env-shim.ts",
"tsup.config.library.ts",
"tsup.config.package.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/build-scripts/tsup.config.browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'tsup';

import { getBaseConfig } from './getBaseConfig';
import { getBaseConfig } from './getBaseConfig.js';

export default defineConfig(options => [...getBaseConfig('browser', ['cjs', 'esm'], options)]);
2 changes: 1 addition & 1 deletion packages/build-scripts/tsup.config.library.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';

import { getBaseConfig } from './getBaseConfig';
import { getBaseConfig } from './getBaseConfig.js';
import packageConfigOrConfigsOrPromiseGetterForSame from './tsup.config.package';

export default defineConfig(async options => {
Expand Down
2 changes: 1 addition & 1 deletion packages/build-scripts/tsup.config.package.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';

import { getBaseConfig } from './getBaseConfig';
import { getBaseConfig } from './getBaseConfig.js';

export default defineConfig(options => [
...getBaseConfig('node', ['cjs', 'esm'], options),
Expand Down
2 changes: 1 addition & 1 deletion packages/codecs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"scripts": {
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node ../../node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
"prepublishOnly": "pnpm pkg delete devDependencies",
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag ${PUBLISH_TAG:-preview} --access public --no-git-checks",
Expand Down

0 comments on commit 2f890a3

Please sign in to comment.