├── .changeset ├── README.md ├── config.json ├── nice-baboons-protect.md └── thirty-experts-tell.md ├── .editorconfig ├── .env.example ├── .github ├── actions │ ├── setup │ │ └── action.yml │ └── tests │ │ └── action.yml └── workflows │ ├── pull-request.yml │ ├── snapshot.yml │ ├── trigger-tests.yml │ └── verify.yml ├── .gitignore ├── .npmrc ├── .nvmrc ├── .prettierignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── biome.json ├── examples ├── create-app │ ├── README.md │ ├── index.html │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── custom-fragments │ ├── README.md │ ├── index.html │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── eoa-only │ ├── README.md │ ├── index.html │ ├── package.json │ ├── public │ │ └── lens.svg │ ├── src │ │ ├── App.tsx │ │ ├── ConnectButton.tsx │ │ ├── DisconnectButton.tsx │ │ ├── Web3Providers.tsx │ │ ├── client.ts │ │ ├── config.ts │ │ ├── main.tsx │ │ └── vite-env.d.ts │ ├── tsconfig.json │ └── vite.config.ts ├── nextjs-client │ ├── .gitignore │ ├── .stackblitzrc │ ├── README.md │ ├── next.config.ts │ ├── package.json │ ├── src │ │ └── app │ │ │ ├── client.ts │ │ │ ├── favicon.ico │ │ │ ├── globals.css │ │ │ ├── layout.tsx │ │ │ └── page.tsx │ └── tsconfig.json ├── on-ramp │ ├── README.md │ ├── index.html │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── react-login │ ├── README.md │ ├── index.html │ ├── package.json │ ├── public │ │ └── lens.svg │ ├── src │ │ ├── App.tsx │ │ ├── LoginForm.tsx │ │ ├── LogoutButton.tsx │ │ ├── MyAccount.tsx │ │ ├── Web3Providers.tsx │ │ ├── client.ts │ │ ├── config.ts │ │ ├── main.tsx │ │ └── vite-env.d.ts │ ├── tsconfig.json │ └── vite.config.ts ├── react-post │ ├── README.md │ ├── index.html │ ├── package.json │ ├── public │ │ └── lens.svg │ ├── src │ │ ├── App.tsx │ │ ├── client.ts │ │ ├── config.ts │ │ ├── main.tsx │ │ ├── vite-env.d.ts │ │ └── wallet.ts │ ├── tsconfig.json │ └── vite.config.ts ├── sponsored-tx-poc │ ├── README.md │ ├── index.html │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── sponsored-tx │ ├── .stackblitzrc │ ├── README.md │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── thirdweb-onramp │ ├── README.md │ ├── index.html │ ├── package.json │ ├── public │ │ └── lens.svg │ ├── src │ │ ├── App.tsx │ │ └── main.tsx │ ├── tsconfig.json │ └── vite.config.ts └── user-onboarding │ ├── README.md │ ├── index.html │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── jest-extended.d.ts ├── package.json ├── packages ├── client │ ├── README.md │ ├── package.json │ ├── src │ │ ├── AuthenticatedUser.ts │ │ ├── actions │ │ │ ├── account.integration.test.ts │ │ │ ├── account.ts │ │ │ ├── accountManager.integration.test.ts │ │ │ ├── accountManager.ts │ │ │ ├── actions.ts │ │ │ ├── admins.ts │ │ │ ├── app.ts │ │ │ ├── authentication.ts │ │ │ ├── feed.ts │ │ │ ├── follow.ts │ │ │ ├── frames.ts │ │ │ ├── funds.e2e.test.ts │ │ │ ├── funds.ts │ │ │ ├── graph.ts │ │ │ ├── group.ts │ │ │ ├── helpers.ts │ │ │ ├── index.ts │ │ │ ├── metadata.integration.test.ts │ │ │ ├── metadata.ts │ │ │ ├── misc.ts │ │ │ ├── ml.integration.test.ts │ │ │ ├── ml.ts │ │ │ ├── namespace.ts │ │ │ ├── notifications.integration.test.ts │ │ │ ├── notifications.ts │ │ │ ├── onboarding.e2e.test.ts │ │ │ ├── post.integration.test.ts │ │ │ ├── post.ts │ │ │ ├── posts.integration.test.ts │ │ │ ├── posts.ts │ │ │ ├── sns.ts │ │ │ ├── sponsorship.ts │ │ │ ├── timeline.ts │ │ │ ├── tipping.e2e.test.ts │ │ │ ├── transactions.ts │ │ │ ├── transfer.ts │ │ │ └── username.ts │ │ ├── authorization.ts │ │ ├── batch.ts │ │ ├── clients.integration.test.ts │ │ ├── clients.ts │ │ ├── config.ts │ │ ├── context.ts │ │ ├── crossRegion.e2e.test.ts │ │ ├── errors.ts │ │ ├── ethers │ │ │ ├── index.ts │ │ │ ├── signer.integration.test.ts │ │ │ ├── signer.ts │ │ │ ├── sponsorship.integration.test.ts │ │ │ └── sponsorship.ts │ │ ├── fragments.ts │ │ ├── fragments.unit.test.ts │ │ ├── index.ts │ │ ├── logger.ts │ │ ├── sponsorship.ts │ │ ├── test-utils.ts │ │ ├── tokens.ts │ │ ├── types.ts │ │ ├── utils.ts │ │ └── viem │ │ │ ├── authorization.test.ts │ │ │ ├── authorization.ts │ │ │ ├── index.ts │ │ │ ├── signer.test.ts │ │ │ ├── signer.ts │ │ │ ├── sponsorship.test.ts │ │ │ ├── sponsorship.ts │ │ │ └── types.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tsup.config.ts ├── env │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tsup.config.ts ├── graphql │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── schema.graphql │ ├── src │ │ ├── accounts │ │ │ ├── account.ts │ │ │ ├── index.ts │ │ │ ├── managers.ts │ │ │ └── signless.ts │ │ ├── actions.ts │ │ ├── admins.ts │ │ ├── app.ts │ │ ├── authentication.ts │ │ ├── common.ts │ │ ├── enums.ts │ │ ├── feed.ts │ │ ├── follow.ts │ │ ├── fragments │ │ │ ├── account.ts │ │ │ ├── common.ts │ │ │ ├── index.ts │ │ │ ├── media.ts │ │ │ ├── metadata.ts │ │ │ ├── pagination.ts │ │ │ ├── post.ts │ │ │ ├── primitives.ts │ │ │ ├── transactions.ts │ │ │ └── username.ts │ │ ├── frames.ts │ │ ├── funds.ts │ │ ├── graph.ts │ │ ├── graphql-env.d.ts │ │ ├── graphql.ts │ │ ├── group.ts │ │ ├── index.ts │ │ ├── metadata.ts │ │ ├── misc.ts │ │ ├── ml.ts │ │ ├── namespace.ts │ │ ├── notifications.ts │ │ ├── post.ts │ │ ├── refinements.ts │ │ ├── scalars.ts │ │ ├── schema.d.ts │ │ ├── sns.ts │ │ ├── sponsorship.ts │ │ ├── test-utils.ts │ │ ├── timeline.ts │ │ ├── transactions.ts │ │ ├── transferOwnership.ts │ │ └── username.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tsup.config.ts ├── react │ ├── README.md │ ├── package.json │ ├── src │ │ ├── LensProvider.tsx │ │ ├── account │ │ │ ├── index.ts │ │ │ ├── useAccount.ts │ │ │ ├── useAccountManagers.ts │ │ │ ├── useAccounts.ts │ │ │ ├── useAccountsBlocked.ts │ │ │ └── useAccountsBulk.ts │ │ ├── authentication │ │ │ ├── index.ts │ │ │ ├── useAccountsAvailable.ts │ │ │ ├── useAuthenticatedUser.integration.test.ts │ │ │ ├── useAuthenticatedUser.ts │ │ │ ├── useImpersonation.ts │ │ │ ├── useLogin.integration.test.ts │ │ │ ├── useLogin.ts │ │ │ ├── useLogout.ts │ │ │ ├── usePublicClient.ts │ │ │ ├── useSessionClient.integration.test.ts │ │ │ ├── useSessionClient.ts │ │ │ └── useSwitchAccount.ts │ │ ├── context.tsx │ │ ├── ethers.ts │ │ ├── feed │ │ │ ├── index.ts │ │ │ └── useFeed.ts │ │ ├── follow │ │ │ ├── index.ts │ │ │ ├── useFollowers.ts │ │ │ ├── useFollowersYouKnow.ts │ │ │ └── useFollowing.ts │ │ ├── graph │ │ │ ├── index.ts │ │ │ └── useGraph.ts │ │ ├── group │ │ │ ├── index.ts │ │ │ ├── useGroup.ts │ │ │ ├── useGroupMembers.ts │ │ │ └── useGroups.ts │ │ ├── helpers │ │ │ ├── index.ts │ │ │ ├── reads.ts │ │ │ ├── results.ts │ │ │ ├── tasks.integration.test.ts │ │ │ └── tasks.ts │ │ ├── index.ts │ │ ├── notification │ │ │ ├── index.ts │ │ │ └── useNotifications.ts │ │ ├── post │ │ │ ├── index.ts │ │ │ ├── useCreatePost.integration.test.ts │ │ │ ├── useCreatePost.ts │ │ │ ├── usePost.ts │ │ │ ├── usePostBookmarks.ts │ │ │ ├── usePostReactions.ts │ │ │ ├── usePostReferences.ts │ │ │ └── usePosts.ts │ │ ├── test-utils.tsx │ │ ├── timeline │ │ │ ├── index.ts │ │ │ ├── useTimeline.ts │ │ │ └── useTimelineHighlights.ts │ │ ├── username │ │ │ ├── index.ts │ │ │ ├── useNamespace.ts │ │ │ └── useUsernames.ts │ │ └── viem.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsup.config.ts │ └── vitest.setup.ts ├── storage │ ├── README.md │ ├── package.json │ ├── src │ │ ├── BaseStorageSchema.ts │ │ ├── CredentialsStorageSchema.ts │ │ ├── IStorage.ts │ │ ├── InMemoryStorageProvider.ts │ │ ├── Storage.test.ts │ │ ├── Storage.ts │ │ ├── __helpers__ │ │ │ └── mocks.ts │ │ └── index.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tsup.config.ts └── types │ ├── README.md │ ├── package.json │ ├── src │ ├── errors.ts │ ├── helpers │ │ ├── Deferred.ts │ │ ├── assertions.ts │ │ ├── fail.ts │ │ ├── identity.ts │ │ ├── index.ts │ │ ├── invariant.ts │ │ ├── never.ts │ │ ├── refinements.ts │ │ └── typeguards.ts │ ├── hex.ts │ ├── id.ts │ ├── index.ts │ ├── jwt.ts │ ├── misc.ts │ ├── number.ts │ ├── tag.ts │ └── uri.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tsup.config.ts ├── plopfile.ts ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── renovate.json ├── templates ├── example-react │ ├── README.md │ ├── index.html │ ├── package.json │ ├── public │ │ └── lens.svg │ ├── src │ │ ├── App.tsx │ │ ├── client.ts │ │ ├── main.tsx │ │ └── vite-env.d.ts │ ├── tsconfig.json │ └── vite.config.ts └── lib │ ├── README.md.hbs │ ├── package.json.hbs │ ├── src │ └── index.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ └── tsup.config.ts ├── tsconfig.base.json ├── tsconfig.json ├── turbo.json ├── vite-env.d.ts ├── vitest.config.ts ├── vitest.d.ts └── vitest.setup.ts /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.4/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [["@lens-protocol/client", "@lens-protocol/react"]], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "next", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /.changeset/nice-baboons-protect.md: -------------------------------------------------------------------------------- 1 | --- 2 | "@lens-protocol/client": major 3 | "@lens-protocol/react": major 4 | "@lens-protocol/storage": major 5 | "@lens-protocol/env": minor 6 | "@lens-protocol/graphql": minor 7 | "@lens-protocol/types": minor 8 | --- 9 | 10 | **chore**: first changeset 11 | -------------------------------------------------------------------------------- /.changeset/thirty-experts-tell.md: -------------------------------------------------------------------------------- 1 | --- 2 | "@lens-protocol/client": patch 3 | --- 4 | 5 | Fix incorrect destructuring of sponsored transactions `customData` in ethers client 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | insert_final_newline = true 6 | end_of_line = lf 7 | indent_style = space 8 | indent_size = 2 9 | max_line_length = 100 10 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | PRIVATE_KEY= 2 | TEST_ACCOUNT= 3 | TEST_APP=0x6F6AC764c218C57a509De5E05013EEdA8c9264E0 4 | TEST_ERC20=0xeee5a340Cdc9c179Db25dea45AcfD5FE8d4d3eB8 5 | ENVIRONMENT=local 6 | GLOBAL_SPONSORSHIP= 7 | SPONSORSHIP_APPROVER_PRIVATE_KEY= 8 | -------------------------------------------------------------------------------- /.github/actions/setup/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup' 2 | description: 'Setup repo and install dependencies' 3 | 4 | runs: 5 | using: 'composite' 6 | steps: 7 | - name: Setup pnpm 8 | uses: pnpm/action-setup@v4 9 | 10 | - name: Setup Node.js 11 | uses: actions/setup-node@v4 12 | with: 13 | node-version-file: '.nvmrc' 14 | cache: 'pnpm' 15 | 16 | - name: Install Dependencies 17 | shell: bash 18 | run: pnpm install --frozen-lockfile 19 | -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request 2 | on: 3 | workflow_dispatch: 4 | pull_request: 5 | branches: [next] 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | verify: 13 | name: Verify 14 | uses: ./.github/workflows/verify.yml 15 | secrets: inherit 16 | -------------------------------------------------------------------------------- /.github/workflows/snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Canary Release 2 | 3 | on: 4 | push: 5 | branches: [next] 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | verify: 13 | name: Verify 14 | uses: ./.github/workflows/verify.yml 15 | secrets: inherit 16 | 17 | publish: 18 | name: Publish Snapshot 19 | runs-on: ubuntu-latest 20 | needs: verify 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Setup Repository 26 | uses: ./.github/actions/setup 27 | 28 | - name: Configure NPM Auth Token 29 | run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" >> ~/.npmrc 30 | 31 | - name: Create Snapshot 32 | id: create_snapshot 33 | run: pnpm changeset version --snapshot canary || echo "No unreleased changesets found" 34 | 35 | - name: Check for Changeset 36 | id: check_changeset 37 | run: echo "changeset_exists=$(grep -q 'No unreleased changesets found' <<< '${{ steps.create_snapshot.outputs.stdout }}' && echo false || echo true)" >> $GITHUB_ENV 38 | 39 | - name: Build 40 | if: env.changeset_exists == 'true' 41 | run: pnpm build 42 | 43 | - name: Publish Snapshot 44 | if: env.changeset_exists == 'true' 45 | run: pnpm changeset publish --snapshot --tag canary --no-git-tag 46 | -------------------------------------------------------------------------------- /.github/workflows/trigger-tests.yml: -------------------------------------------------------------------------------- 1 | name: Run Tests on Demand 2 | 3 | on: 4 | repository_dispatch: 5 | types: [on-demand-test] 6 | workflow_dispatch: 7 | inputs: 8 | environment: 9 | description: 'Environment to run tests against' 10 | required: true 11 | default: 'staging' 12 | type: choice 13 | options: 14 | - staging 15 | - testnet 16 | publish_results: 17 | description: 'Publish test results' 18 | required: false 19 | default: 'true' 20 | type: string 21 | 22 | jobs: 23 | tests: 24 | name: Full Test Suite 25 | runs-on: ubuntu-latest 26 | 27 | steps: 28 | - uses: actions/checkout@v4 29 | 30 | - name: Run Tests 31 | uses: ./.github/actions/tests 32 | with: 33 | environment: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || github.event.client_payload.lens_env || 'staging' }} 34 | private_key: ${{ secrets.PRIVATE_KEY }} 35 | test_app: ${{ vars.TEST_APP }} 36 | test_account: ${{ vars.TEST_ACCOUNT }} 37 | test_erc20: ${{ vars.TEST_ERC20 }} 38 | global_sponsorship: ${{ secrets.GLOBAL_SPONSORSHIP }} 39 | sponsorship_approver_private_key: ${{ secrets.SPONSORSHIP_APPROVER_PRIVATE_KEY }} 40 | publish_results: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish_results || 'true' }} 41 | -------------------------------------------------------------------------------- /.github/workflows/verify.yml: -------------------------------------------------------------------------------- 1 | name: 'Verify' 2 | on: 3 | workflow_call: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | lint: 8 | name: Lint 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: Setup Biome 15 | uses: biomejs/setup-biome@v2 16 | with: 17 | version: latest 18 | 19 | - name: Run Biome 20 | run: biome ci . 21 | 22 | test: 23 | name: Test 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - name: Run Tests 30 | uses: ./.github/actions/tests 31 | with: 32 | environment: 'staging' 33 | private_key: ${{ secrets.PRIVATE_KEY }} 34 | test_app: ${{ vars.TEST_APP }} 35 | test_account: ${{ vars.TEST_ACCOUNT }} 36 | test_erc20: ${{ vars.TEST_ERC20 }} 37 | global_sponsorship: ${{ secrets.GLOBAL_SPONSORSHIP }} 38 | sponsorship_approver_private_key: ${{ secrets.SPONSORSHIP_APPROVER_PRIVATE_KEY }} 39 | publish_results: 'false' 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | .pnp 6 | .pnp.js 7 | 8 | # build output 9 | **/dist 10 | /docs 11 | */graphql-cache.d.ts 12 | 13 | # misc 14 | .DS_Store 15 | *.pem 16 | 17 | # turbo 18 | .turbo 19 | 20 | # lockfiles 21 | package-lock.json 22 | yarn.lock 23 | examples/*/pnpm-lock.yaml 24 | 25 | # debug 26 | .pnpm-debug.log* 27 | 28 | # local env files 29 | .env 30 | 31 | # typescript 32 | *.tsbuildinfo 33 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | auto-install-peers=false 3 | strict-peer-dependencies=false 4 | link-workspace-packages=false 5 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20.13.1 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # use biome instead 2 | * 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[graphql]": { 3 | "editor.defaultFormatter": "biomejs.biome", 4 | "editor.formatOnSave": false 5 | }, 6 | "[typescript]": { 7 | "editor.defaultFormatter": "biomejs.biome", 8 | "editor.codeActionsOnSave": { 9 | "source.fixAll": "explicit", 10 | "source.removeUnused.ts": "never", 11 | "source.removeUnusedImports": "never", 12 | "source.organizeImports.biome": "explicit" 13 | }, 14 | "editor.formatOnSave": true 15 | }, 16 | "[typescriptreact]": { 17 | "editor.defaultFormatter": "biomejs.biome", 18 | "editor.codeActionsOnSave": { 19 | "source.fixAll": "explicit", 20 | "source.removeUnused.ts": "never", 21 | "source.removeUnusedImports": "never", 22 | "source.organizeImports.biome": "explicit" 23 | }, 24 | "editor.formatOnSave": true 25 | }, 26 | "[json]": { 27 | "editor.defaultFormatter": "biomejs.biome", 28 | "editor.quickSuggestions": { 29 | "strings": true 30 | }, 31 | "editor.formatOnSave": true, 32 | "editor.suggest.insertMode": "replace" 33 | }, 34 | "disabledExtensions": ["Orta.vscode-jest"], 35 | "typescript.tsdk": "node_modules/typescript/lib", 36 | "typescript.enablePromptUseWorkspaceTsdk": true 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Avara Labs Cayman Holdings SEZC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/create-app/README.md: -------------------------------------------------------------------------------- 1 | # Create an App 2 | 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/create-app) 4 | -------------------------------------------------------------------------------- /examples/create-app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Create an App

