dialectlabs / sdk

Apache License 2.0
22 stars 7 forks source link

My wallet has received a message via Dialect, but 0 threads in "@dialectlabs/blockchain-sdk-solana" using dialectSDK.threads.findAll() #94

Closed mikemaccana closed 1 year ago

mikemaccana commented 1 year ago

Hi Dialect! Really excited about wallet-to-wallet messaging!

My account (5FHwkrdxntdK24hgQU8qgBjn35Y1zwhz1GZwCkP2UJnM) has received a message using Dialect - I can see this in Decaf wallet.

The wallet is indeed 5FHw...

The message received via Dialect:

As a Solana developer, I am trying to retrieve the message, following the instructions in Dialect's Docs. However dialectSDK.threads.findAll() returns an array of 0 items.

Test reproduction code:

// From https://docs.dialect.to/documentation/messaging/typescript/configuration
import {
  Dialect,
  DialectSdk,
  type DialectCloudEnvironment,
} from "@dialectlabs/sdk";
import {
  SolanaSdkFactory,
  NodeDialectSolanaWalletAdapter,
  type Solana,
} from "@dialectlabs/blockchain-sdk-solana";
import type { Keypair } from "@solana/web3.js";

export const getDialect = (keyPair: Keypair) => {
  const environment: DialectCloudEnvironment = "development";

  const dialectSDK: DialectSdk<Solana> = Dialect.sdk(
    {
      environment,
    },
    SolanaSdkFactory.create({
      wallet: NodeDialectSolanaWalletAdapter.create(keyPair),
    })
  );

  const getThreads = async () => {
    // Fetch all threads the wallet is a part of, across all provided backends
    const threads = await dialectSDK.threads.findAll();
    return threads;
  };

  return {
    getThreads,
  };
};

And the test:

import { getDialect } from "./dialect";
import { mikesKeyPair } from "./get-mikes-keypair";

describe(`dialect`, () => {
  test(`getting threads`, async () => {
    const dialect = getDialect(mikesKeyPair);
    const threads = await dialect.getThreads();
    expect(threads.length).toBeGreaterThan(0);
  });
});
mikemaccana commented 1 year ago

Nevermind, just needed to change DialectCloudEnvironment = "production" WOO MESSAGES 😃