commit
78494d6e6c
@ -0,0 +1,195 @@ |
|||||||
|
'use strict' |
||||||
|
|
||||||
|
import { NightwatchBrowser } from 'nightwatch' |
||||||
|
import init from '../helpers/init' |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
|
||||||
|
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||||
|
init(browser, done) |
||||||
|
}, |
||||||
|
|
||||||
|
'Should create 10 files, reload, and check if the files are saved': function (browser: NightwatchBrowser) { |
||||||
|
const contents = {} |
||||||
|
const checkContent = function (i, done) { |
||||||
|
const name = 'test_' + i + '.sol' |
||||||
|
browser |
||||||
|
.openFile(name) |
||||||
|
.pause(500) |
||||||
|
.getEditorValue((content) => { |
||||||
|
browser.assert.ok(content === contents[i]) |
||||||
|
done() |
||||||
|
}) |
||||||
|
} |
||||||
|
browser.clickLaunchIcon('filePanel').perform((done) => { |
||||||
|
let contentEditSet = content.slice() |
||||||
|
for (let i = 0; i < 10; i++) { |
||||||
|
contentEditSet += contentEditSet |
||||||
|
contents[i] = contentEditSet |
||||||
|
const name = 'test_' + i + '.sol' |
||||||
|
browser.click('[data-id="fileExplorerNewFilecreateNewFile"]') |
||||||
|
.waitForElementContainsText('*[data-id$="/blank"]', '', 60000) |
||||||
|
.sendKeys('*[data-id$="/blank"] .remixui_items', name) |
||||||
|
.sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) |
||||||
|
.waitForElementVisible(`li[data-id="treeViewLitreeViewItem${name}"]`, 60000) |
||||||
|
.setEditorValue(contentEditSet) |
||||||
|
} |
||||||
|
done() |
||||||
|
}).pause(10000).refresh() |
||||||
|
.perform(done => checkContent(0, done)) |
||||||
|
.perform(done => checkContent(1, done)) |
||||||
|
.perform(done => checkContent(2, done)) |
||||||
|
.perform(done => checkContent(3, done)) |
||||||
|
.perform(done => checkContent(4, done)) |
||||||
|
.perform(done => checkContent(5, done)) |
||||||
|
.perform(done => checkContent(6, done)) |
||||||
|
.perform(done => checkContent(7, done)) |
||||||
|
.perform(done => checkContent(8, done)) |
||||||
|
.perform(done => checkContent(9, done)) |
||||||
|
.end() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const content = ` |
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
|
||||||
|
pragma solidity >=0.7.0 <0.9.0; |
||||||
|
|
||||||
|
/** |
||||||
|
* @title Ballot |
||||||
|
* @dev Implements voting process along with vote delegation| |
||||||
|
*/ |
||||||
|
contract Ballot { |
||||||
|
|
||||||
|
struct Voter { |
||||||
|
uint weight; // weight is accumulated by delegation
|
||||||
|
bool voted; // if true, that person already voted
|
||||||
|
address delegate; // person delegated to
|
||||||
|
uint vote; // index of the voted proposal
|
||||||
|
} |
||||||
|
|
||||||
|
struct Proposal { |
||||||
|
// If you can limit the length to a certain number of bytes,
|
||||||
|
// always use one of bytes1 to bytes32 because they are much cheaper
|
||||||
|
bytes32 name; // short name (up to 32 bytes)
|
||||||
|
uint voteCount; // number of accumulated votes
|
||||||
|
} |
||||||
|
|
||||||
|
address public chairperson; |
||||||
|
|
||||||
|
mapping(address => Voter) public voters; |
||||||
|
|
||||||
|
Proposal[] public proposals; |
||||||
|
|
||||||
|
function () test { |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Create a new ballot to choose one of 'proposalNames'. |
||||||
|
* @param proposalNames names of proposals |
||||||
|
*/ |
||||||
|
constructor(bytes32[] memory proposalNames) { |
||||||
|
chairperson = msg.sender; |
||||||
|
voters[chairperson].weight = 1; |
||||||
|
|
||||||
|
for (uint i = 0; i < proposalNames.length; i++) { |
||||||
|
// 'Proposal({...})' creates a temporary
|
||||||
|
// Proposal object and 'proposals.push(...)'
|
||||||
|
// appends it to the end of 'proposals'.
|
||||||
|
proposals.push(Proposal({ |
||||||
|
name: proposalNames[i], |
||||||
|
voteCount: 0 |
||||||
|
})); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. |
||||||
|
* @param voter address of voter |
||||||
|
*/ |
||||||
|
function giveRightToVote(address voter) public { |
||||||
|
require( |
||||||
|
msg.sender == chairperson, |
||||||
|
"Only chairperson can give right to vote." |
||||||
|
); |
||||||
|
require( |
||||||
|
!voters[voter].voted, |
||||||
|
"The voter already voted." |
||||||
|
); |
||||||
|
require(voters[voter].weight == 0); |
||||||
|
voters[voter].weight = 1; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Delegate your vote to the voter 'to'. |
||||||
|
* @param to address to which vote is delegated |
||||||
|
*/ |
||||||
|
function delegate(address to) public { |
||||||
|
Voter storage sender = voters[msg.sender]; |
||||||
|
require(!sender.voted, "You already voted."); |
||||||
|
require(to != msg.sender, "Self-delegation is disallowed."); |
||||||
|
|
||||||
|
while (voters[to].delegate != address(0)) { |
||||||
|
to = voters[to].delegate; |
||||||
|
|
||||||
|
// We found a loop in the delegation, not allowed.
|
||||||
|
require(to != msg.sender, "Found loop in delegation."); |
||||||
|
} |
||||||
|
sender.voted = true; |
||||||
|
sender.delegate = to; |
||||||
|
Voter storage delegate_ = voters[to]; |
||||||
|
if (delegate_.voted) { |
||||||
|
// If the delegate already voted,
|
||||||
|
// directly add to the number of votes
|
||||||
|
proposals[delegate_.vote].voteCount += sender.weight; |
||||||
|
} else { |
||||||
|
// If the delegate did not vote yet,
|
||||||
|
// add to her weight.
|
||||||
|
delegate_.weight += sender.weight; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. |
||||||
|
* @param proposal index of proposal in the proposals array |
||||||
|
*/ |
||||||
|
function vote(uint proposal) public { |
||||||
|
Voter storage sender = voters[msg.sender]; |
||||||
|
require(sender.weight != 0, "Has no right to vote"); |
||||||
|
require(!sender.voted, "Already voted."); |
||||||
|
sender.voted = true; |
||||||
|
sender.vote = proposal; |
||||||
|
|
||||||
|
// If 'proposal' is out of the range of the array,
|
||||||
|
// this will throw automatically and revert all
|
||||||
|
// changes.
|
||||||
|
proposals[proposal].voteCount += sender.weight; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Computes the winning proposal taking all previous votes into account. |
||||||
|
* @return winningProposal_ index of winning proposal in the proposals array |
||||||
|
*/ |
||||||
|
function winningProposal() public view |
||||||
|
returns (uint winningProposal_) |
||||||
|
{ |
||||||
|
uint winningVoteCount = 0; |
||||||
|
for (uint p = 0; p < proposals.length; p++) { |
||||||
|
if (proposals[p].voteCount > winningVoteCount) { |
||||||
|
winningVoteCount = proposals[p].voteCount; |
||||||
|
winningProposal_ = p; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Calls winningProposal() function to get the index of the winner contained in the proposals array and then |
||||||
|
* @return winnerName_ the name of the winner |
||||||
|
*/ |
||||||
|
function winnerName() public view |
||||||
|
returns (bytes32 winnerName_) |
||||||
|
{ |
||||||
|
winnerName_ = proposals[winningProposal()].name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
` |
@ -1,57 +0,0 @@ |
|||||||
const allPrograms = [ |
|
||||||
{ ethers: 'The ethers.js library is a compact and complete JavaScript library for Ethereum.' }, |
|
||||||
{ remix: 'Ethereum IDE and tools for the web.' }, |
|
||||||
{ web3: 'The web3.js library is a collection of modules which contain specific functionality for the ethereum ecosystem.' }, |
|
||||||
{ swarmgw: 'This library can be used to upload/download files to Swarm via https://swarm-gateways.net/.' } |
|
||||||
] |
|
||||||
|
|
||||||
const allCommands = [ |
|
||||||
{ 'remix.execute(filepath)': 'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.' }, |
|
||||||
{ 'remix.exeCurrent()': 'Run the script currently displayed in the editor.' }, |
|
||||||
{ 'remix.help()': 'Display this help message.' }, |
|
||||||
{ 'remix.loadgist(id)': 'Load a gist in the file explorer.' }, |
|
||||||
{ 'remix.loadurl(url)': 'Load the given url in the file explorer. The url can be of type github, swarm or ipfs.' }, |
|
||||||
|
|
||||||
{ 'swarmgw.get(url, cb)': 'Download files from Swarm via https://swarm-gateways.net/' }, |
|
||||||
{ 'swarmgw.put(content, cb)': 'Upload files to Swarm via https://swarm-gateways.net/' }, |
|
||||||
|
|
||||||
{ 'ethers.Contract': 'This API provides a graceful connection to a contract deployed on the blockchain, simplifying calling and querying its functions and handling all the binary protocol and conversion as necessarily.' }, |
|
||||||
{ 'ethers.HDNode': 'A Hierarchical Deterministic Wallet represents a large tree of private keys which can reliably be reproduced from an initial seed.' }, |
|
||||||
{ 'ethers.Interface': 'The Interface Object is a meta-class that accepts a Solidity (or compatible) Application Binary Interface (ABI) and populates functions to deal with encoding and decoding the parameters to pass in and results returned.' }, |
|
||||||
{ 'ethers.providers': 'A Provider abstracts a connection to the Ethereum blockchain, for issuing queries and sending state changing transactions.' }, |
|
||||||
{ 'ethers.SigningKey': 'The SigningKey interface provides an abstraction around the secp256k1 elliptic curve cryptography library.' }, |
|
||||||
{ 'ethers.utils': 'The utility functions exposed in both the ethers umbrella package and the ethers-utils.' }, |
|
||||||
{ 'ethers.utils.AbiCoder': 'Create a new ABI Coder object' }, |
|
||||||
{ 'ethers.utils.RLP': 'This encoding method is used internally for several aspects of Ethereum, such as encoding transactions and determining contract addresses.' }, |
|
||||||
{ 'ethers.Wallet': 'A wallet manages a private/public key pair which is used to cryptographically sign transactions and prove ownership on the Ethereum network.' }, |
|
||||||
{ 'ethers.version': 'Contains the version of the ethers container object.' }, |
|
||||||
|
|
||||||
{ 'web3.eth': 'Eth module for interacting with the Ethereum network.' }, |
|
||||||
{ 'web3.eth.accounts': 'The web3.eth.accounts contains functions to generate Ethereum accounts and sign transactions and data.' }, |
|
||||||
{ 'web3.eth.abi': 'The web3.eth.abi functions let you de- and encode parameters to ABI (Application Binary Interface) for function calls to the EVM (Ethereum Virtual Machine).' }, |
|
||||||
{ 'web3.eth.ens': 'The web3.eth.ens functions let you interacting with ENS.' }, |
|
||||||
{ 'web3.eth.Iban': 'The web3.eth.Iban function lets convert Ethereum addresses from and to IBAN and BBAN.' }, |
|
||||||
{ 'web3.eth.net': 'Net module for interacting with network properties.' }, |
|
||||||
{ 'web3.eth.personal': 'Personal module for interacting with the Ethereum accounts.' }, |
|
||||||
{ 'web3.eth.subscribe': 'The web3.eth.subscribe function lets you subscribe to specific events in the blockchain.' }, |
|
||||||
{ 'web3.givenProvider': 'When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise null.' }, |
|
||||||
{ 'web3.modules': 'Contains the version of the web3 container object.' }, |
|
||||||
{ 'web3.providers': 'Contains the current available providers.' }, |
|
||||||
{ 'web3.shh': 'Shh module for interacting with the whisper protocol' }, |
|
||||||
{ 'web3.utils': 'This package provides utility functions for Ethereum dapps and other web3.js packages.' }, |
|
||||||
{ 'web3.version': 'Contains the version of the web3 container object.' }, |
|
||||||
|
|
||||||
{ 'web3.eth.clearSubscriptions();': 'Resets subscriptions.' }, |
|
||||||
{ 'web3.eth.Contract(jsonInterface[, address][, options])': 'The web3.eth.Contract object makes it easy to interact with smart contracts on the ethereum blockchain.' }, |
|
||||||
{ 'web3.eth.accounts.create([entropy]);': 'The web3.eth.accounts contains functions to generate Ethereum accounts and sign transactions and data.' }, |
|
||||||
{ 'web3.eth.getAccounts();': 'Retrieve the list of accounts' }, |
|
||||||
{ 'web3.eth.accounts.privateKeyToAccount(privateKey [, ignoreLength ]);': 'Get the account from the private key' }, |
|
||||||
{ 'web3.eth.accounts.signTransaction(tx, privateKey [, callback]);': 'Sign Transaction' }, |
|
||||||
{ 'web3.eth.accounts.recoverTransaction(rawTransaction);': 'Sign Transaction' }, |
|
||||||
{ 'web3.eth.accounts.hashMessage(message);': 'Hash message' } |
|
||||||
] |
|
||||||
|
|
||||||
module.exports = { |
|
||||||
allPrograms, |
|
||||||
allCommands |
|
||||||
} |
|
@ -1,55 +0,0 @@ |
|||||||
export class DummyProvider { |
|
||||||
eth |
|
||||||
debug |
|
||||||
providers |
|
||||||
currentProvider |
|
||||||
|
|
||||||
constructor () { |
|
||||||
this.eth = {} |
|
||||||
this.debug = {} |
|
||||||
this.eth.getCode = (address, cb) => { return this.getCode(address, cb) } |
|
||||||
this.eth.getTransaction = (hash, cb) => { return this.getTransaction(hash, cb) } |
|
||||||
this.eth.getTransactionFromBlock = (blockNumber, txIndex, cb) => { return this.getTransactionFromBlock(blockNumber, txIndex, cb) } |
|
||||||
this.eth.getBlockNumber = (cb) => { return this.getBlockNumber(cb) } |
|
||||||
this.debug.traceTransaction = (hash, options, cb) => { return this.traceTransaction(hash, options, cb) } |
|
||||||
this.debug.storageRangeAt = (blockNumber, txIndex, address, start, end, maxLength, cb) => { return this.storageRangeAt(blockNumber, txIndex, address, start, end, maxLength, cb) } |
|
||||||
this.providers = { HttpProvider: function (url) {} } |
|
||||||
this.currentProvider = { host: '' } |
|
||||||
} |
|
||||||
|
|
||||||
getCode (address, cb) { |
|
||||||
cb(null, '') |
|
||||||
} |
|
||||||
|
|
||||||
setProvider (provider) {} |
|
||||||
|
|
||||||
traceTransaction (txHash, options, cb) { |
|
||||||
if (cb) { |
|
||||||
cb(null, {}) |
|
||||||
} |
|
||||||
return {} |
|
||||||
} |
|
||||||
|
|
||||||
storageRangeAt (blockNumber, txIndex, address, start, end, maxLength, cb) { |
|
||||||
if (cb) { |
|
||||||
cb(null, {}) |
|
||||||
} |
|
||||||
return {} |
|
||||||
} |
|
||||||
|
|
||||||
getBlockNumber (cb) { cb(null, '') } |
|
||||||
|
|
||||||
getTransaction (txHash, cb) { |
|
||||||
if (cb) { |
|
||||||
cb(null, {}) |
|
||||||
} |
|
||||||
return {} |
|
||||||
} |
|
||||||
|
|
||||||
getTransactionFromBlock (blockNumber, txIndex, cb) { |
|
||||||
if (cb) { |
|
||||||
cb(null, {}) |
|
||||||
} |
|
||||||
return {} |
|
||||||
} |
|
||||||
} |
|
@ -1,38 +0,0 @@ |
|||||||
import { Web3VmProvider } from './web3VmProvider' |
|
||||||
import { loadWeb3, extendWeb3 } from '../init' |
|
||||||
|
|
||||||
export class Web3Providers { |
|
||||||
modes |
|
||||||
constructor () { |
|
||||||
this.modes = {} |
|
||||||
} |
|
||||||
|
|
||||||
addProvider (type, obj) { |
|
||||||
if (type === 'INTERNAL') { |
|
||||||
const web3 = loadWeb3() |
|
||||||
this.addWeb3(type, web3) |
|
||||||
} else if (type === 'vm') { |
|
||||||
this.addVM(type, obj) |
|
||||||
} else { |
|
||||||
extendWeb3(obj) |
|
||||||
this.addWeb3(type, obj) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
get (type, cb) { |
|
||||||
if (this.modes[type]) { |
|
||||||
return cb(null, this.modes[type]) |
|
||||||
} |
|
||||||
cb('error: this provider has not been setup (' + type + ')', null) |
|
||||||
} |
|
||||||
|
|
||||||
addWeb3 (type, web3) { |
|
||||||
this.modes[type] = web3 |
|
||||||
} |
|
||||||
|
|
||||||
addVM (type, vm) { |
|
||||||
const vmProvider = new Web3VmProvider() |
|
||||||
vmProvider.setVM(vm) |
|
||||||
this.modes[type] = vmProvider |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +1,3 @@ |
|||||||
export * from './lib/remix-ui-helper' |
export * from './lib/remix-ui-helper' |
||||||
export * from './lib/helper-components' |
export * from './lib/helper-components' |
||||||
|
export * from './lib/components/PluginViewWrapper' |
@ -0,0 +1,24 @@ |
|||||||
|
import React from "react" |
||||||
|
import { useEffect, useState } from "react" |
||||||
|
|
||||||
|
interface IPluginViewWrapperProps { |
||||||
|
plugin: any |
||||||
|
} |
||||||
|
|
||||||
|
export const PluginViewWrapper = (props: IPluginViewWrapperProps) => { |
||||||
|
|
||||||
|
const [state, setState] = useState<any>(null) |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
if(props.plugin.setDispatch){ |
||||||
|
props.plugin.setDispatch(setState) |
||||||
|
} |
||||||
|
}, []) |
||||||
|
|
||||||
|
return ( |
||||||
|
<>{state?
|
||||||
|
<>{props.plugin.updateComponent(state)}</> |
||||||
|
:<></> |
||||||
|
}</> |
||||||
|
) |
||||||
|
} |
Loading…
Reference in new issue