@@ -4,10 +4,10 @@ import assert from 'assert';
44import fetch from 'node-fetch' ;
55import jayson from 'jayson/lib/client/browser' ;
66import { struct } from 'superstruct' ;
7- import bs58 from 'bs58' ;
87
98import { Transaction } from './transaction' ;
10- import type { Account , PublicKey } from './account' ;
9+ import { PublicKey } from './publickey' ;
10+ import type { Account } from './account' ;
1111import type { TransactionSignature , TransactionId } from './transaction' ;
1212
1313type RpcRequest = ( methodName : string , args : Array < any > ) => any ;
@@ -174,7 +174,7 @@ export class Connection {
174174 async getBalance ( publicKey : PublicKey ) : Promise < number > {
175175 const unsafeRes = await this . _rpcRequest (
176176 'getBalance' ,
177- [ publicKey ]
177+ [ publicKey . toBase58 ( ) ]
178178 ) ;
179179 const res = GetBalanceRpcResult ( unsafeRes ) ;
180180 if ( res . error ) {
@@ -190,7 +190,7 @@ export class Connection {
190190 async getAccountInfo ( publicKey : PublicKey ) : Promise < AccountInfo > {
191191 const unsafeRes = await this . _rpcRequest (
192192 'getAccountInfo' ,
193- [ publicKey ]
193+ [ publicKey . toBase58 ( ) ]
194194 ) ;
195195 const res = GetAccountInfoRpcResult ( unsafeRes ) ;
196196 if ( res . error ) {
@@ -202,7 +202,7 @@ export class Connection {
202202
203203 return {
204204 tokens : result . tokens ,
205- programId : bs58 . encode ( result . program_id ) ,
205+ programId : new PublicKey ( result . program_id ) ,
206206 userdata : Buffer . from ( result . userdata ) ,
207207 } ;
208208 }
@@ -280,7 +280,7 @@ export class Connection {
280280 * Request an allocation of tokens to the specified account
281281 */
282282 async requestAirdrop ( to : PublicKey , amount : number ) : Promise < TransactionSignature > {
283- const unsafeRes = await this . _rpcRequest ( 'requestAirdrop' , [ to , amount ] ) ;
283+ const unsafeRes = await this . _rpcRequest ( 'requestAirdrop' , [ to . toBase58 ( ) , amount ] ) ;
284284 const res = RequestAirdropRpcResult ( unsafeRes ) ;
285285 if ( res . error ) {
286286 throw new Error ( res . error . message ) ;
0 commit comments