xplore-grpc-web-client
Generated gRPC-web client for Xplore, providing TypeScript definitions and client implementations for the Xplore Aggregator service.
Installation
npm install xplore-grpc-web-client
Usage
Basic Example
import { AggregatorClient } from "xplore-grpc-web-client/aggregator_pb_service";
import {
XploreRequest,
ChainToken,
} from "xplore-grpc-web-client/aggregator_pb";
const client = new AggregatorClient("https://your-grpc-web-server.com");
const request = new XploreRequest();
const inputToken = new ChainToken();
inputToken.setChainId("chain-1");
inputToken.setAddress("0x123...");
request.setInputToken(inputToken);
client.aggregateCall(request, {}, (err, response) => {
if (err) {
console.error(err);
return;
}
console.log(response.toObject());
});
Transaction Record Example
import { AggregatorClient } from "xplore-grpc-web-client/aggregator_pb_service";
import { TransactionRecordRequest } from "xplore-grpc-web-client/aggregator_pb";
const client = new AggregatorClient("https://your-grpc-web-server.com");
const request = new TransactionRecordRequest();
request.setTransactionHash("0xabcdef...");
client.getTransactionRecord(request, {}, (err, record) => {
if (err) {
console.error(err);
return;
}
console.log(record.toObject());
});
API Reference
Services
AggregatorClient
Client for the Aggregator service.
Methods:
aggregateCall(request: XploreRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: XploreResponse | null) => void): grpc.ClientUnaryCall
getTransactionRecord(request: TransactionRecordRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: TransactionRecord | null) => void): grpc.ClientUnaryCall
Messages
XploreRequest
Request for the AggregateCall method.
Properties:
inputToken: ChainToken
outputToken: ChainToken
amountIn: string
amountOutMin: string
slippageTolerancePercent: number
recipientAddress: string
senderAddress: string
exactOut: boolean
timeoutMs: number
generateDepositAddress: boolean
allowedNodes: string[]
XploreResponse
Response from the AggregateCall method.
Properties:
amountIn: string
amountOut: string
priceImpact: number
route: RouteStep[]
executionTime: number
gasEstimate: number
depositAddress: string
value: string
transactionData: TransactionData
ChainToken
Represents a token on a specific chain.
Properties:
chainId: string
address: string
isNative: boolean
License
MIT