Skip to content

Commit

Permalink
[ANCHOR-353] SEP-6: Fix required transaction fields (#122)
Browse files Browse the repository at this point in the history
* Fix required SEP-6 transaction fields

* Bump version
  • Loading branch information
philipliu authored Oct 5, 2023
1 parent 39637de commit cf47531
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 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.6.0",
"version": "0.6.1",
"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
28 changes: 7 additions & 21 deletions @stellar/anchor-tests/src/schemas/sep6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export const transactionSchema = {
status: {
type: "string",
pattern:
"completed|pending_external|pending_anchor|pending_stellar|pending_trust|pending_user|pending_user_transfer_start|incomplete|no_market|too_small|too_large|error",
"completed|pending_external|pending_anchor|pending_stellar|pending_trust|pending_user|pending_customer_info_update|pending_user_transfer_start|incomplete|no_market|too_small|too_large|error",
},
more_info_url: {
type: "string",
Expand Down Expand Up @@ -255,18 +255,7 @@ export const transactionSchema = {
type: ["string", "null"],
},
},
required: [
"id",
"kind",
"status",
"amount_in",
"amount_out",
"amount_fee",
"started_at",
"completed_at",
"stellar_transaction_id",
"refunded",
],
required: ["id", "kind", "status", "started_at"],
},
},
required: ["transaction"],
Expand All @@ -290,10 +279,9 @@ export const transactionsSchema = {

export function getTransactionSchema(isDeposit: boolean) {
const schema = JSON.parse(JSON.stringify(transactionSchema));
const requiredDepositParams = ["from", "to"];
const requiredDepositParams = ["to"];
const requiredWithdrawParams = [
"from",
"to",
"withdraw_memo",
"withdraw_memo_type",
"withdraw_anchor_account",
Expand Down Expand Up @@ -333,14 +321,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
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"winston": "^3.3.3"
},
"peerDependencies": {
"@stellar/anchor-tests": "0.6.0"
"@stellar/anchor-tests": "0.6.1"
}
}

0 comments on commit cf47531

Please sign in to comment.