|
|
@ -88,7 +88,7 @@ class UniversalLinkCoordinator: Coordinator { |
|
|
|
private func createHTTPParametersForCurrencyLinksToPaymentServer( |
|
|
|
private func createHTTPParametersForCurrencyLinksToPaymentServer( |
|
|
|
signedOrder: SignedOrder, |
|
|
|
signedOrder: SignedOrder, |
|
|
|
recipient: AlphaWallet.Address |
|
|
|
recipient: AlphaWallet.Address |
|
|
|
) -> Parameters { |
|
|
|
) -> (Parameters, String) { |
|
|
|
let signature = signedOrder.signature.drop0x |
|
|
|
let signature = signedOrder.signature.drop0x |
|
|
|
let parameters: Parameters = [ |
|
|
|
let parameters: Parameters = [ |
|
|
|
"prefix": Constants.xdaiDropPrefix, |
|
|
|
"prefix": Constants.xdaiDropPrefix, |
|
|
@ -102,20 +102,23 @@ class UniversalLinkCoordinator: Coordinator { |
|
|
|
"networkId": server.chainID.description, |
|
|
|
"networkId": server.chainID.description, |
|
|
|
"contractAddress": signedOrder.order.contractAddress |
|
|
|
"contractAddress": signedOrder.order.contractAddress |
|
|
|
] |
|
|
|
] |
|
|
|
return parameters |
|
|
|
return (parameters, Constants.currencyDropServer) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func createHTTPParametersForNormalLinksToPaymentServer( |
|
|
|
private func createHTTPParametersForNormalLinksToPaymentServer( |
|
|
|
signedOrder: SignedOrder, |
|
|
|
signedOrder: SignedOrder, |
|
|
|
isForTransfer: Bool |
|
|
|
isForTransfer: Bool |
|
|
|
) -> Parameters { |
|
|
|
) -> (Parameters, String) { |
|
|
|
|
|
|
|
let query: String |
|
|
|
let signature = signedOrder.signature.drop0x |
|
|
|
let signature = signedOrder.signature.drop0x |
|
|
|
let indices = signedOrder.order.indices |
|
|
|
let indices = signedOrder.order.indices |
|
|
|
let indicesStringEncoded = stringEncodeIndices(indices) |
|
|
|
let indicesStringEncoded = stringEncodeIndices(indices) |
|
|
|
|
|
|
|
let tokenIdsEncoded = stringEncodeTokenIds(signedOrder.order.tokenIds) |
|
|
|
var parameters: Parameters = [ |
|
|
|
var parameters: Parameters = [ |
|
|
|
"address": walletAddress, |
|
|
|
"address": walletAddress, |
|
|
|
"contractAddress": signedOrder.order.contractAddress, |
|
|
|
"contractAddress": signedOrder.order.contractAddress, |
|
|
|
"indices": indicesStringEncoded, |
|
|
|
"indices": indicesStringEncoded, |
|
|
|
|
|
|
|
"tokenIds": tokenIdsEncoded ?? "", |
|
|
|
"price": signedOrder.order.price.description, |
|
|
|
"price": signedOrder.order.price.description, |
|
|
|
"expiry": signedOrder.order.expiry.description, |
|
|
|
"expiry": signedOrder.order.expiry.description, |
|
|
|
"v": signature.substring(from: 128), |
|
|
|
"v": signature.substring(from: 128), |
|
|
@ -127,8 +130,16 @@ class UniversalLinkCoordinator: Coordinator { |
|
|
|
if isForTransfer { |
|
|
|
if isForTransfer { |
|
|
|
parameters.removeValue(forKey: "price") |
|
|
|
parameters.removeValue(forKey: "price") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if signedOrder.order.spawnable { |
|
|
|
|
|
|
|
parameters.removeValue(forKey: "indices") |
|
|
|
|
|
|
|
query = Constants.paymentServerSpawnable |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
parameters.removeValue(forKey: "tokenIds") |
|
|
|
|
|
|
|
query = Constants.paymentServer |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return parameters |
|
|
|
return (parameters, query) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@discardableResult private func handlePaidImportsImpl(signedOrder: SignedOrder) -> Bool { |
|
|
|
@discardableResult private func handlePaidImportsImpl(signedOrder: SignedOrder) -> Bool { |
|
|
@ -172,23 +183,18 @@ class UniversalLinkCoordinator: Coordinator { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func getParametersAndQuery(signedOrder: SignedOrder) -> (Parameters, String)? { |
|
|
|
private func getParametersAndQuery(signedOrder: SignedOrder) -> (Parameters, String)? { |
|
|
|
let parameters: Parameters |
|
|
|
|
|
|
|
let query: String |
|
|
|
|
|
|
|
switch signedOrder.order.nativeCurrencyDrop { |
|
|
|
switch signedOrder.order.nativeCurrencyDrop { |
|
|
|
case true: |
|
|
|
case true: |
|
|
|
parameters = createHTTPParametersForCurrencyLinksToPaymentServer( |
|
|
|
return createHTTPParametersForCurrencyLinksToPaymentServer( |
|
|
|
signedOrder: signedOrder, |
|
|
|
signedOrder: signedOrder, |
|
|
|
recipient: walletAddress |
|
|
|
recipient: walletAddress |
|
|
|
) |
|
|
|
) |
|
|
|
query = Constants.currencyDropServer |
|
|
|
case false: |
|
|
|
case false: |
|
|
|
return createHTTPParametersForNormalLinksToPaymentServer( |
|
|
|
parameters = createHTTPParametersForNormalLinksToPaymentServer( |
|
|
|
|
|
|
|
signedOrder: signedOrder, |
|
|
|
signedOrder: signedOrder, |
|
|
|
isForTransfer: true |
|
|
|
isForTransfer: true |
|
|
|
) |
|
|
|
) |
|
|
|
query = Constants.paymentServer |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return (parameters, query) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func completeOrderHandling(signedOrder: SignedOrder) { |
|
|
|
func completeOrderHandling(signedOrder: SignedOrder) { |
|
|
@ -431,6 +437,11 @@ class UniversalLinkCoordinator: Coordinator { |
|
|
|
return indices.map(String.init).joined(separator: ",") |
|
|
|
return indices.map(String.init).joined(separator: ",") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func stringEncodeTokenIds(_ tokenIds: [BigUInt]?) -> String? { |
|
|
|
|
|
|
|
guard let tokens = tokenIds else { return nil } |
|
|
|
|
|
|
|
return tokens.map({ $0.serialize().hexString }).joined(separator: ",") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func checkERC875TokensAreAvailable(indices: [UInt16], balance: [String]) -> [String] { |
|
|
|
private func checkERC875TokensAreAvailable(indices: [UInt16], balance: [String]) -> [String] { |
|
|
|
var filteredTokens = [String]() |
|
|
|
var filteredTokens = [String]() |
|
|
|
if balance.count < indices.count { |
|
|
|
if balance.count < indices.count { |
|
|
|