Skip to content

Commit

Permalink
Adding withdraw ETH from transfer gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardonunesp authored and enlight committed Aug 24, 2018
1 parent 881a693 commit f0df59f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/contracts/transfer-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Address } from '../address'
import {
TransferGatewayWithdrawERC721Request,
TransferGatewayWithdrawERC20Request,
TransferGatewayWithdrawETHRequest,
TransferGatewayWithdrawalReceiptRequest,
TransferGatewayWithdrawalReceiptResponse,
TransferGatewayWithdrawalReceipt,
Expand Down Expand Up @@ -137,6 +138,14 @@ export class TransferGateway extends Contract {
return this.callAsync<void>('WithdrawERC20', tgWithdrawERC20Req)
}

withdrawETHAsync(amount: BN, mainNetGateway: Address): Promise<void> {
const tgWithdrawETHReq = new TransferGatewayWithdrawETHRequest()
tgWithdrawETHReq.setAmount(marshalBigUIntPB(amount))
tgWithdrawETHReq.setMainnetGateway(mainNetGateway.MarshalPB())

return this.callAsync<void>('WithdrawETH', tgWithdrawETHReq)
}

async withdrawalReceiptAsync(owner: Address): Promise<IWithdrawalReceipt | null> {
const tgWithdrawReceiptReq = new TransferGatewayWithdrawalReceiptRequest()
tgWithdrawReceiptReq.setOwner(owner.MarshalPB())
Expand Down
7 changes: 7 additions & 0 deletions src/proto/transfer_gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ message TransferGatewayWithdrawERC20Request {
Address token_contract = 2;
}

message TransferGatewayWithdrawETHRequest {
// Amount of ETH to withdraw
BigUInt amount = 1;
// Address of Mainnet Gateway contract
Address mainnet_gateway = 2;
}

message TransferGatewayWithdrawalReceiptRequest {
Address owner = 1;
}
Expand Down
28 changes: 28 additions & 0 deletions src/proto/transfer_gateway_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,34 @@ export namespace TransferGatewayWithdrawERC20Request {
}
}

export class TransferGatewayWithdrawETHRequest extends jspb.Message {
hasAmount(): boolean;
clearAmount(): void;
getAmount(): proto_loom_pb.BigUInt | undefined;
setAmount(value?: proto_loom_pb.BigUInt): void;

hasMainnetGateway(): boolean;
clearMainnetGateway(): void;
getMainnetGateway(): proto_loom_pb.Address | undefined;
setMainnetGateway(value?: proto_loom_pb.Address): void;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): TransferGatewayWithdrawETHRequest.AsObject;
static toObject(includeInstance: boolean, msg: TransferGatewayWithdrawETHRequest): TransferGatewayWithdrawETHRequest.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: TransferGatewayWithdrawETHRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): TransferGatewayWithdrawETHRequest;
static deserializeBinaryFromReader(message: TransferGatewayWithdrawETHRequest, reader: jspb.BinaryReader): TransferGatewayWithdrawETHRequest;
}

export namespace TransferGatewayWithdrawETHRequest {
export type AsObject = {
amount?: proto_loom_pb.BigUInt.AsObject,
mainnetGateway?: proto_loom_pb.Address.AsObject,
}
}

export class TransferGatewayWithdrawalReceiptRequest extends jspb.Message {
hasOwner(): boolean;
clearOwner(): void;
Expand Down

0 comments on commit f0df59f

Please sign in to comment.