Skip to content

Commit

Permalink
few minors
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Jun 27, 2023
1 parent acd1a09 commit f820427
Show file tree
Hide file tree
Showing 23 changed files with 993 additions and 24 deletions.
3 changes: 3 additions & 0 deletions api/example.http
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ GET {{host}}/v2/nfts/collections/EQDaaxtmY6Dk0YzIV0zNnbUpbjZ92TJHBvO72esc0srwv8K
###
GET {{host}}/v2/dns/auctions

###
GET {{host}}/v2/dns/abdul.ton/bids

###
GET {{host}}/v2/accounts/EQDD3n4osteDDhhSerivXKBzi-IJbIhCTkxRYSlhHEh_hyAW/publickey

Expand Down
2 changes: 1 addition & 1 deletion api/http-client.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"host": "https://tonapi.io",
"metrics": "http://localhost:9010"
}
}
}
66 changes: 65 additions & 1 deletion api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"required": false,
"schema": {
"default": 30,
"maximum": 360,
"maximum": 366,
"minimum": 1,
"type": "integer"
}
Expand Down Expand Up @@ -832,6 +832,21 @@
],
"type": "object"
},
"ApyHistory": {
"properties": {
"apy": {
"type": "number"
},
"time": {
"type": "integer"
}
},
"required": [
"apy",
"time"
],
"type": "object"
},
"Auction": {
"properties": {
"bids": {
Expand Down Expand Up @@ -4687,6 +4702,55 @@
]
}
},
"/v2/staking/pool/{account_id}/history": {
"get": {
"description": "Pool info",
"operationId": "stakingPoolHistory",
"parameters": [
{
"$ref": "#/components/parameters/accountIdParameter"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"apy": {
"items": {
"$ref": "#/components/schemas/ApyHistory"
},
"type": "array"
}
},
"required": [
"apy"
],
"type": "object"
}
}
},
"description": "history"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/UnauthorizedError"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
},
"tags": [
"Staking"
]
}
},
"/v2/staking/pools": {
"get": {
"description": "All pools available in network",
Expand Down
44 changes: 43 additions & 1 deletion api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,37 @@ paths:
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/v2/staking/pool/{account_id}/history:
get:
description: Pool info
operationId: stakingPoolHistory
tags:
- Staking
parameters:
- $ref: '#/components/parameters/accountIdParameter'
responses:
'200':
description: "history"
content:
application/json:
schema:
type: object
required:
- apy
properties:
apy:
type: array
items:
$ref: '#/components/schemas/ApyHistory'

'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/v2/staking/pools:
get:
description: All pools available in network
Expand Down Expand Up @@ -1510,7 +1541,7 @@ components:
type: integer
default: 30
minimum: 1
maximum: 360
maximum: 366
collectionQuery:
in: query
name: collection
Expand Down Expand Up @@ -2979,6 +3010,17 @@ components:
items:
$ref: '#/components/schemas/TraceId'

ApyHistory:
type: object
required:
- apy
- time
properties:
apy:
type: number
time:
type: integer

Subscription:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/sourcegraph/conc v0.3.0
github.com/stretchr/testify v1.8.1
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20230413094040-a66ab71fb269
github.com/tonkeeper/tongo v1.1.2-0.20230616094523-df5e7618cf8d
github.com/tonkeeper/tongo v1.1.2-0.20230626203548-fcb095498b53
go.opentelemetry.io/otel v1.11.1
go.opentelemetry.io/otel/metric v0.33.0
go.opentelemetry.io/otel/trace v1.11.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ github.com/tonkeeper/scam_backoffice_rules v0.0.0-20230413094040-a66ab71fb269 h1
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20230413094040-a66ab71fb269/go.mod h1:VGp8QednbWkKHcpQVlWyO0XSqAA0cR6d9wEdrDmHbbA=
github.com/tonkeeper/tongo v1.1.2-0.20230616094523-df5e7618cf8d h1:I8TNw0yH3Pn1bC1hNb37ZfHvQi47I/jHHLUyYax0qxg=
github.com/tonkeeper/tongo v1.1.2-0.20230616094523-df5e7618cf8d/go.mod h1:LdOBjpUz6vLp1EdX3E0XLNks9YI5XMSqaQahfOMrBEY=
github.com/tonkeeper/tongo v1.1.2-0.20230621154152-2691afbb960d h1:ipxDEMcJ4Nn4RkyZlFXg9BtqRanZbeJuNjxhqoRtvUo=
github.com/tonkeeper/tongo v1.1.2-0.20230621154152-2691afbb960d/go.mod h1:LdOBjpUz6vLp1EdX3E0XLNks9YI5XMSqaQahfOMrBEY=
github.com/tonkeeper/tongo v1.1.2-0.20230626203548-fcb095498b53 h1:TzXHChKTlAsqfXr8Vh3lTFYHLfIPBCXbUBbIkGGeUIs=
github.com/tonkeeper/tongo v1.1.2-0.20230626203548-fcb095498b53/go.mod h1:LdOBjpUz6vLp1EdX3E0XLNks9YI5XMSqaQahfOMrBEY=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/account_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func (h Handler) GetDnsExpiring(ctx context.Context, params oas.GetDnsExpiringPa
}
accounts := make([]tongo.AccountID, 0, len(dnsExpiring))
var response oas.DnsExpiring
if len(dnsExpiring) == 0 {
return &response, nil
}
for _, dns := range dnsExpiring {
if dns.DnsItem != nil {
accounts = append(accounts, dns.DnsItem.Address)
Expand Down
19 changes: 10 additions & 9 deletions pkg/api/staking_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ func convertStakingTFPool(p core.TFPool, info addressbook.TFPoolInfo, apy float6
func convertLiquidStaking(p core.LiquidPool, apy float64) oas.PoolInfo {
name := p.Address.ToHuman(true, false)
return oas.PoolInfo{
Address: p.Address.ToRaw(),
Name: name,
TotalAmount: p.TotalAmount,
Implementation: oas.PoolInfoImplementationLiquidTF,
Apy: 330,
MinStake: 10,
Verified: p.VerifiedSources,
CurrentNominators: 1,
MaxNominators: 0,
Address: p.Address.ToRaw(),
Name: name,
TotalAmount: p.TotalAmount,
Implementation: oas.PoolInfoImplementationLiquidTF,
Apy: 330,
MinStake: 10,
Verified: p.VerifiedSources,
CurrentNominators: 1,
MaxNominators: 0,
LiquidJettonMaster: oas.NewOptString(p.JettonMaster.ToRaw()),
}
}
5 changes: 5 additions & 0 deletions pkg/api/staking_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"errors"
"fmt"

"github.com/tonkeeper/tongo"
"golang.org/x/exp/slices"
Expand Down Expand Up @@ -194,3 +195,7 @@ func (h Handler) PoolsByNominators(ctx context.Context, params oas.PoolsByNomina
}
return &result, nil
}

func (h Handler) StakingPoolHistory(ctx context.Context, params oas.StakingPoolHistoryParams) (oas.StakingPoolHistoryRes, error) {
return nil, fmt.Errorf("not implemented")
}
1 change: 1 addition & 0 deletions pkg/core/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ type LiquidPool struct {
Address tongo.AccountID
TotalAmount int64
VerifiedSources bool
JettonMaster tongo.AccountID
}
9 changes: 7 additions & 2 deletions pkg/litestorage/stacking.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ func (s *LiteStorage) GetTFPools(ctx context.Context, onlyVerified bool) ([]core
return result, nil
}
func (s *LiteStorage) GetLiquidPool(ctx context.Context, pool tongo.AccountID) (core.LiquidPool, error) {
_, v, err := abi.GetFinanceData(ctx, s.client, pool)
_, v, err := abi.GetPoolFullData(ctx, s.client, pool)
if err != nil {
return core.LiquidPool{}, err
}
p, ok := v.(abi.GetFinanceData_PoolResult)
p, ok := v.(abi.GetPoolFullDataResult)
if !ok {
return core.LiquidPool{}, fmt.Errorf("invalid type")
}
Expand All @@ -179,10 +179,15 @@ func (s *LiteStorage) GetLiquidPool(ctx context.Context, pool tongo.AccountID) (
}
code := state.Account.Account.Storage.State.AccountActive.StateInit.Code.Value.Value
hash, err := code.Hash()
jettonMaster, err := tongo.AccountIDFromTlb(p.JettonMinter)
if err != nil || jettonMaster == nil {
return core.LiquidPool{}, fmt.Errorf("invalid pool jetton %v", jettonMaster)
}
return core.LiquidPool{
Address: pool,
TotalAmount: p.TotalBalance,
VerifiedSources: bytes.Equal(hash, references.TFLiquidPoolCodeHash[:]),
JettonMaster: *jettonMaster,
}, err
}

Expand Down
77 changes: 77 additions & 0 deletions pkg/oas/oas_client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f820427

Please sign in to comment.