@@ -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 :
@@ -547,12 +547,12 @@ access(all) contract DeFiActions {
547547 )
548548 }
549549 /// Returns a copy of the struct's UniqueIdentifier, used in extending a stack to identify another connector in
550- /// a DeFiActions stack. See DeFiActions.align() for more information.
550+ /// a DeFiActions stack. See DeFiActions.align* functions for more information.
551551 access (contract ) view fun copyID (): UniqueIdentifier ? {
552552 return self .uniqueID
553553 }
554554 /// Sets the UniqueIdentifier of this component to the provided UniqueIdentifier, used in extending a stack to
555- /// identify another connector in a DeFiActions stack. See DeFiActions.align() for more information.
555+ /// identify another connector in a DeFiActions stack. See DeFiActions.align* functions for more information.
556556 access (contract ) fun setID (_ id : UniqueIdentifier ? ) {
557557 self .uniqueID = id
558558 }
@@ -613,12 +613,12 @@ access(all) contract DeFiActions {
613613 )
614614 }
615615 /// Returns a copy of the struct's UniqueIdentifier, used in extending a stack to identify another connector in
616- /// a DeFiActions stack. See DeFiActions.align() for more information.
616+ /// a DeFiActions stack. See DeFiActions.align* functions for more information.
617617 access (contract ) view fun copyID (): UniqueIdentifier ? {
618618 return self .uniqueID
619619 }
620620 /// Sets the UniqueIdentifier of this component to the provided UniqueIdentifier, used in extending a stack to
621- /// identify another connector in a DeFiActions stack. See DeFiActions.align() for more information.
621+ /// identify another connector in a DeFiActions stack. See DeFiActions.align* functions for more information.
622622 access (contract ) fun setID (_ id : UniqueIdentifier ? ) {
623623 self .uniqueID = id
624624 }
@@ -907,10 +907,12 @@ access(all) contract DeFiActions {
907907 /// value will not rebalance
908908 ///
909909 access (Set ) fun setSink (_ sink : {Sink }? , updateSinkID : Bool ) {
910- if sink ! = nil && updateSinkID {
911- let toUpdate = &sink ! as auth (Extend ) &{IdentifiableStruct }
912- let toAlign = &self as auth (Identify ) &{IdentifiableResource }
913- DeFiActions .alignID (toUpdate : toUpdate , with : toAlign )
910+ if updateSinkID {
911+ if let sink = sink {
912+ let toUpdate = &sink as auth (Extend ) &{IdentifiableStruct }
913+ let toAlign = &self as auth (Identify ) &{IdentifiableResource }
914+ DeFiActions .alignStructIDWithResource (toUpdate : toUpdate , with : toAlign )
915+ }
914916 }
915917 self ._rebalanceSink = sink
916918 }
@@ -921,10 +923,12 @@ access(all) contract DeFiActions {
921923 /// value will not rebalance
922924 ///
923925 access (Set ) fun setSource (_ source : {Source }? , updateSourceID : Bool ) {
924- if source ! = nil && updateSourceID {
925- let toUpdate = &source ! as auth (Extend ) &{IdentifiableStruct }
926- let toAlign = &self as auth (Identify ) &{IdentifiableResource }
927- DeFiActions .alignID (toUpdate : toUpdate , with : toAlign )
926+ if updateSourceID {
927+ if let source = source {
928+ let toUpdate = &source as auth (Extend ) &{IdentifiableStruct }
929+ let toAlign = &self as auth (Identify ) &{IdentifiableResource }
930+ DeFiActions .alignStructIDWithResource (toUpdate : toUpdate , with : toAlign )
931+ }
928932 }
929933 self ._rebalanceSource = source
930934 }
@@ -1424,32 +1428,36 @@ access(all) contract DeFiActions {
14241428 return " DeFiActionAutoBalancer_\( vaultType .identifier ) "
14251429 }
14261430
1427- /// Aligns the UniqueIdentifier of the provided component with the provided component, setting the UniqueIdentifier of
1428- /// the provided component to the UniqueIdentifier of the provided component. Parameters are AnyStruct to allow for
1429- /// alignment of both IdentifiableStruct and IdentifiableResource. However, note that the provided component must
1430- /// be an auth(Extend) &{IdentifiableStruct} or auth(Extend) &{IdentifiableResource} to be aligned.
1431- ///
1432- /// @param toUpdate: The component to update the UniqueIdentifier of. Must be an auth(Extend) &{IdentifiableStruct}
1433- /// or auth(Extend) &{IdentifiableResource}
1434- /// @param with: The component to align the UniqueIdentifier of the provided component with. Must be an
1435- /// auth(Identify) &{IdentifiableStruct} or auth(Identify) &{IdentifiableResource}
1436- ///
1437- access (all ) fun alignID (toUpdate : AnyStruct , with : AnyStruct ) {
1438- let maybeISToUpdate = toUpdate as ? auth (Extend ) &{IdentifiableStruct }
1439- let maybeIRToUpdate = toUpdate as ? auth (Extend ) &{IdentifiableResource }
1440- let maybeISWith = with as ? auth (Identify ) &{IdentifiableStruct }
1441- let maybeIRWith = with as ? auth (Identify ) &{IdentifiableResource }
1442-
1443- if maybeISToUpdate ! = nil && maybeISWith ! = nil {
1444- maybeISToUpdate ! .setID (maybeISWith ! .copyID ())
1445- } else if maybeISToUpdate ! = nil && maybeIRWith ! = nil {
1446- maybeISToUpdate ! .setID (maybeIRWith ! .copyID ())
1447- } else if maybeIRToUpdate ! = nil && maybeISWith ! = nil {
1448- maybeIRToUpdate ! .setID (maybeISWith ! .copyID ())
1449- } else if maybeIRToUpdate ! = nil && maybeIRWith ! = nil {
1450- maybeIRToUpdate ! .setID (maybeIRWith ! .copyID ())
1451- }
1452- return
1431+ /// Aligns the UniqueIdentifier of the target IdentifiableStruct with the source IdentifiableStruct
1432+ access (all ) fun alignStructIDWithStruct (
1433+ toUpdate target : auth (Extend ) &{IdentifiableStruct },
1434+ with source : auth (Identify ) &{IdentifiableStruct }
1435+ ) {
1436+ target .setID (source .copyID ())
1437+ }
1438+
1439+ /// Aligns the UniqueIdentifier of the target IdentifiableStruct with the source IdentifiableResource
1440+ access (all ) fun alignStructIDWithResource (
1441+ toUpdate target : auth (Extend ) &{IdentifiableStruct },
1442+ with source : auth (Identify ) &{IdentifiableResource }
1443+ ) {
1444+ target .setID (source .copyID ())
1445+ }
1446+
1447+ /// Aligns the UniqueIdentifier of the target IdentifiableResource with the source IdentifiableStruct
1448+ access (all ) fun alignResourceIDWithStruct (
1449+ toUpdate target : auth (Extend ) &{IdentifiableResource },
1450+ with source : auth (Identify ) &{IdentifiableStruct }
1451+ ) {
1452+ target .setID (source .copyID ())
1453+ }
1454+
1455+ /// Aligns the UniqueIdentifier of the target IdentifiableResource with the source IdentifiableResource
1456+ access (all ) fun alignResourceIDWithResource (
1457+ toUpdate target : auth (Extend ) &{IdentifiableResource },
1458+ with source : auth (Identify ) &{IdentifiableResource }
1459+ ) {
1460+ target .setID (source .copyID ())
14531461 }
14541462
14551463 /* --- INTERNAL CONDITIONAL EVENT EMITTERS --- */
0 commit comments