Skip to content

Commit

Permalink
feat: add escrow related tx (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp2121 authored Jan 31, 2025
1 parent 35582ad commit 1888844
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 0 deletions.
24 changes: 24 additions & 0 deletions shared/requests/submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ components:
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
DIDDelete: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
DIDSet: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
EscrowCancel: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
EscrowCreate: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
EscrowFinish: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1'
- $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction'
Expand All @@ -105,6 +108,9 @@ components:
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
- $ref: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
- $ref: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
- $ref: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
- $ref: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
- $ref: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
# TODO: Add other transaction types here

description: 'Transaction definition in JSON format, optionally omitting any auto-fillable fields.'
Expand Down Expand Up @@ -139,6 +145,9 @@ components:
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
DIDDelete: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
DIDSet: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
EscrowCancel: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
EscrowCreate: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
EscrowFinish: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV2'
- $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction'
Expand All @@ -158,6 +167,9 @@ components:
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
- $ref: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
- $ref: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
- $ref: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
- $ref: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
- $ref: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
# TODO: Add other transaction types here
description: 'Transaction definition in JSON format, optionally omitting any auto-fillable fields.'
required:
Expand Down Expand Up @@ -251,6 +263,9 @@ components:
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
DIDDelete: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
DIDSet: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
EscrowCancel: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
EscrowCreate: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
EscrowFinish: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
# TODO: Add other transaction types here
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1'
Expand All @@ -271,6 +286,9 @@ components:
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
- $ref: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
- $ref: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
- $ref: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
- $ref: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
- $ref: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
# TODO: Add other transaction types here

SubmitSuccessResponseV2:
Expand Down Expand Up @@ -300,6 +318,9 @@ components:
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
DIDDelete: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
DIDSet: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
EscrowCancel: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
EscrowCreate: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
EscrowFinish: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
# TODO: Add other transaction types here
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV2'
Expand All @@ -320,6 +341,9 @@ components:
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
- $ref: '../transactions/did_delete.yaml#/components/schemas/DIDDeleteTransaction'
- $ref: '../transactions/did_set.yaml#/components/schemas/DIDSetTransaction'
- $ref: '../transactions/escrow_cancel.yaml#/components/schemas/EscrowCancelTransaction'
- $ref: '../transactions/escrow_create.yaml#/components/schemas/EscrowCreateTransaction'
- $ref: '../transactions/escrow_finish.yaml#/components/schemas/EscrowFinishTransaction'
# TODO: Add other transaction types here

SubmitErrorResponse:
Expand Down
22 changes: 22 additions & 0 deletions shared/transactions/escrow_cancel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
components:
schemas:
EscrowCancelTransaction:
$id: EscrowCancelTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
Return escrowed XRP to the sender.
required:
- Owner
- OfferSequence
properties:
Owner:
type: string
description: |
Address of the source account that funded the escrow payment.
OfferSequence:
type: integer
format: uint32
description: |
Transaction sequence (or Ticket number) of EscrowCreate transaction that created the escrow to cancel.
51 changes: 51 additions & 0 deletions shared/transactions/escrow_create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
components:
schemas:
EscrowCreateTransaction:
$id: EscrowCreateTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
Sequester XRP until the escrow process either finishes or is canceled.
required:
- Amount
- Destination
properties:
Amount:
type: string
description: |
Amount of XRP, in drops, to deduct from the sender's balance and escrow. Once escrowed, the XRP
can either go to the Destination address (after the FinishAfter time) or be returned to the
sender (after the CancelAfter time).
Destination:
type: string
description: |
Address to receive escrowed XRP.
CancelAfter:
type: integer
format: uint32
description: |
(Optional) The time, in seconds since the Ripple Epoch, when this escrow expires. This value is
immutable; the funds can only be returned to the sender after this time.
FinishAfter:
type: integer
format: uint32
description: |
(Optional) The time, in seconds since the Ripple Epoch, when the escrowed XRP can be released to
the recipient. This value is immutable, and the funds can't be accessed until this time.
Condition:
type: string
description: |
(Optional) Hex value representing a PREIMAGE-SHA-256 crypto-condition. The funds can only be
delivered to the recipient if this condition is fulfilled. If the condition is not fulfilled
before the expiration time specified in the CancelAfter field, the XRP can only revert to the sender.
DestinationTag:
type: integer
format: uint32
description: |
(Optional) Arbitrary tag to further specify the destination for this escrowed payment, such as a
hosted recipient at the destination address.
x-custom-validation:
requireFieldComparison:
- smallerField: FinishAfter
largerField: CancelAfter
41 changes: 41 additions & 0 deletions shared/transactions/escrow_finish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
components:
schemas:
EscrowFinishTransaction:
$id: EscrowFinishTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
Deliver XRP from an escrow (held payment) to the recipient.
required:
- Owner
- OfferSequence
properties:
Owner:
type: string
description: |
(Required) Address of the source account that funded the escrow.
OfferSequence:
type: integer
format: uint32
description: |
(Required) Transaction sequence of EscrowCreate transaction that created the escrow to finish.
Condition:
type: string
description: |
(Optional) Hex value matching the previously-supplied PREIMAGE-SHA-256 crypto-condition of the escrow.
CredentialIDs:
type: array
items:
type: string
description: |
(Optional) Set of Credentials to authorize a deposit made by this transaction. Each member of the
array must be the ledger entry ID of a Credential entry in the ledger. For details, see Credential IDs.
Fulfillment:
type: string
description: |
(Optional) Hex value of the PREIMAGE-SHA-256 crypto-condition fulfillment matching the escrow's Condition.
x-custom-validation:
mutualPresence:
- field1: Condition
field2: Fulfillment

0 comments on commit 1888844

Please sign in to comment.