Skip to content

Commit 9d1b504

Browse files
committed
wip
1 parent 2403b28 commit 9d1b504

File tree

8 files changed

+17
-1
lines changed

8 files changed

+17
-1
lines changed

apps/connect/src/routes/authenticate.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ function AuthenticateComponent() {
364364
appIdentity: {
365365
address: newAppIdentity.address,
366366
addressPrivateKey: newAppIdentity.addressPrivateKey,
367+
accountAddress,
367368
encryptionPrivateKey: keys.encryptionPrivateKey,
368369
signaturePrivateKey: keys.signaturePrivateKey,
369370
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
@@ -420,6 +421,7 @@ function AuthenticateComponent() {
420421
appIdentity: {
421422
address: decryptedIdentity.address,
422423
addressPrivateKey: decryptedIdentity.addressPrivateKey,
424+
accountAddress: decryptedIdentity.accountAddress,
423425
encryptionPrivateKey: decryptedIdentity.encryptionPrivateKey,
424426
signaturePrivateKey: decryptedIdentity.signaturePrivateKey,
425427
encryptionPublicKey: decryptedIdentity.encryptionPublicKey,

apps/events/src/routes/authenticate-success.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function RouteComponent() {
4444
setIdentity({
4545
address: parsedAuthParams.appIdentityAddress,
4646
addressPrivateKey: parsedAuthParams.appIdentityAddressPrivateKey,
47+
accountAddress: parsedAuthParams.accountAddress,
4748
signaturePublicKey: parsedAuthParams.signaturePublicKey,
4849
signaturePrivateKey: parsedAuthParams.signaturePrivateKey,
4950
encryptionPublicKey: parsedAuthParams.encryptionPublicKey,

packages/hypergraph-react/src/hooks/use-spaces.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { store } from '@graphprotocol/hypergraph/store';
12
import { useQuery } from '@tanstack/react-query';
3+
import { useSelector } from '@xstate/store/react';
24
import { gql, request } from 'graphql-request';
35
import { GEO_API_TESTNET_ENDPOINT } from '../internal/constants.js';
46

@@ -27,11 +29,13 @@ type PublicSpacesQueryResult = {
2729
};
2830

2931
export const useSpaces = (params: { mode: 'public' }) => {
32+
const accountAddress = useSelector(store, (state) => state.context.identity?.accountAddress);
33+
console.log('useSpaces accountAddress', accountAddress);
3034
return useQuery({
3135
queryKey: ['hypergraph-spaces', params.mode],
3236
queryFn: async () => {
3337
const result = await request<PublicSpacesQueryResult>(GEO_API_TESTNET_ENDPOINT, publicSpacesQueryDocument, {
34-
accountAddress: '0xBE0298aF8D440bEFA78E7e8A538D8ecBFF06bfC7',
38+
accountAddress,
3539
});
3640
return result?.spaces
3741
? result.spaces.map((space) => ({

packages/hypergraph/src/connect/identity-encryption.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,6 @@ export const decryptAppIdentity = async (
228228
signaturePrivateKey,
229229
address: appIdentityAddress,
230230
addressPrivateKey: appIdentityAddressPrivateKey,
231+
accountAddress,
231232
};
232233
};

packages/hypergraph/src/connect/parse-callback-params.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const parseCallbackParams = ({
5252
return Effect.succeed({
5353
appIdentityAddress: data.appIdentityAddress,
5454
appIdentityAddressPrivateKey: data.appIdentityAddressPrivateKey,
55+
accountAddress: data.accountAddress,
5556
signaturePublicKey: data.signaturePublicKey,
5657
signaturePrivateKey: data.signaturePrivateKey,
5758
encryptionPublicKey: data.encryptionPublicKey,

packages/hypergraph/src/connect/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export type PrivateAppIdentity = IdentityKeys & {
6060
addressPrivateKey: string;
6161
sessionToken: string;
6262
sessionTokenExpires: Date;
63+
accountAddress: string;
6364
};
6465

6566
export class InvalidIdentityError {

packages/hypergraph/src/identity/auth-storage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Storage } from './types.js';
44
export const storeIdentity = (storage: Storage, identity: PrivateAppIdentity) => {
55
storage.setItem('hypergraph:app-identity-address', identity.address);
66
storage.setItem('hypergraph:app-identity-address-private-key', identity.addressPrivateKey);
7+
storage.setItem('hypergraph:app-identity-account-address', identity.accountAddress);
78
storage.setItem('hypergraph:signature-public-key', identity.signaturePublicKey);
89
storage.setItem('hypergraph:signature-private-key', identity.signaturePrivateKey);
910
storage.setItem('hypergraph:encryption-public-key', identity.encryptionPublicKey);
@@ -15,6 +16,7 @@ export const storeIdentity = (storage: Storage, identity: PrivateAppIdentity) =>
1516
export const loadIdentity = (storage: Storage): PrivateAppIdentity | null => {
1617
const address = storage.getItem('hypergraph:app-identity-address');
1718
const addressPrivateKey = storage.getItem('hypergraph:app-identity-address-private-key');
19+
const accountAddress = storage.getItem('hypergraph:app-identity-account-address');
1820
const signaturePublicKey = storage.getItem('hypergraph:signature-public-key');
1921
const signaturePrivateKey = storage.getItem('hypergraph:signature-private-key');
2022
const encryptionPublicKey = storage.getItem('hypergraph:encryption-public-key');
@@ -24,6 +26,7 @@ export const loadIdentity = (storage: Storage): PrivateAppIdentity | null => {
2426
if (
2527
!address ||
2628
!addressPrivateKey ||
29+
!accountAddress ||
2730
!signaturePublicKey ||
2831
!signaturePrivateKey ||
2932
!encryptionPublicKey ||
@@ -36,6 +39,7 @@ export const loadIdentity = (storage: Storage): PrivateAppIdentity | null => {
3639
return {
3740
address,
3841
addressPrivateKey,
42+
accountAddress,
3943
signaturePublicKey,
4044
signaturePrivateKey,
4145
encryptionPublicKey,
@@ -48,6 +52,7 @@ export const loadIdentity = (storage: Storage): PrivateAppIdentity | null => {
4852
export const wipeIdentity = (storage: Storage) => {
4953
storage.removeItem('hypergraph:app-identity-address');
5054
storage.removeItem('hypergraph:app-identity-address-private-key');
55+
storage.removeItem('hypergraph:app-identity-account-address');
5156
storage.removeItem('hypergraph:signature-public-key');
5257
storage.removeItem('hypergraph:signature-private-key');
5358
storage.removeItem('hypergraph:encryption-public-key');

packages/hypergraph/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type ConnectAuthPayload = Schema.Schema.Type<typeof ConnectAuthPayload>;
2020
export const ConnectCallbackResult = Schema.Struct({
2121
appIdentityAddress: Schema.String,
2222
appIdentityAddressPrivateKey: Schema.String,
23+
accountAddress: Schema.String,
2324
signaturePublicKey: Schema.String,
2425
signaturePrivateKey: Schema.String,
2526
encryptionPublicKey: Schema.String,

0 commit comments

Comments
 (0)