TransactionSEALED
□▓▒░~$╳▫*╱!^$▓█*%%░@▓?*%*□^◇$●◆◇%&▪◇*▪^#▫!^^?╱◆?~*╱█╲□^*!╲○◆^□◇╳
Transaction ID
Execution Fee
0.00234 FLOWTransaction Summary
Contract Call
Called FungibleToken, NonFungibleToken, EVMVMBridgedToken_99af3eea856556646c98c8b9b2548fe815240750 +3 more
Script Arguments
Copy:
0sellAmountUFix64
6.55000000
1askTokenTypeIdentifierString
2askAmountUFix64
110.00000000
3durationUFix64
0.00000000
Cadence Script
1import FungibleToken from 0xf233dcee88fe0abe
2 import NonFungibleToken from 0x1d7e57aa55817448
3 import EVMVMBridgedToken_99af3eea856556646c98c8b9b2548fe815240750 from 0x1e4aa0b87d10b141
4 import FlowToken from 0x1654653399040a61
5 import D3SKOfferNFT from 0x5ec90e3dcf0067c4
6 import D3SKFillProxy from 0x5ec90e3dcf0067c4
7
8 transaction(sellAmount: UFix64, askTokenTypeIdentifier: String, askAmount: UFix64, duration: UFix64) {
9 prepare(signer: auth(BorrowValue, SaveValue, LoadValue, IssueStorageCapabilityController, PublishCapability, UnpublishCapability) &Account) {
10 // Calculate expiration
11 var expiresAt: UFix64? = nil
12 if duration > 0.0 {
13 expiresAt = getCurrentBlock().timestamp + duration
14 }
15
16 // Setup NFT Collection if not already in storage
17 if signer.storage.borrow<&D3SKOfferNFT.Collection>(from: D3SKOfferNFT.CollectionStoragePath) == nil {
18 signer.storage.save(<- D3SKOfferNFT.createEmptyCollection(nftType: Type<@D3SKOfferNFT.NFT>()), to: D3SKOfferNFT.CollectionStoragePath)
19 }
20 // Publish NFT collection capability if not already published
21 if !signer.capabilities.get<&D3SKOfferNFT.Collection>(D3SKOfferNFT.CollectionPublicPath).check() {
22 signer.capabilities.unpublish(D3SKOfferNFT.CollectionPublicPath)
23 let colCap = signer.capabilities.storage.issue<&D3SKOfferNFT.Collection>(D3SKOfferNFT.CollectionStoragePath)
24 signer.capabilities.publish(colCap, at: D3SKOfferNFT.CollectionPublicPath)
25 }
26
27 // Setup FillProxy — stores auth(Fill) capability privately inside a resource,
28 // then publishes non-auth &Proxy so takers can call fillOffer without auth
29 if signer.storage.borrow<&D3SKFillProxy.Proxy>(from: D3SKFillProxy.ProxyStoragePath) == nil {
30 let fillCap = signer.capabilities.storage.issue<auth(D3SKOfferNFT.Fill) &D3SKOfferNFT.Collection>(D3SKOfferNFT.CollectionStoragePath)
31 let proxy <- D3SKFillProxy.createProxy(cap: fillCap)
32 signer.storage.save(<-proxy, to: D3SKFillProxy.ProxyStoragePath)
33
34 signer.capabilities.unpublish(D3SKFillProxy.ProxyPublicPath)
35 let proxyCap = signer.capabilities.storage.issue<&D3SKFillProxy.Proxy>(D3SKFillProxy.ProxyStoragePath)
36 signer.capabilities.publish(proxyCap, at: D3SKFillProxy.ProxyPublicPath)
37 }
38
39 // Ensure maker has ask token vault (so taker can pay them on fill)
40 if signer.storage.borrow<&{FungibleToken.Receiver}>(from: /storage/flowTokenVault) == nil {
41 let emptyVault <- FlowToken.createEmptyVault(vaultType: Type<@FlowToken.Vault>())
42 signer.storage.save(<-emptyVault, to: /storage/flowTokenVault)
43 let receiverCap = signer.capabilities.storage.issue<&{FungibleToken.Receiver}>(/storage/flowTokenVault)
44 signer.capabilities.publish(receiverCap, at: /public/flowTokenReceiver)
45 }
46
47 // Withdraw sell tokens
48 let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdraw) &EVMVMBridgedToken_99af3eea856556646c98c8b9b2548fe815240750.Vault>(
49 from: /storage/EVMVMBridgedToken_99af3eea856556646c98c8b9b2548fe815240750Vault
50 ) ?? panic("Could not borrow sell token vault")
51 let sellVault <- vaultRef.withdraw(amount: sellAmount)
52
53 let askType = CompositeType(askTokenTypeIdentifier)
54 ?? panic("Invalid ask token type")
55
56 // Mint offer NFT (also registers with D3SKRegistry)
57 let offerNFT <- D3SKOfferNFT.mintOffer(
58 sellVault: <-sellVault,
59 askTokenType: askType,
60 askAmount: askAmount,
61 makerAddress: signer.address,
62 expiresAt: expiresAt
63 )
64
65 // Deposit the NFT into signer's collection
66 let collectionRef = signer.storage.borrow<&D3SKOfferNFT.Collection>(
67 from: D3SKOfferNFT.CollectionStoragePath
68 ) ?? panic("Could not borrow collection")
69 collectionRef.deposit(token: <-offerNFT)
70 }
71 }