feat: add proxyFor for ArbitrationLicense

This commit is contained in:
Jonathan Rainville 2020-02-12 15:35:52 -05:00
parent 56e178ad4f
commit 58c1585397
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
9 changed files with 46 additions and 54 deletions

View File

@ -56,8 +56,9 @@ module.exports = {
"$KyberFeeBurner" // TODO: replace with "$StakingPool"
]
},
ArbitrationLicenseProxy: {
ArbitrationLicenseInstance: {
instanceOf: "Proxy",
proxyFor: "ArbitrationLicense",
args: ["0x", "$ArbitrationLicense"]
},
UserStore: {
@ -235,8 +236,9 @@ module.exports = {
ArbitrationLicense: {
address: "0x7e571b13aeb1a6abcfc470b7d033a6838e53f440"
},
ArbitrationLicenseProxy: {
ArbitrationLicenseInstance: {
instanceOf: "Proxy",
proxyFor: 'ArbitrationLicense',
address: "0x3e7fc31b9bd5fafde828acc1fd7b7b3dd7c1d927"
},
UserStore: {

View File

@ -50,7 +50,7 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
console.log('- 1/7: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
receipt = await sendTrxAccount0(deps.contracts.SellerLicenseInstance.methods.transferOwnership(mainnetOwner));
console.log('- 2/7: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
receipt = await sendTrxAccount0(deps.contracts.ArbitrationLicense.methods.transferOwnership(mainnetOwner));
receipt = await sendTrxAccount0(deps.contracts.ArbitrationLicenseInstance.methods.transferOwnership(mainnetOwner));
console.log('- 3/7: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
receipt = await sendTrxAccount0(deps.contracts.OfferStoreInstance.methods.transferOwnership(mainnetOwner));
console.log('- 4/7: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
@ -76,8 +76,7 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
{
console.log("Setting the initial ArbitrationLicense template calling the init() function");
deps.contracts.ArbitrationLicense.options.address = deps.contracts.ArbitrationLicenseProxy.options.address;
const receipt = await sendTrxAccount0(deps.contracts.ArbitrationLicense.methods.init(
const receipt = await sendTrxAccount0(deps.contracts.ArbitrationLicenseInstance.methods.init(
deps.contracts.SNT.options.address,
arbitrationLicensePrice,
deps.contracts.KyberFeeBurner.options.address
@ -89,7 +88,7 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
console.log("Setting the initial UserStore template calling the init() function");
const receipt = await sendTrxAccount0(deps.contracts.UserStoreInstance.methods.init(
deps.contracts.SellerLicenseInstance.options.address,
deps.contracts.ArbitrationLicenseProxy.options.address
deps.contracts.ArbitrationLicenseInstance.options.address
));
console.log((receipt.status === true || receipt.status === 1) ? '- Success' : '- FAILURE!!!');
}
@ -99,7 +98,7 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
const receipt = await sendTrxAccount0(deps.contracts.OfferStoreInstance.methods.init(
deps.contracts.UserStoreInstance.options.address,
deps.contracts.SellerLicenseInstance.options.address,
deps.contracts.ArbitrationLicenseProxy.options.address,
deps.contracts.ArbitrationLicenseInstance.options.address,
burnAddress,
deps.contracts.Medianizer.options.address
));
@ -111,7 +110,7 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
const receipt = await sendTrxAccount0(deps.contracts.EscrowInstance.methods.init(
fallbackArbitrator || main,
deps.contracts.EscrowRelay.options.address,
deps.contracts.ArbitrationLicenseProxy.options.address,
deps.contracts.ArbitrationLicenseInstance.options.address,
deps.contracts.OfferStoreInstance.options.address,
deps.contracts.UserStoreInstance.options.address,
deps.contracts.KyberFeeBurner.options.address, // TODO: replace with StakingPool address
@ -158,7 +157,7 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
console.log('- 1/5: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
receipt = await sendTrxAccount0(deps.contracts.SellerLicenseInstance.methods.transferOwnership(mainnetOwner));
console.log('- 2/5: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
receipt = await sendTrxAccount0(deps.contracts.ArbitrationLicense.methods.transferOwnership(mainnetOwner));
receipt = await sendTrxAccount0(deps.contracts.ArbitrationLicenseInstance.methods.transferOwnership(mainnetOwner));
console.log('- 3/5: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
receipt = await sendTrxAccount0(deps.contracts.OfferStoreInstance.methods.transferOwnership(mainnetOwner));
console.log('- 4/5: ' + ((receipt.status === true || receipt.status === 1) ? 'Success' : 'FAILURE!!!'));
@ -220,18 +219,18 @@ module.exports = async (gasPrice, licensePrice, arbitrationLicensePrice, feeMill
console.log("Buy arbitration licenses");
{
const buyLicense = deps.contracts.ArbitrationLicense.methods.buy().encodeABI();
const buyLicense = deps.contracts.ArbitrationLicenseInstance.methods.buy().encodeABI();
const sendTrxAccountArbi = estimateAndSend(arbitrator, gasPrice);
const sendTrxAccount8 = estimateAndSend(addresses[8], gasPrice);
await sendTrxAccountArbi(deps.contracts.SNT.methods.approveAndCall(deps.contracts.ArbitrationLicense._address, arbitrationLicensePrice, buyLicense));
await sendTrxAccountArbi(deps.contracts.SNT.methods.approveAndCall(deps.contracts.ArbitrationLicenseInstance._address, arbitrationLicensePrice, buyLicense));
await sendTrxAccountArbi(deps.contracts.UserStoreInstance.methods.addOrUpdateUser(CONTACT_DATA, "Montreal", "Fake Arbitrator"));
await sendTrxAccount8(deps.contracts.SNT.methods.approveAndCall(deps.contracts.ArbitrationLicense._address, arbitrationLicensePrice, buyLicense));
await sendTrxAccount8(deps.contracts.SNT.methods.approveAndCall(deps.contracts.ArbitrationLicenseInstance._address, arbitrationLicensePrice, buyLicense));
// Accepting everyone
await sendTrxAccountArbi(deps.contracts.ArbitrationLicense.methods.changeAcceptAny(true));
await sendTrxAccountArbi(deps.contracts.ArbitrationLicenseInstance.methods.changeAcceptAny(true));
}
console.log('Buy Licenses...');

View File

@ -38,7 +38,7 @@
"address": "0x137a2417Edb173E43Ccc246Dc76dfeb5281005Cc"
},
"0x75e2aa15d085f598b196a8014dab786618a8527b10b267853b439991daa8ee05": {
"name": "ArbitrationLicenseProxy",
"name": "ArbitrationLicenseInstance",
"address": "0x079A72015Fe55D2F580750fF8Ad7f77ced5a7854"
},
"0xd0daabcef7904c8c61b17193d61db0ef525889e72fd37e9ea1344cd95c07e5ba": {

View File

@ -22,7 +22,7 @@
"address": "0xD0fBD1a8D663B3D31312e0cb24910be82387266A"
},
"0x7838d40774f79e4b65d55111a3ce90c6272ef1cda077ea43a6b60cab8bdb01b5": {
"name": "ArbitrationLicenseProxy",
"name": "ArbitrationLicenseInstance",
"address": "0x75b2e33927Bb5476Abe37A81840d574c5D88d355"
},
"0x6130980fa41a9de00b86901a9edceec277386c25d85b342de6f4fc33ee91033c": {
@ -54,7 +54,7 @@
"address": "0x0ab611F28165A5b694959C1454c0a9027Eae536D"
},
"0x9e013e766512eaeb4a12f5b259804135ef6aa34304fdf063f8f465ca4de94d06": {
"name": "ArbitrationLicenseProxy",
"name": "ArbitrationLicenseInstance",
"address": "0x3e7fc31b9bd5FaFdE828AcC1FD7b7b3dD7c1D927"
},
"0x6a8ab201c0a00914ac65c01f74f7d0e8f7a72c6591fd3cdcb379e1e4f3c5ab50": {

View File

@ -34,7 +34,7 @@
"address": "0x8c7b1e0e2b2B86d5A7bdaaAd1AF67d90C724b5e1"
},
"0xf7f29727d8317b2412f875fb74b6552672e019035ec14ab84fe72b54db845561": {
"name": "ArbitrationLicenseProxy",
"name": "ArbitrationLicenseInstance",
"address": "0xD3570dbFBFb4edC4e37D404ADb373dee54144F51"
},
"0x520b7cf7f3aae72b14ac5275d9d6ee66ed41f6fae5c4cbe9b801a64d052b746a": {

View File

@ -42,7 +42,7 @@
"address": "0x1315b1bC9532c08c44B5C4Ddc5F9c6A1831D272f"
},
"0xb61ac3f971c25164c5cf00fe4616c8c9ad0759848d62c9fb803bdb4914af19eb": {
"name": "ArbitrationLicenseProxy",
"name": "ArbitrationLicenseInstance",
"address": "0x79647AD1d4bAFBbDb326A096A113aFc92158b03d"
},
"0x90be19004e959c27194e39559cbc7461b427237b7feec7de5166fae42877463a": {

View File

@ -24,12 +24,9 @@ import {
GET_FALLBACK_ARBITRATOR,
IS_FALLBACK_ARBITRATOR
} from './constants';
import ArbitrationLicense from '../../../embarkArtifacts/contracts/ArbitrationLicense';
import ArbitrationLicenseProxy from '../../../embarkArtifacts/contracts/ArbitrationLicenseProxy';
import ArbitrationLicenseInstance from '../../../embarkArtifacts/contracts/ArbitrationLicenseInstance';
import EscrowInstance from '../../../embarkArtifacts/contracts/EscrowInstance';
ArbitrationLicense.options.address = ArbitrationLicenseProxy.options.address;
export const getDisputedEscrows = (includeFallbackDisputes = null, isArbitrator = false) => ({type: GET_DISPUTED_ESCROWS, includeFallbackDisputes, isArbitrator});
export const resolveDispute = (escrowId, result) => {
@ -63,25 +60,25 @@ export const loadPrice = () => ({ type: LOAD_PRICE });
export const checkLicenseOwner = () => ({ type: CHECK_LICENSE_OWNER });
export const requestArbitrator = (arbitrator) => ({ type: REQUEST_ARBITRATOR, arbitrator, toSend: ArbitrationLicense.methods.requestArbitrator(arbitrator) });
export const requestArbitrator = (arbitrator) => ({ type: REQUEST_ARBITRATOR, arbitrator, toSend: ArbitrationLicenseInstance.methods.requestArbitrator(arbitrator) });
export const cancelArbitratorRequest = (arbitrator) => ({type: CANCEL_ARBITRATOR_REQUEST, arbitrator});
export const cancelArbitratorActions = () => ({type: CANCEL_ARBITRATOR_SELECTION_ACTIONS});
export const changeAcceptEveryone = (acceptAny) => ({type: CHANGE_ACCEPT_EVERYONE, acceptAny, toSend: ArbitrationLicense.methods.changeAcceptAny(acceptAny)});
export const changeAcceptEveryone = (acceptAny) => ({type: CHANGE_ACCEPT_EVERYONE, acceptAny, toSend: ArbitrationLicenseInstance.methods.changeAcceptAny(acceptAny)});
export const getArbitratorRequests = () => ({type: GET_ARBITRATION_REQUESTS});
export const acceptRequest = (id) => ({type: ACCEPT_ARBITRATOR_REQUEST, id, toSend: ArbitrationLicense.methods.acceptRequest(id)});
export const acceptRequest = (id) => ({type: ACCEPT_ARBITRATOR_REQUEST, id, toSend: ArbitrationLicenseInstance.methods.acceptRequest(id)});
export const rejectRequest = (id) => ({type: REJECT_ARBITRATOR_REQUEST, id, toSend: ArbitrationLicense.methods.rejectRequest(id)});
export const rejectRequest = (id) => ({type: REJECT_ARBITRATOR_REQUEST, id, toSend: ArbitrationLicenseInstance.methods.rejectRequest(id)});
export const getBlacklistedSellers = () => ({type: GET_BLACKLISTED_SELLERS});
export const blacklistSeller = (sellerAddress) => ({type: BLACKLIST_SELLER, sellerAddress, toSend: ArbitrationLicense.methods.blacklistSeller(sellerAddress)});
export const blacklistSeller = (sellerAddress) => ({type: BLACKLIST_SELLER, sellerAddress, toSend: ArbitrationLicenseInstance.methods.blacklistSeller(sellerAddress)});
export const unBlacklistSeller = (sellerAddress) => ({type: UNBLACKLIST_SELLER, sellerAddress, toSend: ArbitrationLicense.methods.unBlacklistSeller(sellerAddress)});
export const unBlacklistSeller = (sellerAddress) => ({type: UNBLACKLIST_SELLER, sellerAddress, toSend: ArbitrationLicenseInstance.methods.unBlacklistSeller(sellerAddress)});
export const loadArbitratorScores = () => ({type: LOAD_ARBITRATOR_SCORES});

View File

@ -1,6 +1,5 @@
/* global web3, subspace */
import ArbitrationLicense from '../../../embarkArtifacts/contracts/ArbitrationLicense';
import ArbitrationLicenseProxy from '../../../embarkArtifacts/contracts/ArbitrationLicenseProxy';
import ArbitrationLicenseInstance from '../../../embarkArtifacts/contracts/ArbitrationLicenseInstance';
import EscrowInstance from '../../../embarkArtifacts/contracts/EscrowInstance';
import OfferStoreInstance from '../../../embarkArtifacts/contracts/OfferStoreInstance';
import SNT from '../../../embarkArtifacts/contracts/SNT';
@ -32,8 +31,6 @@ import {
IS_FALLBACK_ARBITRATOR, IS_FALLBACK_ARBITRATOR_SUCCEEDED, IS_FALLBACK_ARBITRATOR_FAILED
} from './constants';
ArbitrationLicense.options.address = ArbitrationLicenseProxy.options.address;
export function *onResolveDispute() {
yield takeEvery(RESOLVE_DISPUTE, doTransaction.bind(null, RESOLVE_DISPUTE_PRE_SUCCESS, RESOLVE_DISPUTE_SUCCEEDED, RESOLVE_DISPUTE_FAILED));
}
@ -63,18 +60,18 @@ export function *doLoadArbitratorScores() {
export function *doGetArbitrators({address, includeAll}) {
try {
const cnt = yield call(ArbitrationLicense.methods.getNumLicenseOwners().call);
const cnt = yield call(ArbitrationLicenseInstance.methods.getNumLicenseOwners().call);
const arbitrators = {};
for(let i = 0; i < cnt; i++){
const arbitrator = web3.utils.toChecksumAddress(yield call(ArbitrationLicense.methods.licenseOwners(i).call));
const isAllowed = yield call(ArbitrationLicense.methods.isAllowed(address, arbitrator).call);
const isLicenseOwner = yield call(ArbitrationLicense.methods.isLicenseOwner(arbitrator).call);
const arbitrator = web3.utils.toChecksumAddress(yield call(ArbitrationLicenseInstance.methods.licenseOwners(i).call));
const isAllowed = yield call(ArbitrationLicenseInstance.methods.isAllowed(address, arbitrator).call);
const isLicenseOwner = yield call(ArbitrationLicenseInstance.methods.isLicenseOwner(arbitrator).call);
if(isLicenseOwner && (isAllowed || includeAll)) {
const id = web3.utils.soliditySha3(arbitrator, address);
arbitrators[arbitrator] = yield call(ArbitrationLicense.methods.arbitratorlicenseDetails(arbitrator).call);
arbitrators[arbitrator] = yield call(ArbitrationLicenseInstance.methods.arbitratorlicenseDetails(arbitrator).call);
arbitrators[arbitrator].isAllowed = isAllowed;
arbitrators[arbitrator].request = yield call(ArbitrationLicense.methods.requests(id).call);
arbitrators[arbitrator].request = yield call(ArbitrationLicenseInstance.methods.requests(id).call);
}
}
yield put({type: GET_ARBITRATORS_SUCCEEDED, arbitrators});
@ -167,10 +164,10 @@ export function *onGetArbitratorApprovalRequests() {
export function *doGetArbitratorApprovalRequests() {
try {
const events = yield ArbitrationLicense.getPastEvents('ArbitratorRequested', {fromBlock: 1, filter: {arbitrator: web3.eth.defaultAccount} });
const events = yield ArbitrationLicenseInstance.getPastEvents('ArbitratorRequested', {fromBlock: 1, filter: {arbitrator: web3.eth.defaultAccount} });
const requests = yield all(events.map(function *(event) {
const request = event.returnValues;
const requestDetail = yield ArbitrationLicense.methods.requests(request.id).call();
const requestDetail = yield ArbitrationLicenseInstance.methods.requests(request.id).call();
if([NONE, CLOSED].indexOf(requestDetail.status) > -1 || !addressCompare(requestDetail.arbitrator, web3.eth.defaultAccount)) return null;
@ -192,9 +189,9 @@ export function *onGetArbitratorBlacklist() {
export function *doGetArbitratorBlacklist() {
try {
const events = yield ArbitrationLicense.getPastEvents('BlacklistSeller', {fromBlock: 1, filter: {arbitrator: web3.eth.defaultAccount} });
const events = yield ArbitrationLicenseInstance.getPastEvents('BlacklistSeller', {fromBlock: 1, filter: {arbitrator: web3.eth.defaultAccount} });
const sellers = yield all(events.map(function *(event) {
const isBlacklisted = yield ArbitrationLicense.methods.blacklist(event.returnValues.seller).call();
const isBlacklisted = yield ArbitrationLicenseInstance.methods.blacklist(event.returnValues.seller).call();
if (!isBlacklisted) {
return null;
@ -250,9 +247,9 @@ export function *doGetFallbackArbitrator() {
export function *doBuyLicense() {
try {
const price = yield call(ArbitrationLicense.methods.price().call);
const encodedCall = ArbitrationLicense.methods.buy().encodeABI();
const toSend = SNT.methods.approveAndCall(ArbitrationLicense.options.address, price, encodedCall);
const price = yield call(ArbitrationLicenseInstance.methods.price().call);
const encodedCall = ArbitrationLicenseInstance.methods.buy().encodeABI();
const toSend = SNT.methods.approveAndCall(ArbitrationLicenseInstance.options.address, price, encodedCall);
const estimatedGas = yield call(toSend.estimateGas);
const promiseEvent = toSend.send({gasLimit: estimatedGas + 2000});
const channel = eventChannel(promiseEventEmitter.bind(null, promiseEvent));
@ -280,7 +277,7 @@ export function *onBuyLicense() {
export function *loadPrice() {
try {
const price = yield call(ArbitrationLicense.methods.price().call);
const price = yield call(ArbitrationLicenseInstance.methods.price().call);
yield put({type: LOAD_PRICE_SUCCEEDED, price});
} catch (error) {
console.error(error);
@ -296,8 +293,8 @@ export function *doCheckLicenseOwner() {
if(!web3.eth.defaultAccount) return;
try {
const isLicenseOwner = yield call(ArbitrationLicense.methods.isLicenseOwner(web3.eth.defaultAccount).call);
const licenseDetails = yield call(ArbitrationLicense.methods.arbitratorlicenseDetails(web3.eth.defaultAccount).call);
const isLicenseOwner = yield call(ArbitrationLicenseInstance.methods.isLicenseOwner(web3.eth.defaultAccount).call);
const licenseDetails = yield call(ArbitrationLicenseInstance.methods.arbitratorlicenseDetails(web3.eth.defaultAccount).call);
yield put({type: CHECK_LICENSE_OWNER_SUCCEEDED, isLicenseOwner, acceptAny: licenseDetails.acceptAny});
} catch (error) {
console.error(error);
@ -315,7 +312,7 @@ export function *onRequestArbitrator() {
export function *doCancelArbitratorRequest({arbitrator}){
const id = web3.utils.soliditySha3(arbitrator, web3.eth.defaultAccount);
const toSend = ArbitrationLicense.methods.cancelRequest(id);
const toSend = ArbitrationLicenseInstance.methods.cancelRequest(id);
yield doTransaction(CANCEL_ARBITRATOR_REQUEST_PRE_SUCCESS, CANCEL_ARBITRATOR_REQUEST_SUCCEEDED, CANCEL_ARBITRATOR_REQUEST_FAILED, {
arbitrator,
toSend

View File

@ -1,9 +1,9 @@
/* global web3 */
import ArbitrationLicense from '../../../embarkArtifacts/contracts/ArbitrationLicense';
import EscrowInstance from '../../../embarkArtifacts/contracts/EscrowInstance';
import OfferStoreInstance from '../../../embarkArtifacts/contracts/OfferStoreInstance';
import UserStoreInstance from '../../../embarkArtifacts/contracts/UserStoreInstance';
import SellerLicenseInstance from '../../../embarkArtifacts/contracts/SellerLicenseInstance';
import ArbitrationLicenseInstance from '../../../embarkArtifacts/contracts/ArbitrationLicenseInstance';
import {eventChannel} from 'redux-saga';
import {fork, takeEvery, put, all, call, select, take} from 'redux-saga/effects';
import {
@ -46,19 +46,16 @@ import {doTransaction} from '../../utils/saga';
import {getLocation} from '../../services/googleMap';
import { zeroAddress, addressCompare } from '../../utils/address';
import {getContactData} from '../../utils/strings';
import ArbitrationLicenseProxy from '../../../embarkArtifacts/contracts/ArbitrationLicenseProxy';
import {enableEthereum} from '../../services/embarkjs';
import network from '../../features/network';
ArbitrationLicense.options.address = ArbitrationLicenseProxy.options.address;
export function *loadUser({address}) {
if(!address) return;
const defaultAccount = web3.eth.defaultAccount || zeroAddress;
try {
const isArbitrator = yield ArbitrationLicense.methods.isLicenseOwner(address).call({from: defaultAccount});
const isArbitrator = yield ArbitrationLicenseInstance.methods.isLicenseOwner(address).call({from: defaultAccount});
const isSeller = yield SellerLicenseInstance.methods.isLicenseOwner(address).call({from: defaultAccount});
let userLicenses = {