parent
5a8292dccb
commit
0fb27d0352
@ -0,0 +1,94 @@ |
|||||||
|
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ |
||||||
|
'use strict'; |
||||||
|
|
||||||
|
var _createClass = function () { |
||||||
|
function defineProperties(target, props) { |
||||||
|
for (var i = 0; i < props.length; i++) { |
||||||
|
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); |
||||||
|
} |
||||||
|
}return function (Constructor, protoProps, staticProps) { |
||||||
|
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; |
||||||
|
}; |
||||||
|
}(); |
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { |
||||||
|
if (!(instance instanceof Constructor)) { |
||||||
|
throw new TypeError("Cannot call a class as a function"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var RemixExtension = function () { |
||||||
|
function RemixExtension() { |
||||||
|
var _this = this; |
||||||
|
|
||||||
|
_classCallCheck(this, RemixExtension); |
||||||
|
|
||||||
|
this._notifications = {}; |
||||||
|
this._pendingRequests = {}; |
||||||
|
this._id = 0; |
||||||
|
window.addEventListener('message', function (event) { |
||||||
|
return _this._newMessage(event); |
||||||
|
}, false); |
||||||
|
} |
||||||
|
|
||||||
|
_createClass(RemixExtension, [{ |
||||||
|
key: 'listen', |
||||||
|
value: function listen(key, type, callback) { |
||||||
|
if (!this._notifications[key]) this._notifications[key] = {}; |
||||||
|
this._notifications[key][type] = callback; |
||||||
|
} |
||||||
|
}, { |
||||||
|
key: 'call', |
||||||
|
value: function call(key, type, params, callback) { |
||||||
|
this._id++; |
||||||
|
this._pendingRequests[this._id] = callback; |
||||||
|
window.parent.postMessage(JSON.stringify({ |
||||||
|
action: 'request', |
||||||
|
key: key, |
||||||
|
type: type, |
||||||
|
value: params, |
||||||
|
id: this._id |
||||||
|
}), '*'); |
||||||
|
} |
||||||
|
}, { |
||||||
|
key: '_newMessage', |
||||||
|
value: function _newMessage(event) { |
||||||
|
if (!event.data) return; |
||||||
|
if (typeof event.data !== 'string') return; |
||||||
|
|
||||||
|
var msg; |
||||||
|
try { |
||||||
|
msg = JSON.parse(event.data); |
||||||
|
} catch (e) { |
||||||
|
return console.log('unable to parse data'); |
||||||
|
} |
||||||
|
var _msg = msg, |
||||||
|
action = _msg.action, |
||||||
|
key = _msg.key, |
||||||
|
type = _msg.type, |
||||||
|
value = _msg.value; |
||||||
|
|
||||||
|
if (action === 'notification') { |
||||||
|
if (this._notifications[key] && this._notifications[key][type]) { |
||||||
|
this._notifications[key][type](value); |
||||||
|
} |
||||||
|
} else if (action === 'response') { |
||||||
|
var _msg2 = msg, |
||||||
|
id = _msg2.id, |
||||||
|
error = _msg2.error; |
||||||
|
|
||||||
|
if (this._pendingRequests[id]) { |
||||||
|
this._pendingRequests[id](error, value); |
||||||
|
delete this._pendingRequests[id]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}]); |
||||||
|
|
||||||
|
return RemixExtension; |
||||||
|
}(); |
||||||
|
|
||||||
|
if (window) window.RemixExtension = RemixExtension; |
||||||
|
if (module && module.exports) module.exports = RemixExtension; |
||||||
|
|
||||||
|
},{}]},{},[1]); |
@ -0,0 +1,49 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
|
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<!-- |
||||||
|
The MIT License (MIT) |
||||||
|
|
||||||
|
Copyright (c) 2014, 2015, the individual contributors |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in |
||||||
|
all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||||
|
THE SOFTWARE. |
||||||
|
--> |
||||||
|
<meta http-equiv="X-UA-Compatible" content="chrome=1"> |
||||||
|
<title></title> |
||||||
|
<link rel="stylesheet" href="assets/css/pygment_trac.css"> |
||||||
|
<link rel="stylesheet" href="assets/css/font-awesome.min.css"> |
||||||
|
<script type="text/javascript" src="remix.js"></script> |
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<div>PLUGIN</div> |
||||||
|
<input type="text" id="filename"></input> |
||||||
|
<input type="text" id="valuetosend"></input> <br> |
||||||
|
<input type="button" id="testmessageadd">add config</input> <br> |
||||||
|
<input type="button" id="testmessageremove">remove config</input> <br> |
||||||
|
<input type="button" id="testmessagerget">get config</input> <br> |
||||||
|
<input type="button" id="testcontractcreation">oraclize contract creation</input> <br> |
||||||
|
<input type="button" id="testaccountcreation">account creation</input> <br> |
||||||
|
<input type="button" id="testchangetitle">change title</input> <br> |
||||||
|
<br> |
||||||
|
<div id='compilationdata'></div> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,56 @@ |
|||||||
|
|
||||||
|
/* |
||||||
|
test contract creation |
||||||
|
*/ |
||||||
|
var addrResolverByteCode = '0x6060604052341561000f57600080fd5b33600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061033c8061005f6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806338cc483114610067578063767800de146100bc578063a6f9dae114610111578063d1d80fdf1461014a575b600080fd5b341561007257600080fd5b61007a610183565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100c757600080fd5b6100cf6101ac565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561011c57600080fd5b610148600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506101d1565b005b341561015557600080fd5b610181600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610271565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561022d57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156102cd57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058201b23355f578cb9a23c0a43a440ab2631b62df7be0a8e759812a70f01344224da0029' |
||||||
|
|
||||||
|
const addrResolverTx = { |
||||||
|
gasLimit: '0x2710', |
||||||
|
from: '0xca35b7d915458ef540ade6068dfe2f44e8fa733c', |
||||||
|
data: addrResolverByteCode, |
||||||
|
value: '0x00', |
||||||
|
useCall: false |
||||||
|
} |
||||||
|
var extension = new window.RemixExtension() |
||||||
|
window.onload = function () { |
||||||
|
extension.listen('compiler', 'compilationFinished', function () { |
||||||
|
console.log(arguments) |
||||||
|
}) |
||||||
|
|
||||||
|
setInterval(function () { |
||||||
|
extension.call('app', 'detectNetWork', [], function (error, result) { |
||||||
|
console.log(error, result) |
||||||
|
}) |
||||||
|
}, 5000) |
||||||
|
|
||||||
|
document.querySelector('input#testmessageadd').addEventListener('click', function () { |
||||||
|
extension.call('config', 'setConfig', [document.getElementById('filename').value, document.getElementById('valuetosend').value], |
||||||
|
function (error, result) { console.log(error, result) }) |
||||||
|
}) |
||||||
|
|
||||||
|
document.querySelector('input#testmessageremove').addEventListener('click', function () { |
||||||
|
extension.call('config', 'removeConfig', [document.getElementById('filename').value], |
||||||
|
function (error, result) { console.log(error, result) }) |
||||||
|
}) |
||||||
|
|
||||||
|
document.querySelector('input#testmessagerget').addEventListener('click', function () { |
||||||
|
extension.call('config', 'getConfig', [document.getElementById('filename').value], |
||||||
|
function (error, result) { console.log(error, result) }) |
||||||
|
}) |
||||||
|
|
||||||
|
document.querySelector('input#testcontractcreation').addEventListener('click', function () { |
||||||
|
extension.call('udapp', 'runTx', [addrResolverTx], |
||||||
|
function (error, result) { console.log(error, result) }) |
||||||
|
}) |
||||||
|
|
||||||
|
document.querySelector('input#testaccountcreation').addEventListener('click', function () { |
||||||
|
extension.call('udapp', 'createVMAccount', ['71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce', '0x56BC75E2D63100000'], |
||||||
|
function (error, result) { console.log(error, result) }) |
||||||
|
}) |
||||||
|
|
||||||
|
var k = 0 |
||||||
|
document.querySelector('input#testchangetitle').addEventListener('click', function () { |
||||||
|
extension.call('app', 'updateTitle', ['changed title ' + k++], |
||||||
|
function (error, result) { console.log(error, result) }) |
||||||
|
}) |
||||||
|
} |
Loading…
Reference in new issue