@frak-labs/nexus-sdk 0.0.20 → 0.0.21

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.
@@ -3,7 +3,7 @@ import {
3
3
  FrakContextManager,
4
4
  FrakRpcError,
5
5
  RpcErrorCodes
6
- } from "./chunk-7K4L7VQC.js";
6
+ } from "./chunk-ZRPCX25Q.js";
7
7
  import {
8
8
  ReferralInteractionEncoder
9
9
  } from "./chunk-TIKEZMSD.js";
@@ -106,51 +106,69 @@ async function processReferral(client, {
106
106
  walletStatus: walletStatus2,
107
107
  frakContext,
108
108
  modalConfig,
109
- productId
109
+ productId,
110
+ options
110
111
  }) {
111
- try {
112
- let currentWallet = walletStatus2?.wallet;
113
- if (!frakContext?.r) {
114
- if (currentWallet) {
115
- FrakContextManager.replaceUrl({
116
- url: window.location?.href,
117
- context: { r: currentWallet }
118
- });
119
- }
120
- return "no-referrer";
121
- }
122
- let walletRequested = false;
123
- if (!currentWallet) {
124
- currentWallet = await ensureWalletConnected(client, {
125
- modalConfig,
126
- walletStatus: walletStatus2
127
- });
128
- walletRequested = true;
129
- }
130
- if (currentWallet && isAddressEqual(frakContext.r, currentWallet)) {
131
- return "self-referral";
132
- }
133
- if (!(walletStatus2?.interactionSession || walletRequested)) {
134
- currentWallet = await ensureWalletConnected(client, {
135
- modalConfig,
136
- walletStatus: walletStatus2
137
- });
138
- }
139
- if (currentWallet) {
140
- FrakContextManager.replaceUrl({
141
- url: window.location?.href,
142
- context: { r: currentWallet }
143
- });
112
+ let walletRequest = false;
113
+ async function getFreshWalletStatus() {
114
+ if (walletRequest) {
115
+ return;
144
116
  }
117
+ walletRequest = true;
118
+ return ensureWalletConnected(client, {
119
+ modalConfig,
120
+ walletStatus: walletStatus2
121
+ });
122
+ }
123
+ async function pushReferralInteraction(referrer) {
145
124
  const interaction = ReferralInteractionEncoder.referred({
146
- referrer: frakContext.r
125
+ referrer
147
126
  });
148
127
  await sendInteraction(client, { productId, interaction });
149
- return "success";
128
+ }
129
+ try {
130
+ const { status, currentWallet } = await processReferralLogic({
131
+ initialWalletStatus: walletStatus2,
132
+ getFreshWalletStatus,
133
+ pushReferralInteraction,
134
+ frakContext
135
+ });
136
+ FrakContextManager.replaceUrl({
137
+ url: window.location?.href,
138
+ context: options?.alwaysAppendUrl ? { r: currentWallet } : null
139
+ });
140
+ return status;
150
141
  } catch (error) {
142
+ console.log("Error processing referral", { error });
143
+ FrakContextManager.replaceUrl({
144
+ url: window.location?.href,
145
+ context: options?.alwaysAppendUrl ? { r: walletStatus2?.wallet } : null
146
+ });
151
147
  return mapErrorToState(error);
152
148
  }
153
149
  }
150
+ async function processReferralLogic({
151
+ initialWalletStatus,
152
+ getFreshWalletStatus,
153
+ pushReferralInteraction,
154
+ frakContext
155
+ }) {
156
+ let currentWallet = initialWalletStatus?.wallet;
157
+ if (!frakContext?.r) {
158
+ return { status: "no-referrer", currentWallet };
159
+ }
160
+ if (!currentWallet) {
161
+ currentWallet = await getFreshWalletStatus();
162
+ }
163
+ if (currentWallet && isAddressEqual(frakContext.r, currentWallet)) {
164
+ return { status: "self-referral", currentWallet };
165
+ }
166
+ if (!initialWalletStatus?.interactionSession) {
167
+ currentWallet = await getFreshWalletStatus();
168
+ }
169
+ await pushReferralInteraction(frakContext.r);
170
+ return { status: "success", currentWallet };
171
+ }
154
172
  async function ensureWalletConnected(client, {
155
173
  modalConfig,
156
174
  walletStatus: walletStatus2
@@ -181,7 +199,8 @@ function mapErrorToState(error) {
181
199
  // src/core/actions/referral/referralInteraction.ts
182
200
  async function referralInteraction(client, {
183
201
  productId,
184
- modalConfig
202
+ modalConfig,
203
+ options
185
204
  } = {}) {
186
205
  const frakContext = FrakContextManager.parse({
187
206
  url: window.location.href
@@ -192,7 +211,8 @@ async function referralInteraction(client, {
192
211
  walletStatus: currentWalletStatus,
193
212
  frakContext,
194
213
  modalConfig,
195
- productId
214
+ productId,
215
+ options
196
216
  });
197
217
  } catch (error) {
198
218
  return error;
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkYDZBXUC4cjs = require('./chunk-YDZBXUC4.cjs');
9
+ var _chunkE527CMMJcjs = require('./chunk-E527CMMJ.cjs');
10
10
 
11
11
  // src/core/utils/constants.ts
12
12
  var BACKUP_KEY = "nexus-wallet-backup";
@@ -31,7 +31,7 @@ function createIFrameChannelManager() {
31
31
  function createIFrameLifecycleManager({
32
32
  iframe
33
33
  }) {
34
- const isConnectedDeferred = new (0, _chunkYDZBXUC4cjs.Deferred)();
34
+ const isConnectedDeferred = new (0, _chunkE527CMMJcjs.Deferred)();
35
35
  const handler = async (messageEvent) => {
36
36
  switch (messageEvent.iframeLifecycle) {
37
37
  // Resolve the isConnected promise
@@ -53,7 +53,7 @@ function createIFrameLifecycleManager({
53
53
  // Change iframe visibility
54
54
  case "show":
55
55
  case "hide":
56
- _chunkYDZBXUC4cjs.changeIframeVisibility.call(void 0, {
56
+ _chunkE527CMMJcjs.changeIframeVisibility.call(void 0, {
57
57
  iframe,
58
58
  isVisible: messageEvent.iframeLifecycle === "show"
59
59
  });
@@ -74,14 +74,14 @@ function createIFrameMessageHandler({
74
74
  iframeLifecycleManager
75
75
  }) {
76
76
  if (typeof window === "undefined") {
77
- throw new (0, _chunkYDZBXUC4cjs.FrakRpcError)(
78
- _chunkYDZBXUC4cjs.RpcErrorCodes.configError,
77
+ throw new (0, _chunkE527CMMJcjs.FrakRpcError)(
78
+ _chunkE527CMMJcjs.RpcErrorCodes.configError,
79
79
  "iframe client should be used in the browser"
80
80
  );
81
81
  }
82
82
  if (!iframe.contentWindow) {
83
- throw new (0, _chunkYDZBXUC4cjs.FrakRpcError)(
84
- _chunkYDZBXUC4cjs.RpcErrorCodes.configError,
83
+ throw new (0, _chunkE527CMMJcjs.FrakRpcError)(
84
+ _chunkE527CMMJcjs.RpcErrorCodes.configError,
85
85
  "The iframe does not have a product window"
86
86
  );
87
87
  }
@@ -141,17 +141,17 @@ function createIFrameNexusClient({
141
141
  const request = async (args) => {
142
142
  const isConnected = await lifecycleManager.isConnected;
143
143
  if (!isConnected) {
144
- throw new (0, _chunkYDZBXUC4cjs.FrakRpcError)(
145
- _chunkYDZBXUC4cjs.RpcErrorCodes.clientNotConnected,
144
+ throw new (0, _chunkE527CMMJcjs.FrakRpcError)(
145
+ _chunkE527CMMJcjs.RpcErrorCodes.clientNotConnected,
146
146
  "The iframe provider isn't connected yet"
147
147
  );
148
148
  }
149
- const result = new (0, _chunkYDZBXUC4cjs.Deferred)();
149
+ const result = new (0, _chunkE527CMMJcjs.Deferred)();
150
150
  const channelId = channelManager.createChannel(async (message) => {
151
- const decompressed = await _chunkYDZBXUC4cjs.decompressDataAndCheckHash.call(void 0, message.data);
151
+ const decompressed = await _chunkE527CMMJcjs.decompressDataAndCheckHash.call(void 0, message.data);
152
152
  if (decompressed.error) {
153
153
  result.reject(
154
- new (0, _chunkYDZBXUC4cjs.FrakRpcError)(
154
+ new (0, _chunkE527CMMJcjs.FrakRpcError)(
155
155
  decompressed.error.code,
156
156
  decompressed.error.message,
157
157
  _optionalChain([decompressed, 'access', _ => _.error, 'optionalAccess', _2 => _2.data])
@@ -162,7 +162,7 @@ function createIFrameNexusClient({
162
162
  }
163
163
  channelManager.removeChannel(channelId);
164
164
  });
165
- const compressedMessage = await _chunkYDZBXUC4cjs.hashAndCompressData.call(void 0, args);
165
+ const compressedMessage = await _chunkE527CMMJcjs.hashAndCompressData.call(void 0, args);
166
166
  messageHandler.sendEvent({
167
167
  id: channelId,
168
168
  topic: args.method,
@@ -173,20 +173,20 @@ function createIFrameNexusClient({
173
173
  const listenerRequest = async (args, callback) => {
174
174
  const isConnected = await lifecycleManager.isConnected;
175
175
  if (!isConnected) {
176
- throw new (0, _chunkYDZBXUC4cjs.FrakRpcError)(
177
- _chunkYDZBXUC4cjs.RpcErrorCodes.clientNotConnected,
176
+ throw new (0, _chunkE527CMMJcjs.FrakRpcError)(
177
+ _chunkE527CMMJcjs.RpcErrorCodes.clientNotConnected,
178
178
  "The iframe provider isn't connected yet"
179
179
  );
180
180
  }
181
181
  const channelId = channelManager.createChannel(async (message) => {
182
- const decompressed = await _chunkYDZBXUC4cjs.decompressDataAndCheckHash.call(void 0, message.data);
182
+ const decompressed = await _chunkE527CMMJcjs.decompressDataAndCheckHash.call(void 0, message.data);
183
183
  if (decompressed.result) {
184
184
  callback(decompressed.result);
185
185
  } else {
186
- throw new (0, _chunkYDZBXUC4cjs.InternalError)("No valid result in the response");
186
+ throw new (0, _chunkE527CMMJcjs.InternalError)("No valid result in the response");
187
187
  }
188
188
  });
189
- const compressedMessage = await _chunkYDZBXUC4cjs.hashAndCompressData.call(void 0, args);
189
+ const compressedMessage = await _chunkE527CMMJcjs.hashAndCompressData.call(void 0, args);
190
190
  messageHandler.sendEvent({
191
191
  id: channelId,
192
192
  topic: args.method,
@@ -235,9 +235,9 @@ function update({
235
235
  if (!url) return null;
236
236
  const currentContext = parse({ url });
237
237
  const mergedContext = currentContext ? { ...currentContext, ...context } : context;
238
- if (!mergedContext.r) return;
238
+ if (!mergedContext.r) return null;
239
239
  const compressedContext = compress(mergedContext);
240
- if (!compressedContext) return;
240
+ if (!compressedContext) return null;
241
241
  const urlObj = new URL(url);
242
242
  urlObj.searchParams.set(contextKey, compressedContext);
243
243
  return urlObj.toString();
@@ -248,17 +248,23 @@ function remove(url) {
248
248
  return urlObj.toString();
249
249
  }
250
250
  function replaceUrl({
251
- url,
251
+ url: baseUrl,
252
252
  context
253
253
  }) {
254
254
  if (!window.location?.href || typeof window === "undefined") {
255
255
  console.error("No window found, can't update context");
256
256
  return;
257
257
  }
258
- const newUrl = update({
259
- url,
260
- context
261
- });
258
+ const url = baseUrl ?? window.location.href;
259
+ let newUrl;
260
+ if (context !== null) {
261
+ newUrl = update({
262
+ url,
263
+ context
264
+ });
265
+ } else {
266
+ newUrl = remove(url);
267
+ }
262
268
  if (!newUrl) return;
263
269
  window.history.replaceState(null, "", newUrl.toString());
264
270
  }
@@ -6,7 +6,7 @@ import {
6
6
  changeIframeVisibility,
7
7
  decompressDataAndCheckHash,
8
8
  hashAndCompressData
9
- } from "./chunk-7K4L7VQC.js";
9
+ } from "./chunk-ZRPCX25Q.js";
10
10
 
11
11
  // src/core/utils/constants.ts
12
12
  var BACKUP_KEY = "nexus-wallet-backup";
@@ -8,8 +8,8 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkQRECYKIRcjs = require('../../chunk-QRECYKIR.cjs');
12
- require('../../chunk-YDZBXUC4.cjs');
11
+ var _chunkBSCR57ZIcjs = require('../../chunk-BSCR57ZI.cjs');
12
+ require('../../chunk-E527CMMJ.cjs');
13
13
  require('../../chunk-A3XYA7S7.cjs');
14
14
  require('../../chunk-UFJ7W6CQ.cjs');
15
15
 
@@ -22,4 +22,4 @@ require('../../chunk-UFJ7W6CQ.cjs');
22
22
 
23
23
 
24
24
 
25
- exports.displayModal = _chunkQRECYKIRcjs.displayModal; exports.openSso = _chunkQRECYKIRcjs.openSso; exports.processReferral = _chunkQRECYKIRcjs.processReferral; exports.referralInteraction = _chunkQRECYKIRcjs.referralInteraction; exports.sendInteraction = _chunkQRECYKIRcjs.sendInteraction; exports.sendTransaction = _chunkQRECYKIRcjs.sendTransaction; exports.siweAuthenticate = _chunkQRECYKIRcjs.siweAuthenticate; exports.walletStatus = _chunkQRECYKIRcjs.walletStatus; exports.watchWalletStatus = _chunkQRECYKIRcjs.watchWalletStatus;
25
+ exports.displayModal = _chunkBSCR57ZIcjs.displayModal; exports.openSso = _chunkBSCR57ZIcjs.openSso; exports.processReferral = _chunkBSCR57ZIcjs.processReferral; exports.referralInteraction = _chunkBSCR57ZIcjs.referralInteraction; exports.sendInteraction = _chunkBSCR57ZIcjs.sendInteraction; exports.sendTransaction = _chunkBSCR57ZIcjs.sendTransaction; exports.siweAuthenticate = _chunkBSCR57ZIcjs.siweAuthenticate; exports.walletStatus = _chunkBSCR57ZIcjs.walletStatus; exports.watchWalletStatus = _chunkBSCR57ZIcjs.watchWalletStatus;
@@ -1,8 +1,8 @@
1
- import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../client-DaEox5q4.cjs';
1
+ import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../FrakContext-BsezWx2F.cjs';
2
2
  import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-BngPoHA0.cjs';
3
- export { S as SendTransactionParams, a as SiweAuthenticateModalParams, b as sendTransaction, s as siweAuthenticate } from '../../sendTransaction-MhdJPTWd.cjs';
3
+ import { P as ProcessReferralOptions } from '../../processReferral-YbCg90hu.cjs';
4
+ export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-YbCg90hu.cjs';
4
5
  import { Hex } from 'viem';
5
- import { F as FrakContext } from '../../FrakContext-LbQht1ep.cjs';
6
6
  import 'viem/chains';
7
7
  import 'viem/siwe';
8
8
 
@@ -38,25 +38,10 @@ declare function openSso(client: NexusClient, args: OpenSsoParamsType): Promise<
38
38
 
39
39
  declare function walletStatus(client: NexusClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
40
40
 
41
- declare function referralInteraction(client: NexusClient, { productId, modalConfig, }?: {
41
+ declare function referralInteraction(client: NexusClient, { productId, modalConfig, options, }?: {
42
42
  productId?: Hex;
43
43
  modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
44
+ options?: ProcessReferralOptions;
44
45
  }): Promise<unknown>;
45
46
 
46
- type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
47
- /**
48
- * Automatically submit a referral interaction when detected
49
- * -> And automatically set the referral context in the url
50
- * @param walletStatus
51
- * @param frakContext
52
- * @param modalConfig
53
- * @param productId
54
- */
55
- declare function processReferral(client: NexusClient, { walletStatus, frakContext, modalConfig, productId, }: {
56
- walletStatus?: WalletStatusReturnType;
57
- frakContext?: Partial<FrakContext> | null;
58
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
59
- productId?: Hex;
60
- }): Promise<ReferralState>;
61
-
62
- export { displayModal, openSso, processReferral, referralInteraction, sendInteraction, walletStatus, watchWalletStatus };
47
+ export { displayModal, openSso, referralInteraction, sendInteraction, walletStatus, watchWalletStatus };
@@ -1,8 +1,8 @@
1
- import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../client-ALy_TEwJ.js';
1
+ import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, d as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../../FrakContext-p0Jtv9gl.js';
2
2
  import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-BngPoHA0.js';
3
- export { S as SendTransactionParams, a as SiweAuthenticateModalParams, b as sendTransaction, s as siweAuthenticate } from '../../sendTransaction-BOd-pvXr.js';
3
+ import { P as ProcessReferralOptions } from '../../processReferral-t3gUNwJu.js';
4
+ export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-t3gUNwJu.js';
4
5
  import { Hex } from 'viem';
5
- import { F as FrakContext } from '../../FrakContext-LbQht1ep.js';
6
6
  import 'viem/chains';
7
7
  import 'viem/siwe';
8
8
 
@@ -38,25 +38,10 @@ declare function openSso(client: NexusClient, args: OpenSsoParamsType): Promise<
38
38
 
39
39
  declare function walletStatus(client: NexusClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
40
40
 
41
- declare function referralInteraction(client: NexusClient, { productId, modalConfig, }?: {
41
+ declare function referralInteraction(client: NexusClient, { productId, modalConfig, options, }?: {
42
42
  productId?: Hex;
43
43
  modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
44
+ options?: ProcessReferralOptions;
44
45
  }): Promise<unknown>;
45
46
 
46
- type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
47
- /**
48
- * Automatically submit a referral interaction when detected
49
- * -> And automatically set the referral context in the url
50
- * @param walletStatus
51
- * @param frakContext
52
- * @param modalConfig
53
- * @param productId
54
- */
55
- declare function processReferral(client: NexusClient, { walletStatus, frakContext, modalConfig, productId, }: {
56
- walletStatus?: WalletStatusReturnType;
57
- frakContext?: Partial<FrakContext> | null;
58
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
59
- productId?: Hex;
60
- }): Promise<ReferralState>;
61
-
62
- export { displayModal, openSso, processReferral, referralInteraction, sendInteraction, walletStatus, watchWalletStatus };
47
+ export { displayModal, openSso, referralInteraction, sendInteraction, walletStatus, watchWalletStatus };
@@ -8,8 +8,8 @@ import {
8
8
  siweAuthenticate,
9
9
  walletStatus,
10
10
  watchWalletStatus
11
- } from "../../chunk-6LI5YIZB.js";
12
- import "../../chunk-7K4L7VQC.js";
11
+ } from "../../chunk-MDGMJ6EQ.js";
12
+ import "../../chunk-ZRPCX25Q.js";
13
13
  import "../../chunk-TIKEZMSD.js";
14
14
  import "../../chunk-HY6YATLS.js";
15
15
  export {
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk2SDBW6QCcjs = require('../chunk-2SDBW6QC.cjs');
3
+ var _chunkWXNW7ZMUcjs = require('../chunk-WXNW7ZMU.cjs');
4
4
 
5
5
 
6
6
 
@@ -11,7 +11,7 @@ var _chunk2SDBW6QCcjs = require('../chunk-2SDBW6QC.cjs');
11
11
 
12
12
 
13
13
 
14
- var _chunkYDZBXUC4cjs = require('../chunk-YDZBXUC4.cjs');
14
+ var _chunkE527CMMJcjs = require('../chunk-E527CMMJ.cjs');
15
15
 
16
16
 
17
17
 
@@ -31,4 +31,4 @@ var _chunkUFJ7W6CQcjs = require('../chunk-UFJ7W6CQ.cjs');
31
31
 
32
32
 
33
33
 
34
- exports.Deferred = _chunkYDZBXUC4cjs.Deferred; exports.FrakContextManager = _chunkYDZBXUC4cjs.FrakContextManager; exports.FrakRpcError = _chunkYDZBXUC4cjs.FrakRpcError; exports.RpcErrorCodes = _chunkYDZBXUC4cjs.RpcErrorCodes; exports.compressJson = _chunkYDZBXUC4cjs.compressJson; exports.createIFrameNexusClient = _chunk2SDBW6QCcjs.createIFrameNexusClient; exports.createIframe = _chunkYDZBXUC4cjs.createIframe; exports.decompressDataAndCheckHash = _chunkYDZBXUC4cjs.decompressDataAndCheckHash; exports.decompressJson = _chunkYDZBXUC4cjs.decompressJson; exports.hashAndCompressData = _chunkYDZBXUC4cjs.hashAndCompressData; exports.interactionTypes = _chunkUFJ7W6CQcjs.interactionTypes; exports.productTypes = _chunkUFJ7W6CQcjs.productTypes; exports.productTypesMask = _chunkUFJ7W6CQcjs.productTypesMask;
34
+ exports.Deferred = _chunkE527CMMJcjs.Deferred; exports.FrakContextManager = _chunkE527CMMJcjs.FrakContextManager; exports.FrakRpcError = _chunkE527CMMJcjs.FrakRpcError; exports.RpcErrorCodes = _chunkE527CMMJcjs.RpcErrorCodes; exports.compressJson = _chunkE527CMMJcjs.compressJson; exports.createIFrameNexusClient = _chunkWXNW7ZMUcjs.createIFrameNexusClient; exports.createIframe = _chunkE527CMMJcjs.createIframe; exports.decompressDataAndCheckHash = _chunkE527CMMJcjs.decompressDataAndCheckHash; exports.decompressJson = _chunkE527CMMJcjs.decompressJson; exports.hashAndCompressData = _chunkE527CMMJcjs.hashAndCompressData; exports.interactionTypes = _chunkUFJ7W6CQcjs.interactionTypes; exports.productTypes = _chunkUFJ7W6CQcjs.productTypes; exports.productTypesMask = _chunkUFJ7W6CQcjs.productTypesMask;
@@ -1,7 +1,6 @@
1
- import { N as NexusWalletSdkConfig, a as NexusClient } from '../client-DaEox5q4.cjs';
2
- export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, s as ExtractedReturnTypeFromRpc, n as FinalActionType, F as FinalModalStepType, q as IFrameEvent, r as IFrameLifecycleEvent, p as IFrameRpcEvent, I as IFrameRpcSchema, o as IFrameTransport, L as LoginModalStepType, b as ModalRpcMetadata, c as ModalRpcStepsInput, d as ModalRpcStepsResultType, e as ModalStepMetadata, M as ModalStepTypes, m as OpenInteractionSessionModalStepType, l as OpenInteractionSessionReturnType, O as OpenSsoParamsType, R as RpcResponse, j as SendTransactionModalStepType, k as SendTransactionReturnType, i as SendTransactionTxType, f as SiweAuthenticateModalStepType, h as SiweAuthenticateReturnType, g as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType } from '../client-DaEox5q4.cjs';
1
+ import { N as NexusWalletSdkConfig, a as NexusClient, F as FrakContext } from '../FrakContext-BsezWx2F.cjs';
2
+ export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, t as ExtractedReturnTypeFromRpc, o as FinalActionType, n as FinalModalStepType, r as IFrameEvent, s as IFrameLifecycleEvent, q as IFrameRpcEvent, I as IFrameRpcSchema, p as IFrameTransport, L as LoginModalStepType, b as ModalRpcMetadata, c as ModalRpcStepsInput, d as ModalRpcStepsResultType, e as ModalStepMetadata, M as ModalStepTypes, m as OpenInteractionSessionModalStepType, l as OpenInteractionSessionReturnType, O as OpenSsoParamsType, R as RpcResponse, j as SendTransactionModalStepType, k as SendTransactionReturnType, i as SendTransactionTxType, f as SiweAuthenticateModalStepType, h as SiweAuthenticateReturnType, g as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType } from '../FrakContext-BsezWx2F.cjs';
3
3
  import { Address } from 'viem';
4
- import { F as FrakContext } from '../FrakContext-LbQht1ep.cjs';
5
4
  export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.cjs';
6
5
  export { F as FrakRpcError, R as RpcErrorCodes } from '../error-Dflr3G5x.cjs';
7
6
  import 'viem/chains';
@@ -89,7 +88,7 @@ declare function parse({ url }: {
89
88
  declare function update({ url, context, }: {
90
89
  url?: string;
91
90
  context: Partial<FrakContext>;
92
- }): string | null | undefined;
91
+ }): string | null;
93
92
  /**
94
93
  * Remove Nexus context from current url
95
94
  */
@@ -99,9 +98,9 @@ declare function remove(url: string): string;
99
98
  * @param url
100
99
  * @param context
101
100
  */
102
- declare function replaceUrl({ url, context, }: {
101
+ declare function replaceUrl({ url: baseUrl, context, }: {
103
102
  url?: string;
104
- context: Partial<FrakContext>;
103
+ context: Partial<FrakContext> | null;
105
104
  }): void;
106
105
  /**
107
106
  * Export our frak context "class"
@@ -1,7 +1,6 @@
1
- import { N as NexusWalletSdkConfig, a as NexusClient } from '../client-ALy_TEwJ.js';
2
- export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, s as ExtractedReturnTypeFromRpc, n as FinalActionType, F as FinalModalStepType, q as IFrameEvent, r as IFrameLifecycleEvent, p as IFrameRpcEvent, I as IFrameRpcSchema, o as IFrameTransport, L as LoginModalStepType, b as ModalRpcMetadata, c as ModalRpcStepsInput, d as ModalRpcStepsResultType, e as ModalStepMetadata, M as ModalStepTypes, m as OpenInteractionSessionModalStepType, l as OpenInteractionSessionReturnType, O as OpenSsoParamsType, R as RpcResponse, j as SendTransactionModalStepType, k as SendTransactionReturnType, i as SendTransactionTxType, f as SiweAuthenticateModalStepType, h as SiweAuthenticateReturnType, g as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType } from '../client-ALy_TEwJ.js';
1
+ import { N as NexusWalletSdkConfig, a as NexusClient, F as FrakContext } from '../FrakContext-p0Jtv9gl.js';
2
+ export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, t as ExtractedReturnTypeFromRpc, o as FinalActionType, n as FinalModalStepType, r as IFrameEvent, s as IFrameLifecycleEvent, q as IFrameRpcEvent, I as IFrameRpcSchema, p as IFrameTransport, L as LoginModalStepType, b as ModalRpcMetadata, c as ModalRpcStepsInput, d as ModalRpcStepsResultType, e as ModalStepMetadata, M as ModalStepTypes, m as OpenInteractionSessionModalStepType, l as OpenInteractionSessionReturnType, O as OpenSsoParamsType, R as RpcResponse, j as SendTransactionModalStepType, k as SendTransactionReturnType, i as SendTransactionTxType, f as SiweAuthenticateModalStepType, h as SiweAuthenticateReturnType, g as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType } from '../FrakContext-p0Jtv9gl.js';
3
3
  import { Address } from 'viem';
4
- import { F as FrakContext } from '../FrakContext-LbQht1ep.js';
5
4
  export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.js';
6
5
  export { F as FrakRpcError, R as RpcErrorCodes } from '../error-Dflr3G5x.js';
7
6
  import 'viem/chains';
@@ -89,7 +88,7 @@ declare function parse({ url }: {
89
88
  declare function update({ url, context, }: {
90
89
  url?: string;
91
90
  context: Partial<FrakContext>;
92
- }): string | null | undefined;
91
+ }): string | null;
93
92
  /**
94
93
  * Remove Nexus context from current url
95
94
  */
@@ -99,9 +98,9 @@ declare function remove(url: string): string;
99
98
  * @param url
100
99
  * @param context
101
100
  */
102
- declare function replaceUrl({ url, context, }: {
101
+ declare function replaceUrl({ url: baseUrl, context, }: {
103
102
  url?: string;
104
- context: Partial<FrakContext>;
103
+ context: Partial<FrakContext> | null;
105
104
  }): void;
106
105
  /**
107
106
  * Export our frak context "class"
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createIFrameNexusClient
3
- } from "../chunk-54MUKMZK.js";
3
+ } from "../chunk-ZZ7LUFNV.js";
4
4
  import {
5
5
  Deferred,
6
6
  FrakContextManager,
@@ -11,7 +11,7 @@ import {
11
11
  decompressDataAndCheckHash,
12
12
  decompressJson,
13
13
  hashAndCompressData
14
- } from "../chunk-7K4L7VQC.js";
14
+ } from "../chunk-ZRPCX25Q.js";
15
15
  import {
16
16
  interactionTypes,
17
17
  productTypes,
@@ -0,0 +1,53 @@
1
+ import { g as SiweAuthenticationParams, b as ModalRpcMetadata, a as NexusClient, h as SiweAuthenticateReturnType, j as SendTransactionModalStepType, k as SendTransactionReturnType, W as WalletStatusReturnType, F as FrakContext, D as DisplayModalParamsType, M as ModalStepTypes } from './FrakContext-BsezWx2F.cjs';
2
+ import { Hex } from 'viem';
3
+
4
+ /**
5
+ * Partial SIWE params, since we can rebuild them from the SDK if they are empty
6
+ */
7
+ type SiweAuthenticateModalParams = {
8
+ siwe?: Partial<SiweAuthenticationParams>;
9
+ metadata?: ModalRpcMetadata;
10
+ };
11
+ /**
12
+ * Function used to launch a siwe authentication
13
+ * @param client
14
+ * @param siwe
15
+ * @param context
16
+ */
17
+ declare function siweAuthenticate(client: NexusClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
18
+
19
+ type SendTransactionParams = {
20
+ tx: SendTransactionModalStepType["params"]["tx"];
21
+ metadata?: ModalRpcMetadata;
22
+ };
23
+ /**
24
+ * Function used to send a user transaction
25
+ * @param client
26
+ * @param tx
27
+ * @param context
28
+ */
29
+ declare function sendTransaction(client: NexusClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
30
+
31
+ type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
32
+ type ProcessReferralOptions = {
33
+ alwaysAppendUrl?: boolean;
34
+ };
35
+ /**
36
+ * Automatically submit a referral interaction when detected
37
+ * -> And automatically set the referral context in the url
38
+ * @param client
39
+ * @param walletStatus
40
+ * @param frakContext
41
+ * @param modalConfig
42
+ * @param productId
43
+ * @param options
44
+ */
45
+ declare function processReferral(client: NexusClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
46
+ walletStatus?: WalletStatusReturnType;
47
+ frakContext?: Partial<FrakContext> | null;
48
+ modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
49
+ productId?: Hex;
50
+ options?: ProcessReferralOptions;
51
+ }): Promise<ReferralState>;
52
+
53
+ export { type ProcessReferralOptions as P, type SendTransactionParams as S, type SiweAuthenticateModalParams as a, sendTransaction as b, processReferral as p, siweAuthenticate as s };
@@ -0,0 +1,53 @@
1
+ import { g as SiweAuthenticationParams, b as ModalRpcMetadata, a as NexusClient, h as SiweAuthenticateReturnType, j as SendTransactionModalStepType, k as SendTransactionReturnType, W as WalletStatusReturnType, F as FrakContext, D as DisplayModalParamsType, M as ModalStepTypes } from './FrakContext-p0Jtv9gl.js';
2
+ import { Hex } from 'viem';
3
+
4
+ /**
5
+ * Partial SIWE params, since we can rebuild them from the SDK if they are empty
6
+ */
7
+ type SiweAuthenticateModalParams = {
8
+ siwe?: Partial<SiweAuthenticationParams>;
9
+ metadata?: ModalRpcMetadata;
10
+ };
11
+ /**
12
+ * Function used to launch a siwe authentication
13
+ * @param client
14
+ * @param siwe
15
+ * @param context
16
+ */
17
+ declare function siweAuthenticate(client: NexusClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
18
+
19
+ type SendTransactionParams = {
20
+ tx: SendTransactionModalStepType["params"]["tx"];
21
+ metadata?: ModalRpcMetadata;
22
+ };
23
+ /**
24
+ * Function used to send a user transaction
25
+ * @param client
26
+ * @param tx
27
+ * @param context
28
+ */
29
+ declare function sendTransaction(client: NexusClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
30
+
31
+ type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
32
+ type ProcessReferralOptions = {
33
+ alwaysAppendUrl?: boolean;
34
+ };
35
+ /**
36
+ * Automatically submit a referral interaction when detected
37
+ * -> And automatically set the referral context in the url
38
+ * @param client
39
+ * @param walletStatus
40
+ * @param frakContext
41
+ * @param modalConfig
42
+ * @param productId
43
+ * @param options
44
+ */
45
+ declare function processReferral(client: NexusClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
46
+ walletStatus?: WalletStatusReturnType;
47
+ frakContext?: Partial<FrakContext> | null;
48
+ modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
49
+ productId?: Hex;
50
+ options?: ProcessReferralOptions;
51
+ }): Promise<ReferralState>;
52
+
53
+ export { type ProcessReferralOptions as P, type SendTransactionParams as S, type SiweAuthenticateModalParams as a, sendTransaction as b, processReferral as p, siweAuthenticate as s };