Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor types.ts file and update AccountIdentity name to shortName #161

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 78 additions & 74 deletions src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,111 +1,115 @@
import { TransactionFee, TransactionRPC } from '../types'
import { TransactionFee, TransactionRPC } from "../types";

export type NodeRpcMethods = {
contract_fun(params: {
contract: string,
function: string,
args?: any[]
}): any,
estimate_transaction_fee(params: EstimateTransactionFeeRequest): TransactionFee,
send_transaction(params: SendTransactionRequest): SendTransactionResponse,
simulate_contract_execution(params: SimulateContractExecutionRequest): SimulateContractExecutionResponse[],
add_origin_key(params: AddOriginKeyRequest): AddOriginKeyResponse
}
contract_fun(params: {
contract: string;
function: string;
args?: any[];
}): any;
estimate_transaction_fee(
params: EstimateTransactionFeeRequest
): TransactionFee;
send_transaction(params: SendTransactionRequest): SendTransactionResponse;
simulate_contract_execution(
params: SimulateContractExecutionRequest
): SimulateContractExecutionResponse[];
add_origin_key(params: AddOriginKeyRequest): AddOriginKeyResponse;
};

export type AddOriginKeyRequest = {
certificate: string,
origin_public_key: string,
}
certificate: string;
origin_public_key: string;
};

export type AddOriginKeyResponse = {
transaction_address: string,
status: string
}
transaction_address: string;
status: string;
};

export type EstimateTransactionFeeRequest = {
transaction: TransactionRPC
}
transaction: TransactionRPC;
};

export type SendTransactionRequest = {
transaction: TransactionRPC
}
transaction: TransactionRPC;
};

export type SendTransactionResponse = {
transaction_address: string,
status: string
}
transaction_address: string;
status: string;
};

export type SimulateContractExecutionRequest = {
transaction: TransactionRPC
}
transaction: TransactionRPC;
};

export type SimulateContractExecutionResponse = {
recipient_address: string,
valid: boolean,
error?: string
}
recipient_address: string;
valid: boolean;
error?: string;
};

export enum ConnectionState {
Closed = 'WalletRPCConnection_closed',
Closing = 'WalletRPCConnection_closing',
Connecting = 'WalletRPCConnection_connecting',
Open = 'WalletRPCConnection_open',
Closed = "WalletRPCConnection_closed",
Closing = "WalletRPCConnection_closing",
Connecting = "WalletRPCConnection_connecting",
Open = "WalletRPCConnection_open",
}
export enum RpcErrorCode {
UnsupportedMethod = -32601,
Timeout = 5001,
Connectivity = 4901,
ConsensusNotReached = 5002,
InvalidParams = -32602,
InvalidTransaction = 5003,
InvalidConfirmation = 5006,
InsufficientFunds = 5004,
ServiceNotFound = 5007,
UserRejected = 4001,
UnknownAccount = 5005,
Other = 5000,
UnsupportedMethod = -32601,
Timeout = 5001,
Connectivity = 4901,
ConsensusNotReached = 5002,
InvalidParams = -32602,
InvalidTransaction = 5003,
InvalidConfirmation = 5006,
InsufficientFunds = 5004,
ServiceNotFound = 5007,
UserRejected = 4001,
UnknownAccount = 5005,
Other = 5000,
}

export type RpcSubscription = {
id: string;
eventListener: EventListenerOrEventListenerObject;
}
id: string;
eventListener: EventListenerOrEventListenerObject;
};

export type RpcNotification = {
subscriptionId: string;
data: Object;
}
subscriptionId: string;
data: Object;
};

export type RpcRequestOrigin = {
name: string;
url?: string;
logo?: string;
}
name: string;
url?: string;
logo?: string;
};

export type RpcRequest = {
origin: RpcRequestOrigin;
version: number;
payload: Object;
}
origin: RpcRequestOrigin;
version: number;
payload: Object;
};

export type Endpoint = {
endpointUrl: string;
}
endpointUrl: string;
};

export type AccountIdentity = {
name: string;
genesisAddress: string;
}
shortName: string;
genesisAddress: string;
};

export type TransactionSuccess = {
transactionAddress: string,
nbConfirmations: number,
maxConfirmations: number,
}
transactionAddress: string;
nbConfirmations: number;
maxConfirmations: number;
};

export type SignedTransaction = {
address: string,
previousPublicKey: string,
previousSignature: string,
originSignature: string
}
address: string;
previousPublicKey: string;
previousSignature: string;
originSignature: string;
};
Loading