Skip to content
Snippets Groups Projects
Commit 3e2517a8 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[+] The ChainCommon class has been added and it contains the balanceToCoins...

[+] The ChainCommon class has been added and it contains the balanceToCoins function, which converts data into coins and is a wrapper over the dap_chain_balance_to_coins function.
parent ef214798
No related branches found
No related tags found
4 merge requests!69Hotfix - fixed wrapping function dap_chain_ledger_tx_get_token_ticker_by_hash,!68hotfix-4954,!66Made a number of changes that were required to change the work in the blockchain explorer.,!65hotfix-4954
...@@ -383,7 +383,7 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ ...@@ -383,7 +383,7 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
PyType_Ready( &DapChainAtomIter_DapChainAtomIterType ) < 0 || PyType_Ready( &DapChainAtomIter_DapChainAtomIterType ) < 0 ||
PyType_Ready(&DapChainAtomPtr_DapChainAtomPtrType) < 0 || PyType_Ready(&DapChainAtomPtr_DapChainAtomPtrType) < 0 ||
PyType_Ready( &DapChainCell_DapChainCellObjectType ) < 0 || PyType_Ready( &DapChainCell_DapChainCellObjectType ) < 0 ||
// PyType_Ready(&ChainCommonObject_ChainCommonType) < 0 || PyType_Ready(&DapChainCommonObject_DapChainCommonType) < 0 ||
PyType_Ready( &DapChainCellIDObject_DapChainCellIDType) < 0 || PyType_Ready( &DapChainCellIDObject_DapChainCellIDType) < 0 ||
PyType_Ready( &DapChainCellIDObject_DapChainCellIDType) < 0 || PyType_Ready( &DapChainCellIDObject_DapChainCellIDType) < 0 ||
...@@ -484,7 +484,7 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ ...@@ -484,7 +484,7 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
PyModule_AddObject(module, "ChainAtomIter", (PyObject*)&DapChainAtomIter_DapChainAtomIterType); PyModule_AddObject(module, "ChainAtomIter", (PyObject*)&DapChainAtomIter_DapChainAtomIterType);
PyModule_AddObject(module, "ChainAtomPtr", (PyObject*)&DapChainAtomPtr_DapChainAtomPtrType); PyModule_AddObject(module, "ChainAtomPtr", (PyObject*)&DapChainAtomPtr_DapChainAtomPtrType);
PyModule_AddObject(module, "ChainCell", (PyObject*)&DapChainCell_DapChainCellObjectType); PyModule_AddObject(module, "ChainCell", (PyObject*)&DapChainCell_DapChainCellObjectType);
// PyModule_AddObject(module, "ChainCommon", (PyObject*)&ChainCommonObject_ChainCommonType); PyModule_AddObject(module, "ChainCommon", (PyObject*)&DapChainCommonObject_DapChainCommonType);
// PyModule_AddObject(module, "ChainID", (PyObject*)&DapChainIDObject_DapChainIDType); // PyModule_AddObject(module, "ChainID", (PyObject*)&DapChainIDObject_DapChainIDType);
PyModule_AddObject(module, "ChainCellID", (PyObject*)&DapChainCellIDObject_DapChainCellIDType); PyModule_AddObject(module, "ChainCellID", (PyObject*)&DapChainCellIDObject_DapChainCellIDType);
......
...@@ -531,6 +531,62 @@ static PyTypeObject DapChainSlowKindObject_DapChainSlowKindType = { ...@@ -531,6 +531,62 @@ static PyTypeObject DapChainSlowKindObject_DapChainSlowKindType = {
}; };
/*=================*/
/**/
typedef struct PyDapChainCommon{
PyObject_HEAD
}PyDapChainCommonObject;
PyObject * dap_chain_balance_to_coins_py(PyObject *self, PyObject *args);
static PyMethodDef DapChainCommonMethodsDef[] = {
{"balanceToCoins", (PyCFunction)dap_chain_balance_to_coins_py, METH_VARARGS | METH_STATIC, ""},
{NULL, NULL, 0, NULL}
};
static PyTypeObject DapChainCommonObject_DapChainCommonType = {
PyVarObject_HEAD_INIT(NULL, 0)
"CellFrame.ChainCommon" , /* tp_name */
sizeof(PyDapChainCommonObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT |
Py_TPFLAGS_BASETYPE, /* tp_flags */
"Chain common object", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DapChainCommonMethodsDef, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
/*=================*/ /*=================*/
......
...@@ -76,3 +76,13 @@ PyObject *dap_chain_net_srv_uid_from_str_py(PyObject *self, PyObject *args){ ...@@ -76,3 +76,13 @@ PyObject *dap_chain_net_srv_uid_from_str_py(PyObject *self, PyObject *args){
((PyDapChainNetSrvUIDObject*)obj)->net_srv_uid = dap_chain_net_srv_uid_from_str(str); ((PyDapChainNetSrvUIDObject*)obj)->net_srv_uid = dap_chain_net_srv_uid_from_str(str);
return Py_BuildValue("O", obj); return Py_BuildValue("O", obj);
} }
PyObject * dap_chain_balance_to_coins_py(PyObject *self, PyObject *args){
(void)self;
uint64_t balance=0;
if (!PyArg_ParseTuple(args, "k", &balance)){
return NULL;
}
const char *str = dap_chain_balance_to_coins(dap_chain_uint128_to(balance));
return Py_BuildValue("s", str);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment