-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add Filecoin #607
Add Filecoin #607
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly have questions. Maybe some of them need to get fixed.
@@ -0,0 +1,85 @@ | |||
import { Network } from '@zondax/izari-filecoin' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot do any SDK imports inside the currency infos. We only want to load the SDK after the core decides that it needs to use the plugin, based on the return await import()
line near the bottom of this file.
Since you only need one string constant, can you hardcode it here?
src/filecoin/FilecoinEngine.ts
Outdated
const backends = { | ||
filRpc: new RPC(env.networkInfo.rpcNode.networkName, { | ||
url: env.networkInfo.rpcNode.url, | ||
token: env.currencyInfo.currencyCode | ||
}), | ||
filscanApi: new Filscan(env.networkInfo.filscanUrl, env.io.fetchCors), | ||
rpcExtra: new RpcExtra(env.networkInfo.rpcNode.url, env.io.fetchCors) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want a bunch of logic inside makeCurrencyEngine
. Ideally it would just be a one line function, return new FooEngine(...)
, but we have other junk in here for historical reasons. Can the constructor just build the backends? Is there some reason for passing them in that I'm not seeing?
src/filecoin/FilecoinTools.ts
Outdated
throw new Error('InvalidWalletType') | ||
} | ||
|
||
const seed = Buffer.from(this.io.random(32)).toString('hex') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use base16.stringify
, instead of Buffer
. If you prefer lowercase, do base16.stringify(...).toLowerCase()
. Buffer is a Node.js thing, not something we should be using in the browser or React Native (although some SDK's do require it).
src/filecoin/Filscan.ts
Outdated
const responseText = await response.text() | ||
const responseBody = JSON.parse(responseText) | ||
return responseBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't cleaning anything in the Filscan subsystem. What would be the consequences if they return something else, like [ "LOL, we shut the server down" ]
? We generally like to see cleaners whenever data comes in from the wild wild internet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small things.
src/filecoin/filecoinTypes.ts
Outdated
export interface FilecoinNetworkInfo { | ||
filscanUrl: string | ||
hdPathCoinType: number | ||
rpcNode: { | ||
networkName: Network | ||
networkName: Network // Network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the comment?
src/filecoin/Filscan.ts
Outdated
} | ||
export const asFilscanOkResponse = <Result extends any>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the extends any
part needed? I think this is the default if you don't say anything.
e3e11fd
to
8c3b863
Compare
8c3b863
to
5451356
Compare
5451356
to
d99d3eb
Compare
CHANGELOG
Dependencies
noneDescription
none