-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update snapshot proposal page * create snpashot proposal workflow * update UI * utilize snapshot js * add snapshot create proposal * add sushi token for testing purpose * correct wrong code * complete creating snapshot proposal * update manage community form
- Loading branch information
Showing
29 changed files
with
806 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
client/scripts/controllers/chain/ethereum/sushi/adapter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { EthereumCoin } from 'adapters/chain/ethereum/types'; | ||
|
||
import { Erc20Factory } from 'Erc20Factory'; | ||
import EthereumAccount from 'controllers/chain/ethereum/account'; | ||
import EthereumAccounts from 'controllers/chain/ethereum/accounts'; | ||
import { ChainBase, IChainAdapter, NodeInfo } from 'models'; | ||
|
||
import ChainEntityController from 'controllers/server/chain_entities'; | ||
import { IApp } from 'state'; | ||
|
||
import EthereumTokenChain from './chain'; | ||
import SushiApi from './api'; | ||
|
||
export default class Sushi extends IChainAdapter<EthereumCoin, EthereumAccount> { | ||
public readonly base = ChainBase.Ethereum; | ||
// TODO: ensure this chainnetwork -> chainclass | ||
public readonly class; | ||
public readonly contractAddress: string; | ||
public readonly isToken = true; | ||
|
||
public chain: EthereumTokenChain; | ||
public accounts: EthereumAccounts; | ||
public hasToken: boolean = false; | ||
|
||
constructor(meta: NodeInfo, app: IApp) { | ||
super(meta, app); | ||
this.chain = new EthereumTokenChain(this.app); | ||
this.accounts = new EthereumAccounts(this.app); | ||
this.class = meta.chain.network; | ||
this.contractAddress = meta.address; | ||
} | ||
|
||
public async initApi() { | ||
await this.chain.resetApi(this.meta); | ||
await this.chain.initMetadata(); | ||
await this.accounts.init(this.chain); | ||
const api = new SushiApi(Erc20Factory.connect, this.meta.address, this.chain.api.currentProvider as any); | ||
await api.init(); | ||
this.chain.contractApi = api; | ||
await super.initApi(); | ||
} | ||
|
||
public async initData() { | ||
await this.chain.initEventLoop(); | ||
await super.initData(); | ||
await this.activeAddressHasToken(this.app.user?.activeAccount?.address); | ||
} | ||
|
||
public async deinit() { | ||
await super.deinit(); | ||
this.accounts.deinit(); | ||
this.chain.deinitMetadata(); | ||
this.chain.deinitEventLoop(); | ||
this.chain.deinitApi(); | ||
} | ||
|
||
public async activeAddressHasToken(activeAddress?: string) { | ||
if (!activeAddress) return false; | ||
const account = this.accounts.get(activeAddress); | ||
const balance = await account.tokenBalance(this.contractAddress); | ||
this.hasToken = balance && !balance.isZero(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Erc20 } from 'Erc20'; | ||
|
||
import ContractApi from 'controllers/chain/ethereum/contractApi'; | ||
|
||
export default class SushiApi extends ContractApi<Erc20> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import EthereumChain from '../chain'; | ||
import ContractApi from './api'; | ||
|
||
// Thin wrapper over EthereumChain to guarantee the `init()` implementation | ||
// on the Governance module works as expected. | ||
export default class SushiChain extends EthereumChain { | ||
public contractApi: ContractApi; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Client from '@snapshot-labs/snapshot.js/src/client'; | ||
|
||
const hubUrl = process.env.SNAPSHOT_APP_HUB_URL || 'https://testnet.snapshot.org'; | ||
const snapshotClient = new Client(hubUrl); | ||
|
||
export default snapshotClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'pages/new_proposal_page.scss'; | ||
|
||
import m from 'mithril'; | ||
|
||
import Sublayout from 'views/sublayout'; | ||
import NewProposalForm from 'views/pages/new_snapshot_proposal/new_proposal_form'; | ||
|
||
const NewSnapshotProposalPage: m.Component<{snapshotId: string}> = { | ||
view: (vnode) => { | ||
|
||
return m(Sublayout, { | ||
class: 'NewProposalPage', | ||
title: `New Snapshot Proposal`, | ||
showNewProposalButton: true, | ||
}, [ | ||
m('.forum-container', [ | ||
m(NewProposalForm, {snapshotId: vnode.attrs.snapshotId}), | ||
]) | ||
]); | ||
} | ||
}; | ||
|
||
export default NewSnapshotProposalPage; |
Oops, something went wrong.