Skip to content

Commit

Permalink
make sure to not loose waypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Jan 16, 2025
1 parent d73211f commit 047f139
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion packages/modules/src/updateAvatar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ describe('updateAvatar', () => {
})

describe('Account', () => {
it('keeps existing waypoints', () => {
const currentSafe = randomAddress()

const startingPoint = createMockStartingWaypoint()
const roleWaypoint = createMockRoleWaypoint()

const route = createMockExecutionRoute({
avatar: formatPrefixedAddress(Chain.ETH, currentSafe),
waypoints: [startingPoint, roleWaypoint],
})

const safe = randomAddress()

const updatedRoute = updateAvatar(route, { safe })

expect(updatedRoute.waypoints).toEqual([
startingPoint,
roleWaypoint,
expect.anything(),
])
})

it('updates an existing safe endpoint', () => {
const currentSafe = randomAddress()

Expand Down Expand Up @@ -120,7 +142,7 @@ describe('updateAvatar', () => {

const updatedRoute = updateAvatar(route, { safe })

const [updatedWaypoint] = getWaypoints(updatedRoute)
const [, updatedWaypoint] = getWaypoints(updatedRoute)

expect(updatedWaypoint.connection).toEqual({
from: formatPrefixedAddress(Chain.GNO, moduleAddress),
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/src/updateAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const updateEndWaypoint = (

return {
...route,
waypoints: [startingPoint, updatedWaypoint],
waypoints: [startingPoint, ...waypoints, updatedWaypoint],
}
}

Expand Down

0 comments on commit 047f139

Please sign in to comment.