Skip to content

Commit

Permalink
chore(suite): sync types with blockbook
Browse files Browse the repository at this point in the history
  • Loading branch information
enjojoy committed Feb 11, 2025
1 parent faf3e06 commit 8e843a3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
34 changes: 30 additions & 4 deletions packages/blockchain-link-types/src/blockbook-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export interface MultiTokenValue {
value?: string;
}
export interface TokenTransfer {
type: string;
type: '' | 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
standard: '' | 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
from: string;
to: string;
contract: string;
Expand Down Expand Up @@ -125,7 +126,9 @@ export interface StakingPool {
autocompoundBalance: string;
}
export interface ContractInfo {
type: string;
/** @deprecated: Use standard instead. */
type: '' | 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
standard: '' | 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
contract: string;
name: string;
symbol: string;
Expand All @@ -134,13 +137,15 @@ export interface ContractInfo {
destructedInBlock?: number;
}
export interface Token {
type: 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
/** @deprecated: Use standard instead. */
type: '' | 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
standard: '' | 'XPUBAddress' | 'ERC20' | 'ERC721' | 'ERC1155' | 'BEP20' | 'BEP721' | 'BEP1155';
name: string;
path?: string;
contract?: string;
transfers: number;
symbol?: string;
decimals?: number;
decimals: number; // it is optional #14796
balance?: string;
baseValue?: number;
secondaryValue?: number;
Expand Down Expand Up @@ -174,6 +179,7 @@ export interface Address {
totalBaseValue?: number;
totalSecondaryValue?: number;
contractInfo?: ContractInfo;
/** @deprecated: replaced by contractInfo */
erc20Contract?: ContractInfo;
addressAliases?: { [key: string]: AddressAlias };
stakingPools?: StakingPool[];
Expand Down Expand Up @@ -415,10 +421,30 @@ export interface WsEstimateFeeReq {
value?: string;
};
}
export interface Eip1559Fee {
maxFeePerGas: string;
maxPriorityFeePerGas: string;
minWaitTimeEstimate?: number;
maxWaitTimeEstimate?: number;
}
export interface Eip1559Fees {
baseFeePerGas?: string;
low?: Eip1559Fee;
medium?: Eip1559Fee;
high?: Eip1559Fee;
instant?: Eip1559Fee;
networkCongestion?: number;
latestPriorityFeeRange?: string[];
historicalPriorityFeeRange?: string[];
historicalBaseFeeRange?: string[];
priorityFeeTrend?: 'up' | 'down';
baseFeeTrend?: 'up' | 'down';
}
export interface WsEstimateFeeRes {
feePerTx?: string;
feePerUnit?: string;
feeLimit?: string;
eip1559?: Eip1559Fees;
}
export interface WsSendTransactionReq {
hex: string;
Expand Down
12 changes: 12 additions & 0 deletions packages/blockchain-link-types/src/blockbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,39 @@ type BaseERC = Required<Pick<BlockbookToken, 'contract'>> &
Pick<BlockbookToken, 'name' | 'symbol' | 'decimals'>;

export type ERC20 = BaseERC & {
/** @deprecated: Use standard instead. */
type: 'ERC20';
standard: 'ERC20';
} & Pick<BlockbookToken, 'balance' | 'baseValue' | 'secondaryValue'>;

export type ERC721 = BaseERC & {
/** @deprecated: Use standard instead. */
type: 'ERC721';
standard: 'ERC721';
} & Required<Pick<BlockbookToken, 'ids'>>;

export type ERC1155 = BaseERC & {
/** @deprecated: Use standard instead. */
type: 'ERC1155';
standard: 'ERC1155';
} & Required<Pick<BlockbookToken, 'multiTokenValues'>>;

export type BEP20 = BaseERC & {
/** @deprecated: Use standard instead. */
type: 'BEP20';
standard: 'BEP20';
} & Pick<BlockbookToken, 'balance' | 'baseValue' | 'secondaryValue'>;

export type BEP721 = BaseERC & {
/** @deprecated: Use standard instead. */
type: 'BEP721';
standard: 'BEP721';
} & Required<Pick<BlockbookToken, 'ids'>>;

export type BEP1155 = BaseERC & {
/** @deprecated: Use standard instead. */
type: 'BEP1155';
standard: 'BEP1155';
} & Required<Pick<BlockbookToken, 'multiTokenValues'>>;

export interface AccountInfo {
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-link-types/src/blockfrost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export interface AssetBalance {

export type BlockfrostToken = {
type: 'BLOCKFROST';
standard: 'BLOCKFROST';
name: string; // from unit or fingerprint
contract: string; // unit
symbol: string; // from unit or fingerprint
Expand Down
7 changes: 5 additions & 2 deletions packages/blockchain-link-types/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ export type TokenStandard =
| 'ERC1155'
| 'BEP1155'
| 'SPL'
| 'SPL-2022';
| 'SPL-2022'
| 'BLOCKFROST';

export type TransferType = 'sent' | 'recv' | 'self' | 'unknown';

/* Transaction */
export type TokenTransfer = Omit<BlockbookTokenTransfer, 'value'> & {
export type TokenTransfer = Omit<BlockbookTokenTransfer, 'value' | 'type' | 'standard'> & {
type: TransferType;
standard?: TokenStandard;
amount: string;
Expand Down Expand Up @@ -205,7 +206,9 @@ export interface TokenAccount {
}

export interface TokenInfo {
/** @deprecated: Use type instead. */
type: string; // token type: ERC20...
standard: string; // token standard: ERC20...
contract: string; // token address, token unit for ADA
balance?: string; // token balance
name?: string; // token name
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-link-utils/src/blockfrost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export const filterTokenTransfers = (
: tx.txUtxos.inputs.find(i => i.amount.find(a => a.unit === tokenUnit))
?.address || '',
to: type === 'recv' ? tx.address : output.address,
standard: 'BLOCKFROST',
});
});
});
Expand Down

0 comments on commit 8e843a3

Please sign in to comment.