entropyxyz / sdk

Official JavaScript SDK for Entropy blockchain.
GNU Affero General Public License v3.0
7 stars 0 forks source link

Instantiation Option Types Seem Incorrect #237

Closed benschac closed 6 months ago

benschac commented 10 months ago

The options for

const entropy = new Entropy({});

Will currently result in the sdk not working for end developers

interface EntropyOpts {
    seed?: string;
    endpoint?: string;
    adapters?: {
        [key: string | number]: Adapter;
    };
}

If there's not a specified endpoint, where is the client supposed to make an API request to?

Additionally, same goes for seed and adapters.

I'd assume we'd want type errors if developers don't provide values and then throw to let the developer know that we need the required options.

https://github.com/entropyxyz/entropy-js/blob/95eff6e043bd8876482dcc61bde6cd1bea6861c8/src/utils/index.ts#L37

is one of the few places I see a default value that would break if someone didn't have a local setup.

Maybe it could be a good idea to make a default to the test network?

Or just like

if (!endpoint) {
 throw Error("endpoint is required") // blah blah get the endpoint in docs here.
}
frankiebee commented 6 months ago

old