Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion api-specs/openrpc-dapp-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@
"status": {
"$ref": "#/components/schemas/StatusEvent"
},
"userId": {
"title": "userId",
"type": "string",
"description": "The user ID associated with the session."
},
"sessionToken": {
"title": "sessionToken",
"type": "string",
"description": "JWT authentication token (if applicable)."
}
},
"required": ["status", "sessionToken"]
"required": ["status", "userId", "sessionToken"]
}
},
"description": "Ensures ledger connectivity and returns the connected network information along with the user access token. Network ID should follow CAIP-2 and represent the synchronizerId."
Expand Down
5 changes: 5 additions & 0 deletions api-specs/openrpc-dapp-remote-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@
"type": "string",
"description": "A CAIP-2 compliant network ID, e.g. 'canton:da-mainnet'."
},
"userId": {
"title": "userId",
"type": "string",
"description": "The user ID associated with the session."
},
"sessionToken": {
"title": "sessionToken",
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions api-specs/openrpc-user-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@
"network": {
"$ref": "#/components/schemas/Network"
},
"userId": {
"title": "userId",
"type": "string",
"description": "The user ID associated with the session."
},
"accessToken": {
"title": "accessToken",
"type": "string",
Expand Down
6 changes: 5 additions & 1 deletion core/splice-provider/src/SpliceProviderHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { popupHref } from '@canton-network/core-wallet-ui-components'

export class SpliceProviderHttp extends SpliceProviderBase {
private sessionToken?: string
private userId?: string
private socket: Socket
private transport: HttpTransport

Expand Down Expand Up @@ -42,11 +43,13 @@ export class SpliceProviderHttp extends SpliceProviderBase {

constructor(
private url: URL,
sessionToken?: string
sessionToken?: string,
userId?: string
) {
super()

if (sessionToken) this.sessionToken = sessionToken
if (userId) this.userId = userId
this.transport = new HttpTransport(url, sessionToken)

this.socket = this.openSocket(url)
Expand Down Expand Up @@ -78,6 +81,7 @@ export class SpliceProviderHttp extends SpliceProviderBase {
kernel: statusResult.kernel,
networkId: statusResult.networkId,
sessionToken: this.sessionToken,
userId: this.userId,
})
})
.catch((err) => {
Expand Down
7 changes: 7 additions & 0 deletions core/wallet-dapp-remote-rpc-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export interface JsPrepareSubmissionResponse {
*/
export type UserUrl = string
export type Response = string
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* Set as primary wallet for dApp usage.
Expand Down Expand Up @@ -307,6 +313,7 @@ export interface LedgerApiResult {
export interface OnConnectedEvent {
kernel: KernelInfo
networkId: NetworkId
userId?: UserId
sessionToken?: SessionToken
[k: string]: any
}
Expand Down
5 changes: 5 additions & 0 deletions core/wallet-dapp-remote-rpc-client/src/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@
"type": "string",
"description": "A CAIP-2 compliant network ID, e.g. 'canton:da-mainnet'."
},
"userId": {
"title": "userId",
"type": "string",
"description": "The user ID associated with the session."
},
"sessionToken": {
"title": "sessionToken",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions core/wallet-dapp-rpc-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export interface StatusEvent {
networkId?: NetworkId
[k: string]: any
}
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* JWT authentication token (if applicable).
Expand Down Expand Up @@ -278,6 +284,7 @@ export interface LedgerApiParams {
}
export interface ConnectResult {
status: StatusEvent
userId: UserId
sessionToken: SessionToken
[k: string]: any
}
Expand Down
7 changes: 6 additions & 1 deletion core/wallet-dapp-rpc-client/src/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@
"status": {
"$ref": "#/components/schemas/StatusEvent"
},
"userId": {
"title": "userId",
"type": "string",
"description": "The user ID associated with the session."
},
"sessionToken": {
"title": "sessionToken",
"type": "string",
"description": "JWT authentication token (if applicable)."
}
},
"required": ["status", "sessionToken"]
"required": ["status", "userId", "sessionToken"]
}
},
"description": "Ensures ledger connectivity and returns the connected network information along with the user access token. Network ID should follow CAIP-2 and represent the synchronizerId."
Expand Down
8 changes: 8 additions & 0 deletions core/wallet-user-rpc-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ export interface Wallet {
export type Added = Wallet[]
export type Removed = Wallet[]
export type Networks = Network[]
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* The access token for the session.
Expand All @@ -187,6 +193,7 @@ export type Status = 'connected' | 'disconnected'
*/
export interface Session {
network: Network
userId?: UserId
accessToken: AccessToken
status: Status
}
Expand Down Expand Up @@ -285,6 +292,7 @@ export interface ListNetworksResult {
*/
export interface AddSessionResult {
network: Network
userId?: UserId
accessToken: AccessToken
status: Status
}
Expand Down
5 changes: 5 additions & 0 deletions core/wallet-user-rpc-client/src/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@
"network": {
"$ref": "#/components/schemas/Network"
},
"userId": {
"title": "userId",
"type": "string",
"description": "The user ID associated with the session."
},
"accessToken": {
"title": "accessToken",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions sdk/dapp-sdk/src/dapp-api/rpc-gen/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export interface StatusEvent {
networkId?: NetworkId
[k: string]: any
}
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* JWT authentication token (if applicable).
Expand Down Expand Up @@ -278,6 +284,7 @@ export interface LedgerApiParams {
}
export interface ConnectResult {
status: StatusEvent
userId: UserId
sessionToken: SessionToken
[k: string]: any
}
Expand Down
10 changes: 8 additions & 2 deletions sdk/dapp-sdk/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ export class Provider implements SpliceProvider {
private httpProvider?: SpliceProvider
private windowProvider?: SpliceProvider

constructor({ walletType, url }: DiscoverResult, sessionToken?: string) {
constructor(
{ walletType, url }: DiscoverResult,
sessionToken?: string,
userId?: string
) {
if (walletType == 'extension') {
this.providerType = ProviderType.WINDOW
this.windowProvider = new SpliceProviderWindow()
} else if (walletType == 'remote') {
this.providerType = ProviderType.HTTP
this.httpProvider = new SpliceProviderHttp(
new URL(url),
sessionToken
sessionToken,
userId
)
} else {
throw new Error(`Unsupported wallet type ${walletType}`)
Expand Down Expand Up @@ -170,6 +175,7 @@ export const dappController = (provider: SpliceProvider) =>
(event) => {
clearTimeout(timeout)
const result: dappAPI.ConnectResult = {
userId: event.userId ?? '',
sessionToken: event.sessionToken ?? '',
status: {
...event,
Expand Down
7 changes: 7 additions & 0 deletions wallet-gateway/extension/src/dapp-api/rpc-gen/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export interface StatusEvent {
networkId?: NetworkId
[k: string]: any
}
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* JWT authentication token (if applicable).
Expand Down Expand Up @@ -278,6 +284,7 @@ export interface LedgerApiParams {
}
export interface ConnectResult {
status: StatusEvent
userId: UserId
sessionToken: SessionToken
[k: string]: any
}
Expand Down
1 change: 1 addition & 0 deletions wallet-gateway/remote/src/dapp-api/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const dappController = (
const logger = _logger.child({ component: 'dapp-controller' })
return buildController({
connect: async () => ({
userId: '',
sessionToken: '',
status: {
kernel: kernelInfo,
Expand Down
7 changes: 7 additions & 0 deletions wallet-gateway/remote/src/dapp-api/rpc-gen/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export interface JsPrepareSubmissionResponse {
*/
export type UserUrl = string
export type Response = string
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* Set as primary wallet for dApp usage.
Expand Down Expand Up @@ -307,6 +313,7 @@ export interface LedgerApiResult {
export interface OnConnectedEvent {
kernel: KernelInfo
networkId: NetworkId
userId?: UserId
sessionToken?: SessionToken
[k: string]: any
}
Expand Down
8 changes: 8 additions & 0 deletions wallet-gateway/remote/src/user-api/rpc-gen/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ export interface Wallet {
export type Added = Wallet[]
export type Removed = Wallet[]
export type Networks = Network[]
/**
*
* The user ID associated with the session.
*
*/
export type UserId = string
/**
*
* The access token for the session.
Expand All @@ -187,6 +193,7 @@ export type Status = 'connected' | 'disconnected'
*/
export interface Session {
network: Network
userId?: UserId
accessToken: AccessToken
status: Status
}
Expand Down Expand Up @@ -285,6 +292,7 @@ export interface ListNetworksResult {
*/
export interface AddSessionResult {
network: Network
userId?: UserId
accessToken: AccessToken
status: Status
}
Expand Down
Loading