Skip to content

All manually wrapped dcp-client functions need to unwrap Bifrost2 objects #46

Description

@JosephAcernese

There appears to be a gap with some of the function wrapping implementations. Currently any Bifrost2 function needs to account for wrapped objects being passed to them before calling the underlying function. With some of the manually wrapped functions this is missing. This means users need to access the underlying JS proxy object.

job.exec is an example of a function currently missing the unwrapping logic

dcp.init()

id = dcp.wallet.get("id")
dcp.identity.set(id)

pay = dcp.wallet.get("default")

input_set = [1,2,3]

def work_function(number):
  dcp.progress()
  return number

job = dcp.compute_for(input_set, work_function)

job.exec(dcp.compute.marketValue().js_ref, pay.js_ref) // ERRORS without .js_ref
results = job.wait()

The fix can probably be simple like an unwrapping function which can be called at the start of each manually wrapped function. There probably needs to be extra logic for nested items (arrays, dictionaries, etc)

def unwrap_args(*args):
  for i, arg in enumerate(args):
    if hasattr(args[i], 'js_ref'):
      args[i] = args[i].js_ref
  return args;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions