-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
2,297 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @export ChainId */ | ||
export declare enum ChainId { | ||
MAINNET = "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { PrivateTxState, PrivateTxStatus } from './privateTransaction'; | ||
import { ChainId } from './ChainId'; | ||
/** | ||
* @export | ||
* @interface SerializableTransactionReceipt | ||
*/ | ||
export interface SerializableTransactionReceipt { | ||
to: string; | ||
from: string; | ||
contractAddress: string; | ||
transactionIndex: number; | ||
blockHash: string; | ||
transactionHash: string; | ||
blockNumber: number; | ||
status?: number; | ||
} | ||
export declare const addTransaction: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{ | ||
chainId: ChainId; | ||
hash: string; | ||
from: string; | ||
approval?: { | ||
tokenAddress: string; | ||
spender: string; | ||
}; | ||
claim?: { | ||
recipient: string; | ||
}; | ||
summary?: string; | ||
}, string>; | ||
export declare const clearAllTransactions: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{ | ||
chainId: ChainId; | ||
}, string>; | ||
export declare const finalizeTransaction: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{ | ||
chainId: ChainId; | ||
hash: string; | ||
receipt: SerializableTransactionReceipt; | ||
}, string>; | ||
export declare const checkedTransaction: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{ | ||
chainId: ChainId; | ||
hash: string; | ||
blockNumber: number; | ||
}, string>; | ||
export declare const updatePrivateTxStatus: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{ | ||
chainId: ChainId; | ||
hash: string; | ||
status: PrivateTxStatus; | ||
}, string>; | ||
/** | ||
* @export | ||
* @interface TransactionDetails | ||
*/ | ||
export interface TransactionDetails { | ||
hash: string; | ||
approval?: { | ||
tokenAddress: string; | ||
spender: string; | ||
}; | ||
summary?: string; | ||
claim?: { | ||
recipient: string; | ||
}; | ||
receipt?: SerializableTransactionReceipt; | ||
lastCheckedBlockNumber?: number; | ||
addedTime: number; | ||
confirmedTime?: number; | ||
from: string; | ||
privateTx?: { | ||
state: PrivateTxState; | ||
status?: PrivateTxStatus; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export * from './ChainId'; | ||
export * from './actions'; | ||
export * from './isTransactionState'; | ||
export * from './privateTransaction'; | ||
import * as Reducer from './reducer'; | ||
export { Reducer }; | ||
export * from './transaction'; | ||
/** | ||
TODO | ||
import * as ChainId from './ChainId'; | ||
import { | ||
addTransaction, | ||
checkedTransaction, | ||
clearAllTransactions, | ||
finalizeTransaction, | ||
SerializableTransactionReceipt, | ||
updatePrivateTxStatus, | ||
} from './actions'; | ||
import * as Actions from './actions'; | ||
import * as PrivateTransaction from './privateTransaction'; | ||
import * as Reducer from './reducer'; | ||
import * as Transaction from './transaction'; | ||
export { | ||
ChainId, | ||
Actions, | ||
PrivateTransaction, | ||
Reducer, | ||
Transaction, | ||
addTransaction, | ||
checkedTransaction, | ||
clearAllTransactions, | ||
finalizeTransaction, | ||
SerializableTransactionReceipt, | ||
updatePrivateTxStatus, | ||
}; | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* | ||
* @class PrivateTransaction | ||
* @license GPL-3.0-Only | ||
* @see {@link https://docs.manifoldfinance.com} | ||
* @since 2022.03 | ||
* @version 0.1.0 | ||
* | ||
*/ | ||
import { TransactionDetails } from './reducer'; | ||
/** | ||
* @summary | ||
* Basic explanation of the tx state types: | ||
* UNCHECKED -> Tx status has not been checked and there's no information about it. | ||
* PROCESSING -> Tx checks are in place until a resolution happens: OK, INDETERMINATE, ERROR. | ||
* OK -> Relay received the Tx && all downstream miners accepted without complains && tx mined successfully | ||
* INDETERMINATE -> Relay received correctly the Tx && at least one miner accepted the TX && TX potentially mineable | ||
* ERROR -> Relay haven't received the TX || none of the miners accepted the Tx || Tx was not mined successfully | ||
*/ | ||
/** | ||
* | ||
* @export | ||
* @param {TransactionDetails} [tx] | ||
* @return {boolean} | ||
*/ | ||
export declare function isTxPending(tx?: TransactionDetails): boolean; | ||
/** | ||
* | ||
* @export | ||
* @param {TransactionDetails} [tx] | ||
* @return {boolean} | ||
*/ | ||
export declare function isTxSuccessful(tx?: TransactionDetails): boolean; | ||
/** | ||
* | ||
* @export | ||
* @param {TransactionDetails} [tx] | ||
* @return {boolean} | ||
*/ | ||
export declare function isTxIndeterminate(tx?: TransactionDetails): boolean; | ||
/** | ||
* | ||
* @export | ||
* @param {TransactionDetails} [tx] | ||
* @return {number} | ||
*/ | ||
export declare function txMinutesPending(tx?: TransactionDetails): number; | ||
/** | ||
* | ||
* | ||
* @export | ||
* @param {TransactionDetails} [tx] | ||
* @return {boolean} | ||
*/ | ||
export declare function isTxExpired(tx?: TransactionDetails): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { JsonRpcResponse } from '../jsonrpc'; | ||
/** | ||
* @enum PrivateTxState | ||
* @interface PrivateTxStatus | ||
* @interface RelayResponse | ||
* @description Transaction State Types | ||
* | ||
* - UNCHECKED -> Tx status has not been checked and there's no information about it. | ||
* - PROCESSING -> Tx checks are in place until a resolution happens: OK, INDETERMINATE, ERROR. | ||
* - OK -> Relay received the Tx && all downstream miners accepted without complains && tx mined successfully | ||
* - INDETERMINATE -> Relay received correctly the Tx && at least one miner accepted the TX && TX potentially mineable | ||
* - ERROR -> Relay haven't received the TX || none of the miners accepted the Tx || Tx was not mined successfully | ||
* | ||
/** | ||
* | ||
* | ||
* @export | ||
* @enum {number} | ||
*/ | ||
export declare enum PrivateTxState { | ||
UNCHECKED = "UNCHECKED", | ||
PROCESSING = "PROCESSING", | ||
OK = "OK", | ||
INDETERMINATE = "INDETERMINATE", | ||
ERROR = "ERROR" | ||
} | ||
/** @type RelayResponses */ | ||
export declare type RelayResponses = Record<string, RelayResponse>; | ||
/** | ||
* | ||
* @export | ||
* @interface RelayResponse | ||
*/ | ||
export interface RelayResponse { | ||
response: JsonRpcResponse<any>; | ||
error?: string; | ||
} | ||
/** | ||
* | ||
* @export | ||
* @interface PrivateTxStatus | ||
*/ | ||
export interface PrivateTxStatus { | ||
transactionHash: string; | ||
receivedAt: string; | ||
relayedAt?: string; | ||
minedAt?: string; | ||
relayFailure?: boolean; | ||
relayResponses?: RelayResponses; | ||
} | ||
/** | ||
* | ||
* | ||
* @export | ||
* @param {*} privateTx | ||
* @return {*} | ||
*/ | ||
export declare function privateTx(privateTx: any): any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* | ||
* @filename Redux Reducer | ||
* | ||
*/ | ||
import { ChainId } from './ChainId'; | ||
import { PrivateTxState, PrivateTxStatus } from './privateTransaction'; | ||
import { SerializableTransactionReceipt } from './actions'; | ||
export interface TransactionDetails { | ||
hash: string; | ||
approval?: { | ||
tokenAddress: string; | ||
spender: string; | ||
}; | ||
summary?: string; | ||
claim?: { | ||
recipient: string; | ||
}; | ||
receipt?: SerializableTransactionReceipt; | ||
lastCheckedBlockNumber?: number; | ||
addedTime: number; | ||
confirmedTime?: number; | ||
from: string; | ||
privateTx?: { | ||
state: PrivateTxState; | ||
status?: PrivateTxStatus; | ||
}; | ||
} | ||
declare type txHash = string; | ||
export declare type TransactionState = { | ||
[key in ChainId]?: Record<txHash, TransactionDetails>; | ||
}; | ||
export declare const initialState: TransactionState; | ||
declare const _default: import("@reduxjs/toolkit/dist/createReducer").ReducerWithInitialState<TransactionState>; | ||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @package OpenMev Transaction | ||
*/ | ||
/** | ||
* @exports PrivateTransaction | ||
*/ | ||
import * as PrivateTransaction from './privateTransaction'; | ||
export { PrivateTransaction }; | ||
/** | ||
* @exports isTxState | ||
*/ | ||
import { isTxIndeterminate, isTxPending, isTxSuccessful, txMinutesPending } from './isTransactionState'; | ||
export { isTxIndeterminate, isTxPending, isTxSuccessful, txMinutesPending }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './rpc'; | ||
export * from './transaction'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Error subclass implementing JSON RPC 2.0 errors and Ethereum RPC errors per EIP-1474. | ||
* @see https://eips.ethereum.org/EIPS/eip-1474 | ||
*/ | ||
export declare class RpcError<T = undefined> extends Error { | ||
readonly code: number; | ||
readonly data?: T; | ||
readonly internal?: unknown; | ||
constructor( | ||
/** Number error code */ | ||
code: number, | ||
/** Human-readable string */ | ||
message: string, | ||
/** Low-level error */ | ||
internal?: unknown, | ||
/** Other useful information about error */ | ||
data?: T); | ||
} | ||
/** | ||
* Error subclass implementing Ethereum Provider errors per EIP-1193. | ||
* @see https://eips.ethereum.org/EIPS/eip-1193 | ||
*/ | ||
export declare class ProviderRpcError<T = undefined> extends RpcError<T> { | ||
/** | ||
* Create an Ethereum Provider JSON-RPC error. | ||
* `code` must be an integer in the 1000 <= 4999 range. | ||
*/ | ||
constructor( | ||
/** | ||
* Number error code | ||
* @see https://eips.ethereum.org/EIPS/eip-1193#error-standards | ||
*/ | ||
code: 4001 | 4100 | 4200 | 4900 | 4901 | 4902, | ||
/** Human-readable string */ | ||
message: string, | ||
/** Low-level error */ | ||
internal?: unknown, | ||
/** Other useful information about error */ | ||
data?: T); | ||
} | ||
export declare class AddChainError extends Error { | ||
name: string; | ||
message: string; | ||
} | ||
export declare class ChainNotConfiguredError extends Error { | ||
name: string; | ||
message: string; | ||
} | ||
export declare class ConnectorAlreadyConnectedError extends Error { | ||
name: string; | ||
message: string; | ||
} | ||
export declare class ConnectorNotFoundError extends Error { | ||
name: string; | ||
message: string; | ||
} | ||
export declare class SwitchChainError extends ProviderRpcError { | ||
name: string; | ||
constructor(error: unknown); | ||
} | ||
export declare class SwitchChainNotSupportedError extends Error { | ||
name: string; | ||
message: string; | ||
} | ||
export declare class UserRejectedRequestError extends ProviderRpcError { | ||
name: string; | ||
constructor(error: unknown); | ||
} | ||
export declare class ResourceUnavailableError extends RpcError { | ||
name: string; | ||
constructor(error: unknown); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
@export stderrors | ||
@note github.com/WalletConnect/walletconnect-utils/blob/master/jsonrpc/utils/src/constants.ts | ||
*/ | ||
export declare const PARSE_ERROR = "PARSE_ERROR"; | ||
export declare const INVALID_REQUEST = "INVALID_REQUEST"; | ||
export declare const METHOD_NOT_FOUND = "METHOD_NOT_FOUND"; | ||
export declare const INVALID_PARAMS = "INVALID_PARAMS"; | ||
export declare const INTERNAL_ERROR = "INTERNAL_ERROR"; | ||
export declare const SERVER_ERROR = "SERVER_ERROR"; | ||
export declare const RESERVED_ERROR_CODES: number[]; | ||
export declare const SERVER_ERROR_CODE_RANGE: number[]; | ||
export declare const STANDARD_ERROR_MAP: { | ||
PARSE_ERROR: { | ||
code: number; | ||
message: string; | ||
}; | ||
INVALID_REQUEST: { | ||
code: number; | ||
message: string; | ||
}; | ||
METHOD_NOT_FOUND: { | ||
code: number; | ||
message: string; | ||
}; | ||
INVALID_PARAMS: { | ||
code: number; | ||
message: string; | ||
}; | ||
INTERNAL_ERROR: { | ||
code: number; | ||
message: string; | ||
}; | ||
SERVER_ERROR: { | ||
code: number; | ||
message: string; | ||
}; | ||
}; |
Oops, something went wrong.