Skip to content

Commit a06f7a5

Browse files
authored
Merge pull request #30 from joshuahannan/c1.0-updates
Update cadence code for 1.0
2 parents 3599905 + f74f5d3 commit a06f7a5

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

Example/FCLDemo/FCLDemo/ViewModel.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ class ViewModel: NSObject, ObservableObject {
4545

4646
@Published var script: String =
4747
"""
48-
pub struct SomeStruct {
49-
pub var x: Int
50-
pub var y: Int
48+
access(all) struct SomeStruct {
49+
access(all) var x: Int
50+
access(all) var y: Int
5151
5252
init(x: Int, y: Int) {
5353
self.x = x
5454
self.y = y
5555
}
5656
}
5757
58-
pub fun main(): [SomeStruct] {
58+
access(all) fun main(): [SomeStruct] {
5959
return [SomeStruct(x: 1, y: 2),
6060
SomeStruct(x: 3, y: 4)]
6161
}
@@ -64,7 +64,7 @@ class ViewModel: NSObject, ObservableObject {
6464
@Published var transactionScript: String =
6565
"""
6666
transaction(test: String, testInt: Int) {
67-
prepare(signer: AuthAccount) {
67+
prepare(signer: &Account) {
6868
log(signer.address)
6969
log(test)
7070
log(testInt)
@@ -229,9 +229,9 @@ class ViewModel: NSObject, ObservableObject {
229229
import FungibleToken from 0xFungibleToken
230230
import FUSD from 0xFUSD
231231
232-
pub fun main(account: Address): UFix64 {
233-
let receiverRef = getAccount(account).getCapability(/public/fusdBalance)!
234-
.borrow<&FUSD.Vault{FungibleToken.Balance}>()
232+
access(all) fun main(account: Address): UFix64 {
233+
let receiverRef = getAccount(account).capabilities.get<&{FungibleToken.Balance}>(/public/fusdBalance)!
234+
.borrow()
235235
236236
return receiverRef!.balance
237237
}
@@ -291,7 +291,7 @@ class ViewModel: NSObject, ObservableObject {
291291
.transaction(
292292
"""
293293
transaction(test: String, testInt: Int) {
294-
prepare(signer: AuthAccount) {
294+
prepare(signer: &Account) {
295295
log(signer.address)
296296
log(test)
297297
log(testInt)

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ fcl.query {
7878
import FungibleToken from 0xFungibleToken
7979
import FUSD from 0xFUSD
8080
81-
pub fun main(account: Address): UFix64 {
82-
let receiverRef = getAccount(account).getCapability(/public/fusdBalance)!
83-
.borrow<&FUSD.Vault{FungibleToken.Balance}>()
81+
access(all) fun main(account: Address): UFix64 {
82+
let receiverRef = getAccount(account).capabilities.get<&FUSD.Vault>(/public/fusdBalance)
83+
.borrow()
8484
8585
return receiverRef!.balance
8686
}
@@ -137,7 +137,7 @@ A **convenience method** that produces the needed authorization details for the
137137
try await fcl.mutate(cadence:
138138
"""
139139
transaction(test: String, testInt: Int) {
140-
prepare(signer: AuthAccount) {
140+
prepare(signer: &Account) {
141141
log(signer.address)
142142
log(test)
143143
log(testInt)
@@ -189,7 +189,7 @@ _Pass in the following as a single object with the following keys.All keys are o
189189
fcl.query {
190190
cadence {
191191
"""
192-
pub fun main(a: Int, b: Int, addr: Address): Int {
192+
access(all) fun main(a: Int, b: Int, addr: Address): Int {
193193
log(addr)
194194
return a + b
195195
}
@@ -231,7 +231,7 @@ _Pass in the following as a single object with the following keys. All keys are
231231
try await fcl.mutate(cadence:
232232
"""
233233
transaction(test: String, testInt: Int) {
234-
prepare(signer: AuthAccount) {
234+
prepare(signer: &Account) {
235235
log(signer.address)
236236
log(test)
237237
log(testInt)

Sources/Constants/Constants.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension FCL {
1111
enum Constants {
1212
static var verifyAccountProofSignaturesCadence = """
1313
import FCLCrypto from 0xFCLCrypto
14-
pub fun main(
14+
access(all) fun main(
1515
address: Address,
1616
message: String,
1717
keyIndices: [Int],
@@ -23,7 +23,7 @@ extension FCL {
2323

2424
static var verifyUserSignaturesCadence = """
2525
import FCLCrypto from 0xFCLCrypto
26-
pub fun main(
26+
access(all) fun main(
2727
address: Address,
2828
message: String,
2929
keyIndices: [Int],

Tests/FCLTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class FCLTests: XCTestCase {
4242
let response: Int = try await fcl.query {
4343
cadence {
4444
"""
45-
pub fun main(a: Int, b: Int, addr: Address): Int {
45+
access(all) fun main(a: Int, b: Int, addr: Address): Int {
4646
log(addr)
4747
return a + b
4848
}

0 commit comments

Comments
 (0)