rise-wallet 0.2.29 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +153 -15
  2. package/dist/cli/bin/commands-DupUUwJ9.js +50 -0
  3. package/dist/cli/bin/index.js +1 -1
  4. package/dist/core/Chains.d.ts +285 -12
  5. package/dist/core/Chains.d.ts.map +1 -1
  6. package/dist/core/Dialog.d.ts +2 -2
  7. package/dist/core/Dialog.d.ts.map +1 -1
  8. package/dist/core/Dialog.js +10 -2
  9. package/dist/core/Dialog.js.map +1 -1
  10. package/dist/core/Porto.d.ts +476 -26
  11. package/dist/core/Porto.d.ts.map +1 -1
  12. package/dist/core/Porto.js +1 -1
  13. package/dist/core/Porto.js.map +1 -1
  14. package/dist/core/Transport.d.ts +2 -2
  15. package/dist/core/Transport.js +2 -2
  16. package/dist/core/Transport.js.map +1 -1
  17. package/dist/core/internal/_generated/chains.d.ts +1 -1
  18. package/dist/core/internal/_generated/chains.d.ts.map +1 -1
  19. package/dist/core/internal/_generated/chains.js +1 -1
  20. package/dist/core/internal/_generated/chains.js.map +1 -1
  21. package/dist/core/internal/mode.d.ts +4 -0
  22. package/dist/core/internal/mode.d.ts.map +1 -1
  23. package/dist/core/internal/mode.js.map +1 -1
  24. package/dist/core/internal/modes/dialog.d.ts +47 -7
  25. package/dist/core/internal/modes/dialog.d.ts.map +1 -1
  26. package/dist/core/internal/modes/reactNative.d.ts +187 -10
  27. package/dist/core/internal/modes/reactNative.d.ts.map +1 -1
  28. package/dist/core/internal/modes/relay.d.ts +140 -3
  29. package/dist/core/internal/modes/relay.d.ts.map +1 -1
  30. package/dist/core/internal/modes/relay.js +102 -26
  31. package/dist/core/internal/modes/relay.js.map +1 -1
  32. package/dist/core/internal/permissions.d.ts +1 -1
  33. package/dist/core/internal/permissionsRequest.d.ts +1 -1
  34. package/dist/core/internal/provider.d.ts.map +1 -1
  35. package/dist/core/internal/provider.js +13 -2
  36. package/dist/core/internal/provider.js.map +1 -1
  37. package/dist/core/internal/relay/rpcSchema.d.ts +3 -0
  38. package/dist/core/internal/relay/rpcSchema.d.ts.map +1 -1
  39. package/dist/core/internal/relay/schema/rpc.d.ts +23 -0
  40. package/dist/core/internal/relay/schema/rpc.d.ts.map +1 -1
  41. package/dist/core/internal/relay/schema/rpc.js +18 -0
  42. package/dist/core/internal/relay/schema/rpc.js.map +1 -1
  43. package/dist/core/internal/schema/capabilities.d.ts +2 -2
  44. package/dist/core/internal/schema/key.d.ts +2 -2
  45. package/dist/core/internal/schema/key.d.ts.map +1 -1
  46. package/dist/core/internal/schema/key.js +1 -0
  47. package/dist/core/internal/schema/key.js.map +1 -1
  48. package/dist/core/internal/schema/permissions.d.ts +2 -2
  49. package/dist/core/internal/schema/request.d.ts +18 -16
  50. package/dist/core/internal/schema/request.d.ts.map +1 -1
  51. package/dist/core/internal/schema/rpc.d.ts +52 -46
  52. package/dist/core/internal/schema/rpc.d.ts.map +1 -1
  53. package/dist/core/internal/schema/rpc.js +1 -0
  54. package/dist/core/internal/schema/rpc.js.map +1 -1
  55. package/dist/core/react-native/Porto.d.ts +474 -24
  56. package/dist/core/react-native/Porto.d.ts.map +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/remote/Events.d.ts.map +1 -1
  62. package/dist/remote/Events.js +5 -1
  63. package/dist/remote/Events.js.map +1 -1
  64. package/dist/remote/Hooks.d.ts +44 -40
  65. package/dist/remote/Hooks.d.ts.map +1 -1
  66. package/dist/remote/Porto.d.ts +429 -19
  67. package/dist/remote/Porto.d.ts.map +1 -1
  68. package/dist/trusted-hosts.d.ts.map +1 -1
  69. package/dist/trusted-hosts.js +5 -0
  70. package/dist/trusted-hosts.js.map +1 -1
  71. package/dist/tsconfig.tmp.tsbuildinfo +1 -1
  72. package/dist/viem/Account.d.ts +3 -0
  73. package/dist/viem/Account.d.ts.map +1 -1
  74. package/dist/viem/Account.js +16 -12
  75. package/dist/viem/Account.js.map +1 -1
  76. package/dist/viem/Key.d.ts +96 -1
  77. package/dist/viem/Key.d.ts.map +1 -1
  78. package/dist/viem/Key.js +102 -3
  79. package/dist/viem/Key.js.map +1 -1
  80. package/dist/viem/RelayActions.d.ts +12 -1
  81. package/dist/viem/RelayActions.d.ts.map +1 -1
  82. package/dist/viem/RelayActions.js +8 -3
  83. package/dist/viem/RelayActions.js.map +1 -1
  84. package/dist/viem/internal/provider.d.ts +9 -0
  85. package/dist/viem/internal/provider.d.ts.map +1 -0
  86. package/dist/viem/internal/provider.js +15 -0
  87. package/dist/viem/internal/provider.js.map +1 -0
  88. package/dist/viem/internal/relayActions.d.ts +16 -0
  89. package/dist/viem/internal/relayActions.d.ts.map +1 -1
  90. package/dist/viem/internal/relayActions.js +29 -0
  91. package/dist/viem/internal/relayActions.js.map +1 -1
  92. package/dist/wagmi/Connector.d.ts +2 -2
  93. package/dist/wagmi/Connector.d.ts.map +1 -1
  94. package/dist/wagmi/Connector.js +4 -4
  95. package/dist/wagmi/Connector.js.map +1 -1
  96. package/dist/wagmi/index.d.ts +1 -1
  97. package/dist/wagmi/index.d.ts.map +1 -1
  98. package/dist/wagmi/index.js +1 -1
  99. package/dist/wagmi/index.js.map +1 -1
  100. package/dist/wagmi/index.native.d.ts +1 -1
  101. package/dist/wagmi/index.native.d.ts.map +1 -1
  102. package/dist/wagmi/index.native.js +1 -1
  103. package/dist/wagmi/index.native.js.map +1 -1
  104. package/package.json +5 -4
  105. package/src/core/Dialog.ts +12 -2
  106. package/src/core/Porto.ts +5 -5
  107. package/src/core/Transport.ts +2 -2
  108. package/src/core/internal/_generated/chains.ts +4 -1
  109. package/src/core/internal/mode.ts +5 -1
  110. package/src/core/internal/modes/relay.ts +158 -56
  111. package/src/core/internal/provider.browser.test.ts +1 -1
  112. package/src/core/internal/provider.test.ts +2 -2
  113. package/src/core/internal/provider.ts +16 -2
  114. package/src/core/internal/relay/rpcSchema.ts +4 -0
  115. package/src/core/internal/relay/schema/rpc.ts +23 -0
  116. package/src/core/internal/schema/key.ts +1 -0
  117. package/src/core/internal/schema/rpc.ts +1 -0
  118. package/src/core/react-native/Porto.ts +1 -1
  119. package/src/index.ts +1 -1
  120. package/src/remote/Events.ts +5 -1
  121. package/src/remote/Porto.ts +3 -3
  122. package/src/server/Route.test.ts +2 -2
  123. package/src/trusted-hosts.ts +5 -0
  124. package/src/viem/Account.ts +30 -12
  125. package/src/viem/Key.ts +163 -4
  126. package/src/viem/RelayActions.ts +30 -8
  127. package/src/viem/RelayClient.test.ts +2 -2
  128. package/src/viem/WalletActions.test.ts +1 -1
  129. package/src/viem/WalletClient.test.ts +2 -2
  130. package/src/viem/internal/provider.ts +19 -0
  131. package/src/viem/internal/relayActions.ts +42 -0
  132. package/src/wagmi/Connector.ts +5 -5
  133. package/src/wagmi/index.native.ts +1 -1
  134. package/src/wagmi/index.ts +1 -1
  135. package/dist/cli/bin/commands-o468kGU4.js +0 -50
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rise-wallet",
3
3
  "description": "Next-gen Account for Ethereum",
