@funkit/fun-relay 2.1.4-next.1 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -4
- package/dist/index.js +12 -48
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +12 -48
- package/dist/index.mjs.map +2 -2
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/execution.d.ts +8 -7
- package/dist/src/execution.d.ts.map +1 -1
- package/dist/src/quote.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# @funkit/fun-relay
|
|
2
2
|
|
|
3
|
-
## 2.1.
|
|
3
|
+
## 2.1.5
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- e69f7f6: refactor: switch fun relay wallet
|
|
8
|
+
- 20f79ef: chore(fun-relay): add hypevm enum
|
|
8
9
|
|
|
9
|
-
## 2.1.4
|
|
10
|
+
## 2.1.4
|
|
10
11
|
|
|
11
12
|
### Patch Changes
|
|
12
13
|
|
|
13
|
-
- febe9b7: chore(fun-relay): additional options for account abstraction flow
|
|
14
14
|
- 6b531a6: chore: bump relay deps
|
|
15
|
+
- 1b37b9c: feat: support relay originalTxValue
|
|
15
16
|
|
|
16
17
|
## 2.1.3
|
|
17
18
|
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var RELAY_NATIVE_TOKEN = "0x0000000000000000000000000000000000000000";
|
|
|
85
85
|
var RELAY_NATIVE_TOKEN_HYPERCORE = "0x00000000000000000000000000000000";
|
|
86
86
|
var RELAY_NATIVE_TOKEN_SOLANA = "11111111111111111111111111111111";
|
|
87
87
|
var RELAY_NATIVE_TOKEN_BITCOIN = "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8";
|
|
88
|
-
var FUN_RELAY_REVENUE_WALLET = "
|
|
88
|
+
var FUN_RELAY_REVENUE_WALLET = "0xdfd877679e95c1276c85801805b2c2ab8f4f4cf6";
|
|
89
89
|
var FUN_RELAY_REFERRER = "funxyz";
|
|
90
90
|
var RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25e3;
|
|
91
91
|
var RELAY_TERMINAL_STATUSES = [
|
|
@@ -184,33 +184,6 @@ function jsonStringifyWithBigIntSanitization(serializable) {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
// src/execution.ts
|
|
187
|
-
function getFinalTxHash({
|
|
188
|
-
smartWalletAdapter,
|
|
189
|
-
steps,
|
|
190
|
-
fallbackTxHash,
|
|
191
|
-
logger,
|
|
192
|
-
logPrefix
|
|
193
|
-
}) {
|
|
194
|
-
if (!smartWalletAdapter) {
|
|
195
|
-
return fallbackTxHash;
|
|
196
|
-
}
|
|
197
|
-
logger.info(`${logPrefix}:extractingTxHashFromReceipt`, {
|
|
198
|
-
message: "Smart wallet adapter detected, extracting txHash from receipt"
|
|
199
|
-
});
|
|
200
|
-
const receipt = steps[0].items[0].receipt;
|
|
201
|
-
if (receipt && "transactionHash" in receipt) {
|
|
202
|
-
const finalTxHash = receipt.transactionHash;
|
|
203
|
-
logger.info(`${logPrefix}:extractedTxHashFromReceipt`, {
|
|
204
|
-
originalTxHash: fallbackTxHash,
|
|
205
|
-
finalTxHash
|
|
206
|
-
});
|
|
207
|
-
return finalTxHash;
|
|
208
|
-
}
|
|
209
|
-
logger.error(`${logPrefix}:missingReceiptOrTransactionHash`, {
|
|
210
|
-
message: "Smart wallet transaction missing receipt or transactionHash"
|
|
211
|
-
});
|
|
212
|
-
return fallbackTxHash;
|
|
213
|
-
}
|
|
214
187
|
async function executeRelayQuote({
|
|
215
188
|
logger,
|
|
216
189
|
onError,
|
|
@@ -218,8 +191,7 @@ async function executeRelayQuote({
|
|
|
218
191
|
onTransactionConfirmed,
|
|
219
192
|
onUserActionsCompleted,
|
|
220
193
|
relayQuote,
|
|
221
|
-
walletClient
|
|
222
|
-
smartWalletAdapter = false
|
|
194
|
+
walletClient
|
|
223
195
|
}) {
|
|
224
196
|
let isUserActionsCompleted = false;
|
|
225
197
|
let isTransactionConfirmed = false;
|
|
@@ -235,7 +207,6 @@ async function executeRelayQuote({
|
|
|
235
207
|
txHashes,
|
|
236
208
|
details,
|
|
237
209
|
error
|
|
238
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: remove before merging into main
|
|
239
210
|
}) => {
|
|
240
211
|
const logPrefix = "onRelayProgress";
|
|
241
212
|
logger.info(`${logPrefix}:params`, {
|
|
@@ -274,15 +245,8 @@ async function executeRelayQuote({
|
|
|
274
245
|
) {
|
|
275
246
|
logger.info(`${logPrefix}:onUserActionsCompleted`, txHashes);
|
|
276
247
|
isUserActionsCompleted = true;
|
|
277
|
-
const finalTxHash = getFinalTxHash({
|
|
278
|
-
smartWalletAdapter,
|
|
279
|
-
steps,
|
|
280
|
-
fallbackTxHash: txHash,
|
|
281
|
-
logger,
|
|
282
|
-
logPrefix
|
|
283
|
-
});
|
|
284
248
|
try {
|
|
285
|
-
await onUserActionsCompleted?.(
|
|
249
|
+
await onUserActionsCompleted?.(txHash);
|
|
286
250
|
} catch (e) {
|
|
287
251
|
logger.error(
|
|
288
252
|
`${logPrefix}:onUserActionsCompletedFailed`,
|
|
@@ -298,14 +262,7 @@ async function executeRelayQuote({
|
|
|
298
262
|
) {
|
|
299
263
|
logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes);
|
|
300
264
|
isTransactionConfirmed = true;
|
|
301
|
-
|
|
302
|
-
smartWalletAdapter,
|
|
303
|
-
steps,
|
|
304
|
-
fallbackTxHash: txHash,
|
|
305
|
-
logger,
|
|
306
|
-
logPrefix
|
|
307
|
-
});
|
|
308
|
-
if (!smartWalletAdapter) {
|
|
265
|
+
if (relayQuote.steps[0].requestId) {
|
|
309
266
|
manuallyRegisterIndex(logger, {
|
|
310
267
|
requestId: relayQuote.steps[0].requestId,
|
|
311
268
|
chainId: relayQuote.steps[0].items[0].data.chainId,
|
|
@@ -316,7 +273,7 @@ async function executeRelayQuote({
|
|
|
316
273
|
});
|
|
317
274
|
}
|
|
318
275
|
try {
|
|
319
|
-
await onTransactionConfirmed?.(
|
|
276
|
+
await onTransactionConfirmed?.(txHash);
|
|
320
277
|
} catch (e) {
|
|
321
278
|
logger.error(
|
|
322
279
|
`${logPrefix}:onTransactionConfirmedFailed`,
|
|
@@ -570,6 +527,13 @@ async function getRelayQuote({
|
|
|
570
527
|
return {
|
|
571
528
|
data,
|
|
572
529
|
to: action.contractAddress,
|
|
530
|
+
// Relay supports msg.value via 2 fields: `value` and `originalTxValue`
|
|
531
|
+
// Both `value` and `originalTxValue` are required to be set for `erc20` + gas transfers
|
|
532
|
+
// Only `value` is required for native token transfers. // TODO: This flow needs verification.
|
|
533
|
+
// Internally for Relay,
|
|
534
|
+
// - `originalTxValue` is designed to "bubble up" the value to the original tx
|
|
535
|
+
// - `value` is the internal multicall value
|
|
536
|
+
originalTxValue: String(action.value ?? 0n),
|
|
573
537
|
value: String(action.value ?? 0n)
|
|
574
538
|
};
|
|
575
539
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.ts", "../src/bitcoin.ts", "../src/client.ts", "../src/types.ts", "../src/constants.ts", "../src/execution.ts", "../src/utils.ts", "../src/fees.ts", "../src/price.ts", "../src/currency.ts", "../src/quote.ts", "../src/solana.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n type BitcoinAddress,\n type BitcoinPsbt,\n type BitcoinPsbtDynamicParams,\n type BitcoinTxHash,\n type BitcoinWallet,\n getBitcoinWallet,\n getBitcoinWalletFromSigner,\n} from './src/bitcoin'\nexport {\n getRelayClient,\n initializeRelayClient,\n type InitializeRelayClientParams,\n} from './src/client'\nexport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_BITCOIN_CHAIN_ID,\n RELAY_BITCOIN_CHAIN_ID_NUMBER,\n RELAY_NATIVE_TOKEN_BITCOIN,\n RELAY_NATIVE_TOKEN_HYPERCORE,\n RELAY_NATIVE_TOKEN,\n RELAY_SOLANA_CHAIN_ID,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './src/constants'\nexport {\n type ExecuteRelayQuoteParams,\n type RelayAddress,\n type RelayChainId,\n type RelayExecutionStep,\n type RelayTxHash,\n type RelayVmType,\n type RelayWallet,\n executeRelayQuote,\n getRelayExecutionInfo,\n} from './src/execution'\nexport { parseRelayFees } from './src/fees'\nexport { getRelayAssetPriceInfo } from './src/price'\nexport { getRelayAssetInfo } from './src/currency'\nexport {\n type GetRelayQuoteParams,\n type RelayQuote,\n getRelayQuote,\n getReferrer,\n RelayQuoteClientError,\n} from './src/quote'\nexport {\n type SolanaAddress,\n type SolanaTxHash,\n type SolanaWallet,\n getSolanaWallet,\n} from './src/solana'\nexport {\n getRelayExecutionRefundState,\n getRelayExecutionState,\n isRelayExecutionTerminalStatus,\n convertFunToRelayTokenAddress,\n convertFunToRelayChainId,\n} from './src/utils'\nexport {\n LogLevel,\n type RelayExecutionInfo,\n type RelayExecutionStatus,\n type RelayTokenPriceInfo,\n} from './src/types'\n", "import { adaptBitcoinWallet } from '@relayprotocol/relay-bitcoin-wallet-adapter'\nimport type { AdaptedWallet } from '@relayprotocol/relay-sdk'\n\ntype Base16 =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n\nexport type BitcoinAddress =\n | `1${string}`\n | `3${string}`\n | `bc1${string}`\n | `bc1p${string}`\n\nexport type BitcoinTxHash = `${Base16}${string}`\n\nexport type BitcoinWallet = {\n address(): Promise<BitcoinAddress>\n vmType: 'bvm'\n} & AdaptedWallet\n\n/** bitcoinjs-lib Psbt */\nexport type BitcoinPsbt = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[1]\n\nexport type BitcoinPsbtDynamicParams = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[2]\n\n/** bitcoinjs-lib Signer */\nexport type BitcoinSigner = Parameters<BitcoinPsbt['signAllInputs']>[0]\n\nexport function getBitcoinWallet(\n walletAddress: BitcoinAddress,\n signPsbt: (\n address: BitcoinAddress,\n psbt: BitcoinPsbt,\n dynamicParams: BitcoinPsbtDynamicParams,\n ) => Promise<string>,\n): BitcoinWallet {\n return adaptBitcoinWallet(walletAddress, (address, psbt, dynamicParams) =>\n signPsbt(address as BitcoinAddress, psbt, dynamicParams),\n ) as BitcoinWallet\n}\n\nexport function getBitcoinWalletFromSigner(\n walletAddress: BitcoinAddress,\n signer: BitcoinSigner,\n): BitcoinWallet {\n return getBitcoinWallet(walletAddress, async (_, psbt) =>\n psbt.signAllInputs(signer).toBase64(),\n )\n}\n", "import {\n LogLevel,\n MAINNET_RELAY_API,\n type RelayClient,\n type RelayClientOptions,\n convertViemChainToRelayChain,\n createClient,\n getClient,\n} from '@relayprotocol/relay-sdk'\nimport type { Chain } from 'viem'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\nimport type { Logger } from './types'\n\nexport type InitializeRelayClientParams = Omit<\n RelayClientOptions,\n 'baseApiUrl' | 'chains' | 'logger'\n> & {\n chains: Chain[]\n logger: Logger\n}\n\n/**\n * Initializes a global instance of the RelayClient\n * https://docs.relay.link/references/sdk/createClient\n */\nexport function initializeRelayClient({\n chains,\n logger,\n ...options\n}: InitializeRelayClientParams): RelayClient {\n return createClient({\n ...options,\n baseApiUrl: MAINNET_RELAY_API,\n chains: [\n ...chains.map(convertViemChainToRelayChain),\n {\n id: RELAY_SOLANA_CHAIN_ID_NUMBER,\n name: 'Solana',\n displayName: 'Solana',\n },\n ],\n logger: (message, level) => {\n if (level === LogLevel.Error) {\n logger.error('[RelayClient]:', message)\n } else {\n logger.info('[RelayClient]:', message)\n }\n },\n })\n}\n\n/**\n * Gets the global instance of the RelayClient\n */\nexport function getRelayClient(): RelayClient {\n const client = getClient()\n\n if (!client) {\n throw new Error('Relay client is not defined')\n }\n\n return client\n}\n", "import { LogLevel } from '@relayprotocol/relay-sdk'\nimport type { Abi, Address } from 'viem'\n\nexport { LogLevel }\n\n// https://docs.relay.link/references/api/get-intents-status-v2\nexport interface RelayExecutionInfo {\n status: RelayExecutionStatus\n details: string\n /** Incoming transaction hashes */\n inTxHashes: string[]\n /** Outgoing transaction hashes */\n txHashes: string[]\n /** The last timestamp the data was updated in milliseconds */\n time: number\n originChainId: number\n destinationChainId: number\n}\n\n// https://docs.relay.link/references/api/get-token-price\nexport interface RelayTokenPriceInfo {\n price: number\n}\n\n//// The types below are duplicated from @funkit/api-base atm, but this package should be used in BE as well\n//// TODO: Are we fine with BE importing @funkit/api-base and (by extension) @funkit/utils?\n//// See https://linear.app/funxyz/issue/PE-1342/sdk-extract-domainsrelayts-to-a-new-package#comment-d487d533\n\nexport interface Logger {\n error(message: string, data?: object): void\n info(message: string, data?: object): void\n}\n\n// Reference: https://github.com/reservoirprotocol/relay-kit/blob/211c645f9702a3b459ff545aa4e2e9d536c38455/packages/sdk/src/types/Execute.ts#L54-L61\nexport enum RelayExecutionStatus {\n DELAYED = 'delayed',\n FAILURE = 'failure',\n PENDING = 'pending',\n REFUND = 'refund',\n SUCCESS = 'success',\n WAITING = 'waiting',\n UNKNOWN = 'unknown',\n}\n\nexport interface ApiFunkitCheckoutActionParams {\n contractAbi: Abi\n contractAddress: Address\n functionName: string\n functionArgs: unknown[]\n value?: bigint\n}\n\nexport enum CheckoutRefundState {\n INITIATED = 'INITIATED',\n ERROR = 'ERROR',\n REFUNDED = 'REFUNDED',\n PROCEEDED = 'PROCEEDED',\n WAITING_FOR_FULFILLMENT = 'WAITING_FOR_FULFILLMENT',\n FULFILLED = 'FULFILLED',\n}\n\n// Reference from api server: https://github.com/fun-xyz/fun-api-server/blob/main/src/tables/FunWalletCheckout.ts#L11C1-L21C2\nexport enum CheckoutState {\n // In-progress States\n FROM_UNFUNDED = 'FROM_UNFUNDED',\n FROM_FUNDED = 'FROM_FUNDED',\n FROM_POOLED = 'FROM_POOLED',\n TO_UNFUNDED = 'TO_UNFUNDED',\n TO_FUNDED = 'TO_FUNDED',\n TO_POOLED = 'TO_POOLED',\n TO_READY = 'TO_READY',\n PENDING_RECEIVAL = 'PENDING_RECEIVAL',\n // Terminal States\n COMPLETED = 'COMPLETED',\n CHECKOUT_ERROR = 'CHECKOUT_ERROR',\n EXPIRED = 'EXPIRED',\n CANCELLED = 'CANCELLED',\n}\n\n// The response of the actual /checkout/quote api\nexport type CheckoutApiQuoteResponse = {\n quoteId: string\n estTotalFromAmountBaseUnit: string\n estSubtotalFromAmountBaseUnit: string\n estFeesFromAmountBaseUnit: string\n fromTokenAddress: Address\n estFeesUsd: number\n estSubtotalUsd: number\n estTotalUsd: number\n estCheckoutTimeMs: number\n estMarketMakerGasUsd: number\n lpFeePercentage: number\n lpFeeUsd: number\n}\n\n// The formatted response quote interface from the core sdk\nexport type CheckoutQuoteResponse = CheckoutApiQuoteResponse & {\n estTotalFromAmount: string\n estSubtotalFromAmount: string\n estFeesFromAmount: string\n\n // Any additional fields purely for frontend use\n metadata?: { [key: string]: unknown }\n}\n", "import type { Address } from 'viem'\nimport type { BitcoinAddress } from './bitcoin'\nimport type { SolanaAddress } from './solana'\nimport { RelayExecutionStatus } from './types'\n\n/**\n * Chain id that Relay uses to identify Bitcoin\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_BITCOIN_CHAIN_ID_NUMBER = 8253038 // Why cannot Relay export this themselves... -.-\nexport const RELAY_BITCOIN_CHAIN_ID = `${RELAY_BITCOIN_CHAIN_ID_NUMBER}`\n\n/**\n * Chain id that Relay uses to identify Solana\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_SOLANA_CHAIN_ID_NUMBER = 792703809 // Why cannot Relay export this themselves... -.-\nexport const RELAY_SOLANA_CHAIN_ID = `${RELAY_SOLANA_CHAIN_ID_NUMBER}`\n\nexport const FUN_SOLANA_CHAIN_ID_NUMBER = 1151111081099710\nexport const FUN_HYPERCORE_CHAIN_ID_NUMBER = 1337\n\n/**\n * Fake address for a chain's native currency used by Funkit\n */\nexport const FUNKIT_NATIVE_TOKEN =\n '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' satisfies Address\n\n/**\n * Fake address for a chain's native currency used by Relay\n */\nexport const RELAY_NATIVE_TOKEN =\n '0x0000000000000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for Hypercore's native currency used by Relay. This is shorter than the default native token...\n */\nexport const RELAY_NATIVE_TOKEN_HYPERCORE =\n '0x00000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_SOLANA =\n '11111111111111111111111111111111' satisfies SolanaAddress\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_BITCOIN =\n 'bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8' satisfies BitcoinAddress\n\n/**\n * Wallet that receives the app fees collected by Relay\n */\nexport const FUN_RELAY_REVENUE_WALLET =\n '0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E' satisfies Address\n\n/**\n * Referred field in Relay quote\n */\nexport const FUN_RELAY_REFERRER = 'funxyz'\n\n/**\n * Buffer added to Relay's time estimate (which sometimes is 0)\n */\nexport const RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25_000 // 25 seconds\n\nexport const RELAY_TERMINAL_STATUSES: RelayExecutionStatus[] = [\n RelayExecutionStatus.REFUND,\n RelayExecutionStatus.FAILURE,\n RelayExecutionStatus.SUCCESS,\n]\n\nexport const SUSHI_ORG_ID = 'fysix7gj5j'\nexport const HYPERSWAP_ORG_ID = '2ejzdxhfge'\nexport const HYPERBEAT_ORG_ID = 'opzh9rydei'\n", "import {\n type AdaptedWallet,\n MAINNET_RELAY_API,\n type ProgressData,\n} from '@relayprotocol/relay-sdk'\nimport type { Address, Hex, WalletClient } from 'viem'\nimport type { BitcoinAddress, BitcoinTxHash, BitcoinWallet } from './bitcoin'\nimport { getRelayClient } from './client'\nimport type { RELAY_BITCOIN_CHAIN_ID, RELAY_SOLANA_CHAIN_ID } from './constants'\nimport type { RelayQuoteResult } from './quote'\nimport type { SolanaAddress, SolanaTxHash, SolanaWallet } from './solana'\nimport type { Logger, RelayExecutionInfo } from './types'\nimport { jsonStringifyWithBigIntSanitization } from './utils'\n\nexport type RelayExecutionStep = ProgressData['currentStep'] & {}\n\nexport type RelayVmType = 'bvm' | 'evm' | 'svm'\n\nexport type RelayAddress<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinAddress\n evm: Address\n svm: SolanaAddress\n}[VmType]\n\nexport type RelayChainId<VmType extends RelayVmType = RelayVmType> = {\n bvm: typeof RELAY_BITCOIN_CHAIN_ID\n evm: string\n svm: typeof RELAY_SOLANA_CHAIN_ID\n}[VmType]\n\nexport type RelayTxHash<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinTxHash\n evm: Hex\n svm: SolanaTxHash\n}[VmType]\n\nexport type RelayWallet<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinWallet\n evm: WalletClient | (AdaptedWallet & { vmType: 'evm' })\n svm: SolanaWallet\n}[VmType]\n\nexport interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {\n logger: Logger\n onError: (error: Error) => Promise<void>\n onProgress?: (step: RelayExecutionStep | null) => void\n /**\n * Fired when all *input* transactions are confirmed on-chain.\n */\n onTransactionConfirmed?: (txHash: RelayTxHash<VmType>) => Promise<void>\n /**\n * Fired as soon as user has *signed* all input transactions, but before they are confirmed on-chain.\n *\n * After this event, no more action should be needed from the user.\n * However, it is possible that the transactions will be rejected and the execution will NOT continue.\n */\n onUserActionsCompleted?: (txHash: RelayTxHash<VmType>) => Promise<void>\n relayQuote: RelayQuoteResult<VmType>\n walletClient: RelayWallet<VmType>\n\n /**\n * Whether to use a smart wallet adapter.\n * Used for account abstraction transactions.\n */\n smartWalletAdapter?: boolean\n}\n\nfunction getFinalTxHash<VmType extends RelayVmType>({\n smartWalletAdapter,\n steps,\n fallbackTxHash,\n logger,\n logPrefix,\n}: {\n smartWalletAdapter: boolean\n steps: RelayQuoteResult<VmType>['steps']\n fallbackTxHash: RelayTxHash<VmType>\n logger: Logger\n logPrefix: string\n}): RelayTxHash<VmType> {\n if (!smartWalletAdapter) {\n return fallbackTxHash\n }\n\n logger.info(`${logPrefix}:extractingTxHashFromReceipt`, {\n message: 'Smart wallet adapter detected, extracting txHash from receipt',\n })\n\n const receipt = steps[0].items[0].receipt\n if (receipt && 'transactionHash' in receipt) {\n const finalTxHash = receipt.transactionHash as RelayTxHash<VmType>\n logger.info(`${logPrefix}:extractedTxHashFromReceipt`, {\n originalTxHash: fallbackTxHash,\n finalTxHash,\n })\n return finalTxHash\n }\n\n logger.error(`${logPrefix}:missingReceiptOrTransactionHash`, {\n message: 'Smart wallet transaction missing receipt or transactionHash',\n })\n return fallbackTxHash\n}\n\nexport async function executeRelayQuote<VmType extends RelayVmType>({\n logger,\n onError,\n onProgress,\n onTransactionConfirmed,\n onUserActionsCompleted,\n relayQuote,\n walletClient,\n smartWalletAdapter = false,\n}: ExecuteRelayQuoteParams<VmType>): Promise<void> {\n let isUserActionsCompleted = false\n let isTransactionConfirmed = false\n\n await getRelayClient().actions.execute({\n quote: relayQuote,\n wallet: walletClient,\n onProgress: async ({\n steps,\n fees,\n breakdown,\n currentStep,\n currentStepItem,\n txHashes,\n details,\n error,\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: remove before merging into main\n }) => {\n const logPrefix = 'onRelayProgress'\n logger.info(`${logPrefix}:params`, {\n steps,\n currentStep,\n fees,\n breakdown,\n currentStepItem,\n txHashes,\n details,\n error,\n })\n\n onProgress?.(currentStep ?? null)\n\n if (error) {\n logger.info(`${logPrefix}:errorDetected`, error)\n await onError(error).catch((e) => {\n logger.error(`${logPrefix}:onErrorFailed`, e)\n })\n } else if (txHashes?.length) {\n // Use first txHash as the main txHash in fun DE table\n // Bad surprise from Relay: txHash may be an object, this is not present in their typing...\n const rawTxHashWithUnreliableTyping = txHashes[0].txHash as\n | RelayTxHash<VmType>\n | { id: RelayTxHash<VmType> }\n\n const txHash =\n typeof rawTxHashWithUnreliableTyping === 'object'\n ? rawTxHashWithUnreliableTyping.id\n : rawTxHashWithUnreliableTyping\n\n if (\n // Call onUserActionsCompleted only once\n !isUserActionsCompleted &&\n steps.every((step) =>\n step.items.every(\n // 'completed' - catch-all for items marked completed with no other info\n // - e.g. Batched items will not have txHash but will have their item marked 'complete'\n // 'pending' - for origin chain transactions that have been included on chain\n // - may sometimes be skipped, hence the need for 'submitted' condition below\n // 'submitted' - for destination chain transactions that have been submitted to the network\n // receipt - is present when the transaction has been mined/confirmed\n // Ensure onUserActionsCompleted is always called before onTransactionConfirmed\n (item) =>\n item.status === 'complete' ||\n item.checkStatus === 'pending' ||\n item.checkStatus === 'submitted' ||\n item.receipt !== undefined,\n ),\n )\n ) {\n logger.info(`${logPrefix}:onUserActionsCompleted`, txHashes)\n isUserActionsCompleted = true\n // Get the actual txHash from the receipt if using a smart wallet\n const finalTxHash = getFinalTxHash({\n smartWalletAdapter,\n steps,\n fallbackTxHash: txHash,\n logger,\n logPrefix,\n })\n\n try {\n await onUserActionsCompleted?.(finalTxHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onUserActionsCompletedFailed`,\n e as Error,\n )\n }\n }\n\n if (\n // Call onTransactionConfirmed only once\n !isTransactionConfirmed &&\n steps.every((step) =>\n step.items.every((item) => item.status === 'complete'),\n )\n ) {\n logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes)\n isTransactionConfirmed = true\n // Get the actual txHash from the receipt if using a smart wallet\n const finalTxHash = getFinalTxHash({\n smartWalletAdapter,\n steps,\n fallbackTxHash: txHash,\n logger,\n logPrefix,\n })\n\n // fire and forget index registration - skip for smart wallet adapters\n if (!smartWalletAdapter) {\n manuallyRegisterIndex(logger, {\n requestId: relayQuote.steps[0].requestId as string,\n chainId: relayQuote.steps[0].items[0].data.chainId,\n tx: jsonStringifyWithBigIntSanitization({\n ...relayQuote.steps[0].items[0].data,\n txHash: txHash,\n }),\n })\n }\n\n try {\n await onTransactionConfirmed?.(finalTxHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onTransactionConfirmedFailed`,\n e as Error,\n )\n }\n }\n }\n },\n })\n}\n\nexport interface PostRegistrationRequest {\n requestId: string\n chainId: string\n tx: string\n}\n\nexport type RegisterIndexingResponse =\n | { success: never; message: 'Success' }\n | { success: false; message: string }\n\nexport async function manuallyRegisterIndex(\n logger: Logger,\n registerRequest: PostRegistrationRequest,\n): Promise<void> {\n const logPrefix = 'manuallyRegisterIndex'\n const stringifiedRequest = JSON.stringify(registerRequest)\n const url = `${MAINNET_RELAY_API}/transactions/single`\n try {\n logger.info(`${logPrefix}:onManuallyRegisterIndex`, {\n params: stringifiedRequest,\n })\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(registerRequest),\n })\n if (!response.ok) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: 'Error !response.ok - request to manually register index',\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n return\n }\n\n const data = (await response.json()) as RegisterIndexingResponse\n if (data.message !== 'Success') {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Data.message is not of type Success - ${data.message}`,\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n }\n return\n } catch (err) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Error sending request to register index at ${url}: ${JSON.stringify((err as Error)?.message)}`,\n params: stringifiedRequest,\n })\n }\n}\n\nexport async function getRelayExecutionInfo(\n requestId: string,\n): Promise<RelayExecutionInfo> {\n const url = `${MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayExecutionInfo\n}\n", "import {\n FUNKIT_NATIVE_TOKEN,\n FUN_HYPERCORE_CHAIN_ID_NUMBER,\n FUN_SOLANA_CHAIN_ID_NUMBER,\n RELAY_BITCOIN_CHAIN_ID_NUMBER,\n RELAY_NATIVE_TOKEN,\n RELAY_NATIVE_TOKEN_BITCOIN,\n RELAY_NATIVE_TOKEN_HYPERCORE,\n RELAY_NATIVE_TOKEN_SOLANA,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './constants'\nimport type { RelayAddress, RelayVmType } from './execution'\nimport {\n CheckoutRefundState,\n CheckoutState,\n type RelayExecutionInfo,\n RelayExecutionStatus,\n} from './types'\n\n/**\n * Converts a token address within Funkit to the corresponding Relay token address.\n */\nexport function convertFunToRelayTokenAddress<T extends RelayVmType>(\n address: RelayAddress<T>,\n chainId: number,\n): RelayAddress<T> {\n // convert Fun's NATIVE_TOKEN representation\n if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {\n switch (chainId) {\n case FUN_HYPERCORE_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_HYPERCORE as RelayAddress<T>\n\n case RELAY_BITCOIN_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_BITCOIN as RelayAddress<T>\n\n case RELAY_SOLANA_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_SOLANA as RelayAddress<T>\n\n default:\n return RELAY_NATIVE_TOKEN as RelayAddress<T>\n }\n }\n\n return address\n}\n\n/**\n * Converts a chainId within Funkit to the corresponding Relay chainId.\n */\nexport function convertFunToRelayChainId(chainId: number): number {\n if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {\n return RELAY_SOLANA_CHAIN_ID_NUMBER\n }\n return chainId\n}\n\nexport function getRelayExecutionRefundState(\n info: RelayExecutionInfo,\n): CheckoutRefundState | undefined {\n switch (info.status) {\n case RelayExecutionStatus.REFUND:\n return CheckoutRefundState.REFUNDED\n default:\n return undefined\n }\n}\n\nexport function getRelayExecutionState(\n info: RelayExecutionInfo,\n): CheckoutState {\n switch (info.status) {\n case RelayExecutionStatus.SUCCESS:\n return CheckoutState.COMPLETED\n case RelayExecutionStatus.FAILURE:\n case RelayExecutionStatus.REFUND:\n return CheckoutState.CHECKOUT_ERROR\n default:\n return CheckoutState.PENDING_RECEIVAL\n }\n}\n\n/**\n * Checks whether the Relay execution has reached a terminal status.\n */\nexport function isRelayExecutionTerminalStatus(\n info: RelayExecutionInfo,\n): boolean {\n return RELAY_TERMINAL_STATUSES.includes(info.status)\n}\n\nexport type Serializable =\n | bigint\n | boolean\n | null\n | number\n | string\n | Date\n | object // Should be '{ [key: string]: Serializable }' but helper gets called with loosely-typed 'object' and interfaces\n | Serializable[]\n\nexport function jsonStringifyWithBigIntSanitization(\n serializable: Serializable,\n): string {\n return JSON.stringify(\n serializable,\n (_, value) =>\n typeof value === 'bigint' ? `0x${value.toString(16)}` : value, // return everything else unchanged\n )\n}\n", "import type { CallFees } from '@relayprotocol/relay-sdk'\nimport type { Logger } from './types'\n\nexport interface FunRelayFeeItem {\n b: number\n v: number\n config: {\n options: Record<string, unknown>\n }\n headers: Record<string, string>\n}\n\nexport async function getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue,\n clientId,\n recipientAddress,\n}: {\n fromTokenAddress: string\n fromChainId: string\n toTokenAddress: string\n toChainId: string\n estUsdValue: number\n clientId: string\n recipientAddress: string | undefined\n}): Promise<FunRelayFeeItem> {\n const params = new URLSearchParams({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: estUsdValue.toString(),\n clientId,\n ...(recipientAddress ? { recipientAddress } : {}),\n })\n const url = `https://frog.fun.xyz/api/fee?${params.toString()}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data\n}\n\nexport function parseRelayFees({\n fees,\n logger,\n}: {\n fees: CallFees | undefined\n logger: Logger\n}) {\n // Gas fees, denominated in source chain native token\n const relayGasFeesUsd = Number.parseFloat(fees?.gas?.amountUsd || '0')\n\n // App fees, denominated in source chain token\n const funLpFeesUsd = Number.parseFloat(fees?.app?.amountUsd || '0')\n const funLpFeesFromAmount = Number.parseFloat(\n fees?.app?.amountFormatted || '0',\n )\n const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || '0')\n\n // Relay fees, denominated in source chain token\n const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || '0')\n const relayLpFeesFromAmount = Number.parseFloat(\n fees?.relayer?.amountFormatted || '0',\n )\n const relayLpFeesFromAmountBaseUnit = BigInt(fees?.relayer?.amount || '0')\n\n const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd\n const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount\n const totalLpFeesFromAmountBaseUnit =\n funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit\n\n logger.info('parseRelayFees', {\n relayGasFeesUsd,\n funLpFeesUsd,\n funLpFeesFromAmount,\n funLpFeesFromAmountBaseUnit,\n relayLpFeesUsd,\n relayLpFeesFromAmount,\n relayLpFeesFromAmountBaseUnit,\n totalLpFeesUsd,\n totalLpFeesFromAmount,\n totalLpFeesFromAmountBaseUnit,\n })\n\n return {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd: relayGasFeesUsd + totalLpFeesUsd,\n totalFeesFromAmount: totalLpFeesFromAmount,\n totalFeesFromAmountBaseUnit: totalLpFeesFromAmountBaseUnit,\n }\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport type { RelayTokenPriceInfo } from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport async function getRelayAssetPriceInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenPriceInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/token/price?chainId=${relayChainId}&address=${relayTokenAddress}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayTokenPriceInfo\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport interface RelayTokenInfo {\n chainId: number\n address: string\n symbol: string\n name: string\n decimals: number\n vmType: string\n metadata: {\n logoURI: string\n verified: boolean\n isNative: boolean\n }\n}\n\nexport async function getRelayAssetInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/v2`\n const body = {\n chainIds: [relayChainId],\n address: relayTokenAddress,\n }\n const response = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data?.[0] as RelayTokenInfo\n}\n", "import {\n type APIError,\n type Execute,\n type GetQuoteParameters,\n isAPIError,\n} from '@relayprotocol/relay-sdk'\nimport { type Address, encodeFunctionData } from 'viem'\nimport { getRelayClient } from './client'\nimport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n} from './constants'\nimport { getRelayAssetInfo } from './currency'\nimport type {\n RelayAddress,\n RelayChainId,\n RelayVmType,\n RelayWallet,\n} from './execution'\nimport { getFunRelayFees, parseRelayFees } from './fees'\nimport { getRelayAssetPriceInfo } from './price'\nimport type { SolanaAddress } from './solana'\nimport type {\n ApiFunkitCheckoutActionParams,\n CheckoutQuoteResponse,\n Logger,\n} from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\ntype RelayQuoteOptions = GetQuoteParameters['options'] & {\n // TODO: Relay does not yet explicitly handle this field in their SDK, nor is it in their typings - but it gets forwarded to API\n depositFeePayer?: SolanaAddress\n}\n\nexport type RelayQuoteResult<VmType extends RelayVmType> = {\n details?: {\n currencyIn?: NonNullable<Execute['details']>['currencyIn']\n currencyOut?: NonNullable<Execute['details']>['currencyOut']\n }\n steps: Execute['steps']\n vmType: VmType\n}\n\nexport type GetRelayQuoteParams<\n SourceVmType extends RelayVmType = RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n> = {\n actionParams?: ApiFunkitCheckoutActionParams[]\n clientId: string\n fromChainId: RelayChainId<SourceVmType>\n fromTokenAddress: RelayAddress<SourceVmType>\n logger: Logger\n /**\n * {@link getRelayQuote} already sets {@link RelayQuoteOptions.appFees|appFees} and {@link RelayQuoteOptions.referrer|referrer}.\n * Only include them if you wish to override.\n */\n options?: RelayQuoteOptions\n recipientAddress: RelayAddress<TargetVmType> | undefined\n toChainId: RelayChainId<TargetVmType>\n toTokenAddress: RelayAddress<TargetVmType>\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n userAddress: RelayAddress<SourceVmType> | undefined\n walletClient?: RelayWallet<SourceVmType>\n} & (\n | {\n fromTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_INPUT'\n }\n | {\n toTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n }\n)\n\nexport type RelayQuote<VmType extends RelayVmType = RelayVmType> =\n CheckoutQuoteResponse & {\n /** Required for EXACT_INPUT checkouts */\n finalToAmountBaseUnit: string\n metadata: {\n fromAmountBaseUnit: string\n relayQuote: RelayQuoteResult<VmType>\n toAmountBaseUnit: string\n }\n }\n\nasync function getQuoteEstUsdValue({\n tokenChainId,\n tokenAddress,\n tokenAmountBaseUnit,\n logger,\n}: {\n tokenChainId: string\n tokenAddress: string\n tokenAmountBaseUnit: string\n logger: Logger\n}) {\n try {\n const normalizedChainId = convertFunToRelayChainId(\n Number(tokenChainId),\n ).toString()\n const normalizedTokenAddress = convertFunToRelayTokenAddress(\n tokenAddress as Address,\n Number(tokenChainId),\n )\n\n const [tokenPriceRes, tokenInfoRes] = await Promise.all([\n getRelayAssetPriceInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n getRelayAssetInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n ])\n\n // FIXME: Temp hardcode until relay supports WUSDE on Ethereal\n const isWUsdeEthereal =\n normalizedChainId === '5064014' &&\n normalizedTokenAddress.toLowerCase() ===\n '0xB6fC4B1BFF391e5F6b4a3D2C7Bda1FeE3524692D'.toLowerCase()\n\n const price = tokenPriceRes.price\n const decimals = isWUsdeEthereal ? 18 : tokenInfoRes.decimals\n\n const absoluteAmount = BigInt(tokenAmountBaseUnit) / BigInt(10 ** decimals)\n return Number(price) * Number(absoluteAmount)\n } catch (err) {\n logger.error('getQuoteEstUsdValueError', {\n message: `Failed to get USD value for token ${tokenAddress} on chain ${tokenChainId}: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }. Falling back to 0 USD.`,\n })\n // If any part fails, just fallback to 0 USD so that we do not block quote\n return 0\n }\n}\n\nexport function getReferrer(clientId: string) {\n return clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER\n}\n\nexport class RelayQuoteClientError extends Error {\n public constructor(\n public readonly statusCode: number,\n public readonly relayErrorCode: string,\n message: string,\n ) {\n super(\n `An error occurred trying to generate a relay quote: ${relayErrorCode} - ${message}`,\n )\n\n this.name = new.target.name\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport async function getRelayQuote<\n SourceVmType extends RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n>({\n logger,\n walletClient,\n ...params\n}: GetRelayQuoteParams<SourceVmType, TargetVmType>): Promise<\n RelayQuote<SourceVmType>\n> {\n const {\n actionParams,\n clientId,\n fromChainId,\n fromTokenAddress,\n options,\n recipientAddress,\n toChainId,\n toTokenAddress,\n tradeType,\n userAddress,\n } = params\n\n const vmType = (\n walletClient && 'vmType' in walletClient ? walletClient.vmType : 'evm'\n ) as SourceVmType\n\n try {\n const relayClient = getRelayClient()\n\n const txs = actionParams?.map((action) => {\n const data = encodeFunctionData({\n abi: action.contractAbi,\n args: action.functionArgs,\n functionName: action.functionName,\n })\n\n return {\n data,\n to: action.contractAddress,\n value: String(action.value ?? 0n),\n }\n })\n\n const isExactIn = params.tradeType === 'EXACT_INPUT'\n const queryTokenAmountBaseUnit = isExactIn\n ? params.fromTokenAmountBaseUnit\n : params.toTokenAmountBaseUnit\n const queryTokenAddress = isExactIn ? fromTokenAddress : toTokenAddress\n const queryTokenChainId = isExactIn ? fromChainId : toChainId\n\n const estUsdValue = await getQuoteEstUsdValue({\n tokenChainId: queryTokenChainId,\n tokenAddress: queryTokenAddress,\n tokenAmountBaseUnit: queryTokenAmountBaseUnit.toString(),\n logger,\n })\n\n const funRelayConfig = await getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: Number(estUsdValue) || 0,\n clientId,\n recipientAddress,\n })\n\n const appFeeBp = funRelayConfig.b + funRelayConfig.v\n\n logger.info('getRelayQuoteParams', {\n ...params,\n appFeeBp,\n estUsdValue,\n funRelayConfig,\n queryTokenAmountBaseUnit,\n txs,\n })\n\n // Get the full quote with fees\n const relayQuote = await relayClient.actions.getQuote(\n {\n amount: queryTokenAmountBaseUnit.toString(),\n chainId: convertFunToRelayChainId(Number(fromChainId)),\n currency: convertFunToRelayTokenAddress(\n fromTokenAddress,\n Number(fromChainId),\n ),\n recipient: recipientAddress,\n toChainId: convertFunToRelayChainId(Number(toChainId)),\n toCurrency: convertFunToRelayTokenAddress(\n toTokenAddress,\n Number(toChainId),\n ),\n tradeType,\n txs,\n user: userAddress,\n wallet: walletClient,\n options: {\n referrer: getReferrer(clientId),\n appFees: [\n {\n fee: appFeeBp.toString(),\n recipient: FUN_RELAY_REVENUE_WALLET,\n },\n ],\n // Passed in options\n ...options,\n // Remote options will always override passed in options\n ...funRelayConfig.config.options,\n },\n },\n undefined,\n funRelayConfig.headers,\n )\n\n logger.info('relayQuote', relayQuote)\n\n const estSubtotalUsd = Number(\n relayQuote.details?.currencyOut?.amountUsd || 0,\n )\n const estTotalUsd = Number(relayQuote.details?.currencyIn?.amountUsd || 0)\n // Get how much fromAmount is needed for the quote\n const fromAmountString =\n relayQuote.details?.currencyIn?.amountFormatted || '0'\n const fromAmountBaseUnitString =\n relayQuote.details?.currencyIn?.amount || '0'\n\n // RequestID will be consistent across steps in the quote\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1747774944603209\n const relayRequestId = relayQuote.steps[0]?.requestId\n\n // TODO: Verify with relay team if this is possible?\n if (!relayRequestId) {\n throw new Error('Relay quote does not contain a requestId')\n }\n\n // TODO: Verify with relay team if this is possible?\n if (!relayQuote.details?.currencyIn || !relayQuote.details?.currencyOut) {\n throw new Error('Relay quote does not contain trade details')\n }\n\n const {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd,\n totalFeesFromAmount,\n totalFeesFromAmountBaseUnit,\n } = parseRelayFees({ fees: relayQuote.fees, logger })\n\n const estSubtotalFromAmount = (\n Number.parseFloat(fromAmountString) - totalFeesFromAmount\n ).toString()\n\n const estSubtotalFromAmountBaseUnit = (\n BigInt(fromAmountBaseUnitString) - totalFeesFromAmountBaseUnit\n ).toString()\n\n return {\n quoteId: relayRequestId,\n estCheckoutTimeMs:\n (relayQuote.details.timeEstimate || 0) * 1000 +\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n estFeesFromAmount: totalFeesFromAmount.toString(),\n estFeesFromAmountBaseUnit: totalFeesFromAmountBaseUnit.toString(),\n estFeesUsd: totalFeesUsd,\n estMarketMakerGasUsd: relayGasFeesUsd,\n estSubtotalFromAmount,\n estSubtotalFromAmountBaseUnit,\n estSubtotalUsd,\n estTotalFromAmount: fromAmountString,\n estTotalFromAmountBaseUnit: fromAmountBaseUnitString,\n estTotalUsd,\n finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? '0', // TODO: Or do we want 'minimumAmount'?\n fromTokenAddress: fromTokenAddress as Address, // TODO: fromTokenAddress is typed as `0x${string}` why does not accept SolanaAddress\n lpFeePercentage: 0, // TODO: ?\n lpFeeUsd: totalLpFeesUsd,\n metadata: {\n fromAmountBaseUnit: isExactIn\n ? queryTokenAmountBaseUnit.toString()\n : (relayQuote.details.currencyIn.amount ?? '0'),\n relayQuote: {\n ...relayQuote,\n vmType,\n },\n toAmountBaseUnit: isExactIn\n ? (relayQuote.details.currencyOut.amount ?? '0')\n : queryTokenAmountBaseUnit.toString(),\n },\n }\n } catch (err) {\n if (err instanceof Error && isAPIError(err)) {\n const apiError = err as APIError\n const rawError = apiError.rawError as {\n errorCode?: string\n message?: string\n }\n\n if (rawError?.errorCode) {\n throw new RelayQuoteClientError(\n apiError.statusCode,\n rawError.errorCode,\n rawError.message ?? apiError.message,\n )\n }\n }\n\n const message = getErrorMessage(err)\n throw new Error(\n `An error occurred trying to generate a relay quote: ${message}`,\n )\n }\n}\n\nfunction getErrorMessage(err: unknown): string {\n return err instanceof Error\n ? err.message\n : typeof err === 'string'\n ? err\n : JSON.stringify(err)\n}\n", "import type { AdaptedWallet } from '@relayprotocol/relay-sdk'\nimport { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'\nimport {\n type Connection,\n SendTransactionError,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\n\ntype Base58 =\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n\nexport type SolanaAddress = `${Base58}${string}`\n\nexport type SolanaTxHash = `${Base58}${string}`\n\nexport type SolanaWallet = {\n address(): Promise<SolanaAddress>\n vmType: 'svm'\n} & AdaptedWallet\n\nexport function getSolanaWallet(\n walletAddress: SolanaAddress,\n connection: Connection,\n signTransaction: (\n transaction: VersionedTransaction,\n ) => Promise<VersionedTransaction>,\n payerKey?: SolanaAddress,\n): SolanaWallet {\n return adaptSolanaWallet(\n walletAddress,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n connection,\n async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection),\n )\n }\n\n throw error\n }\n },\n payerKey,\n ) as SolanaWallet\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AS,OAAO;AACd,YAAI,iBAAiB,kCAAsB;AACzC,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA,MAAM,MAAM,QAAQ,UAAU;AAAA,UAChC;AAAA,QACF;AAEA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["export {\n type BitcoinAddress,\n type BitcoinPsbt,\n type BitcoinPsbtDynamicParams,\n type BitcoinTxHash,\n type BitcoinWallet,\n getBitcoinWallet,\n getBitcoinWalletFromSigner,\n} from './src/bitcoin'\nexport {\n getRelayClient,\n initializeRelayClient,\n type InitializeRelayClientParams,\n} from './src/client'\nexport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_BITCOIN_CHAIN_ID,\n RELAY_BITCOIN_CHAIN_ID_NUMBER,\n RELAY_NATIVE_TOKEN_BITCOIN,\n RELAY_NATIVE_TOKEN_HYPERCORE,\n RELAY_NATIVE_TOKEN,\n RELAY_SOLANA_CHAIN_ID,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './src/constants'\nexport {\n type ExecuteRelayQuoteParams,\n type RelayAddress,\n type RelayChainId,\n type RelayExecutionStep,\n type RelayTxHash,\n type RelayVmType,\n type RelayWallet,\n executeRelayQuote,\n getRelayExecutionInfo,\n} from './src/execution'\nexport { parseRelayFees } from './src/fees'\nexport { getRelayAssetPriceInfo } from './src/price'\nexport { getRelayAssetInfo } from './src/currency'\nexport {\n type GetRelayQuoteParams,\n type RelayQuote,\n getRelayQuote,\n getReferrer,\n RelayQuoteClientError,\n} from './src/quote'\nexport {\n type SolanaAddress,\n type SolanaTxHash,\n type SolanaWallet,\n getSolanaWallet,\n} from './src/solana'\nexport {\n getRelayExecutionRefundState,\n getRelayExecutionState,\n isRelayExecutionTerminalStatus,\n convertFunToRelayTokenAddress,\n convertFunToRelayChainId,\n} from './src/utils'\nexport {\n LogLevel,\n type RelayExecutionInfo,\n type RelayExecutionStatus,\n type RelayTokenPriceInfo,\n} from './src/types'\n", "import { adaptBitcoinWallet } from '@relayprotocol/relay-bitcoin-wallet-adapter'\nimport type { AdaptedWallet } from '@relayprotocol/relay-sdk'\n\ntype Base16 =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n\nexport type BitcoinAddress =\n | `1${string}`\n | `3${string}`\n | `bc1${string}`\n | `bc1p${string}`\n\nexport type BitcoinTxHash = `${Base16}${string}`\n\nexport type BitcoinWallet = {\n address(): Promise<BitcoinAddress>\n vmType: 'bvm'\n} & AdaptedWallet\n\n/** bitcoinjs-lib Psbt */\nexport type BitcoinPsbt = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[1]\n\nexport type BitcoinPsbtDynamicParams = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[2]\n\n/** bitcoinjs-lib Signer */\nexport type BitcoinSigner = Parameters<BitcoinPsbt['signAllInputs']>[0]\n\nexport function getBitcoinWallet(\n walletAddress: BitcoinAddress,\n signPsbt: (\n address: BitcoinAddress,\n psbt: BitcoinPsbt,\n dynamicParams: BitcoinPsbtDynamicParams,\n ) => Promise<string>,\n): BitcoinWallet {\n return adaptBitcoinWallet(walletAddress, (address, psbt, dynamicParams) =>\n signPsbt(address as BitcoinAddress, psbt, dynamicParams),\n ) as BitcoinWallet\n}\n\nexport function getBitcoinWalletFromSigner(\n walletAddress: BitcoinAddress,\n signer: BitcoinSigner,\n): BitcoinWallet {\n return getBitcoinWallet(walletAddress, async (_, psbt) =>\n psbt.signAllInputs(signer).toBase64(),\n )\n}\n", "import {\n LogLevel,\n MAINNET_RELAY_API,\n type RelayClient,\n type RelayClientOptions,\n convertViemChainToRelayChain,\n createClient,\n getClient,\n} from '@relayprotocol/relay-sdk'\nimport type { Chain } from 'viem'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\nimport type { Logger } from './types'\n\nexport type InitializeRelayClientParams = Omit<\n RelayClientOptions,\n 'baseApiUrl' | 'chains' | 'logger'\n> & {\n chains: Chain[]\n logger: Logger\n}\n\n/**\n * Initializes a global instance of the RelayClient\n * https://docs.relay.link/references/sdk/createClient\n */\nexport function initializeRelayClient({\n chains,\n logger,\n ...options\n}: InitializeRelayClientParams): RelayClient {\n return createClient({\n ...options,\n baseApiUrl: MAINNET_RELAY_API,\n chains: [\n ...chains.map(convertViemChainToRelayChain),\n {\n id: RELAY_SOLANA_CHAIN_ID_NUMBER,\n name: 'Solana',\n displayName: 'Solana',\n },\n ],\n logger: (message, level) => {\n if (level === LogLevel.Error) {\n logger.error('[RelayClient]:', message)\n } else {\n logger.info('[RelayClient]:', message)\n }\n },\n })\n}\n\n/**\n * Gets the global instance of the RelayClient\n */\nexport function getRelayClient(): RelayClient {\n const client = getClient()\n\n if (!client) {\n throw new Error('Relay client is not defined')\n }\n\n return client\n}\n", "import { LogLevel } from '@relayprotocol/relay-sdk'\nimport type { Abi, Address } from 'viem'\n\nexport { LogLevel }\n\n// https://docs.relay.link/references/api/get-intents-status-v2\nexport interface RelayExecutionInfo {\n status: RelayExecutionStatus\n details: string\n /** Incoming transaction hashes */\n inTxHashes: string[]\n /** Outgoing transaction hashes */\n txHashes: string[]\n /** The last timestamp the data was updated in milliseconds */\n time: number\n originChainId: number\n destinationChainId: number\n}\n\n// https://docs.relay.link/references/api/get-token-price\nexport interface RelayTokenPriceInfo {\n price: number\n}\n\n//// The types below are duplicated from @funkit/api-base atm, but this package should be used in BE as well\n//// TODO: Are we fine with BE importing @funkit/api-base and (by extension) @funkit/utils?\n//// See https://linear.app/funxyz/issue/PE-1342/sdk-extract-domainsrelayts-to-a-new-package#comment-d487d533\n\nexport interface Logger {\n error(message: string, data?: object): void\n info(message: string, data?: object): void\n}\n\n// Reference: https://github.com/reservoirprotocol/relay-kit/blob/211c645f9702a3b459ff545aa4e2e9d536c38455/packages/sdk/src/types/Execute.ts#L54-L61\nexport enum RelayExecutionStatus {\n DELAYED = 'delayed',\n FAILURE = 'failure',\n PENDING = 'pending',\n REFUND = 'refund',\n SUCCESS = 'success',\n WAITING = 'waiting',\n UNKNOWN = 'unknown',\n}\n\nexport interface ApiFunkitCheckoutActionParams {\n contractAbi: Abi\n contractAddress: Address\n functionName: string\n functionArgs: unknown[]\n value?: bigint\n}\n\nexport enum CheckoutRefundState {\n INITIATED = 'INITIATED',\n ERROR = 'ERROR',\n REFUNDED = 'REFUNDED',\n PROCEEDED = 'PROCEEDED',\n WAITING_FOR_FULFILLMENT = 'WAITING_FOR_FULFILLMENT',\n FULFILLED = 'FULFILLED',\n}\n\n// Reference from api server: https://github.com/fun-xyz/fun-api-server/blob/main/src/tables/FunWalletCheckout.ts#L11C1-L21C2\nexport enum CheckoutState {\n // In-progress States\n FROM_UNFUNDED = 'FROM_UNFUNDED',\n FROM_FUNDED = 'FROM_FUNDED',\n FROM_POOLED = 'FROM_POOLED',\n TO_UNFUNDED = 'TO_UNFUNDED',\n TO_FUNDED = 'TO_FUNDED',\n TO_POOLED = 'TO_POOLED',\n TO_READY = 'TO_READY',\n PENDING_RECEIVAL = 'PENDING_RECEIVAL',\n // Terminal States\n COMPLETED = 'COMPLETED',\n CHECKOUT_ERROR = 'CHECKOUT_ERROR',\n EXPIRED = 'EXPIRED',\n CANCELLED = 'CANCELLED',\n}\n\n// The response of the actual /checkout/quote api\nexport type CheckoutApiQuoteResponse = {\n quoteId: string\n estTotalFromAmountBaseUnit: string\n estSubtotalFromAmountBaseUnit: string\n estFeesFromAmountBaseUnit: string\n fromTokenAddress: Address\n estFeesUsd: number\n estSubtotalUsd: number\n estTotalUsd: number\n estCheckoutTimeMs: number\n estMarketMakerGasUsd: number\n lpFeePercentage: number\n lpFeeUsd: number\n}\n\n// The formatted response quote interface from the core sdk\nexport type CheckoutQuoteResponse = CheckoutApiQuoteResponse & {\n estTotalFromAmount: string\n estSubtotalFromAmount: string\n estFeesFromAmount: string\n\n // Any additional fields purely for frontend use\n metadata?: { [key: string]: unknown }\n}\n", "import type { Address } from 'viem'\nimport type { BitcoinAddress } from './bitcoin'\nimport type { SolanaAddress } from './solana'\nimport { RelayExecutionStatus } from './types'\n\n/**\n * Chain id that Relay uses to identify Bitcoin\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_BITCOIN_CHAIN_ID_NUMBER = 8253038 // Why cannot Relay export this themselves... -.-\nexport const RELAY_BITCOIN_CHAIN_ID = `${RELAY_BITCOIN_CHAIN_ID_NUMBER}`\n\n/**\n * Chain id that Relay uses to identify Solana\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_SOLANA_CHAIN_ID_NUMBER = 792703809 // Why cannot Relay export this themselves... -.-\nexport const RELAY_SOLANA_CHAIN_ID = `${RELAY_SOLANA_CHAIN_ID_NUMBER}`\n\nexport const FUN_SOLANA_CHAIN_ID_NUMBER = 1151111081099710\nexport const FUN_HYPERCORE_CHAIN_ID_NUMBER = 1337\n\n/**\n * Fake address for a chain's native currency used by Funkit\n */\nexport const FUNKIT_NATIVE_TOKEN =\n '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' satisfies Address\n\n/**\n * Fake address for a chain's native currency used by Relay\n */\nexport const RELAY_NATIVE_TOKEN =\n '0x0000000000000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for Hypercore's native currency used by Relay. This is shorter than the default native token...\n */\nexport const RELAY_NATIVE_TOKEN_HYPERCORE =\n '0x00000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_SOLANA =\n '11111111111111111111111111111111' satisfies SolanaAddress\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_BITCOIN =\n 'bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8' satisfies BitcoinAddress\n\n/**\n * Wallet that receives the app fees collected by Relay\n * Prev: 0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E\n */\nexport const FUN_RELAY_REVENUE_WALLET =\n '0xdfd877679e95c1276c85801805b2c2ab8f4f4cf6' satisfies Address\n\n/**\n * Referred field in Relay quote\n */\nexport const FUN_RELAY_REFERRER = 'funxyz'\n\n/**\n * Buffer added to Relay's time estimate (which sometimes is 0)\n */\nexport const RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25_000 // 25 seconds\n\nexport const RELAY_TERMINAL_STATUSES: RelayExecutionStatus[] = [\n RelayExecutionStatus.REFUND,\n RelayExecutionStatus.FAILURE,\n RelayExecutionStatus.SUCCESS,\n]\n\nexport const SUSHI_ORG_ID = 'fysix7gj5j'\nexport const HYPERSWAP_ORG_ID = '2ejzdxhfge'\nexport const HYPERBEAT_ORG_ID = 'opzh9rydei'\n", "import {\n type AdaptedWallet,\n MAINNET_RELAY_API,\n type ProgressData,\n} from '@relayprotocol/relay-sdk'\nimport type { Address, Hex, WalletClient } from 'viem'\nimport type { BitcoinAddress, BitcoinTxHash, BitcoinWallet } from './bitcoin'\nimport { getRelayClient } from './client'\nimport type { RELAY_BITCOIN_CHAIN_ID, RELAY_SOLANA_CHAIN_ID } from './constants'\nimport type { RelayQuoteResult } from './quote'\nimport type { SolanaAddress, SolanaTxHash, SolanaWallet } from './solana'\nimport type { Logger, RelayExecutionInfo } from './types'\nimport { jsonStringifyWithBigIntSanitization } from './utils'\n\nexport type RelayExecutionStep = ProgressData['currentStep'] & {}\n\nexport type RelayVmType = 'bvm' | 'evm' | 'hypevm' | 'svm'\n\nexport type RelayAddress<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinAddress\n evm: Address\n hypevm: Address\n svm: SolanaAddress\n}[VmType]\n\nexport type RelayChainId<VmType extends RelayVmType = RelayVmType> = {\n bvm: typeof RELAY_BITCOIN_CHAIN_ID\n evm: string\n hypevm: string\n svm: typeof RELAY_SOLANA_CHAIN_ID\n}[VmType]\n\nexport type RelayTxHash<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinTxHash\n evm: Hex\n hypevm: Hex\n svm: SolanaTxHash\n}[VmType]\n\nexport type RelayWallet<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinWallet\n evm: WalletClient | (AdaptedWallet & { vmType: 'evm' })\n hypevm: AdaptedWallet & { vmType: 'hypevm' }\n svm: SolanaWallet\n}[VmType]\n\nexport interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {\n logger: Logger\n onError: (error: Error) => Promise<void>\n onProgress?: (step: RelayExecutionStep | null) => void\n /**\n * Fired when all *input* transactions are confirmed on-chain.\n */\n onTransactionConfirmed?: (txHash: RelayTxHash<VmType>) => Promise<void>\n /**\n * Fired as soon as user has *signed* all input transactions, but before they are confirmed on-chain.\n *\n * After this event, no more action should be needed from the user.\n * However, it is possible that the transactions will be rejected and the execution will NOT continue.\n */\n onUserActionsCompleted?: (txHash: RelayTxHash<VmType>) => Promise<void>\n relayQuote: RelayQuoteResult<VmType>\n walletClient: RelayWallet<VmType>\n}\n\nexport async function executeRelayQuote<VmType extends RelayVmType>({\n logger,\n onError,\n onProgress,\n onTransactionConfirmed,\n onUserActionsCompleted,\n relayQuote,\n walletClient,\n}: ExecuteRelayQuoteParams<VmType>): Promise<void> {\n let isUserActionsCompleted = false\n let isTransactionConfirmed = false\n\n await getRelayClient().actions.execute({\n quote: relayQuote,\n wallet: walletClient,\n onProgress: async ({\n steps,\n fees,\n breakdown,\n currentStep,\n currentStepItem,\n txHashes,\n details,\n error,\n }) => {\n const logPrefix = 'onRelayProgress'\n logger.info(`${logPrefix}:params`, {\n steps,\n currentStep,\n fees,\n breakdown,\n currentStepItem,\n txHashes,\n details,\n error,\n })\n\n onProgress?.(currentStep ?? null)\n\n if (error) {\n logger.info(`${logPrefix}:errorDetected`, error)\n await onError(error).catch((e) => {\n logger.error(`${logPrefix}:onErrorFailed`, e)\n })\n } else if (txHashes?.length) {\n // Use first txHash as the main txHash in fun DE table\n // Bad surprise from Relay: txHash may be an object, this is not present in their typing...\n const rawTxHashWithUnreliableTyping = txHashes[0].txHash as\n | RelayTxHash<VmType>\n | { id: RelayTxHash<VmType> }\n\n const txHash =\n typeof rawTxHashWithUnreliableTyping === 'object'\n ? rawTxHashWithUnreliableTyping.id\n : rawTxHashWithUnreliableTyping\n\n if (\n // Call onUserActionsCompleted only once\n !isUserActionsCompleted &&\n steps.every((step) =>\n step.items.every(\n // 'completed' - catch-all for items marked completed with no other info\n // - e.g. Batched items will not have txHash but will have their item marked 'complete'\n // 'pending' - for origin chain transactions that have been included on chain\n // - may sometimes be skipped, hence the need for 'submitted' condition below\n // 'submitted' - for destination chain transactions that have been submitted to the network\n // receipt - is present when the transaction has been mined/confirmed\n // Ensure onUserActionsCompleted is always called before onTransactionConfirmed\n (item) =>\n item.status === 'complete' ||\n item.checkStatus === 'pending' ||\n item.checkStatus === 'submitted' ||\n item.receipt !== undefined,\n ),\n )\n ) {\n logger.info(`${logPrefix}:onUserActionsCompleted`, txHashes)\n isUserActionsCompleted = true\n\n try {\n await onUserActionsCompleted?.(txHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onUserActionsCompletedFailed`,\n e as Error,\n )\n }\n }\n\n if (\n // Call onTransactionConfirmed only once\n !isTransactionConfirmed &&\n steps.every((step) =>\n step.items.every((item) => item.status === 'complete'),\n )\n ) {\n logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes)\n isTransactionConfirmed = true\n\n // fire and forget index registration\n if (relayQuote.steps[0].requestId) {\n manuallyRegisterIndex(logger, {\n requestId: relayQuote.steps[0].requestId,\n chainId: relayQuote.steps[0].items[0].data.chainId,\n tx: jsonStringifyWithBigIntSanitization({\n ...relayQuote.steps[0].items[0].data,\n txHash,\n }),\n })\n }\n\n try {\n await onTransactionConfirmed?.(txHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onTransactionConfirmedFailed`,\n e as Error,\n )\n }\n }\n }\n },\n })\n}\n\nexport interface PostRegistrationRequest {\n requestId: string\n chainId: string\n tx: string\n}\n\nexport type RegisterIndexingResponse =\n | { success: never; message: 'Success' }\n | { success: false; message: string }\n\nexport async function manuallyRegisterIndex(\n logger: Logger,\n registerRequest: PostRegistrationRequest,\n): Promise<void> {\n const logPrefix = 'manuallyRegisterIndex'\n const stringifiedRequest = JSON.stringify(registerRequest)\n const url = `${MAINNET_RELAY_API}/transactions/single`\n try {\n logger.info(`${logPrefix}:onManuallyRegisterIndex`, {\n params: stringifiedRequest,\n })\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(registerRequest),\n })\n if (!response.ok) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: 'Error !response.ok - request to manually register index',\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n return\n }\n\n const data = (await response.json()) as RegisterIndexingResponse\n if (data.message !== 'Success') {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Data.message is not of type Success - ${data.message}`,\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n }\n return\n } catch (err) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Error sending request to register index at ${url}: ${JSON.stringify((err as Error)?.message)}`,\n params: stringifiedRequest,\n })\n }\n}\n\nexport async function getRelayExecutionInfo(\n requestId: string,\n): Promise<RelayExecutionInfo> {\n const url = `${MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayExecutionInfo\n}\n", "import {\n FUNKIT_NATIVE_TOKEN,\n FUN_HYPERCORE_CHAIN_ID_NUMBER,\n FUN_SOLANA_CHAIN_ID_NUMBER,\n RELAY_BITCOIN_CHAIN_ID_NUMBER,\n RELAY_NATIVE_TOKEN,\n RELAY_NATIVE_TOKEN_BITCOIN,\n RELAY_NATIVE_TOKEN_HYPERCORE,\n RELAY_NATIVE_TOKEN_SOLANA,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './constants'\nimport type { RelayAddress, RelayVmType } from './execution'\nimport {\n CheckoutRefundState,\n CheckoutState,\n type RelayExecutionInfo,\n RelayExecutionStatus,\n} from './types'\n\n/**\n * Converts a token address within Funkit to the corresponding Relay token address.\n */\nexport function convertFunToRelayTokenAddress<T extends RelayVmType>(\n address: RelayAddress<T>,\n chainId: number,\n): RelayAddress<T> {\n // convert Fun's NATIVE_TOKEN representation\n if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {\n switch (chainId) {\n case FUN_HYPERCORE_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_HYPERCORE as RelayAddress<T>\n\n case RELAY_BITCOIN_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_BITCOIN as RelayAddress<T>\n\n case RELAY_SOLANA_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_SOLANA as RelayAddress<T>\n\n default:\n return RELAY_NATIVE_TOKEN as RelayAddress<T>\n }\n }\n\n return address\n}\n\n/**\n * Converts a chainId within Funkit to the corresponding Relay chainId.\n */\nexport function convertFunToRelayChainId(chainId: number): number {\n if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {\n return RELAY_SOLANA_CHAIN_ID_NUMBER\n }\n return chainId\n}\n\nexport function getRelayExecutionRefundState(\n info: RelayExecutionInfo,\n): CheckoutRefundState | undefined {\n switch (info.status) {\n case RelayExecutionStatus.REFUND:\n return CheckoutRefundState.REFUNDED\n default:\n return undefined\n }\n}\n\nexport function getRelayExecutionState(\n info: RelayExecutionInfo,\n): CheckoutState {\n switch (info.status) {\n case RelayExecutionStatus.SUCCESS:\n return CheckoutState.COMPLETED\n case RelayExecutionStatus.FAILURE:\n case RelayExecutionStatus.REFUND:\n return CheckoutState.CHECKOUT_ERROR\n default:\n return CheckoutState.PENDING_RECEIVAL\n }\n}\n\n/**\n * Checks whether the Relay execution has reached a terminal status.\n */\nexport function isRelayExecutionTerminalStatus(\n info: RelayExecutionInfo,\n): boolean {\n return RELAY_TERMINAL_STATUSES.includes(info.status)\n}\n\nexport type Serializable =\n | bigint\n | boolean\n | null\n | number\n | string\n | Date\n | object // Should be '{ [key: string]: Serializable }' but helper gets called with loosely-typed 'object' and interfaces\n | Serializable[]\n\nexport function jsonStringifyWithBigIntSanitization(\n serializable: Serializable,\n): string {\n return JSON.stringify(\n serializable,\n (_, value) =>\n typeof value === 'bigint' ? `0x${value.toString(16)}` : value, // return everything else unchanged\n )\n}\n", "import type { CallFees } from '@relayprotocol/relay-sdk'\nimport type { Logger } from './types'\n\nexport interface FunRelayFeeItem {\n b: number\n v: number\n config: {\n options: Record<string, unknown>\n }\n headers: Record<string, string>\n}\n\nexport async function getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue,\n clientId,\n recipientAddress,\n}: {\n fromTokenAddress: string\n fromChainId: string\n toTokenAddress: string\n toChainId: string\n estUsdValue: number\n clientId: string\n recipientAddress: string | undefined\n}): Promise<FunRelayFeeItem> {\n const params = new URLSearchParams({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: estUsdValue.toString(),\n clientId,\n ...(recipientAddress ? { recipientAddress } : {}),\n })\n const url = `https://frog.fun.xyz/api/fee?${params.toString()}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data\n}\n\nexport function parseRelayFees({\n fees,\n logger,\n}: {\n fees: CallFees | undefined\n logger: Logger\n}) {\n // Gas fees, denominated in source chain native token\n const relayGasFeesUsd = Number.parseFloat(fees?.gas?.amountUsd || '0')\n\n // App fees, denominated in source chain token\n const funLpFeesUsd = Number.parseFloat(fees?.app?.amountUsd || '0')\n const funLpFeesFromAmount = Number.parseFloat(\n fees?.app?.amountFormatted || '0',\n )\n const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || '0')\n\n // Relay fees, denominated in source chain token\n const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || '0')\n const relayLpFeesFromAmount = Number.parseFloat(\n fees?.relayer?.amountFormatted || '0',\n )\n const relayLpFeesFromAmountBaseUnit = BigInt(fees?.relayer?.amount || '0')\n\n const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd\n const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount\n const totalLpFeesFromAmountBaseUnit =\n funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit\n\n logger.info('parseRelayFees', {\n relayGasFeesUsd,\n funLpFeesUsd,\n funLpFeesFromAmount,\n funLpFeesFromAmountBaseUnit,\n relayLpFeesUsd,\n relayLpFeesFromAmount,\n relayLpFeesFromAmountBaseUnit,\n totalLpFeesUsd,\n totalLpFeesFromAmount,\n totalLpFeesFromAmountBaseUnit,\n })\n\n return {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd: relayGasFeesUsd + totalLpFeesUsd,\n totalFeesFromAmount: totalLpFeesFromAmount,\n totalFeesFromAmountBaseUnit: totalLpFeesFromAmountBaseUnit,\n }\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport type { RelayTokenPriceInfo } from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport async function getRelayAssetPriceInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenPriceInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/token/price?chainId=${relayChainId}&address=${relayTokenAddress}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayTokenPriceInfo\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport interface RelayTokenInfo {\n chainId: number\n address: string\n symbol: string\n name: string\n decimals: number\n vmType: string\n metadata: {\n logoURI: string\n verified: boolean\n isNative: boolean\n }\n}\n\nexport async function getRelayAssetInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/v2`\n const body = {\n chainIds: [relayChainId],\n address: relayTokenAddress,\n }\n const response = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data?.[0] as RelayTokenInfo\n}\n", "import {\n type APIError,\n type Execute,\n type GetQuoteParameters,\n isAPIError,\n} from '@relayprotocol/relay-sdk'\nimport { type Address, encodeFunctionData } from 'viem'\nimport { getRelayClient } from './client'\nimport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n} from './constants'\nimport { getRelayAssetInfo } from './currency'\nimport type {\n RelayAddress,\n RelayChainId,\n RelayVmType,\n RelayWallet,\n} from './execution'\nimport { getFunRelayFees, parseRelayFees } from './fees'\nimport { getRelayAssetPriceInfo } from './price'\nimport type { SolanaAddress } from './solana'\nimport type {\n ApiFunkitCheckoutActionParams,\n CheckoutQuoteResponse,\n Logger,\n} from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\ntype RelayQuoteOptions = GetQuoteParameters['options'] & {\n // TODO: Relay does not yet explicitly handle this field in their SDK, nor is it in their typings - but it gets forwarded to API\n depositFeePayer?: SolanaAddress\n}\n\nexport type RelayQuoteResult<VmType extends RelayVmType> = {\n details?: {\n currencyIn?: NonNullable<Execute['details']>['currencyIn']\n currencyOut?: NonNullable<Execute['details']>['currencyOut']\n }\n steps: Execute['steps']\n vmType: VmType\n}\n\nexport type GetRelayQuoteParams<\n SourceVmType extends RelayVmType = RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n> = {\n actionParams?: ApiFunkitCheckoutActionParams[]\n clientId: string\n fromChainId: RelayChainId<SourceVmType>\n fromTokenAddress: RelayAddress<SourceVmType>\n logger: Logger\n /**\n * {@link getRelayQuote} already sets {@link RelayQuoteOptions.appFees|appFees} and {@link RelayQuoteOptions.referrer|referrer}.\n * Only include them if you wish to override.\n */\n options?: RelayQuoteOptions\n recipientAddress: RelayAddress<TargetVmType> | undefined\n toChainId: RelayChainId<TargetVmType>\n toTokenAddress: RelayAddress<TargetVmType>\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n userAddress: RelayAddress<SourceVmType> | undefined\n walletClient?: RelayWallet<SourceVmType>\n} & (\n | {\n fromTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_INPUT'\n }\n | {\n toTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n }\n)\n\nexport type RelayQuote<VmType extends RelayVmType = RelayVmType> =\n CheckoutQuoteResponse & {\n /** Required for EXACT_INPUT checkouts */\n finalToAmountBaseUnit: string\n metadata: {\n fromAmountBaseUnit: string\n relayQuote: RelayQuoteResult<VmType>\n toAmountBaseUnit: string\n }\n }\n\nasync function getQuoteEstUsdValue({\n tokenChainId,\n tokenAddress,\n tokenAmountBaseUnit,\n logger,\n}: {\n tokenChainId: string\n tokenAddress: string\n tokenAmountBaseUnit: string\n logger: Logger\n}) {\n try {\n const normalizedChainId = convertFunToRelayChainId(\n Number(tokenChainId),\n ).toString()\n const normalizedTokenAddress = convertFunToRelayTokenAddress(\n tokenAddress as Address,\n Number(tokenChainId),\n )\n\n const [tokenPriceRes, tokenInfoRes] = await Promise.all([\n getRelayAssetPriceInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n getRelayAssetInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n ])\n\n // FIXME: Temp hardcode until relay supports WUSDE on Ethereal\n const isWUsdeEthereal =\n normalizedChainId === '5064014' &&\n normalizedTokenAddress.toLowerCase() ===\n '0xB6fC4B1BFF391e5F6b4a3D2C7Bda1FeE3524692D'.toLowerCase()\n\n const price = tokenPriceRes.price\n const decimals = isWUsdeEthereal ? 18 : tokenInfoRes.decimals\n\n const absoluteAmount = BigInt(tokenAmountBaseUnit) / BigInt(10 ** decimals)\n return Number(price) * Number(absoluteAmount)\n } catch (err) {\n logger.error('getQuoteEstUsdValueError', {\n message: `Failed to get USD value for token ${tokenAddress} on chain ${tokenChainId}: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }. Falling back to 0 USD.`,\n })\n // If any part fails, just fallback to 0 USD so that we do not block quote\n return 0\n }\n}\n\nexport function getReferrer(clientId: string) {\n return clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER\n}\n\nexport class RelayQuoteClientError extends Error {\n public constructor(\n public readonly statusCode: number,\n public readonly relayErrorCode: string,\n message: string,\n ) {\n super(\n `An error occurred trying to generate a relay quote: ${relayErrorCode} - ${message}`,\n )\n\n this.name = new.target.name\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport async function getRelayQuote<\n SourceVmType extends RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n>({\n logger,\n walletClient,\n ...params\n}: GetRelayQuoteParams<SourceVmType, TargetVmType>): Promise<\n RelayQuote<SourceVmType>\n> {\n const {\n actionParams,\n clientId,\n fromChainId,\n fromTokenAddress,\n options,\n recipientAddress,\n toChainId,\n toTokenAddress,\n tradeType,\n userAddress,\n } = params\n\n const vmType = (\n walletClient && 'vmType' in walletClient ? walletClient.vmType : 'evm'\n ) as SourceVmType\n\n try {\n const relayClient = getRelayClient()\n\n const txs = actionParams?.map((action) => {\n const data = encodeFunctionData({\n abi: action.contractAbi,\n args: action.functionArgs,\n functionName: action.functionName,\n })\n\n return {\n data,\n to: action.contractAddress,\n // Relay supports msg.value via 2 fields: `value` and `originalTxValue`\n // Both `value` and `originalTxValue` are required to be set for `erc20` + gas transfers\n // Only `value` is required for native token transfers. // TODO: This flow needs verification.\n // Internally for Relay,\n // - `originalTxValue` is designed to \"bubble up\" the value to the original tx\n // - `value` is the internal multicall value\n originalTxValue: String(action.value ?? 0n),\n value: String(action.value ?? 0n),\n }\n })\n\n const isExactIn = params.tradeType === 'EXACT_INPUT'\n const queryTokenAmountBaseUnit = isExactIn\n ? params.fromTokenAmountBaseUnit\n : params.toTokenAmountBaseUnit\n const queryTokenAddress = isExactIn ? fromTokenAddress : toTokenAddress\n const queryTokenChainId = isExactIn ? fromChainId : toChainId\n\n const estUsdValue = await getQuoteEstUsdValue({\n tokenChainId: queryTokenChainId,\n tokenAddress: queryTokenAddress,\n tokenAmountBaseUnit: queryTokenAmountBaseUnit.toString(),\n logger,\n })\n\n const funRelayConfig = await getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: Number(estUsdValue) || 0,\n clientId,\n recipientAddress,\n })\n\n const appFeeBp = funRelayConfig.b + funRelayConfig.v\n\n logger.info('getRelayQuoteParams', {\n ...params,\n appFeeBp,\n estUsdValue,\n funRelayConfig,\n queryTokenAmountBaseUnit,\n txs,\n })\n\n // Get the full quote with fees\n const relayQuote = await relayClient.actions.getQuote(\n {\n amount: queryTokenAmountBaseUnit.toString(),\n chainId: convertFunToRelayChainId(Number(fromChainId)),\n currency: convertFunToRelayTokenAddress(\n fromTokenAddress,\n Number(fromChainId),\n ),\n recipient: recipientAddress,\n toChainId: convertFunToRelayChainId(Number(toChainId)),\n toCurrency: convertFunToRelayTokenAddress(\n toTokenAddress,\n Number(toChainId),\n ),\n tradeType,\n txs,\n user: userAddress,\n wallet: walletClient,\n options: {\n referrer: getReferrer(clientId),\n appFees: [\n {\n fee: appFeeBp.toString(),\n recipient: FUN_RELAY_REVENUE_WALLET,\n },\n ],\n // Passed in options\n ...options,\n // Remote options will always override passed in options\n ...funRelayConfig.config.options,\n },\n },\n undefined,\n funRelayConfig.headers,\n )\n\n logger.info('relayQuote', relayQuote)\n\n const estSubtotalUsd = Number(\n relayQuote.details?.currencyOut?.amountUsd || 0,\n )\n const estTotalUsd = Number(relayQuote.details?.currencyIn?.amountUsd || 0)\n // Get how much fromAmount is needed for the quote\n const fromAmountString =\n relayQuote.details?.currencyIn?.amountFormatted || '0'\n const fromAmountBaseUnitString =\n relayQuote.details?.currencyIn?.amount || '0'\n\n // RequestID will be consistent across steps in the quote\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1747774944603209\n const relayRequestId = relayQuote.steps[0]?.requestId\n\n // TODO: Verify with relay team if this is possible?\n if (!relayRequestId) {\n throw new Error('Relay quote does not contain a requestId')\n }\n\n // TODO: Verify with relay team if this is possible?\n if (!relayQuote.details?.currencyIn || !relayQuote.details?.currencyOut) {\n throw new Error('Relay quote does not contain trade details')\n }\n\n const {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd,\n totalFeesFromAmount,\n totalFeesFromAmountBaseUnit,\n } = parseRelayFees({ fees: relayQuote.fees, logger })\n\n const estSubtotalFromAmount = (\n Number.parseFloat(fromAmountString) - totalFeesFromAmount\n ).toString()\n\n const estSubtotalFromAmountBaseUnit = (\n BigInt(fromAmountBaseUnitString) - totalFeesFromAmountBaseUnit\n ).toString()\n\n return {\n quoteId: relayRequestId,\n estCheckoutTimeMs:\n (relayQuote.details.timeEstimate || 0) * 1000 +\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n estFeesFromAmount: totalFeesFromAmount.toString(),\n estFeesFromAmountBaseUnit: totalFeesFromAmountBaseUnit.toString(),\n estFeesUsd: totalFeesUsd,\n estMarketMakerGasUsd: relayGasFeesUsd,\n estSubtotalFromAmount,\n estSubtotalFromAmountBaseUnit,\n estSubtotalUsd,\n estTotalFromAmount: fromAmountString,\n estTotalFromAmountBaseUnit: fromAmountBaseUnitString,\n estTotalUsd,\n finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? '0', // TODO: Or do we want 'minimumAmount'?\n fromTokenAddress: fromTokenAddress as Address, // TODO: fromTokenAddress is typed as `0x${string}` why does not accept SolanaAddress\n lpFeePercentage: 0, // TODO: ?\n lpFeeUsd: totalLpFeesUsd,\n metadata: {\n fromAmountBaseUnit: isExactIn\n ? queryTokenAmountBaseUnit.toString()\n : (relayQuote.details.currencyIn.amount ?? '0'),\n relayQuote: {\n ...relayQuote,\n vmType,\n },\n toAmountBaseUnit: isExactIn\n ? (relayQuote.details.currencyOut.amount ?? '0')\n : queryTokenAmountBaseUnit.toString(),\n },\n }\n } catch (err) {\n if (err instanceof Error && isAPIError(err)) {\n const apiError = err as APIError\n const rawError = apiError.rawError as {\n errorCode?: string\n message?: string\n }\n\n if (rawError?.errorCode) {\n throw new RelayQuoteClientError(\n apiError.statusCode,\n rawError.errorCode,\n rawError.message ?? apiError.message,\n )\n }\n }\n\n const message = getErrorMessage(err)\n throw new Error(\n `An error occurred trying to generate a relay quote: ${message}`,\n )\n }\n}\n\nfunction getErrorMessage(err: unknown): string {\n return err instanceof Error\n ? err.message\n : typeof err === 'string'\n ? err\n : JSON.stringify(err)\n}\n", "import type { AdaptedWallet } from '@relayprotocol/relay-sdk'\nimport { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'\nimport {\n type Connection,\n SendTransactionError,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\n\ntype Base58 =\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n\nexport type SolanaAddress = `${Base58}${string}`\n\nexport type SolanaTxHash = `${Base58}${string}`\n\nexport type SolanaWallet = {\n address(): Promise<SolanaAddress>\n vmType: 'svm'\n} & AdaptedWallet\n\nexport function getSolanaWallet(\n walletAddress: SolanaAddress,\n connection: Connection,\n signTransaction: (\n transaction: VersionedTransaction,\n ) => Promise<VersionedTransaction>,\n payerKey?: SolanaAddress,\n): SolanaWallet {\n return adaptSolanaWallet(\n walletAddress,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n connection,\n async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection),\n )\n }\n\n throw error\n }\n },\n payerKey,\n ) as SolanaWallet\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,0CAAmC;AA8C5B,SAAS,iBACd,eACA,UAKe;AACf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AClB,IAAI,UACJ,OAAO,QAAQ,WACb,MACA,KAAK,UAAU,GAAG;AAC1B;;;ACnYA,sCAAkC;AAClC,kBAIO;AAwEA,SAAS,gBACd,eACA,YACA,iBAGA,UACc;AACd,aAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,aAAa,YAAY;AAC9B,YAAM,SAAS,MAAM,gBAAgB,WAAW;AAChD,UAAI;AACF,cAAM,YAAY,MAAM,WAAW,gBAAgB,QAAQ;AAAA,UACzD,GAAG;AAAA,UACH,YAAY;AAAA,QACd,CAAC;AAED,eAAO,EAAE,UAAU;AAAA,MACrB,SAAS,OAAO;AACd,YAAI,iBAAiB,kCAAsB;AACzC,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA,MAAM,MAAM,QAAQ,UAAU;AAAA,UAChC;AAAA,QACF;AAEA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["import_relay_sdk", "import_relay_sdk", "import_relay_sdk", "import_relay_sdk", "import_relay_sdk"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -37,7 +37,7 @@ var RELAY_NATIVE_TOKEN = "0x0000000000000000000000000000000000000000";
|
|
|
37
37
|
var RELAY_NATIVE_TOKEN_HYPERCORE = "0x00000000000000000000000000000000";
|
|
38
38
|
var RELAY_NATIVE_TOKEN_SOLANA = "11111111111111111111111111111111";
|
|
39
39
|
var RELAY_NATIVE_TOKEN_BITCOIN = "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8";
|
|
40
|
-
var FUN_RELAY_REVENUE_WALLET = "
|
|
40
|
+
var FUN_RELAY_REVENUE_WALLET = "0xdfd877679e95c1276c85801805b2c2ab8f4f4cf6";
|
|
41
41
|
var FUN_RELAY_REFERRER = "funxyz";
|
|
42
42
|
var RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25e3;
|
|
43
43
|
var RELAY_TERMINAL_STATUSES = [
|
|
@@ -138,33 +138,6 @@ function jsonStringifyWithBigIntSanitization(serializable) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// src/execution.ts
|
|
141
|
-
function getFinalTxHash({
|
|
142
|
-
smartWalletAdapter,
|
|
143
|
-
steps,
|
|
144
|
-
fallbackTxHash,
|
|
145
|
-
logger,
|
|
146
|
-
logPrefix
|
|
147
|
-
}) {
|
|
148
|
-
if (!smartWalletAdapter) {
|
|
149
|
-
return fallbackTxHash;
|
|
150
|
-
}
|
|
151
|
-
logger.info(`${logPrefix}:extractingTxHashFromReceipt`, {
|
|
152
|
-
message: "Smart wallet adapter detected, extracting txHash from receipt"
|
|
153
|
-
});
|
|
154
|
-
const receipt = steps[0].items[0].receipt;
|
|
155
|
-
if (receipt && "transactionHash" in receipt) {
|
|
156
|
-
const finalTxHash = receipt.transactionHash;
|
|
157
|
-
logger.info(`${logPrefix}:extractedTxHashFromReceipt`, {
|
|
158
|
-
originalTxHash: fallbackTxHash,
|
|
159
|
-
finalTxHash
|
|
160
|
-
});
|
|
161
|
-
return finalTxHash;
|
|
162
|
-
}
|
|
163
|
-
logger.error(`${logPrefix}:missingReceiptOrTransactionHash`, {
|
|
164
|
-
message: "Smart wallet transaction missing receipt or transactionHash"
|
|
165
|
-
});
|
|
166
|
-
return fallbackTxHash;
|
|
167
|
-
}
|
|
168
141
|
async function executeRelayQuote({
|
|
169
142
|
logger,
|
|
170
143
|
onError,
|
|
@@ -172,8 +145,7 @@ async function executeRelayQuote({
|
|
|
172
145
|
onTransactionConfirmed,
|
|
173
146
|
onUserActionsCompleted,
|
|
174
147
|
relayQuote,
|
|
175
|
-
walletClient
|
|
176
|
-
smartWalletAdapter = false
|
|
148
|
+
walletClient
|
|
177
149
|
}) {
|
|
178
150
|
let isUserActionsCompleted = false;
|
|
179
151
|
let isTransactionConfirmed = false;
|
|
@@ -189,7 +161,6 @@ async function executeRelayQuote({
|
|
|
189
161
|
txHashes,
|
|
190
162
|
details,
|
|
191
163
|
error
|
|
192
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: remove before merging into main
|
|
193
164
|
}) => {
|
|
194
165
|
const logPrefix = "onRelayProgress";
|
|
195
166
|
logger.info(`${logPrefix}:params`, {
|
|
@@ -228,15 +199,8 @@ async function executeRelayQuote({
|
|
|
228
199
|
) {
|
|
229
200
|
logger.info(`${logPrefix}:onUserActionsCompleted`, txHashes);
|
|
230
201
|
isUserActionsCompleted = true;
|
|
231
|
-
const finalTxHash = getFinalTxHash({
|
|
232
|
-
smartWalletAdapter,
|
|
233
|
-
steps,
|
|
234
|
-
fallbackTxHash: txHash,
|
|
235
|
-
logger,
|
|
236
|
-
logPrefix
|
|
237
|
-
});
|
|
238
202
|
try {
|
|
239
|
-
await onUserActionsCompleted?.(
|
|
203
|
+
await onUserActionsCompleted?.(txHash);
|
|
240
204
|
} catch (e) {
|
|
241
205
|
logger.error(
|
|
242
206
|
`${logPrefix}:onUserActionsCompletedFailed`,
|
|
@@ -252,14 +216,7 @@ async function executeRelayQuote({
|
|
|
252
216
|
) {
|
|
253
217
|
logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes);
|
|
254
218
|
isTransactionConfirmed = true;
|
|
255
|
-
|
|
256
|
-
smartWalletAdapter,
|
|
257
|
-
steps,
|
|
258
|
-
fallbackTxHash: txHash,
|
|
259
|
-
logger,
|
|
260
|
-
logPrefix
|
|
261
|
-
});
|
|
262
|
-
if (!smartWalletAdapter) {
|
|
219
|
+
if (relayQuote.steps[0].requestId) {
|
|
263
220
|
manuallyRegisterIndex(logger, {
|
|
264
221
|
requestId: relayQuote.steps[0].requestId,
|
|
265
222
|
chainId: relayQuote.steps[0].items[0].data.chainId,
|
|
@@ -270,7 +227,7 @@ async function executeRelayQuote({
|
|
|
270
227
|
});
|
|
271
228
|
}
|
|
272
229
|
try {
|
|
273
|
-
await onTransactionConfirmed?.(
|
|
230
|
+
await onTransactionConfirmed?.(txHash);
|
|
274
231
|
} catch (e) {
|
|
275
232
|
logger.error(
|
|
276
233
|
`${logPrefix}:onTransactionConfirmedFailed`,
|
|
@@ -526,6 +483,13 @@ async function getRelayQuote({
|
|
|
526
483
|
return {
|
|
527
484
|
data,
|
|
528
485
|
to: action.contractAddress,
|
|
486
|
+
// Relay supports msg.value via 2 fields: `value` and `originalTxValue`
|
|
487
|
+
// Both `value` and `originalTxValue` are required to be set for `erc20` + gas transfers
|
|
488
|
+
// Only `value` is required for native token transfers. // TODO: This flow needs verification.
|
|
489
|
+
// Internally for Relay,
|
|
490
|
+
// - `originalTxValue` is designed to "bubble up" the value to the original tx
|
|
491
|
+
// - `value` is the internal multicall value
|
|
492
|
+
originalTxValue: String(action.value ?? 0n),
|
|
529
493
|
value: String(action.value ?? 0n)
|
|
530
494
|
};
|
|
531
495
|
});
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/bitcoin.ts", "../src/client.ts", "../src/types.ts", "../src/constants.ts", "../src/execution.ts", "../src/utils.ts", "../src/fees.ts", "../src/price.ts", "../src/currency.ts", "../src/quote.ts", "../src/solana.ts"],
|
|
4
|
-
"sourcesContent": ["import { adaptBitcoinWallet } from '@relayprotocol/relay-bitcoin-wallet-adapter'\nimport type { AdaptedWallet } from '@relayprotocol/relay-sdk'\n\ntype Base16 =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n\nexport type BitcoinAddress =\n | `1${string}`\n | `3${string}`\n | `bc1${string}`\n | `bc1p${string}`\n\nexport type BitcoinTxHash = `${Base16}${string}`\n\nexport type BitcoinWallet = {\n address(): Promise<BitcoinAddress>\n vmType: 'bvm'\n} & AdaptedWallet\n\n/** bitcoinjs-lib Psbt */\nexport type BitcoinPsbt = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[1]\n\nexport type BitcoinPsbtDynamicParams = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[2]\n\n/** bitcoinjs-lib Signer */\nexport type BitcoinSigner = Parameters<BitcoinPsbt['signAllInputs']>[0]\n\nexport function getBitcoinWallet(\n walletAddress: BitcoinAddress,\n signPsbt: (\n address: BitcoinAddress,\n psbt: BitcoinPsbt,\n dynamicParams: BitcoinPsbtDynamicParams,\n ) => Promise<string>,\n): BitcoinWallet {\n return adaptBitcoinWallet(walletAddress, (address, psbt, dynamicParams) =>\n signPsbt(address as BitcoinAddress, psbt, dynamicParams),\n ) as BitcoinWallet\n}\n\nexport function getBitcoinWalletFromSigner(\n walletAddress: BitcoinAddress,\n signer: BitcoinSigner,\n): BitcoinWallet {\n return getBitcoinWallet(walletAddress, async (_, psbt) =>\n psbt.signAllInputs(signer).toBase64(),\n )\n}\n", "import {\n LogLevel,\n MAINNET_RELAY_API,\n type RelayClient,\n type RelayClientOptions,\n convertViemChainToRelayChain,\n createClient,\n getClient,\n} from '@relayprotocol/relay-sdk'\nimport type { Chain } from 'viem'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\nimport type { Logger } from './types'\n\nexport type InitializeRelayClientParams = Omit<\n RelayClientOptions,\n 'baseApiUrl' | 'chains' | 'logger'\n> & {\n chains: Chain[]\n logger: Logger\n}\n\n/**\n * Initializes a global instance of the RelayClient\n * https://docs.relay.link/references/sdk/createClient\n */\nexport function initializeRelayClient({\n chains,\n logger,\n ...options\n}: InitializeRelayClientParams): RelayClient {\n return createClient({\n ...options,\n baseApiUrl: MAINNET_RELAY_API,\n chains: [\n ...chains.map(convertViemChainToRelayChain),\n {\n id: RELAY_SOLANA_CHAIN_ID_NUMBER,\n name: 'Solana',\n displayName: 'Solana',\n },\n ],\n logger: (message, level) => {\n if (level === LogLevel.Error) {\n logger.error('[RelayClient]:', message)\n } else {\n logger.info('[RelayClient]:', message)\n }\n },\n })\n}\n\n/**\n * Gets the global instance of the RelayClient\n */\nexport function getRelayClient(): RelayClient {\n const client = getClient()\n\n if (!client) {\n throw new Error('Relay client is not defined')\n }\n\n return client\n}\n", "import { LogLevel } from '@relayprotocol/relay-sdk'\nimport type { Abi, Address } from 'viem'\n\nexport { LogLevel }\n\n// https://docs.relay.link/references/api/get-intents-status-v2\nexport interface RelayExecutionInfo {\n status: RelayExecutionStatus\n details: string\n /** Incoming transaction hashes */\n inTxHashes: string[]\n /** Outgoing transaction hashes */\n txHashes: string[]\n /** The last timestamp the data was updated in milliseconds */\n time: number\n originChainId: number\n destinationChainId: number\n}\n\n// https://docs.relay.link/references/api/get-token-price\nexport interface RelayTokenPriceInfo {\n price: number\n}\n\n//// The types below are duplicated from @funkit/api-base atm, but this package should be used in BE as well\n//// TODO: Are we fine with BE importing @funkit/api-base and (by extension) @funkit/utils?\n//// See https://linear.app/funxyz/issue/PE-1342/sdk-extract-domainsrelayts-to-a-new-package#comment-d487d533\n\nexport interface Logger {\n error(message: string, data?: object): void\n info(message: string, data?: object): void\n}\n\n// Reference: https://github.com/reservoirprotocol/relay-kit/blob/211c645f9702a3b459ff545aa4e2e9d536c38455/packages/sdk/src/types/Execute.ts#L54-L61\nexport enum RelayExecutionStatus {\n DELAYED = 'delayed',\n FAILURE = 'failure',\n PENDING = 'pending',\n REFUND = 'refund',\n SUCCESS = 'success',\n WAITING = 'waiting',\n UNKNOWN = 'unknown',\n}\n\nexport interface ApiFunkitCheckoutActionParams {\n contractAbi: Abi\n contractAddress: Address\n functionName: string\n functionArgs: unknown[]\n value?: bigint\n}\n\nexport enum CheckoutRefundState {\n INITIATED = 'INITIATED',\n ERROR = 'ERROR',\n REFUNDED = 'REFUNDED',\n PROCEEDED = 'PROCEEDED',\n WAITING_FOR_FULFILLMENT = 'WAITING_FOR_FULFILLMENT',\n FULFILLED = 'FULFILLED',\n}\n\n// Reference from api server: https://github.com/fun-xyz/fun-api-server/blob/main/src/tables/FunWalletCheckout.ts#L11C1-L21C2\nexport enum CheckoutState {\n // In-progress States\n FROM_UNFUNDED = 'FROM_UNFUNDED',\n FROM_FUNDED = 'FROM_FUNDED',\n FROM_POOLED = 'FROM_POOLED',\n TO_UNFUNDED = 'TO_UNFUNDED',\n TO_FUNDED = 'TO_FUNDED',\n TO_POOLED = 'TO_POOLED',\n TO_READY = 'TO_READY',\n PENDING_RECEIVAL = 'PENDING_RECEIVAL',\n // Terminal States\n COMPLETED = 'COMPLETED',\n CHECKOUT_ERROR = 'CHECKOUT_ERROR',\n EXPIRED = 'EXPIRED',\n CANCELLED = 'CANCELLED',\n}\n\n// The response of the actual /checkout/quote api\nexport type CheckoutApiQuoteResponse = {\n quoteId: string\n estTotalFromAmountBaseUnit: string\n estSubtotalFromAmountBaseUnit: string\n estFeesFromAmountBaseUnit: string\n fromTokenAddress: Address\n estFeesUsd: number\n estSubtotalUsd: number\n estTotalUsd: number\n estCheckoutTimeMs: number\n estMarketMakerGasUsd: number\n lpFeePercentage: number\n lpFeeUsd: number\n}\n\n// The formatted response quote interface from the core sdk\nexport type CheckoutQuoteResponse = CheckoutApiQuoteResponse & {\n estTotalFromAmount: string\n estSubtotalFromAmount: string\n estFeesFromAmount: string\n\n // Any additional fields purely for frontend use\n metadata?: { [key: string]: unknown }\n}\n", "import type { Address } from 'viem'\nimport type { BitcoinAddress } from './bitcoin'\nimport type { SolanaAddress } from './solana'\nimport { RelayExecutionStatus } from './types'\n\n/**\n * Chain id that Relay uses to identify Bitcoin\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_BITCOIN_CHAIN_ID_NUMBER = 8253038 // Why cannot Relay export this themselves... -.-\nexport const RELAY_BITCOIN_CHAIN_ID = `${RELAY_BITCOIN_CHAIN_ID_NUMBER}`\n\n/**\n * Chain id that Relay uses to identify Solana\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_SOLANA_CHAIN_ID_NUMBER = 792703809 // Why cannot Relay export this themselves... -.-\nexport const RELAY_SOLANA_CHAIN_ID = `${RELAY_SOLANA_CHAIN_ID_NUMBER}`\n\nexport const FUN_SOLANA_CHAIN_ID_NUMBER = 1151111081099710\nexport const FUN_HYPERCORE_CHAIN_ID_NUMBER = 1337\n\n/**\n * Fake address for a chain's native currency used by Funkit\n */\nexport const FUNKIT_NATIVE_TOKEN =\n '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' satisfies Address\n\n/**\n * Fake address for a chain's native currency used by Relay\n */\nexport const RELAY_NATIVE_TOKEN =\n '0x0000000000000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for Hypercore's native currency used by Relay. This is shorter than the default native token...\n */\nexport const RELAY_NATIVE_TOKEN_HYPERCORE =\n '0x00000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_SOLANA =\n '11111111111111111111111111111111' satisfies SolanaAddress\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_BITCOIN =\n 'bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8' satisfies BitcoinAddress\n\n/**\n * Wallet that receives the app fees collected by Relay\n */\nexport const FUN_RELAY_REVENUE_WALLET =\n '0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E' satisfies Address\n\n/**\n * Referred field in Relay quote\n */\nexport const FUN_RELAY_REFERRER = 'funxyz'\n\n/**\n * Buffer added to Relay's time estimate (which sometimes is 0)\n */\nexport const RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25_000 // 25 seconds\n\nexport const RELAY_TERMINAL_STATUSES: RelayExecutionStatus[] = [\n RelayExecutionStatus.REFUND,\n RelayExecutionStatus.FAILURE,\n RelayExecutionStatus.SUCCESS,\n]\n\nexport const SUSHI_ORG_ID = 'fysix7gj5j'\nexport const HYPERSWAP_ORG_ID = '2ejzdxhfge'\nexport const HYPERBEAT_ORG_ID = 'opzh9rydei'\n", "import {\n type AdaptedWallet,\n MAINNET_RELAY_API,\n type ProgressData,\n} from '@relayprotocol/relay-sdk'\nimport type { Address, Hex, WalletClient } from 'viem'\nimport type { BitcoinAddress, BitcoinTxHash, BitcoinWallet } from './bitcoin'\nimport { getRelayClient } from './client'\nimport type { RELAY_BITCOIN_CHAIN_ID, RELAY_SOLANA_CHAIN_ID } from './constants'\nimport type { RelayQuoteResult } from './quote'\nimport type { SolanaAddress, SolanaTxHash, SolanaWallet } from './solana'\nimport type { Logger, RelayExecutionInfo } from './types'\nimport { jsonStringifyWithBigIntSanitization } from './utils'\n\nexport type RelayExecutionStep = ProgressData['currentStep'] & {}\n\nexport type RelayVmType = 'bvm' | 'evm' | 'svm'\n\nexport type RelayAddress<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinAddress\n evm: Address\n svm: SolanaAddress\n}[VmType]\n\nexport type RelayChainId<VmType extends RelayVmType = RelayVmType> = {\n bvm: typeof RELAY_BITCOIN_CHAIN_ID\n evm: string\n svm: typeof RELAY_SOLANA_CHAIN_ID\n}[VmType]\n\nexport type RelayTxHash<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinTxHash\n evm: Hex\n svm: SolanaTxHash\n}[VmType]\n\nexport type RelayWallet<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinWallet\n evm: WalletClient | (AdaptedWallet & { vmType: 'evm' })\n svm: SolanaWallet\n}[VmType]\n\nexport interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {\n logger: Logger\n onError: (error: Error) => Promise<void>\n onProgress?: (step: RelayExecutionStep | null) => void\n /**\n * Fired when all *input* transactions are confirmed on-chain.\n */\n onTransactionConfirmed?: (txHash: RelayTxHash<VmType>) => Promise<void>\n /**\n * Fired as soon as user has *signed* all input transactions, but before they are confirmed on-chain.\n *\n * After this event, no more action should be needed from the user.\n * However, it is possible that the transactions will be rejected and the execution will NOT continue.\n */\n onUserActionsCompleted?: (txHash: RelayTxHash<VmType>) => Promise<void>\n relayQuote: RelayQuoteResult<VmType>\n walletClient: RelayWallet<VmType>\n\n /**\n * Whether to use a smart wallet adapter.\n * Used for account abstraction transactions.\n */\n smartWalletAdapter?: boolean\n}\n\nfunction getFinalTxHash<VmType extends RelayVmType>({\n smartWalletAdapter,\n steps,\n fallbackTxHash,\n logger,\n logPrefix,\n}: {\n smartWalletAdapter: boolean\n steps: RelayQuoteResult<VmType>['steps']\n fallbackTxHash: RelayTxHash<VmType>\n logger: Logger\n logPrefix: string\n}): RelayTxHash<VmType> {\n if (!smartWalletAdapter) {\n return fallbackTxHash\n }\n\n logger.info(`${logPrefix}:extractingTxHashFromReceipt`, {\n message: 'Smart wallet adapter detected, extracting txHash from receipt',\n })\n\n const receipt = steps[0].items[0].receipt\n if (receipt && 'transactionHash' in receipt) {\n const finalTxHash = receipt.transactionHash as RelayTxHash<VmType>\n logger.info(`${logPrefix}:extractedTxHashFromReceipt`, {\n originalTxHash: fallbackTxHash,\n finalTxHash,\n })\n return finalTxHash\n }\n\n logger.error(`${logPrefix}:missingReceiptOrTransactionHash`, {\n message: 'Smart wallet transaction missing receipt or transactionHash',\n })\n return fallbackTxHash\n}\n\nexport async function executeRelayQuote<VmType extends RelayVmType>({\n logger,\n onError,\n onProgress,\n onTransactionConfirmed,\n onUserActionsCompleted,\n relayQuote,\n walletClient,\n smartWalletAdapter = false,\n}: ExecuteRelayQuoteParams<VmType>): Promise<void> {\n let isUserActionsCompleted = false\n let isTransactionConfirmed = false\n\n await getRelayClient().actions.execute({\n quote: relayQuote,\n wallet: walletClient,\n onProgress: async ({\n steps,\n fees,\n breakdown,\n currentStep,\n currentStepItem,\n txHashes,\n details,\n error,\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: remove before merging into main\n }) => {\n const logPrefix = 'onRelayProgress'\n logger.info(`${logPrefix}:params`, {\n steps,\n currentStep,\n fees,\n breakdown,\n currentStepItem,\n txHashes,\n details,\n error,\n })\n\n onProgress?.(currentStep ?? null)\n\n if (error) {\n logger.info(`${logPrefix}:errorDetected`, error)\n await onError(error).catch((e) => {\n logger.error(`${logPrefix}:onErrorFailed`, e)\n })\n } else if (txHashes?.length) {\n // Use first txHash as the main txHash in fun DE table\n // Bad surprise from Relay: txHash may be an object, this is not present in their typing...\n const rawTxHashWithUnreliableTyping = txHashes[0].txHash as\n | RelayTxHash<VmType>\n | { id: RelayTxHash<VmType> }\n\n const txHash =\n typeof rawTxHashWithUnreliableTyping === 'object'\n ? rawTxHashWithUnreliableTyping.id\n : rawTxHashWithUnreliableTyping\n\n if (\n // Call onUserActionsCompleted only once\n !isUserActionsCompleted &&\n steps.every((step) =>\n step.items.every(\n // 'completed' - catch-all for items marked completed with no other info\n // - e.g. Batched items will not have txHash but will have their item marked 'complete'\n // 'pending' - for origin chain transactions that have been included on chain\n // - may sometimes be skipped, hence the need for 'submitted' condition below\n // 'submitted' - for destination chain transactions that have been submitted to the network\n // receipt - is present when the transaction has been mined/confirmed\n // Ensure onUserActionsCompleted is always called before onTransactionConfirmed\n (item) =>\n item.status === 'complete' ||\n item.checkStatus === 'pending' ||\n item.checkStatus === 'submitted' ||\n item.receipt !== undefined,\n ),\n )\n ) {\n logger.info(`${logPrefix}:onUserActionsCompleted`, txHashes)\n isUserActionsCompleted = true\n // Get the actual txHash from the receipt if using a smart wallet\n const finalTxHash = getFinalTxHash({\n smartWalletAdapter,\n steps,\n fallbackTxHash: txHash,\n logger,\n logPrefix,\n })\n\n try {\n await onUserActionsCompleted?.(finalTxHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onUserActionsCompletedFailed`,\n e as Error,\n )\n }\n }\n\n if (\n // Call onTransactionConfirmed only once\n !isTransactionConfirmed &&\n steps.every((step) =>\n step.items.every((item) => item.status === 'complete'),\n )\n ) {\n logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes)\n isTransactionConfirmed = true\n // Get the actual txHash from the receipt if using a smart wallet\n const finalTxHash = getFinalTxHash({\n smartWalletAdapter,\n steps,\n fallbackTxHash: txHash,\n logger,\n logPrefix,\n })\n\n // fire and forget index registration - skip for smart wallet adapters\n if (!smartWalletAdapter) {\n manuallyRegisterIndex(logger, {\n requestId: relayQuote.steps[0].requestId as string,\n chainId: relayQuote.steps[0].items[0].data.chainId,\n tx: jsonStringifyWithBigIntSanitization({\n ...relayQuote.steps[0].items[0].data,\n txHash: txHash,\n }),\n })\n }\n\n try {\n await onTransactionConfirmed?.(finalTxHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onTransactionConfirmedFailed`,\n e as Error,\n )\n }\n }\n }\n },\n })\n}\n\nexport interface PostRegistrationRequest {\n requestId: string\n chainId: string\n tx: string\n}\n\nexport type RegisterIndexingResponse =\n | { success: never; message: 'Success' }\n | { success: false; message: string }\n\nexport async function manuallyRegisterIndex(\n logger: Logger,\n registerRequest: PostRegistrationRequest,\n): Promise<void> {\n const logPrefix = 'manuallyRegisterIndex'\n const stringifiedRequest = JSON.stringify(registerRequest)\n const url = `${MAINNET_RELAY_API}/transactions/single`\n try {\n logger.info(`${logPrefix}:onManuallyRegisterIndex`, {\n params: stringifiedRequest,\n })\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(registerRequest),\n })\n if (!response.ok) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: 'Error !response.ok - request to manually register index',\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n return\n }\n\n const data = (await response.json()) as RegisterIndexingResponse\n if (data.message !== 'Success') {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Data.message is not of type Success - ${data.message}`,\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n }\n return\n } catch (err) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Error sending request to register index at ${url}: ${JSON.stringify((err as Error)?.message)}`,\n params: stringifiedRequest,\n })\n }\n}\n\nexport async function getRelayExecutionInfo(\n requestId: string,\n): Promise<RelayExecutionInfo> {\n const url = `${MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayExecutionInfo\n}\n", "import {\n FUNKIT_NATIVE_TOKEN,\n FUN_HYPERCORE_CHAIN_ID_NUMBER,\n FUN_SOLANA_CHAIN_ID_NUMBER,\n RELAY_BITCOIN_CHAIN_ID_NUMBER,\n RELAY_NATIVE_TOKEN,\n RELAY_NATIVE_TOKEN_BITCOIN,\n RELAY_NATIVE_TOKEN_HYPERCORE,\n RELAY_NATIVE_TOKEN_SOLANA,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './constants'\nimport type { RelayAddress, RelayVmType } from './execution'\nimport {\n CheckoutRefundState,\n CheckoutState,\n type RelayExecutionInfo,\n RelayExecutionStatus,\n} from './types'\n\n/**\n * Converts a token address within Funkit to the corresponding Relay token address.\n */\nexport function convertFunToRelayTokenAddress<T extends RelayVmType>(\n address: RelayAddress<T>,\n chainId: number,\n): RelayAddress<T> {\n // convert Fun's NATIVE_TOKEN representation\n if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {\n switch (chainId) {\n case FUN_HYPERCORE_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_HYPERCORE as RelayAddress<T>\n\n case RELAY_BITCOIN_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_BITCOIN as RelayAddress<T>\n\n case RELAY_SOLANA_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_SOLANA as RelayAddress<T>\n\n default:\n return RELAY_NATIVE_TOKEN as RelayAddress<T>\n }\n }\n\n return address\n}\n\n/**\n * Converts a chainId within Funkit to the corresponding Relay chainId.\n */\nexport function convertFunToRelayChainId(chainId: number): number {\n if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {\n return RELAY_SOLANA_CHAIN_ID_NUMBER\n }\n return chainId\n}\n\nexport function getRelayExecutionRefundState(\n info: RelayExecutionInfo,\n): CheckoutRefundState | undefined {\n switch (info.status) {\n case RelayExecutionStatus.REFUND:\n return CheckoutRefundState.REFUNDED\n default:\n return undefined\n }\n}\n\nexport function getRelayExecutionState(\n info: RelayExecutionInfo,\n): CheckoutState {\n switch (info.status) {\n case RelayExecutionStatus.SUCCESS:\n return CheckoutState.COMPLETED\n case RelayExecutionStatus.FAILURE:\n case RelayExecutionStatus.REFUND:\n return CheckoutState.CHECKOUT_ERROR\n default:\n return CheckoutState.PENDING_RECEIVAL\n }\n}\n\n/**\n * Checks whether the Relay execution has reached a terminal status.\n */\nexport function isRelayExecutionTerminalStatus(\n info: RelayExecutionInfo,\n): boolean {\n return RELAY_TERMINAL_STATUSES.includes(info.status)\n}\n\nexport type Serializable =\n | bigint\n | boolean\n | null\n | number\n | string\n | Date\n | object // Should be '{ [key: string]: Serializable }' but helper gets called with loosely-typed 'object' and interfaces\n | Serializable[]\n\nexport function jsonStringifyWithBigIntSanitization(\n serializable: Serializable,\n): string {\n return JSON.stringify(\n serializable,\n (_, value) =>\n typeof value === 'bigint' ? `0x${value.toString(16)}` : value, // return everything else unchanged\n )\n}\n", "import type { CallFees } from '@relayprotocol/relay-sdk'\nimport type { Logger } from './types'\n\nexport interface FunRelayFeeItem {\n b: number\n v: number\n config: {\n options: Record<string, unknown>\n }\n headers: Record<string, string>\n}\n\nexport async function getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue,\n clientId,\n recipientAddress,\n}: {\n fromTokenAddress: string\n fromChainId: string\n toTokenAddress: string\n toChainId: string\n estUsdValue: number\n clientId: string\n recipientAddress: string | undefined\n}): Promise<FunRelayFeeItem> {\n const params = new URLSearchParams({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: estUsdValue.toString(),\n clientId,\n ...(recipientAddress ? { recipientAddress } : {}),\n })\n const url = `https://frog.fun.xyz/api/fee?${params.toString()}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data\n}\n\nexport function parseRelayFees({\n fees,\n logger,\n}: {\n fees: CallFees | undefined\n logger: Logger\n}) {\n // Gas fees, denominated in source chain native token\n const relayGasFeesUsd = Number.parseFloat(fees?.gas?.amountUsd || '0')\n\n // App fees, denominated in source chain token\n const funLpFeesUsd = Number.parseFloat(fees?.app?.amountUsd || '0')\n const funLpFeesFromAmount = Number.parseFloat(\n fees?.app?.amountFormatted || '0',\n )\n const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || '0')\n\n // Relay fees, denominated in source chain token\n const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || '0')\n const relayLpFeesFromAmount = Number.parseFloat(\n fees?.relayer?.amountFormatted || '0',\n )\n const relayLpFeesFromAmountBaseUnit = BigInt(fees?.relayer?.amount || '0')\n\n const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd\n const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount\n const totalLpFeesFromAmountBaseUnit =\n funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit\n\n logger.info('parseRelayFees', {\n relayGasFeesUsd,\n funLpFeesUsd,\n funLpFeesFromAmount,\n funLpFeesFromAmountBaseUnit,\n relayLpFeesUsd,\n relayLpFeesFromAmount,\n relayLpFeesFromAmountBaseUnit,\n totalLpFeesUsd,\n totalLpFeesFromAmount,\n totalLpFeesFromAmountBaseUnit,\n })\n\n return {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd: relayGasFeesUsd + totalLpFeesUsd,\n totalFeesFromAmount: totalLpFeesFromAmount,\n totalFeesFromAmountBaseUnit: totalLpFeesFromAmountBaseUnit,\n }\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport type { RelayTokenPriceInfo } from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport async function getRelayAssetPriceInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenPriceInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/token/price?chainId=${relayChainId}&address=${relayTokenAddress}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayTokenPriceInfo\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport interface RelayTokenInfo {\n chainId: number\n address: string\n symbol: string\n name: string\n decimals: number\n vmType: string\n metadata: {\n logoURI: string\n verified: boolean\n isNative: boolean\n }\n}\n\nexport async function getRelayAssetInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/v2`\n const body = {\n chainIds: [relayChainId],\n address: relayTokenAddress,\n }\n const response = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data?.[0] as RelayTokenInfo\n}\n", "import {\n type APIError,\n type Execute,\n type GetQuoteParameters,\n isAPIError,\n} from '@relayprotocol/relay-sdk'\nimport { type Address, encodeFunctionData } from 'viem'\nimport { getRelayClient } from './client'\nimport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n} from './constants'\nimport { getRelayAssetInfo } from './currency'\nimport type {\n RelayAddress,\n RelayChainId,\n RelayVmType,\n RelayWallet,\n} from './execution'\nimport { getFunRelayFees, parseRelayFees } from './fees'\nimport { getRelayAssetPriceInfo } from './price'\nimport type { SolanaAddress } from './solana'\nimport type {\n ApiFunkitCheckoutActionParams,\n CheckoutQuoteResponse,\n Logger,\n} from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\ntype RelayQuoteOptions = GetQuoteParameters['options'] & {\n // TODO: Relay does not yet explicitly handle this field in their SDK, nor is it in their typings - but it gets forwarded to API\n depositFeePayer?: SolanaAddress\n}\n\nexport type RelayQuoteResult<VmType extends RelayVmType> = {\n details?: {\n currencyIn?: NonNullable<Execute['details']>['currencyIn']\n currencyOut?: NonNullable<Execute['details']>['currencyOut']\n }\n steps: Execute['steps']\n vmType: VmType\n}\n\nexport type GetRelayQuoteParams<\n SourceVmType extends RelayVmType = RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n> = {\n actionParams?: ApiFunkitCheckoutActionParams[]\n clientId: string\n fromChainId: RelayChainId<SourceVmType>\n fromTokenAddress: RelayAddress<SourceVmType>\n logger: Logger\n /**\n * {@link getRelayQuote} already sets {@link RelayQuoteOptions.appFees|appFees} and {@link RelayQuoteOptions.referrer|referrer}.\n * Only include them if you wish to override.\n */\n options?: RelayQuoteOptions\n recipientAddress: RelayAddress<TargetVmType> | undefined\n toChainId: RelayChainId<TargetVmType>\n toTokenAddress: RelayAddress<TargetVmType>\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n userAddress: RelayAddress<SourceVmType> | undefined\n walletClient?: RelayWallet<SourceVmType>\n} & (\n | {\n fromTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_INPUT'\n }\n | {\n toTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n }\n)\n\nexport type RelayQuote<VmType extends RelayVmType = RelayVmType> =\n CheckoutQuoteResponse & {\n /** Required for EXACT_INPUT checkouts */\n finalToAmountBaseUnit: string\n metadata: {\n fromAmountBaseUnit: string\n relayQuote: RelayQuoteResult<VmType>\n toAmountBaseUnit: string\n }\n }\n\nasync function getQuoteEstUsdValue({\n tokenChainId,\n tokenAddress,\n tokenAmountBaseUnit,\n logger,\n}: {\n tokenChainId: string\n tokenAddress: string\n tokenAmountBaseUnit: string\n logger: Logger\n}) {\n try {\n const normalizedChainId = convertFunToRelayChainId(\n Number(tokenChainId),\n ).toString()\n const normalizedTokenAddress = convertFunToRelayTokenAddress(\n tokenAddress as Address,\n Number(tokenChainId),\n )\n\n const [tokenPriceRes, tokenInfoRes] = await Promise.all([\n getRelayAssetPriceInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n getRelayAssetInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n ])\n\n // FIXME: Temp hardcode until relay supports WUSDE on Ethereal\n const isWUsdeEthereal =\n normalizedChainId === '5064014' &&\n normalizedTokenAddress.toLowerCase() ===\n '0xB6fC4B1BFF391e5F6b4a3D2C7Bda1FeE3524692D'.toLowerCase()\n\n const price = tokenPriceRes.price\n const decimals = isWUsdeEthereal ? 18 : tokenInfoRes.decimals\n\n const absoluteAmount = BigInt(tokenAmountBaseUnit) / BigInt(10 ** decimals)\n return Number(price) * Number(absoluteAmount)\n } catch (err) {\n logger.error('getQuoteEstUsdValueError', {\n message: `Failed to get USD value for token ${tokenAddress} on chain ${tokenChainId}: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }. Falling back to 0 USD.`,\n })\n // If any part fails, just fallback to 0 USD so that we do not block quote\n return 0\n }\n}\n\nexport function getReferrer(clientId: string) {\n return clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER\n}\n\nexport class RelayQuoteClientError extends Error {\n public constructor(\n public readonly statusCode: number,\n public readonly relayErrorCode: string,\n message: string,\n ) {\n super(\n `An error occurred trying to generate a relay quote: ${relayErrorCode} - ${message}`,\n )\n\n this.name = new.target.name\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport async function getRelayQuote<\n SourceVmType extends RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n>({\n logger,\n walletClient,\n ...params\n}: GetRelayQuoteParams<SourceVmType, TargetVmType>): Promise<\n RelayQuote<SourceVmType>\n> {\n const {\n actionParams,\n clientId,\n fromChainId,\n fromTokenAddress,\n options,\n recipientAddress,\n toChainId,\n toTokenAddress,\n tradeType,\n userAddress,\n } = params\n\n const vmType = (\n walletClient && 'vmType' in walletClient ? walletClient.vmType : 'evm'\n ) as SourceVmType\n\n try {\n const relayClient = getRelayClient()\n\n const txs = actionParams?.map((action) => {\n const data = encodeFunctionData({\n abi: action.contractAbi,\n args: action.functionArgs,\n functionName: action.functionName,\n })\n\n return {\n data,\n to: action.contractAddress,\n value: String(action.value ?? 0n),\n }\n })\n\n const isExactIn = params.tradeType === 'EXACT_INPUT'\n const queryTokenAmountBaseUnit = isExactIn\n ? params.fromTokenAmountBaseUnit\n : params.toTokenAmountBaseUnit\n const queryTokenAddress = isExactIn ? fromTokenAddress : toTokenAddress\n const queryTokenChainId = isExactIn ? fromChainId : toChainId\n\n const estUsdValue = await getQuoteEstUsdValue({\n tokenChainId: queryTokenChainId,\n tokenAddress: queryTokenAddress,\n tokenAmountBaseUnit: queryTokenAmountBaseUnit.toString(),\n logger,\n })\n\n const funRelayConfig = await getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: Number(estUsdValue) || 0,\n clientId,\n recipientAddress,\n })\n\n const appFeeBp = funRelayConfig.b + funRelayConfig.v\n\n logger.info('getRelayQuoteParams', {\n ...params,\n appFeeBp,\n estUsdValue,\n funRelayConfig,\n queryTokenAmountBaseUnit,\n txs,\n })\n\n // Get the full quote with fees\n const relayQuote = await relayClient.actions.getQuote(\n {\n amount: queryTokenAmountBaseUnit.toString(),\n chainId: convertFunToRelayChainId(Number(fromChainId)),\n currency: convertFunToRelayTokenAddress(\n fromTokenAddress,\n Number(fromChainId),\n ),\n recipient: recipientAddress,\n toChainId: convertFunToRelayChainId(Number(toChainId)),\n toCurrency: convertFunToRelayTokenAddress(\n toTokenAddress,\n Number(toChainId),\n ),\n tradeType,\n txs,\n user: userAddress,\n wallet: walletClient,\n options: {\n referrer: getReferrer(clientId),\n appFees: [\n {\n fee: appFeeBp.toString(),\n recipient: FUN_RELAY_REVENUE_WALLET,\n },\n ],\n // Passed in options\n ...options,\n // Remote options will always override passed in options\n ...funRelayConfig.config.options,\n },\n },\n undefined,\n funRelayConfig.headers,\n )\n\n logger.info('relayQuote', relayQuote)\n\n const estSubtotalUsd = Number(\n relayQuote.details?.currencyOut?.amountUsd || 0,\n )\n const estTotalUsd = Number(relayQuote.details?.currencyIn?.amountUsd || 0)\n // Get how much fromAmount is needed for the quote\n const fromAmountString =\n relayQuote.details?.currencyIn?.amountFormatted || '0'\n const fromAmountBaseUnitString =\n relayQuote.details?.currencyIn?.amount || '0'\n\n // RequestID will be consistent across steps in the quote\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1747774944603209\n const relayRequestId = relayQuote.steps[0]?.requestId\n\n // TODO: Verify with relay team if this is possible?\n if (!relayRequestId) {\n throw new Error('Relay quote does not contain a requestId')\n }\n\n // TODO: Verify with relay team if this is possible?\n if (!relayQuote.details?.currencyIn || !relayQuote.details?.currencyOut) {\n throw new Error('Relay quote does not contain trade details')\n }\n\n const {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd,\n totalFeesFromAmount,\n totalFeesFromAmountBaseUnit,\n } = parseRelayFees({ fees: relayQuote.fees, logger })\n\n const estSubtotalFromAmount = (\n Number.parseFloat(fromAmountString) - totalFeesFromAmount\n ).toString()\n\n const estSubtotalFromAmountBaseUnit = (\n BigInt(fromAmountBaseUnitString) - totalFeesFromAmountBaseUnit\n ).toString()\n\n return {\n quoteId: relayRequestId,\n estCheckoutTimeMs:\n (relayQuote.details.timeEstimate || 0) * 1000 +\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n estFeesFromAmount: totalFeesFromAmount.toString(),\n estFeesFromAmountBaseUnit: totalFeesFromAmountBaseUnit.toString(),\n estFeesUsd: totalFeesUsd,\n estMarketMakerGasUsd: relayGasFeesUsd,\n estSubtotalFromAmount,\n estSubtotalFromAmountBaseUnit,\n estSubtotalUsd,\n estTotalFromAmount: fromAmountString,\n estTotalFromAmountBaseUnit: fromAmountBaseUnitString,\n estTotalUsd,\n finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? '0', // TODO: Or do we want 'minimumAmount'?\n fromTokenAddress: fromTokenAddress as Address, // TODO: fromTokenAddress is typed as `0x${string}` why does not accept SolanaAddress\n lpFeePercentage: 0, // TODO: ?\n lpFeeUsd: totalLpFeesUsd,\n metadata: {\n fromAmountBaseUnit: isExactIn\n ? queryTokenAmountBaseUnit.toString()\n : (relayQuote.details.currencyIn.amount ?? '0'),\n relayQuote: {\n ...relayQuote,\n vmType,\n },\n toAmountBaseUnit: isExactIn\n ? (relayQuote.details.currencyOut.amount ?? '0')\n : queryTokenAmountBaseUnit.toString(),\n },\n }\n } catch (err) {\n if (err instanceof Error && isAPIError(err)) {\n const apiError = err as APIError\n const rawError = apiError.rawError as {\n errorCode?: string\n message?: string\n }\n\n if (rawError?.errorCode) {\n throw new RelayQuoteClientError(\n apiError.statusCode,\n rawError.errorCode,\n rawError.message ?? apiError.message,\n )\n }\n }\n\n const message = getErrorMessage(err)\n throw new Error(\n `An error occurred trying to generate a relay quote: ${message}`,\n )\n }\n}\n\nfunction getErrorMessage(err: unknown): string {\n return err instanceof Error\n ? err.message\n : typeof err === 'string'\n ? err\n : JSON.stringify(err)\n}\n", "import type { AdaptedWallet } from '@relayprotocol/relay-sdk'\nimport { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'\nimport {\n type Connection,\n SendTransactionError,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\n\ntype Base58 =\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n\nexport type SolanaAddress = `${Base58}${string}`\n\nexport type SolanaTxHash = `${Base58}${string}`\n\nexport type SolanaWallet = {\n address(): Promise<SolanaAddress>\n vmType: 'svm'\n} & AdaptedWallet\n\nexport function getSolanaWallet(\n walletAddress: SolanaAddress,\n connection: Connection,\n signTransaction: (\n transaction: VersionedTransaction,\n ) => Promise<VersionedTransaction>,\n payerKey?: SolanaAddress,\n): SolanaWallet {\n return adaptSolanaWallet(\n walletAddress,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n connection,\n async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection),\n )\n }\n\n throw error\n }\n },\n payerKey,\n ) as SolanaWallet\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,0BAA0B;AA8C5B,SAAS,iBACd,eACA,UAKe;AACf,SAAO;AAAA,IAAmB;AAAA,IAAe,CAAC,SAAS,MAAM,kBACvD,SAAS,SAA2B,MAAM,aAAa;AAAA,EACzD;AACF;AAEO,SAA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;AAAA,MACR;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import { adaptBitcoinWallet } from '@relayprotocol/relay-bitcoin-wallet-adapter'\nimport type { AdaptedWallet } from '@relayprotocol/relay-sdk'\n\ntype Base16 =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n\nexport type BitcoinAddress =\n | `1${string}`\n | `3${string}`\n | `bc1${string}`\n | `bc1p${string}`\n\nexport type BitcoinTxHash = `${Base16}${string}`\n\nexport type BitcoinWallet = {\n address(): Promise<BitcoinAddress>\n vmType: 'bvm'\n} & AdaptedWallet\n\n/** bitcoinjs-lib Psbt */\nexport type BitcoinPsbt = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[1]\n\nexport type BitcoinPsbtDynamicParams = Parameters<\n Parameters<typeof adaptBitcoinWallet>[1]\n>[2]\n\n/** bitcoinjs-lib Signer */\nexport type BitcoinSigner = Parameters<BitcoinPsbt['signAllInputs']>[0]\n\nexport function getBitcoinWallet(\n walletAddress: BitcoinAddress,\n signPsbt: (\n address: BitcoinAddress,\n psbt: BitcoinPsbt,\n dynamicParams: BitcoinPsbtDynamicParams,\n ) => Promise<string>,\n): BitcoinWallet {\n return adaptBitcoinWallet(walletAddress, (address, psbt, dynamicParams) =>\n signPsbt(address as BitcoinAddress, psbt, dynamicParams),\n ) as BitcoinWallet\n}\n\nexport function getBitcoinWalletFromSigner(\n walletAddress: BitcoinAddress,\n signer: BitcoinSigner,\n): BitcoinWallet {\n return getBitcoinWallet(walletAddress, async (_, psbt) =>\n psbt.signAllInputs(signer).toBase64(),\n )\n}\n", "import {\n LogLevel,\n MAINNET_RELAY_API,\n type RelayClient,\n type RelayClientOptions,\n convertViemChainToRelayChain,\n createClient,\n getClient,\n} from '@relayprotocol/relay-sdk'\nimport type { Chain } from 'viem'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\nimport type { Logger } from './types'\n\nexport type InitializeRelayClientParams = Omit<\n RelayClientOptions,\n 'baseApiUrl' | 'chains' | 'logger'\n> & {\n chains: Chain[]\n logger: Logger\n}\n\n/**\n * Initializes a global instance of the RelayClient\n * https://docs.relay.link/references/sdk/createClient\n */\nexport function initializeRelayClient({\n chains,\n logger,\n ...options\n}: InitializeRelayClientParams): RelayClient {\n return createClient({\n ...options,\n baseApiUrl: MAINNET_RELAY_API,\n chains: [\n ...chains.map(convertViemChainToRelayChain),\n {\n id: RELAY_SOLANA_CHAIN_ID_NUMBER,\n name: 'Solana',\n displayName: 'Solana',\n },\n ],\n logger: (message, level) => {\n if (level === LogLevel.Error) {\n logger.error('[RelayClient]:', message)\n } else {\n logger.info('[RelayClient]:', message)\n }\n },\n })\n}\n\n/**\n * Gets the global instance of the RelayClient\n */\nexport function getRelayClient(): RelayClient {\n const client = getClient()\n\n if (!client) {\n throw new Error('Relay client is not defined')\n }\n\n return client\n}\n", "import { LogLevel } from '@relayprotocol/relay-sdk'\nimport type { Abi, Address } from 'viem'\n\nexport { LogLevel }\n\n// https://docs.relay.link/references/api/get-intents-status-v2\nexport interface RelayExecutionInfo {\n status: RelayExecutionStatus\n details: string\n /** Incoming transaction hashes */\n inTxHashes: string[]\n /** Outgoing transaction hashes */\n txHashes: string[]\n /** The last timestamp the data was updated in milliseconds */\n time: number\n originChainId: number\n destinationChainId: number\n}\n\n// https://docs.relay.link/references/api/get-token-price\nexport interface RelayTokenPriceInfo {\n price: number\n}\n\n//// The types below are duplicated from @funkit/api-base atm, but this package should be used in BE as well\n//// TODO: Are we fine with BE importing @funkit/api-base and (by extension) @funkit/utils?\n//// See https://linear.app/funxyz/issue/PE-1342/sdk-extract-domainsrelayts-to-a-new-package#comment-d487d533\n\nexport interface Logger {\n error(message: string, data?: object): void\n info(message: string, data?: object): void\n}\n\n// Reference: https://github.com/reservoirprotocol/relay-kit/blob/211c645f9702a3b459ff545aa4e2e9d536c38455/packages/sdk/src/types/Execute.ts#L54-L61\nexport enum RelayExecutionStatus {\n DELAYED = 'delayed',\n FAILURE = 'failure',\n PENDING = 'pending',\n REFUND = 'refund',\n SUCCESS = 'success',\n WAITING = 'waiting',\n UNKNOWN = 'unknown',\n}\n\nexport interface ApiFunkitCheckoutActionParams {\n contractAbi: Abi\n contractAddress: Address\n functionName: string\n functionArgs: unknown[]\n value?: bigint\n}\n\nexport enum CheckoutRefundState {\n INITIATED = 'INITIATED',\n ERROR = 'ERROR',\n REFUNDED = 'REFUNDED',\n PROCEEDED = 'PROCEEDED',\n WAITING_FOR_FULFILLMENT = 'WAITING_FOR_FULFILLMENT',\n FULFILLED = 'FULFILLED',\n}\n\n// Reference from api server: https://github.com/fun-xyz/fun-api-server/blob/main/src/tables/FunWalletCheckout.ts#L11C1-L21C2\nexport enum CheckoutState {\n // In-progress States\n FROM_UNFUNDED = 'FROM_UNFUNDED',\n FROM_FUNDED = 'FROM_FUNDED',\n FROM_POOLED = 'FROM_POOLED',\n TO_UNFUNDED = 'TO_UNFUNDED',\n TO_FUNDED = 'TO_FUNDED',\n TO_POOLED = 'TO_POOLED',\n TO_READY = 'TO_READY',\n PENDING_RECEIVAL = 'PENDING_RECEIVAL',\n // Terminal States\n COMPLETED = 'COMPLETED',\n CHECKOUT_ERROR = 'CHECKOUT_ERROR',\n EXPIRED = 'EXPIRED',\n CANCELLED = 'CANCELLED',\n}\n\n// The response of the actual /checkout/quote api\nexport type CheckoutApiQuoteResponse = {\n quoteId: string\n estTotalFromAmountBaseUnit: string\n estSubtotalFromAmountBaseUnit: string\n estFeesFromAmountBaseUnit: string\n fromTokenAddress: Address\n estFeesUsd: number\n estSubtotalUsd: number\n estTotalUsd: number\n estCheckoutTimeMs: number\n estMarketMakerGasUsd: number\n lpFeePercentage: number\n lpFeeUsd: number\n}\n\n// The formatted response quote interface from the core sdk\nexport type CheckoutQuoteResponse = CheckoutApiQuoteResponse & {\n estTotalFromAmount: string\n estSubtotalFromAmount: string\n estFeesFromAmount: string\n\n // Any additional fields purely for frontend use\n metadata?: { [key: string]: unknown }\n}\n", "import type { Address } from 'viem'\nimport type { BitcoinAddress } from './bitcoin'\nimport type { SolanaAddress } from './solana'\nimport { RelayExecutionStatus } from './types'\n\n/**\n * Chain id that Relay uses to identify Bitcoin\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_BITCOIN_CHAIN_ID_NUMBER = 8253038 // Why cannot Relay export this themselves... -.-\nexport const RELAY_BITCOIN_CHAIN_ID = `${RELAY_BITCOIN_CHAIN_ID_NUMBER}`\n\n/**\n * Chain id that Relay uses to identify Solana\n *\n * See https://docs.relay.link/references/sdk/adapters#how-can-i-use-an-adapter%3F\n */\nexport const RELAY_SOLANA_CHAIN_ID_NUMBER = 792703809 // Why cannot Relay export this themselves... -.-\nexport const RELAY_SOLANA_CHAIN_ID = `${RELAY_SOLANA_CHAIN_ID_NUMBER}`\n\nexport const FUN_SOLANA_CHAIN_ID_NUMBER = 1151111081099710\nexport const FUN_HYPERCORE_CHAIN_ID_NUMBER = 1337\n\n/**\n * Fake address for a chain's native currency used by Funkit\n */\nexport const FUNKIT_NATIVE_TOKEN =\n '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' satisfies Address\n\n/**\n * Fake address for a chain's native currency used by Relay\n */\nexport const RELAY_NATIVE_TOKEN =\n '0x0000000000000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for Hypercore's native currency used by Relay. This is shorter than the default native token...\n */\nexport const RELAY_NATIVE_TOKEN_HYPERCORE =\n '0x00000000000000000000000000000000' satisfies Address\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_SOLANA =\n '11111111111111111111111111111111' satisfies SolanaAddress\n\n/**\n * Fake address for native Bitcoin used by Relay\n */\nexport const RELAY_NATIVE_TOKEN_BITCOIN =\n 'bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8' satisfies BitcoinAddress\n\n/**\n * Wallet that receives the app fees collected by Relay\n * Prev: 0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E\n */\nexport const FUN_RELAY_REVENUE_WALLET =\n '0xdfd877679e95c1276c85801805b2c2ab8f4f4cf6' satisfies Address\n\n/**\n * Referred field in Relay quote\n */\nexport const FUN_RELAY_REFERRER = 'funxyz'\n\n/**\n * Buffer added to Relay's time estimate (which sometimes is 0)\n */\nexport const RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25_000 // 25 seconds\n\nexport const RELAY_TERMINAL_STATUSES: RelayExecutionStatus[] = [\n RelayExecutionStatus.REFUND,\n RelayExecutionStatus.FAILURE,\n RelayExecutionStatus.SUCCESS,\n]\n\nexport const SUSHI_ORG_ID = 'fysix7gj5j'\nexport const HYPERSWAP_ORG_ID = '2ejzdxhfge'\nexport const HYPERBEAT_ORG_ID = 'opzh9rydei'\n", "import {\n type AdaptedWallet,\n MAINNET_RELAY_API,\n type ProgressData,\n} from '@relayprotocol/relay-sdk'\nimport type { Address, Hex, WalletClient } from 'viem'\nimport type { BitcoinAddress, BitcoinTxHash, BitcoinWallet } from './bitcoin'\nimport { getRelayClient } from './client'\nimport type { RELAY_BITCOIN_CHAIN_ID, RELAY_SOLANA_CHAIN_ID } from './constants'\nimport type { RelayQuoteResult } from './quote'\nimport type { SolanaAddress, SolanaTxHash, SolanaWallet } from './solana'\nimport type { Logger, RelayExecutionInfo } from './types'\nimport { jsonStringifyWithBigIntSanitization } from './utils'\n\nexport type RelayExecutionStep = ProgressData['currentStep'] & {}\n\nexport type RelayVmType = 'bvm' | 'evm' | 'hypevm' | 'svm'\n\nexport type RelayAddress<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinAddress\n evm: Address\n hypevm: Address\n svm: SolanaAddress\n}[VmType]\n\nexport type RelayChainId<VmType extends RelayVmType = RelayVmType> = {\n bvm: typeof RELAY_BITCOIN_CHAIN_ID\n evm: string\n hypevm: string\n svm: typeof RELAY_SOLANA_CHAIN_ID\n}[VmType]\n\nexport type RelayTxHash<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinTxHash\n evm: Hex\n hypevm: Hex\n svm: SolanaTxHash\n}[VmType]\n\nexport type RelayWallet<VmType extends RelayVmType = RelayVmType> = {\n bvm: BitcoinWallet\n evm: WalletClient | (AdaptedWallet & { vmType: 'evm' })\n hypevm: AdaptedWallet & { vmType: 'hypevm' }\n svm: SolanaWallet\n}[VmType]\n\nexport interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {\n logger: Logger\n onError: (error: Error) => Promise<void>\n onProgress?: (step: RelayExecutionStep | null) => void\n /**\n * Fired when all *input* transactions are confirmed on-chain.\n */\n onTransactionConfirmed?: (txHash: RelayTxHash<VmType>) => Promise<void>\n /**\n * Fired as soon as user has *signed* all input transactions, but before they are confirmed on-chain.\n *\n * After this event, no more action should be needed from the user.\n * However, it is possible that the transactions will be rejected and the execution will NOT continue.\n */\n onUserActionsCompleted?: (txHash: RelayTxHash<VmType>) => Promise<void>\n relayQuote: RelayQuoteResult<VmType>\n walletClient: RelayWallet<VmType>\n}\n\nexport async function executeRelayQuote<VmType extends RelayVmType>({\n logger,\n onError,\n onProgress,\n onTransactionConfirmed,\n onUserActionsCompleted,\n relayQuote,\n walletClient,\n}: ExecuteRelayQuoteParams<VmType>): Promise<void> {\n let isUserActionsCompleted = false\n let isTransactionConfirmed = false\n\n await getRelayClient().actions.execute({\n quote: relayQuote,\n wallet: walletClient,\n onProgress: async ({\n steps,\n fees,\n breakdown,\n currentStep,\n currentStepItem,\n txHashes,\n details,\n error,\n }) => {\n const logPrefix = 'onRelayProgress'\n logger.info(`${logPrefix}:params`, {\n steps,\n currentStep,\n fees,\n breakdown,\n currentStepItem,\n txHashes,\n details,\n error,\n })\n\n onProgress?.(currentStep ?? null)\n\n if (error) {\n logger.info(`${logPrefix}:errorDetected`, error)\n await onError(error).catch((e) => {\n logger.error(`${logPrefix}:onErrorFailed`, e)\n })\n } else if (txHashes?.length) {\n // Use first txHash as the main txHash in fun DE table\n // Bad surprise from Relay: txHash may be an object, this is not present in their typing...\n const rawTxHashWithUnreliableTyping = txHashes[0].txHash as\n | RelayTxHash<VmType>\n | { id: RelayTxHash<VmType> }\n\n const txHash =\n typeof rawTxHashWithUnreliableTyping === 'object'\n ? rawTxHashWithUnreliableTyping.id\n : rawTxHashWithUnreliableTyping\n\n if (\n // Call onUserActionsCompleted only once\n !isUserActionsCompleted &&\n steps.every((step) =>\n step.items.every(\n // 'completed' - catch-all for items marked completed with no other info\n // - e.g. Batched items will not have txHash but will have their item marked 'complete'\n // 'pending' - for origin chain transactions that have been included on chain\n // - may sometimes be skipped, hence the need for 'submitted' condition below\n // 'submitted' - for destination chain transactions that have been submitted to the network\n // receipt - is present when the transaction has been mined/confirmed\n // Ensure onUserActionsCompleted is always called before onTransactionConfirmed\n (item) =>\n item.status === 'complete' ||\n item.checkStatus === 'pending' ||\n item.checkStatus === 'submitted' ||\n item.receipt !== undefined,\n ),\n )\n ) {\n logger.info(`${logPrefix}:onUserActionsCompleted`, txHashes)\n isUserActionsCompleted = true\n\n try {\n await onUserActionsCompleted?.(txHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onUserActionsCompletedFailed`,\n e as Error,\n )\n }\n }\n\n if (\n // Call onTransactionConfirmed only once\n !isTransactionConfirmed &&\n steps.every((step) =>\n step.items.every((item) => item.status === 'complete'),\n )\n ) {\n logger.info(`${logPrefix}:onTransactionConfirmed`, txHashes)\n isTransactionConfirmed = true\n\n // fire and forget index registration\n if (relayQuote.steps[0].requestId) {\n manuallyRegisterIndex(logger, {\n requestId: relayQuote.steps[0].requestId,\n chainId: relayQuote.steps[0].items[0].data.chainId,\n tx: jsonStringifyWithBigIntSanitization({\n ...relayQuote.steps[0].items[0].data,\n txHash,\n }),\n })\n }\n\n try {\n await onTransactionConfirmed?.(txHash)\n } catch (e) {\n logger.error(\n `${logPrefix}:onTransactionConfirmedFailed`,\n e as Error,\n )\n }\n }\n }\n },\n })\n}\n\nexport interface PostRegistrationRequest {\n requestId: string\n chainId: string\n tx: string\n}\n\nexport type RegisterIndexingResponse =\n | { success: never; message: 'Success' }\n | { success: false; message: string }\n\nexport async function manuallyRegisterIndex(\n logger: Logger,\n registerRequest: PostRegistrationRequest,\n): Promise<void> {\n const logPrefix = 'manuallyRegisterIndex'\n const stringifiedRequest = JSON.stringify(registerRequest)\n const url = `${MAINNET_RELAY_API}/transactions/single`\n try {\n logger.info(`${logPrefix}:onManuallyRegisterIndex`, {\n params: stringifiedRequest,\n })\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(registerRequest),\n })\n if (!response.ok) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: 'Error !response.ok - request to manually register index',\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n return\n }\n\n const data = (await response.json()) as RegisterIndexingResponse\n if (data.message !== 'Success') {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Data.message is not of type Success - ${data.message}`,\n response: JSON.stringify(response),\n params: stringifiedRequest,\n })\n }\n return\n } catch (err) {\n logger.error(`${logPrefix}:onManuallyRegisterIndexError`, {\n message: `Error sending request to register index at ${url}: ${JSON.stringify((err as Error)?.message)}`,\n params: stringifiedRequest,\n })\n }\n}\n\nexport async function getRelayExecutionInfo(\n requestId: string,\n): Promise<RelayExecutionInfo> {\n const url = `${MAINNET_RELAY_API}/intents/status/v2?requestId=${requestId}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayExecutionInfo\n}\n", "import {\n FUNKIT_NATIVE_TOKEN,\n FUN_HYPERCORE_CHAIN_ID_NUMBER,\n FUN_SOLANA_CHAIN_ID_NUMBER,\n RELAY_BITCOIN_CHAIN_ID_NUMBER,\n RELAY_NATIVE_TOKEN,\n RELAY_NATIVE_TOKEN_BITCOIN,\n RELAY_NATIVE_TOKEN_HYPERCORE,\n RELAY_NATIVE_TOKEN_SOLANA,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n RELAY_TERMINAL_STATUSES,\n} from './constants'\nimport type { RelayAddress, RelayVmType } from './execution'\nimport {\n CheckoutRefundState,\n CheckoutState,\n type RelayExecutionInfo,\n RelayExecutionStatus,\n} from './types'\n\n/**\n * Converts a token address within Funkit to the corresponding Relay token address.\n */\nexport function convertFunToRelayTokenAddress<T extends RelayVmType>(\n address: RelayAddress<T>,\n chainId: number,\n): RelayAddress<T> {\n // convert Fun's NATIVE_TOKEN representation\n if (address.toLowerCase() === FUNKIT_NATIVE_TOKEN.toLowerCase()) {\n switch (chainId) {\n case FUN_HYPERCORE_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_HYPERCORE as RelayAddress<T>\n\n case RELAY_BITCOIN_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_BITCOIN as RelayAddress<T>\n\n case RELAY_SOLANA_CHAIN_ID_NUMBER:\n return RELAY_NATIVE_TOKEN_SOLANA as RelayAddress<T>\n\n default:\n return RELAY_NATIVE_TOKEN as RelayAddress<T>\n }\n }\n\n return address\n}\n\n/**\n * Converts a chainId within Funkit to the corresponding Relay chainId.\n */\nexport function convertFunToRelayChainId(chainId: number): number {\n if (chainId === FUN_SOLANA_CHAIN_ID_NUMBER) {\n return RELAY_SOLANA_CHAIN_ID_NUMBER\n }\n return chainId\n}\n\nexport function getRelayExecutionRefundState(\n info: RelayExecutionInfo,\n): CheckoutRefundState | undefined {\n switch (info.status) {\n case RelayExecutionStatus.REFUND:\n return CheckoutRefundState.REFUNDED\n default:\n return undefined\n }\n}\n\nexport function getRelayExecutionState(\n info: RelayExecutionInfo,\n): CheckoutState {\n switch (info.status) {\n case RelayExecutionStatus.SUCCESS:\n return CheckoutState.COMPLETED\n case RelayExecutionStatus.FAILURE:\n case RelayExecutionStatus.REFUND:\n return CheckoutState.CHECKOUT_ERROR\n default:\n return CheckoutState.PENDING_RECEIVAL\n }\n}\n\n/**\n * Checks whether the Relay execution has reached a terminal status.\n */\nexport function isRelayExecutionTerminalStatus(\n info: RelayExecutionInfo,\n): boolean {\n return RELAY_TERMINAL_STATUSES.includes(info.status)\n}\n\nexport type Serializable =\n | bigint\n | boolean\n | null\n | number\n | string\n | Date\n | object // Should be '{ [key: string]: Serializable }' but helper gets called with loosely-typed 'object' and interfaces\n | Serializable[]\n\nexport function jsonStringifyWithBigIntSanitization(\n serializable: Serializable,\n): string {\n return JSON.stringify(\n serializable,\n (_, value) =>\n typeof value === 'bigint' ? `0x${value.toString(16)}` : value, // return everything else unchanged\n )\n}\n", "import type { CallFees } from '@relayprotocol/relay-sdk'\nimport type { Logger } from './types'\n\nexport interface FunRelayFeeItem {\n b: number\n v: number\n config: {\n options: Record<string, unknown>\n }\n headers: Record<string, string>\n}\n\nexport async function getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue,\n clientId,\n recipientAddress,\n}: {\n fromTokenAddress: string\n fromChainId: string\n toTokenAddress: string\n toChainId: string\n estUsdValue: number\n clientId: string\n recipientAddress: string | undefined\n}): Promise<FunRelayFeeItem> {\n const params = new URLSearchParams({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: estUsdValue.toString(),\n clientId,\n ...(recipientAddress ? { recipientAddress } : {}),\n })\n const url = `https://frog.fun.xyz/api/fee?${params.toString()}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data\n}\n\nexport function parseRelayFees({\n fees,\n logger,\n}: {\n fees: CallFees | undefined\n logger: Logger\n}) {\n // Gas fees, denominated in source chain native token\n const relayGasFeesUsd = Number.parseFloat(fees?.gas?.amountUsd || '0')\n\n // App fees, denominated in source chain token\n const funLpFeesUsd = Number.parseFloat(fees?.app?.amountUsd || '0')\n const funLpFeesFromAmount = Number.parseFloat(\n fees?.app?.amountFormatted || '0',\n )\n const funLpFeesFromAmountBaseUnit = BigInt(fees?.app?.amount || '0')\n\n // Relay fees, denominated in source chain token\n const relayLpFeesUsd = Number.parseFloat(fees?.relayer?.amountUsd || '0')\n const relayLpFeesFromAmount = Number.parseFloat(\n fees?.relayer?.amountFormatted || '0',\n )\n const relayLpFeesFromAmountBaseUnit = BigInt(fees?.relayer?.amount || '0')\n\n const totalLpFeesUsd = funLpFeesUsd + relayLpFeesUsd\n const totalLpFeesFromAmount = funLpFeesFromAmount + relayLpFeesFromAmount\n const totalLpFeesFromAmountBaseUnit =\n funLpFeesFromAmountBaseUnit + relayLpFeesFromAmountBaseUnit\n\n logger.info('parseRelayFees', {\n relayGasFeesUsd,\n funLpFeesUsd,\n funLpFeesFromAmount,\n funLpFeesFromAmountBaseUnit,\n relayLpFeesUsd,\n relayLpFeesFromAmount,\n relayLpFeesFromAmountBaseUnit,\n totalLpFeesUsd,\n totalLpFeesFromAmount,\n totalLpFeesFromAmountBaseUnit,\n })\n\n return {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd: relayGasFeesUsd + totalLpFeesUsd,\n totalFeesFromAmount: totalLpFeesFromAmount,\n totalFeesFromAmountBaseUnit: totalLpFeesFromAmountBaseUnit,\n }\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport type { RelayTokenPriceInfo } from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport async function getRelayAssetPriceInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenPriceInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/token/price?chainId=${relayChainId}&address=${relayTokenAddress}`\n const response = await fetch(url)\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data as RelayTokenPriceInfo\n}\n", "import { MAINNET_RELAY_API } from '@relayprotocol/relay-sdk'\nimport type { RelayAddress } from './execution'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\nexport interface RelayTokenInfo {\n chainId: number\n address: string\n symbol: string\n name: string\n decimals: number\n vmType: string\n metadata: {\n logoURI: string\n verified: boolean\n isNative: boolean\n }\n}\n\nexport async function getRelayAssetInfo({\n chainId,\n address,\n}: {\n chainId: string\n address: string\n}): Promise<RelayTokenInfo> {\n const relayChainId = convertFunToRelayChainId(Number(chainId))\n const relayTokenAddress = convertFunToRelayTokenAddress(\n address as RelayAddress,\n relayChainId,\n )\n\n const url = `${MAINNET_RELAY_API}/currencies/v2`\n const body = {\n chainIds: [relayChainId],\n address: relayTokenAddress,\n }\n const response = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw Error(response.statusText)\n }\n\n const data = await response.json()\n return data?.[0] as RelayTokenInfo\n}\n", "import {\n type APIError,\n type Execute,\n type GetQuoteParameters,\n isAPIError,\n} from '@relayprotocol/relay-sdk'\nimport { type Address, encodeFunctionData } from 'viem'\nimport { getRelayClient } from './client'\nimport {\n FUN_RELAY_REFERRER,\n FUN_RELAY_REVENUE_WALLET,\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n} from './constants'\nimport { getRelayAssetInfo } from './currency'\nimport type {\n RelayAddress,\n RelayChainId,\n RelayVmType,\n RelayWallet,\n} from './execution'\nimport { getFunRelayFees, parseRelayFees } from './fees'\nimport { getRelayAssetPriceInfo } from './price'\nimport type { SolanaAddress } from './solana'\nimport type {\n ApiFunkitCheckoutActionParams,\n CheckoutQuoteResponse,\n Logger,\n} from './types'\nimport {\n convertFunToRelayChainId,\n convertFunToRelayTokenAddress,\n} from './utils'\n\ntype RelayQuoteOptions = GetQuoteParameters['options'] & {\n // TODO: Relay does not yet explicitly handle this field in their SDK, nor is it in their typings - but it gets forwarded to API\n depositFeePayer?: SolanaAddress\n}\n\nexport type RelayQuoteResult<VmType extends RelayVmType> = {\n details?: {\n currencyIn?: NonNullable<Execute['details']>['currencyIn']\n currencyOut?: NonNullable<Execute['details']>['currencyOut']\n }\n steps: Execute['steps']\n vmType: VmType\n}\n\nexport type GetRelayQuoteParams<\n SourceVmType extends RelayVmType = RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n> = {\n actionParams?: ApiFunkitCheckoutActionParams[]\n clientId: string\n fromChainId: RelayChainId<SourceVmType>\n fromTokenAddress: RelayAddress<SourceVmType>\n logger: Logger\n /**\n * {@link getRelayQuote} already sets {@link RelayQuoteOptions.appFees|appFees} and {@link RelayQuoteOptions.referrer|referrer}.\n * Only include them if you wish to override.\n */\n options?: RelayQuoteOptions\n recipientAddress: RelayAddress<TargetVmType> | undefined\n toChainId: RelayChainId<TargetVmType>\n toTokenAddress: RelayAddress<TargetVmType>\n tradeType: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n userAddress: RelayAddress<SourceVmType> | undefined\n walletClient?: RelayWallet<SourceVmType>\n} & (\n | {\n fromTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_INPUT'\n }\n | {\n toTokenAmountBaseUnit: bigint | string\n tradeType: 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT'\n }\n)\n\nexport type RelayQuote<VmType extends RelayVmType = RelayVmType> =\n CheckoutQuoteResponse & {\n /** Required for EXACT_INPUT checkouts */\n finalToAmountBaseUnit: string\n metadata: {\n fromAmountBaseUnit: string\n relayQuote: RelayQuoteResult<VmType>\n toAmountBaseUnit: string\n }\n }\n\nasync function getQuoteEstUsdValue({\n tokenChainId,\n tokenAddress,\n tokenAmountBaseUnit,\n logger,\n}: {\n tokenChainId: string\n tokenAddress: string\n tokenAmountBaseUnit: string\n logger: Logger\n}) {\n try {\n const normalizedChainId = convertFunToRelayChainId(\n Number(tokenChainId),\n ).toString()\n const normalizedTokenAddress = convertFunToRelayTokenAddress(\n tokenAddress as Address,\n Number(tokenChainId),\n )\n\n const [tokenPriceRes, tokenInfoRes] = await Promise.all([\n getRelayAssetPriceInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n getRelayAssetInfo({\n chainId: normalizedChainId,\n address: normalizedTokenAddress,\n }),\n ])\n\n // FIXME: Temp hardcode until relay supports WUSDE on Ethereal\n const isWUsdeEthereal =\n normalizedChainId === '5064014' &&\n normalizedTokenAddress.toLowerCase() ===\n '0xB6fC4B1BFF391e5F6b4a3D2C7Bda1FeE3524692D'.toLowerCase()\n\n const price = tokenPriceRes.price\n const decimals = isWUsdeEthereal ? 18 : tokenInfoRes.decimals\n\n const absoluteAmount = BigInt(tokenAmountBaseUnit) / BigInt(10 ** decimals)\n return Number(price) * Number(absoluteAmount)\n } catch (err) {\n logger.error('getQuoteEstUsdValueError', {\n message: `Failed to get USD value for token ${tokenAddress} on chain ${tokenChainId}: ${\n err instanceof Error ? err.message : JSON.stringify(err)\n }. Falling back to 0 USD.`,\n })\n // If any part fails, just fallback to 0 USD so that we do not block quote\n return 0\n }\n}\n\nexport function getReferrer(clientId: string) {\n return clientId ? `${FUN_RELAY_REFERRER}|${clientId}` : FUN_RELAY_REFERRER\n}\n\nexport class RelayQuoteClientError extends Error {\n public constructor(\n public readonly statusCode: number,\n public readonly relayErrorCode: string,\n message: string,\n ) {\n super(\n `An error occurred trying to generate a relay quote: ${relayErrorCode} - ${message}`,\n )\n\n this.name = new.target.name\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport async function getRelayQuote<\n SourceVmType extends RelayVmType,\n TargetVmType extends RelayVmType = RelayVmType,\n>({\n logger,\n walletClient,\n ...params\n}: GetRelayQuoteParams<SourceVmType, TargetVmType>): Promise<\n RelayQuote<SourceVmType>\n> {\n const {\n actionParams,\n clientId,\n fromChainId,\n fromTokenAddress,\n options,\n recipientAddress,\n toChainId,\n toTokenAddress,\n tradeType,\n userAddress,\n } = params\n\n const vmType = (\n walletClient && 'vmType' in walletClient ? walletClient.vmType : 'evm'\n ) as SourceVmType\n\n try {\n const relayClient = getRelayClient()\n\n const txs = actionParams?.map((action) => {\n const data = encodeFunctionData({\n abi: action.contractAbi,\n args: action.functionArgs,\n functionName: action.functionName,\n })\n\n return {\n data,\n to: action.contractAddress,\n // Relay supports msg.value via 2 fields: `value` and `originalTxValue`\n // Both `value` and `originalTxValue` are required to be set for `erc20` + gas transfers\n // Only `value` is required for native token transfers. // TODO: This flow needs verification.\n // Internally for Relay,\n // - `originalTxValue` is designed to \"bubble up\" the value to the original tx\n // - `value` is the internal multicall value\n originalTxValue: String(action.value ?? 0n),\n value: String(action.value ?? 0n),\n }\n })\n\n const isExactIn = params.tradeType === 'EXACT_INPUT'\n const queryTokenAmountBaseUnit = isExactIn\n ? params.fromTokenAmountBaseUnit\n : params.toTokenAmountBaseUnit\n const queryTokenAddress = isExactIn ? fromTokenAddress : toTokenAddress\n const queryTokenChainId = isExactIn ? fromChainId : toChainId\n\n const estUsdValue = await getQuoteEstUsdValue({\n tokenChainId: queryTokenChainId,\n tokenAddress: queryTokenAddress,\n tokenAmountBaseUnit: queryTokenAmountBaseUnit.toString(),\n logger,\n })\n\n const funRelayConfig = await getFunRelayFees({\n fromTokenAddress,\n fromChainId,\n toTokenAddress,\n toChainId,\n estUsdValue: Number(estUsdValue) || 0,\n clientId,\n recipientAddress,\n })\n\n const appFeeBp = funRelayConfig.b + funRelayConfig.v\n\n logger.info('getRelayQuoteParams', {\n ...params,\n appFeeBp,\n estUsdValue,\n funRelayConfig,\n queryTokenAmountBaseUnit,\n txs,\n })\n\n // Get the full quote with fees\n const relayQuote = await relayClient.actions.getQuote(\n {\n amount: queryTokenAmountBaseUnit.toString(),\n chainId: convertFunToRelayChainId(Number(fromChainId)),\n currency: convertFunToRelayTokenAddress(\n fromTokenAddress,\n Number(fromChainId),\n ),\n recipient: recipientAddress,\n toChainId: convertFunToRelayChainId(Number(toChainId)),\n toCurrency: convertFunToRelayTokenAddress(\n toTokenAddress,\n Number(toChainId),\n ),\n tradeType,\n txs,\n user: userAddress,\n wallet: walletClient,\n options: {\n referrer: getReferrer(clientId),\n appFees: [\n {\n fee: appFeeBp.toString(),\n recipient: FUN_RELAY_REVENUE_WALLET,\n },\n ],\n // Passed in options\n ...options,\n // Remote options will always override passed in options\n ...funRelayConfig.config.options,\n },\n },\n undefined,\n funRelayConfig.headers,\n )\n\n logger.info('relayQuote', relayQuote)\n\n const estSubtotalUsd = Number(\n relayQuote.details?.currencyOut?.amountUsd || 0,\n )\n const estTotalUsd = Number(relayQuote.details?.currencyIn?.amountUsd || 0)\n // Get how much fromAmount is needed for the quote\n const fromAmountString =\n relayQuote.details?.currencyIn?.amountFormatted || '0'\n const fromAmountBaseUnitString =\n relayQuote.details?.currencyIn?.amount || '0'\n\n // RequestID will be consistent across steps in the quote\n // https://fun-xyz.slack.com/archives/C08MQ85QB2N/p1747774944603209\n const relayRequestId = relayQuote.steps[0]?.requestId\n\n // TODO: Verify with relay team if this is possible?\n if (!relayRequestId) {\n throw new Error('Relay quote does not contain a requestId')\n }\n\n // TODO: Verify with relay team if this is possible?\n if (!relayQuote.details?.currencyIn || !relayQuote.details?.currencyOut) {\n throw new Error('Relay quote does not contain trade details')\n }\n\n const {\n relayGasFeesUsd,\n totalLpFeesUsd,\n totalFeesUsd,\n totalFeesFromAmount,\n totalFeesFromAmountBaseUnit,\n } = parseRelayFees({ fees: relayQuote.fees, logger })\n\n const estSubtotalFromAmount = (\n Number.parseFloat(fromAmountString) - totalFeesFromAmount\n ).toString()\n\n const estSubtotalFromAmountBaseUnit = (\n BigInt(fromAmountBaseUnitString) - totalFeesFromAmountBaseUnit\n ).toString()\n\n return {\n quoteId: relayRequestId,\n estCheckoutTimeMs:\n (relayQuote.details.timeEstimate || 0) * 1000 +\n RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS,\n estFeesFromAmount: totalFeesFromAmount.toString(),\n estFeesFromAmountBaseUnit: totalFeesFromAmountBaseUnit.toString(),\n estFeesUsd: totalFeesUsd,\n estMarketMakerGasUsd: relayGasFeesUsd,\n estSubtotalFromAmount,\n estSubtotalFromAmountBaseUnit,\n estSubtotalUsd,\n estTotalFromAmount: fromAmountString,\n estTotalFromAmountBaseUnit: fromAmountBaseUnitString,\n estTotalUsd,\n finalToAmountBaseUnit: relayQuote.details.currencyOut.amount ?? '0', // TODO: Or do we want 'minimumAmount'?\n fromTokenAddress: fromTokenAddress as Address, // TODO: fromTokenAddress is typed as `0x${string}` why does not accept SolanaAddress\n lpFeePercentage: 0, // TODO: ?\n lpFeeUsd: totalLpFeesUsd,\n metadata: {\n fromAmountBaseUnit: isExactIn\n ? queryTokenAmountBaseUnit.toString()\n : (relayQuote.details.currencyIn.amount ?? '0'),\n relayQuote: {\n ...relayQuote,\n vmType,\n },\n toAmountBaseUnit: isExactIn\n ? (relayQuote.details.currencyOut.amount ?? '0')\n : queryTokenAmountBaseUnit.toString(),\n },\n }\n } catch (err) {\n if (err instanceof Error && isAPIError(err)) {\n const apiError = err as APIError\n const rawError = apiError.rawError as {\n errorCode?: string\n message?: string\n }\n\n if (rawError?.errorCode) {\n throw new RelayQuoteClientError(\n apiError.statusCode,\n rawError.errorCode,\n rawError.message ?? apiError.message,\n )\n }\n }\n\n const message = getErrorMessage(err)\n throw new Error(\n `An error occurred trying to generate a relay quote: ${message}`,\n )\n }\n}\n\nfunction getErrorMessage(err: unknown): string {\n return err instanceof Error\n ? err.message\n : typeof err === 'string'\n ? err\n : JSON.stringify(err)\n}\n", "import type { AdaptedWallet } from '@relayprotocol/relay-sdk'\nimport { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'\nimport {\n type Connection,\n SendTransactionError,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport { RELAY_SOLANA_CHAIN_ID_NUMBER } from './constants'\n\ntype Base58 =\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n\nexport type SolanaAddress = `${Base58}${string}`\n\nexport type SolanaTxHash = `${Base58}${string}`\n\nexport type SolanaWallet = {\n address(): Promise<SolanaAddress>\n vmType: 'svm'\n} & AdaptedWallet\n\nexport function getSolanaWallet(\n walletAddress: SolanaAddress,\n connection: Connection,\n signTransaction: (\n transaction: VersionedTransaction,\n ) => Promise<VersionedTransaction>,\n payerKey?: SolanaAddress,\n): SolanaWallet {\n return adaptSolanaWallet(\n walletAddress,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n connection,\n async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection),\n )\n }\n\n throw error\n }\n },\n payerKey,\n ) as SolanaWallet\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,0BAA0B;AA8C5B,SAAS,iBACd,eACA,UAKe;AACf,SAAO;AAAA,IAAmB;AAAA,IAAe,CAAC,SAAS,MAAM,kBACvD,SAAS,SAA2B,MAAM,aAAa;AAAA,EACzD;AACF;AAEO,SAAS,2BACd,eACA,QACe;AACf,SAAO;AAAA,IAAiB;AAAA,IAAe,OAAO,GAAG,SAC/C,KAAK,cAAc,MAAM,E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;AAClC;AAAA,EAEE;AAAA,OAEK;AAwEA,SAAS,gBACd,eACA,YACA,iBAGA,UACc;AACd,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,aAAa,YAAY;AAC9B,YAAM,SAAS,MAAM,gBAAgB,WAAW;AAChD,UAAI;AACF,cAAM,YAAY,MAAM,WAAW,gBAAgB,QAAQ;AAAA,UACzD,GAAG;AAAA,UACH,YAAY;AAAA,QACd,CAAC;AAED,eAAO,EAAE,UAAU;AAAA,MACrB,SAAS,OAAO;AACd,YAAI,iBAAiB,sBAAsB;AACzC,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA,MAAM,MAAM,QAAQ,UAAU;AAAA,UAChC;AAAA,QACF;AAEA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["LogLevel", "LogLevel", "MAINNET_RELAY_API", "MAINNET_RELAY_API", "MAINNET_RELAY_API", "MAINNET_RELAY_API", "MAINNET_RELAY_API", "MAINNET_RELAY_API"]
|
|
7
7
|
}
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -37,8 +37,9 @@ export declare const RELAY_NATIVE_TOKEN_SOLANA = "111111111111111111111111111111
|
|
|
37
37
|
export declare const RELAY_NATIVE_TOKEN_BITCOIN = "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8";
|
|
38
38
|
/**
|
|
39
39
|
* Wallet that receives the app fees collected by Relay
|
|
40
|
+
* Prev: 0xb61562d83aEC43a050A06BED12Ac2bD8f9BFfd5E
|
|
40
41
|
*/
|
|
41
|
-
export declare const FUN_RELAY_REVENUE_WALLET = "
|
|
42
|
+
export declare const FUN_RELAY_REVENUE_WALLET = "0xdfd877679e95c1276c85801805b2c2ab8f4f4cf6";
|
|
42
43
|
/**
|
|
43
44
|
* Referred field in Relay quote
|
|
44
45
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE9C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,UAAU,CAAA;AACpD,eAAO,MAAM,sBAAsB,YAAqC,CAAA;AAExE;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,YAAY,CAAA;AACrD,eAAO,MAAM,qBAAqB,cAAoC,CAAA;AAEtE,eAAO,MAAM,0BAA0B,mBAAmB,CAAA;AAC1D,eAAO,MAAM,6BAA6B,OAAO,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,mBAAmB,+CACgC,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,kBAAkB,+CACiC,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,4BAA4B,uCACe,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,yBAAyB,qCACsB,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,0BAA0B,8CAC+B,CAAA;AAEtE
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE9C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,UAAU,CAAA;AACpD,eAAO,MAAM,sBAAsB,YAAqC,CAAA;AAExE;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,YAAY,CAAA;AACrD,eAAO,MAAM,qBAAqB,cAAoC,CAAA;AAEtE,eAAO,MAAM,0BAA0B,mBAAmB,CAAA;AAC1D,eAAO,MAAM,6BAA6B,OAAO,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,mBAAmB,+CACgC,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,kBAAkB,+CACiC,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,4BAA4B,uCACe,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,yBAAyB,qCACsB,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,0BAA0B,8CAC+B,CAAA;AAEtE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,+CAC2B,CAAA;AAEhE;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,mCAAmC,QAAS,CAAA;AAEzD,eAAO,MAAM,uBAAuB,EAAE,oBAAoB,EAIzD,CAAA;AAED,eAAO,MAAM,YAAY,eAAe,CAAA;AACxC,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,gBAAgB,eAAe,CAAA"}
|
package/dist/src/execution.d.ts
CHANGED
|
@@ -6,20 +6,23 @@ import type { RelayQuoteResult } from './quote';
|
|
|
6
6
|
import type { SolanaAddress, SolanaTxHash, SolanaWallet } from './solana';
|
|
7
7
|
import type { Logger, RelayExecutionInfo } from './types';
|
|
8
8
|
export type RelayExecutionStep = ProgressData['currentStep'] & {};
|
|
9
|
-
export type RelayVmType = 'bvm' | 'evm' | 'svm';
|
|
9
|
+
export type RelayVmType = 'bvm' | 'evm' | 'hypevm' | 'svm';
|
|
10
10
|
export type RelayAddress<VmType extends RelayVmType = RelayVmType> = {
|
|
11
11
|
bvm: BitcoinAddress;
|
|
12
12
|
evm: Address;
|
|
13
|
+
hypevm: Address;
|
|
13
14
|
svm: SolanaAddress;
|
|
14
15
|
}[VmType];
|
|
15
16
|
export type RelayChainId<VmType extends RelayVmType = RelayVmType> = {
|
|
16
17
|
bvm: typeof RELAY_BITCOIN_CHAIN_ID;
|
|
17
18
|
evm: string;
|
|
19
|
+
hypevm: string;
|
|
18
20
|
svm: typeof RELAY_SOLANA_CHAIN_ID;
|
|
19
21
|
}[VmType];
|
|
20
22
|
export type RelayTxHash<VmType extends RelayVmType = RelayVmType> = {
|
|
21
23
|
bvm: BitcoinTxHash;
|
|
22
24
|
evm: Hex;
|
|
25
|
+
hypevm: Hex;
|
|
23
26
|
svm: SolanaTxHash;
|
|
24
27
|
}[VmType];
|
|
25
28
|
export type RelayWallet<VmType extends RelayVmType = RelayVmType> = {
|
|
@@ -27,6 +30,9 @@ export type RelayWallet<VmType extends RelayVmType = RelayVmType> = {
|
|
|
27
30
|
evm: WalletClient | (AdaptedWallet & {
|
|
28
31
|
vmType: 'evm';
|
|
29
32
|
});
|
|
33
|
+
hypevm: AdaptedWallet & {
|
|
34
|
+
vmType: 'hypevm';
|
|
35
|
+
};
|
|
30
36
|
svm: SolanaWallet;
|
|
31
37
|
}[VmType];
|
|
32
38
|
export interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {
|
|
@@ -46,13 +52,8 @@ export interface ExecuteRelayQuoteParams<VmType extends RelayVmType> {
|
|
|
46
52
|
onUserActionsCompleted?: (txHash: RelayTxHash<VmType>) => Promise<void>;
|
|
47
53
|
relayQuote: RelayQuoteResult<VmType>;
|
|
48
54
|
walletClient: RelayWallet<VmType>;
|
|
49
|
-
/**
|
|
50
|
-
* Whether to use a smart wallet adapter.
|
|
51
|
-
* Used for account abstraction transactions.
|
|
52
|
-
*/
|
|
53
|
-
smartWalletAdapter?: boolean;
|
|
54
55
|
}
|
|
55
|
-
export declare function executeRelayQuote<VmType extends RelayVmType>({ logger, onError, onProgress, onTransactionConfirmed, onUserActionsCompleted, relayQuote, walletClient,
|
|
56
|
+
export declare function executeRelayQuote<VmType extends RelayVmType>({ logger, onError, onProgress, onTransactionConfirmed, onUserActionsCompleted, relayQuote, walletClient, }: ExecuteRelayQuoteParams<VmType>): Promise<void>;
|
|
56
57
|
export interface PostRegistrationRequest {
|
|
57
58
|
requestId: string;
|
|
58
59
|
chainId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE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