This commit is contained in:
Jaco Greeff
2019-03-29 22:11:48 +01:00
parent 69ddf7746a
commit 6b8ecb26f2
14 changed files with 86 additions and 76 deletions
+8 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "0.53.1",
"version": "0.75.0",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
@@ -30,12 +30,12 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.4.0",
"@polkadot/api-derive": "^0.53.1",
"@polkadot/extrinsics": "^0.53.1",
"@polkadot/rpc-provider": "^0.53.1",
"@polkadot/rpc-rx": "^0.53.1",
"@polkadot/storage": "^0.53.1",
"@polkadot/types": "^0.53.1",
"@polkadot/util-crypto": "^0.43.1"
"@polkadot/api-derive": "^0.75.0",
"@polkadot/extrinsics": "^0.75.0",
"@polkadot/rpc-provider": "^0.75.0",
"@polkadot/rpc-rx": "^0.75.0",
"@polkadot/storage": "^0.75.0",
"@polkadot/types": "^0.75.0",
"@polkadot/util-crypto": "^0.75.1"
}
}
+15 -8
View File
@@ -33,7 +33,7 @@ describe.skip('e2e transactions', () => {
const nonce = await api.query.system.accountNonce(keyring.dave.address());
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.sign(keyring.dave, { nonce })
.send(({ events, status }) => {
console.log('Transaction status:', status.type);
@@ -57,7 +57,7 @@ describe.skip('e2e transactions', () => {
const nonce = await api.query.system.accountNonce(keyring.dave.address());
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.sign(keyring.dave, nonce)
.send(({ events, status }) => {
console.log('Transaction status:', status.type);
@@ -79,7 +79,7 @@ describe.skip('e2e transactions', () => {
it('makes a transfer (signAndSend)', async (done) => {
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.signAndSend(keyring.dave, ({ events, status }) => {
console.log('Transaction status:', status.type);
@@ -100,9 +100,11 @@ describe.skip('e2e transactions', () => {
it('makes a transfer (signAndSend via Signer)', async (done) => {
const signer = new SingleAccountSigner(keyring.dave);
api.setSigner(signer);
return api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.signAndSend(keyring.dave.address(), ({ events, status }) => {
console.log('Transaction status:', status.type);
@@ -124,25 +126,30 @@ describe.skip('e2e transactions', () => {
it('makes a transfer (signAndSend via Signer) - sad path', async () => {
//no signer
api.setSigner();
await expect(api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.signAndSend(keyring.alice.address())).rejects.toThrow('no signer exists');
const signer = new SingleAccountSigner(keyring.dave);
api.setSigner(signer);
//no callback
await expect(api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.signAndSend(keyring.alice.address())).rejects.toThrow('does not have the keyringPair');
//with callback
await expect(api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.signAndSend(keyring.alice.address(), ({ events, status }) => {
})).rejects.toThrow('does not have the keyringPair');
});
it('makes a transfer (no callback)', async () => {
const hash = await api.tx.balances
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
.transfer(keyring.eve.address(), 12345)
.signAndSend(keyring.dave);
expect(hash.toHex()).toHaveLength(66);