Skip to content

Commit

Permalink
Upgrade to @solana/kit via Codama (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva authored Mar 1, 2025
1 parent 4414f51 commit bf5c619
Show file tree
Hide file tree
Showing 41 changed files with 473 additions and 394 deletions.
4 changes: 2 additions & 2 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
},
"homepage": "https://github.com/solana-program/system#readme",
"peerDependencies": {
"@solana/web3.js": "^2.0.0"
"@solana/kit": "^2.1.0"
},
"devDependencies": {
"@ava/typescript": "^4.1.0",
"@solana/eslint-config-solana": "^3.0.3",
"@solana/web3.js": "^2.0.0",
"@solana/kit": "^2.1.0",
"@types/node": "^20",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
Expand Down
569 changes: 285 additions & 284 deletions clients/js/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/js/src/generated/accounts/nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
type FetchAccountsConfig,
type MaybeAccount,
type MaybeEncodedAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import {
getNonceStateDecoder,
getNonceStateEncoder,
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/errors/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
type Address,
type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
type SolanaError,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';

/** AccountAlreadyInUse: an account with the same address already exists */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
type ReadonlySignerAccount,
type TransactionSigner,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

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 @@ -26,7 +26,7 @@ import {
type IInstructionWithData,
type TransactionSigner,
type WritableSignerAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

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 @@ -33,7 +33,7 @@ import {
type ReadonlySignerAccount,
type TransactionSigner,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

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 @@ -26,7 +26,7 @@ import {
type IInstructionWithData,
type TransactionSigner,
type WritableSignerAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

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 @@ -33,7 +33,7 @@ import {
type ReadonlySignerAccount,
type TransactionSigner,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
type ReadonlySignerAccount,
type TransactionSigner,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

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 @@ -29,7 +29,7 @@ import {
type IInstructionWithData,
type TransactionSigner,
type WritableSignerAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import {
getAccountMetaFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
type TransactionSigner,
type WritableAccount,
type WritableSignerAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
type IInstructionWithData,
type ReadonlyAccount,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

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 @@ -27,7 +27,7 @@ import {
type TransactionSigner,
type WritableAccount,
type WritableSignerAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
type ReadonlySignerAccount,
type TransactionSigner,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
type IInstructionWithAccounts,
type IInstructionWithData,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
type ReadonlySignerAccount,
type TransactionSigner,
type WritableAccount,
} from '@solana/web3.js';
} from '@solana/kit';
import { SYSTEM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/programs/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
getU32Encoder,
type Address,
type ReadonlyUint8Array,
} from '@solana/web3.js';
} from '@solana/kit';
import {
type ParsedAdvanceNonceAccountInstruction,
type ParsedAllocateInstruction,
Expand Down
6 changes: 3 additions & 3 deletions clients/js/src/generated/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import {
AccountRole,
isProgramDerivedAddress,
isTransactionSigner as web3JsIsTransactionSigner,
isTransactionSigner as kitIsTransactionSigner,
type Address,
type IAccountMeta,
type IAccountSignerMeta,
type ProgramDerivedAddress,
type TransactionSigner,
upgradeRoleToSigner,
} from '@solana/web3.js';
} from '@solana/kit';

/**
* Asserts that the given value is not null or undefined.
Expand Down Expand Up @@ -159,6 +159,6 @@ export function isTransactionSigner<TAddress extends string = string>(
!!value &&
typeof value === 'object' &&
'address' in value &&
web3JsIsTransactionSigner(value)
kitIsTransactionSigner(value)
);
}
2 changes: 1 addition & 1 deletion clients/js/src/generated/types/nonceState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
type Codec,
type Decoder,
type Encoder,
} from '@solana/web3.js';
} from '@solana/kit';

export enum NonceState {
Uninitialized,
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/types/nonceVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
type Codec,
type Decoder,
type Encoder,
} from '@solana/web3.js';
} from '@solana/kit';

export enum NonceVersion {
Legacy,
Expand Down
2 changes: 1 addition & 1 deletion clients/js/test/_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
signTransactionMessageWithSigners,
} from '@solana/web3.js';
} from '@solana/kit';
import {
SYSTEM_PROGRAM_ADDRESS,
getCreateAccountInstruction,
Expand Down
2 changes: 1 addition & 1 deletion clients/js/test/advanceNonceAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
appendTransactionMessageInstruction,
generateKeyPairSigner,
pipe,
} from '@solana/web3.js';
} from '@solana/kit';
import test from 'ava';
import { fetchNonce, getAdvanceNonceAccountInstruction } from '../src';
import {
Expand Down
3 changes: 2 additions & 1 deletion clients/js/test/createAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
fetchEncodedAccount,
generateKeyPairSigner,
pipe,
} from '@solana/web3.js';
} from '@solana/kit';
import test from 'ava';
import { SYSTEM_PROGRAM_ADDRESS, getCreateAccountInstruction } from '../src';
import {
Expand Down Expand Up @@ -49,5 +49,6 @@ test('it creates a new empty account', async (t) => {
address: newAccount.address,
data: new Uint8Array(Array.from({ length: 42 }, () => 0)),
exists: true,
space: 42n,
});
});
2 changes: 1 addition & 1 deletion clients/js/test/initializeNonceAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
appendTransactionMessageInstruction,
generateKeyPairSigner,
pipe,
} from '@solana/web3.js';
} from '@solana/kit';
import test from 'ava';
import {
Nonce,
Expand Down
2 changes: 1 addition & 1 deletion clients/js/test/transferSol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
generateKeyPairSigner,
lamports,
pipe,
} from '@solana/web3.js';
} from '@solana/kit';
import test from 'ava';
import { getTransferSolInstruction, parseTransferSolInstruction } from '../src';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ impl AdvanceNonceAccount {
true,
));
accounts.extend_from_slice(remaining_accounts);
let data = AdvanceNonceAccountInstructionData::new()
.try_to_vec()
.unwrap();
let data = borsh::to_vec(&AdvanceNonceAccountInstructionData::new()).unwrap();

solana_program::instruction::Instruction {
program_id: crate::SYSTEM_ID,
Expand Down Expand Up @@ -230,9 +228,7 @@ impl<'a, 'b> AdvanceNonceAccountCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let data = AdvanceNonceAccountInstructionData::new()
.try_to_vec()
.unwrap();
let data = borsh::to_vec(&AdvanceNonceAccountInstructionData::new()).unwrap();

let instruction = solana_program::instruction::Instruction {
program_id: crate::SYSTEM_ID,
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/allocate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ impl Allocate {
true,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = AllocateInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AllocateInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -198,8 +198,8 @@ impl<'a, 'b> AllocateCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = AllocateInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AllocateInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/allocate_with_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl AllocateWithSeed {
true,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = AllocateWithSeedInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AllocateWithSeedInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -250,8 +250,8 @@ impl<'a, 'b> AllocateWithSeedCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = AllocateWithSeedInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AllocateWithSeedInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ impl Assign {
true,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = AssignInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AssignInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -202,8 +202,8 @@ impl<'a, 'b> AssignCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = AssignInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AssignInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/assign_with_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl AssignWithSeed {
true,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = AssignWithSeedInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AssignWithSeedInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -242,8 +242,8 @@ impl<'a, 'b> AssignWithSeedCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = AssignWithSeedInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AssignWithSeedInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ impl AuthorizeNonceAccount {
true,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = AuthorizeNonceAccountInstructionData::new()
.try_to_vec()
.unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AuthorizeNonceAccountInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -230,10 +228,8 @@ impl<'a, 'b> AuthorizeNonceAccountCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = AuthorizeNonceAccountInstructionData::new()
.try_to_vec()
.unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&AuthorizeNonceAccountInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
Loading

0 comments on commit bf5c619

Please sign in to comment.