2024-02-02 06:49:03 +00:00
|
|
|
package util
|
2021-11-29 12:33:46 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
|
|
|
)
|
|
|
|
|
2024-02-02 06:49:03 +00:00
|
|
|
func AddManifestGroup(cw *wallet.Wallet, h util.Uint160, cs *ContractState) error {
|
2024-02-01 11:30:59 +00:00
|
|
|
priv := cw.Accounts[0].PrivateKey()
|
2021-11-29 12:33:46 +00:00
|
|
|
pub := priv.PublicKey()
|
|
|
|
|
|
|
|
sig := priv.Sign(h.BytesBE())
|
|
|
|
found := false
|
|
|
|
|
|
|
|
for i := range cs.Manifest.Groups {
|
|
|
|
if cs.Manifest.Groups[i].PublicKey.Equal(pub) {
|
|
|
|
cs.Manifest.Groups[i].Signature = sig
|
|
|
|
found = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !found {
|
|
|
|
cs.Manifest.Groups = append(cs.Manifest.Groups, manifest.Group{
|
|
|
|
PublicKey: pub,
|
|
|
|
Signature: sig,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err := json.Marshal(cs.Manifest)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cs.RawManifest = data
|
|
|
|
return nil
|
|
|
|
}
|