github.com/ava-labs/avalanchego@v1.11.11/vms/platformvm/warp/gwarp/client.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package gwarp 5 6 import ( 7 "context" 8 9 "github.com/ava-labs/avalanchego/vms/platformvm/warp" 10 11 pb "github.com/ava-labs/avalanchego/proto/pb/warp" 12 ) 13 14 var _ warp.Signer = (*Client)(nil) 15 16 type Client struct { 17 client pb.SignerClient 18 } 19 20 func NewClient(client pb.SignerClient) *Client { 21 return &Client{client: client} 22 } 23 24 func (c *Client) Sign(unsignedMsg *warp.UnsignedMessage) ([]byte, error) { 25 resp, err := c.client.Sign(context.Background(), &pb.SignRequest{ 26 NetworkId: unsignedMsg.NetworkID, 27 SourceChainId: unsignedMsg.SourceChainID[:], 28 Payload: unsignedMsg.Payload, 29 }) 30 if err != nil { 31 return nil, err 32 } 33 return resp.Signature, nil 34 }