Skip to content

Commit

Permalink
no explicit username token registration owner (#1079)
Browse files Browse the repository at this point in the history
This change is a reverse of modification introduced in 0.23.0 release.
Do not allow to explicitely specify a new token owner. Rely on the
`AnySigner` result.
The above was an improvement. We deprecate `x/username` pacakge and do
not want to introduce more work, even if those are fixing issues.

resolve #1066
  • Loading branch information
husio authored Dec 16, 2019
1 parent 4cb0080 commit 1200d0d
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 119 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Breaking changes
- `orm.WithIndex` supports multiple indexer types,
- `orm.NewIndex` function was removed,

Breaking changes

- `x/username`: rollback of registration change introduced in 0.23.0. When
registering a token, do not allow to explicitly specify the new token owner.


## 0.23.0

Expand Down
1 change: 0 additions & 1 deletion cmd/bnscli/clitests/register_username.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set -e
bnscli register-username \
-name alice \
-bc fairycoin \
-owner 92066456B2BE7F1934624087D98C203A87F7752C \
-addr 46722031342e204a756e2031303a35363a3337204345535420323031390a \
| bnscli view

Expand Down
3 changes: 1 addition & 2 deletions cmd/bnscli/clitests/register_username.test.gold
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"blockchain_id": "fairycoin",
"address": "46722031342e204a756e2031303a35363a3337204345535420323031390a"
}
],
"owner": "92066456B2BE7F1934624087D98C203A87F7752C"
]
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/bnscli/cmd_username.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Create a transaction for registering a username.
}
var (
nameFl = fl.String("name", "", "Name part of the username. For example 'alice'")
ownerFl = flAddress(fl, "owner", "", "An address that the newly registered token will belong to. Transaction does not have to be signed by this address.")
namespaceFl = fl.String("ns", "iov", "Namespace (domain) part of the username. For example 'iov'")
blockchainFl = fl.String("bc", "", "Blockchain network ID.")
addressFl = fl.String("addr", "", "String representation of the blochain address on this network.")
Expand All @@ -47,7 +46,6 @@ Create a transaction for registering a username.
Metadata: &weave.Metadata{Schema: 1},
Username: *nameFl + "*" + *namespaceFl,
Targets: targets,
Owner: *ownerFl,
}
if err := msg.Validate(); err != nil {
return fmt.Errorf("given data produce an invalid message: %s", err)
Expand Down
117 changes: 32 additions & 85 deletions cmd/bnsd/x/username/codec.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions cmd/bnsd/x/username/codec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ message RegisterTokenMsg {
string username = 2;
// Targets is a blockchain address list that this token should point to.
repeated BlockchainAddress targets = 3 [(gogoproto.nullable) = false];
// Owner is the address that the newly created token will belong to.
bytes owner = 4 [(gogoproto.casttype) = "github.com/iov-one/weave.Address"];
}

// TransferTokenMsg is a request to transfer an ownership of a token. The
Expand Down
12 changes: 3 additions & 9 deletions cmd/bnsd/x/username/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,9 @@ func (h *registerTokenHandler) Deliver(ctx weave.Context, db weave.KVStore, tx w
return nil, err
}

var owner weave.Address
if len(msg.Owner) != 0 {
// Permission is not required.
owner = msg.Owner
} else {
owner = x.AnySigner(ctx, h.auth).Address()
if len(owner) == 0 {
return nil, errors.Wrap(errors.ErrUnauthorized, "message must be signed")
}
owner := x.AnySigner(ctx, h.auth).Address()
if len(owner) == 0 {
return nil, errors.Wrap(errors.ErrUnauthorized, "message must be signed")
}

token := Token{
Expand Down
7 changes: 0 additions & 7 deletions cmd/bnsd/x/username/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ func (m *RegisterTokenMsg) Validate() error {

// Username should but cannot be validated here.

// Owner field is optional.
if len(m.Owner) != 0 {
if err := m.Owner.Validate(); err != nil {
return errors.Wrap(err, "owner")
}
}

if err := validateTargets(m.Targets); err != nil {
return errors.Wrap(err, "targets")
}
Expand Down
7 changes: 0 additions & 7 deletions docs/proto/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2979,13 +2979,6 @@ <h3 id="username.RegisterTokenMsg">RegisterTokenMsg</h3>
<td><p>Targets is a blockchain address list that this token should point to. </p></td>
</tr>

<tr>
<td>owner</td>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>Owner is the address that the newly created token will belong to. </p></td>
</tr>

</tbody>
</table>

Expand Down
2 changes: 0 additions & 2 deletions spec/gogo/cmd/bnsd/x/username/codec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ message RegisterTokenMsg {
string username = 2;
// Targets is a blockchain address list that this token should point to.
repeated BlockchainAddress targets = 3 [(gogoproto.nullable) = false];
// Owner is the address that the newly created token will belong to.
bytes owner = 4 [(gogoproto.casttype) = "github.com/iov-one/weave.Address"];
}

// TransferTokenMsg is a request to transfer an ownership of a token. The
Expand Down
2 changes: 0 additions & 2 deletions spec/proto/cmd/bnsd/x/username/codec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ message RegisterTokenMsg {
string username = 2;
// Targets is a blockchain address list that this token should point to.
repeated BlockchainAddress targets = 3 ;
// Owner is the address that the newly created token will belong to.
bytes owner = 4 ;
}

// TransferTokenMsg is a request to transfer an ownership of a token. The
Expand Down

0 comments on commit 1200d0d

Please sign in to comment.