This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,019 additions
and
145 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import PinakionPOCArtifact from 'kleros-interaction/build/contracts/MiniMeTokenERC20' | ||
import _ from 'lodash' | ||
|
||
import * as ethConstants from '../../../constants/eth' | ||
import * as errorConstants from '../../../constants/error' | ||
import ContractImplementation from '../../ContractImplementation' | ||
import deployContractAsync from '../../../utils/deployContractAsync' | ||
import isRequired from '../../../utils/isRequired' | ||
|
||
/** | ||
* Provides interaction with a PinakionPOC contract deployed on the blockchain. | ||
*/ | ||
class MiniMePinakion extends ContractImplementation { | ||
/** | ||
* Constructor PinakionPOC. | ||
* @param {object} web3Provider - web3 instance. | ||
* @param {string} contractAddress - of the contract (optionnal). | ||
*/ | ||
constructor(web3Provider, contractAddress) { | ||
super(web3Provider, PinakionPOCArtifact, contractAddress) | ||
} | ||
|
||
/** | ||
* Deploy a new instance of PinakionPOC. | ||
* @param {string} account - account of user | ||
* @param {object} web3Provider - web3 provider object | ||
* @param {string} tokenFactoryAddress - The address of the MiniMeTokenFactory contract that will create the Clone token contracts | ||
* @param {string} parentTokenAddress - Address of the parent token, set to 0x0 if it is a new token | ||
* @param {number} parentSnapshotBlock - Block of the parent token that will determine the initial distribution of the clone token, set to 0 if it is a new token | ||
* @param {string} tokenName - Name of the token. | ||
* @param {number} decimalUnits - Number of decimal units token is divisible by. | ||
* @param {string} tokenSymbol - Abreviated symbol to represent the token. | ||
* @param {bool} transfersEnabled - If users can transfer tokens. | ||
* @returns {object} - 'truffle-contract' Object | err The contract object or error deploy. | ||
*/ | ||
static deploy = async ( | ||
account = isRequired('account'), | ||
web3Provider = isRequired('web3Provider'), | ||
tokenFactoryAddress = isRequired('tokenFactoryAddress'), | ||
parentTokenAddress = '0x0', | ||
parentSnapshotBlock = 0, | ||
tokenName = 'Pinakion', | ||
decimalUnits = 18, | ||
tokenSymbol = 'PNK', | ||
transfersEnabled = true | ||
) => { | ||
const contractDeployed = await deployContractAsync( | ||
account, | ||
0, // value | ||
PinakionPOCArtifact, | ||
web3Provider, | ||
tokenFactoryAddress, // args | ||
parentTokenAddress, | ||
parentSnapshotBlock, | ||
tokenName, | ||
decimalUnits, | ||
tokenSymbol, | ||
transfersEnabled | ||
) | ||
|
||
return contractDeployed | ||
} | ||
|
||
/** | ||
* Transfer ownership of the PNK contract to the kleros POC contract. | ||
* @param {string} klerosAddress - Address of Kleros POC contract. | ||
* @param {string} account - Address of user. | ||
* @returns {object} - The result transaction object. | ||
*/ | ||
changeController = async ( | ||
klerosAddress, | ||
account = this._Web3Wrapper.getAccount(0) | ||
) => { | ||
await this.loadContract() | ||
|
||
try { | ||
return this.contractInstance.changeController(klerosAddress, { | ||
from: account, | ||
gas: ethConstants.TRANSACTION.GAS | ||
}) | ||
} catch (err) { | ||
console.error(err) | ||
throw new Error(errorConstants.UNABLE_TO_TRANSFER_OWNERSHIP) | ||
} | ||
} | ||
} | ||
|
||
export default MiniMePinakion |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
MiniMeTokenFactoryAbi, | ||
MiniMeTokenFactoryByteCode | ||
} from 'minimetoken/build/MiniMeToken.sol' | ||
import _ from 'lodash' | ||
|
||
import ContractImplementation from '../../ContractImplementation' | ||
import deployContractAsync from '../../../utils/deployContractAsync' | ||
|
||
/** | ||
* Provides interaction with a PinakionPOC contract deployed on the blockchain. | ||
*/ | ||
class TokenFactory extends ContractImplementation { | ||
/** | ||
* Constructor PinakionPOC. | ||
* @param {object} web3Provider - web3 instance. | ||
* @param {string} contractAddress - of the contract (optionnal). | ||
*/ | ||
constructor(web3Provider, contractAddress) { | ||
const artifact = { | ||
abi: MiniMeTokenFactoryAbi, | ||
bytecode: MiniMeTokenFactoryByteCode | ||
} | ||
super(web3Provider, artifact, contractAddress) | ||
} | ||
|
||
/** | ||
* Deploy a new instance of PinakionPOC. | ||
* @param {string} account - account of user | ||
* @param {object} web3Provider - web3 provider object | ||
* @returns {object} - 'truffle-contract' Object | err The contract object or error deploy. | ||
*/ | ||
static deploy = async (account, web3Provider) => { | ||
const artifact = { | ||
abi: MiniMeTokenFactoryAbi, | ||
bytecode: MiniMeTokenFactoryByteCode | ||
} | ||
|
||
const contractDeployed = await deployContractAsync( | ||
account, // account | ||
0, // value | ||
artifact, // artifact | ||
web3Provider // web3 | ||
) | ||
|
||
return contractDeployed | ||
} | ||
} | ||
|
||
export default TokenFactory |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import PinakionPOC from './PinakionPOC' | ||
import MiniMePinakion from './MiniMePinakion' | ||
import TokenFactory from './TokenFactory' | ||
|
||
export { PinakionPOC } | ||
export { PinakionPOC, MiniMePinakion, TokenFactory } |
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
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
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
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
Oops, something went wrong.