GithubHelp home page GithubHelp logo

algorand / go-algorand-sdk Goto Github PK

View Code? Open in Web Editor NEW
185.0 185.0 90.0 1.74 MB

Algorand Golang SDK

Home Page: https://pkg.go.dev/github.com/algorand/go-algorand-sdk/v2

License: MIT License

Go 99.38% Makefile 0.18% Shell 0.41% Dockerfile 0.03%

go-algorand-sdk's People

Contributors

ahangsu avatar algobarb avatar algobolson avatar algochoi avatar algoidurovic avatar algojack avatar algomaxj avatar algonautshant avatar algorandskiy avatar algorotem avatar barnjamin avatar bricerisingalgorand avatar egieseke avatar eric-warehime avatar evanjrichard avatar excalq avatar fabrice102 avatar github-actions[bot] avatar gmalouf avatar jasonpaulos avatar jasonweathersby avatar justicz avatar michaeldiamant avatar mjiang102628 avatar onetechnical avatar rotemh avatar shiqizng avatar tzaffi avatar vervious avatar winder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

go-algorand-sdk's Issues

[unplanned] Go template bugfixes

DynamicFee: Fix bug where the grouped transactions were presented to the contract in the wrong order. Fix incorrect lsig/txn building.
Split: Remove precise flag and change corresponding error. Fix rounding error in amount calculation. Fix bug where ratn and ratd were inversed. GetSendFundsTransaction becomes static-like GetSplitFundsTransaction, which accepts a complete contract.
PeriodicPayment: Fix bug where the maximum fee passed to the contract was then used as the payment transaction's fee-per-byte.
LimitOrder: Fix bug where the transactions were being presented to the contract in the wrong order.
HTLC: Add getter for HTLC-unlocking txn.

Update all unit tests.

golint violations in transaction.go

pzbitskiy@mbr: .../go-algorand-sdk (pavel/logicsig)$ make 
golint `go list ./... | grep -v /vendor/`
algorand/go-algorand-sdk/transaction/transaction.go:462:1: comment on exported function MakeAssetAcceptanceTxn should be of the form "MakeAssetAcceptanceTxn ..."
algorand/go-algorand-sdk/transaction/transaction.go:479:1: comment on exported function MakeAssetRevocationTxn should be of the form "MakeAssetRevocationTxn ..."
algorand/go-algorand-sdk/transaction/transaction.go:683:1: comment on exported function MakeAssetAcceptanceTxnWithFlatFee should be of the form "MakeAssetAcceptanceTxnWithFlatFee ..."
algorand/go-algorand-sdk/transaction/transaction.go:699:1: comment on exported function MakeAssetRevocationTxnWithFlatFee should be of the form "MakeAssetRevocationTxnWithFlatFee ..."

found by pzbitskiy

related thought - maybe we could have the SDKs present a reminder to golint to PR-ing users, like go-algorand PRs

algodClient.AccountInformation() doesn't return all the info

When i use the algodClient in the go sdk to retrieve the Account information it only returns the following json:
(NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU as example)

{
        "address": "NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU",
        "amount": 0,
        "status": "Offline"
}

When i use the same rest server but query it directly without using the sdk i get the following json as response:

{
"round": 99109,
"address": "NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU",
"amount": 100000000,
"pendingrewards": 0,
"amountwithoutpendingrewards": 100000000,
"rewards": 0,
"status": "Offline"
}

Code to reproduce:

package main

import (
	"fmt"
	"encoding/json"
	"github.com/algorand/go-algorand-sdk/client/algod"
)

const algodAddress = "<>"
const algodToken = "<>"



func main() {
	// Create an algod client
	algodClient, err := algod.MakeClient(algodAddress, algodToken)
	if err != nil {
		return
	}

	// Account Info
	AccountInfo, err := algodClient.AccountInformation("NCTCJR6YAZDPGJ66EIHAUNCTLGOXFVIOWPJUSCUKB7V3YX5UXNHK5UZPCU")
	if err != nil {
		fmt.Printf("error getting algod status: %s\n", err)
		return
	}
	
	// Print the account info as json
	fmt.Printf("\n-----------------Account Information-------------------\n")
	accountJSON, err := json.MarshalIndent(AccountInfo, "", "\t")
	if err != nil {
		fmt.Printf("Error: %s\n", err)
	}
	fmt.Printf("%s\n", accountJSON)
}

