Added more classes to browser
This commit is contained in:
parent
c693d01a44
commit
47fb987600
22
RpcClient.js
22
RpcClient.js
@ -123,17 +123,19 @@ function ClassSpec(b) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for(var k in apiCalls) {
|
for(var k in apiCalls) {
|
||||||
var spec = apiCalls[k].split(' ');
|
if (apiCalls.hasOwnProperty(k)) {
|
||||||
for (var i = 0; i < spec.length; i++) {
|
var spec = apiCalls[k].split(' ');
|
||||||
if(types[spec[i]]) {
|
for (var i = 0; i < spec.length; i++) {
|
||||||
spec[i] = types[spec[i]];
|
if(types[spec[i]]) {
|
||||||
} else {
|
spec[i] = types[spec[i]];
|
||||||
spec[i] = types.string;
|
} else {
|
||||||
|
spec[i] = types.string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
var methodName = k.toLowerCase();
|
||||||
var methodName = k.toLowerCase();
|
constructor.prototype[k] = createRPCMethod(methodName, spec);
|
||||||
constructor.prototype[k] = createRPCMethod(methodName, spec);
|
constructor.prototype[methodName] = constructor.prototype[k];
|
||||||
constructor.prototype[methodName] = constructor.prototype[k];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,8 @@ function ClassSpec(b) {
|
|||||||
var Address = require('./Address').class();
|
var Address = require('./Address').class();
|
||||||
|
|
||||||
function WalletKey(cfg) {
|
function WalletKey(cfg) {
|
||||||
|
if (!cfg) cfg = {};
|
||||||
|
if (!cfg.network) throw new Error('network parameter is required');
|
||||||
this.network = cfg.network; // required
|
this.network = cfg.network; // required
|
||||||
this.created = cfg.created;
|
this.created = cfg.created;
|
||||||
this.privKey = cfg.privKey;
|
this.privKey = cfg.privKey;
|
||||||
|
|||||||
@ -17,13 +17,20 @@ module.exports.VersionedData = require('./util/VersionedData');
|
|||||||
module.exports.Address = require('./Address');
|
module.exports.Address = require('./Address');
|
||||||
module.exports.Opcode = require('./Opcode');
|
module.exports.Opcode = require('./Opcode');
|
||||||
module.exports.Script = require('./Script');
|
module.exports.Script = require('./Script');
|
||||||
module.exports.SINKey = require('./SINKey');
|
|
||||||
module.exports.Transaction = require('./Transaction');
|
module.exports.Transaction = require('./Transaction');
|
||||||
module.exports.Peer = require('./Peer');
|
module.exports.Peer = require('./Peer');
|
||||||
|
module.exports.PeerManager = require('./PeerManager');
|
||||||
module.exports.Block = require('./Block');
|
module.exports.Block = require('./Block');
|
||||||
module.exports.Connection = require('./Connection');
|
module.exports.Connection = require('./Connection');
|
||||||
module.exports.ScriptInterpreter = require('./ScriptInterpreter');
|
module.exports.ScriptInterpreter = require('./ScriptInterpreter');
|
||||||
module.exports.Bloom = require('./Bloom');
|
module.exports.Bloom = require('./Bloom');
|
||||||
|
module.exports.Key = require('./Key').Key;
|
||||||
|
module.exports.SINKey = require('./SINKey');
|
||||||
|
module.exports.SIN = require('./SIN');
|
||||||
|
module.exports.PrivateKey = require('./PrivateKey');
|
||||||
|
module.exports.RpcClient = require('./RpcClient');
|
||||||
|
module.exports.Wallet = require('./Wallet');
|
||||||
|
module.exports.WalletKey = require('./WalletKey');
|
||||||
|
|
||||||
|
|
||||||
if (typeof process.versions === 'undefined') {
|
if (typeof process.versions === 'undefined') {
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classtool": "=1.0.0",
|
"classtool": "git://github.com/bitpay/classtool.git",
|
||||||
"base58-native": "=0.1.3",
|
"base58-native": "=0.1.3",
|
||||||
"bindings": "=1.1.1",
|
"bindings": "=1.1.1",
|
||||||
"bufferput": "=0.1.1",
|
"bufferput": "=0.1.1",
|
||||||
|
|||||||
@ -16,8 +16,3 @@ if (typeof require === 'undefined') {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (typeof module === 'undefined') {
|
|
||||||
var that = this;
|
|
||||||
that.module = bitcore.module;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -15,20 +15,30 @@
|
|||||||
<script src="../browser/bundle.js"></script>
|
<script src="../browser/bundle.js"></script>
|
||||||
<script src="adapter.js"></script>
|
<script src="adapter.js"></script>
|
||||||
|
|
||||||
<script src="test.main.js"></script>
|
|
||||||
<script src="test.base58.js"></script>
|
|
||||||
<script src="test.EncodedData.js"></script>
|
|
||||||
<script src="test.VersionedData.js"></script>
|
|
||||||
<script src="test.Address.js"></script>
|
<script src="test.Address.js"></script>
|
||||||
<script src="test.Opcode.js"></script>
|
|
||||||
<script src="test.Script.js"></script>
|
|
||||||
<script src="test.Transaction.js"></script>
|
|
||||||
<script src="test.Peer.js"></script>
|
|
||||||
<script src="test.Block.js"></script>
|
<script src="test.Block.js"></script>
|
||||||
<script src="test.Connection.js"></script>
|
|
||||||
<script src="test.ScriptInterpreter.js"></script>
|
|
||||||
<script src="test.Bloom.js"></script>
|
<script src="test.Bloom.js"></script>
|
||||||
|
<script src="test.Connection.js"></script>
|
||||||
|
<script src="test.EncodedData.js"></script>
|
||||||
|
<script src="test.main.js"></script>
|
||||||
<script src="test.misc.js"></script>
|
<script src="test.misc.js"></script>
|
||||||
|
<script src="test.Opcode.js"></script>
|
||||||
|
<script src="test.Peer.js"></script>
|
||||||
|
<script src="test.PeerManager.js"></script>
|
||||||
|
<script src="test.PrivateKey.js"></script>
|
||||||
|
<script src="test.RpcClient.js"></script>
|
||||||
|
<script src="test.Script.js"></script>
|
||||||
|
<script src="test.ScriptInterpreter.js"></script>
|
||||||
|
<script src="test.SIN.js"></script>
|
||||||
|
<script src="test.Transaction.js"></script>
|
||||||
|
<script src="test.VersionedData.js"></script>
|
||||||
|
<script src="test.Wallet.js"></script>
|
||||||
|
<!--
|
||||||
|
<script src="test.WalletKey.js"></script>
|
||||||
|
<script src="test.basic.js"></script>
|
||||||
|
<script src="test.SINKey.js"></script>
|
||||||
|
<script src="test.Key.js"></script>
|
||||||
|
-->
|
||||||
<script>
|
<script>
|
||||||
mocha.run();
|
mocha.run();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
23
test/test.Key.js
Normal file
23
test/test.Key.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var Key = bitcore.Key;
|
||||||
|
|
||||||
|
describe.skip('Key', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(Key);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var k = new Key();
|
||||||
|
should.exist(k);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
37
test/test.PeerManager.js
Normal file
37
test/test.PeerManager.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var PeerManagerModule = bitcore.PeerManager;
|
||||||
|
var PeerManager;
|
||||||
|
|
||||||
|
describe('PeerManager', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(PeerManagerModule);
|
||||||
|
});
|
||||||
|
it('should be able to create class', function() {
|
||||||
|
PeerManager = PeerManagerModule.class();
|
||||||
|
should.exist(PeerManager);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var pm = new PeerManager();
|
||||||
|
should.exist(pm);
|
||||||
|
});
|
||||||
|
it('should be able to start instance', function() {
|
||||||
|
var pm = new PeerManager();
|
||||||
|
pm.start.bind(pm).should.not.throw();
|
||||||
|
});
|
||||||
|
it('should be able to stop instance', function() {
|
||||||
|
var pm = new PeerManager();
|
||||||
|
pm.start();
|
||||||
|
pm.stop.bind(pm).should.not.throw();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
28
test/test.PrivateKey.js
Normal file
28
test/test.PrivateKey.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var PrivateKeyModule = bitcore.PrivateKey;
|
||||||
|
var PrivateKey;
|
||||||
|
|
||||||
|
describe('PrivateKey', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(PrivateKeyModule);
|
||||||
|
});
|
||||||
|
it('should be able to create class', function() {
|
||||||
|
PrivateKey = PrivateKeyModule.class();
|
||||||
|
should.exist(PrivateKey);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var pk = new PrivateKey();
|
||||||
|
should.exist(pk);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
28
test/test.RpcClient.js
Normal file
28
test/test.RpcClient.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var RpcClientModule = bitcore.RpcClient;
|
||||||
|
var RpcClient;
|
||||||
|
RpcClient = RpcClientModule.class();
|
||||||
|
|
||||||
|
describe('RpcClient', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(RpcClientModule);
|
||||||
|
});
|
||||||
|
it('should be able to create class', function() {
|
||||||
|
should.exist(RpcClient);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var s = new RpcClient();
|
||||||
|
should.exist(s);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,30 +1,28 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var chai = require('chai');
|
var chai = require('chai');
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
var should = chai.should();
|
var should = chai.should();
|
||||||
|
|
||||||
var SINKeyModule = bitcore.SINKey;
|
var SINModule = bitcore.SIN;
|
||||||
var SINKey;
|
var SIN;
|
||||||
|
|
||||||
|
describe('SIN', function() {
|
||||||
describe('SINKey', function() {
|
|
||||||
it('should initialze the main object', function() {
|
it('should initialze the main object', function() {
|
||||||
should.exist(SINKeyModule);
|
should.exist(SINModule);
|
||||||
});
|
});
|
||||||
it('should be able to create class', function() {
|
it('should be able to create class', function() {
|
||||||
SINKey = SINKeyModule.class();
|
SIN = SINModule.class();
|
||||||
should.exist(SINKey);
|
should.exist(SIN);
|
||||||
});
|
});
|
||||||
it('should be able to create instance', function() {
|
it('should be able to create instance', function() {
|
||||||
var sk = new SINKey();
|
var s = new SIN();
|
||||||
sk.generate();
|
should.exist(s);
|
||||||
should.exist(sk.created);
|
|
||||||
should.exist(sk.privKey.private);
|
|
||||||
should.exist(sk.privKey.public);
|
|
||||||
should.exist(sk.privKey.compressed);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
30
test/test.SINKey.js
Normal file
30
test/test.SINKey.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var SINKeyModule = bitcore.SINKey;
|
||||||
|
var SINKey;
|
||||||
|
|
||||||
|
|
||||||
|
describe('SINKey', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(SINKeyModule);
|
||||||
|
});
|
||||||
|
it('should be able to create class', function() {
|
||||||
|
SINKey = SINKeyModule.class();
|
||||||
|
should.exist(SINKey);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var sk = new SINKey();
|
||||||
|
sk.generate();
|
||||||
|
should.exist(sk.created);
|
||||||
|
should.exist(sk.privKey.private);
|
||||||
|
should.exist(sk.privKey.public);
|
||||||
|
should.exist(sk.privKey.compressed);
|
||||||
|
});
|
||||||
|
});
|
||||||
28
test/test.Wallet.js
Normal file
28
test/test.Wallet.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var WalletModule = bitcore.Wallet;
|
||||||
|
var Wallet;
|
||||||
|
|
||||||
|
describe('Wallet', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(WalletModule);
|
||||||
|
});
|
||||||
|
it('should be able to create class', function() {
|
||||||
|
Wallet = WalletModule.class();
|
||||||
|
should.exist(Wallet);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var s = new Wallet();
|
||||||
|
should.exist(s);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
31
test/test.WalletKey.js
Normal file
31
test/test.WalletKey.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var chai = require('chai');
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
|
||||||
|
var should = chai.should();
|
||||||
|
|
||||||
|
var WalletKeyModule = bitcore.WalletKey;
|
||||||
|
var networks = bitcore.networks;
|
||||||
|
var WalletKey;
|
||||||
|
|
||||||
|
describe('WalletKey', function() {
|
||||||
|
it('should initialze the main object', function() {
|
||||||
|
should.exist(WalletKeyModule);
|
||||||
|
});
|
||||||
|
it('should be able to create class', function() {
|
||||||
|
WalletKey = WalletKeyModule.class();
|
||||||
|
should.exist(WalletKey);
|
||||||
|
});
|
||||||
|
it('should be able to create instance', function() {
|
||||||
|
var s = new WalletKey({
|
||||||
|
network: networks.livenet
|
||||||
|
});
|
||||||
|
should.exist(s);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user