Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions .github/workflows/pull-request-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:
name-service,
stake-pool,
token,
token-group,
token-metadata,
token-swap,
]
include:
Expand All @@ -58,8 +56,12 @@ jobs:
node-version: 20.x
- package: single-pool
node-version: 20.5
- package: token-group
node-version: 20.x
- package: token-lending
node-version: 18.5
- package: token-metadata
node-version: 20.x
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions token-group/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"@solana/web3.js": "^1.95.3"
},
"dependencies": {
"@solana/codecs": "2.0.0-rc.1",
"@solana/spl-type-length-value": "0.1.0"
"@solana/codecs": "2.0.0-rc.1"
},
"devDependencies": {
"@solana/spl-type-length-value": "0.2.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR won't pass until this is published.

"@solana/web3.js": "^1.95.3",
"@types/chai": "^5.0.0",
"@types/mocha": "^10.0.9",
Expand Down
21 changes: 16 additions & 5 deletions token-group/js/src/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getU64Encoder,
transformEncoder,
} from '@solana/codecs';
import { splDiscriminate } from '@solana/spl-type-length-value';
import { SystemProgram, TransactionInstruction } from '@solana/web3.js';

function getInstructionEncoder<T extends object>(discriminator: Uint8Array, dataEncoder: Encoder<T>): Encoder<T> {
Expand Down Expand Up @@ -43,7 +42,10 @@ export function createInitializeGroupInstruction(args: InitializeGroupInstructio
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_group_interface:initialize_token_group'),
new Uint8Array([
/* await splDiscriminate('spl_token_group_interface:initialize_token_group') */
121, 113, 108, 39, 54, 51, 0, 4,
]),
getStructEncoder([
['updateAuthority', getPublicKeyEncoder()],
['maxSize', getU64Encoder()],
Expand All @@ -70,7 +72,10 @@ export function createUpdateGroupMaxSizeInstruction(args: UpdateGroupMaxSize): T
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_group_interface:update_group_max_size'),
new Uint8Array([
/* await splDiscriminate('spl_token_group_interface:update_group_max_size') */
108, 37, 171, 143, 248, 30, 18, 110,
]),
getStructEncoder([['maxSize', getU64Encoder()]]),
).encode({ maxSize }),
),
Expand All @@ -95,7 +100,10 @@ export function createUpdateGroupAuthorityInstruction(args: UpdateGroupAuthority
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_group_interface:update_authority'),
new Uint8Array([
/* await splDiscriminate('spl_token_group_interface:update_authority') */
161, 105, 88, 1, 237, 221, 216, 203,
]),
getStructEncoder([['newAuthority', getPublicKeyEncoder()]]),
).encode({ newAuthority: newAuthority ?? SystemProgram.programId }),
),
Expand Down Expand Up @@ -125,7 +133,10 @@ export function createInitializeMemberInstruction(args: InitializeMember): Trans
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_group_interface:initialize_member'),
new Uint8Array([
/* await splDiscriminate('spl_token_group_interface:initialize_member') */
152, 32, 222, 176, 223, 237, 116, 134,
]),
getStructEncoder([]),
).encode({}),
),
Expand Down
16 changes: 8 additions & 8 deletions token-group/js/test/instruction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Token Group Instructions', () => {
const mintAuthority = new PublicKey('66666666666666666666666666666666666666666666');
const maxSize = BigInt(100);

