diff --git a/definitions/opencode/protos/src/main/proto/transaction/v1/transaction_service.proto b/definitions/opencode/protos/src/main/proto/transaction/v1/transaction_service.proto index 32c6f348a..f06736d12 100644 --- a/definitions/opencode/protos/src/main/proto/transaction/v1/transaction_service.proto +++ b/definitions/opencode/protos/src/main/proto/transaction/v1/transaction_service.proto @@ -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 }]; @@ -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, @@ -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; } diff --git a/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/LocalToProtobuf.kt b/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/LocalToProtobuf.kt index 9c3bb3420..cbe474f4f 100644 --- a/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/LocalToProtobuf.kt +++ b/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/LocalToProtobuf.kt @@ -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 } } diff --git a/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/ProtobufToLocal.kt b/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/ProtobufToLocal.kt index 09ce80e58..faf6479a4 100644 --- a/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/ProtobufToLocal.kt +++ b/services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/ProtobufToLocal.kt @@ -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 } ) @@ -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(), diff --git a/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapFundingSource.kt b/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapFundingSource.kt index 3110d33b9..e356d2279 100644 --- a/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapFundingSource.kt +++ b/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapFundingSource.kt @@ -20,4 +20,12 @@ sealed class SwapFundingSource { * wallet to complete the transaction. */ data class ExternalWallet(val transactionSignature: List): 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): SwapFundingSource() { + constructor(orderId: String): this(orderId.toByteArray().toList()) + } } \ No newline at end of file diff --git a/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapRequest.kt b/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapRequest.kt index 7179e2cc3..38fdc0c9d 100644 --- a/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapRequest.kt +++ b/services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapRequest.kt @@ -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") } }