45 lines
2.1 KiB
Go
45 lines
2.1 KiB
Go
package main
|
|
|
|
const (
|
|
quoteCostEnvelopeVersion = "edut.quote_cost_envelope.v1"
|
|
quoteProviderFeePolicyEdutAbsorbed = "edut_absorbed"
|
|
quoteProviderFeeEstimateStatusAbsorbed = "absorbed_by_edut"
|
|
quoteNetworkFeePolicyPayerPaysGas = "payer_wallet_pays_chain_gas"
|
|
quoteNetworkFeeEstimateStatusWalletQuoted = "wallet_estimate_required"
|
|
quoteNetworkFeeDefaultCurrency = "ETH"
|
|
)
|
|
|
|
type quoteCostEnvelope struct {
|
|
Version string `json:"version"`
|
|
CheckoutCurrency string `json:"checkout_currency"`
|
|
CheckoutDecimals int `json:"checkout_decimals"`
|
|
CheckoutTotalAtomic string `json:"checkout_total_atomic"`
|
|
CheckoutTotal string `json:"checkout_total"`
|
|
ProviderFeePolicy string `json:"provider_fee_policy"`
|
|
ProviderFeeIncluded bool `json:"provider_fee_included"`
|
|
ProviderFeeEstimateStatus string `json:"provider_fee_estimate_status"`
|
|
ProviderFeeEstimateAtomic string `json:"provider_fee_estimate_atomic"`
|
|
NetworkFeePolicy string `json:"network_fee_policy"`
|
|
NetworkFeeCurrency string `json:"network_fee_currency"`
|
|
NetworkFeeEstimateStatus string `json:"network_fee_estimate_status"`
|
|
NetworkFeeEstimateAtomic string `json:"network_fee_estimate_atomic"`
|
|
}
|
|
|
|
func newQuoteCostEnvelope(checkoutCurrency string, checkoutDecimals int, checkoutTotalAtomic string) quoteCostEnvelope {
|
|
return quoteCostEnvelope{
|
|
Version: quoteCostEnvelopeVersion,
|
|
CheckoutCurrency: checkoutCurrency,
|
|
CheckoutDecimals: checkoutDecimals,
|
|
CheckoutTotalAtomic: checkoutTotalAtomic,
|
|
CheckoutTotal: formatAtomicAmount(checkoutTotalAtomic, checkoutDecimals),
|
|
ProviderFeePolicy: quoteProviderFeePolicyEdutAbsorbed,
|
|
ProviderFeeIncluded: true,
|
|
ProviderFeeEstimateStatus: quoteProviderFeeEstimateStatusAbsorbed,
|
|
ProviderFeeEstimateAtomic: "0",
|
|
NetworkFeePolicy: quoteNetworkFeePolicyPayerPaysGas,
|
|
NetworkFeeCurrency: quoteNetworkFeeDefaultCurrency,
|
|
NetworkFeeEstimateStatus: quoteNetworkFeeEstimateStatusWalletQuoted,
|
|
NetworkFeeEstimateAtomic: "0",
|
|
}
|
|
}
|