From 236454915a2c57f35d64421e09d7b2979b325c81 Mon Sep 17 00:00:00 2001 From: Philip Liu <12836897+philipliu@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:55:13 -0400 Subject: [PATCH] Make SEP-31 transfer fields optional (#143) * Make SEP-31 tranfer fields optional * Bump version --- @stellar/anchor-tests/package.json | 2 +- @stellar/anchor-tests/src/schemas/sep31.ts | 10 ++-------- @stellar/anchor-tests/src/tests/sep31/transactions.ts | 8 ++++++-- server/package.json | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/@stellar/anchor-tests/package.json b/@stellar/anchor-tests/package.json index 80d258c..679d280 100644 --- a/@stellar/anchor-tests/package.json +++ b/@stellar/anchor-tests/package.json @@ -1,6 +1,6 @@ { "name": "@stellar/anchor-tests", - "version": "0.6.12", + "version": "0.6.13", "description": "stellar-anchor-tests is a library and command line interface for testing Stellar anchors.", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/@stellar/anchor-tests/src/schemas/sep31.ts b/@stellar/anchor-tests/src/schemas/sep31.ts index 8274d40..ef1a7c2 100644 --- a/@stellar/anchor-tests/src/schemas/sep31.ts +++ b/@stellar/anchor-tests/src/schemas/sep31.ts @@ -15,7 +15,7 @@ export const postTransactionsSchema = { type: "string", }, }, - required: ["id", "stellar_memo", "stellar_memo_type", "stellar_memo"], + required: ["id"], additionalProperties: false, }; @@ -87,13 +87,7 @@ export const getTransactionSchema = { type: "boolean", }, }, - required: [ - "id", - "status", - "stellar_account_id", - "stellar_memo", - "stellar_memo_type", - ], + required: ["id", "status"], }, }, required: ["transaction"], diff --git a/@stellar/anchor-tests/src/tests/sep31/transactions.ts b/@stellar/anchor-tests/src/tests/sep31/transactions.ts index 51b7e33..d24fd51 100644 --- a/@stellar/anchor-tests/src/tests/sep31/transactions.ts +++ b/@stellar/anchor-tests/src/tests/sep31/transactions.ts @@ -255,7 +255,9 @@ const canCreateTransaction: Test = { return result; } try { - Keypair.fromPublicKey(responseBody.stellar_account_id); + if (responseBody.stellar_account_id) { + Keypair.fromPublicKey(responseBody.stellar_account_id); + } } catch { result.failure = makeFailure(this.failureModes.INVALID_SCHEMA, { errors: "'stellar_acocunt_id' must be a valid Stellar public key", @@ -267,7 +269,9 @@ const canCreateTransaction: Test = { memoValue = Buffer.from(responseBody.stellar_memo, "base64"); } try { - new Memo(responseBody.stellar_memo_type, memoValue); + if (memoValue) { + new Memo(responseBody.stellar_memo_type, memoValue); + } } catch { result.failure = makeFailure(this.failureModes.INVALID_SCHEMA, { errors: "invalid 'stellar_memo' for 'stellar_memo_type'", diff --git a/server/package.json b/server/package.json index da961f0..d45b446 100644 --- a/server/package.json +++ b/server/package.json @@ -30,6 +30,6 @@ "winston": "^3.3.3" }, "peerDependencies": { - "@stellar/anchor-tests": "0.6.12" + "@stellar/anchor-tests": "0.6.13" } }