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
async execute(identityAddress, serviceContractAddress, value, data, signedDataHash) { | |
const identityContract = new ethers.Contract(identityAddress, IIdentityContract.abi, connection.wallet); | |
const transaction = await identityContract.execute(serviceContractAddress, value, data, signedDataHash); | |
return transaction.hash | |
} |
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.24; | |
import "./IIdentityContract.sol"; | |
import "./ECTools.sol"; | |
import "../Proxy/SharedStorage.sol"; | |
contract IdentityContract is IIdentityContract, SharedStorage { | |
uint256 public nonce; |
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.24; | |
import "./IIdentityContract.sol"; | |
import "./ECTools.sol"; | |
import "../Proxy/SharedStorage.sol"; | |
contract IdentityContract is IIdentityContract, SharedStorage { | |
uint256 public nonce; |
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.24; | |
contract IdentityContract is IIdentityContract, SharedStorage { | |
function getSigner(bytes32 raw, bytes sig) public view returns(address signer) { | |
return ECTools.prefixedRecover(raw, sig); | |
} | |
modifier onlyValidSignature(address target, uint256 value, bytes data, bytes dataHashSignature) { | |
bytes32 dataHash = keccak256(abi.encodePacked(data, value, target)); | |
address signer = getSigner(dataHash, dataHashSignature); |
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
function getSigner(bytes32 raw, bytes sig) public view returns(address signer) { | |
return ECTools.prefixedRecover(raw, sig); | |
} | |
modifier onlyValidSignature(address target, uint256 value, bytes data, bytes dataHashSignature) { | |
bytes32 dataHash = keccak256(abi.encodePacked(data, value, target, nonce)); | |
address signer = getSigner(dataHash, dataHashSignature); | |
require(isSigner[signer]); | |
emit LogActionAuthorised(nonce, signer); | |
_; |
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
declare var require: any; | |
function MetamaskSigner(web3, provider) { | |
this.provider = provider; | |
this.getAddress = function () { | |
return web3.eth.accounts[0]; | |
}; | |
Object.defineProperty(this, 'address', { |
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 ethers = require('ethers'); | |
const providers = ethers.providers; | |
const Wallet = ethers.Wallet; | |
const utils = ethers.utils; | |
const contractABI = require('../build/contracts/ECToolsTest.json').abi; | |
var provider; | |
(async function () { |
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.18; | |
library ECTools { | |
/** | |
* @dev Recover signer address from a message by using his signature | |
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. | |
* @param sig bytes signature | |
*/ | |
function recover(bytes32 hash, bytes sig) public pure returns (address) { |
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
function MetamaskSigner(web3, provider) { | |
this.provider = provider; | |
this.getAddress = function () { | |
return web3.eth.accounts[0]; | |
} | |
Object.defineProperty(this, 'address', { | |
get: function () { | |
if (web3.eth.accounts.length == 0) { |
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
struct CatchedPoke { | |
uint caughtTime; | |
uint playerArrayIndex; | |
} | |
mapping(bytes32=>CatchedPoke) pokeLookupTable; | |
function addPoke(uint pokeId) { | |
bytes32 key = keccak256(msg.sender, pokeId); | |
CatchedPoke poke = pokeLookupTable[key]; |