@@ -23,36 +23,48 @@ class API implements ProviderAPIInterface {
2323 return getSolAddress ( pubkey ) ;
2424 }
2525
26- async init ( ) : Promise < void > { }
26+ async init ( ) : Promise < void > { }
27+
28+ /**
29+ * Returns null if the transaction hasn't been received by the node
30+ * or has been dropped
31+ */
2732 async getTransactionStatus ( hash : string ) : Promise < SOLRawInfo | null > {
28- return this . web3
29- . getTransaction ( hash , {
30- maxSupportedTransactionVersion : 0 ,
31- commitment : 'confirmed' ,
32- } )
33- . then ( tx => {
34- if ( ! tx ) return null ;
35- const retVal : SOLRawInfo = {
36- blockNumber : tx . slot ,
37- timestamp : tx . blockTime ,
38- transactionHash : hash ,
39- status : tx . meta ?. err ? false : true ,
40- } ;
41- return retVal ;
42- } ) ;
33+ const tx = await this . web3 . getTransaction ( hash , {
34+ maxSupportedTransactionVersion : 0 ,
35+ commitment : 'confirmed' ,
36+ } )
37+
38+ if ( ! tx ) {
39+ // Transaction hasn't been picked up by the node
40+ // (maybe it's too soon, or maybe node is behind, or maybe it's been dropped)
41+ return null ;
42+ }
43+
44+ const retVal : SOLRawInfo = {
45+ blockNumber : tx . slot ,
46+ timestamp : tx . blockTime ,
47+ transactionHash : hash ,
48+ status : tx . meta ?. err ? false : true ,
49+ } ;
50+
51+ return retVal ;
4352 }
53+
4454 async getBalance ( pubkey : string ) : Promise < string > {
4555 const balance = await this . web3 . getBalance (
4656 new PublicKey ( this . getAddress ( pubkey ) ) ,
4757 ) ;
4858 return numberToHex ( balance ) ;
4959 }
60+
5061 async broadcastTx ( rawtx : string ) : Promise < boolean > {
5162 return this . web3
5263 . sendRawTransaction ( hexToBuffer ( rawtx ) )
5364 . then ( ( ) => true )
5465 . catch ( ( ) => false ) ;
5566 }
67+
5668 getTokenInfo = async ( contractAddress : string ) : Promise < SPLTokenInfo > => {
5769 interface TokenDetails {
5870 address : string ;
0 commit comments