import type { Op } from '@geoprotocol/grc-20'; import type { Address, Hex } from 'viem'; import type { UpdateRankClientParams } from './client/ranks.js'; import type { VotingSettingsInput } from './encodings/get-create-dao-space-calldata.js'; import type { Id } from './id.js'; import type { UpdateRankResult } from './ranks/types.js'; import type { GeoNetworkConfig } from './types.js'; export type FetchLike = typeof fetch; export type GraphQlResponse = { data?: T; errors?: unknown; }; export type EditCalldataParams = { spaceId: string; cid: string; }; export type ApiCalldataResult = { to: `0x${string}`; data: `0x${string}`; }; export type ImageSource = { blob: Blob; } | { url: string; }; export type UploadImageParams = ImageSource & { alternativeGateway?: boolean; }; export type UploadImageResult = { cid: `ipfs://${string}`; dimensions?: { width: number; height: number; }; }; export type CreateImageParams = ImageSource & { name?: string; description?: string; id?: Id | string; alternativeGateway?: boolean; }; export type CreateResult = { id: Id; ops: Op[]; }; export type CreateImageResult = CreateResult & { cid: string; dimensions?: { width: number; height: number; }; }; export type DeleteEntityParams = { id: Id | string; spaceId: Id | string; }; export type CreateCommentParams = { id?: Id | string; content: string; replyTo: { entityId: Id | string; spaceId: Id | string; }; resolved?: boolean; }; export type UpdateCommentParams = { id: Id | string; content?: string; resolved?: boolean; }; export type CalldataResult = { to: `0x${string}`; calldata: `0x${string}`; }; export type CreatePersonalSpaceParams = { name: string; accountAddress: Address; }; export type CreatePersonalSpaceResult = CalldataResult & { spaceEntityId: Id; accountId: string; ops: Op[]; }; export type SetPersonalSpaceTopicParams = { spaceId: Id | string; topicId: Id | string; authorSpaceId?: Id | string; }; export type HasPersonalSpaceParams = { address: Hex; rpcUrl?: string; }; export type PublishEditParams = { name: string; ops: Op[]; author: Id | string; }; export type PublishEditResult = { cid: `ipfs://${string}`; editId: Id; }; export type PublishPersonalSpaceEditParams = PublishEditParams & { spaceId: Id | string; }; export type PublishPersonalSpaceEditResult = PublishEditResult & CalldataResult; export type { VotingSettingsInput } from './encodings/get-create-dao-space-calldata.js'; export type VotingMode = 'SLOW' | 'FAST'; export type VoteOption = 'YES' | 'NO' | 'ABSTAIN'; export type CreateDaoSpaceParams = { name: string; author: Id | string; votingSettings: VotingSettingsInput; initialEditorSpaceIds: `0x${string}`[]; initialMemberSpaceIds?: `0x${string}`[]; initialTopicId?: string; ops?: Op[]; }; export type CreateDaoSpaceResult = CalldataResult & { spaceEntityId: Id; cid: `ipfs://${string}`; }; export type ProposalAction = { to: `0x${string}`; value: bigint; data: `0x${string}`; }; export type CreateProposalParams = { fromSpaceId: string; daoSpaceId: string; proposalId?: string; votingMode?: VotingMode; actions: ProposalAction[]; }; export type ProposalResult = CalldataResult & { proposalId: `0x${string}`; }; export type ProposeEditParams = PublishEditParams & { daoSpaceAddress: `0x${string}`; callerSpaceId: string; daoSpaceId: string; votingMode?: VotingMode; proposalId?: string; }; export type ProposeEditResult = PublishEditResult & ProposalResult; export type DaoSpaceRoleProposalBaseParams = { authorSpaceId: string; spaceId: string; daoSpaceAddress: `0x${string}`; votingMode?: VotingMode; proposalId?: string; }; export type ProposeAddMemberParams = DaoSpaceRoleProposalBaseParams & { newMemberSpaceId: string; }; export type ProposeRemoveMemberParams = DaoSpaceRoleProposalBaseParams & { memberToRemoveSpaceId: string; }; export type ProposeAddEditorParams = Omit & { votingMode?: 'SLOW'; newEditorSpaceId: string; }; export type ProposeRemoveEditorParams = Omit & { votingMode?: 'SLOW'; editorToRemoveSpaceId: string; }; export type ProposeRequestMembershipParams = { authorSpaceId: string; spaceId: string; proposalId?: string; }; export type VoteProposalParams = { authorSpaceId: string; spaceId: string; proposalId: string; vote: VoteOption; }; export type ExecuteProposalParams = { authorSpaceId: string; spaceId: string; proposalId: string; }; export type EntityVoteParams = { authorSpaceId: Id | string; spaceId: Id | string; entityId: Id | string; }; export type Client = { network: GeoNetworkConfig; api: { graphql(query: string): Promise>; getEditCalldata(params: EditCalldataParams): Promise; }; storage: { uploadImage(params: UploadImageParams): Promise; uploadCSV(csvString: string): Promise<`ipfs://${string}`>; }; entities: { delete(params: DeleteEntityParams): Promise; }; images: { create(params: CreateImageParams): Promise; }; comments: { create(params: CreateCommentParams): Promise; update(params: UpdateCommentParams): CreateResult; }; ranks: { update(params: UpdateRankClientParams): Promise; }; personalSpaces: { create(params: CreatePersonalSpaceParams): CreatePersonalSpaceResult; setTopic(params: SetPersonalSpaceTopicParams): CalldataResult; hasSpace(params: HasPersonalSpaceParams): Promise; publishEdit(params: PublishPersonalSpaceEditParams): Promise; }; daoSpaces: { create(params: CreateDaoSpaceParams): Promise; proposeEdit(params: ProposeEditParams): Promise; proposeAddMember(params: ProposeAddMemberParams): ProposalResult; proposeRemoveMember(params: ProposeRemoveMemberParams): ProposalResult; proposeAddEditor(params: ProposeAddEditorParams): ProposalResult; proposeRemoveEditor(params: ProposeRemoveEditorParams): ProposalResult; proposeRequestMembership(params: ProposeRequestMembershipParams): ProposalResult; proposals: { create(params: CreateProposalParams): ProposalResult; vote(params: VoteProposalParams): CalldataResult; execute(params: ExecuteProposalParams): CalldataResult; actions: { publishEdit(daoSpaceAddress: `0x${string}`, cid: string): ProposalAction; addEditor(daoSpaceAddress: `0x${string}`, spaceId: string): ProposalAction; removeEditor(daoSpaceAddress: `0x${string}`, spaceId: string): ProposalAction; addMember(daoSpaceAddress: `0x${string}`, spaceId: string): ProposalAction; removeMember(daoSpaceAddress: `0x${string}`, spaceId: string): ProposalAction; updateVotingSettings(daoSpaceAddress: `0x${string}`, votingSettings: VotingSettingsInput): ProposalAction; }; }; }; entityVotes: { upvote(params: EntityVoteParams): CalldataResult; downvote(params: EntityVoteParams): CalldataResult; withdraw(params: EntityVoteParams): CalldataResult; }; }; export type CreateGeoClientParams = { /** * Built-in or custom network configuration. * * Pass `GeoTestnetConfig` for the built-in testnet config, or * `defineGeoNetworkConfig(...)` when running against a local or custom * deployment. The network config is required so callers make an explicit * environment choice. String IDs such as `"TESTNET"` are intentionally not * accepted by the client. * * @example * ```ts * import { GeoTestnetConfig } from '@geoprotocol/geo-sdk'; * * const geo = createGeoClient({ network: GeoTestnetConfig }); * ``` */ network: GeoNetworkConfig; /** * Fetch implementation used by API, IPFS, and GraphQL-backed helpers. * * Async helpers that upload or query data use this value, then fall back to * `globalThis.fetch`. * * @example * ```ts * const geo = createGeoClient({ * network: GeoTestnetConfig, * fetch: customFetch, * }); * ``` */ fetch?: FetchLike; }; /** * Creates a configured Geo SDK client. * * The client groups the SDK into namespaces by workflow: * - `api`, `storage`, `images`, `comments`, and delete helpers use the * configured API origin and fetch implementation. * - transaction/calldata helpers use contract addresses from the configured * network. * * @example * ```ts * import { createGeoClient, GeoTestnetConfig } from '@geoprotocol/geo-sdk'; * import * as Ops from '@geoprotocol/geo-sdk/ops'; * * const geo = createGeoClient({ network: GeoTestnetConfig }); * const { ops } = Ops.entities.create({ name: 'Geo entity' }); * const edit = await geo.personalSpaces.publishEdit({ * name: 'Create entity', * spaceId, * author, * ops, * }); * ``` * * @example * Create a client for a custom deployment. * * ```ts * import { createGeoClient, defineGeoNetworkConfig } from '@geoprotocol/geo-sdk'; * * const local = defineGeoNetworkConfig({ * id: 'LOCAL', * name: 'Local Geo', * apiOrigin: 'http://localhost:3000', * chain: { id: 31337, name: 'Anvil', rpcUrl: 'http://localhost:8545' }, * contracts: { * SPACE_REGISTRY_ADDRESS: '0x...', * DAO_SPACE_FACTORY_ADDRESS: '0x...', * }, * }); * * const geo = createGeoClient({ network: local }); * ``` * * @param params Network and fetch configuration for context-aware helpers. * @returns A configured client with API helpers and transaction workflows. */ export declare function createGeoClient(params: CreateGeoClientParams): Client; //# sourceMappingURL=client.d.ts.map