Skip to content

Commit

Permalink
Relax SEP-24 transaction schema (#106)
Browse files Browse the repository at this point in the history
* Relax SEP-24 transaction schema

* Version bump
  • Loading branch information
Ifropc authored Dec 20, 2022
1 parent d24af54 commit 46431f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion @stellar/anchor-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/anchor-tests",
"version": "0.5.6",
"version": "0.5.7",
"description": "stellar-anchor-tests is a library and command line interface for testing Stellar anchors.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
25 changes: 6 additions & 19 deletions @stellar/anchor-tests/src/schemas/sep24.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ export const transactionSchema = {
"kind",
"status",
"more_info_url",
"amount_in",
"amount_out",
"amount_fee",
"started_at",
"completed_at",
"stellar_transaction_id",
"refunded",
],
},
Expand All @@ -144,14 +139,8 @@ export const transactionsSchema = {

export function getTransactionSchema(isDeposit: boolean) {
const schema = JSON.parse(JSON.stringify(transactionSchema));
const requiredDepositParams = ["from", "to"];
const requiredWithdrawParams = [
"from",
"to",
"withdraw_memo",
"withdraw_memo_type",
"withdraw_anchor_account",
];
const requiredDepositParams = ["to"];
const requiredWithdrawParams = ["from"];

const depositProperties = {
deposit_memo: {
Expand Down Expand Up @@ -187,14 +176,12 @@ export function getTransactionSchema(isDeposit: boolean) {
};

if (isDeposit) {
schema.properties.transaction.required = schema.properties.transaction.required.concat(
requiredDepositParams,
);
schema.properties.transaction.required =
schema.properties.transaction.required.concat(requiredDepositParams);
Object.assign(schema.properties.transaction.properties, depositProperties);
} else {
schema.properties.transaction.required = schema.properties.transaction.required.concat(
requiredWithdrawParams,
);
schema.properties.transaction.required =
schema.properties.transaction.required.concat(requiredWithdrawParams);
Object.assign(schema.properties.transaction.properties, withdrawProperties);
}

Expand Down

0 comments on commit 46431f0

Please sign in to comment.