Skip to content

Instantly share code, notes, and snippets.

@thelostone-mc
Last active August 13, 2019 13:15
Show Gist options
  • Save thelostone-mc/9bd990d38eeca3ccb31db975d2710a47 to your computer and use it in GitHub Desktop.
Save thelostone-mc/9bd990d38eeca3ccb31db975d2710a47 to your computer and use it in GitHub Desktop.

The following doc explores how we'd go about updating the codebase to support cross chain integrations.

These requires a lot of documentation + strict guidelines which engineering WILL have to f ollow to ensure we can get a decent implementation of the idea listed below of it.

Currently the following are tightly coupled with Ethereum + Metamask.

  • Frontend (FE)
  • Backend (BE)
  • Data Model (DB)

^ Decoupling that and make it super generic is what I've based my ideas on

This would inolve rewriting the every product one by one! As that is not a small task -> It makes sense to start with the smallest product we've got aka TIPS.

NOTE: A couple of terms I refer to in the below description are described here in detail _FE + BE : frontend + backend _ core business logic : concerned with the logic on how the tips feature works irrespective of the underlying blockchain used orchestrator : responsible/smart enough to deciding which blockchain flow to invoke psuedo-interface : a well documented README consisting of what function every blockchain would have to implement. Every function in the psuedo interface WOULD have be defined in the blockchain implementation.

FE + BE
Endstate:

When we onboard a new blockchain, the core business logic for tips should not change (except for a few lines of code of integrating) The FE + BE would both have their version of orchestrator and this what the core business logic would interact with

How do we get there ?

Since python + JS don't support interfaces, we'd have to create a pseudo interface to ensure easy onboarding of new chains can be done in an isolated manner without touching the rest of the app

Ideally we'd have have something along the lines of

// frontend
psuedo-interface Tip {
  send()    {}  // Business logic to send money to address 
  recieve() {}  // Business logic to recieve money from address
}

// backend
psuedo-interface Tip {
  send()    {}  // Business logic + save money to address 
  recieve() {}  // Business logic to recieve money from address
}

The FE / BE would talk to it's respective orchestrator which would be responsible for for deciding which implementation of the interface to be invoked.


Data Model Design

Following Seperation of Concern : Cleaned way would be creating a new model for each blockchain

Tip Model which would store generic infomration which we would need Tip Model - { id, from_profile, to_profile, amount} Aka Ethereum Tips would have Model Tip-Ethereum - {id, tip_id, gas_fees, address} While Ontology Tips would have Model Tip-Ontology - {id, tip_id, xyz} // we don't know what xyz could be

Anything we need to store in terms of the Tips on Gitcoin would be in Tip Model, Any remotely specific field to a particular blockchain and not the Tips product itself would reside in it's own model


Adding a new chain would involve

  • creating a new implementation for FE + BE which would talk to it's respective data model
  • wiring it to the FE + BE orchestrator

Removing a chain would involve

  • removing the blockchain implmentation of the interface
  • remove the handling logic within the orchestrator in FE + BE
@owocki
Copy link

owocki commented Aug 13, 2019

Here is a visual of what I want to do architecture-wise. design is meant to minimize the amount of work for each cross-chain integration.:

Image 2019-08-13 at 9 11 51 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment