Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ message StatefulSwapRequest {

// Where "amount" of "from_mint" will be sent from to the VM swap PDA
FundingSource funding_source = 5 [(validate.rules).enum = {
in: [1, 2] // FUNDING_SOURCE_SUBMIT_INTENT, FUNDING_SOURCE_EXTERNAL_WALLET
in: [1, 2, 3] // FUNDING_SOURCE_SUBMIT_INTENT, FUNDING_SOURCE_EXTERNAL_WALLET, FUNDING_SOURCE_COINBASE_ONRAMP
}];


Expand All @@ -390,6 +390,7 @@ message StatefulSwapRequest {
//
// For FUNDING_SOURCE_SUBMIT_INTENT, this value is the base58 encoded intent ID.
// For FUNDING_SOURCE_EXTERNAL_WALLET, this value is the base58 encoded transaction signature.
// For FUNDING_SOURCE_COINBASE_ONRAMP, this value is the order ID
string funding_id = 6 [(validate.rules).string = {
min_len: 32,
max_len: 88,
Expand Down Expand Up @@ -1462,4 +1463,5 @@ enum FundingSource {
FUNDING_SOURCE_UNKNOWN = 0;
FUNDING_SOURCE_SUBMIT_INTENT = 1;
FUNDING_SOURCE_EXTERNAL_WALLET = 2;
FUNDING_SOURCE_COINBASE_ONRAMP = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ internal fun SwapRequest.currencyCreatorParams(): TransactionService.StatefulSwa
setFundingId(source.id.base58)
}

is SwapFundingSource.CoinbaseOnramp -> {
setFundingSource(TransactionService.FundingSource.FUNDING_SOURCE_COINBASE_ONRAMP)
setFundingId(source.orderId)
}

SwapFundingSource.Unknown -> Unit
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ internal fun TransactionService.StatefulSwapRequest.Initiate.ReserveSwapClientPa
TransactionService.FundingSource.FUNDING_SOURCE_SUBMIT_INTENT -> SwapFundingSource.SubmitIntent(PublicKey(fundingId).bytes)
TransactionService.FundingSource.FUNDING_SOURCE_EXTERNAL_WALLET -> SwapFundingSource.ExternalWallet(
fundingId.toByteArray().toList())
TransactionService.FundingSource.FUNDING_SOURCE_COINBASE_ONRAMP -> SwapFundingSource.CoinbaseOnramp(fundingId.toByteArray().toList())
TransactionService.FundingSource.UNRECOGNIZED -> SwapFundingSource.Unknown
}
)
Expand All @@ -219,6 +220,7 @@ internal fun TransactionService.StatefulSwapRequest.Initiate.CoinbaseStableSwapp
TransactionService.FundingSource.FUNDING_SOURCE_SUBMIT_INTENT -> SwapFundingSource.SubmitIntent(PublicKey(fundingId).bytes)
TransactionService.FundingSource.FUNDING_SOURCE_EXTERNAL_WALLET -> SwapFundingSource.ExternalWallet(
fundingId.toByteArray().toList())
TransactionService.FundingSource.FUNDING_SOURCE_COINBASE_ONRAMP -> SwapFundingSource.CoinbaseOnramp(fundingId.toByteArray().toList())
TransactionService.FundingSource.UNRECOGNIZED -> SwapFundingSource.Unknown
},
destinationOwner = destinationOwner.toPublicKey(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ sealed class SwapFundingSource {
* wallet to complete the transaction.
*/
data class ExternalWallet(val transactionSignature: List<Byte>): SwapFundingSource()

/**
* Represents a funding source where the user pays via a Coinbase onramp.
* @param orderId The Coinbase onramp order ID.
*/
data class CoinbaseOnramp(val orderId: List<Byte>): SwapFundingSource() {
constructor(orderId: String): this(orderId.toByteArray().toList())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ sealed interface SwapStartKind {
get() = when (fundingSource) {
is SwapFundingSource.ExternalWallet -> fundingSource.transactionSignature
is SwapFundingSource.SubmitIntent -> fundingSource.id
is SwapFundingSource.CoinbaseOnramp -> fundingSource.orderId
SwapFundingSource.Unknown -> throw IllegalArgumentException("Invalid funding source")
}
}
Expand Down
Loading