Skip to content

Commit

Permalink
update dependencies and add public burn tokens method
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Dec 4, 2023
1 parent b41a334 commit f8dfacb
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 44 deletions.
30 changes: 10 additions & 20 deletions contracts/FlowToken.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,6 @@ access(all) contract FlowToken: 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)
}

destroy() {
if self.balance > 0.0 {
FlowToken.totalSupply = FlowToken.totalSupply - self.balance
}
}

/// Get all the Metadata Views implemented by FlowToken
///
/// @return An array of Types defining the implemented views. This value will be used by
Expand Down Expand Up @@ -275,9 +258,16 @@ access(all) contract FlowToken: ViewResolver {
// total supply in the Vault destructor.
//
access(all) fun burnTokens(from: @FlowToken.Vault) {
let vault <- from as! @FlowToken.Vault
let amount = vault.balance
destroy vault
FlowToken.burnTokens(from: <-from)
}
}

access(all) fun burnTokens(from: @FlowToken.Vault) {
let vault <- from as! @FlowToken.Vault
let amount = vault.balance
destroy vault
if amount > 0.0 {
FlowToken.totalSupply = FlowToken.totalSupply - amount
emit TokensBurned(amount: amount)
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/go/contracts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.18

require (
github.com/kevinburke/go-bindata v3.23.0+incompatible
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231121165523-9e68e5a6ce6a
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231201182806-a95f9ec50b08
github.com/onflow/flow-go-sdk v0.44.0-stable-cadence.2
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231120214141-b11e79f1bb27
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231204201122-eb1dd9560768
github.com/stretchr/testify v1.8.4
)

Expand Down
4 changes: 4 additions & 0 deletions lib/go/contracts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ github.com/onflow/cadence v1.0.0-preview.1 h1:Y/q/43aDc93/1Atsxx3+e2V/dZiQuF1Tqk
github.com/onflow/cadence v1.0.0-preview.1/go.mod h1:Q5Up9Kt+J6zuAFmgrsiKz6t//E/hR5/iuVjH62pdztk=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231121165523-9e68e5a6ce6a h1:pDUUKxDmHpO7P7lRUu2Niq0VbCcKU9IWEHclbTI37m0=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231121165523-9e68e5a6ce6a/go.mod h1:uugR8U8Rlk2Xbn1ne7WWkPIcLReOyyXeQ/6tBg2Lsu8=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231201182806-a95f9ec50b08 h1:52o4zeQlBhn0EGkg/AWudypTYKr4nmKkT5qxfD0L9Hw=
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231201182806-a95f9ec50b08/go.mod h1:uugR8U8Rlk2Xbn1ne7WWkPIcLReOyyXeQ/6tBg2Lsu8=
github.com/onflow/flow-go-sdk v0.41.7-stable-cadence/go.mod h1:ejVN+bqcsTHVvRpDDJDoBNdmcxUfFMW4IvdTbMeQ/hQ=
github.com/onflow/flow-go-sdk v0.44.0-stable-cadence.2 h1:vUVO6m85BiT8c50Oc8YGc3CU+sGqiKW9FZbmiRph2dU=
github.com/onflow/flow-go-sdk v0.44.0-stable-cadence.2/go.mod h1:mbLrR3MkYbi9LH3yasDj1jrR4QTR8vjRLVFCm4jMHn0=
Expand All @@ -895,6 +897,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20230921055127-6493dc1ba948
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20230921055127-6493dc1ba948/go.mod h1:cWMAsK1grBHKPIKxYVUv2rX+Nz0Ttq+PEQz4OjqCmpU=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231120214141-b11e79f1bb27 h1:qm4ErSz3B3lsdVy/usLYpLvpzibbG6xQTkxAIcmYuDs=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231120214141-b11e79f1bb27/go.mod h1:OKA2xWNugqqbaFSmxdb1VWixtuqSdz/VK1MlbdcIUxw=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231204201122-eb1dd9560768 h1:MxeL05qV/fKEkrQhAmjJ8D9W2r8BuKfpljc1EOlg1q4=
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231204201122-eb1dd9560768/go.mod h1:OKA2xWNugqqbaFSmxdb1VWixtuqSdz/VK1MlbdcIUxw=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20221202093946-932d1c70e288/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8=
github.com/onflow/sdks v0.5.0/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
Expand Down
6 changes: 3 additions & 3 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/go/test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ require (
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f // indirect
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231121165523-9e68e5a6ce6a // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231120214141-b11e79f1bb27 // indirect
github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20231201182806-a95f9ec50b08 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20231204201122-eb1dd9560768 // indirect
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230628215638-83439d22e0ce // indirect
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
Expand Down
Loading

0 comments on commit f8dfacb

Please sign in to comment.