From 1c24bdec7016c5338ae8a6e35a07876a3cb96998 Mon Sep 17 00:00:00 2001 From: rrr523 <59029880+rrr523@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:30:24 +0800 Subject: [PATCH] feat: ListUserPaymentAccounts add config (#392) * feat: ListUserPaymentAccounts add config * feat: Add SpConfig --- .changeset/great-elephants-hide.md | 5 +++++ packages/js-sdk/src/api/config.ts | 3 +++ packages/js-sdk/src/api/payment.ts | 13 +++++++++++-- 3 files changed, 19 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..1039e48a 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 { @@ -113,6 +114,7 @@ export interface IPayment { listUserPaymentAccounts( params: ListUserPaymentAccountsResquest, authType: AuthType, + config?: SpConfig, ): Promise>; } @@ -220,12 +222,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, );