@campnetwork/origin 0.0.2 → 0.0.4

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.
package/dist/core.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import t from"axios";import{custom as e,createWalletClient as i,createPublicClient as n,http as s,getAbiItem as r,encodeFunctionData as o}from"viem";import{toAccount as a}from"viem/accounts";import{createSiweMessage as d}from"viem/siwe";
1
+ import t from"axios";import{custom as e,createWalletClient as n,createPublicClient as i,http as a,erc20Abi as r,getAbiItem as s,encodeFunctionData as o,zeroAddress as d}from"viem";import{toAccount as u}from"viem/accounts";import{createSiweMessage as l}from"viem/siwe";
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -13,7 +13,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */function h(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{d(n.next(t))}catch(t){r(t)}}function a(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}d((n=n.apply(t,e||[])).next())}))}function c(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function l(t,e,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(t,i):s?s.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;class u extends Error{constructor(t,e){super(t),this.name="APIError",this.statusCode=e||500,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:this.statusCode||500}}}
16
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */function p(t,e,n,i){return new(n||(n=Promise))((function(a,r){function s(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}d((i=i.apply(t,e||[])).next())}))}function c(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function y(t,e,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(t,n):a?a.value=n:e.set(t,n),n}"function"==typeof SuppressedError&&SuppressedError;class h extends Error{constructor(t,e){super(t),this.name="APIError",this.statusCode=e||500,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:this.statusCode||500}}}
17
17
  /**
18
18
  * Makes a GET request to the given URL with the provided headers.
19
19
  *
@@ -21,7 +21,7 @@ PERFORMANCE OF THIS SOFTWARE.
21
21
  * @param {object} headers - The headers to include in the request.
22
22
  * @returns {Promise<object>} - The response data.
23
23
  * @throws {APIError} - Throws an error if the request fails.
24
- */function f(e){return h(this,arguments,void 0,(function*(e,i={}){try{return(yield t.get(e,{headers:i})).data}catch(t){if(t.response)throw new u(t.response.data.message||"API request failed",t.response.status);throw new u("Network error or server is unavailable",500)}}))}
24
+ */function m(e){return p(this,arguments,void 0,(function*(e,n={}){try{return(yield t.get(e,{headers:n})).data}catch(t){if(t.response)throw new h(t.response.data.message||"API request failed",t.response.status);throw new h("Network error or server is unavailable",500)}}))}
25
25
  /**
26
26
  * Constructs a query string from an object of query parameters.
27
27
  *
@@ -35,13 +35,13 @@ PERFORMANCE OF THIS SOFTWARE.
35
35
  * @param {object} params - An object representing query parameters.
36
36
  * @returns {string} - The complete URL with query string.
37
37
  */
38
- function w(t,e={}){const i=function(t={}){return Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}(e);return i?`${t}?${i}`:t}const m="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",p="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";
38
+ function f(t,e={}){const n=function(t={}){return Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}(e);return n?`${t}?${n}`:t}const w="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",v="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";
39
39
  /**
40
40
  * The TwitterAPI class.
41
41
  * @class
42
42
  * @classdesc The TwitterAPI class is used to interact with the Twitter API.
43
43
  */
44
- class v{
44
+ class T{
45
45
  /**
46
46
  * Constructor for the TwitterAPI class.
47
47
  * @param {object} options - The options object.
@@ -53,7 +53,7 @@ constructor({apiKey:t}){this.apiKey=t}
53
53
  * @param {string} twitterUserName - The Twitter username.
54
54
  * @returns {Promise<object>} - The user details.
55
55
  * @throws {APIError} - Throws an error if the request fails.
56
- */fetchUserByUsername(t){return h(this,void 0,void 0,(function*(){const e=w(`${m}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
56
+ */fetchUserByUsername(t){return p(this,void 0,void 0,(function*(){const e=f(`${w}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
57
57
  /**
58
58
  * Fetch tweets by Twitter username.
59
59
  * @param {string} twitterUserName - The Twitter username.
@@ -61,7 +61,7 @@ constructor({apiKey:t}){this.apiKey=t}
61
61
  * @param {number} limit - The number of items per page.
62
62
  * @returns {Promise<object>} - The tweets.
63
63
  * @throws {APIError} - Throws an error if the request fails.
64
- */fetchTweetsByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/tweets`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
64
+ */fetchTweetsByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/tweets`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
65
65
  /**
66
66
  * Fetch followers by Twitter username.
67
67
  * @param {string} twitterUserName - The Twitter username.
@@ -69,7 +69,7 @@ constructor({apiKey:t}){this.apiKey=t}
69
69
  * @param {number} limit - The number of items per page.
70
70
  * @returns {Promise<object>} - The followers.
71
71
  * @throws {APIError} - Throws an error if the request fails.
72
- */fetchFollowersByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/followers`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
72
+ */fetchFollowersByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/followers`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
73
73
  /**
74
74
  * Fetch following by Twitter username.
75
75
  * @param {string} twitterUserName - The Twitter username.
@@ -77,13 +77,13 @@ constructor({apiKey:t}){this.apiKey=t}
77
77
  * @param {number} limit - The number of items per page.
78
78
  * @returns {Promise<object>} - The following.
79
79
  * @throws {APIError} - Throws an error if the request fails.
80
- */fetchFollowingByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/following`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
80
+ */fetchFollowingByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/following`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
81
81
  /**
82
82
  * Fetch tweet by tweet ID.
83
83
  * @param {string} tweetId - The tweet ID.
84
84
  * @returns {Promise<object>} - The tweet.
85
85
  * @throws {APIError} - Throws an error if the request fails.
86
- */fetchTweetById(t){return h(this,void 0,void 0,(function*(){const e=w(`${m}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
86
+ */fetchTweetById(t){return p(this,void 0,void 0,(function*(){const e=f(`${w}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
87
87
  /**
88
88
  * Fetch user by wallet address.
89
89
  * @param {string} walletAddress - The wallet address.
@@ -91,7 +91,7 @@ constructor({apiKey:t}){this.apiKey=t}
91
91
  * @param {number} limit - The number of items per page.
92
92
  * @returns {Promise<object>} - The user data.
93
93
  * @throws {APIError} - Throws an error if the request fails.
94
- */fetchUserByWalletAddress(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/wallet-twitter-data`,{walletAddress:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
94
+ */fetchUserByWalletAddress(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/wallet-twitter-data`,{walletAddress:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
95
95
  /**
96
96
  * Fetch reposted tweets by Twitter username.
97
97
  * @param {string} twitterUserName - The Twitter username.
@@ -99,7 +99,7 @@ constructor({apiKey:t}){this.apiKey=t}
99
99
  * @param {number} limit - The number of items per page.
100
100
  * @returns {Promise<object>} - The reposted tweets.
101
101
  * @throws {APIError} - Throws an error if the request fails.
102
- */fetchRepostedByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/reposted`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
102
+ */fetchRepostedByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/reposted`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
103
103
  /**
104
104
  * Fetch replies by Twitter username.
105
105
  * @param {string} twitterUserName - The Twitter username.
@@ -107,7 +107,7 @@ constructor({apiKey:t}){this.apiKey=t}
107
107
  * @param {number} limit - The number of items per page.
108
108
  * @returns {Promise<object>} - The replies.
109
109
  * @throws {APIError} - Throws an error if the request fails.
110
- */fetchRepliesByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/replies`,{twitterUserName:t,page:e,limit:i});return this._fetchDataWithAuth(n)}))}
110
+ */fetchRepliesByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/replies`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
111
111
  /**
112
112
  * Fetch likes by Twitter username.
113
113
  * @param {string} twitterUserName - The Twitter username.
@@ -115,7 +115,7 @@ constructor({apiKey:t}){this.apiKey=t}
115
115
  * @param {number} limit - The number of items per page.
116
116
  * @returns {Promise<object>} - The likes.
117
117
  * @throws {APIError} - Throws an error if the request fails.
118
- */fetchLikesByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/event/likes/${t}`,{page:e,limit:i});return this._fetchDataWithAuth(n)}))}
118
+ */fetchLikesByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/event/likes/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
119
119
  /**
120
120
  * Fetch follows by Twitter username.
121
121
  * @param {string} twitterUserName - The Twitter username.
@@ -123,7 +123,7 @@ constructor({apiKey:t}){this.apiKey=t}
123
123
  * @param {number} limit - The number of items per page.
124
124
  * @returns {Promise<object>} - The follows.
125
125
  * @throws {APIError} - Throws an error if the request fails.
126
- */fetchFollowsByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/event/follows/${t}`,{page:e,limit:i});return this._fetchDataWithAuth(n)}))}
126
+ */fetchFollowsByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/event/follows/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
127
127
  /**
128
128
  * Fetch viewed tweets by Twitter username.
129
129
  * @param {string} twitterUserName - The Twitter username.
@@ -131,17 +131,17 @@ constructor({apiKey:t}){this.apiKey=t}
131
131
  * @param {number} limit - The number of items per page.
132
132
  * @returns {Promise<object>} - The viewed tweets.
133
133
  * @throws {APIError} - Throws an error if the request fails.
134
- */fetchViewedTweetsByUsername(t){return h(this,arguments,void 0,(function*(t,e=1,i=10){const n=w(`${m}/event/viewed-tweets/${t}`,{page:e,limit:i});return this._fetchDataWithAuth(n)}))}
134
+ */fetchViewedTweetsByUsername(t){return p(this,arguments,void 0,(function*(t,e=1,n=10){const i=f(`${w}/event/viewed-tweets/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
135
135
  /**
136
136
  * Private method to fetch data with authorization header.
137
137
  * @param {string} url - The URL to fetch.
138
138
  * @returns {Promise<object>} - The response data.
139
139
  * @throws {APIError} - Throws an error if the request fails.
140
- */_fetchDataWithAuth(t){return h(this,void 0,void 0,(function*(){if(!this.apiKey)throw new u("API key is required for fetching data",401);try{return yield f(t,{"x-api-key":this.apiKey})}catch(t){throw new u(t.message,t.statusCode)}}))}}
140
+ */_fetchDataWithAuth(t){return p(this,void 0,void 0,(function*(){if(!this.apiKey)throw new h("API key is required for fetching data",401);try{return yield m(t,{"x-api-key":this.apiKey})}catch(t){throw new h(t.message,t.statusCode)}}))}}
141
141
  /**
142
142
  * The SpotifyAPI class.
143
143
  * @class
144
- */class y{
144
+ */class b{
145
145
  /**
146
146
  * Constructor for the SpotifyAPI class.
147
147
  * @constructor
@@ -155,85 +155,135 @@ constructor(t){this.apiKey=t.apiKey}
155
155
  * @param {string} spotifyId - The user's Spotify ID.
156
156
  * @returns {Promise<object>} - The saved tracks.
157
157
  * @throws {APIError} - Throws an error if the request fails.
158
- */fetchSavedTracksById(t){return h(this,void 0,void 0,(function*(){const e=w(`${p}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
158
+ */fetchSavedTracksById(t){return p(this,void 0,void 0,(function*(){const e=f(`${v}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
159
159
  /**
160
160
  * Fetch the played tracks of a user by Spotify ID.
161
161
  * @param {string} spotifyId - The user's Spotify ID.
162
162
  * @returns {Promise<object>} - The played tracks.
163
163
  * @throws {APIError} - Throws an error if the request fails.
164
- */fetchPlayedTracksById(t){return h(this,void 0,void 0,(function*(){const e=w(`${p}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
164
+ */fetchPlayedTracksById(t){return p(this,void 0,void 0,(function*(){const e=f(`${v}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
165
165
  /**
166
166
  * Fetch the user's saved albums by Spotify user ID.
167
167
  * @param {string} spotifyId - The user's Spotify ID.
168
168
  * @returns {Promise<object>} - The saved albums.
169
169
  * @throws {APIError} - Throws an error if the request fails.
170
- */fetchSavedAlbumsById(t){return h(this,void 0,void 0,(function*(){const e=w(`${p}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
170
+ */fetchSavedAlbumsById(t){return p(this,void 0,void 0,(function*(){const e=f(`${v}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
171
171
  /**
172
172
  * Fetch the user's saved playlists by Spotify user ID.
173
173
  * @param {string} spotifyId - The user's Spotify ID.
174
174
  * @returns {Promise<object>} - The saved playlists.
175
175
  * @throws {APIError} - Throws an error if the request fails.
176
- */fetchSavedPlaylistsById(t){return h(this,void 0,void 0,(function*(){const e=w(`${p}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
176
+ */fetchSavedPlaylistsById(t){return p(this,void 0,void 0,(function*(){const e=f(`${v}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
177
177
  /**
178
178
  * Fetch the tracks of an album by album ID.
179
179
  * @param {string} spotifyId - The Spotify ID of the user.
180
180
  * @param {string} albumId - The album ID.
181
181
  * @returns {Promise<object>} - The tracks in the album.
182
182
  * @throws {APIError} - Throws an error if the request fails.
183
- */fetchTracksInAlbum(t,e){return h(this,void 0,void 0,(function*(){const i=w(`${p}/album/tracks`,{spotifyId:t,albumId:e});return this._fetchDataWithAuth(i)}))}
183
+ */fetchTracksInAlbum(t,e){return p(this,void 0,void 0,(function*(){const n=f(`${v}/album/tracks`,{spotifyId:t,albumId:e});return this._fetchDataWithAuth(n)}))}
184
184
  /**
185
185
  * Fetch the tracks in a playlist by playlist ID.
186
186
  * @param {string} spotifyId - The Spotify ID of the user.
187
187
  * @param {string} playlistId - The playlist ID.
188
188
  * @returns {Promise<object>} - The tracks in the playlist.
189
189
  * @throws {APIError} - Throws an error if the request fails.
190
- */fetchTracksInPlaylist(t,e){return h(this,void 0,void 0,(function*(){const i=w(`${p}/playlist/tracks`,{spotifyId:t,playlistId:e});return this._fetchDataWithAuth(i)}))}
190
+ */fetchTracksInPlaylist(t,e){return p(this,void 0,void 0,(function*(){const n=f(`${v}/playlist/tracks`,{spotifyId:t,playlistId:e});return this._fetchDataWithAuth(n)}))}
191
191
  /**
192
192
  * Fetch the user's Spotify data by wallet address.
193
193
  * @param {string} walletAddress - The wallet address.
194
194
  * @returns {Promise<object>} - The user's Spotify data.
195
195
  * @throws {APIError} - Throws an error if the request fails.
196
- */fetchUserByWalletAddress(t){return h(this,void 0,void 0,(function*(){const e=w(`${p}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
196
+ */fetchUserByWalletAddress(t){return p(this,void 0,void 0,(function*(){const e=f(`${v}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
197
197
  /**
198
198
  * Private method to fetch data with authorization header.
199
199
  * @param {string} url - The URL to fetch.
200
200
  * @returns {Promise<object>} - The response data.
201
201
  * @throws {APIError} - Throws an error if the request fails.
202
- */_fetchDataWithAuth(t){return h(this,void 0,void 0,(function*(){if(!this.apiKey)throw new u("API key is required for fetching data",401);try{return yield f(t,{"x-api-key":this.apiKey})}catch(t){throw new u(t.message,t.statusCode)}}))}}const g={id:123420001114,name:"Basecamp",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc-campnetwork.xyz","https://rpc.basecamp.t.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Explorer",url:"https://basecamp.cloud.blockscout.com/"}}};
202
+ */_fetchDataWithAuth(t){return p(this,void 0,void 0,(function*(){if(!this.apiKey)throw new h("API key is required for fetching data",401);try{return yield m(t,{"x-api-key":this.apiKey})}catch(t){throw new h(t.message,t.statusCode)}}))}}const g={id:123420001114,name:"Basecamp",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc-campnetwork.xyz","https://rpc.basecamp.t.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Explorer",url:"https://basecamp.cloud.blockscout.com/"}}};
203
203
  // @ts-ignore
204
- let I=null,k=null;const T=(t,n="window.ethereum",s)=>{var r;if(!t&&!I)return console.warn("Provider is required to create a client."),null;if(!I||I.transport.name!==n&&t||s!==(null===(r=I.account)||void 0===r?void 0:r.address)&&t){const r={chain:g,transport:e(t,{name:n})};s&&(r.account=a(s)),I=i(r)}return I},A=()=>(k||(k=n({chain:g,transport:s()})),k);var E="Connect with Camp Network",b="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",$={USER_CONNECTED:"ed42542d-b676-4112-b6d9-6db98048b2e0",USER_DISCONNECTED:"20af31ac-e602-442e-9e0e-b589f4dd4016",TWITTER_LINKED:"7fbea086-90ef-4679-ba69-f47f9255b34c",DISCORD_LINKED:"d73f5ae3-a8e8-48f2-8532-85e0c7780d6a",SPOTIFY_LINKED:"fc1788b4-c984-42c8-96f4-c87f6bb0b8f7",TIKTOK_LINKED:"4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",TELEGRAM_LINKED:"9006bc5d-bcc9-4d01-a860-4f1a201e8e47"};let S=[];const j=()=>S,C=t=>{function e(e){S.some((t=>t.info.uuid===e.detail.info.uuid))||(S=[...S,e.detail],t(S))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)};var U,O,N,P,_,D,B,W,x,F,q,K,z,L;
204
+ let I=null,k=null;const A=()=>(k||(k=i({chain:g,transport:a()})),k);var C="Connect with Camp Network",M="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",E={USER_CONNECTED:"ed42542d-b676-4112-b6d9-6db98048b2e0",USER_DISCONNECTED:"20af31ac-e602-442e-9e0e-b589f4dd4016",TWITTER_LINKED:"7fbea086-90ef-4679-ba69-f47f9255b34c",DISCORD_LINKED:"d73f5ae3-a8e8-48f2-8532-85e0c7780d6a",SPOTIFY_LINKED:"fc1788b4-c984-42c8-96f4-c87f6bb0b8f7",TIKTOK_LINKED:"4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",TELEGRAM_LINKED:"9006bc5d-bcc9-4d01-a860-4f1a201e8e47"},x="0xd064817Dc0Af032c3fb5dd4671fd10E0a5F0515D",S="0x3B782d053de8910cC0EF3DC09EEA055229a70c6b";let $=[];const D=()=>$,F=t=>{function e(e){$.some((t=>t.info.uuid===e.detail.info.uuid))||($=[...$,e.detail],t($))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)};var j=[{inputs:[{internalType:"string",name:"_name",type:"string"},{internalType:"string",name:"_symbol",type:"string"},{internalType:"string",name:"_baseURI",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"DurationZero",type:"error"},{inputs:[{internalType:"uint16",name:"royaltyBps",type:"uint16"}],name:"InvalidRoyalty",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"caller",type:"address"}],name:"NotTokenOwner",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"TokenAlreadyExists",type:"error"},{inputs:[],name:"URIQueryForNonexistentToken",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"Verifier_InvalidDeadline",type:"error"},{inputs:[],name:"Verifier_InvalidSignature",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint32",name:"periods",type:"uint32"},{indexed:!1,internalType:"uint64",name:"newExpiry",type:"uint64"},{indexed:!1,internalType:"uint256",name:"amountPaid",type:"uint256"}],name:"AccessPurchased",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"DataDeleted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"}],name:"DataDeletionRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"DataMinted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"royaltyAmount",type:"uint256"},{indexed:!1,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"uint256",name:"protocolAmount",type:"uint256"}],name:"RoyaltyPaid",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"newPrice",type:"uint128"},{indexed:!1,internalType:"uint32",name:"newDuration",type:"uint32"},{indexed:!1,internalType:"uint16",name:"newRoyaltyBps",type:"uint16"},{indexed:!1,internalType:"address",name:"paymentToken",type:"address"}],name:"TermsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"creator",type:"address"}],name:"addCreator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pauser",type:"address"}],name:"addPauser",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner_",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"contentHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"creators",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"dataStatus",outputs:[{internalType:"enum DataNFT.DataStatus",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"finalizeDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getTerms",outputs:[{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner_",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"hash",type:"bytes32"},{internalType:"string",name:"uri",type:"string"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"licenseTerms",type:"tuple"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"mintWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"pausers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"creator",type:"address"}],name:"removeCreator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pauser",type:"address"}],name:"removePauser",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"requestDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"salePrice",type:"uint256"}],name:"royaltyInfo",outputs:[{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"royaltyAmount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyPercentages",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyReceivers",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"terms",outputs:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"newTerms",type:"tuple"}],name:"updateTerms",outputs:[],stateMutability:"nonpayable",type:"function"}];
205
+ /**
206
+ * Mints a Data NFT with a signature.
207
+ * @param to The address to mint the NFT to.
208
+ * @param tokenId The ID of the token to mint.
209
+ * @param hash The hash of the data associated with the NFT.
210
+ * @param uri The URI of the NFT metadata.
211
+ * @param licenseTerms The terms of the license for the NFT.
212
+ * @param deadline The deadline for the minting operation.
213
+ * @param signature The signature for the minting operation.
214
+ * @returns A promise that resolves when the minting is complete.
215
+ */function U(t,e,n,i,a,r,s){return p(this,void 0,void 0,(function*(){return yield this.callContractMethod(x,j,"mintWithSignature",[t,e,n,i,a,r,s.v,s.r,s.s],{waitForReceipt:!0})}))}
216
+ /**
217
+ * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
218
+ * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
219
+ * @param deadline The deadline for the registration operation.
220
+ * @param fileKey Optional file key for file uploads.
221
+ * @return A promise that resolves with the registration data.
222
+ */function P(t,e,n){return p(this,void 0,void 0,(function*(){const i={source:t,deadline:e.toString()};void 0!==n&&(i.fileKey=n);const a=yield fetch(`${M}/auth/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to get signature: ${a.statusText}`);const r=yield a.json();if(r.isError)throw new Error(`Failed to get signature: ${r.message}`);return r.data}))}function N(t,e){return this.callContractMethod(x,j,"updateTerms",[t,e],{waitForReceipt:!0})}function O(t){return this.callContractMethod(x,j,"requestDelete",[t])}function B(t){return this.callContractMethod(x,j,"getTerms",[t])}function _(t){return this.callContractMethod(x,j,"ownerOf",[t])}function W(t){return this.callContractMethod(x,j,"balanceOf",[t])}function R(t){return this.callContractMethod(x,j,"contentHash",[t])}function q(t){return this.callContractMethod(x,j,"tokenURI",[t])}function z(t){return this.callContractMethod(x,j,"dataStatus",[t])}function L(t,e){return p(this,void 0,void 0,(function*(){return this.callContractMethod(x,j,"royaltyInfo",[t,e])}))}function K(t){return this.callContractMethod(x,j,"getApproved",[t])}function J(t,e){return this.callContractMethod(x,j,"isApprovedForAll",[t,e])}function H(t,e,n){return this.callContractMethod(x,j,"transferFrom",[t,e,n])}function G(t,e,n,i){const a=i?[t,e,n,i]:[t,e,n];return this.callContractMethod(x,j,"safeTransferFrom",a)}function V(t,e){return this.callContractMethod(x,j,"approve",[t,e])}function Z(t,e){return this.callContractMethod(x,j,"setApprovalForAll",[t,e])}var Q,Y,X,tt,et,nt,it,at,rt,st,ot,dt,ut,lt,pt,ct=[{type:"constructor",inputs:[{name:"dataNFT_",type:"address",internalType:"address"},{name:"router_",type:"address",internalType:"address"},{name:"protocolFeeBps_",type:"uint16",internalType:"uint16"}],stateMutability:"nonpayable"},{type:"function",name:"addFeeManager",inputs:[{name:"feeManager",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addPauser",inputs:[{name:"pauser",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"buyAccess",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"periods",type:"uint32",internalType:"uint32"}],outputs:[],stateMutability:"payable"},{type:"function",name:"dataNFT",inputs:[],outputs:[{name:"",type:"address",internalType:"contract DataNFT"}],stateMutability:"view"},{type:"function",name:"feeManagers",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"hasAccess",inputs:[{name:"user",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"pausers",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"protocolFeeBps",inputs:[],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"removeFeeManager",inputs:[{name:"feeManager",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"removePauser",inputs:[{name:"pauser",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renewAccess",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"buyer",type:"address",internalType:"address"},{name:"periods",type:"uint32",internalType:"uint32"}],outputs:[],stateMutability:"payable"},{type:"function",name:"router",inputs:[],outputs:[{name:"",type:"address",internalType:"contract RoyaltyRouter"}],stateMutability:"view"},{type:"function",name:"subscriptionExpiry",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateProtocolFee",inputs:[{name:"newFeeBps",type:"uint16",internalType:"uint16"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint64",indexed:!1,internalType:"uint64"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeletionRequested",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"error",name:"DurationZero",inputs:[]},{type:"error",name:"InvalidPayment",inputs:[{name:"expected",type:"uint256",internalType:"uint256"},{name:"actual",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidPeriods",inputs:[{name:"periods",type:"uint32",internalType:"uint32"}]},{type:"error",name:"InvalidRoyalty",inputs:[{name:"royaltyBps",type:"uint16",internalType:"uint16"}]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]}];function yt(t,e,n){return this.callContractMethod(S,ct,"buyAccess",[t,e],{waitForReceipt:!0,value:n})}function ht(t,e,n,i){return this.callContractMethod(S,ct,"renewAccess",[t,e,n],void 0!==i?{value:i}:void 0)}function mt(t,e){return this.callContractMethod(S,ct,"hasAccess",[t,e])}function ft(t,e){return this.callContractMethod(S,ct,"subscriptionExpiry",[t,e])}
223
+ /**
224
+ * Approves a spender to spend a specified amount of tokens on behalf of the owner.
225
+ * If the current allowance is less than the specified amount, it will perform the approval.
226
+ * @param {ApproveParams} params - The parameters for the approval.
227
+ */
205
228
  /**
206
229
  * The Origin class
207
230
  * Handles the upload of files to Origin, as well as querying the user's stats
208
- */class J{constructor(e){U.set(this,(t=>h(this,void 0,void 0,(function*(){const e=yield fetch(`${b}/auth/origin/upload-url`,{method:"POST",body:JSON.stringify({name:t.name,type:t.type}),headers:{Authorization:`Bearer ${this.jwt}`}}),i=yield e.json();return i.isError?i.message:i.data})))),O.set(this,((t,e)=>h(this,void 0,void 0,(function*(){(yield fetch(`${b}/auth/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:e,fileKey:t}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}})).ok||console.error("Failed to update origin status")})))),this.uploadFile=(e,i)=>h(this,void 0,void 0,(function*(){const n=yield c(this,U,"f").call(this,e);if(n){try{yield((e,i,n)=>new Promise(((s,r)=>{t.put(i,e,Object.assign({headers:{"Content-Type":e.type}},"undefined"!=typeof window&&"function"==typeof n?{onUploadProgress:t=>{if(t.total){const e=t.loaded/t.total*100;n(e)}}}:{})).then((t=>{s(t.data)})).catch((t=>{var e;const i=(null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.data)||(null==t?void 0:t.message)||"Upload failed";r(i)}))})))(e,n.url,(null==i?void 0:i.progressCallback)||(()=>{}))}catch(t){throw yield c(this,O,"f").call(this,n.key,"failed"),new Error("Failed to upload file: "+t)}yield c(this,O,"f").call(this,n.key,"success")}else console.error("Failed to generate upload URL")})),this.getOriginUploads=()=>h(this,void 0,void 0,(function*(){const t=yield fetch(`${b}/auth/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!t.ok)return console.error("Failed to get origin uploads"),null;return(yield t.json()).data})),this.jwt=e}
231
+ */
232
+ class wt{constructor(e,n){Q.add(this),Y.set(this,(t=>p(this,void 0,void 0,(function*(){const e=yield fetch(`${M}/auth/origin/upload-url`,{method:"POST",body:JSON.stringify({name:t.name,type:t.type}),headers:{Authorization:`Bearer ${this.jwt}`}}),n=yield e.json();return n.isError?n.message:n.data})))),X.set(this,((t,e)=>p(this,void 0,void 0,(function*(){(yield fetch(`${M}/auth/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:e,fileKey:t}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}})).ok||console.error("Failed to update origin status")})))),this.uploadFile=(e,n)=>p(this,void 0,void 0,(function*(){const i=yield c(this,Y,"f").call(this,e);if(i){try{yield((e,n,i)=>new Promise(((a,r)=>{t.put(n,e,Object.assign({headers:{"Content-Type":e.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:t=>{if(t.total){const e=t.loaded/t.total*100;i(e)}}}:{})).then((t=>{a(t.data)})).catch((t=>{var e;const n=(null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.data)||(null==t?void 0:t.message)||"Upload failed";r(n)}))})))(e,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(t){throw yield c(this,X,"f").call(this,i.key,"failed"),new Error("Failed to upload file: "+t)}return yield c(this,X,"f").call(this,i.key,"success"),i}console.error("Failed to generate upload URL")})),this.mintFile=(t,e,n)=>p(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");try{const i=yield this.uploadFile(t,n);if(!i||!i.key)return console.error("Invalid upload info:",i),null;const a=BigInt(Math.floor(Date.now()/1e3)+600),r=yield this.registerDataNFT("file",a,i.key),{tokenId:s,signerAddress:o,hash:d,v:u,r:l,s:p}=r;// 10 minutes from now
233
+ if(!s||!o||!d||void 0===u||void 0===l||void 0===p)return console.error("Invalid registration data:",r),null;const[c]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),y={v:u,r:l,s:p};yield this.mintWithSignature(c,s,d,i.url,e,a,y);return s.toString()}catch(t){return console.error("Failed to upload file:",t),null}})),this.mintSocial=t=>p(this,void 0,void 0,(function*(){try{const e=BigInt(Math.floor(Date.now()/1e3)+600),n=yield this.registerDataNFT(t,e);// 10 minutes from now (temp)
234
+ return n?n.tokenId.toString():(console.error("Failed to register DataNFT"),null)}catch(t){return console.error("Failed to mint social DataNFT:",t),null}})),this.getOriginUploads=()=>p(this,void 0,void 0,(function*(){const t=yield fetch(`${M}/auth/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!t.ok)return console.error("Failed to get origin uploads"),null;return(yield t.json()).data})),this.jwt=e,this.viemClient=n,
235
+ // DataNFT methods
236
+ this.mintWithSignature=U.bind(this),this.registerDataNFT=P.bind(this),this.updateTerms=N.bind(this),this.requestDelete=O.bind(this),this.getTerms=B.bind(this),this.ownerOf=_.bind(this),this.balanceOf=W.bind(this),this.contentHash=R.bind(this),this.tokenURI=q.bind(this),this.dataStatus=z.bind(this),this.royaltyInfo=L.bind(this),this.getApproved=K.bind(this),this.isApprovedForAll=J.bind(this),this.transferFrom=H.bind(this),this.safeTransferFrom=G.bind(this),this.approve=V.bind(this),this.setApprovalForAll=Z.bind(this),
237
+ // Marketplace methods
238
+ this.buyAccess=yt.bind(this),this.renewAccess=ht.bind(this),this.hasAccess=mt.bind(this),this.subscriptionExpiry=ft.bind(this)}getJwt(){return this.jwt}setViemClient(t){this.viemClient=t}
209
239
  /**
210
240
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
211
241
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
212
- */getOriginUsage(){return h(this,void 0,void 0,(function*(){const t=yield fetch(`${b}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
242
+ */getOriginUsage(){return p(this,void 0,void 0,(function*(){const t=yield fetch(`${M}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
213
243
  // "x-client-id": this.clientId,
214
- "Content-Type":"application/json"}}).then((t=>t.json()));if(!t.isError&&t.data.user)return t;throw new u(t.message||"Failed to fetch Origin usage")}))}
244
+ "Content-Type":"application/json"}}).then((t=>t.json()));if(!t.isError&&t.data.user)return t;throw new h(t.message||"Failed to fetch Origin usage")}))}
215
245
  /**
216
246
  * Set the user's consent for Origin usage.
217
247
  * @param {boolean} consent The user's consent.
218
248
  * @returns {Promise<void>}
219
249
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
220
- */setOriginConsent(t){return h(this,void 0,void 0,(function*(){if(void 0===t)throw new u("Consent is required");const e=yield fetch(`${b}/auth/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
250
+ */setOriginConsent(t){return p(this,void 0,void 0,(function*(){if(void 0===t)throw new h("Consent is required");const e=yield fetch(`${M}/auth/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
221
251
  // "x-client-id": this.clientId,
222
- "Content-Type":"application/json"},body:JSON.stringify({active:t})}).then((t=>t.json()));if(e.isError)throw new u(e.message||"Failed to set Origin consent")}))}
252
+ "Content-Type":"application/json"},body:JSON.stringify({active:t})}).then((t=>t.json()));if(e.isError)throw new h(e.message||"Failed to set Origin consent")}))}
223
253
  /**
224
254
  * Set the user's Origin multiplier.
225
255
  * @param {number} multiplier The user's Origin multiplier.
226
256
  * @returns {Promise<void>}
227
257
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the multiplier is not provided.
228
- */setOriginMultiplier(t){return h(this,void 0,void 0,(function*(){if(void 0===t)throw new u("Multiplier is required");const e=yield fetch(`${b}/auth/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
258
+ */setOriginMultiplier(t){return p(this,void 0,void 0,(function*(){if(void 0===t)throw new h("Multiplier is required");const e=yield fetch(`${M}/auth/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
229
259
  // "x-client-id": this.clientId,
230
- "Content-Type":"application/json"},body:JSON.stringify({multiplier:t})}).then((t=>t.json()));if(e.isError)throw new u(e.message||"Failed to set Origin multiplier")}))}}U=new WeakMap,O=new WeakMap;
260
+ "Content-Type":"application/json"},body:JSON.stringify({multiplier:t})}).then((t=>t.json()));if(e.isError)throw new h(e.message||"Failed to set Origin multiplier")}))}
261
+ /**
262
+ * Call a contract method.
263
+ * @param {string} contractAddress The contract address.
264
+ * @param {Abi} abi The contract ABI.
265
+ * @param {string} methodName The method name.
266
+ * @param {any[]} params The method parameters.
267
+ * @param {CallOptions} [options] The call options.
268
+ * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
269
+ * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
270
+ */callContractMethod(t,e,n,i){return p(this,arguments,void 0,(function*(t,e,n,i,a={}){const r=s({abi:e,name:n}),d=r&&"stateMutability"in r&&("view"===r.stateMutability||"pure"===r.stateMutability);if(!d&&!this.viemClient)throw new Error("WalletClient not connected.");if(d){const a=A();return(yield a.readContract({address:t,abi:e,functionName:n,args:i}))||null}{const[r]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),s=o({abi:e,functionName:n,args:i});yield c(this,Q,"m",et).call(this,g);const d=yield this.viemClient.sendTransaction({to:t,data:s,account:r,value:a.value,gas:a.gas});if("string"!=typeof d)throw new Error("Transaction failed to send.");if(!a.waitForReceipt)return d;return yield c(this,Q,"m",tt).call(this,d)}}))}
271
+ /**
272
+ * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
273
+ * @param {bigint} tokenId The token ID of the asset.
274
+ * @param {number} periods The number of periods to buy access for.
275
+ * @returns {Promise<any>} The result of the buyAccess call.
276
+ */buyAccessSmart(t,e){return p(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const n=yield this.getTerms(t);if(!n)throw new Error("Failed to fetch terms for asset");const{price:i,paymentToken:a}=n;if(void 0===i||void 0===a)throw new Error("Terms missing price or paymentToken");const s=i*BigInt(e);if(a===d)return this.buyAccess(t,e,s);const o=yield this.viemClient.getAddress();return yield function(t){return p(this,arguments,void 0,(function*({walletClient:t,publicClient:e,tokenAddress:n,owner:i,spender:a,amount:s}){(yield e.readContract({address:n,abi:r,functionName:"allowance",args:[i,a]}))<s&&(yield t.writeContract({address:n,account:i,abi:r,functionName:"approve",args:[a,s],chain:g}))}))}({walletClient:this.viemClient,publicClient:A(),tokenAddress:a,owner:o,spender:S,amount:s}),this.buyAccess(t,e)}))}getData(t){return p(this,void 0,void 0,(function*(){const e=yield fetch(`${M}/auth/origin/data/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Failed to fetch data");return e.json()}))}}Y=new WeakMap,X=new WeakMap,Q=new WeakSet,tt=function(t){return p(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");for(;;){const e=yield this.viemClient.request({method:"eth_getTransactionReceipt",params:[t]});if(e&&e.blockNumber)return e;yield new Promise((t=>setTimeout(t,1e3)))}}))},et=function(t){return p(this,void 0,void 0,(function*(){
277
+ // return;
278
+ if(!this.viemClient)throw new Error("WalletClient not connected.");let e=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof e&&(e=parseInt(e,16)),e!==t.id)try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}catch(e){
279
+ // Unrecognized chain
280
+ if(4902!==e.code)throw e;yield this.viemClient.request({method:"wallet_addEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16),chainName:t.name,rpcUrls:t.rpcUrls.default.http,nativeCurrency:t.nativeCurrency}]}),yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}}))};
231
281
  /**
232
282
  * The Auth class.
233
283
  * @class
234
284
  * @classdesc The Auth class is used to authenticate the user.
235
285
  */
236
- class R{
286
+ class vt{
237
287
  /**
238
288
  * Constructor for the Auth class.
239
289
  * @param {object} options The options object.
@@ -243,11 +293,11 @@ class R{
243
293
  * @param {object} [options.ackeeInstance] The Ackee instance.
244
294
  * @throws {APIError} - Throws an error if the clientId is not provided.
245
295
  */
246
- constructor({clientId:t,redirectUri:e,allowAnalytics:i=!0,ackeeInstance:n}){if(N.add(this),P.set(this,void 0),_.set(this,void 0),!t)throw new Error("clientId is required");this.viem=null,
296
+ constructor({clientId:t,redirectUri:e,allowAnalytics:n=!0,ackeeInstance:i}){if(nt.add(this),it.set(this,void 0),at.set(this,void 0),!t)throw new Error("clientId is required");this.viem=null,
247
297
  // if (typeof window !== "undefined") {
248
298
  // if (window.ethereum) this.viem = getClient(window.ethereum);
249
299
  // }
250
- this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==typeof t?e.reduce(((e,i)=>(e[i]=t[i]||("undefined"!=typeof window?window.location.href:""),e)),{}):"string"==typeof t?e.reduce(((e,i)=>(e[i]=t,e)),{}):t?{}:e.reduce(((t,e)=>(t[e]="undefined"!=typeof window?window.location.href:"",t)),{})})(e),n&&l(this,_,n,"f"),i&&c(this,_,"f"),this.clientId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,l(this,P,{},"f"),C((t=>{c(this,N,"m",D).call(this,"providers",t)})),c(this,N,"m",B).call(this)}
300
+ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==typeof t?e.reduce(((e,n)=>(e[n]=t[n]||("undefined"!=typeof window?window.location.href:""),e)),{}):"string"==typeof t?e.reduce(((e,n)=>(e[n]=t,e)),{}):t?{}:e.reduce(((t,e)=>(t[e]="undefined"!=typeof window?window.location.href:"",t)),{})})(e),i&&y(this,at,i,"f"),n&&c(this,at,"f"),this.clientId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,y(this,it,{},"f"),F((t=>{c(this,nt,"m",rt).call(this,"providers",t)})),c(this,nt,"m",st).call(this)}
251
301
  /**
252
302
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
253
303
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
@@ -257,18 +307,18 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
257
307
  * auth.on("state", (state) => {
258
308
  * console.log(state);
259
309
  * });
260
- */on(t,e){c(this,P,"f")[t]||(c(this,P,"f")[t]=[]),c(this,P,"f")[t].push(e),"providers"===t&&e(j())}
310
+ */on(t,e){c(this,it,"f")[t]||(c(this,it,"f")[t]=[]),c(this,it,"f")[t].push(e),"providers"===t&&e(D())}
261
311
  /**
262
312
  * Set the loading state.
263
313
  * @param {boolean} loading The loading state.
264
314
  * @returns {void}
265
- */setLoading(t){c(this,N,"m",D).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
315
+ */setLoading(t){c(this,nt,"m",rt).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
266
316
  /**
267
317
  * Set the provider. This is useful for setting the provider when the user selects a provider from the UI or when dApp wishes to use a specific provider.
268
318
  * @param {object} options The options object. Includes the provider and the provider info.
269
319
  * @returns {void}
270
320
  * @throws {APIError} - Throws an error if the provider is not provided.
271
- */setProvider({provider:t,info:e,address:i}){if(!t)throw new u("provider is required");this.viem=T(t,e.name,i),c(this,N,"m",D).call(this,"viem",this.viem),c(this,N,"m",D).call(this,"provider",{provider:t,info:e})}
321
+ */setProvider({provider:t,info:i,address:a}){if(!t)throw new h("provider is required");this.viem=((t,i="window.ethereum",a)=>{var r;if(!t&&!I)return console.warn("Provider is required to create a client."),null;if(!I||I.transport.name!==i&&t||a!==(null===(r=I.account)||void 0===r?void 0:r.address)&&t){const r={chain:g,transport:e(t,{name:i})};a&&(r.account=u(a)),I=n(r)}return I})(t,i.name,a),this.origin&&this.origin.setViemClient(this.viem),c(this,nt,"m",rt).call(this,"viem",this.viem),c(this,nt,"m",rt).call(this,"provider",{provider:t,info:i})}
272
322
  /**
273
323
  * Set the wallet address. This is useful for edge cases where the provider can't return the wallet address. Don't use this unless you know what you're doing.
274
324
  * @param {string} walletAddress The wallet address.
@@ -277,12 +327,12 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
277
327
  /**
278
328
  * Disconnect the user.
279
329
  * @returns {Promise<void>}
280
- */disconnect(){return h(this,void 0,void 0,(function*(){this.isAuthenticated&&(this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,localStorage.removeItem("camp-sdk:wallet-address"),localStorage.removeItem("camp-sdk:user-id"),localStorage.removeItem("camp-sdk:jwt"),c(this,N,"m",D).call(this,"state","unauthenticated"),yield c(this,N,"m",K).call(this,$.USER_DISCONNECTED,"User Disconnected"))}))}
330
+ */disconnect(){return p(this,void 0,void 0,(function*(){this.isAuthenticated&&(c(this,nt,"m",rt).call(this,"state","unauthenticated"),this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,localStorage.removeItem("camp-sdk:wallet-address"),localStorage.removeItem("camp-sdk:user-id"),localStorage.removeItem("camp-sdk:jwt"))}))}
281
331
  /**
282
332
  * Connect the user's wallet and sign the message.
283
333
  * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
284
334
  * @throws {APIError} - Throws an error if the user cannot be authenticated.
285
- */connect(){return h(this,void 0,void 0,(function*(){c(this,N,"m",D).call(this,"state","loading");try{this.walletAddress||(yield c(this,N,"m",W).call(this));const t=yield c(this,N,"m",x).call(this),e=c(this,N,"m",q).call(this,t),i=yield this.viem.signMessage({account:this.walletAddress,message:e}),n=yield c(this,N,"m",F).call(this,e,i);if(n.success)return this.isAuthenticated=!0,this.userId=n.userId,this.jwt=n.token,this.origin=new J(this.jwt),localStorage.setItem("camp-sdk:jwt",this.jwt),localStorage.setItem("camp-sdk:wallet-address",this.walletAddress),localStorage.setItem("camp-sdk:user-id",this.userId),c(this,N,"m",D).call(this,"state","authenticated"),yield c(this,N,"m",K).call(this,$.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,c(this,N,"m",D).call(this,"state","unauthenticated"),new u("Failed to authenticate")}catch(t){throw this.isAuthenticated=!1,c(this,N,"m",D).call(this,"state","unauthenticated"),new u(t)}}))}
335
+ */connect(){return p(this,void 0,void 0,(function*(){c(this,nt,"m",rt).call(this,"state","loading");try{this.walletAddress||(yield c(this,nt,"m",ot).call(this));const t=yield c(this,nt,"m",dt).call(this),e=c(this,nt,"m",lt).call(this,t),n=yield this.viem.signMessage({account:this.walletAddress,message:e}),i=yield c(this,nt,"m",ut).call(this,e,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new wt(this.jwt,this.viem),localStorage.setItem("camp-sdk:jwt",this.jwt),localStorage.setItem("camp-sdk:wallet-address",this.walletAddress),localStorage.setItem("camp-sdk:user-id",this.userId),c(this,nt,"m",rt).call(this,"state","authenticated"),yield c(this,nt,"m",pt).call(this,E.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,c(this,nt,"m",rt).call(this,"state","unauthenticated"),new h("Failed to authenticate")}catch(t){throw this.isAuthenticated=!1,c(this,nt,"m",rt).call(this,"state","unauthenticated"),new h(t)}}))}
286
336
  /**
287
337
  * Get the user's linked social accounts.
288
338
  * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
@@ -291,49 +341,49 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
291
341
  * const auth = new Auth({ clientId: "your-client-id" });
292
342
  * const socials = await auth.getLinkedSocials();
293
343
  * console.log(socials);
294
- */getLinkedSocials(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${b}/auth/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((t=>t.json()));if(t.isError)throw new u(t.message||"Failed to fetch connections");{const e={};return Object.keys(t.data.data).forEach((i=>{e[i.split("User")[0]]=t.data.data[i]})),e}}))}
344
+ */getLinkedSocials(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${M}/auth/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((t=>t.json()));if(t.isError)throw new h(t.message||"Failed to fetch connections");{const e={};return Object.keys(t.data.data).forEach((n=>{e[n.split("User")[0]]=t.data.data[n]})),e}}))}
295
345
  /**
296
346
  * Link the user's Twitter account.
297
347
  * @returns {Promise<void>}
298
348
  * @throws {Error} - Throws an error if the user is not authenticated.
299
- */linkTwitter(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
349
+ */linkTwitter(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
300
350
  // await this.#sendAnalyticsEvent(
301
351
  // constants.ACKEE_EVENTS.TWITTER_LINKED,
302
352
  // "Twitter Linked"
303
353
  // );
304
- window.location.href=`${b}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
354
+ window.location.href=`${M}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
305
355
  /**
306
356
  * Link the user's Discord account.
307
357
  * @returns {Promise<void>}
308
358
  * @throws {Error} - Throws an error if the user is not authenticated.
309
- */linkDiscord(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
359
+ */linkDiscord(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
310
360
  // await this.#sendAnalyticsEvent(
311
361
  // constants.ACKEE_EVENTS.DISCORD_LINKED,
312
362
  // "Discord Linked"
313
363
  // );
314
- window.location.href=`${b}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
364
+ window.location.href=`${M}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
315
365
  /**
316
366
  * Link the user's Spotify account.
317
367
  * @returns {Promise<void>}
318
368
  * @throws {Error} - Throws an error if the user is not authenticated.
319
- */linkSpotify(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
369
+ */linkSpotify(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
320
370
  // await this.#sendAnalyticsEvent(
321
371
  // constants.ACKEE_EVENTS.SPOTIFY_LINKED,
322
372
  // "Spotify Linked"
323
373
  // );
324
- window.location.href=`${b}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
374
+ window.location.href=`${M}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
325
375
  /**
326
376
  * Link the user's TikTok account.
327
377
  * @param {string} handle The user's TikTok handle.
328
378
  * @returns {Promise<any>} A promise that resolves with the TikTok account data.
329
379
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
330
- */linkTikTok(t){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${b}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:t,clientId:this.clientId,userId:this.userId})}).then((t=>t.json()));if(e.isError)throw"Request failed with status code 502"===e.message?new u("TikTok service is currently unavailable, try again later"):new u(e.message||"Failed to link TikTok account");return c(this,N,"m",K).call(this,$.TIKTOK_LINKED,"TikTok Linked"),e.data}))}
380
+ */linkTikTok(t){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${M}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:t,clientId:this.clientId,userId:this.userId})}).then((t=>t.json()));if(e.isError)throw"Request failed with status code 502"===e.message?new h("TikTok service is currently unavailable, try again later"):new h(e.message||"Failed to link TikTok account");return c(this,nt,"m",pt).call(this,E.TIKTOK_LINKED,"TikTok Linked"),e.data}))}
331
381
  /**
332
382
  * Send an OTP to the user's Telegram account.
333
383
  * @param {string} phoneNumber The user's phone number.
334
384
  * @returns {Promise<any>} A promise that resolves with the OTP data.
335
385
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
336
- */sendTelegramOTP(t){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t)throw new u("Phone number is required");yield this.unlinkTelegram();const e=yield fetch(`${b}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t})}).then((t=>t.json()));if(e.isError)throw new u(e.message||"Failed to send Telegram OTP");return e.data}))}
386
+ */sendTelegramOTP(t){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t)throw new h("Phone number is required");yield this.unlinkTelegram();const e=yield fetch(`${M}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t})}).then((t=>t.json()));if(e.isError)throw new h(e.message||"Failed to send Telegram OTP");return e.data}))}
337
387
  /**
338
388
  * Link the user's Telegram account.
339
389
  * @param {string} phoneNumber The user's phone number.
@@ -341,52 +391,40 @@ window.location.href=`${b}/spotify/connect?clientId=${this.clientId}&userId=${th
341
391
  * @param {string} phoneCodeHash The phone code hash.
342
392
  * @returns {Promise<object>} A promise that resolves with the Telegram account data.
343
393
  * @throws {APIError|Error} - Throws an error if the user is not authenticated. Also throws an error if the phone number, OTP, and phone code hash are not provided.
344
- */linkTelegram(t,e,i){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t||!e||!i)throw new u("Phone number, OTP, and phone code hash are required");const n=yield fetch(`${b}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t,code:e,phone_code_hash:i,userId:this.userId,clientId:this.clientId})}).then((t=>t.json()));if(n.isError)throw new u(n.message||"Failed to link Telegram account");return c(this,N,"m",K).call(this,$.TELEGRAM_LINKED,"Telegram Linked"),n.data}))}
394
+ */linkTelegram(t,e,n){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t||!e||!n)throw new h("Phone number, OTP, and phone code hash are required");const i=yield fetch(`${M}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t,code:e,phone_code_hash:n,userId:this.userId,clientId:this.clientId})}).then((t=>t.json()));if(i.isError)throw new h(i.message||"Failed to link Telegram account");return c(this,nt,"m",pt).call(this,E.TELEGRAM_LINKED,"Telegram Linked"),i.data}))}
345
395
  /**
346
396
  * Unlink the user's Twitter account.
347
397
  * @returns {Promise<any>} A promise that resolves with the unlink result.
348
398
  * @throws {Error} - Throws an error if the user is not authenticated.
349
399
  * @throws {APIError} - Throws an error if the request fails.
350
- */unlinkTwitter(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${b}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new u(t.message||"Failed to unlink Twitter account");return t.data}))}
400
+ */unlinkTwitter(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${M}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new h(t.message||"Failed to unlink Twitter account");return t.data}))}
351
401
  /**
352
402
  * Unlink the user's Discord account.
353
403
  * @returns {Promise<any>} A promise that resolves with the unlink result.
354
404
  * @throws {Error} - Throws an error if the user is not authenticated.
355
405
  * @throws {APIError} - Throws an error if the request fails.
356
- */unlinkDiscord(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new u("User needs to be authenticated");const t=yield fetch(`${b}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new u(t.message||"Failed to unlink Discord account");return t.data}))}
406
+ */unlinkDiscord(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new h("User needs to be authenticated");const t=yield fetch(`${M}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new h(t.message||"Failed to unlink Discord account");return t.data}))}
357
407
  /**
358
408
  * Unlink the user's Spotify account.
359
409
  * @returns {Promise<any>} A promise that resolves with the unlink result.
360
410
  * @throws {Error} - Throws an error if the user is not authenticated.
361
411
  * @throws {APIError} - Throws an error if the request fails.
362
- */unlinkSpotify(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new u("User needs to be authenticated");const t=yield fetch(`${b}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new u(t.message||"Failed to unlink Spotify account");return t.data}))}
412
+ */unlinkSpotify(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new h("User needs to be authenticated");const t=yield fetch(`${M}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new h(t.message||"Failed to unlink Spotify account");return t.data}))}
363
413
  /**
364
414
  * Unlink the user's TikTok account.
365
415
  * @returns {Promise<any>} A promise that resolves with the unlink result.
366
416
  * @throws {Error} - Throws an error if the user is not authenticated.
367
417
  * @throws {APIError} - Throws an error if the request fails.
368
- */unlinkTikTok(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new u("User needs to be authenticated");const t=yield fetch(`${b}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new u(t.message||"Failed to unlink TikTok account");return t.data}))}
418
+ */unlinkTikTok(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new h("User needs to be authenticated");const t=yield fetch(`${M}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new h(t.message||"Failed to unlink TikTok account");return t.data}))}
369
419
  /**
370
420
  * Unlink the user's Telegram account.
371
421
  * @returns {Promise<any>} A promise that resolves with the unlink result.
372
422
  * @throws {Error} - Throws an error if the user is not authenticated.
373
423
  * @throws {APIError} - Throws an error if the request fails.
374
- */unlinkTelegram(){return h(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new u("User needs to be authenticated");const t=yield fetch(`${b}/telegram/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new u(t.message||"Failed to unlink Telegram account");return t.data}))}
375
- /**
376
- * Call a contract method.
377
- * @param {string} contractAddress The contract address.
378
- * @param {Abi} abi The contract ABI.
379
- * @param {string} methodName The method name.
380
- * @param {any[]} params The method parameters.
381
- * @param {CallOptions} [options] The call options.
382
- * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
383
- * @throws {Error} - Throws an error if the wallet client is not connected or if the method is not a view function.
384
- */callContractMethod(t,e,i,n){return h(this,arguments,void 0,(function*(t,e,i,n,s={}){const a=r({abi:e,name:i}),d=a&&"stateMutability"in a&&("view"===a.stateMutability||"pure"===a.stateMutability);if(!d&&!this.viem)throw new Error("WalletClient not connected.");if(d){const s=A();return(yield s.readContract({address:t,abi:e,functionName:i,args:n}))||null}{const[r]=yield this.viem.getAddresses(),a=o({abi:e,functionName:i,args:n});yield c(this,N,"m",L).call(this,g);const d=yield this.viem.sendTransaction({to:t,data:a,account:r,value:s.value,gas:s.gas});if(s.waitForReceipt){return yield c(this,N,"m",z).call(this,d)}return d}}))}}P=new WeakMap,_=new WeakMap,N=new WeakSet,D=function(t,e){c(this,P,"f")[t]&&c(this,P,"f")[t].forEach((t=>t(e)))},B=function(t){return h(this,void 0,void 0,(function*(){var e,i;if("undefined"==typeof localStorage)return;const n=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:wallet-address"),s=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),r=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");if(n&&s&&r){this.walletAddress=n,this.userId=s,this.jwt=r,this.origin=new J(this.jwt),this.isAuthenticated=!0;let o=t;if(!o){const t=null!==(e=j())&&void 0!==e?e:[];for(const e of t)try{if((null===(i=(yield e.provider.request({method:"eth_accounts"}))[0])||void 0===i?void 0:i.toLowerCase())===n.toLowerCase()){o=e.provider;break}}catch(t){console.warn("Failed to fetch accounts from provider:",t)}}o&&(this.viem=T(o,(new Date).getTime().toString(),n),c(this,N,"m",D).call(this,"viem",this.viem))}else this.isAuthenticated=!1}))},W=function(){return h(this,void 0,void 0,(function*(){try{const[t]=yield this.viem.requestAddresses();return this.walletAddress=t,t}catch(t){throw new u(t)}}))},x=function(){return h(this,void 0,void 0,(function*(){try{const t=yield fetch(`${b}/auth/client-user/nonce`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({walletAddress:this.walletAddress})}),e=yield t.json();return 200!==t.status?Promise.reject(e.message||"Failed to fetch nonce"):e.data}catch(t){throw new Error(t)}}))},F=function(t,e){return h(this,void 0,void 0,(function*(){try{const i=yield fetch(`${b}/auth/client-user/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({message:t,signature:e,walletAddress:this.walletAddress})}),n=yield i.json(),s=n.data.split(".")[1],r=JSON.parse(atob(s));return{success:!n.isError,userId:r.id,token:n.data}}catch(t){throw new u(t)}}))},q=function(t){return d({domain:window.location.host,address:this.walletAddress,statement:E,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:t})},K=function(t,e){return h(this,arguments,void 0,(function*(t,e,i=1){
424
+ */unlinkTelegram(){return p(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new h("User needs to be authenticated");const t=yield fetch(`${M}/telegram/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new h(t.message||"Failed to unlink Telegram account");return t.data}))}}it=new WeakMap,at=new WeakMap,nt=new WeakSet,rt=function(t,e){c(this,it,"f")[t]&&c(this,it,"f")[t].forEach((t=>t(e)))},st=function(t){return p(this,void 0,void 0,(function*(){var e,n;if("undefined"==typeof localStorage)return;const i=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:wallet-address"),a=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),r=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");if(i&&a&&r){this.walletAddress=i,this.userId=a,this.jwt=r,this.origin=new wt(this.jwt),this.isAuthenticated=!0;let s=t;if(!s){const t=null!==(e=D())&&void 0!==e?e:[];for(const e of t)try{if((null===(n=(yield e.provider.request({method:"eth_requestAccounts"}))[0])||void 0===n?void 0:n.toLowerCase())===i.toLowerCase()){s=e;break}}catch(t){console.warn("Failed to fetch accounts from provider:",t)}}s?this.setProvider({provider:s.provider,info:s.info||{name:"Unknown"},address:i}):
425
+ // await this.disconnect();
426
+ console.warn("No matching provider found for the stored wallet address. User disconnected.")}else this.isAuthenticated=!1}))},ot=function(){return p(this,void 0,void 0,(function*(){try{const[t]=yield this.viem.requestAddresses();return this.walletAddress=t,t}catch(t){throw new h(t)}}))},dt=function(){return p(this,void 0,void 0,(function*(){try{const t=yield fetch(`${M}/auth/client-user/nonce`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({walletAddress:this.walletAddress})}),e=yield t.json();return 200!==t.status?Promise.reject(e.message||"Failed to fetch nonce"):e.data}catch(t){throw new Error(t)}}))},ut=function(t,e){return p(this,void 0,void 0,(function*(){try{const n=yield fetch(`${M}/auth/client-user/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({message:t,signature:e,walletAddress:this.walletAddress})}),i=yield n.json(),a=i.data.split(".")[1],r=JSON.parse(atob(a));return{success:!i.isError,userId:r.id,token:i.data}}catch(t){throw new h(t)}}))},lt=function(t){return l({domain:window.location.host,address:this.walletAddress,statement:C,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:t})},pt=function(t,e){return p(this,arguments,void 0,(function*(t,e,n=1){
385
427
  // if (this.#ackeeInstance)
386
428
  // await sendAnalyticsEvent(this.#ackeeInstance, event, message, count);
387
429
  // else return;
388
- }))},z=function(t){return h(this,void 0,void 0,(function*(){if(!this.viem)throw new Error("WalletClient not connected.");for(;;){const e=yield this.viem.request({method:"eth_getTransactionReceipt",params:[t]});if(e&&e.blockNumber)return e;yield new Promise((t=>setTimeout(t,1e3)))}}))},L=function(t){return h(this,void 0,void 0,(function*(){
389
- // return;
390
- if(!this.viem)throw new Error("WalletClient not connected.");let e=yield this.viem.request({method:"eth_chainId",params:[]});if("string"==typeof e&&(e=parseInt(e,16)),e!==t.id)try{yield this.viem.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}catch(e){
391
- // Unrecognized chain
392
- if(4902!==e.code)throw e;yield this.viem.request({method:"wallet_addEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16),chainName:t.name,rpcUrls:t.rpcUrls.default.http,nativeCurrency:t.nativeCurrency}]}),yield this.viem.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}}))};export{R as Auth,y as SpotifyAPI,v as TwitterAPI};
430
+ }))};export{vt as Auth,b as SpotifyAPI,T as TwitterAPI};