-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTransakFiatPay.cs
More file actions
87 lines (75 loc) · 3.55 KB
/
TransakFiatPay.cs
File metadata and controls
87 lines (75 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Threading.Tasks;
using Sequence.ABI;
using Sequence.Contracts;
using Sequence.Marketplace;
using Sequence.Pay.Sardine;
using Sequence.Utils;
using UnityEngine;
namespace Sequence.Pay.Transak
{
internal class TransakFiatPay : IFiatPay
{
private TransakOnRamp _onRamp;
private TransakNFTCheckout _checkout;
private Dictionary<Address, TransakContractId> _contractIds;
public TransakFiatPay(TransakOnRamp onRamp, TransakNFTCheckout checkout)
{
_onRamp = onRamp;
_checkout = checkout;
_contractIds = new Dictionary<Address, TransakContractId>();
}
public async Task OnRamp()
{
_onRamp.OpenTransakLink();
}
public async Task<string> GetOnRampLink()
{
return await _onRamp.GetTransakLink();
}
public Task<string> GetNftCheckoutLink(CollectibleOrder order, ulong amount, NFTType nftType = NFTType.ERC721,
Address recipient = null, AdditionalFee additionalFee = null,
string marketplaceContractAddress = ISardineCheckout.SequenceMarketplaceV2Contract)
{
return _checkout.GetNFTCheckoutLink(order, amount, nftType, additionalFee);
}
public void ConfigureSaleContractId(TransakContractId contractId)
{
if (_contractIds.TryGetValue(contractId.ContractAddress, out var id))
{
if (id == contractId)
{
return;
}
SequenceLog.Warning($"{nameof(_contractIds)} already contains a different {nameof(TransakContractId)} for {contractId.ContractAddress}. Replacing existing instance with provided...");
}
_contractIds[contractId.ContractAddress] = contractId;
}
public Task<string> GetNftCheckoutLink(ERC1155Sale saleContract, Address collection, BigInteger tokenId, BigInteger amount,
Address recipient = null, byte[] data = null, FixedByte[] proof = null)
{
if (_contractIds.TryGetValue(saleContract, out var contractId))
{
return _checkout.GetNFTCheckoutLink(saleContract, collection, tokenId, (ulong)amount, contractId, data, proof);
}
throw new InvalidOperationException($"No contract ID found for provided {nameof(saleContract)} contract address; please call {nameof(ConfigureSaleContractId)} first");
}
public Task<string> GetNftCheckoutLink(ERC721Sale saleContract, Address collection, BigInteger tokenId, BigInteger amount,
Address recipient = null, FixedByte[] proof = null)
{
if (_contractIds.TryGetValue(saleContract, out var contractId))
{
return _checkout.GetNFTCheckoutLink(saleContract, collection, tokenId, (ulong)amount, contractId, proof);
}
throw new InvalidOperationException($"No contract ID found for provided {nameof(saleContract)} contract address; please call {nameof(ConfigureSaleContractId)} first");
}
public Task<string> GetNftCheckoutLink(CollectibleOrder[] orders, BigInteger quantity, NFTType nftType = NFTType.ERC721,
string marketplaceContractAddress = ISardineCheckout.SequenceMarketplaceV2Contract, Address recipient = null,
AdditionalFee[] additionalFee = null)
{
return _checkout.GetNFTCheckoutLink(orders, (ulong)quantity, nftType, additionalFee);
}
}
}