Adapt to new @polkadot/keyring KeyPair interface (#994)
* Adapt to new @polkadot/keyring KeyPair interface * Pull in common 0.93.0-beta.4
This commit is contained in:
@@ -34,6 +34,6 @@
|
||||
"memoizee": "^0.4.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.93.0-beta.3"
|
||||
"@polkadot/keyring": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
"@polkadot/rpc-rx": "^0.81.0-beta.11",
|
||||
"@polkadot/storage": "^0.81.0-beta.11",
|
||||
"@polkadot/types": "^0.81.0-beta.11",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.3"
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.93.0-beta.3"
|
||||
"@polkadot/keyring": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ export default function createSubmittableExtrinsic<CodecResult, SubscriptionResu
|
||||
|
||||
const isSubscription = _noStatusCb || !!statusCb;
|
||||
const isKeyringPair = isFunction((account as IKeyringPair).address) && isFunction((account as IKeyringPair).sign);
|
||||
const address = isKeyringPair ? (account as IKeyringPair).address() : account.toString();
|
||||
const address = isKeyringPair ? (account as IKeyringPair).address : account.toString();
|
||||
let updateId: number | undefined;
|
||||
|
||||
return onCall(
|
||||
|
||||
@@ -31,7 +31,7 @@ export default async function test () {
|
||||
console.log('current author:', header.author);
|
||||
});
|
||||
|
||||
const transfer = api.tx.balances.transfer(keyring.bob.address(), 12345);
|
||||
const transfer = api.tx.balances.transfer(keyring.bob.address, 12345);
|
||||
|
||||
console.log('transfer as Method', transfer as IMethod);
|
||||
console.log('transfer as Extrinsic', transfer as IExtrinsic);
|
||||
@@ -40,7 +40,7 @@ export default async function test () {
|
||||
console.log('hash:', hash.toHex());
|
||||
|
||||
const unsub = await api.tx.balances
|
||||
.transfer(keyring.bob.address(), 12345)
|
||||
.transfer(keyring.bob.address, 12345)
|
||||
.signAndSend(keyring.alice, ({ status }: SubmittableResult) => {
|
||||
console.log('transfer status:', status.type);
|
||||
|
||||
|
||||
@@ -82,11 +82,11 @@ import Combinator, { CombinatorCallback, CombinatorFunction } from './Combinator
|
||||
* import ApiPromise from '@polkadot/api/promise';
|
||||
*
|
||||
* ApiPromise.create().then((api) => {
|
||||
* const nonce = await api.query.system.accountNonce(keyring.alice.address());
|
||||
* const nonce = await api.query.system.accountNonce(keyring.alice.address);
|
||||
*
|
||||
* api.tx.balances
|
||||
* // create transfer
|
||||
* transfer(keyring.bob.address(), 12345)
|
||||
* transfer(keyring.bob.address, 12345)
|
||||
* // sign the transcation
|
||||
* .sign(keyring.alice, { nonce })
|
||||
* // send the transaction (optional status callback)
|
||||
|
||||
@@ -89,14 +89,14 @@ import ApiBase from '../Base';
|
||||
*
|
||||
* // retrieve nonce for the account
|
||||
* api.query.system
|
||||
* .accountNonce(keyring.alice.address())
|
||||
* .accountNonce(keyring.alice.address)
|
||||
* .pipe(
|
||||
* first(),
|
||||
* // pipe nonce into transfer
|
||||
* switchMap((nonce) =>
|
||||
* api.tx.balances
|
||||
* // create transfer
|
||||
* .transfer(keyring.bob.address(), 12345)
|
||||
* .transfer(keyring.bob.address, 12345)
|
||||
* // sign the transcation
|
||||
* .sign(keyring.alice, { nonce })
|
||||
* // send the transaction
|
||||
|
||||
@@ -42,7 +42,7 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it('queries state for a balance', async () => {
|
||||
return (
|
||||
api.query.balances.freeBalance(keyring.alice.address(), (balance) => {
|
||||
api.query.balances.freeBalance(keyring.alice.address, (balance) => {
|
||||
expect(balance).toBeInstanceOf(BN);
|
||||
expect(balance.isZero()).toBe(false);
|
||||
})
|
||||
@@ -81,7 +81,7 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it('subscribes to queries', (done) => {
|
||||
return (
|
||||
api.query.system.accountNonce(keyring.ferdie.address(), (nonce) => {
|
||||
api.query.system.accountNonce(keyring.ferdie.address, (nonce) => {
|
||||
expect(nonce instanceof BN).toBe(true);
|
||||
|
||||
done();
|
||||
@@ -91,7 +91,7 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it.skip('subscribes to queries (default)', (done) => {
|
||||
return (
|
||||
api.query.staking.validators(keyring.ferdie.address(), (prefs) => {
|
||||
api.query.staking.validators(keyring.ferdie.address, (prefs) => {
|
||||
expect(prefs.unstakeThreshold.toNumber()).toBe(3);
|
||||
|
||||
done();
|
||||
@@ -112,10 +112,10 @@ describe.skip('Promise e2e queries', () => {
|
||||
it('subscribes to multiple results (freeBalance.multi)', (done) => {
|
||||
return (
|
||||
api.query.balances.freeBalance.multi([
|
||||
keyring.alice.address(),
|
||||
keyring.bob.address(),
|
||||
keyring.alice.address,
|
||||
keyring.bob.address,
|
||||
'5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y',
|
||||
keyring.ferdie.address()
|
||||
keyring.ferdie.address
|
||||
], (balances) => {
|
||||
expect(balances).toHaveLength(4);
|
||||
|
||||
@@ -126,10 +126,10 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it('subscribes to multiple results (api.queryMulti)', (done) => {
|
||||
return api.queryMulti([
|
||||
[api.query.balances.freeBalance, keyring.alice.address()],
|
||||
[api.query.balances.freeBalance, keyring.bob.address()],
|
||||
[api.query.balances.freeBalance, keyring.alice.address],
|
||||
[api.query.balances.freeBalance, keyring.bob.address],
|
||||
[api.query.balances.freeBalance, '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y'],
|
||||
[api.query.balances.freeBalance, keyring.ferdie.address()]
|
||||
[api.query.balances.freeBalance, keyring.ferdie.address]
|
||||
], (balances: Array<BN>) => {
|
||||
expect(balances).toHaveLength(4);
|
||||
|
||||
@@ -140,9 +140,9 @@ describe.skip('Promise e2e queries', () => {
|
||||
it('subscribes to derived balances (balances.all)', (done) => {
|
||||
return (
|
||||
api.derive.balances.all(
|
||||
keyring.alice.address(),
|
||||
keyring.alice.address,
|
||||
(all) => {
|
||||
expect(all.accountId.toString()).toEqual(keyring.alice.address());
|
||||
expect(all.accountId.toString()).toEqual(keyring.alice.address);
|
||||
|
||||
expect(all.freeBalance).toBeDefined();
|
||||
expect(all.freeBalance.gt(ZERO)).toBe(true);
|
||||
@@ -229,16 +229,16 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
describe('with map type', () => {
|
||||
it('queries correct value', async () => {
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address()) as Balance;
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address) as Balance;
|
||||
|
||||
expect(balance.isZero()).toBe(false);
|
||||
});
|
||||
|
||||
it('queries correct value at a specified block', async () => {
|
||||
// assume the account Alice is only used in test(the balance of Alice does not change in this test case)
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address());
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address);
|
||||
const header = await api.rpc.chain.getHeader() as Header;
|
||||
const balanceAt = await api.query.balances.freeBalance.at(header.hash, keyring.alice.address()) as Balance;
|
||||
const balanceAt = await api.query.balances.freeBalance.at(header.hash, keyring.alice.address) as Balance;
|
||||
|
||||
expect(balanceAt.isZero()).toBe(false);
|
||||
expect(balanceAt.toString()).toEqual(balance.toString());
|
||||
@@ -246,9 +246,9 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it('subscribes to query and get correct result', async (done) => {
|
||||
// assume the account Alice is only used in test(the balance of Alice does not change in this test case)
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address());
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address);
|
||||
|
||||
return api.query.balances.freeBalance(keyring.alice.address(), (balanceSubscribed) => {
|
||||
return api.query.balances.freeBalance(keyring.alice.address, (balanceSubscribed) => {
|
||||
expect(balanceSubscribed.isZero()).toBe(false);
|
||||
expect(balanceSubscribed.toString()).toEqual(balance.toString());
|
||||
done();
|
||||
@@ -256,18 +256,18 @@ describe.skip('Promise e2e queries', () => {
|
||||
});
|
||||
|
||||
it('queries correct hash', async () => {
|
||||
const hash = await api.query.balances.freeBalance.hash(keyring.alice.address());
|
||||
const hash = await api.query.balances.freeBalance.hash(keyring.alice.address);
|
||||
|
||||
expect(hash).toBeDefined();
|
||||
});
|
||||
|
||||
it('gets correct key', async () => {
|
||||
// assume the account Alice is only used in test(the balance of Alice does not change in this test case)
|
||||
const key = api.query.balances.freeBalance.key(keyring.alice.address());
|
||||
const key = api.query.balances.freeBalance.key(keyring.alice.address);
|
||||
const balanceData = await api.rpc.state.getStorage(key) as Option<any>;
|
||||
const balanceRPC = new Balance(balanceData.unwrapOr(undefined));
|
||||
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address());
|
||||
const balance = await api.query.balances.freeBalance(keyring.alice.address);
|
||||
|
||||
expect(balanceRPC.isZero()).toBe(false);
|
||||
expect(balanceRPC.toString()).toEqual(balance.toString());
|
||||
@@ -275,12 +275,12 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it('queries multiple results', async () => {
|
||||
// assume the account Alice and Bob are only used in test(the balance of them do not change in this test case)
|
||||
const balanceAlice = await api.query.balances.freeBalance(keyring.alice.address());
|
||||
const balanceBob = await api.query.balances.freeBalance(keyring.bob.address());
|
||||
const balanceAlice = await api.query.balances.freeBalance(keyring.alice.address);
|
||||
const balanceBob = await api.query.balances.freeBalance(keyring.bob.address);
|
||||
|
||||
const balances = await api.query.balances.freeBalance.multi([
|
||||
keyring.alice.address(),
|
||||
keyring.bob.address()
|
||||
keyring.alice.address,
|
||||
keyring.bob.address
|
||||
]);
|
||||
|
||||
expect(balances).toHaveLength(2);
|
||||
@@ -290,12 +290,12 @@ describe.skip('Promise e2e queries', () => {
|
||||
|
||||
it('subscribes to multiple queries and get correct results', async (done) => {
|
||||
// assume the account Alice and Bob are only used in test(the balance of them do not change in this test case)
|
||||
const balanceAlice = await api.query.balances.freeBalance(keyring.alice.address());
|
||||
const balanceBob = await api.query.balances.freeBalance(keyring.bob.address());
|
||||
const balanceAlice = await api.query.balances.freeBalance(keyring.alice.address);
|
||||
const balanceBob = await api.query.balances.freeBalance(keyring.bob.address);
|
||||
|
||||
return api.query.balances.freeBalance.multi([
|
||||
keyring.alice.address(),
|
||||
keyring.bob.address()
|
||||
keyring.alice.address,
|
||||
keyring.bob.address
|
||||
], (balances) => {
|
||||
expect(balances).toHaveLength(2);
|
||||
expect(balances[0].toString()).toEqual(balanceAlice.toString());
|
||||
@@ -305,7 +305,7 @@ describe.skip('Promise e2e queries', () => {
|
||||
});
|
||||
|
||||
it('queries correct size', async () => {
|
||||
const size = await api.query.balances.freeBalance.size(keyring.alice.address());
|
||||
const size = await api.query.balances.freeBalance.size(keyring.alice.address);
|
||||
|
||||
expect(size.toNumber()).not.toEqual(0);
|
||||
});
|
||||
|
||||
@@ -52,9 +52,9 @@ describe.skip('Promise e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('can submit an extrinsic from hex', async (done) => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address()) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address) as Index;
|
||||
const hex = api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.sign(keyring.dave, { nonce })
|
||||
.toHex();
|
||||
|
||||
@@ -62,26 +62,26 @@ describe.skip('Promise e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('makes a transfer (sign, then send)', async (done) => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address()) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address) as Index;
|
||||
|
||||
return api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.sign(keyring.dave, { nonce })
|
||||
.send(logEvents(done));
|
||||
});
|
||||
|
||||
it('makes a transfer (sign, then send - compat version)', async (done) => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address()) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address) as Index;
|
||||
|
||||
return api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.sign(keyring.dave, { nonce })
|
||||
.send(logEvents(done));
|
||||
});
|
||||
|
||||
it('makes a transfer (signAndSend)', async (done) => {
|
||||
return api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAndSend(keyring.dave, logEvents(done));
|
||||
});
|
||||
|
||||
@@ -91,8 +91,8 @@ describe.skip('Promise e2e transactions', () => {
|
||||
api.setSigner(signer);
|
||||
|
||||
return api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.signAndSend(keyring.dave.address(), logEvents(done));
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAndSend(keyring.dave.address, logEvents(done));
|
||||
});
|
||||
|
||||
it('makes a transfer (signAndSend via Signer) with undefined Signer', async () => {
|
||||
@@ -101,8 +101,8 @@ describe.skip('Promise e2e transactions', () => {
|
||||
api.setSigner(signer);
|
||||
|
||||
await expect(api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.signAndSend(keyring.alice.address())).rejects.toThrow('no signer exists');
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAndSend(keyring.alice.address)).rejects.toThrow('no signer exists');
|
||||
});
|
||||
|
||||
it('makes a transfer (signAndSend via Signer) with the wrong keyring pair', async () => {
|
||||
@@ -112,20 +112,20 @@ describe.skip('Promise e2e transactions', () => {
|
||||
|
||||
// no callback
|
||||
await expect(api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.signAndSend(keyring.alice.address())).rejects.toThrow('does not have the keyringPair');
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAndSend(keyring.alice.address)).rejects.toThrow('does not have the keyringPair');
|
||||
});
|
||||
|
||||
it('makes a transfer (signAndSend via Signer) with the wrong keyring pair with a callback', async () => {
|
||||
// with callback
|
||||
await expect(api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.signAndSend(keyring.alice.address(), (cb: any) => { /*do nothing */ })).rejects.toThrow('does not have the keyringPair');
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAndSend(keyring.alice.address, (cb: any) => { /*do nothing */ })).rejects.toThrow('does not have the keyringPair');
|
||||
});
|
||||
|
||||
it('makes a transfer (no callback)', async () => {
|
||||
const hash = await api.tx.balances
|
||||
.transfer(keyring.eve.address(), 12345)
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAndSend(keyring.dave);
|
||||
|
||||
expect(hash.toHex()).toHaveLength(66);
|
||||
@@ -146,13 +146,13 @@ describe.skip('Promise e2e transactions', () => {
|
||||
|
||||
function doOne (cb: any) {
|
||||
return api.tx.balances
|
||||
.transfer(pair.address(), 123456)
|
||||
.transfer(pair.address, 123456)
|
||||
.signAndSend(keyring.dave, logEvents(cb));
|
||||
}
|
||||
|
||||
function doTwo (cb: any) {
|
||||
return api.tx.balances
|
||||
.transfer(keyring.alice.address(), 12345)
|
||||
.transfer(keyring.alice.address, 12345)
|
||||
.signAndSend(pair, logEvents(cb));
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ describe.skip('Promise e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('makes a transfer with ERA (signAndSend)', async (done) => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address()) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.dave.address) as Index;
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
const currentHeight = (signedBlock as SignedBlock).block.header.number;
|
||||
const exERA = new ExtrinsicEra({ current: currentHeight, period: 10 });
|
||||
@@ -171,7 +171,7 @@ describe.skip('Promise e2e transactions', () => {
|
||||
const eraDeath = exERA.asMortalEra.death(currentHeight.toNumber());
|
||||
console.log('STARTED AT :' + eraBirth + ' EXPIRED AT :' + eraDeath);
|
||||
const eraHash = await api.rpc.chain.getBlockHash(eraBirth);
|
||||
const ex = api.tx.balances.transfer(keyring.eve.address(), 12345);
|
||||
const ex = api.tx.balances.transfer(keyring.eve.address, 12345);
|
||||
const hash = await ex.signAndSend(keyring.dave, { blockHash: eraHash, era: exERA, nonce } as any);
|
||||
|
||||
expect(hash.toHex()).toHaveLength(66);
|
||||
@@ -179,7 +179,7 @@ describe.skip('Promise e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('makes a transfer with ERA (signAndSend) with invalid time', async (done) => {
|
||||
const nonce = await api.query.system.accountNonce(keyring.alice.address()) as Index;
|
||||
const nonce = await api.query.system.accountNonce(keyring.alice.address) as Index;
|
||||
const signedBlock = await api.rpc.chain.getBlock();
|
||||
const currentHeight = (signedBlock as SignedBlock).block.header.number;
|
||||
const exERA = new ExtrinsicEra({ current: currentHeight, period: 4 });
|
||||
@@ -187,7 +187,7 @@ describe.skip('Promise e2e transactions', () => {
|
||||
const eraDeath = exERA.asMortalEra.death(currentHeight.toNumber());
|
||||
console.log('STARTED AT :' + eraBirth + ' EXPIRED AT :' + eraDeath);
|
||||
const eraHash = await api.rpc.chain.getBlockHash(eraBirth);
|
||||
const ex = api.tx.balances.transfer(keyring.eve.address(), 12345);
|
||||
const ex = api.tx.balances.transfer(keyring.eve.address, 12345);
|
||||
|
||||
return (
|
||||
api.rpc.chain.subscribeNewHead(async (header) => {
|
||||
|
||||
@@ -32,7 +32,7 @@ describe.skip('Rx e2e queries', () => {
|
||||
});
|
||||
|
||||
it('queries state for a balance', (done) => {
|
||||
api.query.balances.freeBalance(keyring.alice.address()).subscribe((balance) => {
|
||||
api.query.balances.freeBalance(keyring.alice.address).subscribe((balance) => {
|
||||
expect(balance).toBeInstanceOf(BN);
|
||||
expect((balance as Balance).isZero()).toBe(false);
|
||||
done();
|
||||
|
||||
@@ -26,12 +26,12 @@ describe.skip('Rx e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('makes a transfer', (done) => {
|
||||
(api.query.system.accountNonce(keyring.alice.address()) as Observable<Index>)
|
||||
(api.query.system.accountNonce(keyring.alice.address) as Observable<Index>)
|
||||
.pipe(
|
||||
first(),
|
||||
switchMap((nonce: Index) =>
|
||||
api.tx.balances
|
||||
.transfer(keyring.bob.address(), 12345)
|
||||
.transfer(keyring.bob.address, 12345)
|
||||
.sign(keyring.alice, { nonce })
|
||||
.send()
|
||||
)
|
||||
@@ -44,7 +44,7 @@ describe.skip('Rx e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('makes a proposal', (done) => {
|
||||
(api.query.system.accountNonce(keyring.alice.address()) as Observable<Index>)
|
||||
(api.query.system.accountNonce(keyring.alice.address) as Observable<Index>)
|
||||
.pipe(
|
||||
first(),
|
||||
switchMap((nonce: Index) =>
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class SingleAccountSigner {
|
||||
}
|
||||
|
||||
async sign (extrinsic: Extrinsic, address: string, options: SignatureOptions) {
|
||||
if (!this.keyringPair || String(address) !== this.keyringPair.address()) {
|
||||
if (!this.keyringPair || String(address) !== this.keyringPair.address) {
|
||||
throw new Error('does not have the keyringPair');
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@
|
||||
"@polkadot/jsonrpc": "^0.81.0-beta.11",
|
||||
"@polkadot/rpc-provider": "^0.81.0-beta.11",
|
||||
"@polkadot/types": "^0.81.0-beta.11",
|
||||
"@polkadot/util": "^0.93.0-beta.3"
|
||||
"@polkadot/util": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,15 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.5",
|
||||
"@polkadot/storage": "^0.81.0-beta.11",
|
||||
"@polkadot/util": "^0.93.0-beta.3",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.3",
|
||||
"@polkadot/util": "^0.93.0-beta.4",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.4",
|
||||
"@types/nock": "^10.0.3",
|
||||
"eventemitter3": "^3.1.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"websocket": "^1.0.28"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.93.0-beta.3",
|
||||
"@polkadot/keyring": "^0.93.0-beta.4",
|
||||
"mock-socket": "^8.0.5",
|
||||
"nock": "^10.0.4"
|
||||
}
|
||||
|
||||
@@ -151,8 +151,8 @@ export default class Mock implements ProviderInterface {
|
||||
|
||||
// increment the balances and nonce for each account
|
||||
keyring.getPairs().forEach(({ publicKey }, index) => {
|
||||
this.setStateBn(storage.balances.freeBalance(publicKey()), newHead.blockNumber.muln(3).iaddn(index));
|
||||
this.setStateBn(storage.system.accountNonce(publicKey()), newHead.blockNumber.addn(index));
|
||||
this.setStateBn(storage.balances.freeBalance(publicKey), newHead.blockNumber.muln(3).iaddn(index));
|
||||
this.setStateBn(storage.system.accountNonce(publicKey), newHead.blockNumber.addn(index));
|
||||
});
|
||||
|
||||
// set the timestamp for the current block
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
"rxjs": "^6.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.93.0-beta.3"
|
||||
"@polkadot/keyring": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ describe('createCachedObservable', () => {
|
||||
});
|
||||
|
||||
it('creates a single observable (multiple calls, different arguments that should be cached together)', () => {
|
||||
const observable1 = creator(keyring.alice.address());
|
||||
const observable2 = creator(new AccountId(keyring.alice.address()));
|
||||
const observable1 = creator(keyring.alice.address);
|
||||
const observable2 = creator(new AccountId(keyring.alice.address));
|
||||
|
||||
expect(
|
||||
observable2
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.5",
|
||||
"@polkadot/types": "^0.81.0-beta.11",
|
||||
"@polkadot/util": "^0.93.0-beta.3"
|
||||
"@polkadot/util": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('extrinsics', () => {
|
||||
it('encodes an actual transfer (actual data)', () => {
|
||||
expect(
|
||||
new Extrinsic(
|
||||
extrinsics.balances.transfer(keyring.bob.publicKey(), 6969)
|
||||
extrinsics.balances.transfer(keyring.bob.publicKey, 6969)
|
||||
).sign(keyring.alice, {
|
||||
blockHash: '0xec7afaf1cca720ce88c1d1b689d81f0583cc15a97d621cf046dd9abf605ef22f',
|
||||
nonce: 0
|
||||
|
||||
@@ -36,7 +36,7 @@ describe.skip('e2e transfer', () => {
|
||||
return api.chain
|
||||
.getBlockHash(0)
|
||||
.then((genesisHash) => {
|
||||
const extrinsic = extrinsics.balances.transfer(keyring.bob.publicKey(), 6969) as any;
|
||||
const extrinsic = extrinsics.balances.transfer(keyring.bob.publicKey, 6969) as any;
|
||||
extrinsic.sign(keyring.alice, { blockHash: genesisHash, nonce: 0 });
|
||||
|
||||
return api.author.submitExtrinsic(extrinsic.toU8a());
|
||||
@@ -47,7 +47,7 @@ describe.skip('e2e transfer', () => {
|
||||
return api.chain
|
||||
.getBlockHash(0)
|
||||
.then((genesisHash) => {
|
||||
const extrinsic = extrinsics.balances.transfer(keyring.bob.publicKey(), 6969) as any;
|
||||
const extrinsic = extrinsics.balances.transfer(keyring.bob.publicKey, 6969) as any;
|
||||
extrinsic.sign(keyring.alice, { blockHash: genesisHash, nonce: 0 });
|
||||
|
||||
return api.author.submitAndWatchExtrinsic(extrinsic, (result: SubmittableResult) => {
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.5",
|
||||
"@polkadot/types": "^0.81.0-beta.11",
|
||||
"@polkadot/util": "^0.93.0-beta.3",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.3"
|
||||
"@polkadot/util": "^0.93.0-beta.4",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.93.0-beta.3"
|
||||
"@polkadot/keyring": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('fromMetadata', () => {
|
||||
it('should return the correct length-prefixed storage key', () => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
storage.balances.freeBalance(keyring.alice.address())
|
||||
storage.balances.freeBalance(keyring.alice.address)
|
||||
)
|
||||
).toEqual(
|
||||
'0x807f864e18e3dd8b58386310d2fe0919eef27c6e558564b7f67f22d99d20f587bb'
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.5",
|
||||
"@polkadot/util": "^0.93.0-beta.3",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.3"
|
||||
"@polkadot/util": "^0.93.0-beta.4",
|
||||
"@polkadot/util-crypto": "^0.93.0-beta.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.93.0-beta.3"
|
||||
"@polkadot/keyring": "^0.93.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ export default class ExtrinsicSignature extends Struct implements IExtrinsicSign
|
||||
* @description Generate a payload and pplies the signature from a keypair
|
||||
*/
|
||||
sign (method: Method, account: IKeyringPair, { blockHash, era, nonce, version }: SignatureOptions): ExtrinsicSignature {
|
||||
const signer = new Address(account.publicKey());
|
||||
const signer = new Address(account.publicKey);
|
||||
const signingPayload = new SignaturePayload({
|
||||
nonce,
|
||||
method,
|
||||
|
||||
@@ -10,8 +10,8 @@ import Method from './primitive/Method';
|
||||
import Address from './primitive/Address';
|
||||
|
||||
export type IKeyringPair = {
|
||||
address: () => string,
|
||||
publicKey: () => Uint8Array,
|
||||
address: string,
|
||||
publicKey: Uint8Array,
|
||||
sign: (data: Uint8Array) => Uint8Array;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user