@@ -14,9 +14,14 @@ import uniffi.yttrium.InitialTransactionMetadata
1414import uniffi.yttrium.OwnerSignature
1515import uniffi.yttrium.PrepareResponseAvailable
1616import uniffi.yttrium.PreparedSendTransaction
17+ import uniffi.yttrium.Route
18+ import uniffi.yttrium.RouteSig
19+ import uniffi.yttrium.SolanaTransaction
20+ import uniffi.yttrium.SolanaTxnDetails
1721import uniffi.yttrium.Metadata as YMetadata
1822import uniffi.yttrium.Transaction
1923import uniffi.yttrium.TransactionFee
24+ import uniffi.yttrium.Transactions
2025import uniffi.yttrium.TxnDetails
2126import uniffi.yttrium.UiFields
2227
@@ -86,7 +91,13 @@ internal fun Wallet.Model.PayloadAuthRequestParams.toSign(): Sign.Model.PayloadP
8691
8792@JvmSynthetic
8893internal fun Sign.Model.Session.toWallet (): Wallet .Model .Session = Wallet .Model .Session (
89- pairingTopic, topic, expiry, requiredNamespaces.toWalletProposalNamespaces(), optionalNamespaces?.toWalletProposalNamespaces(), namespaces.toWallet(), metaData
94+ pairingTopic,
95+ topic,
96+ expiry,
97+ requiredNamespaces.toWalletProposalNamespaces(),
98+ optionalNamespaces?.toWalletProposalNamespaces(),
99+ namespaces.toWallet(),
100+ metaData
90101)
91102
92103@JvmSynthetic
@@ -133,7 +144,8 @@ internal fun Sign.Model.SessionAuthenticate.toWallet(): Wallet.Model.SessionAuth
133144 Wallet .Model .SessionAuthenticate (id, topic, participant.toWallet(), payloadParams.toWallet())
134145
135146@JvmSynthetic
136- internal fun Sign.Model.SessionAuthenticate.Participant.toWallet (): Wallet .Model .SessionAuthenticate .Participant = Wallet .Model .SessionAuthenticate .Participant (publicKey, metadata)
147+ internal fun Sign.Model.SessionAuthenticate.Participant.toWallet (): Wallet .Model .SessionAuthenticate .Participant =
148+ Wallet .Model .SessionAuthenticate .Participant (publicKey, metadata)
137149
138150@JvmSynthetic
139151internal fun Sign.Model.PayloadParams.toWallet (): Wallet .Model .PayloadAuthRequestParams =
@@ -323,7 +335,13 @@ internal fun UiFields.toWallet(): Wallet.Model.PrepareSuccess.Available =
323335 Wallet .Model .PrepareSuccess .Available (
324336 orchestratorId = routeResponse.orchestrationId,
325337 checkIn = routeResponse.metadata.checkIn.toLong(),
326- transactions = routeResponse.transactions.map { it.toWallet() },
338+ transactions = routeResponse.transactions.map {
339+ when (it) {
340+ is Transactions .Eip155 -> Wallet .Model .Transactions .Eip155 (it.v1.map { eip155 -> eip155.toWallet() })
341+ is Transactions .Solana -> Wallet .Model .Transactions .Solana (it.v1.map { solana -> solana.toWallet() })
342+ else -> throw Exception (" Unsupported Transaction type" )
343+ }
344+ },
327345 initialTransaction = routeResponse.initialTransaction.toWallet(),
328346 initialTransactionMetadata = routeResponse.metadata.initialTransaction.toWallet(),
329347 funding = routeResponse.metadata.fundingFrom.map { it.toWallet() },
@@ -333,7 +351,13 @@ internal fun UiFields.toWallet(): Wallet.Model.PrepareSuccess.Available =
333351private fun UiFields.toTransactionsDetails () = Wallet .Model .TransactionsDetails (
334352 localTotal = localTotal.toWallet(),
335353 initialDetails = initial.toWallet(),
336- details = route.map { it.toWallet() },
354+ route = route.map {
355+ when (it) {
356+ is Route .Eip155 -> Wallet .Model .Route .Eip155 (it.v1.map { eip155 -> eip155.toWallet() })
357+ is Route .Solana -> Wallet .Model .Route .Solana (it.v1.map { solana -> solana.toWallet() })
358+ else -> throw Exception (" Unsupported Route type" )
359+ }
360+ },
337361 bridgeFees = bridge.map { it.toWallet() },
338362 localFulfilmentTotal = localRouteTotal.toWallet(),
339363 localBridgeTotal = localBridgeTotal.toWallet()
@@ -349,12 +373,28 @@ internal fun Wallet.Model.PrepareSuccess.Available.toResponseYttrium(): PrepareR
349373 fundingFrom = funding.map { it.toYttrium() }
350374 ),
351375 initialTransaction = initialTransaction.toYttrium(),
352- transactions = transactions.map { it.toYttrium() })
376+ transactions = transactions.map {
377+ when (it) {
378+ is Wallet .Model .Transactions .Eip155 -> Transactions .Eip155 (it.transactions.map { eip155 -> eip155.toYttrium() })
379+ is Wallet .Model .Transactions .Solana -> Transactions .Solana (it.transactions.map { solana -> solana.toYttrium() })
380+ }
381+ })
382+
383+ @JvmSynthetic
384+ internal fun Wallet.Model.RouteSig.toYttrium (): RouteSig = when (this ) {
385+ is Wallet .Model .RouteSig .Eip155 -> RouteSig .Eip155 (this .signatures)
386+ is Wallet .Model .RouteSig .Solana -> RouteSig .Solana (this .signatures)
387+ }
353388
354389@JvmSynthetic
355390internal fun Wallet.Model.PrepareSuccess.Available.toYttrium (): UiFields =
356391 UiFields (
357- route = transactionsDetails.details.map { it.toYttrium() },
392+ route = transactionsDetails.route.map {
393+ when (it) {
394+ is Wallet .Model .Route .Eip155 -> Route .Eip155 (it.transactionDetails.map { eip155 -> eip155.toYttrium() })
395+ is Wallet .Model .Route .Solana -> Route .Solana (it.solanaTransactionDetails.map { solana -> solana.toYttrium() })
396+ }
397+ },
358398 localTotal = transactionsDetails.localTotal.toYttrium(),
359399 localRouteTotal = transactionsDetails.localFulfilmentTotal.toYttrium(),
360400 bridge = transactionsDetails.bridgeFees.map { it.toYttrium() },
@@ -394,6 +434,13 @@ fun Transaction.toWallet(): Wallet.Model.Transaction = Wallet.Model.Transaction(
394434 chainId = chainId
395435)
396436
437+ @JvmSynthetic
438+ fun SolanaTransaction.toWallet (): Wallet .Model .SolanaTransaction = Wallet .Model .SolanaTransaction (
439+ from = from,
440+ chainId = chainId,
441+ versionedTransaction = transaction
442+ )
443+
397444@JvmSynthetic
398445fun Wallet.Model.Transaction.toYttrium (): Transaction = Transaction (
399446 from = from,
@@ -406,13 +453,23 @@ fun Wallet.Model.Transaction.toYttrium(): Transaction = Transaction(
406453)
407454
408455@JvmSynthetic
409- private fun Wallet.Model.FundingMetadata.toYttrium (): FundingMetadata = FundingMetadata (chainId, tokenContract, symbol, amount = amount, bridgingFee = bridgingFee, decimals = decimals.toUByte())
456+ fun Wallet.Model.SolanaTransaction.toYttrium (): SolanaTransaction = SolanaTransaction (
457+ from = from,
458+ chainId = chainId,
459+ transaction = versionedTransaction
460+ )
461+
462+ @JvmSynthetic
463+ private fun Wallet.Model.FundingMetadata.toYttrium (): FundingMetadata =
464+ FundingMetadata (chainId, tokenContract, symbol, amount = amount, bridgingFee = bridgingFee, decimals = decimals.toUByte())
410465
411466@JvmSynthetic
412- private fun FundingMetadata.toWallet (): Wallet .Model .FundingMetadata = Wallet .Model .FundingMetadata (chainId, tokenContract, symbol, amount, bridgingFee, 1 )
467+ private fun FundingMetadata.toWallet (): Wallet .Model .FundingMetadata =
468+ Wallet .Model .FundingMetadata (chainId, tokenContract, symbol, amount, bridgingFee, 1 )
413469
414470@JvmSynthetic
415- internal fun Eip1559Estimation.toWallet (): Wallet .Model .EstimatedFees = Wallet .Model .EstimatedFees (maxFeePerGas = maxFeePerGas, maxPriorityFeePerGas = maxPriorityFeePerGas)
471+ internal fun Eip1559Estimation.toWallet (): Wallet .Model .EstimatedFees =
472+ Wallet .Model .EstimatedFees (maxFeePerGas = maxFeePerGas, maxPriorityFeePerGas = maxPriorityFeePerGas)
416473
417474@JvmSynthetic
418475internal fun Amount.toWallet (): Wallet .Model .Amount = Wallet .Model .Amount (
@@ -438,12 +495,22 @@ private fun TxnDetails.toWallet(): Wallet.Model.TransactionDetails = Wallet.Mode
438495 transactionHashToSign = transactionHashToSign
439496)
440497
498+ private fun SolanaTxnDetails.toWallet (): Wallet .Model .SolanaTransactionDetails = Wallet .Model .SolanaTransactionDetails (
499+ transaction = transaction.toWallet(),
500+ transactionHashToSign = transactionHashToSign
501+ )
502+
441503private fun Wallet.Model.TransactionDetails.toYttrium (): TxnDetails = TxnDetails (
442504 transaction = feeEstimatedTransaction.toWallet(),
443505 fee = transactionFee.toYttrium(),
444506 transactionHashToSign = transactionHashToSign
445507)
446508
509+ private fun Wallet.Model.SolanaTransactionDetails.toYttrium (): SolanaTxnDetails = SolanaTxnDetails (
510+ transaction = SolanaTransaction (chainId = transaction.chainId, from = transaction.from, transaction = transaction.versionedTransaction),
511+ transactionHashToSign = transactionHashToSign
512+ )
513+
447514fun FeeEstimatedTransaction.toWallet (): Wallet .Model .FeeEstimatedTransaction = Wallet .Model .FeeEstimatedTransaction (
448515 from = from,
449516 to = to,
0 commit comments