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

[TABJS-3] SDK cannot be used with ethers.js v6 #77

Closed
dtbuchholz opened this issue Nov 9, 2023 · 0 comments · Fixed by #137
Closed

[TABJS-3] SDK cannot be used with ethers.js v6 #77

dtbuchholz opened this issue Nov 9, 2023 · 0 comments · Fixed by #137
Labels
Improvement Created by Linear-GitHub Sync sdk Created by Linear-GitHub Sync

Comments

@dtbuchholz
Copy link
Contributor

dtbuchholz commented Nov 9, 2023

context

A user reported this bug in Discord here https://discord.com/channels/592843512312102924/1077277654132215960

initial report

The initial report is from a user running the basic sdk example from the docs:

import { Database, helpers } from "@tableland/sdk"
import { Wallet } from "ethers"
import * as dotenv from "dotenv"
dotenv.config()

async function main() {
    const privateKey: any = process.env.PRIVATE_KEY
    const rpc: any = process.env.RPC_URL
    
    const wallet = new Wallet(privateKey);
    const provider: any = helpers.getDefaultProvider(rpc)
    const signer: any = wallet.connect(provider);    
    interface Schema {
        id: number;
        name: string;
    }
    
    const db = new Database<Schema>({ signer: signer })
    
    const prefix: string = "my_sdk_table";
    
    const { meta: create } = await db
        .prepare(`CREATE TABLE ${prefix} (id integer primary key, name text);`)
        .run();
    
    console.log(create.txn?.name)
}

main();

This results in: Error: RUN_ERROR: signer.getChainId is not a function

details

Ethers.js v6 was recently released https://docs.ethers.org/v6
With this release the signer interface no longer has the getChainId method. The chainId is potentially available elsewhere within the ethers v6 signer, but we might want to decide if there's a more robust way to get the chainId.
The v3 SDK had the requirement that a specific network had been connected to, which made this problem a little easier.

ideas for a solution

  • We could potentially try to sniff out what kind of interface the passed in signer supports. The downside I see here is that this could be cumbersome.
  • We could determine the chainId from the query. I think this makes sense, but I'd have to dive into implementation to be sure.

additional comments

  • This is blocked by hardhat supporting ethers v6. I'm gonna move this to cycle 3, but I don't know how long it will take for hardhat to introduce support
  • Looks like we will have to wait until Adding missing exports for v6.1 ethers-io/ethers.js#3734 is fixed to properly fix this and upgrade this package to Ethers v6
  • Hardhat has beta support for ethers v6, but some of the evm-tableland open zeppelin dependencies have peer dependencies that require ethers v5. So we will have to wait for something to change in OZ, as such I'm moving this out to cycle 6
  • This has turned into a pretty difficult update because of all of the dependency requirements. Moving this out another cycle.

From SyncLinear.com | TABJS-3

@dtbuchholz dtbuchholz added the Improvement Created by Linear-GitHub Sync label Nov 9, 2023
@dtbuchholz dtbuchholz added the sdk Created by Linear-GitHub Sync label Nov 9, 2023
@dtbuchholz dtbuchholz changed the title [TABJS-3] SDK: cannot be used with ethers.js v6 [TABJS-3] SDK cannot be used with ethers.js v6 Nov 9, 2023
@dtbuchholz dtbuchholz mentioned this issue May 2, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Created by Linear-GitHub Sync sdk Created by Linear-GitHub Sync
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant