Skip to content

Commit

Permalink
remove AnyResource
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Jul 26, 2023
1 parent 0b47d4d commit f908054
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion contracts/ExampleToken-v2.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ access(all) contract ExampleToken: ViewResolver, MultipleVaults {
/// was a temporary holder of the tokens. The Vault's balance has
/// been consumed and therefore can be destroyed.
///
access(all) fun deposit(from: @AnyResource{FungibleToken.Vault}) {
access(all) fun deposit(from: @{FungibleToken.Vault}) {
let vault <- from as! @ExampleToken.Vault
self.balance = self.balance + vault.balance
vault.balance = 0.0
Expand Down
12 changes: 6 additions & 6 deletions contracts/FungibleToken-v2.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ access(all) contract FungibleToken {
/// capability that allows all users to access the provider
/// resource through a reference.
///
access(Withdrawable) fun withdraw(amount: UFix64): @AnyResource{Vault} {
access(Withdrawable) fun withdraw(amount: UFix64): @{Vault} {
post {
// `result` refers to the return value
result.getBalance() == amount:
Expand All @@ -126,7 +126,7 @@ access(all) contract FungibleToken {

/// deposit takes a Vault and deposits it into the implementing resource type
///
access(all) fun deposit(from: @AnyResource{Vault})
access(all) fun deposit(from: @{Vault})

/// getSupportedVaultTypes optionally returns a list of vault types that this receiver accepts
access(all) view fun getSupportedVaultTypes(): {Type: Bool}
Expand Down Expand Up @@ -181,7 +181,7 @@ access(all) contract FungibleToken {
access(all) view fun getSupportedVaultTypes(): {Type: Bool} {
// Below check is implemented to make sure that run-time type would
// only get returned when the parent resource conforms with `FungibleToken.Vault`.
if self.getType().isSubtype(of: Type<@AnyResource{FungibleToken.Vault}>()) {
if self.getType().isSubtype(of: Type<@{FungibleToken.Vault}>()) {
return {self.getType(): true}
} else {
// Return an empty dictionary as the default value for resource who don't
Expand Down Expand Up @@ -210,7 +210,7 @@ access(all) contract FungibleToken {
/// withdraw subtracts `amount` from the Vault's balance
/// and returns a new Vault with the subtracted balance
///
access(Withdrawable) fun withdraw(amount: UFix64): @AnyResource{Vault} {
access(Withdrawable) fun withdraw(amount: UFix64): @{Vault} {
pre {
self.getBalance() >= amount:
"Amount withdrawn must be less than or equal than the balance of the Vault"
Expand All @@ -226,7 +226,7 @@ access(all) contract FungibleToken {

/// deposit takes a Vault and adds its balance to the balance of this Vault
///
access(all) fun deposit(from: @AnyResource{FungibleToken.Vault}) {
access(all) fun deposit(from: @{FungibleToken.Vault}) {
// Assert that the concrete type of the deposited vault is the same
// as the vault that is accepting the deposit
pre {
Expand All @@ -252,7 +252,7 @@ access(all) contract FungibleToken {

/// createEmptyVault allows any user to create a new Vault that has a zero balance
///
access(all) fun createEmptyVault(): @AnyResource{Vault} {
access(all) fun createEmptyVault(): @{Vault} {
post {
result.getBalance() == 0.0: "The newly created Vault must have zero balance"
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/FungibleTokenMetadataViews.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ access(all) contract FungibleTokenMetadataViews {

/// Function that allows creation of an empty FT vault that is intended
/// to store the funds.
access(all) let createEmptyVault: fun(): @AnyResource{FungibleToken.Vault}
access(all) let createEmptyVault: fun(): @{FungibleToken.Vault}

view init(
storagePath: StoragePath,
Expand All @@ -149,7 +149,7 @@ access(all) contract FungibleTokenMetadataViews {
receiverLinkedType: Type,
metadataLinkedType: Type,
providerLinkedType: Type,
createEmptyVaultFunction: fun(): @AnyResource{FungibleToken.Vault}
createEmptyVaultFunction: fun(): @{FungibleToken.Vault}
) {
pre {
receiverLinkedType.isSubtype(of: Type<&{FungibleToken.Receiver}>()): "Receiver public type must include FungibleToken.Receiver."
Expand Down
2 changes: 1 addition & 1 deletion contracts/MultipleVaults.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ access(all) contract interface MultipleVaults {

/// createEmptyVault allows any user to create a new Vault that has a zero balance
///
access(all) fun createEmptyVault(vaultType: Type): @AnyResource{FungibleToken.Vault} {
access(all) fun createEmptyVault(vaultType: Type): @{FungibleToken.Vault} {
post {
result.getBalance() == 0.0: "The newly created Vault must have zero balance"
}
Expand Down
Loading

0 comments on commit f908054

Please sign in to comment.