from .src import *
# Initialize environment (explicit wiring)
def get_decode_rows(table=None,offset=None,asc=None):
    return get_latest_from_table(table=table,offset=offset,asc=asc)
def decode_record_data(**kwargs):
    ENV = initializeEnvironment()
    signature=kwargs.get("signature")
    program_id=kwargs.get("program_id")
    data = kwargs.get("b64")
    result = ENV.decode(
        data,
        signature=kwargs["signature"],
        program_id=kwargs["program_id"],
    )
    event = kwargs.get("event")
    discriminator = kwargs.get("discriminator")
    if result == None:
        
        update_none_payloads(
            discriminator,
            event,
            data=data,
            signature=signature,
            program_id=program_id
            )           
    else:
        update_sample_payloads(
            discriminator,
            event,
            data=data,
            signature=signature,
            program_id=program_id,
            result=result
            )
def decode_record_rows(rows=None,table=None,offset=None,asc=None):
    rows = rows or get_decode_rows(
        table=table,
        offset=offset,
        asc=asc
        )
    for row in make_list(rows):
        decode_record_data(**row)

##for log in logs:
##    b64 = log.get('b64')
##    event_name = log.get("event")
##    signature = log.get('signature')
##    program_id = log.get('program_id')
##    result = env.decode(b64, signature=signature, program_id=program_id)
##    print(result)
