Skip to content

Commit

Permalink
less specific type
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Sep 19, 2024
1 parent 076d3fb commit 5fe044c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions packages/store-sync/src/stash/createStorageAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CreateStashResult, deleteRecord, getRecord, setRecord, StoreConfig } from "@latticexyz/stash/internal";
import { Stash, deleteRecord, getRecord, setRecord } from "@latticexyz/stash/internal";
import {
decodeKey,
decodeValueArgs,
Expand All @@ -12,13 +12,11 @@ import { size } from "viem";
import { Table } from "@latticexyz/config";
import { StorageAdapter, StorageAdapterBlock, emptyValueArgs } from "../common";

export type CreateStorageAdapter<config extends StoreConfig> = {
stash: CreateStashResult<config>;
export type CreateStorageAdapter = {
stash: Stash;
};

export function createStorageAdapter<const config extends StoreConfig>({
stash,
}: CreateStorageAdapter<config>): StorageAdapter {
export function createStorageAdapter({ stash }: CreateStorageAdapter): StorageAdapter {
const tablesById = Object.fromEntries(
Object.values(stash.get().config)
.flatMap((namespace) => Object.values(namespace) as readonly Table[])
Expand Down
10 changes: 5 additions & 5 deletions packages/store-sync/src/stash/syncToStash.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CreateStashResult, StoreConfig, getRecord, setRecord, registerTable } from "@latticexyz/stash/internal";
import { getRecord, setRecord, registerTable, Stash } from "@latticexyz/stash/internal";
import { Address, Client, publicActions } from "viem";
import { createStorageAdapter } from "./createStorageAdapter";
import { defineTable } from "@latticexyz/store/config/v2";
Expand Down Expand Up @@ -28,8 +28,8 @@ export const initialProgress = {
message: "Connecting",
} satisfies getSchemaPrimitives<getValueSchema<typeof SyncProgress>>;

export type SyncToStashOptions<config extends StoreConfig> = {
stash: CreateStashResult<config>;
export type SyncToStashOptions = {
stash: Stash;
client: Client;
address: Address;
startSync?: boolean;
Expand All @@ -40,12 +40,12 @@ export type SyncToStashResult = Omit<SyncResult, "waitForTransaction"> & {
stopSync: () => void;
};

export async function syncToStash<const config extends StoreConfig>({
export async function syncToStash({
stash,
client,
address,
startSync = true,
}: SyncToStashOptions<config>): Promise<SyncToStashResult> {
}: SyncToStashOptions): Promise<SyncToStashResult> {
registerTable({ stash, table: SyncProgress });

const storageAdapter = createStorageAdapter({ stash });
Expand Down

0 comments on commit 5fe044c

Please sign in to comment.