Skip to content

Instantly share code, notes, and snippets.

View 0xdeepmehta's full-sized avatar
🤿
Solana

0xDeep 0xdeepmehta

🤿
Solana
View GitHub Profile
async processTrancationJito(
jitoTip: number, // in ui
tx: Transaction,
luts?: AddressLookupTableAccount[],
priorityFee?: number, // priorityFeeUi
) {
console.log(`this.provider.connection.commitment :: ${this.provider.connection.commitment}`);
const jitoTipInLamport = jitoTip * LAMPORTS_PER_SOL;
console.log(`jitoTipInLamport :: ${jitoTipInLamport}`)
#!/bin/sh
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "old_email" ]; then
export GIT_COMMITTER_EMAIL="new_email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "old_email" ]; then
export GIT_AUTHOR_EMAIL="new_email"
fi
' --tag-name-filter cat -- --branches --tags
@0xdeepmehta
0xdeepmehta / sol_wrap_unwrap.rs
Created October 3, 2023 17:38
wrap and unwrap sol snippet
use spl_associated_token_account::instruction::create_associated_token_account_idempotent;
use spl_token::instruction::close_account;
pub fn make_wrap_sol_ixs(config: &Config) -> Result<()> {
println!("sol transfer :: {}", config.payer.pubkey());
// ata get -> ata create_idempotent -> trasnfer -> sync
let deposit_ata = anchor_spl::associated_token::get_associated_token_address(
&config.payer.pubkey(),
&pubkey!("So11111111111111111111111111111111111111112"),
@0xdeepmehta
0xdeepmehta / keypair_utils.ts
Created September 29, 2023 17:08
Read and write keypair in jsonfile anchor solana
import * as fs from 'fs/promises';
import * as path from 'path';
const writeKeypairToFile = async (sk: Uint8Array, fileName: string): Promise<void> => {
const filePath = path.join('tests/keys', `${fileName}.json`);
try {
await fs.writeFile(filePath, JSON.stringify(Array.from(sk)));
console.log(`Keypair written to file: ${filePath}`);
} catch (error) {
const credential = (await
navigator
.credentials.create({
publicKey: {
challenge: new Uint8Array(16),
rp: {
name: "0xdeep.com",
},
user: {
id: new Uint8Array(16),
import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { HelloSupersec } from "../target/types/hello_supersec";
describe("hello-supersec", () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const program = anchor.workspace.HelloSupersec as Program<HelloSupersec>;
// Define the size of each chunk
const chunkSize = 1000;
// Create a function to iterate over the items in chunks
async function iterateInChunks(items: any[], callback: (chunk: any[]) => void) {
// Calculate the number of chunks
const numChunks = Math.ceil(items.length / chunkSize);
// Create an array to hold the promises for the async operations
const promises = [];
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract AMM is ReentrancyGuard{
using Counters for Counters.Counter;
Counters.Counter private caseID;
{
header: {
numRequiredSignatures: 2,
numReadonlySignedAccounts: 0,
numReadonlyUnsignedAccounts: 2
},
accountKeys: [
PublicKey {
_bn: <BN: ac0c28f702f61dca52e1e6260991e7db6bc3abbc0956434c9cbf0046b384ed5>
},
@0xdeepmehta
0xdeepmehta / check_proton_mail_exit.js
Last active September 9, 2022 11:25
check whether username exist in proton or not
await fetch("https://account.proton.me/api/users/available?Name=0xdeepmehta%40protonmail.com&ParseDomain=1", {
"headers": {
"accept": "application/vnd.protonmail.v1+json",
"accept-language": "en-GB,en;q=0.6",
"cache-control": "no-cache",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"sec-gpc": "1",