Skip to content

Commit 86c496e

Browse files
committed
feat(opencode): update protos; add Coinbase onramp funding source
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 9d0bb77 commit 86c496e

5 files changed

Lines changed: 19 additions & 1 deletion

File tree

definitions/opencode/protos/src/main/proto/transaction/v1/transaction_service.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ message StatefulSwapRequest {
381381

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

387387

@@ -390,6 +390,7 @@ message StatefulSwapRequest {
390390
//
391391
// For FUNDING_SOURCE_SUBMIT_INTENT, this value is the base58 encoded intent ID.
392392
// For FUNDING_SOURCE_EXTERNAL_WALLET, this value is the base58 encoded transaction signature.
393+
// For FUNDING_SOURCE_COINBASE_ONRAMP, this value is the order ID
393394
string funding_id = 6 [(validate.rules).string = {
394395
min_len: 32,
395396
max_len: 88,
@@ -1462,4 +1463,5 @@ enum FundingSource {
14621463
FUNDING_SOURCE_UNKNOWN = 0;
14631464
FUNDING_SOURCE_SUBMIT_INTENT = 1;
14641465
FUNDING_SOURCE_EXTERNAL_WALLET = 2;
1466+
FUNDING_SOURCE_COINBASE_ONRAMP = 3;
14651467
}

services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/LocalToProtobuf.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ internal fun SwapRequest.currencyCreatorParams(): TransactionService.StatefulSwa
296296
setFundingId(source.id.base58)
297297
}
298298

299+
is SwapFundingSource.CoinbaseOnramp -> {
300+
setFundingSource(TransactionService.FundingSource.FUNDING_SOURCE_COINBASE_ONRAMP)
301+
setFundingId(source.orderId)
302+
}
303+
299304
SwapFundingSource.Unknown -> Unit
300305
}
301306
}

services/opencode/src/main/kotlin/com/getcode/opencode/internal/network/extensions/ProtobufToLocal.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ internal fun TransactionService.StatefulSwapRequest.Initiate.ReserveSwapClientPa
202202
TransactionService.FundingSource.FUNDING_SOURCE_SUBMIT_INTENT -> SwapFundingSource.SubmitIntent(PublicKey(fundingId).bytes)
203203
TransactionService.FundingSource.FUNDING_SOURCE_EXTERNAL_WALLET -> SwapFundingSource.ExternalWallet(
204204
fundingId.toByteArray().toList())
205+
TransactionService.FundingSource.FUNDING_SOURCE_COINBASE_ONRAMP -> SwapFundingSource.CoinbaseOnramp(fundingId.toByteArray().toList())
205206
TransactionService.FundingSource.UNRECOGNIZED -> SwapFundingSource.Unknown
206207
}
207208
)
@@ -219,6 +220,7 @@ internal fun TransactionService.StatefulSwapRequest.Initiate.CoinbaseStableSwapp
219220
TransactionService.FundingSource.FUNDING_SOURCE_SUBMIT_INTENT -> SwapFundingSource.SubmitIntent(PublicKey(fundingId).bytes)
220221
TransactionService.FundingSource.FUNDING_SOURCE_EXTERNAL_WALLET -> SwapFundingSource.ExternalWallet(
221222
fundingId.toByteArray().toList())
223+
TransactionService.FundingSource.FUNDING_SOURCE_COINBASE_ONRAMP -> SwapFundingSource.CoinbaseOnramp(fundingId.toByteArray().toList())
222224
TransactionService.FundingSource.UNRECOGNIZED -> SwapFundingSource.Unknown
223225
},
224226
destinationOwner = destinationOwner.toPublicKey(),

services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapFundingSource.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ sealed class SwapFundingSource {
2020
* wallet to complete the transaction.
2121
*/
2222
data class ExternalWallet(val transactionSignature: List<Byte>): SwapFundingSource()
23+
24+
/**
25+
* Represents a funding source where the user pays via a Coinbase onramp.
26+
* @param orderId The Coinbase onramp order ID.
27+
*/
28+
data class CoinbaseOnramp(val orderId: List<Byte>): SwapFundingSource() {
29+
constructor(orderId: String): this(orderId.toByteArray().toList())
30+
}
2331
}

services/opencode/src/main/kotlin/com/getcode/opencode/model/transactions/SwapRequest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ sealed interface SwapStartKind {
5252
get() = when (fundingSource) {
5353
is SwapFundingSource.ExternalWallet -> fundingSource.transactionSignature
5454
is SwapFundingSource.SubmitIntent -> fundingSource.id
55+
is SwapFundingSource.CoinbaseOnramp -> fundingSource.orderId
5556
SwapFundingSource.Unknown -> throw IllegalArgumentException("Invalid funding source")
5657
}
5758
}

0 commit comments

Comments
 (0)