@toon-protocol/client 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1871,6 +1871,17 @@ function deriveChannelPDA(participantA, participantB, tokenMint, programId) {
|
|
|
1871
1871
|
const { pda, bump } = findProgramAddress(seeds, program);
|
|
1872
1872
|
return { pda: base58Encode(pda), bump };
|
|
1873
1873
|
}
|
|
1874
|
+
function deriveAssociatedTokenAccount(owner, tokenMint) {
|
|
1875
|
+
const TOKEN_PROGRAM_ID2 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1876
|
+
const ASSOCIATED_TOKEN_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
1877
|
+
const seeds = [
|
|
1878
|
+
padTo32(base58Decode(owner)),
|
|
1879
|
+
padTo32(base58Decode(TOKEN_PROGRAM_ID2)),
|
|
1880
|
+
padTo32(base58Decode(tokenMint))
|
|
1881
|
+
];
|
|
1882
|
+
const { pda } = findProgramAddress(seeds, padTo32(base58Decode(ASSOCIATED_TOKEN_PROGRAM_ID)));
|
|
1883
|
+
return base58Encode(pda);
|
|
1884
|
+
}
|
|
1874
1885
|
function deriveVaultPDA(channelPDA, programId) {
|
|
1875
1886
|
const channel = padTo32(base58Decode(channelPDA));
|
|
1876
1887
|
const program = padTo32(base58Decode(programId));
|
|
@@ -2586,14 +2597,17 @@ var OnChainChannelClient = class {
|
|
|
2586
2597
|
throw new Error("Solana channel config not set \u2014 cannot deposit.");
|
|
2587
2598
|
}
|
|
2588
2599
|
const cfg = this.solanaConfig;
|
|
2589
|
-
const payerTokenAccount = cfg.deposit?.payerTokenAccount;
|
|
2590
|
-
if (!payerTokenAccount) {
|
|
2591
|
-
throw new Error(
|
|
2592
|
-
"Solana deposit requires solanaConfig.deposit.payerTokenAccount (the funded SPL token account)."
|
|
2593
|
-
);
|
|
2594
|
-
}
|
|
2595
2600
|
const payerSeed = cfg.keypair.slice(0, 32);
|
|
2596
2601
|
const payerPubkey = base58Encode2(new Uint8Array(ed255192.getPublicKey(payerSeed)));
|
|
2602
|
+
let payerTokenAccount = cfg.deposit?.payerTokenAccount;
|
|
2603
|
+
if (!payerTokenAccount) {
|
|
2604
|
+
if (!cfg.tokenMint) {
|
|
2605
|
+
throw new Error(
|
|
2606
|
+
"Solana deposit requires solanaConfig.deposit.payerTokenAccount or solanaConfig.tokenMint to derive the payer ATA."
|
|
2607
|
+
);
|
|
2608
|
+
}
|
|
2609
|
+
payerTokenAccount = deriveAssociatedTokenAccount(payerPubkey, cfg.tokenMint);
|
|
2610
|
+
}
|
|
2597
2611
|
const { depositTxSignature } = await depositSolanaChannel({
|
|
2598
2612
|
rpcUrl: cfg.rpcUrl,
|
|
2599
2613
|
programId: cfg.programId,
|
|
@@ -2799,7 +2813,9 @@ var OnChainChannelClient = class {
|
|
|
2799
2813
|
);
|
|
2800
2814
|
const deposit = cfg.deposit ? {
|
|
2801
2815
|
amount: BigInt(cfg.deposit.amount),
|
|
2802
|
-
|
|
2816
|
+
// Derive the payer ATA (owner + channel mint) when not supplied — it is
|
|
2817
|
+
// deterministic, so the caller need not thread payerTokenAccount through.
|
|
2818
|
+
payerTokenAccount: cfg.deposit.payerTokenAccount || deriveAssociatedTokenAccount(payerPubkey, tokenMint)
|
|
2803
2819
|
} : void 0;
|
|
2804
2820
|
const { channelPDA } = await openSolanaChannel({
|
|
2805
2821
|
rpcUrl: cfg.rpcUrl,
|