mirror of
https://github.com/luxfi/vm.git
synced 2026-10-30 15:13:40 +00:00
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
//go:build grpc
|
|
|
|
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package dag
|
|
|
|
import (
|
|
pwarp "github.com/luxfi/proto/p/warp"
|
|
"github.com/luxfi/warp"
|
|
)
|
|
|
|
// protocolWarpSignerAdapter wraps a warp.Signer (from github.com/luxfi/warp)
|
|
// and adapts it to protocol/p/warp.Signer interface.
|
|
type protocolWarpSignerAdapter struct {
|
|
inner warp.Signer
|
|
}
|
|
|
|
// newProtocolWarpSignerAdapter creates an adapter that wraps a warp.Signer
|
|
// to satisfy protocol/p/warp.Signer.
|
|
func newProtocolWarpSignerAdapter(signer warp.Signer) pwarp.Signer {
|
|
if signer == nil {
|
|
return nil
|
|
}
|
|
return &protocolWarpSignerAdapter{inner: signer}
|
|
}
|
|
|
|
// Sign implements protocol/p/warp.Signer by converting the UnsignedMessage
|
|
// from protocol/p/warp to warp format and delegating to the inner signer.
|
|
func (a *protocolWarpSignerAdapter) Sign(msg *pwarp.UnsignedMessage) ([]byte, error) {
|
|
innerMsg, err := warp.NewUnsignedMessage(
|
|
msg.NetworkID,
|
|
msg.SourceChainID,
|
|
msg.Payload,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return a.inner.Sign(innerMsg)
|
|
}
|