Compare commits
2 commits
master
...
proxy-add-
Author | SHA1 | Date | |
---|---|---|---|
ca6cb402a2 | |||
a096c5c38d |
3 changed files with 27 additions and 14 deletions
|
@ -20,23 +20,32 @@ const (
|
||||||
accountAddressFlag = "account"
|
accountAddressFlag = "account"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func parseAddresses(cmd *cobra.Command) []util.Uint160 {
|
||||||
|
var addrs []util.Uint160
|
||||||
|
|
||||||
|
accs, _ := cmd.Flags().GetStringArray(accountAddressFlag)
|
||||||
|
for _, acc := range accs {
|
||||||
|
addr, err := address.StringToUint160(acc)
|
||||||
|
commonCmd.ExitOnErr(cmd, "invalid account: %w", err)
|
||||||
|
|
||||||
|
addrs = append(addrs, addr)
|
||||||
|
}
|
||||||
|
return addrs
|
||||||
|
}
|
||||||
|
|
||||||
func addProxyAccount(cmd *cobra.Command, _ []string) {
|
func addProxyAccount(cmd *cobra.Command, _ []string) {
|
||||||
acc, _ := cmd.Flags().GetString(accountAddressFlag)
|
addrs := parseAddresses(cmd)
|
||||||
addr, err := address.StringToUint160(acc)
|
err := processAccount(cmd, addrs, "addAccount")
|
||||||
commonCmd.ExitOnErr(cmd, "invalid account: %w", err)
|
|
||||||
err = processAccount(cmd, addr, "addAccount")
|
|
||||||
commonCmd.ExitOnErr(cmd, "processing error: %w", err)
|
commonCmd.ExitOnErr(cmd, "processing error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeProxyAccount(cmd *cobra.Command, _ []string) {
|
func removeProxyAccount(cmd *cobra.Command, _ []string) {
|
||||||
acc, _ := cmd.Flags().GetString(accountAddressFlag)
|
addrs := parseAddresses(cmd)
|
||||||
addr, err := address.StringToUint160(acc)
|
err := processAccount(cmd, addrs, "removeAccount")
|
||||||
commonCmd.ExitOnErr(cmd, "invalid account: %w", err)
|
|
||||||
err = processAccount(cmd, addr, "removeAccount")
|
|
||||||
commonCmd.ExitOnErr(cmd, "processing error: %w", err)
|
commonCmd.ExitOnErr(cmd, "processing error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func processAccount(cmd *cobra.Command, addr util.Uint160, method string) error {
|
func processAccount(cmd *cobra.Command, addrs []util.Uint160, method string) error {
|
||||||
wCtx, err := helper.NewInitializeContext(cmd, viper.GetViper())
|
wCtx, err := helper.NewInitializeContext(cmd, viper.GetViper())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't initialize context: %w", err)
|
return fmt.Errorf("can't initialize context: %w", err)
|
||||||
|
@ -54,7 +63,9 @@ func processAccount(cmd *cobra.Command, addr util.Uint160, method string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
bw := io.NewBufBinWriter()
|
bw := io.NewBufBinWriter()
|
||||||
emit.AppCall(bw.BinWriter, proxyHash, method, callflag.All, addr)
|
for _, addr := range addrs {
|
||||||
|
emit.AppCall(bw.BinWriter, proxyHash, method, callflag.All, addr)
|
||||||
|
}
|
||||||
|
|
||||||
if err := wCtx.SendConsensusTx(bw.Bytes()); err != nil {
|
if err := wCtx.SendConsensusTx(bw.Bytes()); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -29,13 +29,15 @@ var (
|
||||||
|
|
||||||
func initProxyAddAccount() {
|
func initProxyAddAccount() {
|
||||||
AddAccountCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
AddAccountCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
AddAccountCmd.Flags().String(accountAddressFlag, "", "Wallet address string")
|
AddAccountCmd.Flags().StringArray(accountAddressFlag, nil, "Wallet address string")
|
||||||
|
_ = AddAccountCmd.MarkFlagRequired(accountAddressFlag)
|
||||||
AddAccountCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
AddAccountCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initProxyRemoveAccount() {
|
func initProxyRemoveAccount() {
|
||||||
RemoveAccountCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
RemoveAccountCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
||||||
RemoveAccountCmd.Flags().String(accountAddressFlag, "", "Wallet address string")
|
RemoveAccountCmd.Flags().StringArray(accountAddressFlag, nil, "Wallet address string")
|
||||||
|
_ = AddAccountCmd.MarkFlagRequired(accountAddressFlag)
|
||||||
RemoveAccountCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
RemoveAccountCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,13 +162,13 @@ func (s *searchStreamMsgSizeCtrl) Send(resp *object.SearchResponse) error {
|
||||||
|
|
||||||
var newResp *object.SearchResponse
|
var newResp *object.SearchResponse
|
||||||
|
|
||||||
for {
|
for ln := uint64(len(ids)); ; {
|
||||||
if newResp == nil {
|
if newResp == nil {
|
||||||
newResp = new(object.SearchResponse)
|
newResp = new(object.SearchResponse)
|
||||||
newResp.SetBody(body)
|
newResp.SetBody(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
cut := min(s.addrAmount, uint64(len(ids)))
|
cut := min(s.addrAmount, ln)
|
||||||
|
|
||||||
body.SetIDList(ids[:cut])
|
body.SetIDList(ids[:cut])
|
||||||
newResp.SetMetaHeader(resp.GetMetaHeader())
|
newResp.SetMetaHeader(resp.GetMetaHeader())
|
||||||
|
|
Loading…
Reference in a new issue