@dappykit/sdk
Version:
Web3 SDK for DApps
429 lines (428 loc) • 17.7 kB
TypeScript
import { INetworkConfig } from '../network-config';
import { HttpClient } from '../http-client/http-client';
import { ISigner } from '../service/delegated-fs/interfaces';
export interface IUserInfo {
nonce: number;
}
export interface IGeneralResponse {
status: string;
message?: string;
}
export interface ICreateResponse {
status: string;
requestId: number;
answer: number;
message?: string;
}
export interface IExistsResponse {
status: string;
isExists: boolean;
}
export interface IAddressesInfo {
/**
* User main address in the form of hex without 0x prefix
*/
userMainAddress: string;
/**
* Delegated address which created by 3rd party application for the user
*/
userDelegatedAddress: string;
/**
* Application address in the form of hex without 0x prefix
*/
applicationAddress: string;
}
export interface IGetProofResponse extends IAddressesInfo {
/**
* Status of the response
*/
status: string;
/**
* Authentication service proof in the form of hex without 0x prefix
*/
authServiceProof: string;
/**
* Proof signature from 3rd party service in the form of hex without 0x prefix
*/
serviceProof: string;
}
export interface ICallbackDataCheck extends IAddressesInfo {
/**
* Auth service proof signature
*/
proof: string;
/**
* Error message in case of failure
*/
errorMessage?: string;
}
export declare class FarcasterClient {
readonly config: INetworkConfig;
readonly httpClient: HttpClient;
constructor(config: INetworkConfig, httpClient: HttpClient);
/**
* Returns the URL of the Farcaster Auth Frame
*/
getAuthFrameUrl(): string;
/**
* Checks that FID authorized in the application
* @param fid FID of the user
* @param applicationAddress Address of the app signer
*/
isFidAuthorized(fid: number, applicationAddress: string): Promise<boolean>;
/**
* Creates an authorization request.
* @param messageBytesProof Proof of user's request to the app
* @param userDelegatedAddress Address of a signer created for a user. ETH address with 0x prefix.
* @param signer Service signer to sign the proof of the delegated address
*/
createAuthRequest(messageBytesProof: string, userDelegatedAddress: string, signer: ISigner): Promise<ICreateResponse>;
/**
* Gets the user info in the application.
* @param userAddress User address
* @param applicationAddress Application address
*/
getUserInfo(userAddress: string, applicationAddress: string): Promise<IUserInfo>;
/**
* Saves the user data in the application.
* @param userAddress User address
* @param applicationAddress Application address
* @param data Data to save
* @param authServiceProof Proof of the auth service to operate from delegated signer
* @param userDelegatedSigner Delegated signer of the user
*/
saveUserAppData(userAddress: string, applicationAddress: string, data: string, authServiceProof: string, userDelegatedSigner: ISigner): Promise<IGeneralResponse>;
/**
* Gets the user data in the application.
* @param userAddress User address
* @param applicationAddress Application address
*/
getDataByAddress(userAddress: string, applicationAddress: string): Promise<string>;
/**
* Gets the proof of the user's authorization.
* @param userAddress User address
* @param applicationAddress Application address
*/
getAuthProofByAddress(userAddress: string, applicationAddress: string): Promise<IGetProofResponse>;
/**
* Checks the callback data correctness.
* @param data Callback data
* @param expectedApplicationAddress Expected application address
* @param expectedAuthServiceAddress Expected auth service address
*/
checkCallbackData(data: ICallbackDataCheck, expectedApplicationAddress: string, expectedAuthServiceAddress: string): Promise<void>;
/**
* Gets the custody address of the FID.
* @param fid FID
* @param chain RPC URL
* @param contractAddress Contract address
*/
getCustodyAddress(fid: number, chain?: {
blockExplorers: {
readonly default: {
readonly name: "Optimism Explorer";
readonly url: "https://optimistic.etherscan.io";
readonly apiUrl: "https://api-optimistic.etherscan.io/api";
};
};
contracts: {
readonly disputeGameFactory: {
readonly 1: {
readonly address: "0xe5965Ab5962eDc7477C8520243A95517CD252fA9";
};
};
readonly l2OutputOracle: {
readonly 1: {
readonly address: "0xdfe97868233d1aa22e815a266982f2cf17685a27";
};
};
readonly multicall3: {
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
readonly blockCreated: 4286263;
};
readonly portal: {
readonly 1: {
readonly address: "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed";
};
};
readonly l1StandardBridge: {
readonly 1: {
readonly address: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1";
};
};
readonly gasPriceOracle: {
readonly address: "0x420000000000000000000000000000000000000F";
};
readonly l1Block: {
readonly address: "0x4200000000000000000000000000000000000015";
};
readonly l2CrossDomainMessenger: {
readonly address: "0x4200000000000000000000000000000000000007";
};
readonly l2Erc721Bridge: {
readonly address: "0x4200000000000000000000000000000000000014";
};
readonly l2StandardBridge: {
readonly address: "0x4200000000000000000000000000000000000010";
};
readonly l2ToL1MessagePasser: {
readonly address: "0x4200000000000000000000000000000000000016";
};
};
id: 10;
name: "OP Mainnet";
nativeCurrency: {
readonly name: "Ether";
readonly symbol: "ETH";
readonly decimals: 18;
};
rpcUrls: {
readonly default: {
readonly http: readonly ["https://mainnet.optimism.io"];
};
};
sourceId: 1;
testnet?: boolean | undefined;
custom?: Record<string, unknown> | undefined;
fees?: import("viem").ChainFees<undefined> | undefined;
formatters: {
readonly block: {
exclude: [] | undefined;
format: (args: import("viem/chains").OpStackRpcBlock) => {
baseFeePerGas: bigint | null;
blobGasUsed: bigint;
difficulty: bigint;
excessBlobGas: bigint;
extraData: import("viem").Hex;
gasLimit: bigint;
gasUsed: bigint;
hash: `0x${string}` | null;
logsBloom: `0x${string}` | null;
miner: import("viem").Address;
mixHash: import("viem").Hash;
nonce: `0x${string}` | null;
number: bigint | null;
parentBeaconBlockRoot?: import("viem").Hex | undefined;
parentHash: import("viem").Hash;
receiptsRoot: import("viem").Hex;
sealFields: import("viem").Hex[];
sha3Uncles: import("viem").Hash;
size: bigint;
stateRoot: import("viem").Hash;
timestamp: bigint;
totalDifficulty: bigint | null;
transactions: `0x${string}`[] | import("viem/chains").OpStackTransaction<boolean>[];
transactionsRoot: import("viem").Hash;
uncles: import("viem").Hash[];
withdrawals?: import("viem").Withdrawal[] | undefined;
withdrawalsRoot?: import("viem").Hex | undefined;
} & {};
type: "block";
};
readonly transaction: {
exclude: [] | undefined;
format: (args: import("viem/chains").OpStackRpcTransaction) => ({
blockHash: `0x${string}` | null;
blockNumber: bigint | null;
from: import("viem").Address;
gas: bigint;
hash: import("viem").Hash;
input: import("viem").Hex;
nonce: number;
r: import("viem").Hex;
s: import("viem").Hex;
to: import("viem").Address | null;
transactionIndex: number | null;
typeHex: import("viem").Hex | null;
v: bigint;
value: bigint;
yParity: number;
gasPrice?: undefined;
maxFeePerBlobGas?: undefined;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
isSystemTx?: boolean;
mint?: bigint | undefined;
sourceHash: import("viem").Hex;
type: "deposit";
} | {
r: import("viem").Hex;
s: import("viem").Hex;
v: bigint;
to: import("viem").Address | null;
from: import("viem").Address;
gas: bigint;
nonce: number;
value: bigint;
blockHash: `0x${string}` | null;
blockNumber: bigint | null;
hash: import("viem").Hash;
input: import("viem").Hex;
transactionIndex: number | null;
typeHex: import("viem").Hex | null;
accessList?: undefined;
authorizationList?: undefined;
blobVersionedHashes?: undefined;
chainId?: number | undefined;
yParity?: undefined;
type: "legacy";
gasPrice: bigint;
maxFeePerBlobGas?: undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
isSystemTx?: undefined;
mint?: undefined;
sourceHash?: undefined;
} | {
blockHash: `0x${string}` | null;
blockNumber: bigint | null;
from: import("viem").Address;
gas: bigint;
hash: import("viem").Hash;
input: import("viem").Hex;
nonce: number;
r: import("viem").Hex;
s: import("viem").Hex;
to: import("viem").Address | null;
transactionIndex: number | null;
typeHex: import("viem").Hex | null;
v: bigint;
value: bigint;
yParity: number;
accessList: import("viem").AccessList;
authorizationList?: undefined;
blobVersionedHashes?: undefined;
chainId: number;
type: "eip2930";
gasPrice: bigint;
maxFeePerBlobGas?: undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
isSystemTx?: undefined;
mint?: undefined;
sourceHash?: undefined;
} | {
blockHash: `0x${string}` | null;
blockNumber: bigint | null;
from: import("viem").Address;
gas: bigint;
hash: import("viem").Hash;
input: import("viem").Hex;
nonce: number;
r: import("viem").Hex;
s: import("viem").Hex;
to: import("viem").Address | null;
transactionIndex: number | null;
typeHex: import("viem").Hex | null;
v: bigint;
value: bigint;
yParity: number;
accessList: import("viem").AccessList;
authorizationList?: undefined;
blobVersionedHashes?: undefined;
chainId: number;
type: "eip1559";
gasPrice?: undefined;
maxFeePerBlobGas?: undefined;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
isSystemTx?: undefined;
mint?: undefined;
sourceHash?: undefined;
} | {
blockHash: `0x${string}` | null;
blockNumber: bigint | null;
from: import("viem").Address;
gas: bigint;
hash: import("viem").Hash;
input: import("viem").Hex;
nonce: number;
r: import("viem").Hex;
s: import("viem").Hex;
to: import("viem").Address | null;
transactionIndex: number | null;
typeHex: import("viem").Hex | null;
v: bigint;
value: bigint;
yParity: number;
accessList: import("viem").AccessList;
authorizationList?: undefined;
blobVersionedHashes: readonly import("viem").Hex[];
chainId: number;
type: "eip4844";
gasPrice?: undefined;
maxFeePerBlobGas: bigint;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
isSystemTx?: undefined;
mint?: undefined;
sourceHash?: undefined;
} | {
blockHash: `0x${string}` | null;
blockNumber: bigint | null;
from: import("viem").Address;
gas: bigint;
hash: import("viem").Hash;
input: import("viem").Hex;
nonce: number;
r: import("viem").Hex;
s: import("viem").Hex;
to: import("viem").Address | null;
transactionIndex: number | null;
typeHex: import("viem").Hex | null;
v: bigint;
value: bigint;
yParity: number;
accessList: import("viem").AccessList;
authorizationList: import("viem/experimental").SignedAuthorizationList;
blobVersionedHashes?: undefined;
chainId: number;
type: "eip7702";
gasPrice?: undefined;
maxFeePerBlobGas?: undefined;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
isSystemTx?: undefined;
mint?: undefined;
sourceHash?: undefined;
}) & {};
type: "transaction";
};
readonly transactionReceipt: {
exclude: [] | undefined;
format: (args: import("viem/chains").OpStackRpcTransactionReceipt) => {
blobGasPrice?: bigint | undefined;
blobGasUsed?: bigint | undefined;
blockHash: import("viem").Hash;
blockNumber: bigint;
contractAddress: import("viem").Address | null | undefined;
cumulativeGasUsed: bigint;
effectiveGasPrice: bigint;
from: import("viem").Address;
gasUsed: bigint;
logs: import("viem").Log<bigint, number, false>[];
logsBloom: import("viem").Hex;
root?: import("viem").Hash | undefined;
status: "success" | "reverted";
to: import("viem").Address | null;
transactionHash: import("viem").Hash;
transactionIndex: number;
type: import("viem").TransactionType;
l1GasPrice: bigint | null;
l1GasUsed: bigint | null;
l1Fee: bigint | null;
l1FeeScalar: number | null;
} & {};
type: "transactionReceipt";
};
};
serializers: {
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
};
}, contractAddress?: string): Promise<string>;
/**
* Checks if the app with the address already exists.
* @param applicationAddress Application address
*/
applicationExists(applicationAddress: string): Promise<boolean>;
}