Skip to content

Commit 1901282

Browse files
authored
Crescendo (#48)
* upgrade all LostAndFound contracts to Crescendo
1 parent 384d57c commit 1901282

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+945
-823
lines changed

.github/workflows/unit-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install Flow dependencies
2727
run: npm i
2828
- name: Install Flow CLI
29-
run: bash -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.10.0
29+
run: bash -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)"
3030
- name: Run tests
3131
run: |
3232
./run-tests.sh

codecov.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ignore:
2+
- "contracts/standard/ExampleToken.cdc"
3+
- "contracts/standard/ExampleNFT.cdc"

contracts/FeeEstimator.cdc

+14-22
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,41 @@ import "FlowToken"
1111
1212
Consumers of this contract would then need to pop the resource out of the DepositEstimate resource to get it back
1313
*/
14-
pub contract FeeEstimator {
15-
pub resource DepositEstimate {
16-
pub var item: @AnyResource?
17-
pub var storageFee: UFix64
14+
access(all) contract FeeEstimator {
15+
access(all) resource DepositEstimate {
16+
access(all) var item: @AnyResource?
17+
access(all) var storageFee: UFix64
1818

1919
init(item: @AnyResource, storageFee: UFix64) {
2020
self.item <- item
2121
self.storageFee = storageFee
2222
}
2323

24-
pub fun withdraw(): @AnyResource {
25-
let resource <- self.item <- nil
26-
return <-resource!
27-
}
28-
29-
destroy() {
30-
pre {
31-
self.item == nil: "cannot destroy with non-null item"
32-
}
33-
34-
destroy self.item
24+
access(all) fun withdraw(): @AnyResource {
25+
let r <- self.item <- nil
26+
return <-r!
3527
}
3628
}
3729

38-
pub fun hasStorageCapacity(_ addr: Address, _ storageFee: UFix64): Bool {
30+
access(all) fun hasStorageCapacity(_ addr: Address, _ storageFee: UFix64): Bool {
3931
return FlowStorageFees.defaultTokenAvailableBalance(addr) > storageFee
4032
}
4133

42-
pub fun estimateDeposit(
34+
access(all) fun estimateDeposit(
4335
item: @AnyResource,
4436
): @DepositEstimate {
45-
let storageUsedBefore = FeeEstimator.account.storageUsed
46-
FeeEstimator.account.save(<-item, to: /storage/temp)
47-
let storageUsedAfter = FeeEstimator.account.storageUsed
37+
let storageUsedBefore = FeeEstimator.account.storage.used
38+
FeeEstimator.account.storage.save(<-item, to: /storage/temp)
39+
let storageUsedAfter = FeeEstimator.account.storage.used
4840

4941
let storageDiff = storageUsedAfter - storageUsedBefore
5042
let storageFee = FeeEstimator.storageUsedToFlowAmount(storageDiff)
51-
let loadedItem <- FeeEstimator.account.load<@AnyResource>(from: /storage/temp)!
43+
let loadedItem <- FeeEstimator.account.storage.load<@AnyResource>(from: /storage/temp)!
5244
let estimate <- create DepositEstimate(item: <-loadedItem, storageFee: storageFee)
5345
return <- estimate
5446
}
5547

56-
pub fun storageUsedToFlowAmount(_ storageUsed: UInt64): UFix64 {
48+
access(all) fun storageUsedToFlowAmount(_ storageUsed: UInt64): UFix64 {
5749
let storageMB = FlowStorageFees.convertUInt64StorageBytesToUFix64Megabytes(storageUsed)
5850
return FlowStorageFees.storageCapacityToFlow(storageMB)
5951
}

0 commit comments

Comments
 (0)