Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

ComposableFi/cBridge-typescript-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cBridge-typescript-client

cBridge provides a simple liquidity provider experience and high liquidity efficiency for users when they manage their funds in different chains with lower costs. known more about flow and terminology from this doc

cBridge requirements

Client folders

proto: .d.ts protobuf. using grpc-web to do the gateway communication.

contract: cBridge contract.

Quick Start

Install grpc-web

https://github.com/grpc/grpc-web

install gprc-web with yarn or npm

yarn install

yarn add grpc-web

npm install

npm install grpc-web

gRPC-web Refund request example

testnet url: https://cbridge-v2-test.celer.network

  1. imports
// import reqquest, response and reletive messages
import {
  WithdrawReq,
  WithdrawLq,
  WithdrawType
} from "../../proto/sgn/cbridge/v1/tx_pb";

// import grpc-web WebClient
import { WebClient } from "../proto/sgn/gateway/v1/GatewayServiceClientPb";
  1. rpc with grpc-web client
// construct request
const bytes = ethers.utils.arrayify(sig);
const req = new WithdrawLiquidityRequest();
req.setWithdrawReq(withdrawReqProto.serializeBinary());
req.setSig(bytes);
req.setEstimatedReceivedAmt(estimatedAmount);
req.setMethodType(WithdrawMethodType.WD_METHOD_TYPE_ONE_RM);

// rpc calling with gprc-web client

const client = new WebClient(`${process.env.CBRIDEGE_TESTNET_URL}`, null, null);
client.withdrawLiquidity(req, null)

About

cBridge gateway typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 90.8%
  • TypeScript 9.2%