Skip to content

Commit 1b3f5c1

Browse files
committed
[pyth] Remove transfer and get_balance commands.
1 parent 4b02739 commit 1b3f5c1

File tree

5 files changed

+0
-424
lines changed

5 files changed

+0
-424
lines changed

pc/request.cpp

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,133 +1440,6 @@ void upd_test::on_response( rpc::account_update *res )
14401440
st_ = e_done;
14411441
}
14421442

1443-
///////////////////////////////////////////////////////////////////////////
1444-
// transfer
1445-
1446-
transfer::transfer()
1447-
: st_( e_sent ),
1448-
cmt_( commitment::e_confirmed )
1449-
{
1450-
}
1451-
1452-
void transfer::set_receiver( pub_key *pkey )
1453-
{
1454-
req_->set_receiver( pkey );
1455-
}
1456-
1457-
void transfer::set_lamports( uint64_t funds )
1458-
{
1459-
req_->set_lamports( funds );
1460-
}
1461-
1462-
void transfer::set_commitment( commitment cmt )
1463-
{
1464-
cmt_ = cmt;
1465-
}
1466-
1467-
void transfer::on_response( rpc::transfer *res )
1468-
{
1469-
if ( res->get_is_err() ) {
1470-
on_error_sub( res->get_err_msg(), this );
1471-
st_ = e_error;
1472-
} else if ( st_ == e_sent ) {
1473-
st_ = e_sig;
1474-
sig_->set_commitment( cmt_ );
1475-
sig_->set_signature( res->get_signature() );
1476-
get_rpc_client()->send( sig_ );
1477-
}
1478-
}
1479-
1480-
void transfer::on_response( rpc::signature_subscribe *res )
1481-
{
1482-
if ( res->get_is_err() ) {
1483-
on_error_sub( res->get_err_msg(), this );
1484-
st_ = e_error;
1485-
} else if ( st_ == e_sig ) {
1486-
st_ = e_done;
1487-
on_response_sub( this );
1488-
}
1489-
}
1490-
1491-
void transfer::submit()
1492-
{
1493-
manager *cptr = get_manager();
1494-
key_pair *pkey = cptr->get_publish_key_pair();
1495-
if ( !pkey ) {
1496-
on_error_sub( "missing or invalid publish key [" +
1497-
cptr->get_publish_key_pair_file() + "]", this );
1498-
return;
1499-
}
1500-
req_->set_sender( pkey );
1501-
req_->set_sub( this );
1502-
sig_->set_sub( this );
1503-
1504-
// get recent block hash and submit request
1505-
st_ = e_sent;
1506-
req_->set_block_hash( cptr->get_recent_block_hash() );
1507-
get_rpc_client()->send( req_ );
1508-
}
1509-
1510-
bool transfer::get_is_done() const
1511-
{
1512-
return st_ == e_done;
1513-
}
1514-
1515-
///////////////////////////////////////////////////////////////////////////
1516-
// balance
1517-
1518-
balance::balance()
1519-
: st_( e_sent ),
1520-
pub_( nullptr )
1521-
{
1522-
}
1523-
1524-
void balance::set_pub_key( pub_key *pkey )
1525-
{
1526-
pub_ = pkey;
1527-
}
1528-
1529-
uint64_t balance::get_lamports() const
1530-
{
1531-
return req_->get_lamports();
1532-
}
1533-
1534-
void balance::on_response( rpc::get_account_info *res )
1535-
{
1536-
if ( res->get_is_err() ) {
1537-
on_error_sub( res->get_err_msg(), this );
1538-
st_ = e_error;
1539-
} else if ( st_ == e_sent ) {
1540-
st_ = e_done;
1541-
on_response_sub( this );
1542-
}
1543-
}
1544-
1545-
void balance::submit()
1546-
{
1547-
if ( pub_ ) {
1548-
req_->set_account( pub_ );
1549-
} else {
1550-
manager *cptr = get_manager();
1551-
pub_key *pkey = cptr->get_publish_pub_key();
1552-
if ( !pkey ) {
1553-
on_error_sub( "missing or invalid publish key [" +
1554-
cptr->get_publish_key_pair_file() + "]", this );
1555-
return;
1556-
}
1557-
req_->set_account( pkey );
1558-
}
1559-
st_ = e_sent;
1560-
req_->set_sub( this );
1561-
req_->set_commitment( get_manager()->get_commitment() );
1562-
get_rpc_client()->send( req_ );
1563-
}
1564-
1565-
bool balance::get_is_done() const
1566-
{
1567-
return st_ == e_done;
1568-
}
1569-
15701443
///////////////////////////////////////////////////////////////////////////
15711444
// get_block
15721445

pc/request.hpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -473,56 +473,6 @@ namespace pc
473473
rpc::account_subscribe areq_[1];
474474
};
475475

