feat: add unstable API for dynamic program loading

This commit is contained in:
Michael Vines
2018-10-10 15:19:59 -07:00
parent 715556a611
commit 1436eca398
6 changed files with 118 additions and 34 deletions

View File

@@ -0,0 +1,32 @@
// @flow
import {
Account,
Connection,
} from '../src';
import {mockRpc} from './__mocks__/node-fetch';
import {url} from './url';
export async function newAccountWithTokens(connection: Connection, amount: number = 10): Promise<Account> {
const account = new Account();
{
mockRpc.push([
url,
{
method: 'requestAirdrop',
params: [account.publicKey.toBase58(), amount],
},
{
error: null,
// Signature doesn't matter
result: '3WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}
]);
}
await connection.requestAirdrop(account.publicKey, amount);
return account;
}