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

Add Filecoin #607

Merged
merged 2 commits into from
Aug 28, 2023
Merged

Add Filecoin #607

merged 2 commits into from
Aug 28, 2023

Conversation

samholmes
Copy link
Collaborator

@samholmes samholmes commented Aug 26, 2023

CHANGELOG

  • added: Add Filecoin

Dependencies

none

Description

none

Copy link
Contributor

@swansontec swansontec left a 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'
Copy link
Contributor

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?

Comment on lines 384 to 391
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)
}
Copy link
Contributor

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?

throw new Error('InvalidWalletType')
}

const seed = Buffer.from(this.io.random(32)).toString('hex')
Copy link
Contributor

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/FilecoinTools.ts Show resolved Hide resolved
Comment on lines 93 to 170
const responseText = await response.text()
const responseBody = JSON.parse(responseText)
return responseBody
Copy link
Contributor

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.

Copy link
Contributor

@swansontec swansontec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things.

export interface FilecoinNetworkInfo {
filscanUrl: string
hdPathCoinType: number
rpcNode: {
networkName: Network
networkName: Network // Network
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the comment?

}
export const asFilscanOkResponse = <Result extends any>(
Copy link
Contributor

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.

@samholmes samholmes merged commit 3c88089 into master Aug 28, 2023
3 checks passed
@samholmes samholmes deleted the sam/filecoin branch August 28, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants