repo_id
stringclasses
563 values
file_path
stringlengths
40
166
content
stringlengths
1
2.94M
__index_level_0__
int64
0
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/button.tsx
import * as React from "react"; import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-backgrou...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/toggle.tsx
"use client" import * as React from "react" import * as TogglePrimitive from "@radix-ui/react-toggle" import { cva, type VariantProps } from "class-variance-authority" import { cn } from "@/lib/utils" const toggleVariants = cva( "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-ba...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/toast.tsx
"use client" import * as React from "react" import * as ToastPrimitives from "@radix-ui/react-toast" import { cva, type VariantProps } from "class-variance-authority" import { X } from "lucide-react" import { cn } from "@/lib/utils" const ToastProvider = ToastPrimitives.Provider const ToastViewport = React.forwardR...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/checkbox.tsx
"use client" import * as React from "react" import * as CheckboxPrimitive from "@radix-ui/react-checkbox" import { Check } from "lucide-react" import { cn } from "@/lib/utils" const Checkbox = React.forwardRef< React.ElementRef<typeof CheckboxPrimitive.Root>, React.ComponentPropsWithoutRef<typeof CheckboxPrimiti...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/select.tsx
"use client" import * as React from "react" import * as SelectPrimitive from "@radix-ui/react-select" import { Check, ChevronDown, ChevronUp } from "lucide-react" import { cn } from "@/lib/utils" const Select = SelectPrimitive.Root const SelectGroup = SelectPrimitive.Group const SelectValue = SelectPrimitive.Value...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/input.tsx
import * as React from "react" import { cn } from "@/lib/utils" export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {} const Input = React.forwardRef<HTMLInputElement, InputProps>( ({ className, type, ...props }, ref) => { return ( <input type={type} classNam...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/skeleton.tsx
import { cn } from "@/lib/utils"; function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) { return ( <div className={cn("animate-pulse rounded-md bg-muted", className)} {...props} /> ); } export { Skeleton };
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/ui/form.tsx
import * as React from "react" import * as LabelPrimitive from "@radix-ui/react-label" import { Slot } from "@radix-ui/react-slot" import { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext, } from "react-hook-form" import { cn } from "@/lib/utils" import { Label } from "@/c...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/providers/theme-provider.tsx
"use client"; import * as React from "react"; import { ThemeProvider as NextThemesProvider } from "next-themes"; import { type ThemeProviderProps } from "next-themes/dist/types"; export function ThemeProvider({ children, ...props }: ThemeProviderProps) { return <NextThemesProvider {...props}>{children}</NextThemesP...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/providers/pyth-pricefeed-provider.tsx
"use client"; import React, { createContext, useContext, useEffect, useState } from "react"; import { PriceServiceConnection, PriceFeed, } from "@pythnetwork/price-service-client"; import { PublicKey } from "@solana/web3.js"; const SOL_PRICE_FEED_ID = "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c2...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/providers/wallet-provider.tsx
"use client"; import { WalletAdapterNetwork } from "@solana/wallet-adapter-base"; import { ConnectionProvider, WalletProvider, } from "@solana/wallet-adapter-react"; import { WalletModalProvider } from "@solana/wallet-adapter-react-ui"; import { clusterApiUrl } from "@solana/web3.js"; import "@solana/wallet-adapte...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/providers/config-account-provider.tsx
"use client"; import React, { createContext, useContext, useEffect, useState } from "react"; import { useConnection } from "@solana/wallet-adapter-react"; import { AccountInfo } from "@solana/web3.js"; import { program, configPDA, ConfigAccount } from "@/anchor/setup"; // Shared state for program config account inter...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/providers/collateral-account-provider.tsx
"use client"; import React, { createContext, useContext, useEffect, useState, useCallback, } from "react"; import { useConnection, useWallet } from "@solana/wallet-adapter-react"; import { AccountInfo, PublicKey } from "@solana/web3.js"; import { program, CollateralAccount } from "@/anchor/setup"; // Shared...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/deposit.tsx
import React, { useState, useEffect, useCallback } from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Slider } from "@/components/ui/slider"; import { Button } from "@/components/ui/button"; import { AlertCircle } from "lucide-react"; import { Alert, Ale...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/withdraw.tsx
import React, { useState, useEffect, useCallback } from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Slider } from "@/components/ui/slider"; import { Button } from "@/components/ui/button"; import { AlertCircle } from "lucide-react"; import { Alert, Ale...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/liquidate.tsx
import React, { useState, useEffect, useCallback } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Label } from "@/components/ui/label"; import { Slider } from "@/components/ui/slider"; import { Button } from "@/components/ui/button"; import { AlertCircle, Loader2...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/collateral.tsx
import React from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"; import { useCollateral } from "../providers/collateral-account-provider"; import { usePythPrice } from "../providers/pyth-pricefeed-p...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/update-config.tsx
import React, { useState } from "react"; import { Card, CardContent, CardHeader, CardTitle, CardDescription, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { AlertCircle, Loade...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/deposit-withdraw.tsx
import React, { useState } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import CollateralMintUI from "@/components/stablecoin/deposit"; import RedeemBurnUI from "@/components/stablecoin/wit...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/toast.tsx
import React from "react"; import { useToast } from "@/components/ui/use-toast"; import { Button } from "@/components/ui/button"; import { ExternalLink } from "lucide-react"; // Toast with link to solana explorer transaction export const useTransactionToast = () => { const { toast } = useToast(); const showTransa...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/components/stablecoin/collateral-table.tsx
import React, { useState, useMemo, useEffect } from "react"; import { useCollateral } from "../providers/collateral-account-provider"; import { usePythPrice } from "../providers/pyth-pricefeed-provider"; import { useConfig } from "../providers/config-account-provider"; import { calculateHealthFactor, getUsdValue } from...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/public/vercel.svg
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-1...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/public/next.svg
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/lib/fonts.ts
import { JetBrains_Mono as FontMono, Inter as FontSans, } from "next/font/google"; export const fontSans = FontSans({ subsets: ["latin"], variable: "--font-sans", }); export const fontMono = FontMono({ subsets: ["latin"], variable: "--font-mono", });
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/lib/utils.ts
import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/anchor/idl.json
{ "address": "6DjiD8tQhJ9ZS3WZrwNubfoBRBrqfWacNR3bXBQ7ir91", "metadata": { "name": "stablecoin", "version": "0.1.0", "spec": "0.1.0", "description": "Created with Anchor" }, "instructions": [ { "name": "deposit_collateral_and_mint", "discriminator": [186, 99, 85, 148, 89, 72, 66,...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/anchor/setup.ts
import { clusterApiUrl, Connection, PublicKey } from "@solana/web3.js"; import { IdlAccounts, Program } from "@coral-xyz/anchor"; import type { Stablecoin } from "./idlType"; import idl from "./idl.json"; const connection = new Connection(clusterApiUrl("devnet"), "confirmed"); export const program = new Program(idl a...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/frontend/anchor/idlType.ts
/** * Program IDL in camelCase format in order to be used in JS/TS. * * Note that this is only a type helper and is not the actual IDL. The original * IDL can be found at `target/idl/stablecoin.json`. */ export type Stablecoin = { address: "6DjiD8tQhJ9ZS3WZrwNubfoBRBrqfWacNR3bXBQ7ir91"; metadata: { name: "...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/Cargo.toml
[workspace] members = [ "programs/*" ] resolver = "2" [profile.release] overflow-checks = true lto = "fat" codegen-units = 1 [profile.release.build-override] opt-level = 3 incremental = false codegen-units = 1
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/.prettierignore
.anchor .DS_Store target node_modules dist build test-ledger
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/Anchor.toml
[toolchain] [features] resolution = true skip-lint = false [programs.localnet] stablecoin = "6DjiD8tQhJ9ZS3WZrwNubfoBRBrqfWacNR3bXBQ7ir91" [registry] url = "https://api.apr.dev" [provider] cluster = "devnet" wallet = "~/.config/solana/id.json" [scripts] test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/package.json
{ "license": "ISC", "scripts": { "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" }, "dependencies": { "@coral-xyz/anchor": "^0.30.1", "@pythnetwork/price-service-client": "^1.9.0", "@pythnetwork/pyth-solana-receiver": "0.7.0", "...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/tsconfig.json
{ "compilerOptions": { "types": ["mocha", "chai"], "typeRoots": ["./node_modules/@types"], "lib": ["es2015"], "module": "commonjs", "target": "es6", "esModuleInterop": true } }
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/migrations/deploy.ts
// Migrations are an early feature. Currently, they're nothing more than this // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. const anchor = require("@coral-xyz/anchor"); module.exports = async function (provider) { // Configure client to use...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/tests/stablecoin.ts
import * as anchor from "@coral-xyz/anchor"; import { Program } from "@coral-xyz/anchor"; import { Stablecoin } from "../target/types/stablecoin"; import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver"; describe("stablecoin", () => { const provider = anchor.AnchorProvider.env(); const connection = ...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/Cargo.toml
[package] name = "stablecoin" version = "0.1.0" description = "Created with Anchor" edition = "2021" [lib] crate-type = ["cdylib", "lib"] name = "stablecoin" [features] default = [] cpi = ["no-entrypoint"] no-entrypoint = [] no-idl = [] no-log-ix-name = [] idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/Xargo.toml
[target.bpfel-unknown-unknown.dependencies.std] features = []
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/constants.rs
use anchor_lang::prelude::*; pub const SEED_CONFIG_ACCOUNT: &[u8] = b"config"; pub const SEED_COLLATERAL_ACCOUNT: &[u8] = b"collateral"; pub const SEED_SOL_ACCOUNT: &[u8] = b"sol"; pub const SEED_MINT_ACCOUNT: &[u8] = b"mint"; #[constant] pub const FEED_ID: &str = "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/error.rs
use anchor_lang::prelude::*; #[error_code] pub enum CustomError { #[msg("Below Minimum Health Factor")] BelowMinimumHealthFactor, #[msg("Above Minimum Health Factor, Cannot Liquidate Healthy Account")] AboveMinimumHealthFactor, #[msg("Price should not be negative")] InvalidPrice, }
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/lib.rs
use anchor_lang::prelude::*; use constants::*; use instructions::*; use state::*; mod constants; mod error; mod instructions; mod state; declare_id!("6DjiD8tQhJ9ZS3WZrwNubfoBRBrqfWacNR3bXBQ7ir91"); #[program] pub mod stablecoin { use super::*; pub fn initialize_config(ctx: Context<InitializeConfig>) -> Resul...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/state.rs
use anchor_lang::prelude::*; #[account] #[derive(InitSpace, Debug)] pub struct Collateral { pub depositor: Pubkey, // depositor wallet address pub sol_account: Pubkey, // depositor pda collateral account (deposit SOL to this account) pub token_account: Pubkey, // depositor ata token account (mint sta...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/mod.rs
pub use admin::*; pub mod admin; pub use deposit::*; pub mod deposit; pub use withdraw::*; pub mod withdraw; pub use utils::*; pub mod utils;
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/utils.rs
use crate::{ error::CustomError, Collateral, Config, FEED_ID, MAXIMUM_AGE, PRICE_FEED_DECIMAL_ADJUSTMENT, }; use anchor_lang::{prelude::*, solana_program::native_token::LAMPORTS_PER_SOL}; use pyth_solana_receiver_sdk::price_update::{get_feed_id_from_hex, PriceUpdateV2}; // Check health factor for Collateral accoun...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/deposit/mod.rs
pub use deposit_collateral_and_mint_tokens::*; pub mod deposit_collateral_and_mint_tokens; pub use utils::*; pub mod utils;
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/deposit/deposit_collateral_and_mint_tokens.rs
use crate::{ check_health_factor, deposit_sol_internal, mint_tokens_internal, Collateral, Config, SEED_COLLATERAL_ACCOUNT, SEED_CONFIG_ACCOUNT, SEED_SOL_ACCOUNT, }; use anchor_lang::prelude::*; use anchor_spl::{ associated_token::AssociatedToken, token_interface::{Mint, Token2022, TokenAccount}, }; use ...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/deposit/utils.rs
use crate::SEED_MINT_ACCOUNT; use anchor_lang::prelude::*; use anchor_lang::system_program::{transfer, Transfer}; use anchor_spl::{ token_2022::{mint_to, MintTo}, token_interface::{Mint, Token2022, TokenAccount}, }; pub fn mint_tokens_internal<'info>( mint_account: &InterfaceAccount<'info, Mint>, token...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/admin/mod.rs
pub use initialize_config::*; pub mod update_config; pub use update_config::*; pub mod initialize_config;
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/admin/initialize_config.rs
use anchor_lang::prelude::*; use anchor_spl::token_interface::{ Mint, Token2022, }; use crate::{Config, LIQUIDATION_BONUS, LIQUIDATION_THRESHOLD, MINT_DECIMALS, MIN_HEALTH_FACTOR, SEED_CONFIG_ACCOUNT, SEED_MINT_ACCOUNT}; #[derive(Accounts)] pub struct InitializeConfig<'info> { #[account(mut)] pub authority:...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/admin/update_config.rs
use crate::{Config, SEED_CONFIG_ACCOUNT}; use anchor_lang::prelude::*; #[derive(Accounts)] pub struct UpdateConfig<'info> { #[account( mut, seeds = [SEED_CONFIG_ACCOUNT], bump = config_account.bump, )] pub config_account: Account<'info, Config>, } // Change health factor to test li...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/withdraw/redeem_collateral_and_burn_tokens.rs
use crate::{ burn_tokens_internal, check_health_factor, withdraw_sol_internal, Collateral, Config, SEED_COLLATERAL_ACCOUNT, SEED_CONFIG_ACCOUNT, }; use anchor_lang::prelude::*; use anchor_spl::token_interface::{Mint, Token2022, TokenAccount}; use pyth_solana_receiver_sdk::price_update::PriceUpdateV2; #[derive(...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/withdraw/mod.rs
pub use redeem_collateral_and_burn_tokens::*; pub mod redeem_collateral_and_burn_tokens; pub use liquidate::*; pub mod liquidate; pub use utils::*; pub mod utils;
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/withdraw/utils.rs
use crate::SEED_SOL_ACCOUNT; use anchor_lang::prelude::*; use anchor_lang::system_program::{transfer, Transfer}; use anchor_spl::{ token_2022::{burn, Burn}, token_interface::{Mint, Token2022, TokenAccount}, }; pub fn withdraw_sol_internal<'info>( from: &SystemAccount<'info>, to: &AccountInfo<'info>, ...
0
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions
solana_public_repos/developer-bootcamp-2024/project-11-programmable-money/program/programs/stablecoin/src/instructions/withdraw/liquidate.rs
use crate::{ burn_tokens_internal, calculate_health_factor, error::CustomError, get_lamports_from_usd, withdraw_sol_internal, Collateral, Config, SEED_CONFIG_ACCOUNT, }; use anchor_lang::prelude::*; use anchor_spl::token_interface::{Mint, Token2022, TokenAccount}; use pyth_solana_receiver_sdk::price_update::Pri...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-5-tokens/create-token-metadata.ts
// This uses "@metaplex-foundation/mpl-token-metadata@2" to create tokens import "dotenv/config"; import { getKeypairFromEnvironment, getExplorerLink, } from "@solana-developers/helpers"; import { Connection, clusterApiUrl, PublicKey, Transaction, sendAndConfirmTransaction, } from "@solana/web3.js"; impor...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-5-tokens/send-spl-tokens.ts
import "dotenv/config"; import { getExplorerLink, getKeypairFromEnvironment, } from "@solana-developers/helpers"; import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js"; import { getOrCreateAssociatedTokenAccount, transfer } from "@solana/spl-token"; const connection = new Connection(clusterApiUrl("...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-5-tokens/create-token-mint.ts
import { createMint } from "@solana/spl-token"; import "dotenv/config"; import { getKeypairFromEnvironment, getExplorerLink, } from "@solana-developers/helpers"; import { Connection, clusterApiUrl } from "@solana/web3.js"; const connection = new Connection(clusterApiUrl("devnet")); const user = getKeypairFromEnvi...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-5-tokens/mint-tokens.ts
import { getOrCreateAssociatedTokenAccount, mintTo } from "@solana/spl-token"; import "dotenv/config"; import { getExplorerLink, getKeypairFromEnvironment, } from "@solana-developers/helpers"; import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js"; // mintTo() doesn't default to a commitment level ...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/jest.preset.js
const nxPreset = require('@nx/jest/preset').default; module.exports = { ...nxPreset };
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/nx.json
{ "$schema": "./node_modules/nx/schemas/nx-schema.json", "targetDefaults": { "build": { "cache": true, "dependsOn": ["^build"], "inputs": ["production", "^production"] }, "lint": { "cache": true, "inputs": [ "default", "{workspaceRoot}/.eslintrc.json", ...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/LICENSE
MIT License Copyright (c) 2024 brimigs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribut...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/vercel.json
{ "buildCommand": "npm run build", "outputDirectory": "dist/web/.next" }
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/tsconfig.base.json
{ "compileOnSave": false, "compilerOptions": { "rootDir": ".", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, "target": "es2015", "module": "esnext", "lib": ["es2020", ...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/package.json
{ "name": "@journal/source", "version": "0.0.0", "license": "MIT", "scripts": { "anchor": "nx run anchor:anchor", "anchor-build": "nx run anchor:anchor build", "anchor-localnet": "nx run anchor:anchor localnet", "anchor-test": "nx run anchor:anchor test", "feature": "nx generate @solana-deve...
0
solana_public_repos/developer-bootcamp-2024
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/jest.config.ts
import { getJestProjects } from '@nx/jest'; export default { projects: getJestProjects(), };
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/tailwind.config.js
const { createGlobPatternsForDependencies } = require('@nx/react/tailwind'); const { join } = require('path'); /** @type {import('tailwindcss').Config} */ module.exports = { content: [ join( __dirname, '{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}' ), ...createGlobPatterns...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/project.json
{ "name": "web", "$schema": "../node_modules/nx/schemas/project-schema.json", "sourceRoot": "web", "projectType": "application", "targets": { "build": { "executor": "@nx/next:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "options": { "ou...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/next.config.js
//@ts-check // eslint-disable-next-line @typescript-eslint/no-var-requires const { composePlugins, withNx } = require('@nx/next'); /** * @type {import('@nx/next/plugins/with-nx').WithNxOptions} **/ const nextConfig = { webpack: (config) => { config.externals = [ ...(config.externals || []), 'bigin...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/next-env.d.ts
/// <reference types="next" /> /// <reference types="next/image-types/global" /> // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information.
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/tsconfig.json
{ "extends": "../tsconfig.base.json", "compilerOptions": { "jsx": "preserve", "allowJs": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "resolveJsonModule": true, "isolatedModules": tr...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/index.d.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ declare module '*.svg' { const content: any; export const ReactComponent: any; export default content; }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/postcss.config.js
const { join } = require('path'); // Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build // option from your application's configuration (i.e. project.json). // // See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libr...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/.eslintrc.json
{ "extends": [ "plugin:@nx/react-typescript", "next", "next/core-web-vitals", "../.eslintrc.json" ], "ignorePatterns": ["!**/*", ".next/**/*"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "rules": { "@next/next/no-html-link-for-pages": ["error", "web/pag...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/react-query-provider.tsx
'use client'; import React, { ReactNode, useState } from 'react'; import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental'; import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; export function ReactQueryProvider({ children }: { children: ReactNode }) { const [client...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/global.css
@tailwind base; @tailwind components; @tailwind utilities; html, body { height: 100%; } .wallet-adapter-button-trigger { background: rgb(100, 26, 230) !important; border-radius: 8px !important; padding-left: 16px !important; padding-right: 16px !important; } .wallet-adapter-dropdown-list, .wallet-adapter-bu...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/page.module.css
.page { }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/layout.tsx
import './global.css'; import { UiLayout } from '@/components/ui/ui-layout'; import { ClusterProvider } from '@/components/cluster/cluster-data-access'; import { SolanaProvider } from '@/components/solana/solana-provider'; import { ReactQueryProvider } from './react-query-provider'; export const metadata = { title: ...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/page.tsx
import DashboardFeature from '@/components/dashboard/dashboard-feature'; export default function Page() { return <DashboardFeature />; }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/journal/page.tsx
import JournalFeature from '@/components/journal/journal-feature'; export default function Page() { return <JournalFeature />; }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/clusters/page.tsx
import ClusterFeature from '@/components/cluster/cluster-feature'; export default function Page() { return <ClusterFeature />; }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/api
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/api/hello/route.ts
export async function GET(request: Request) { return new Response('Hello, from API!'); }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/account/page.tsx
import AccountListFeature from '@/components/account/account-list-feature'; export default function Page() { return <AccountListFeature />; }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/account
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/app/account/[address]/page.tsx
import AccountDetailFeature from '@/components/account/account-detail-feature'; export default function Page() { return <AccountDetailFeature />; }
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/journal/journal-data-access.tsx
"use client"; import { getJournalProgram, getJournalProgramId, JournalIDL, } from "@journal/anchor"; import { Program } from "@coral-xyz/anchor"; import { useConnection } from "@solana/wallet-adapter-react"; import { Cluster, PublicKey } from "@solana/web3.js"; import { useMutation, useQuery } from "@tanstack/re...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/journal/journal-feature.tsx
"use client"; import { useWallet } from "@solana/wallet-adapter-react"; import { WalletButton } from "../solana/solana-provider"; import { AppHero, ellipsify } from "../ui/ui-layout"; import { ExplorerLink } from "../cluster/cluster-ui"; import { useJournalProgram } from "./journal-data-access"; import { JournalCreate...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/journal/journal-ui.tsx
"use client"; import { Keypair, PublicKey } from "@solana/web3.js"; // import { useMemo } from 'react'; import { ellipsify } from "../ui/ui-layout"; import { ExplorerLink } from "../cluster/cluster-ui"; import { useJournalProgram, useJournalProgramAccount, } from "./journal-data-access"; import { useWallet } from ...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/ui/ui-layout.tsx
'use client'; import { WalletButton } from '../solana/solana-provider'; import * as React from 'react'; import { ReactNode, Suspense, useEffect, useRef } from 'react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { AccountChecker } from '../account/account-ui'; import { Clust...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/cluster/cluster-data-access.tsx
'use client'; import { clusterApiUrl, Connection } from '@solana/web3.js'; import { atom, useAtomValue, useSetAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; import { createContext, ReactNode, useContext } from 'react'; import toast from 'react-hot-toast'; export interface Cluster { name: string...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/cluster/cluster-ui.tsx
'use client'; import { useConnection } from '@solana/wallet-adapter-react'; import { IconTrash } from '@tabler/icons-react'; import { useQuery } from '@tanstack/react-query'; import { ReactNode, useState } from 'react'; import { AppModal } from '../ui/ui-layout'; import { ClusterNetwork, useCluster } from './cluster-d...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/cluster/cluster-feature.tsx
'use client'; import { useState } from 'react'; import { AppHero } from '../ui/ui-layout'; import { ClusterUiModal } from './cluster-ui'; import { ClusterUiTable } from './cluster-ui'; export default function ClusterFeature() { const [showModal, setShowModal] = useState(false); return ( <div> <AppHero ...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/solana/solana-provider.tsx
'use client'; import dynamic from 'next/dynamic'; import { AnchorProvider } from '@coral-xyz/anchor'; import { WalletError } from '@solana/wallet-adapter-base'; import { AnchorWallet, useConnection, useWallet, ConnectionProvider, WalletProvider, } from '@solana/wallet-adapter-react'; import { WalletModalProv...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/dashboard/dashboard-feature.tsx
'use client'; import { AppHero } from '../ui/ui-layout'; const links: { label: string; href: string }[] = [ { label: 'Solana Docs', href: 'https://docs.solana.com/' }, { label: 'Solana Faucet', href: 'https://faucet.solana.com/' }, { label: 'Solana Cookbook', href: 'https://solanacookbook.com/' }, { label: 'S...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/account/account-data-access.tsx
'use client'; import { useConnection, useWallet } from '@solana/wallet-adapter-react'; import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'; import { Connection, LAMPORTS_PER_SOL, PublicKey, SystemProgram, TransactionMessage, TransactionSignature, VersionedTransaction, } from '@sol...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/account/account-ui.tsx
'use client'; import { useWallet } from '@solana/wallet-adapter-react'; import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; import { IconRefresh } from '@tabler/icons-react'; import { useQueryClient } from '@tanstack/react-query'; import { useMemo, useState } from 'react'; import { AppModal, ellipsify } fro...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/account/account-detail-feature.tsx
'use client'; import { PublicKey } from '@solana/web3.js'; import { useMemo } from 'react'; import { useParams } from 'next/navigation'; import { ExplorerLink } from '../cluster/cluster-ui'; import { AppHero, ellipsify } from '../ui/ui-layout'; import { AccountBalance, AccountButtons, AccountTokens, AccountT...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/web/components/account/account-list-feature.tsx
'use client'; import { useWallet } from '@solana/wallet-adapter-react'; import { WalletButton } from '../solana/solana-provider'; import { redirect } from 'next/navigation'; export default function AccountListFeature() { const { publicKey } = useWallet(); if (publicKey) { return redirect(`/account/${publicK...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/anchor/Cargo.toml
[workspace] members = [ "programs/*" ] resolver = "2" [profile.release] overflow-checks = true lto = "fat" codegen-units = 1 [profile.release.build-override] opt-level = 3 incremental = false codegen-units = 1
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/anchor/project.json
{ "name": "anchor", "$schema": "../node_modules/nx/schemas/project-schema.json", "sourceRoot": "anchor/src", "projectType": "library", "targets": { "build": { "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/anchor", "...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/anchor/.swcrc
{ "jsc": { "target": "es2017", "parser": { "syntax": "typescript", "decorators": true, "dynamicImport": true }, "transform": { "decoratorMetadata": true, "legacyDecorator": true }, "keepClassNames": true, "externalHelpers": true, "loose": true }, "modu...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/anchor/Anchor.toml
[toolchain] [features] seeds = false skip-lint = false [programs.localnet] journal = "94L2mJxVu6ZMmHaGsCHRQ65Kk2mea6aTnwWjSdfSsmBC" [registry] url = "https://api.apr.dev" [provider] cluster = "Localnet" wallet = "/Users/brimigs/.config/solana/id.json" [scripts] test = "../node_modules/.bin/nx run anchor:jest" [te...
0
solana_public_repos/developer-bootcamp-2024/project-4-crud-app
solana_public_repos/developer-bootcamp-2024/project-4-crud-app/anchor/package.json
{ "name": "@journal/anchor", "version": "0.0.1", "dependencies": { "@coral-xyz/anchor": "^0.30.1", "@solana/web3.js": "1.90.0" }, "type": "commonjs", "main": "./index.cjs", "module": "./index.js" }
0