privacycash 1.0.18 → 1.0.19
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/README.md +5 -1
- package/dist/depositSPL.js +2 -1
- package/dist/utils/constants.d.ts +0 -1
- package/dist/utils/constants.js +3 -5
- package/dist/withdraw.js +1 -2
- package/dist/withdrawSPL.js +1 -2
- package/package.json +1 -1
- package/src/depositSPL.ts +2 -1
- package/src/utils/constants.ts +3 -6
- package/src/withdraw.ts +1 -3
- package/src/withdrawSPL.ts +1 -3
package/README.md
CHANGED
|
@@ -9,7 +9,11 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
|
|
|
9
9
|
### Usage
|
|
10
10
|
This SDK provides APIs for developers to interact with Privacy Cash relayers easily. Developers can easily deposit/withdraw/query balances in Privacy Cash solana program.
|
|
11
11
|
|
|
12
|
-
Main APIs for this SDK are:
|
|
12
|
+
Main APIs for this SDK are:
|
|
13
|
+
a. for SOL:
|
|
14
|
+
deposit(), withdraw(), getPrivateBalance()
|
|
15
|
+
b. for USDC:
|
|
16
|
+
depositUSDC(), withdrawUSDC(), getPrivateBalanceUSDC()
|
|
13
17
|
|
|
14
18
|
Check the example project under /example folder. The code should be fairly self-explanatory.
|
|
15
19
|
|
package/dist/depositSPL.js
CHANGED
|
@@ -371,7 +371,8 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
371
371
|
const signature = await relayDepositToIndexer({
|
|
372
372
|
mintAddress: mintAddress.toString(),
|
|
373
373
|
publicKey,
|
|
374
|
-
signedTransaction: serializedTransaction
|
|
374
|
+
signedTransaction: serializedTransaction,
|
|
375
|
+
referrer
|
|
375
376
|
});
|
|
376
377
|
logger.debug('Transaction signature:', signature);
|
|
377
378
|
logger.debug(`Transaction link: https://explorer.solana.com/tx/${signature}`);
|
|
@@ -2,7 +2,6 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
export declare const FIELD_SIZE: BN;
|
|
4
4
|
export declare const PROGRAM_ID: PublicKey;
|
|
5
|
-
export declare const DEPLOYER_ID: PublicKey;
|
|
6
5
|
export declare const FEE_RECIPIENT: PublicKey;
|
|
7
6
|
export declare const FETCH_UTXOS_GROUP_SIZE = 10000;
|
|
8
7
|
export declare const TRANSACT_IX_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
export const FIELD_SIZE = new BN('21888242871839275222246405745257275088548364400416034343698204186575808495617');
|
|
4
|
-
export const PROGRAM_ID = new PublicKey('9fhQBbumKEFuXtMBDw8AaQyAjCorLGJQiS3skWZdQyQD');
|
|
5
|
-
export const DEPLOYER_ID = new PublicKey('97rSMQUukMDjA7PYErccyx7ZxbHvSDaeXp2ig5BwSrTf');
|
|
6
|
-
//BxuZn19npE43qkrQycBSb12vgruyD3vLygxwZss7eXLU
|
|
4
|
+
export const PROGRAM_ID = process.env.NEXT_PUBLIC_PROGRAM_ID ? new PublicKey(process.env.NEXT_PUBLIC_PROGRAM_ID) : new PublicKey('9fhQBbumKEFuXtMBDw8AaQyAjCorLGJQiS3skWZdQyQD');
|
|
7
5
|
export const FEE_RECIPIENT = new PublicKey('AWexibGxNFKTa1b5R5MN4PJr9HWnWRwf8EW9g8cLx3dM');
|
|
8
6
|
export const FETCH_UTXOS_GROUP_SIZE = 10_000;
|
|
9
7
|
export const TRANSACT_IX_DISCRIMINATOR = Buffer.from([217, 149, 130, 143, 221, 52, 252, 119]);
|
|
10
8
|
export const TRANSACT_SPL_IX_DISCRIMINATOR = Buffer.from([154, 66, 244, 204, 78, 225, 163, 151]);
|
|
11
9
|
export const MERKLE_TREE_DEPTH = 26;
|
|
12
|
-
export const ALT_ADDRESS = new PublicKey('HEN49U2ySJ85Vc78qprSW9y6mFDhs1NczRxyppNHjofe');
|
|
10
|
+
export const ALT_ADDRESS = process.env.NEXT_PUBLIC_ALT_ADDRESS ? new PublicKey(process.env.NEXT_PUBLIC_ALT_ADDRESS) : new PublicKey('HEN49U2ySJ85Vc78qprSW9y6mFDhs1NczRxyppNHjofe');
|
|
13
11
|
export const RELAYER_API_URL = process.env.NEXT_PUBLIC_RELAYER_API_URL ?? 'https://api3.privacycash.org';
|
|
14
12
|
export const SIGN_MESSAGE = `Privacy Money account sign in`;
|
|
15
13
|
// localStorage cache keys
|
|
16
14
|
export const LSK_FETCH_OFFSET = 'fetch_offset';
|
|
17
15
|
export const LSK_ENCRYPTED_OUTPUTS = 'encrypted_outputs';
|
|
18
|
-
export const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
|
|
16
|
+
export const USDC_MINT = process.env.NEXT_PUBLIC_USDC_MINT ? new PublicKey(process.env.NEXT_PUBLIC_USDC_MINT) : new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
|
package/dist/withdraw.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import { Keypair as UtxoKeypair } from './models/keypair.js';
|
|
5
5
|
import { Utxo } from './models/utxo.js';
|
|
6
6
|
import { parseProofToBytesArray, parseToBytesArray, prove } from './utils/prover.js';
|
|
7
|
-
import { ALT_ADDRESS,
|
|
7
|
+
import { ALT_ADDRESS, FEE_RECIPIENT, FIELD_SIZE, RELAYER_API_URL, MERKLE_TREE_DEPTH } from './utils/constants.js';
|
|
8
8
|
import { serializeProofAndExtData } from './utils/encryption.js';
|
|
9
9
|
import { fetchMerkleProof, findNullifierPDAs, getExtDataHash, getProgramAccounts, queryRemoteTreeState, findCrossCheckNullifierPDAs } from './utils/utils.js';
|
|
10
10
|
import { getUtxos } from './getUtxos.js';
|
|
@@ -40,7 +40,6 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
40
40
|
amount_in_lamports -= fee_in_lamports;
|
|
41
41
|
let isPartial = false;
|
|
42
42
|
logger.debug('Encryption key generated from user keypair');
|
|
43
|
-
logger.debug(`Deployer wallet: ${DEPLOYER_ID.toString()}`);
|
|
44
43
|
const { treeAccount, treeTokenAccount, globalConfigAccount } = getProgramAccounts();
|
|
45
44
|
// Get current tree state
|
|
46
45
|
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
package/dist/withdrawSPL.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import { Keypair as UtxoKeypair } from './models/keypair.js';
|
|
5
5
|
import { Utxo } from './models/utxo.js';
|
|
6
6
|
import { parseProofToBytesArray, parseToBytesArray, prove } from './utils/prover.js';
|
|
7
|
-
import { ALT_ADDRESS,
|
|
7
|
+
import { ALT_ADDRESS, FEE_RECIPIENT, FIELD_SIZE, RELAYER_API_URL, MERKLE_TREE_DEPTH, PROGRAM_ID } from './utils/constants.js';
|
|
8
8
|
import { serializeProofAndExtData } from './utils/encryption.js';
|
|
9
9
|
import { fetchMerkleProof, findNullifierPDAs, getProgramAccounts, queryRemoteTreeState, findCrossCheckNullifierPDAs, getMintAddressField, getExtDataHash } from './utils/utils.js';
|
|
10
10
|
import { getUtxosSPL } from './getUtxosSPL.js';
|
|
@@ -51,7 +51,6 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
51
51
|
let feeRecipientTokenAccount = getAssociatedTokenAddressSync(mintAddress, FEE_RECIPIENT, true);
|
|
52
52
|
let signerTokenAccount = getAssociatedTokenAddressSync(mintAddress, publicKey);
|
|
53
53
|
logger.debug('Encryption key generated from user keypair');
|
|
54
|
-
logger.debug(`Deployer wallet: ${DEPLOYER_ID.toString()}`);
|
|
55
54
|
// Derive tree account PDA with mint address for SPL (different from SOL version)
|
|
56
55
|
const [treeAccount] = PublicKey.findProgramAddressSync([Buffer.from('merkle_tree'), mintAddress.toBuffer()], PROGRAM_ID);
|
|
57
56
|
const { globalConfigAccount, treeTokenAccount } = getProgramAccounts();
|
package/package.json
CHANGED
package/src/depositSPL.ts
CHANGED
|
@@ -484,7 +484,8 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
484
484
|
const signature = await relayDepositToIndexer({
|
|
485
485
|
mintAddress: mintAddress.toString(),
|
|
486
486
|
publicKey,
|
|
487
|
-
signedTransaction: serializedTransaction
|
|
487
|
+
signedTransaction: serializedTransaction,
|
|
488
|
+
referrer
|
|
488
489
|
});
|
|
489
490
|
logger.debug('Transaction signature:', signature);
|
|
490
491
|
logger.debug(`Transaction link: https://explorer.solana.com/tx/${signature}`);
|
package/src/utils/constants.ts
CHANGED
|
@@ -3,11 +3,8 @@ import BN from 'bn.js';
|
|
|
3
3
|
|
|
4
4
|
export const FIELD_SIZE = new BN('21888242871839275222246405745257275088548364400416034343698204186575808495617')
|
|
5
5
|
|
|
6
|
-
export const PROGRAM_ID = new PublicKey('9fhQBbumKEFuXtMBDw8AaQyAjCorLGJQiS3skWZdQyQD');
|
|
6
|
+
export const PROGRAM_ID = process.env.NEXT_PUBLIC_PROGRAM_ID ? new PublicKey(process.env.NEXT_PUBLIC_PROGRAM_ID) : new PublicKey('9fhQBbumKEFuXtMBDw8AaQyAjCorLGJQiS3skWZdQyQD');
|
|
7
7
|
|
|
8
|
-
export const DEPLOYER_ID = new PublicKey('97rSMQUukMDjA7PYErccyx7ZxbHvSDaeXp2ig5BwSrTf')
|
|
9
|
-
|
|
10
|
-
//BxuZn19npE43qkrQycBSb12vgruyD3vLygxwZss7eXLU
|
|
11
8
|
export const FEE_RECIPIENT = new PublicKey('AWexibGxNFKTa1b5R5MN4PJr9HWnWRwf8EW9g8cLx3dM')
|
|
12
9
|
|
|
13
10
|
export const FETCH_UTXOS_GROUP_SIZE = 10_000
|
|
@@ -18,7 +15,7 @@ export const TRANSACT_SPL_IX_DISCRIMINATOR = Buffer.from([154, 66, 244, 204, 78,
|
|
|
18
15
|
|
|
19
16
|
export const MERKLE_TREE_DEPTH = 26;
|
|
20
17
|
|
|
21
|
-
export const ALT_ADDRESS = new PublicKey('HEN49U2ySJ85Vc78qprSW9y6mFDhs1NczRxyppNHjofe');
|
|
18
|
+
export const ALT_ADDRESS = process.env.NEXT_PUBLIC_ALT_ADDRESS ? new PublicKey(process.env.NEXT_PUBLIC_ALT_ADDRESS) : new PublicKey('HEN49U2ySJ85Vc78qprSW9y6mFDhs1NczRxyppNHjofe');
|
|
22
19
|
|
|
23
20
|
export const RELAYER_API_URL = process.env.NEXT_PUBLIC_RELAYER_API_URL ?? 'https://api3.privacycash.org';
|
|
24
21
|
|
|
@@ -28,4 +25,4 @@ export const SIGN_MESSAGE = `Privacy Money account sign in`
|
|
|
28
25
|
export const LSK_FETCH_OFFSET = 'fetch_offset'
|
|
29
26
|
export const LSK_ENCRYPTED_OUTPUTS = 'encrypted_outputs'
|
|
30
27
|
|
|
31
|
-
export const USDC_MINT = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
|
|
28
|
+
export const USDC_MINT = process.env.NEXT_PUBLIC_USDC_MINT ? new PublicKey(process.env.NEXT_PUBLIC_USDC_MINT) : new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
|
package/src/withdraw.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as hasher from '@lightprotocol/hasher.rs';
|
|
|
6
6
|
import { Utxo } from './models/utxo.js';
|
|
7
7
|
import { parseProofToBytesArray, parseToBytesArray, prove } from './utils/prover.js';
|
|
8
8
|
|
|
9
|
-
import { ALT_ADDRESS,
|
|
9
|
+
import { ALT_ADDRESS, FEE_RECIPIENT, FIELD_SIZE, RELAYER_API_URL, MERKLE_TREE_DEPTH, PROGRAM_ID } from './utils/constants.js';
|
|
10
10
|
import { EncryptionService, serializeProofAndExtData } from './utils/encryption.js';
|
|
11
11
|
import { fetchMerkleProof, findNullifierPDAs, getExtDataHash, getProgramAccounts, queryRemoteTreeState, findCrossCheckNullifierPDAs } from './utils/utils.js';
|
|
12
12
|
|
|
@@ -62,8 +62,6 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
62
62
|
|
|
63
63
|
logger.debug('Encryption key generated from user keypair');
|
|
64
64
|
|
|
65
|
-
logger.debug(`Deployer wallet: ${DEPLOYER_ID.toString()}`);
|
|
66
|
-
|
|
67
65
|
const { treeAccount, treeTokenAccount, globalConfigAccount } = getProgramAccounts()
|
|
68
66
|
|
|
69
67
|
// Get current tree state
|
package/src/withdrawSPL.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as hasher from '@lightprotocol/hasher.rs';
|
|
|
6
6
|
import { Utxo } from './models/utxo.js';
|
|
7
7
|
import { parseProofToBytesArray, parseToBytesArray, prove } from './utils/prover.js';
|
|
8
8
|
|
|
9
|
-
import { ALT_ADDRESS,
|
|
9
|
+
import { ALT_ADDRESS, FEE_RECIPIENT, FIELD_SIZE, RELAYER_API_URL, MERKLE_TREE_DEPTH, PROGRAM_ID } from './utils/constants.js';
|
|
10
10
|
import { EncryptionService, serializeProofAndExtData } from './utils/encryption.js';
|
|
11
11
|
import { fetchMerkleProof, findNullifierPDAs, getProgramAccounts, queryRemoteTreeState, findCrossCheckNullifierPDAs, getMintAddressField, getExtDataHash } from './utils/utils.js';
|
|
12
12
|
|
|
@@ -91,8 +91,6 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
91
91
|
|
|
92
92
|
logger.debug('Encryption key generated from user keypair');
|
|
93
93
|
|
|
94
|
-
logger.debug(`Deployer wallet: ${DEPLOYER_ID.toString()}`);
|
|
95
|
-
|
|
96
94
|
// Derive tree account PDA with mint address for SPL (different from SOL version)
|
|
97
95
|
const [treeAccount] = PublicKey.findProgramAddressSync(
|
|
98
96
|
[Buffer.from('merkle_tree'), mintAddress.toBuffer()],
|