I have an interface which is implemented by a module.
(interface my_interface
(defun balance:decimal())
)
(module IMPL 'admin
(implements my_interface)
(defun balance:decimal() 1.1)
)
In another module, I have a schema which includes a module reference. I have some functions to store and read that reference.
(defschema schema
token:module{my_interface}
)
(deftable table:{schema})
(defun i (m:module{my_interface})
(insert table "key" {
"token":m
}
)
(m::balance)
)
(defun r:decimal ()
(with-read table "key" {
"token":=token
}
(token::balance)
)
)
The first dereference (with the param being inserted) works but the second one (reading from database) fails with error:
"resolveRef: dynamic ref not found: token::balance"
But, the PACT lang docs states:
Module references can be used as normal pact values, which includes storage in the database.
What am I doing wrong? Any help will be appreciated!
Full code:
(define-keyset 'admin (read-keyset "admin-2596680724"))
(interface my_interface
(defun balance:decimal())
)
(module IMPL 'admin
(implements my_interface)
(defun balance:decimal() 1.1)
)
(module MY_MODULE 'admin
(defschema schema
token:module{my_interface}
)
(deftable table:{schema})
(defun i (m:module{my_interface})
(insert table "key" {
"token":m
}
)
(m::balance)
)
(defun r:decimal ()
(with-read table "key" {
"token":=token
}
(token::balance)
)
)
)
(create-table table)