Skip to content

Commit

Permalink
Merge pull request #120 from iotaledger/develop
Browse files Browse the repository at this point in the history
0.1.1
  • Loading branch information
BugFreeSoftware authored Mar 3, 2021
2 parents a4ab1a4 + fff2125 commit cac1cc7
Show file tree
Hide file tree
Showing 242 changed files with 3,395 additions and 4,005 deletions.
2 changes: 1 addition & 1 deletion client/chainclient/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *Client) FetchSCStatus(addCustomQueries func(query *statequery.Request))
StateTxId: res.StateTxId.ID(),
Requests: res.Requests,

ProgramHash: res.Get(vmconst.VarNameProgramData).MustHashValue(),
ProgramHash: &res.Get(vmconst.VarNameProgramData).MustHashValue(),
Description: description,
OwnerAddress: res.Get(vmconst.VarNameOwnerAddress).MustAddress(),
MinimumReward: minReward,
Expand Down
2 changes: 1 addition & 1 deletion client/chainclient/uploadblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (c *Client) UploadBlob(fields dict.Dict, waspHosts []string, quorum int, op
}
nodesMultiApi := multiclient.New(waspHosts)
if err := nodesMultiApi.UploadData(fieldValues, quorum); err != nil {
return hashing.HashValue{}, nil, err
return hashing.NilHash, nil, err
}
blobHash := blob.MustGetBlobHash(fields)

Expand Down
2 changes: 1 addition & 1 deletion contracts/common/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
CreatorWallet signaturescheme.SignatureScheme
)

func DeployContract(t *testing.T, scName string) *solo.Chain {
func StartChainAndDeployWasmContractByName(t *testing.T, scName string) *solo.Chain {
wasmhost.HostTracing = TraceHost
env := solo.New(t, Debug, StackTrace)
CreatorWallet = env.NewSignatureSchemeWithFunds()
Expand Down
12 changes: 6 additions & 6 deletions contracts/getproc.go → contracts/native/getproc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package contracts
package native

import (
"fmt"
Expand All @@ -18,19 +18,19 @@ var (
allExamplesMutex = &sync.Mutex{}
)

// AddExampleProcessor adds new processor to the runtime registry of example processors.
// AddProcessor adds new processor to the runtime registry of example processors.
// The 'proc' represents executable of the specific smart contract.
// It must implement coretypes.Processor
func AddExampleProcessor(c *coreutil.ContractInterface) {
func AddProcessor(c *coreutil.ContractInterface) {
allExamplesMutex.Lock()
defer allExamplesMutex.Unlock()
allExamples[c.ProgramHash] = c
fmt.Printf("----- AddExampleProcessor: name: '%s', program hash: %s, description: '%s'\n",
fmt.Printf("----- AddProcessor: name: '%s', program hash: %s, description: '%s'\n",
c.Name, c.ProgramHash.String(), c.Description)
}

// GetExampleProcessor retrieves smart contract processor (VM) by the hash (with existence flag)
func GetExampleProcessor(progHash hashing.HashValue) (coretypes.Processor, bool) {
// GetProcessor retrieves smart contract processor (VM) by the hash (with existence flag)
func GetProcessor(progHash hashing.HashValue) (coretypes.Processor, bool) {
ret, ok := allExamples[progHash]
if !ok {
return nil, false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/wasp/contracts/examples_core/donatewithfeedback"
"github.com/iotaledger/wasp/contracts/native/ignore/donatewithfeedback"
"github.com/iotaledger/wasp/packages/coretypes"
"github.com/iotaledger/wasp/packages/kv/codec"
"github.com/iotaledger/wasp/packages/kv/collections"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func placeBet(ctx coretypes.Sandbox) error {
if collections.NewArray(state, StateVarLockedBets).MustLen() > 0 {
ok := state.MustHas(StateVarEntropyFromLocking)
if !ok {
ehv := ctx.GetEntropy()
state.Set(StateVarEntropyFromLocking, codec.EncodeHashValue(&ehv))
entropy := codec.EncodeHashValue(ctx.GetEntropy())
state.Set(StateVarEntropyFromLocking, entropy)
}
}

Expand Down Expand Up @@ -305,8 +305,7 @@ func playAndDistribute(ctx coretypes.Sandbox) error {
// the current context
entropy, ok, _ := codec.DecodeHashValue(state.MustGet(StateVarEntropyFromLocking))
if !ok {
h := ctx.GetEntropy()
entropy = &h
entropy = ctx.GetEntropy()
}

// 'playing the wheel' means taking first 8 bytes of the entropy as uint64 number and
Expand Down Expand Up @@ -545,15 +544,15 @@ func (ps *PlayerStats) String() string {

func withPlayerStats(ctx coretypes.Sandbox, player *coretypes.AgentID, f func(ps *PlayerStats)) error {
statsDict := collections.NewMap(ctx.State(), StateVarPlayerStats)
b := statsDict.MustGetAt(player.Bytes())
b := statsDict.MustGetAt(player[:])
stats, err := DecodePlayerStats(b)
if err != nil {
return err
}

f(stats)

statsDict.MustSetAt(player.Bytes(), encodePlayerStats(stats))
statsDict.MustSetAt(player[:], encodePlayerStats(stats))

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package inccounter

import (
"fmt"
"github.com/iotaledger/wasp/contracts"
"github.com/iotaledger/wasp/contracts/native"
"github.com/iotaledger/wasp/packages/coretypes"
"github.com/iotaledger/wasp/packages/coretypes/coreutil"
"github.com/iotaledger/wasp/packages/hashing"
Expand Down Expand Up @@ -49,7 +49,7 @@ const (
)

func init() {
contracts.AddExampleProcessor(Interface)
native.AddProcessor(Interface)
}

func initialize(ctx coretypes.Sandbox) (dict.Dict, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestIncDefaultParam(t *testing.T) {
require.NoError(t, err)
checkCounter(chain, 17)

_, err = chain.PostRequest(solo.NewCallParams(incName, FuncIncCounter), nil)
_, err = chain.PostRequestSync(solo.NewCallParams(incName, FuncIncCounter), nil)
require.NoError(t, err)
checkCounter(chain, 18)
chain.CheckAccountLedger()
Expand All @@ -69,7 +69,7 @@ func TestIncParam(t *testing.T) {
require.NoError(t, err)
checkCounter(chain, 17)

_, err = chain.PostRequest(solo.NewCallParams(incName, FuncIncCounter, VarCounter, 3), nil)
_, err = chain.PostRequestSync(solo.NewCallParams(incName, FuncIncCounter, VarCounter, 3), nil)
require.NoError(t, err)
checkCounter(chain, 20)

Expand All @@ -86,7 +86,7 @@ func TestIncWith1Post(t *testing.T) {

req := solo.NewCallParams(incName, FuncIncAndRepeatOnceAfter5s).
WithTransfer(balance.ColorIOTA, 1)
_, err = chain.PostRequest(req, nil)
_, err = chain.PostRequestSync(req, nil)
require.NoError(t, err)
// advance logical clock to unlock that timelocked request
env.AdvanceClockBy(6 * time.Second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/address"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/hive.go/crypto/ed25519"
"github.com/iotaledger/wasp/packages/coretypes"
"github.com/iotaledger/wasp/packages/coretypes/assert"
"github.com/iotaledger/wasp/packages/coretypes/cbalances"
Expand All @@ -28,9 +27,8 @@ func publicKey(ctx coretypes.Sandbox) (dict.Dict, error) {
par := kvdecoder.New(ctx.Params(), ctx.Log())

pubKeyBin := par.MustGetBytes(ParamPublicKey)
pubKey, _, err := ed25519.PublicKeyFromBytes(pubKeyBin)
addr, err := ctx.Utils().ED25519().AddressFromPublicKey(pubKeyBin)
a.RequireNoError(err)
addr := address.FromED25519PubKey(pubKey)
a.Require(addr == ctx.Caller().MustAddress(), "public key does not correspond to the caller's address")

pkRegistry := collections.NewMap(ctx.State(), StateVarPublicKeys)
Expand Down Expand Up @@ -263,7 +261,7 @@ func processPayments(ctx coretypes.Sandbox, payments []*Payment, payerAddr, targ
}
data := paymentEssence(p.Ord, p.Amount, payerAddr, targetAddr)
lastOrd = int64(p.Ord)
if !ctx.Utils().ValidED25519Signature(data, payerPubKey, p.SignatureShort) {
if !ctx.Utils().ED25519().ValidSignature(data, payerPubKey, p.SignatureShort) {
ctx.Log().Infof("wrong signature")
notSettled = append(notSettled, p)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package micropay

import (
"github.com/iotaledger/wasp/contracts"
"github.com/iotaledger/wasp/contracts/native"
"github.com/iotaledger/wasp/packages/coretypes/coreutil"
"github.com/iotaledger/wasp/packages/hashing"
"time"
Expand Down Expand Up @@ -32,7 +32,7 @@ func init() {
coreutil.Func(FuncSettle, settle),
coreutil.ViewFunc(FuncGetChannelInfo, getWarrantInfo),
})
contracts.AddExampleProcessor(Interface)
native.AddProcessor(Interface)
}

const (
Expand Down
Loading

0 comments on commit cac1cc7

Please sign in to comment.