Code Monkey home page Code Monkey logo

immutable / imx-core-sdk-golang Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 4.0 7.34 MB

The Immutable Core SDK Golang provides convenient access to the Immutable APIs and Ethereum contract methods for applications integrating with ImmutableX platform.

Home Page: https://docs.x.immutable.com/sdk-docs/core-sdk-golang/overview

License: Apache License 2.0

Makefile 0.61% Go 77.95% Solidity 9.53% Mustache 11.07% Shell 0.85%
blockchain ethereum immutable nft-marketplace sdk web3

imx-core-sdk-golang's People

Contributors

alex-connolly avatar allan-almeida avatar brayansdt avatar bruno-imx avatar carleeto avatar cynsupercat avatar kaihirota avatar nathan-ballantyne avatar sprngbk avatar suluvai avatar zatlite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imx-core-sdk-golang's Issues

DemoTransferWorkFlow is failing due to "invalid_stark_signature"

@suluvai I'm trying to transfer an amount as per following example.
https://github.com/immutable/imx-core-sdk-golang/blob/main/imx/examples/transfer/main.go

Additional Info
I kept STARK_PRIVATE_KEY_IN_HEX blank to have it auto-generated using the SDK. Tried with pre-generated Stark-key and found same result.

Steps to reproduce:

func main() {
	//CommonInitialise(".env")
	ctx, envs, cl, l1signer, l2signer := CommonInitialise(".env")
	// Transfer workflow demo
	DemoTransferWorkflow(ctx, cl, l1signer, l2signer, envs)
}

It is failing due to following error

2022/11/14 16:57:10
HTTP/2.0 401 Unauthorized
Content-Length: 210
Content-Type: application/json
Date: Mon, 14 Nov 2022 11:27:10 GMT
Vary: Origin
Vary: Origin
Via: 1.1 2ec72a3e72a08b5f1d2e07fe02b4fea0.cloudfront.net (CloudFront)
X-Amz-Apigw-Id: blriMHxQCYcF4tg=
X-Amz-Cf-Id: x5ygzbMj7ICBLC7FXPjkhF_BmLn6GhN78Ra9JQ_9YoBfJ6YR1ZmyTA==
X-Amz-Cf-Pop: CCU50-P2
X-Amzn-Remapped-Content-Length: 210
X-Amzn-Remapped-Date: Mon, 14 Nov 2022 11:27:10 GMT
X-Amzn-Remapped-Server: istio-envoy
X-Amzn-Requestid: 39eb2d32-0990-45c9-a474-7a3489601205
X-Cache: Error from cloudfront
X-Envoy-Upstream-Service-Time: 918

{"code":"invalid_stark_signature","message":"unable to verify stark signature 0x01ac0b0b4ed81dd46de6fdb785d6b2f9ebcf4021b0f557bbcc6e6264a58d55e7045cf4a1f1ebeca1eb3f11e6f7c2e733344a146ad9ad577dfe247affa629b01f"}
2022/11/14 16:57:10 error calling transfer workflow: Request URL: https://api.sandbox.x.immutable.com/v1/transfers Status:
401, Message: unable to verify stark signature 0x01ac0b0b4ed81dd46de6fdb785d6b2f9ebcf4021b0f557bbcc6e6264a58d55e7045cf4a1f1ebeca1eb3f11e6f7c2e733344a146ad9ad577dfe247affa629b01f
panic: error calling transfer workflow: Request URL: https://api.sandbox.x.immutable.com/v1/transfers Status: 401, Message: unable to verify stark signature 0x01ac0b0b4ed81dd46de6fdb785d6b2f9ebcf4021b0f557bbcc6e6264a58d55e7045cf4a1f1ebeca1eb3f11e6f7c2e733344a146ad9ad577dfe247affa629b01f

goroutine 1 [running]:
log.Panicf({0x7ff6e5a3cf53?, 0xa?}, {0xc00079fed0?, 0x2a?, 0xc00032bb30?})
C:/Program Files/Go/src/log/log.go:392 +0x67
main.DemoTransferWorkflow({0x7ff6e5b030e8, 0xc000020048}, 0x7ff6e54a4ba7?, {0x7ff6e5b02da8?, 0xc0001fc3c0?}, {0x7ff6e5b02268, 0xc000086020}, 0xc000050000?)
C:/ilv-repo/k6/signer/imxinit.go:108 +0x2f2
main.main()
C:/ilv-repo/k6/signer/imxinit.go:25 +0x3f
exit status 2

Code in first example block has typo

in README.md

import "github.com/immutable/imx-core-sdk-golang/imx/api"

const alchemyAPIKey = "alchemy api key"

func main() {
    apiConfiguration := api.NewConfiguration()
    cfg := imx.Config{
        APIConfig:     apiConfiguration,
        AlchemyAPIKey: YOUR_ALCHEMY_API_KEY,
        Environment:   imx.Sandbox,
    }
    client, err := imx.NewClient(&cfg)
    if err != nil {
        log.Panicf("error in NewClient: %v\n", err)
    }
    defer c.EthClient.Close()
}

defer c.EthClient.Close() should be defer client.EthClient.Close()

bug: unable to recover eth address from signature

Steps to reproduce