it('Can create InitializeGroup Instruction', () => {
it('Can create InitializeGroup Instruction', async () => {
checkPackUnpack(
createInitializeGroupInstruction({
programId,
Expand All @@ -40,7 +40,7 @@ describe('Token Group Instructions', () => {
updateAuthority,
maxSize,
}),
splDiscriminate('spl_token_group_interface:initialize_token_group'),
await splDiscriminate('spl_token_group_interface:initialize_token_group'),
getStructDecoder([
['updateAuthority', fixDecoderSize(getBytesDecoder(), 32)],
['maxSize', getU64Decoder()],
Expand All @@ -49,35 +49,35 @@ describe('Token Group Instructions', () => {
);
});

it('Can create UpdateGroupMaxSize Instruction', () => {
it('Can create UpdateGroupMaxSize Instruction', async () => {
checkPackUnpack(
createUpdateGroupMaxSizeInstruction({
programId,
group,
updateAuthority,
maxSize,
}),
splDiscriminate('spl_token_group_interface:update_group_max_size'),
await splDiscriminate('spl_token_group_interface:update_group_max_size'),
getStructDecoder([['maxSize', getU64Decoder()]]),
{ maxSize },
);
});

it('Can create UpdateGroupAuthority Instruction', () => {
it('Can create UpdateGroupAuthority Instruction', async () => {
checkPackUnpack(
createUpdateGroupAuthorityInstruction({
programId,
group,
currentAuthority: updateAuthority,
newAuthority: PublicKey.default,
}),
splDiscriminate('spl_token_group_interface:update_authority'),
await splDiscriminate('spl_token_group_interface:update_authority'),
getStructDecoder([['newAuthority', fixDecoderSize(getBytesDecoder(), 32)]]),
{ newAuthority: Uint8Array.from(PublicKey.default.toBuffer()) },
);
});

it('Can create InitializeMember Instruction', () => {
it('Can create InitializeMember Instruction', async () => {
const member = new PublicKey('22222222222222222222222222222222222222222222');
const memberMint = new PublicKey('33333333333333333333333333333333333333333333');
const memberMintAuthority = new PublicKey('44444444444444444444444444444444444444444444');
Expand All @@ -93,7 +93,7 @@ describe('Token Group Instructions', () => {
group,
groupUpdateAuthority,
}),
splDiscriminate('spl_token_group_interface:initialize_member'),
await splDiscriminate('spl_token_group_interface:initialize_member'),
getStructDecoder([]),
{},
);
Expand Down
4 changes: 2 additions & 2 deletions token-metadata/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"@solana/web3.js": "^1.95.3"
},
"dependencies": {
"@solana/codecs": "2.0.0-rc.1",
"@solana/spl-type-length-value": "0.1.0"
"@solana/codecs": "2.0.0-rc.1"
},
"devDependencies": {
"@solana/spl-type-length-value": "0.2.0",
"@solana/web3.js": "^1.95.3",
"@types/chai": "^5.0.0",
"@types/mocha": "^10.0.9",
Expand Down
26 changes: 20 additions & 6 deletions token-metadata/js/src/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
transformEncoder,
} from '@solana/codecs';
import type { VariableSizeEncoder } from '@solana/codecs';
import { splDiscriminate } from '@solana/spl-type-length-value';
import type { PublicKey } from '@solana/web3.js';
import { SystemProgram, TransactionInstruction } from '@solana/web3.js';

Expand Down Expand Up @@ -66,7 +65,10 @@ export function createInitializeInstruction(args: InitializeInstructionArgs): Tr
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_metadata_interface:initialize_account'),
new Uint8Array([
/* await splDiscriminate('spl_token_metadata_interface:initialize_account') */
210, 225, 30, 162, 88, 184, 77, 141,
]),
getStructEncoder([
['name', getStringEncoder()],
['symbol', getStringEncoder()],
Expand Down Expand Up @@ -99,7 +101,10 @@ export function createUpdateFieldInstruction(args: UpdateFieldInstruction): Tran
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_metadata_interface:updating_field'),
new Uint8Array([
/* await splDiscriminate('spl_token_metadata_interface:updating_field') */
221, 233, 49, 45, 181, 202, 220, 200,
]),
getStructEncoder([
['field', getDataEnumCodec(getFieldCodec())],
['value', getStringEncoder()],
Expand Down Expand Up @@ -127,7 +132,10 @@ export function createRemoveKeyInstruction(args: RemoveKeyInstructionArgs) {
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_metadata_interface:remove_key_ix'),
new Uint8Array([
/* await splDiscriminate('spl_token_metadata_interface:remove_key_ix') */
234, 18, 32, 56, 89, 141, 37, 181,
]),
getStructEncoder([
['idempotent', getBooleanEncoder()],
['key', getStringEncoder()],
Expand Down Expand Up @@ -155,7 +163,10 @@ export function createUpdateAuthorityInstruction(args: UpdateAuthorityInstructio
],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_metadata_interface:update_the_authority'),
new Uint8Array([
/* await splDiscriminate('spl_token_metadata_interface:update_the_authority') */
215, 228, 166, 228, 84, 100, 86, 123,
]),
getStructEncoder([['newAuthority', getPublicKeyEncoder()]]),
).encode({ newAuthority: newAuthority ?? SystemProgram.programId }),
),
Expand All @@ -176,7 +187,10 @@ export function createEmitInstruction(args: EmitInstructionArgs): TransactionIns
keys: [{ isSigner: false, isWritable: false, pubkey: metadata }],
data: Buffer.from(
getInstructionEncoder(
splDiscriminate('spl_token_metadata_interface:emitter'),
new Uint8Array([
/* await splDiscriminate('spl_token_metadata_interface:emitter') */
250, 166, 180, 250, 13, 12, 184, 70,
]),
getStructEncoder([
['start', getOptionEncoder(getU64Encoder())],
['end', getOptionEncoder(getU64Encoder())],
Expand Down
24 changes: 12 additions & 12 deletions token-metadata/js/test/instruction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Token Metadata Instructions', () => {
const mint = new PublicKey('55555555555555555555555555555555555555555555');
const mintAuthority = new PublicKey('66666666666666666666666666666666666666666666');

it('Can create Initialize Instruction', () => {
it('Can create Initialize Instruction', async () => {
const name = 'My test token';
const symbol = 'TEST';
const uri = 'http://test.test';
Expand All @@ -63,7 +63,7 @@ describe('Token Metadata Instructions', () => {
symbol,
uri,
}),
splDiscriminate('spl_token_metadata_interface:initialize_account'),
await splDiscriminate('spl_token_metadata_interface:initialize_account'),
getStructDecoder([
['name', getStringDecoder()],
['symbol', getStringDecoder()],
Expand All @@ -73,7 +73,7 @@ describe('Token Metadata Instructions', () => {
);
});

it('Can create Update Field Instruction', () => {
it('Can create Update Field Instruction', async () => {
const field = 'MyTestField';
const value = 'http://test.uri';
checkPackUnpack(
Expand All @@ -84,7 +84,7 @@ describe('Token Metadata Instructions', () => {
field,
value,
}),
splDiscriminate('spl_token_metadata_interface:updating_field'),
await splDiscriminate('spl_token_metadata_interface:updating_field'),
getStructDecoder([
['key', getDataEnumCodec(getFieldCodec())],
['value', getStringDecoder()],
Expand All @@ -93,7 +93,7 @@ describe('Token Metadata Instructions', () => {
);
});

it('Can create Update Field Instruction with Field Enum', () => {
it('Can create Update Field Instruction with Field Enum', async () => {
const field = 'Name';
const value = 'http://test.uri';
checkPackUnpack(
Expand All @@ -104,7 +104,7 @@ describe('Token Metadata Instructions', () => {
field,
value,
}),
splDiscriminate('spl_token_metadata_interface:updating_field'),
await splDiscriminate('spl_token_metadata_interface:updating_field'),
getStructDecoder([
['key', getDataEnumCodec(getFieldCodec())],
['value', getStringDecoder()],
Expand All @@ -113,7 +113,7 @@ describe('Token Metadata Instructions', () => {
);
});

it('Can create Remove Key Instruction', () => {
it('Can create Remove Key Instruction', async () => {
checkPackUnpack(
createRemoveKeyInstruction({
programId,
Expand All @@ -122,7 +122,7 @@ describe('Token Metadata Instructions', () => {
key: 'MyTestField',
idempotent: true,
}),
splDiscriminate('spl_token_metadata_interface:remove_key_ix'),
await splDiscriminate('spl_token_metadata_interface:remove_key_ix'),
getStructDecoder([
['idempotent', getBooleanDecoder()],
['key', getStringDecoder()],
Expand All @@ -131,7 +131,7 @@ describe('Token Metadata Instructions', () => {
);
});

it('Can create Update Authority Instruction', () => {
it('Can create Update Authority Instruction', async () => {
const newAuthority = PublicKey.default;
checkPackUnpack(
createUpdateAuthorityInstruction({
Expand All @@ -140,13 +140,13 @@ describe('Token Metadata Instructions', () => {
oldAuthority: updateAuthority,
newAuthority,
}),
splDiscriminate('spl_token_metadata_interface:update_the_authority'),
await splDiscriminate('spl_token_metadata_interface:update_the_authority'),
getStructDecoder([['newAuthority', fixDecoderSize(getBytesDecoder(), 32)]]),
{ newAuthority: Uint8Array.from(newAuthority.toBuffer()) },
);
});

it('Can create Emit Instruction', () => {
it('Can create Emit Instruction', async () => {
const start: Option<bigint> = some(0n);
const end: Option<bigint> = some(10n);
checkPackUnpack(
Expand All @@ -156,7 +156,7 @@ describe('Token Metadata Instructions', () => {
start: 0n,
end: 10n,
}),
splDiscriminate('spl_token_metadata_interface:emitter'),
await splDiscriminate('spl_token_metadata_interface:emitter'),
getStructDecoder([
['start', getOptionDecoder(getU64Decoder())],
['end', getOptionDecoder(getU64Decoder())],
Expand Down