Commit 2e7a02fd authored by gxkai's avatar gxkai

chore: 与baas通讯

parent 61f0cf6b
...@@ -142,7 +142,6 @@ class App { ...@@ -142,7 +142,6 @@ class App {
// setup storage // setup storage
const configStorage = new Storage('config-v0.8:') const configStorage = new Storage('config-v0.8:')
// load app config // load app config
const config = new Config(configStorage) const config = new Config(configStorage)
registry.put({ api: config, name: 'config' }) registry.put({ api: config, name: 'config' })
...@@ -157,8 +156,19 @@ class App { ...@@ -157,8 +156,19 @@ class App {
registry.put({ api: self._components.filesProviders.workspace, name: 'fileproviders/workspace' }) registry.put({ api: self._components.filesProviders.workspace, name: 'fileproviders/workspace' })
registry.put({ api: self._components.filesProviders, name: 'fileproviders' }) registry.put({ api: self._components.filesProviders, name: 'fileproviders' })
migrateFileSystem(self._components.filesProviders.browser) migrateFileSystem(self._components.filesProviders.browser)
// 请求token
window.parent.postMessage({event: 'getToken'}, '\*')
window.addEventListener("message", this.handleListenMessage, false)
}
handleListenMessage(event$){
const {event,data: token} = event$.data
if (!event) return
// 接收token
if (event === 'giveToken') {
registry.put({api: token, name: 'baas-token'})
}
} }
init () { init () {
...@@ -507,7 +517,7 @@ class App { ...@@ -507,7 +517,7 @@ class App {
}).catch(console.error) }).catch(console.error)
} else { } else {
// activate solidity plugin // activate solidity plugin
appManager.activatePlugin(['solidity', 'udapp']) appManager.activatePlugin(['solidity', 'udapp','debugger'])
} }
}) })
......
...@@ -21,7 +21,7 @@ contract Storage { ...@@ -21,7 +21,7 @@ contract Storage {
} }
/** /**
* @dev Return value * @dev Return value
* @return value of 'number' * @return value of 'number'
*/ */
function retrieve() public view returns (uint256){ function retrieve() public view returns (uint256){
...@@ -40,10 +40,10 @@ pragma solidity >=0.7.0 <0.9.0; ...@@ -40,10 +40,10 @@ pragma solidity >=0.7.0 <0.9.0;
contract Owner { contract Owner {
address private owner; address private owner;
// event for EVM logging // event for EVM logging
event OwnerSet(address indexed oldOwner, address indexed newOwner); event OwnerSet(address indexed oldOwner, address indexed newOwner);
// modifier to check if caller is owner // modifier to check if caller is owner
modifier isOwner() { modifier isOwner() {
// If the first argument of 'require' evaluates to 'false', execution terminates and all // If the first argument of 'require' evaluates to 'false', execution terminates and all
...@@ -54,7 +54,7 @@ contract Owner { ...@@ -54,7 +54,7 @@ contract Owner {
require(msg.sender == owner, "Caller is not owner"); require(msg.sender == owner, "Caller is not owner");
_; _;
} }
/** /**
* @dev Set contract deployer as owner * @dev Set contract deployer as owner
*/ */
...@@ -73,7 +73,7 @@ contract Owner { ...@@ -73,7 +73,7 @@ contract Owner {
} }
/** /**
* @dev Return owner address * @dev Return owner address
* @return address of owner * @return address of owner
*/ */
function getOwner() external view returns (address) { function getOwner() external view returns (address) {
...@@ -85,12 +85,12 @@ const ballot = `// SPDX-License-Identifier: GPL-3.0 ...@@ -85,12 +85,12 @@ const ballot = `// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0; pragma solidity >=0.7.0 <0.9.0;
/** /**
* @title Ballot * @title Ballot
* @dev Implements voting process along with vote delegation * @dev Implements voting process along with vote delegation
*/ */
contract Ballot { contract Ballot {
struct Voter { struct Voter {
uint weight; // weight is accumulated by delegation uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted bool voted; // if true, that person already voted
...@@ -99,7 +99,7 @@ contract Ballot { ...@@ -99,7 +99,7 @@ contract Ballot {
} }
struct Proposal { struct Proposal {
// If you can limit the length to a certain number of bytes, // If you can limit the length to a certain number of bytes,
// always use one of bytes1 to bytes32 because they are much cheaper // always use one of bytes1 to bytes32 because they are much cheaper
bytes32 name; // short name (up to 32 bytes) bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes uint voteCount; // number of accumulated votes
...@@ -111,7 +111,7 @@ contract Ballot { ...@@ -111,7 +111,7 @@ contract Ballot {
Proposal[] public proposals; Proposal[] public proposals;
/** /**
* @dev Create a new ballot to choose one of 'proposalNames'. * @dev Create a new ballot to choose one of 'proposalNames'.
* @param proposalNames names of proposals * @param proposalNames names of proposals
*/ */
...@@ -129,8 +129,8 @@ contract Ballot { ...@@ -129,8 +129,8 @@ contract Ballot {
})); }));
} }
} }
/** /**
* @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. * @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'.
* @param voter address of voter * @param voter address of voter
*/ */
...@@ -193,7 +193,7 @@ contract Ballot { ...@@ -193,7 +193,7 @@ contract Ballot {
proposals[proposal].voteCount += sender.weight; proposals[proposal].voteCount += sender.weight;
} }
/** /**
* @dev Computes the winning proposal taking all previous votes into account. * @dev Computes the winning proposal taking all previous votes into account.
* @return winningProposal_ index of winning proposal in the proposals array * @return winningProposal_ index of winning proposal in the proposals array
*/ */
...@@ -209,7 +209,7 @@ contract Ballot { ...@@ -209,7 +209,7 @@ contract Ballot {
} }
} }
/** /**
* @dev Calls winningProposal() function to get the index of the winner contained in the proposals array and then * @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 * @return winnerName_ the name of the winner
*/ */
...@@ -228,21 +228,21 @@ import "remix_tests.sol"; // this import is automatically injected by Remix. ...@@ -228,21 +228,21 @@ import "remix_tests.sol"; // this import is automatically injected by Remix.
import "../contracts/3_Ballot.sol"; import "../contracts/3_Ballot.sol";
contract BallotTest { contract BallotTest {
bytes32[] proposalNames; bytes32[] proposalNames;
Ballot ballotToTest; Ballot ballotToTest;
function beforeAll () public { function beforeAll () public {
proposalNames.push(bytes32("candidate1")); proposalNames.push(bytes32("candidate1"));
ballotToTest = new Ballot(proposalNames); ballotToTest = new Ballot(proposalNames);
} }
function checkWinningProposal () public { function checkWinningProposal () public {
ballotToTest.vote(0); ballotToTest.vote(0);
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal");
Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name"); Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name");
} }
function checkWinninProposalWithReturnValue () public view returns (bool) { function checkWinninProposalWithReturnValue () public view returns (bool) {
return ballotToTest.winningProposal() == 0; return ballotToTest.winningProposal() == 0;
} }
...@@ -252,24 +252,24 @@ const deployWithWeb3 = `// Right click on the script name and hit "Run" to execu ...@@ -252,24 +252,24 @@ const deployWithWeb3 = `// Right click on the script name and hit "Run" to execu
(async () => { (async () => {
try { try {
console.log('Running deployWithWeb3 script...') console.log('Running deployWithWeb3 script...')
const contractName = 'Storage' // Change this for other contract const contractName = 'Storage' // Change this for other contract
const constructorArgs = [] // Put constructor args (if any) here for your contract const constructorArgs = [] // Put constructor args (if any) here for your contract
// Note that the script needs the ABI which is generated from the compilation artifact. // Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated // Make sure contract is compiled and artifacts are generated
const artifactsPath = \`browser/contracts/artifacts/\${contractName}.json\` // Change this for different path const artifactsPath = \`browser/contracts/artifacts/\${contractName}.json\` // Change this for different path
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
const accounts = await web3.eth.getAccounts() const accounts = await web3.eth.getAccounts()
let contract = new web3.eth.Contract(metadata.abi) let contract = new web3.eth.Contract(metadata.abi)
contract = contract.deploy({ contract = contract.deploy({
data: metadata.data.bytecode.object, data: metadata.data.bytecode.object,
arguments: constructorArgs arguments: constructorArgs
}) })
const newContractInstance = await contract.send({ const newContractInstance = await contract.send({
from: accounts[0], from: accounts[0],
gas: 1500000, gas: 1500000,
...@@ -285,24 +285,24 @@ const deployWithEthers = `// Right click on the script name and hit "Run" to exe ...@@ -285,24 +285,24 @@ const deployWithEthers = `// Right click on the script name and hit "Run" to exe
(async () => { (async () => {
try { try {
console.log('Running deployWithEthers script...') console.log('Running deployWithEthers script...')
const contractName = 'Storage' // Change this for other contract const contractName = 'Storage' // Change this for other contract
const constructorArgs = [] // Put constructor args (if any) here for your contract const constructorArgs = [] // Put constructor args (if any) here for your contract
// Note that the script needs the ABI which is generated from the compilation artifact. // Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated // Make sure contract is compiled and artifacts are generated
const artifactsPath = \`browser/contracts/artifacts/\${contractName}.json\` // Change this for different path const artifactsPath = \`browser/contracts/artifacts/\${contractName}.json\` // Change this for different path
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object // 'web3Provider' is a remix global variable object
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer);
let contract = await factory.deploy(...constructorArgs); let contract = await factory.deploy(...constructorArgs);
console.log('Contract Address: ', contract.address); console.log('Contract Address: ', contract.address);
// The contract is NOT deployed yet; we must wait until it is mined // The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed() await contract.deployed()
console.log('Deployment successful.') console.log('Deployment successful.')
...@@ -313,7 +313,7 @@ const deployWithEthers = `// Right click on the script name and hit "Run" to exe ...@@ -313,7 +313,7 @@ const deployWithEthers = `// Right click on the script name and hit "Run" to exe
const readme = `REMIX EXAMPLE PROJECT const readme = `REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer. Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories: It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name. 1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
...@@ -323,7 +323,7 @@ It contains 3 directories: ...@@ -323,7 +323,7 @@ It contains 3 directories:
SCRIPTS SCRIPTS
The 'scripts' folder contains example async/await scripts for deploying the 'Storage' contract. The 'scripts' folder contains example async/await scripts for deploying the 'Storage' contract.
For the deployment of any other contract, 'contractName' and 'constructorArgs' should be updated (along with other code if required). For the deployment of any other contract, 'contractName' and 'constructorArgs' should be updated (along with other code if required).
Scripts have full access to the web3.js and ethers.js libraries. Scripts have full access to the web3.js and ethers.js libraries.
To run a script, right click on file name in the file explorer and click 'Run'. Remember, Solidity file must already be compiled. To run a script, right click on file name in the file explorer and click 'Run'. Remember, Solidity file must already be compiled.
...@@ -333,10 +333,10 @@ Output from script will appear in remix terminal. ...@@ -333,10 +333,10 @@ Output from script will appear in remix terminal.
module.exports = { module.exports = {
storage: { name: 'contracts/1_Storage.sol', content: storage }, storage: { name: 'contracts/1_Storage.sol', content: storage },
owner: { name: 'contracts/2_Owner.sol', content: owner }, // owner: { name: 'contracts/2_Owner.sol', content: owner },
ballot: { name: 'contracts/3_Ballot.sol', content: ballot }, // ballot: { name: 'contracts/3_Ballot.sol', content: ballot },
deployWithWeb3: { name: 'scripts/deploy_web3.js', content: deployWithWeb3 }, // deployWithWeb3: { name: 'scripts/deploy_web3.js', content: deployWithWeb3 },
deployWithEthers: { name: 'scripts/deploy_ethers.js', content: deployWithEthers }, // deployWithEthers: { name: 'scripts/deploy_ethers.js', content: deployWithEthers },
ballot_test: { name: 'tests/4_Ballot_test.sol', content: ballotTest }, // ballot_test: { name: 'tests/4_Ballot_test.sol', content: ballotTest },
readme: { name: 'README.txt', content: readme } // readme: { name: 'README.txt', content: readme }
} }
...@@ -402,7 +402,6 @@ class FileManager extends Plugin { ...@@ -402,7 +402,6 @@ class FileManager extends Plugin {
this._deps.workspaceExplorer.event.on('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) }) this._deps.workspaceExplorer.event.on('fileRenamed', (oldName, newName, isFolder) => { this.fileRenamedEvent(oldName, newName, isFolder) })
this._deps.workspaceExplorer.event.on('fileRemoved', (path) => { this.fileRemovedEvent(path) }) this._deps.workspaceExplorer.event.on('fileRemoved', (path) => { this.fileRemovedEvent(path) })
this._deps.workspaceExplorer.event.on('fileAdded', (path) => { this.fileAddedEvent(path) }) this._deps.workspaceExplorer.event.on('fileAdded', (path) => { this.fileAddedEvent(path) })
this.getCurrentFile = this.file this.getCurrentFile = this.file
this.getFile = this.readFile this.getFile = this.readFile
this.getFolder = this.readdir this.getFolder = this.readdir
...@@ -515,7 +514,7 @@ class FileManager extends Plugin { ...@@ -515,7 +514,7 @@ class FileManager extends Plugin {
<span> <span>
${this.currentRequest.from} ${this.currentRequest.from}
<span class="font-weight-bold text-warning"> <span class="font-weight-bold text-warning">
is modifying is modifying
</span>${path} </span>${path}
</span> </span>
</div> </div>
......
...@@ -281,7 +281,6 @@ class FileProvider { ...@@ -281,7 +281,6 @@ class FileProvider {
window.remixFileSystem.readdir(path, (error, files) => { window.remixFileSystem.readdir(path, (error, files) => {
var ret = {} var ret = {}
if (files) { if (files) {
files.forEach(element => { files.forEach(element => {
path = path.replace(/^\/|\/$/g, '') // remove first and last slash path = path.replace(/^\/|\/$/g, '') // remove first and last slash
......
...@@ -102,19 +102,19 @@ class SettingsUI { ...@@ -102,19 +102,19 @@ class SettingsUI {
title="Execution environment does not connect to any node, everything is local and in memory only." title="Execution environment does not connect to any node, everything is local and in memory only."
value="vm-london" name="executionContext" fork="london"> JavaScript VM (London) value="vm-london" name="executionContext" fork="london"> JavaScript VM (London)
</option> </option>
<option id="vm-mode-berlin" data-id="settingsVMBerlinMode" <!-- <option id="vm-mode-berlin" data-id="settingsVMBerlinMode"-->
title="Execution environment does not connect to any node, everything is local and in memory only." <!-- title="Execution environment does not connect to any node, everything is local and in memory only."-->
value="vm-berlin" name="executionContext" fork="berlin" > JavaScript VM (Berlin) <!-- value="vm-berlin" name="executionContext" fork="berlin" > JavaScript VM (Berlin)-->
</option> <!-- </option>-->
<option id="injected-mode" data-id="settingsInjectedMode" <!-- <option id="injected-mode" data-id="settingsInjectedMode"-->
title="Execution environment has been provided by Metamask or similar provider." <!-- title="Execution environment has been provided by Metamask or similar provider."-->
value="injected" name="executionContext"> Injected Web3 <!-- value="injected" name="executionContext"> Injected Web3-->
</option> <!-- </option>-->
<option id="web3-mode" data-id="settingsWeb3Mode" <!-- <option id="web3-mode" data-id="settingsWeb3Mode"-->
title="Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse! <!-- title="Execution environment connects to node at localhost (or via IPC if available), transactions will be sent to the network and can cause loss of money or worse!-->
If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http." <!-- If this page is served via https and you access your node via http, it might not work. In this case, try cloning the repository and serving it via http."-->
value="web3" name="executionContext"> Web3 Provider <!-- value="web3" name="executionContext"> Web3 Provider-->
</option> <!-- </option>-->
</select> </select>
<a href="https://remix-ide.readthedocs.io/en/latest/run.html#run-setup" target="_blank"><i class="${css.infoDeployAction} ml-2 fas fa-info" title="check out docs to setup Environment"></i></a> <a href="https://remix-ide.readthedocs.io/en/latest/run.html#run-setup" target="_blank"><i class="${css.infoDeployAction} ml-2 fas fa-info" title="check out docs to setup Environment"></i></a>
</div> </div>
...@@ -274,12 +274,12 @@ class SettingsUI { ...@@ -274,12 +274,12 @@ class SettingsUI {
To run Remix & a local Geth test node, use this command: (see <a href="https://geth.ethereum.org/getting-started/dev-mode" target="_blank">Geth Docs on Dev mode</a>) To run Remix & a local Geth test node, use this command: (see <a href="https://geth.ethereum.org/getting-started/dev-mode" target="_blank">Geth Docs on Dev mode</a>)
<div class="border p-1">geth --http --http.corsdomain="${window.origin}" --http.api web3,eth,debug,personal,net --vmdebug --datadir ${thePath} --dev console</div> <div class="border p-1">geth --http --http.corsdomain="${window.origin}" --http.api web3,eth,debug,personal,net --vmdebug --datadir ${thePath} --dev console</div>
<br> <br>
<br> <br>
<b>WARNING:</b> It is not safe to use the --http.corsdomain flag with a wildcard: <b>--http.corsdomain *</b> <b>WARNING:</b> It is not safe to use the --http.corsdomain flag with a wildcard: <b>--http.corsdomain *</b>
<br> <br>
<br>For more info: <a href="https://remix-ide.readthedocs.io/en/latest/run.html#more-about-web3-provider" target="_blank">Remix Docs on Web3 Provider</a> <br>For more info: <a href="https://remix-ide.readthedocs.io/en/latest/run.html#more-about-web3-provider" target="_blank">Remix Docs on Web3 Provider</a>
<br> <br>
<br> <br>
Web3 Provider Endpoint Web3 Provider Endpoint
</div> </div>
` `
......
This diff is collapsed.
...@@ -467,117 +467,7 @@ export class LandingPage extends ViewPlugin { ...@@ -467,117 +467,7 @@ export class LandingPage extends ViewPlugin {
// to retrieve medium posts // to retrieve medium posts
document.body.appendChild(yo`<script src="https://www.twilik.com/assets/retainable/rss-embed/retainable-rss-embed.js"></script>`) document.body.appendChild(yo`<script src="https://www.twilik.com/assets/retainable/rss-embed/retainable-rss-embed.js"></script>`)
const container = yo` const container = yo`
<div class="${css.homeContainer} d-flex" data-id="landingPageHomeContainer"> <div></div>
<div class="${css.mainContent} bg-light">
<div class="d-flex justify-content-between">
<div class="d-flex flex-column">
<div class="border-bottom d-flex justify-content-between clearfix py-3 mb-4">
<div class="mx-4 w-100 d-flex">
${img}
<audio id="remiAudio" muted=false src="assets/audio/remiGuitar-single-power-chord-A-minor.wav"></audio>
<div class="w-80 pl-5 ml-5">
<h5 class="mb-1">Quicklinks</h5>
<a class="${css.text} mr-1" target="__blank" href="https://medium.com/remix-ide/migrating-files-to-workspaces-8e34737c751c?source=friends_link&sk=b75cfd9093aa23c78be13cce49e4a5e8">Guide </a>for migrating the old File System
<p class="font-weight-bold mb-0 py-1">Migration tools:</p>
<li class="pl-1">
<spam class="pl-0">
<u class="${css.text} pr-1" onclick=${() => migrateWorkspace()}>Basic migration</u>
</spam>
</li>
<li class="pl-1">
<u class="${css.text} pr-1" onclick=${() => downloadFiles()}>Download all Files</u>
as a backup zip
</li>
<li class="pl-1">
<u class="${css.text} pr-1" onclick=${() => startRestoreBackupZip()}>Restore files</u>from backup zip
</li>
<p class="font-weight-bold mb-0 mt-2">Help:</p>
<dir class="d-flex flex-column mt-1 pl-0">
<a class="${css.text} mx-1" target="__blank" href="https://gitter.im/ethereum/remix">Gitter channel</a>
<a class="${css.text} mx-1" target="__blank" href="https://github.com/ethereum/remix-project/issues">Report on Github</a>
</dir>
</div>
</div>
</div>
<div class="row ${css.hpSections} mx-4" data-id="landingPageHpSections">
<div class="ml-3">
<div class="plugins mb-5">
<h4>Featured Plugins</h4>
<div class="d-flex flex-row pt-2">
${this.solEnv}
${this.optimismEnv}
${this.learnEthEnv}
${this.solhintEnv}
${this.sourcifyEnv}
${this.moreEnv}
</div>
</div>
<div class="d-flex">
<div class="file">
<h4>File</h4>
<p class="mb-1">
<i class="mr-1 far fa-file"></i>
<span class="ml-1 mb-1 ${css.text}" onclick=${() => createNewFile()}>New File</span>
</p>
<p class="mb-1">
<i class="mr-1 far fa-file-alt"></i>
<label class="ml-1 ${css.labelIt} ${css.bigLabelSize} ${css.text}">
Open Files
<input title="open file" type="file" onchange="${(event) => {
event.stopPropagation()
uploadFile(event.target)
}
}" multiple />
</label>
</p>
<p class="mb-1">
<i class="far fa-hdd"></i>
<span class="ml-1 ${css.text}" onclick=${() => connectToLocalhost()}>Connect to Localhost</span>
</p>
<p class="mt-3 mb-0"><label>LOAD FROM:</label></p>
<div class="btn-group">
<button class="btn mr-1 btn-secondary" data-id="landingPageImportFromGistButton" onclick="${() => importFromGist()}">Gist</button>
<button class="btn mx-1 btn-secondary" onclick="${() => load('Github', 'github URL', ['https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol', 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol'])}">GitHub</button>
<button class="btn mx-1 btn-secondary" onclick="${() => load('Ipfs', 'ipfs URL', ['ipfs://<ipfs-hash>'])}">Ipfs</button>
<button class="btn mx-1 btn-secondary" onclick="${() => load('Https', 'http/https raw content', ['https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol'])}">https</button>
</div><!-- end of btn-group -->
</div><!-- end of div.file -->
<div class="ml-4 pl-4">
<h4>Resources</h4>
<p class="mb-1">
<i class="mr-1 fas fa-book"></i>
<a class="${css.text}" target="__blank" href="https://remix-ide.readthedocs.io/en/latest/#">Documentation</a>
</p>
<p class="mb-1">
<i class="mr-1 fab fa-gitter"></i>
<a class="${css.text}" target="__blank" href="https://gitter.im/ethereum/remix">Gitter channel</a>
</p>
<p class="mb-1">
${this.websiteIcon}
<a class="${css.text}" target="__blank" href="https://remix-project.org">Featuring website</a>
</p>
<p class="mb-1">
<i class="fab fa-ethereum ${css.image}"></i>
<span class="${css.text}" onclick=${() => switchToPreviousVersion()}>Old experience</span>
</p>
</div>
</div>
</div>
</div><!-- end of hpSections -->
</div>
<div class="d-flex flex-column ${css.rightPanel}">
<div class="d-flex pr-3 py-2 align-self-end" id="remixIDEMediaPanelsTitle">
${this.badgeTwitter}
${this.badgeMedium}
</div>
<div class="mr-3 d-flex bg-light ${css.panels}" id="remixIDEMediaPanels">
${this.mediumPanel}
${this.twitterPanel}
</div>
</div>
</div>
</div>
</div>
` `
return container return container
......
...@@ -19,7 +19,8 @@ if (typeof window !== 'undefined' && typeof window.ethereum !== 'undefined') { ...@@ -19,7 +19,8 @@ if (typeof window !== 'undefined' && typeof window.ethereum !== 'undefined') {
export class ExecutionContext { export class ExecutionContext {
constructor () { constructor () {
this.event = new EventManager() this.event = new EventManager()
this.executionContext = null // @todo 关闭执行
this.executionContext = 'vm' // null
this.lastBlock = null this.lastBlock = null
this.blockGasLimitDefault = 4300000 this.blockGasLimitDefault = 4300000
this.blockGasLimit = this.blockGasLimitDefault this.blockGasLimit = this.blockGasLimitDefault
......
...@@ -25,7 +25,6 @@ export async function migrateToWorkspace (fileManager, filePanel) { ...@@ -25,7 +25,6 @@ export async function migrateToWorkspace (fileManager, filePanel) {
const browserProvider = fileManager.getProvider('browser') const browserProvider = fileManager.getProvider('browser')
const workspaceProvider = fileManager.getProvider('workspace') const workspaceProvider = fileManager.getProvider('workspace')
const files = await browserProvider.copyFolderToJson('/') const files = await browserProvider.copyFolderToJson('/')
if (Object.keys(files).length === 0) { if (Object.keys(files).length === 0) {
// we don't have any root file, only .workspaces // we don't have any root file, only .workspaces
// don't need to create a workspace // don't need to create a workspace
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ export interface RemixUiSettingsProps { ...@@ -19,7 +19,7 @@ export interface RemixUiSettingsProps {
export const RemixUiSettings = (props: RemixUiSettingsProps) => { export const RemixUiSettings = (props: RemixUiSettingsProps) => {
const [, dispatch] = useReducer(settingReducer, initialState) const [, dispatch] = useReducer(settingReducer, initialState)
const [state, dispatchToast] = useReducer(toastReducer, toastInitialState) const [state, dispatchToast] = useReducer(toastReducer, toastInitialState)
const [tokenValue, setTokenValue] = useState('') const [tokenValue, setTokenValue] = useState('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')
const [themeName, setThemeName] = useState('') const [themeName, setThemeName] = useState('')
useEffect(() => { useEffect(() => {
......
...@@ -150,6 +150,72 @@ export const publishToGist = async (path?: string, type?: string) => { ...@@ -150,6 +150,72 @@ export const publishToGist = async (path?: string, type?: string) => {
} }
} }
export const publishToBaas = async (path?: string, type?: string) => {
// If 'id' is not defined, it is not a gist update but a creation so we have to take the files from the browser explorer.
const folder = path || '/'
const id = type === 'baas' ? extractNameFromKey(path).split('-')[1] : null
try {
const packaged = await packageGistFiles(folder)
// check for token
const config = plugin.registry.get('config').api
const accessToken = config.get('settings/gist-access-token')
if (!accessToken) {
dispatch(displayNotification('Authorize Token', 'Remix requires an access token (which includes gists creation permission). Please go to the settings tab to create one.', 'Close', null, () => {}))
} else {
const description = 'Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=' +
queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&runs=' + queryParams.get().runs + '&gist='
const gists = new Gists({ token: accessToken })
if (id) {
const originalFileList = await getOriginalFiles(id)
// Telling the GIST API to remove files
const updatedFileList = Object.keys(packaged)
const allItems = Object.keys(originalFileList)
.filter(fileName => updatedFileList.indexOf(fileName) === -1)
.reduce((acc, deleteFileName) => ({
...acc,
[deleteFileName]: null
}), originalFileList)
// adding new files
updatedFileList.forEach((file) => {
const _items = file.split('/')
const _fileName = _items[_items.length - 1]
allItems[_fileName] = packaged[file]
})
dispatch(displayPopUp('Saving gist (' + id + ') ...'))
gists.edit({
description: description,
public: true,
files: allItems,
id: id
}, (error, result) => {
handleGistResponse(error, result)
if (!error) {
for (const key in allItems) {
if (allItems[key] === null) delete allItems[key]
}
}
})
} else {
// id is not existing, need to create a new gist
dispatch(displayPopUp('Creating a new gist ...'))
gists.create({
description: description,
public: true,
files: packaged
}, (error, result) => {
handleGistResponse(error, result)
})
}
}
} catch (error) {
console.log(error)
dispatch(displayNotification('Publish to gist Failed', 'Failed to create gist: ' + error.message, 'Close', null, async () => {}))
}
}
export const clearPopUp = async () => { export const clearPopUp = async () => {
dispatch(hidePopUp()) dispatch(hidePopUp())
} }
...@@ -260,7 +326,6 @@ const packageGistFiles = (directory) => { ...@@ -260,7 +326,6 @@ const packageGistFiles = (directory) => {
const workspaceProvider = plugin.fileProviders.workspace const workspaceProvider = plugin.fileProviders.workspace
const isFile = workspaceProvider.isFile(directory) const isFile = workspaceProvider.isFile(directory)
const ret = {} const ret = {}
if (isFile) { if (isFile) {
try { try {
workspaceProvider.get(directory, (error, content) => { workspaceProvider.get(directory, (error, content) => {
......
...@@ -6,7 +6,6 @@ import { checkSlash, checkSpecialChars } from '@remix-ui/helper' ...@@ -6,7 +6,6 @@ import { checkSlash, checkSpecialChars } from '@remix-ui/helper'
const examples = require('../../../../../../apps/remix-ide/src/app/editor/examples') const examples = require('../../../../../../apps/remix-ide/src/app/editor/examples')
const QueryParams = require('../../../../../../apps/remix-ide/src/lib/query-params') const QueryParams = require('../../../../../../apps/remix-ide/src/lib/query-params')
const LOCALHOST = ' - connect to localhost - ' const LOCALHOST = ' - connect to localhost - '
const NO_WORKSPACE = ' - none - ' const NO_WORKSPACE = ' - none - '
const queryParams = new QueryParams() const queryParams = new QueryParams()
...@@ -42,7 +41,6 @@ export const addInputField = async (type: 'file' | 'folder', path: string, cb?: ...@@ -42,7 +41,6 @@ export const addInputField = async (type: 'file' | 'folder', path: string, cb?:
export const createWorkspace = async (workspaceName: string, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => { export const createWorkspace = async (workspaceName: string, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => {
await plugin.fileManager.closeAllFiles() await plugin.fileManager.closeAllFiles()
const promise = createWorkspaceTemplate(workspaceName, 'default-template') const promise = createWorkspaceTemplate(workspaceName, 'default-template')
dispatch(createWorkspaceRequest(promise)) dispatch(createWorkspaceRequest(promise))
promise.then(async () => { promise.then(async () => {
dispatch(createWorkspaceSuccess(workspaceName)) dispatch(createWorkspaceSuccess(workspaceName))
...@@ -72,7 +70,6 @@ export const createWorkspaceTemplate = async (workspaceName: string, template: ' ...@@ -72,7 +70,6 @@ export const createWorkspaceTemplate = async (workspaceName: string, template: '
export const loadWorkspacePreset = async (template: 'gist-template' | 'code-template' | 'default-template' = 'default-template') => { export const loadWorkspacePreset = async (template: 'gist-template' | 'code-template' | 'default-template' = 'default-template') => {
const workspaceProvider = plugin.fileProviders.workspace const workspaceProvider = plugin.fileProviders.workspace
const params = queryParams.get() const params = queryParams.get()
switch (template) { switch (template) {
case 'code-template': case 'code-template':
// creates a new workspace code-sample and loads code from url params. // creates a new workspace code-sample and loads code from url params.
...@@ -292,7 +289,6 @@ export const getWorkspaces = async (): Promise<string[]> | undefined => { ...@@ -292,7 +289,6 @@ export const getWorkspaces = async (): Promise<string[]> | undefined => {
.map((folder) => folder.replace(workspacesPath + '/', ''))) .map((folder) => folder.replace(workspacesPath + '/', '')))
}) })
}) })
plugin.setWorkspaces(workspaces) plugin.setWorkspaces(workspaces)
return workspaces return workspaces
} catch (e) {} } catch (e) {}
......
...@@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line ...@@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
import { FileSystemContext } from '../contexts' import { FileSystemContext } from '../contexts'
import { browserReducer, browserInitialState } from '../reducers/workspace' import { browserReducer, browserInitialState } from '../reducers/workspace'
import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from '../actions' import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, publishToBaas, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile } from '../actions'
import { Modal, WorkspaceProps } from '../types' import { Modal, WorkspaceProps } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Workspace } from '../remix-ui-workspace' import { Workspace } from '../remix-ui-workspace'
...@@ -67,6 +67,11 @@ export const FileSystemProvider = (props: WorkspaceProps) => { ...@@ -67,6 +67,11 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await publishToGist(path, type) await publishToGist(path, type)
} }
// 上传到bass
const dispatchPublishToBaas = async (path?: string, type?: string) => {
await publishToBaas(path, type)
}
const dispatchUploadFile = async (target?: SyntheticEvent, targetFolder?: string) => { const dispatchUploadFile = async (target?: SyntheticEvent, targetFolder?: string) => {
await uploadFile(target, targetFolder) await uploadFile(target, targetFolder)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment