Skip to content

Commit

Permalink
fix before oss publish
Browse files Browse the repository at this point in the history
  • Loading branch information
taijusanagi committed Aug 15, 2019
1 parent 5e42397 commit 3f3e68c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 105 deletions.
7 changes: 3 additions & 4 deletions src/satellites.ts
Expand Up @@ -178,8 +178,8 @@ export class Satellites {
for (const order of orders.records) {
const assetData = assetDataUtils.decodeERC721AssetData(order.order.makerAssetData)
const tokenId = assetData.tokenId.toString()
if(!this.whitelists || this.whitelists.includes(assetData.tokenAddress)) {
if(!tokenAddresses || tokenAddresses.length === 0 || tokenAddresses.includes(assetData.tokenAddress)) {
if (!this.whitelists || this.whitelists.includes(assetData.tokenAddress)) {
if (!tokenAddresses || tokenAddresses.length === 0 || tokenAddresses.includes(assetData.tokenAddress)) {
if (!refinedOrders[assetData.tokenAddress]) {
refinedOrders[assetData.tokenAddress] = {}
}
Expand All @@ -198,7 +198,7 @@ export class Satellites {
async getOrder(assetContractAddress: string, tokenId: number) {
let order: SignedOrder | undefined
let price: BigNumber
if(!this.whitelists || this.whitelists.includes(assetContractAddress)) {
if (!this.whitelists || this.whitelists.includes(assetContractAddress)) {
const assetData = assetDataUtils.encodeERC721AssetData(assetContractAddress, new BigNumber(tokenId))
const orderbookRequest = {
baseAssetData: assetData,
Expand All @@ -218,5 +218,4 @@ export class Satellites {
}
return order
}

}
4 changes: 0 additions & 4 deletions templates/components/molecules/Asset.vue
Expand Up @@ -44,10 +44,6 @@ export default class Asset extends Vue {
</script>

<style scoped>
a {
text-decoration: none;
}
.opacity {
opacity: 0.6;
}
Expand Down
98 changes: 23 additions & 75 deletions templates/components/molecules/Buttons.vue
Expand Up @@ -96,8 +96,6 @@
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
const contracts = {}
@Component
export default class Buttons extends Vue {
dialogDisplay = false
Expand All @@ -108,7 +106,7 @@ export default class Buttons extends Vue {
@Prop() asset
computeFee() {
return this.$config.defaultRatio / this.$config.perBase
return this.$config.defaultRatio / this.$config.feePer
}
openDialog(dialogKey) {
this.dialogDisplay = true
Expand All @@ -132,26 +130,11 @@ export default class Buttons extends Vue {
this.openDialog(6)
}
async sell() {
let approved = false
if (!this.$config.exceptions[this.asset.asset_contract.address]) {
approved = await this.$satellites.erc721Token.isApprovedForAllAsync(
this.asset.asset_contract.address,
this.$store.state.address,
this.$satellites.contractAddresses.erc721Proxy
)
} else {
const name = this.$config.exceptions[this.asset.asset_contract.address][0].name
if (!contracts[this.asset.asset_contract.address]) {
const contract = new this.$web3.eth.Contract(
this.$config.exceptions[this.asset.asset_contract.address],
this.asset.asset_contract.address
)
contracts[this.asset.asset_contract.address] = contract
}
const operator = await contracts[this.asset.asset_contract.address].methods[name](this.asset.token_id).call()
approved = operator.toLowerCase() === this.$satellites.contractAddresses.erc721Proxy
}
const approved = await this.$satellites.erc721Token.isApprovedForAllAsync(
this.asset.asset_contract.address,
this.$store.state.address,
this.$satellites.contractAddresses.erc721Proxy
)
if (!approved) {
await this.executeApprove()
} else {
Expand All @@ -172,57 +155,28 @@ export default class Buttons extends Vue {
async executeApprove() {
this.openDialog(3)
if (!this.$config.exceptions[this.asset.asset_contract.address]) {
const txhash = await this.$satellites.erc721Token.setApprovalForAllAsync(
this.asset.asset_contract.address,
this.$store.state.address,
this.$satellites.contractAddresses.erc721Proxy,
true
)
this.etherscan = `${this.$config.etherscan}${txhash}`
this.openDialog(6)
} else {
const name = this.$config.exceptions[this.asset.asset_contract.address][1].name
if (!contracts[this.asset.asset_contract.address]) {
const contract = new this.$web3.eth.Contract(
this.$config.exceptions[this.asset.asset_contract.address],
this.asset.asset_contract.address
)
contracts[this.asset.asset_contract.address] = contract
}
const self = this
await contracts[this.asset.asset_contract.address].methods[name](
this.$satellites.contractAddresses.erc721Proxy,
this.asset.token_id
)
.send({ from: this.$store.state.address })
.on('transactionHash', function(txhash) {
self.etherscan = self.$config.etherscan + txhash
self.openDialog(6)
})
}
const txhash = await this.$satellites.erc721Token.setApprovalForAllAsync(
this.asset.asset_contract.address,
this.$store.state.address,
this.$satellites.contractAddresses.erc721Proxy,
true
)
this.etherscan = `${this.$config.etherscan}${txhash}`
this.openDialog(6)
}
async executeBuy() {
this.openDialog(4)
// let recipients: string[] | undefined
// let fees: string[] | undefined
// const keys = Object.keys(this.$config.addressToFee)
// for (let i = 0; i < keys.length; i++) {
// const feeRatio = this.$config.addressToFee[i].ratio / this.$config.feeBase
// const fee = this.asset.order.takerAssetAmount.times(feeRatio)
// fees.push(fee)
// recipients.push(this.$config.addressToFee[i].recipients)
// }
const fees: number[] = []
const recipients: string[] = []
for (let i = 0; i < this.$config.feeDistribution.length; i++) {
const ratio = this.$config.feeDistribution[i].ratio / this.$config.feeBase
const fee = this.asset.order.takerAssetAmount.times(ratio)
fees.push(fee)
recipients.push(this.$config.feeDistribution[i].recipient)
}
const feeRatio0 = this.$config.addressToFee[0].ratio / this.$config.feeBase
const fee0 = this.asset.order.takerAssetAmount.times(feeRatio0)
const feeRatio1 = this.$config.addressToFee[1].ratio / this.$config.feeBase
const fee1 = this.asset.order.takerAssetAmount.times(feeRatio1)
const fees = [fee0, fee1]
const recipients = [this.$config.addressToFee[0].recipients, this.$config.addressToFee[1].recipients]
console.log(fees)
console.log(recipients)
const txhash = await this.$satellites.buy(this.$store.state.address, this.asset.order, recipients, fees)
this.etherscan = `${this.$config.etherscan}${txhash}`
this.openDialog(6)
Expand All @@ -236,9 +190,3 @@ export default class Buttons extends Vue {
}
}
</script>

<style scoped>
a {
text-decoration: none;
}
</style>
6 changes: 0 additions & 6 deletions templates/components/organisms/Header.vue
Expand Up @@ -30,9 +30,3 @@ import { Component, Vue } from 'vue-property-decorator'
@Component
export default class Header extends Vue {}
</script>

<style scoped>
a {
text-decoration: none;
}
</style>
6 changes: 6 additions & 0 deletions templates/layouts/default.vue
Expand Up @@ -35,3 +35,9 @@ export default class DefaultLayout extends Vue {
}
}
</script>

<style>
a {
text-decoration: none;
}
</style>
5 changes: 0 additions & 5 deletions templates/nuxt.config.ts
Expand Up @@ -2,11 +2,6 @@ import NuxtConfiguration from '@nuxt/config'

const nuxtConfig: NuxtConfiguration = {
mode: 'spa',

env: {
NETWORK_ID: process.env.NETWORK_ID || '1',
RELAYER: process.env.RELAYER || 'https://relayer-mainnet.nftsatellites.com/v2/'
},
/*
** Headers of the page
*/
Expand Down
20 changes: 10 additions & 10 deletions templates/plugins/config.ts
@@ -1,12 +1,12 @@
const networkId = Number(process.env.NETWORK_ID) || 1
const relayer = process.env.RELAYER || 'http://relayer-mainnet.nftsatellites.com/v2/'
const ga = process.env.GA || 'UA-130401695-4'
const feeBase = process.env.FEE_BASE || 10000
const feePer = process.env.FEE_PER || 100
const networkId = 4
const relayer = 'http://localhost:3000/v2/'
const ga = 'UA-130401695-4'
const feeBase = 10000
const feePer = 100
const satellitesAddress = '0x764Fe0b6dF8575b30bCfd0c9Bb2A7ADb390b5359'
const satellitesFeeRatio = process.env.SATELLITES_FEE_RATIO || 100
const ownerAddress = process.env.OWNER_ADDRESS || satellitesAddress
const ownerFeeRatio = Number(process.env.OWNER_FEE_RARIO) || 900
const satellitesFeeRatio = 100
const ownerAddress = satellitesAddress
const ownerFeeRatio = 900

const networkIdToInfura: { [networkId: number]: string } = {
1: 'https://mainnet.infura.io/',
Expand Down Expand Up @@ -43,11 +43,11 @@ const networkIdToTokens: { [networkId: number]: any[] } = {
const feeDistribution = [
// first fee recipient is satellites address. This Fee goes to issueHunt and is returned to the developer.
{
recipients: satellitesAddress,
recipient: satellitesAddress,
ratio: satellitesFeeRatio
},
{
recipients: ownerAddress,
recipient: ownerAddress,
ratio: ownerFeeRatio
}
]
Expand Down
1 change: 0 additions & 1 deletion templates/plugins/initialize.ts
Expand Up @@ -9,7 +9,6 @@ export default async function({ store, isServer }, inject) {
}

inject('config', config)

const web3 = (window as any).web3
const ethereum = (window as any).ethereum

Expand Down

0 comments on commit 3f3e68c

Please sign in to comment.