From 5fbd7fcc9c6b06a9c928e589ab5146401d0154f1 Mon Sep 17 00:00:00 2001 From: rrr523 Date: Mon, 20 Nov 2023 15:08:52 +0800 Subject: [PATCH 1/2] feat: ListUserPaymentAccounts add config --- .changeset/great-elephants-hide.md | 5 +++++ packages/js-sdk/src/api/config.ts | 3 +++ packages/js-sdk/src/api/payment.ts | 12 ++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changeset/great-elephants-hide.md create mode 100644 packages/js-sdk/src/api/config.ts diff --git a/.changeset/great-elephants-hide.md b/.changeset/great-elephants-hide.md new file mode 100644 index 00000000..a95b6d1b --- /dev/null +++ b/.changeset/great-elephants-hide.md @@ -0,0 +1,5 @@ +--- +'@bnb-chain/greenfield-js-sdk': patch +--- + +feat: ListUserPaymentAccounts add config for endpoint diff --git a/packages/js-sdk/src/api/config.ts b/packages/js-sdk/src/api/config.ts new file mode 100644 index 00000000..1797598e --- /dev/null +++ b/packages/js-sdk/src/api/config.ts @@ -0,0 +1,3 @@ +export interface SpConfig { + endpoint: string; +} diff --git a/packages/js-sdk/src/api/payment.ts b/packages/js-sdk/src/api/payment.ts index 31ec7b71..c23b24d4 100644 --- a/packages/js-sdk/src/api/payment.ts +++ b/packages/js-sdk/src/api/payment.ts @@ -50,6 +50,7 @@ import { ListUserPaymentAccountsResponse, ListUserPaymentAccountsResquest, } from '../types/sp/ListUserPaymentAccounts'; +import { SpConfig } from './config'; import { Sp } from './sp'; export interface IPayment { @@ -220,12 +221,19 @@ export class Payment implements IPayment { public async listUserPaymentAccounts( params: ListUserPaymentAccountsResquest, authType: AuthType, + config?: SpConfig, ) { try { - const sp = await this.sp.getInServiceSP(); + let endpoint = ''; + if (config && config.endpoint) { + endpoint = config.endpoint; + } else { + const sp = await this.sp.getInServiceSP(); + endpoint = sp.endpoint; + } const { url, optionsWithOutHeaders, reqMeta } = getListUserPaymentAccountMetaInfo( - sp.endpoint, + endpoint, params, ); From ac3dd529c958f953e99fd4bd450bcbc45c22806b Mon Sep 17 00:00:00 2001 From: rrr523 Date: Mon, 20 Nov 2023 17:29:50 +0800 Subject: [PATCH 2/2] feat: Add SpConfig --- packages/js-sdk/src/api/payment.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/js-sdk/src/api/payment.ts b/packages/js-sdk/src/api/payment.ts index c23b24d4..1039e48a 100644 --- a/packages/js-sdk/src/api/payment.ts +++ b/packages/js-sdk/src/api/payment.ts @@ -114,6 +114,7 @@ export interface IPayment { listUserPaymentAccounts( params: ListUserPaymentAccountsResquest, authType: AuthType, + config?: SpConfig, ): Promise>; }