mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 03:58:13 +00:00
commit
43e8f0e73b
@ -9,7 +9,7 @@
|
||||
"maxdepth": 3,
|
||||
"maxerr": 50,
|
||||
/*"maxlen": 80*/ /*this should be our goal*/
|
||||
"maxparams": 3,
|
||||
/*"maxparams": 3,*/
|
||||
"nonew": true,
|
||||
"unused": true,
|
||||
"undef": true,
|
||||
|
316
dist/web3-light.js
vendored
316
dist/web3-light.js
vendored
@ -838,7 +838,7 @@ module.exports = function (str, isNew) {
|
||||
};
|
||||
|
||||
|
||||
},{"./utils":7,"crypto-js/sha3":30}],7:[function(require,module,exports){
|
||||
},{"./utils":7,"crypto-js/sha3":33}],7:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1288,6 +1288,18 @@ var isJson = function (str) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method should be called to check if string is valid ethereum IBAN number
|
||||
* Supports direct and indirect IBANs
|
||||
*
|
||||
* @method isIBAN
|
||||
* @param {String}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isIBAN = function (iban) {
|
||||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30})$/.test(iban);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
padLeft: padLeft,
|
||||
toHex: toHex,
|
||||
@ -1311,7 +1323,8 @@ module.exports = {
|
||||
isObject: isObject,
|
||||
isBoolean: isBoolean,
|
||||
isArray: isArray,
|
||||
isJson: isJson
|
||||
isJson: isJson,
|
||||
isIBAN: isIBAN
|
||||
};
|
||||
|
||||
|
||||
@ -1445,6 +1458,7 @@ web3.toBigNumber = utils.toBigNumber;
|
||||
web3.toWei = utils.toWei;
|
||||
web3.fromWei = utils.fromWei;
|
||||
web3.isAddress = utils.isAddress;
|
||||
web3.isIBAN = utils.isIBAN;
|
||||
web3.sha3 = sha3;
|
||||
web3.createBatch = function () {
|
||||
return new Batch();
|
||||
@ -1483,7 +1497,7 @@ setupMethods(web3.shh, shh.methods);
|
||||
module.exports = web3;
|
||||
|
||||
|
||||
},{"./utils/config":5,"./utils/sha3":6,"./utils/utils":7,"./version.json":8,"./web3/batch":10,"./web3/db":12,"./web3/eth":14,"./web3/filter":16,"./web3/formatters":17,"./web3/net":22,"./web3/property":23,"./web3/requestmanager":25,"./web3/shh":26,"./web3/watches":27}],10:[function(require,module,exports){
|
||||
},{"./utils/config":5,"./utils/sha3":6,"./utils/utils":7,"./version.json":8,"./web3/batch":10,"./web3/db":12,"./web3/eth":14,"./web3/filter":16,"./web3/formatters":17,"./web3/net":24,"./web3/property":25,"./web3/requestmanager":27,"./web3/shh":28,"./web3/watches":30}],10:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1546,7 +1560,7 @@ Batch.prototype.execute = function () {
|
||||
module.exports = Batch;
|
||||
|
||||
|
||||
},{"./requestmanager":25}],11:[function(require,module,exports){
|
||||
},{"./requestmanager":27}],11:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1786,7 +1800,7 @@ module.exports = {
|
||||
methods: methods
|
||||
};
|
||||
|
||||
},{"./method":21}],13:[function(require,module,exports){
|
||||
},{"./method":22}],13:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -2103,7 +2117,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./formatters":17,"./method":21,"./property":23}],15:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./formatters":17,"./method":22,"./property":25}],15:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -2457,7 +2471,7 @@ Filter.prototype.get = function (callback) {
|
||||
module.exports = Filter;
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./formatters":17,"./requestmanager":25}],17:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./formatters":17,"./requestmanager":27}],17:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -2755,7 +2769,7 @@ SolidityFunction.prototype.signature = function () {
|
||||
|
||||
|
||||
SolidityFunction.prototype.unpackOutput = function (output) {
|
||||
if (output === null) {
|
||||
if (!output) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2775,7 +2789,7 @@ SolidityFunction.prototype.unpackOutput = function (output) {
|
||||
* @return {String} output bytes
|
||||
*/
|
||||
SolidityFunction.prototype.call = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
||||
var callback = this.extractCallback(args);
|
||||
var payload = this.toPayload(args);
|
||||
|
||||
@ -2797,7 +2811,7 @@ SolidityFunction.prototype.call = function () {
|
||||
* @param {Object} options
|
||||
*/
|
||||
SolidityFunction.prototype.sendTransaction = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
||||
var callback = this.extractCallback(args);
|
||||
var payload = this.toPayload(args);
|
||||
|
||||
@ -3013,6 +3027,116 @@ module.exports = HttpProvider;
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file icap.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var utils = require('../utils/utils');
|
||||
|
||||
/**
|
||||
* This prototype should be used to extract necessary information from iban address
|
||||
*
|
||||
* @param {String} iban
|
||||
*/
|
||||
var ICAP = function (iban) {
|
||||
this._iban = iban;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if icap is correct
|
||||
*
|
||||
* @method isValid
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isValid = function () {
|
||||
return utils.isIBAN(this._iban);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if iban number is direct
|
||||
*
|
||||
* @method isDirect
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isDirect = function () {
|
||||
return this._iban.length === 34;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if iban number if indirect
|
||||
*
|
||||
* @method isIndirect
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isIndirect = function () {
|
||||
return this._iban.length === 20;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get iban checksum
|
||||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
|
||||
*
|
||||
* @method checksum
|
||||
* @returns {String} checksum
|
||||
*/
|
||||
ICAP.prototype.checksum = function () {
|
||||
return this._iban.substr(2, 2);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get institution identifier
|
||||
* eg. XREG
|
||||
*
|
||||
* @method institution
|
||||
* @returns {String} institution identifier
|
||||
*/
|
||||
ICAP.prototype.institution = function () {
|
||||
return this.isIndirect() ? this._iban.substr(7, 4) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get client identifier within institution
|
||||
* eg. GAVOFYORK
|
||||
*
|
||||
* @method client
|
||||
* @returns {String} client identifier
|
||||
*/
|
||||
ICAP.prototype.client = function () {
|
||||
return this.isIndirect() ? this._iban.substr(11) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get client direct address
|
||||
*
|
||||
* @method address
|
||||
* @returns {String} client direct address
|
||||
*/
|
||||
ICAP.prototype.address = function () {
|
||||
return this.isDirect() ? this._iban.substr(4) : '';
|
||||
};
|
||||
|
||||
module.exports = ICAP;
|
||||
|
||||
|
||||
},{"../utils/utils":7}],21:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @file jsonrpc.js
|
||||
* @authors:
|
||||
* Marek Kotewicz <marek@ethdev.com>
|
||||
@ -3089,7 +3213,7 @@ Jsonrpc.prototype.toBatchPayload = function (messages) {
|
||||
module.exports = Jsonrpc;
|
||||
|
||||
|
||||
},{}],21:[function(require,module,exports){
|
||||
},{}],22:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3263,7 +3387,55 @@ Method.prototype.send = function () {
|
||||
module.exports = Method;
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./errors":13,"./requestmanager":25}],22:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./errors":13,"./requestmanager":27}],23:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file namereg.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var contract = require('./contract');
|
||||
|
||||
var address = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
|
||||
|
||||
var abi = [
|
||||
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},
|
||||
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"}],"name":"PrimaryChanged","type":"event"}
|
||||
];
|
||||
|
||||
module.exports = contract(abi).at(address);
|
||||
|
||||
|
||||
},{"./contract":11}],24:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3313,7 +3485,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./property":23}],23:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./property":25}],25:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3431,7 +3603,7 @@ Property.prototype.getAsync = function (callback) {
|
||||
module.exports = Property;
|
||||
|
||||
|
||||
},{"./requestmanager":25}],24:[function(require,module,exports){
|
||||
},{"./requestmanager":27}],26:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3466,7 +3638,7 @@ QtSyncProvider.prototype.send = function (payload) {
|
||||
module.exports = QtSyncProvider;
|
||||
|
||||
|
||||
},{}],25:[function(require,module,exports){
|
||||
},{}],27:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3714,7 +3886,7 @@ RequestManager.prototype.poll = function () {
|
||||
module.exports = RequestManager;
|
||||
|
||||
|
||||
},{"../utils/config":5,"../utils/utils":7,"./errors":13,"./jsonrpc":20}],26:[function(require,module,exports){
|
||||
},{"../utils/config":5,"../utils/utils":7,"./errors":13,"./jsonrpc":21}],28:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3784,7 +3956,103 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"./formatters":17,"./method":21}],27:[function(require,module,exports){
|
||||
},{"./formatters":17,"./method":22}],29:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file transfer.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var web3 = require('../web3');
|
||||
var ICAP = require('./icap');
|
||||
var namereg = require('./namereg');
|
||||
var contract = require('./contract');
|
||||
|
||||
/**
|
||||
* Should be used to make ICAP transfer
|
||||
*
|
||||
* @method transfer
|
||||
* @param {String} iban number
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var transfer = function (from, iban, value, callback) {
|
||||
var icap = new ICAP(iban);
|
||||
if (!icap.isValid()) {
|
||||
throw new Error('invalid iban address');
|
||||
}
|
||||
|
||||
if (icap.isDirect()) {
|
||||
return transferToAddress(from, icap.address(), value, callback);
|
||||
}
|
||||
|
||||
if (!callback) {
|
||||
var address = namereg.addr(icap.institution());
|
||||
return deposit(from, address, value, icap.client());
|
||||
}
|
||||
|
||||
namereg.addr(icap.insitution(), function (err, address) {
|
||||
return deposit(from, address, value, icap.client(), callback);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to transfer funds to certain address
|
||||
*
|
||||
* @method transferToAddress
|
||||
* @param {String} address
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var transferToAddress = function (from, address, value, callback) {
|
||||
return web3.eth.sendTransaction({
|
||||
address: address,
|
||||
from: from,
|
||||
value: value
|
||||
}, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
|
||||
*
|
||||
* @method deposit
|
||||
* @param {String} address
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {String} client unique identifier
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var deposit = function (from, address, value, client, callback) {
|
||||
var abi = [{"constant":false,"inputs":[{"name":"name","type":"bytes32"}],"name":"deposit","outputs":[],"type":"function"}];
|
||||
return contract(abi).at(address).deposit(client, {
|
||||
from: from,
|
||||
value: value
|
||||
}, callback);
|
||||
};
|
||||
|
||||
module.exports = transfer;
|
||||
|
||||
|
||||
},{"../web3":9,"./contract":11,"./icap":20,"./namereg":23}],30:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3900,9 +4168,9 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"./method":21}],28:[function(require,module,exports){
|
||||
},{"./method":22}],31:[function(require,module,exports){
|
||||
|
||||
},{}],29:[function(require,module,exports){
|
||||
},{}],32:[function(require,module,exports){
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -4648,7 +4916,7 @@ module.exports = {
|
||||
return CryptoJS;
|
||||
|
||||
}));
|
||||
},{}],30:[function(require,module,exports){
|
||||
},{}],33:[function(require,module,exports){
|
||||
;(function (root, factory, undef) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -4972,7 +5240,7 @@ module.exports = {
|
||||
return CryptoJS.SHA3;
|
||||
|
||||
}));
|
||||
},{"./core":29,"./x64-core":31}],31:[function(require,module,exports){
|
||||
},{"./core":32,"./x64-core":34}],34:[function(require,module,exports){
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -5277,7 +5545,7 @@ module.exports = {
|
||||
return CryptoJS;
|
||||
|
||||
}));
|
||||
},{"./core":29}],"bignumber.js":[function(require,module,exports){
|
||||
},{"./core":32}],"bignumber.js":[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
module.exports = BigNumber; // jshint ignore:line
|
||||
@ -5288,6 +5556,8 @@ var web3 = require('./lib/web3');
|
||||
web3.providers.HttpProvider = require('./lib/web3/httpprovider');
|
||||
web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
|
||||
web3.eth.contract = require('./lib/web3/contract');
|
||||
web3.eth.namereg = require('./lib/web3/namereg');
|
||||
web3.eth.sendIBANTransaction = require('./lib/web3/transfer');
|
||||
|
||||
// dont override global variable
|
||||
if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
||||
@ -5297,7 +5567,7 @@ if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
||||
module.exports = web3;
|
||||
|
||||
|
||||
},{"./lib/web3":9,"./lib/web3/contract":11,"./lib/web3/httpprovider":19,"./lib/web3/qtsync":24}]},{},["web3"])
|
||||
},{"./lib/web3":9,"./lib/web3/contract":11,"./lib/web3/httpprovider":19,"./lib/web3/namereg":23,"./lib/web3/qtsync":26,"./lib/web3/transfer":29}]},{},["web3"])
|
||||
|
||||
|
||||
//# sourceMappingURL=web3-light.js.map
|
16
dist/web3-light.js.map
vendored
16
dist/web3-light.js.map
vendored
File diff suppressed because one or more lines are too long
5
dist/web3-light.min.js
vendored
5
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
318
dist/web3.js
vendored
318
dist/web3.js
vendored
@ -838,7 +838,7 @@ module.exports = function (str, isNew) {
|
||||
};
|
||||
|
||||
|
||||
},{"./utils":7,"crypto-js/sha3":30}],7:[function(require,module,exports){
|
||||
},{"./utils":7,"crypto-js/sha3":33}],7:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1288,6 +1288,18 @@ var isJson = function (str) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method should be called to check if string is valid ethereum IBAN number
|
||||
* Supports direct and indirect IBANs
|
||||
*
|
||||
* @method isIBAN
|
||||
* @param {String}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isIBAN = function (iban) {
|
||||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30})$/.test(iban);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
padLeft: padLeft,
|
||||
toHex: toHex,
|
||||
@ -1311,7 +1323,8 @@ module.exports = {
|
||||
isObject: isObject,
|
||||
isBoolean: isBoolean,
|
||||
isArray: isArray,
|
||||
isJson: isJson
|
||||
isJson: isJson,
|
||||
isIBAN: isIBAN
|
||||
};
|
||||
|
||||
|
||||
@ -1445,6 +1458,7 @@ web3.toBigNumber = utils.toBigNumber;
|
||||
web3.toWei = utils.toWei;
|
||||
web3.fromWei = utils.fromWei;
|
||||
web3.isAddress = utils.isAddress;
|
||||
web3.isIBAN = utils.isIBAN;
|
||||
web3.sha3 = sha3;
|
||||
web3.createBatch = function () {
|
||||
return new Batch();
|
||||
@ -1483,7 +1497,7 @@ setupMethods(web3.shh, shh.methods);
|
||||
module.exports = web3;
|
||||
|
||||
|
||||
},{"./utils/config":5,"./utils/sha3":6,"./utils/utils":7,"./version.json":8,"./web3/batch":10,"./web3/db":12,"./web3/eth":14,"./web3/filter":16,"./web3/formatters":17,"./web3/net":22,"./web3/property":23,"./web3/requestmanager":25,"./web3/shh":26,"./web3/watches":27}],10:[function(require,module,exports){
|
||||
},{"./utils/config":5,"./utils/sha3":6,"./utils/utils":7,"./version.json":8,"./web3/batch":10,"./web3/db":12,"./web3/eth":14,"./web3/filter":16,"./web3/formatters":17,"./web3/net":24,"./web3/property":25,"./web3/requestmanager":27,"./web3/shh":28,"./web3/watches":30}],10:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1546,7 +1560,7 @@ Batch.prototype.execute = function () {
|
||||
module.exports = Batch;
|
||||
|
||||
|
||||
},{"./requestmanager":25}],11:[function(require,module,exports){
|
||||
},{"./requestmanager":27}],11:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1786,7 +1800,7 @@ module.exports = {
|
||||
methods: methods
|
||||
};
|
||||
|
||||
},{"./method":21}],13:[function(require,module,exports){
|
||||
},{"./method":22}],13:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -2103,7 +2117,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./formatters":17,"./method":21,"./property":23}],15:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./formatters":17,"./method":22,"./property":25}],15:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -2457,7 +2471,7 @@ Filter.prototype.get = function (callback) {
|
||||
module.exports = Filter;
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./formatters":17,"./requestmanager":25}],17:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./formatters":17,"./requestmanager":27}],17:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -2755,7 +2769,7 @@ SolidityFunction.prototype.signature = function () {
|
||||
|
||||
|
||||
SolidityFunction.prototype.unpackOutput = function (output) {
|
||||
if (output === null) {
|
||||
if (!output) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2775,7 +2789,7 @@ SolidityFunction.prototype.unpackOutput = function (output) {
|
||||
* @return {String} output bytes
|
||||
*/
|
||||
SolidityFunction.prototype.call = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
||||
var callback = this.extractCallback(args);
|
||||
var payload = this.toPayload(args);
|
||||
|
||||
@ -2797,7 +2811,7 @@ SolidityFunction.prototype.call = function () {
|
||||
* @param {Object} options
|
||||
*/
|
||||
SolidityFunction.prototype.sendTransaction = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
||||
var callback = this.extractCallback(args);
|
||||
var payload = this.toPayload(args);
|
||||
|
||||
@ -3013,6 +3027,116 @@ module.exports = HttpProvider;
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file icap.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var utils = require('../utils/utils');
|
||||
|
||||
/**
|
||||
* This prototype should be used to extract necessary information from iban address
|
||||
*
|
||||
* @param {String} iban
|
||||
*/
|
||||
var ICAP = function (iban) {
|
||||
this._iban = iban;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if icap is correct
|
||||
*
|
||||
* @method isValid
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isValid = function () {
|
||||
return utils.isIBAN(this._iban);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if iban number is direct
|
||||
*
|
||||
* @method isDirect
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isDirect = function () {
|
||||
return this._iban.length === 34;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if iban number if indirect
|
||||
*
|
||||
* @method isIndirect
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isIndirect = function () {
|
||||
return this._iban.length === 20;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get iban checksum
|
||||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
|
||||
*
|
||||
* @method checksum
|
||||
* @returns {String} checksum
|
||||
*/
|
||||
ICAP.prototype.checksum = function () {
|
||||
return this._iban.substr(2, 2);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get institution identifier
|
||||
* eg. XREG
|
||||
*
|
||||
* @method institution
|
||||
* @returns {String} institution identifier
|
||||
*/
|
||||
ICAP.prototype.institution = function () {
|
||||
return this.isIndirect() ? this._iban.substr(7, 4) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get client identifier within institution
|
||||
* eg. GAVOFYORK
|
||||
*
|
||||
* @method client
|
||||
* @returns {String} client identifier
|
||||
*/
|
||||
ICAP.prototype.client = function () {
|
||||
return this.isIndirect() ? this._iban.substr(11) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get client direct address
|
||||
*
|
||||
* @method address
|
||||
* @returns {String} client direct address
|
||||
*/
|
||||
ICAP.prototype.address = function () {
|
||||
return this.isDirect() ? this._iban.substr(4) : '';
|
||||
};
|
||||
|
||||
module.exports = ICAP;
|
||||
|
||||
|
||||
},{"../utils/utils":7}],21:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @file jsonrpc.js
|
||||
* @authors:
|
||||
* Marek Kotewicz <marek@ethdev.com>
|
||||
@ -3089,7 +3213,7 @@ Jsonrpc.prototype.toBatchPayload = function (messages) {
|
||||
module.exports = Jsonrpc;
|
||||
|
||||
|
||||
},{}],21:[function(require,module,exports){
|
||||
},{}],22:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3263,7 +3387,55 @@ Method.prototype.send = function () {
|
||||
module.exports = Method;
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./errors":13,"./requestmanager":25}],22:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./errors":13,"./requestmanager":27}],23:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file namereg.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var contract = require('./contract');
|
||||
|
||||
var address = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
|
||||
|
||||
var abi = [
|
||||
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},
|
||||
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"}],"name":"PrimaryChanged","type":"event"}
|
||||
];
|
||||
|
||||
module.exports = contract(abi).at(address);
|
||||
|
||||
|
||||
},{"./contract":11}],24:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3313,7 +3485,7 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"../utils/utils":7,"./property":23}],23:[function(require,module,exports){
|
||||
},{"../utils/utils":7,"./property":25}],25:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3431,7 +3603,7 @@ Property.prototype.getAsync = function (callback) {
|
||||
module.exports = Property;
|
||||
|
||||
|
||||
},{"./requestmanager":25}],24:[function(require,module,exports){
|
||||
},{"./requestmanager":27}],26:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3466,7 +3638,7 @@ QtSyncProvider.prototype.send = function (payload) {
|
||||
module.exports = QtSyncProvider;
|
||||
|
||||
|
||||
},{}],25:[function(require,module,exports){
|
||||
},{}],27:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3714,7 +3886,7 @@ RequestManager.prototype.poll = function () {
|
||||
module.exports = RequestManager;
|
||||
|
||||
|
||||
},{"../utils/config":5,"../utils/utils":7,"./errors":13,"./jsonrpc":20}],26:[function(require,module,exports){
|
||||
},{"../utils/config":5,"../utils/utils":7,"./errors":13,"./jsonrpc":21}],28:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3784,7 +3956,103 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"./formatters":17,"./method":21}],27:[function(require,module,exports){
|
||||
},{"./formatters":17,"./method":22}],29:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file transfer.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var web3 = require('../web3');
|
||||
var ICAP = require('./icap');
|
||||
var namereg = require('./namereg');
|
||||
var contract = require('./contract');
|
||||
|
||||
/**
|
||||
* Should be used to make ICAP transfer
|
||||
*
|
||||
* @method transfer
|
||||
* @param {String} iban number
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var transfer = function (from, iban, value, callback) {
|
||||
var icap = new ICAP(iban);
|
||||
if (!icap.isValid()) {
|
||||
throw new Error('invalid iban address');
|
||||
}
|
||||
|
||||
if (icap.isDirect()) {
|
||||
return transferToAddress(from, icap.address(), value, callback);
|
||||
}
|
||||
|
||||
if (!callback) {
|
||||
var address = namereg.addr(icap.institution());
|
||||
return deposit(from, address, value, icap.client());
|
||||
}
|
||||
|
||||
namereg.addr(icap.insitution(), function (err, address) {
|
||||
return deposit(from, address, value, icap.client(), callback);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to transfer funds to certain address
|
||||
*
|
||||
* @method transferToAddress
|
||||
* @param {String} address
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var transferToAddress = function (from, address, value, callback) {
|
||||
return web3.eth.sendTransaction({
|
||||
address: address,
|
||||
from: from,
|
||||
value: value
|
||||
}, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
|
||||
*
|
||||
* @method deposit
|
||||
* @param {String} address
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {String} client unique identifier
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var deposit = function (from, address, value, client, callback) {
|
||||
var abi = [{"constant":false,"inputs":[{"name":"name","type":"bytes32"}],"name":"deposit","outputs":[],"type":"function"}];
|
||||
return contract(abi).at(address).deposit(client, {
|
||||
from: from,
|
||||
value: value
|
||||
}, callback);
|
||||
};
|
||||
|
||||
module.exports = transfer;
|
||||
|
||||
|
||||
},{"../web3":9,"./contract":11,"./icap":20,"./namereg":23}],30:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3900,9 +4168,9 @@ module.exports = {
|
||||
};
|
||||
|
||||
|
||||
},{"./method":21}],28:[function(require,module,exports){
|
||||
},{"./method":22}],31:[function(require,module,exports){
|
||||
|
||||
},{}],29:[function(require,module,exports){
|
||||
},{}],32:[function(require,module,exports){
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -4648,7 +4916,7 @@ module.exports = {
|
||||
return CryptoJS;
|
||||
|
||||
}));
|
||||
},{}],30:[function(require,module,exports){
|
||||
},{}],33:[function(require,module,exports){
|
||||
;(function (root, factory, undef) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -4972,7 +5240,7 @@ module.exports = {
|
||||
return CryptoJS.SHA3;
|
||||
|
||||
}));
|
||||
},{"./core":29,"./x64-core":31}],31:[function(require,module,exports){
|
||||
},{"./core":32,"./x64-core":34}],34:[function(require,module,exports){
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -5277,7 +5545,7 @@ module.exports = {
|
||||
return CryptoJS;
|
||||
|
||||
}));
|
||||
},{"./core":29}],"bignumber.js":[function(require,module,exports){
|
||||
},{"./core":32}],"bignumber.js":[function(require,module,exports){
|
||||
/*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
|
||||
|
||||
;(function (global) {
|
||||
@ -7962,11 +8230,13 @@ module.exports = {
|
||||
}
|
||||
})(this);
|
||||
|
||||
},{"crypto":28}],"web3":[function(require,module,exports){
|
||||
},{"crypto":31}],"web3":[function(require,module,exports){
|
||||
var web3 = require('./lib/web3');
|
||||
web3.providers.HttpProvider = require('./lib/web3/httpprovider');
|
||||
web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
|
||||
web3.eth.contract = require('./lib/web3/contract');
|
||||
web3.eth.namereg = require('./lib/web3/namereg');
|
||||
web3.eth.sendIBANTransaction = require('./lib/web3/transfer');
|
||||
|
||||
// dont override global variable
|
||||
if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
||||
@ -7976,7 +8246,7 @@ if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
||||
module.exports = web3;
|
||||
|
||||
|
||||
},{"./lib/web3":9,"./lib/web3/contract":11,"./lib/web3/httpprovider":19,"./lib/web3/qtsync":24}]},{},["web3"])
|
||||
},{"./lib/web3":9,"./lib/web3/contract":11,"./lib/web3/httpprovider":19,"./lib/web3/namereg":23,"./lib/web3/qtsync":26,"./lib/web3/transfer":29}]},{},["web3"])
|
||||
|
||||
|
||||
//# sourceMappingURL=web3.js.map
|
16
dist/web3.js.map
vendored
16
dist/web3.js.map
vendored
File diff suppressed because one or more lines are too long
5
dist/web3.min.js
vendored
5
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
102
example/icap.html
Normal file
102
example/icap.html
Normal file
@ -0,0 +1,102 @@
|
||||
<!doctype>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script type="text/javascript" src="../dist/web3.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var web3 = require('web3');
|
||||
var BigNumber = require('bignumber.js');
|
||||
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
|
||||
var from = web3.eth.coinbase;
|
||||
web3.eth.defaultAccount = from;
|
||||
|
||||
/*
|
||||
window.onload = function () {
|
||||
var abi = [{
|
||||
"anonymous" : false,
|
||||
"inputs" : [
|
||||
{
|
||||
"indexed" : true,
|
||||
"name" : "from",
|
||||
"type" : "address"
|
||||
},
|
||||
{
|
||||
"indexed" : true,
|
||||
"name" : "to",
|
||||
"type" : "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed" : false,
|
||||
"name" : "value",
|
||||
"type" : "uint256"
|
||||
}
|
||||
],
|
||||
"name" : "Deposit",
|
||||
"type" : "event"
|
||||
}];
|
||||
|
||||
var ExchangeInterface = web3.eth.contract(abi).at(web3.eth.namereg.addr('XROO'));
|
||||
var filter = ExchangeInterface.Deposit({}, {fromBlock: 0});
|
||||
filter.watch(function (err, event) {
|
||||
console.log(event);
|
||||
displayDeposit("block: " + event.blockNumber + " user: " + event.args._id + "\nvalue : " + event.args._value.toString(10));
|
||||
});
|
||||
};
|
||||
*/
|
||||
|
||||
function displayDeposit(text) {
|
||||
var node = document.createElement('li');
|
||||
var textnode = document.createTextNode(text);
|
||||
node.appendChild(textnode);
|
||||
document.getElementById('deposits').appendChild(node);
|
||||
}
|
||||
|
||||
function validateValue() {
|
||||
try {
|
||||
var value = document.getElementById('value').value;
|
||||
var bnValue = new BigNumber(value);
|
||||
document.getElementById('valueValidation').innerText = bnValue.toString(10);
|
||||
} catch (err) {
|
||||
document.getElementById('valueValidation').innerText = 'Value is incorrect, cannot parse';
|
||||
}
|
||||
};
|
||||
|
||||
function validateIBAN() {
|
||||
var iban = document.getElementById('iban').value;
|
||||
if (!web3.isIBAN(iban)) {
|
||||
return document.getElementById('ibanValidation').innerText = 'IBAN number is incorrect';
|
||||
}
|
||||
var institution = iban.substr(7, 4);
|
||||
var address = web3.eth.namereg.addr(institution);
|
||||
document.getElementById('ibanValidation').innerText = 'IBAN number correct, exchange address: ' + address;
|
||||
};
|
||||
|
||||
function transfer() {
|
||||
var value = new BigNumber(document.getElementById('value').value);
|
||||
var iban = document.getElementById('iban').value;
|
||||
web3.eth.sendIBANTransaction(from, iban, value);
|
||||
};
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ICAP</h1>
|
||||
<h3>Transfer</h3>
|
||||
<div>
|
||||
<text>Destination IBAN (eg. XE81ETHXROOGAVOFYORK): </text>
|
||||
<input type="text" id="iban" onkeyup='validateIBAN()'></input>
|
||||
<text id="ibanValidation"></text>
|
||||
</div>
|
||||
<div>
|
||||
<text>Value: </text>
|
||||
<input type="text" id="value" onkeyup='validateValue()'></input>
|
||||
<text id="valueValidation"></text>
|
||||
</div>
|
||||
<div>
|
||||
<button id="transfer" type="button" onClick="transfer()">Transfer!</button>
|
||||
</div>
|
||||
<h3 style="visibility: hidden;">"XREG" Exchange deposits</h3>
|
||||
<ul style="visibility: hidden;" id="deposits"></ul>
|
||||
</body>
|
||||
</html>
|
102
example/namereg.html
Normal file
102
example/namereg.html
Normal file
@ -0,0 +1,102 @@
|
||||
<!doctype>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script type="text/javascript" src="../dist/web3.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var web3 = require('web3');
|
||||
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
|
||||
var from = web3.eth.coinbase;
|
||||
web3.eth.defaultAccount = from;
|
||||
|
||||
window.onload = function () {
|
||||
var filter = web3.eth.namereg.Changed();
|
||||
filter.watch(function (err, event) {
|
||||
// live update all fields
|
||||
onAddressKeyUp();
|
||||
onNameKeyUp();
|
||||
onRegisterOwnerKeyUp();
|
||||
});
|
||||
};
|
||||
|
||||
function registerOwner() {
|
||||
var name = document.getElementById('registerOwner').value;
|
||||
web3.eth.namereg.reserve(name);
|
||||
document.getElementById('nameAvailability').innerText += ' Registering name in progress, please wait...';
|
||||
};
|
||||
|
||||
function changeAddress() {
|
||||
var name = document.getElementById('registerOwner').value;
|
||||
var address = document.getElementById('newAddress').value;
|
||||
web3.eth.namereg.setAddress(name, address, true);
|
||||
document.getElementById('currentAddress').innerText += ' Changing address in progress. Please wait.';
|
||||
};
|
||||
|
||||
function onRegisterOwnerKeyUp() {
|
||||
var name = document.getElementById('registerOwner').value;
|
||||
var owner = web3.eth.namereg.owner(name)
|
||||
document.getElementById('currentAddress').innerText = web3.eth.namereg.addr(name);
|
||||
if (owner !== '0x0000000000000000000000000000000000000000') {
|
||||
if (owner === from) {
|
||||
document.getElementById('nameAvailability').innerText = "This name is already owned by you " + owner;
|
||||
} else {
|
||||
document.getElementById('nameAvailability').innerText = "This name is not available. It's already registered by " + owner;
|
||||
}
|
||||
return;
|
||||
}
|
||||
document.getElementById('nameAvailability').innerText = "This name is available. You can register it.";
|
||||
};
|
||||
|
||||
function onAddressKeyUp() {
|
||||
var address = document.getElementById('address').value;
|
||||
document.getElementById('nameOf').innerText = web3.eth.namereg.name(address);
|
||||
};
|
||||
|
||||
function onNameKeyUp() {
|
||||
var name = document.getElementById('name').value;
|
||||
document.getElementById('addressOf').innerText = web3.eth.namereg.addr(name);
|
||||
};
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<i>This example shows only part of namereg functionalities. Namereg contract is available <a href="https://github.com/ethereum/dapp-bin/blob/master/GlobalRegistrar/contract.sol">here</a>
|
||||
</i>
|
||||
<h1>Namereg</h1>
|
||||
<h3>Search for name</h3>
|
||||
<div>
|
||||
<text>Address: </text>
|
||||
<input type="text" id="address" onkeyup='onAddressKeyUp()'></input>
|
||||
<text>Name: </text>
|
||||
<text id="nameOf"></text>
|
||||
</div>
|
||||
<h3>Search for address</h3>
|
||||
<div>
|
||||
<text>Name: </text>
|
||||
<input type="text" id="name" onkeyup='onNameKeyUp()'></input>
|
||||
<text>Address: </text>
|
||||
<text id="addressOf"></text>
|
||||
</div>
|
||||
<h3>Register name</h3>
|
||||
<div>
|
||||
<text>Check if name is available: </text>
|
||||
<input type="text" id="registerOwner" onkeyup='onRegisterOwnerKeyUp()'></input>
|
||||
<text id='nameAvailability'></text>
|
||||
</div>
|
||||
<div>
|
||||
<button id="registerOwnerButton" type="button" onClick="registerOwner()">Register!</button>
|
||||
</div>
|
||||
<h3></h3>
|
||||
<i>If you own the name, you can also change the address it points to</i>
|
||||
<div>
|
||||
<text>Address: </text>
|
||||
<input type="text" id="newAddress"></input>
|
||||
<button id="changeAddress" type="button" onClick="changeAddress()">Change address!</button>
|
||||
<text>Current address :</text>
|
||||
<text id="currentAddress"></text>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
2
index.js
2
index.js
@ -2,6 +2,8 @@ var web3 = require('./lib/web3');
|
||||
web3.providers.HttpProvider = require('./lib/web3/httpprovider');
|
||||
web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
|
||||
web3.eth.contract = require('./lib/web3/contract');
|
||||
web3.eth.namereg = require('./lib/web3/namereg');
|
||||
web3.eth.sendIBANTransaction = require('./lib/web3/transfer');
|
||||
|
||||
// dont override global variable
|
||||
if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
||||
|
@ -447,6 +447,18 @@ var isJson = function (str) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method should be called to check if string is valid ethereum IBAN number
|
||||
* Supports direct and indirect IBANs
|
||||
*
|
||||
* @method isIBAN
|
||||
* @param {String}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isIBAN = function (iban) {
|
||||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30})$/.test(iban);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
padLeft: padLeft,
|
||||
toHex: toHex,
|
||||
@ -470,6 +482,7 @@ module.exports = {
|
||||
isObject: isObject,
|
||||
isBoolean: isBoolean,
|
||||
isArray: isArray,
|
||||
isJson: isJson
|
||||
isJson: isJson,
|
||||
isIBAN: isIBAN
|
||||
};
|
||||
|
||||
|
@ -122,6 +122,7 @@ web3.toBigNumber = utils.toBigNumber;
|
||||
web3.toWei = utils.toWei;
|
||||
web3.fromWei = utils.fromWei;
|
||||
web3.isAddress = utils.isAddress;
|
||||
web3.isIBAN = utils.isIBAN;
|
||||
web3.sha3 = sha3;
|
||||
web3.createBatch = function () {
|
||||
return new Batch();
|
||||
|
@ -75,7 +75,7 @@ SolidityFunction.prototype.signature = function () {
|
||||
|
||||
|
||||
SolidityFunction.prototype.unpackOutput = function (output) {
|
||||
if (output === null) {
|
||||
if (!output) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ SolidityFunction.prototype.unpackOutput = function (output) {
|
||||
* @return {String} output bytes
|
||||
*/
|
||||
SolidityFunction.prototype.call = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
||||
var callback = this.extractCallback(args);
|
||||
var payload = this.toPayload(args);
|
||||
|
||||
@ -117,7 +117,7 @@ SolidityFunction.prototype.call = function () {
|
||||
* @param {Object} options
|
||||
*/
|
||||
SolidityFunction.prototype.sendTransaction = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
|
||||
var callback = this.extractCallback(args);
|
||||
var payload = this.toPayload(args);
|
||||
|
||||
|
108
lib/web3/icap.js
Normal file
108
lib/web3/icap.js
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file icap.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var utils = require('../utils/utils');
|
||||
|
||||
/**
|
||||
* This prototype should be used to extract necessary information from iban address
|
||||
*
|
||||
* @param {String} iban
|
||||
*/
|
||||
var ICAP = function (iban) {
|
||||
this._iban = iban;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if icap is correct
|
||||
*
|
||||
* @method isValid
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isValid = function () {
|
||||
return utils.isIBAN(this._iban);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if iban number is direct
|
||||
*
|
||||
* @method isDirect
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isDirect = function () {
|
||||
return this._iban.length === 34;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to check if iban number if indirect
|
||||
*
|
||||
* @method isIndirect
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
ICAP.prototype.isIndirect = function () {
|
||||
return this._iban.length === 20;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get iban checksum
|
||||
* Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
|
||||
*
|
||||
* @method checksum
|
||||
* @returns {String} checksum
|
||||
*/
|
||||
ICAP.prototype.checksum = function () {
|
||||
return this._iban.substr(2, 2);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get institution identifier
|
||||
* eg. XREG
|
||||
*
|
||||
* @method institution
|
||||
* @returns {String} institution identifier
|
||||
*/
|
||||
ICAP.prototype.institution = function () {
|
||||
return this.isIndirect() ? this._iban.substr(7, 4) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get client identifier within institution
|
||||
* eg. GAVOFYORK
|
||||
*
|
||||
* @method client
|
||||
* @returns {String} client identifier
|
||||
*/
|
||||
ICAP.prototype.client = function () {
|
||||
return this.isIndirect() ? this._iban.substr(11) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get client direct address
|
||||
*
|
||||
* @method address
|
||||
* @returns {String} client direct address
|
||||
*/
|
||||
ICAP.prototype.address = function () {
|
||||
return this.isDirect() ? this._iban.substr(4) : '';
|
||||
};
|
||||
|
||||
module.exports = ICAP;
|
||||
|
46
lib/web3/namereg.js
Normal file
46
lib/web3/namereg.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file namereg.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var contract = require('./contract');
|
||||
|
||||
var address = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
|
||||
|
||||
var abi = [
|
||||
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},
|
||||
{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"type":"function"},
|
||||
{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"type":"function"},
|
||||
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},
|
||||
{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"}],"name":"PrimaryChanged","type":"event"}
|
||||
];
|
||||
|
||||
module.exports = contract(abi).at(address);
|
||||
|
94
lib/web3/transfer.js
Normal file
94
lib/web3/transfer.js
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file transfer.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var web3 = require('../web3');
|
||||
var ICAP = require('./icap');
|
||||
var namereg = require('./namereg');
|
||||
var contract = require('./contract');
|
||||
|
||||
/**
|
||||
* Should be used to make ICAP transfer
|
||||
*
|
||||
* @method transfer
|
||||
* @param {String} iban number
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var transfer = function (from, iban, value, callback) {
|
||||
var icap = new ICAP(iban);
|
||||
if (!icap.isValid()) {
|
||||
throw new Error('invalid iban address');
|
||||
}
|
||||
|
||||
if (icap.isDirect()) {
|
||||
return transferToAddress(from, icap.address(), value, callback);
|
||||
}
|
||||
|
||||
if (!callback) {
|
||||
var address = namereg.addr(icap.institution());
|
||||
return deposit(from, address, value, icap.client());
|
||||
}
|
||||
|
||||
namereg.addr(icap.insitution(), function (err, address) {
|
||||
return deposit(from, address, value, icap.client(), callback);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to transfer funds to certain address
|
||||
*
|
||||
* @method transferToAddress
|
||||
* @param {String} address
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var transferToAddress = function (from, address, value, callback) {
|
||||
return web3.eth.sendTransaction({
|
||||
address: address,
|
||||
from: from,
|
||||
value: value
|
||||
}, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
|
||||
*
|
||||
* @method deposit
|
||||
* @param {String} address
|
||||
* @param {String} from (address)
|
||||
* @param {Value} value to be tranfered
|
||||
* @param {String} client unique identifier
|
||||
* @param {Function} callback, callback
|
||||
*/
|
||||
var deposit = function (from, address, value, client, callback) {
|
||||
var abi = [{"constant":false,"inputs":[{"name":"name","type":"bytes32"}],"name":"deposit","outputs":[],"type":"function"}];
|
||||
return contract(abi).at(address).deposit(client, {
|
||||
from: from,
|
||||
value: value
|
||||
}, callback);
|
||||
};
|
||||
|
||||
module.exports = transfer;
|
||||
|
32
test/utils.isIBAN.js
Normal file
32
test/utils.isIBAN.js
Normal file
@ -0,0 +1,32 @@
|
||||
var chai = require('chai');
|
||||
var utils = require('../lib/utils/utils.js');
|
||||
var assert = chai.assert;
|
||||
|
||||
var tests = [
|
||||
{ obj: function () {}, is: false},
|
||||
{ obj: new Function(), is: false},
|
||||
{ obj: 'function', is: false},
|
||||
{ obj: {}, is: false},
|
||||
{ obj: '[]', is: false},
|
||||
{ obj: '[1, 2]', is: false},
|
||||
{ obj: '{}', is: false},
|
||||
{ obj: '{"a": 123, "b" :3,}', is: false},
|
||||
{ obj: '{"c" : 2}', is: false},
|
||||
{ obj: 'XE81ETHXREGGAVOFYORK', is: true},
|
||||
{ obj: 'XE81ETCXREGGAVOFYORK', is: false},
|
||||
{ obj: 'XE81ETHXREGGAVOFYORKD', is: false},
|
||||
{ obj: 'XE81ETHXREGGaVOFYORK', is: false},
|
||||
{ obj: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', is: true},
|
||||
{ obj: 'XD7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', is: false}
|
||||
];
|
||||
|
||||
describe('lib/utils/utils', function () {
|
||||
describe('isIBAN', function () {
|
||||
tests.forEach(function (test) {
|
||||
it('shoud test if value ' + test.obj + ' is iban: ' + test.is, function () {
|
||||
assert.equal(utils.isIBAN(test.obj), test.is);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
49
test/web3.eth.sendIBANTransaction.js
Normal file
49
test/web3.eth.sendIBANTransaction.js
Normal file
@ -0,0 +1,49 @@
|
||||
var chai = require('chai');
|
||||
var assert = chai.assert;
|
||||
var web3 = require('../index');
|
||||
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
||||
var FakeHttpProvider2 = require('./helpers/FakeHttpProvider2');
|
||||
|
||||
describe('web3.eth.sendIBANTransaction', function () {
|
||||
it('should send transaction', function () {
|
||||
|
||||
var iban = 'XE81ETHXREGGAVOFYORK';
|
||||
var address = '0x1234567890123456789012345678901234500000';
|
||||
var exAddress = '0x1234567890123456789012345678901234567890'
|
||||
|
||||
var provider = new FakeHttpProvider2();
|
||||
web3.setProvider(provider);
|
||||
web3.reset();
|
||||
|
||||
provider.injectResultList([{
|
||||
result: exAddress
|
||||
}, {
|
||||
result: ''
|
||||
}]);
|
||||
|
||||
var step = 0;
|
||||
provider.injectValidation(function (payload) {
|
||||
if (step === 0) {
|
||||
step++;
|
||||
assert.equal(payload.method, 'eth_call');
|
||||
assert.deepEqual(payload.params, [{
|
||||
data: '0x3b3b57de5852454700000000000000000000000000000000000000000000000000000000',
|
||||
to: web3.eth.namereg.address
|
||||
}, "latest"]);
|
||||
|
||||
return;
|
||||
}
|
||||
assert.equal(payload.method, 'eth_sendTransaction');
|
||||
assert.deepEqual(payload.params, [{
|
||||
data: '0xb214faa54741564f46594f524b0000000000000000000000000000000000000000000000',
|
||||
from: address,
|
||||
to: exAddress,
|
||||
value: payload.params[0].value // don't check this
|
||||
}]);
|
||||
});
|
||||
|
||||
web3.eth.sendIBANTransaction(address, iban, 10000);
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user