Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2023-12-21 #793

Merged
merged 10 commits into from
Dec 21, 2023
5 changes: 5 additions & 0 deletions .changeset/flat-boxes-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lens-protocol/client": minor
---

**feat:** support `handleToAddress` query
8 changes: 8 additions & 0 deletions .changeset/honest-berries-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@lens-protocol/react-native": minor
"@lens-protocol/react-web": minor
"@lens-protocol/react": minor
"@lens-protocol/api-bindings": patch
---

**feat:** adds `useResolveAddress` hook
5 changes: 5 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"eleven-numbers-wave",
"empty-apricots-cross",
"five-seals-tap",
"flat-boxes-work",
"fluffy-apricots-provide",
"forty-brooms-wonder",
"fresh-lamps-explain",
Expand All @@ -75,6 +76,7 @@
"heavy-dodos-raise",
"heavy-terms-prove",
"hip-buckets-tickle",
"honest-berries-fetch",
"honest-drinks-try",
"hot-eels-divide",
"hot-hornets-drum",
Expand Down Expand Up @@ -118,6 +120,7 @@
"quick-knives-tap",
"quiet-rules-pay",
"rare-birds-breathe",
"rude-suns-visit",
"serious-bats-shake",
"shaggy-carrots-cry",
"sharp-snakes-push",
Expand All @@ -133,11 +136,13 @@
"small-seas-switch",
"smooth-ties-roll",
"sour-avocados-look",
"sour-tables-impress",
"spicy-hornets-protect",
"spotty-bikes-eat",
"strange-yaks-sit",
"strong-cherries-compare",
"stupid-birds-wait",
"stupid-taxis-move",
"swift-dragons-watch",
"swift-hornets-camp",
"tall-gorillas-build",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/rude-suns-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lens-protocol/client": minor
---

**feat:** allow decryptable content with wallet-only auth
8 changes: 8 additions & 0 deletions .changeset/sour-tables-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
"@lens-protocol/client": patch
"@lens-protocol/react": patch
---

**fixed:** issue #777
8 changes: 8 additions & 0 deletions .changeset/stupid-taxis-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
"@lens-protocol/client": patch
"@lens-protocol/react": patch
---

**fixed:** TSDocs typos/mistakes
13 changes: 13 additions & 0 deletions examples/node/scripts/handle/resolveAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { LensClient, development } from '@lens-protocol/client';

async function main() {
const client = new LensClient({
environment: development,
});

const address = await client.handle.resolveAddress({ handle: 'test/wagmi' });

console.log(`Address: `, address);
}

