-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bcca61
commit 4dca40c
Showing
14 changed files
with
279 additions
and
68 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
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,73 @@ | ||
import React, { useMemo, useState } from 'react'; | ||
import { Networks } from 'src/types/networks'; | ||
import { CYBERNET_CONTRACT_ADDRESS } from '../constants'; | ||
|
||
type ContractType = 'graph' | 'ml'; | ||
|
||
type Contract = { | ||
name: string; | ||
address: string; | ||
apr: number; | ||
}; | ||
|
||
const data = [ | ||
{ | ||
name: 'graph', | ||
type: 'graph', | ||
address: CYBERNET_CONTRACT_ADDRESS, | ||
// apr: 35, | ||
// docs: 'https://docs.spacepussy.ai', | ||
network: Networks.SPACE_PUSSY, | ||
}, | ||
{ | ||
name: 'ml', | ||
type: 'ml', | ||
address: '-', | ||
// apr: 20, | ||
// docs: 'https://docs.spacepussy.ai', | ||
network: Networks.SPACE_PUSSY, | ||
}, | ||
]; | ||
|
||
const CybernetContext = React.createContext<{ | ||
contracts: Contract[]; | ||
selectContract: (address: string) => void; | ||
selectedContract: string | null; | ||
}>({ | ||
contracts: {}, | ||
selectContract: null, | ||
selectedContract: null, | ||
}); | ||
|
||
export function useCybernet() { | ||
return React.useContext(CybernetContext); | ||
} | ||
|
||
function CybernetProvider({ children }: { children: React.ReactNode }) { | ||
const [selectedContractAddress, setSelectedContractAddress] = useState( | ||
CYBERNET_CONTRACT_ADDRESS | ||
); | ||
const [contracts] = useState<(typeof CybernetContext)['']>(data); | ||
|
||
const selectedContract = contracts.find( | ||
(contract) => contract.address === selectedContractAddress | ||
); | ||
|
||
console.debug('selectedContract', selectedContract); | ||
|
||
return ( | ||
<CybernetContext.Provider | ||
value={useMemo(() => { | ||
return { | ||
contracts, | ||
selectContract: setSelectedContractAddress, | ||
selectedContract, | ||
}; | ||
}, [contracts, selectedContract])} | ||
> | ||
{children} | ||
</CybernetContext.Provider> | ||
); | ||
} | ||
|
||
export default CybernetProvider; |
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,68 @@ | ||
export const texts: { | ||
[key: string]: { | ||
default: string | { single: string; plural: string }; | ||
graph: string | { single: string; plural: string }; | ||
}; | ||
} = { | ||
contract: { | ||
default: 'contract', | ||
graph: 'verse', | ||
}, | ||
root: { | ||
default: 'root', | ||
graph: 'board', | ||
}, | ||
subnetwork: { | ||
default: 'subnet', | ||
graph: { | ||
single: 'faculty', | ||
plural: 'faculties', | ||
}, | ||
}, | ||
uid: { | ||
default: 'uid', | ||
graph: 'card', | ||
}, | ||
contractOwner: { | ||
default: 'owner', | ||
graph: 'rector', | ||
}, | ||
subnetOwner: { | ||
default: 'owner', | ||
graph: 'dean', | ||
}, | ||
delegate: { | ||
default: 'delegate', | ||
graph: 'mentor', | ||
}, | ||
delegator: { | ||
default: 'delegator', | ||
graph: 'learner', | ||
}, | ||
validator: { | ||
default: 'validator', | ||
graph: 'professor', | ||
}, | ||
rootValidator: { | ||
default: 'lead', | ||
graph: 'professor', | ||
}, | ||
miner: { | ||
default: 'miner', | ||
graph: 'teacher', | ||
}, | ||
}; | ||
|
||
// fix | ||
export type Texts = | ||
| 'contract' | ||
| 'root' | ||
| 'subnetwork' | ||
| 'uid' | ||
| 'contractOwner' | ||
| 'subnetOwner' | ||
| 'delegate' | ||
| 'delegator' | ||
| 'validator' | ||
| 'rootValidator' | ||
| 'miner'; |
File renamed without changes.
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
Oops, something went wrong.