10 |
Loading...
11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/create-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-create-app", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "dev": "vite" 7 | }, 8 | "dependencies": { 9 | "@lens-chain/sdk": "latest", 10 | "@lens-protocol/client": "canary", 11 | "@lens-protocol/metadata": "latest", 12 | "@lens-chain/storage-client": "latest", 13 | "viem": "^2.21.55" 14 | }, 15 | "devDependencies": { 16 | "typescript": "^5.6.3", 17 | "vite": "^5.4.11" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/create-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["ESNext", "DOM"], 6 | "module": "ESNext", 7 | "moduleResolution": "Bundler", 8 | "strict": true, 9 | "resolveJsonModule": true, 10 | "isolatedModules": true, 11 | "esModuleInterop": true, 12 | "noEmit": true, 13 | "noUnusedLocals": true, 14 | "noUnusedParameters": true, 15 | "noImplicitReturns": true, 16 | "skipLibCheck": true 17 | }, 18 | "include": ["./"] 19 | } 20 | -------------------------------------------------------------------------------- /examples/custom-fragments/README.md: -------------------------------------------------------------------------------- 1 | # Custom Fragments 2 | 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/custom-fragments) 4 | -------------------------------------------------------------------------------- /examples/custom-fragments/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Custom Fragments

10 |
Loading...
11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/custom-fragments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-custom-fragments", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "dev": "vite" 7 | }, 8 | "dependencies": { 9 | "@lens-protocol/client": "canary", 10 | "viem": "^2.21.55" 11 | }, 12 | "devDependencies": { 13 | "typescript": "^5.6.3", 14 | "vite": "^5.4.11" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/custom-fragments/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["ESNext", "DOM"], 6 | "module": "ESNext", 7 | "moduleResolution": "Bundler", 8 | "strict": true, 9 | "resolveJsonModule": true, 10 | "isolatedModules": true, 11 | "esModuleInterop": true, 12 | "noEmit": true, 13 | "noUnusedLocals": true, 14 | "noUnusedParameters": true, 15 | "noImplicitReturns": true, 16 | "skipLibCheck": true 17 | }, 18 | "include": ["./"] 19 | } 20 | -------------------------------------------------------------------------------- /examples/eoa-only/README.md: -------------------------------------------------------------------------------- 1 | # EOA Only Example 2 | 3 | This is a POC example to explore a new type of integration. Nothing to adopt here yet. 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/eoa-only) 6 | -------------------------------------------------------------------------------- /examples/eoa-only/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | EOA Only Example 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/eoa-only/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eoa-only-example", 3 | "description": "EOA Only Example", 4 | "private": true, 5 | "version": "0.0.0", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "vite" 9 | }, 10 | "dependencies": { 11 | "@lens-chain/sdk": "latest", 12 | "@lens-protocol/react": "0.0.0-canary-20250603100701", 13 | "@tanstack/react-query": "^5.63.0", 14 | "connectkit": "^1.9.0", 15 | "react": "^18.3.1", 16 | "react-dom": "^18.3.1", 17 | "viem": "^2.22.4", 18 | "wagmi": "^2.14.6" 19 | }, 20 | "devDependencies": { 21 | "@types/react": "^18.3.12", 22 | "@types/react-dom": "^18.3.1", 23 | "@vitejs/plugin-react-swc": "^3.8.1", 24 | "typescript": "^5.6.3", 25 | "vite": "^5.4.9" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/eoa-only/public/lens.svg: -------------------------------------------------------------------------------- 1 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /examples/eoa-only/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useAuthenticatedUser } from '@lens-protocol/react'; 2 | import { ConnectButton } from './ConnectButton'; 3 | import { DisconnectButton } from './DisconnectButton'; 4 | 5 | export function App() { 6 | const { data } = useAuthenticatedUser({ suspense: true }); 7 | 8 | if (data) { 9 | return ( 10 | <> 11 |

12 | Connected with {data.address} with {data.role} role. 13 |

14 | 15 | 16 | ); 17 | } 18 | 19 | return ; 20 | } 21 | -------------------------------------------------------------------------------- /examples/eoa-only/src/ConnectButton.tsx: -------------------------------------------------------------------------------- 1 | import { evmAddress, useImpersonation } from '@lens-protocol/react'; 2 | 3 | import { useModal } from 'connectkit'; 4 | 5 | export function ConnectButton() { 6 | const { execute } = useImpersonation(); 7 | const { setOpen } = useModal({ 8 | onConnect: async ({ address }) => { 9 | if (!address) { 10 | throw new Error('Address is required to connect'); 11 | } 12 | await execute({ signer: evmAddress(address) }); 13 | }, 14 | }); 15 | 16 | return ( 17 | 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /examples/eoa-only/src/DisconnectButton.tsx: -------------------------------------------------------------------------------- 1 | import { useLogout } from '@lens-protocol/react'; 2 | import { useDisconnect } from 'wagmi'; 3 | 4 | export function DisconnectButton() { 5 | const { execute } = useLogout(); 6 | const { disconnectAsync } = useDisconnect(); 7 | 8 | const onClick = async () => { 9 | await execute(); 10 | await disconnectAsync(); 11 | }; 12 | 13 | return ( 14 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /examples/eoa-only/src/Web3Providers.tsx: -------------------------------------------------------------------------------- 1 | import type React from 'react'; 2 | 3 | import { LensProvider } from '@lens-protocol/react'; 4 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; 5 | import { WagmiProvider } from 'wagmi'; 6 | 7 | import { ConnectKitProvider } from 'connectkit'; 8 | 9 | import { client } from './client'; 10 | import { config } from './config'; 11 | 12 | const queryClient = new QueryClient(); 13 | 14 | export function Web3Providers({ 15 | children, 16 | }: { 17 | children: React.ReactNode; 18 | }) { 19 | return ( 20 | 21 | 22 | 23 | {children} 24 | 25 | 26 | 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /examples/eoa-only/src/client.ts: -------------------------------------------------------------------------------- 1 | import { PublicClient, mainnet } from '@lens-protocol/react'; 2 | 3 | export const client = PublicClient.create({ 4 | environment: mainnet, 5 | storage: window.localStorage, 6 | }); 7 | -------------------------------------------------------------------------------- /examples/eoa-only/src/config.ts: -------------------------------------------------------------------------------- 1 | import { chains } from '@lens-chain/sdk/viem'; 2 | import { getDefaultConfig } from 'connectkit'; 3 | import { http, createConfig } from 'wagmi'; 4 | 5 | export const config = createConfig( 6 | getDefaultConfig({ 7 | chains: [chains.mainnet, chains.testnet], 8 | transports: { 9 | [chains.mainnet.id]: http(chains.mainnet.rpcUrls.default.http[0]!), 10 | [chains.testnet.id]: http(chains.testnet.rpcUrls.default.http[0]!), 11 | }, 12 | walletConnectProjectId: '', 13 | appName: 'EOA Only Example', 14 | appDescription: 'A sample app.', 15 | appUrl: `${import.meta.env.BASE_URL}`, 16 | appIcon: `${import.meta.env.BASE_URL}/lens.svg`, 17 | }), 18 | ); 19 | -------------------------------------------------------------------------------- /examples/eoa-only/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { createRoot } from 'react-dom/client'; 2 | 3 | import { Suspense } from 'react'; 4 | import { App } from './App'; 5 | import { Web3Providers } from './Web3Providers'; 6 | 7 | createRoot(document.getElementById('root')!).render( 8 | 9 | Loading...

}> 10 | 11 |
12 |
, 13 | ); 14 | -------------------------------------------------------------------------------- /examples/eoa-only/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/eoa-only/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "jsx": "react-jsx", 7 | "module": "ESNext", 8 | "moduleResolution": "Bundler", 9 | "strict": true, 10 | "resolveJsonModule": true, 11 | "isolatedModules": true, 12 | "esModuleInterop": true, 13 | "noEmit": true, 14 | "noUnusedLocals": true, 15 | "noUnusedParameters": true, 16 | "noImplicitReturns": true, 17 | "skipLibCheck": true 18 | }, 19 | "include": ["src", "vite.config.ts"] 20 | } 21 | -------------------------------------------------------------------------------- /examples/eoa-only/vite.config.ts: -------------------------------------------------------------------------------- 1 | import react from '@vitejs/plugin-react-swc'; 2 | import { defineConfig } from 'vite'; 3 | 4 | export default defineConfig({ 5 | plugins: [react()], 6 | }); 7 | -------------------------------------------------------------------------------- /examples/nextjs-client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | -------------------------------------------------------------------------------- /examples/nextjs-client/.stackblitzrc: -------------------------------------------------------------------------------- 1 | { 2 | "startCommand": "npm run dev", 3 | "env": {} 4 | } 5 | -------------------------------------------------------------------------------- /examples/nextjs-client/README.md: -------------------------------------------------------------------------------- 1 | # Next.js - Lens Client Integration Example 2 | 3 | This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/nextjs-client) 6 | -------------------------------------------------------------------------------- /examples/nextjs-client/next.config.ts: -------------------------------------------------------------------------------- 1 | import type { NextConfig } from 'next'; 2 | 3 | const nextConfig: NextConfig = { 4 | /* config options here */ 5 | }; 6 | 7 | export default nextConfig; 8 | -------------------------------------------------------------------------------- /examples/nextjs-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nextjs-client", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@lens-protocol/client": "canary", 13 | "next": "15.1.3", 14 | "react": "^19.0.0", 15 | "react-dom": "^19.0.0", 16 | "simpledotcss": "^2.3.3" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "^20", 20 | "@types/react": "^19", 21 | "@types/react-dom": "^19", 22 | "typescript": "^5" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/nextjs-client/src/app/client.ts: -------------------------------------------------------------------------------- 1 | import { PublicClient, testnet } from '@lens-protocol/client'; 2 | 3 | export const client = PublicClient.create({ 4 | environment: testnet, 5 | }); 6 | -------------------------------------------------------------------------------- /examples/nextjs-client/src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lens-protocol/lens-sdk/ce39ebbeb963a36397934a30324ef6b296aadee6/examples/nextjs-client/src/app/favicon.ico -------------------------------------------------------------------------------- /examples/nextjs-client/src/app/globals.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --background: #ffffff; 3 | --foreground: #171717; 4 | } 5 | 6 | @media (prefers-color-scheme: dark) { 7 | :root { 8 | --background: #0a0a0a; 9 | --foreground: #ededed; 10 | } 11 | } 12 | 13 | html, 14 | body { 15 | max-width: 100vw; 16 | overflow-x: hidden; 17 | } 18 | 19 | body { 20 | color: var(--foreground); 21 | background: var(--background); 22 | font-family: Arial, Helvetica, sans-serif; 23 | -webkit-font-smoothing: antialiased; 24 | -moz-osx-font-smoothing: grayscale; 25 | } 26 | 27 | * { 28 | box-sizing: border-box; 29 | padding: 0; 30 | margin: 0; 31 | } 32 | 33 | a { 34 | color: inherit; 35 | text-decoration: none; 36 | } 37 | 38 | @media (prefers-color-scheme: dark) { 39 | html { 40 | color-scheme: dark; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/nextjs-client/src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from 'next'; 2 | import { Geist, Geist_Mono } from 'next/font/google'; 3 | import 'simpledotcss/simple.min.css'; 4 | import './globals.css'; 5 | 6 | const geistSans = Geist({ 7 | variable: '--font-geist-sans', 8 | subsets: ['latin'], 9 | }); 10 | 11 | const geistMono = Geist_Mono({ 12 | variable: '--font-geist-mono', 13 | subsets: ['latin'], 14 | }); 15 | 16 | export const metadata: Metadata = { 17 | title: 'Next.js - Lens Client Integration', 18 | description: 'Generated by create next app', 19 | }; 20 | 21 | export default function RootLayout({ 22 | children, 23 | }: Readonly<{ 24 | children: React.ReactNode; 25 | }>) { 26 | return ( 27 | 28 | {children} 29 | 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /examples/nextjs-client/src/app/page.tsx: -------------------------------------------------------------------------------- 1 | import { AccountsOrderBy, PageSize } from '@lens-protocol/client'; 2 | import { fetchAccounts } from '@lens-protocol/client/actions'; 3 | import { client } from './client'; 4 | 5 | export default async function Home() { 6 | const result = await fetchAccounts(client, { 7 | orderBy: AccountsOrderBy.AccountScore, 8 | pageSize: PageSize.Ten, 9 | }); 10 | 11 | if (result.isErr()) { 12 | return
{result.error.message}
; 13 | } 14 | 15 | return ( 16 |
17 |

Top 10 Accounts by Account Score:

18 | 19 |
    20 | {result.value?.items.map((account) => ( 21 |
  • {account.username?.value}
  • 22 | ))} 23 |
24 |
25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /examples/nextjs-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./src/*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | -------------------------------------------------------------------------------- /examples/on-ramp/README.md: -------------------------------------------------------------------------------- 1 | # Create an App 2 | 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/on-ramp) 4 | -------------------------------------------------------------------------------- /examples/on-ramp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Fiat On-Ramp

10 |
Loading...
11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/on-ramp/index.ts: -------------------------------------------------------------------------------- 1 | import 'viem/window'; 2 | 3 | import { openHalliday } from '@halliday-sdk/commerce'; 4 | import { chains } from '@lens-chain/sdk/viem'; 5 | import { PublicClient, testnet as protocolTestnet } from '@lens-protocol/client'; 6 | import { type Address, createWalletClient, custom } from 'viem'; 7 | 8 | const chain = chains.testnet; 9 | 10 | // hoist account 11 | const [address] = (await window.ethereum!.request({ method: 'eth_requestAccounts' })) as [Address]; 12 | 13 | const walletClient = createWalletClient({ 14 | account: address, 15 | chain, 16 | transport: custom(window.ethereum!), 17 | }); 18 | 19 | const client = PublicClient.create({ 20 | environment: protocolTestnet, 21 | }); 22 | 23 | await openHalliday({ 24 | apiKey: '10e4e6e2-7d66-4fb3-b691-48dba9e6a24d', 25 | destinationChainId: 421614, 26 | destinationTokenAddress: '0x9EbD77f6F4f94C86C138E1da78CD15Ba72808eA1', 27 | services: ['ONRAMP'], 28 | useSandbox: true, 29 | windowType: 'EMBED', 30 | targetElementId: 'app', 31 | }); 32 | 33 | export default []; 34 | -------------------------------------------------------------------------------- /examples/on-ramp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-on-ramp", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "dev": "vite" 7 | }, 8 | "dependencies": { 9 | "@halliday-sdk/commerce": "^3.2.2", 10 | "@lens-chain/sdk": "latest", 11 | "@lens-protocol/client": "link:../../packages/client", 12 | "@lens-protocol/metadata": "latest", 13 | "@lens-protocol/storage-node-client": "next", 14 | "viem": "^2.21.55" 15 | }, 16 | "devDependencies": { 17 | "typescript": "^5.6.3", 18 | "vite": "^5.4.11" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/on-ramp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["ESNext", "DOM"], 6 | "module": "ESNext", 7 | "moduleResolution": "Bundler", 8 | "strict": true, 9 | "resolveJsonModule": true, 10 | "isolatedModules": true, 11 | "esModuleInterop": true, 12 | "noEmit": true, 13 | "noUnusedLocals": true, 14 | "noUnusedParameters": true, 15 | "noImplicitReturns": true, 16 | "skipLibCheck": true 17 | }, 18 | "include": ["./"] 19 | } 20 | -------------------------------------------------------------------------------- /examples/react-login/README.md: -------------------------------------------------------------------------------- 1 | # Log in to Lens 2 | 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/react-login) 4 | -------------------------------------------------------------------------------- /examples/react-login/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Log in to Lens 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/react-login/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-login", 3 | "description": "Log in to Lens", 4 | "private": true, 5 | "version": "0.0.0", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "vite" 9 | }, 10 | "dependencies": { 11 | "@lens-chain/sdk": "latest", 12 | "@lens-protocol/react": "canary", 13 | "@tanstack/react-query": "^5.63.0", 14 | "connectkit": "^1.9.0", 15 | "react": "^18.3.1", 16 | "react-dom": "^18.3.1", 17 | "viem": "^2.22.4", 18 | "wagmi": "^2.14.6" 19 | }, 20 | "devDependencies": { 21 | "@types/react": "^18.3.12", 22 | "@types/react-dom": "^18.3.1", 23 | "@vitejs/plugin-react-swc": "^3.8.1", 24 | "typescript": "^5.6.3", 25 | "vite": "^5.4.9" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/react-login/public/lens.svg: -------------------------------------------------------------------------------- 1 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /examples/react-login/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useAuthenticatedUser } from '@lens-protocol/react'; 2 | import { LoginForm } from './LoginForm'; 3 | import { MyAccount } from './MyAccount'; 4 | 5 | export function App() { 6 | const { data } = useAuthenticatedUser({ suspense: true }); 7 | 8 | if (data) { 9 | return ; 10 | } 11 | 12 | return ; 13 | } 14 | -------------------------------------------------------------------------------- /examples/react-login/src/LogoutButton.tsx: -------------------------------------------------------------------------------- 1 | import { useLogout } from '@lens-protocol/react'; 2 | import { useDisconnect } from 'wagmi'; 3 | 4 | export function LogoutButton() { 5 | const { execute } = useLogout(); 6 | const { disconnectAsync } = useDisconnect(); 7 | 8 | const onClick = async () => { 9 | await execute(); 10 | await disconnectAsync(); 11 | }; 12 | 13 | return ( 14 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /examples/react-login/src/MyAccount.tsx: -------------------------------------------------------------------------------- 1 | import { type EvmAddress, useAccount } from '@lens-protocol/react'; 2 | import { LogoutButton } from './LogoutButton'; 3 | 4 | export function MyAccount({ address }: { address: EvmAddress }) { 5 | const { data } = useAccount({ address, suspense: true }); 6 | 7 | return ( 8 |
9 |

Welcome, {data?.metadata?.name ?? data?.username?.value ?? data?.address}!

10 | 11 |

Created on: {data?.createdAt}

12 |

Account Score: {data?.score}

13 | 14 | 15 |
16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /examples/react-login/src/Web3Providers.tsx: -------------------------------------------------------------------------------- 1 | import type React from 'react'; 2 | 3 | import { LensProvider } from '@lens-protocol/react'; 4 | import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; 5 | import { WagmiProvider } from 'wagmi'; 6 | 7 | import { ConnectKitProvider } from 'connectkit'; 8 | 9 | import { client } from './client'; 10 | import { config } from './config'; 11 | 12 | const queryClient = new QueryClient(); 13 | 14 | export function Web3Providers({ 15 | children, 16 | }: { 17 | children: React.ReactNode; 18 | }) { 19 | return ( 20 | 21 | 22 | 23 | {children} 24 | 25 | 26 | 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /examples/react-login/src/client.ts: -------------------------------------------------------------------------------- 1 | import { PublicClient, mainnet } from '@lens-protocol/react'; 2 | 3 | export const client = PublicClient.create({ 4 | environment: mainnet, 5 | storage: window.localStorage, 6 | }); 7 | -------------------------------------------------------------------------------- /examples/react-login/src/config.ts: -------------------------------------------------------------------------------- 1 | import { chains } from '@lens-chain/sdk/viem'; 2 | import { getDefaultConfig } from 'connectkit'; 3 | import { http, createConfig } from 'wagmi'; 4 | 5 | export const config = createConfig( 6 | getDefaultConfig({ 7 | chains: [chains.mainnet, chains.testnet], 8 | transports: { 9 | [chains.mainnet.id]: http(chains.mainnet.rpcUrls.default.http[0]!), 10 | [chains.testnet.id]: http(chains.testnet.rpcUrls.default.http[0]!), 11 | }, 12 | walletConnectProjectId: '', 13 | appName: 'Lens + ConnectKit Example', 14 | appDescription: 'A sample app integrating ConnectKit and Lens React SDK.', 15 | appUrl: `${import.meta.env.BASE_URL}`, 16 | appIcon: `${import.meta.env.BASE_URL}/lens.svg`, 17 | }), 18 | ); 19 | -------------------------------------------------------------------------------- /examples/react-login/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { createRoot } from 'react-dom/client'; 2 | 3 | import { Suspense } from 'react'; 4 | import { App } from './App'; 5 | import { Web3Providers } from './Web3Providers'; 6 | 7 | createRoot(document.getElementById('root')!).render( 8 | 9 | Loading...

}> 10 | 11 |
12 |
, 13 | ); 14 | -------------------------------------------------------------------------------- /examples/react-login/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/react-login/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "jsx": "react-jsx", 7 | "module": "ESNext", 8 | "moduleResolution": "Bundler", 9 | "strict": true, 10 | "resolveJsonModule": true, 11 | "isolatedModules": true, 12 | "esModuleInterop": true, 13 | "noEmit": true, 14 | "noUnusedLocals": true, 15 | "noUnusedParameters": true, 16 | "noImplicitReturns": true, 17 | "skipLibCheck": true 18 | }, 19 | "include": ["src", "vite.config.ts"] 20 | } 21 | -------------------------------------------------------------------------------- /examples/react-login/vite.config.ts: -------------------------------------------------------------------------------- 1 | import react from '@vitejs/plugin-react-swc'; 2 | import { defineConfig } from 'vite'; 3 | 4 | export default defineConfig({ 5 | plugins: [react()], 6 | }); 7 | -------------------------------------------------------------------------------- /examples/react-post/README.md: -------------------------------------------------------------------------------- 1 | # Create a Lens Post with Lens React Hooks 2 | 3 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/react-post) 4 | -------------------------------------------------------------------------------- /examples/react-post/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Create a Lens Post with Lens React Hooks 9 | 10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/react-post/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-post", 3 | "description": "Create a Lens Post with Lens React Hooks", 4 | "private": true, 5 | "version": "0.0.0", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "vite" 9 | }, 10 | "dependencies": { 11 | "@lens-chain/sdk": "^1.0.3", 12 | "@lens-protocol/client": "canary", 13 | "@lens-protocol/metadata": "^2.0.0", 14 | "@lens-protocol/react": "canary", 15 | "@tanstack/react-query": "^5.74.3", 16 | "react": "^18.3.1", 17 | "react-dom": "^18.3.1", 18 | "viem": "2.x", 19 | "wagmi": "^2.14.16" 20 | }, 21 | "devDependencies": { 22 | "@types/react": "^18.3.12", 23 | "@types/react-dom": "^18.3.1", 24 | "@vitejs/plugin-react-swc": "^3.7.2", 25 | "typescript": "^5.6.3", 26 | "vite": "^5.4.9" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/react-post/public/lens.svg: -------------------------------------------------------------------------------- 1 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /examples/react-post/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { textOnly } from '@lens-protocol/metadata'; 2 | import { useCreatePost } from '@lens-protocol/react'; 3 | import { handleOperationWith } from '@lens-protocol/react/viem'; 4 | import { useWalletClient } from 'wagmi'; 5 | 6 | export function App() { 7 | const { data: wallet } = useWalletClient(); 8 | const { execute, loading, data: post } = useCreatePost(handleOperationWith(wallet)); 9 | 10 | const onSubmit = async (event: React.FormEvent) => { 11 | event.preventDefault(); 12 | const formData = new FormData(event.currentTarget); 13 | 14 | const content = formData.get('content') as string; 15 | 16 | const metadata = textOnly({ 17 | content, 18 | }); 19 | 20 | const result = await execute({ 21 | contentUri: `data:application/json,${JSON.stringify(metadata)}`, 22 | }); 23 | 24 | if (result.isErr()) { 25 | alert(result.error.message); 26 | } 27 | }; 28 | 29 | return ( 30 |
31 |

Post Example

32 | {post && ( 33 |
34 |

Post Created

35 |

Slug: {post.slug}

36 |

Created At: {post.timestamp.toString()}

37 |

Content: {post.metadata.__typename === 'TextOnlyMetadata' && post.metadata.content}

38 |
39 | )} 40 |
41 |