Skip to content

Commit

Permalink
remove transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Nov 14, 2023
1 parent a2f4f3b commit b77ea96
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 45 deletions.
11 changes: 0 additions & 11 deletions contracts/ExampleToken-v2.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,6 @@ access(all) contract ExampleToken: ViewResolver {
destroy vault
}

access(FungibleToken.Withdrawable) fun transfer(amount: UFix64, receiver: Capability<&{FungibleToken.Receiver}>) {
let transferVault <- self.withdraw(amount: amount)

// Get a reference to the recipient's Receiver
let receiverRef = receiver.borrow()
?? panic("Could not borrow receiver reference to the recipient's Vault")

// Deposit the withdrawn tokens in the recipient's receiver
receiverRef.deposit(from: <-transferVault)
}

/// createEmptyVault
///
/// Function that creates a new Vault with a balance of zero
Expand Down
29 changes: 1 addition & 28 deletions contracts/FungibleToken-v2.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,12 @@ access(all) contract FungibleToken {
}
}

access(all) resource interface Transferor {
/// Function for a direct transfer instead of having to do a deposit and withdrawal
///
access(Withdrawable) fun transfer(amount: UFix64, receiver: Capability<&{FungibleToken.Receiver}>) {
pre {
receiver.check(): "Could not borrow a reference to the NFT receiver"
}
}
}

/// Vault
///
/// Ideally, this interface would also conform to Receiver, Balance, Transferor, Provider, and Resolver
/// but that is not supported yet
///
access(all) resource interface Vault: Receiver, Transferor, Provider, ViewResolver.Resolver { //,Balance {
access(all) resource interface Vault: Receiver, Provider, ViewResolver.Resolver {

/// Get the balance of the vault
access(all) view fun getBalance(): UFix64
Expand Down Expand Up @@ -194,13 +184,6 @@ access(all) contract FungibleToken {
return nil
}

// access(all) view fun getViews(): [Type] {
// pre { true: "dummy" }
// }
// access(all) fun resolveView(_ view: Type): AnyStruct? {
// pre { true: "dummy" }
// }
/// withdraw subtracts `amount` from the Vault's balance
/// and returns a new Vault with the subtracted balance
///
Expand Down Expand Up @@ -234,16 +217,6 @@ access(all) contract FungibleToken {
}
}

/// Function for a direct transfer instead of having to do a deposit and withdrawal
///
access(Withdrawable) fun transfer(amount: UFix64, receiver: Capability<&{FungibleToken.Receiver}>) {
post {
self.getBalance() == before(self.getBalance()) - amount:
"New Vault balance from the sender must be the difference of the previous balance and the withdrawn Vault balance"
//FungibleToken.emitTransferEvent(amount: amount, from: self.owner?.address, to: receiver.borrow()?.owner?.address, type: self.getType().identifier)
}
}

/// createEmptyVault allows any user to create a new Vault that has a zero balance
///
access(all) fun createEmptyVault(): @{Vault} {
Expand Down
Loading

0 comments on commit b77ea96

Please sign in to comment.