Skip to content

Commit a59ff6c

Browse files
fix hybrid custody nft withdrawal example transaction (#1123)
1 parent 657a36a commit a59ff6c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/build/guides/account-linking/parent-accounts.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ transaction(
360360
withdrawID: UInt64 // ID of the NFT to withdraw
361361
) {
362362
363-
let providerRef: &{NonFungibleToken.Provider}
363+
let providerRef: auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Provider}
364364
365365
prepare(signer: auth(BorrowValue) &Account) {
366366
// Get a reference to the signer's HybridCustody.Manager from storage
@@ -377,7 +377,7 @@ transaction(
377377
let controllerID = account.getControllerIDForType(
378378
type: collectionType,
379379
forPath: storagePath
380-
) ?? panic("Could not find Capability controller ID for collection type ".concat(type.identifier)
380+
) ?? panic("Could not find Capability controller ID for collection type ".concat(collectionType.identifier)
381381
.concat(" at path ").concat(storagePath.toString()))
382382
383383
// Get a reference to the child NFT Provider and assign to the transaction scope variable
@@ -388,7 +388,8 @@ transaction(
388388
389389
// We'll need to cast the Capability - this is possible thanks to CapabilityFactory, though we'll rely on the relevant
390390
// Factory having been configured for this Type or it won't be castable
391-
self.providerRef = cap as! Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Provider}>
391+
let providerCap = cap as! Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Provider}>
392+
self.providerRef = providerCap.borrow() ?? panic("Provider capability is invalid - cannot borrow reference")
392393
}
393394
394395
execute {
@@ -400,6 +401,9 @@ transaction(
400401
// ...
401402
}
402403
}
404+
405+
406+
403407
```
404408

405409
At the end of this transaction, you withdrew an NFT from the specified account using an NFT `Provider` Capability. A

0 commit comments

Comments
 (0)