def get_raw_tx_lst(version, limit): global last_version_seen global stub tx_req = GetTransactionsRequest(start_version=version, limit=limit, fetch_events=True) item = RequestItem(get_transactions_request=tx_req) request = UpdateToLatestLedgerRequest( client_known_version=last_version_seen, requested_items=[item]) response = stub.UpdateToLatestLedger(request) infos = response.response_items[ 0].get_transactions_response.txn_list_with_proof.infos raw = response.response_items[ 0].get_transactions_response.txn_list_with_proof events = response.response_items[ 0].get_transactions_response.txn_list_with_proof.events_for_versions tx_struct = [] for x in raw.transactions: y = RawTransaction() y.ParseFromString(x.raw_txn_bytes) tx_struct.append(y) return tx_struct, infos, raw, events
def get_acct_raw(acct): global last_version_seen global stub account = GetAccountStateRequest(address=bytes.fromhex(acct)) item = RequestItem(get_account_state_request=account) request = UpdateToLatestLedgerRequest(client_known_version=last_version_seen, requested_items=[item]) response = stub.UpdateToLatestLedger(request) return response.response_items[0].get_account_state_response
def run(): channel = grpc.insecure_channel(SERVER_ADDRESS) stub = AdmissionControlStub(channel) account = GetAccountStateRequest(address=bytes.fromhex(ADDRESS)) item = RequestItem(get_account_state_request=account) request = UpdateToLatestLedgerRequest(client_known_version=125190, requested_items=[item]) response = stub.UpdateToLatestLedger(request) state = response.response_items[ 0].get_account_state_response.account_state_with_proof print(state)