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
const HDWalletProvider = require('@truffle/hdwallet-provider'); | |
const { readFileSync } = require('fs'); | |
const path = require('path'); | |
module.exports = { | |
networks: { | |
ganache: { | |
host: "127.0.0.1", |
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
pragma solidity >=0.4.22 <0.7.0; | |
import "./HitchensUnorderedKeySet.sol"; | |
import "./SafeRemotePurchase.sol"; | |
import "./Ownable.sol"; | |
contract FleaMarketFactory is Ownable { | |
using HitchensUnorderedKeySetLib for HitchensUnorderedKeySetLib.Set; | |
HitchensUnorderedKeySetLib.Set private widgetSet; |
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
/** | |
based on | |
https://solidity.readthedocs.io/en/v0.5.14/solidity-by-example.html | |
*/ | |
pragma solidity >=0.4.22 <0.7.0; | |
import "@openzeppelin/contracts/math/SafeMath.sol"; | |
import "./Ownable.sol"; | |
contract SafeRemotePurchase is Ownable { |
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
public confirmDelivery(contractAddress: string): Observable<string> { | |
const contract: Contract = new ethers.Contract(contractAddress, | |
this.abi, this.provider.getSigner()); | |
const token = contract.buyerConfirmReceived(); | |
return from(token) | |
.pipe( | |
switchMap((tx: any) => { |
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
public confirmPurchase(contractAddress: string, | |
etherValue: string): Observable<string> { | |
const contract: Contract = | |
new ethers.Contract(contractAddress, this.abi, | |
this.provider.getSigner()); | |
const wei = utils.parseEther(etherValue); | |
const token = contract.buyerPurchase({ | |
value: wei |
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
confirmBuy$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType(PurchaseContractActions.confirmBuy), | |
withLatestFrom( | |
this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
switchMap(([payload, contract]) => { | |
const dialogConfig = new MatDialogConfig(); | |
dialogConfig.width = '420px'; |
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
public removePurchaseContract(productKey: string): Observable<string> { | |
const bytes32Key = utils.formatBytes32String(productKey); | |
const token = this.contractToken.removeContractByKey(bytes32Key); | |
return from(token) | |
.pipe( | |
switchMap((tx: any) => { | |
console.log('removeContractByKey Transaction', tx); |
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
removeProduct$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType(PurchaseContractActions.removePurchaseContract), | |
map(payload => payload.key), | |
switchMap(key => { | |
const dialogConfig = new MatDialogConfig(); | |
dialogConfig.width = '420px'; | |
dialogConfig.disableClose = true; |
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
reload$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType( | |
PurchaseContractActions.abortSelectedPurchaseContractSuccess, | |
PurchaseContractActions.confirmBuySuccess, | |
PurchaseContractActions.confirmDeliverySuccess, | |
PurchaseContractActions.releaseEscrowSuccess, | |
PurchaseContractActions.withdrawByOwnerSuccess), | |
withLatestFrom( |
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
abortContract$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType(PurchaseContractActions.abortSelectedPurchaseContract), | |
withLatestFrom( | |
this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
switchMap(([action, contract]) => { | |
const dialogConfig = new MatDialogConfig(); | |
dialogConfig.width = '420px'; |
NewerOlder