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

Fix/refactor zboxcore mobilesdk fixes #1633

Open
wants to merge 84 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6232578
expose GetBlobbers method.
yash10019coder Oct 4, 2024
41d74b3
expose GetStorageConfig method.
yash10019coder Oct 4, 2024
a663839
expose ConvertToValue method.
yash10019coder Oct 4, 2024
dae2ef2
Merge branch 'fix/refactor-zboxcore' of github.com:0chain/gosdk into …
yash10019coder Oct 4, 2024
9e6cc0a
exposed staking, unstaking and collect reward methods for miners, sha…
yash10019coder Oct 4, 2024
e2d9cbd
expose GetStakePoolUserInfo.
yash10019coder Oct 4, 2024
e3c8286
Fix
Jayashsatolia403 Oct 5, 2024
43ae0c1
Setup auth
Jayashsatolia403 Oct 6, 2024
0798c08
fix: fixed restriction setup
YarikRevich Sep 29, 2024
9129f74
fix: fixed bugs
YarikRevich Sep 30, 2024
7c80f4c
fix: fixed bugs
YarikRevich Oct 2, 2024
d9a4d8a
fix: fixed bugs
YarikRevich Oct 2, 2024
9c757d4
fix: fixed bugs
YarikRevich Oct 3, 2024
7c937b1
fix: fixed bugs
YarikRevich Oct 5, 2024
5d61294
Fix
Jayashsatolia403 Oct 6, 2024
84b4833
add docs for expose GetStakePoolUserInfo method.
yash10019coder Oct 7, 2024
eb98429
expose VerifyTransaction method.
yash10019coder Oct 7, 2024
90b641f
expose GetTransactions method in gosdk.
yash10019coder Oct 10, 2024
73c00c0
expose GetFeesTable method.
yash10019coder Oct 10, 2024
a7179c2
fix: error initializing sdk.
yash10019coder Oct 10, 2024
9fe872f
Merge branch 'fix/refactor-zboxcore' of github.com:0chain/gosdk into …
yash10019coder Oct 11, 2024
a5fb305
fix: GetTransactions method.
yash10019coder Oct 14, 2024
7d9c82f
fix: init_node.go network initialization.
yash10019coder Oct 14, 2024
9bd0b1c
Merge branch 'fix/refactor-zboxcore' of github.com:0chain/gosdk into …
yash10019coder Oct 14, 2024
e271ce6
fix: sdk not initialized error for zboxcore methods.
yash10019coder Oct 14, 2024
270e868
refactor: add provider type field in StakePoolDelegatePoolInfo.
yash10019coder Oct 14, 2024
e7d3f0f
debug: mobile build flagsin mobilesdk/sdk.go.
yash10019coder Oct 14, 2024
f6e55b8
debug: playground script.
yash10019coder Oct 14, 2024
6a7efd5
refactor: combined blobber and miner/sharder user stake pool info.
yash10019coder Oct 14, 2024
fb7a466
go mod tidy
yash10019coder Oct 14, 2024
d6696c7
fix: add provider id in StakePoolDelegatePoolInfo.
yash10019coder Oct 14, 2024
ceb0b37
expose: GetConfig method.
yash10019coder Oct 14, 2024
79e1bd8
remove faucet method from mobilesdk.
yash10019coder Oct 14, 2024
884e4e6
Merge branch 'fix/refactor-zboxcore' of github.com:0chain/gosdk into …
yash10019coder Oct 16, 2024
6658cc4
fix: InitStorageSDK method error.
yash10019coder Oct 16, 2024
d80d6fe
refactor: add custom fees to all of the mobilesdk methods for staking…
yash10019coder Oct 16, 2024
1d1b9cc
refactor: add fees in sendZCN.
yash10019coder Oct 16, 2024
fe4c8bc
fix: wasmsdk send token to pass fee parameter.
yash10019coder Oct 16, 2024
dd34eee
expose: client.Sign
yash10019coder Oct 20, 2024
7cef159
Merge branch 'fix/refactor-zboxcore' into fix/refactor-zboxcore-mobil…
Jayashsatolia403 Oct 20, 2024
6370ea7
Merge branch 'fix/refactor-zboxcore' into fix/refactor-zboxcore-mobil…
Jayashsatolia403 Oct 21, 2024
a5a3f5f
Merge branch 'sprint-1.18' of github.com:0chain/gosdk into fix/refact…
yash10019coder Oct 22, 2024
ed290f3
fix mobilesdk methods.
yash10019coder Oct 22, 2024
619b640
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Oct 22, 2024
45b4d5e
fix: send txn pass fee mobilesdk.
yash10019coder Oct 22, 2024
4ad5e70
nit fix.
yash10019coder Oct 22, 2024
d890a2b
Merge branch 'sprint-1.18' of github.com:0chain/gosdk into fix/refact…
yash10019coder Oct 23, 2024
5c6115c
fix: zwalletcli build error.
yash10019coder Oct 23, 2024
fb9d904
go mod tidy.
yash10019coder Oct 23, 2024
d5453c4
Merge branch 'sprint-1.18' of github.com:0chain/gosdk into fix/refact…
yash10019coder Oct 24, 2024
1b26dce
fix errors after merge conflicts.
yash10019coder Oct 24, 2024
ce60981
fix: lint.
yash10019coder Oct 24, 2024
fa89c88
fix: CreateThumbnail method.
yash10019coder Oct 24, 2024
0aabfae
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Oct 25, 2024
4d44f83
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
Jayashsatolia403 Oct 27, 2024
3ff9be1
revert network config changes.
yash10019coder Oct 27, 2024
e9fbde1
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Oct 28, 2024
6313913
nit fix init_node.go
yash10019coder Oct 28, 2024
d148f0b
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Oct 28, 2024
e20c598
remove: withParams in get_data.go unused
yash10019coder Nov 1, 2024
6f87297
add: mobile build flags in mobilesdk/../sdk.go
yash10019coder Nov 1, 2024
7e7b313
fix: sanitize inputs in SignRequest mobilesdk method.
yash10019coder Nov 1, 2024
1ac888b
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 1, 2024
8c6721d
revert: play.go
yash10019coder Nov 1, 2024
03f3b2c
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 2, 2024
08f4c98
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
Jayashsatolia403 Nov 2, 2024
cdda18e
fix: add input sanitization for RedeemFreeStorage method in mobilesdk…
yash10019coder Nov 4, 2024
9c5b214
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 4, 2024
54dfae0
refactor: using methods for staking, unstaking and collect rewards fr…
yash10019coder Nov 4, 2024
4531ab2
expose: GetBlobberByID
yash10019coder Nov 4, 2024
57e739c
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 6, 2024
ac55873
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
Jayashsatolia403 Nov 11, 2024
be79089
fix: add registerkmszauth server
yash10019coder Nov 11, 2024
a5a6d02
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 12, 2024
f11ea45
Merge branch 'sprint-1.18' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 12, 2024
a7b8d9a
Merge branch 'staging' into fix/refactor-zboxcore-mobilesdk-fixes
Jayashsatolia403 Nov 13, 2024
15f0fd2
feat: add StorageSCCollectReward in execute_transactions.go
yash10019coder Nov 14, 2024
2235178
Merge branch 'staging' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Nov 14, 2024
8e6844b
Fix authCommon for mobile
peterlimg Nov 15, 2024
33e1ec2
Add get allocationsOfClient
peterlimg Nov 17, 2024
6353377
Merge branch 'staging' into fix/refactor-zboxcore-mobilesdk-fixes
yash10019coder Dec 26, 2024
00b4ba9
fix: duplicate method in wallet_base.go.
yash10019coder Dec 26, 2024
b67cf80
fix: wasmsdk build.
yash10019coder Dec 27, 2024
95d0a90
go mod tidy.
yash10019coder Dec 27, 2024
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
18 changes: 7 additions & 11 deletions core/client/init_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (n *Node) ShouldUpdateNetwork() (bool, *conf.Network, error) {
if err != nil {
return false, nil, err
}
network, err := GetNetwork(n.clientCtx)
network, err := GetNetwork(n.clientCtx, cfg.BlockWorker)
Jayashsatolia403 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
logging.Error("Failed to get network details ", zap.Error(err), zap.String("block_worker", cfg.BlockWorker))
return false, nil, err
Expand Down Expand Up @@ -126,10 +126,7 @@ func Init(ctx context.Context, cfg conf.Config) error {
// set default value for options if unset
setOptionsDefaultValue(&cfg)

//init packages
conf.InitClientConfig(&cfg)

network, err := GetNetwork(ctx)
network, err := GetNetwork(ctx, cfg.BlockWorker)
if err != nil {
logging.Error("Failed to get network details ", zap.Error(err), zap.Any("block_worker", cfg.BlockWorker))
return err
Expand All @@ -144,6 +141,8 @@ func Init(ctx context.Context, cfg conf.Config) error {
clientCtx: ctx,
}

//init packages
conf.InitClientConfig(&cfg)
InitCache(nodeClient.sharders)

// update Network periodically
Expand All @@ -169,6 +168,7 @@ func Init(ctx context.Context, cfg conf.Config) error {
}
}()

SetSdkInitialized(true)
return nil
}

Expand All @@ -181,12 +181,8 @@ func GetNode() (*Node, error) {
}

// GetNetwork gets current network details from 0chain network.
func GetNetwork(ctx context.Context) (*conf.Network, error) {
cfg, err := conf.GetClientConfig()
if err != nil {
return nil, err
}
networkUrl := cfg.BlockWorker + "/network"
func GetNetwork(ctx context.Context, blockWorker string) (*conf.Network, error) {
Jayashsatolia403 marked this conversation as resolved.
Show resolved Hide resolved
networkUrl := blockWorker + "/network"
networkGetCtx, networkGetCancelCtx := context.WithTimeout(ctx, 60*time.Second)
defer networkGetCancelCtx()
req, err := util.NewHTTPGetRequestContext(networkGetCtx, networkUrl)
Expand Down
2 changes: 1 addition & 1 deletion core/client/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Client struct {
authUrl string
nonce int64
txnFee uint64
sign SignFunc
sign SignFunc //nolint:unused
}

func init() {
Expand Down
56 changes: 31 additions & 25 deletions core/imageutil/thumbnailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ package imageutil
import (
"bytes"
"fmt"
"github.com/disintegration/gift"
"image"
"image/gif"
_ "image/gif"
"image/jpeg"
_ "image/jpeg"
"image/png"
_ "image/png"
Expand Down Expand Up @@ -37,39 +40,42 @@ type SubImager interface {
// - vp8l
// - webp
func CreateThumbnail(buf []byte, width, height int) ([]byte, error) {
// image.Decode requires that you import the right image package.
// Ignored return value is image format name.
img, _, err := image.Decode(bytes.NewReader(buf))
// Decode the image from the buffer
img, format, err := image.Decode(bytes.NewReader(buf))
if err != nil {
return nil, err
}

// I've hard-coded a crop rectangle, start (0,0), end (100, 100).
img, err = cropImage(img, image.Rect(0, 0, width, height))
if err != nil {
return nil, err
}
// Resize the image using Lanczos resampling

fd := &bytes.Buffer{}
g := gift.New(
gift.Resize(width, height, gift.LanczosResampling),
)
thumbnail := image.NewRGBA(g.Bounds(img.Bounds()))
g.Draw(thumbnail, img)
//thumbnail := resize.Resize(uint(width), uint(height), img, resize.Lanczos3)

err = png.Encode(fd, img)
if err != nil {
return nil, err
}
// Create a buffer to hold the new resized image
var outBuffer bytes.Buffer

return fd.Bytes(), nil
}

// cropImage takes an image and crops it to the specified rectangle.
func cropImage(img image.Image, crop image.Rectangle) (image.Image, error) {
// Encode the image back into the original format
switch format {
case "jpeg", "jpg":
err = jpeg.Encode(&outBuffer, thumbnail, nil)
case "png":
err = png.Encode(&outBuffer, thumbnail)
case "gif":
err = gif.Encode(&outBuffer, thumbnail, nil)
case "bmp", "ccitt", "riff", "tiff", "vector", "vp8", "vp8l", "webp":
err = jpeg.Encode(&outBuffer, thumbnail, nil) // Use JPEG as fallback since WebP/GIF encoding is less common in Go
default:
err = fmt.Errorf("unsupported image format")
}

// img is an Image interface. This checks if the underlying value has a
// method called SubImage. If it does, then we can use SubImage to crop the
// image.
simg, ok := img.(SubImager)
if !ok {
return nil, fmt.Errorf("image does not support cropping")
if err != nil {
return nil, err
}

return simg.SubImage(crop), nil
// Return the resized image buffer
return outBuffer.Bytes(), nil
}
14 changes: 8 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ require (
github.com/uptrace/bunrouter v1.0.20
go.dedis.ch/kyber/v3 v3.1.0
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.21.0
golang.org/x/image v0.14.0
golang.org/x/sync v0.7.0
golang.org/x/crypto v0.28.0
golang.org/x/image v0.21.0
golang.org/x/sync v0.8.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
github.com/disintegration/gift v1.2.1
github.com/hack-pad/go-webworkers v0.1.0
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/minio/sha256-simd v1.0.1
Expand Down Expand Up @@ -67,6 +68,7 @@ require (
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -107,8 +109,8 @@ require (
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
Expand All @@ -123,7 +125,7 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/time v0.3.0 // indirect
)

Expand Down
30 changes: 16 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc=
github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
Expand Down Expand Up @@ -242,8 +244,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -579,8 +581,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand All @@ -599,8 +601,8 @@ golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N0
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -659,8 +661,8 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -681,8 +683,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -734,17 +736,17 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
46 changes: 39 additions & 7 deletions mobilesdk/sdk/sdk.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//go:build mobile
// +build mobile

// TODO: add mobile build flags later here.
package sdk

import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/0chain/gosdk/core/imageutil"
coreTransaction "github.com/0chain/gosdk/core/transaction"
"math"
"strconv"
"strings"
Expand All @@ -27,8 +27,6 @@ import (
"github.com/0chain/gosdk/zcncore"
)

var nonce = int64(0)

type Autorizer interface {
Auth(msg string) (string, error)
}
Expand Down Expand Up @@ -71,8 +69,10 @@ func Init(chainConfigJson string) error {
cfg := conf.Config{}
err := json.Unmarshal([]byte(chainConfigJson), &cfg)
if err != nil {
return err
return errors.WithMessage(err, "failed to unmarshal chain config")
}
l.Logger.Info("InitSDK chain config")
l.Logger.Info(cfg)
return client.Init(context.Background(), cfg)
}

Expand Down Expand Up @@ -114,7 +114,7 @@ func InitStorageSDK(clientJson string, configJson string) (*StorageSDK, error) {
l.Logger.Error(err)
return nil, err
}
err = Init(configObj.BlockWorker)
err = Init(configJson)
if err != nil {
l.Logger.Error(err)
return nil, err
Expand Down Expand Up @@ -358,6 +358,11 @@ func (s *StorageSDK) GetVersion() string {
return version.VERSIONSTR
}

// GetVersion getting current version for gomobile lib
func GetVersion() string {
return version.VERSIONSTR
}

// UpdateAllocation update allocation settings with new expiry and size
// - size: size of space reserved on blobbers
// - extend: extend allocation
Expand Down Expand Up @@ -385,6 +390,21 @@ func (s *StorageSDK) GetBlobbersList() (string, error) {
return string(retBytes), nil
}

// GetStorageConfig get storage config
// configType: storage_sc_config, miners_sc_globals, miner_sc_configs
func GetStorageConfig(configType string) ([]byte, error) {
configBytes, err := coreTransaction.GetConfig(configType)
if err != nil {
return nil, err
}

retBytes, err := json.Marshal(configBytes)
if err != nil {
return nil, err
}
return retBytes, nil
}

// GetAllocations return back list of allocations for the wallet
// Extracted from main method, bcz of class fields
func GetAllocations() (string, error) {
Expand Down Expand Up @@ -455,3 +475,15 @@ func decodeTicket(ticket string) (string, string, uint64, error) {
func RegisterAuthorizer(auth Autorizer) {
sys.Authorize = auth.Auth
}

func CreateThumbnail(fileData []byte, height, width int) ([]byte, error) {
if len(fileData) == 0 {
return nil, errors.New("empty image data")
}

if height == 0 || width == 0 {
return nil, errors.New("invalid height or width")
}

return imageutil.CreateThumbnail(fileData, width, height)
}
14 changes: 14 additions & 0 deletions mobilesdk/zbox/util.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package zbox

import (
"fmt"
"github.com/0chain/gosdk/core/client"
"github.com/0chain/gosdk/zboxcore/sdk"
"regexp"
"strconv"
)
Expand All @@ -14,3 +17,14 @@ func GetNumber(value string) int {
}
return -1
}

func Sign(clientId string) (string, error) {
if len(clientId) == 0 {
return "", fmt.Errorf("null client ID for signing")
}
return client.Sign(clientId)
}

func GetClientEncryptedPublicKey() (string, error) {
return sdk.GetClientEncryptedPublicKey()
}
Loading
Loading