476-
477-
// transfer SOL from publisher to other account
478-
class transfer : public request,
479-
public rpc_sub_i<rpc::transfer>,
480-
public rpc_sub_i<rpc::signature_subscribe>
481-
{
482-
public:
483-
transfer();
484-
void set_receiver( pub_key * );
485-
void set_lamports( uint64_t funds );
486-
void set_commitment( commitment );
487-
488-
public:
489-
void on_response( rpc::transfer *msg ) override;
490-
void on_response( rpc::signature_subscribe * ) override;
491-
bool get_is_done() const override;
492-
void submit() override;
493-
494-
private:
495-
typedef enum { e_sent, e_sig, e_done, e_error } state_t;
496-
497-
state_t st_;
498-
commitment cmt_;
499-
key_pair akey_;
500-
key_pair skey_;
501-
rpc::transfer req_[1];
502-
rpc::signature_subscribe sig_[1];
503-
};
504-
505-
// get account balance
506-
class balance : public request,
507-
public rpc_sub_i<rpc::get_account_info>
508-
{
509-
public:
510-
balance();
511-
void set_pub_key( pub_key * );
512-
uint64_t get_lamports() const;
513-
514-
public:
515-
void submit() override;
516-
void on_response( rpc::get_account_info * ) override;
517-
bool get_is_done() const override;
518-
519-
private:
520-
typedef enum { e_sent, e_done, e_error } state_t;
521-
state_t st_;
522-
pub_key *pub_;
523-
rpc::get_account_info req_[1];
524-
};
525-
526476
// get transactions in single block
527477
class get_block : public request,
528478
public rpc_sub_i<rpc::get_block>

pc/rpc_client.cpp

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ enum system_instruction : uint32_t
1111
{
1212
e_create_account,
1313
e_assign,
14-
e_transfer
1514
};
1615

1716
static hash gen_sys_id()
@@ -729,97 +728,6 @@ void rpc::get_slot_leaders::response( const jtree& jt )
729728
on_response( this );
730729
}
731730

732-
///////////////////////////////////////////////////////////////////////////
733-
// transfer
734-
735-
void rpc::transfer::set_block_hash( hash *bhash )
736-
{
737-
bhash_ = bhash;
738-
}
739-
740-
void rpc::transfer::set_sender( key_pair *snd )
741-
{
742-
snd_ = snd;
743-
}
744-
745-
void rpc::transfer::set_receiver( pub_key *rcv )
746-
{
747-
rcv_ = rcv;
748-
}
749-
750-
void rpc::transfer::set_lamports( uint64_t funds )
751-
{
752-
lamports_ = funds;
753-
}
754-
755-
signature *rpc::transfer::get_signature()
756-
{
757-
return &sig_;
758-
}
759-
760-
void rpc::transfer::enc_signature( std::string& sig )
761-
{
762-
sig_.enc_base58( sig );
763-
}
764-
765-
766-
rpc::transfer::transfer()
767-
: lamports_( 0UL )
768-
{
769-
}
770-
771-
void rpc::transfer::request( json_wtr& msg )
772-
{
773-
// construct binary transaction
774-
net_buf *bptr = net_buf::alloc();
775-
bincode tx( bptr->buf_ );
776-
777-
// signatures section
778-
tx.add_len<1>(); // one signature
779-
size_t sign_idx = tx.reserve_sign();
780-
781-
// message header
782-
size_t tx_idx = tx.get_pos();
783-
tx.add( (uint8_t)1 ); // signing accounts
784-
tx.add( (uint8_t)0 ); // read-only signed accounts
785-
tx.add( (uint8_t)1 ); // read-only unsigned accounts
786-
787-
// accounts
788-
tx.add_len<3>(); // 3 accounts: sender, receiver, program
789-
tx.add( *snd_ ); // sender account
790-
tx.add( *rcv_ ); // receiver account
791-
tx.add( sys_id ); // system programid
792-
793-
// recent block hash
794-
tx.add( *bhash_ ); // recent block hash
795-
796-
// instructions section
797-
tx.add_len<1>(); // one instruction
798-
tx.add( (uint8_t)2); // program_id index
799-
tx.add_len<2>(); // 2 accounts: sender, receiver
800-
tx.add( (uint8_t)0 ); // index of sender account
801-
tx.add( (uint8_t)1 ); // index of receiver account
802-
803-
// instruction parameter section
804-
tx.add_len<12>(); // size of data array
805-
tx.add( (uint32_t)system_instruction::e_transfer );
806-
tx.add( (uint64_t)lamports_ );
807-
808-
// sign message
809-
tx.sign( sign_idx, tx_idx, *snd_ );
810-
sig_.init_from_buf( (const uint8_t*)(tx.get_buf() + sign_idx) );
811-
812-
// encode transaction and add to json params
813-
send_transaction( msg, tx, false );
814-
bptr->dealloc();
815-
}
816-
817-
void rpc::transfer::response( const jtree& jt )
818-
{
819-
if ( on_error( jt, this ) ) return;
820-
on_response( this );
821-
}
822-
823731
///////////////////////////////////////////////////////////////////////////
824732
// account_update
825733

pc/rpc_client.hpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -529,32 +529,6 @@ namespace pc
529529
commitment cmt_;
530530
};
531531

532-
// transaction to transfer funds between accounts
533-
class transfer : public rpc_request
534-
{
535-
public:
536-
// parameters
537-
void set_block_hash( hash * );
538-
void set_sender( key_pair * );
539-
void set_receiver( pub_key * );
540-
void set_lamports( uint64_t funds );
541-
542-
// results
543-
signature *get_signature();
544-
void enc_signature( std::string& );
545-
546-
transfer();
547-
void request( json_wtr& ) override;
548-
void response( const jtree& ) override;
549-
550-
private:
551-
hash *bhash_;
552-
key_pair *snd_;
553-
pub_key *rcv_;
554-
uint64_t lamports_;
555-
signature sig_;
556-
};
557-
558532
// create new account and assign ownership to some (program) key
559533
class create_account : public rpc_request
560534
{

0 commit comments

Comments
 (0)