Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f44071f
Change `balance` type from `number` to `string` in token and account …
Comp0te Oct 23, 2025
1737d5f
Refactor repositories to utilize environment-based and network-based …
Comp0te Oct 23, 2025
a6da935
Update `cep-nft-transfer` to specify `CLTypeUInt8` for `CLOption` ini…
Comp0te Nov 10, 2025
043df32
Add support for handling CEP-18 entry points and improve `TxSignature…
Comp0te Dec 1, 2025
6ab3703
Add `iconUrl` support to deploy DTOs and entities; refine CEP-18 entr…
Comp0te Dec 1, 2025
9375f47
Refactor `TxSignatureRequestDto` and related actions to replace `sign…
Comp0te Dec 15, 2025
ad5cad1
Refactor CEP-18 and NFT entry point validation logic by introducing `…
Comp0te Dec 15, 2025
e5bdabb
Merge remote-tracking branch 'origin/master' into release/1.1.8
Comp0te Dec 15, 2025
e7f9fb3
Remove unused `isCep18Action` function from `TxSignatureRequestDto` t…
Comp0te Dec 15, 2025
6209150
Add `WASM` and `WASM_PROXY` deploy types and related utilities for de…
Comp0te Dec 18, 2025
9e68c6e
Extend `Cep18DeployDto` to handle `recipientAccountHash` by utilizing…
Comp0te Dec 22, 2025
3c21b4e
Lockfile updates: bump dependencies (`@noble/curves`, `@scure/base`, …
Comp0te Dec 22, 2025
3842cd7
Add support for customizable HTTP Authorization headers in setup and …
Comp0te Mar 2, 2026
1c11b29
Bump `apisauce` to `^3.2.2`, `axios` to `^1.13.6`, and `casper-js-sdk…
Comp0te Mar 2, 2026
079845a
Remove unused `CEP_18_ACTION_ENTRY_POINTS` import from `TxSignatureRe…
Comp0te Mar 2, 2026
bae9073
Add `getTransactionsFeed` method to deploys repository and extend DTO…
Comp0te Mar 5, 2026
1ccbfcb
Refactor market data handling by replacing `coingecko_data` and `frie…
Comp0te Mar 5, 2026
41bcc3f
Bump version to 1.2.0 in package.json.
Comp0te Mar 5, 2026
3185019
Merge remote-tracking branch 'origin/master' into release/1.2.0
Comp0te Mar 5, 2026
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CasperWalletCore",
"version": "1.1.5",
"version": "1.2.0",
"main": "index.ts",
"repository": {
"type": "git",
Expand All @@ -15,8 +15,8 @@
"@noble/hashes": "^1.8.0",
"@react-native/typescript-config": "0.74.83",
"@types/uuid": "^10.0.0",
"apisauce": "^3.1.1",
"casper-js-sdk": "5.0.6",
"apisauce": "^3.2.2",
"casper-js-sdk": "5.0.10",
"date-fns": "^2.30.0",
"decimal.js": "^10.4.3",
"lru-cache": "10.4.3",
Expand Down
4 changes: 2 additions & 2 deletions src/data/data-providers/http/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export class HttpDataProvider implements IHttpDataProvider {
});
}

