Skip to content

Commit

Permalink
Merge pull request #213 from keyko-io/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jernejpregelj authored Mar 3, 2021
2 parents 45da211 + 8440c5f commit fe9fb34
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 57 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filecoin-verifier-frontend",
"version": "1.2.7",
"version": "1.3.3",
"private": true,
"dependencies": {
"@emotion/react": "^11.0.0-next.13",
Expand Down
24 changes: 24 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,30 @@
}
}

.tabs {
position: absolute;
height: 25px;
left: 1px;
top: 440px;
background: #ffffff;
width: 100%;
text-align: center;
border-bottom: 1px solid #ccc;
display: flex;
justify-content: space-evenly;
color: #33a7ff;

.tab {
cursor: pointer;
}
}

.multisiginput {
width: 200px;
margin-top: 5px;
padding: 5px;
}

.buttons {
position: absolute;
height: 96px;
Expand Down
25 changes: 22 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class App extends Component<{}, States> {
}
}
return '0'
}

}
updateSearch = () => {
this.context.search(this.state.search)
}
Expand Down Expand Up @@ -200,6 +200,25 @@ class App extends Component<{}, States> {
/>
</div>
</div>
{this.context.wallet.multisig && this.context.viewroot === false ?
<React.Fragment>
<div className="headertitles">Multisig address</div>
<div className="accountentry">
<div>
<div className="datacapdata">
<span className="datacap">Datacap: {bytesToiB(this.getVerifierAmount(this.context.wallet.multisigAddress))}</span>
{this.context.wallet.multisig ?
<img src={Network} alt="network" />
: null}
</div>
<div className="accountdata">
<span className="accountaddress">{this.context.wallet.multisigAddress.length > 20 ? addressFilter(this.context.wallet.multisigAddress): this.context.wallet.multisigAddress}</span>
<span className="copyaddress"><SVG.CopyAndPaste height='15px' /></span>
</div>
</div>
</div>
</React.Fragment>
: null}
<div className="headertitles">Account addresses</div>
{this.context.wallet.accounts.map((account: any, index: number) => {
return <div key={index} className="accountentry" style={{ backgroundColor: index === this.context.wallet.walletIndex ? '#C7C7C7' : 'inherit' }}>
Expand All @@ -224,7 +243,7 @@ class App extends Component<{}, States> {
</div>
: null}
<div className="headertitles">{this.context.viewroot ? 'Rootkey Holder ID' : 'Approved Notary ID'}</div>
<div>{addressFilter(this.context.wallet.activeAccount)}</div>
<div>{addressFilter(this.context.wallet.activeAccount)}, {this.context.wallet.multisig && this.context.viewroot === false ? this.context.wallet.multisigAddress.length > 20 ? addressFilter(this.context.wallet.multisigAddress): this.context.wallet.multisigAddress : null}</div>
</div>
<div className="wallet">
<div className="WalletMenu">
Expand Down
3 changes: 2 additions & 1 deletion src/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Pagination extends Component<PaginationProps> {
state = {
initialIndex: 0,
actualPage: 1,
pages: []
pages: [],

}

componentDidMount() {
Expand Down
7 changes: 6 additions & 1 deletion src/components/overview/Notary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ export default class Notary extends Component<NotaryProps, NotaryStates> {
if (address.length < 12) {
address = await this.context.wallet.api.actorKey(address)
}
let messageID = await this.context.wallet.api.verifyClient(address, BigInt(datacap), this.context.wallet.walletIndex)
let messageID
if(this.context.wallet.multisig){
messageID = await this.context.wallet.api.multisigVerifyClient(this.context.wallet.multisigID, address, BigInt(datacap), this.context.wallet.walletIndex)
} else {
messageID = await this.context.wallet.api.verifyClient(address, BigInt(datacap), this.context.wallet.walletIndex)
}
// github update
this.context.updateGithubVerified(request.number, messageID, address, request.data.datacap)

Expand Down
66 changes: 58 additions & 8 deletions src/context/Wallet/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ interface WalletProviderStates {
message: string
loadWallet: any
dispatchNotification: any
multisig: boolean
multisigAddress: string
multisigActor: string
multisigID: string
}

type Props = {
Expand All @@ -52,7 +56,7 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
this.setState(state, resolve)
});
}
loadLedger = async () => {
loadLedger = async (options: any = {}) => {
try {
const wallet = new LedgerWallet()
await wallet.loadWallet(this.state.networkIndex)
Expand All @@ -71,6 +75,23 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
}
}
}
let multisigInfo: any = {}
let multisigActor: string = ''
let multisigID: string = ''
if (options.multisig) {
try {
if (options.multisigAddress.length > 20) {
multisigID = await wallet.api.actorAddress(options.multisigAddress)
} else {
multisigID = options.multisigAddress
}
multisigInfo = await wallet.api.multisigInfo(multisigID)
multisigActor = await wallet.api.actorKey(multisigInfo.signers[0])
} catch (e) {
this.state.dispatchNotification('Multisig not found')
return false
}
}
await this.setStateAsync({
isLogged: true,
isLoading: false,
Expand All @@ -95,7 +116,11 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
},
activeAccount: lastWallet ? lastWallet : accounts[0],
accounts,
accountsActive
accountsActive,
multisig: options.multisig ? true : false,
multisigAddress: options.multisig ? options.multisigAddress : '',
multisigActor: options.multisig ? multisigActor : '',
multisigID: multisigID
})
// this.loadGithub()
return true
Expand All @@ -109,7 +134,7 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
}
}

loadBurner = async () => {
loadBurner = async (options: any = {}) => {
try {
const wallet = new BurnerWallet()
await wallet.loadWallet(this.state.networkIndex)
Expand All @@ -128,6 +153,23 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
}
}
}
let multisigInfo: any = {}
let multisigActor: string = ''
let multisigID: string = ''
if (options.multisig) {
try {
if (options.multisigAddress.length > 20) {
multisigID = await wallet.api.actorAddress(options.multisigAddress)
} else {
multisigID = options.multisigAddress
}
multisigInfo = await wallet.api.multisigInfo(multisigID)
multisigActor = await wallet.api.actorKey(multisigInfo.signers[0])
} catch (e) {
this.state.dispatchNotification('Multisig not found')
return false
}
}
this.setStateAsync({
isLogged: true,
isLoading: false,
Expand All @@ -138,7 +180,11 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
walletIndex: walletCookieIndex !== -1 ? walletCookieIndex : 0,
activeAccount: lastWallet ? lastWallet : accounts[0],
accounts,
accountsActive
accountsActive,
multisig: options.multisig ? true : false,
multisigAddress: options.multisig ? options.multisigAddress : '',
multisigActor: options.multisig ? multisigActor : '',
multisigID: multisigID
})
return true
// this.loadGithub()
Expand Down Expand Up @@ -213,14 +259,14 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
},
balance: 0,
message: '',
loadWallet: async (type: string) => {
loadWallet: async (type: string, options: any = {}) => {
this.setState({ isLoading: true })
switch (type) {
case 'Ledger':
const resLedger = await this.loadLedger()
const resLedger = await this.loadLedger(options)
return resLedger
case 'Burner':
const resBurner = await this.loadBurner()
const resBurner = await this.loadBurner(options)
return resBurner
default:
return false
Expand All @@ -235,7 +281,11 @@ class WalletProvider extends React.Component<Props, WalletProviderStates> {
timeout: 5000
}
});
}
},
multisig: false,
multisigAddress: '',
multisigActor: '',
multisigID: ''
}

render() {
Expand Down
9 changes: 8 additions & 1 deletion src/modals/AddClientModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ class AddClientModal extends Component<ModalProps, States> {

console.log("datacap: " + this.state.datacap)
console.log("fullDatacap: " + fullDatacap)
let messageID = await this.context.wallet.api.verifyClient(this.state.address, BigInt(fullDatacap), this.context.wallet.walletIndex);

let messageID
if(this.context.wallet.multisig){
messageID =await this.context.wallet.api.multisigVerifyClient(this.context.wallet.multisigID, this.state.address, BigInt(fullDatacap), this.context.wallet.walletIndex)
} else {
messageID = await this.context.wallet.api.verifyClient(this.state.address, BigInt(fullDatacap), this.context.wallet.walletIndex)
}

if (this.props.newDatacap) {
this.context.updateGithubVerified(this.state.issueNumber, messageID, this.state.address, dataCapIssue)
}
Expand Down
Loading

0 comments on commit fe9fb34

Please sign in to comment.