Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ yarn-error.log*
# vercel
.vercel

.env
.env
.env.*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Albert Vo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
90 changes: 68 additions & 22 deletions app/user/userSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const escrowCreateAction = createAction('escrowCreateAction')
const escrowConfirmPaymentAction = createAction('escrowConfirmPaymentAction')
const escrowConfirmDeliveryAction = createAction('escrowConfirmDeliveryAction')
const requestConversionAction = createAction('requestConversionAction')
const escrowDeclineDeliveryAction = createAction('escrowDeclineDeliveryAction')

export const Roles = {
SELLER: 'seller',
Expand Down Expand Up @@ -64,7 +65,7 @@ export const mintNft = createAsyncThunk(
gasPrice: gasPrice,
})
console.log(result, 'mintNft thunk result')
console.log('https://ropsten.etherscan.io/tx/' + result.transactionHash)
console.log('https://rinkeby.etherscan.io/tx/' + result.transactionHash)
return {
name: state.user.preMintingData.name,
price: state.user.preMintingData.price,
Expand Down Expand Up @@ -102,7 +103,11 @@ export const createEscrow = createAsyncThunk(
gasPrice: gasPrice,
})
console.log(result, 'createEscrow')
console.log('https://ropsten.etherscan.io/tx/' + result.transactionHash)
const transactionLink =
'https://rinkeby.etherscan.io/tx/' + result.transactionHash
console.log(transactionLink)
alert('NFT Listing Successful: ' + transactionLink)

return result
} catch (err) {
console.log(err, 'createEscrow error')
Expand Down Expand Up @@ -137,9 +142,10 @@ export const confirmPaymentEscrow = createAsyncThunk(

console.log(result, 'Confirm payment for escrow')
const transactionLink =
'https://ropsten.etherscan.io/tx/' + result.transactionHash
'https://rinkeby.etherscan.io/tx/' + result.transactionHash
console.log(transactionLink)
alert('Transaction Successful: ' + transactionLink)
alert('Payment for NFT Successful: ' + transactionLink)

return result
} catch (err) {
console.log(err, 'confirmPaymentEscrow error')
Expand Down Expand Up @@ -171,39 +177,75 @@ export const confirmDeliveryEscrow = createAsyncThunk(

console.log(result, 'Confirm delivery from escrow')
const transactionLink =
'https://ropsten.etherscan.io/tx/' + result.transactionHash
'https://rinkeby.etherscan.io/tx/' + result.transactionHash
console.log(transactionLink)
alert('Transaction Successful: ' + transactionLink)
alert('Funds/NFT Delivery Successful: ' + transactionLink)

return result
} catch (err) {
console.log(err, 'confirmDeliveryEscrow error')
}
}
)

export const declineDeliveryEscrow = createAsyncThunk(
escrowDeclineDeliveryAction,
async ({}, { getState }) => {
const state = getState()
try {
await window.web3.currentProvider.enable()
const web3 = new Web3(window.ethereum)
const gasPrice = await web3.eth.getGasPrice()
gasPrice = parseInt(gasPrice)
//console.log(gasPrice, ' gasPrice')

const result = await state.user.escrowVMContract.methods
.declinePendingOffer(
'0x4C4a07F737Bf57F6632B6CAB089B78f62385aCaE',
state.user.mintedNftData.tokenId
//
) //NFT address(hard-coded is ok), NFT index, Price
.send({
from: state.user.walletAddress,
gasPrice: gasPrice,
})

console.log(result, 'Decline pending offer from escrow')
const transactionLink =
'https://rinkeby.etherscan.io/tx/' + result.transactionHash
console.log(transactionLink)
alert('Pending Offer Declined Successful: ' + transactionLink)
return result
} catch (err) {
console.log(err, 'declineDeliveryEscrow error')
}
}
)

export const requestConversion = createAsyncThunk(
requestConversionAction,
async ({}, { getState }) => {
//make requests here (with fetch)
// try {
// ;(function () {
const result = {
eth: '1.839,51',
btc: '29.551,10',
eur: '1,07',
} // a mock
return {
eth: result.eth,
btc: result.btc,
eur: result.eur,
const state = getState()
try {
await window.web3.currentProvider.enable()
const web3 = new Web3(window.ethereum)

const resultEthUsd = await state.user.chainlinkVMContract.methods.getEthUsd().call()
const resultBtcUsd = await state.user.chainlinkVMContract.methods.getBtcUsd().call()
const resultEurUsd = await state.user.chainlinkVMContract.methods.getEurUsd().call()
//console.log(resultEthUsd + ' getEthUsd call ')
//console.log(resultBtcUsd + ' getBtcUsd call ')
//console.log(resultEurUsd + ' getEurUsd call ')

return {resultEthUsd, resultBtcUsd, resultEurUsd}
} catch (err) {
console.log(err)
}
// })()
// } catch (err) {
// console.log(err, 'requestConversion error')
// }
}
)



export const userSlice = createSlice({
name: 'user',
initialState,
Expand All @@ -221,6 +263,9 @@ export const userSlice = createSlice({
setEscrowVMContract: (state, action) => {
state.escrowVMContract = action.payload
},
setChainlinkVMContract: (state, action) => {
state.chainlinkVMContract = action.payload
},
setRole: (state, action) => {
state.role = action.payload
},
Expand Down Expand Up @@ -260,6 +305,7 @@ export const {
setWalletAddress,
setVmContract,
setEscrowVMContract,
setChainlinkVMContract,
setPreMintingName,
setPreMintingPrice,
setPreMintingRoyalty,
Expand Down
55 changes: 55 additions & 0 deletions blockchain/chainlink_pricefeeds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const abi = [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "getBtcUsd",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getEthUsd",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getEurUsd",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]

const escrowContract = web3 => {
return new web3.eth.Contract(
abi, "0x936fa5be4F6194615Af2F1B9cf3e78A8d46b6429"
)
}


export default escrowContract
3 changes: 1 addition & 2 deletions blockchain/contract.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading