-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into nialexsan/update-pack…
…ages
- Loading branch information
Showing
61 changed files
with
5,544 additions
and
11,320 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
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 |
---|---|---|
|
@@ -24,3 +24,5 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.idea |
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,2 +1,2 @@ | ||
# Sumbit an issue to be added as a codeowner | ||
* @10thfloor @MrDSGC @alse @srinjoyc | ||
* @jribbink @ianthpun @bthaile |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/// Burner is a contract that can facilitate the destruction of any resource on flow. | ||
/// | ||
/// Contributors | ||
/// - Austin Kline - https://twitter.com/austin_flowty | ||
/// - Deniz Edincik - https://twitter.com/bluesign | ||
/// - Bastian Müller - https://twitter.com/turbolent | ||
access(all) contract Burner { | ||
/// When Crescendo (Cadence 1.0) is released, custom destructors will be removed from cadece. | ||
/// Burnable is an interface meant to replace this lost feature, allowing anyone to add a callback | ||
/// method to ensure they do not destroy something which is not meant to be, | ||
/// or to add logic based on destruction such as tracking the supply of a FT Collection | ||
/// | ||
/// NOTE: The only way to see benefit from this interface | ||
/// is to always use the burn method in this contract. Anyone who owns a resource can always elect **not** | ||
/// to destroy a resource this way | ||
access(all) resource interface Burnable { | ||
access(contract) fun burnCallback() | ||
} | ||
|
||
/// burn is a global method which will destroy any resource it is given. | ||
/// If the provided resource implements the Burnable interface, | ||
/// it will call the burnCallback method and then destroy afterwards. | ||
access(all) fun burn(_ r: @AnyResource) { | ||
if let s <- r as? @{Burnable} { | ||
s.burnCallback() | ||
destroy s | ||
} else if let arr <- r as? @[AnyResource] { | ||
while arr.length > 0 { | ||
let item <- arr.removeFirst() | ||
self.burn(<-item) | ||
} | ||
destroy arr | ||
} else if let dict <- r as? @{HashableStruct: AnyResource} { | ||
let keys = dict.keys | ||
while keys.length > 0 { | ||
let item <- dict.remove(key: keys.removeFirst())! | ||
self.burn(<-item) | ||
} | ||
destroy dict | ||
} else { | ||
destroy r | ||
} | ||
} | ||
} |
Oops, something went wrong.