@@ -188,15 +188,15 @@ access(all) contract DeFiActions {
188188 /// each inner component in the stack.
189189 access (all ) fun getComponentInfo (): ComponentInfo
190190 /// Returns a copy of the struct's UniqueIdentifier, used in extending a stack to identify another connector in
191- /// a DeFiActions stack. See DeFiActions.align() for more information.
191+ /// a DeFiActions stack. See DeFiActions.align* functions for more information.
192192 access (contract ) view fun copyID (): UniqueIdentifier ? {
193193 post {
194194 result ?. id == self .uniqueID ?. id :
195195 " UniqueIdentifier of \( self .getType ().identifier ) was not successfully copied"
196196 }
197197 }
198198 /// Sets the UniqueIdentifier of this component to the provided UniqueIdentifier, used in extending a stack to
199- /// identify another connector in a DeFiActions stack. See DeFiActions.align() for more information.
199+ /// identify another connector in a DeFiActions stack. See DeFiActions.align* functions for more information.
200200 access (contract ) fun setID (_ id : UniqueIdentifier ? ) {
201201 post {
202202 self .uniqueID ?. id == id ?. id :
@@ -230,15 +230,15 @@ access(all) contract DeFiActions {
230230 /// each inner component in the stack.
231231 access (all ) fun getComponentInfo (): ComponentInfo
232232 /// Returns a copy of the struct's UniqueIdentifier, used in extending a stack to identify another connector in
233- /// a DeFiActions stack. See DeFiActions.align() for more information.
233+ /// a DeFiActions stack. See DeFiActions.align* functions for more information.
234234 access (contract ) view fun copyID (): UniqueIdentifier ? {
235235 post {
236236 result ?. id == self .uniqueID ?. id :
237237 " UniqueIdentifier of \( self .getType ().identifier ) was not successfully copied"
238238 }
239239 }
240240 /// Sets the UniqueIdentifier of this component to the provided UniqueIdentifier, used in extending a stack to
241- /// identify another connector in a DeFiActions stack. See DeFiActions.align() for more information.
241+ /// identify another connector in a DeFiActions stack. See DeFiActions.align* functions for more information.
242242 access (contract ) fun setID (_ id : UniqueIdentifier ? ) {
243243 post {
244244 self .uniqueID ?. id == id ?. id :
@@ -544,12 +544,12 @@ access(all) contract DeFiActions {
544544 )
545545 }
546546 /// Returns a copy of the struct's UniqueIdentifier, used in extending a stack to identify another connector in
547- /// a DeFiActions stack. See DeFiActions.align() for more information.
547+ /// a DeFiActions stack. See DeFiActions.align* functions for more information.
548548 access (contract ) view fun copyID (): UniqueIdentifier ? {
549549 return self .uniqueID
550550 }
551551 /// Sets the UniqueIdentifier of this component to the provided UniqueIdentifier, used in extending a stack to
552- /// identify another connector in a DeFiActions stack. See DeFiActions.align() for more information.
552+ /// identify another connector in a DeFiActions stack. See DeFiActions.align* functions for more information.
553553 access (contract ) fun setID (_ id : UniqueIdentifier ? ) {
554554 self .uniqueID = id
555555 }
@@ -610,12 +610,12 @@ access(all) contract DeFiActions {
610610 )
611611 }
612612 /// Returns a copy of the struct's UniqueIdentifier, used in extending a stack to identify another connector in
613- /// a DeFiActions stack. See DeFiActions.align() for more information.
613+ /// a DeFiActions stack. See DeFiActions.align* functions for more information.
614614 access (contract ) view fun copyID (): UniqueIdentifier ? {
615615 return self .uniqueID
616616 }
617617 /// Sets the UniqueIdentifier of this component to the provided UniqueIdentifier, used in extending a stack to
618- /// identify another connector in a DeFiActions stack. See DeFiActions.align() for more information.
618+ /// identify another connector in a DeFiActions stack. See DeFiActions.align* functions for more information.
619619 access (contract ) fun setID (_ id : UniqueIdentifier ? ) {
620620 self .uniqueID = id
621621 }
@@ -901,10 +901,12 @@ access(all) contract DeFiActions {
901901 /// value will not rebalance
902902 ///
903903 access (Set ) fun setSink (_ sink : {Sink }? , updateSinkID : Bool ) {
904- if sink ! = nil && updateSinkID {
905- let toUpdate = &sink ! as auth (Extend ) &{IdentifiableStruct }
906- let toAlign = &self as auth (Identify ) &{IdentifiableResource }
907- DeFiActions .alignID (toUpdate : toUpdate , with : toAlign )
904+ if updateSinkID {
905+ if let sink = sink {
906+ let toUpdate = &sink as auth (Extend ) &{IdentifiableStruct }
907+ let toAlign = &self as auth (Identify ) &{IdentifiableResource }
908+ DeFiActions .alignStructIDWithResource (toUpdate : toUpdate , with : toAlign )
909+ }
908910 }
909911 self ._rebalanceSink = sink
910912 }
@@ -915,10 +917,12 @@ access(all) contract DeFiActions {
915917 /// value will not rebalance
916918 ///
917919 access (Set ) fun setSource (_ source : {Source }? , updateSourceID : Bool ) {
918- if source ! = nil && updateSourceID {
919- let toUpdate = &source ! as auth (Extend ) &{IdentifiableStruct }
920- let toAlign = &self as auth (Identify ) &{IdentifiableResource }
921- DeFiActions .alignID (toUpdate : toUpdate , with : toAlign )
920+ if updateSourceID {
921+ if let source = source {
922+ let toUpdate = &source as auth (Extend ) &{IdentifiableStruct }
923+ let toAlign = &self as auth (Identify ) &{IdentifiableResource }
924+ DeFiActions .alignStructIDWithResource (toUpdate : toUpdate , with : toAlign )
925+ }
922926 }
923927 self ._rebalanceSource = source
924928 }
@@ -1407,32 +1411,36 @@ access(all) contract DeFiActions {
14071411 return " DeFiActionAutoBalancer_\( vaultType .identifier ) "
14081412 }
14091413
1410- /// Aligns the UniqueIdentifier of the provided component with the provided component, setting the UniqueIdentifier of
1411- /// the provided component to the UniqueIdentifier of the provided component. Parameters are AnyStruct to allow for
1412- /// alignment of both IdentifiableStruct and IdentifiableResource. However, note that the provided component must
1413- /// be an auth(Extend) &{IdentifiableStruct} or auth(Extend) &{IdentifiableResource} to be aligned.
1414- ///
1415- /// @param toUpdate: The component to update the UniqueIdentifier of. Must be an auth(Extend) &{IdentifiableStruct}
1416- /// or auth(Extend) &{IdentifiableResource}
1417- /// @param with: The component to align the UniqueIdentifier of the provided component with. Must be an
1418- /// auth(Identify) &{IdentifiableStruct} or auth(Identify) &{IdentifiableResource}
1419- ///
1420- access (all ) fun alignID (toUpdate : AnyStruct , with : AnyStruct ) {
1421- let maybeISToUpdate = toUpdate as ? auth (Extend ) &{IdentifiableStruct }
1422- let maybeIRToUpdate = toUpdate as ? auth (Extend ) &{IdentifiableResource }
1423- let maybeISWith = with as ? auth (Identify ) &{IdentifiableStruct }
1424- let maybeIRWith = with as ? auth (Identify ) &{IdentifiableResource }
1425-
1426- if maybeISToUpdate ! = nil && maybeISWith ! = nil {
1427- maybeISToUpdate ! .setID (maybeISWith ! .copyID ())
1428- } else if maybeISToUpdate ! = nil && maybeIRWith ! = nil {
1429- maybeISToUpdate ! .setID (maybeIRWith ! .copyID ())
1430- } else if maybeIRToUpdate ! = nil && maybeISWith ! = nil {
1431- maybeIRToUpdate ! .setID (maybeISWith ! .copyID ())
1432- } else if maybeIRToUpdate ! = nil && maybeIRWith ! = nil {
1433- maybeIRToUpdate ! .setID (maybeIRWith ! .copyID ())
1434- }
1435- return
1414+ /// Aligns the UniqueIdentifier of the target IdentifiableStruct with the source IdentifiableStruct
1415+ access (all ) fun alignStructIDWithStruct (
1416+ toUpdate target : auth (Extend ) &{IdentifiableStruct },
1417+ with source : auth (Identify ) &{IdentifiableStruct }
1418+ ) {
1419+ target .setID (source .copyID ())
1420+ }
1421+
1422+ /// Aligns the UniqueIdentifier of the target IdentifiableStruct with the source IdentifiableResource
1423+ access (all ) fun alignStructIDWithResource (
1424+ toUpdate target : auth (Extend ) &{IdentifiableStruct },
1425+ with source : auth (Identify ) &{IdentifiableResource }
1426+ ) {
1427+ target .setID (source .copyID ())
1428+ }
1429+
1430+ /// Aligns the UniqueIdentifier of the target IdentifiableResource with the source IdentifiableStruct
1431+ access (all ) fun alignResourceIDWithStruct (
1432+ toUpdate target : auth (Extend ) &{IdentifiableResource },
1433+ with source : auth (Identify ) &{IdentifiableStruct }
1434+ ) {
1435+ target .setID (source .copyID ())
1436+ }
1437+
1438+ /// Aligns the UniqueIdentifier of the target IdentifiableResource with the source IdentifiableResource
1439+ access (all ) fun alignResourceIDWithResource (
1440+ toUpdate target : auth (Extend ) &{IdentifiableResource },
1441+ with source : auth (Identify ) &{IdentifiableResource }
1442+ ) {
1443+ target .setID (source .copyID ())
14361444 }
14371445
14381446 /* --- INTERNAL CONDITIONAL EVENT EMITTERS --- */
0 commit comments