repo_id stringclasses 563
values | file_path stringlengths 40 166 | content stringlengths 1 2.94M | __index_level_0__ int64 0 0 |
|---|---|---|---|
solana_public_repos/solana-playground/solana-playground/client/src/components | solana_public_repos/solana-playground/solana-playground/client/src/components/Tag/Tag.tsx | import { FC, useMemo } from "react";
import styled, { css } from "styled-components";
import Img from "../Img";
import LangIcon from "../LangIcon";
import {
OrString,
PgFramework,
PgLanguage,
TutorialCategory,
TutorialDetailKey,
TutorialLevel,
} from "../../utils/pg";
import { useDifferentBackground } from... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components | solana_public_repos/solana-playground/solana-playground/client/src/components/Tag/index.ts | export { default } from "./Tag";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Editor.tsx | import { useEffect, lazy, Suspense, useState } from "react";
import styled, { css } from "styled-components";
import { SpinnerWithBg } from "../Loading";
import { Id } from "../../constants";
import { PgCommon, PgExplorer, PgTheme } from "../../utils/pg";
const Home = lazy(() => import("./Home"));
const Monaco = lazy... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/index.ts | export { Editor } from "./Editor";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Home/resources.ts | export interface ResourceProps {
title: string;
text: string;
url: string;
src: string;
circleImage?: boolean;
}
const ROOT_DIR = "/icons/platforms/";
export const RESOURCES: ResourceProps[] = [
{
title: "Cookbook",
text: "Detailed explanations and guides for building applications on Solana.",
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Home/Home.tsx | import { FC, useEffect, useState } from "react";
import styled, { css } from "styled-components";
import Button from "../../Button";
import Img from "../../Img";
import Link from "../../Link";
import { ResourceProps, RESOURCES } from "./resources";
import { TutorialProps, TUTORIALS } from "./tutorials";
import { Exter... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Home/index.ts | export { default } from "./Home";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Home/tutorials.ts | export interface TutorialProps {
title: string;
url: string;
}
export const TUTORIALS: TutorialProps[] = [
{
title: "Build a Blog DApp using Solana Playground",
url: "https://www.youtube.com/watch?v=PWvbMWyuYNQ",
},
{
title: "Build a Todo DApp using Solana Playground",
url: "https://www.youtu... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/CodeMirror.tsx | import { useEffect, useMemo, useRef, useState } from "react";
import styled, { css, useTheme } from "styled-components";
import { EditorView } from "@codemirror/view";
import { Compartment, EditorState } from "@codemirror/state";
import { autosave, defaultExtensions, getThemeExtension } from "./extensions";
import { E... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/index.ts | export { default } from "./CodeMirror";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/extensions.ts | import {
keymap,
highlightSpecialChars,
drawSelection,
highlightActiveLine,
dropCursor,
rectangularSelection,
crosshairCursor,
lineNumbers,
highlightActiveLineGutter,
scrollPastEnd,
} from "@codemirror/view";
import { Extension, EditorState } from "@codemirror/state";
import {
indentOnInput,
bra... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/index.ts | export { autosave } from "./autosave";
export { getThemeExtension } from "./theme";
export * from "./extensions";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/snippets/rust.ts | /* eslint-disable no-template-curly-in-string */
import {
Completion,
snippetCompletion as snip,
} from "@codemirror/autocomplete";
/** Rust language snippets */
export const RUST_SNIPPETS: Completion[] = [
snip("struct ${1:MyStruct} {\n\t${2}\n}", {
label: "create struct(cst)",
type: "class",
info: ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/snippets/python.ts | /* eslint-disable no-template-curly-in-string */
import {
Completion,
snippetCompletion as snip,
} from "@codemirror/autocomplete";
/** Python language snippets */
export const PYTHON_SNIPPETS: Completion[] = [];
/** Seahorse specific snippets */
export const SEAHORSE_SNIPPETS: Completion[] = [
snip("from seaho... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/languages/rust.ts | import { rustLanguage } from "@codemirror/lang-rust";
import {
ifNotIn,
completeFromList,
Completion,
} from "@codemirror/autocomplete";
import { indentUnit, LanguageSupport } from "@codemirror/language";
import {
ANCHOR_SNIPPETS,
COMMON_SNIPPETS,
NATIVE_SNIPPETS,
RUST_SNIPPETS,
} from "../snippets/rust"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/languages/javascript.ts | import { javascript } from "@codemirror/lang-javascript";
export const javascriptExtensions = (isTypescript: boolean) => {
return [javascript({ typescript: isTypescript })];
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/languages/python.ts | import { pythonLanguage } from "@codemirror/lang-python";
import {
ifNotIn,
completeFromList,
Completion,
} from "@codemirror/autocomplete";
import { LanguageSupport } from "@codemirror/language";
import { PYTHON_SNIPPETS, SEAHORSE_SNIPPETS } from "../snippets/python";
export const pythonExtensions = () => {
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/autosave/autosave.ts | import { EditorView, ViewUpdate } from "@codemirror/view";
import { PgExplorer, FullFile } from "../../../../../utils/pg";
export const autosave = (curFile: FullFile, ms: number) => {
let timeoutId: NodeJS.Timeout;
return EditorView.updateListener.of((v: ViewUpdate) => {
// Runs when the editor content chang... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/autosave/index.ts | export * from "./autosave";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/theme/index.ts | export { getThemeExtension } from "./theme";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/CodeMirror/extensions/theme/theme.ts | import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
import { tags as t } from "@lezer/highlight";
import type { Highlight } from "../../../../../utils/pg";
export const getThemeExtension = (h: Highlight) => {
return syntaxHighlighting(
HighlightStyle.define([
{
tag: t.typeNa... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/Monaco.tsx | import { useEffect, useRef, useState } from "react";
import styled, { useTheme } from "styled-components";
import * as monaco from "monaco-editor";
import { initLanguages } from "./languages";
import { SpinnerWithBg } from "../../Loading";
import { EventName } from "../../../constants";
import {
PgCommand,
PgCommo... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/index.ts | export { default } from "./Monaco";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/init.ts | import * as monaco from "monaco-editor";
import {
loadWASM,
createOnigScanner,
createOnigString,
} from "vscode-oniguruma";
import {
INITIAL,
Registry,
parseRawGrammar,
StateStack,
IRawTheme,
} from "vscode-textmate";
import { RequiredKey, PgExplorer, PgCommon } from "../../../../utils/pg";
// Remove ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/common.ts | import * as monaco from "monaco-editor";
import {
Arrayable,
Disposable,
PgCommon,
SyncOrAsync,
} from "../../../../utils/pg";
/**
* Common import implementation based on model and model's content change.
*
* @param update update method
* @param language language(s) to support
* @returns a disposable to ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/index.ts | export { initLanguages } from "./init";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/python/configuration.json | {
"comments": {
"lineComment": "#",
"blockComment": ["\"\"\"", "\"\"\""]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"", ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/init.ts | export const init = async () => {
const { initDeclarations } = await import("./declarations");
return await initDeclarations();
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/configuration.json | {
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
},
"brackets": [
["${", "}"],
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{
"open": "{",
"close": "}"
},
{
"open": "[",
"close": "]"
},
{
"open": "(",
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/declarations.ts | import { declareDisposableTypes } from "./disposable";
import { declareGlobalTypes } from "./global";
import { declareImportableTypes } from "./importable";
import type { Disposable } from "../../../../../../utils/pg";
/**
* Initialize type declarations.
*
* Steps:
* 1. Declare global and importable types
* 2. De... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/disposable.ts | import * as monaco from "monaco-editor";
import type { Idl } from "@coral-xyz/anchor";
import { declareModule } from "./helper";
import {
ClientPackageName,
Disposable,
PgCommon,
PgExplorer,
PgProgramInfo,
PgWallet,
} from "../../../../../../utils/pg";
/**
* Declare types that can change based on outside... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/helper.ts | import * as monaco from "monaco-editor";
import {
ClientPackageName,
Disposable,
PgCommon,
TupleFiles,
} from "../../../../../../utils/pg";
/**
* Some declaration files need to be declared for them to be referenced by other
* declaration files.
*
* @param packageName package name to be referenced in decla... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/importable.ts | import { declarePackage } from "./helper";
import { importTypes } from "../../common";
import type { ClientPackageName, Disposable } from "../../../../../../utils/pg";
/**
* Declare importable types in the editor and update them based on file switch
* or the current editor model's content change.
*/
export const de... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/global.ts | import * as monaco from "monaco-editor";
import { declarePackage } from "./helper";
import { Disposable, MergeUnion, PgCommon } from "../../../../../../utils/pg";
/** Global packages */
type GlobalPackages = typeof PACKAGES["global"];
/** Global package name */
type GlobalPackageName = keyof GlobalPackages;
/** ESM... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/index.ts | export { initDeclarations } from "./declarations";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/raw/light-dom.raw.d.ts | /* eslint-disable @typescript-eslint/no-redeclare */
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
interface AbortController {
/** Returns the AbortSignal object associated with this object. */
readonly signal: AbortSignal;
/** Invoking this method will s... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/raw/pg.raw.d.ts | declare module "solana-playground" {
import * as web3 from "@solana/web3.js";
interface DefaultWallet {
/** Public key of the wallet */
publicKey: web3.PublicKey;
/** Sign the transaction with the wallet */
signTransaction<T extends web3.Transaction | web3.VersionedTransaction>(
tx: T
): ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/raw/console.raw.d.ts | declare global {
interface Console {
/**
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
* first used as the primary message and all additional used as substitution
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/typescript/declarations/raw/globals.raw.d.ts | declare global {
/**
* @param ms amount of time to sleep in miliseconds
* @returns a promise that will resolve after specified ms
*/
function sleep(ms?: number): Promise<void>;
}
export {};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust/init.ts | import { initRustAnalyzer } from "./rust-analyzer";
export const init = () => initRustAnalyzer();
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust/configuration.json | {
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"colorizedBracketPairs": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust/rust-analyzer/index.ts | export { initRustAnalyzer } from "./rust-analyzer";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust/rust-analyzer/rust-analyzer.ts | // @ts-nocheck
import * as monaco from "monaco-editor";
import type { WorldState } from "@solana-playground/rust-analyzer";
import { importTypes } from "../../common";
import {
AsyncMethods,
Disposable,
PgCommon,
PgExplorer,
} from "../../../../../../utils/pg";
/** Monaco language id for Rust */
const LANGUAG... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/rust/rust-analyzer/worker.ts | import init, {
initThreadPool,
WorldState,
} from "@solana-playground/rust-analyzer";
(async () => {
await init();
// Thread pool initialization with the given number of threads
// (pass `navigator.hardwareConcurrency` if you want to use all cores)
// https://github.com/GoogleChromeLabs/wasm-bindgen-rayon... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/json/configuration.json | {
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
["[", "]"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string"] },
{ "open": "[", "close": "]", "notIn": ["string"] },
{ "open": "(", "close": ")", "notIn": ["string"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages | solana_public_repos/solana-playground/solana-playground/client/src/components/Editor/Monaco/languages/javascript/configuration.json | {
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
},
"brackets": [
["${", "}"],
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{
"open": "{",
"close": "}"
},
{
"open": "[",
"close": "]"
},
{
"open": "(",
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components | solana_public_repos/solana-playground/solana-playground/client/src/components/UploadArea/index.ts | export { default } from "./UploadArea";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/components | solana_public_repos/solana-playground/solana-playground/client/src/components/UploadArea/UploadArea.tsx | import { FC } from "react";
import styled, { css, DefaultTheme } from "styled-components";
import { DropzoneOptions, DropzoneState, useDropzone } from "react-dropzone";
import Input from "../Input";
import { Checkmark, Upload } from "../Icons";
import { PgCommon, PgTheme } from "../../utils/pg";
interface UploadAreaP... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/theme/fonts.ts | import type { Font } from "../utils/pg";
/** All available fonts */
export const FONTS: Font[] = [
{
family: "JetBrains Mono",
size: {
xsmall: "0.7rem",
small: "0.75rem",
medium: "0.8125rem",
large: "0.875rem",
xlarge: "1rem",
},
},
{
family: "Hack",
size: {
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/theme/index.ts | export { FONTS } from "./fonts";
export { THEMES } from "./themes";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/theme/create.ts | import { PgCommon } from "../utils/pg/common";
import type { ImportableTheme } from "../utils/pg";
/**
* Create themes from the given names.
*
* Theme names are expected to be Title Case and the theme files are expected
* to be kebab-case, e.g. if name is "My Theme", file name should be "my-theme.ts"
*
* @param ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/theme/themes.ts | import { createThemes } from "./create";
/** All available themes */
export const THEMES = createThemes("Dracula", "Solana", "Playground", "Light");
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/theme | solana_public_repos/solana-playground/solana-playground/client/src/theme/themes/dracula.ts | import type { Theme } from "../../utils/pg";
// BG
const BG_DEFAULT = "#282A36",
BG_DARK = "#21222C",
BG_DARKER = "#191A21",
// FG
CYAN = "#8BE9FD",
GREEN = "#50FA7B",
ORANGE = "#FFB86C",
PINK = "#FF79C6",
PURPLE = "#BD93F9",
RED = "#FF5555",
YELLOW = "#F1FA8C",
// TEXT
TEXT_PRIMARY = "#F8F8F2"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/theme | solana_public_repos/solana-playground/solana-playground/client/src/theme/themes/solana.ts | import type { Theme } from "../../utils/pg";
// BG
const BG_BLACK = "#000000",
// BG_WHITE = "#F9F9FB",
BG_GRAY = "#18191E",
// FG
GREEN = "#14F195",
PURPLE = "#9945FF",
BLUE = "#80ECFF",
PINK = "#EB54BC",
ORANGE = "#F85228",
RED = "#DC3545",
YELLOW = "#FFC107",
// TEXT
TEXT_PRIMARY = "#FFFFFF"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/theme | solana_public_repos/solana-playground/solana-playground/client/src/theme/themes/light.ts | import type { Theme } from "../../utils/pg";
// BG
const BG_DARK = "#2c2c2c";
const BG_LIGHT = "#f3f3f3";
const BG_WHITE = "#ffffff";
// FG
const BLUE = "#2979cc";
const PURPLE = "#af22db";
const GUTTER_BLUE = "#257893";
const TYPE_BLUE = "#41b3e8";
const FN_YELLOW = "#e19f41";
const KEYWORDS_BLUE = "#285fff";
const ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/theme | solana_public_repos/solana-playground/solana-playground/client/src/theme/themes/playground.ts | import type { Theme } from "../../utils/pg";
// BG
const BG_DEFAULT = "#151721",
BG_DARK = "#0e1019",
BG_LIGHT = "#212431",
// FG
BLUE = "#5288f2",
DARK_BLUE = "#1a2c4f",
CYAN = "#46c9d7",
RED = "#c63453",
GREEN = "#29cd7d",
YELLOW = "#e7d354",
// TEXT
TEXT_PRIMARY = "#f2f2f7",
TEXT_SECONDARY =... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useProgramInfo.tsx | import { PgProgramInfo } from "../utils/pg";
import { useRenderOnChange } from "./useRenderOnChange";
/** Get the current program info. */
export const useProgramInfo = () => {
useRenderOnChange(PgProgramInfo.onDidChange);
return {
programInfo: PgProgramInfo,
error: !PgProgramInfo.onChain,
deployed: Pg... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useSetStatic.tsx | import { Dispatch, SetStateAction, useEffect } from "react";
export const useSetStatic = (
set: Dispatch<SetStateAction<any>>,
eventName: string
) => {
useEffect(() => {
const handle = (e: UIEvent & { detail: any }) => {
set(e.detail);
};
document.addEventListener(eventName, handle as EventLis... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useWallet.tsx | import { PgWallet } from "../utils/pg";
import { useRenderOnChange } from "./useRenderOnChange";
export const useWallet = () => {
useRenderOnChange(PgWallet.onDidChangeCurrent);
return { wallet: PgWallet.current };
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useBalance.tsx | import { PgWallet } from "../utils/pg";
import { useRenderOnChange } from "./useRenderOnChange";
/** Get globally synced current wallet's balance. */
export const useBalance = () => {
useRenderOnChange(PgWallet.onDidChangeBalance);
return { balance: PgWallet.balance };
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useOnClickOutside.tsx | import { RefObject, useEffect } from "react";
/**
* Run the given callback when the user clicks outside of the given element.
*
* @param ref element reference
* @param cb callback function to run on outside click
* @param listenCondition only listen for click events if this condition is truthy
*/
export const us... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useMounted.tsx | import { useEffect, useRef } from "react";
/**
* Get whether the component is mounted.
*
* @returns whether the component is mounted
*/
export const useMounted = () => {
const mounted = useRef(false);
useEffect(() => {
mounted.current = true;
return () => {
mounted.current = false;
};
});
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useGetAndSetStatic.tsx | import { Dispatch, SetStateAction, useMemo } from "react";
import { PgCommon } from "../utils/pg/common";
import { useGetStatic } from "./useGetStatic";
import { useSetStatic } from "./useSetStatic";
export const useGetAndSetStatic = <T,>(
get: T,
set: Dispatch<SetStateAction<T>>,
eventName: string
) => {
con... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useExposeStatic.tsx | import { useCallback, useMemo } from "react";
import { useSendAndReceiveCustomEvent } from "./useSendAndReceiveCustomEvent";
import { PgCommon } from "../utils/pg/common";
import type { Methods } from "../utils/pg";
/**
* Expose the given class object inside a component to outside, allowing it to
* be used anywhere... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useBlockExplorer.tsx | import { useRenderOnChange } from "./useRenderOnChange";
import { PgBlockExplorer } from "../utils/pg";
/** Get the current block explorer */
export const useBlockExplorer = () => {
useRenderOnChange(PgBlockExplorer.onDidChange);
return PgBlockExplorer.current;
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useCopy.tsx | import useCopyClipboard from "react-use-clipboard";
export const useCopy = (str: string): [boolean, () => void] => {
const [copied, setCopied] = useCopyClipboard(str, {
successDuration: 5000,
});
return [copied, setCopied];
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useDifferentBackground.tsx | import { useEffect, useRef } from "react";
import { useTheme } from "styled-components";
import { PgTheme } from "../utils/pg";
/**
* Use a different background than the parent node's background.
*
* @param delay the amount of miliseconds to delay the background check
*
* @returns the element ref object to attac... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useConnection.tsx | import { PgConnection } from "../utils/pg";
import { useRenderOnChange } from "./useRenderOnChange";
/** Get access to Playnet compatible globally synced `Connection` object. */
export const useConnection = () => {
useRenderOnChange(PgConnection.onDidChangeCurrent);
useRenderOnChange(PgConnection.onDidChangeIsConn... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useSendAndReceiveCustomEvent.tsx | import { DependencyList, useEffect } from "react";
import { PgCommon } from "../utils/pg/common";
export const useSendAndReceiveCustomEvent = <T,>(
eventName: string,
cb: (data: T) => Promise<any>,
deps?: DependencyList
) => {
useEffect(() => {
const eventNames = PgCommon.getSendAndReceiveEventNames(event... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useGetStatic.tsx | import { useSendAndReceiveCustomEvent } from "./useSendAndReceiveCustomEvent";
export const useGetStatic = (get: any, eventName: string) => {
useSendAndReceiveCustomEvent(eventName, () => get);
};
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/index.ts | export { useAsyncEffect } from "./useAsyncEffect";
export { useBalance } from "./useBalance";
export { useBlockExplorer } from "./useBlockExplorer";
export { useConnection } from "./useConnection";
export { useCopy } from "./useCopy";
export { useDifferentBackground } from "./useDifferentBackground";
export { useDispos... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useRenderOnChange.tsx | import { useEffect, useReducer, useState } from "react";
import type { Disposable } from "../utils/pg";
export const useRenderOnChange = <T,>(
onChange: (cb: (v?: T) => any) => Disposable,
defaultValue?: T
) => {
const [value, setValue] = useState(defaultValue);
const [, render] = useReducer((r) => r + 1, 0);... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useFilteredSearch.tsx | import { ChangeEvent } from "react";
import { useLocation, useSearchParams } from "react-router-dom";
import { Arrayable, PgCommon, PgRouter } from "../utils/pg";
type Filterable = { name: string; featured?: boolean } & Record<string, any>;
interface FilterSearchProps<T extends Filterable> {
/** Global route path ... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useDisposable.tsx | import { useAsyncEffect } from "./useAsyncEffect";
import type { Disposable, SyncOrAsync } from "../utils/pg";
/** Run the given callback on mount and dispose it on unmount. */
export const useDisposable = (disposable: () => SyncOrAsync<Disposable>) => {
useAsyncEffect(async () => {
const { dispose } = await dis... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useAsyncEffect.tsx | import { DependencyList, useEffect } from "react";
import type { Fn } from "../utils/pg";
/**
* Async version of the `useEffect` hook.
*
* NOTE: Be careful when using this hook with a callback that subscribes to changes
* (especially nested subscribes) because it could potentially not get cleaned up.
*
* @param... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/hooks/useExplorer.tsx | import { PgExplorer } from "../utils/pg";
import { useRenderOnChange } from "./useRenderOnChange";
/**
* Globally synced explorer.
*
* @param checkInitialization whether to check whether the explorer is initialized
* @returns the global explorer object
*/
export const useExplorer = <C,>(opts?: { checkInitializati... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/block-explorers/solana-explorer.ts | import { Endpoint } from "../constants";
import { PgBlockExplorer, PgConnection } from "../utils/pg";
export const solanaExplorer = PgBlockExplorer.create({
name: "Solana Explorer",
url: "https://explorer.solana.com",
getClusterParam: () => {
switch (PgConnection.cluster) {
case "mainnet-beta":
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/block-explorers/solana-fm.ts | import { Endpoint } from "../constants";
import { PgBlockExplorer, PgConnection } from "../utils/pg";
export const solanaFM = PgBlockExplorer.create({
name: "Solana FM",
url: "https://solana.fm",
getClusterParam: () => {
switch (PgConnection.cluster) {
case "mainnet-beta":
return "";
case... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/block-explorers/solscan.ts | import { PgBlockExplorer, PgConnection } from "../utils/pg";
export const solscan = PgBlockExplorer.create({
name: "Solscan",
url: "https://solscan.io",
getClusterParam: () => {
switch (PgConnection.cluster) {
case "mainnet-beta":
return "";
case "testnet":
return "?cluster=testne... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/block-explorers/index.ts | import * as _BLOCK_EXPLORERS from "./block-explorers";
export const BLOCK_EXPLORERS = Object.values(_BLOCK_EXPLORERS);
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/block-explorers/block-explorers.ts | export * from "./solana-explorer";
export * from "./solana-fm";
export * from "./solscan";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/index.ts | export { TUTORIALS } from "./tutorials";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/create.ts | import { PgCommon, TutorialData, TutorialDataInit } from "../utils/pg";
/** Create tutorials with defaults. */
export const createTutorials = (...tutorials: TutorialDataInit[]) => {
return tutorials.map((tutorial) => {
if (tutorial.categories && tutorial.categories.length > 3) {
throw new Error(
[
... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/tutorials.ts | import { createTutorials } from "./create";
/** All visible tutorials at `/tutorials`(in order) */
export const TUTORIALS = createTutorials(
{
name: "Hello Solana",
description: "Hello world program with Native Solana/Rust.",
authors: [
{
name: "acheron",
link: "https://twitter.com/... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/CounterEasy/CounterEasy.tsx | import { Tutorial } from "../../components/Tutorial";
const CounterEasy = () => (
<Tutorial
// About section that will be shown under the description of the tutorial page
about={require("./about.md")}
// Actual tutorial pages to show next to the editor
pages={[
{ content: require("./pages/1.md"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/CounterEasy/index.ts | export { default } from "./CounterEasy";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/CounterEasy | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/CounterEasy/files/lib.rs | use anchor_lang::prelude::*;
declare_id!("");
#[program]
// Smart contract functions
pub mod counter {
use super::*;
pub fn create_counter(ctx: Context<CreateCounter>) -> Result<()> {
msg!("Creating a Counter!!");
// The creation of the counter must be here
msg!("Current cou... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/CounterEasy | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/CounterEasy/files/anchor.test.ts.raw | describe("counter", () => {
// Configure the client to use the local cluster.
const systemProgram = anchor.web3.SystemProgram;
it("Create Counter!", async () => {
// Keypair = account
const [counter, _counterBump] =
await anchor.web3.PublicKey.findProgramAddress(
[pg.wallet.publicKey.toByt... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BattleCoins/BattleCoins.tsx | import { Tutorial } from "../../components/Tutorial";
const BattleCoins = () => (
<Tutorial
// About section that will be shown under the description of the tutorial page
about={require("./about.md")}
// Actual tutorial pages to show next to the editor
pages={[
{ content: require("./pages/1.md"... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BattleCoins/index.ts | export { default } from "./BattleCoins";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BattleCoins | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BattleCoins/files/client.ts.raw | import { Metaplex } from "@metaplex-foundation/js";
import { getMint, getAssociatedTokenAddressSync } from "@solana/spl-token";
// metaplex token metadata program ID
const TOKEN_METADATA_PROGRAM_ID = new web3.PublicKey(
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
);
// metaplex setup
const metaplex = Metaplex.mak... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BattleCoins | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BattleCoins/files/lib.rs | use anchor_lang::prelude::*;
use anchor_spl::{
associated_token::AssociatedToken,
metadata::{
create_metadata_accounts_v3,
mpl_token_metadata::{accounts::Metadata as MetadataAccount, types::DataV2},
CreateMetadataAccountsV3, Metadata,
},
token::{burn, mint_to, Burn, Mint, MintTo,... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BankSimulator/BankSimulator.tsx | import { Tutorial } from "../../components/Tutorial";
const ExpenseTracker = () => (
<Tutorial
// About section that will be shown under the description of the tutorial page
about={require("./about.md")}
// Actual tutorial pages to show next to the editor
pages={[
{ content: require("./pages/1.... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BankSimulator/index.ts | export { default } from "./BankSimulator";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BankSimulator | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BankSimulator/files/lib.rs | use anchor_lang::prelude::*;
use anchor_lang::solana_program::{instruction::Instruction};
use anchor_lang::InstructionData;
use clockwork_sdk::state::{Thread, ThreadAccount};
// Your program Id will be added here when you enter "build" command
declare_id!("");
// Calculating interest per minute instead of anually for... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BankSimulator | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/BankSimulator/files/index.test.ts.raw | import { ClockworkProvider } from "@clockwork-xyz/sdk";
describe("Bank Simulator", async () => {
const threadId = "bank_account-1";
const holderName = "test";
const balance = 10.0;
const clockworkProvider = ClockworkProvider.fromAnchorProvider(
pg.program.provider
);
const [bankAccount] = anchor.web3... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/SplTokenVault/SplTokenVault.tsx | import { Tutorial } from "../../components/Tutorial";
const SplTokenVault = () => (
<Tutorial
// About section that will be shown under the description of the tutorial page
about={require("./about.md")}
// Actual tutorial pages to show next to the editor
pages={[
{ content: require("./pages/1.m... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/SplTokenVault/index.ts | export { default } from "./SplTokenVault";
| 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/SplTokenVault | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/SplTokenVault/files/client.ts.raw | import {
getAccount,
getOrCreateAssociatedTokenAccount,
} from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { keypairIdentity, token, Metaplex } from "@metaplex-foundation/js";
const mintAuthority = pg.wallet.keypair;
const decimals = 9;
let [tokenAccountOwnerPda] = PublicKey.findProg... | 0 |
solana_public_repos/solana-playground/solana-playground/client/src/tutorials/SplTokenVault | solana_public_repos/solana-playground/solana-playground/client/src/tutorials/SplTokenVault/files/lib.rs | use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token, TokenAccount};
// This is your program's public key and it will update
// automatically when you build the project.
declare_id!("HCLBrPG3A9agLsVE3j1BCBRUfv9jc1juk5Wt888ZDDsV");
#[program]
mod token_vault {
use super::*;
pub fn initialize(_ctx: ... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.