Skip to content

Commit

Permalink
🐛 Fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Feb 1, 2024
1 parent 5046aee commit e0ae239
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
- name: Build packages
run: yarn lerna run build

- name: Generate TypeDoc for @gumhq/sdk
run: yarn workspace @gumhq/sdk run build:docs
- name: Generate TypeDoc for @magicblock-labs/gum-sdk
run: yarn workspace @magicblock-labs/gum-sdk run build:docs

- name: Generate TypeDoc for @gumhq/react-sdk
run: yarn workspace @gumhq/react-sdk run build:docs
Expand Down
8 changes: 4 additions & 4 deletions packages/gpl-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

### Features

- **@gumhq/sdk:** add getOrCreate() method for user and profile ([adb574f](https://github.com/gumhq/sdk/commit/adb574f368381b7a4a11482b21245498f74a9576))
- **@gumhq/sdk:** add getPostsByNamespace and getPostsByFollowedUsers functions ([c7a2a26](https://github.com/gumhq/sdk/commit/c7a2a26ac965d2368996cdd8b9f81aec5fdc1d6c))
- **@magicblock-labs/gum-sdk:** add getOrCreate() method for user and profile ([adb574f](https://github.com/gumhq/sdk/commit/adb574f368381b7a4a11482b21245498f74a9576))
- **@magicblock-labs/gum-sdk:** add getPostsByNamespace and getPostsByFollowedUsers functions ([c7a2a26](https://github.com/gumhq/sdk/commit/c7a2a26ac965d2368996cdd8b9f81aec5fdc1d6c))

## [1.0.10-alpha.0](https://github.com/gumhq/sdk/compare/@gumhq/sdk@1.0.9...@gumhq/sdk@1.0.10-alpha.0) (2023-02-17)
## [1.0.10-alpha.0](https://github.com/gumhq/sdk/compare/@magicblock-labs/gum-sdk@1.0.9...@magicblock-labs/gum-sdk@1.0.10-alpha.0) (2023-02-17)

**Note:** Version bump only for package @gumhq/sdk
**Note:** Version bump only for package @magicblock-labs/gum-sdk
2 changes: 1 addition & 1 deletion packages/gpl-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magicblock-labs/gum-sdk",
"version": "3.0.4",
"version": "3.0.5",
"main": "lib/index.js",
"license": "GPL-3.0",
"description": "Gum Protocol SDK",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

### Features

- **@gumhq/react-sdk:** feat(deps): bump up @gumhq/sdk to 1.0.13
- **@gumhq/react-sdk:** feat(deps): bump up @magicblock-labs/gum-sdk to 1.0.13

## [1.0.8](https://github.com/gumhq/sdk/compare/v1.0.10...v1.0.8) (2023-03-01)

Expand Down
77 changes: 6 additions & 71 deletions packages/react-sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,28 @@
# Gum React SDK

<p align="center">
<img alt="npm" src="https://img.shields.io/npm/v/@gumhq/react-sdk?color=%23d45bff">
<img alt="npm" src="https://img.shields.io/npm/dt/@gumhq/react-sdk?color=%23d45bff">
<img alt="npm" src="https://img.shields.io/npm/v/@magicblock-labs/gum-react-sdk?color=%23d45bff">
<img alt="npm" src="https://img.shields.io/npm/dt/@magicblock-labs/gum-react-sdk?color=%23d45bff">
</p>

## Installation

```bash
yarn add @gumhq/react-sdk
yarn add @magicblock-labs/gum-react-sdk
```

## Documentation

For more detailed documentation, please visit the [Magicblock documentation](https://docs.gum.fun/).

## Usage

The `useGumContext`, `useCreateProfile`, and `useUploaderContext` hooks provide the necessary utilities to create a new profile.

```tsx
import {
useCreateProfile,
useGumContext,
useUploaderContext,
} from "@gumhq/react-sdk";
import { useWallet } from "@solana/wallet-adapter-react";
import { useState } from "react";

export function ProfileCreation() {
const [profileName, setProfileName] = useState("");
const [profileBio, setProfileBio] = useState("");
const [profileUsername, setProfileUsername] = useState("");
const [profileAvatar, setProfileAvatar] = useState("");

const wallet = useWallet();
const { publicKey } = wallet;
const { sdk } = useGumContext(); // access the Gum SDK
const { createProfileWithDomain } = useCreateProfile(sdk); // create a new profile
const { handleUpload } = useUploaderContext(); // upload metadata to Arweave/GenesysGo

const createProfile = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();

const profileMetadata = {
name: profileName,
bio: profileBio,
avatar: profileAvatar,
};

const uploadResponse = await handleUpload(profileMetadata, wallet);
if (!uploadResponse) {
console.error("Error uploading profile metadata");
return false;
}

const profileResponse = await createProfileWithDomain(
uploadResponse.url,
profileUsername,
publicKey
);
if (!profileResponse) {
console.error("Error creating profile");
return false;
}

console.log("Profile created successfully", profileResponse);
};

// Your HTML form and fields would go here
}
```

## Gum Quickstart

The Gum Quickstart is an excellent starting point for developers aiming to leverage Gum in their Next.js applications. This ready-to-use template not only expedites the setup process, but also includes functional examples and components to facilitate the creation of domain profiles, posts, and more. Check out the [Gum Quickstart](https://github.com/gumhq/gum-quickstart) to get started.
For more detailed documentation, please visit the [Magicblock documentation](https://docs.magicblock.gg/Onboarding/Session%20Keys/integrating-sessions-in-your-program).

## Example App

Check out the [example app](https://github.com/gumhq/gum-example-app) that uses the Gum SDK to demonstrate its capabilities. The app is a simple React app that showcases the creation of a domain, profile, and posts.
Check out the [example app](https://github.com/solana-developers/solana-game-starter-kits/tree/main/lumberjack) that uses the Gum SDK to demonstrate its capabilities. The app is a simple React app that showcases the use of session keys.

## Contributing

We welcome contributions to improve the SDK. Please raise an issue or submit a pull request with any suggestions or bug fixes.

## License

The Gum SDK is licensed under the [GNU General Public License v3.0](https://github.com/gumhq/sdk/blob/master/packages/react-sdk/LICENSE).

## Support

Join our Discord community at [https://discord.gg/tCswbSK5W2](https://discord.gg/tCswbSK5W2) for any questions or support.
Join our Discord community at [https://discord.com/invite/MBkdC3gxcv](https://discord.com/invite/MBkdC3gxcv) for any questions or support.
4 changes: 2 additions & 2 deletions packages/react-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@magicblock-labs/gum-react-sdk",
"version": "3.0.2",
"version": "3.0.5",
"license": "GPL-3.0",
"description": "React SDK for Gum",
"repository": {
Expand All @@ -26,7 +26,7 @@
},
"dependencies": {
"@bundlr-network/client": "^0.10.5",
"@gumhq/sdk": "^3.0.1",
"@magicblock-labs/gum-sdk": "^3.0.5",
"@orca-so/sdk": "^1.2.25",
"@project-serum/anchor": "^0.26.0",
"@shadow-drive/sdk": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/badge/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GATEWAY_SERVICE_URL, SDK } from "@gumhq/sdk";
import { GATEWAY_SERVICE_URL, SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey } from "@solana/web3.js";
import axios from "axios";
Expand Down
6 changes: 3 additions & 3 deletions packages/react-sdk/src/hooks/connection/useFollow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey, Transaction, Connection } from "@solana/web3.js";
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
Expand Down Expand Up @@ -27,7 +27,7 @@ const useFollow = (sdk: SDK) => {
owner,
payer
);

if (ixMethodBuilder) {
return await ixMethodBuilder.rpc();
} else {
Expand Down Expand Up @@ -66,7 +66,7 @@ const useFollow = (sdk: SDK) => {
sessionAccount,
payer
);

if (ixMethodBuilder) {
const tx = await ixMethodBuilder.transaction();
if (tx) {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-sdk/src/hooks/connection/useUnfollow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey, Transaction, Connection } from "@solana/web3.js";
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
Expand Down Expand Up @@ -28,7 +28,7 @@ const useUnfollow = (sdk: SDK) => {
owner,
refundReceiver
);

if (ixMethodBuilder) {
return await ixMethodBuilder.rpc();
} else {
Expand Down Expand Up @@ -68,7 +68,7 @@ const useUnfollow = (sdk: SDK) => {
sessionAccount,
refundReceiver
);

if (ixMethodBuilder) {
const tx = await ixMethodBuilder.transaction();
if (tx) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/nameservice/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey } from "@solana/web3.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/nameservice/useDomains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback } from "react";
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { PublicKey } from "@solana/web3.js";

const useDomains = (sdk: SDK, authority: PublicKey) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/post/useCreatePost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey, Transaction, Connection } from "@solana/web3.js";
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/post/useExploreFeed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useEffect, useCallback } from "react";

const useExploreFeed = (sdk: SDK) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/post/useFeed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useEffect, useCallback } from "react";
import { PublicKey } from "@solana/web3.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/post/usePost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useEffect, useCallback } from "react";
import { PublicKey } from "@solana/web3.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/profile/useCreateProfile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey } from "@solana/web3.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/profile/useProfile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useEffect, useCallback } from "react";
import { PublicKey } from "@solana/web3.js";

Expand Down
8 changes: 4 additions & 4 deletions packages/react-sdk/src/hooks/reaction/useReaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SDK } from "@gumhq/sdk";
import { SDK } from "@magicblock-labs/gum-sdk";
import { useState, useCallback } from "react";
import { PublicKey, Transaction, Connection } from "@solana/web3.js";
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
Expand Down Expand Up @@ -126,7 +126,7 @@ const useReaction = (sdk: SDK, ) => {

try {
const ixMethodBuilder = deleteReactionIxMethodBuilder(reactionAccount, fromProfile, toPostAccount, owner, refundReceiver);

if (ixMethodBuilder) {
return await ixMethodBuilder.rpc();
} else {
Expand Down Expand Up @@ -157,7 +157,7 @@ const useReaction = (sdk: SDK, ) => {

try {
const ixMethodBuilder = deleteReactionWithSessionIxMethodBuilder(reactionAccount, fromProfile, toPostAccount, sessionPublicKey, sessionAccount, refundReceiver);

if (ixMethodBuilder) {
const tx = await ixMethodBuilder.transaction();
if (tx) {
Expand Down Expand Up @@ -213,7 +213,7 @@ const useReaction = (sdk: SDK, ) => {
}, [sdk]);


return {
return {
createReaction,
createReactionWithSession,
createReactionIxMethodBuilder,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-sdk/src/hooks/session/useSessionKeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SendTransactionOptions } from '@solana/wallet-adapter-base';
import { Keypair, PublicKey, Transaction, Cluster, Connection, SystemProgram } from '@solana/web3.js';
import { useEffect, useRef, useState } from 'react';
import { generateEncryptionKey, encrypt, decrypt } from '../../utils/crypto';
import { SessionTokenManager } from '@gumhq/sdk';
import { SessionTokenManager } from '@magicblock-labs/gum-sdk';
import * as nacl from 'tweetnacl';
import { BN } from "@project-serum/anchor";
import { deleteItemFromIndexedDB, getItemFromIndexedDB, setItemToIndexedDB } from 'src/utils/indexedDB';
Expand Down Expand Up @@ -193,7 +193,7 @@ export function useSessionKeyManager(wallet: AnchorWallet, connection: Connectio
const getSessionToken = async (): Promise<string | null> => {
try {
const sessionKey = await getItemFromIndexedDB(WALLET_PUBKEY_TO_SESSION_STORE, wallet.publicKey.toString());

if (!sessionKey) {
resetSessionData();
return null;
Expand Down Expand Up @@ -239,7 +239,7 @@ export function useSessionKeyManager(wallet: AnchorWallet, connection: Connectio
const createSession = async (targetProgramPublicKey: PublicKey, topUp = false, expiryInMinutes = 60, sessionCreatedCallback?: (sessionInfo: { sessionToken: string; publicKey: string; }) => void): Promise<SessionWalletInterface> => {
return withLoading(async () => {
try {

// if expiry is more than 24 hours then throw error
if (expiryInMinutes > 24 * 60) {
throw new Error("Expiry cannot be more than 24 hours.");
Expand Down Expand Up @@ -375,7 +375,7 @@ export function useSessionKeyManager(wallet: AnchorWallet, connection: Connectio
tx.feePayer = sessionTokenPublicKey;
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
const estimatedFee = await tx.getEstimatedFee(connection);

if (estimatedFee && sessionSignerSolanaBalance > estimatedFee) {
const transaction = new Transaction().add(
SystemProgram.transfer({
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/hooks/useGum.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { GraphQLClient } from 'graphql-request';
import { AnchorWallet } from '@solana/wallet-adapter-react';
import { SDK } from '@gumhq/sdk';
import { SDK } from '@magicblock-labs/gum-sdk';
import { Connection, ConfirmOptions, Cluster } from '@solana/web3.js';

const useGum = (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ export {
GPLSESSION_PROGRAMS,
GATEWAY_SERVICE_URL,
GUM_TLD_ACCOUNT,
} from "@gumhq/sdk";
} from "@magicblock-labs/gum-sdk";

export type { SessionWalletInterface } from "./hooks";
2 changes: 1 addition & 1 deletion packages/react-sdk/src/providers/GumContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { createContext, useContext, useMemo, ReactNode } from 'react';
import { SDK } from '@gumhq/sdk';
import { SDK } from '@magicblock-labs/gum-sdk';

interface GumContextValue {
sdk: SDK;
Expand Down

0 comments on commit e0ae239

Please sign in to comment.