Skip to content
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

Important details NFT #53

Merged
merged 3 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import { store } from '@/store.js'

export default {
name: 'ImportantDetails',
name: 'ImportantDetailsErc20',
props: {
rskFee: {
type: Number,
Expand Down
98 changes: 98 additions & 0 deletions src/components/importantDetails/ImportantDetailsErc721.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<template>
<div class="important-details mt-5 mb-5">
<h2 id="important-details" class="subtitle">Important details</h2>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">{{ sharedState.rskConfig.name }}</th>
<th scope="col">{{ sharedState.sideConfig.name }}</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Fee</th>
<td>{{ rskFeeFormated }}</td>
<td>{{ sideFeeFormated }}</td>
</tr>
<tr>
<th scope="row">Avarage seconds per block</th>
<td>~ {{ sharedState.rskConfig.secondsPerBlock }} seconds</td>
<td>~ {{ sharedState.sideConfig.secondsPerBlock }} seconds</td>
</tr>
<tr>
<th scope="row">Confirmations needed</th>
<td>
{{ rskConfirmationsNft?.confirmations }} blocks (~ {{ rskConfirmationsNft?.time }}) +
{{ votingTime }}
</td>
<td>
{{ sideConfirmationsNft?.confirmations }} blocks (~ {{ sideConfirmationsNft?.time }}) +
{{ votingTime }}
</td>
</tr>
<tr>
<th scope="row">Signatories</th>
<td>{{ rskFedMembersLen }}</td>
<td>{{ sideFedMembersLen }}</td>
</tr>
</tbody>
</table>
</div>
</template>

<script>
import { store } from '@/store.js'

export default {
name: 'ImportantDetailsErc721',
props: {
rskFeeNft: {
type: Number,
required: true,
},
sideFeeNft: {
type: Number,
required: true,
},
rskConfirmationsNft: {
type: Object,
required: true,
},
sideConfirmationsNft: {
type: Object,
required: true,
},
rskFedMembers: {
type: Array,
required: true,
},
sideFedMembers: {
type: Array,
required: true,
},
},
data() {
return {
sharedState: store.state,
}
},
computed: {
votingTime() {
return '2 minutes voting'
},
rskFeeFormated() {
return this.rskFeeNft * 100 + '%'
},
sideFeeFormated() {
return this.sideFeeNft * 100 + '%'
},
rskFedMembersLen() {
return this.rskFedMembers.length
},
sideFedMembersLen() {
return this.sideFedMembers.length
},
},
}
</script>
2 changes: 1 addition & 1 deletion src/constants/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const TEST_NET_RSK_CROSS_RINKEBY_CONFIG = {
feePercentageDivider: 10_000,
crossToNetwork: TEST_NET_RINKEBY_CONFIG,
tokenPrefix: 'b',
mainToken: TEST_NET_RSK_CROSS_BINANCE_MAIN_TOKEN,
mainToken: TEST_NET_RSK_CROSS_KOVAN_MAIN_TOKEN,
isRsk: true,
isSide: false,
tokens: [],
Expand Down
66 changes: 60 additions & 6 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,30 @@
:new-transaction="newTransaction"
/>

<ImportantDetails
<ImportantDetailsErc20
v-if="globalState.currentTokenType == tokenTypeErc20"
:rsk-fee="rskFee"
:side-fee="sideFee"
:rsk-confirmations="rskConfirmations"
:side-confirmations="sideConfirmations"
:rsk-fed-members="rskFedMembers"
:side-fed-members="sideFedMembers"
/>
<ImportantDetailsErc721
v-else
:rsk-fee-nft="rskFeeNft"
:side-fee-nft="sideFeeNft"
:rsk-confirmations-nft="rskConfirmationsNft"
:side-confirmations-nft="sideConfirmationsNft"
:rsk-fed-members="rskFedMembers"
:side-fed-members="sideFedMembers"
/>

<TokenList
v-if="globalState.currentTokenType == tokenTypeErc20"
v-if="
globalState.currentTokenType == tokenTypeErc20 &&
sharedState.rskConfig?.tokens.length > 0
"
:types-limits="typesLimits"
/>
</div>
Expand All @@ -45,6 +58,7 @@

// ------ ABIS -----
import BRIDGE_ABI from '@/constants/abis/bridge.json'
import NFT_BRIDGE from '@/constants/abis/nft-bridge.json'
import ALLOW_TOKENS_ABI from '@/constants/abis/allowTokens.json'
import FEDERATION_ABI from '@/constants/abis/federation.json'
import { TOKEN_TYPE_ERC_20 } from '@/constants/tokenType.js'
Expand All @@ -57,7 +71,8 @@ import { retry3Times, blocksToTime } from '@/utils'
import Title from '@/components/title/Title.vue'
// import SearchTransaction from '@/components/transactions/SearchTransaction.vue'
import Transactions from '@/components/transactions/Transactions.vue'
import ImportantDetails from '@/components/importantDetails/ImportantDetails.vue'
import ImportantDetailsErc20 from '@/components/importantDetails/ImportantDetailsErc20.vue'
import ImportantDetailsErc721 from '@/components/importantDetails/ImportantDetailsErc721.vue'
import TokenList from '@/components/tokenList/TokenList.vue'
import { store } from '@/store.js'
import globalStore from '@/stores/global.store'
Expand All @@ -68,7 +83,8 @@ export default {
components: {
FormWrapper,
Title,
ImportantDetails,
ImportantDetailsErc20,
ImportantDetailsErc721,
TokenList,
Transactions,
},
Expand All @@ -78,8 +94,12 @@ export default {
typesLimits: [],
rskFee: 0,
sideFee: 0,
rskFeeNft: 0,
sideFeeNft: 0,
rskConfirmations: {},
sideConfirmations: {},
rskConfirmationsNft: {},
sideConfirmationsNft: {},
rskFedMembers: [],
sideFedMembers: [],
newTransaction: null,
Expand All @@ -106,8 +126,8 @@ export default {
console.log('Error in getFeePercentage', err)
})

const ethBridge = new sideWeb3.eth.Contract(BRIDGE_ABI, sideConfig.bridge)
retry3Times(ethBridge.methods.getFeePercentage().call).then(fee => {
const sideBridge = new sideWeb3.eth.Contract(BRIDGE_ABI, sideConfig.bridge)
retry3Times(sideBridge.methods.getFeePercentage().call).then(fee => {
data.sideFee = fee / sideConfig.feePercentageDivider
})
// We have the premice that the limits will be equal in Side and in RSK
Expand Down Expand Up @@ -149,6 +169,40 @@ export default {
retry3Times(sideFederation.methods.getMembers().call).then(
members => (data.sideFedMembers = members),
)

// NFT
if (rskConfig.nftBridge == undefined || sideConfig.nftBridge == undefined) {
return
}

const rskBridgeNft = new rskWeb3.eth.Contract(NFT_BRIDGE, rskConfig.bridge)
rskBridgeNft.methods
.getFixedFee()
.call()
.then(fee => {
debugger
data.rskFeeNft = fee / rskConfig.feePercentageDivider
})
.catch(err => {
// eslint-disable-next-line no-console
console.log('Error in getFixedFee', err)
})

const sideBridgeNft = new sideWeb3.eth.Contract(NFT_BRIDGE, sideConfig.bridge)
retry3Times(sideBridgeNft.methods.getFixedFee().call).then(fee => {
data.sideFeeNft = fee / sideConfig.feePercentageDivider
})

const NFT_FIXED_CONFIRMATIONS_BLOCK = 3 // maybe we are going to define it into the nft bridge contract
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe add a Github issue / Jira ticket under 'technical debt' to not lose sight of this comment


data.rskConfirmationsNft = {
confirmations: NFT_FIXED_CONFIRMATIONS_BLOCK,
time: blocksToTime(NFT_FIXED_CONFIRMATIONS_BLOCK, rskConfig.secondsPerBlock),
}
data.sideConfirmationsNft = {
confirmations: NFT_FIXED_CONFIRMATIONS_BLOCK,
time: blocksToTime(NFT_FIXED_CONFIRMATIONS_BLOCK, sideConfig.secondsPerBlock),
}
},
}
</script>