Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claimable balance: bug fix when claiming XLM #248

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ducks/claimAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const claimAssetAction = createAsyncThunk<
const networkConfig = getNetworkConfig(pubnet);
const { assetCode, assetIssuer } = balance;
// Cannot use balance.assetString because it's an id
const assetString = `${assetCode}:${assetIssuer}`;
const assetString = assetIssuer ? `${assetCode}:${assetIssuer}` : assetCode;

log.instruction({
title: `Claiming asset \`${assetString}\``,
Expand All @@ -37,7 +37,7 @@ export const claimAssetAction = createAsyncThunk<
let trustedAssetAdded;

try {
if (!data?.balances[assetString]) {
if (assetString !== "XLM" && !data?.balances[assetString]) {
log.instruction({
title: "Not a trusted asset, need to add a trustline",
});
Expand Down
10 changes: 9 additions & 1 deletion src/ducks/claimableBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getNetworkConfig } from "helpers/getNetworkConfig";
import { log } from "helpers/log";
import {
ActionStatus,
AssetType,
ClaimableAsset,
ClaimableBalancesInitialState,
RejectMessage,
Expand All @@ -33,7 +34,14 @@ export const fetchClaimableBalancesAction = createAsyncThunk<

claimableBalanceResponse.records.forEach(
(record: ServerApi.ClaimableBalanceRecord) => {
const [assetCode, assetIssuer] = record.asset.split(":");
let assetCode;
let assetIssuer;

if (record.asset === AssetType.NATIVE) {
assetCode = "XLM";
} else {
[assetCode, assetIssuer] = record.asset.split(":");
}

const cleanedRecord = {
id: record.id,
Expand Down