git clone https://github.com/immutable/imx-core-sdk-golang.git
cd imx-core-sdk-golang/imx/examples/minting
cp .env.example .env
// .env STARK_PRIVATE_KEY=""
// .env ETH_NETWORK="sandbox"
// .env rest of .env values
go build && ./minting

Additional info

I was able to successfully create a project, collection and set collection metadata using go sdk. Only mint gave me the error.

Error

2022/10/14 16:23:02
POST /v2/mints HTTP/1.1
Host: api.sandbox.x.immutable.com
User-Agent: OpenAPI-Generator/0.2.1/go
Content-Length: 500
Accept: application/json
Content-Type: application/json
X-Sdk-Version: imx-core-sdk-golang-0.2.1
Accept-Encoding: gzip

[{"auth_signature":"0xa9a8a2918fa9df1cbf44853a1ed6c7142b97b90bad0606683f367dcaa963bf8644ee695169ffe3d6c88e4ee4325b0fa16ef79b88501b15b902727354acbfeb9400","contract_address":"0xAca938C9B07E681Fa01cD7174D6CB272Cb5b4214","royalties":[{"percentage":1,"recipient":"0x49343FB21B2ff7cdf0E723a88be9d2e0890bF96a"}],"users":[{"tokens":[{"blueprint":"123","id":"0","royalties":[{"percentage":1,"recipient":"0x49343FB21B2ff7cdf0E723a88be9d2e0890bF96a"}]}],"user":"0x49343FB21B2ff7cdf0E723a88be9d2e0890bF96a"}]}]

2022/10/14 16:23:03
HTTP/2.0 400 Bad Request
Content-Length: 223
Content-Type: application/json
Date: Fri, 14 Oct 2022 19:23:03 GMT
Mint_limit: 50000
Mint_limit_reset: 1668191200
Mint_remaining: 49977
Vary: Origin
Vary: Origin
Via: 1.1 d3e98d8cca4d16199794e4f4191b942c.cloudfront.net (CloudFront)
X-Amz-Apigw-Id: aAmLoHh_CYcFf9A=
X-Amz-Cf-Id: Pq-AdUdwNN6hefFc4JTuPrY7AfBksnHDNxvuHGaznEbcd2p5IF2tsw==
X-Amz-Cf-Pop: HEL51-P1
X-Amzn-Remapped-Content-Length: 223
X-Amzn-Remapped-Date: Fri, 14 Oct 2022 19:23:03 GMT
X-Amzn-Remapped-Server: istio-envoy
X-Amzn-Requestid: 91257b9d-a433-4a82-8e61-505522aabd8f
X-Cache: Error from cloudfront
X-Envoy-Upstream-Service-Time: 411

`{"code":"mint_validation_failed","message":"unable to recover eth address from signature 0xa9a8a2918fa9df1cbf44853a1ed6c7142b97b90bad0606683f367dcaa963bf8644ee695169ffe3d6c88e4ee4325b0fa16ef79b88501b15b902727354acbfeb9400"}
2022/10/14 16:23:03 error in minting.MintTokensWorkflow: Request URL: https://api.sandbox.x.immutable.com/v2/mints Status: 400, Message: unable to recover eth address from signature 0xa9a8a2918fa9df1cbf44853a1ed6c7142b97b90bad0606683f367dcaa963bf8644ee695169ffe3d6c88e4ee4325b0fa16ef79b88501b15b902727354acbfeb9400
panic: error in minting.MintTokensWorkflow: Request URL: https://api.sandbox.x.immutable.com/v2/mints Status: 400, Message: unable to recover eth address from signature 0xa9a8a2918fa9df1cbf44853a1ed6c7142b97b90bad0606683f367dcaa963bf8644ee695169ffe3d6c88e4ee4325b0fa16ef79b88501b15b902727354acbfeb9400

goroutine 1 [running]:
log.Panicf({0x957914?, 0xa12088?}, {0xc00059fec0?, 0xa11c60?, 0xc000363c80?})
/usr/local/go/src/log/log.go:392 +0x67
main.main()
/imx-core-sdk-golang/imx/examples/minting/main.go:51 +0x3fe`

Difficult to set server url configs to mainnet

func NewConfiguration() *Configuration { cfg := &Configuration{ DefaultHeader: make(map[string]string), UserAgent: "OpenAPI-Generator/0.2.1/go", Debug: false, Servers: ServerConfigurations{ { URL: "https://api.sandbox.x.immutable.com", Description: "No description provided", }, }, OperationServers: map[string]ServerConfigurations{ }, } return cfg }

hard coded "https://api.sandbox.x.immutable.com" server configs without variable makes it hard to use NewConfiguration() dynamically

Unable to generate Stark Private Key on Windows machine on Go 1.18

In IMX examples common package, stark key generation fails due to following exception
starkPrivateKey, err = stark.GenerateKey()

ERRO[0010] panic: error in Generating Stark Private Key: open github.com\immutable\[email protected]\imx\signers\stark/pedersen_params.json: The system cannot find the path specified.

Looks like a path syntax issue or missing files.
If we hardcode the path, eliminating the need for determining path, then it works. However, that is not a practical solution.
Request to solve this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.