Skip to content

Commit

Permalink
Refactor types.ts file and update AccountIdentity name to shortName (#…
Browse files Browse the repository at this point in the history
…161)

* Refactor types.ts file

* Update AccountIdentity name to shortName
  • Loading branch information
Rudy-Perrin authored Nov 29, 2023
1 parent 8e2ad0e commit 47f0b9a
Showing 1 changed file with 78 additions and 74 deletions.
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;
};

0 comments on commit 47f0b9a

Please sign in to comment.