-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8ec1ec
commit 64de953
Showing
8 changed files
with
102 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.DS_Store | ||
.DS_Store | ||
/imports/ | ||
/.idea/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
access(all) contract Recipe { | ||
// Above is more code from the SetAndSeries Contract... | ||
access(all) resource Admin { | ||
|
||
access(all) fun addSeries(seriesId: UInt32, metadata: {String: String}) { | ||
pre { | ||
SetAndSeries.series[seriesId] == nil: | ||
"Cannot add Series: The Series already exists" | ||
} | ||
|
||
// Create the new Series | ||
let newSeries <- create Series( | ||
seriesId: seriesId, | ||
metadata: metadata | ||
) | ||
|
||
// Add the new Series resource to the Series dictionary in the contract | ||
SetAndSeries.series[seriesId] <-! newSeries | ||
} | ||
|
||
access(all) fun borrowSeries(seriesId: UInt32): &Series { | ||
pre { | ||
SetAndSeries.series[seriesId] != nil: | ||
"Cannot borrow Series: The Series does not exist" | ||
} | ||
|
||
// Get a reference to the Series and return it | ||
return &SetAndSeries.series[seriesId] as &Series | ||
} | ||
|
||
access(all) fun createNewAdmin(): @Admin { | ||
return <-create Admin() | ||
} | ||
} | ||
|
||
// Add the init() function to properly initialize the contract | ||
init() { | ||
// Save Admin resource in storage | ||
self.account.storage.save(<-create Admin(), to: self.AdminStoragePath) | ||
|
||
// Publish a capability for the Admin resource | ||
let adminCapability = self.account.capabilities.storage.issue<&SetAndSeries.Admin>( | ||
from: self.AdminStoragePath | ||
) | ||
self.account.capabilities.publish(adminCapability, at: self.AdminPrivatePath) | ||
?? panic("Could not get a capability to the admin") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Test | ||
|
||
access(all) fun testExample() { | ||
let array = [1, 2, 3] | ||
Test.expect(array.length, Test.equal(3)) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0xdc07d83a937644ff362b279501b7f7a3735ac91a0f3647147acf649dda804e28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters