Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #35 from O3Labs/claim-ong
Browse files Browse the repository at this point in the history
claim ong method
  • Loading branch information
apisit authored Jul 30, 2018
2 parents 1ac7a3e + 6bce313 commit ec881cc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
8 changes: 4 additions & 4 deletions neoutils/mobile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestMintTokensFromMobile(t *testing.T) {
scriptHash := "5f03828cb45198eedd659d264b6d3a1c889978ce"
scriptHash := "0x3e390ae61acb6713389c8fbbd47d1d69c32655a3"

wif := ""
wallet, _ := neoutils.GenerateFromWIF(wif)
Expand All @@ -19,9 +19,9 @@ func TestMintTokensFromMobile(t *testing.T) {
neo := string(smartcontract.NEO)
// gas := string(smartcontract.GAS)
amount := float64(2)
remark := "o3x"
network := "private"
networkFeeAmountInGAS := float64(0.0011)
remark := "O3XMOONLIGHT2"
network := "test"
networkFeeAmountInGAS := float64(0)
tx, err := neoutils.MintTokensRawTransactionMobile(network, scriptHash, wif, neo, amount, remark, networkFeeAmountInGAS)
if err != nil {
log.Printf("%v", err)
Expand Down
14 changes: 14 additions & 0 deletions neoutils/ont.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ func OntologyTransfer(endpoint string, gasPrice int, gasLimit int, wif string, a

return txid, nil
}

func ClaimONG(endpoint string, gasPrice int, gasLimit int, wif string) (string, error) {
raw, err := ontmobile.WithdrawONG(uint(gasPrice), uint(gasLimit), endpoint, wif)
if err != nil {
return "", err
}

txid, err := ontmobile.SendRawTransaction(endpoint, fmt.Sprintf("%x", raw.Data))
if err != nil {
return "", err
}

return txid, nil
}
14 changes: 14 additions & 0 deletions neoutils/ont_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,17 @@ func TestONTTransfer(t *testing.T) {
}
log.Printf("tx id =%v", txid)
}

func TestClaimONG(t *testing.T) {
endpoint := "http://dappnode2.ont.io:20336"
wif, _ := neoutils.NEP2Decrypt("", "")

gasPrice := int(500)
gasLimit := int(20000)
txid, err := neoutils.ClaimONG(endpoint, gasPrice, gasLimit, wif)
if err != nil {
log.Printf("err %v", err)
return
}
log.Printf("tx id =%v", txid)
}
6 changes: 3 additions & 3 deletions neoutils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestSmartContractScripthashToAddress(t *testing.T) {
}

func TestNEOAddressToScriptHash(t *testing.T) {
hash := NEOAddressToScriptHashWithEndian("AeNkbJdiMx49kBStQdDih7BzfDwyTNVRfb", binary.LittleEndian)
hash := NEOAddressToScriptHashWithEndian("ASi48wqdF9avm91pWwdphcAmaDJQkPNdNt", binary.LittleEndian)
b, _ := hex.DecodeString(hash)
log.Printf("\nlittle endian %v \nbig endian %x", hash, ReverseBytes(b))
}
Expand All @@ -49,7 +49,7 @@ func TestValidateNEOAddressInvalidAddress(t *testing.T) {
}

func TestConverting(t *testing.T) {
hexByteArray := "07ca92e5b37b4fff" //500000000000000000
hexByteArray := "c02709" //500000000000000000
//hex := "005c7c875e" = 405991873536
value := ConvertByteArrayToBigInt(hexByteArray)
vvv := float64(value.Int64()) / float64(math.Pow10(8))
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestHash256(t *testing.T) {
}

func TestPublicKeyToNEOAddress(t *testing.T) {
publicKey := "02ac3cecf6a5909c199fb5d6840577680c232fe3d5594c6514cc7897c4dd384728"
publicKey := "022c9652d3ad5cc065aa9147dc2ad022f80001e8ed233de20f352950d351d472b7"
b, _ := hex.DecodeString(publicKey)
address := PublicKeyToNEOAddress(b)
log.Printf("%v", address)
Expand Down
5 changes: 4 additions & 1 deletion neoutils/version.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package neoutils

const (
VERSION = "1.2.0"
VERSION = "1.2.1"
)

//RELEASE NOTES

// V.1.2.1
// - Added ClaimONG

// V.1.2.0
// - Added generate multisignature address redeem script
// - Added gasPrice and gasLimit to ontology transfer method
Expand Down

0 comments on commit ec881cc

Please sign in to comment.