Comments (2)
Hey @pkoch,
Thanks for opening an issue! I can definitely see why you would want to be able to control / omit the error message. And you are correct that is where the warning comes from.
The one concern I have with just omitting the warning altogether with chainId: ""
is that, before submitting a transaction securely, a developer should know that they are using the correct chainId to prevent transaction forwarding (e.g. preventing a malicious node operator from taking a valid transaction on network A and submitting it on network B). So if someone sets an empty string as a placeholder but later forgets to properly set the chain id, we definitely want to warn them.
I think there are two other approaches we could take on this:
1. Optional params to .chainInfo()
to disable warning
We could add an optional argument to the .chainInfo()
method that makes the warning configurable. Eg:
interface ChainInfoOpts {
disableWarning?: boolean;
}
public async chainInfo(opts?: ChainInfoOpts): Promise<GenericResponse<ChainInfo>> {
const info = await this.client.chainInfo();
if (!opts?.disableWarning && info.data?.chain_id !== this.chainId) {
console.warn(
`WARNING: Chain ID mismatch. Expected ${info.data?.chain_id}, got ${this.chainId}`
);
}
return info;
}
2. Make warning respect config.logging
argument
We can make the warning message respect the configuration on the config.logging
property on the WebKwil Constructor. So the implementation would be:
public async chainInfo(): Promise<GenericResponse<ChainInfo>> {
const info = await this.client.chainInfo();
if (this.config.logging && info.data?.chain_id !== this.chainId) {
this.config.logger!(
`WARNING: Chain ID mismatch. Expected ${info.data?.chain_id}, got ${this.chainId}`
);
}
return info;
}
And then, you can turn this message on/off with:
new WebKwil({
kwilProvider: "some_provider",
chainId: "",
logging: false / true
});
Thoughts on either of these approaches? I would probably lean towards option 1, but am open to ideas.
from kwil-js.
Thank you! <3
from kwil-js.
Related Issues (20)
- Limit characters allowed in friendly sign
- Add validation for builders HOT 1
- Proposal: Builder Pattern Alternatives HOT 4
- Add validation for .call() endpoint HOT 4
- Allow for custom signer names
- Remove ed25519_nr signature type
- Deprecate external API for DBBuilder and ActionBuilder HOT 1
- Remove salt and add chain ID to TX Body
- Make public key on `KwilSigner` Uint8Array only HOT 1
- Change `.publicKey()` method on builders to `.identifier()`.
- Add stateful unconfirmed nonce tracking to account requests
- Remove kwilSigner pass to kwil.call() HOT 1
- Add optional nonce config
- Feature request: Blocking on kwil.execute()
- Replace cache with a third party library
- Problem: `CompiledKuneiform` type is not available on the exported `Types` object
- Problem: `NodeKwil` does not respect logout HOT 2
- Problem: `foreign_call` not supported in kwil-js HOT 1
- Feature: Add generics to `kwil.call` and `kwil.selectQuery`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kwil-js.