Skip to content

Commit

Permalink
Merge pull request #62 from janezpodhostnik/janez/cadence-1.0
Browse files Browse the repository at this point in the history
Upgrade to cadence 1.0
  • Loading branch information
janezpodhostnik authored Aug 9, 2024
2 parents a41d66b + 99c5610 commit 7958270
Show file tree
Hide file tree
Showing 14 changed files with 1,379 additions and 1,037 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ jobs:
needs: test
services:
emulator:
image: gcr.io/flow-container-registry/emulator:latest
#image: gcr.io/flow-container-registry/emulator:latest
# temporarily changed because the latest emulator is not 1.0
image: gcr.io/flow-container-registry/emulator:v1.0.0-preview.38
ports:
- 3569:3569
env:
Expand Down
16 changes: 8 additions & 8 deletions examples/account_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ async def run(self, ctx: Config):
# A test Contract define for this example, you can modify it by your self
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
"source": """access(all) contract TestOne {
access(all) fun add(a: Int, b: Int): Int {
return a + b
}
}""",
Expand Down Expand Up @@ -141,8 +141,8 @@ async def run(self, ctx: Config):
# A test Contract define for this example, you can modify it by your self
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
"source": """access(all) contract TestOne {
access(all) fun add(a: Int, b: Int): Int {
return a + b
}
}""",
Expand Down Expand Up @@ -190,8 +190,8 @@ async def run(self, ctx: Config):
# Updated Contract
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
"source": """access(all) contract TestOne {
access(all) fun add(a: Int, b: Int): Int {
return a * b
}
}""",
Expand Down Expand Up @@ -241,8 +241,8 @@ async def run(self, ctx: Config):
# A test Contract define for this example, you can modify it by your self
contract = {
"Name": "TestOne",
"source": """pub contract TestOne {
pub fun add(a: Int, b: Int): Int {
"source": """access(all) contract TestOne {
access(all) fun add(a: Int, b: Int): Int {
return a + b
}
}""",
Expand Down
6 changes: 3 additions & 3 deletions examples/events_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ async def run(self, ctx: Config):
ctx=ctx,
contracts={
"EventDemo": """
pub contract EventDemo {
pub event Add(x: Int, y: Int, sum: Int)
access(all) contract EventDemo {
access(all) event Add(x: Int, y: Int, sum: Int)
pub fun add(_ x: Int, _ y: Int) {
access(all) fun add(_ x: Int, _ y: Int) {
let sum = x + y
emit Add(x: x, y: y, sum: sum)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"accounts": {
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"keys": "39a162b7ea58314c2cda19f32020b3992e9017a0acc5b3ac53ce3a3f8511a877",
"keys": "aff3a277caf2bdd6582c156ae7b07dbca537da7833309de88e56987faa2c0f1b",
"sigAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256"
}
Expand Down
14 changes: 7 additions & 7 deletions examples/scripts_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def run(self, ctx: Config):
# --------------------------------
script = Script(
code="""
pub fun main(): Int {
access(all) fun main(): Int {
let a = 1
let b = 1
return a + b
Expand Down Expand Up @@ -54,7 +54,7 @@ async def run(self, ctx: Config):
# --------------------------------
script = Script(
code="""
pub fun main(a: Int, b: Int): Int {
access(all) fun main(a: Int, b: Int): Int {
return a + b
}
""",
Expand Down Expand Up @@ -83,10 +83,10 @@ def __init__(self) -> None:
async def run(self, ctx: Config):
script = Script(
code="""
pub struct User {
pub var balance: UFix64
pub var address: Address
pub var name: String
access(all) struct User {
access(all) var balance: UFix64
access(all) var address: Address
access(all) var name: String
init(name: String, address: Address, balance: UFix64) {
self.name = name
Expand All @@ -95,7 +95,7 @@ async def run(self, ctx: Config):
}
}
pub fun main(name: String): User {
access(all) fun main(name: String): User {
return User(
name: name,
address: 0x1,
Expand Down
2 changes: 1 addition & 1 deletion examples/transactions_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def run(self, ctx: Config):
transaction = (
Tx(
code="""transaction {
prepare(signer1: AuthAccount, signer2: AuthAccount) {
prepare(signer1: &Account, signer2: &Account) {
log(signer1.address)
log(signer2.address)
}
Expand Down
11 changes: 10 additions & 1 deletion flow_py_sdk/cadence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Function,
KeyValuePair,
TypeValue,
InclusiveRange,
)
from .composite import (
Struct,
Expand Down Expand Up @@ -115,7 +116,15 @@
ContractInterfaceKind,
FunctionKind,
ReferenceKind,
RestrictedKind,
IntersectionKind,
CapabilityKind,
EnumKind,
InclusiveRangeKind,
EntitlementConjunctionSetKind,
EntitlementDisjunctionSetKind,
EntitlementMapAuthorization,
EntitlementUnauthorizedKind,
EntitlementMapKind,
EntitlementKind,
EntitlementsKind,
)
12 changes: 9 additions & 3 deletions flow_py_sdk/cadence/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
identifierKey = "identifier"
staticTypeKey = "staticType"
addressKey = "address"
pathKey = "path"
initializersKey = "initializers"
labelKey = "label"
parametersKey = "parameters"
returnKey = "return"
authorizedKey = "authorized"
restrictionsKey = "restrictions"
authorizationKey = "authorization"
typesKey = "types"
functionTypeKey = "functionType"
elementKey = "element"
startKey = "start"
endKey = "end"
stepKey = "step"
purityKey = "purity"
entitlementsKey = "entitlements"

voidTypeStr = "Void"
optionalTypeStr = "Optional"
Expand Down Expand Up @@ -57,6 +62,7 @@
linkTypeStr = "Link"
pathTypeStr = "Path"
typeTypeStr = "Type"
inclusiveRangeTypeStr = "InclusiveRange"
capabilityTypeStr = "Capability"
functionTypeStr = "Function"

Expand Down
Loading

0 comments on commit 7958270

Please sign in to comment.