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, );