Skip to content

Commit

Permalink
feat: integrate with divvy protocol (#6492)
Browse files Browse the repository at this point in the history
### Description

This PR integrates the divvy protocol into the transaction flows:
1. the registration transaction is calculated and added to the prepared
transactions the user will send so that the network fee quoted to the
user can include the registration transaction
2. the registration transaction is sent first, before the rest of the
prepared transactions

### Test plan

1. the registration is completed with the user's first transaction
3. on wallet restore, the registration is not done again
4. the transaction flows continue to work without any user facing
changes

### Related issues

- Fixes RET-1318

### Backwards compatibility

Y

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [ ] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
  • Loading branch information
kathaypacific authored Feb 19, 2025
1 parent 6ecfc3c commit 5fba34e
Show file tree
Hide file tree
Showing 13 changed files with 1,149 additions and 63 deletions.
6 changes: 3 additions & 3 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ interface ToggleHideBalances {
interface DivviRegistrationCompleted {
type: Actions.DIVVI_REGISTRATION_COMPLETED
networkId: NetworkId
protocolId: SupportedProtocolId
protocolIds: SupportedProtocolId[]
}

export type ActionTypes =
Expand Down Expand Up @@ -341,11 +341,11 @@ export const toggleHideBalances = (): ToggleHideBalances => {

export const divviRegistrationCompleted = (
networkId: NetworkId,
protocolId: SupportedProtocolId
protocolIds: SupportedProtocolId[]
): DivviRegistrationCompleted => {
return {
type: Actions.DIVVI_REGISTRATION_COMPLETED,
networkId,
protocolId,
protocolIds,
}
}
2 changes: 1 addition & 1 deletion src/app/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const appReducer = (
...state.divviRegistrations,
[action.networkId]: [
...(state.divviRegistrations[action.networkId] ?? []),
action.protocolId,
...action.protocolIds,
],
},
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ export const showNotificationSpotlightSelector = (state: RootState) =>
export const hideWalletBalancesSelector = (state: RootState) => state.app.hideBalances

export const pendingDeepLinkSelector = (state: RootState) => state.app.pendingDeepLinks[0] ?? null

export const divviRegistrationsSelector = (state: RootState) => state.app.divviRegistrations
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LoggerLevel } from 'src/utils/LoggerLevels'
// eslint-disable-next-line import/no-relative-packages
import { TORUS_SAPPHIRE_NETWORK } from '@toruslabs/constants'
import { LaunchArguments } from 'react-native-launch-arguments'
import { SupportedProtocolId } from 'src/divviProtocol/constants'
import { HomeActionName } from 'src/home/types'
import { ToggleableOnboardingFeatures } from 'src/onboarding/types'
import { stringToBoolean } from 'src/utils/parsing'
Expand Down Expand Up @@ -226,3 +227,6 @@ export const ENABLED_QUICK_ACTIONS = (
export const FETCH_FIATCONNECT_QUOTES = true

export const WALLETCONNECT_UNIVERSAL_LINK = 'https://valoraapp.com/wc'

export const DIVVI_PROTOCOL_IDS: SupportedProtocolId[] = []
export const DIVVI_REFERRER_ID: string | undefined = undefined
Loading

0 comments on commit 5fba34e

Please # to comment.