setAuthHeader(token: string) {
this.instance.setHeader(HttpDataProvider.AUTH_HEADER_KEY, `Bearer ${token}`);
setAuthHeader(value: string) {
this.instance.setHeader(HttpDataProvider.AUTH_HEADER_KEY, value);
}

removeAuthHeader() {
Expand Down
17 changes: 17 additions & 0 deletions src/data/dto/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SupportedMarketDataProviders,
} from '../../domain';
import { Maybe } from '../../typings';
import { ITokenMarketData } from '../repositories';

export function getCsprFiatAmount(amount: string | number, rate?: string | number) {
const isZeroRate = Number(rate ?? 0) === 0;
Expand Down Expand Up @@ -95,6 +96,8 @@ export function getMarketDataProviderUrl(
latestVersionContractHash?: string | null,
) {
switch (marketDataProvider) {
case 'CsprTrade':
return 'https://cspr.trade/'; // TODO link to token page
case 'CoinGecko':
return coingeckoId ? `https://www.coingecko.com/en/coins/${coingeckoId}` : null;
case 'FriendlyMarket':
Expand Down Expand Up @@ -122,3 +125,17 @@ export function isNftAction(entryPointName: string, contractTypeId?: Maybe<numbe
NFT_ACTION_ENTRY_POINTS.includes(entryPointName.toLowerCase())
);
}

export function getPreferredTokenMarketData(tokenMarketData?: ITokenMarketData[] | null) {
if (!tokenMarketData || !tokenMarketData.length) {
return null;
}

return [...tokenMarketData].sort((a, b) => a.dex_id - b.dex_id)?.[0];
}

export const dexIdToMarketDataProviderMap: Record<number, SupportedMarketDataProviders> = {
1: 'CsprTrade',
2: 'CoinGecko',
3: 'FriendlyMarket',
};
13 changes: 5 additions & 8 deletions src/data/dto/deploys/ActionResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
NFTEntryPointType,
} from '../../../domain';
import { getAccountInfoFromMap, getNftTokenUrlsMap } from '../common';
import { ExtendedCloudDeploy } from '../../repositories';
import { ExtendedCloudDeploy, ICloudTransactionFeedItem } from '../../repositories';
import { getCsprFiatAmount } from '../common';

const mapCep18EntryPointIdToName: Record<number, CEP18EntryPointType> = {
Expand All @@ -36,7 +36,7 @@ const mapNftentryPointIdToName: Record<number, NFTEntryPointType> = {

export function getCep18ActionsResult(
activePublicKey: string,
deploy?: Partial<ExtendedCloudDeploy>,
deploy?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
return (
Expand Down Expand Up @@ -93,7 +93,7 @@ export function getNftActionsResult(
activePublicKey: string,
network: Network,
collectionHash: string,
deploy?: Partial<ExtendedCloudDeploy>,
deploy?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
return (
Expand Down Expand Up @@ -141,7 +141,7 @@ export function getNftActionsResult(

export function getTransferActionsResult(
activePublicKey: string,
deploy?: Partial<ExtendedCloudDeploy>,
deploy?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
return (
Expand Down Expand Up @@ -180,10 +180,7 @@ export function getTransferActionsResult(
amount: action.amount,
decimalAmount: getDecimalTokenBalance(action.amount, CSPR_COIN.decimals),
formattedDecimalAmount: formatTokenBalance(action.amount, CSPR_COIN.decimals),
fiatAmount: getCsprFiatAmount(
action.amount,
deploy?.time_transaction_currency_rate ?? deploy?.rate,
),
fiatAmount: getCsprFiatAmount(action.amount, deploy?.rate),
};
}) ?? []
);
Expand Down
4 changes: 2 additions & 2 deletions src/data/dto/deploys/AssociatedKeysDeployDto.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DeployDto } from './DeployDto';
import { getEntryPoint } from './common';
import { ExtendedCloudDeploy } from '../../repositories';
import { ExtendedCloudDeploy, ICloudTransactionFeedItem } from '../../repositories';
import { IAccountInfo, IAssociatedKeysDeploy, Network } from '../../../domain';
import { Maybe } from '../../../typings';

export class AssociatedKeysDeployDto extends DeployDto implements IAssociatedKeysDeploy {
constructor(
network: Network,
activePublicKey: string,
data?: Partial<ExtendedCloudDeploy>,
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
super(network, activePublicKey, data, accountInfoMap);
Expand Down
15 changes: 7 additions & 8 deletions src/data/dto/deploys/AuctionDeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { getDeployAmount, getEntryPoint } from './common';
import { deriveKeyType, getAccountInfoFromMap } from '../common';
import { formatTokenBalance, getDecimalTokenBalance } from '../../../utils';
import { DeployDto } from './DeployDto';
import { ExtendedCloudDeploy } from '../../repositories';
import { ExtendedCloudDeploy, ICloudTransactionFeedItem } from '../../repositories';
import { Maybe } from '../../../typings';
import { getCsprFiatAmount } from '../common';

export class AuctionDeployDto extends DeployDto implements IAuctionDeploy {
constructor(
network: Network,
activePublicKey: string,
data?: Partial<ExtendedCloudDeploy>,
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
super(network, activePublicKey, data, accountInfoMap);
Expand All @@ -29,10 +29,7 @@ export class AuctionDeployDto extends DeployDto implements IAuctionDeploy {
this.amount = getDeployAmount(data?.args);
this.decimalAmount = getDecimalTokenBalance(this.amount, this.decimals);
this.formattedDecimalAmount = formatTokenBalance(this.amount, this.decimals);
this.fiatAmount = getCsprFiatAmount(
this.amount,
data?.time_transaction_currency_rate ?? data?.rate,
);
this.fiatAmount = getCsprFiatAmount(this.amount, data?.rate);

const fromValidator = getFromValidator(data);
const fromValidatorKeyType = deriveKeyType(fromValidator);
Expand Down Expand Up @@ -76,7 +73,9 @@ export class AuctionDeployDto extends DeployDto implements IAuctionDeploy {
readonly fiatAmount: string;
}

function getFromValidator(data?: Partial<ExtendedCloudDeploy>): string | null {
function getFromValidator(
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
): string | null {
const entryPoint = getEntryPoint(data);

if (entryPoint === 'undelegate' && data?.args?.validator?.cl_type === 'PublicKey') {
Expand All @@ -88,7 +87,7 @@ function getFromValidator(data?: Partial<ExtendedCloudDeploy>): string | null {
return null;
}

function getToValidator(data?: Partial<ExtendedCloudDeploy>) {
function getToValidator(data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>) {
const entryPoint = getEntryPoint(data);

if (data?.args?.new_validator) {
Expand Down
42 changes: 18 additions & 24 deletions src/data/dto/deploys/Cep18DeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
isNotEmpty,
} from '../../../utils';
import { DeployDto } from './DeployDto';
import { ExtendedCloudDeploy } from '../../repositories';
import { ExtendedCloudDeploy, ICloudTransactionFeedItem } from '../../repositories';
import {
AccountKeyType,
CEP18EntryPointType,
Expand All @@ -23,13 +23,18 @@ import {
SupportedMarketDataProviders,
} from '../../../domain';
import { Maybe } from '../../../typings';
import { getAccountInfoFromMap, getMarketDataProviderUrl } from '../common';
import {
dexIdToMarketDataProviderMap,
getAccountInfoFromMap,
getMarketDataProviderUrl,
getPreferredTokenMarketData,
} from '../common';

export class Cep18DeployDto extends DeployDto implements ICep18Deploy {
constructor(
network: Network,
activePublicKey: string,
data?: Partial<ExtendedCloudDeploy>,
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
super(network, activePublicKey, data, accountInfoMap);
Expand All @@ -51,26 +56,15 @@ export class Cep18DeployDto extends DeployDto implements ICep18Deploy {
this.recipientKeyType = this.recipientAccountInfo?.publicKey ? 'publicKey' : recipientKeyType;
this.isReceive = isKeysEqual(activePublicKey, this.recipientKey);

this.fiatAmount = getCep18FiatAmount(
this.decimalAmount,
data?.contract_package?.coingecko_data?.price ??
data?.contract_package?.friendlymarket_data?.price ??
0,
false,
);
this.formattedFiatAmount = getCep18FiatAmount(
this.decimalAmount,
data?.contract_package?.coingecko_data?.price ??
data?.contract_package?.friendlymarket_data?.price ??
0,
true,
);
const tokenMarketData = getPreferredTokenMarketData(data?.contract_package?.token_market_data);
const fiatRate = tokenMarketData?.latest_rate ?? 0;

this.fiatAmount = getCep18FiatAmount(this.decimalAmount, fiatRate, false);
this.formattedFiatAmount = getCep18FiatAmount(this.decimalAmount, fiatRate, true);
this.fiatCurrency = 'USD';
this.marketDataProvider = data?.contract_package?.coingecko_data?.price
? 'CoinGecko'
: data?.contract_package?.friendlymarket_data?.price
? 'FriendlyMarket'
: null;
this.marketDataProvider = tokenMarketData
? dexIdToMarketDataProviderMap[tokenMarketData.dex_id]
: null;
this.marketDataProviderUrl = getMarketDataProviderUrl(
this.marketDataProvider,
data?.contract_package?.coingecko_id,
Expand Down Expand Up @@ -99,7 +93,7 @@ export class Cep18DeployDto extends DeployDto implements ICep18Deploy {
}

export function getCep18RecipientKeyAndType(
data?: Partial<ExtendedCloudDeploy>,
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
): Pick<ICep18Deploy, 'recipientKey' | 'recipientKeyType'> {
const recipient = guardedDeriveSplitDataFromArguments(data?.args?.recipient, 'Hash');
const recipientAccount = guardedDeriveSplitDataFromArguments(data?.args?.recipient, 'Account');
Expand Down Expand Up @@ -135,7 +129,7 @@ export function getCep18RecipientKeyAndType(

export function derivePublicKeyFromCep18ActionResults(
accountHash: string,
deploy?: Partial<ExtendedCloudDeploy>,
deploy?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
) {
return deploy?.ft_token_actions
?.reduce<string[]>((acc, cur) => {
Expand Down
34 changes: 14 additions & 20 deletions src/data/dto/deploys/Cep18transferDeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import {
SupportedMarketDataProviders,
} from '../../../domain';

import { getAccountInfoFromMap, getMarketDataProviderUrl } from '../common';
import {
dexIdToMarketDataProviderMap,
getAccountInfoFromMap,
getMarketDataProviderUrl,
getPreferredTokenMarketData,
} from '../common';
import { getCsprFiatAmount } from '../common';
import { Maybe } from '../../../typings';
import { IErc20TokensTransferResponse } from '../../repositories';
Expand Down Expand Up @@ -78,26 +83,15 @@ export class Cep18TransferDeployDto implements ICep18Deploy {
this.fiatPaymentAmount = getCsprFiatAmount(this.paymentAmount, data?.deploy?.rate);
this.nftActionsResult = [];

this.fiatAmount = getCep18FiatAmount(
this.decimalAmount,
data?.contract_package?.coingecko_data?.price ??
data?.contract_package?.friendlymarket_data?.price ??
0,
false,
);
this.formattedFiatAmount = getCep18FiatAmount(
this.decimalAmount,
data?.contract_package?.coingecko_data?.price ??
data?.contract_package?.friendlymarket_data?.price ??
0,
true,
);
const tokenMarketData = getPreferredTokenMarketData(data?.contract_package?.token_market_data);
const fiatRate = tokenMarketData?.latest_rate ?? 0;

this.fiatAmount = getCep18FiatAmount(this.decimalAmount, fiatRate, false);
this.formattedFiatAmount = getCep18FiatAmount(this.decimalAmount, fiatRate, true);
this.fiatCurrency = 'USD';
this.marketDataProvider = data?.contract_package?.coingecko_data?.price
? 'CoinGecko'
: data?.contract_package?.friendlymarket_data?.price
? 'FriendlyMarket'
: null;
this.marketDataProvider = tokenMarketData
? dexIdToMarketDataProviderMap[tokenMarketData.dex_id]
: null;
this.marketDataProviderUrl = getMarketDataProviderUrl(
this.marketDataProvider,
data?.contract_package?.coingecko_id,
Expand Down
11 changes: 4 additions & 7 deletions src/data/dto/deploys/CsprMarketDeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import {
Network,
} from '../../../domain';
import { DeployDto } from './DeployDto';
import { ExtendedCloudDeploy } from '../../repositories';
import { ExtendedCloudDeploy, ICloudTransactionFeedItem } from '../../repositories';
import { Maybe } from '../../../typings';
import { getAccountInfoFromMap, getCsprFiatAmount, getNftTokenUrlsMap } from '../common';

export class CsprMarketDeployDto extends DeployDto implements ICasperMarketDeploy {
constructor(
network: Network,
activePublicKey: string,
data?: Partial<ExtendedCloudDeploy>,
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
super(network, activePublicKey, data, accountInfoMap);
Expand All @@ -50,10 +50,7 @@ export class CsprMarketDeployDto extends DeployDto implements ICasperMarketDeplo
this.amount = getDeployAmount(data?.args);
this.decimalAmount = getDecimalTokenBalance(this.amount, CSPR_COIN.decimals);
this.formattedDecimalAmount = formatTokenBalance(this.amount, CSPR_COIN.decimals);
this.fiatAmount = getCsprFiatAmount(
this.amount,
data?.time_transaction_currency_rate ?? data?.rate,
);
this.fiatAmount = getCsprFiatAmount(this.amount, data?.rate);
this.iconUrl = data?.contract_package?.icon_url ?? null;
}

Expand All @@ -74,7 +71,7 @@ export class CsprMarketDeployDto extends DeployDto implements ICasperMarketDeplo
}

export function getOffererFormDeploy(
deploy?: Partial<ExtendedCloudDeploy>,
deploy?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
): Pick<ICasperMarketDeploy, 'offererHash' | 'offererHashType'> {
const offererHash = guardedDeriveSplitDataFromArguments(deploy?.args?.offerer, 'Account');

Expand Down
18 changes: 7 additions & 11 deletions src/data/dto/deploys/DeployDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import {
getNftActionsResult,
getTransferActionsResult,
} from './ActionResults';
import { ExtendedCloudDeploy } from '../../repositories';
import { ExtendedCloudDeploy, ICloudTransactionFeedItem } from '../../repositories';
import { Maybe } from '../../../typings';
import { getCsprFiatAmount } from '../common';

export class DeployDto implements IDeploy {
constructor(
network: Network,
activePublicKey: string,
data?: Partial<ExtendedCloudDeploy>,
data?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
accountInfoMap: Record<string, IAccountInfo> = {},
) {
this.deployHash = data?.deploy_hash ?? '';
Expand All @@ -38,16 +38,10 @@ export class DeployDto implements IDeploy {
this.timestamp = data?.timestamp ?? '';
this.cost = data?.consumed_gas ?? '0';
this.formattedCost = formatTokenBalance(this.cost, CSPR_COIN.decimals);
this.fiatCost = getCsprFiatAmount(
this.cost,
data?.time_transaction_currency_rate ?? data?.rate,
);
this.fiatCost = getCsprFiatAmount(this.cost, data?.rate);
this.paymentAmount = data?.payment_amount ?? '0';
this.formattedPaymentAmount = formatTokenBalance(this.paymentAmount, CSPR_COIN.decimals);
this.fiatPaymentAmount = getCsprFiatAmount(
this.paymentAmount,
data?.time_transaction_currency_rate ?? data?.rate,
);
this.fiatPaymentAmount = getCsprFiatAmount(this.paymentAmount, data?.rate);
this.contractHash = data?.contract_hash ?? '';
this.contractPackageHash = data?.contract_package_hash ?? '';
this.iconUrl = data?.contract_package?.icon_url ?? null;
Expand Down Expand Up @@ -97,7 +91,9 @@ export class DeployDto implements IDeploy {
readonly cep18ActionsResult: ICep18ActionsResult[];
}

export function getDeployStatus(deploy?: Partial<ExtendedCloudDeploy>): DeployStatus {
export function getDeployStatus(
deploy?: Partial<ExtendedCloudDeploy | ICloudTransactionFeedItem>,
): DeployStatus {
const status = deploy?.status as DeployStatus | undefined;

if (deploy?.error_message) {
Expand Down
Loading