Skip to content

Commit 7382cc6

Browse files
fix ci again
1 parent de7374f commit 7382cc6

7 files changed

Lines changed: 72 additions & 59 deletions

File tree

scripts/ci/run-localnet-examples.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ run_script "typescript-client" "create-spl-mint:action"
2727
run_script "typescript-client" "create-spl-mint:instruction"
2828
run_script "typescript-client" "create-t22-mint:action"
2929
run_script "typescript-client" "create-t22-mint:instruction"
30-
run_script "typescript-client" "create-spl-interface:action"
31-
run_script "typescript-client" "create-spl-interface:instruction"
3230
run_script "typescript-client" "create-interface-pda:action"
3331
run_script "typescript-client" "create-interface-pda:instruction"
3432
run_script "typescript-client" "create-ata:action"

toolkits/payments-and-wallets/register-spl-mint.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import {
55
sendAndConfirmTransaction,
66
} from "@solana/web3.js";
77
import { createRpc } from "@lightprotocol/stateless.js";
8-
import {
9-
LightTokenProgram,
10-
createMintInterface,
11-
} from "@lightprotocol/compressed-token";
12-
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
8+
import { LightTokenProgram } from "@lightprotocol/compressed-token";
9+
import { TOKEN_PROGRAM_ID, createMint } from "@solana/spl-token";
1310
import { homedir } from "os";
1411
import { readFileSync } from "fs";
1512

@@ -26,11 +23,10 @@ const payer = Keypair.fromSecretKey(
2623
);
2724

2825
(async function () {
29-
// Create a fresh SPL mint for a self-contained localnet example.
30-
const { mint } = await createMintInterface(
26+
const mint = await createMint(
3127
rpc,
3228
payer,
33-
payer,
29+
payer.publicKey,
3430
null,
3531
9,
3632
undefined,

toolkits/payments-and-wallets/send-and-receive.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ const payer = Keypair.fromSecretKey(
5959

6060
// 4. Transfer from payer to recipient
6161
const recipient = Keypair.generate();
62+
await createAtaInterface(rpc, payer, mint, recipient.publicKey);
63+
const recipientAta = getAssociatedTokenAddressInterface(
64+
mint,
65+
recipient.publicKey
66+
);
6267
const txId = await transferInterface(
6368
rpc,
6469
payer,
6570
senderAta,
6671
mint,
67-
recipient.publicKey,
72+
recipientAta,
6873
payer,
6974
100
7075
);

typescript-client/actions/create-spl-interface.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import "dotenv/config";
22
import { Keypair } from "@solana/web3.js";
33
import { createRpc } from "@lightprotocol/stateless.js";
4-
import {
5-
createSplInterface,
6-
createMintInterface,
7-
} from "@lightprotocol/compressed-token";
8-
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
4+
import { createSplInterface } from "@lightprotocol/compressed-token";
5+
import { TOKEN_PROGRAM_ID, createMint } from "@solana/spl-token";
96
import { homedir } from "os";
107
import { readFileSync } from "fs";
118

@@ -22,10 +19,10 @@ const payer = Keypair.fromSecretKey(
2219
);
2320

2421
(async function () {
25-
const { mint: existingMint } = await createMintInterface(
22+
const existingMint = await createMint(
2623
rpc,
2724
payer,
28-
payer,
25+
payer.publicKey,
2926
null,
3027
9,
3128
undefined,

typescript-client/actions/unwrap.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { createRpc } from "@lightprotocol/stateless.js";
44
import {
55
createMintInterface,
66
createAtaInterface,
7-
mintToInterface,
87
getAssociatedTokenAddressInterface,
98
} from "@lightprotocol/compressed-token";
10-
import { unwrap } from "@lightprotocol/compressed-token/unified";
9+
import { unwrap, wrap } from "@lightprotocol/compressed-token/unified";
1110
import {
1211
createAssociatedTokenAccount,
13-
TOKEN_2022_PROGRAM_ID,
12+
TOKEN_PROGRAM_ID,
13+
mintTo,
1414
} from "@solana/spl-token";
1515
import { homedir } from "os";
1616
import { readFileSync } from "fs";
@@ -37,24 +37,25 @@ const payer = Keypair.fromSecretKey(
3737
9,
3838
undefined,
3939
undefined,
40-
TOKEN_2022_PROGRAM_ID
40+
TOKEN_PROGRAM_ID
4141
);
42-
await createAtaInterface(rpc, payer, mint, payer.publicKey);
43-
const destination = getAssociatedTokenAddressInterface(
44-
mint,
45-
payer.publicKey
46-
);
47-
await mintToInterface(rpc, payer, mint, destination, payer, 1000);
48-
49-
// Unwrap light-token to SPL associated token account
5042
const splAta = await createAssociatedTokenAccount(
5143
rpc,
5244
payer,
5345
mint,
5446
payer.publicKey,
5547
undefined,
56-
TOKEN_2022_PROGRAM_ID
48+
TOKEN_PROGRAM_ID
5749
);
50+
await mintTo(rpc, payer, mint, splAta, payer, 1000, [], undefined, TOKEN_PROGRAM_ID);
51+
await createAtaInterface(rpc, payer, mint, payer.publicKey);
52+
const destination = getAssociatedTokenAddressInterface(
53+
mint,
54+
payer.publicKey
55+
);
56+
await wrap(rpc, payer, splAta, destination, payer, mint, BigInt(1000));
57+
58+
// Unwrap light-token to SPL associated token account
5859
const tx = await unwrap(rpc, payer, splAta, payer, mint, 500);
5960

6061
console.log("Tx:", tx);
Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import "dotenv/config";
22
import {
33
Keypair,
4+
SystemProgram,
45
Transaction,
56
sendAndConfirmTransaction,
67
} from "@solana/web3.js";
78
import { createRpc } from "@lightprotocol/stateless.js";
9+
import { LightTokenProgram } from "@lightprotocol/compressed-token";
810
import {
9-
LightTokenProgram,
10-
createMintInterface,
11-
} from "@lightprotocol/compressed-token";
12-
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
11+
MINT_SIZE,
12+
TOKEN_PROGRAM_ID,
13+
createInitializeMint2Instruction,
14+
} from "@solana/spl-token";
1315
import { homedir } from "os";
1416
import { readFileSync } from "fs";
1517

@@ -26,27 +28,40 @@ const payer = Keypair.fromSecretKey(
2628
);
2729

2830
(async function () {
29-
const { mint: existingMint } = await createMintInterface(
30-
rpc,
31-
payer,
32-
payer,
31+
const mintKeypair = Keypair.generate();
32+
const decimals = 9;
33+
const rentExemptBalance = await rpc.getMinimumBalanceForRentExemption(
34+
MINT_SIZE
35+
);
36+
37+
const createMintAccountIx = SystemProgram.createAccount({
38+
fromPubkey: payer.publicKey,
39+
lamports: rentExemptBalance,
40+
newAccountPubkey: mintKeypair.publicKey,
41+
programId: TOKEN_PROGRAM_ID,
42+
space: MINT_SIZE,
43+
});
44+
45+
const initializeMintIx = createInitializeMint2Instruction(
46+
mintKeypair.publicKey,
47+
decimals,
48+
payer.publicKey,
3349
null,
34-
9,
35-
undefined,
36-
undefined,
3750
TOKEN_PROGRAM_ID
3851
);
3952

40-
// Register SPL interface PDA to enable interop with Light Tokens
4153
const ix = await LightTokenProgram.createSplInterface({
4254
feePayer: payer.publicKey,
43-
mint: existingMint,
55+
mint: mintKeypair.publicKey,
4456
tokenProgramId: TOKEN_PROGRAM_ID,
4557
});
4658

47-
const tx = new Transaction().add(ix);
48-
const signature = await sendAndConfirmTransaction(rpc, tx, [payer]);
59+
const tx = new Transaction().add(createMintAccountIx, initializeMintIx, ix);
60+
const signature = await sendAndConfirmTransaction(rpc, tx, [
61+
payer,
62+
mintKeypair,
63+
]);
4964

50-
console.log("Mint:", existingMint.toBase58());
65+
console.log("Mint:", mintKeypair.publicKey.toBase58());
5166
console.log("Tx:", signature);
5267
})();

typescript-client/instructions/unwrap.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import { createRpc } from "@lightprotocol/stateless.js";
88
import {
99
createMintInterface,
1010
createAtaInterface,
11-
mintToInterface,
1211
getAssociatedTokenAddressInterface,
1312
createUnwrapInstructions,
13+
wrap,
1414
} from "@lightprotocol/compressed-token/unified";
1515
import {
1616
createAssociatedTokenAccount,
17-
TOKEN_2022_PROGRAM_ID,
17+
TOKEN_PROGRAM_ID,
18+
mintTo,
1819
} from "@solana/spl-token";
1920
import { homedir } from "os";
2021
import { readFileSync } from "fs";
@@ -41,25 +42,25 @@ const payer = Keypair.fromSecretKey(
4142
9,
4243
undefined,
4344
undefined,
44-
TOKEN_2022_PROGRAM_ID
45+
TOKEN_PROGRAM_ID
4546
);
46-
await createAtaInterface(rpc, payer, mint, payer.publicKey);
47-
const destination = getAssociatedTokenAddressInterface(
48-
mint,
49-
payer.publicKey
50-
);
51-
await mintToInterface(rpc, payer, mint, destination, payer, 1000);
52-
53-
// Create destination SPL ATA
5447
const splAta = await createAssociatedTokenAccount(
5548
rpc,
5649
payer,
5750
mint,
5851
payer.publicKey,
5952
undefined,
60-
TOKEN_2022_PROGRAM_ID
53+
TOKEN_PROGRAM_ID
6154
);
55+
await mintTo(rpc, payer, mint, splAta, payer, 1000, [], undefined, TOKEN_PROGRAM_ID);
56+
await createAtaInterface(rpc, payer, mint, payer.publicKey);
57+
const destination = getAssociatedTokenAddressInterface(
58+
mint,
59+
payer.publicKey
60+
);
61+
await wrap(rpc, payer, splAta, destination, payer, mint, BigInt(1000));
6262

63+
// Create destination SPL ATA
6364
// Returns TransactionInstruction[][]. Each inner array is one txn.
6465
// Handles loading cold state + unwrapping in one go.
6566
const instructions = await createUnwrapInstructions(

0 commit comments

Comments
 (0)