Skip to content

Instantly share code, notes, and snippets.

View samfisher7777's full-sized avatar

samfisher7777

View GitHub Profile
@samfisher7777
samfisher7777 / counties_list.json
Created September 22, 2023 12:41 — forked from vitalii-z8i/counties_list.json
A Complete list on US counties (With state) in JSON format
[
{
"County": "Autauga County",
"State": "Alabama"
},
{
"County": "Baldwin County",
"State": "Alabama"
},
{
@samfisher7777
samfisher7777 / statesAndCounties.js
Created September 22, 2023 12:41 — forked from JoshuaCarroll/statesAndCounties.js
JavaScript array of all US states and counties
function County(strState, strCountyName) {
this.state = strState;
this.countyName = strCountyName;
}
var arrStates = new Array("AK","AL","AR","AZ","CA","CO","CT","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY", "OH","OK","OR","PA","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY");
var arrCounties = new Array(
new County("AL","Autauga County"),
@samfisher7777
samfisher7777 / US_States_and_Cities.json
Created September 21, 2023 12:25 — forked from ahmu83/US_States_and_Cities.json
List of US States and Cities in JSON format.
{
"New York": [
"New York",
"Buffalo",
"Rochester",
"Yonkers",
"Syracuse",
"Albany",
"New Rochelle",
"Mount Vernon",
@samfisher7777
samfisher7777 / file-upload.tsx
Created September 20, 2023 08:35 — forked from brenopolanski/file-upload.tsx
File Upload with Chakra UI and react-hook-form
import { ReactNode, useRef } from 'react'
import { Button, FormControl, FormErrorMessage, FormLabel, Icon, InputGroup } from '@chakra-ui/react'
import { useForm, UseFormRegisterReturn } from 'react-hook-form'
import { FiFile } from 'react-icons/fi'
type FileUploadProps = {
register: UseFormRegisterReturn
accept?: string
multiple?: boolean
children?: ReactNode
@samfisher7777
samfisher7777 / AnchorExemple.tsx
Created April 27, 2023 11:23
AnchorExemple.tsx
import { useWallet, useConnection } from '@solana/wallet-adapter-react';
import { Connection } from '@solana/web3.js';
import { Program, Provider } from '@project-serum/anchor';
const AnchorExemple = () => {
const { publicKey, sendTransaction } = useWallet();
const { connection } = useConnection();
@samfisher7777
samfisher7777 / Main.tsx
Created April 27, 2023 11:19
Finished Main.tsx
import { useWallet } from "@solana/wallet-adapter-react";
function Main() {
const { wallets, select, publicKey } = useWallet();
const isConnectedWallet = !!publicKey;
const phantomWallet = wallets[0];
const { createUserTransaction, initPoolTransaction
} = useTransaction();
@samfisher7777
samfisher7777 / useTransactions.ts
Created April 27, 2023 11:15
useTransactions.ts
import {PublicKey, SystemProgram, Transaction,
TransactionInstruction} from "@solana/web3.js";
import BN from "bn.js";
import { Buffer } from "buffer";
import { useConnection } from "@solana/wallet-adapter-react";
import { ContractInstructions, Pubkeys } from "./constats";
//Defines an asynchronous getUserStorageAccountWithNonce function that accepts
// the user’s public key and returns the user’s public key and unique number (nonce).
// Inside the function, we use the findProgramAddress method from @solana/web3.js to
// calculate the user’s public key:
@samfisher7777
samfisher7777 / Pubkeys.ts
Last active April 27, 2023 11:15
Pubkeys.ts
import { PublicKey } from "@solana/web3.js";
// pub enum Instruction {
// Initialize { rewards_per_token: u64 },
// CreateUser {},
// }
export class Pubkeys {
static ownerWallet = new PublicKey(
"E1J2ufLWSwXUjrAySpQhScrv2fuci3JJSjTJXCM5TniY"
@samfisher7777
samfisher7777 / Main.tsx
Created April 27, 2023 11:11
connect the selected wallet
import { useWallet } from "@solana/wallet-adapter-react";
function Main() {
const { wallets, select, publicKey } = useWallet();
const isConnectedWallet = !!publicKey;
const phantomWallet = wallets[0];
const connectWalletHandler = () => {
if (phantomWallet.readyState === "NotDetected") {
window.open("https://phantom.app/download");
@samfisher7777
samfisher7777 / App.tsx
Created April 27, 2023 11:09
configure supported wallets
import { useMemo } from "react";
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
import { clusterApiUrl } from "@solana/web3.js";
import { PhantomWalletAdapter } from "@solana/wallet-adapter-wallets";
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
import {
ConnectionProvider,
WalletProvider,
} from "@solana/wallet-adapter-react";
import Main from "./Main";