-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding endpoints for Data Access configuration (#37)
* updating data access endpoints * refactoring * cleanup * PR comment
- Loading branch information
1 parent
57ed893
commit de96258
Showing
12 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
models/src/main/kotlin/io/provenance/api/models/p8e/tx/permissions/DataAccessChangeType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.provenance.api.models.p8e.tx.permissions | ||
|
||
enum class DataAccessChangeType { | ||
ADD, | ||
REMOVE | ||
} |
6 changes: 6 additions & 0 deletions
6
models/src/main/kotlin/io/provenance/api/models/p8e/tx/permissions/DataAccessUpdate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.provenance.api.models.p8e.tx.permissions | ||
|
||
data class DataAccessUpdate( | ||
val type: DataAccessChangeType, | ||
val address: String, | ||
) |
12 changes: 12 additions & 0 deletions
12
...c/main/kotlin/io/provenance/api/models/p8e/tx/permissions/UpdateScopeDataAccessRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.provenance.api.models.p8e.tx.permissions | ||
|
||
import io.provenance.api.models.account.AccountInfo | ||
import io.provenance.api.models.p8e.ProvenanceConfig | ||
import java.util.UUID | ||
|
||
data class UpdateScopeDataAccessRequest( | ||
val scopeUuid: UUID, | ||
val account: AccountInfo = AccountInfo(), | ||
val provenanceConfig: ProvenanceConfig, | ||
val changes: List<DataAccessUpdate> | ||
) |
6 changes: 3 additions & 3 deletions
6
.../domain/usecase/provenance/tx/CreateTx.kt → .../usecase/provenance/tx/create/CreateTx.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...enance/tx/model/CreateTxRequestWrapper.kt → ...x/create/models/CreateTxRequestWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...domain/usecase/provenance/tx/ExecuteTx.kt → ...secase/provenance/tx/execute/ExecuteTx.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nance/tx/model/ExecuteTxRequestWrapper.kt → ...execute/models/ExecuteTxRequestWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...otlin/io/provenance/api/domain/usecase/provenance/tx/permissions/UpdateScopeDataAccess.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.provenance.api.domain.usecase.provenance.tx.permissions | ||
|
||
import io.provenance.api.domain.usecase.AbstractUseCase | ||
import io.provenance.api.domain.usecase.provenance.account.GetSigner | ||
import io.provenance.api.domain.usecase.provenance.account.models.GetSignerRequest | ||
import io.provenance.api.domain.usecase.provenance.tx.permissions.models.UpdateScopeDataAccessRequestWrapper | ||
import io.provenance.api.frameworks.provenance.ProvenanceService | ||
import io.provenance.api.frameworks.provenance.extensions.toTxResponse | ||
import io.provenance.api.models.p8e.TxResponse | ||
import io.provenance.api.models.p8e.tx.permissions.DataAccessChangeType | ||
import io.provenance.client.protobuf.extensions.toAny | ||
import io.provenance.client.protobuf.extensions.toTxBody | ||
import io.provenance.metadata.v1.MsgAddScopeDataAccessRequest | ||
import io.provenance.metadata.v1.MsgDeleteScopeDataAccessRequest | ||
import io.provenance.scope.util.MetadataAddress | ||
import io.provenance.scope.util.toByteString | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class UpdateScopeDataAccess( | ||
private val provenanceService: ProvenanceService, | ||
private val getSigner: GetSigner | ||
) : AbstractUseCase<UpdateScopeDataAccessRequestWrapper, TxResponse>() { | ||
override suspend fun execute(args: UpdateScopeDataAccessRequestWrapper): TxResponse { | ||
val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) | ||
|
||
val messages = args.request.changes.map { | ||
when (it.type) { | ||
DataAccessChangeType.ADD -> { | ||
MsgAddScopeDataAccessRequest.newBuilder() | ||
.setScopeId(MetadataAddress.forScope(args.request.scopeUuid).bytes.toByteString()) | ||
.addDataAccess(it.address) | ||
.addAllSigners(listOf(signer.address())) | ||
.build().toAny() | ||
} | ||
DataAccessChangeType.REMOVE -> { | ||
MsgDeleteScopeDataAccessRequest.newBuilder() | ||
.setScopeId(MetadataAddress.forScope(args.request.scopeUuid).bytes.toByteString()) | ||
.addDataAccess(it.address) | ||
.addAllSigners(listOf(signer.address())) | ||
.build().toAny() | ||
} | ||
} | ||
}.toTxBody() | ||
|
||
return provenanceService.executeTransaction(args.request.provenanceConfig, messages, signer).toTxResponse() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...pi/domain/usecase/provenance/tx/permissions/models/UpdateScopeDataAccessRequestWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.provenance.api.domain.usecase.provenance.tx.permissions.models | ||
|
||
import io.provenance.api.models.p8e.tx.permissions.UpdateScopeDataAccessRequest | ||
import java.util.UUID | ||
|
||
data class UpdateScopeDataAccessRequestWrapper( | ||
val uuid: UUID, | ||
val request: UpdateScopeDataAccessRequest, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters