39 | {user ? (
40 |
Signed in as {user.address}
41 | ) : (
42 |
43 | )}
44 |
45 | )
46 | }
47 | ```
48 |
--------------------------------------------------------------------------------
/packages/solana-client/src/client/error-codes.ts:
--------------------------------------------------------------------------------
1 | export enum SolanaRpcError {
2 | // https://github.com/solana-labs/solana/blob/3114c199bde434b47f255bb6fdd6492836fd9a45/client/src/rpc_custom_error.rs#L10-L24
3 | SERVER_ERROR_BLOCK_CLEANED_UP = -32001,
4 | SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE = -32002,
5 | SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE = -32003,
6 | SERVER_ERROR_BLOCK_NOT_AVAILABLE = -32004,
7 | SERVER_ERROR_NODE_UNHEALTHY = -32005,
8 | SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE = -32006,
9 | SERVER_ERROR_SLOT_SKIPPED = -32007,
10 | SERVER_ERROR_NO_SNAPSHOT = -32008,
11 | SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED = -32009,
12 | SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX = -32010,
13 | SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE = -32011,
14 | SCAN_ERROR = -32012,
15 | SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH = -32013,
16 | SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET = -32014,
17 | SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION = -32015,
18 |
19 | INVALID_PARAM = -32602,
20 | }
21 |
--------------------------------------------------------------------------------
/packages/solana-client/src/transaction/TransactionInterface.ts:
--------------------------------------------------------------------------------
1 | import { Buffer } from "buffer";
2 | import { Base58, Base64, Hex, Solana } from "../base-types";
3 | import { GKeypair } from "../GKeypair";
4 |
5 | export interface TransactionInterface {
6 | sign: (args: { signers: GKeypair[] }) => TransactionInterface;
7 | toBuffer: () => Buffer;
8 | toHex: () => Hex;
9 | toBase64: () => Base64;
10 |
11 | addresses: Solana.Address[];
12 | instructions: TransactionInstruction[];
13 | accounts: TransactionAccount[];
14 | signature: Solana.Signature;
15 | feePayer: Solana.Address;
16 | latestBlockhash: string;
17 |
18 | numRequiredSigs: number;
19 | }
20 |
21 | export type TransactionInstruction = {
22 | accounts: Solana.Address[];
23 | program: Solana.Address;
24 | data_base64: Base64;
25 | };
26 |
27 | export type TransactionAccount = {
28 | address: Solana.Address;
29 | signer: boolean;
30 | writable: boolean;
31 | wasLookedUp: boolean;
32 | };
33 |
34 | export type SignatureInfo = {
35 | signature: Base58;
36 | address: Solana.Address;
37 | };
38 |
--------------------------------------------------------------------------------
/packages/glow-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@glow-xyz/glow-react",
3 | "version": "1.1.0",
4 | "main": "dist/index.js",
5 | "module": "dist/index.cjs.js",
6 | "typings": "dist/index.d.ts",
7 | "files": [
8 | "dist/**/*",
9 | "src/**/*"
10 | ],
11 | "sideEffects": false,
12 | "scripts": {
13 | "build": "npm run build:js && npm run build:css",
14 | "build:js": "tsc",
15 | "build:css": "sass src/styles/index.scss:dist/styles.css",
16 | "release": "pnpm build && release-it"
17 | },
18 | "dependencies": {
19 | "@glow-xyz/glow-client": "^1.5.0",
20 | "@glow-xyz/solana-client": "^1.8.0",
21 | "classnames": "2.3.2"
22 | },
23 | "devDependencies": {
24 | "@solana/web3.js": "1.95.4",
25 | "@types/react": "18.3.12",
26 | "@types/react-dom": "18.3.1",
27 | "esbuild": "0.15.17",
28 | "esbuild-register": "3.4.1",
29 | "prettier": "2.8.0",
30 | "sass": "1.56.1"
31 | },
32 | "peerDependencies": {
33 | "react": "^17.0.0 || ^18.0.0",
34 | "react-dom": "^17.0.0 || ^18.0.0"
35 | },
36 | "private": false
37 | }
38 |
--------------------------------------------------------------------------------
/packages/glow-react/src/hooks/usePolling.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useRef } from "react";
2 | import { useOnMount } from "./useOnMount";
3 |
4 | // From here https://overreacted.io/making-setinterval-declarative-with-react-hooks/
5 | // If intervalMs is null, then we will not run the loop
6 | export const usePolling = (
7 | callback: () => void,
8 | intervalMs: number | null,
9 | { runOnMount }: { runOnMount: boolean } = { runOnMount: false }
10 | ) => {
11 | const savedCallback = useRef<() => void>(() => null);
12 |
13 | // Remember the latest callback.
14 | useEffect(() => {
15 | savedCallback.current = callback;
16 | }, [callback]);
17 |
18 | useOnMount(() => {
19 | if (runOnMount) {
20 | callback();
21 | }
22 | });
23 |
24 | // Set up the interval.
25 | useEffect(() => {
26 | function tick() {
27 | savedCallback.current();
28 | }
29 |
30 | if (intervalMs != null) {
31 | const id = setInterval(tick, intervalMs);
32 | return () => clearInterval(id);
33 | }
34 |
35 | return undefined;
36 | }, [intervalMs]);
37 | };
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Glow JS
2 |
3 | This is a set of packages that helps you integrate the [Glow Solana Wallet](https://glow.app) into your dApp. 🤩
4 |
5 | ## Video Overview
6 |
7 | [](https://www.loom.com/share/837a218eca284292a5c69d719564ed9d)
8 |
9 | ## Packages
10 |
11 | Here is a set of packages that you can use to integrate Glow onto your dApp:
12 |
13 | - `@glow-xyz/glow-client` - this gives you a `GlowClient` instance which interacts with the Glow Chrome Extension
14 | - `@glow-xyz/glow-react` - this gives you a React Context provider `