diff --git a/convex-cli/GENESIS.md b/convex-cli/GENESIS.md index 175eac7cb..81963ae75 100644 --- a/convex-cli/GENESIS.md +++ b/convex-cli/GENESIS.md @@ -42,6 +42,7 @@ alias convex="java -jar ~/convex.jar" Genesis/Admin Key: `0xc1d3b0104d55ddf7680181a46e93422e49e2ea9298e37794860f1ef1128427f7` Governance key: `0x12EF73ee900eD1FE78A188f59bF8CedE467bAA66f5b60368aFAaA3B9521aB94d` +Genesis Peer key: `0x12EF73ee900eD1FE78A188f59bF8CedE467bAA66f5b60368aFAaA3B9521aB94d` mikera key: `0x89b5142678bfef7a2245af5ae5b9ab1e10c282b375fa297c5aaeccc48ac97cac` diff --git a/convex-core/src/main/cvx/convex/lab/archon.cvx b/convex-core/src/main/cvx/convex/lab/archon.cvx index 86b162021..0e9ad7635 100644 --- a/convex-core/src/main/cvx/convex/lab/archon.cvx +++ b/convex-core/src/main/cvx/convex/lab/archon.cvx @@ -56,19 +56,22 @@ ;; These functions provide full CAD19 asset functionality ;; -;; Quanity check +;; Quanity check, enforces use as a set (defn -qc [q] (cond (set? q) q ;; base case, quantity should always be a Set - (valid-id? q) #{q} ;; we allow a blob ID to be used as a quanitity if valid + (valid-id? q) #{q} ;; we allow an ID to be used as a quanitity if valid (nil? q) #{} (fail :ARGUMENT "Invalid NFT quantity"))) (defn -direct-transfer ^{:private? true} ;; Used internally by [[accept]] and [[direct-transfer]]. - [sender receiver quantity] + ([sender receiver quqnitity] + (recur sender receiver quanity nil)) + + ([sender receiver quantity data] (let [q (-qc quantity) receiver (address receiver) sender-balance (or (get-holding sender) @@ -81,7 +84,10 @@ new-receiver-balance (union receiver-balance q)] (set-holding sender new-sender-balance) (set-holding receiver new-receiver-balance) - quantity)) + (for [tok q] + (log "NTR" sender receiver tok data)) + + quantity))) (defn accept @@ -124,7 +130,8 @@ [receiver quantity data] (-direct-transfer *caller* receiver - quantity)) + quantity + data)) (defn offer ^{:callable true} diff --git a/convex-core/src/main/java/convex/core/init/Init.java b/convex-core/src/main/java/convex/core/init/Init.java index 6867b8296..79186534b 100644 --- a/convex-core/src/main/java/convex/core/init/Init.java +++ b/convex-core/src/main/java/convex/core/init/Init.java @@ -75,7 +75,9 @@ public class Init { private static final long GENESIS_COINS=1000000*Coin.GOLD; public static final AccountKey DEFAULT_GOV_KEY = AccountKey.fromHex("12EF73ee900eD1FE78A188f59bF8CedE467bAA66f5b60368aFAaA3B9521aB94d"); - + public static final AccountKey DEFAULT_GENESIS_KEY = AccountKey.fromHex("c1d3b0104d55ddf7680181a46e93422e49e2ea9298e37794860f1ef1128427f7"); + public static final AccountKey FIRST_PEER_KEY = AccountKey.fromHex("d6ef2d429b73ef1c78d9e46d87feb9d9535a991b8102099f54ed243f1e557d42"); + private static final long RESERVED_USER_LIMIT = 64; private static final long RESERVED_ACTOR_LIMIT = 128; diff --git a/convex-core/src/test/java/convex/core/init/GenesisTest.java b/convex-core/src/test/java/convex/core/init/GenesisTest.java new file mode 100644 index 000000000..55b46a880 --- /dev/null +++ b/convex-core/src/test/java/convex/core/init/GenesisTest.java @@ -0,0 +1,18 @@ +package convex.core.init; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +import convex.core.cvm.State; + +public class GenesisTest { + + @Test + public static void testGenesis() { + State genesis=Init.createState(Init.DEFAULT_GOV_KEY, Init.DEFAULT_GENESIS_KEY, List.of(Init.FIRST_PEER_KEY)); + assertEquals("b0e44f2a645abfa539f5b96b7a0eabb0f902866feaff0f7c12d1213e02333f13",genesis.getHash().toHexString()); + } +} diff --git a/convex-core/src/test/java/lab/ArchonTest.java b/convex-core/src/test/java/lab/ArchonTest.java index 07970423f..6d7e1791c 100644 --- a/convex-core/src/test/java/lab/ArchonTest.java +++ b/convex-core/src/test/java/lab/ArchonTest.java @@ -13,6 +13,7 @@ import convex.core.cvm.Context; import convex.core.data.ACell; import convex.core.data.AHashMap; +import convex.core.data.ASet; import convex.core.data.AString; import convex.core.data.Strings; import convex.core.lang.ACVMTest; @@ -70,4 +71,24 @@ public class ArchonTest extends ACVMTest { ctx=exec(ctx,"(asset/transfer "+VILLAIN+" [archon #{0x0123}])"); AssetTester.doAssetTests(ctx, ARCHON, HERO, VILLAIN); } + + @Test public void testPeaceSetup() { + Context ctx=context(); + + String patch="(let [vs [:I :believe :that :unarmed :truth :and :unconditional :love :will \r\n" + + " :have :the :final :word :in :reality :This :is :why :right :temporarily \r\n" + + " :defeated :is-1 :stronger :than :evil :triumphant :I-1 :believe-1 :that-1 :even \r\n" + + " :amid :todays :mortar :bursts :and-1 :whining :bullets :there :is-2 :still :hope \r\n" + + " :for :a :brighter :tomorrow :I-2 :believe-2 :that-2 :wounded :justice :lying\r\n" + + " :prostrate :on :the-1 :blood-flowing :streets :of :our :nations :can :be :lifted \r\n" + + " :from :this :dust :of :shame :to :reign :supreme :among :the-2 :children :of :men \r\n" + + " :I-3 :have :the-3 :audacity :to :believe-3 :that-3 :peoples :everywhere :can :have\r\n" + + " :three :meals :a :day :for-1 :their :bodies :education :and-2 :culture :for-2 \r\n" + + " :their-1 :minds :dignity :bar1 :bar2 :bar3 :bar4 :bar5 :bar6 :bar7]\r\n" + + " vset (into #{} vs)]\r\n" + + " vset)"; + + ctx=exec(ctx,patch); + assertTrue(ctx.getResult() instanceof ASet); + } }