4
- "version": "0.2.29",
4
+ "version": "0.3.1",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "porto": "./dist/cli/bin/index.js"
@@ -20,7 +20,8 @@
20
20
  "mipd": "^0.0.7",
21
21
  "ox": "^0.9.6",
22
22
  "zod": "^4.1.5",
23
- "zustand": "^5.0.1"
23
+ "zustand": "^5.0.1",
24
+ "mipd-postmessage": "^0.0.6"
24
25
  },
25
26
  "peerDependencies": {
26
27
  "@tanstack/react-query": ">=5.59.0",
@@ -61,8 +62,8 @@
61
62
  }
62
63
  },
63
64
  "license": "MIT",
64
- "homepage": "https://ithaca.xyz",
65
- "repository": "ithacaxyz/porto",
65
+ "homepage": "https://wallet.risechain.com",
66
+ "repository": "risechain/porto-rise",
66
67
  "contributors": [
67
68
  "jxom.eth <jake@ithaca.xyz>",
68
69
  "awkweb.eth <tom@ithaca.xyz>",
@@ -1,3 +1,5 @@
1
+ import * as Mipd from 'mipd'
2
+ import * as MipdPostMessage from 'mipd-postmessage/parent'
1
3
  import type { RpcRequest, RpcResponse } from 'ox'
2
4
  import * as Json from 'ox/Json'
3
5
  import * as Provider from 'ox/Provider'
@@ -23,8 +25,8 @@ type AuthSessionStatus =
23
25
 
24
26
  export const hostUrls = {
25
27
  local: 'http://localhost:5175/dialog/',
26
- prod: 'https://rise-wallet-testnet.vercel.app/dialog',
27
- stg: 'https://rise-wallet-testnet.vercel.app/dialog',
28
+ prod: 'https://wallet.risechain.com/dialog',
29
+ stg: 'https://stg.wallet.risechain.com/dialog',
28
30
  } as const
29
31
 
30
32
  /** Dialog interface. */
@@ -80,6 +82,8 @@ export function iframe(options: iframe.Options = {}) {
80
82
  )
81
83
 
82
84
  if (typeof window === 'undefined') return noop()
85
+
86
+ const mipdStore = Mipd.createStore()
83
87
  return from({
84
88
  name: 'iframe',
85
89
  setup(parameters) {
@@ -149,6 +153,12 @@ export function iframe(options: iframe.Options = {}) {
149
153
  root.appendChild(style)
150
154
  root.appendChild(iframe)
151
155
 
156
+ MipdPostMessage.expose({
157
+ child: iframe.contentWindow!,
158
+ origin: hostUrl.origin,
159
+ store: mipdStore,
160
+ })
161
+
152
162
  const messenger = Messenger.bridge({
153
163
  from: Messenger.fromWindow(window, { targetOrigin: hostUrl.origin }),
154
164
  to: Messenger.fromWindow(iframe.contentWindow!, {
package/src/core/Porto.ts CHANGED
@@ -32,7 +32,7 @@ export const defaultConfig = {
32
32
  browser && typeof indexedDB !== 'undefined'
33
33
  ? Storage.idb()
34
34
  : Storage.memory(),
35
- storageKey: 'porto.store',
35
+ storageKey: 'risewallet.store',
36
36
  } as const satisfies ExactPartial<Config>
37
37
 
38
38
  /**
@@ -40,7 +40,7 @@ export const defaultConfig = {
40
40
  *
41
41
  * @example
42
42
  * ```ts twoslash
43
- * import { Porto } from 'porto'
43
+ * import { Porto } from 'rise-wallet'
44
44
  *
45
45
  * const porto = Porto.create()
46
46
  *
@@ -49,10 +49,10 @@ export const defaultConfig = {
49
49
  */
50
50
  export function create<
51
51
  const chains extends readonly [Chains.Chain, ...Chains.Chain[]],
52
- >(parameters?: ExactPartial<Config<chains>> | undefined): Porto<chains>
52
+ >(parameters?: ExactPartial<Config<chains>> | undefined): RiseWallet<chains>
53
53
  export function create(
54
54
  parameters: ExactPartial<Config> | undefined = {},
55
- ): Porto {
55
+ ): RiseWallet {
56
56
  const chains = parameters.chains ?? defaultConfig.chains
57
57
  const transports = Object.fromEntries(
58
58
  chains!.map((chain) => [
@@ -216,7 +216,7 @@ export type Config<
216
216
  transports: Record<chains[number]['id'], Transport>
217
217
  }
218
218
 
219
- export type Porto<
219
+ export type RiseWallet<
220
220
  chains extends readonly [Chains.Chain, ...Chains.Chain[]] = readonly [
221
221
  Chains.Chain,
222
222
  ...Chains.Chain[],
@@ -4,8 +4,8 @@ export { fallback, http, type Transport, webSocket } from 'viem'
4
4
 
5
5
  export const relayUrls = {
6
6
  anvil: { http: 'http://localhost:9119' },
7
- prod: { http: 'https://rise-testnet-porto.fly.dev' },
8
- stg: { http: 'https://rise-testnet-porto.fly.dev' },
7
+ prod: { http: 'https://relay.wallet.risechain.com' },
8
+ stg: { http: 'https://stg.relay.wallet.risechain.com' },
9
9
  } as const
10
10
 
11
11
  export function relayProxy(
@@ -1,2 +1,5 @@
1
1
  // Generated by `pnpm gen:chains`
2
- export { riseTestnet } from 'viem/chains'
2
+ export {
3
+ baseSepolia,
4
+ riseTestnet,
5
+ } from 'viem/chains'
@@ -2,7 +2,6 @@ import * as AbiItem from 'ox/AbiItem'
2
2
  import type * as Address from 'ox/Address'
3
3
  import * as Hex from 'ox/Hex'
4
4
  import type * as z from 'zod/mini'
5
-
6
5
  import type * as Account from '../../viem/Account.js'
7
6
  import type * as Key from '../../viem/Key.js'
8
7
  import type { RelayClient } from '../../viem/RelayClient.js'
@@ -60,6 +59,7 @@ export type Mode = {
60
59
  permissions?: PermissionsRequest.PermissionsRequest | undefined
61
60
  /** Adds support for offchain authentication using ERC-4361. */
62
61
  signInWithEthereum?: Capabilities.signInWithEthereum.Request | undefined
62
+ providerRdns?: string | undefined
63
63
  }) => Promise<{
64
64
  /** Account. */
65
65
  account: Account.Account & {
@@ -158,6 +158,9 @@ export type Mode = {
158
158
  /** Public key. */
159
159
  publicKey: Hex.Hex
160
160
  }
161
+ | {
162
+ rdns?: string | undefined
163
+ }
161
164
  | undefined
162
165
  /** Internal properties. */
163
166
  internal: ActionsInternal
@@ -165,6 +168,7 @@ export type Mode = {
165
168
  permissions?: PermissionsRequest.PermissionsRequest | undefined
166
169
  /** Adds support for offchain authentication using ERC-4361. */
167
170
  signInWithEthereum?: Capabilities.signInWithEthereum.Request | undefined
171
+ providerRdns?: string | undefined
168
172
  }) => Promise<{
169
173
  /** Accounts. */
170
174
  accounts: readonly (Account.Account & {
@@ -62,6 +62,7 @@ export function relay(parameters: relay.Parameters = {}) {
62
62
  permissions,
63
63
  internal,
64
64
  signInWithEthereum,
65
+ providerRdns,
65
66
  } = parameters
66
67
  const { client } = internal
67
68
 
@@ -70,14 +71,16 @@ export function relay(parameters: relay.Parameters = {}) {
70
71
  const feeTokens = await Tokens.getTokens(client)
71
72
 
72
73
  const adminKey = !mock
73
- ? await Key.createWebAuthnP256({
74
- createFn: webAuthn?.createFn,
75
- label:
76
- label ||
77
- `${eoa.address.slice(0, 8)}\u2026${eoa.address.slice(-6)}`,
78
- rpId: keystoreHost,
79
- userId: Bytes.from(eoa.address),
80
- })
74
+ ? providerRdns
75
+ ? await Key.createEip1193Provider({ rdns: providerRdns })
76
+ : await Key.createWebAuthnP256({
77
+ createFn: webAuthn?.createFn,
78
+ label:
79
+ label ||
80
+ `${eoa.address.slice(0, 8)}\u2026${eoa.address.slice(-6)}`,
81
+ rpId: keystoreHost,
82
+ userId: Bytes.from(eoa.address),
83
+ })
81
84
  : Key.createHeadlessWebAuthnP256()
82
85
  const sessionKey = await PermissionsRequest.toKey(permissions, {
83
86
  chainId: client.chain.id,
@@ -86,14 +89,47 @@ export function relay(parameters: relay.Parameters = {}) {
86
89
 
87
90
  const adminKeys = admins?.map((admin) => Key.from(admin))
88
91
 
89
- const account = await RelayActions.upgradeAccount(client, {
90
- account: eoa,
91
- authorizeKeys: [
92
- adminKey,
93
- ...(adminKeys ?? []),
94
- ...(sessionKey ? [sessionKey] : []),
95
- ],
96
- })
92
+ const { address: existingAccount } = providerRdns
93
+ ? await RelayActions.getAccount(client, { keyHash: adminKey.hash })
94
+ : { address: null }
95
+
96
+ const account = existingAccount
97
+ ? Account.from({
98
+ address: existingAccount,
99
+ keys: [
100
+ adminKey,
101
+ ...(adminKeys ?? []),
102
+ ...(sessionKey ? [sessionKey] : []),
103
+ ],
104
+ })
105
+ : await RelayActions.upgradeAccount(client, {
106
+ account: eoa,
107
+ authorizeKeys: [
108
+ adminKey,
109
+ ...(adminKeys ?? []),
110
+ ...(sessionKey ? [sessionKey] : []),
111
+ ],
112
+ })
113
+
114
+ if (existingAccount && sessionKey) {
115
+ const { context, digest, typedData } =
116
+ await RelayActions.prepareCalls(client, {
117
+ account,
118
+ authorizeKeys: [sessionKey],
119
+ key: adminKey,
120
+ preCalls: true,
121
+ })
122
+ const signature = await Key.sign(adminKey, {
123
+ address: null,
124
+ payload: digest,
125
+ typedData,
126
+ })
127
+ await RelayActions.sendPreparedCalls(client, {
128
+ context,
129
+ key: adminKey,
130
+ signature,
131
+ })
132
+ }
97
133
 
98
134
  address_internal = eoa.address
99
135
 
@@ -306,15 +342,19 @@ export function relay(parameters: relay.Parameters = {}) {
306
342
  )
307
343
  if (!adminKey) throw new Error('admin key not found.')
308
344
 
309
- const { context, digest } = await RelayActions.prepareCalls(client, {
310
- account,
311
- authorizeKeys: [authorizeKey],
312
- key: adminKey,
313
- preCalls: true,
314
- })
345
+ const { context, digest, typedData } = await RelayActions.prepareCalls(
346
+ client,
347
+ {
348
+ account,
349
+ authorizeKeys: [authorizeKey],
350
+ key: adminKey,
351
+ preCalls: true,
352
+ },
353
+ )
315
354
  const signature = await Key.sign(adminKey, {
316
355
  address: null,
317
356
  payload: digest,
357
+ typedData,
318
358
  })
319
359
  await RelayActions.sendPreparedCalls(client, {
320
360
  context,
@@ -326,7 +366,12 @@ export function relay(parameters: relay.Parameters = {}) {
326
366
  },
327
367
 
328
368
  async loadAccounts(parameters) {
329
- const { internal, permissions, signInWithEthereum } = parameters
369
+ const {
370
+ internal,
371
+ permissions,
372
+ signInWithEthereum,
373
+ providerRdns: _providerRdns,
374
+ } = parameters
330
375
  const { client } = internal
331
376
 
332
377
  const feeTokens = await Tokens.getTokens(client)
@@ -362,42 +407,86 @@ export function relay(parameters: relay.Parameters = {}) {
362
407
  } as const
363
408
  })()
364
409
 
365
- const { address, credentialId, webAuthnSignature } =
366
- await (async () => {
367
- if (mock) {
368
- if (!address_internal)
369
- throw new Error('address_internal not found.')
370
- return {
371
- address: address_internal,
372
- credentialId: undefined,
373
- } as const
374
- }
410
+ const {
411
+ address,
412
+ credentialId,
413
+ webAuthnSignature,
414
+ rdns,
415
+ providerSignature,
416
+ } = await (async () => {
417
+ if (mock) {
418
+ if (!address_internal)
419
+ throw new Error('address_internal not found.')
420
+ return {
421
+ address: address_internal,
422
+ credentialId: undefined,
423
+ } as const
424
+ }
375
425
 
376
- // If the address and credentialId are provided, we can skip the
377
- // WebAuthn discovery step.
378
- if (parameters.address && parameters.key)
426
+ // If the address and credentialId are provided, we can skip the
427
+ // WebAuthn discovery step.
428
+ if (parameters.address && parameters.key) {
429
+ if ('credentialId' in parameters.key)
379
430
  return {
380
431
  address: parameters.address,
381
432
  credentialId: parameters.key.credentialId,
382
433
  }
434
+ if ('rdns' in parameters.key)
435
+ return {
436
+ address: parameters.address,
437
+ rdns: parameters.key.rdns,
438
+ }
439
+ }
383
440
 
384
- // Discovery step. We need to do this to extract the key id
385
- // to query for the Account.
386
- // We will also optionally sign over a digest to authorize
387
- // a session key if the user has provided one.
388
- const webAuthnSignature = await WebAuthnP256.sign({
389
- challenge: digest,
390
- getFn: webAuthn?.getFn,
391
- rpId: keystoreHost,
441
+ if (_providerRdns) {
442
+ const key = await Key.createEip1193Provider({
443
+ rdns: _providerRdns,
392
444
  })
393
- const response = webAuthnSignature.raw
394
- .response as AuthenticatorAssertionResponse
395
445
 
396
- const address = Bytes.toHex(new Uint8Array(response.userHandle!))
397
- const credentialId = webAuthnSignature.raw.id
446
+ const account = await RelayActions.getAccount(client, {
447
+ keyHash: key.hash,
448
+ })
398
449
 
399
- return { address, credentialId, webAuthnSignature }
400
- })()
450
+ if (account.address) {
451
+ const signature =
452
+ digest !== '0x'
453
+ ? await Key.sign(key, {
454
+ address: null,
455
+ payload: message as Hex.Hex,
456
+ wrap: true,
457
+ })
458
+ : undefined
459
+
460
+ return {
461
+ address: account.address,
462
+ providerSignature: signature,
463
+ rdns: _providerRdns,
464
+ }
465
+ }
466
+ throw new Error(
467
+ `No account found for external wallet ${key.publicKey}`,
468
+ )
469
+ }
470
+
471
+ // Discovery step. We need to do this to extract the key id
472
+ // to query for the Account.
473
+ // We will also optionally sign over a digest to authorize
474
+ // a session key if the user has provided one.
475
+ const webAuthnSignature = await WebAuthnP256.sign({
476
+ challenge: digest,
477
+ getFn: webAuthn?.getFn,
478
+ rpId: keystoreHost,
479
+ })
480
+ const response = webAuthnSignature.raw
481
+ .response as AuthenticatorAssertionResponse
482
+
483
+ const address = Bytes.toHex(new Uint8Array(response.userHandle!))
484
+ const credentialId = webAuthnSignature.raw.id
485
+
486
+ return { address, credentialId, webAuthnSignature }
487
+ })()
488
+
489
+ const providerRdns = rdns ?? _providerRdns
401
490
 
402
491
  const keys = await RelayActions.getKeys(client, {
403
492
  account: address,
@@ -421,6 +510,12 @@ export function relay(parameters: relay.Parameters = {}) {
421
510
  id: address,
422
511
  rpId: keystoreHost,
423
512
  })
513
+ if (key.type === 'address' && providerRdns)
514
+ return Key.fromEip1193Provider({
515
+ ...key,
516
+ account: key.publicKey,
517
+ rdns: providerRdns,
518
+ })
424
519
  }
425
520
  return key
426
521
  },
@@ -446,6 +541,8 @@ export function relay(parameters: relay.Parameters = {}) {
446
541
  },
447
542
  )
448
543
 
544
+ if (providerSignature) return providerSignature
545
+
449
546
  // Otherwise, we will sign over the digest for authorizing
450
547
  // the session key.
451
548
  return await Key.sign(adminKey, {
@@ -456,14 +553,16 @@ export function relay(parameters: relay.Parameters = {}) {
456
553
 
457
554
  // Prepare and send the authorize key pre-call.
458
555
  if (authorizeKey) {
459
- const { context, digest } = await RelayActions.prepareCalls(client, {
460
- account,
461
- authorizeKeys: [authorizeKey],
462
- preCalls: true,
463
- })
556
+ const { context, digest, typedData } =
557
+ await RelayActions.prepareCalls(client, {
558
+ account,
559
+ authorizeKeys: [authorizeKey],
560
+ preCalls: true,
561
+ })
464
562
  const signature = await Key.sign(adminKey, {
465
563
  address: null,
466
564
  payload: digest,
565
+ typedData,
467
566
  })
468
567
  await RelayActions.sendPreparedCalls(client, {
469
568
  context,
@@ -492,7 +591,9 @@ export function relay(parameters: relay.Parameters = {}) {
492
591
  },
493
592
  )
494
593
  const signature = await Account.sign(account, {
495
- payload: PersonalMessage.getSignPayload(Hex.fromString(message)),
594
+ payload: providerRdns
595
+ ? (message as Hex.Hex)
596
+ : PersonalMessage.getSignPayload(Hex.fromString(message)),
496
597
  role: 'admin',
497
598
  })
498
599
  const signature_erc8010 = await Erc8010.wrap(client, {
@@ -803,6 +904,7 @@ export function relay(parameters: relay.Parameters = {}) {
803
904
  payload: TypedData.getSignPayload(data),
804
905
  // If the domain is the Orchestrator, we don't need to replay-safe sign.
805
906
  replaySafe: !isOrchestrator,
907
+ typedData: data,
806
908
  webAuthn,
807
909
  })
808
910
 
@@ -1,4 +1,4 @@
1
- import type { Porto } from 'porto'
1
+ import type { Porto } from 'rise-wallet'
2
2
  import { waitForCallsStatus } from 'viem/actions'
3
3
  import { afterEach, describe, expect, test } from 'vitest'
4
4
  import { getPorto } from '../../../test/src/browser/config.js'
@@ -9,8 +9,8 @@ import {
9
9
  Value,
10
10
  WebCryptoP256,
11
11
  } from 'ox'
12
- import { Key, Mode } from 'porto'
13
- import { Route } from 'porto/server'
12
+ import { Key, Mode } from 'rise-wallet'
13
+ import { Route } from 'rise-wallet/server'
14
14
  import { encodeFunctionData, hashMessage, hashTypedData } from 'viem'
15
15
  import {
16
16
  readContract,
@@ -783,6 +783,7 @@ export function from<
783
783
  grantPermissions: permissions,
784
784
  selectAccount,
785
785
  signInWithEthereum,
786
+ providerRdns,
786
787
  } = capabilities ?? {}
787
788
 
788
789
  const internal = {
@@ -802,6 +803,7 @@ export function from<
802
803
  internal,
803
804
  label,
804
805
  permissions,
806
+ providerRdns,
805
807
  signInWithEthereum,
806
808
  })
807
809
  return { accounts: [account] }
@@ -826,6 +828,17 @@ export function from<
826
828
  publicKey: key.publicKey,
827
829
  },
828
830
  }
831
+ if (
832
+ key.type === 'eip1193provider' &&
833
+ key.role === 'admin' &&
834
+ !providerRdns
835
+ )
836
+ return {
837
+ address: account?.address,
838
+ key: {
839
+ rdns: key.privateKey?.rdns,
840
+ },
841
+ }
829
842
  }
830
843
  return {
831
844
  address: undefined,
@@ -835,6 +848,7 @@ export function from<
835
848
  const loadAccountsParams = {
836
849
  internal,
837
850
  permissions,
851
+ providerRdns,
838
852
  signInWithEthereum,
839
853
  }
840
854
  try {
@@ -1207,8 +1221,8 @@ function announce(
1207
1221
  if (typeof window === 'undefined' || !window.dispatchEvent) return () => {}
1208
1222
  const {
1209
1223
  icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDIyIiBoZWlnaHQ9IjQyMiIgdmlld0JveD0iMCAwIDQyMiA0MjIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSI0MjIiIGhlaWdodD0iNDIyIiBmaWxsPSJibGFjayIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMV8x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xMS42NjIgODUuNDUwNSAzMTYuMTAxIDkwLjk0MDQgMzE2LjEwMUgzMjkuNTExQzMzNS4wMDEgMzE2LjEwMSAzMzkuNDUyIDMxMS42NjIgMzM5LjQ1MiAzMDYuMTg4VjI4Ni4zNjZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNMjY5Ljg2OCAxMzEuNzUyQzI2OS44NjggMTI2LjI3OCAyNzQuMzE4IDEyMS44NCAyNzkuODA4IDEyMS44NEgzMTEuNjE4QzMxNy4xMDggMTIxLjg0IDMyMS41NTggMTI2LjI3OCAzMjEuNTU4IDEzMS43NTJWMTYxLjQ4NUMzMjEuNTU4IDE2Ni45NTkgMzE3LjEwOCAxNzEuMzk2IDMxMS42MTggMTcxLjM5NkgyNzkuODA4QzI3NC4zMTggMTcxLjM5NiAyNjkuODY4IDE2Ni45NTkgMjY5Ljg2OCAxNjEuNDg1VjEzMS43NTJaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzFfMTUiPgo8cmVjdCB3aWR0aD0iMjU5IiBoZWlnaHQ9IjIxMyIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDgxIDEwNCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K',
1210
- name = 'Porto',
1211
- rdns = 'xyz.ithaca.porto',
1224
+ name = 'Rise Wallet',
1225
+ rdns = 'com.risechain.wallet',
1212
1226
  } = typeof info === 'object' ? info : {}
1213
1227
  return Mipd.announceProvider({
1214
1228
  info: {
@@ -52,6 +52,10 @@ export type Schema = RpcSchema_ox.From<
52
52
  Request: z.input<typeof Rpc.wallet_feeTokens.Request>
53
53
  ReturnType: z.input<typeof Rpc.wallet_feeTokens.Response>
54
54
  }
55
+ | {
56
+ Request: z.input<typeof Rpc.wallet_getAccount.Request>
57
+ ReturnType: z.input<typeof Rpc.wallet_getAccount.Response>
58
+ }
55
59
  | {
56
60
  Request: z.input<typeof Rpc.wallet_getAccounts.Request>
57
61
  ReturnType: z.input<typeof Rpc.wallet_getAccounts.Response>
@@ -231,6 +231,29 @@ export namespace wallet_addFaucetFunds {
231
231
  export type Response = z.infer<typeof Response>
232
232
  }
233
233
 
234
+ export namespace wallet_getAccount {
235
+ /** Parameters for `wallet_getAccount` request. */
236
+ export const Parameters = z.object({
237
+ /** Key hash to look up account by. */
238
+ keyHash: u.hex(),
239
+ })
240
+ export type Parameters = z.infer<typeof Parameters>
241
+
242
+ /** Request for `wallet_getAccount`. */
243
+ export const Request = z.object({
244
+ method: z.literal('wallet_getAccount'),
245
+ params: z.readonly(z.tuple([Parameters])),
246
+ })
247
+ export type Request = z.infer<typeof Request>
248
+
249
+ /** Response for `wallet_getAccount`. */
250
+ export const Response = z.object({
251
+ /** Account address. */
252
+ address: z.nullable(u.address()),
253
+ })
254
+ export type Response = z.infer<typeof Response>
255
+ }
256
+
234
257
  export namespace wallet_getAccounts {
235
258
  /** Parameters for `wallet_getAccounts` request. */
236
259
  export const Parameters = z.object({
@@ -23,6 +23,7 @@ export const Base = z.object({
23
23
  z.literal('p256'),
24
24
  z.literal('secp256k1'),
25
25
  z.literal('webauthn-p256'),
26
+ z.literal('eip1193provider'),
26
27
  ]),
27
28
  })
28
29
  export type Base = z.infer<typeof Base>
@@ -465,6 +465,7 @@ export namespace wallet_connect {
465
465
  ),
466
466
  grantPermissions: z.optional(C.grantPermissions.Request),
467
467
  preCalls: z.optional(C.preCalls.Request),
468
+ providerRdns: z.optional(z.string()),
468
469
  selectAccount: z.optional(
469
470
  z.union([
470
471
  z.boolean(),
@@ -12,7 +12,7 @@ export const defaultConfig = {
12
12
  */
13
13
  export function create(
14
14
  parameters: ExactPartial<Porto.Config> | undefined = {},
15
- ): Porto.Porto {
15
+ ): Porto.RiseWallet {
16
16
  return Porto.create({
17
17
  ...parameters,
18
18
  mode: parameters.mode ?? defaultConfig.mode,
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ export {
8
8
  } from './core/internal/provider.js'
9
9
  export * as Messenger from './core/Messenger.js'
10
10
  export * as Mode from './core/Mode.js'
11
- export * as Porto from './core/Porto.js'
11
+ export * as RiseWallet from './core/Porto.js'
12
12
  export * as RpcSchema from './core/RpcSchema.js'
13
13
  export * as Storage from './core/Storage.js'
14
14
  export * as Transport from './core/Transport.js'
@@ -7,7 +7,11 @@ import type { Payload } from '../core/Messenger.js'
7
7
  import * as Actions from './Actions.js'
8
8
  import type * as Remote from './Porto.js'
9
9
 
10
- const trustedOrigins = ['id.porto.sh', 'localhost:5174', 'localhost:5173']
10
+ const trustedOrigins = [
11
+ 'wallet.risechain.com',
12
+ 'localhost:5174',
13
+ 'localhost:5173',
14
+ ]
11
15
 
12
16
  /**
13
17
  * Event listener which is triggered when a request is ready
@@ -38,7 +38,7 @@ export const defaultConfig = {
38
38
  *
39
39
  * @example
40
40
  * ```ts twoslash
41
- * import { Porto } from 'porto/remote'
41
+ * import { Porto } from 'rise-wallet/remote'
42
42
  * const porto = Porto.create()
43
43
  * ```
44
44
  */
@@ -109,12 +109,12 @@ export type Porto<
109
109
  Chains.Chain,
110
110
  ...Chains.Chain[],
111
111
  ],
112
- > = Porto_.Porto<chains> & {
112
+ > = Porto_.RiseWallet<chains> & {
113
113
  mode: Mode.Mode
114
114
  messenger: OneOf<Messenger.WithReady | Messenger.Messenger>
115
115
  methodPolicies?: MethodPolicies.MethodPolicies | undefined
116
116
  ready: () => Promise<void>
117
- _internal: Porto_.Porto<chains>['_internal'] & {
117
+ _internal: Porto_.RiseWallet<chains>['_internal'] & {
118
118
  remoteStore: StoreApi<RemoteState>
119
119
  }
120
120
  }