Skip to content

Commit

Permalink
feat: ListUserPaymentAccounts add config
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Nov 20, 2023
1 parent 10a2c31 commit 5fbd7fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-elephants-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/greenfield-js-sdk': patch
---

feat: ListUserPaymentAccounts add config for endpoint
3 changes: 3 additions & 0 deletions packages/js-sdk/src/api/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface SpConfig {
endpoint: string;
}
12 changes: 10 additions & 2 deletions packages/js-sdk/src/api/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
ListUserPaymentAccountsResponse,
ListUserPaymentAccountsResquest,
} from '../types/sp/ListUserPaymentAccounts';
import { SpConfig } from './config';
import { Sp } from './sp';

export interface IPayment {
Expand Down Expand Up @@ -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,
);

Expand Down

0 comments on commit 5fbd7fc

Please sign in to comment.