Skip to content

Commit b5cadcb

Browse files
committed
feat: simplify contract templates
1 parent 7822bef commit b5cadcb

File tree

14 files changed

+56
-70
lines changed
  • template_content
    • .algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}
    • smart_contracts/{{ contract_name }}
  • tests_generated
    • test_smart_contract_generator_default_production_preset_python
    • test_smart_contract_generator_default_production_preset_typescript
    • test_smart_contract_generator_default_starter_preset_python
    • test_smart_contract_generator_default_starter_preset_typescript

14 files changed

+56
-70
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class CoolContract(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class HelloWorld(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class CoolContract(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class HelloWorld(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class CoolContract(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class HelloWorld(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class {{ contract_name.split('_')|map('capitalize')|join }}(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class CoolContract(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from puyapy import ARC4Contract, Bytes
2-
from puyapy.arc4 import String, abimethod
1+
from puyapy import ARC4Contract, arc4
32

43

54
class HelloWorld(ARC4Contract):
6-
@abimethod()
7-
def hello(self, name: String) -> String:
8-
return String.encode(Bytes(b"Hello, ") + name.decode())
5+
@arc4.abimethod()
6+
def hello(self, name: arc4.String) -> arc4.String:
7+
return "Hello, " + name

0 commit comments

Comments
 (0)