UNPKG

@ar.io/sdk

Version:

[![codecov](https://codecov.io/gh/ar-io/ar-io-sdk/graph/badge.svg?token=7dXKcT7dJy)](https://codecov.io/gh/ar-io/ar-io-sdk)

97 lines (96 loc) 4.05 kB
/** * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ARIOWithFaucet, TokenFaucet } from '../types/faucet.js'; import { ARIOReadable, ARIOWriteable } from './io.js'; /** * Creates a proxy object that implements the TokenFaucet interface. It wraps the ARIOReadable instance and adds methods for claiming tokens from the faucet API. * @param arioInstance - The ARIOReadable instance * @param faucetApiUrl - The URL of the faucet API * @returns A proxy object that implements the TokenFaucet interface */ export declare function createFaucet({ arioInstance, faucetApiUrl, }: { arioInstance: ARIOReadable | ARIOWriteable; faucetApiUrl?: string; }): ARIOWithFaucet<ARIOReadable | ARIOWriteable>; export declare class ARIOTokenFaucet implements TokenFaucet { private faucetUrl; private processId; constructor({ faucetUrl, processId, }: { faucetUrl: string; processId: string; }); /** * Returns the captcha URL for a process. The captcha is used to verify a human is solving the captcha. Once you have a captcha response, you can use it to request an authorization token via the requestAuthToken method. * @returns The captcha URL for a process */ captchaUrl(): Promise<{ processId: string; captchaUrl: string; }>; /** * Claim tokens for a process using a captcha response. This method is used to synchronously claim tokens for a process using a captcha response. * @param captchaResponse - The captcha response * @param recipient - The recipient address * @param quantity - The quantity of tokens to claim * @returns The claim id and success status */ claimWithCaptchaResponse({ captchaResponse, recipient, quantity, }: { captchaResponse: string; recipient: string; quantity: number; }): Promise<{ id: string; success: boolean; }>; /** * Requests an authorization token for a process. The captcha response is used to verify a human is solving the captcha. Once you have an authorization token, you can use it to claim tokens from the faucet via the claimWithAuthToken method. * @param captchaResponse - The captcha response * @returns The status of the request, the authorization token, and the expiration time */ requestAuthToken({ captchaResponse, }: { captchaResponse: string; }): Promise<{ status: 'success' | 'error'; token: string; expiresAt: number; }>; /** * Transfers tokens from the faucet wallet to a recipient address using an authorization token. To request an authorization token, solve the captcha from the captchaUrl method. * @param authToken - The authorization token * @param recipient - The recipient address * @param quantity - The quantity of tokens to claim * @returns The message id of the transfer and success status */ claimWithAuthToken({ authToken, recipient, quantity, }: { authToken: string; recipient: string; quantity: number; }): Promise<{ id: string; success: boolean; }>; /** * Verifies an authorization token is valid. * @param authToken - The authorization token * @returns The validity of the authorization token and the expiration time */ verifyAuthToken({ authToken }: { authToken: string; }): Promise<{ valid: boolean; expiresAt: number; }>; }