sorare/mutations/approval.go

37 lines
1.3 KiB
Go

package mutations
import "git.lehouerou.net/laurent/sorare/starkware"
type StarkExApprovalInput struct {
ExpirationTimestamp int `json:"expirationTimestamp"`
Nonce int `json:"nonce"`
Signature starkware.Signature `json:"signature"`
}
type MangopayWalletTransferApprovalInput struct {
Nonce int `json:"nonce"`
Signature starkware.Signature `json:"signature"`
}
type AuthorizationApprovalInput struct {
Fingerprint string `json:"fingerprint"`
StarkExLimitOrderApproval *StarkExApprovalInput `json:"starkexLimitOrderApproval,omitempty"`
StarkExTransferApproval *StarkExApprovalInput `json:"starkexTransferApproval,omitempty"`
MangopayWalletTransferApproval *MangopayWalletTransferApprovalInput `json:"mangopayWalletTransferApproval,omitempty"`
}
func signAuthorizationRequests(
privatekey string,
requests []AuthorizationRequest,
) ([]AuthorizationApprovalInput, error) {
var approvals []AuthorizationApprovalInput
for _, request := range requests {
approval, err := request.sign(privatekey)
if err != nil {
return nil, err
}
approvals = append(approvals, approval)
}
return approvals, nil
}