@funkit/fun-relay 2.2.0-next.6 → 2.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @funkit/fun-relay
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c289ca6: feat(fun-relay): require api key for relay to prevent rate limiting
8
+ feat(connect): pass pseudo api key to fun-relay
9
+ - aa767b0: feat: add tron adapter
10
+
11
+ ### Patch Changes
12
+
13
+ - 173d602: chore(fun-relay): dynamic routes
14
+ - 3601d23: feat(fun-relay): support for more lighter addresses
15
+ - 320236b: refactor: refactor approval calldata generation
16
+ - 52406e3: feat(connect,fun-relay): add new lighter spot assets
17
+ - e009c8d: Fix USDC_PERPS icon displaying ETH logo instead of USDC logo
18
+ - 7312429: adopt checkedIndexedAccess for safety
19
+ - 2f57830: feat: implemented revoke/reset approval mechanics for tokens with non-standard approval implementation
20
+ - 0152e69: chore(fun-relay): expose `RelayExecute` type
21
+ - fd5fe29: fix(fun-relay): add protocolVersion to tests
22
+ - ab9c1e9: chore: update assets
23
+ - 85ab331: remove unused manual register indexing
24
+ - 9257a9b: remove tick size read in connect
25
+ - d4b9ea5: feat(fun-relay): add new lighter routes
26
+ - dc9cc8c: add relay request id to error message
27
+
3
28
  ## 2.2.0-next.6
4
29
 
5
30
  ### Patch Changes
