Skip to content

Commit

Permalink
[ANCHOR-849] Add get_transaction rpc method (#1112)
Browse files Browse the repository at this point in the history
* wip

* address comments
  • Loading branch information
JiahuiWho authored Dec 5, 2024
1 parent 350a4fc commit 14eae72
Show file tree
Hide file tree
Showing 15 changed files with 1,360 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,14 @@
"schema": {
"$ref": "#/components/schemas/transaction_id"
}
},
"id": {
"name": "id",
"summary": "ID of the transaction.",
"description": "The unique identifier of this transaction.",
"required": true,
"schema": {
"$ref": "#/components/schemas/transaction_id"
}
}
}
8 changes: 8 additions & 0 deletions openrpc/src/anchor-platform/examples/datetime.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"name": "datetime",
"value": "2023-08-04T10:04:06.280923Z"
},
"created_at": {
"name": "created_at",
"value": "2023-08-04T10:04:06.280923Z"
},
"started_at": {
"name": "started_at",
"value": "2023-08-04T10:04:06.280923Z"
Expand All @@ -18,5 +22,9 @@
"funds_sent_at": {
"name": "funds_sent_at",
"value": "2023-07-04T12:34:38Z"
},
"user_action_required_by": {
"name": "user_action_required_by",
"value": "2023-07-04T12:34:38Z"
}
}
98 changes: 98 additions & 0 deletions openrpc/src/anchor-platform/examples/platform_transaction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"platformTransactionResponse": {
"name": "platformTransactionResponse",
"value": {
"id": "1c186184-09ee-486c-82a7-aa7a0ab1119d",
"sep": "31",
"kind": "receive",
"status": "completed",
"funding_method": "SWIFT",
"amount_expected": {
"amount": "100",
"asset": "iso4217:USD"
},
"amount_in": {
"amount": "100.0000",
"asset": "iso4217:USD"
},
"amount_out": {
"amount": "98.0000000",
"asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
},
"fee_details": {
"total": "2.0000",
"asset": "iso4217:USD"
},
"quote_id": "quote-id",
"message": "Please don\u0027t forget to foo bar",
"refunds": {
"amount_refunded": {
"amount": "90.0000",
"asset": "iso4217:USD"
},
"amount_fee": {
"amount": "8.0000",
"asset": "iso4217:USD"
},
"payments": [
{
"id": "1111",
"id_type": "stellar",
"amount": {
"amount": "50.0000",
"asset": "iso4217:USD"
},
"fee": {
"amount": "4.0000",
"asset": "iso4217:USD"
}
},
{
"id": "2222",
"id_type": "stellar",
"amount": {
"amount": "40.0000",
"asset": "iso4217:USD"
},
"fee": {
"amount": "4.0000",
"asset": "iso4217:USD"
}
}
]
},
"stellar_transactions": [
{
"id": "stellar-tx-id",
"memo": "my-memo",
"memo_type": "text",
"envelope": "here_comes_the_envelope",
"payments": [
{
"id": "payment-id",
"amount": {
"amount": "100.0000",
"asset": "iso4217:USD"
},
"payment_type": "payment",
"source_account": "GB4GJAV4Q7DPGU7WI3H5TMVKEYZJ4JFLFEF3O3TRJKDPXK7NAMRBXWFL",
"destination_account": "GDIN5ZULIOT5YPBIXJXFGNH4TCNTDKIA4ZF6QQE3S2P5P44BHCQQJNDC"
}
]
}
],
"external_transaction_id": "external-tx-id",
"customers": {
"sender": {
"id": "sender-id"
},
"receiver": {
"id": "receiver-id"
}
},
"creator": {
"id": "creator-id"
}
}
}
}
4 changes: 4 additions & 0 deletions openrpc/src/anchor-platform/examples/transaction_id.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"external_transaction_id": {
"name": "external_transaction_id",
"value": "3320c6faad48c3cf39b6d4ac15ed50b6e5868b62551e69cde15df2d66c8ca360"
},
"id": {
"name": "id",
"value": "1c186184-09ee-486c-82a7-aa7a0ab1119d"
}
}
32 changes: 32 additions & 0 deletions openrpc/src/anchor-platform/methods/get_transaction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "get_transaction",
"summary": "Retrieve a transaction.",
"description": "Retrieve a transaction by its ID.",
"paramStructure": "by-name",
"tags": [
{ "name": "SEP-6" },
{ "name": "SEP-24" },
{ "name": "SEP-31" }
],
"params": [
{ "$ref": "#/components/contentDescriptors/id" }
],
"result": {
"name": "get_transactionResponse",
"schema": {
"$ref": "#/components/schemas/platform_transaction"
}
},
"examples": [
{
"name": "get_transactionExample",
"description": "Example request to the `get_transaction` method.",
"params": [
{ "$ref": "#/components/examples/id" }
],
"result": {
"$ref": "#/components/examples/platformTransactionResponse"
}
}
]
}
12 changes: 12 additions & 0 deletions openrpc/src/anchor-platform/schemas/account.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"source_account": {
"title": "source_account",
"description":"The account being debited in the Stellar Network.",
"type": "string"
},
"destination_account": {
"title": "destination_account",
"description":"The account being credited in the Stellar Network.",
"type": "string"
}
}
32 changes: 32 additions & 0 deletions openrpc/src/anchor-platform/schemas/customer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"stellar_id": {
"description": "A object that identify end-user. \nFor a SEP-12 customer, the `id` field should be sufficient to fully identify the customer in the business' Backend. \nFor a SEP-31 Sending Anchor, the `account` and `memo` fields should be used. \nFor a SEP-6 or SEP-24 Anchor, the `account` and `memo` fields should be used.",
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The `id` of the customer registered through SEP-12."
},
"account": {
"type": "string",
"description": "Either the Stellar account or Muxed account address of the on-chain entity."
},
"memo": {
"type": "string",
"description": "The memo value identifying a customer with a shared account, where the shared account is `account`."
}
}
},
"customers": {
"description": "The Identification info of the sending and receiving customers. If they were created through [SEP-12](https://stellar.org/protocol/sep-12),\n this object should contain the SEP-12 customer `id`. Otherwise, the `account` address of the customer.",
"type": "object",
"properties": {
"sender": {
"$ref": "#/components/schemas/stellar_id"
},
"receiver": {
"$ref": "#/components/schemas/stellar_id"
}
}
}
}
10 changes: 10 additions & 0 deletions openrpc/src/anchor-platform/schemas/datetime.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"description": "A date and time.",
"type": "string"
},
"created_at": {
"title": "created_at",
"description": "The date and time when the transaction is created.",
"$ref": "#/components/schemas/datetime"
},
"started_at": {
"title": "started_at",
"description": "Start date and time of transaction.",
Expand All @@ -23,5 +28,10 @@
"title": "transfer_received_at",
"description": "The date and time of receiving transfer.",
"$ref": "#/components/schemas/datetime"
},
"user_action_required_by": {
"title": "user_action_required_by",
"description": "Time and date by which user action is required.",
"$ref": "#/components/schemas/datetime"
}
}
12 changes: 12 additions & 0 deletions openrpc/src/anchor-platform/schemas/memo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"memo": {
"title": "memo",
"type": "string"
},
"memo_type": {
"title": "memo_type",
"description": "The memo type of the transaction in the Stellar network. Should be present if memo is not null.",
"type": "string",
"enum": ["id", "hash", "text"]
}
}
107 changes: 107 additions & 0 deletions openrpc/src/anchor-platform/schemas/platform_transaction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"platform_transaction": {
"title": "Platform Transaction",
"description": "A platform transaction object",
"type": "object",
"properties": {
"id": {
"$ref": "#/components/schemas/transaction_id"
},
"sep": {
"$ref": "#/components/schemas/sep"
},
"kind": {
"$ref": "#/components/schemas/kind"
},
"status": {
"$ref": "#/components/schemas/status"
},
"funding_method": {
"description": "Funding method used for transferring or settling assets.",
"type": "string"
},
"type": {
"description": "DEPRECATED in favor of funding_method. Type of deposit, withdrawal or receive.",
"type": "string"
},
"amount_expected": {
"$ref": "#/components/schemas/amount_expected"
},
"amount_in": {
"$ref": "#/components/schemas/amount_in"
},
"amount_out": {
"$ref": "#/components/schemas/amount_out"
},
"fee_details": {
"$ref": "#/components/schemas/fee_details"
},
"quote_id": {
"$ref": "#/components/schemas/quote_id"
},
"started_at": {
"$ref": "#/components/schemas/started_at"
},
"updated_at": {
"$ref": "#/components/schemas/updated_at"
},
"completed_at": {
"$ref": "#/components/schemas/completed_at"
},
"transfer_received_at": {
"$ref": "#/components/schemas/transfer_received_at"
},
"user_action_required_by": {
"$ref": "#/components/schemas/user_action_required_by"
},
"message": {
"description": "Human readable explanation of transaction status",
"$ref": "#/components/schemas/message"
},
"refunds": {
"$ref": "#/components/schemas/refunds"
},
"stellar_transactions": {
"type": "array",
"items": {
"$ref": "#/components/schemas/stellar_transaction"
}
},
"source_account": {
"$ref": "#/components/schemas/source_account"
},
"destination_account": {
"$ref": "#/components/schemas/destination_account"
},
"external_transaction_id": {
"$ref": "#/components/schemas/transaction_id"
},
"memo": {
"$ref": "#/components/schemas/memo"
},
"memo_type": {
"$ref": "#/components/schemas/memo_type"
},
"refund_memo": {
"$ref": "#/components/schemas/memo"
},
"refund_memo_type": {
"$ref": "#/components/schemas/memo_type"
},
"client_domain": {
"description": "The domain of the client.",
"type": "string"
},
"client_name": {
"description": "The domain of the client.",
"type": "string"
},
"customers": {
"$ref": "#/components/schemas/customers"
},
"creator": {
"$ref": "#/components/schemas/stellar_id"
}
}
}
}
Loading

0 comments on commit 14eae72

Please sign in to comment.