Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Added type and mergedAccount to fetchPayments (#179)
Browse files Browse the repository at this point in the history
* Added type and mergedAccount to fetchPayments

* Bump version to 0.2.0-rc.2
  • Loading branch information
quietbits authored Sep 22, 2020
1 parent 173e4b2 commit b412fd3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## In master

- [DataProvider] Added `type` and `mergedAccount` to `fetchPayments` response.

## [v0.2.0-rc.1](https://github.com/stellar/js-stellar-wallets/compare/v0.1.0-rc.1...v0.2.0-rc.1)

- [KeyManager] Added Trezor wallet.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/wallet-sdk",
"version": "0.2.0-rc.1",
"version": "0.2.0-rc.2",
"description": "Libraries to help you write Stellar-enabled wallets in Javascript",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
14 changes: 11 additions & 3 deletions src/data/makeDisplayablePayments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ async function getAccountMergePaymentAmount(
}
}

function getMergedAccount(payment: ServerApi.AccountMergeOperationRecord) {
return {
publicKey: payment.source_account,
};
}

export async function makeDisplayablePayments(
subjectAccount: Account,
payments: Array<
Expand All @@ -69,9 +75,7 @@ export async function makeDisplayablePayments(

if (isCreateAccount(payment)) {
otherAccount = {
publicKey: isRecipient
? payment.source_account
: payment.source_account,
publicKey: payment.funder,
};
} else {
otherAccount = { publicKey: isRecipient ? payment.from : payment.to };
Expand All @@ -95,12 +99,14 @@ export async function makeDisplayablePayments(

// "account_merge" record does not have "amount" property
let accountMergePaymentAmount;
let mergedAccount;

if (isAccountMerge(payment)) {
accountMergePaymentAmount = await getAccountMergePaymentAmount(
payment,
subjectAccount.publicKey,
);
mergedAccount = getMergedAccount(payment);
}

let transaction: ServerApi.TransactionRecord | undefined;
Expand Down Expand Up @@ -138,12 +144,14 @@ export async function makeDisplayablePayments(
? new BigNumber(payment.source_amount)
: undefined,
transactionId: payment.transaction_hash,
type: payment.type,
...(transaction
? {
memo: transaction.memo,
memoType: transaction.memo_type,
}
: {}),
mergedAccount,
};
},
),
Expand Down
3 changes: 3 additions & 0 deletions src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ export interface Payment {
sourceAmount?: BigNumber;

transactionId: string;
type: Horizon.OperationResponseType;

memo?: Memo | string;
memoType?: MemoType;

mergedAccount?: Account;
}

export interface Balance {
Expand Down

0 comments on commit b412fd3

Please sign in to comment.