main();
2 changes: 2 additions & 0 deletions examples/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
UseCurrencies,
UseInviteWallets,
UseNotifications,
UseResolveAddress,
} from './misc';
import {
ProfilesPage,
Expand Down Expand Up @@ -198,6 +199,7 @@ export function App() {
<Route path="useApproveModule" element={<UseApproveModule />} />
<Route path="useClaimHandle" element={<UseClaimHandle />} />
<Route path="useInviteWallets" element={<UseInviteWallets />} />
<Route path="useResolveAddress" element={<UseResolveAddress />} />
<Route
path="lensClientInteroperability"
element={<LensClientInteroperability />}
Expand Down
4 changes: 2 additions & 2 deletions examples/web/src/LogInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LoginForm } from './components/auth';

export function LogInPage() {
const navigate = useNavigate();
const { address, isConnected, isConnecting } = useAccount();
const { address, isConnecting, isDisconnected } = useAccount();

const { connect } = useConnect({
connector: new InjectedConnector(),
Expand All @@ -18,7 +18,7 @@ export function LogInPage() {

return (
<div>
{!isConnected && (
{isDisconnected && (
<button disabled={isConnecting} onClick={() => connect()}>
Connect first
</button>
Expand Down
5 changes: 5 additions & 0 deletions examples/web/src/misc/MiscPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const hooks = [
description: `Test ReactHooks SDK and Client SDK interoperability.`,
path: '/misc/lensClientInteroperability',
},
{
label: 'useResolveAddress',
description: `Resolves and EVM address from a Lens Handle.`,
path: '/misc/useResolveAddress',
},
];

export function MiscPage() {
Expand Down
29 changes: 29 additions & 0 deletions examples/web/src/misc/UseResolveAddress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useResolveAddress } from '@lens-protocol/react-web';
import toast from 'react-hot-toast';

export function UseResolveAddress() {
const { execute, loading } = useResolveAddress();

const resolve = async () => {
const result = await execute({ handle: 'test/wagmi' });

if (result.isFailure()) {
toast.error(result.error.message);
return;
}

toast.success(`Resolved address: ${String(result.value)}`);
};

return (
<div>
<h1>
<code>useResolveAddress</code>
</h1>

<button onClick={resolve} disabled={loading}>
Resolve test/wagmi
</button>
</div>
);
}
1 change: 1 addition & 0 deletions examples/web/src/misc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export * from './MiscPage';
export * from './UseApproveModule';
export * from './UseClaimHandle';
export * from './UseCurrencies';
export * from './UseResolveAddress';
export * from './UseInviteWallets';
export * from './UseNotifications';
6 changes: 6 additions & 0 deletions packages/api-bindings/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @lens-protocol/api-bindings

## 0.11.0-alpha.24

### Patch Changes

- 481e1d7aa: **feat:** adds `useResolveAddress` hook

## 0.11.0-alpha.23

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/api-bindings/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lens-protocol/api-bindings",
"version": "0.11.0-alpha.23",
"version": "0.11.0-alpha.24",
"description": "Graphql fragments, react hooks, typescript types of lens API.",
"repository": {
"directory": "packages/api-bindings",
Expand Down
91 changes: 91 additions & 0 deletions packages/api-bindings/src/lens/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ export type GetProfileMetadataArgs = {
useFallback?: InputMaybe<Scalars['Boolean']>;
};

export type HandleToAddressRequest = {
/** The full handle - namespace/localname */
handle: Scalars['Handle'];
};

export type HidePublicationRequest = {
for: Scalars['PublicationId'];
};
Expand Down Expand Up @@ -3064,6 +3069,12 @@ export type InjectCommonQueryParams = {
imageMediumSize: ImageTransformParam | null;
};

export type HandleToAddressVariables = Exact<{
request: HandleToAddressRequest;
}>;

export type HandleToAddressData = { result: EvmAddress | null };

export type InvitedResult = { by: EvmAddress; when: string; profileMinted: Profile | null };

export type InvitedProfilesVariables = Exact<{
Expand Down Expand Up @@ -170475,6 +170486,84 @@ export type FeedHighlightsQueryResult = Apollo.QueryResult<
FeedHighlightsData,
FeedHighlightsVariables
>;
export const HandleToAddressDocument = /*#__PURE__*/ {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'HandleToAddress' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'request' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'HandleToAddressRequest' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
alias: { kind: 'Name', value: 'result' },
name: { kind: 'Name', value: 'handleToAddress' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'request' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'request' } },
},
],
},
],
},
},
],
} as unknown as DocumentNode;

/**
* __useHandleToAddress__
*
* To run a query within a React component, call `useHandleToAddress` and pass it any options that fit your needs.
* When your component renders, `useHandleToAddress` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useHandleToAddress({
* variables: {
* request: // value for 'request'
* },
* });
*/
export function useHandleToAddress(
baseOptions: Apollo.QueryHookOptions<HandleToAddressData, HandleToAddressVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<HandleToAddressData, HandleToAddressVariables>(
HandleToAddressDocument,
options,
);
}
export function useHandleToAddressLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<HandleToAddressData, HandleToAddressVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<HandleToAddressData, HandleToAddressVariables>(
HandleToAddressDocument,
options,
);
}
export type HandleToAddressHookResult = ReturnType<typeof useHandleToAddress>;
export type HandleToAddressLazyQueryHookResult = ReturnType<typeof useHandleToAddressLazyQuery>;
export type HandleToAddressQueryResult = Apollo.QueryResult<
HandleToAddressData,
HandleToAddressVariables
>;
export const InvitedProfilesDocument = /*#__PURE__*/ {
kind: 'Document',
definitions: [
Expand Down Expand Up @@ -248432,6 +248521,7 @@ export type QueryKeySpecifier = (
| 'following'
| 'fxRateFor'
| 'generateModuleCurrencyApprovalData'
| 'handleToAddress'
| 'imageMediumSize'
| 'imageSmallSize'
| 'internalAllowedDomains'
Expand Down Expand Up @@ -248517,6 +248607,7 @@ export type QueryFieldPolicy = {
following?: FieldPolicy<any> | FieldReadFunction<any>;
fxRateFor?: FieldPolicy<any> | FieldReadFunction<any>;
generateModuleCurrencyApprovalData?: FieldPolicy<any> | FieldReadFunction<any>;
handleToAddress?: FieldPolicy<any> | FieldReadFunction<any>;
imageMediumSize?: FieldPolicy<any> | FieldReadFunction<any>;
imageSmallSize?: FieldPolicy<any> | FieldReadFunction<any>;
internalAllowedDomains?: FieldPolicy<any> | FieldReadFunction<any>;
Expand Down
3 changes: 3 additions & 0 deletions packages/api-bindings/src/lens/graphql/handle.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
query HandleToAddress($request: HandleToAddressRequest!) {
result: handleToAddress(request: $request)
}
12 changes: 12 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @lens-protocol/client

## 2.0.0-alpha.27

### Minor Changes

- 75e2caea6: **feat:** support `handleToAddress` query
- 61f0aedb6: **feat:** allow decryptable content with wallet-only auth

### Patch Changes

- c074c4ded: **fixed:** issue #777
- fa944c274: **fixed:** TSDocs typos/mistakes

## 2.0.0-alpha.26

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lens-protocol/client",
"version": "2.0.0-alpha.26",
"version": "2.0.0-alpha.27",
"description": "Low level Lens API client",
"repository": {
"directory": "packages/client",
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/LensClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Transaction,
Wallet,
} from './submodules';
import { Handle } from './submodules/handle';

/**
* LensClient configuration
Expand Down Expand Up @@ -114,6 +115,13 @@ export class LensClient {
return new Feed(this.context, this._authentication);
}

/**
* The Handle module
*/
get handle(): Handle {
return new Handle(this.context, this._authentication);
}

/**
* The Invites module
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/__helpers__/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export async function createOrGetProfile(signer: Wallet, client: LensClient, han
return result ?? never('Profile not found');
}

export async function authenticate(signer: Wallet, client: LensClient, profile: ProfileFragment) {
export async function authenticate(signer: Wallet, client: LensClient, profile?: ProfileFragment) {
const { id, text } = await client.authentication.generateChallenge({
signedBy: signer.address,
for: profile.id,
for: profile?.id,
});

const signature = await signer.signMessage(text);
Expand Down
Loading
Loading