Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,729 changes: 691 additions & 2,038 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@
},
"homepage": "https://github.com/solana-program/system#readme",
"peerDependencies": {
"@solana/kit": "^6.1.0"
"@solana/kit": "^6.4.0"
},
"devDependencies": {
"@solana/eslint-config-solana": "^6.0.0",
"@solana/kit-client-rpc": "^0.6.0",
"@solana/kit": "^6.1.0",
"@solana/kit-plugin-rpc": "^0.10.0",
"@solana/kit-plugin-signer": "^0.10.0",
"@solana/kit": "^6.4.0",
Comment on lines -47 to +53
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping Kit and Kit plugins

"@types/node": "^24",
"eslint": "^9.39.2",
"prettier": "^3.7.4",
Expand Down
848 changes: 412 additions & 436 deletions clients/js/pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clients/js/src/generated/errors/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type SystemError =
| typeof SYSTEM_ERROR__RESULT_WITH_NEGATIVE_LAMPORTS;

let systemErrorMessages: Record<SystemError, string> | undefined;
if (process.env.NODE_ENV !== 'production') {
if (process.env['NODE_ENV'] !== 'production') {
systemErrorMessages = {
[SYSTEM_ERROR__ACCOUNT_ALREADY_IN_USE]: `an account with the same address already exists`,
[SYSTEM_ERROR__ADDRESS_WITH_SEED_MISMATCH]: `provided address does not match addressed derived from seed`,
Expand All @@ -60,7 +60,7 @@ if (process.env.NODE_ENV !== 'production') {
}

export function getSystemErrorMessage(code: SystemError): string {
if (process.env.NODE_ENV !== 'production') {
if (process.env['NODE_ENV'] !== 'production') {
return (systemErrorMessages as Record<SystemError, string>)[code];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR = 4;

export function getAdvanceNonceAccountDiscriminatorBytes() {
export function getAdvanceNonceAccountDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR);
}

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/allocate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const ALLOCATE_DISCRIMINATOR = 8;

export function getAllocateDiscriminatorBytes() {
export function getAllocateDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(ALLOCATE_DISCRIMINATOR);
}

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/allocateWithSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const ALLOCATE_WITH_SEED_DISCRIMINATOR = 9;

export function getAllocateWithSeedDiscriminatorBytes() {
export function getAllocateWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(ALLOCATE_WITH_SEED_DISCRIMINATOR);
}

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const ASSIGN_DISCRIMINATOR = 1;

export function getAssignDiscriminatorBytes() {
export function getAssignDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(ASSIGN_DISCRIMINATOR);
}

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/assignWithSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const ASSIGN_WITH_SEED_DISCRIMINATOR = 10;

export function getAssignWithSeedDiscriminatorBytes() {
export function getAssignWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(ASSIGN_WITH_SEED_DISCRIMINATOR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR = 7;

export function getAuthorizeNonceAccountDiscriminatorBytes() {
export function getAuthorizeNonceAccountDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR);
}

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/createAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const CREATE_ACCOUNT_DISCRIMINATOR = 0;

export function getCreateAccountDiscriminatorBytes() {
export function getCreateAccountDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(CREATE_ACCOUNT_DISCRIMINATOR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR = 3;

export function getCreateAccountWithSeedDiscriminatorBytes() {
export function getCreateAccountWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR = 6;

export function getInitializeNonceAccountDiscriminatorBytes() {
export function getInitializeNonceAccountDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR);
}

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/transferSol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const TRANSFER_SOL_DISCRIMINATOR = 2;

export function getTransferSolDiscriminatorBytes() {
export function getTransferSolDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(TRANSFER_SOL_DISCRIMINATOR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const TRANSFER_SOL_WITH_SEED_DISCRIMINATOR = 11;

export function getTransferSolWithSeedDiscriminatorBytes() {
export function getTransferSolWithSeedDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(TRANSFER_SOL_WITH_SEED_DISCRIMINATOR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR = 12;

export function getUpgradeNonceAccountDiscriminatorBytes() {
export function getUpgradeNonceAccountDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

export const WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR = 5;

export function getWithdrawNonceAccountDiscriminatorBytes() {
export function getWithdrawNonceAccountDiscriminatorBytes(): ReadonlyUint8Array {
return getU32Encoder().encode(WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR);
}

Expand Down
8 changes: 4 additions & 4 deletions clients/js/src/generated/programs/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
assertIsInstructionWithAccounts,
containsBytes,
extendClient,
getU32Encoder,
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
Expand Down Expand Up @@ -312,9 +313,8 @@ export type SystemPluginRequirements = ClientWithRpc<GetAccountInfoApi & GetMult
ClientWithTransactionSending;

export function systemProgram() {
return <T extends SystemPluginRequirements>(client: T) => {
return {
...client,
return <T extends SystemPluginRequirements>(client: T): Omit<T, 'system'> & { system: SystemPlugin } => {
return extendClient(client, {
system: <SystemPlugin>{
accounts: { nonce: addSelfFetchFunctions(client, getNonceCodec()) },
instructions: {
Expand Down Expand Up @@ -348,7 +348,7 @@ export function systemProgram() {
addSelfPlanAndSendFunctions(client, getUpgradeNonceAccountInstruction(input)),
},
},
};
});
};
}

Expand Down
13 changes: 10 additions & 3 deletions clients/js/test/_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import {
ClientWithRpc,
GetMinimumBalanceForRentExemptionApi,
TransactionSigner,
createClient,
lamports,
sequentialInstructionPlan,
} from '@solana/kit';
import { createLocalClient } from '@solana/kit-client-rpc';
import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
import { airdropSigner, generatedSigner } from '@solana/kit-plugin-signer';
import {
SYSTEM_PROGRAM_ADDRESS,
getCreateAccountInstruction,
Expand All @@ -14,8 +17,12 @@ import {
systemProgram,
} from '../src';

export const createClient = () => {
return createLocalClient().use(systemProgram());
export const createTestClient = () => {
return createClient()
.use(generatedSigner())
.use(solanaLocalRpc())
.use(systemProgram())
.use(airdropSigner(lamports(1_000_000_000n)));
};
Comment on lines -17 to 26
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the way we construct our test client to match latest Kit Plugin API.


export const getCreateNonceInstructionPlan = async (
Expand Down
4 changes: 2 additions & 2 deletions clients/js/test/advanceNonceAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { generateKeyPairSigner } from '@solana/kit';
import { expect, it } from 'vitest';
import { createClient, getCreateNonceInstructionPlan } from './_setup';
import { createTestClient, getCreateNonceInstructionPlan } from './_setup';

it('advances the nonce account', async () => {
// Given an existing nonce account.
const [client, nonce, authority] = await Promise.all([
createClient(),
createTestClient(),
generateKeyPairSigner(),
generateKeyPairSigner(),
]);
Expand Down
4 changes: 2 additions & 2 deletions clients/js/test/allocate.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assertAccountExists, fetchEncodedAccount, generateKeyPairSigner } from '@solana/kit';
import { expect, it } from 'vitest';
import { createClient } from './_setup';
import { createTestClient } from './_setup';

it('allocates space for an account', async () => {
// Given an existing account with some SOL and 0 data.
const client = await createClient();
const client = await createTestClient();
const newSpace = 100n;
const [accountToAllocate, newRent] = await Promise.all([
generateKeyPairSigner(),
Expand Down
4 changes: 2 additions & 2 deletions clients/js/test/assign.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fetchEncodedAccount, generateKeyPairSigner } from '@solana/kit';
import { expect, it } from 'vitest';
import { createClient } from './_setup';
import { createTestClient } from './_setup';

it('assigns a new owner to an account', async () => {
// Given an existing account with enough SOL to be rent exempt with 0 data.
const client = await createClient();
const client = await createTestClient();
const space = 0n;
const [accountToAssign, newOwner, rent] = await Promise.all([
generateKeyPairSigner(),
Expand Down
4 changes: 2 additions & 2 deletions clients/js/test/createAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { fetchEncodedAccount, generateKeyPairSigner } from '@solana/kit';
import { expect, it } from 'vitest';
import { SYSTEM_PROGRAM_ADDRESS } from '../src';
import { createClient } from './_setup';
import { createTestClient } from './_setup';

it('creates a new empty account', async () => {
// Given a new keypair and the computed rent for 42 bytes of space.
const client = await createClient();
const client = await createTestClient();
const space = 42n;
const [newAccount, lamports] = await Promise.all([
generateKeyPairSigner(),
Expand Down
6 changes: 3 additions & 3 deletions clients/js/test/createAccountWithSeed.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createAddressWithSeed, fetchEncodedAccount, generateKeyPairSigner } from '@solana/kit';
import { expect, it } from 'vitest';
import { createClient } from './_setup';
import { createTestClient } from './_setup';

it('creates a new empty account when base is not payer', async () => {
// Given a program, a base account, and an address derived from them with a seed.
const client = await createClient();
const client = await createTestClient();
const space = 42n;
const [program, baseAccount, rent] = await Promise.all([
generateKeyPairSigner(),
Expand Down Expand Up @@ -46,7 +46,7 @@ it('creates a new empty account when base is not payer', async () => {

it('creates a new empty account when base is payer', async () => {
// Given a program and an address derived from the program and the payer with a seed.
const client = await createClient();
const client = await createTestClient();
const space = 42n;
const [program, rent] = await Promise.all([
generateKeyPairSigner(),
Expand Down
4 changes: 2 additions & 2 deletions clients/js/test/initializeNonceAccount.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { generateKeyPairSigner } from '@solana/kit';
import { expect, it } from 'vitest';
import { NonceState, NonceVersion, SYSTEM_PROGRAM_ADDRESS, getNonceSize } from '../src';
import { createClient } from './_setup';
import { createTestClient } from './_setup';

it('creates and initialize a durable nonce account', async () => {
// Given some brand new authority, and nonce KeyPairSigners.
const client = await createClient();
const client = await createTestClient();
const space = BigInt(getNonceSize());
const [nonce, nonceAuthority, rent] = await Promise.all([
generateKeyPairSigner(),
Expand Down
4 changes: 2 additions & 2 deletions clients/js/test/transferSol.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AccountRole, generateKeyPairSigner, lamports } from '@solana/kit';
import { expect, it } from 'vitest';
import { getTransferSolInstruction, parseTransferSolInstruction } from '../src';
import { createClient } from './_setup';
import { createTestClient } from './_setup';

it('transfers SOL from one account to another', async () => {
// Given a source account with 3 SOL and a destination account with no SOL.
const client = await createClient();
const client = await createTestClient();
const [source, destination] = await Promise.all([
generateKeyPairSigner(),
generateKeyPairSigner().then(signer => signer.address),
Expand Down
31 changes: 16 additions & 15 deletions clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ readme = "README.md"
license-file = "../../LICENSE"

[features]
fetch = ["dep:solana-client", "dep:solana-sdk"]
fetch = ["dep:solana-client"]
test-sbf = []
serde = ["dep:serde", "dep:serde_with", "kaigan/serde"]

[dependencies]
borsh = "^0.10"
kaigan = "^0.3"
borsh = "^1.0"
num-derive = "^0.4"
num-traits = "^0.2"
serde = { version = "^1.0", features = ["derive"], optional = true }
serde_with = { version = "^3.0", optional = true }
solana-client = { version = "2.3.4", optional = true }
solana-sdk = { version = "2.2.1", optional = true }
solana-program = "2.2.1"
solana-account = "~3.0"
solana-account-info = "~3.1"
solana-address = { version = "~2.4", features = [
'borsh',
'copy',
'curve25519',
'decode',
] }
solana-client = { version = "^3.0", optional = true }
solana-cpi = "~3.1"
solana-decode-error = "~2.3"
solana-instruction = "~3.2"
solana-program-error = "~3.0"
spl-collections = { version = "^0.1", features = ["borsh"] }
thiserror = "^1.0"
solana-account = "~2.2"
solana-account-info = "~2.3"
solana-instruction = "~2.3"
solana-program-error = "~2.2"
solana-pubkey = { version = "~2.4", features = ["curve25519", "borsh"] }
solana-cpi = "~2.2"
Comment on lines 10 to -31
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update client dependencies to match latest Rust renderer code.

Loading
Loading