summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-09-26 12:53:55 +0530
committerAndinus <andinus@nand.sh>2021-09-26 12:53:55 +0530
commit7237e2e5d4a24dab9caaa7d3fdbb86c8d130708a (patch)
tree1f6f06ef90f7a34593dc52240ce01d44d9abb987
parent8e321251e28d8a88d133eab55dc2d69b258f5789 (diff)
downloadMyMedMemoir-7237e2e5d4a24dab9caaa7d3fdbb86c8d130708a.tar.gz
Revert to lists
-rw-r--r--contract/memoir.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/contract/memoir.py b/contract/memoir.py
index a9f3cc6..cce8c72 100644
--- a/contract/memoir.py
+++ b/contract/memoir.py
@@ -3,28 +3,28 @@ import smartpy as sp
 class Memoir(sp.Contract):
     def __init__(self):
         self.init(
-            records = sp.big_map(
-                tkey = sp.TInt,
-                tvalue = sp.TString
-            ),
+            dates = sp.list([]),
+            records = sp.list([])
         )
 
     @sp.entry_point
     def add_record(self, params):
-        self.data.records[params.id] = params.record
+        self.data.dates.push(sp.now)
+        self.data.records.push(params.record)
+        # self.data.records[params.id] = params.record
         # Verify that the ID doesn't exist.
         # sp.verify(
         #     self.data.records.contains(params.id) == False,
         #     message = "Record exists"
         # )
 
-    @sp.entry_point
-    def update_record(self, params):
-        self.data.records = sp.update_map(
-            self.data.records,
-            params.id,
-            sp.some(params.record)
-        )
+    # @sp.entry_point
+    # def update_record(self, params):
+    #     self.data.records = sp.update_map(
+    #         self.data.records,
+    #         params.id,
+    #         sp.some(params.record)
+    #     )
 
     @sp.entry_point
     def delete_record(self, params):
@@ -39,14 +39,17 @@ def test():
     scenario += c1
 
     # Try adding records.
-    scenario += c1.add_record(id = 0, record = '{record #0}')
-    scenario += c1.add_record(id = 1, record = '{record #1}')
-    scenario += c1.add_record(id = 2, record = '{record #2}')
+    # scenario += c1.add_record(id = 0, record = '{record #0}')
+    # scenario += c1.add_record(id = 1, record = '{record #1}')
+    # scenario += c1.add_record(id = 2, record = '{record #2}')
+    scenario += c1.add_record(record = '{record #1}')
+    scenario += c1.add_record(record = '{record #2}')
 
     # Updating records.
-    scenario += c1.update_record(id = 1, record = '{record #1 - updated}')
+    # scenario += c1.update_record(id = 1, record = '{record #1 - updated}')
 
     # Deleting records.
+    # scenario += c1.delete_record(id = 2)
     scenario += c1.delete_record(id = 2)
 
     # Trying to add over existing record. Should Fail.