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

[JST-11] SDK cannot be used with ethers.js v6 #41

Closed
joewagner opened this issue Feb 20, 2023 · 4 comments · May be fixed by tablelandnetwork/js-tableland#422
Closed

[JST-11] SDK cannot be used with ethers.js v6 #41

joewagner opened this issue Feb 20, 2023 · 4 comments · May be fixed by tablelandnetwork/js-tableland#422
Assignees
Labels
linear Sync issue with linear

Comments

@joewagner
Copy link
Contributor

joewagner commented Feb 20, 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.

JST-11

@joewagner
Copy link
Contributor Author

Looks like we will have to wait until ethers-io/ethers.js#3734 is fixed to properly fix this and upgrade this package to Ethers v6

@joewagner joewagner added the linear Sync issue with linear label Mar 17, 2023
@joewagner joewagner self-assigned this Mar 17, 2023
@sanderpick sanderpick removed the linear Sync issue with linear label Mar 21, 2023
@joewagner joewagner added linear Sync issue with linear and removed linear Sync issue with linear labels Mar 22, 2023
@joewagner joewagner changed the title SDK cannot be used with ethers.js v6 [JST-11] SDK cannot be used with ethers.js v6 Mar 22, 2023
@joewagner joewagner assigned awmuncy and joewagner and unassigned joewagner and awmuncy Apr 7, 2023
@joewagner joewagner self-assigned this Apr 7, 2023
@joewagner joewagner transferred this issue from tablelandnetwork/js-tableland Sep 27, 2023
@dtbuchholz
Copy link
Contributor

@joewagner i set up a Linear sync for tableland-js and recreated this issue from the Linear app so that it syncs to GH: #77. before i go about doing this for the rest of the issues in this repo (i.e., those not prefixed with [TABJS-XX]), i wanted to double check to make sure this is all okay to do.

also, i was wondering if any of the old issues in the Linear teams for js-tableland, js-tableland-cli, and local-tableland should be recreated in this repo? or, are those old project issues outdated and should not be recreated in tableland-js? i can set them all up, just lmk.

@joewagner
Copy link
Contributor Author

@joewagner i set up a Linear sync for tableland-js and recreated this issue from the Linear app so that it syncs to GH: #77. before i go about doing this for the rest of the issues in this repo (i.e., those not prefixed with [TABJS-XX]), i wanted to double check to make sure this is all okay to do.

That would be great! You might be able to add the linear tag to an issue instead of re-creating, but I'm not soure on that. If not then re-creating works for me.

also, i was wondering if any of the old issues in the Linear teams for js-tableland, js-tableland-cli, and local-tableland should be recreated in this repo? or, are those old project issues outdated and should not be recreated in tableland-js? i can set them all up, just lmk.

I Haven't looked recently. If there are any issues that still exist in the code and are listed in the old repos, you can use github's "transfer issue" feature to move them. If for some reason that doesn't work re-creating them is ok with me.

Thanks again for dealing with this.

@dtbuchholz
Copy link
Contributor

cool, sounds good, happy to help!

@joewagner joewagner closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear Sync issue with linear
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants