rise-wallet 0.3.4 → 0.3.5

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.
@@ -224,6 +224,26 @@ export function iframe(options: iframe.Options = {}) {
224
224
  }
225
225
  })
226
226
 
227
+ // Safari ITP workaround: When accounts are set in the parent's store
228
+ // (after wallet_connect via popup), sync them to the iframe via postMessage.
229
+ // This is necessary because Safari's ITP partitions storage between windows
230
+ // opened from different origins, preventing the iframe from reading accounts
231
+ // stored by the popup even though they share the same origin.
232
+ if (UserAgent.isSafari()) {
233
+ internal.store.subscribe(
234
+ (state) => state.accounts,
235
+ (accounts, prevAccounts) => {
236
+ // Only sync when accounts are added (not when cleared)
237
+ if (accounts.length > 0 && prevAccounts.length === 0) {
238
+ messenger.send('__internal', {
239
+ accounts,
240
+ type: 'sync-accounts',
241
+ })
242
+ }
243
+ },
244
+ )
245
+ }
246
+
227
247
  let bodyStyle: CSSStyleDeclaration | null = null
228
248
 
229
249
  // store the opening element to restore the focus
@@ -118,6 +118,11 @@ export type Schema = [
118
118
  type: 'dialog-lifecycle'
119
119
  action: 'request:close' | 'done:close'
120
120
  }
121
+ | {
122
+ // Sync accounts from popup to iframe (Safari ITP workaround)
123
+ type: 'sync-accounts'
124
+ accounts: Porto.State['accounts']
125
+ }
121
126
  response: undefined
122
127
  },
123
128
  ]
@@ -176,10 +181,8 @@ export function fromWindow(
176
181
  },
177
182
  async send(topic, payload, target) {
178
183
  const id = Utils.uuidv4()
179
- w.postMessage(
180
- Utils.normalizeValue({ id, payload, topic }),
181
- target ?? targetOrigin ?? '*',
182
- )
184
+ const normalizedPayload = Utils.normalizeValue({ id, payload, topic })
185
+ w.postMessage(normalizedPayload, target ?? targetOrigin ?? '*')
183
186
  return { id, payload, topic } as never
184
187
  },
185
188
  async sendAsync(topic, payload, target) {
@@ -210,13 +213,15 @@ export function bridge(parameters: bridge.Parameters): Bridge {
210
213
  let pending = false
211
214
 
212
215
  const ready = promise.withResolvers<ReadyOptions>()
216
+ // Prevent unhandled rejection if ready is rejected during destroy
217
+ ready.promise.catch(() => {})
213
218
  from_.on('ready', ready.resolve)
214
219
 
215
220
  const messenger = from({
216
221
  destroy() {
217
222
  from_.destroy()
218
223
  to.destroy()
219
- if (pending) ready.reject()
224
+ if (pending) ready.reject(new Error('Messenger destroyed'))
220
225
  },
221
226
  on(topic, listener, id) {
222
227
  return from_.on(topic, listener, id)
@@ -565,6 +565,7 @@ export function relay(parameters: relay.Parameters = {}) {
565
565
  address: null,
566
566
  payload: digest,
567
567
  typedData,
568
+ verificationOptional: true,
568
569
  })
569
570
  await RelayActions.sendPreparedCalls(client, {
570
571
  context,