@@ -91,26 +91,18 @@ public final class AccountAllowanceApproveTransaction: Transaction {
9191 public func approveTokenNftAllowance(
9292 _ nftId: NftId ,
9393 _ ownerAccountId: AccountId ,
94- _ spenderAccountId: AccountId
94+ _ spenderAccountId: AccountId ,
95+ _ delegatingSpenderAccountId: AccountId ? = nil
9596 ) -> Self {
96- ensureNotFrozen ( )
97-
98- if var allowance = nftAllowances. first ( where: { ( allowance) in
99- allowance. tokenId == nftId. tokenId && allowance. spenderAccountId == spenderAccountId
100- && allowance. ownerAccountId == ownerAccountId && allowance. approvedForAll == nil
101- } ) {
102- allowance. serials. append ( nftId. serial)
103- } else {
104- nftAllowances. append (
105- TokenNftAllowance (
106- tokenId: nftId. tokenId,
107- ownerAccountId: ownerAccountId,
108- spenderAccountId: spenderAccountId,
109- serials: [ nftId. serial] ,
110- approvedForAll: nil ,
111- delegatingSpenderAccountId: nil
112- ) )
113- }
97+ nftAllowances. append (
98+ TokenNftAllowance (
99+ tokenId: nftId. tokenId,
100+ ownerAccountId: ownerAccountId,
101+ spenderAccountId: spenderAccountId,
102+ serials: [ nftId. serial] ,
103+ approvedForAll: nil ,
104+ delegatingSpenderAccountId: delegatingSpenderAccountId
105+ ) )
114106
115107 return self
116108 }
@@ -136,6 +128,27 @@ public final class AccountAllowanceApproveTransaction: Transaction {
136128 return self
137129 }
138130
131+ /// Delete the NFT allowance on all serial numbers (present and future).
132+ @discardableResult
133+ public func deleteTokenNftAllowanceAllSerials(
134+ _ tokenId: TokenId ,
135+ _ ownerAccountId: AccountId ,
136+ _ spenderAccountId: AccountId
137+ ) -> Self {
138+
139+ nftAllowances. append (
140+ TokenNftAllowance (
141+ tokenId: tokenId,
142+ ownerAccountId: ownerAccountId,
143+ spenderAccountId: spenderAccountId,
144+ serials: [ ] ,
145+ approvedForAll: false ,
146+ delegatingSpenderAccountId: nil
147+ ) )
148+
149+ return self
150+ }
151+
139152 public func getNftApprovals( ) -> [ TokenNftAllowance ] {
140153 self . nftAllowances
141154 }
0 commit comments