feat(contract): init and implement create with get
This commit is contained in:
parent
502cd51a66
commit
183a25dbe3
3 changed files with 30 additions and 0 deletions
5
contract/go.mod
Normal file
5
contract/go.mod
Normal file
|
@ -0,0 +1,5 @@
|
|||
module git.frostfs.info/Web3N3/neowolves/contract
|
||||
|
||||
go 1.21.5
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20231229133344-d90169761595
|
2
contract/go.sum
Normal file
2
contract/go.sum
Normal file
|
@ -0,0 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20231229133344-d90169761595 h1:vWtkeZPpwlHV55W/PSTbRP8aH37UrbdTAOyB5J1xgDM=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20231229133344-d90169761595/go.mod h1:J/Mk6+nKeKSW4wygkZQFLQ6SkLOSGX5Ga0RuuuktEag=
|
23
contract/passtorage.go
Normal file
23
contract/passtorage.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||
)
|
||||
|
||||
func CreateUser(login string, password interop.Hash256) {
|
||||
ctx := storage.GetContext()
|
||||
// NOTE: maybe we should handle case where user already exists
|
||||
storage.Put(ctx, login, password)
|
||||
}
|
||||
|
||||
func CheckUser(login string, givenPassword interop.Hash256) {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
password := storage.Get(ctx, login).(interop.Hash256)
|
||||
if password == nil {
|
||||
panic("This user does not exist")
|
||||
}
|
||||
if !password.Equals(givenPassword) {
|
||||
panic("Password hashes does not match")
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue