Skip to content

Commit c21fb9c

Browse files
authored
Merge pull request #693 from EdgeApp/sam/v2corerollup
Sam/v2corerollup
2 parents a44f133 + 27d44af commit c21fb9c

13 files changed

Lines changed: 74 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
- added: Add `appVersion`, `osType`, and `osVersion` to `EdgeContextOptions` for v2 coreRollup endpoint support.
6+
- changed: Use `/v2/coreRollup` endpoint when device info is available, with `/v1/coreRollup` as fallback.
7+
58
## 2.38.4 (2026-01-12)
69

710
- fixed: Allow duplicate sync keys when performing a wallet split, in case a previous failed attempt left a repo behind.

src/core/actions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ export type RootAction =
369369
apiKey: string
370370
apiSecret?: Uint8Array
371371
appId: string
372+
appVersion?: string
373+
osType?: string
374+
osVersion?: string
372375
changeServers: string[]
373376
infoCache: InfoCacheFile
374377
infoServers: string[]

src/core/context/context-pixie.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,25 @@ export const context: TamePixie<RootProps> = combinePixies({
5959
(input: ApiInput) => {
6060
async function doInfoSync(): Promise<void> {
6161
const { dispatch, io } = input.props
62+
const { contextAppId, deviceInfo } = input.props.state.login
63+
const { appVersion, osType, osVersion } = deviceInfo
6264

6365
const [infoServerUri] = shuffle(input.props.state.infoServers)
64-
const response = await fetch(`${infoServerUri}/v1/coreRollup`, {
66+
67+
// Use v2 endpoint if we have the required device info, otherwise fall back to v1
68+
let url: string
69+
if (osType != null && osVersion != null && appVersion != null) {
70+
const params = new URLSearchParams()
71+
params.set('appId', contextAppId !== '' ? contextAppId : 'edge')
72+
params.set('os', osType)
73+
params.set('osVersion', osVersion)
74+
params.set('appVersion', appVersion)
75+
url = `${infoServerUri}/v2/coreRollup?${params.toString()}`
76+
} else {
77+
url = `${infoServerUri}/v1/coreRollup`
78+
}
79+
80+
const response = await fetch(url, {
6581
headers: { accept: 'application/json' }
6682
})
6783
if (!response.ok) return

src/core/currency/wallet/currency-wallet-api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,9 @@ export function makeCurrencyWalletApi(
600600
if (swapData != null) tx.swapData = asEdgeTxSwap(swapData)
601601
if (savedAction != null) tx.savedAction = asEdgeTxAction(savedAction)
602602
if (assetAction != null) tx.assetAction = asEdgeAssetAction(assetAction)
603-
if (input.props.state.login.deviceDescription != null)
604-
tx.deviceDescription = input.props.state.login.deviceDescription
603+
if (input.props.state.login.deviceInfo.deviceDescription != null)
604+
tx.deviceDescription =
605+
input.props.state.login.deviceInfo.deviceDescription
605606

606607
return tx
607608
},

src/core/login/login-delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function deleteLogin(
1212
login: LoginTree
1313
): Promise<void> {
1414
const { stashTree } = getStashById(ai, login.loginId)
15-
const { deviceDescription } = ai.props.state.login
15+
const { deviceDescription } = ai.props.state.login.deviceInfo
1616

1717
const request = makeAuthJson(stashTree, login)
1818
if (deviceDescription != null) request.deviceDescription = deviceDescription

src/core/login/login-reducer.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ import { findDuressStash, LoginStash } from './login-stash'
1010
import { WalletInfoFullMap } from './login-types'
1111
import { findPin2Stash } from './pin2'
1212

13+
export interface DeviceInfo {
14+
readonly deviceDescription?: string
15+
readonly osType?: string
16+
readonly osVersion?: string
17+
readonly appVersion?: string
18+
}
19+
1320
export interface LoginState {
1421
readonly apiKey: string
1522
readonly apiSecret: Uint8Array | null
1623
readonly contextAppId: string
17-
readonly deviceDescription: string | null
24+
readonly deviceInfo: DeviceInfo
1825
readonly loginServers: string[]
1926
readonly stashes: LoginStash[]
2027
readonly localUsers: EdgeUserInfo[]
@@ -34,8 +41,18 @@ export const login = buildReducer<LoginState, RootAction, RootState>({
3441
return action.type === 'INIT' ? action.payload.appId : state
3542
},
3643

37-
deviceDescription(state = null, action): string | null {
38-
return action.type === 'INIT' ? action.payload.deviceDescription : state
44+
deviceInfo(state: DeviceInfo = {}, action): DeviceInfo {
45+
if (action.type === 'INIT') {
46+
const { appVersion, deviceDescription, osType, osVersion } =
47+
action.payload
48+
return {
49+
deviceDescription: deviceDescription ?? undefined,
50+
osType,
51+
osVersion,
52+
appVersion
53+
}
54+
}
55+
return state
3956
},
4057

4158
localUsers: memoizeReducer(

src/core/login/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export async function serverLogin(
349349
decrypt: (reply: LoginPayload) => Promise<Uint8Array>
350350
): Promise<SessionKey> {
351351
const { now = new Date() } = opts
352-
const { deviceDescription } = ai.props.state.login
352+
const { deviceDescription } = ai.props.state.login.deviceInfo
353353

354354
const request: LoginRequestBody = {
355355
challengeId: opts.challengeId,
@@ -427,7 +427,7 @@ export async function applyKit(
427427
const { serverMethod = 'POST', serverPath } = kit
428428

429429
const { stashTree } = getStashById(ai, kit.loginId)
430-
const { deviceDescription } = ai.props.state.login
430+
const { deviceDescription } = ai.props.state.login.deviceInfo
431431

432432
const newStashTree = updateTree<LoginStash, LoginStash>(
433433
stashTree,

src/core/login/vouchers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function changeVoucherStatus(
1919
vouchers: ChangeVouchersPayload
2020
): Promise<void> {
2121
const { stashTree } = getStashById(ai, login.loginId)
22-
const { deviceDescription } = ai.props.state.login
22+
const { deviceDescription } = ai.props.state.login.deviceInfo
2323

2424
const request = makeAuthJson(stashTree, login)
2525
if (deviceDescription != null) request.deviceDescription = deviceDescription

src/core/root-reducer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface RootState {
1515
readonly accountIds: string[]
1616
readonly accounts: { [accountId: string]: AccountState }
1717
readonly changeServers: string[]
18-
readonly contextAppId: string
1918
readonly clientInfo: ClientInfo
2019
readonly hideKeys: boolean
2120
readonly infoCache: InfoCacheFile
@@ -105,10 +104,6 @@ export const reducer = buildReducer<RootState, RootAction, RootState>({
105104
return state
106105
},
107106

108-
contextAppId: (state = '', action): string => {
109-
return action.type === 'LOGIN' ? action.payload.appId : state
110-
},
111-
112107
hideKeys(state = true, action): boolean {
113108
return action.type === 'INIT' ? action.payload.hideKeys : state
114109
},

src/core/root.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ export async function makeContext(
3737
airbitzSupport = false,
3838
apiSecret,
3939
appId = '',
40+
appVersion,
4041
authServer,
4142
deviceDescription = null,
4243
changeServer,
4344
hideKeys = false,
4445
infoServer,
4546
loginServer,
47+
osType,
48+
osVersion,
4649
plugins: pluginsInit = {},
4750
skipBlockHeight = false,
4851
syncServer
@@ -132,6 +135,9 @@ export async function makeContext(
132135
apiKey,
133136
apiSecret,
134137
appId,
138+
appVersion,
139+
osType,
140+
osVersion,
135141
changeServers,
136142
loginServers,
137143
infoCache,

0 commit comments

Comments
 (0)