SDK Requests hard-code X-Algo-API-Token in header

All requests created by SDK have either no extra header key value pairs or hard code 'X-Algo-API-Token' into the request. SDK should support additional headers or alternates to the current header to support more use cases.

An example of how this could be done is in PR #33.

Go Support of Indexer v2 [5]

  • implementation plan informed by oapi design
  • update algod rest client
  • write indexer rest client
  • write tests: positive tests that hit all end points and negative tests that exercise listed errors (longest part, removes duplicate work for other sdks)
    -- [X] feature files
    -- [x] step impls
    -- [ ] mock jsondata
  • write handlers, update models
  • cleanup and docs
  • review design with team and address comments

N.B. this ticket scope does not include integration tests, just unit tests.

go build err

go build

github.com/algorand/go-algorand-sdk/logic

../../../../pkg/mod/github.com/algorand/[email protected]/logic/logic.go:45:28: undefined: langSpecJson

how deal this bug ๏ผŸ thanks .

Implement algorand-sdk-testing tests for new asset features

  • Create Asset -> Ask for details -> Verify Equality
  • Create Asset -> Ask for details -> Verfy Equality -> Update Asset -> Verify Equality
  • Create -> Destroy
  • Create -> Approve Acceptance -> Transfer -> Verify Equality
  • Freeze account -> Transfer in and out -> Make sure they both fail
  • Unfreeze the account -> transfer in and out -> Make sure they succeed
  • Create -> Mint -> Veriy -> Burn -> Verfy
  • Create with Frozen by default -> Approve Acceptance -> Unfreeze -> Transfer in and out -> Verify
  • Create -> Approve acceptance -> Transfer in -> Revoke -> Verify
  • Create -> attempt to transfer to non-accepting account-> verify failure

Clean up keyreg txn creation flow

Summary: Right now, only goal can generate participation keys and this significantly limits what our custody providers and other staking service developers can do at this time. I think this is a reasonable thing to add in general but this is the use case that warrants a high priority.

In other words, there needs to be a way fo developers to do the goal addpartkey/goal changeonlinestatus flow without using goal, because goal is not meant to be a developer tool.

Add the following components to the go-algorand-sdk
- [ ] add ability to generate participation key pairs
- [ ] add ability to generate keyreg txns that we can submit later

Note that this story does not encapsulate the changeonlinestatus flow, which requires administering a node to actually vote with participation keys. That should not be part of a developer SDK.

UPDATE 06/28/2019
For now, the go-sdk does not need to know about .partkey files. The flow is now for spending key providers to receive (through some mechanism) the VRF public key, and root participation public key, and then to sign a keyreg transaction, and then sending this txn to a node host. The node operator can use goal and algokey to manipulate .partkey files. The go-sdk only needs to create key reg transactions.

This functionality already exists. This issue now refers to making this functionality a little nicer to use (add a sdk-level function for creating keyreg transactions).

There is another conversation about allowing the (java?) sdk to create and manipulate .partkey files. Because this is significantly more effort consider that deferred.

Balance 199000 below min 100000

$ goal asset send --amount 0 --creator CBIH... -t PDUR... --assetid 1 --from PDUR...
Couldn't broadcast tx with algod: HTTP 400 Bad Request: TransactionPool.Remember: transaction S63U...: account PDUR... balance 199000 below min 100000 (1 assets)

$ goal account list
[online] CBIH... CBIH... 5001430048935245 microAlgos [created assets: 1 (10 )]
10 (creator CBIH..., ID 1, name )
[offline] exampleAccount PDUR... 200000 microAlgos *Default

$ goal report
4295016318
1.0.49022.dev [shant/readme_changes] (commit #445b9b6d+)

Darwin Admins-MacBook-Pro.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Genesis ID from genesis.json: privateFuture-v1

Last committed block: 11446
Time since last block: 1.6s
Sync Time: 0.0s
Last consensus protocol: future
...

goal: command not found

After installing the sdk...

go get -u github.com/algorand/go-algorand-sdk/...

I am getting this failure when trying to use goal

-bash: goal: command not found

Tx POST missing Content-type header

The algod /v1/transactions POST endpoint expects a binary content, but the Content-Type: x-binary header is not set by the Go SDK when making that request (SendRawTransaction). Right now the algod node API works without this header, but other APIs might not (e.g. PureStake API).
The Java SDK already does that, so it would be update this SDK to match that behavior.

LimitOrder Validations + Test

Verify minTrade and maxFee

Missing the transactions golden, compare to Java:

        String goldenTx1 =
                        "gqRsc2lngaFsxLcBIAoAAcCWsQICkE4EuWBkHsDEByYBIP68oLsUSlpOp7Q4pG" +
                        "gayA5soQW8tgf8VlMlyVaV9qITMRYiEjEQIxIQMQEkDhAyBCMSQABVMgQlEjEI" +
                        "IQQNEDEJMgMSEDMBECEFEhAzAREhBhIQMwEUKBIQMwETMgMSEDMBEiEHHTUCNQ" +
                        "ExCCEIHTUENQM0ATQDDUAAJDQBNAMSNAI0BA8QQAAWADEJKBIxAiEJDRAxBzID" +
                        "EhAxCCISEBCjdHhuiaNhbXTNJxCjZmVlzQisomZ2zQTSomdoxCB/g7Flf/H8U7" +
                        "ktwYFIodZd/C1LH6PWdyhK3dIAEm2QaaNncnDEIKz368WOGpdE/Ww0L8wUu5Ly" +
                        "2u2bpG3ZSMKCJvcvGApTomx2zQi6o3JjdsQgzUWoS2tM1RvtuQQyGhwdXUqCBy" +
                        "LFEPBRXHZwnSqBvgajc25kxCBd4Wnq60VaWXeVmuPt0x1XgMQSyP4nUnlh5G2R" +
                        "hyo+taR0eXBlo3BheQ==";
        String goldenTx2 =
                        "gqNzaWfEQKXv8Z6OUDNmiZ5phpoQJHmfKyBal4gBZLPYsByYnlXCAlXMBeVFG5" +
                        "CLP1k5L6BPyEG2/XIbjbyM0CGG55CxxAKjdHhuiqRhYW10zQu4pGFyY3bEIP68" +
                        "oLsUSlpOp7Q4pGgayA5soQW8tgf8VlMlyVaV9qITo2ZlZc0JJKJmds0E0qJnaM" +
                        "Qgf4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGmjZ3JwxCCs9+vFjhqX" +
                        "RP1sNC/MFLuS8trtm6Rt2UjCgib3LxgKU6Jsds0IuqNzbmTEIM1FqEtrTNUb7b" +
                        "kEMhocHV1KggcixRDwUVx2cJ0qgb4GpHR5cGWlYXhmZXKkeGFpZM0wOQ==";

        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        bytes.write(Encoder.decodeFromBase64(goldenTx1));
        bytes.write(Encoder.decodeFromBase64(goldenTx2));

        assertThat(Encoder.encodeToBase64(transactions)).isEqualTo(Encoder.encodeToBase64(bytes.toByteArray()));

parsing go.mod: unexpected module path "github.com/ugorji/go/codec"

hey,

running macOS Mojave Version 10.14.3 (18D109)

I am using the Go SDK and following the tutorial on the github readme to create a wallet. When I try to run my app, go modules tries to download the package files, and eventually returns an error

go: github.com/algorand/go-codec/[email protected]: parsing go.mod: unexpected module path "github.com/ugorji/go/codec"
go: error loading module requirements

[Unplanned/pulled into sprint after planning] Transaction model returned from GET only has PaymentTransactionType

Relates to algorand/java-algorand-sdk#71

More context: the algod node potentially reports the following information (go-algorand/daemon/algod/api/spec/v1/model.go) - and of the below, go only supports PaymentTransactionType

	// This is a list of all supported transactions.
	// To add another one, create a struct with XXXTransactionType and embed it here.
	// To prevent extraneous fields, all must have the "omitempty" tag.

	// Payment contains the additional fields for a payment transaction.
	//
	// required: false
	Payment *PaymentTransactionType `json:"payment,omitempty"`

	// Keyreg contains the additional fields for a keyreg transaction.
	//
	// required: false
	Keyreg *KeyregTransactionType `json:"keyreg,omitempty"`

	// AssetConfig contains the additional fields for an asset config transaction.
	//
	// required: false
	AssetConfig *AssetConfigTransactionType `json:"curcfg,omitempty"`

	// AssetTransfer contains the additional fields for an asset transfer transaction.
	//
	// required: false
	AssetTransfer *AssetTransferTransactionType `json:"curxfer,omitempty"`

	// AssetFreeze contains the additional fields for an asset freeze transaction.
	//
	// required: false
	AssetFreeze *AssetFreezeTransactionType `json:"curfrz,omitempty"`

allow KMD to accept account addresses

for example, ImportMultisig() takes in a public key which forces you to decode an address

func (kcl Client) ImportMultisig(walletHandle string, version, threshold uint8, pks []ed25519.PublicKey) (resp ImportMultisigResponse, err error) {

python works nicely where it takes in an msig object to import a multisig account into a kmd wallet
https://github.com/algorand/py-algorand-sdk/blob/b079db660ae92d0dbf24dc04f28eb722711e426f/algosdk/kmd.py#L353

Panic on creating new wallet

I'm trying out the Algorand go sdk and get this when I try to create a new wallet on a private network:

./goal wallet new testwallet -d private/
Please choose a password for wallet 'testwallet':
Please confirm the password:
Creating wallet...
Created wallet 'testwallet'
Your new wallet has a backup phrase that can be used for recovery.
Keeping this backup phrase safe is extremely important.
Would you like to see it now? (Y/n): Y
Your backup phrase is printed below.
Keep this information safe -- never share it with anyone!

parrot rifle bean into elephant poet rough erosion turn prevent file capital twelve cabin dizzy leaf mercy agree tag quantum clock paddle bright able taste
ERRO[0008] [Stack] goroutine 1 [running]:
runtime/debug.Stack(0xc0000c82d0, 0xc000010490, 0xc0003361e0)
	/Users/travis/.gimme/versions/go1.12.darwin.amd64/src/runtime/debug/stack.go:24 +0x9d
github.com/algorand/go-algorand/logging.logger.Error(0xc0000c82d0, 0xc000010490, 0xc000330240, 0x1, 0x1)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/logging/log.go:216 +0x48
main.(*AccountsList).dumpList(0xc0002565c0)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/accountsList.go:189 +0x1a6
main.(*AccountsList).setDefaultWalletID(...)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/accountsList.go:82
main.glob..func58(0x572b100, 0xc0002da540, 0x1, 0x3)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/wallet.go:183 +0x7e9
github.com/algorand/go-algorand/vendor/github.com/spf13/cobra.(*Command).execute(0x572b100, 0xc0002da4b0, 0x3, 0x3, 0x572b100, 0xc0002da4b0)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/vendor/github.com/spf13/cobra/command.go:766 +0x2ae
github.com/algorand/go-algorand/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x572eec0, 0x4d107f6, 0x7, 0x4d0c83c)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/vendor/github.com/spf13/cobra/command.go:852 +0x2c0
github.com/algorand/go-algorand/vendor/github.com/spf13/cobra.(*Command).Execute(...)
	/Users/travis/gopath/src/github.com/algorand/go-algorand/vendor/github.com/spf13/cobra/command.go:800
main.main()
	/Users/travis/gopath/src/github.com/algorand/go-algorand/cmd/goal/commands.go:133 +0x97
  file=accountsList.go function="main.(*AccountsList).dumpList" line=189
ERRO[0008] open private/private-v38/accountList.json: no such file or directory  file=accountsList.go function="main.(*AccountsList).dumpList" line=189
open private/private-v38/accountList.json: no such file or directory

Any reason why?

Bug in limitorder.GetSwapAssetsTransaction

From Jason trying to build out contract template examples:

The second payment in GetSwapAssetsTransaction, which transfers assets from the buyer's account to the owner, sets assetCloseRemainderTo=owner, but other SDKs do not.

Additionally, the comment says the first payment, which transfers algos from the contract, will close the remainder back to the owner; but the function sets algoCloseRemainderTo="", i.e. none.

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.