fix spaces
This commit is contained in:
parent
956395df8a
commit
d5126a94e4
7 changed files with 39 additions and 36 deletions
1
Comment/comment.json
Executable file
1
Comment/comment.json
Executable file
|
@ -0,0 +1 @@
|
|||
{"name":"comment","abi":{"methods":[{"name":"_deploy","offset":0,"parameters":[{"name":"data","type":"Any"},{"name":"isUpdate","type":"Boolean"}],"returntype":"Void","safe":false},{"name":"createNewComment","offset":35,"parameters":[{"name":"userLogin","type":"String"},{"name":"postId","type":"String"},{"name":"text","type":"String"}],"returntype":"Void","safe":false},{"name":"getByLogin","offset":580,"parameters":[{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"getByLoginInPost","offset":529,"parameters":[{"name":"postId","type":"String"},{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"getByPostId","offset":430,"parameters":[{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"getComment","offset":648,"parameters":[{"name":"commentId","type":"String"}],"returntype":"Array","safe":false},{"name":"rateComment","offset":709,"parameters":[{"name":"isLike","type":"Boolean"},{"name":"postId","type":"String"},{"name":"commentId","type":"String"}],"returntype":"Void","safe":false},{"name":"updateComment","offset":740,"parameters":[{"name":"comment","type":"Array"},{"name":"postId","type":"String"}],"returntype":"Void","safe":false}],"events":[{"name":"Hello world!","parameters":[{"name":"args","type":"Array"}]}]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"extra":null}
|
BIN
Comment/comment.nef
Executable file
BIN
Comment/comment.nef
Executable file
Binary file not shown.
1
Post/post_contract.json
Executable file
1
Post/post_contract.json
Executable file
|
@ -0,0 +1 @@
|
|||
{"name":"Post","abi":{"methods":[{"name":"getAllPosts","offset":217,"parameters":[],"returntype":"Array","safe":false},{"name":"getAllPostsByUser","offset":358,"parameters":[{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"getPost","offset":300,"parameters":[{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"newPost","offset":0,"parameters":[{"name":"login","type":"String"},{"name":"text","type":"String"},{"name":"postName","type":"String"}],"returntype":"Void","safe":false},{"name":"ratePost","offset":514,"parameters":[{"name":"isLike","type":"Boolean"},{"name":"postId","type":"String"}],"returntype":"Void","safe":false}],"events":[]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"extra":null}
|
BIN
Post/post_contract.nef
Executable file
BIN
Post/post_contract.nef
Executable file
Binary file not shown.
72
User/user.go
72
User/user.go
|
@ -1,66 +1,66 @@
|
|||
package Users
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
name string
|
||||
surname string
|
||||
login string
|
||||
password string
|
||||
ownerHash interop.Hash160
|
||||
name string
|
||||
surname string
|
||||
login string
|
||||
password string
|
||||
ownerHash interop.Hash160
|
||||
}
|
||||
|
||||
const (
|
||||
lastIndex = "_lastIndex"
|
||||
lastIndex = "_lastIndex"
|
||||
)
|
||||
|
||||
func NewUser(name string, surname string, login string, password string, owner interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
existing_login := storage.Get(ctx, login)
|
||||
if existing_login != nil {
|
||||
panic("this login is taken by someone else")
|
||||
}
|
||||
ctx := storage.GetContext()
|
||||
existing_login := storage.Get(ctx, login)
|
||||
if existing_login != nil {
|
||||
panic("this login is taken by someone else")
|
||||
}
|
||||
|
||||
user := User{
|
||||
name: name,
|
||||
surname: surname,
|
||||
login: login,
|
||||
password: password,
|
||||
ownerHash: owner,
|
||||
}
|
||||
user := User{
|
||||
name: name,
|
||||
surname: surname,
|
||||
login: login,
|
||||
password: password,
|
||||
ownerHash: owner,
|
||||
}
|
||||
|
||||
saveUser(ctx, login, user)
|
||||
saveUser(ctx, login, user)
|
||||
|
||||
}
|
||||
|
||||
func GetUser(login string) User {
|
||||
return getUserTst(storage.GetReadOnlyContext(), login)
|
||||
return getUserTst(storage.GetReadOnlyContext(), login)
|
||||
}
|
||||
|
||||
func RateForGas(commentId string, contractHash interop.Hash160, login string) {
|
||||
ctx := storage.GetContext()
|
||||
contract.Call(contractHash, "rate", contract.ReadOnly, commentId, storage.Get(ctx, login+"_hash"))
|
||||
ctx := storage.GetContext()
|
||||
contract.Call(contractHash, "rate", contract.ReadOnly, commentId, storage.Get(ctx, login+"_hash"))
|
||||
}
|
||||
|
||||
func getUserTst(ctx storage.Context, login string) User {
|
||||
data := storage.Get(ctx, login)
|
||||
data := storage.Get(ctx, login)
|
||||
|
||||
if data == nil {
|
||||
panic("User does not exist")
|
||||
}
|
||||
if data == nil {
|
||||
panic("User does not exist")
|
||||
}
|
||||
|
||||
return std.Deserialize(data.([]byte)).(User)
|
||||
return std.Deserialize(data.([]byte)).(User)
|
||||
}
|
||||
|
||||
func saveUser(ctx storage.Context, userLogin string, user User) {
|
||||
runtime.Log("User " + userLogin + " was created")
|
||||
runtime.Log("User " + userLogin + " was created")
|
||||
|
||||
storage.Put(ctx, userLogin+"_hash", user.ownerHash)
|
||||
storage.Put(ctx, userLogin, std.Serialize(user))
|
||||
}
|
||||
storage.Put(ctx, userLogin+"_hash", user.ownerHash)
|
||||
storage.Put(ctx, userLogin, std.Serialize(user))
|
||||
}
|
||||
|
|
1
User/user.json
Executable file
1
User/user.json
Executable file
|
@ -0,0 +1 @@
|
|||
{"name":"user","abi":{"methods":[{"name":"getUser","offset":83,"parameters":[{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"newUser","offset":0,"parameters":[{"name":"name","type":"String"},{"name":"surname","type":"String"},{"name":"login","type":"String"},{"name":"password","type":"String"},{"name":"owner","type":"Hash160"}],"returntype":"Void","safe":false},{"name":"rateForGas","offset":96,"parameters":[{"name":"commentId","type":"String"},{"name":"contractHash","type":"Hash160"},{"name":"login","type":"String"}],"returntype":"Void","safe":false}],"events":[]},"features":{},"groups":[],"permissions":[],"supportedstandards":[],"trusts":[],"extra":null}
|
BIN
User/user.nef
Executable file
BIN
User/user.nef
Executable file
Binary file not shown.
Loading…
Reference in a new issue