RebelfiError
class RebelfiError extends Error {
constructor(
message: string,
public readonly statusCode: number,
public readonly code?: ErrorCode | string,
public readonly details?: Record<string, unknown>
);
/** Check if error matches a specific code */
is(code: ErrorCode): boolean;
}
Usage
import { RebelfiError, ErrorCode } from '@rebelfi/sdk';
try {
await client.operations.supply(request);
} catch (error) {
if (error instanceof RebelfiError) {
if (error.is(ErrorCode.INSUFFICIENT_BALANCE)) {
console.error('Available:', error.details?.available);
}
}
}
ErrorCode Enum
enum ErrorCode {
// Validation
INVALID_AMOUNT = 'INVALID_AMOUNT',
INVALID_ADDRESS = 'INVALID_ADDRESS',
INVALID_TOKEN = 'INVALID_TOKEN',
// Business logic
INSUFFICIENT_BALANCE = 'INSUFFICIENT_BALANCE',
STRATEGY_NOT_ACTIVE = 'STRATEGY_NOT_ACTIVE',
ALLOCATION_NOT_FOUND = 'ALLOCATION_NOT_FOUND',
OPERATION_EXPIRED = 'OPERATION_EXPIRED',
OPERATION_ALREADY_SUBMITTED = 'OPERATION_ALREADY_SUBMITTED',
TOKEN_MISMATCH = 'TOKEN_MISMATCH',
INVALID_OPERATION_STATUS = 'INVALID_OPERATION_STATUS',
OPERATION_IN_PROGRESS = 'OPERATION_IN_PROGRESS',
TRANSACTION_MISMATCH = 'TRANSACTION_MISMATCH', // 1.4.5
WALLET_NOT_VERIFIED = 'WALLET_NOT_VERIFIED',
// Proof of control
CHALLENGE_EXPIRED = 'CHALLENGE_EXPIRED',
CHALLENGE_USED = 'CHALLENGE_USED',
CHALLENGE_MISMATCH = 'CHALLENGE_MISMATCH',
INVALID_SIGNATURE = 'INVALID_SIGNATURE',
ADDRESS_NOT_CLAIMABLE = 'ADDRESS_NOT_CLAIMABLE',
// Client accounts
CLIENT_ACCOUNTS_NOT_ENABLED = 'CLIENT_ACCOUNTS_NOT_ENABLED',
ACCOUNT_REFERENCE_CONFLICT = 'ACCOUNT_REFERENCE_CONFLICT',
CONTACT_EMAIL_UNAVAILABLE = 'CONTACT_EMAIL_UNAVAILABLE',
ACCOUNT_ALREADY_ACTIVE = 'ACCOUNT_ALREADY_ACTIVE',
ACTIVATION_LINK_USED = 'ACTIVATION_LINK_USED',
USER_ID_NOT_ALLOWED = 'USER_ID_NOT_ALLOWED',
WALLET_LINKED_TO_ANOTHER_ACCOUNT = 'WALLET_LINKED_TO_ANOTHER_ACCOUNT',
CLIENT_ACCOUNT_REQUIRED = 'CLIENT_ACCOUNT_REQUIRED',
CLIENT_ACCOUNT_NOT_ACTIVE = 'CLIENT_ACCOUNT_NOT_ACTIVE',
// Resources
VENUE_NOT_FOUND = 'VENUE_NOT_FOUND',
STRATEGY_NOT_FOUND = 'STRATEGY_NOT_FOUND',
OPERATION_NOT_FOUND = 'OPERATION_NOT_FOUND',
TRANSACTION_NOT_FOUND = 'TRANSACTION_NOT_FOUND',
WALLET_NOT_FOUND = 'WALLET_NOT_FOUND',
ORGANIZATION_NOT_FOUND = 'ORGANIZATION_NOT_FOUND',
TOKEN_NOT_FOUND = 'TOKEN_NOT_FOUND',
ACCOUNT_NOT_FOUND = 'ACCOUNT_NOT_FOUND',
// Simulation
INSUFFICIENT_GAS = 'INSUFFICIENT_GAS',
SIMULATION_FAILED = 'SIMULATION_FAILED',
// Client
INVALID_API_KEY = 'INVALID_API_KEY',
API_KEY_DISABLED = 'API_KEY_DISABLED',
API_KEY_ADDRESS_NOT_ALLOWED = 'API_KEY_ADDRESS_NOT_ALLOWED',
API_KEY_EXPIRED = 'API_KEY_EXPIRED',
ORGANIZATION_PENDING_APPROVAL = 'ORGANIZATION_PENDING_APPROVAL',
ORGANIZATION_SUSPENDED = 'ORGANIZATION_SUSPENDED',
FORBIDDEN = 'FORBIDDEN',
VALIDATION_FAILED = 'VALIDATION_FAILED',
RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED',
INTERNAL_ERROR = 'INTERNAL_ERROR', // 1.4.5
TIMEOUT = 'TIMEOUT',
NETWORK_ERROR = 'NETWORK_ERROR',
UNKNOWN_ERROR = 'UNKNOWN_ERROR',
}
Operation codes
| Code | HTTP | Meaning |
|---|---|---|
OPERATION_EXPIRED | 400 | The operation passed its five-minute signing deadline. getUnsignedTransactions() and submitSigned() refuse it; nothing was broadcast. error.details: { operationId, expiresAt? }. If a submitSigned() returned resubmitSameTransaction: true, or you reported a hash, the operation stays live until RebelFi sees whether that transaction landed: poll operations.get() until it leaves AWAITING_SIGNATURE before planning again (a plan meanwhile gets OPERATION_IN_PROGRESS) |
OPERATION_IN_PROGRESS | 400 | supply() / unwind(): the wallet has a live operation this API key may not replace (awaiting approval, under way, another key’s or user’s plan awaiting signature, or a plan whose transaction may still land). error.details: { operationId, walletId, status, expiresAt? }. Wait for it, or cancel it by operationId |
TRANSACTION_MISMATCH | 400 | submitSigned() / submitHash(): not the transaction planned for the operation. Nothing was broadcast or recorded. error.details: { operationId } |
OPERATION_ALREADY_SUBMITTED | 409 | submitSigned(): another signed transaction for this transaction is in flight or recorded. Nothing was broadcast. error.details: { operationId, transactionId } |
OPERATION_ALREADY_SUBMITTED | 400 | submitSigned(): the broadcast failed. error.details: { operationId, resubmitSameTransaction }. true: resubmit the same signed transaction, don’t sign again. false: the node refused it; sign again |
INVALID_OPERATION_STATUS | 400 | cancel(): a transaction of the operation was already submitted, or it is confirmed |
INTERNAL_ERROR | 503 | submitSigned(): the transaction could not be checked against the plan right now. Nothing was broadcast; retry the same bytes |
import { RebelfiError, ErrorCode } from '@rebelfi/sdk';
try {
await client.transactions.submitSigned({ operationId, signedTransaction });
} catch (error) {
if (error instanceof RebelfiError && error.is(ErrorCode.OPERATION_ALREADY_SUBMITTED)) {
if (error.statusCode === 409) {
// Another signature is in flight: resubmit that one, or check the operation before signing again
} else if (error.details?.resubmitSameTransaction === true) {
// May have reached the network: resubmit the same signedTransaction
} else {
// Refused by the node: fetch fresh unsigned transactions and sign again
}
}
}
Proof of control codes
| Code | HTTP | Meaning |
|---|---|---|
WALLET_NOT_VERIFIED | 403 | The wallet is watch-only. Supply, Unwind and Transfer Out are refused until you prove control with wallets.verify(). error.details.orgWalletId is the wallet. |
CHALLENGE_EXPIRED | 410 | The challenge expired. Request a new one. |
CHALLENGE_USED | 409 | The challenge was already used. Request a new one. |
CHALLENGE_MISMATCH | 400 | Unknown challenge, or one issued for another wallet address or chain. |
INVALID_SIGNATURE | 400 | The signature isn’t the address’s signature of the challenge message. The challenge is used up. |
ADDRESS_NOT_CLAIMABLE | 409 | The proof is valid, but another organization has already proven control of the address. Contact support. |
Client account codes
For organizations that open client accounts.| Code | HTTP | Meaning |
|---|---|---|
CLIENT_ACCOUNTS_NOT_ENABLED | 403 | Your organization doesn’t open client accounts. Contact RebelFi. |
ACCOUNT_NOT_FOUND | 404 | No client account with this ID in your organization. |
ACCOUNT_REFERENCE_CONFLICT | 409 | accounts.create(): the reference already names an account with another contact email. |
CONTACT_EMAIL_UNAVAILABLE | 409 | accounts.create(): the contact email already belongs to a RebelFi user or another client account. |
ACCOUNT_ALREADY_ACTIVE | 409 | accounts.resendActivation(): the account is no longer pending activation. |
ACTIVATION_LINK_USED | 409 | accounts.resendActivation(): the contact already used the link. They finish by signing in to the portal. |
USER_ID_NOT_ALLOWED | 400 | wallets.register() or wallets.update() with userId. Send accountId instead. |
WALLET_LINKED_TO_ANOTHER_ACCOUNT | 409 | The wallet is already linked to another account. error.details: { walletId, accountId, linkedAccountId }. |
CLIENT_ACCOUNT_REQUIRED | 403 | Supply refused: the wallet is linked to no client account. error.details.orgWalletId. |
CLIENT_ACCOUNT_NOT_ACTIVE | 403 | Supply refused: the account is PENDING_ACTIVATION or SUSPENDED. error.details: { orgWalletId, accountId, status }. Unwind is never refused for account status. |
TransactionFailureCode Enum
enum TransactionFailureCode {
REVERTED = 'REVERTED',
OUT_OF_GAS = 'OUT_OF_GAS',
TIMEOUT = 'TIMEOUT',
NONCE_TOO_LOW = 'NONCE_TOO_LOW',
INSUFFICIENT_FUNDS = 'INSUFFICIENT_FUNDS',
REPLACED = 'REPLACED',
DROPPED = 'DROPPED',
UNKNOWN = 'UNKNOWN',
}