@@ -10,12 +10,13 @@ import (
1010// ApprovalToSign defines approval mechanisms used by different blockchains to transfer ownership of funds to resolver.
1111//
1212// `approvalMechanism` holds the type of approval mechanism required for signing operations, and one of
13- // the `permit2|htlc|cosign` fields will be not nil (corresponding).
13+ // the `permit2|htlc|cosign|nativetransfer ` fields will be not nil (corresponding).
1414type ApprovalToSign struct {
1515 ApprovalMechanism ApprovalToSignType
1616 Permit2 * ApprovalToSignPermit2
1717 Htlc * ApprovalToSignHtlc
1818 Cosign * ApprovalToSignCosign
19+ NativeTransfer * ApprovalToSignNativeTransfer
1920}
2021
2122// ApprovalToSignType represents the type of approval mechanism required for signing operations.
@@ -28,6 +29,8 @@ const (
2829 ApprovalToSignTypeHtlc ApprovalToSignType = "htlc"
2930 // ApprovalToSignTypeCosign defines `cosign` approval types.
3031 ApprovalToSignTypeCosign ApprovalToSignType = "cosign"
32+ // ApprovalToSignTypeCosign defines `nativetransfer` approval types.
33+ ApprovalToSignTypeNativeTransfer ApprovalToSignType = "nativetransfer"
3134)
3235
3336// ApprovalToSignPermit2 represents parameters of a permit2 approval used to authorize a resolver as a spender.
@@ -68,12 +71,18 @@ type ApprovalToSignCosign struct {
6871 Nonce int64 `json:"nonce"`
6972}
7073
74+ // ApprovalToSignNativeTransfer represents parameters of a native transfer approval used for Ethereum/Tron networks.
75+ type ApprovalToSignNativeTransfer struct {
76+ ResolverSignature string `json:"resolver_signature"`
77+ }
78+
7179// IntentApproval is a container for the intent approval.
7280type IntentApproval struct {
7381 approvalMechanism ApprovalToSignType
7482 permit2 * string
7583 psbt * string
7684 cosign * CosignApproval
85+ nativeTransfer * string
7786}
7887
7988// NewPermit2IntentApproval creates a new intent approval for permit2.
@@ -103,6 +112,14 @@ func NewCosignIntentApproval(transaction string, userAddress string) IntentAppro
103112 }
104113}
105114
115+ // NewCosignIntentApproval creates a new intent approval for cosign.
116+ func NewNativeTransferIntentApproval (transactionHash string ) IntentApproval {
117+ return IntentApproval {
118+ approvalMechanism : ApprovalToSignTypeNativeTransfer ,
119+ nativeTransfer : & transactionHash ,
120+ }
121+ }
122+
106123// MarshalJSON implements json.Marshaler interface.
107124func (a * IntentApproval ) MarshalJSON () ([]byte , error ) {
108125 var v = addIntentApprovalRequestCodec {Type : string (a .approvalMechanism )}
@@ -114,6 +131,8 @@ func (a *IntentApproval) MarshalJSON() ([]byte, error) {
114131 v .SignedData = * a .psbt
115132 case a .approvalMechanism == ApprovalToSignTypeCosign && a .cosign != nil :
116133 v .SignedData = * a .cosign
134+ case a .approvalMechanism == ApprovalToSignTypeNativeTransfer && a != nil :
135+ v .SignedData = * a .nativeTransfer
117136 default :
118137 return nil , fmt .Errorf ("unrecognized approval mechanism %v or missing signed data" , a .approvalMechanism )
119138 }
0 commit comments