-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: refactor Delia #10
base: main
Are you sure you want to change the base?
Conversation
This refactor introduces a bunch of new features, while temporarily removing others. Added: * TS support * Biome support * SCALE encoding support * Libp2p support * FE is now "detached" - doesn't need to be served by the SP Removed: * Time/block conversion * Upload to get the Piece CID & size
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 was able to get it running and propose a deal succesfully. However, there are some docs missing. It would be nice the have some docs on how the flow works, prerequisites for running delia (run testnet, register storage provider, add market account balance for sp and client), getting the piece cid/size (ik this will be upgraded soon), etc.
I think you were using a dev account for testing, I used a user generated wallet and had to add the market balance too
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.
Some other notes:
- When you select your Polkadot extension wallet, it doesn't rellow the webpage automatically and shows you the error. You need to hit F5.
- When you don't start the testnet, there is an infinite loading bar.
- Would be useful to have a *nix flake for this one.
- Eslint is not configured for production like it should.
- The instructions on how to run it should be in the README.md
- delia needs to detect network issues and raise errors accordingly
DealPreparation = 1, | ||
} | ||
|
||
function setupTypeRegistry(): TypeRegistry { |
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.
Should this be hardcoded or in the future come from the metadata.scale
?
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.
This is actually how it's done. Parity doesn't really offer a translation from the SCALE file
import { type Ctx, GlobalCtx } from "./GlobalCtx"; | ||
|
||
export function GlobalCtxProvider(props: React.PropsWithChildren<Ctx>) { | ||
const value = useMemo(() => ({ registry: props.registry }), [props.registry]); |
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'm not sure this memo is necessary here, GlobalCtxProvider
never ever changes as of now. I might be rusty with React though...
}, | ||
"ignore": [ | ||
"tsconfig*.json", | ||
"TimeBlockConverter.tsx" |
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.
If TimeBlockConverter.tsx
it's not used, why is it here?
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.
So Biome doesn't complain
const timeOptions = useMemo(() => generateTimeOptions(), []); | ||
|
||
useEffect(() => { | ||
let mounted = true; | ||
|
||
const connectWebSocket = () => { | ||
if (wsRef.current?.readyState === WebSocket.OPEN) return; | ||
|
||
wsRef.current = new WebSocket("ws://127.0.0.1:42069"); | ||
|
||
wsRef.current.onopen = () => { | ||
console.log("Connected to chain for block number"); |
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'm afraid of the complexity of this entire component, if it's not used, should we just delete it?
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.
This is not used right now, I was keeping it to add it but I can remove and fetch it from the git history
if (proposeDealResponse instanceof Error) { | ||
toast.error(proposeDealResponse.message); | ||
return; | ||
} |
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.
This is not Rust, we don't do instanceof, we catch Errors.
const signedRpc = await validDealProposal.toSignedRpc(p, ctx.registry, account); | ||
const publishDealResponse = await callPublishDeal( | ||
signedRpc, | ||
{ ...address, port: 8000 }, // We can't hardcode this but we can't do anything about it *right now* |
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.
{ ...address, port: 8000 }, // We can't hardcode this but we can't do anything about it *right now* | |
{ ...address, port: DEFAULT_RPC_PORT }, // We can't hardcode this but we can't do anything about it *right now* |
for some reason sometimes it's 8000, sometimes it's 8001?
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.
Yes, one is the HTTP upload server and the other is the JSON RPC
|
||
// TODO: type this | ||
const providerPeerId = provider.peerId; | ||
// TODO: catch the error? |
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 do
const [loading, setLoading] = useState(false); | ||
|
||
const updateProviderSelection = useCallback((newProvider: string) => { | ||
selectProviders((oldState) => { |
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.
What's going on here? This callback works like a toggle? Should it just accept the 'list of selected providers'?
account: InjectedAccountWithMeta; | ||
}) { | ||
const [dealProposal, setDealProposal] = useState( | ||
DealProposal.default().copyUpdate("client", account.address), |
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.
rusty rust
This refactor introduces a bunch of new features, while temporarily removing others.
Added:
Removed:
Closes #7
Running instructions:
In 3 shells:
pnpm run dev
just testnet
examples/start_sp.sh