@funkit/api-base
Advanced tools
Comparing version 0.0.2 to 0.0.3
# @funkit/api-base | ||
## 0.0.3 | ||
### Patch Changes | ||
- ad4a3ce: chore: add unit tests for checkout utils | ||
## 0.0.2 | ||
@@ -4,0 +10,0 @@ |
export declare const API_BASE_URL: string; | ||
export declare const FUN_FAUCET_URL = "https://api.fun.xyz/demo-faucet"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.API_BASE_URL = void 0; | ||
exports.FUN_FAUCET_URL = exports.API_BASE_URL = void 0; | ||
exports.API_BASE_URL = process.env.NODE_ENV === 'staging' | ||
@@ -12,2 +12,3 @@ ? 'https://api.fun.xyz/staging/v1' | ||
'https://api.fun.xyz/v1'; | ||
exports.FUN_FAUCET_URL = 'https://api.fun.xyz/demo-faucet'; | ||
//# sourceMappingURL=api.js.map |
@@ -17,3 +17,3 @@ export interface GetAssetPriceInfoRequest { | ||
} | ||
interface AssetBalanceInfo { | ||
export interface AssetBalanceInfo { | ||
chainId: string; | ||
@@ -29,3 +29,3 @@ contractAddress: string; | ||
} | ||
interface ChainAssetBalanceInfo { | ||
export interface ChainAssetBalanceInfo { | ||
[tokenAddress: string]: AssetBalanceInfo; | ||
@@ -47,3 +47,3 @@ } | ||
} | ||
interface ChainNFTInfo { | ||
export interface ChainNFTInfo { | ||
address: string; | ||
@@ -53,5 +53,8 @@ token_id: string; | ||
} | ||
export interface GetAllWalletNFTsResponse { | ||
export interface ChainToNFTMapInfo { | ||
[chainId: string]: ChainNFTInfo[]; | ||
} | ||
export interface GetAllWalletNFTsResponse { | ||
nfts: ChainToNFTMapInfo; | ||
} | ||
export interface GetAllWalletNFTsByChainIdRequest { | ||
@@ -62,3 +65,5 @@ chainId: string; | ||
} | ||
export type GetAllWalletNFTsByChainIdResponse = ChainNFTInfo[]; | ||
export interface GetAllWalletNFTsByChainIdResponse { | ||
nfts: ChainNFTInfo[]; | ||
} | ||
export interface GetWalletLidoWithdrawalsByChainId { | ||
@@ -65,0 +70,0 @@ chainId: string; |
@@ -41,2 +41,3 @@ "use strict"; | ||
sponsorInitialTransferGasLimit, | ||
// @deprecated Not in use | ||
refuel: needsRefuel.toString(), | ||
@@ -159,3 +160,3 @@ }; | ||
const res = await (0, utils_1.sendPostRequest)({ | ||
uri: `${consts_1.API_BASE_URL}/checkout/sponsorship`, | ||
uri: `${consts_1.API_BASE_URL}/checkout/sponsor-transfer`, | ||
body, | ||
@@ -162,0 +163,0 @@ apiKey, |
export * from './assets'; | ||
export * from './checkout'; | ||
export * from './faucet'; | ||
export * from './mesh'; | ||
export * from './moonpay'; | ||
export * from './support'; | ||
export * from './turnkey'; |
@@ -19,4 +19,7 @@ "use strict"; | ||
__exportStar(require("./checkout"), exports); | ||
__exportStar(require("./faucet"), exports); | ||
__exportStar(require("./mesh"), exports); | ||
__exportStar(require("./moonpay"), exports); | ||
__exportStar(require("./support"), exports); | ||
__exportStar(require("./turnkey"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { ExecuteTransferRequest, GetCryptocurrencyHoldingsRequest, GetLinkTokenRequest, GetLinkTokenResponse, GetTransferIntegrationsRequest, GetTransferIntegrationsResponse, PreviewTransferRequest } from './types'; | ||
import { GetCryptocurrencyHoldingsRequest, GetLinkTokenRequest, GetLinkTokenResponse, GetTransferIntegrationsRequest, GetTransferIntegrationsResponse, MeshExecuteTransferRequest, MeshExecuteTransferResponse, PreviewTransferRequest } from './types'; | ||
/** | ||
@@ -45,2 +45,2 @@ * @param authToken The authentication token to send the asset from. | ||
*/ | ||
export declare function meshExecuteTransfer({ fromAuthToken, fromType, previewId, mfaCode, apiKey, }: ExecuteTransferRequest): Promise<any>; | ||
export declare function meshExecuteTransfer({ fromAuthToken, fromType, previewId, mfaCode, apiKey, }: MeshExecuteTransferRequest): Promise<MeshExecuteTransferResponse>; |
@@ -9,3 +9,3 @@ export interface GetCryptocurrencyHoldingsRequest { | ||
} | ||
interface IntegrationNetworkInfo { | ||
export interface IntegrationNetworkInfo { | ||
chainId: string; | ||
@@ -18,3 +18,3 @@ id: string; | ||
} | ||
interface TransferIntegration { | ||
export interface TransferIntegration { | ||
networks: IntegrationNetworkInfo[]; | ||
@@ -51,3 +51,3 @@ supportsIncomingTransfers: boolean; | ||
} | ||
export interface ExecuteTransferRequest { | ||
export interface MeshExecuteTransferRequest { | ||
apiKey: string; | ||
@@ -59,2 +59,29 @@ fromAuthToken: string; | ||
} | ||
export {}; | ||
export declare enum MeshExecuteTransferStatus { | ||
succeeded = "succeeded", | ||
failed = "failed", | ||
mfaRequired = "mfaRequired", | ||
emailConfirmationRequired = "emailConfirmationRequired", | ||
deviceConfirmationRequired = "deviceConfirmationRequired", | ||
mfaFailed = "mfaFailed", | ||
addressWhitelistRequired = "addressWhitelistRequired", | ||
secondMfaRequired = "secondMfaRequired" | ||
} | ||
export declare enum MeshExecuteTransferMfaType { | ||
unspecified = "unspecified", | ||
phone = "phone", | ||
email = "email", | ||
otp = "otp" | ||
} | ||
export interface MeshExecuteTransferContent { | ||
status: MeshExecuteTransferStatus; | ||
mfaType: MeshExecuteTransferMfaType; | ||
errorMessage: string | null; | ||
executeTransferResult: object | null; | ||
} | ||
export interface MeshExecuteTransferResponse { | ||
status: MeshExecuteTransferStatus; | ||
mfaType: MeshExecuteTransferMfaType; | ||
errorMessage: string | null; | ||
executeTransferResult: object | null; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MeshExecuteTransferMfaType = exports.MeshExecuteTransferStatus = void 0; | ||
// Reference: https://docs.meshconnect.com/reference/post_api-v1-transfers-managed-execute | ||
var MeshExecuteTransferStatus; | ||
(function (MeshExecuteTransferStatus) { | ||
MeshExecuteTransferStatus["succeeded"] = "succeeded"; | ||
MeshExecuteTransferStatus["failed"] = "failed"; | ||
MeshExecuteTransferStatus["mfaRequired"] = "mfaRequired"; | ||
MeshExecuteTransferStatus["emailConfirmationRequired"] = "emailConfirmationRequired"; | ||
MeshExecuteTransferStatus["deviceConfirmationRequired"] = "deviceConfirmationRequired"; | ||
MeshExecuteTransferStatus["mfaFailed"] = "mfaFailed"; | ||
MeshExecuteTransferStatus["addressWhitelistRequired"] = "addressWhitelistRequired"; | ||
MeshExecuteTransferStatus["secondMfaRequired"] = "secondMfaRequired"; | ||
})(MeshExecuteTransferStatus || (exports.MeshExecuteTransferStatus = MeshExecuteTransferStatus = {})); | ||
var MeshExecuteTransferMfaType; | ||
(function (MeshExecuteTransferMfaType) { | ||
MeshExecuteTransferMfaType["unspecified"] = "unspecified"; | ||
MeshExecuteTransferMfaType["phone"] = "phone"; | ||
MeshExecuteTransferMfaType["email"] = "email"; | ||
MeshExecuteTransferMfaType["otp"] = "otp"; | ||
})(MeshExecuteTransferMfaType || (exports.MeshExecuteTransferMfaType = MeshExecuteTransferMfaType = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -1,3 +0,11 @@ | ||
import { GetMoonpayBuyQuoteForCreditCardRequest, GetMoonpayUrlSignatureRequest } from './types'; | ||
import { GetMoonpayBuyQuoteForCreditCardRequest, GetMoonpayOffRampUrlRequest, GetMoonpayOnRampUrlRequest, GetMoonpayUrlSignatureRequest, MoonpayCurrency } from './types'; | ||
export declare function getMoonpayUrlSignature({ url, isSandbox, apiKey, }: GetMoonpayUrlSignatureRequest): Promise<string>; | ||
export declare function getMoonpayBuyQuoteForCreditCard({ currencyCode, baseCurrencyCode, quoteCurrencyAmount, baseCurrencyAmount, extraFeePercentage, areFeesIncluded, apiKey, }: GetMoonpayBuyQuoteForCreditCardRequest): Promise<any>; | ||
/**======================= | ||
* POTENTIAL DEPRECATION | ||
*=======================*/ | ||
export declare function getMoonpayOnRampUrl({ apiKey, walletAddr, currencyCode, }: GetMoonpayOnRampUrlRequest): Promise<string>; | ||
export declare function getMoonpayOffRampUrl({ walletAddr, apiKey, }: GetMoonpayOffRampUrlRequest): Promise<string>; | ||
export declare function getMoonpayOnRampSupportedCurrencies({ apiKey, }: { | ||
apiKey: string; | ||
}): Promise<MoonpayCurrency[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getMoonpayBuyQuoteForCreditCard = exports.getMoonpayUrlSignature = void 0; | ||
exports.getMoonpayOnRampSupportedCurrencies = exports.getMoonpayOffRampUrl = exports.getMoonpayOnRampUrl = exports.getMoonpayBuyQuoteForCreditCard = exports.getMoonpayUrlSignature = void 0; | ||
const consts_1 = require("../../consts"); | ||
@@ -43,2 +43,42 @@ const errors_1 = require("../../errors"); | ||
exports.getMoonpayBuyQuoteForCreditCard = getMoonpayBuyQuoteForCreditCard; | ||
/**======================= | ||
* POTENTIAL DEPRECATION | ||
*=======================*/ | ||
async function getMoonpayOnRampUrl({ apiKey, walletAddr, currencyCode, }) { | ||
const endpoint = `on-ramp/${walletAddr}?provider=moonpay`; | ||
if (currencyCode) { | ||
endpoint.concat(`¤cyCode=${currencyCode}`); | ||
} | ||
const url = (await (0, utils_1.sendGetRequest)({ | ||
uri: `${consts_1.API_BASE_URL}/${endpoint}`, | ||
apiKey, | ||
}))?.url; | ||
if (!url) { | ||
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No onramp url found.', { walletAddr }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz'); | ||
} | ||
return url; | ||
} | ||
exports.getMoonpayOnRampUrl = getMoonpayOnRampUrl; | ||
async function getMoonpayOffRampUrl({ walletAddr, apiKey, }) { | ||
const url = (await (0, utils_1.sendGetRequest)({ | ||
uri: `${consts_1.API_BASE_URL}/off-ramp/${walletAddr}?provider=moonpay`, | ||
apiKey, | ||
}))?.url; | ||
if (!url) { | ||
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No offramp url found.', { walletAddr }, 'This is an internal error, please contact support.', 'https://docs.fun.xyz'); | ||
} | ||
return url; | ||
} | ||
exports.getMoonpayOffRampUrl = getMoonpayOffRampUrl; | ||
async function getMoonpayOnRampSupportedCurrencies({ apiKey, }) { | ||
const currencies = await (0, utils_1.sendGetRequest)({ | ||
uri: `${consts_1.API_BASE_URL}/on-ramp/moonpay-currencies`, | ||
apiKey, | ||
}); | ||
if (!currencies || !currencies.length) { | ||
throw new errors_1.InternalFailureError(errors_1.ErrorCode.UnknownServerError, 'No supported currencies found.', {}, 'This is an internal error, please contact support.', 'https://docs.fun.xyz'); | ||
} | ||
return currencies; | ||
} | ||
exports.getMoonpayOnRampSupportedCurrencies = getMoonpayOnRampSupportedCurrencies; | ||
//# sourceMappingURL=endpoints.js.map |
@@ -15,1 +15,34 @@ export interface GetMoonpayUrlSignatureRequest { | ||
} | ||
export interface GetMoonpayOnRampUrlRequest { | ||
apiKey: string; | ||
walletAddr: string; | ||
currencyCode?: string; | ||
} | ||
export interface GetMoonpayOffRampUrlRequest { | ||
apiKey: string; | ||
walletAddr: string; | ||
} | ||
export interface MoonpayCurrency { | ||
id: string; | ||
name: string; | ||
code: string; | ||
createdAt?: string; | ||
updatedAt?: string; | ||
type?: string; | ||
precision?: number; | ||
addressRegex?: string; | ||
testnetAddressRegex?: string; | ||
maxAmount?: number; | ||
maxBuyAmount?: number; | ||
maxSellAmount?: number; | ||
minAmount?: number; | ||
minBuyAmount?: number; | ||
minSellAmount?: number; | ||
supportsAddressTag?: boolean; | ||
addressTagRegex?: string; | ||
supportsTestMode?: boolean; | ||
isSuspended?: boolean; | ||
isSupportedInUS?: boolean; | ||
isSellSupported?: boolean; | ||
notAllowedUSStates?: string[]; | ||
} |
@@ -0,2 +1,3 @@ | ||
export declare function randomBytes(length: number): `0x${string}`; | ||
export declare function generateRandomCheckoutSalt(): bigint; | ||
export declare function roundToNearestBottomTenth(n: number): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.roundToNearestBottomTenth = exports.generateRandomCheckoutSalt = void 0; | ||
exports.roundToNearestBottomTenth = exports.generateRandomCheckoutSalt = exports.randomBytes = void 0; | ||
const viem_1 = require("viem"); | ||
const randomBytes = (length) => { | ||
function randomBytes(length) { | ||
const bytes = new Uint8Array(length); | ||
@@ -11,3 +11,4 @@ for (let i = 0; i < length; i++) { | ||
return (0, viem_1.toHex)(bytes); | ||
}; | ||
} | ||
exports.randomBytes = randomBytes; | ||
function generateRandomCheckoutSalt() { | ||
@@ -14,0 +15,0 @@ return BigInt(randomBytes(32)); |
{ | ||
"name": "@funkit/api-base", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Base API for Funkit", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146292
112
2455