-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: move MigrateToL2Information out of SignOrExecute
- Loading branch information
Showing
9 changed files
with
160 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
src/components/tx/SignOrExecuteForm/UnknownContractError.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { trackEvent } from '@/services/analytics' | ||
import { TX_EVENTS } from '@/services/analytics/events/transactions' | ||
import { getTransactionTrackingType } from '@/services/analytics/tx-tracking' | ||
import { isNestedConfirmationTxInfo } from '@/utils/transaction-guards' | ||
import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' | ||
|
||
function getCreationEvent(args: { isParentSigner: boolean; isRoleExecution: boolean; isProposerCreation: boolean }) { | ||
if (args.isParentSigner) { | ||
return TX_EVENTS.CREATE_VIA_PARENT | ||
} | ||
if (args.isRoleExecution) { | ||
return TX_EVENTS.CREATE_VIA_ROLE | ||
} | ||
if (args.isProposerCreation) { | ||
return TX_EVENTS.CREATE_VIA_PROPOSER | ||
} | ||
return TX_EVENTS.CREATE | ||
} | ||
|
||
function getConfirmationEvent(args: { isParentSigner: boolean; isNestedConfirmation: boolean }) { | ||
if (args.isParentSigner) { | ||
return TX_EVENTS.CONFIRM_VIA_PARENT | ||
} | ||
if (args.isNestedConfirmation) { | ||
return TX_EVENTS.CONFIRM_IN_PARENT | ||
} | ||
return TX_EVENTS.CONFIRM | ||
} | ||
|
||
function getExecutionEvent(args: { isParentSigner: boolean; isNestedConfirmation: boolean; isRoleExecution: boolean }) { | ||
if (args.isParentSigner) { | ||
return TX_EVENTS.EXECUTE_VIA_PARENT | ||
} | ||
if (args.isNestedConfirmation) { | ||
return TX_EVENTS.EXECUTE_IN_PARENT | ||
} | ||
if (args.isRoleExecution) { | ||
return TX_EVENTS.EXECUTE_VIA_ROLE | ||
} | ||
return TX_EVENTS.EXECUTE | ||
} | ||
|
||
export function trackTxEvents( | ||
details: TransactionDetails | undefined, | ||
isCreation: boolean, | ||
isExecuted: boolean, | ||
isRoleExecution: boolean, | ||
isProposerCreation: boolean, | ||
isParentSigner: boolean, | ||
origin?: string, | ||
) { | ||
const isNestedConfirmation = !!details && isNestedConfirmationTxInfo(details.txInfo) | ||
|
||
const creationEvent = getCreationEvent({ isParentSigner, isRoleExecution, isProposerCreation }) | ||
const confirmationEvent = getConfirmationEvent({ isParentSigner, isNestedConfirmation }) | ||
const executionEvent = getExecutionEvent({ isParentSigner, isNestedConfirmation, isRoleExecution }) | ||
|
||
const event = (() => { | ||
if (isCreation) { | ||
return creationEvent | ||
} | ||
if (isExecuted) { | ||
return executionEvent | ||
} | ||
return confirmationEvent | ||
})() | ||
|
||
const txType = getTransactionTrackingType(details, origin) | ||
trackEvent({ ...event, label: txType }) | ||
|
||
// Immediate execution on creation | ||
if (isCreation && isExecuted) { | ||
trackEvent({ ...executionEvent, label: txType }) | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
...nOrExecuteForm/MigrateToL2Information.tsx → ...on-views/MigrateToL2Information/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.