package/dist/index.js CHANGED
@@ -146,90 +146,6 @@ function getRelayClient() {
146
146
 
147
147
  // src/execution.ts
148
148
  var import_relay_sdk3 = require("@relayprotocol/relay-sdk");
149
-
150
- // src/utils.ts
151
- function convertFunToRelayTokenAddress(address, chainId) {
152
- if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {
153
- switch (chainId) {
154
- case FUN_HYPERCORE_CHAIN_ID_NUMBER:
155
- return RELAY_NATIVE_TOKEN_HYPERCORE;
156
- case RELAY_BITCOIN_CHAIN_ID_NUMBER:
157
- return RELAY_NATIVE_TOKEN_BITCOIN;
158
- // TODO: is it correct to assume chainId here is relay chain id?
159
- case RELAY_SOLANA_CHAIN_ID_NUMBER:
160
- case FUN_SOLANA_CHAIN_ID_NUMBER:
161
- return RELAY_NATIVE_TOKEN_SOLANA;
162
- case RELAY_LIGHTER_CHAIN_ID_NUMBER:
163
- return RELAY_LIGHTER_USDC_PERPS;
164
- default:
165
- return RELAY_NATIVE_TOKEN;
166
- }
167
- }
168
- if (RELAY_LIGHTER_CHAIN_ID_NUMBER === chainId) {
169
- const relayAddress = RELAY_LIGHTER_FUN_ADDRESS_MAP[address.toLowerCase()];
170
- if (relayAddress) {
171
- return relayAddress;
172
- }
173
- }
174
- return address;
175
- }
176
- function convertFunToRelayChainId(chainId) {
177
- if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {
178
- return RELAY_SOLANA_CHAIN_ID_NUMBER;
179
- }
180
- return chainId;
181
- }
182
- function getRelayExecutionRefundState(info) {
183
- switch (info.status) {
184
- case "refund" /* REFUND */:
185
- return "REFUNDED" /* REFUNDED */;
186
- default:
187
- return void 0;
188
- }
189
- }
190
- function getRelayExecutionState(info) {
191
- switch (info.status) {
192
- case "success" /* SUCCESS */:
193
- return "COMPLETED" /* COMPLETED */;
194
- case "failure" /* FAILURE */:
195
- case "refund" /* REFUND */:
196
- return "CHECKOUT_ERROR" /* CHECKOUT_ERROR */;
197
- default:
198
- return "PENDING_RECEIVAL" /* PENDING_RECEIVAL */;
199
- }
200
- }
201
- function isRelayExecutionTerminalStatus(info) {
202
- return RELAY_TERMINAL_STATUSES.includes(info.status);
203
- }
204
- function jsonStringifyWithBigIntSanitization(serializable) {
205
- return JSON.stringify(
206
- serializable,
207
- (_, value) => typeof value === "bigint" ? `0x${value.toString(16)}` : value
208
- // return everything else unchanged
209
- );
210
- }
211
- function indexBy(items, getKey) {
212
- const indexedItems = {};
213
- for (const item of items) {
214
- const key = getKey(item);
215
- if (!key) {
216
- continue;
217
- }
218
- indexedItems[key] = item;
219
- }
220
- return indexedItems;
221
- }
222
- function filterNullishHeaders(params) {
223
- const result = {};
224
- for (const [key, value] of Object.entries(params)) {
225
- if (value != null) {
226
- result[key] = value;
227
- }
228
- }
229
- return result;
230
- }
231
-
232
- // src/execution.ts
233
149
  function getTxHash({
234
150
  logger,
235
151
  transactionType,
@@ -380,18 +296,6 @@ async function executeRelayQuote({
380
296
  ) {
381
297
  logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes);
382
298
  isTransactionConfirmed = true;
383
- const firstStep = relayQuote.steps[0];
384
- const firstItem = firstStep?.items[0];
385
- if (firstStep?.requestId && firstItem) {
386
- manuallyRegisterIndex(logger, {
387
- requestId: firstStep.requestId,
388
- chainId: firstItem.data.chainId,
389
- tx: jsonStringifyWithBigIntSanitization({
390
- ...firstItem.data,
391
- txHash
392
- })
393
- });
394
- }
395
299
  try {
396
300
  await onTransactionConfirmed?.(txHash);
397
301
  } catch (e) {
@@ -405,42 +309,6 @@ async function executeRelayQuote({
405
309
  }
406
310
  });
407
311
  }
408
- async function manuallyRegisterIndex(logger, registerRequest) {
409
- const logPrefix = "manuallyRegisterIndex";
410
- const stringifiedRequest = JSON.stringify(registerRequest);
411
- const url = `${import_relay_sdk3.MAINNET_RELAY_API}/transactions/single`;
412
- try {
413
- logger.info(`${logPrefix}:onManuallyRegisterIndex`, {
414
- params: stringifiedRequest
415
- });
416
- const response = await fetch(url, {
417
- method: "POST",
418
- body: JSON.stringify(registerRequest)
419
- });
420
- if (!response.ok) {
421
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
422
- message: "Error !response.ok - request to manually register index",
423
- response: JSON.stringify(response),
424
- params: stringifiedRequest
425
- });
426
- return;
427
- }
428
- const data = await response.json();
429
- if (data.message !== "Success") {
430
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
431
- message: `Data.message is not of type Success - ${data.message}`,
432
- response: JSON.stringify(response),
433
- params: stringifiedRequest
434
- });
435
- }
436
- return;
437
- } catch (err) {
438
- logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {
439
- message: `Error sending request to register index at ${url}: ${JSON.stringify(err?.message)}`,
440
- params: stringifiedRequest
441
- });
442
- }
443
- }
444
312
  async function getRelayExecutionInfo(requestId, apiKey) {
445
313
  const url = `${import_relay_sdk3.MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`;
446
314
  const response = await fetch(url, {
@@ -525,6 +393,83 @@ function parseRelayFees({
525
393
 
526
394
  // src/price.ts
527
395
  var import_relay_sdk4 = require("@relayprotocol/relay-sdk");
396
+
397
+ // src/utils.ts
398
+ function convertFunToRelayTokenAddress(address, chainId) {
399
+ if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {
400
+ switch (chainId) {
401
+ case FUN_HYPERCORE_CHAIN_ID_NUMBER:
402
+ return RELAY_NATIVE_TOKEN_HYPERCORE;
403
+ case RELAY_BITCOIN_CHAIN_ID_NUMBER:
404
+ return RELAY_NATIVE_TOKEN_BITCOIN;
405
+ // TODO: is it correct to assume chainId here is relay chain id?
406
+ case RELAY_SOLANA_CHAIN_ID_NUMBER:
407
+ case FUN_SOLANA_CHAIN_ID_NUMBER:
408
+ return RELAY_NATIVE_TOKEN_SOLANA;
409
+ case RELAY_LIGHTER_CHAIN_ID_NUMBER:
410
+ return RELAY_LIGHTER_USDC_PERPS;
411
+ default:
412
+ return RELAY_NATIVE_TOKEN;
413
+ }
414
+ }
415
+ if (RELAY_LIGHTER_CHAIN_ID_NUMBER === chainId) {
416
+ const relayAddress = RELAY_LIGHTER_FUN_ADDRESS_MAP[address.toLowerCase()];
417
+ if (relayAddress) {
418
+ return relayAddress;
419
+ }
420
+ }
421
+ return address;
422
+ }
423
+ function convertFunToRelayChainId(chainId) {
424
+ if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {
425
+ return RELAY_SOLANA_CHAIN_ID_NUMBER;
426
+ }
427
+ return chainId;
428
+ }
429
+ function getRelayExecutionRefundState(info) {
430
+ switch (info.status) {
431
+ case "refund" /* REFUND */:
432
+ return "REFUNDED" /* REFUNDED */;
433
+ default:
434
+ return void 0;
435
+ }
436
+ }
437
+ function getRelayExecutionState(info) {
438
+ switch (info.status) {
439
+ case "success" /* SUCCESS */:
440
+ return "COMPLETED" /* COMPLETED */;
441
+ case "failure" /* FAILURE */:
442
+ case "refund" /* REFUND */:
443
+ return "CHECKOUT_ERROR" /* CHECKOUT_ERROR */;
444
+ default:
445
+ return "PENDING_RECEIVAL" /* PENDING_RECEIVAL */;
446
+ }
447
+ }
448
+ function isRelayExecutionTerminalStatus(info) {
449
+ return RELAY_TERMINAL_STATUSES.includes(info.status);
450
+ }
451
+ function indexBy(items, getKey) {
452
+ const indexedItems = {};
453
+ for (const item of items) {
454
+ const key = getKey(item);
455
+ if (!key) {
456
+ continue;
457
+ }
458
+ indexedItems[key] = item;
459
+ }
460
+ return indexedItems;
461
+ }
462
+ function filterNullishHeaders(params) {
463
+ const result = {};
464
+ for (const [key, value] of Object.entries(params)) {
465
+ if (value != null) {
466
+ result[key] = value;
467
+ }
468
+ }
469
+ return result;
470
+ }
471
+
472
+ // src/price.ts
528
473
  async function getRelayAssetPriceInfo({
529
474
  chainId,
530
475
  address,