diff --git a/tzpro/defi/dex_event.go b/tzpro/defi/dex_event.go index f198118..7b136cf 100644 --- a/tzpro/defi/dex_event.go +++ b/tzpro/defi/dex_event.go @@ -11,8 +11,8 @@ import ( type DexEvent struct { Id uint64 `json:"id"` - Contract string `json:"contract"` - PairId int64 `json:"pair_id"` + Contract Address `json:"contract"` + PairId int `json:"pair_id"` Name string `json:"name"` Entity string `json:"entity"` Pair string `json:"pair"` @@ -26,10 +26,11 @@ type DexEvent struct { SupplyA Z `json:"supply_a"` SupplyB Z `json:"supply_b"` SupplyLP Z `json:"supply_lp"` - Signer string `json:"signer"` - Sender string `json:"sender"` - Receiver string `json:"receiver"` - Router string `json:"router"` + ValueUSD float64 `json:"value_usd,string"` + Signer Address `json:"signer"` + Sender Address `json:"sender"` + Receiver Address `json:"receiver"` + Router Address `json:"router"` TxHash OpHash `json:"tx_hash"` TxFee int64 `json:"tx_fee,string"` Block int64 `json:"block"` diff --git a/tzpro/defi/dex_position.go b/tzpro/defi/dex_position.go index 4d1e281..eec6e2d 100644 --- a/tzpro/defi/dex_position.go +++ b/tzpro/defi/dex_position.go @@ -11,37 +11,39 @@ import ( type DexPosition struct { Id uint64 `json:"id"` - Contract string `json:"contract"` - PairId int64 `json:"pair_id"` + Contract Address `json:"contract"` + PairId int `json:"pair_id"` Name string `json:"name"` Entity string `json:"entity"` Pair string `json:"pair"` - Owner string `json:"owner"` + Owner Address `json:"owner"` DecimalsA int `json:"decimals_a"` DecimalsB int `json:"decimals_b"` DecimalsLP int `json:"decimals_lp"` - TotalShares string `json:"total_shares"` - Shares string `json:"shares"` - ValueA string `json:"value_a"` - ValueB string `json:"value_b"` - SharesMinted string `json:"shares_minted"` - SharesBurned string `json:"shares_burned"` - SharesSent string `json:"shares_sent"` - SharesReceived string `json:"shares_received"` - DepositedA string `json:"deposited_a"` - DepositedB string `json:"deposited_b"` - WithdrawnA string `json:"withdrawn_a"` - WithdrawnB string `json:"withdrawn_b"` + TotalShares Z `json:"total_shares"` + Shares Z `json:"shares"` + ValueA Z `json:"value_a"` + ValueB Z `json:"value_b"` + SharesMinted Z `json:"shares_minted"` + SharesBurned Z `json:"shares_burned"` + SharesSent Z `json:"shares_sent"` + SharesReceived Z `json:"shares_received"` + DepositedA Z `json:"deposited_a"` + DepositedB Z `json:"deposited_b"` + WithdrawnA Z `json:"withdrawn_a"` + WithdrawnB Z `json:"withdrawn_b"` IsClosed bool `json:"is_closed"` OpenBlock int64 `json:"open_block"` OpenTime time.Time `json:"open_time"` CloseBlock int64 `json:"close_block,omitempty"` CloseTime *time.Time `json:"close_time,omitempty"` - PositionValueUSD string `json:"position_value_usd"` - ShareValueUSD string `json:"share_value_usd"` - OpenValueUSD string `json:"open_value_usd"` - CloseValueUSD string `json:"close_value_usd"` - ProfitLossUSD string `json:"pnl_usd"` + PositionValueUSD float64 `json:"position_value_usd,string"` + ShareValueUSD float64 `json:"share_value_usd,string"` + OpenValueUSD float64 `json:"open_value_usd,string"` + CloseValueUSD float64 `json:"close_value_usd,string"` + FeeIncomeUSD float64 `json:"fee_income_usd,string"` + FeeIncomeBps float64 `json:"fee_income_bps,string"` + ProfitLossUSD float64 `json:"pnl_usd,string"` ProfitLossBps float64 `json:"pnl_bps,string"` } diff --git a/tzpro/defi/dex_ticker.go b/tzpro/defi/dex_ticker.go index ac53535..b633ac4 100644 --- a/tzpro/defi/dex_ticker.go +++ b/tzpro/defi/dex_ticker.go @@ -10,27 +10,27 @@ import ( ) type DexTicker struct { - Pair string `json:"pair"` - Pool string `json:"pool"` - Name string `json:"name"` - Entity string `json:"entity"` - PriceChange string `json:"price_change"` - PriceChangeBps string `json:"price_change_bps"` - AskPrice string `json:"ask_price"` - WeightedAvgPrice string `json:"weighted_avg_price"` - LastPrice string `json:"last_price"` - LastQty string `json:"last_qty"` - LastTradeTime string `json:"last_trade_time"` - BaseVolume string `json:"base_volume"` - QuoteVolume string `json:"quote_volume"` - OpenPrice string `json:"open_price"` - HighPrice string `json:"high_price"` - LowPrice string `json:"low_price"` - OpenTime time.Time `json:"open_time"` - CloseTime time.Time `json:"close_time"` - NumTrades int `json:"num_trades"` - LiquidityUSD string `json:"liquidity_usd"` - PriceUSD string `json:"price_usd"` + Pair string `json:"pair"` + Pool PoolAddress `json:"pool"` + Name string `json:"name"` + Entity string `json:"entity"` + PriceChange float64 `json:"price_change,string"` + PriceChangeBps float64 `json:"price_change_bps,string"` + AskPrice float64 `json:"ask_price,string"` + WeightedAvgPrice float64 `json:"weighted_avg_price,string"` + LastPrice float64 `json:"last_price,string"` + LastQty float64 `json:"last_qty,string"` + LastTradeTime float64 `json:"last_trade_time,string"` + BaseVolume float64 `json:"base_volume,string"` + QuoteVolume float64 `json:"quote_volume,string"` + OpenPrice float64 `json:"open_price,string"` + HighPrice float64 `json:"high_price,string"` + LowPrice float64 `json:"low_price,string"` + OpenTime time.Time `json:"open_time"` + CloseTime time.Time `json:"close_time"` + NumTrades int `json:"num_trades"` + LiquidityUSD string `json:"liquidity_usd"` + PriceUSD string `json:"price_usd"` } func (c *dexClient) GetTicker(ctx context.Context, addr PoolAddress) (*DexTicker, error) { diff --git a/tzpro/defi/dex_trade.go b/tzpro/defi/dex_trade.go index e1d3e9f..06f91db 100644 --- a/tzpro/defi/dex_trade.go +++ b/tzpro/defi/dex_trade.go @@ -11,7 +11,7 @@ import ( type DexTrade struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` PairId int `json:"pair_id"` Name string `json:"name"` Entity string `json:"entity"` diff --git a/tzpro/defi/farm.go b/tzpro/defi/farm.go index a2d3949..b11efc4 100644 --- a/tzpro/defi/farm.go +++ b/tzpro/defi/farm.go @@ -32,9 +32,9 @@ type farmClient struct { type Farm struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` PoolId int `json:"pool_id"` - Creator string `json:"creator"` + Creator Address `json:"creator"` Name string `json:"name"` Entity string `json:"entity"` StakeToken *Token `json:"stake_token"` @@ -42,16 +42,15 @@ type Farm struct { FirstBlock int64 `json:"first_block"` FirstTime time.Time `json:"first_time"` Tags []string `json:"tags"` - TotalStake string `json:"total_stake"` - RemainingRewards string `json:"remaining_rewards"` + TotalStake Z `json:"total_stake"` + RemainingRewards Z `json:"remaining_rewards"` NumPositions int `json:"num_positions"` StartTime *time.Time `json:"start_time,omitempty"` EndTime *time.Time `json:"end_time,omitempty"` } func (p Farm) Address() PoolAddress { - a, _ := ParseAddress(p.Contract) - return NewPoolAddress(a, p.PoolId) + return NewPoolAddress(p.Contract, p.PoolId) } func (c *farmClient) GetFarm(ctx context.Context, addr PoolAddress) (*Farm, error) { diff --git a/tzpro/defi/farm_event.go b/tzpro/defi/farm_event.go index 37bf03a..184d60c 100644 --- a/tzpro/defi/farm_event.go +++ b/tzpro/defi/farm_event.go @@ -10,32 +10,32 @@ import ( ) type FarmEvent struct { - Id uint64 `json:"id"` - Contract string `json:"contract"` - PoolId int64 `json:"pool_id"` - Name string `json:"name"` - Entity string `json:"entity"` - Type string `json:"event_type"` - StakeToken string `json:"stake_token"` - RewardToken string `json:"reward_token"` - StakeSymbol string `json:"stake_symbol"` - RewardSymbol string `json:"reward_symbol"` - StakeDecimals int `json:"stake_decimals"` - RewardDecimals int `json:"reward_decimals"` - Volume Z `json:"volume"` - Reward Z `json:"reward"` - Fee Z `json:"fee"` - FeeBps float64 `json:"fee_bps,string"` - StakeId int64 `json:"stake_id"` - StakeSupply Z `json:"stake_supply"` - RewardSupply Z `json:"reward_supply"` - Signer string `json:"signer"` - Sender string `json:"sender"` - Receiver string `json:"receiver"` - TxHash string `json:"tx_hash"` - TxFee int64 `json:"tx_fee,string"` - Block int64 `json:"block"` - Time time.Time `json:"time"` + Id uint64 `json:"id"` + Contract Address `json:"contract"` + PoolId int `json:"pool_id"` + Name string `json:"name"` + Entity string `json:"entity"` + Type string `json:"event_type"` + StakeToken TokenAddress `json:"stake_token"` + RewardToken TokenAddress `json:"reward_token"` + StakeSymbol string `json:"stake_symbol"` + RewardSymbol string `json:"reward_symbol"` + StakeDecimals int `json:"stake_decimals"` + RewardDecimals int `json:"reward_decimals"` + Volume Z `json:"volume"` + Reward Z `json:"reward"` + Fee Z `json:"fee"` + FeeBps float64 `json:"fee_bps,string"` + StakeId int64 `json:"stake_id"` + StakeSupply Z `json:"stake_supply"` + RewardSupply Z `json:"reward_supply"` + Signer Address `json:"signer"` + Sender Address `json:"sender"` + Receiver Address `json:"receiver"` + TxHash OpHash `json:"tx_hash"` + TxFee int64 `json:"tx_fee,string"` + Block int64 `json:"block"` + Time time.Time `json:"time"` } func (c *farmClient) ListEvents(ctx context.Context, params Query) ([]*FarmEvent, error) { diff --git a/tzpro/defi/farm_position.go b/tzpro/defi/farm_position.go index 80127e6..68a8100 100644 --- a/tzpro/defi/farm_position.go +++ b/tzpro/defi/farm_position.go @@ -10,30 +10,33 @@ import ( ) type FarmPosition struct { - Id uint64 `json:"id"` - Contract string `json:"contract"` - PoolId int64 `json:"pool_id"` - Name string `json:"name"` - Entity string `json:"entity"` - Owner string `json:"owner"` - StakeToken string `json:"stake_token"` - RewardToken string `json:"reward_token"` - StakeSymbol string `json:"stake_symbol"` - RewardSymbol string `json:"reward_symbol"` - StakeDecimals int `json:"stake_decimals"` - RewardDecimals int `json:"reward_decimals"` - TotalStake string `json:"total_stake"` - StakeId int64 `json:"stake_id"` - Stake Z `json:"stake_balance"` - Deposited Z `json:"stake_deposited"` - Withdrawn Z `json:"stake_withdrawn"` - Claimed Z `json:"rewards_claimed"` - Pending Z `json:"rewards_pending"` - IsClosed bool `json:"is_closed"` - OpenBlock int64 `json:"open_block"` - OpenTime time.Time `json:"open_time"` - CloseBlock int64 `json:"close_block,omitempty"` - CloseTime *time.Time `json:"close_time,omitempty"` + Id uint64 `json:"id"` + Contract Address `json:"contract"` + PoolId int `json:"pool_id"` + Name string `json:"name"` + Entity string `json:"entity"` + Owner Address `json:"owner"` + StakeToken TokenAddress `json:"stake_token"` + RewardToken TokenAddress `json:"reward_token"` + StakeSymbol string `json:"stake_symbol"` + RewardSymbol string `json:"reward_symbol"` + StakeDecimals int `json:"stake_decimals"` + RewardDecimals int `json:"reward_decimals"` + TotalStake Z `json:"total_stake"` + StakeId int64 `json:"stake_id"` + Stake Z `json:"stake_balance"` + Deposited Z `json:"stake_deposited"` + Withdrawn Z `json:"stake_withdrawn"` + Claimed Z `json:"rewards_claimed"` + Pending Z `json:"rewards_pending"` + IsClosed bool `json:"is_closed"` + OpenBlock int64 `json:"open_block"` + OpenTime time.Time `json:"open_time"` + CloseBlock int64 `json:"close_block,omitempty"` + CloseTime *time.Time `json:"close_time,omitempty"` + ValueUSD float64 `json:"value_usd,string"` + PendingUSD float64 `json:"pending_usd,string"` + ClaimedUSD float64 `json:"claimed_usd,string"` } func (c *farmClient) ListPositions(ctx context.Context, params Query) ([]*FarmPosition, error) { diff --git a/tzpro/defi/lend.go b/tzpro/defi/lend.go index 8abfcfa..f757af7 100644 --- a/tzpro/defi/lend.go +++ b/tzpro/defi/lend.go @@ -32,9 +32,9 @@ type lendClient struct { type LendingPool struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` PoolId int `json:"pool_id"` - Creator string `json:"creator"` + Creator Address `json:"creator"` Name string `json:"name"` Entity string `json:"entity"` DebtToken *Token `json:"debt_token"` @@ -42,15 +42,14 @@ type LendingPool struct { FirstBlock int64 `json:"first_block"` FirstTime time.Time `json:"first_time"` Tags []string `json:"tags"` - TotalCollateral string `json:"total_collateral"` - TotalDebt string `json:"total_debt"` + TotalCollateral Z `json:"total_collateral"` + TotalDebt Z `json:"total_debt"` NumDeposits int `json:"num_deposits"` NumBorrows int `json:"num_borrows"` } func (p LendingPool) Address() PoolAddress { - a, _ := ParseAddress(p.Contract) - return NewPoolAddress(a, p.PoolId) + return NewPoolAddress(p.Contract, p.PoolId) } func (c *lendClient) GetPool(ctx context.Context, addr PoolAddress) (*LendingPool, error) { diff --git a/tzpro/defi/lend_event.go b/tzpro/defi/lend_event.go index 377e873..822fee6 100644 --- a/tzpro/defi/lend_event.go +++ b/tzpro/defi/lend_event.go @@ -10,32 +10,32 @@ import ( ) type LendingEvent struct { - Id uint64 `json:"id"` - Contract string `json:"contract"` - PoolId int64 `json:"pool_id"` - Name string `json:"name"` - Entity string `json:"entity"` - Type string `json:"event_type"` - DebtToken string `json:"debt_token"` - CollateralToken string `json:"collateral_token"` - DebtDecimals int `json:"debt_decimals"` - CollateralDecimals int `json:"collateral_decimals"` - DebtSymbol string `json:"debt_symbol"` - CollateralSymbol string `json:"collateral_symbol"` - Owner string `json:"owner"` - StakeId int64 `json:"stake_id"` - Volume Z `json:"volume"` - Debt Z `json:"debt"` - Collateral Z `json:"collateral"` - Fee Z `json:"fee"` - Interest Z `json:"interest"` - Signer string `json:"signer"` - Sender string `json:"sender"` - Receiver string `json:"receiver"` - TxHash string `json:"tx_hash"` - TxFee int64 `json:"tx_fee,string"` - Block int64 `json:"block"` - Time time.Time `json:"time"` + Id uint64 `json:"id"` + Contract Address `json:"contract"` + PoolId int `json:"pool_id"` + Name string `json:"name"` + Entity string `json:"entity"` + Type string `json:"event_type"` + DebtToken TokenAddress `json:"debt_token"` + CollateralToken TokenAddress `json:"collateral_token"` + DebtDecimals int `json:"debt_decimals"` + CollateralDecimals int `json:"collateral_decimals"` + DebtSymbol string `json:"debt_symbol"` + CollateralSymbol string `json:"collateral_symbol"` + Owner Address `json:"owner"` + StakeId int64 `json:"stake_id"` + Volume Z `json:"volume"` + Debt Z `json:"debt"` + Collateral Z `json:"collateral"` + Fee Z `json:"fee"` + Interest Z `json:"interest"` + Signer Address `json:"signer"` + Sender Address `json:"sender"` + Receiver Address `json:"receiver"` + TxHash OpHash `json:"tx_hash"` + TxFee int64 `json:"tx_fee,string"` + Block int64 `json:"block"` + Time time.Time `json:"time"` } func (c *lendClient) ListEvents(ctx context.Context, params Query) ([]*LendingEvent, error) { diff --git a/tzpro/defi/lend_position.go b/tzpro/defi/lend_position.go index f4092fc..4c7d155 100644 --- a/tzpro/defi/lend_position.go +++ b/tzpro/defi/lend_position.go @@ -10,37 +10,37 @@ import ( ) type LendingPosition struct { - Id uint64 `json:"id"` - Contract string `json:"contract"` - PoolId int64 `json:"pool_id"` - Name string `json:"name"` - Entity string `json:"entity"` - Owner string `json:"owner"` - StakeId int64 `json:"stake_id"` - DebtToken string `json:"debt_token"` - CollateralToken string `json:"collateral_token"` - DebtDecimals int `json:"debt_decimals"` - CollateralDecimals int `json:"collateral_decimals"` - DebtSymbol string `json:"debt_symbol"` - CollateralSymbol string `json:"collateral_symbol"` - Balance Z `json:"balance"` - Deposited Z `json:"deposited"` - Withdrawn Z `json:"withdrawn"` - Borrowed Z `json:"borrowed"` - Repaid Z `json:"repaid"` - Liquidated Z `json:"liquidated"` - Sent Z `json:"sent"` - Received Z `json:"received"` - InterestEarned Z `json:"interest_earned"` - InterestPaid Z `json:"interest_paid"` - InterestPending Z `json:"interest_pending"` - IsClosed bool `json:"is_closed"` - OpenBlock int64 `json:"open_block"` - OpenTime time.Time `json:"open_time"` - CloseBlock int64 `json:"close_block,omitempty"` - CloseTime *time.Time `json:"close_time,omitempty"` - PositionUSD float64 `json:"position_value_usd,string"` - InterestUSD float64 `json:"interest_pending_usd,string"` + Id uint64 `json:"id"` + Contract Address `json:"contract"` + PoolId int `json:"pool_id"` + Name string `json:"name"` + Entity string `json:"entity"` + Owner Address `json:"owner"` + StakeId int64 `json:"stake_id"` + DebtToken TokenAddress `json:"debt_token"` + CollateralToken TokenAddress `json:"collateral_token"` + DebtDecimals int `json:"debt_decimals"` + CollateralDecimals int `json:"collateral_decimals"` + DebtSymbol string `json:"debt_symbol"` + CollateralSymbol string `json:"collateral_symbol"` + Balance Z `json:"balance"` + Deposited Z `json:"deposited"` + Withdrawn Z `json:"withdrawn"` + Borrowed Z `json:"borrowed"` + Repaid Z `json:"repaid"` + Liquidated Z `json:"liquidated"` + Sent Z `json:"sent"` + Received Z `json:"received"` + InterestEarned Z `json:"interest_earned"` + InterestPaid Z `json:"interest_paid"` + InterestPending Z `json:"interest_pending"` + IsClosed bool `json:"is_closed"` + OpenBlock int64 `json:"open_block"` + OpenTime time.Time `json:"open_time"` + CloseBlock int64 `json:"close_block,omitempty"` + CloseTime *time.Time `json:"close_time,omitempty"` + PositionUSD float64 `json:"position_value_usd,string"` + InterestUSD float64 `json:"interest_pending_usd,string"` } func (c *lendClient) ListPositions(ctx context.Context, params Query) ([]*LendingPosition, error) { diff --git a/tzpro/defi/types.go b/tzpro/defi/types.go index 69e05de..c6693ba 100644 --- a/tzpro/defi/types.go +++ b/tzpro/defi/types.go @@ -16,7 +16,8 @@ type ( Address = tezos.Address Z = tezos.Z - Token = token.Token + Token = token.Token + TokenAddress = tezos.Token ) var ( diff --git a/tzpro/nft/nft.go b/tzpro/nft/nft.go index 5f47317..165ee11 100644 --- a/tzpro/nft/nft.go +++ b/tzpro/nft/nft.go @@ -34,9 +34,9 @@ type nftClient struct { type NftMarket struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` Kind string `json:"kind"` - Creator string `json:"creator"` + Creator Address `json:"creator"` Name string `json:"name"` Entity string `json:"entity"` Tags []string `json:"tags"` @@ -44,11 +44,6 @@ type NftMarket struct { FirstTime time.Time `json:"first_time"` } -func (m NftMarket) Address() Address { - a, _ := ParseAddress(m.Contract) - return a -} - func (c *nftClient) GetMarket(ctx context.Context, addr Address) (*NftMarket, error) { p := &NftMarket{} u := fmt.Sprintf("/v1/nft/%s", addr) diff --git a/tzpro/nft/nft_event.go b/tzpro/nft/nft_event.go index 17b7458..f97ec9a 100644 --- a/tzpro/nft/nft_event.go +++ b/tzpro/nft/nft_event.go @@ -11,14 +11,14 @@ import ( type NftEvent struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` Name string `json:"name"` Entity string `json:"entity"` Category string `json:"category"` EventType string `json:"event_type"` SaleId int64 `json:"sale_id"` SaleType string `json:"sale_type"` - Collection string `json:"collection"` + Collection Address `json:"collection"` TokenId Z `json:"token_id,omitempty"` Currency *Token `json:"currency,omitempty"` NumUnits int64 `json:"num_units,omitempty"` @@ -26,9 +26,9 @@ type NftEvent struct { Fee Z `json:"fee,omitempty"` Royalty Z `json:"royalty,omitempty"` RoyaltyBps int64 `json:"royalty_bps,omitempty"` - Signer string `json:"signer"` - Sender string `json:"sender"` - TxHash string `json:"tx_hash"` + Signer Address `json:"signer"` + Sender Address `json:"sender"` + TxHash OpHash `json:"tx_hash"` TxFee int64 `json:"tx_fee,string"` Block int64 `json:"block"` Time time.Time `json:"time"` diff --git a/tzpro/nft/nft_position.go b/tzpro/nft/nft_position.go index eec620c..b8731a6 100644 --- a/tzpro/nft/nft_position.go +++ b/tzpro/nft/nft_position.go @@ -11,7 +11,7 @@ import ( type NftPosition struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` Name string `json:"name"` Entity string `json:"entity"` Category string `json:"category"` @@ -19,8 +19,8 @@ type NftPosition struct { SaleType string `json:"sale_type"` SaleStatus string `json:"sale_status"` IsClosed bool `json:"is_closed"` - Seller string `json:"seller"` - Buyer string `json:"buyer"` + Seller Address `json:"seller"` + Buyer Address `json:"buyer"` AskPrice Z `json:"ask_price"` BidPrice Z `json:"bid_price"` MaxUnits int64 `json:"max_units"` diff --git a/tzpro/nft/nft_trade.go b/tzpro/nft/nft_trade.go index 596b623..86155ab 100644 --- a/tzpro/nft/nft_trade.go +++ b/tzpro/nft/nft_trade.go @@ -11,7 +11,7 @@ import ( type NftTrade struct { Id uint64 `json:"id"` - Contract string `json:"contract"` + Contract Address `json:"contract"` Name string `json:"name"` Entity string `json:"entity"` Category string `json:"category"` diff --git a/tzpro/token/token.go b/tzpro/token/token.go index 4a72276..32a846e 100644 --- a/tzpro/token/token.go +++ b/tzpro/token/token.go @@ -41,7 +41,7 @@ type tokenClient struct { type Token struct { Id uint64 `json:"id"` - Ledger string `json:"ledger"` + Contract Address `json:"contract"` TokenId Z `json:"token_id"` Kind string `json:"token_kind"` Type string `json:"token_type"` @@ -62,8 +62,7 @@ type Token struct { } func (t Token) Address() TokenAddress { - addr, _ := ParseAddress(t.Ledger) - return NewTokenAddress(addr, t.TokenId) + return NewTokenAddress(t.Contract, t.TokenId) } func (c *tokenClient) GetToken(ctx context.Context, addr TokenAddress) (*Token, error) { diff --git a/tzpro/token/token_balance.go b/tzpro/token/token_balance.go index 9621503..c986047 100644 --- a/tzpro/token/token_balance.go +++ b/tzpro/token/token_balance.go @@ -11,7 +11,7 @@ import ( type TokenBalance struct { Id int64 `json:"id"` Owner Address `json:"owner"` - Ledger Address `json:"ledger"` + Contract Address `json:"contract"` TokenId Z `json:"token_id"` Kind string `json:"token_kind"` Type string `json:"token_type"` diff --git a/tzpro/token/token_event.go b/tzpro/token/token_event.go index dd30a52..241d519 100644 --- a/tzpro/token/token_event.go +++ b/tzpro/token/token_event.go @@ -11,7 +11,7 @@ import ( type TokenEvent struct { Id int64 `json:"id"` - Ledger Address `json:"contract"` + Contract Address `json:"contract"` TokenId Z `json:"token_id"` TokenKind string `json:"token_kind"` TokenType string `json:"token_type"` diff --git a/tzpro/token/token_ledger.go b/tzpro/token/token_ledger.go index c42a9f3..9f9a9c4 100644 --- a/tzpro/token/token_ledger.go +++ b/tzpro/token/token_ledger.go @@ -11,7 +11,7 @@ import ( type Ledger struct { Id uint64 `json:"id"` - Ledger string `json:"ledger"` + Contract Address `json:"contract"` TokenId Z `json:"token_id"` Kind string `json:"token_kind"` Type string `json:"token_type"` @@ -21,7 +21,7 @@ type Ledger struct { Decimals int `json:"decimals"` Logo string `json:"logo"` Tags []string `json:"tags"` - Creator string `json:"creator"` + Creator Address `json:"creator"` FirstBlock int64 `json:"first_block"` FirstTime time.Time `json:"first_time"` Supply Z `json:"total_supply"` @@ -31,11 +31,6 @@ type Ledger struct { LastChangeTime time.Time `json:"last_supply_change_time"` } -func (t Ledger) Address() Address { - addr, _ := ParseAddress(t.Ledger) - return addr -} - func (c *tokenClient) GetLedger(ctx context.Context, addr Address) (*Ledger, error) { t := &Ledger{} u := fmt.Sprintf("/v1/ledgers/%s", addr) diff --git a/tzpro/token/token_meta.go b/tzpro/token/token_meta.go index 554246c..4dedd7d 100644 --- a/tzpro/token/token_meta.go +++ b/tzpro/token/token_meta.go @@ -11,7 +11,7 @@ import ( type TokenMetadata struct { Id int64 `json:"id"` - Ledger Address `json:"contract"` + Contract Address `json:"contract"` TokenId Z `json:"token_id"` Kind string `json:"kind"` Status string `json:"status"`