Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credentials related transactions #30

Merged
merged 5 commits into from
Feb 19, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/*
dist
.DS_Store
.DS_Store
.idea
27 changes: 27 additions & 0 deletions shared/requests/submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ components:
AMMDeposit: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
AMMVote: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
AMMWithdraw: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
CredentialAccept: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
CredentialCreate: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
CredentialDelete: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -122,6 +125,9 @@ components:
- $ref: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
- $ref: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
- $ref: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
- $ref: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
- $ref: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
- $ref: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -181,6 +187,9 @@ components:
AMMDeposit: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
AMMVote: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
AMMWithdraw: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
CredentialAccept: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
CredentialCreate: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
CredentialDelete: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -225,6 +234,9 @@ components:
- $ref: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
- $ref: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
- $ref: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
- $ref: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
- $ref: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
- $ref: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -343,6 +355,9 @@ components:
AMMDeposit: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
AMMVote: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
AMMWithdraw: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
CredentialAccept: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
CredentialCreate: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
CredentialDelete: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -388,6 +403,9 @@ components:
- $ref: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
- $ref: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
- $ref: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
- $ref: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
- $ref: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
- $ref: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -442,6 +460,9 @@ components:
AMMDeposit: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
AMMVote: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
AMMWithdraw: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
CredentialAccept: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
CredentialCreate: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
CredentialDelete: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -487,6 +508,9 @@ components:
- $ref: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositTransaction'
- $ref: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteTransaction'
- $ref: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawTransaction'
- $ref: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptTransaction'
- $ref: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateTransaction'
- $ref: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteTransaction'
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
Expand Down Expand Up @@ -535,6 +559,9 @@ components:
- $ref: '../transactions/amm_deposit.yaml#/components/schemas/AMMDepositErrorCode'
- $ref: '../transactions/amm_vote.yaml#/components/schemas/AMMVoteErrorCode'
- $ref: '../transactions/amm_withdraw.yaml#/components/schemas/AMMWithdrawErrorCode'
- $ref: '../transactions/credential_accept.yaml#/components/schemas/CredentialAcceptErrorCode'
- $ref: '../transactions/credential_create.yaml#/components/schemas/CredentialCreateErrorCode'
- $ref: '../transactions/credential_delete.yaml#/components/schemas/CredentialDeleteErrorCode'
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelErrorCode'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashErrorCode'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateErrorCode'
Expand Down
40 changes: 40 additions & 0 deletions shared/transactions/credential_accept.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
components:
schemas:
CredentialAcceptTransaction:
$id: CredentialAcceptTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
A CredentialAccept transaction accepts a credential, which makes the credential valid. Only the subject of the credential can do this.
required:
- CredentialType
- Issuer
properties:
CredentialType:
type: string
pattern: '^[0-9a-fA-F]+$'
description: Arbitrary data defining the type of credential. The minimum size is 1 byte and the maximum is 64 bytes.
Issuer:
type: string
description: The address of the issuer that created the credential.
x-custom-validation:
validCredentialType:
field: CredentialType

CredentialAcceptErrorCode:
$id: CredentialAcceptErrorCode
type: string
description: Error codes for the CredentialAccept transaction.
enum:
- tecDUPLICATE
- tecEXPIRED
- tecNO_ENTRY
- temDISABLED
- temINVALID_ACCOUNT_ID
x-enum-descriptions:
tecDUPLICATE: The specified credential has already been accepted.
tecEXPIRED: The specified credential has an expiration time in the past. (In this case, the transaction also deletes the expired credentials from the ledger.)
tecNO_ENTRY: The credential uniquely identified by the Account, Issuer, and CredentialType fields of the transaction does not exist in the ledger.
temDISABLED: The related amendment is not enabled.
temINVALID_ACCOUNT_ID: The provided Issuer field is invalid. For example, it contains ACCOUNT_ZERO.
54 changes: 54 additions & 0 deletions shared/transactions/credential_create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
components:
schemas:
CredentialCreateTransaction:
$id: CredentialCreateTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: >
A CredentialCreate transaction creates a credential in the ledger.
The issuer of the credential uses this transaction to provisionally issue a credential.
The credential is not valid until the subject of the credential accepts it with a CredentialAccept transaction.
required:
- CredentialType
- Expiration
- Subject
properties:
CredentialType:
type: string
pattern: '^[0-9a-fA-F]+$'
description: Arbitrary data defining the type of credential this entry represents. The minimum length is 1 byte and the maximum length is 64 bytes.
Expiration:
type: number
format: uint32
description: Time after which this credential expires, in seconds since the Ripple Epoch.
Subject:
type: string
description: The subject of the credential.
URI:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a max length of 256 for uri

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it's should be a valid hex

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added maxLength of 512 characters as 1 byte accommodates two hex values

type: string
pattern: '^[0-9a-fA-F]+$'
maxLength: 512
description: |
Arbitrary additional data about the credential, such as the URL where users can look up an associated Verifiable Credential document.
If present, the minimum length is 1 byte and the maximum is 256 bytes.
x-custom-validation:
validCredentialType:
field: CredentialType

CredentialCreateErrorCode:
$id: CredentialCreateErrorCode
type: string
description: Error codes for the CredentialCreate transaction.
enum:
- tecDUPLICATE
- tecEXPIRED
- tecNO_TARGET
- temDISABLED
- temINVALID_ACCOUNT_ID
x-enum-descriptions:
tecDUPLICATE: A credential with the same subject, issuer, and credential type already exists in the ledger.
tecEXPIRED: The credential's expiration time is in the past.
tecNO_TARGET: The account specified in the Subject field is not a funded account in the ledger.
temDISABLED: The related amendment is not enabled.
temINVALID_ACCOUNT_ID: The provided Subject field is invalid. For example, it contains ACCOUNT_ZERO.
45 changes: 45 additions & 0 deletions shared/transactions/credential_delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
components:
schemas:
CredentialDeleteTransaction:
$id: CredentialDeleteTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: >
A CredentialDelete transaction removes a credential from the ledger, effectively revoking it.
Users may also want to delete an unwanted credential to reduce their reserve requirement.
required:
- CredentialType
properties:
CredentialType:
type: string
pattern: '^[0-9a-fA-F]+$'
description: Arbitrary data defining the type of credential to delete. The minimum length is 1 byte and the maximum length is 256 bytes.
Subject:
type: string
description: The subject of the credential to delete. If omitted, use the Account (sender of the transaction) as the subject of the credential.
Issuer:
type: string
description: The issuer of the credential to delete. If omitted, use the Account (sender of the transaction) as the issuer of the credential.
x-custom-validation:
requireOneOf:
- fields:
- Subject
- Issuer
validCredentialType:
field: CredentialType

CredentialDeleteErrorCode:
$id: CredentialDeleteErrorCode
type: string
description: Error codes for the CredentialDelete transaction.
enum:
- temDISABLED
- temINVALID_ACCOUNT_ID
- tecNO_PERMISSION
- tecNO_ENTRY
x-enum-descriptions:
temDISABLED: The related amendment is not enabled.
temINVALID_ACCOUNT_ID: A provided Subject or Issuer field is invalid. For example, it contains ACCOUNT_ZERO.
tecNO_PERMISSION: The sender is neither the issuer nor subject of the credential, and the credential is not expired.
tecNO_ENTRY: The specified credential does not exist in the ledger.