Skip to content

Commit 65c59eb

Browse files
committed
address PR comments with small formatting changes
1 parent ab58bbf commit 65c59eb

30 files changed

+151
-145
lines changed

contracts/FungibleToken.cdc

+16-16
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ access(all) contract interface FungibleToken: ViewResolver {
182182
}
183183
post {
184184
self.balance == 0.0:
185-
"FungibleToken.Vault.burnCallback: Cannot burn this Vault with Burner.burn()."
186-
.concat("The balance must be set to zero during the burnCallback method so that it cannot be spammed")
185+
"FungibleToken.Vault.burnCallback: Cannot burn this Vault with Burner.burn(). "
186+
.concat("The balance must be set to zero during the burnCallback method so that it cannot be spammed.")
187187
}
188188
self.balance = 0.0
189189
}
@@ -223,21 +223,21 @@ access(all) contract interface FungibleToken: ViewResolver {
223223
}
224224
post {
225225
result.getType() == self.getType():
226-
"FungibleToken.Vault.withdraw: Cannot withdraw tokens!"
226+
"FungibleToken.Vault.withdraw: Cannot withdraw tokens! "
227227
.concat("The withdraw method tried to return an incompatible Vault type <")
228228
.concat(result.getType().identifier).concat(">. ")
229-
.concat("It must return a Vault with the same type as self (")
229+
.concat("It must return a Vault with the same type as self <")
230230
.concat(self.getType().identifier).concat(">.")
231231

232232
// use the special function `before` to get the value of the `balance` field
233233
// at the beginning of the function execution
234234
//
235235
self.balance == before(self.balance) - amount:
236-
"FungibleToken.Vault.withdraw: Cannot withdraw tokens!"
236+
"FungibleToken.Vault.withdraw: Cannot withdraw tokens! "
237237
.concat("The sender's balance after the withdrawal (")
238238
.concat(self.balance.toString())
239239
.concat(") must be the difference of the previous balance (").concat(before(self.balance.toString()))
240-
.concat(") and the amount withdrawn (").concat(amount.toString())
240+
.concat(") and the amount withdrawn (").concat(amount.toString()).concat(")")
241241

242242
emit Withdrawn(
243243
type: result.getType().identifier,
@@ -257,12 +257,12 @@ access(all) contract interface FungibleToken: ViewResolver {
257257
// as the vault that is accepting the deposit
258258
pre {
259259
from.isInstance(self.getType()):
260-
"FungibleToken.Vault.deposit: Cannot deposit tokens!"
260+
"FungibleToken.Vault.deposit: Cannot deposit tokens! "
261261
.concat("The type of the deposited tokens <")
262262
.concat(from.getType().identifier)
263263
.concat("> has to be the same type as the Vault being deposited into <")
264264
.concat(self.getType().identifier)
265-
.concat(">. Check that you are withdrawing and depositing to the correct paths in the sender and receiver accounts")
265+
.concat(">. Check that you are withdrawing and depositing to the correct paths in the sender and receiver accounts ")
266266
.concat("and that those paths hold the same Vault types.")
267267
}
268268
post {
@@ -275,11 +275,11 @@ access(all) contract interface FungibleToken: ViewResolver {
275275
balanceAfter: self.balance
276276
)
277277
self.balance == before(self.balance) + before(from.balance):
278-
"FungibleToken.Vault.deposit: Cannot deposit tokens!"
278+
"FungibleToken.Vault.deposit: Cannot deposit tokens! "
279279
.concat("The receiver's balance after the deposit (")
280280
.concat(self.balance.toString())
281281
.concat(") must be the sum of the previous balance (").concat(before(self.balance.toString()))
282-
.concat(") and the amount deposited (").concat(before(from.balance).toString())
282+
.concat(") and the amount deposited (").concat(before(from.balance).toString()).concat(")")
283283
}
284284
}
285285

@@ -289,12 +289,12 @@ access(all) contract interface FungibleToken: ViewResolver {
289289
access(all) fun createEmptyVault(): @{Vault} {
290290
post {
291291
result.balance == 0.0:
292-
"FungibleToken.Vault.createEmptyVault: Empty Vault creation failed!"
292+
"FungibleToken.Vault.createEmptyVault: Empty Vault creation failed! "
293293
.concat("The newly created Vault must have zero balance but it has a balance of ")
294294
.concat(result.balance.toString())
295295

296296
result.getType() == self.getType():
297-
"FungibleToken.Vault.createEmptyVault: Empty Vault creation failed!"
297+
"FungibleToken.Vault.createEmptyVault: Empty Vault creation failed! "
298298
.concat("The type of the new Vault <")
299299
.concat(result.getType().identifier)
300300
.concat("> has to be the same type as the Vault that created it <")
@@ -310,12 +310,12 @@ access(all) contract interface FungibleToken: ViewResolver {
310310
access(all) fun createEmptyVault(vaultType: Type): @{FungibleToken.Vault} {
311311
post {
312312
result.balance == 0.0:
313-
"FungibleToken.createEmptyVault: Empty Vault creation failed!"
314-
.concat("The newly created Vault must have zero balance but it has a balance of ")
315-
.concat(result.balance.toString())
313+
"FungibleToken.createEmptyVault: Empty Vault creation failed! "
314+
.concat("The newly created Vault must have zero balance but it has a balance of (")
315+
.concat(result.balance.toString()).concat(")")
316316

317317
result.getType() == vaultType:
318-
"FungibleToken.Vault.createEmptyVault: Empty Vault creation failed!"
318+
"FungibleToken.Vault.createEmptyVault: Empty Vault creation failed! "
319319
.concat("The type of the new Vault <")
320320
.concat(result.getType().identifier)
321321
.concat("> has to be the same as the type that was requested <")

contracts/FungibleTokenSwitchboard.cdc

+14-9
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ access(all) contract FungibleTokenSwitchboard {
6767
// Borrow a reference to the vault pointed to by the capability we
6868
// want to store inside the switchboard
6969
let vaultRef = capability.borrow()
70-
?? panic("FungibleTokenSwitchboard.Switchboard.addNewVault: Cannot borrow reference to vault from capability"
71-
.concat("Make sure that the capability path points to a Vault that has been properly initialized"))
70+
?? panic("FungibleTokenSwitchboard.Switchboard.addNewVault: Cannot borrow reference to vault from capability! "
71+
.concat("Make sure that the capability path points to a Vault that has been properly initialized. "))
7272

73-
// Check if there is a previous capability for this token, if not
73+
// Check if there is a previous capability for this token
7474
if (self.receiverCapabilities[vaultRef.getType()] == nil) {
7575
// use the vault reference type as key for storing the
7676
// capability and then
@@ -80,6 +80,11 @@ access(all) contract FungibleTokenSwitchboard {
8080
emit VaultCapabilityAdded(type: vaultRef.getType(),
8181
switchboardOwner: self.owner?.address,
8282
capabilityOwner: capability.address)
83+
} else {
84+
// If there was already a capability for that token, panic
85+
panic("FungibleTokenSwitchboard.Switchboard.addNewVault: Cannot add new Vault capability! "
86+
.concat("There is already a vault in the Switchboard for this type <")
87+
.concat(vaultRef.getType().identifier).concat(">."))
8388
}
8489
}
8590

@@ -137,8 +142,8 @@ access(all) contract FungibleTokenSwitchboard {
137142
assert (
138143
capability.check(),
139144
message:
140-
"FungibleTokenSwitchboard.Switchboard.addNewVaultWrapper: Cannot borrow reference to a vault from the provided capability"
141-
.concat("Make sure that the capability path points to a Vault that has been properly initialized")
145+
"FungibleTokenSwitchboard.Switchboard.addNewVaultWrapper: Cannot borrow reference to a vault from the provided capability! "
146+
.concat("Make sure that the capability path points to a Vault that has been properly initialized.")
142147
)
143148
// Use the type parameter as key for the capability
144149
self.receiverCapabilities[type] = capability
@@ -196,8 +201,8 @@ access(all) contract FungibleTokenSwitchboard {
196201
// Borrow a reference to the vault pointed to by the capability we
197202
// want to remove from the switchboard
198203
let vaultRef = capability.borrow()
199-
?? panic ("FungibleTokenSwitchboard.Switchboard.addNewVaultWrapper: Cannot borrow reference to a vault from the provided capability"
200-
.concat("Make sure that the capability path points to a Vault that has been properly initialized"))
204+
?? panic ("FungibleTokenSwitchboard.Switchboard.addNewVaultWrapper: Cannot borrow reference to a vault from the provided capability! "
205+
.concat("Make sure that the capability path points to a Vault that has been properly initialized."))
201206

202207
// Use the vault reference to find the capability to remove
203208
self.receiverCapabilities.remove(key: vaultRef.getType())
@@ -225,9 +230,9 @@ access(all) contract FungibleTokenSwitchboard {
225230

226231
// Borrow the reference to the desired vault
227232
let vaultRef = depositedVaultCapability.borrow()
228-
?? panic ("FungibleTokenSwitchboard.Switchboard.deposit: Cannot borrow reference to a vault"
233+
?? panic ("FungibleTokenSwitchboard.Switchboard.deposit: Cannot borrow reference to a vault "
229234
.concat("from the type of the deposited Vault <").concat(from.getType().identifier)
230-
.concat(">. Make sure that the capability path points to a Vault that has been properly initialized"))
235+
.concat(">. Make sure that the capability path points to a Vault that has been properly initialized."))
231236

232237
vaultRef.deposit(from: <-from)
233238
}

contracts/utility/PrivateReceiverForwarder.cdc

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ access(all) contract PrivateReceiverForwarder {
4646
init(recipient: Capability<&{FungibleToken.Receiver}>) {
4747
pre {
4848
recipient.borrow() != nil:
49-
"PrivateReceiverForwarder.Forwarder.init: Could not borrow a Receiver reference from the recipient Capability."
50-
.concat("The recipient needs to have the correct Fungible Token Vault initialized in their account with a public Receiver Capability")
49+
"PrivateReceiverForwarder.Forwarder.init: Could not borrow a Receiver reference from the recipient Capability. "
50+
.concat("The recipient needs to have the correct Fungible Token Vault initialized in their account with a public Receiver Capability.")
5151
}
5252
self.recipient = recipient
5353
}

contracts/utility/TokenForwarding.cdc

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ access(all) contract TokenForwarding {
8989
"TokenForwarding.Forwarder.changeRecipient: Could not borrow a Receiver reference from the new Capability. "
9090
.concat("This is likely because the recipient account ")
9191
.concat(newRecipient.address.toString())
92-
.concat(" has not set up the FungibleToken Vault or public capability correctly.")
93-
.concat("Verify that the address is correct and the account has the correct Vault and capability")
92+
.concat(" has not set up the FungibleToken Vault or public capability correctly. ")
93+
.concat("Verify that the address is correct and the account has the correct Vault and capability.")
9494
}
9595
let newRef = newRecipient.borrow<&{FungibleToken.Receiver}>()!
9696
let oldRef = self.recipient.borrow<&{FungibleToken.Receiver}>()!
@@ -127,8 +127,8 @@ access(all) contract TokenForwarding {
127127
"TokenForwarding.Forwarder.changeRecipient: Could not borrow a Receiver reference from the Capability. "
128128
.concat("This is likely because the recipient account ")
129129
.concat(recipient.address.toString())
130-
.concat(" has not set up the FungibleToken Vault or public capability correctly.")
131-
.concat("Verify that the address is correct and the account has the correct Vault and capability")
130+
.concat(" has not set up the FungibleToken Vault or public capability correctly. ")
131+
.concat("Verify that the address is correct and the account has the correct Vault and capability. ")
132132
}
133133
self.recipient = recipient
134134
}

0 commit comments

Comments
 (0)