Compare commits

...
47 Commits
Author SHA1 Message Date
nabarun 94920171ae Upgrade package version (#13) 2022-12-09 17:35:49 +05:30
nabarun 2a9223fdd3 Add missing dependecies in package.json (#12) 2022-12-09 17:23:09 +05:30
nabarun 7ecd3eefa8 Add github workflow to publish package (#11) 2022-12-09 16:15:39 +05:30
nabarun ee0443b5fa Changes to use laconic-sdk with console-app (#10)
* Use older version of tiny-secp256k1 to work in browser

* Make REST endpoint optional
2022-12-09 14:25:13 +05:30
dboreham 3a890ab46c Merge pull request #5 from cerc-io/murali/fix-tests
fix: tests failing against updated laconicd
2022-11-04 06:46:09 -06:00
dboreham b9cb479381 Revert to fixturenet chain id 2022-11-04 06:45:42 -06:00
0xmuralik fa0a4150bd update fee 2022-11-01 15:40:34 +05:30
dboreham 733e4a6cc6 Merge pull request #4 from cerc-io/dboreham/repo-rename
Changes to match repo renaming
2022-10-12 21:00:54 -06:00
dboreham 8e852ad2ce Changes to match repo renaming 2022-10-10 16:13:24 -06:00
dboreham 62d47f0c4b Merge pull request #2 from cerc-io/dboreham/doc-fixes
Blind attempt to re-brand
2022-10-03 12:19:57 -06:00
dboreham faf7c18e5c Merge pull request #1 from cerc-io/dboreham/fix-dependency-versions
Fix dependencies to remove yarn warnings
2022-10-03 12:19:27 -06:00
dboreham fb3edfabd3 Revert postinstall script 2022-09-28 20:37:00 -06:00
dboreham ff3d70cc0d Add postinstall target 2022-09-28 19:52:00 -06:00
dboreham b1d3c83d32 Files the IDE thoughtfully did not save earlier 2022-09-28 13:22:57 -06:00
dboreham b07df23804 Blind attempt to re-brand 2022-09-28 13:20:15 -06:00
dboreham 5f1f3fa9e6 Fix dependencies to remove yarn warnings 2022-09-28 11:22:34 -06:00
nabarun 27a176fbad Implement methods and tests for associate/dissociate bonds and records (#4)
* Implement methods for bond associate and dissociate

* Uncomment test for getStatus GQL query
2022-04-27 15:30:21 +05:30
nabarun 3d103b5fca Add getRecordsByIds method and sdk tests (#3)
* Implement getRecordsByIds method

* Add tests for sdk
2022-04-25 15:12:46 +05:30
nabarun 003cfcbf5c Use GQL query getAccounts instead of REST API 2022-04-22 16:01:04 +05:30
nabarun 349bc650d9 Generate same CID from chiba-clonk chain 2022-04-22 16:01:04 +05:30
nabarun 28c8099b16 Get record id from setRecord message response 2022-04-21 09:44:24 +05:30
nabarun 79b55b73da Replace wrn with crn 2022-04-21 09:44:24 +05:30
nabarun e563cfe6b1 Add tests for record and authority expiry 2022-04-21 09:44:24 +05:30
nabarun 6ca9f4041a Fixes from review 2022-04-21 09:44:24 +05:30
nabarun c3066db987 Add test for util getContentId 2022-04-21 09:44:24 +05:30
nabarun 407d31cea7 Fix queryRecords to return results filtered by attributes 2022-04-21 09:44:24 +05:30
nabarun 0bc619cad2 Send messages from secondary accounts 2022-04-21 09:44:24 +05:30
nabarun 838edaa9a6 Add auction tests for commitBid and revealBid 2022-04-21 09:44:24 +05:30
nabarun d51f9618e0 Implement tests for auction module 2022-04-21 09:44:24 +05:30
nabarun 44b3990377 Fix generating account address from private key 2022-04-21 09:44:24 +05:30
nabarun 837d9691ec Check if error contains expected message for failing transactions 2022-04-21 09:44:24 +05:30
nabarun 394f015a5e Add tests for nameservice deleteName 2022-04-21 09:44:24 +05:30
nabarun f207be4838 Add tests for querying names and deleteName 2022-04-21 09:44:24 +05:30
nabarun 9de3c59c19 Implement setRecord and add test for setAutorityBond 2022-04-21 09:44:24 +05:30
nabarun 48507ca46a Rename ethermint to chibaclonk 2022-04-21 09:44:24 +05:30
nabarun 58227b68be Changes from review 2022-04-21 09:44:24 +05:30
nabarun 252665512d Add tests for reserving authority with different owner 2022-04-21 09:44:24 +05:30
nabarun 65e90e7af0 Add nameservice tests for reserve and lookup authority 2022-04-21 09:44:24 +05:30
nabarun 36b633b908 Update README with steps to run tests 2022-04-21 09:44:24 +05:30
nabarun df5619932d Add tests for bond refill, withdraw and cancel 2022-04-21 09:44:24 +05:30
nabarun 7fe5bcda83 Add tests for querying bond 2022-04-21 09:44:24 +05:30
nabarun 19d5405087 Implement pattern from dxns-registry-client 2022-04-21 09:44:24 +05:30
nabarun 6bb264d69c Fix create bond message 2022-04-21 09:44:24 +05:30
nabarun 4c3a3558d3 Message for creating bond 2022-04-21 09:44:24 +05:30
nabarun 3f2bdd34f8 Send vote message in gov module 2022-04-21 09:44:24 +05:30
nabarun 72ab467d9b Send tokens using evmosjs and eth-sig-util 2022-04-21 09:44:24 +05:30
nabarun 6871e35964 Add failing test case for sending tokens 2022-04-21 09:44:24 +05:30
81 changed files with 25669 additions and 1 deletions
+2
View File
@@ -0,0 +1,2 @@
PRIVATE_KEY=75f719e613d05efab06a3f1dde5250b497723b13d4afa4f8ed80145764e40cf7
COSMOS_CHAIN_ID=laconic_9000-1
+32
View File
@@ -0,0 +1,32 @@
name: Publish npm package to gitea
on:
release:
types: [published]
jobs:
npm_publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- name: Run yarn build
run: |
yarn build
- name: Configure git.vdb.to npm registry
run: |
npm config set registry https://git.vdb.to/api/packages/cerc-io/npm/
- name: Authenticate to git.vdb.to registry
run: |
npm config set -- '//git.vdb.to/api/packages/cerc-io/npm/:_authToken' "${{ secrets.GITEA_PUBLISH_TOKEN }}"
- name: npm publish
run: |
npm publish
+3
View File
@@ -0,0 +1,3 @@
node_modules
dist
.env
+24
View File
@@ -0,0 +1,24 @@
# Development
## Protobuf
Run following scripts when [proto files](./proto/) are updated.
1. Install dependencies
```bash
yarn
```
2. Generate typescript code for the proto files
```bash
./scripts/create-proto-files.sh
```
3. Remove GRPC code from generated code
```bash
./scripts/remove-grpc.sh
```
Reference: https://github.com/tharsis/evmosjs/tree/main/packages/proto#note
+90 -1
View File
@@ -1 +1,90 @@
# chiba-clonk-client
# laconic-sdk
## Tests
Follow these steps to run the tests:
- After cloning this repo run:
```bash
yarn
```
- Copy [.env.example](./.env.example) file and create a `.env` file.
- Clone the [laconicd repo](https://github.com/cerc-io/laconicd) and change to repo directory.
- Run the chain using `./init.sh`.
- Export the private key using:
```bash
laconicd keys export mykey --unarmored-hex --unsafe
```
- Copy the private key and assign it to variable `PRIVATE_KEY` in the `.env` file.
- Run the tests in laconic-sdk repo:
```bash
yarn test
```
- Run the tests with auctions enabled
- In laconicd repo run:
```bash
TEST_AUCTION_ENABLED=true ./init.sh
```
- Export the private key and change it in `.env` file again using:
```bash
laconicd keys export mykey --unarmored-hex --unsafe
```
- Run tests:
```bash
yarn test:auctions
```
- Run the tests for record and authority expiry
- In laconicd repo run:
```bash
TEST_NAMESERVICE_EXPIRY=true ./init.sh
```
- Export the private key and change it in `.env` file again using:
```bash
laconicd keys export mykey --unarmored-hex --unsafe
```
- Run tests:
```bash
yarn test:nameservice-expiry
```
## Development
[README](./DEVELOPMENT.md)
## Known Issues
- Passing a float type value in [watcher attributes](./src/testing/data/watcher.yml) throws error when sending `setRecord` message.
```
failed to execute message; message index: 0: Invalid signature.: unauthorized
```
- When sending `setRecord` message, an integer value passed in watcher attributes is parsed as float type in laconicd while [unmarshalling json](https://pkg.go.dev/encoding/json#Unmarshal).
- `setRecord` message throws error when fileds in [Record](./src/types.ts) message are not assigned.
```
failed to pack and hash typedData primary type: provided data '<nil>' doesn't match type 'string' [tharsis/ethermint/ethereum/eip712/eip712.go:33]
```
Passing dummy values to work around issue.
+6
View File
@@ -0,0 +1,6 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFiles: ["dotenv/config"]
};
+58
View File
@@ -0,0 +1,58 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/laconic-sdk.git",
"author": "",
"license": "UNLICENSED",
"devDependencies": {
"@types/is-url": "^1.2.30",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.181",
"@types/semver": "^7.3.9",
"@types/tiny-secp256k1": "1.0.0",
"dotenv": "^16.0.0",
"google-protobuf": "^3.21.0",
"jest": "29.0.0",
"protoc-gen-ts": "^0.8.5",
"ts-jest": "^29.0.2",
"typescript": "^4.6.2"
},
"dependencies": {
"@cosmjs/amino": "^0.28.1",
"@cosmjs/crypto": "^0.28.1",
"@cosmjs/encoding": "^0.28.1",
"@ipld/dag-cbor": "^7.0.1",
"@ipld/dag-json": "^8.0.9",
"@metamask/eth-sig-util": "^4.0.0",
"@tharsis/address-converter": "^0.1.7",
"@tharsis/eip712": "^0.2.1",
"@tharsis/proto": "^0.1.16",
"@tharsis/provider": "^0.2.4",
"@tharsis/transactions": "^0.2.2",
"axios": "^0.26.1",
"bip32": "^3.0.1",
"bip39": "^3.0.4",
"canonical-json": "^0.0.4",
"ethers": "^5.6.2",
"evmosjs": "^0.2.5",
"graphql.js": "^0.6.8",
"is-url": "^1.2.4",
"js-sha256": "^0.9.0",
"js-yaml": "^3.14.1",
"jsonschema": "^1.4.0",
"lodash": "^4.17.21",
"multiformats": "^9.5.4",
"node-yaml": "^4.0.1",
"secp256k1": "^4.0.1",
"semver": "^7.3.5",
"tiny-secp256k1": "^1.1.6"
},
"scripts": {
"test": "jest --runInBand --verbose",
"test:auctions": "TEST_AUCTIONS_ENABLED=1 jest --runInBand --verbose src/auction.test.ts",
"test:nameservice-expiry": "TEST_NAMESERVICE_EXPIRY=1 jest --runInBand --verbose src/nameservice-expiry.test.ts",
"build": "tsc"
}
}
+137
View File
@@ -0,0 +1,137 @@
syntax = "proto3";
package cosmos.base.abci.v1beta1;
import "gogoproto/gogo.proto";
import "tendermint/abci/types.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/cosmos/cosmos-sdk/types";
option (gogoproto.goproto_stringer_all) = false;
// TxResponse defines a structure containing relevant tx data and metadata. The
// tags are stringified and the log is JSON decoded.
message TxResponse {
option (gogoproto.goproto_getters) = false;
// The block height
int64 height = 1;
// The transaction hash.
string txhash = 2 [(gogoproto.customname) = "TxHash"];
// Namespace for the Code
string codespace = 3;
// Response code.
uint32 code = 4;
// Result bytes, if any.
string data = 5;
// The output of the application's logger (raw string). May be
// non-deterministic.
string raw_log = 6;
// The output of the application's logger (typed). May be non-deterministic.
repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false];
// Additional information. May be non-deterministic.
string info = 8;
// Amount of gas requested for transaction.
int64 gas_wanted = 9;
// Amount of gas consumed by transaction.
int64 gas_used = 10;
// The request transaction bytes.
google.protobuf.Any tx = 11;
// Time of the previous block. For heights > 1, it's the weighted median of
// the timestamps of the valid votes in the block.LastCommit. For height == 1,
// it's genesis time.
string timestamp = 12;
}
// ABCIMessageLog defines a structure containing an indexed tx ABCI message log.
message ABCIMessageLog {
option (gogoproto.stringer) = true;
uint32 msg_index = 1;
string log = 2;
// Events contains a slice of Event objects that were emitted during some
// execution.
repeated StringEvent events = 3 [(gogoproto.castrepeated) = "StringEvents", (gogoproto.nullable) = false];
}
// StringEvent defines en Event object wrapper where all the attributes
// contain key/value pairs that are strings instead of raw bytes.
message StringEvent {
option (gogoproto.stringer) = true;
string type = 1;
repeated Attribute attributes = 2 [(gogoproto.nullable) = false];
}
// Attribute defines an attribute wrapper where the key and value are
// strings instead of raw bytes.
message Attribute {
string key = 1;
string value = 2;
}
// GasInfo defines tx execution gas context.
message GasInfo {
// GasWanted is the maximum units of work we allow this tx to perform.
uint64 gas_wanted = 1 [(gogoproto.moretags) = "yaml:\"gas_wanted\""];
// GasUsed is the amount of gas actually consumed.
uint64 gas_used = 2 [(gogoproto.moretags) = "yaml:\"gas_used\""];
}
// Result is the union of ResponseFormat and ResponseCheckTx.
message Result {
option (gogoproto.goproto_getters) = false;
// Data is any data returned from message or handler execution. It MUST be
// length prefixed in order to separate data from multiple message executions.
bytes data = 1;
// Log contains the log information from message or handler execution.
string log = 2;
// Events contains a slice of Event objects that were emitted during message
// or handler execution.
repeated tendermint.abci.Event events = 3 [(gogoproto.nullable) = false];
}
// SimulationResponse defines the response generated when a transaction is
// successfully simulated.
message SimulationResponse {
GasInfo gas_info = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
Result result = 2;
}
// MsgData defines the data returned in a Result object during message
// execution.
message MsgData {
option (gogoproto.stringer) = true;
string msg_type = 1;
bytes data = 2;
}
// TxMsgData defines a list of MsgData. A transaction will have a MsgData object
// for each message.
message TxMsgData {
option (gogoproto.stringer) = true;
repeated MsgData data = 1;
}
// SearchTxsResult defines a structure for querying txs pageable
message SearchTxsResult {
option (gogoproto.stringer) = true;
// Count of all txs
uint64 total_count = 1 [(gogoproto.moretags) = "yaml:\"total_count\"", (gogoproto.jsontag) = "total_count"];
// Count of txs in current page
uint64 count = 2;
// Index of current page, start from 1
uint64 page_number = 3 [(gogoproto.moretags) = "yaml:\"page_number\"", (gogoproto.jsontag) = "page_number"];
// Count of total pages
uint64 page_total = 4 [(gogoproto.moretags) = "yaml:\"page_total\"", (gogoproto.jsontag) = "page_total"];
// Max count txs per page
uint64 limit = 5;
// List of txs in current page
repeated TxResponse txs = 6;
}
+17
View File
@@ -0,0 +1,17 @@
syntax = "proto3";
package cosmos.base.kv.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/cosmos-sdk/types/kv";
// Pairs defines a repeated slice of Pair objects.
message Pairs {
repeated Pair pairs = 1 [(gogoproto.nullable) = false];
}
// Pair defines a key/value bytes tuple.
message Pair {
bytes key = 1;
bytes value = 2;
}
@@ -0,0 +1,53 @@
syntax = "proto3";
package cosmos.base.query.v1beta1;
option go_package = "github.com/cosmos/cosmos-sdk/types/query";
// PageRequest is to be embedded in gRPC request messages for efficient
// pagination. Ex:
//
// message SomeRequest {
// Foo some_parameter = 1;
// PageRequest pagination = 2;
// }
message PageRequest {
// key is a value returned in PageResponse.next_key to begin
// querying the next page most efficiently. Only one of offset or key
// should be set.
bytes key = 1;
// offset is a numeric offset that can be used when key is unavailable.
// It is less efficient than using key. Only one of offset or key should
// be set.
uint64 offset = 2;
// limit is the total number of results to be returned in the result page.
// If left empty it will default to a value to be set by each app.
uint64 limit = 3;
// count_total is set to true to indicate that the result set should include
// a count of the total number of items available for pagination in UIs.
// count_total is only respected when offset is used. It is ignored when key
// is set.
bool count_total = 4;
// reverse is set to true if results are to be returned in the descending order.
bool reverse = 5;
}
// PageResponse is to be embedded in gRPC response messages where the
// corresponding request message has used PageRequest.
//
// message SomeResponse {
// repeated Bar results = 1;
// PageResponse page = 2;
// }
message PageResponse {
// next_key is the key to be passed to PageRequest.key to
// query the next page most efficiently
bytes next_key = 1;
// total is total number of results available if PageRequest.count_total
// was set, its value is undefined otherwise
uint64 total = 2;
}
@@ -0,0 +1,44 @@
syntax = "proto3";
package cosmos.base.reflection.v1beta1;
import "google/api/annotations.proto";
option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/reflection";
// ReflectionService defines a service for interface reflection.
service ReflectionService {
// ListAllInterfaces lists all the interfaces registered in the interface
// registry.
rpc ListAllInterfaces(ListAllInterfacesRequest) returns (ListAllInterfacesResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces";
};
// ListImplementations list all the concrete types that implement a given
// interface.
rpc ListImplementations(ListImplementationsRequest) returns (ListImplementationsResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/"
"{interface_name}/implementations";
};
}
// ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC.
message ListAllInterfacesRequest {}
// ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC.
message ListAllInterfacesResponse {
// interface_names is an array of all the registered interfaces.
repeated string interface_names = 1;
}
// ListImplementationsRequest is the request type of the ListImplementations
// RPC.
message ListImplementationsRequest {
// interface_name defines the interface to query the implementations for.
string interface_name = 1;
}
// ListImplementationsResponse is the response type of the ListImplementations
// RPC.
message ListImplementationsResponse {
repeated string implementation_message_names = 1;
}
@@ -0,0 +1,217 @@
syntax = "proto3";
package cosmos.base.reflection.v2alpha1;
import "google/api/annotations.proto";
option go_package = "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1";
// AppDescriptor describes a cosmos-sdk based application
message AppDescriptor {
// AuthnDescriptor provides information on how to authenticate transactions on the application
// NOTE: experimental and subject to change in future releases.
AuthnDescriptor authn = 1;
// chain provides the chain descriptor
ChainDescriptor chain = 2;
// codec provides metadata information regarding codec related types
CodecDescriptor codec = 3;
// configuration provides metadata information regarding the sdk.Config type
ConfigurationDescriptor configuration = 4;
// query_services provides metadata information regarding the available queriable endpoints
QueryServicesDescriptor query_services = 5;
// tx provides metadata information regarding how to send transactions to the given application
TxDescriptor tx = 6;
}
// TxDescriptor describes the accepted transaction type
message TxDescriptor {
// fullname is the protobuf fullname of the raw transaction type (for instance the tx.Tx type)
// it is not meant to support polymorphism of transaction types, it is supposed to be used by
// reflection clients to understand if they can handle a specific transaction type in an application.
string fullname = 1;
// msgs lists the accepted application messages (sdk.Msg)
repeated MsgDescriptor msgs = 2;
}
// AuthnDescriptor provides information on how to sign transactions without relying
// on the online RPCs GetTxMetadata and CombineUnsignedTxAndSignatures
message AuthnDescriptor {
// sign_modes defines the supported signature algorithm
repeated SigningModeDescriptor sign_modes = 1;
}
// SigningModeDescriptor provides information on a signing flow of the application
// NOTE(fdymylja): here we could go as far as providing an entire flow on how
// to sign a message given a SigningModeDescriptor, but it's better to think about
// this another time
message SigningModeDescriptor {
// name defines the unique name of the signing mode
string name = 1;
// number is the unique int32 identifier for the sign_mode enum
int32 number = 2;
// authn_info_provider_method_fullname defines the fullname of the method to call to get
// the metadata required to authenticate using the provided sign_modes
string authn_info_provider_method_fullname = 3;
}
// ChainDescriptor describes chain information of the application
message ChainDescriptor {
// id is the chain id
string id = 1;
}
// CodecDescriptor describes the registered interfaces and provides metadata information on the types
message CodecDescriptor {
// interfaces is a list of the registerted interfaces descriptors
repeated InterfaceDescriptor interfaces = 1;
}
// InterfaceDescriptor describes the implementation of an interface
message InterfaceDescriptor {
// fullname is the name of the interface
string fullname = 1;
// interface_accepting_messages contains information regarding the proto messages which contain the interface as
// google.protobuf.Any field
repeated InterfaceAcceptingMessageDescriptor interface_accepting_messages = 2;
// interface_implementers is a list of the descriptors of the interface implementers
repeated InterfaceImplementerDescriptor interface_implementers = 3;
}
// InterfaceImplementerDescriptor describes an interface implementer
message InterfaceImplementerDescriptor {
// fullname is the protobuf queryable name of the interface implementer
string fullname = 1;
// type_url defines the type URL used when marshalling the type as any
// this is required so we can provide type safe google.protobuf.Any marshalling and
// unmarshalling, making sure that we don't accept just 'any' type
// in our interface fields
string type_url = 2;
}
// InterfaceAcceptingMessageDescriptor describes a protobuf message which contains
// an interface represented as a google.protobuf.Any
message InterfaceAcceptingMessageDescriptor {
// fullname is the protobuf fullname of the type containing the interface
string fullname = 1;
// field_descriptor_names is a list of the protobuf name (not fullname) of the field
// which contains the interface as google.protobuf.Any (the interface is the same, but
// it can be in multiple fields of the same proto message)
repeated string field_descriptor_names = 2;
}
// ConfigurationDescriptor contains metadata information on the sdk.Config
message ConfigurationDescriptor {
// bech32_account_address_prefix is the account address prefix
string bech32_account_address_prefix = 1;
}
// MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction
message MsgDescriptor {
// msg_type_url contains the TypeURL of a sdk.Msg.
string msg_type_url = 1;
}
// ReflectionService defines a service for application reflection.
service ReflectionService {
// GetAuthnDescriptor returns information on how to authenticate transactions in the application
// NOTE: this RPC is still experimental and might be subject to breaking changes or removal in
// future releases of the cosmos-sdk.
rpc GetAuthnDescriptor(GetAuthnDescriptorRequest) returns (GetAuthnDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/authn";
}
// GetChainDescriptor returns the description of the chain
rpc GetChainDescriptor(GetChainDescriptorRequest) returns (GetChainDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/chain";
};
// GetCodecDescriptor returns the descriptor of the codec of the application
rpc GetCodecDescriptor(GetCodecDescriptorRequest) returns (GetCodecDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/codec";
}
// GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application
rpc GetConfigurationDescriptor(GetConfigurationDescriptorRequest) returns (GetConfigurationDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/configuration";
}
// GetQueryServicesDescriptor returns the available gRPC queryable services of the application
rpc GetQueryServicesDescriptor(GetQueryServicesDescriptorRequest) returns (GetQueryServicesDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/query_services";
}
// GetTxDescriptor returns information on the used transaction object and available msgs that can be used
rpc GetTxDescriptor(GetTxDescriptorRequest) returns (GetTxDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/tx_descriptor";
}
}
// GetAuthnDescriptorRequest is the request used for the GetAuthnDescriptor RPC
message GetAuthnDescriptorRequest {}
// GetAuthnDescriptorResponse is the response returned by the GetAuthnDescriptor RPC
message GetAuthnDescriptorResponse {
// authn describes how to authenticate to the application when sending transactions
AuthnDescriptor authn = 1;
}
// GetChainDescriptorRequest is the request used for the GetChainDescriptor RPC
message GetChainDescriptorRequest {}
// GetChainDescriptorResponse is the response returned by the GetChainDescriptor RPC
message GetChainDescriptorResponse {
// chain describes application chain information
ChainDescriptor chain = 1;
}
// GetCodecDescriptorRequest is the request used for the GetCodecDescriptor RPC
message GetCodecDescriptorRequest {}
// GetCodecDescriptorResponse is the response returned by the GetCodecDescriptor RPC
message GetCodecDescriptorResponse {
// codec describes the application codec such as registered interfaces and implementations
CodecDescriptor codec = 1;
}
// GetConfigurationDescriptorRequest is the request used for the GetConfigurationDescriptor RPC
message GetConfigurationDescriptorRequest {}
// GetConfigurationDescriptorResponse is the response returned by the GetConfigurationDescriptor RPC
message GetConfigurationDescriptorResponse {
// config describes the application's sdk.Config
ConfigurationDescriptor config = 1;
}
// GetQueryServicesDescriptorRequest is the request used for the GetQueryServicesDescriptor RPC
message GetQueryServicesDescriptorRequest {}
// GetQueryServicesDescriptorResponse is the response returned by the GetQueryServicesDescriptor RPC
message GetQueryServicesDescriptorResponse {
// queries provides information on the available queryable services
QueryServicesDescriptor queries = 1;
}
// GetTxDescriptorRequest is the request used for the GetTxDescriptor RPC
message GetTxDescriptorRequest {}
// GetTxDescriptorResponse is the response returned by the GetTxDescriptor RPC
message GetTxDescriptorResponse {
// tx provides information on msgs that can be forwarded to the application
// alongside the accepted transaction protobuf type
TxDescriptor tx = 1;
}
// QueryServicesDescriptor contains the list of cosmos-sdk queriable services
message QueryServicesDescriptor {
// query_services is a list of cosmos-sdk QueryServiceDescriptor
repeated QueryServiceDescriptor query_services = 1;
}
// QueryServiceDescriptor describes a cosmos-sdk queryable service
message QueryServiceDescriptor {
// fullname is the protobuf fullname of the service descriptor
string fullname = 1;
// is_module describes if this service is actually exposed by an application's module
bool is_module = 2;
// methods provides a list of query service methods
repeated QueryMethodDescriptor methods = 3;
}
// QueryMethodDescriptor describes a queryable method of a query service
// no other info is provided beside method name and tendermint queryable path
// because it would be redundant with the grpc reflection service
message QueryMethodDescriptor {
// name is the protobuf name (not fullname) of the method
string name = 1;
// full_query_path is the path that can be used to query
// this method via tendermint abci.Query
string full_query_path = 2;
}
@@ -0,0 +1,20 @@
syntax = "proto3";
package cosmos.base.snapshots.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/cosmos-sdk/snapshots/types";
// Snapshot contains Tendermint state sync snapshot info.
message Snapshot {
uint64 height = 1;
uint32 format = 2;
uint32 chunks = 3;
bytes hash = 4;
Metadata metadata = 5 [(gogoproto.nullable) = false];
}
// Metadata contains SDK-specific snapshot metadata.
message Metadata {
repeated bytes chunk_hashes = 1; // SHA-256 chunk hashes
}
@@ -0,0 +1,29 @@
syntax = "proto3";
package cosmos.base.store.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/cosmos-sdk/store/types";
// CommitInfo defines commit information used by the multi-store when committing
// a version/height.
message CommitInfo {
int64 version = 1;
repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false];
}
// StoreInfo defines store-specific commit information. It contains a reference
// between a store name and the commit ID.
message StoreInfo {
string name = 1;
CommitID commit_id = 2 [(gogoproto.nullable) = false];
}
// CommitID defines the committment information when a specific store is
// committed.
message CommitID {
option (gogoproto.goproto_stringer) = false;
int64 version = 1;
bytes hash = 2;
}
@@ -0,0 +1,14 @@
syntax = "proto3";
package cosmos.base.store.v1beta1;
option go_package = "github.com/cosmos/cosmos-sdk/store/types";
// StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes)
// It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and
// Deletes
message StoreKVPair {
string store_key = 1; // the store key for the KVStore this pair originates from
bool delete = 2; // true indicates a delete operation, false indicates a set operation
bytes key = 3;
bytes value = 4;
}
@@ -0,0 +1,28 @@
syntax = "proto3";
package cosmos.base.store.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/cosmos-sdk/store/types";
// SnapshotItem is an item contained in a rootmulti.Store snapshot.
message SnapshotItem {
// item is the specific type of snapshot item.
oneof item {
SnapshotStoreItem store = 1;
SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"];
}
}
// SnapshotStoreItem contains metadata about a snapshotted store.
message SnapshotStoreItem {
string name = 1;
}
// SnapshotIAVLItem is an exported IAVL node.
message SnapshotIAVLItem {
bytes key = 1;
bytes value = 2;
int64 version = 3;
int32 height = 4;
}
@@ -0,0 +1,136 @@
syntax = "proto3";
package cosmos.base.tendermint.v1beta1;
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "tendermint/p2p/types.proto";
import "tendermint/types/block.proto";
import "tendermint/types/types.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/tmservice";
// Service defines the gRPC querier service for tendermint queries.
service Service {
// GetNodeInfo queries the current node info.
rpc GetNodeInfo(GetNodeInfoRequest) returns (GetNodeInfoResponse) {
option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/node_info";
}
// GetSyncing queries node syncing.
rpc GetSyncing(GetSyncingRequest) returns (GetSyncingResponse) {
option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/syncing";
}
// GetLatestBlock returns the latest block.
rpc GetLatestBlock(GetLatestBlockRequest) returns (GetLatestBlockResponse) {
option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/latest";
}
// GetBlockByHeight queries block for given height.
rpc GetBlockByHeight(GetBlockByHeightRequest) returns (GetBlockByHeightResponse) {
option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/{height}";
}
// GetLatestValidatorSet queries latest validator-set.
rpc GetLatestValidatorSet(GetLatestValidatorSetRequest) returns (GetLatestValidatorSetResponse) {
option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/latest";
}
// GetValidatorSetByHeight queries validator-set at a given height.
rpc GetValidatorSetByHeight(GetValidatorSetByHeightRequest) returns (GetValidatorSetByHeightResponse) {
option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/{height}";
}
}
// GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method.
message GetValidatorSetByHeightRequest {
int64 height = 1;
// pagination defines an pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method.
message GetValidatorSetByHeightResponse {
int64 block_height = 1;
repeated Validator validators = 2;
// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 3;
}
// GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method.
message GetLatestValidatorSetRequest {
// pagination defines an pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method.
message GetLatestValidatorSetResponse {
int64 block_height = 1;
repeated Validator validators = 2;
// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 3;
}
// Validator is the type for the validator-set.
message Validator {
string address = 1;
google.protobuf.Any pub_key = 2;
int64 voting_power = 3;
int64 proposer_priority = 4;
}
// GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method.
message GetBlockByHeightRequest {
int64 height = 1;
}
// GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method.
message GetBlockByHeightResponse {
.tendermint.types.BlockID block_id = 1;
.tendermint.types.Block block = 2;
}
// GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method.
message GetLatestBlockRequest {}
// GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method.
message GetLatestBlockResponse {
.tendermint.types.BlockID block_id = 1;
.tendermint.types.Block block = 2;
}
// GetSyncingRequest is the request type for the Query/GetSyncing RPC method.
message GetSyncingRequest {}
// GetSyncingResponse is the response type for the Query/GetSyncing RPC method.
message GetSyncingResponse {
bool syncing = 1;
}
// GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method.
message GetNodeInfoRequest {}
// GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method.
message GetNodeInfoResponse {
.tendermint.p2p.DefaultNodeInfo default_node_info = 1;
VersionInfo application_version = 2;
}
// VersionInfo is the type for the GetNodeInfoResponse message.
message VersionInfo {
string name = 1;
string app_name = 2;
string version = 3;
string git_commit = 4;
string build_tags = 5;
string go_version = 6;
repeated Module build_deps = 7;
string cosmos_sdk_version = 8;
}
// Module is the type for VersionInfo
message Module {
// module path
string path = 1;
// module version
string version = 2;
// checksum
string sum = 3;
}
+40
View File
@@ -0,0 +1,40 @@
syntax = "proto3";
package cosmos.base.v1beta1;
import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/cosmos-sdk/types";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = false;
// Coin defines a token with a denomination and an amount.
//
// NOTE: The amount field is an Int which implements the custom method
// signatures required by gogoproto.
message Coin {
option (gogoproto.equal) = true;
string denom = 1;
string amount = 2 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false];
}
// DecCoin defines a token with a denomination and a decimal amount.
//
// NOTE: The amount field is an Dec which implements the custom method
// signatures required by gogoproto.
message DecCoin {
option (gogoproto.equal) = true;
string denom = 1;
string amount = 2 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false];
}
// IntProto defines a Protobuf wrapper around an Int object.
message IntProto {
string int = 1 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false];
}
// DecProto defines a Protobuf wrapper around a Dec object.
message DecProto {
string dec = 1 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false];
}
+145
View File
@@ -0,0 +1,145 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package gogoproto;
import "google/protobuf/descriptor.proto";
option java_package = "com.google.protobuf";
option java_outer_classname = "GoGoProtos";
option go_package = "github.com/gogo/protobuf/gogoproto";
extend google.protobuf.EnumOptions {
optional bool goproto_enum_prefix = 62001;
optional bool goproto_enum_stringer = 62021;
optional bool enum_stringer = 62022;
optional string enum_customname = 62023;
optional bool enumdecl = 62024;
}
extend google.protobuf.EnumValueOptions {
optional string enumvalue_customname = 66001;
}
extend google.protobuf.FileOptions {
optional bool goproto_getters_all = 63001;
optional bool goproto_enum_prefix_all = 63002;
optional bool goproto_stringer_all = 63003;
optional bool verbose_equal_all = 63004;
optional bool face_all = 63005;
optional bool gostring_all = 63006;
optional bool populate_all = 63007;
optional bool stringer_all = 63008;
optional bool onlyone_all = 63009;
optional bool equal_all = 63013;
optional bool description_all = 63014;
optional bool testgen_all = 63015;
optional bool benchgen_all = 63016;
optional bool marshaler_all = 63017;
optional bool unmarshaler_all = 63018;
optional bool stable_marshaler_all = 63019;
optional bool sizer_all = 63020;
optional bool goproto_enum_stringer_all = 63021;
optional bool enum_stringer_all = 63022;
optional bool unsafe_marshaler_all = 63023;
optional bool unsafe_unmarshaler_all = 63024;
optional bool goproto_extensions_map_all = 63025;
optional bool goproto_unrecognized_all = 63026;
optional bool gogoproto_import = 63027;
optional bool protosizer_all = 63028;
optional bool compare_all = 63029;
optional bool typedecl_all = 63030;
optional bool enumdecl_all = 63031;
optional bool goproto_registration = 63032;
optional bool messagename_all = 63033;
optional bool goproto_sizecache_all = 63034;
optional bool goproto_unkeyed_all = 63035;
}
extend google.protobuf.MessageOptions {
optional bool goproto_getters = 64001;
optional bool goproto_stringer = 64003;
optional bool verbose_equal = 64004;
optional bool face = 64005;
optional bool gostring = 64006;
optional bool populate = 64007;
optional bool stringer = 67008;
optional bool onlyone = 64009;
optional bool equal = 64013;
optional bool description = 64014;
optional bool testgen = 64015;
optional bool benchgen = 64016;
optional bool marshaler = 64017;
optional bool unmarshaler = 64018;
optional bool stable_marshaler = 64019;
optional bool sizer = 64020;
optional bool unsafe_marshaler = 64023;
optional bool unsafe_unmarshaler = 64024;
optional bool goproto_extensions_map = 64025;
optional bool goproto_unrecognized = 64026;
optional bool protosizer = 64028;
optional bool compare = 64029;
optional bool typedecl = 64030;
optional bool messagename = 64033;
optional bool goproto_sizecache = 64034;
optional bool goproto_unkeyed = 64035;
}
extend google.protobuf.FieldOptions {
optional bool nullable = 65001;
optional bool embed = 65002;
optional string customtype = 65003;
optional string customname = 65004;
optional string jsontag = 65005;
optional string moretags = 65006;
optional string casttype = 65007;
optional string castkey = 65008;
optional string castvalue = 65009;
optional bool stdtime = 65010;
optional bool stdduration = 65011;
optional bool wktpointer = 65012;
optional string castrepeated = 65013;
}
+31
View File
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
+325
View File
@@ -0,0 +1,325 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
// Defines the HTTP configuration for an API service. It contains a list of
// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
// to one or more HTTP REST API methods.
message Http {
// A list of HTTP configuration rules that apply to individual API methods.
//
// **NOTE:** All service configuration rules follow "last one wins" order.
repeated HttpRule rules = 1;
// When set to true, URL path parmeters will be fully URI-decoded except in
// cases of single segment matches in reserved expansion, where "%2F" will be
// left encoded.
//
// The default behavior is to not decode RFC 6570 reserved characters in multi
// segment matches.
bool fully_decode_reserved_expansion = 2;
}
// `HttpRule` defines the mapping of an RPC method to one or more HTTP
// REST API methods. The mapping specifies how different portions of the RPC
// request message are mapped to URL path, URL query parameters, and
// HTTP request body. The mapping is typically specified as an
// `google.api.http` annotation on the RPC method,
// see "google/api/annotations.proto" for details.
//
// The mapping consists of a field specifying the path template and
// method kind. The path template can refer to fields in the request
// message, as in the example below which describes a REST GET
// operation on a resource collection of messages:
//
//
// service Messaging {
// rpc GetMessage(GetMessageRequest) returns (Message) {
// option (google.api.http).get =
// "/v1/messages/{message_id}/{sub.subfield}";
// }
// }
// message GetMessageRequest {
// message SubMessage {
// string subfield = 1;
// }
// string message_id = 1; // mapped to the URL
// SubMessage sub = 2; // `sub.subfield` is url-mapped
// }
// message Message {
// string text = 1; // content of the resource
// }
//
// The same http annotation can alternatively be expressed inside the
// `GRPC API Configuration` YAML file.
//
// http:
// rules:
// - selector: <proto_package_name>.Messaging.GetMessage
// get: /v1/messages/{message_id}/{sub.subfield}
//
// This definition enables an automatic, bidrectional mapping of HTTP
// JSON to RPC. Example:
//
// HTTP | RPC
// -----|-----
// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub:
// SubMessage(subfield: "foo"))`
//
// In general, not only fields but also field paths can be referenced
// from a path pattern. Fields mapped to the path pattern cannot be
// repeated and must have a primitive (non-message) type.
//
// Any fields in the request message which are not bound by the path
// pattern automatically become (optional) HTTP query
// parameters. Assume the following definition of the request message:
//
//
// service Messaging {
// rpc GetMessage(GetMessageRequest) returns (Message) {
// option (google.api.http).get = "/v1/messages/{message_id}";
// }
// }
// message GetMessageRequest {
// message SubMessage {
// string subfield = 1;
// }
// string message_id = 1; // mapped to the URL
// int64 revision = 2; // becomes a parameter
// SubMessage sub = 3; // `sub.subfield` becomes a parameter
// }
//
//
// This enables a HTTP JSON to RPC mapping as below:
//
// HTTP | RPC
// -----|-----
// `GET /v1/messages/123456?revision=2&sub.subfield=foo` |
// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield:
// "foo"))`
//
// Note that fields which are mapped to HTTP parameters must have a
// primitive type or a repeated primitive type. Message types are not
// allowed. In the case of a repeated type, the parameter can be
// repeated in the URL, as in `...?param=A&param=B`.
//
// For HTTP method kinds which allow a request body, the `body` field
// specifies the mapping. Consider a REST update method on the
// message resource collection:
//
//
// service Messaging {
// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
// option (google.api.http) = {
// put: "/v1/messages/{message_id}"
// body: "message"
// };
// }
// }
// message UpdateMessageRequest {
// string message_id = 1; // mapped to the URL
// Message message = 2; // mapped to the body
// }
//
//
// The following HTTP JSON to RPC mapping is enabled, where the
// representation of the JSON in the request body is determined by
// protos JSON encoding:
//
// HTTP | RPC
// -----|-----
// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
// "123456" message { text: "Hi!" })`
//
// The special name `*` can be used in the body mapping to define that
// every field not bound by the path template should be mapped to the
// request body. This enables the following alternative definition of
// the update method:
//
// service Messaging {
// rpc UpdateMessage(Message) returns (Message) {
// option (google.api.http) = {
// put: "/v1/messages/{message_id}"
// body: "*"
// };
// }
// }
// message Message {
// string message_id = 1;
// string text = 2;
// }
//
//
// The following HTTP JSON to RPC mapping is enabled:
//
// HTTP | RPC
// -----|-----
// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id:
// "123456" text: "Hi!")`
//
// Note that when using `*` in the body mapping, it is not possible to
// have HTTP parameters, as all fields not bound by the path end in
// the body. This makes this option more rarely used in practice of
// defining REST APIs. The common usage of `*` is in custom methods
// which don't use the URL at all for transferring data.
//
// It is possible to define multiple HTTP methods for one RPC by using
// the `additional_bindings` option. Example:
//
// service Messaging {
// rpc GetMessage(GetMessageRequest) returns (Message) {
// option (google.api.http) = {
// get: "/v1/messages/{message_id}"
// additional_bindings {
// get: "/v1/users/{user_id}/messages/{message_id}"
// }
// };
// }
// }
// message GetMessageRequest {
// string message_id = 1;
// string user_id = 2;
// }
//
//
// This enables the following two alternative HTTP JSON to RPC
// mappings:
//
// HTTP | RPC
// -----|-----
// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id:
// "123456")`
//
// # Rules for HTTP mapping
//
// The rules for mapping HTTP path, query parameters, and body fields
// to the request message are as follows:
//
// 1. The `body` field specifies either `*` or a field path, or is
// omitted. If omitted, it indicates there is no HTTP request body.
// 2. Leaf fields (recursive expansion of nested messages in the
// request) can be classified into three types:
// (a) Matched in the URL template.
// (b) Covered by body (if body is `*`, everything except (a) fields;
// else everything under the body field)
// (c) All other fields.
// 3. URL query parameters found in the HTTP request are mapped to (c) fields.
// 4. Any body sent with an HTTP request can contain only (b) fields.
//
// The syntax of the path template is as follows:
//
// Template = "/" Segments [ Verb ] ;
// Segments = Segment { "/" Segment } ;
// Segment = "*" | "**" | LITERAL | Variable ;
// Variable = "{" FieldPath [ "=" Segments ] "}" ;
// FieldPath = IDENT { "." IDENT } ;
// Verb = ":" LITERAL ;
//
// The syntax `*` matches a single path segment. The syntax `**` matches zero
// or more path segments, which must be the last part of the path except the
// `Verb`. The syntax `LITERAL` matches literal text in the path.
//
// The syntax `Variable` matches part of the URL path as specified by its
// template. A variable template must not contain other variables. If a variable
// matches a single path segment, its template may be omitted, e.g. `{var}`
// is equivalent to `{var=*}`.
//
// If a variable contains exactly one path segment, such as `"{var}"` or
// `"{var=*}"`, when such a variable is expanded into a URL path, all characters
// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the
// Discovery Document as `{var}`.
//
// If a variable contains one or more path segments, such as `"{var=foo/*}"`
// or `"{var=**}"`, when such a variable is expanded into a URL path, all
// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables
// show up in the Discovery Document as `{+var}`.
//
// NOTE: While the single segment variable matches the semantics of
// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2
// Simple String Expansion, the multi segment variable **does not** match
// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion
// does not expand special characters like `?` and `#`, which would lead
// to invalid URLs.
//
// NOTE: the field paths in variables and in the `body` must not refer to
// repeated fields or map fields.
message HttpRule {
// Selects methods to which this rule applies.
//
// Refer to [selector][google.api.DocumentationRule.selector] for syntax
// details.
string selector = 1;
// Determines the URL pattern is matched by this rules. This pattern can be
// used with any of the {get|put|post|delete|patch} methods. A custom method
// can be defined using the 'custom' field.
oneof pattern {
// Used for listing and getting information about resources.
string get = 2;
// Used for updating a resource.
string put = 3;
// Used for creating a resource.
string post = 4;
// Used for deleting a resource.
string delete = 5;
// Used for updating a resource.
string patch = 6;
// The custom pattern is used for specifying an HTTP method that is not
// included in the `pattern` field, such as HEAD, or "*" to leave the
// HTTP method unspecified for this rule. The wild-card rule is useful
// for services that provide content to Web (HTML) clients.
CustomHttpPattern custom = 8;
}
// The name of the request field whose value is mapped to the HTTP body, or
// `*` for mapping all fields not captured by the path pattern to the HTTP
// body. NOTE: the referred field must not be a repeated field and must be
// present at the top-level of request message type.
string body = 7;
// Optional. The name of the response field whose value is mapped to the HTTP
// body of response. Other response fields are ignored. When
// not set, the response message will be used as HTTP body of response.
string response_body = 12;
// Additional HTTP bindings for the selector. Nested bindings must
// not contain an `additional_bindings` field themselves (that is,
// the nesting may only be one level deep).
repeated HttpRule additional_bindings = 11;
}
// A custom pattern is used for defining custom HTTP verb.
message CustomHttpPattern {
// The name of this custom HTTP verb.
string kind = 1;
// The path matched by this custom verb.
string path = 2;
}
+78
View File
@@ -0,0 +1,78 @@
// Copyright 2018 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
syntax = "proto3";
package google.api;
import "google/protobuf/any.proto";
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody";
option java_multiple_files = true;
option java_outer_classname = "HttpBodyProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
// Message that represents an arbitrary HTTP body. It should only be used for
// payload formats that can't be represented as JSON, such as raw binary or
// an HTML page.
//
//
// This message can be used both in streaming and non-streaming API methods in
// the request as well as the response.
//
// It can be used as a top-level request field, which is convenient if one
// wants to extract parameters from either the URL or HTTP template into the
// request fields and also want access to the raw HTTP body.
//
// Example:
//
// message GetResourceRequest {
// // A unique request id.
// string request_id = 1;
//
// // The raw HTTP body is bound to this field.
// google.api.HttpBody http_body = 2;
// }
//
// service ResourceService {
// rpc GetResource(GetResourceRequest) returns (google.api.HttpBody);
// rpc UpdateResource(google.api.HttpBody) returns
// (google.protobuf.Empty);
// }
//
// Example with streaming methods:
//
// service CaldavService {
// rpc GetCalendar(stream google.api.HttpBody)
// returns (stream google.api.HttpBody);
// rpc UpdateCalendar(stream google.api.HttpBody)
// returns (stream google.api.HttpBody);
// }
//
// Use of this type only changes how the request and response bodies are
// handled, all other features will continue to work unchanged.
message HttpBody {
// The HTTP Content-Type header value specifying the content type of the body.
string content_type = 1;
// The HTTP request/response body as raw binary.
bytes data = 2;
// Application specific response metadata. Must be set in the first response
// for streaming APIs.
repeated google.protobuf.Any extensions = 3;
}
+161
View File
@@ -0,0 +1,161 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto3";
package google.protobuf;
import "gogoproto/gogo.proto";
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "types";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
option objc_class_prefix = "GPB";
// `Any` contains an arbitrary serialized protocol buffer message along with a
// URL that describes the type of the serialized message.
//
// Protobuf library provides support to pack/unpack Any values in the form
// of utility functions or additional generated methods of the Any type.
//
// Example 1: Pack and unpack a message in C++.
//
// Foo foo = ...;
// Any any;
// any.PackFrom(foo);
// ...
// if (any.UnpackTo(&foo)) {
// ...
// }
//
// Example 2: Pack and unpack a message in Java.
//
// Foo foo = ...;
// Any any = Any.pack(foo);
// ...
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
//
// Example 3: Pack and unpack a message in Python.
//
// foo = Foo(...)
// any = Any()
// any.Pack(foo)
// ...
// if any.Is(Foo.DESCRIPTOR):
// any.Unpack(foo)
// ...
//
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/'
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
// name "y.z".
//
//
// JSON
// ====
// The JSON representation of an `Any` value uses the regular
// representation of the deserialized, embedded message, with an
// additional field `@type` which contains the type URL. Example:
//
// package google.profile;
// message Person {
// string first_name = 1;
// string last_name = 2;
// }
//
// {
// "@type": "type.googleapis.com/google.profile.Person",
// "firstName": <string>,
// "lastName": <string>
// }
//
// If the embedded message type is well-known and has a custom JSON
// representation, that representation will be embedded adding a field
// `value` which holds the custom JSON in addition to the `@type`
// field. Example (for message [google.protobuf.Duration][]):
//
// {
// "@type": "type.googleapis.com/google.protobuf.Duration",
// "value": "1.212s"
// }
//
message Any {
// A URL/resource name that uniquely identifies the type of the serialized
// protocol buffer message. This string must contain at least
// one "/" character. The last segment of the URL's path must represent
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
//
// In practice, teams usually precompile into the binary all types that they
// expect it to use in the context of Any. However, for URLs which use the
// scheme `http`, `https`, or no scheme, one can optionally set up a type
// server that maps type URLs to message definitions as follows:
//
// * If no scheme is provided, `https` is assumed.
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
// value in binary format, or produce an error.
// * Applications are allowed to cache lookup results based on the
// URL, or have them precompiled into a binary to avoid any
// lookup. Therefore, binary compatibility needs to be preserved
// on changes to types. (Use versioned type names to manage
// breaking changes.)
//
// Note: this functionality is not currently available in the official
// protobuf release, and it is not used for type URLs beginning with
// type.googleapis.com.
//
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
//
string type_url = 1;
// Must be a valid serialized protocol buffer of the above specified type.
bytes value = 2;
option (gogoproto.typedecl) = false;
}
option (gogoproto.goproto_registration) = false;
+895
View File
@@ -0,0 +1,895 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// The messages in this file describe the definitions found in .proto files.
// A valid .proto file can be translated directly to a FileDescriptorProto
// without any other information (e.g. without reading its imports).
syntax = "proto2";
package google.protobuf;
option go_package = "google.golang.org/protobuf/types/descriptorpb";
option java_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.Protobuf.Reflection";
option objc_class_prefix = "GPB";
option cc_enable_arenas = true;
// descriptor.proto must be optimized for speed because reflection-based
// algorithms don't work during bootstrapping.
option optimize_for = SPEED;
// The protocol compiler can output a FileDescriptorSet containing the .proto
// files it parses.
message FileDescriptorSet {
repeated FileDescriptorProto file = 1;
}
// Describes a complete .proto file.
message FileDescriptorProto {
optional string name = 1; // file name, relative to root of source tree
optional string package = 2; // e.g. "foo", "foo.bar", etc.
// Names of files imported by this file.
repeated string dependency = 3;
// Indexes of the public imported files in the dependency list above.
repeated int32 public_dependency = 10;
// Indexes of the weak imported files in the dependency list.
// For Google-internal migration only. Do not use.
repeated int32 weak_dependency = 11;
// All top-level definitions in this file.
repeated DescriptorProto message_type = 4;
repeated EnumDescriptorProto enum_type = 5;
repeated ServiceDescriptorProto service = 6;
repeated FieldDescriptorProto extension = 7;
optional FileOptions options = 8;
// This field contains optional information about the original source code.
// You may safely remove this entire field without harming runtime
// functionality of the descriptors -- the information is needed only by
// development tools.
optional SourceCodeInfo source_code_info = 9;
// The syntax of the proto file.
// The supported values are "proto2" and "proto3".
optional string syntax = 12;
}
// Describes a message type.
message DescriptorProto {
optional string name = 1;
repeated FieldDescriptorProto field = 2;
repeated FieldDescriptorProto extension = 6;
repeated DescriptorProto nested_type = 3;
repeated EnumDescriptorProto enum_type = 4;
message ExtensionRange {
optional int32 start = 1; // Inclusive.
optional int32 end = 2; // Exclusive.
optional ExtensionRangeOptions options = 3;
}
repeated ExtensionRange extension_range = 5;
repeated OneofDescriptorProto oneof_decl = 8;
optional MessageOptions options = 7;
// Range of reserved tag numbers. Reserved tag numbers may not be used by
// fields or extension ranges in the same message. Reserved ranges may
// not overlap.
message ReservedRange {
optional int32 start = 1; // Inclusive.
optional int32 end = 2; // Exclusive.
}
repeated ReservedRange reserved_range = 9;
// Reserved field names, which may not be used by fields in the same message.
// A given name may only be reserved once.
repeated string reserved_name = 10;
}
message ExtensionRangeOptions {
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
// Describes a field within a message.
message FieldDescriptorProto {
enum Type {
// 0 is reserved for errors.
// Order is weird for historical reasons.
TYPE_DOUBLE = 1;
TYPE_FLOAT = 2;
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
// negative values are likely.
TYPE_INT64 = 3;
TYPE_UINT64 = 4;
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
// negative values are likely.
TYPE_INT32 = 5;
TYPE_FIXED64 = 6;
TYPE_FIXED32 = 7;
TYPE_BOOL = 8;
TYPE_STRING = 9;
// Tag-delimited aggregate.
// Group type is deprecated and not supported in proto3. However, Proto3
// implementations should still be able to parse the group wire format and
// treat group fields as unknown fields.
TYPE_GROUP = 10;
TYPE_MESSAGE = 11; // Length-delimited aggregate.
// New in version 2.
TYPE_BYTES = 12;
TYPE_UINT32 = 13;
TYPE_ENUM = 14;
TYPE_SFIXED32 = 15;
TYPE_SFIXED64 = 16;
TYPE_SINT32 = 17; // Uses ZigZag encoding.
TYPE_SINT64 = 18; // Uses ZigZag encoding.
}
enum Label {
// 0 is reserved for errors
LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2;
LABEL_REPEATED = 3;
}
optional string name = 1;
optional int32 number = 3;
optional Label label = 4;
// If type_name is set, this need not be set. If both this and type_name
// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
optional Type type = 5;
// For message and enum types, this is the name of the type. If the name
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
// rules are used to find the type (i.e. first the nested types within this
// message are searched, then within the parent, on up to the root
// namespace).
optional string type_name = 6;
// For extensions, this is the name of the type being extended. It is
// resolved in the same manner as type_name.
optional string extendee = 2;
// For numeric types, contains the original text representation of the value.
// For booleans, "true" or "false".
// For strings, contains the default text contents (not escaped in any way).
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
// TODO(kenton): Base-64 encode?
optional string default_value = 7;
// If set, gives the index of a oneof in the containing type's oneof_decl
// list. This field is a member of that oneof.
optional int32 oneof_index = 9;
// JSON name of this field. The value is set by protocol compiler. If the
// user has set a "json_name" option on this field, that option's value
// will be used. Otherwise, it's deduced from the field's name by converting
// it to camelCase.
optional string json_name = 10;
optional FieldOptions options = 8;
// If true, this is a proto3 "optional". When a proto3 field is optional, it
// tracks presence regardless of field type.
//
// When proto3_optional is true, this field must be belong to a oneof to
// signal to old proto3 clients that presence is tracked for this field. This
// oneof is known as a "synthetic" oneof, and this field must be its sole
// member (each proto3 optional field gets its own synthetic oneof). Synthetic
// oneofs exist in the descriptor only, and do not generate any API. Synthetic
// oneofs must be ordered after all "real" oneofs.
//
// For message fields, proto3_optional doesn't create any semantic change,
// since non-repeated message fields always track presence. However it still
// indicates the semantic detail of whether the user wrote "optional" or not.
// This can be useful for round-tripping the .proto file. For consistency we
// give message fields a synthetic oneof also, even though it is not required
// to track presence. This is especially important because the parser can't
// tell if a field is a message or an enum, so it must always create a
// synthetic oneof.
//
// Proto2 optional fields do not set this flag, because they already indicate
// optional with `LABEL_OPTIONAL`.
optional bool proto3_optional = 17;
}
// Describes a oneof.
message OneofDescriptorProto {
optional string name = 1;
optional OneofOptions options = 2;
}
// Describes an enum type.
message EnumDescriptorProto {
optional string name = 1;
repeated EnumValueDescriptorProto value = 2;
optional EnumOptions options = 3;
// Range of reserved numeric values. Reserved values may not be used by
// entries in the same enum. Reserved ranges may not overlap.
//
// Note that this is distinct from DescriptorProto.ReservedRange in that it
// is inclusive such that it can appropriately represent the entire int32
// domain.
message EnumReservedRange {
optional int32 start = 1; // Inclusive.
optional int32 end = 2; // Inclusive.
}
// Range of reserved numeric values. Reserved numeric values may not be used
// by enum values in the same enum declaration. Reserved ranges may not
// overlap.
repeated EnumReservedRange reserved_range = 4;
// Reserved enum value names, which may not be reused. A given name may only
// be reserved once.
repeated string reserved_name = 5;
}
// Describes a value within an enum.
message EnumValueDescriptorProto {
optional string name = 1;
optional int32 number = 2;
optional EnumValueOptions options = 3;
}
// Describes a service.
message ServiceDescriptorProto {
optional string name = 1;
repeated MethodDescriptorProto method = 2;
optional ServiceOptions options = 3;
}
// Describes a method of a service.
message MethodDescriptorProto {
optional string name = 1;
// Input and output type names. These are resolved in the same way as
// FieldDescriptorProto.type_name, but must refer to a message type.
optional string input_type = 2;
optional string output_type = 3;
optional MethodOptions options = 4;
// Identifies if client streams multiple client messages
optional bool client_streaming = 5 [default = false];
// Identifies if server streams multiple server messages
optional bool server_streaming = 6 [default = false];
}
// ===================================================================
// Options
// Each of the definitions above may have "options" attached. These are
// just annotations which may cause code to be generated slightly differently
// or may contain hints for code that manipulates protocol messages.
//
// Clients may define custom options as extensions of the *Options messages.
// These extensions may not yet be known at parsing time, so the parser cannot
// store the values in them. Instead it stores them in a field in the *Options
// message called uninterpreted_option. This field must have the same name
// across all *Options messages. We then use this field to populate the
// extensions when we build a descriptor, at which point all protos have been
// parsed and so all extensions are known.
//
// Extension numbers for custom options may be chosen as follows:
// * For options which will only be used within a single application or
// organization, or for experimental options, use field numbers 50000
// through 99999. It is up to you to ensure that you do not use the
// same number for multiple options.
// * For options which will be published and used publicly by multiple
// independent entities, e-mail protobuf-global-extension-registry@google.com
// to reserve extension numbers. Simply provide your project name (e.g.
// Objective-C plugin) and your project website (if available) -- there's no
// need to explain how you intend to use them. Usually you only need one
// extension number. You can declare multiple options with only one extension
// number by putting them in a sub-message. See the Custom Options section of
// the docs for examples:
// https://developers.google.com/protocol-buffers/docs/proto#options
// If this turns out to be popular, a web service will be set up
// to automatically assign option numbers.
message FileOptions {
// Sets the Java package where classes generated from this .proto will be
// placed. By default, the proto package is used, but this is often
// inappropriate because proto packages do not normally start with backwards
// domain names.
optional string java_package = 1;
// If set, all the classes from the .proto file are wrapped in a single
// outer class with the given name. This applies to both Proto1
// (equivalent to the old "--one_java_file" option) and Proto2 (where
// a .proto always translates to a single class, but you may want to
// explicitly choose the class name).
optional string java_outer_classname = 8;
// If set true, then the Java code generator will generate a separate .java
// file for each top-level message, enum, and service defined in the .proto
// file. Thus, these types will *not* be nested inside the outer class
// named by java_outer_classname. However, the outer class will still be
// generated to contain the file's getDescriptor() method as well as any
// top-level extensions defined in the file.
optional bool java_multiple_files = 10 [default = false];
// This option does nothing.
optional bool java_generate_equals_and_hash = 20 [deprecated = true];
// If set true, then the Java2 code generator will generate code that
// throws an exception whenever an attempt is made to assign a non-UTF-8
// byte sequence to a string field.
// Message reflection will do the same.
// However, an extension field still accepts non-UTF-8 byte sequences.
// This option has no effect on when used with the lite runtime.
optional bool java_string_check_utf8 = 27 [default = false];
// Generated classes can be optimized for speed or code size.
enum OptimizeMode {
SPEED = 1; // Generate complete code for parsing, serialization,
// etc.
CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
}
optional OptimizeMode optimize_for = 9 [default = SPEED];
// Sets the Go package where structs generated from this .proto will be
// placed. If omitted, the Go package will be derived from the following:
// - The basename of the package import path, if provided.
// - Otherwise, the package statement in the .proto file, if present.
// - Otherwise, the basename of the .proto file, without extension.
optional string go_package = 11;
// Should generic services be generated in each language? "Generic" services
// are not specific to any particular RPC system. They are generated by the
// main code generators in each language (without additional plugins).
// Generic services were the only kind of service generation supported by
// early versions of google.protobuf.
//
// Generic services are now considered deprecated in favor of using plugins
// that generate code specific to your particular RPC system. Therefore,
// these default to false. Old code which depends on generic services should
// explicitly set them to true.
optional bool cc_generic_services = 16 [default = false];
optional bool java_generic_services = 17 [default = false];
optional bool py_generic_services = 18 [default = false];
optional bool php_generic_services = 42 [default = false];
// Is this file deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for everything in the file, or it will be completely ignored; in the very
// least, this is a formalization for deprecating files.
optional bool deprecated = 23 [default = false];
// Enables the use of arenas for the proto messages in this file. This applies
// only to generated classes for C++.
optional bool cc_enable_arenas = 31 [default = true];
// Sets the objective c class prefix which is prepended to all objective c
// generated classes from this .proto. There is no default.
optional string objc_class_prefix = 36;
// Namespace for generated classes; defaults to the package.
optional string csharp_namespace = 37;
// By default Swift generators will take the proto package and CamelCase it
// replacing '.' with underscore and use that to prefix the types/symbols
// defined. When this options is provided, they will use this value instead
// to prefix the types/symbols defined.
optional string swift_prefix = 39;
// Sets the php class prefix which is prepended to all php generated classes
// from this .proto. Default is empty.
optional string php_class_prefix = 40;
// Use this option to change the namespace of php generated classes. Default
// is empty. When this option is empty, the package name will be used for
// determining the namespace.
optional string php_namespace = 41;
// Use this option to change the namespace of php generated metadata classes.
// Default is empty. When this option is empty, the proto file name will be
// used for determining the namespace.
optional string php_metadata_namespace = 44;
// Use this option to change the package of ruby generated classes. Default
// is empty. When this option is not set, the package name will be used for
// determining the ruby package.
optional string ruby_package = 45;
// The parser stores options it doesn't recognize here.
// See the documentation for the "Options" section above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message.
// See the documentation for the "Options" section above.
extensions 1000 to max;
reserved 38;
}
message MessageOptions {
// Set true to use the old proto1 MessageSet wire format for extensions.
// This is provided for backwards-compatibility with the MessageSet wire
// format. You should not use this for any other reason: It's less
// efficient, has fewer features, and is more complicated.
//
// The message must be defined exactly as follows:
// message Foo {
// option message_set_wire_format = true;
// extensions 4 to max;
// }
// Note that the message cannot have any defined fields; MessageSets only
// have extensions.
//
// All extensions of your type must be singular messages; e.g. they cannot
// be int32s, enums, or repeated messages.
//
// Because this is an option, the above two restrictions are not enforced by
// the protocol compiler.
optional bool message_set_wire_format = 1 [default = false];
// Disables the generation of the standard "descriptor()" accessor, which can
// conflict with a field of the same name. This is meant to make migration
// from proto1 easier; new code should avoid fields named "descriptor".
optional bool no_standard_descriptor_accessor = 2 [default = false];
// Is this message deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the message, or it will be completely ignored; in the very least,
// this is a formalization for deprecating messages.
optional bool deprecated = 3 [default = false];
// Whether the message is an automatically generated map entry type for the
// maps field.
//
// For maps fields:
// map<KeyType, ValueType> map_field = 1;
// The parsed descriptor looks like:
// message MapFieldEntry {
// option map_entry = true;
// optional KeyType key = 1;
// optional ValueType value = 2;
// }
// repeated MapFieldEntry map_field = 1;
//
// Implementations may choose not to generate the map_entry=true message, but
// use a native map in the target language to hold the keys and values.
// The reflection APIs in such implementations still need to work as
// if the field is a repeated message field.
//
// NOTE: Do not set the option in .proto files. Always use the maps syntax
// instead. The option should only be implicitly set by the proto compiler
// parser.
optional bool map_entry = 7;
reserved 8; // javalite_serializable
reserved 9; // javanano_as_lite
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message FieldOptions {
// The ctype option instructs the C++ code generator to use a different
// representation of the field than it normally would. See the specific
// options below. This option is not yet implemented in the open source
// release -- sorry, we'll try to include it in a future version!
optional CType ctype = 1 [default = STRING];
enum CType {
// Default mode.
STRING = 0;
CORD = 1;
STRING_PIECE = 2;
}
// The packed option can be enabled for repeated primitive fields to enable
// a more efficient representation on the wire. Rather than repeatedly
// writing the tag and type for each element, the entire array is encoded as
// a single length-delimited blob. In proto3, only explicit setting it to
// false will avoid using packed encoding.
optional bool packed = 2;
// The jstype option determines the JavaScript type used for values of the
// field. The option is permitted only for 64 bit integral and fixed types
// (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
// is represented as JavaScript string, which avoids loss of precision that
// can happen when a large value is converted to a floating point JavaScript.
// Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
// use the JavaScript "number" type. The behavior of the default option
// JS_NORMAL is implementation dependent.
//
// This option is an enum to permit additional types to be added, e.g.
// goog.math.Integer.
optional JSType jstype = 6 [default = JS_NORMAL];
enum JSType {
// Use the default type.
JS_NORMAL = 0;
// Use JavaScript strings.
JS_STRING = 1;
// Use JavaScript numbers.
JS_NUMBER = 2;
}
// Should this field be parsed lazily? Lazy applies only to message-type
// fields. It means that when the outer message is initially parsed, the
// inner message's contents will not be parsed but instead stored in encoded
// form. The inner message will actually be parsed when it is first accessed.
//
// This is only a hint. Implementations are free to choose whether to use
// eager or lazy parsing regardless of the value of this option. However,
// setting this option true suggests that the protocol author believes that
// using lazy parsing on this field is worth the additional bookkeeping
// overhead typically needed to implement it.
//
// This option does not affect the public interface of any generated code;
// all method signatures remain the same. Furthermore, thread-safety of the
// interface is not affected by this option; const methods remain safe to
// call from multiple threads concurrently, while non-const methods continue
// to require exclusive access.
//
//
// Note that implementations may choose not to check required fields within
// a lazy sub-message. That is, calling IsInitialized() on the outer message
// may return true even if the inner message has missing required fields.
// This is necessary because otherwise the inner message would have to be
// parsed in order to perform the check, defeating the purpose of lazy
// parsing. An implementation which chooses not to check required fields
// must be consistent about it. That is, for any particular sub-message, the
// implementation must either *always* check its required fields, or *never*
// check its required fields, regardless of whether or not the message has
// been parsed.
optional bool lazy = 5 [default = false];
// Is this field deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for accessors, or it will be completely ignored; in the very least, this
// is a formalization for deprecating fields.
optional bool deprecated = 3 [default = false];
// For Google-internal migration only. Do not use.
optional bool weak = 10 [default = false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
reserved 4; // removed jtype
}
message OneofOptions {
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message EnumOptions {
// Set this option to true to allow mapping different tag names to the same
// value.
optional bool allow_alias = 2;
// Is this enum deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the enum, or it will be completely ignored; in the very least, this
// is a formalization for deprecating enums.
optional bool deprecated = 3 [default = false];
reserved 5; // javanano_as_lite
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message EnumValueOptions {
// Is this enum value deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the enum value, or it will be completely ignored; in the very least,
// this is a formalization for deprecating enum values.
optional bool deprecated = 1 [default = false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message ServiceOptions {
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
// framework. We apologize for hoarding these numbers to ourselves, but
// we were already using them long before we decided to release Protocol
// Buffers.
// Is this service deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the service, or it will be completely ignored; in the very least,
// this is a formalization for deprecating services.
optional bool deprecated = 33 [default = false];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
message MethodOptions {
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
// framework. We apologize for hoarding these numbers to ourselves, but
// we were already using them long before we decided to release Protocol
// Buffers.
// Is this method deprecated?
// Depending on the target platform, this can emit Deprecated annotations
// for the method, or it will be completely ignored; in the very least,
// this is a formalization for deprecating methods.
optional bool deprecated = 33 [default = false];
// Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
// or neither? HTTP based RPC implementation may choose GET verb for safe
// methods, and PUT verb for idempotent methods instead of the default POST.
enum IdempotencyLevel {
IDEMPOTENCY_UNKNOWN = 0;
NO_SIDE_EFFECTS = 1; // implies idempotent
IDEMPOTENT = 2; // idempotent, but may have side effects
}
optional IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
// A message representing a option the parser does not recognize. This only
// appears in options protos created by the compiler::Parser class.
// DescriptorPool resolves these when building Descriptor objects. Therefore,
// options protos in descriptor objects (e.g. returned by Descriptor::options(),
// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
// in them.
message UninterpretedOption {
// The name of the uninterpreted option. Each string represents a segment in
// a dot-separated name. is_extension is true iff a segment represents an
// extension (denoted with parentheses in options specs in .proto files).
// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
// "foo.(bar.baz).qux".
message NamePart {
required string name_part = 1;
required bool is_extension = 2;
}
repeated NamePart name = 2;
// The value of the uninterpreted option, in whatever type the tokenizer
// identified it as during parsing. Exactly one of these should be set.
optional string identifier_value = 3;
optional uint64 positive_int_value = 4;
optional int64 negative_int_value = 5;
optional double double_value = 6;
optional bytes string_value = 7;
optional string aggregate_value = 8;
}
// ===================================================================
// Optional source code info
// Encapsulates information about the original source file from which a
// FileDescriptorProto was generated.
message SourceCodeInfo {
// A Location identifies a piece of source code in a .proto file which
// corresponds to a particular definition. This information is intended
// to be useful to IDEs, code indexers, documentation generators, and similar
// tools.
//
// For example, say we have a file like:
// message Foo {
// optional string foo = 1;
// }
// Let's look at just the field definition:
// optional string foo = 1;
// ^ ^^ ^^ ^ ^^^
// a bc de f ghi
// We have the following locations:
// span path represents
// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
//
// Notes:
// - A location may refer to a repeated field itself (i.e. not to any
// particular index within it). This is used whenever a set of elements are
// logically enclosed in a single code segment. For example, an entire
// extend block (possibly containing multiple extension definitions) will
// have an outer location whose path refers to the "extensions" repeated
// field without an index.
// - Multiple locations may have the same path. This happens when a single
// logical declaration is spread out across multiple places. The most
// obvious example is the "extend" block again -- there may be multiple
// extend blocks in the same scope, each of which will have the same path.
// - A location's span is not always a subset of its parent's span. For
// example, the "extendee" of an extension declaration appears at the
// beginning of the "extend" block and is shared by all extensions within
// the block.
// - Just because a location's span is a subset of some other location's span
// does not mean that it is a descendant. For example, a "group" defines
// both a type and a field in a single declaration. Thus, the locations
// corresponding to the type and field and their components will overlap.
// - Code which tries to interpret locations should probably be designed to
// ignore those that it doesn't understand, as more types of locations could
// be recorded in the future.
repeated Location location = 1;
message Location {
// Identifies which part of the FileDescriptorProto was defined at this
// location.
//
// Each element is a field number or an index. They form a path from
// the root FileDescriptorProto to the place where the definition. For
// example, this path:
// [ 4, 3, 2, 7, 1 ]
// refers to:
// file.message_type(3) // 4, 3
// .field(7) // 2, 7
// .name() // 1
// This is because FileDescriptorProto.message_type has field number 4:
// repeated DescriptorProto message_type = 4;
// and DescriptorProto.field has field number 2:
// repeated FieldDescriptorProto field = 2;
// and FieldDescriptorProto.name has field number 1:
// optional string name = 1;
//
// Thus, the above path gives the location of a field name. If we removed
// the last element:
// [ 4, 3, 2, 7 ]
// this path refers to the whole field declaration (from the beginning
// of the label to the terminating semicolon).
repeated int32 path = 1 [packed = true];
// Always has exactly three or four elements: start line, start column,
// end line (optional, otherwise assumed same as start line), end column.
// These are packed into a single field for efficiency. Note that line
// and column numbers are zero-based -- typically you will want to add
// 1 to each before displaying to a user.
repeated int32 span = 2 [packed = true];
// If this SourceCodeInfo represents a complete declaration, these are any
// comments appearing before and after the declaration which appear to be
// attached to the declaration.
//
// A series of line comments appearing on consecutive lines, with no other
// tokens appearing on those lines, will be treated as a single comment.
//
// leading_detached_comments will keep paragraphs of comments that appear
// before (but not connected to) the current element. Each paragraph,
// separated by empty lines, will be one comment element in the repeated
// field.
//
// Only the comment content is provided; comment markers (e.g. //) are
// stripped out. For block comments, leading whitespace and an asterisk
// will be stripped from the beginning of each line other than the first.
// Newlines are included in the output.
//
// Examples:
//
// optional int32 foo = 1; // Comment attached to foo.
// // Comment attached to bar.
// optional int32 bar = 2;
//
// optional string baz = 3;
// // Comment attached to baz.
// // Another line attached to baz.
//
// // Comment attached to qux.
// //
// // Another line attached to qux.
// optional double qux = 4;
//
// // Detached comment for corge. This is not leading or trailing comments
// // to qux or corge because there are blank lines separating it from
// // both.
//
// // Detached comment for corge paragraph 2.
//
// optional string corge = 5;
// /* Block comment attached
// * to corge. Leading asterisks
// * will be removed. */
// /* Block comment attached to
// * grault. */
// optional int32 grault = 6;
//
// // ignored detached comments.
optional string leading_comments = 3;
optional string trailing_comments = 4;
repeated string leading_detached_comments = 6;
}
}
// Describes the relationship between generated code and its original source
// file. A GeneratedCodeInfo message is associated with only one generated
// source file, but may contain references to different source .proto files.
message GeneratedCodeInfo {
// An Annotation connects some span of text in generated code to an element
// of its generating .proto file.
repeated Annotation annotation = 1;
message Annotation {
// Identifies the element in the original source .proto file. This field
// is formatted the same as SourceCodeInfo.Location.path.
repeated int32 path = 1 [packed = true];
// Identifies the filesystem path to the original source .proto.
optional string source_file = 2;
// Identifies the starting offset in bytes in the generated code
// that relates to the identified object.
optional int32 begin = 3;
// Identifies the ending offset in bytes in the generated code that
// relates to the identified offset. The end offset should be one past
// the last relevant byte (so the length of the text = end - begin).
optional int32 end = 4;
}
}
@@ -0,0 +1,15 @@
syntax = "proto3";
package vulcanize.auction.v1beta1;
import "gogoproto/gogo.proto";
import "vulcanize/auction/v1beta1/types.proto";
option go_package = "github.com/tharsis/ethermint/x/auction/types";
// GenesisState defines the genesis state of the auction module
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated Auction auctions = 2 [
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
];
}
+149
View File
@@ -0,0 +1,149 @@
syntax = "proto3";
package vulcanize.auction.v1beta1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "vulcanize/auction/v1beta1/types.proto";
option go_package = "github.com/tharsis/ethermint/x/auction/types";
// AuctionsRequest is the format for querying all the auctions
message AuctionsRequest {
// pagination defines an optional pagination info for the next request
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// AuctionsResponse returns the list of all auctions
message AuctionsResponse {
// List of auctions
Auctions auctions = 1;
// pagination defines an optional pagination info for the next request
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// AuctionRequest is the format for querying a specific auction
message AuctionRequest {
// Auction ID
string id = 1;
}
// AuctionResponse returns the details of the queried auction
message AuctionResponse {
// Auction details
Auction auction = 1;
}
// BidRequest is the format for querying a specific bid in an auction
message BidRequest {
// Auction ID
string auction_id = 1;
// Bidder address
string bidder = 2;
}
// BidResponse returns the details of the queried bid
message BidResponse {
// Bid details
Bid bid = 1;
}
// BidsRequest is the format for querying all bids in an auction
message BidsRequest {
// Auction ID
string auction_id = 1;
}
// BidsResponse returns details of all bids in an auction
message BidsResponse {
// List of bids in the auction
repeated Bid bids = 1;
}
// AuctionsByBidderRequest is the format for querying all auctions containing a bidder address
message AuctionsByBidderRequest {
// Address of the bidder
string bidder_address = 1;
}
// AuctionsByBidderResponse returns all auctions containing a bidder
message AuctionsByBidderResponse {
// List of auctions
Auctions auctions = 1;
}
// AuctionsByOwnerRequest is the format for querying all auctions created by an owner
message AuctionsByOwnerRequest {
// Address of the owner
string owner_address = 1;
}
// AuctionsByOwnerResponse returns all auctions created by an owner
message AuctionsByOwnerResponse {
// List of auctions
Auctions auctions = 1;
}
// QueryParamsRequest is the format to query the parameters of the auction module
message QueryParamsRequest {
}
// QueryParamsResponse returns parameters of the auction module
message QueryParamsResponse {
Params params = 1;
}
// BalanceRequest is the format to fetch all balances
message BalanceRequest {
}
message BalanceResponse {
// Set of all balances within the auction
repeated cosmos.base.v1beta1.Coin balance = 1 [
(gogoproto.nullable) = false
];
}
// Query defines the gRPC querier interface for the auction module
service Query {
// Auctions queries all auctions
rpc Auctions(AuctionsRequest) returns (AuctionsResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/auctions";
}
// GetAuction queries an auction
rpc GetAuction(AuctionRequest) returns (AuctionResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/auctions/{id}";
}
// GetBid queries an auction bid
rpc GetBid(BidRequest) returns (BidResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/bids/{auction_id}/{bidder}";
}
// GetBids queries all auction bids
rpc GetBids(BidsRequest) returns (BidsResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/bids/{auction_id}";
}
// AuctionsByBidder queries auctions by bidder
rpc AuctionsByBidder(AuctionsByBidderRequest) returns (AuctionsByBidderResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/by-bidder/{bidder_address}";
}
// AuctionsByOwner queries auctions by owner
rpc AuctionsByOwner(AuctionsByOwnerRequest) returns (AuctionsByOwnerResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/by-owner/{owner_address}";
}
// QueryParams implements the params query command
rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/params";
}
// Balance queries the auction module account balance
rpc Balance(BalanceRequest) returns (BalanceResponse) {
option (google.api.http).get = "/vulcanize/auction/v1beta1/balance";
}
}
+122
View File
@@ -0,0 +1,122 @@
syntax = "proto3";
package vulcanize.auction.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "cosmos/base/v1beta1/coin.proto";
import "vulcanize/auction/v1beta1/types.proto";
option go_package = "github.com/tharsis/ethermint/x/auction/types";
// MsgCreateAuction defines a create auction message
message MsgCreateAuction {
option (gogoproto.goproto_getters) = false;
// Duration of the commits phase in seconds
google.protobuf.Duration commits_duration = 1 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
];
// Duration of the reveals phase in seconds
google.protobuf.Duration reveals_duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
];
// Commit fees
cosmos.base.v1beta1.Coin commit_fee = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
];
// Reveal fees
cosmos.base.v1beta1.Coin reveal_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
];
// Minimum acceptable bid amount
cosmos.base.v1beta1.Coin minimum_bid = 5 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
];
// Address of the signer
string signer = 6 [
(gogoproto.moretags) = "json:\"signer\" yaml:\"signer\""
];
}
// MsgCreateAuctionResponse returns the details of the created auction
message MsgCreateAuctionResponse {
option (gogoproto.goproto_getters) = false;
// Auction details
Auction auction = 1 [
(gogoproto.moretags) = "json:\"auction\" yaml:\"auction\""
];
}
// CommitBid defines the message to commit a bid
message MsgCommitBid {
option (gogoproto.goproto_getters) = false;
// Auction ID
string auction_id = 1 [
(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""
];
// Commit Hash
string commit_hash = 2 [
(gogoproto.moretags) = "json:\"commit_hash\" yaml:\"commit_hash\""
];
// Address of the signer
string signer = 3 [
(gogoproto.moretags) = "json:\"signer\" yaml:\"signer\""
];
}
// RevealBid defines the message to reveal a bid
message MsgRevealBid {
option (gogoproto.goproto_getters) = false;
// Auction ID
string auction_id = 1 [
(gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\""
];
// Commit Hash
string reveal = 2 [
(gogoproto.moretags) = "json:\"reveal\" yaml:\"reveal\""
];
// Address of the signer
string signer = 3 [
(gogoproto.moretags) = "json:\"signer\" yaml:\"signer\""
];
}
// MsgCommitBidResponse returns the state of the auction after the bid creation
message MsgCommitBidResponse {
option (gogoproto.goproto_getters) = false;
// Auction details
Bid bid = 1 [
(gogoproto.moretags) = "json:\"bid\" yaml:\"bid\""
];
}
// MsgRevealBidResponse returns the state of the auction after the bid reveal
message MsgRevealBidResponse {
option (gogoproto.goproto_getters) = false;
// Auction details
Auction auction = 1 [
(gogoproto.moretags) = "json:\"auction\" yaml:\"auction\""
];
}
// Tx defines the gRPC tx interface
service Msg {
// CreateAuction is the command for creating an auction
rpc CreateAuction(MsgCreateAuction) returns (MsgCreateAuctionResponse);
// CommitBid is the command for committing a bid
rpc CommitBid(MsgCommitBid) returns (MsgCommitBidResponse);
//RevealBid is the command for revealing a bid
rpc RevealBid(MsgRevealBid) returns (MsgRevealBidResponse);
}
+135
View File
@@ -0,0 +1,135 @@
syntax = "proto3";
package vulcanize.auction.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
option go_package = "github.com/tharsis/ethermint/x/auction/types";
// Params defines the auction module parameters
message Params {
option (gogoproto.goproto_stringer) = false;
// Duration of the commits phase in seconds
google.protobuf.Duration commits_duration = 1 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
];
// Duration of the reveals phase in seconds
google.protobuf.Duration reveals_duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
];
// Commit fees
cosmos.base.v1beta1.Coin commit_fee = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
];
// Reveal fees
cosmos.base.v1beta1.Coin reveal_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
];
// Minimum acceptable bid amount
cosmos.base.v1beta1.Coin minimum_bid = 5 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
];
}
// Auction represents a sealed-bid on-chain auction
message Auction {
option (gogoproto.goproto_getters) = false;
string id = 1;
string status = 2;
// Address of the creator of the auction
string owner_address = 3;
// Timestamp at which the auction was created
google.protobuf.Timestamp create_time = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"create_time\" yaml:\"create_time\""
];
// Timestamp at which the commits phase concluded
google.protobuf.Timestamp commits_end_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commits_end_time\" yaml:\"commits_end_time\""
];
// Timestamp at which the reveals phase concluded
google.protobuf.Timestamp reveals_end_time = 6 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveals_end_time\" yaml:\"reveals_end_time\""
];
// Commit and reveal fees must both be paid when committing a bid
// Reveal fee is returned only if the bid is revealed
cosmos.base.v1beta1.Coin commit_fee = 7 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
];
cosmos.base.v1beta1.Coin reveal_fee = 8 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
];
// Minimum acceptable bid amount for a valid commit
cosmos.base.v1beta1.Coin minimum_bid = 9 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
];
// Address of the winner
string winner_address = 10;
// Winning bid, i.e., the highest bid
cosmos.base.v1beta1.Coin winning_bid = 11 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"winning_bid\" yaml:\"winning_bid\""
];
// Amount the winner pays, i.e. the second highest auction
cosmos.base.v1beta1.Coin winning_price = 12 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\""
];
}
message Auctions {
option (gogoproto.goproto_getters) = false;
repeated Auction auctions = 1 [(gogoproto.nullable) = false];
}
// Bid represents a sealed bid (commit) made during the auction
message Bid {
option (gogoproto.goproto_getters) = false;
string auction_id = 1;
string bidder_address = 2;
string status = 3;
string commit_hash = 4;
google.protobuf.Timestamp commit_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commit_time\" yaml:\"commit_time\""
];
cosmos.base.v1beta1.Coin commit_fee = 6 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
];
google.protobuf.Timestamp reveal_time = 7 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveal_time\" yaml:\"reveal_time\""
];
cosmos.base.v1beta1.Coin reveal_fee = 8 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
];
cosmos.base.v1beta1.Coin bid_amount = 9 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"bid_amount\" yaml:\"bid_amount\""
];;
}
+29
View File
@@ -0,0 +1,29 @@
syntax = "proto3";
package vulcanize.bond.v1beta1;
option go_package = "github.com/tharsis/ethermint/x/bond/types";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
// Params defines the bond module parameters
message Params {
// max_bond_amount is maximum amount to bond
cosmos.base.v1beta1.Coin max_bond_amount = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"max_bond_amount\" yaml:\"max_bond_amount\""
];
}
// Bond represents funds deposited by an account for record rent payments.
message Bond {
// id is unique identifier of the bond
string id = 1;
// owner of the bond
string owner = 2;
// balance of the bond
repeated cosmos.base.v1beta1.Coin balance = 3 [
(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "json:\"balance\" yaml:\"balance\""
];
}
@@ -0,0 +1,18 @@
syntax = "proto3";
package vulcanize.bond.v1beta1;
import "gogoproto/gogo.proto";
import "vulcanize/bond/v1beta1/bond.proto";
option go_package = "github.com/tharsis/ethermint/x/bond/types";
// GenesisState defines the bond module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// bonds defines all the bonds
repeated Bond bonds = 2 [
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
];
}
+109
View File
@@ -0,0 +1,109 @@
syntax = "proto3";
package vulcanize.bond.v1beta1;
import "gogoproto/gogo.proto";
import "vulcanize/bond/v1beta1/bond.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
option go_package = "github.com/tharsis/ethermint/x/bond/types";
// Query defines the gRPC querier service for bond module
service Query {
// Params queries bonds module params.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/vulcanize/bond/v1beta1/params";
}
// Bonds queries bonds list.
rpc Bonds(QueryGetBondsRequest) returns (QueryGetBondsResponse) {
option (google.api.http).get = "/vulcanize/bond/v1beta1/bonds";
}
// GetBondById
rpc GetBondById(QueryGetBondByIdRequest) returns (QueryGetBondByIdResponse){
option (google.api.http).get = "/vulcanize/bond/v1beta1/bonds/{id}";
}
// Get Bonds List by Owner
rpc GetBondsByOwner(QueryGetBondsByOwnerRequest) returns (QueryGetBondsByOwnerResponse){
option (google.api.http).get = "/vulcanize/bond/v1beta1/by-owner/{owner}";
}
// Get Bonds module balance
rpc GetBondsModuleBalance(QueryGetBondModuleBalanceRequest) returns (QueryGetBondModuleBalanceResponse){
option (google.api.http).get = "/vulcanize/bond/v1beta1/balance";
}
}
// QueryParamsRequest is request for query the bond module params
message QueryParamsRequest{
}
// QueryParamsResponse returns response type of bond module params
message QueryParamsResponse{
Params params = 1 [
(gogoproto.moretags) = "json:\"params\" yaml:\"params\""
];
}
// QueryGetBondById queries a bond by bond-id.
message QueryGetBondsRequest{
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// QueryGetBondsResponse is response type for get the bonds by bond-id
message QueryGetBondsResponse{
repeated Bond bonds = 1 [
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryGetBondById
message QueryGetBondByIdRequest{
string id = 1 [
(gogoproto.moretags) = "json:\"id\" yaml:\"id\""
];
}
// QueryGetBondByIdResponse returns QueryGetBondById query response
message QueryGetBondByIdResponse{
Bond bond = 1 [
(gogoproto.moretags) = "json:\"bond\" yaml:\"bond\""
];
}
// QueryGetBondsByOwnerRequest is request type for Query/GetBondsByOwner RPC Method
message QueryGetBondsByOwnerRequest{
string owner = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryGetBondsByOwnerResponse is response type for Query/GetBondsByOwner RPC Method
message QueryGetBondsByOwnerResponse {
repeated Bond bonds = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\""
];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryGetBondModuleBalanceRequest is request type for bond module balance rpc method
message QueryGetBondModuleBalanceRequest{
}
// QueryGetBondModuleBalanceResponse is the response type for bond module balance rpc method
message QueryGetBondModuleBalanceResponse{
repeated cosmos.base.v1beta1.Coin balance = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
];
}
+77
View File
@@ -0,0 +1,77 @@
syntax = "proto3";
package vulcanize.bond.v1beta1;
option go_package = "github.com/tharsis/ethermint/x/bond/types";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
// Msg defines the bond Msg service.
service Msg {
// CreateBond defines a method for creating a new bond.
rpc CreateBond(MsgCreateBond) returns (MsgCreateBondResponse);
// RefillBond defines a method for refilling amount for bond.
rpc RefillBond(MsgRefillBond) returns (MsgRefillBondResponse);
// WithdrawBond defines a method for withdrawing amount from bond.
rpc WithdrawBond(MsgWithdrawBond) returns (MsgWithdrawBondResponse);
// CancelBond defines a method for cancelling a bond.
rpc CancelBond(MsgCancelBond) returns (MsgCancelBondResponse);
}
// MsgCreateBond defines a SDK message for creating a new bond.
message MsgCreateBond{
string signer = 1;
repeated cosmos.base.v1beta1.Coin coins = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
];
}
// MsgCreateBondResponse defines the Msg/CreateBond response type.
message MsgCreateBondResponse{
string id = 1;
}
// MsgRefillBond defines a SDK message for refill the amount for bond.
message MsgRefillBond{
string id = 1;
string signer = 2;
repeated cosmos.base.v1beta1.Coin coins = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
];
}
// MsgRefillBondResponse defines the Msg/RefillBond response type.
message MsgRefillBondResponse{
}
// MsgWithdrawBond defines a SDK message for withdrawing amount from bond.
message MsgWithdrawBond {
string id = 1;
string signer = 2;
repeated cosmos.base.v1beta1.Coin coins = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "json:\"coins\" yaml:\"coins\""
];
}
// MsgWithdrawBondResponse defines the Msg/WithdrawBond response type.
message MsgWithdrawBondResponse{
}
// MsgCancelBond defines a SDK message for the cancel the bond.
message MsgCancelBond{
string id = 1;
string signer = 2;
}
// MsgCancelBondResponse defines the Msg/CancelBond response type.
message MsgCancelBondResponse{
}
@@ -0,0 +1,30 @@
syntax = "proto3";
package vulcanize.nameservice.v1beta1;
import "gogoproto/gogo.proto";
import "vulcanize/nameservice/v1beta1/nameservice.proto";
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
// GenesisState defines the nameservice module's genesis state.
message GenesisState {
// params defines all the params of nameservice module.
Params params = 1 [
(gogoproto.nullable) = false
];
// records
repeated Record records = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"records\" yaml:\"records\""
];
// authorities
repeated AuthorityEntry authorities = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"authorities\" yaml:\"authorities\""
];
// names
repeated NameEntry names = 4 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"names\" yaml:\"names\""
];
}
@@ -0,0 +1,169 @@
syntax = "proto3";
package vulcanize.nameservice.v1beta1;
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
// Params defines the nameservice module parameters
message Params {
cosmos.base.v1beta1.Coin record_rent = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"record_rent\" yaml:\"record_rent\""
];
google.protobuf.Duration record_rent_duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"record_rent_duration\" yaml:\"record_rent_duration\""
];
cosmos.base.v1beta1.Coin authority_rent = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"authority_rent\" yaml:\"authority_rent\""
];
google.protobuf.Duration authority_rent_duration = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"authority_rent_duration\" yaml:\"authority_rent_duration\""
];
google.protobuf.Duration authority_grace_period = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"authority_grace_period\" yaml:\"authority_grace_period\""
];
bool authority_auction_enabled = 6 [
(gogoproto.moretags) = "json:\"authority_auction_enabled\" yaml:\"authority_auction_enabled\""
];
google.protobuf.Duration authority_auction_commits_duration = 7 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"authority_auction_commits_duration\" yaml:\"authority_auction_commits_duration\""
];
google.protobuf.Duration authority_auction_reveals_duration = 8 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.moretags) = "json:\"authority_auction_reveals_duration\" yaml:\"authority_auction_reveals_duration\""
];
cosmos.base.v1beta1.Coin authority_auction_commit_fee = 9 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"authority_auction_commit_fee\" yaml:\"authority_auction_commit_fee\""
];
cosmos.base.v1beta1.Coin authority_auction_reveal_fee = 10 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"authority_auction_reveal_fee\" yaml:\"authority_auction_reveal_fee\""
];
cosmos.base.v1beta1.Coin authority_auction_minimum_bid = 11 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"authority_auction_minimum_bid\" yaml:\"authority_auction_minimum_bid\""
];
}
// Params defines the nameservice module records
message Record {
string id = 1 [
(gogoproto.moretags) = "json:\"id\" yaml:\"id\""
];
string bond_id = 2 [
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
];
string create_time = 3 [
(gogoproto.moretags) = "json:\"createTime\" yaml:\"createTime\""
];
string expiry_time = 4 [
(gogoproto.moretags) = "json:\"expiryTime\" yaml:\"expiryTime\""
];
bool deleted = 5;
repeated string owners = 6 [
(gogoproto.moretags) = "json:\"owners\" yaml:\"owners\""
];
string attributes = 7 [
(gogoproto.moretags) = "json:\"attributes\" yaml:\"attributes\""
];
repeated string names = 8 [
(gogoproto.moretags) = "json:\"names\" yaml:\"names\""
];
}
// AuthorityEntry defines the nameservice module AuthorityEntries
message AuthorityEntry{
string name = 1;
NameAuthority entry = 2;
}
// NameAuthority
message NameAuthority {
// Owner public key.
string owner_public_key = 1 [
(gogoproto.moretags) = "json:\"ownerPublicKey\" yaml:\"ownerPublicKey\""
];
// Owner address.
string owner_address = 2 [
(gogoproto.moretags) = "json:\"ownerAddress\" yaml:\"ownerAddress\""
];
// height at which name/authority was created.
uint64 height = 3;
string status = 4;
string auction_id = 5 [
(gogoproto.moretags) = "json:\"auctionID\" yaml:\"auctionID\""
];
string bond_id = 6 [
(gogoproto.moretags) = "json:\"bondID\" yaml:\"bondID\""
];
google.protobuf.Timestamp expiry_time = 7 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "json:\"expiryTime\" yaml:\"expiryTime\""
];
}
// NameEntry
message NameEntry{
string name = 1;
NameRecord entry = 2;
}
// NameRecord
message NameRecord {
NameRecordEntry latest = 1;
repeated NameRecordEntry history = 2;
}
// NameRecordEntry
message NameRecordEntry{
string id = 1;
uint64 height = 2;
}
// Signature
message Signature{
string sig = 1 [
(gogoproto.moretags) = "json:\"sig\" yaml:\"sig\""
];
string pub_key = 2 [
(gogoproto.moretags) = "json:\"pubKey\" yaml:\"pubKey\""
];
}
// BlockChangeSet
message BlockChangeSet{
int64 height = 1;
repeated string records = 2;
repeated string auctions = 3;
repeated AuctionBidInfo auction_bids = 4 [
(gogoproto.moretags) = "json:\"auctionBids\" yaml:\"auctionBids\""
];
repeated string authorities = 5;
repeated string names = 6;
}
// AuctionBidInfo
message AuctionBidInfo {
string auction_id = 1 [
(gogoproto.moretags) = "json:\"auctionID\" yaml:\"auctionID\""
];
string bidder_address = 2 [
(gogoproto.moretags) = "json:\"bidderAddress\" yaml:\"bidderAddress\""
];
}
@@ -0,0 +1,231 @@
syntax = "proto3";
package vulcanize.nameservice.v1beta1;
import "vulcanize/nameservice/v1beta1/nameservice.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
// Query defines the gRPC querier service for nameservice module
service Query {
// Params queries the nameservice module params.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/params";
}
// List records
rpc ListRecords(QueryListRecordsRequest) returns (QueryListRecordsResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/records";
}
// Get record by id
rpc GetRecord(QueryRecordByIdRequest) returns (QueryRecordByIdResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/records/{id}";
}
// Get records by bond id
rpc GetRecordByBondId(QueryRecordByBondIdRequest) returns (QueryRecordByBondIdResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/records-by-bond-id/{id}";
}
// Get nameservice module balance
rpc GetNameServiceModuleBalance(GetNameServiceModuleBalanceRequest) returns (GetNameServiceModuleBalanceResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/balance";
}
// List name records
rpc ListNameRecords(QueryListNameRecordsRequest) returns (QueryListNameRecordsResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/names";
}
// Whois method retrieve the name authority info
rpc Whois(QueryWhoisRequest) returns (QueryWhoisResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/whois/{name}";
}
// LookupCrn
rpc LookupCrn(QueryLookupCrn) returns (QueryLookupCrnResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/lookup";
}
// ResolveCrn
rpc ResolveCrn(QueryResolveCrn) returns (QueryResolveCrnResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/resolve";
}
// GetRecordExpiryQueue
rpc GetRecordExpiryQueue(QueryGetRecordExpiryQueue) returns (QueryGetRecordExpiryQueueResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/record-expiry";
}
// GetAuthorityExpiryQueue
rpc GetAuthorityExpiryQueue(QueryGetAuthorityExpiryQueue) returns (QueryGetAuthorityExpiryQueueResponse){
option (google.api.http).get = "/vulcanize/nameservice/v1beta1/authority-expiry";
}
}
// QueryParamsRequest is request type for nameservice params
message QueryParamsRequest{
}
// QueryParamsResponse is response type for nameservice params
message QueryParamsResponse{
Params params = 1;
}
// QueryListRecordsRequest is request type for nameservice records list
message QueryListRecordsRequest{
message ReferenceInput {
string id = 1;
}
message ValueInput {
string type = 1;
string string = 2;
int64 int = 3;
double float = 4;
bool boolean = 5;
ReferenceInput reference = 6;
repeated ValueInput values = 7;
}
message KeyValueInput {
string key = 1;
ValueInput value = 2;
}
repeated KeyValueInput attributes = 1;
bool all = 2;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryListRecordsResponse is response type for nameservice records list
message QueryListRecordsResponse{
repeated Record records = 1 [
(gogoproto.nullable) = false
];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
//QueryRecordByIdRequest is request type for nameservice records by id
message QueryRecordByIdRequest{
string id = 1 ;
}
// QueryRecordByIdResponse is response type for nameservice records by id
message QueryRecordByIdResponse{
Record record = 1[
(gogoproto.nullable) = false
];
}
// QueryRecordByBondIdRequest is request type for get the records by bond-id
message QueryRecordByBondIdRequest{
string id = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryRecordByBondIdResponse is response type for records list by bond-id
message QueryRecordByBondIdResponse{
repeated Record records = 1 [
(gogoproto.nullable) = false
];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// GetNameServiceModuleBalanceRequest is request type for nameservice module accounts balance
message GetNameServiceModuleBalanceRequest{
}
// GetNameServiceModuleBalanceResponse is response type for nameservice module accounts balance
message GetNameServiceModuleBalanceResponse{
repeated AccountBalance balances = 1;
}
// AccountBalance is nameservice module account balance
message AccountBalance {
string account_name = 1 [
(gogoproto.moretags) = "json:\"accountName\" yaml:\"accountName\""
];
repeated cosmos.base.v1beta1.Coin balance = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "json:\"balance\" yaml:\"balance\""
];
}
// QueryListNameRecordsRequest is request type for nameservice names records
message QueryListNameRecordsRequest{
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// QueryListNameRecordsResponse is response type for nameservice names records
message QueryListNameRecordsResponse{
repeated NameEntry names = 1 [
(gogoproto.nullable) = false
];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryWhoisRequest is request type for Get NameAuthority
message QueryWhoisRequest{
string name = 1;
}
// QueryWhoisResponse is response type for whois request
message QueryWhoisResponse{
NameAuthority name_authority = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"nameAuthority\" yaml:\"nameAuthority\""
];
}
// QueryLookupCrn is request type for LookupCrn
message QueryLookupCrn{
string crn = 1;
}
// QueryLookupCrnResponse is response type for QueryLookupCrn
message QueryLookupCrnResponse{
NameRecord name = 1;
}
// QueryResolveCrn is request type for ResolveCrn
message QueryResolveCrn{
string crn = 1;
}
// QueryResolveCrnResponse is response type for QueryResolveCrn
message QueryResolveCrnResponse{
Record record = 1;
}
// QueryGetRecordExpiryQueue
message QueryGetRecordExpiryQueue{
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// QueryGetRecordExpiryQueueResponse
message QueryGetRecordExpiryQueueResponse{
repeated ExpiryQueueRecord records = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// ExpiryQueueRecord
message ExpiryQueueRecord{
string id = 1;
repeated string value = 2;
}
// QueryGetAuthorityExpiryQueue
message QueryGetAuthorityExpiryQueue{
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
// QueryGetAuthorityExpiryQueueResponse
message QueryGetAuthorityExpiryQueueResponse{
repeated ExpiryQueueRecord authorities = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
@@ -0,0 +1,168 @@
syntax = "proto3";
package vulcanize.nameservice.v1beta1;
import "gogoproto/gogo.proto";
import "vulcanize/nameservice/v1beta1/nameservice.proto";
option go_package = "github.com/tharsis/ethermint/x/nameservice/types";
// Msg
service Msg {
// SetRecord will records a new record with given payload and bond id
rpc SetRecord(MsgSetRecord) returns(MsgSetRecordResponse){}
// Renew Record will renew the expire record
rpc RenewRecord(MsgRenewRecord) returns (MsgRenewRecordResponse){}
// AssociateBond
rpc AssociateBond(MsgAssociateBond) returns (MsgAssociateBondResponse){}
// DissociateBond
rpc DissociateBond(MsgDissociateBond) returns (MsgDissociateBondResponse){}
// DissociateRecords
rpc DissociateRecords(MsgDissociateRecords) returns (MsgDissociateRecordsResponse){}
// ReAssociateRecords
rpc ReAssociateRecords(MsgReAssociateRecords) returns (MsgReAssociateRecordsResponse){}
// SetName will store the name with given crn and name
rpc SetName(MsgSetName) returns (MsgSetNameResponse){}
// Reserve name
rpc ReserveName(MsgReserveAuthority) returns (MsgReserveAuthorityResponse){}
// Delete Name method will remove authority name
rpc DeleteName(MsgDeleteNameAuthority) returns (MsgDeleteNameAuthorityResponse){}
// SetAuthorityBond
rpc SetAuthorityBond(MsgSetAuthorityBond) returns (MsgSetAuthorityBondResponse){}
}
// MsgSetRecord
message MsgSetRecord{
string bond_id = 1 [
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
];
string signer = 2;
Payload payload = 3 [
(gogoproto.nullable) = false
];
}
// MsgSetRecordResponse
message MsgSetRecordResponse{
string id = 1;
}
// Payload
message Payload {
Record record = 1;
repeated Signature signatures = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "json:\"signatures\" yaml:\"signatures\""
];
}
// MsgSetName
message MsgSetName{
string crn = 1;
string cid = 2;
string signer = 3;
}
// MsgSetNameResponse
message MsgSetNameResponse{
}
// MsgReserveName
message MsgReserveAuthority{
string name = 1;
string signer = 2;
// if creating a sub-authority.
string owner = 3;
}
// MsgReserveNameResponse
message MsgReserveAuthorityResponse{
}
// MsgSetAuthorityBond is SDK message for SetAuthorityBond
message MsgSetAuthorityBond{
string name = 1;
string bond_id = 2 [
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
];
string signer = 3;
}
// MsgSetAuthorityBondResponse
message MsgSetAuthorityBondResponse{
}
// MsgDeleteNameAuthority is SDK message for DeleteNameAuthority
message MsgDeleteNameAuthority{
string crn = 1;
string signer = 2;
}
// MsgDeleteNameAuthorityResponse
message MsgDeleteNameAuthorityResponse{
}
//MsgRenewRecord is SDK message for Renew a record
message MsgRenewRecord{
string record_id = 1 [
(gogoproto.moretags) = "json:\"recordId\" yaml:\"recordId\""
];
string signer = 2;
}
// MsgRenewRecordResponse
message MsgRenewRecordResponse{
}
// MsgAssociateBond
message MsgAssociateBond{
string record_id = 1 [
(gogoproto.moretags) = "json:\"recordId\" yaml:\"recordId\""
];
string bond_id = 2 [
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
];
string signer = 3;
}
// MsgAssociateBondResponse
message MsgAssociateBondResponse{
}
// MsgDissociateBond is SDK message for Msg/DissociateBond
message MsgDissociateBond{
string record_id = 1 [
(gogoproto.moretags) = "json:\"recordId\" yaml:\"recordId\""
];
string signer = 2;
}
// MsgDissociateBondResponse is response type for MsgDissociateBond
message MsgDissociateBondResponse{
}
// MsgDissociateRecords is SDK message for Msg/DissociateRecords
message MsgDissociateRecords{
string bond_id = 1 [
(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""
];
string signer = 2;
}
// MsgDissociateRecordsResponse is response type for MsgDissociateRecords
message MsgDissociateRecordsResponse{
}
// MsgReAssociateRecords is SDK message for Msg/ReAssociateRecords
message MsgReAssociateRecords{
string new_bond_id = 1 [
(gogoproto.moretags) = "json:\"newBondId\" yaml:\"newBondId\""
];
string old_bond_id = 2 [
(gogoproto.moretags) = "json:\"oldBondId\" yaml:\"oldBondId\""
];
string signer = 3;
}
// MsgReAssociateRecordsResponse is response type for MsgReAssociateRecords
message MsgReAssociateRecordsResponse{
}
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# NOTE: protoc is required
I=$(pwd)/proto
DEST_TS=$(pwd)/src/proto/
mkdir -p $DEST_TS
protoc \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--ts_out=$DEST_TS \
--proto_path=$I \
$(find $(pwd)/proto/vulcanize -iname "*.proto")
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
echo $PWD
for file in $(find src/proto -type f)
do
line=$(grep -n '@grpc/grpc-js' $file | cut -f1 -d':')
if [[ $line -gt 0 ]];
then
echo "Processing file... $file"
sed -i "${line}d" ${file}
functions=$(grep -n 'interface GrpcUnaryServiceInterface' $file | cut -f1 -d':')
sed -i "${functions},\$d" ${file}
echo '}' >> $file
fi
sed -i '1s#^#/* eslint-disable */\n#' $file
sed -i '1s#^#// @ts-nocheck\n#' $file
done
+182
View File
@@ -0,0 +1,182 @@
import assert from 'assert';
import BIP32Factory from 'bip32';
import * as ecc from 'tiny-secp256k1';
import * as bip39 from 'bip39';
import canonicalStringify from 'canonical-json';
import secp256k1 from 'secp256k1';
import { utils } from 'ethers';
import { sha256 } from 'js-sha256';
import { MessageTypes, signTypedData, SignTypedDataVersion } from '@metamask/eth-sig-util';
import { Ripemd160 } from "@cosmjs/crypto";
import { fromHex, toHex } from '@cosmjs/encoding';
import { ethToEthermint } from "@tharsis/address-converter"
import { encodeSecp256k1Pubkey } from '@cosmjs/amino';
import { Payload, Signature } from './types';
const AMINO_PREFIX = 'EB5AE98721';
const HDPATH = "m/44'/60'/0'/0";
const bip32 = BIP32Factory(ecc);
interface TypedMessageDomain {
name?: string;
version?: string;
chainId?: number;
verifyingContract?: string;
salt?: ArrayBuffer;
}
/**
* Registry account.
*/
export class Account {
_privateKey: Buffer
_publicKey!: Uint8Array
_encodedPubkey!: string
_formattedCosmosAddress!: string
_registryPublicKey!: string
_registryAddress!: string
_ethAddress!: string
/**
* Generate bip39 mnemonic.
*/
static generateMnemonic() {
return bip39.generateMnemonic();
}
/**
* Generate private key from mnemonic.
*/
static async generateFromMnemonic(mnemonic: string) {
assert(mnemonic);
const seed = await bip39.mnemonicToSeed(mnemonic);
const wallet = bip32.fromSeed(seed);
const account = wallet.derivePath(HDPATH);
const { privateKey } = account;
assert(privateKey);
return new Account(privateKey);
}
/**
* New Account.
*/
constructor(privateKey: Buffer) {
assert(privateKey);
this._privateKey = privateKey;
this.init()
}
get privateKey() {
return this._privateKey;
}
get encodedPubkey() {
return this._encodedPubkey;
}
get formattedCosmosAddress() {
return this._formattedCosmosAddress;
}
get registryPublicKey() {
return this._registryPublicKey;
}
get registryAddress() {
return this._registryAddress;
}
init () {
// Generate public key.
this._publicKey = secp256k1.publicKeyCreate(this._privateKey)
this._encodedPubkey = encodeSecp256k1Pubkey(this._publicKey).value
// 2. Generate eth address.
this._ethAddress = utils.computeAddress(this._publicKey)
// 3. Generate cosmos-sdk formatted address.
this._formattedCosmosAddress = ethToEthermint(this._ethAddress);
// 4. Generate registry formatted public key.
const publicKeyInHex = AMINO_PREFIX + toHex(this._publicKey);
this._registryPublicKey = Buffer.from(publicKeyInHex, 'hex').toString('base64');
// 5. Generate registry formatted address.
let publicKeySha256 = sha256(Buffer.from(publicKeyInHex, 'hex'));
this._registryAddress = new Ripemd160().update(fromHex(publicKeySha256)).digest().toString();
}
/**
* Get private key.
*/
getPrivateKey() {
return this._privateKey.toString('hex');
}
/**
* Get cosmos address.
*/
getCosmosAddress() {
return this._formattedCosmosAddress;
}
/**
* Get record signature.
*/
async signRecord(record: any) {
assert(record);
const recordAsJson = canonicalStringify(record);
// Double sha256.
const recordBytesToSign = Buffer.from(sha256(Buffer.from(sha256(Buffer.from(recordAsJson)), 'hex')), 'hex');
// Sign message
assert(recordBytesToSign);
const messageToSignSha256 = sha256(recordBytesToSign);
const messageToSignSha256InBytes = Buffer.from(messageToSignSha256, 'hex');
const sigObj = secp256k1.ecdsaSign(messageToSignSha256InBytes, this.privateKey);
return Buffer.from(sigObj.signature);
}
async signPayload(payload: Payload) {
assert(payload);
const { record } = payload;
const messageToSign = record.getMessageToSign();
const sig = await this.signRecord(messageToSign);
assert(this.registryPublicKey)
const signature = new Signature(this.registryPublicKey, sig.toString('base64'));
payload.addSignature(signature);
return signature;
}
/**
* Sign message.
*/
sign(message: any) {
assert(message);
const eipMessageDomain: any = message.eipToSign.domain;
const signature = signTypedData({
data: {
types: message.eipToSign.types as MessageTypes,
primaryType: message.eipToSign.primaryType,
domain: eipMessageDomain as TypedMessageDomain,
message: message.eipToSign.message as Record<string, unknown>
},
privateKey: this._privateKey,
version: SignTypedDataVersion.V4
})
return signature;
}
}
+130
View File
@@ -0,0 +1,130 @@
import { Registry, Account, createBid } from './index';
import { getConfig } from './testing/helper';
jest.setTimeout(30 * 60 * 1000);
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
const auctionTests = (numBidders = 3) => {
let registry: Registry;
const accounts: { address: string, privateKey: string, bid?: any }[] = [];
let auctionId: string;
let authorityName: string;
beforeAll(async () => {
console.log('Running auction tests with num bidders', numBidders);
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
});
test('Setup bidder accounts', async () => {
for (let i = 0; i < numBidders; i++) {
const mnenonic = Account.generateMnemonic();
const account = await Account.generateFromMnemonic(mnenonic);
const bidderAddress = account.formattedCosmosAddress;
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: bidderAddress }, privateKey, fee);
accounts.push({ address: bidderAddress, privateKey: account.privateKey.toString('hex') });
}
});
test('Reserve authority.', async () => {
authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, accounts[0].privateKey, fee);
});
test('Authority should be under auction.', async () => {
const [record] = await registry.lookupAuthorities([authorityName], true);
expect(record.ownerAddress).toEqual('');
expect(record.height).toBeDefined();
expect(record.status).toEqual('auction');
expect(record.auction.id).toBeDefined();
expect(record.auction.status).toEqual('commit');
auctionId = record.auction.id;
});
test('Commit bids.', async () => {
for (let i = 0; i < numBidders; i++) {
accounts[i].bid = await createBid(chainId, auctionId, accounts[i].address, `${10000000 + (i * 500)}aphoton`);
await registry.commitBid({ auctionId, commitHash: accounts[i].bid.commitHash }, accounts[i].privateKey, fee);
}
});
test('Check bids are committed', async () => {
const [record] = await registry.lookupAuthorities([authorityName], true);
expect(record.auction.id).toBeDefined();
expect(record.auction.status).toEqual('commit');
expect(record.auction.bids).toHaveLength(accounts.length);
record.auction.bids.forEach((bid: any) => {
expect(bid.status).toEqual('commit');
});
});
test('Wait for reveal phase.', (done) => {
setTimeout(done, 60 * 1000);
});
test('Reveal bids.', async () => {
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('reveal');
for (let i = 0; i < numBidders; i++) {
await registry.revealBid({ auctionId, reveal: accounts[i].bid.revealString }, accounts[i].privateKey, fee);
}
});
test('Check bids are revealed', async () => {
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('reveal');
auction.bids.forEach((bid: any) => {
expect(bid.status).toEqual('reveal');
});
});
test('Wait for auction completion.', (done) => {
setTimeout(done, 60 * 1000);
});
test('Check auction winner, authority owner and status.', async () => {
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('completed');
const highestBidder = accounts[accounts.length - 1];
const secondHighestBidder = (accounts.length > 1 ? accounts[accounts.length - 2] : highestBidder);
expect(auction.winnerAddress).toEqual(highestBidder.address);
expect(highestBidder.bid.reveal.bidAmount).toEqual(`${auction.winnerBid.quantity}${auction.winnerBid.type}`);
expect(secondHighestBidder.bid.reveal.bidAmount).toEqual(`${auction.winnerPrice.quantity}${auction.winnerPrice.type}`);
const [record] = await registry.lookupAuthorities([authorityName], true);
expect(record.ownerAddress).toEqual(highestBidder.address);
expect(record.height).toBeDefined();
expect(record.status).toEqual('active');
});
};
const withNumBidders = (numBidders: number) => () => auctionTests(numBidders);
if (!process.env.TEST_AUCTIONS_ENABLED) {
// Required as jest complains if file has no tests.
test('skipping auction tests', () => {});
} else {
/**
Running these tests requires name auctions enabled. In laconicd repo run:
TEST_AUCTION_ENABLED=true ./init.sh
Run tests:
yarn test:auctions
*/
describe('Auction (1 bidder)', withNumBidders(1));
describe('Auction (2 bidders)', withNumBidders(2));
describe('Auction (4 bidders)', withNumBidders(4));
}
+148
View File
@@ -0,0 +1,148 @@
import path from 'path';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
jest.setTimeout(90 * 1000);
const bondTests = () => {
let registry: Registry;
let watcher: any;
let version1: string;
let version2: string;
let bondId1: string;
let bondId2: string;
let bondOwner: string;
const publishNewWatcherVersion = async (bondId: string) => {
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
await registry.setRecord({ privateKey, record: watcher.record, bondId }, privateKey, fee);
return watcher.record.version;
};
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
});
test('Create bond.', async () => {
bondId1 = await registry.getNextBondId(privateKey);
expect(bondId1).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
})
test('Get bond by ID.', async () => {
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bondId1);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000000' });
bondOwner = bond.owner;
});
test('Query bonds.', async () => {
const bonds = await registry.queryBonds();
expect(bonds).toBeDefined();
const bond = bonds.filter((bond: any) => bond.id === bondId1);
expect(bond).toBeDefined();
});
test('Query bonds by owner.', async () => {
const bonds = await registry.queryBonds({ owner: bondOwner });
expect(bonds).toBeDefined();
const bond = bonds.filter((bond: any) => bond.id === bondId1);
expect(bond).toBeDefined();
});
test('Refill bond.', async () => {
await registry.refillBond({ id: bondId1, denom: 'aphoton', amount: '500' }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bondId1);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000500' });
});
test('Withdraw bond.', async () => {
await registry.withdrawBond({ id: bondId1, denom: 'aphoton', amount: '500' }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond).toBeDefined();
expect(bond.id).toBe(bondId1);
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0]).toEqual({ type: 'aphoton', quantity: '1000000000' });
});
test('Cancel bond.', async () => {
await registry.cancelBond({ id: bondId1 }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bondId1]);
expect(bond.id).toBe("");
expect(bond.owner).toBe("");
expect(bond.balance).toHaveLength(0);
});
test('Associate/Dissociate bond.', async () => {
bondId1 = await registry.getNextBondId(privateKey);
expect(bondId1).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// Create a new record.
version1 = await publishNewWatcherVersion(bondId1);
let [record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe(bondId1);
// Dissociate record, query and confirm.
await registry.dissociateBond({ recordId: record1.id }, privateKey, fee);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe('');
// Associate record with bond, query and confirm.
await registry.associateBond({ recordId: record1.id, bondId: bondId1 }, privateKey, fee);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(record1.bondId).toBe(bondId1);
});
test('Reassociate/Dissociate records.', async () => {
// Create a new record version.
version2 = await publishNewWatcherVersion(bondId1);
// Check version1, version2 as associated with bondId1.
let records;
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(records[0].bondId).toBe(bondId1);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe(bondId1);
// Create another bond.
bondId2 = await registry.getNextBondId(privateKey);
expect(bondId2).toBeDefined();
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
const [bond] = await registry.getBondsByIds([bondId2]);
expect(bond.id).toBe(bondId2);
// Reassociate records from bondId1 to bondId2, verify change.
await registry.reassociateRecords({ oldBondId: bondId1, newBondId: bondId2 }, privateKey, fee);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(records[0].bondId).toBe(bondId2);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe(bondId2);
// Dissociate all records from bond, verify change.
await registry.dissociateRecords({ bondId: bondId2 }, privateKey, fee);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
expect(records[0].bondId).toBe('');
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
expect(records[0].bondId).toBe('');
});
};
describe('Bonds', bondTests);
+3
View File
@@ -0,0 +1,3 @@
declare module 'graphql.js'
declare module 'node-yaml'
declare module 'canonical-json'
+46
View File
@@ -0,0 +1,46 @@
import { Account } from './account';
import { Registry } from './index';
import { getConfig } from './testing/helper';
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
jest.setTimeout(90 * 1000);
const registryTests = () => {
let registry: Registry;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
});
test('Get account info.', async() => {
const account = new Account(Buffer.from(privateKey, 'hex'));
const accounts = await registry.getAccounts([account.formattedCosmosAddress]);
expect(accounts).toHaveLength(1)
const [accountObj] = accounts;
expect(accountObj.address).toBe(account.formattedCosmosAddress);
expect(accountObj.pubKey).toBe(account.encodedPubkey);
expect(accountObj.number).toBe('0');
expect(accountObj.sequence).toBeDefined();
expect(accountObj.balance).toHaveLength(1);
const [{ type, quantity }] = accountObj.balance
expect(type).toBe('aphoton');
expect(quantity).toBeDefined();
})
test('Get account balance.', async() => {
const mnenonic1 = Account.generateMnemonic();
const otherAccount = await Account.generateFromMnemonic(mnenonic1);
await registry.sendCoins({ denom: 'aphoton', amount: '100000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
const [accountObj] = await registry.getAccounts([otherAccount.formattedCosmosAddress]);
expect(accountObj).toBeDefined();
expect(accountObj.address).toBe(otherAccount.formattedCosmosAddress);
const [{ type, quantity }] = accountObj.balance
expect(type).toBe('aphoton');
expect(quantity).toBe('100000000');
})
}
describe('Registry', registryTests);
+577
View File
@@ -0,0 +1,577 @@
import isUrl from 'is-url';
import { sha256 } from 'js-sha256';
import { generatePostBodyBroadcast, BroadcastMode } from '@tharsis/provider';
import {
Chain,
Sender,
Fee,
createMessageSend,
MessageSendParams
} from '@tharsis/transactions'
import { RegistryClient } from "./registry-client";
import { Account } from "./account";
import { createTransaction } from "./txbuilder";
import { Payload, Record } from './types';
import { Util } from './util';
import {
createTxMsgAssociateBond,
createTxMsgCancelBond,
createTxMsgCreateBond,
createTxMsgDissociateBond,
createTxMsgDissociateRecords,
createTxMsgReAssociateRecords,
createTxMsgRefillBond,
createTxMsgWithdrawBond,
MessageMsgAssociateBond,
MessageMsgCancelBond,
MessageMsgCreateBond,
MessageMsgDissociateBond,
MessageMsgDissociateRecords,
MessageMsgReAssociateRecords,
MessageMsgRefillBond,
MessageMsgWithdrawBond
} from "./messages/bond";
import {
createTxMsgDeleteName,
createTxMsgReserveAuthority,
createTxMsgSetAuthorityBond,
createTxMsgSetName,
createTxMsgSetRecord,
MessageMsgDeleteName,
MessageMsgReserveAuthority,
MessageMsgSetAuthorityBond,
MessageMsgSetName,
MessageMsgSetRecord,
NAMESERVICE_ERRORS,
parseMsgSetRecordResponse
} from './messages/nameservice';
import {
createTxMsgCommitBid,
createTxMsgRevealBid,
MessageMsgCommitBid,
MessageMsgRevealBid
} from './messages/auction';
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
// Parse Tx response from cosmos-sdk.
export const parseTxResponse = (result: any, parseResponse?: (data: string) => any) => {
const { txhash: hash, height, ...txResponse } = result;
if (parseResponse) {
txResponse.data = parseResponse(txResponse.data)
}
txResponse.events.forEach((event:any) => {
event.attributes = event.attributes.map(({ key, value }: { key: string, value: string }) => ({
key: Buffer.from(key, 'base64').toString('utf8'),
value: Buffer.from(value, 'base64').toString('utf8')
}));
});
return { hash, height, ...txResponse };
};
/**
* Create an auction bid.
*/
export const createBid = async (chainId: string, auctionId: string, bidderAddress: string, bidAmount: string, noise?: string) => {
if (!noise) {
noise = Account.generateMnemonic();
}
const reveal = {
chainId,
auctionId,
bidderAddress,
bidAmount,
noise
};
const commitHash = await Util.getContentId(reveal);
const revealString = Buffer.from(JSON.stringify(reveal)).toString('hex');
return {
commitHash,
reveal,
revealString
};
};
export const isKeyValid = (key: string) => key && key.match(/^[0-9a-fA-F]{64}$/);
export class Registry {
_endpoints: {[key: string]: string}
_chainID: string
_chain: Chain
_client: RegistryClient
static processWriteError(error: string) {
// error string a stacktrace containing the message.
// https://gist.github.com/nikugogoi/de55d390574ded3466abad8bffd81952#file-txresponse-js-L7
const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message))
if (!errorMessage) {
console.error(error)
}
return errorMessage || DEFAULT_WRITE_ERROR;
}
constructor(gqlUrl: string, restUrl: string = "", chainId: string = DEFAULT_CHAIN_ID) {
if (!isUrl(gqlUrl)) {
throw new Error('Path to a GQL endpoint should be provided.');
}
if (restUrl && !isUrl(restUrl)) {
throw new Error('REST endpoint is not a URL string.');
}
this._endpoints = {
rest: restUrl,
gql: gqlUrl
};
this._client = new RegistryClient(gqlUrl, restUrl);
this._chainID = chainId;
this._chain = {
cosmosChainId: chainId,
chainId: this._parseEthChainId(chainId)
};
}
/**
* Get accounts by addresses.
*/
async getAccounts(addresses: string[]) {
return this._client.getAccounts(addresses);
}
get endpoints() {
return this._endpoints;
}
get chainID() {
return this._chainID;
}
/**
* Get server status.
*/
async getStatus() {
return this._client.getStatus();
}
/**
* Get records by ids.
*/
async getRecordsByIds(ids: string[], refs = false) {
return this._client.getRecordsByIds(ids, refs);
}
/**
* Get records by attributes.
*/
async queryRecords(attributes: {[key: string]: any}, all = false, refs = false) {
return this._client.queryRecords(attributes, all, refs);
}
/**
* Resolve names to records.
*/
async resolveNames(names: string[], refs = false) {
return this._client.resolveNames(names, refs);
}
/**
* Publish record.
* @param transactionPrivateKey - private key in HEX to sign transaction.
*/
async setRecord(
params: { privateKey: string, record: any, bondId: string },
transactionPrivateKey: string,
fee: Fee
) {
let result;
result = await this._submitRecordTx(params, transactionPrivateKey, fee);
return parseTxResponse(result, parseMsgSetRecordResponse);
}
/**
* Send coins.
*/
async sendCoins(params: MessageSendParams, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createMessageSend(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Computes the next bondId for the given account private key.
*/
async getNextBondId(privateKey: string) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const accounts = await this.getAccounts([account.formattedCosmosAddress]);
if (!accounts.length) {
throw new Error('Account does not exist.');
}
const [accountObj] = accounts;
const nextSeq = parseInt(accountObj.sequence, 10) + 1;
result = sha256(`${accountObj.address}:${accountObj.number}:${nextSeq}`);
return result;
}
/**
* Get bonds by ids.
*/
async getBondsByIds(ids: string[]) {
return this._client.getBondsByIds(ids);
}
/**
* Query bonds by attributes.
*/
async queryBonds(attributes = {}) {
return this._client.queryBonds(attributes);
}
/**
* Create bond.
*/
async createBond(params: MessageMsgCreateBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgCreateBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Refill bond.
*/
async refillBond(params: MessageMsgRefillBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgRefillBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Withdraw (from) bond.
*/
async withdrawBond(params: MessageMsgWithdrawBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgWithdrawBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Cancel bond.
*/
async cancelBond(params: MessageMsgCancelBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgCancelBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Associate record with bond.
*/
async associateBond(params: MessageMsgAssociateBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgAssociateBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Dissociate record from bond.
*/
async dissociateBond(params: MessageMsgDissociateBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgDissociateBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Dissociate all records from bond.
*/
async dissociateRecords(params: MessageMsgDissociateRecords, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgDissociateRecords(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Reassociate records (switch bond).
*/
async reassociateRecords(params: MessageMsgReAssociateRecords, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgReAssociateRecords(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Reserve authority.
*/
async reserveAuthority(params: { name: string, owner?: string }, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msgParams = {
name: params.name,
owner: params.owner || sender.accountAddress
}
const msg = createTxMsgReserveAuthority(this._chain, sender, fee, '', msgParams)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Set authority bond.
*/
async setAuthorityBond(params: MessageMsgSetAuthorityBond, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgSetAuthorityBond(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Commit auction bid.
*/
async commitBid(params: MessageMsgCommitBid, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgCommitBid(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Reveal auction bid.
*/
async revealBid(params: MessageMsgRevealBid, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgRevealBid(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Get records by ids.
*/
async getAuctionsByIds(ids: string[]) {
return this._client.getAuctionsByIds(ids);
}
/**
* Lookup authorities by names.
*/
async lookupAuthorities(names: string[], auction = false) {
return this._client.lookupAuthorities(names, auction);
}
/**
* Set name (CRN) to record ID (CID).
*/
async setName(params: MessageMsgSetName, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgSetName(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Lookup naming information.
*/
async lookupNames(names: string[], history = false) {
return this._client.lookupNames(names, history);
}
/**
* Delete name (CRN) mapping.
*/
async deleteName(params: MessageMsgDeleteName, privateKey: string, fee: Fee) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgDeleteName(this._chain, sender, fee, '', params)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Submit record transaction.
* @param privateKey - private key in HEX to sign message.
* @param txPrivateKey - private key in HEX to sign transaction.
*/
async _submitRecordTx(
{ privateKey, record, bondId }: { privateKey: string, record: any, bondId: string },
txPrivateKey: string,
fee: Fee
) {
if (!isKeyValid(privateKey)) {
throw new Error('Registry privateKey should be a hex string.');
}
if (!isKeyValid(bondId)) {
throw new Error(`Invalid bondId: ${bondId}.`);
}
// Sign record.
const recordSignerAccount = new Account(Buffer.from(privateKey, 'hex'));
const registryRecord = new Record(record);
const payload = new Payload(registryRecord);
await recordSignerAccount.signPayload(payload);
// Send record payload Tx.
txPrivateKey = txPrivateKey || recordSignerAccount.getPrivateKey();
return this._submitRecordPayloadTx({ payload, bondId }, txPrivateKey, fee);
}
async _submitRecordPayloadTx(params: MessageMsgSetRecord, privateKey: string, fee: Fee) {
if (!isKeyValid(privateKey)) {
throw new Error('Registry privateKey should be a hex string.');
}
if (!isKeyValid(params.bondId)) {
throw new Error(`Invalid bondId: ${params.bondId}.`);
}
const account = new Account(Buffer.from(privateKey, 'hex'));
const sender = await this._getSender(account);
const msg = createTxMsgSetRecord(this._chain, sender, fee, '', params)
return this._submitTx(msg, privateKey, sender);
}
/**
* Submit a generic Tx to the chain.
*/
async _submitTx(message: any, privateKey: string, sender: Sender) {
// Check private key.
if (!isKeyValid(privateKey)) {
throw new Error('Registry privateKey should be a hex string.');
}
// Check that the account exists on-chain.
const account = new Account(Buffer.from(privateKey, 'hex'));
// Generate signed Tx.
const transaction = createTransaction(message, account, sender, this._chain);
const tx = generatePostBodyBroadcast(transaction, BroadcastMode.Block)
// Submit Tx to chain.
const { tx_response: response } = await this._client.submit(tx);
if (response.code !== 0) {
// Throw error when transaction is not successful.
// https://docs.starport.com/guide/nameservice/05-play.html#buy-name-transaction-details
throw new Error(Registry.processWriteError(response.raw_log))
}
return response;
}
/**
* https://evmos.dev/basics/chain_id.html
*/
_parseEthChainId (chainId: string) {
const [ idWithChainNumber ] = chainId.split('-')
const [ _, ethChainId ] = idWithChainNumber.split('_')
return Number(ethChainId)
}
/**
* Get sender used for creating message.
*/
async _getSender (account: Account) {
const accounts = await this.getAccounts([account.formattedCosmosAddress]);
if (!accounts.length) {
throw new Error('Account does not exist.');
}
const [{ number, sequence }] = accounts;
return {
accountAddress: account.formattedCosmosAddress,
sequence: sequence,
accountNumber: number,
pubkey: account.encodedPubkey,
}
}
}
export { Account }
+149
View File
@@ -0,0 +1,149 @@
import {
generateTypes,
} from '@tharsis/eip712'
import {
Chain,
Sender,
Fee,
} from '@tharsis/transactions'
import * as auctionTx from '../proto/vulcanize/auction/v1beta1/tx'
import { createTx } from './util'
const MSG_COMMIT_BID_TYPES = {
MsgValue: [
{ name: 'auction_id', type: 'string' },
{ name: 'commit_hash', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
export interface MessageMsgCommitBid {
auctionId: string,
commitHash: string,
}
const MSG_REVEAL_BID_TYPES = {
MsgValue: [
{ name: 'auction_id', type: 'string' },
{ name: 'reveal', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
export interface MessageMsgRevealBid {
auctionId: string,
reveal: string,
}
export function createTxMsgCommitBid(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgCommitBid,
) {
const types = generateTypes(MSG_COMMIT_BID_TYPES)
const msg = createMsgCommitBid(
params.auctionId,
params.commitHash,
sender.accountAddress,
)
const msgCosmos = protoCreateMsgCommitBid(
params.auctionId,
params.commitHash,
sender.accountAddress,
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgRevealBid(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgRevealBid,
) {
const types = generateTypes(MSG_REVEAL_BID_TYPES)
const msg = createMsgRevealBid(
params.auctionId,
params.reveal,
sender.accountAddress,
)
const msgCosmos = protoCreateMsgRevealBid(
params.auctionId,
params.reveal,
sender.accountAddress,
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
function createMsgCommitBid(
auctionId: string,
commitHash: string,
signer: string
) {
return {
type: 'auction/MsgCommitBid',
value: {
auction_id: auctionId,
commit_hash: commitHash,
signer,
},
}
}
const protoCreateMsgCommitBid = (
auctionId: string,
commitHash: string,
signer: string
) => {
const commitBidMessage = new auctionTx.vulcanize.auction.v1beta1.MsgCommitBid({
auction_id: auctionId,
commit_hash: commitHash,
signer,
})
return {
message: commitBidMessage,
path: 'vulcanize.auction.v1beta1.MsgCommitBid',
}
}
function createMsgRevealBid(
auctionId: string,
reveal: string,
signer: string
) {
return {
type: 'auction/MsgRevealBid',
value: {
auction_id: auctionId,
reveal,
signer,
},
}
}
const protoCreateMsgRevealBid = (
auctionId: string,
reveal: string,
signer: string
) => {
const revealBidMessage = new auctionTx.vulcanize.auction.v1beta1.MsgRevealBid({
auction_id: auctionId,
reveal,
signer,
})
return {
message: revealBidMessage,
path: 'vulcanize.auction.v1beta1.MsgRevealBid',
}
}
+590
View File
@@ -0,0 +1,590 @@
import {
generateTypes,
} from '@tharsis/eip712'
import {
Chain,
Sender,
Fee,
} from '@tharsis/transactions'
import * as bondTx from '../proto/vulcanize/bond/v1beta1/tx'
import * as nameserviceTx from '../proto/vulcanize/nameservice/v1beta1/tx'
import * as coin from '../proto/cosmos/base/v1beta1/coin'
import { createTx } from './util'
const MSG_CREATE_BOND_TYPES = {
MsgValue: [
{ name: 'signer', type: 'string' },
{ name: 'coins', type: 'TypeCoins[]' },
],
TypeCoins: [
{ name: 'denom', type: 'string' },
{ name: 'amount', type: 'string' },
],
}
const MSG_REFILL_BOND_TYPES = {
MsgValue: [
{ name: 'id', type: 'string' },
{ name: 'signer', type: 'string' },
{ name: 'coins', type: 'TypeCoins[]' },
],
TypeCoins: [
{ name: 'denom', type: 'string' },
{ name: 'amount', type: 'string' },
],
}
const MSG_WITHDRAW_BOND_TYPES = {
MsgValue: [
{ name: 'id', type: 'string' },
{ name: 'signer', type: 'string' },
{ name: 'coins', type: 'TypeCoins[]' },
],
TypeCoins: [
{ name: 'denom', type: 'string' },
{ name: 'amount', type: 'string' },
],
}
const MSG_CANCEL_BOND_TYPES = {
MsgValue: [
{ name: 'id', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
const MSG_ASSOCIATE_BOND_TYPES = {
MsgValue: [
{ name: 'record_id', type: 'string' },
{ name: 'bond_id', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
const MSG_DISSOCIATE_BOND_TYPES = {
MsgValue: [
{ name: 'record_id', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
const MSG_DISSOCIATE_RECORDS_TYPES = {
MsgValue: [
{ name: 'bond_id', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
const MSG_REASSOCIATE_RECORDS_TYPES = {
MsgValue: [
{ name: 'new_bond_id', type: 'string' },
{ name: 'old_bond_id', type: 'string' },
{ name: 'signer', type: 'string' },
]
}
export interface MessageMsgCreateBond {
amount: string
denom: string
}
export interface MessageMsgRefillBond {
id: string,
amount: string
denom: string
}
export interface MessageMsgWithdrawBond {
id: string
amount: string
denom: string
}
export interface MessageMsgCancelBond {
id: string
}
export interface MessageMsgAssociateBond {
bondId: string,
recordId: string
}
export interface MessageMsgDissociateBond {
recordId: string
}
export interface MessageMsgDissociateRecords {
bondId: string
}
export interface MessageMsgReAssociateRecords {
newBondId: string
oldBondId: string
}
export function createTxMsgCreateBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgCreateBond,
) {
const types = generateTypes(MSG_CREATE_BOND_TYPES)
const msg = createMsgCreateBond(
sender.accountAddress,
params.amount,
params.denom
)
const msgCosmos = protoCreateMsgCreateBond(
sender.accountAddress,
params.amount,
params.denom
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgRefillBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgRefillBond,
) {
const types = generateTypes(MSG_REFILL_BOND_TYPES)
const msg = createMsgRefillBond(
params.id,
sender.accountAddress,
params.amount,
params.denom
)
const msgCosmos = protoCreateMsgRefillBond(
params.id,
sender.accountAddress,
params.amount,
params.denom
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgWithdrawBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgWithdrawBond,
) {
const types = generateTypes(MSG_WITHDRAW_BOND_TYPES)
const msg = createMsgWithdrawBond(
params.id,
sender.accountAddress,
params.amount,
params.denom
)
const msgCosmos = protoCreateMsgWithdrawBond(
params.id,
sender.accountAddress,
params.amount,
params.denom
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgCancelBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgCancelBond,
) {
const types = generateTypes(MSG_CANCEL_BOND_TYPES)
const msg = createMsgCancelBond(
params.id,
sender.accountAddress
)
const msgCosmos = protoCreateMsgCancelBond(
params.id,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgAssociateBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgAssociateBond,
) {
const types = generateTypes(MSG_ASSOCIATE_BOND_TYPES)
const msg = createMsgAssociateBond(
params.recordId,
params.bondId,
sender.accountAddress
)
const msgCosmos = protoCreateMsgAssociateBond(
params.recordId,
params.bondId,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgDissociateBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgDissociateBond,
) {
const types = generateTypes(MSG_DISSOCIATE_BOND_TYPES)
const msg = createMsgDissociateBond(
params.recordId,
sender.accountAddress
)
const msgCosmos = protoCreateMsgDissociateBond(
params.recordId,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgDissociateRecords(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgDissociateRecords,
) {
const types = generateTypes(MSG_DISSOCIATE_RECORDS_TYPES)
const msg = createMsgDissociateRecords(
params.bondId,
sender.accountAddress
)
const msgCosmos = protoCreateMsgDissociateRecords(
params.bondId,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgReAssociateRecords(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgReAssociateRecords,
) {
const types = generateTypes(MSG_REASSOCIATE_RECORDS_TYPES)
const msg = createMsgReAssociateRecords(
params.newBondId,
params.oldBondId,
sender.accountAddress
)
const msgCosmos = protoCreateMsgReAssociateRecords(
params.newBondId,
params.oldBondId,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
function createMsgCreateBond(
signer: string,
amount: string,
denom: string,
) {
return {
type: 'bond/MsgCreateBond',
value: {
coins: [
{
amount,
denom,
},
],
signer
},
}
}
const protoCreateMsgCreateBond = (
signer: string,
amount: string,
denom: string,
) => {
const value = new coin.cosmos.base.v1beta1.Coin({
denom,
amount,
})
const createBondMessage = new bondTx.vulcanize.bond.v1beta1.MsgCreateBond({
signer,
coins: [value]
})
return {
message: createBondMessage,
path: 'vulcanize.bond.v1beta1.MsgCreateBond',
}
}
function createMsgRefillBond(
id: string,
signer: string,
amount: string,
denom: string,
) {
return {
type: 'bond/MsgRefillBond',
value: {
coins: [
{
amount,
denom,
},
],
id,
signer
},
}
}
const protoCreateMsgRefillBond = (
id: string,
signer: string,
amount: string,
denom: string,
) => {
const value = new coin.cosmos.base.v1beta1.Coin({
denom,
amount,
})
const refillBondMessage = new bondTx.vulcanize.bond.v1beta1.MsgRefillBond({
id,
signer,
coins: [value]
})
return {
message: refillBondMessage,
path: 'vulcanize.bond.v1beta1.MsgRefillBond',
}
}
function createMsgWithdrawBond(
id: string,
signer: string,
amount: string,
denom: string,
) {
return {
type: 'bond/MsgWithdrawBond',
value: {
id,
coins: [
{
amount,
denom,
},
],
signer
},
}
}
const protoCreateMsgWithdrawBond = (
id: string,
signer: string,
amount: string,
denom: string,
) => {
const value = new coin.cosmos.base.v1beta1.Coin({
denom,
amount,
})
const withdrawBondMessage = new bondTx.vulcanize.bond.v1beta1.MsgWithdrawBond({
id,
signer,
coins: [value]
})
return {
message: withdrawBondMessage,
path: 'vulcanize.bond.v1beta1.MsgWithdrawBond',
}
}
function createMsgCancelBond(
id: string,
signer: string
) {
return {
type: 'bond/MsgCancelBond',
value: {
id,
signer
},
}
}
const protoCreateMsgCancelBond = (
id: string,
signer: string
) => {
const cancelBondMessage = new bondTx.vulcanize.bond.v1beta1.MsgCancelBond({
id,
signer
})
return {
message: cancelBondMessage,
path: 'vulcanize.bond.v1beta1.MsgCancelBond',
}
}
function createMsgAssociateBond(
recordId: string,
bondId: string,
signer: string
) {
return {
type: 'nameservice/AssociateBond',
value: {
record_id: recordId,
bond_id: bondId,
signer
},
}
}
const protoCreateMsgAssociateBond = (
recordId: string,
bondId: string,
signer: string
) => {
const associateBondMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgAssociateBond({
record_id: recordId,
bond_id: bondId,
signer
})
return {
message: associateBondMessage,
path: 'vulcanize.nameservice.v1beta1.MsgAssociateBond',
}
}
function createMsgDissociateBond(
recordId: string,
signer: string
) {
return {
type: 'nameservice/DissociateBond',
value: {
record_id: recordId,
signer
},
}
}
const protoCreateMsgDissociateBond = (
recordId: string,
signer: string
) => {
const dissociateBondMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgDissociateBond({
record_id: recordId,
signer
})
return {
message: dissociateBondMessage,
path: 'vulcanize.nameservice.v1beta1.MsgDissociateBond',
}
}
function createMsgDissociateRecords(
bondId: string,
signer: string
) {
return {
type: 'nameservice/DissociateRecords',
value: {
bond_id: bondId,
signer
},
}
}
const protoCreateMsgDissociateRecords = (
bondId: string,
signer: string
) => {
const dissociateRecordsMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgDissociateRecords({
bond_id: bondId,
signer
})
return {
message: dissociateRecordsMessage,
path: 'vulcanize.nameservice.v1beta1.MsgDissociateRecords',
}
}
function createMsgReAssociateRecords(
newBondId: string,
oldBondId: string,
signer: string
) {
return {
type: 'nameservice/ReassociateRecords',
value: {
new_bond_id: newBondId,
old_bond_id: oldBondId,
signer
},
}
}
const protoCreateMsgReAssociateRecords = (
newBondId: string,
oldBondId: string,
signer: string
) => {
const reAssociateRecordsMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgReAssociateRecords({
new_bond_id: newBondId,
old_bond_id: oldBondId,
signer
})
return {
message: reAssociateRecordsMessage,
path: 'vulcanize.nameservice.v1beta1.MsgReAssociateRecords',
}
}
+399
View File
@@ -0,0 +1,399 @@
import {
generateTypes,
} from '@tharsis/eip712'
import {
Chain,
Sender,
Fee,
} from '@tharsis/transactions'
import * as nameserviceTx from '../proto/vulcanize/nameservice/v1beta1/tx'
import * as nameservice from '../proto/vulcanize/nameservice/v1beta1/nameservice'
import { createTx } from './util'
import { Payload } from '../types'
const MSG_RESERVE_AUTHORITY_TYPES = {
MsgValue: [
{ name: 'name', type: 'string' },
{ name: 'signer', type: 'string' },
{ name: 'owner', type: 'string' },
],
}
const MSG_SET_NAME_TYPES = {
MsgValue: [
{ name: 'crn', type: 'string' },
{ name: 'cid', type: 'string' },
{ name: 'signer', type: 'string' },
],
}
const MSG_SET_RECORD_TYPES = {
MsgValue: [
{ name: 'bond_id', type: 'string' },
{ name: 'signer', type: 'string' },
{ name: 'payload', type: 'TypePayload' },
],
TypePayload: [
{ name: 'record', type: 'TypePayloadRecord' },
{ name: 'signatures', type: 'TypePayloadSignatures[]' },
],
TypePayloadRecord: [
{ name: 'id', type: 'string' },
{ name: 'bond_id', type: 'string' },
{ name: 'create_time', type: 'string' },
{ name: 'expiry_time', type: 'string' },
{ name: 'deleted', type: 'bool' },
{ name: 'attributes', type: 'string' },
],
TypePayloadSignatures: [
{ name: 'sig', type: 'string' },
{ name: 'pub_key', type: 'string' }
],
}
const MSG_SET_AUTHORITY_BOND_TYPES = {
MsgValue: [
{ name: 'name', type: 'string' },
{ name: 'bond_id', type: 'string' },
{ name: 'signer', type: 'string' },
],
}
const MSG_DELETE_NAME_TYPES = {
MsgValue: [
{ name: 'crn', type: 'string' },
{ name: 'signer', type: 'string' },
],
}
export const parseMsgSetRecordResponse = (data: string) => {
const responseBytes = Buffer.from(data, 'hex')
// TODO: Decode response using protobuf.
// const msgSetRecordResponse = nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
// return msgSetRecordResponse.toObject();
// Workaround as proto based decoding is not working.
const [_, id] = responseBytes.toString().split(';')
return { id }
}
export const NAMESERVICE_ERRORS = [
'Name already reserved.',
'Authority bond not found.',
'Name authority not found.',
'Access denied.',
]
export interface MessageMsgReserveAuthority {
name: string
owner: string
}
export interface MessageMsgSetName {
crn: string
cid: string
}
export interface MessageMsgSetRecord {
bondId: string
payload: Payload
}
export interface MessageMsgSetAuthorityBond {
name: string
bondId: string
}
export interface MessageMsgDeleteName {
crn: string
}
export function createTxMsgReserveAuthority(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgReserveAuthority,
) {
const types = generateTypes(MSG_RESERVE_AUTHORITY_TYPES)
const msg = createMsgReserveAuthority(
params.name,
sender.accountAddress,
params.owner
)
const msgCosmos = protoCreateMsgReserveAuthority(
params.name,
sender.accountAddress,
params.owner
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgSetName(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgSetName,
) {
const types = generateTypes(MSG_SET_NAME_TYPES)
const msg = createMsgSetName(
params.crn,
params.cid,
sender.accountAddress
)
const msgCosmos = protoCreateMsgSetName(
params.crn,
params.cid,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgSetRecord(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgSetRecord,
) {
const types = generateTypes(MSG_SET_RECORD_TYPES)
const msg = createMsgSetRecord(
params.bondId,
params.payload,
sender.accountAddress
)
const msgCosmos = protoCreateMsgSetRecord(
params.bondId,
params.payload,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgSetAuthorityBond(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgSetAuthorityBond,
) {
const types = generateTypes(MSG_SET_AUTHORITY_BOND_TYPES)
const msg = createMsgSetAuthorityBond(
params.name,
params.bondId,
sender.accountAddress
)
const msgCosmos = protoCreateMsgSetAuthorityBond(
params.name,
params.bondId,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
export function createTxMsgDeleteName(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgDeleteName,
) {
const types = generateTypes(MSG_DELETE_NAME_TYPES)
const msg = createMsgDeleteName(
params.crn,
sender.accountAddress
)
const msgCosmos = protoCreateMsgDeleteName(
params.crn,
sender.accountAddress
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
function createMsgReserveAuthority(
name: string,
signer: string,
owner: string
) {
return {
type: 'nameservice/ReserveAuthority',
value: {
name,
signer,
owner
},
}
}
const protoCreateMsgReserveAuthority = (
name: string,
signer: string,
owner: string,
) => {
const reserveAuthorityMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgReserveAuthority({
name,
signer,
owner
})
return {
message: reserveAuthorityMessage,
path: 'vulcanize.nameservice.v1beta1.MsgReserveAuthority',
}
}
function createMsgSetName(
crn: string,
cid: string,
signer: string
) {
return {
type: 'nameservice/SetName',
value: {
crn,
cid,
signer
},
}
}
const protoCreateMsgSetName = (
crn: string,
cid: string,
signer: string
) => {
const setNameMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetName({
crn,
cid,
signer,
})
return {
message: setNameMessage,
path: 'vulcanize.nameservice.v1beta1.MsgSetName',
}
}
function createMsgSetRecord(
bondId: string,
payload: Payload,
signer: string
) {
return {
type: 'nameservice/SetRecord',
value: {
bond_id: bondId,
signer,
payload: payload.serialize()
},
}
}
const protoCreateMsgSetRecord = (
bondId: string,
payloadData: Payload,
signer: string
) => {
const record = new nameservice.vulcanize.nameservice.v1beta1.Record(payloadData.record.serialize())
const signatures = payloadData.signatures.map(
signature => new nameservice.vulcanize.nameservice.v1beta1.Signature(
signature.serialize()
)
)
const payload = new nameserviceTx.vulcanize.nameservice.v1beta1.Payload({
record,
signatures
})
const setNameMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetRecord({
bond_id: bondId,
signer,
payload
})
return {
message: setNameMessage,
path: 'vulcanize.nameservice.v1beta1.MsgSetRecord',
}
}
function createMsgSetAuthorityBond(
name: string,
bondId: string,
signer: string
) {
return {
type: 'nameservice/SetAuthorityBond',
value: {
name,
bond_id: bondId,
signer
},
}
}
const protoCreateMsgSetAuthorityBond = (
name: string,
bondId: string,
signer: string
) => {
const setAuthorityBondMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetAuthorityBond({
name,
bond_id: bondId,
signer,
})
return {
message: setAuthorityBondMessage,
path: 'vulcanize.nameservice.v1beta1.MsgSetAuthorityBond',
}
}
function createMsgDeleteName(
crn: string,
signer: string
) {
return {
type: 'nameservice/DeleteAuthority',
value: {
crn,
signer
},
}
}
const protoCreateMsgDeleteName = (
crn: string,
signer: string
) => {
const deleteNameAutorityMessage = new nameserviceTx.vulcanize.nameservice.v1beta1.MsgDeleteNameAuthority({
crn,
signer,
})
return {
message: deleteNameAutorityMessage,
path: 'vulcanize.nameservice.v1beta1.MsgDeleteNameAuthority',
}
}
+79
View File
@@ -0,0 +1,79 @@
import { Message } from "google-protobuf";
import {
createEIP712,
generateFee,
generateMessage,
generateTypes,
} from '@tharsis/eip712'
import {
Chain,
Sender,
Fee,
} from '@tharsis/transactions'
import { createTransaction } from '@tharsis/proto'
interface Msg {
type: string
value: any
}
interface MsgCosmos {
message: Message
path: string
}
interface Types {
[key: string]: Array<{
name: string
type: string
}>
}
export const createTx = (
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
messageTypes: Types,
msg: Msg,
msgCosmos: MsgCosmos,
) => {
// EIP712
const feeObject = generateFee(
fee.amount,
fee.denom,
fee.gas,
sender.accountAddress,
)
const types = generateTypes(messageTypes)
const messages = generateMessage(
sender.accountNumber.toString(),
sender.sequence.toString(),
chain.cosmosChainId,
memo,
feeObject,
msg,
)
const eipToSign = createEIP712(types, chain.chainId, messages)
// Cosmos
const tx = createTransaction(
msgCosmos,
memo,
fee.amount,
fee.denom,
parseInt(fee.gas, 10),
'ethsecp256',
sender.pubkey,
sender.sequence,
sender.accountNumber,
chain.cosmosChainId,
)
return {
signDirect: tx.signDirect,
legacyAmino: tx.legacyAmino,
eipToSign,
}
}
+116
View File
@@ -0,0 +1,116 @@
import path from 'path';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(120 * 1000);
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
const nameserviceExpiryTests = () => {
let registry: Registry;
let bondId: string;
let watcher: any;
let authorityName: string;
let authorityExpiryTime: Date;
let recordExpiryTime: Date;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
// Create bond.
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: 'aphoton', amount: '3000000' }, privateKey, fee);
});
test('Set record and check bond balance', async () => {
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
await registry.setRecord(
{
privateKey,
bondId,
record: watcher.record
},
privateKey,
fee
)
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
recordExpiryTime = new Date(record.expiryTime);
const [bond] = await registry.getBondsByIds([bondId]);
expect(bond).toBeDefined();
expect(bond.balance).toHaveLength(1);
expect(bond.balance[0].quantity).toBe('2000000');
})
test('Reserve authority and set bond', async () => {
authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
const [authority] = await registry.lookupAuthorities([authorityName]);
expect(authority.status).toBe('active');
authorityExpiryTime = new Date(authority.expiryTime);
});
test('Wait for expiry duration', (done) => {
setTimeout(done, 60 * 1000);
});
test('Check record expiry time', async() => {
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
const updatedExpiryTime = new Date(record.expiryTime);
expect(updatedExpiryTime.getTime()).toBeGreaterThan(recordExpiryTime.getTime());
recordExpiryTime = updatedExpiryTime;
})
test('Check authority expiry time', async() => {
const [authority] = await registry.lookupAuthorities([authorityName]);
const updatedExpiryTime = new Date(authority.expiryTime);
expect(updatedExpiryTime.getTime()).toBeGreaterThan(authorityExpiryTime.getTime());
authorityExpiryTime = updatedExpiryTime;
})
test('Check bond balance', async () => {
const [bond] = await registry.getBondsByIds([bondId]);
expect(bond).toBeDefined();
expect(bond.balance).toHaveLength(0);
})
test('Wait for expiry duration', (done) => {
setTimeout(done, 60 * 1000);
});
test('Check record deleted without bond balance', async() => {
const records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
expect(records).toHaveLength(0);
})
test('Check authority expired without bond balance', async() => {
const [authority] = await registry.lookupAuthorities([authorityName]);
expect(authority.status).toBe('expired');
})
}
if (!process.env.TEST_NAMESERVICE_EXPIRY) {
// Required as jest complains if file has no tests.
test('skipping nameservice expiry tests', () => {});
} else {
/**
Running these tests requires timers to be set. In laconicd repo run:
TEST_NAMESERVICE_EXPIRY=true ./init.sh
Run tests:
yarn test:nameservice-expiry
*/
describe('Nameservice Expiry', nameserviceExpiryTests)
}
+273
View File
@@ -0,0 +1,273 @@
import assert from 'assert';
import path from 'path';
import { Account } from './account';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(120 * 1000);
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
const namingTests = () => {
let registry: Registry;
let bondId: string;
let watcher: any;
let watcherId: string;
let authorityName: string;
let otherAuthorityName: string;
let otherPrivateKey: string;
let crn: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
// Create bond.
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
bondId,
record: watcher.record
},
privateKey,
fee
)
watcherId = result.data.id;
});
test('Reserve authority.', async () => {
authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
});
test('Lookup authority.', async () => {
const [record] = await registry.lookupAuthorities([authorityName]);
expect(record).toBeDefined();
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
});
test('Lookup non existing authority', async () => {
const [record] = await registry.lookupAuthorities(['does-not-exist']);
expect(record.ownerAddress).toBe('');
expect(record.ownerPublicKey).toBe('');
expect(Number(record.height)).toBe(0);
});
test('Reserve already reserved authority', async () => {
await expect(registry.reserveAuthority({ name: authorityName }, privateKey, fee)).rejects.toThrow('Name already reserved.');
});
test('Reserve sub-authority.', async () => {
const subAuthority = `echo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority }, privateKey, fee);
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
});
test('Reserve sub-authority with different owner.', async () => {
// Create another account, send tx to set public key on the account.
const mnenonic1 = Account.generateMnemonic();
const otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount1.formattedCosmosAddress }, privateKey, fee);
const mnenonic2 = Account.generateMnemonic();
const otherAccount2 = await Account.generateFromMnemonic(mnenonic2);
await registry.sendCoins({ denom: 'aphoton', amount: '10', destinationAddress: otherAccount2.formattedCosmosAddress }, otherAccount1.getPrivateKey(), fee);
const subAuthority = `halo.${authorityName}`;
await registry.reserveAuthority({ name: subAuthority, owner: otherAccount1.formattedCosmosAddress }, privateKey, fee);
const [record] = await registry.lookupAuthorities([subAuthority]);
expect(record).toBeDefined();
expect(record.ownerAddress).toBeDefined();
expect(record.ownerAddress).toBe(otherAccount1.getCosmosAddress());
expect(record.ownerPublicKey).toBeDefined();
expect(Number(record.height)).toBeGreaterThan(0);
});
test('Set name for unbonded authority', async () => {
crn = `crn://${authorityName}/app/test`;
assert(watcherId)
await expect(registry.setName({ crn, cid: watcherId }, privateKey, fee)).rejects.toThrow('Authority bond not found.');
});
test('Set authority bond', async () => {
await registry.setAuthorityBond({ name: authorityName, bondId }, privateKey, fee);
});
test('Set name', async () => {
crn = `crn://${authorityName}/app/test`;
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
// Query records should return it (some CRN points to it).
const records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
test('Lookup name', async () => {
const records = await registry.lookupNames([crn]);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest, history }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe(watcherId);
expect(latest.height).toBeDefined();
expect(history).toBeUndefined();
});
test('Resolve name', async () => {
const records = await registry.resolveNames([crn]);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ attributes }] = records;
expect(attributes).toEqual(watcher.record);
});
test('Lookup name with history', async () => {
const updatedWatcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
bondId,
record: updatedWatcher.record
},
privateKey,
fee
)
const updatedWatcherId = result.data.id;
await registry.setName({ crn, cid: updatedWatcherId }, privateKey, fee);
const records = await registry.lookupNames([crn], true);
expect(records).toHaveLength(1);
const [{ latest, history }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe(updatedWatcherId);
expect(latest.height).toBeDefined();
expect(history).toBeDefined();
expect(history).toHaveLength(1);
const [oldRecord] = history;
expect(oldRecord).toBeDefined();
expect(oldRecord.id).toBeDefined();
expect(oldRecord.id).toBe(watcherId);
expect(oldRecord.height).toBeDefined();
});
test('Set name without reserving authority', async () => {
await expect(registry.setName({ crn: 'crn://not-reserved/app/test', cid: watcherId }, privateKey, fee))
.rejects.toThrow('Name authority not found.');
});
test('Set name for non-owned authority', async () => {
// Create another account.
const mnenonic = Account.generateMnemonic();
const otherAccount = await Account.generateFromMnemonic(mnenonic);
await registry.sendCoins({ denom: 'aphoton', amount: '1000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
// Other account reserves an authority.
otherAuthorityName = `other-${Date.now()}`;
otherPrivateKey = otherAccount.privateKey.toString('hex');
await registry.reserveAuthority({ name: otherAuthorityName }, otherPrivateKey, fee);
// Try setting name under other authority.
await expect(registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, privateKey, fee)).rejects.toThrow('Access denied.');
});
test('Lookup non existing name', async () => {
const records = await registry.lookupNames(['crn://not-reserved/app/test']);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [record] = records;
expect(record).toBeNull();
});
test('Resolve non existing name', async () => {
const records = await registry.resolveNames(['crn://not-reserved/app/test']);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [record] = records;
expect(record).toBeNull();
});
test('Delete name', async () => {
await registry.deleteName({ crn }, privateKey, fee);
let records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe('');
expect(latest.height).toBeDefined();
// Query records should NOT return it (no CRN points to it).
records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(0);
// Query all records should return it (all: true).
records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
test('Delete already deleted name', async () => {
await registry.deleteName({ crn }, privateKey, fee);
const records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest }] = records;
expect(latest).toBeDefined();
expect(latest.id).toBeDefined();
expect(latest.id).toBe('');
expect(latest.height).toBeDefined();
});
test('Delete name for non-owned authority.', async () => {
const otherBondId = await registry.getNextBondId(otherPrivateKey);
await registry.createBond({ denom: 'aphoton', amount: '10000' }, otherPrivateKey, fee);
await registry.setAuthorityBond({ name: otherAuthorityName, bondId: otherBondId }, otherPrivateKey, fee);
await registry.setName({ crn: `crn://${otherAuthorityName}/app/test`, cid: watcherId }, otherPrivateKey, fee);
// Try deleting name under other authority.
await expect(registry.deleteName({ crn: `crn://${otherAuthorityName}/app/test` }, privateKey, fee)).rejects.toThrow('Access denied.');
});
};
if (process.env.TEST_AUCTIONS_ENABLED) {
// Required as jest complains if file has no tests.
test('skipping naming tests', () => {});
} else {
describe('Naming', namingTests);
}
@@ -0,0 +1,257 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: cosmos/base/query/v1beta1/pagination.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export namespace cosmos.base.query.v1beta1 {
export class PageRequest extends pb_1.Message {
constructor(data?: any[] | {
key?: Uint8Array;
offset?: number;
limit?: number;
count_total?: boolean;
reverse?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("key" in data && data.key != undefined) {
this.key = data.key;
}
if ("offset" in data && data.offset != undefined) {
this.offset = data.offset;
}
if ("limit" in data && data.limit != undefined) {
this.limit = data.limit;
}
if ("count_total" in data && data.count_total != undefined) {
this.count_total = data.count_total;
}
if ("reverse" in data && data.reverse != undefined) {
this.reverse = data.reverse;
}
}
}
get key() {
return pb_1.Message.getField(this, 1) as Uint8Array;
}
set key(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
}
get offset() {
return pb_1.Message.getField(this, 2) as number;
}
set offset(value: number) {
pb_1.Message.setField(this, 2, value);
}
get limit() {
return pb_1.Message.getField(this, 3) as number;
}
set limit(value: number) {
pb_1.Message.setField(this, 3, value);
}
get count_total() {
return pb_1.Message.getField(this, 4) as boolean;
}
set count_total(value: boolean) {
pb_1.Message.setField(this, 4, value);
}
get reverse() {
return pb_1.Message.getField(this, 5) as boolean;
}
set reverse(value: boolean) {
pb_1.Message.setField(this, 5, value);
}
static fromObject(data: {
key?: Uint8Array;
offset?: number;
limit?: number;
count_total?: boolean;
reverse?: boolean;
}) {
const message = new PageRequest({});
if (data.key != null) {
message.key = data.key;
}
if (data.offset != null) {
message.offset = data.offset;
}
if (data.limit != null) {
message.limit = data.limit;
}
if (data.count_total != null) {
message.count_total = data.count_total;
}
if (data.reverse != null) {
message.reverse = data.reverse;
}
return message;
}
toObject() {
const data: {
key?: Uint8Array;
offset?: number;
limit?: number;
count_total?: boolean;
reverse?: boolean;
} = {};
if (this.key != null) {
data.key = this.key;
}
if (this.offset != null) {
data.offset = this.offset;
}
if (this.limit != null) {
data.limit = this.limit;
}
if (this.count_total != null) {
data.count_total = this.count_total;
}
if (this.reverse != null) {
data.reverse = this.reverse;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.key !== undefined)
writer.writeBytes(1, this.key);
if (this.offset !== undefined)
writer.writeUint64(2, this.offset);
if (this.limit !== undefined)
writer.writeUint64(3, this.limit);
if (this.count_total !== undefined)
writer.writeBool(4, this.count_total);
if (this.reverse !== undefined)
writer.writeBool(5, this.reverse);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PageRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PageRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.key = reader.readBytes();
break;
case 2:
message.offset = reader.readUint64();
break;
case 3:
message.limit = reader.readUint64();
break;
case 4:
message.count_total = reader.readBool();
break;
case 5:
message.reverse = reader.readBool();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): PageRequest {
return PageRequest.deserialize(bytes);
}
}
export class PageResponse extends pb_1.Message {
constructor(data?: any[] | {
next_key?: Uint8Array;
total?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("next_key" in data && data.next_key != undefined) {
this.next_key = data.next_key;
}
if ("total" in data && data.total != undefined) {
this.total = data.total;
}
}
}
get next_key() {
return pb_1.Message.getField(this, 1) as Uint8Array;
}
set next_key(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
}
get total() {
return pb_1.Message.getField(this, 2) as number;
}
set total(value: number) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
next_key?: Uint8Array;
total?: number;
}) {
const message = new PageResponse({});
if (data.next_key != null) {
message.next_key = data.next_key;
}
if (data.total != null) {
message.total = data.total;
}
return message;
}
toObject() {
const data: {
next_key?: Uint8Array;
total?: number;
} = {};
if (this.next_key != null) {
data.next_key = this.next_key;
}
if (this.total != null) {
data.total = this.total;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.next_key !== undefined)
writer.writeBytes(1, this.next_key);
if (this.total !== undefined)
writer.writeUint64(2, this.total);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PageResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PageResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.next_key = reader.readBytes();
break;
case 2:
message.total = reader.readUint64();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): PageResponse {
return PageResponse.deserialize(bytes);
}
}
}
+321
View File
@@ -0,0 +1,321 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: cosmos/base/v1beta1/coin.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as pb_1 from "google-protobuf";
export namespace cosmos.base.v1beta1 {
export class Coin extends pb_1.Message {
constructor(data?: any[] | {
denom?: string;
amount?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("denom" in data && data.denom != undefined) {
this.denom = data.denom;
}
if ("amount" in data && data.amount != undefined) {
this.amount = data.amount;
}
}
}
get denom() {
return pb_1.Message.getField(this, 1) as string;
}
set denom(value: string) {
pb_1.Message.setField(this, 1, value);
}
get amount() {
return pb_1.Message.getField(this, 2) as string;
}
set amount(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
denom?: string;
amount?: string;
}) {
const message = new Coin({});
if (data.denom != null) {
message.denom = data.denom;
}
if (data.amount != null) {
message.amount = data.amount;
}
return message;
}
toObject() {
const data: {
denom?: string;
amount?: string;
} = {};
if (this.denom != null) {
data.denom = this.denom;
}
if (this.amount != null) {
data.amount = this.amount;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.denom === "string" && this.denom.length)
writer.writeString(1, this.denom);
if (typeof this.amount === "string" && this.amount.length)
writer.writeString(2, this.amount);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Coin {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Coin();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.denom = reader.readString();
break;
case 2:
message.amount = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Coin {
return Coin.deserialize(bytes);
}
}
export class DecCoin extends pb_1.Message {
constructor(data?: any[] | {
denom?: string;
amount?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("denom" in data && data.denom != undefined) {
this.denom = data.denom;
}
if ("amount" in data && data.amount != undefined) {
this.amount = data.amount;
}
}
}
get denom() {
return pb_1.Message.getField(this, 1) as string;
}
set denom(value: string) {
pb_1.Message.setField(this, 1, value);
}
get amount() {
return pb_1.Message.getField(this, 2) as string;
}
set amount(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
denom?: string;
amount?: string;
}) {
const message = new DecCoin({});
if (data.denom != null) {
message.denom = data.denom;
}
if (data.amount != null) {
message.amount = data.amount;
}
return message;
}
toObject() {
const data: {
denom?: string;
amount?: string;
} = {};
if (this.denom != null) {
data.denom = this.denom;
}
if (this.amount != null) {
data.amount = this.amount;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.denom === "string" && this.denom.length)
writer.writeString(1, this.denom);
if (typeof this.amount === "string" && this.amount.length)
writer.writeString(2, this.amount);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DecCoin {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DecCoin();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.denom = reader.readString();
break;
case 2:
message.amount = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): DecCoin {
return DecCoin.deserialize(bytes);
}
}
export class IntProto extends pb_1.Message {
constructor(data?: any[] | {
int?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("int" in data && data.int != undefined) {
this.int = data.int;
}
}
}
get int() {
return pb_1.Message.getField(this, 1) as string;
}
set int(value: string) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
int?: string;
}) {
const message = new IntProto({});
if (data.int != null) {
message.int = data.int;
}
return message;
}
toObject() {
const data: {
int?: string;
} = {};
if (this.int != null) {
data.int = this.int;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.int === "string" && this.int.length)
writer.writeString(1, this.int);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): IntProto {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new IntProto();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.int = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): IntProto {
return IntProto.deserialize(bytes);
}
}
export class DecProto extends pb_1.Message {
constructor(data?: any[] | {
dec?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("dec" in data && data.dec != undefined) {
this.dec = data.dec;
}
}
}
get dec() {
return pb_1.Message.getField(this, 1) as string;
}
set dec(value: string) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
dec?: string;
}) {
const message = new DecProto({});
if (data.dec != null) {
message.dec = data.dec;
}
return message;
}
toObject() {
const data: {
dec?: string;
} = {};
if (this.dec != null) {
data.dec = this.dec;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.dec === "string" && this.dec.length)
writer.writeString(1, this.dec);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DecProto {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DecProto();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.dec = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): DecProto {
return DecProto.deserialize(bytes);
}
}
}
+9
View File
@@ -0,0 +1,9 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: gogoproto/gogo.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../google/protobuf/descriptor";
export namespace gogoproto { }
+10
View File
@@ -0,0 +1,10 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: google/api/annotations.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./http";
import * as dependency_2 from "./../protobuf/descriptor";
export namespace google.api { }
+511
View File
@@ -0,0 +1,511 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: google/api/http.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export namespace google.api {
export class Http extends pb_1.Message {
constructor(data?: any[] | {
rules?: HttpRule[];
fully_decode_reserved_expansion?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("rules" in data && data.rules != undefined) {
this.rules = data.rules;
}
if ("fully_decode_reserved_expansion" in data && data.fully_decode_reserved_expansion != undefined) {
this.fully_decode_reserved_expansion = data.fully_decode_reserved_expansion;
}
}
}
get rules() {
return pb_1.Message.getRepeatedWrapperField(this, HttpRule, 1) as HttpRule[];
}
set rules(value: HttpRule[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
get fully_decode_reserved_expansion() {
return pb_1.Message.getField(this, 2) as boolean;
}
set fully_decode_reserved_expansion(value: boolean) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
rules?: ReturnType<typeof HttpRule.prototype.toObject>[];
fully_decode_reserved_expansion?: boolean;
}) {
const message = new Http({});
if (data.rules != null) {
message.rules = data.rules.map(item => HttpRule.fromObject(item));
}
if (data.fully_decode_reserved_expansion != null) {
message.fully_decode_reserved_expansion = data.fully_decode_reserved_expansion;
}
return message;
}
toObject() {
const data: {
rules?: ReturnType<typeof HttpRule.prototype.toObject>[];
fully_decode_reserved_expansion?: boolean;
} = {};
if (this.rules != null) {
data.rules = this.rules.map((item: HttpRule) => item.toObject());
}
if (this.fully_decode_reserved_expansion != null) {
data.fully_decode_reserved_expansion = this.fully_decode_reserved_expansion;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.rules !== undefined)
writer.writeRepeatedMessage(1, this.rules, (item: HttpRule) => item.serialize(writer));
if (this.fully_decode_reserved_expansion !== undefined)
writer.writeBool(2, this.fully_decode_reserved_expansion);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Http {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Http();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.rules, () => pb_1.Message.addToRepeatedWrapperField(message, 1, HttpRule.deserialize(reader), HttpRule));
break;
case 2:
message.fully_decode_reserved_expansion = reader.readBool();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Http {
return Http.deserialize(bytes);
}
}
export class HttpRule extends pb_1.Message {
constructor(data?: any[] | ({
selector?: string;
body?: string;
response_body?: string;
additional_bindings?: HttpRule[];
} & (({
get?: string;
put?: never;
post?: never;
delete?: never;
patch?: never;
custom?: never;
} | {
get?: never;
put?: string;
post?: never;
delete?: never;
patch?: never;
custom?: never;
} | {
get?: never;
put?: never;
post?: string;
delete?: never;
patch?: never;
custom?: never;
} | {
get?: never;
put?: never;
post?: never;
delete?: string;
patch?: never;
custom?: never;
} | {
get?: never;
put?: never;
post?: never;
delete?: never;
patch?: string;
custom?: never;
} | {
get?: never;
put?: never;
post?: never;
delete?: never;
patch?: never;
custom?: CustomHttpPattern;
})))) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [11], [[2, 3, 4, 5, 6, 8]]);
if (!Array.isArray(data) && typeof data == "object") {
if ("selector" in data && data.selector != undefined) {
this.selector = data.selector;
}
if ("get" in data && data.get != undefined) {
this.get = data.get;
}
if ("put" in data && data.put != undefined) {
this.put = data.put;
}
if ("post" in data && data.post != undefined) {
this.post = data.post;
}
if ("delete" in data && data.delete != undefined) {
this.delete = data.delete;
}
if ("patch" in data && data.patch != undefined) {
this.patch = data.patch;
}
if ("custom" in data && data.custom != undefined) {
this.custom = data.custom;
}
if ("body" in data && data.body != undefined) {
this.body = data.body;
}
if ("response_body" in data && data.response_body != undefined) {
this.response_body = data.response_body;
}
if ("additional_bindings" in data && data.additional_bindings != undefined) {
this.additional_bindings = data.additional_bindings;
}
}
}
get selector() {
return pb_1.Message.getField(this, 1) as string;
}
set selector(value: string) {
pb_1.Message.setField(this, 1, value);
}
get get() {
return pb_1.Message.getField(this, 2) as string;
}
set get(value: string) {
pb_1.Message.setOneofField(this, 2, [2, 3, 4, 5, 6, 8], value);
}
get put() {
return pb_1.Message.getField(this, 3) as string;
}
set put(value: string) {
pb_1.Message.setOneofField(this, 3, [2, 3, 4, 5, 6, 8], value);
}
get post() {
return pb_1.Message.getField(this, 4) as string;
}
set post(value: string) {
pb_1.Message.setOneofField(this, 4, [2, 3, 4, 5, 6, 8], value);
}
get delete() {
return pb_1.Message.getField(this, 5) as string;
}
set delete(value: string) {
pb_1.Message.setOneofField(this, 5, [2, 3, 4, 5, 6, 8], value);
}
get patch() {
return pb_1.Message.getField(this, 6) as string;
}
set patch(value: string) {
pb_1.Message.setOneofField(this, 6, [2, 3, 4, 5, 6, 8], value);
}
get custom() {
return pb_1.Message.getWrapperField(this, CustomHttpPattern, 8) as CustomHttpPattern;
}
set custom(value: CustomHttpPattern) {
pb_1.Message.setOneofWrapperField(this, 8, [2, 3, 4, 5, 6, 8], value);
}
get body() {
return pb_1.Message.getField(this, 7) as string;
}
set body(value: string) {
pb_1.Message.setField(this, 7, value);
}
get response_body() {
return pb_1.Message.getField(this, 12) as string;
}
set response_body(value: string) {
pb_1.Message.setField(this, 12, value);
}
get additional_bindings() {
return pb_1.Message.getRepeatedWrapperField(this, HttpRule, 11) as HttpRule[];
}
set additional_bindings(value: HttpRule[]) {
pb_1.Message.setRepeatedWrapperField(this, 11, value);
}
get pattern() {
const cases: {
[index: number]: "none" | "get" | "put" | "post" | "delete" | "patch" | "custom";
} = {
0: "none",
2: "get",
3: "put",
4: "post",
5: "delete",
6: "patch",
8: "custom"
};
return cases[pb_1.Message.computeOneofCase(this, [2, 3, 4, 5, 6, 8])];
}
static fromObject(data: {
selector?: string;
get?: string;
put?: string;
post?: string;
delete?: string;
patch?: string;
custom?: ReturnType<typeof CustomHttpPattern.prototype.toObject>;
body?: string;
response_body?: string;
additional_bindings?: ReturnType<typeof HttpRule.prototype.toObject>[];
}) {
const message = new HttpRule({});
if (data.selector != null) {
message.selector = data.selector;
}
if (data.get != null) {
message.get = data.get;
}
if (data.put != null) {
message.put = data.put;
}
if (data.post != null) {
message.post = data.post;
}
if (data.delete != null) {
message.delete = data.delete;
}
if (data.patch != null) {
message.patch = data.patch;
}
if (data.custom != null) {
message.custom = CustomHttpPattern.fromObject(data.custom);
}
if (data.body != null) {
message.body = data.body;
}
if (data.response_body != null) {
message.response_body = data.response_body;
}
if (data.additional_bindings != null) {
message.additional_bindings = data.additional_bindings.map(item => HttpRule.fromObject(item));
}
return message;
}
toObject() {
const data: {
selector?: string;
get?: string;
put?: string;
post?: string;
delete?: string;
patch?: string;
custom?: ReturnType<typeof CustomHttpPattern.prototype.toObject>;
body?: string;
response_body?: string;
additional_bindings?: ReturnType<typeof HttpRule.prototype.toObject>[];
} = {};
if (this.selector != null) {
data.selector = this.selector;
}
if (this.get != null) {
data.get = this.get;
}
if (this.put != null) {
data.put = this.put;
}
if (this.post != null) {
data.post = this.post;
}
if (this.delete != null) {
data.delete = this.delete;
}
if (this.patch != null) {
data.patch = this.patch;
}
if (this.custom != null) {
data.custom = this.custom.toObject();
}
if (this.body != null) {
data.body = this.body;
}
if (this.response_body != null) {
data.response_body = this.response_body;
}
if (this.additional_bindings != null) {
data.additional_bindings = this.additional_bindings.map((item: HttpRule) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.selector === "string" && this.selector.length)
writer.writeString(1, this.selector);
if (typeof this.get === "string" && this.get.length)
writer.writeString(2, this.get);
if (typeof this.put === "string" && this.put.length)
writer.writeString(3, this.put);
if (typeof this.post === "string" && this.post.length)
writer.writeString(4, this.post);
if (typeof this.delete === "string" && this.delete.length)
writer.writeString(5, this.delete);
if (typeof this.patch === "string" && this.patch.length)
writer.writeString(6, this.patch);
if (this.custom !== undefined)
writer.writeMessage(8, this.custom, () => this.custom.serialize(writer));
if (typeof this.body === "string" && this.body.length)
writer.writeString(7, this.body);
if (typeof this.response_body === "string" && this.response_body.length)
writer.writeString(12, this.response_body);
if (this.additional_bindings !== undefined)
writer.writeRepeatedMessage(11, this.additional_bindings, (item: HttpRule) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): HttpRule {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new HttpRule();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.selector = reader.readString();
break;
case 2:
message.get = reader.readString();
break;
case 3:
message.put = reader.readString();
break;
case 4:
message.post = reader.readString();
break;
case 5:
message.delete = reader.readString();
break;
case 6:
message.patch = reader.readString();
break;
case 8:
reader.readMessage(message.custom, () => message.custom = CustomHttpPattern.deserialize(reader));
break;
case 7:
message.body = reader.readString();
break;
case 12:
message.response_body = reader.readString();
break;
case 11:
reader.readMessage(message.additional_bindings, () => pb_1.Message.addToRepeatedWrapperField(message, 11, HttpRule.deserialize(reader), HttpRule));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): HttpRule {
return HttpRule.deserialize(bytes);
}
}
export class CustomHttpPattern extends pb_1.Message {
constructor(data?: any[] | {
kind?: string;
path?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("kind" in data && data.kind != undefined) {
this.kind = data.kind;
}
if ("path" in data && data.path != undefined) {
this.path = data.path;
}
}
}
get kind() {
return pb_1.Message.getField(this, 1) as string;
}
set kind(value: string) {
pb_1.Message.setField(this, 1, value);
}
get path() {
return pb_1.Message.getField(this, 2) as string;
}
set path(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
kind?: string;
path?: string;
}) {
const message = new CustomHttpPattern({});
if (data.kind != null) {
message.kind = data.kind;
}
if (data.path != null) {
message.path = data.path;
}
return message;
}
toObject() {
const data: {
kind?: string;
path?: string;
} = {};
if (this.kind != null) {
data.kind = this.kind;
}
if (this.path != null) {
data.path = this.path;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.kind === "string" && this.kind.length)
writer.writeString(1, this.kind);
if (typeof this.path === "string" && this.path.length)
writer.writeString(2, this.path);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CustomHttpPattern {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CustomHttpPattern();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.kind = reader.readString();
break;
case 2:
message.path = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CustomHttpPattern {
return CustomHttpPattern.deserialize(bytes);
}
}
}
File diff suppressed because it is too large Load Diff
+99
View File
@@ -0,0 +1,99 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: google/protobuf/duration.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export namespace google.protobuf {
export class Duration extends pb_1.Message {
constructor(data?: any[] | {
seconds?: number;
nanos?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("seconds" in data && data.seconds != undefined) {
this.seconds = data.seconds;
}
if ("nanos" in data && data.nanos != undefined) {
this.nanos = data.nanos;
}
}
}
get seconds() {
return pb_1.Message.getField(this, 1) as number;
}
set seconds(value: number) {
pb_1.Message.setField(this, 1, value);
}
get nanos() {
return pb_1.Message.getField(this, 2) as number;
}
set nanos(value: number) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
seconds?: number;
nanos?: number;
}) {
const message = new Duration({});
if (data.seconds != null) {
message.seconds = data.seconds;
}
if (data.nanos != null) {
message.nanos = data.nanos;
}
return message;
}
toObject() {
const data: {
seconds?: number;
nanos?: number;
} = {};
if (this.seconds != null) {
data.seconds = this.seconds;
}
if (this.nanos != null) {
data.nanos = this.nanos;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.seconds !== undefined)
writer.writeInt64(1, this.seconds);
if (this.nanos !== undefined)
writer.writeInt32(2, this.nanos);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Duration {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Duration();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.seconds = reader.readInt64();
break;
case 2:
message.nanos = reader.readInt32();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Duration {
return Duration.deserialize(bytes);
}
}
}
+99
View File
@@ -0,0 +1,99 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: google/protobuf/timestamp.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as pb_1 from "google-protobuf";
export namespace google.protobuf {
export class Timestamp extends pb_1.Message {
constructor(data?: any[] | {
seconds?: number;
nanos?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("seconds" in data && data.seconds != undefined) {
this.seconds = data.seconds;
}
if ("nanos" in data && data.nanos != undefined) {
this.nanos = data.nanos;
}
}
}
get seconds() {
return pb_1.Message.getField(this, 1) as number;
}
set seconds(value: number) {
pb_1.Message.setField(this, 1, value);
}
get nanos() {
return pb_1.Message.getField(this, 2) as number;
}
set nanos(value: number) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
seconds?: number;
nanos?: number;
}) {
const message = new Timestamp({});
if (data.seconds != null) {
message.seconds = data.seconds;
}
if (data.nanos != null) {
message.nanos = data.nanos;
}
return message;
}
toObject() {
const data: {
seconds?: number;
nanos?: number;
} = {};
if (this.seconds != null) {
data.seconds = this.seconds;
}
if (this.nanos != null) {
data.nanos = this.nanos;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.seconds !== undefined)
writer.writeInt64(1, this.seconds);
if (this.nanos !== undefined)
writer.writeInt32(2, this.nanos);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Timestamp {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Timestamp();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.seconds = reader.readInt64();
break;
case 2:
message.nanos = reader.readInt32();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Timestamp {
return Timestamp.deserialize(bytes);
}
}
}
@@ -0,0 +1,101 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/auction/v1beta1/genesis.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./types";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.auction.v1beta1 {
export class GenesisState extends pb_1.Message {
constructor(data?: any[] | {
params?: dependency_2.vulcanize.auction.v1beta1.Params;
auctions?: dependency_2.vulcanize.auction.v1beta1.Auction[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("params" in data && data.params != undefined) {
this.params = data.params;
}
if ("auctions" in data && data.auctions != undefined) {
this.auctions = data.auctions;
}
}
}
get params() {
return pb_1.Message.getWrapperField(this, dependency_2.vulcanize.auction.v1beta1.Params, 1) as dependency_2.vulcanize.auction.v1beta1.Params;
}
set params(value: dependency_2.vulcanize.auction.v1beta1.Params) {
pb_1.Message.setWrapperField(this, 1, value);
}
get auctions() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.auction.v1beta1.Auction, 2) as dependency_2.vulcanize.auction.v1beta1.Auction[];
}
set auctions(value: dependency_2.vulcanize.auction.v1beta1.Auction[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
static fromObject(data: {
params?: ReturnType<typeof dependency_2.vulcanize.auction.v1beta1.Params.prototype.toObject>;
auctions?: ReturnType<typeof dependency_2.vulcanize.auction.v1beta1.Auction.prototype.toObject>[];
}) {
const message = new GenesisState({});
if (data.params != null) {
message.params = dependency_2.vulcanize.auction.v1beta1.Params.fromObject(data.params);
}
if (data.auctions != null) {
message.auctions = data.auctions.map(item => dependency_2.vulcanize.auction.v1beta1.Auction.fromObject(item));
}
return message;
}
toObject() {
const data: {
params?: ReturnType<typeof dependency_2.vulcanize.auction.v1beta1.Params.prototype.toObject>;
auctions?: ReturnType<typeof dependency_2.vulcanize.auction.v1beta1.Auction.prototype.toObject>[];
} = {};
if (this.params != null) {
data.params = this.params.toObject();
}
if (this.auctions != null) {
data.auctions = this.auctions.map((item: dependency_2.vulcanize.auction.v1beta1.Auction) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.params !== undefined)
writer.writeMessage(1, this.params, () => this.params.serialize(writer));
if (this.auctions !== undefined)
writer.writeRepeatedMessage(2, this.auctions, (item: dependency_2.vulcanize.auction.v1beta1.Auction) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GenesisState {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GenesisState();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.params, () => message.params = dependency_2.vulcanize.auction.v1beta1.Params.deserialize(reader));
break;
case 2:
reader.readMessage(message.auctions, () => pb_1.Message.addToRepeatedWrapperField(message, 2, dependency_2.vulcanize.auction.v1beta1.Auction.deserialize(reader), dependency_2.vulcanize.auction.v1beta1.Auction));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GenesisState {
return GenesisState.deserialize(bytes);
}
}
}
File diff suppressed because it is too large Load Diff
+617
View File
@@ -0,0 +1,617 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/auction/v1beta1/tx.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./../../../google/protobuf/duration";
import * as dependency_3 from "./../../../cosmos/base/v1beta1/coin";
import * as dependency_4 from "./types";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.auction.v1beta1 {
export class MsgCreateAuction extends pb_1.Message {
constructor(data?: any[] | {
commits_duration?: dependency_2.google.protobuf.Duration;
reveals_duration?: dependency_2.google.protobuf.Duration;
commit_fee?: dependency_3.cosmos.base.v1beta1.Coin;
reveal_fee?: dependency_3.cosmos.base.v1beta1.Coin;
minimum_bid?: dependency_3.cosmos.base.v1beta1.Coin;
signer?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("commits_duration" in data && data.commits_duration != undefined) {
this.commits_duration = data.commits_duration;
}
if ("reveals_duration" in data && data.reveals_duration != undefined) {
this.reveals_duration = data.reveals_duration;
}
if ("commit_fee" in data && data.commit_fee != undefined) {
this.commit_fee = data.commit_fee;
}
if ("reveal_fee" in data && data.reveal_fee != undefined) {
this.reveal_fee = data.reveal_fee;
}
if ("minimum_bid" in data && data.minimum_bid != undefined) {
this.minimum_bid = data.minimum_bid;
}
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
}
}
get commits_duration() {
return pb_1.Message.getWrapperField(this, dependency_2.google.protobuf.Duration, 1) as dependency_2.google.protobuf.Duration;
}
set commits_duration(value: dependency_2.google.protobuf.Duration) {
pb_1.Message.setWrapperField(this, 1, value);
}
get reveals_duration() {
return pb_1.Message.getWrapperField(this, dependency_2.google.protobuf.Duration, 2) as dependency_2.google.protobuf.Duration;
}
set reveals_duration(value: dependency_2.google.protobuf.Duration) {
pb_1.Message.setWrapperField(this, 2, value);
}
get commit_fee() {
return pb_1.Message.getWrapperField(this, dependency_3.cosmos.base.v1beta1.Coin, 3) as dependency_3.cosmos.base.v1beta1.Coin;
}
set commit_fee(value: dependency_3.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 3, value);
}
get reveal_fee() {
return pb_1.Message.getWrapperField(this, dependency_3.cosmos.base.v1beta1.Coin, 4) as dependency_3.cosmos.base.v1beta1.Coin;
}
set reveal_fee(value: dependency_3.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 4, value);
}
get minimum_bid() {
return pb_1.Message.getWrapperField(this, dependency_3.cosmos.base.v1beta1.Coin, 5) as dependency_3.cosmos.base.v1beta1.Coin;
}
set minimum_bid(value: dependency_3.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 5, value);
}
get signer() {
return pb_1.Message.getField(this, 6) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 6, value);
}
static fromObject(data: {
commits_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
reveals_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_3.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_3.cosmos.base.v1beta1.Coin.prototype.toObject>;
minimum_bid?: ReturnType<typeof dependency_3.cosmos.base.v1beta1.Coin.prototype.toObject>;
signer?: string;
}) {
const message = new MsgCreateAuction({});
if (data.commits_duration != null) {
message.commits_duration = dependency_2.google.protobuf.Duration.fromObject(data.commits_duration);
}
if (data.reveals_duration != null) {
message.reveals_duration = dependency_2.google.protobuf.Duration.fromObject(data.reveals_duration);
}
if (data.commit_fee != null) {
message.commit_fee = dependency_3.cosmos.base.v1beta1.Coin.fromObject(data.commit_fee);
}
if (data.reveal_fee != null) {
message.reveal_fee = dependency_3.cosmos.base.v1beta1.Coin.fromObject(data.reveal_fee);
}
if (data.minimum_bid != null) {
message.minimum_bid = dependency_3.cosmos.base.v1beta1.Coin.fromObject(data.minimum_bid);
}
if (data.signer != null) {
message.signer = data.signer;
}
return message;
}
toObject() {
const data: {
commits_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
reveals_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_3.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_3.cosmos.base.v1beta1.Coin.prototype.toObject>;
minimum_bid?: ReturnType<typeof dependency_3.cosmos.base.v1beta1.Coin.prototype.toObject>;
signer?: string;
} = {};
if (this.commits_duration != null) {
data.commits_duration = this.commits_duration.toObject();
}
if (this.reveals_duration != null) {
data.reveals_duration = this.reveals_duration.toObject();
}
if (this.commit_fee != null) {
data.commit_fee = this.commit_fee.toObject();
}
if (this.reveal_fee != null) {
data.reveal_fee = this.reveal_fee.toObject();
}
if (this.minimum_bid != null) {
data.minimum_bid = this.minimum_bid.toObject();
}
if (this.signer != null) {
data.signer = this.signer;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.commits_duration !== undefined)
writer.writeMessage(1, this.commits_duration, () => this.commits_duration.serialize(writer));
if (this.reveals_duration !== undefined)
writer.writeMessage(2, this.reveals_duration, () => this.reveals_duration.serialize(writer));
if (this.commit_fee !== undefined)
writer.writeMessage(3, this.commit_fee, () => this.commit_fee.serialize(writer));
if (this.reveal_fee !== undefined)
writer.writeMessage(4, this.reveal_fee, () => this.reveal_fee.serialize(writer));
if (this.minimum_bid !== undefined)
writer.writeMessage(5, this.minimum_bid, () => this.minimum_bid.serialize(writer));
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(6, this.signer);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCreateAuction {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCreateAuction();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.commits_duration, () => message.commits_duration = dependency_2.google.protobuf.Duration.deserialize(reader));
break;
case 2:
reader.readMessage(message.reveals_duration, () => message.reveals_duration = dependency_2.google.protobuf.Duration.deserialize(reader));
break;
case 3:
reader.readMessage(message.commit_fee, () => message.commit_fee = dependency_3.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 4:
reader.readMessage(message.reveal_fee, () => message.reveal_fee = dependency_3.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 5:
reader.readMessage(message.minimum_bid, () => message.minimum_bid = dependency_3.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 6:
message.signer = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCreateAuction {
return MsgCreateAuction.deserialize(bytes);
}
}
export class MsgCreateAuctionResponse extends pb_1.Message {
constructor(data?: any[] | {
auction?: dependency_4.vulcanize.auction.v1beta1.Auction;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("auction" in data && data.auction != undefined) {
this.auction = data.auction;
}
}
}
get auction() {
return pb_1.Message.getWrapperField(this, dependency_4.vulcanize.auction.v1beta1.Auction, 1) as dependency_4.vulcanize.auction.v1beta1.Auction;
}
set auction(value: dependency_4.vulcanize.auction.v1beta1.Auction) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
auction?: ReturnType<typeof dependency_4.vulcanize.auction.v1beta1.Auction.prototype.toObject>;
}) {
const message = new MsgCreateAuctionResponse({});
if (data.auction != null) {
message.auction = dependency_4.vulcanize.auction.v1beta1.Auction.fromObject(data.auction);
}
return message;
}
toObject() {
const data: {
auction?: ReturnType<typeof dependency_4.vulcanize.auction.v1beta1.Auction.prototype.toObject>;
} = {};
if (this.auction != null) {
data.auction = this.auction.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.auction !== undefined)
writer.writeMessage(1, this.auction, () => this.auction.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCreateAuctionResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCreateAuctionResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.auction, () => message.auction = dependency_4.vulcanize.auction.v1beta1.Auction.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCreateAuctionResponse {
return MsgCreateAuctionResponse.deserialize(bytes);
}
}
export class MsgCommitBid extends pb_1.Message {
constructor(data?: any[] | {
auction_id?: string;
commit_hash?: string;
signer?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("auction_id" in data && data.auction_id != undefined) {
this.auction_id = data.auction_id;
}
if ("commit_hash" in data && data.commit_hash != undefined) {
this.commit_hash = data.commit_hash;
}
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
}
}
get auction_id() {
return pb_1.Message.getField(this, 1) as string;
}
set auction_id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get commit_hash() {
return pb_1.Message.getField(this, 2) as string;
}
set commit_hash(value: string) {
pb_1.Message.setField(this, 2, value);
}
get signer() {
return pb_1.Message.getField(this, 3) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
auction_id?: string;
commit_hash?: string;
signer?: string;
}) {
const message = new MsgCommitBid({});
if (data.auction_id != null) {
message.auction_id = data.auction_id;
}
if (data.commit_hash != null) {
message.commit_hash = data.commit_hash;
}
if (data.signer != null) {
message.signer = data.signer;
}
return message;
}
toObject() {
const data: {
auction_id?: string;
commit_hash?: string;
signer?: string;
} = {};
if (this.auction_id != null) {
data.auction_id = this.auction_id;
}
if (this.commit_hash != null) {
data.commit_hash = this.commit_hash;
}
if (this.signer != null) {
data.signer = this.signer;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.auction_id === "string" && this.auction_id.length)
writer.writeString(1, this.auction_id);
if (typeof this.commit_hash === "string" && this.commit_hash.length)
writer.writeString(2, this.commit_hash);
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(3, this.signer);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCommitBid {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCommitBid();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.auction_id = reader.readString();
break;
case 2:
message.commit_hash = reader.readString();
break;
case 3:
message.signer = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCommitBid {
return MsgCommitBid.deserialize(bytes);
}
}
export class MsgRevealBid extends pb_1.Message {
constructor(data?: any[] | {
auction_id?: string;
reveal?: string;
signer?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("auction_id" in data && data.auction_id != undefined) {
this.auction_id = data.auction_id;
}
if ("reveal" in data && data.reveal != undefined) {
this.reveal = data.reveal;
}
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
}
}
get auction_id() {
return pb_1.Message.getField(this, 1) as string;
}
set auction_id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get reveal() {
return pb_1.Message.getField(this, 2) as string;
}
set reveal(value: string) {
pb_1.Message.setField(this, 2, value);
}
get signer() {
return pb_1.Message.getField(this, 3) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
auction_id?: string;
reveal?: string;
signer?: string;
}) {
const message = new MsgRevealBid({});
if (data.auction_id != null) {
message.auction_id = data.auction_id;
}
if (data.reveal != null) {
message.reveal = data.reveal;
}
if (data.signer != null) {
message.signer = data.signer;
}
return message;
}
toObject() {
const data: {
auction_id?: string;
reveal?: string;
signer?: string;
} = {};
if (this.auction_id != null) {
data.auction_id = this.auction_id;
}
if (this.reveal != null) {
data.reveal = this.reveal;
}
if (this.signer != null) {
data.signer = this.signer;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.auction_id === "string" && this.auction_id.length)
writer.writeString(1, this.auction_id);
if (typeof this.reveal === "string" && this.reveal.length)
writer.writeString(2, this.reveal);
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(3, this.signer);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgRevealBid {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgRevealBid();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.auction_id = reader.readString();
break;
case 2:
message.reveal = reader.readString();
break;
case 3:
message.signer = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgRevealBid {
return MsgRevealBid.deserialize(bytes);
}
}
export class MsgCommitBidResponse extends pb_1.Message {
constructor(data?: any[] | {
bid?: dependency_4.vulcanize.auction.v1beta1.Bid;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("bid" in data && data.bid != undefined) {
this.bid = data.bid;
}
}
}
get bid() {
return pb_1.Message.getWrapperField(this, dependency_4.vulcanize.auction.v1beta1.Bid, 1) as dependency_4.vulcanize.auction.v1beta1.Bid;
}
set bid(value: dependency_4.vulcanize.auction.v1beta1.Bid) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
bid?: ReturnType<typeof dependency_4.vulcanize.auction.v1beta1.Bid.prototype.toObject>;
}) {
const message = new MsgCommitBidResponse({});
if (data.bid != null) {
message.bid = dependency_4.vulcanize.auction.v1beta1.Bid.fromObject(data.bid);
}
return message;
}
toObject() {
const data: {
bid?: ReturnType<typeof dependency_4.vulcanize.auction.v1beta1.Bid.prototype.toObject>;
} = {};
if (this.bid != null) {
data.bid = this.bid.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.bid !== undefined)
writer.writeMessage(1, this.bid, () => this.bid.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCommitBidResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCommitBidResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.bid, () => message.bid = dependency_4.vulcanize.auction.v1beta1.Bid.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCommitBidResponse {
return MsgCommitBidResponse.deserialize(bytes);
}
}
export class MsgRevealBidResponse extends pb_1.Message {
constructor(data?: any[] | {
auction?: dependency_4.vulcanize.auction.v1beta1.Auction;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("auction" in data && data.auction != undefined) {
this.auction = data.auction;
}
}
}
get auction() {
return pb_1.Message.getWrapperField(this, dependency_4.vulcanize.auction.v1beta1.Auction, 1) as dependency_4.vulcanize.auction.v1beta1.Auction;
}
set auction(value: dependency_4.vulcanize.auction.v1beta1.Auction) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
auction?: ReturnType<typeof dependency_4.vulcanize.auction.v1beta1.Auction.prototype.toObject>;
}) {
const message = new MsgRevealBidResponse({});
if (data.auction != null) {
message.auction = dependency_4.vulcanize.auction.v1beta1.Auction.fromObject(data.auction);
}
return message;
}
toObject() {
const data: {
auction?: ReturnType<typeof dependency_4.vulcanize.auction.v1beta1.Auction.prototype.toObject>;
} = {};
if (this.auction != null) {
data.auction = this.auction.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.auction !== undefined)
writer.writeMessage(1, this.auction, () => this.auction.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgRevealBidResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgRevealBidResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.auction, () => message.auction = dependency_4.vulcanize.auction.v1beta1.Auction.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgRevealBidResponse {
return MsgRevealBidResponse.deserialize(bytes);
}
}
}
@@ -0,0 +1,807 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/auction/v1beta1/types.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./../../../google/protobuf/duration";
import * as dependency_3 from "./../../../google/protobuf/timestamp";
import * as dependency_4 from "./../../../cosmos/base/v1beta1/coin";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.auction.v1beta1 {
export class Params extends pb_1.Message {
constructor(data?: any[] | {
commits_duration?: dependency_2.google.protobuf.Duration;
reveals_duration?: dependency_2.google.protobuf.Duration;
commit_fee?: dependency_4.cosmos.base.v1beta1.Coin;
reveal_fee?: dependency_4.cosmos.base.v1beta1.Coin;
minimum_bid?: dependency_4.cosmos.base.v1beta1.Coin;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("commits_duration" in data && data.commits_duration != undefined) {
this.commits_duration = data.commits_duration;
}
if ("reveals_duration" in data && data.reveals_duration != undefined) {
this.reveals_duration = data.reveals_duration;
}
if ("commit_fee" in data && data.commit_fee != undefined) {
this.commit_fee = data.commit_fee;
}
if ("reveal_fee" in data && data.reveal_fee != undefined) {
this.reveal_fee = data.reveal_fee;
}
if ("minimum_bid" in data && data.minimum_bid != undefined) {
this.minimum_bid = data.minimum_bid;
}
}
}
get commits_duration() {
return pb_1.Message.getWrapperField(this, dependency_2.google.protobuf.Duration, 1) as dependency_2.google.protobuf.Duration;
}
set commits_duration(value: dependency_2.google.protobuf.Duration) {
pb_1.Message.setWrapperField(this, 1, value);
}
get reveals_duration() {
return pb_1.Message.getWrapperField(this, dependency_2.google.protobuf.Duration, 2) as dependency_2.google.protobuf.Duration;
}
set reveals_duration(value: dependency_2.google.protobuf.Duration) {
pb_1.Message.setWrapperField(this, 2, value);
}
get commit_fee() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 3) as dependency_4.cosmos.base.v1beta1.Coin;
}
set commit_fee(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 3, value);
}
get reveal_fee() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 4) as dependency_4.cosmos.base.v1beta1.Coin;
}
set reveal_fee(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 4, value);
}
get minimum_bid() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 5) as dependency_4.cosmos.base.v1beta1.Coin;
}
set minimum_bid(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 5, value);
}
static fromObject(data: {
commits_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
reveals_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
minimum_bid?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
}) {
const message = new Params({});
if (data.commits_duration != null) {
message.commits_duration = dependency_2.google.protobuf.Duration.fromObject(data.commits_duration);
}
if (data.reveals_duration != null) {
message.reveals_duration = dependency_2.google.protobuf.Duration.fromObject(data.reveals_duration);
}
if (data.commit_fee != null) {
message.commit_fee = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.commit_fee);
}
if (data.reveal_fee != null) {
message.reveal_fee = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.reveal_fee);
}
if (data.minimum_bid != null) {
message.minimum_bid = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.minimum_bid);
}
return message;
}
toObject() {
const data: {
commits_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
reveals_duration?: ReturnType<typeof dependency_2.google.protobuf.Duration.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
minimum_bid?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
} = {};
if (this.commits_duration != null) {
data.commits_duration = this.commits_duration.toObject();
}
if (this.reveals_duration != null) {
data.reveals_duration = this.reveals_duration.toObject();
}
if (this.commit_fee != null) {
data.commit_fee = this.commit_fee.toObject();
}
if (this.reveal_fee != null) {
data.reveal_fee = this.reveal_fee.toObject();
}
if (this.minimum_bid != null) {
data.minimum_bid = this.minimum_bid.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.commits_duration !== undefined)
writer.writeMessage(1, this.commits_duration, () => this.commits_duration.serialize(writer));
if (this.reveals_duration !== undefined)
writer.writeMessage(2, this.reveals_duration, () => this.reveals_duration.serialize(writer));
if (this.commit_fee !== undefined)
writer.writeMessage(3, this.commit_fee, () => this.commit_fee.serialize(writer));
if (this.reveal_fee !== undefined)
writer.writeMessage(4, this.reveal_fee, () => this.reveal_fee.serialize(writer));
if (this.minimum_bid !== undefined)
writer.writeMessage(5, this.minimum_bid, () => this.minimum_bid.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Params {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Params();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.commits_duration, () => message.commits_duration = dependency_2.google.protobuf.Duration.deserialize(reader));
break;
case 2:
reader.readMessage(message.reveals_duration, () => message.reveals_duration = dependency_2.google.protobuf.Duration.deserialize(reader));
break;
case 3:
reader.readMessage(message.commit_fee, () => message.commit_fee = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 4:
reader.readMessage(message.reveal_fee, () => message.reveal_fee = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 5:
reader.readMessage(message.minimum_bid, () => message.minimum_bid = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Params {
return Params.deserialize(bytes);
}
}
export class Auction extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
status?: string;
owner_address?: string;
create_time?: dependency_3.google.protobuf.Timestamp;
commits_end_time?: dependency_3.google.protobuf.Timestamp;
reveals_end_time?: dependency_3.google.protobuf.Timestamp;
commit_fee?: dependency_4.cosmos.base.v1beta1.Coin;
reveal_fee?: dependency_4.cosmos.base.v1beta1.Coin;
minimum_bid?: dependency_4.cosmos.base.v1beta1.Coin;
winner_address?: string;
winning_bid?: dependency_4.cosmos.base.v1beta1.Coin;
winning_price?: dependency_4.cosmos.base.v1beta1.Coin;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("status" in data && data.status != undefined) {
this.status = data.status;
}
if ("owner_address" in data && data.owner_address != undefined) {
this.owner_address = data.owner_address;
}
if ("create_time" in data && data.create_time != undefined) {
this.create_time = data.create_time;
}
if ("commits_end_time" in data && data.commits_end_time != undefined) {
this.commits_end_time = data.commits_end_time;
}
if ("reveals_end_time" in data && data.reveals_end_time != undefined) {
this.reveals_end_time = data.reveals_end_time;
}
if ("commit_fee" in data && data.commit_fee != undefined) {
this.commit_fee = data.commit_fee;
}
if ("reveal_fee" in data && data.reveal_fee != undefined) {
this.reveal_fee = data.reveal_fee;
}
if ("minimum_bid" in data && data.minimum_bid != undefined) {
this.minimum_bid = data.minimum_bid;
}
if ("winner_address" in data && data.winner_address != undefined) {
this.winner_address = data.winner_address;
}
if ("winning_bid" in data && data.winning_bid != undefined) {
this.winning_bid = data.winning_bid;
}
if ("winning_price" in data && data.winning_price != undefined) {
this.winning_price = data.winning_price;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get status() {
return pb_1.Message.getField(this, 2) as string;
}
set status(value: string) {
pb_1.Message.setField(this, 2, value);
}
get owner_address() {
return pb_1.Message.getField(this, 3) as string;
}
set owner_address(value: string) {
pb_1.Message.setField(this, 3, value);
}
get create_time() {
return pb_1.Message.getWrapperField(this, dependency_3.google.protobuf.Timestamp, 4) as dependency_3.google.protobuf.Timestamp;
}
set create_time(value: dependency_3.google.protobuf.Timestamp) {
pb_1.Message.setWrapperField(this, 4, value);
}
get commits_end_time() {
return pb_1.Message.getWrapperField(this, dependency_3.google.protobuf.Timestamp, 5) as dependency_3.google.protobuf.Timestamp;
}
set commits_end_time(value: dependency_3.google.protobuf.Timestamp) {
pb_1.Message.setWrapperField(this, 5, value);
}
get reveals_end_time() {
return pb_1.Message.getWrapperField(this, dependency_3.google.protobuf.Timestamp, 6) as dependency_3.google.protobuf.Timestamp;
}
set reveals_end_time(value: dependency_3.google.protobuf.Timestamp) {
pb_1.Message.setWrapperField(this, 6, value);
}
get commit_fee() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 7) as dependency_4.cosmos.base.v1beta1.Coin;
}
set commit_fee(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 7, value);
}
get reveal_fee() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 8) as dependency_4.cosmos.base.v1beta1.Coin;
}
set reveal_fee(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 8, value);
}
get minimum_bid() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 9) as dependency_4.cosmos.base.v1beta1.Coin;
}
set minimum_bid(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 9, value);
}
get winner_address() {
return pb_1.Message.getField(this, 10) as string;
}
set winner_address(value: string) {
pb_1.Message.setField(this, 10, value);
}
get winning_bid() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 11) as dependency_4.cosmos.base.v1beta1.Coin;
}
set winning_bid(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 11, value);
}
get winning_price() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 12) as dependency_4.cosmos.base.v1beta1.Coin;
}
set winning_price(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 12, value);
}
static fromObject(data: {
id?: string;
status?: string;
owner_address?: string;
create_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
commits_end_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
reveals_end_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
minimum_bid?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
winner_address?: string;
winning_bid?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
winning_price?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
}) {
const message = new Auction({});
if (data.id != null) {
message.id = data.id;
}
if (data.status != null) {
message.status = data.status;
}
if (data.owner_address != null) {
message.owner_address = data.owner_address;
}
if (data.create_time != null) {
message.create_time = dependency_3.google.protobuf.Timestamp.fromObject(data.create_time);
}
if (data.commits_end_time != null) {
message.commits_end_time = dependency_3.google.protobuf.Timestamp.fromObject(data.commits_end_time);
}
if (data.reveals_end_time != null) {
message.reveals_end_time = dependency_3.google.protobuf.Timestamp.fromObject(data.reveals_end_time);
}
if (data.commit_fee != null) {
message.commit_fee = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.commit_fee);
}
if (data.reveal_fee != null) {
message.reveal_fee = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.reveal_fee);
}
if (data.minimum_bid != null) {
message.minimum_bid = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.minimum_bid);
}
if (data.winner_address != null) {
message.winner_address = data.winner_address;
}
if (data.winning_bid != null) {
message.winning_bid = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.winning_bid);
}
if (data.winning_price != null) {
message.winning_price = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.winning_price);
}
return message;
}
toObject() {
const data: {
id?: string;
status?: string;
owner_address?: string;
create_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
commits_end_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
reveals_end_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
minimum_bid?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
winner_address?: string;
winning_bid?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
winning_price?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.status != null) {
data.status = this.status;
}
if (this.owner_address != null) {
data.owner_address = this.owner_address;
}
if (this.create_time != null) {
data.create_time = this.create_time.toObject();
}
if (this.commits_end_time != null) {
data.commits_end_time = this.commits_end_time.toObject();
}
if (this.reveals_end_time != null) {
data.reveals_end_time = this.reveals_end_time.toObject();
}
if (this.commit_fee != null) {
data.commit_fee = this.commit_fee.toObject();
}
if (this.reveal_fee != null) {
data.reveal_fee = this.reveal_fee.toObject();
}
if (this.minimum_bid != null) {
data.minimum_bid = this.minimum_bid.toObject();
}
if (this.winner_address != null) {
data.winner_address = this.winner_address;
}
if (this.winning_bid != null) {
data.winning_bid = this.winning_bid.toObject();
}
if (this.winning_price != null) {
data.winning_price = this.winning_price.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (typeof this.status === "string" && this.status.length)
writer.writeString(2, this.status);
if (typeof this.owner_address === "string" && this.owner_address.length)
writer.writeString(3, this.owner_address);
if (this.create_time !== undefined)
writer.writeMessage(4, this.create_time, () => this.create_time.serialize(writer));
if (this.commits_end_time !== undefined)
writer.writeMessage(5, this.commits_end_time, () => this.commits_end_time.serialize(writer));
if (this.reveals_end_time !== undefined)
writer.writeMessage(6, this.reveals_end_time, () => this.reveals_end_time.serialize(writer));
if (this.commit_fee !== undefined)
writer.writeMessage(7, this.commit_fee, () => this.commit_fee.serialize(writer));
if (this.reveal_fee !== undefined)
writer.writeMessage(8, this.reveal_fee, () => this.reveal_fee.serialize(writer));
if (this.minimum_bid !== undefined)
writer.writeMessage(9, this.minimum_bid, () => this.minimum_bid.serialize(writer));
if (typeof this.winner_address === "string" && this.winner_address.length)
writer.writeString(10, this.winner_address);
if (this.winning_bid !== undefined)
writer.writeMessage(11, this.winning_bid, () => this.winning_bid.serialize(writer));
if (this.winning_price !== undefined)
writer.writeMessage(12, this.winning_price, () => this.winning_price.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Auction {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Auction();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.status = reader.readString();
break;
case 3:
message.owner_address = reader.readString();
break;
case 4:
reader.readMessage(message.create_time, () => message.create_time = dependency_3.google.protobuf.Timestamp.deserialize(reader));
break;
case 5:
reader.readMessage(message.commits_end_time, () => message.commits_end_time = dependency_3.google.protobuf.Timestamp.deserialize(reader));
break;
case 6:
reader.readMessage(message.reveals_end_time, () => message.reveals_end_time = dependency_3.google.protobuf.Timestamp.deserialize(reader));
break;
case 7:
reader.readMessage(message.commit_fee, () => message.commit_fee = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 8:
reader.readMessage(message.reveal_fee, () => message.reveal_fee = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 9:
reader.readMessage(message.minimum_bid, () => message.minimum_bid = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 10:
message.winner_address = reader.readString();
break;
case 11:
reader.readMessage(message.winning_bid, () => message.winning_bid = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 12:
reader.readMessage(message.winning_price, () => message.winning_price = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Auction {
return Auction.deserialize(bytes);
}
}
export class Auctions extends pb_1.Message {
constructor(data?: any[] | {
auctions?: Auction[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("auctions" in data && data.auctions != undefined) {
this.auctions = data.auctions;
}
}
}
get auctions() {
return pb_1.Message.getRepeatedWrapperField(this, Auction, 1) as Auction[];
}
set auctions(value: Auction[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
static fromObject(data: {
auctions?: ReturnType<typeof Auction.prototype.toObject>[];
}) {
const message = new Auctions({});
if (data.auctions != null) {
message.auctions = data.auctions.map(item => Auction.fromObject(item));
}
return message;
}
toObject() {
const data: {
auctions?: ReturnType<typeof Auction.prototype.toObject>[];
} = {};
if (this.auctions != null) {
data.auctions = this.auctions.map((item: Auction) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.auctions !== undefined)
writer.writeRepeatedMessage(1, this.auctions, (item: Auction) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Auctions {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Auctions();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.auctions, () => pb_1.Message.addToRepeatedWrapperField(message, 1, Auction.deserialize(reader), Auction));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Auctions {
return Auctions.deserialize(bytes);
}
}
export class Bid extends pb_1.Message {
constructor(data?: any[] | {
auction_id?: string;
bidder_address?: string;
status?: string;
commit_hash?: string;
commit_time?: dependency_3.google.protobuf.Timestamp;
commit_fee?: dependency_4.cosmos.base.v1beta1.Coin;
reveal_time?: dependency_3.google.protobuf.Timestamp;
reveal_fee?: dependency_4.cosmos.base.v1beta1.Coin;
bid_amount?: dependency_4.cosmos.base.v1beta1.Coin;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("auction_id" in data && data.auction_id != undefined) {
this.auction_id = data.auction_id;
}
if ("bidder_address" in data && data.bidder_address != undefined) {
this.bidder_address = data.bidder_address;
}
if ("status" in data && data.status != undefined) {
this.status = data.status;
}
if ("commit_hash" in data && data.commit_hash != undefined) {
this.commit_hash = data.commit_hash;
}
if ("commit_time" in data && data.commit_time != undefined) {
this.commit_time = data.commit_time;
}
if ("commit_fee" in data && data.commit_fee != undefined) {
this.commit_fee = data.commit_fee;
}
if ("reveal_time" in data && data.reveal_time != undefined) {
this.reveal_time = data.reveal_time;
}
if ("reveal_fee" in data && data.reveal_fee != undefined) {
this.reveal_fee = data.reveal_fee;
}
if ("bid_amount" in data && data.bid_amount != undefined) {
this.bid_amount = data.bid_amount;
}
}
}
get auction_id() {
return pb_1.Message.getField(this, 1) as string;
}
set auction_id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get bidder_address() {
return pb_1.Message.getField(this, 2) as string;
}
set bidder_address(value: string) {
pb_1.Message.setField(this, 2, value);
}
get status() {
return pb_1.Message.getField(this, 3) as string;
}
set status(value: string) {
pb_1.Message.setField(this, 3, value);
}
get commit_hash() {
return pb_1.Message.getField(this, 4) as string;
}
set commit_hash(value: string) {
pb_1.Message.setField(this, 4, value);
}
get commit_time() {
return pb_1.Message.getWrapperField(this, dependency_3.google.protobuf.Timestamp, 5) as dependency_3.google.protobuf.Timestamp;
}
set commit_time(value: dependency_3.google.protobuf.Timestamp) {
pb_1.Message.setWrapperField(this, 5, value);
}
get commit_fee() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 6) as dependency_4.cosmos.base.v1beta1.Coin;
}
set commit_fee(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 6, value);
}
get reveal_time() {
return pb_1.Message.getWrapperField(this, dependency_3.google.protobuf.Timestamp, 7) as dependency_3.google.protobuf.Timestamp;
}
set reveal_time(value: dependency_3.google.protobuf.Timestamp) {
pb_1.Message.setWrapperField(this, 7, value);
}
get reveal_fee() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 8) as dependency_4.cosmos.base.v1beta1.Coin;
}
set reveal_fee(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 8, value);
}
get bid_amount() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.v1beta1.Coin, 9) as dependency_4.cosmos.base.v1beta1.Coin;
}
set bid_amount(value: dependency_4.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 9, value);
}
static fromObject(data: {
auction_id?: string;
bidder_address?: string;
status?: string;
commit_hash?: string;
commit_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
bid_amount?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
}) {
const message = new Bid({});
if (data.auction_id != null) {
message.auction_id = data.auction_id;
}
if (data.bidder_address != null) {
message.bidder_address = data.bidder_address;
}
if (data.status != null) {
message.status = data.status;
}
if (data.commit_hash != null) {
message.commit_hash = data.commit_hash;
}
if (data.commit_time != null) {
message.commit_time = dependency_3.google.protobuf.Timestamp.fromObject(data.commit_time);
}
if (data.commit_fee != null) {
message.commit_fee = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.commit_fee);
}
if (data.reveal_time != null) {
message.reveal_time = dependency_3.google.protobuf.Timestamp.fromObject(data.reveal_time);
}
if (data.reveal_fee != null) {
message.reveal_fee = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.reveal_fee);
}
if (data.bid_amount != null) {
message.bid_amount = dependency_4.cosmos.base.v1beta1.Coin.fromObject(data.bid_amount);
}
return message;
}
toObject() {
const data: {
auction_id?: string;
bidder_address?: string;
status?: string;
commit_hash?: string;
commit_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
commit_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
reveal_time?: ReturnType<typeof dependency_3.google.protobuf.Timestamp.prototype.toObject>;
reveal_fee?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
bid_amount?: ReturnType<typeof dependency_4.cosmos.base.v1beta1.Coin.prototype.toObject>;
} = {};
if (this.auction_id != null) {
data.auction_id = this.auction_id;
}
if (this.bidder_address != null) {
data.bidder_address = this.bidder_address;
}
if (this.status != null) {
data.status = this.status;
}
if (this.commit_hash != null) {
data.commit_hash = this.commit_hash;
}
if (this.commit_time != null) {
data.commit_time = this.commit_time.toObject();
}
if (this.commit_fee != null) {
data.commit_fee = this.commit_fee.toObject();
}
if (this.reveal_time != null) {
data.reveal_time = this.reveal_time.toObject();
}
if (this.reveal_fee != null) {
data.reveal_fee = this.reveal_fee.toObject();
}
if (this.bid_amount != null) {
data.bid_amount = this.bid_amount.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.auction_id === "string" && this.auction_id.length)
writer.writeString(1, this.auction_id);
if (typeof this.bidder_address === "string" && this.bidder_address.length)
writer.writeString(2, this.bidder_address);
if (typeof this.status === "string" && this.status.length)
writer.writeString(3, this.status);
if (typeof this.commit_hash === "string" && this.commit_hash.length)
writer.writeString(4, this.commit_hash);
if (this.commit_time !== undefined)
writer.writeMessage(5, this.commit_time, () => this.commit_time.serialize(writer));
if (this.commit_fee !== undefined)
writer.writeMessage(6, this.commit_fee, () => this.commit_fee.serialize(writer));
if (this.reveal_time !== undefined)
writer.writeMessage(7, this.reveal_time, () => this.reveal_time.serialize(writer));
if (this.reveal_fee !== undefined)
writer.writeMessage(8, this.reveal_fee, () => this.reveal_fee.serialize(writer));
if (this.bid_amount !== undefined)
writer.writeMessage(9, this.bid_amount, () => this.bid_amount.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Bid {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Bid();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.auction_id = reader.readString();
break;
case 2:
message.bidder_address = reader.readString();
break;
case 3:
message.status = reader.readString();
break;
case 4:
message.commit_hash = reader.readString();
break;
case 5:
reader.readMessage(message.commit_time, () => message.commit_time = dependency_3.google.protobuf.Timestamp.deserialize(reader));
break;
case 6:
reader.readMessage(message.commit_fee, () => message.commit_fee = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 7:
reader.readMessage(message.reveal_time, () => message.reveal_time = dependency_3.google.protobuf.Timestamp.deserialize(reader));
break;
case 8:
reader.readMessage(message.reveal_fee, () => message.reveal_fee = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
case 9:
reader.readMessage(message.bid_amount, () => message.bid_amount = dependency_4.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Bid {
return Bid.deserialize(bytes);
}
}
}
+190
View File
@@ -0,0 +1,190 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/bond/v1beta1/bond.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./../../../cosmos/base/v1beta1/coin";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.bond.v1beta1 {
export class Params extends pb_1.Message {
constructor(data?: any[] | {
max_bond_amount?: dependency_2.cosmos.base.v1beta1.Coin;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("max_bond_amount" in data && data.max_bond_amount != undefined) {
this.max_bond_amount = data.max_bond_amount;
}
}
}
get max_bond_amount() {
return pb_1.Message.getWrapperField(this, dependency_2.cosmos.base.v1beta1.Coin, 1) as dependency_2.cosmos.base.v1beta1.Coin;
}
set max_bond_amount(value: dependency_2.cosmos.base.v1beta1.Coin) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
max_bond_amount?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>;
}) {
const message = new Params({});
if (data.max_bond_amount != null) {
message.max_bond_amount = dependency_2.cosmos.base.v1beta1.Coin.fromObject(data.max_bond_amount);
}
return message;
}
toObject() {
const data: {
max_bond_amount?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>;
} = {};
if (this.max_bond_amount != null) {
data.max_bond_amount = this.max_bond_amount.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.max_bond_amount !== undefined)
writer.writeMessage(1, this.max_bond_amount, () => this.max_bond_amount.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Params {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Params();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.max_bond_amount, () => message.max_bond_amount = dependency_2.cosmos.base.v1beta1.Coin.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Params {
return Params.deserialize(bytes);
}
}
export class Bond extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
owner?: string;
balance?: dependency_2.cosmos.base.v1beta1.Coin[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("owner" in data && data.owner != undefined) {
this.owner = data.owner;
}
if ("balance" in data && data.balance != undefined) {
this.balance = data.balance;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get owner() {
return pb_1.Message.getField(this, 2) as string;
}
set owner(value: string) {
pb_1.Message.setField(this, 2, value);
}
get balance() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.cosmos.base.v1beta1.Coin, 3) as dependency_2.cosmos.base.v1beta1.Coin[];
}
set balance(value: dependency_2.cosmos.base.v1beta1.Coin[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
static fromObject(data: {
id?: string;
owner?: string;
balance?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
}) {
const message = new Bond({});
if (data.id != null) {
message.id = data.id;
}
if (data.owner != null) {
message.owner = data.owner;
}
if (data.balance != null) {
message.balance = data.balance.map(item => dependency_2.cosmos.base.v1beta1.Coin.fromObject(item));
}
return message;
}
toObject() {
const data: {
id?: string;
owner?: string;
balance?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.owner != null) {
data.owner = this.owner;
}
if (this.balance != null) {
data.balance = this.balance.map((item: dependency_2.cosmos.base.v1beta1.Coin) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (typeof this.owner === "string" && this.owner.length)
writer.writeString(2, this.owner);
if (this.balance !== undefined)
writer.writeRepeatedMessage(3, this.balance, (item: dependency_2.cosmos.base.v1beta1.Coin) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Bond {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Bond();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.owner = reader.readString();
break;
case 3:
reader.readMessage(message.balance, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_2.cosmos.base.v1beta1.Coin.deserialize(reader), dependency_2.cosmos.base.v1beta1.Coin));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Bond {
return Bond.deserialize(bytes);
}
}
}
+101
View File
@@ -0,0 +1,101 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/bond/v1beta1/genesis.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./bond";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.bond.v1beta1 {
export class GenesisState extends pb_1.Message {
constructor(data?: any[] | {
params?: dependency_2.vulcanize.bond.v1beta1.Params;
bonds?: dependency_2.vulcanize.bond.v1beta1.Bond[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("params" in data && data.params != undefined) {
this.params = data.params;
}
if ("bonds" in data && data.bonds != undefined) {
this.bonds = data.bonds;
}
}
}
get params() {
return pb_1.Message.getWrapperField(this, dependency_2.vulcanize.bond.v1beta1.Params, 1) as dependency_2.vulcanize.bond.v1beta1.Params;
}
set params(value: dependency_2.vulcanize.bond.v1beta1.Params) {
pb_1.Message.setWrapperField(this, 1, value);
}
get bonds() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.bond.v1beta1.Bond, 2) as dependency_2.vulcanize.bond.v1beta1.Bond[];
}
set bonds(value: dependency_2.vulcanize.bond.v1beta1.Bond[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
static fromObject(data: {
params?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Params.prototype.toObject>;
bonds?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>[];
}) {
const message = new GenesisState({});
if (data.params != null) {
message.params = dependency_2.vulcanize.bond.v1beta1.Params.fromObject(data.params);
}
if (data.bonds != null) {
message.bonds = data.bonds.map(item => dependency_2.vulcanize.bond.v1beta1.Bond.fromObject(item));
}
return message;
}
toObject() {
const data: {
params?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Params.prototype.toObject>;
bonds?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>[];
} = {};
if (this.params != null) {
data.params = this.params.toObject();
}
if (this.bonds != null) {
data.bonds = this.bonds.map((item: dependency_2.vulcanize.bond.v1beta1.Bond) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.params !== undefined)
writer.writeMessage(1, this.params, () => this.params.serialize(writer));
if (this.bonds !== undefined)
writer.writeRepeatedMessage(2, this.bonds, (item: dependency_2.vulcanize.bond.v1beta1.Bond) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GenesisState {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GenesisState();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.params, () => message.params = dependency_2.vulcanize.bond.v1beta1.Params.deserialize(reader));
break;
case 2:
reader.readMessage(message.bonds, () => pb_1.Message.addToRepeatedWrapperField(message, 2, dependency_2.vulcanize.bond.v1beta1.Bond.deserialize(reader), dependency_2.vulcanize.bond.v1beta1.Bond));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GenesisState {
return GenesisState.deserialize(bytes);
}
}
}
+690
View File
@@ -0,0 +1,690 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/bond/v1beta1/query.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./bond";
import * as dependency_3 from "./../../../google/api/annotations";
import * as dependency_4 from "./../../../cosmos/base/query/v1beta1/pagination";
import * as dependency_5 from "./../../../cosmos/base/v1beta1/coin";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.bond.v1beta1 {
export class QueryParamsRequest extends pb_1.Message {
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}) {
const message = new QueryParamsRequest({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryParamsRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryParamsRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryParamsRequest {
return QueryParamsRequest.deserialize(bytes);
}
}
export class QueryParamsResponse extends pb_1.Message {
constructor(data?: any[] | {
params?: dependency_2.vulcanize.bond.v1beta1.Params;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("params" in data && data.params != undefined) {
this.params = data.params;
}
}
}
get params() {
return pb_1.Message.getWrapperField(this, dependency_2.vulcanize.bond.v1beta1.Params, 1) as dependency_2.vulcanize.bond.v1beta1.Params;
}
set params(value: dependency_2.vulcanize.bond.v1beta1.Params) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
params?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Params.prototype.toObject>;
}) {
const message = new QueryParamsResponse({});
if (data.params != null) {
message.params = dependency_2.vulcanize.bond.v1beta1.Params.fromObject(data.params);
}
return message;
}
toObject() {
const data: {
params?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Params.prototype.toObject>;
} = {};
if (this.params != null) {
data.params = this.params.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.params !== undefined)
writer.writeMessage(1, this.params, () => this.params.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryParamsResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryParamsResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.params, () => message.params = dependency_2.vulcanize.bond.v1beta1.Params.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryParamsResponse {
return QueryParamsResponse.deserialize(bytes);
}
}
export class QueryGetBondsRequest extends pb_1.Message {
constructor(data?: any[] | {
pagination?: dependency_4.cosmos.base.query.v1beta1.PageRequest;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("pagination" in data && data.pagination != undefined) {
this.pagination = data.pagination;
}
}
}
get pagination() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.query.v1beta1.PageRequest, 1) as dependency_4.cosmos.base.query.v1beta1.PageRequest;
}
set pagination(value: dependency_4.cosmos.base.query.v1beta1.PageRequest) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageRequest.prototype.toObject>;
}) {
const message = new QueryGetBondsRequest({});
if (data.pagination != null) {
message.pagination = dependency_4.cosmos.base.query.v1beta1.PageRequest.fromObject(data.pagination);
}
return message;
}
toObject() {
const data: {
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageRequest.prototype.toObject>;
} = {};
if (this.pagination != null) {
data.pagination = this.pagination.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.pagination !== undefined)
writer.writeMessage(1, this.pagination, () => this.pagination.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondsRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondsRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.pagination, () => message.pagination = dependency_4.cosmos.base.query.v1beta1.PageRequest.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondsRequest {
return QueryGetBondsRequest.deserialize(bytes);
}
}
export class QueryGetBondsResponse extends pb_1.Message {
constructor(data?: any[] | {
bonds?: dependency_2.vulcanize.bond.v1beta1.Bond[];
pagination?: dependency_4.cosmos.base.query.v1beta1.PageResponse;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("bonds" in data && data.bonds != undefined) {
this.bonds = data.bonds;
}
if ("pagination" in data && data.pagination != undefined) {
this.pagination = data.pagination;
}
}
}
get bonds() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.bond.v1beta1.Bond, 1) as dependency_2.vulcanize.bond.v1beta1.Bond[];
}
set bonds(value: dependency_2.vulcanize.bond.v1beta1.Bond[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
get pagination() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.query.v1beta1.PageResponse, 2) as dependency_4.cosmos.base.query.v1beta1.PageResponse;
}
set pagination(value: dependency_4.cosmos.base.query.v1beta1.PageResponse) {
pb_1.Message.setWrapperField(this, 2, value);
}
static fromObject(data: {
bonds?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>[];
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageResponse.prototype.toObject>;
}) {
const message = new QueryGetBondsResponse({});
if (data.bonds != null) {
message.bonds = data.bonds.map(item => dependency_2.vulcanize.bond.v1beta1.Bond.fromObject(item));
}
if (data.pagination != null) {
message.pagination = dependency_4.cosmos.base.query.v1beta1.PageResponse.fromObject(data.pagination);
}
return message;
}
toObject() {
const data: {
bonds?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>[];
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageResponse.prototype.toObject>;
} = {};
if (this.bonds != null) {
data.bonds = this.bonds.map((item: dependency_2.vulcanize.bond.v1beta1.Bond) => item.toObject());
}
if (this.pagination != null) {
data.pagination = this.pagination.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.bonds !== undefined)
writer.writeRepeatedMessage(1, this.bonds, (item: dependency_2.vulcanize.bond.v1beta1.Bond) => item.serialize(writer));
if (this.pagination !== undefined)
writer.writeMessage(2, this.pagination, () => this.pagination.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondsResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondsResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.bonds, () => pb_1.Message.addToRepeatedWrapperField(message, 1, dependency_2.vulcanize.bond.v1beta1.Bond.deserialize(reader), dependency_2.vulcanize.bond.v1beta1.Bond));
break;
case 2:
reader.readMessage(message.pagination, () => message.pagination = dependency_4.cosmos.base.query.v1beta1.PageResponse.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondsResponse {
return QueryGetBondsResponse.deserialize(bytes);
}
}
export class QueryGetBondByIdRequest extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
id?: string;
}) {
const message = new QueryGetBondByIdRequest({});
if (data.id != null) {
message.id = data.id;
}
return message;
}
toObject() {
const data: {
id?: string;
} = {};
if (this.id != null) {
data.id = this.id;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondByIdRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondByIdRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondByIdRequest {
return QueryGetBondByIdRequest.deserialize(bytes);
}
}
export class QueryGetBondByIdResponse extends pb_1.Message {
constructor(data?: any[] | {
bond?: dependency_2.vulcanize.bond.v1beta1.Bond;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("bond" in data && data.bond != undefined) {
this.bond = data.bond;
}
}
}
get bond() {
return pb_1.Message.getWrapperField(this, dependency_2.vulcanize.bond.v1beta1.Bond, 1) as dependency_2.vulcanize.bond.v1beta1.Bond;
}
set bond(value: dependency_2.vulcanize.bond.v1beta1.Bond) {
pb_1.Message.setWrapperField(this, 1, value);
}
static fromObject(data: {
bond?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>;
}) {
const message = new QueryGetBondByIdResponse({});
if (data.bond != null) {
message.bond = dependency_2.vulcanize.bond.v1beta1.Bond.fromObject(data.bond);
}
return message;
}
toObject() {
const data: {
bond?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>;
} = {};
if (this.bond != null) {
data.bond = this.bond.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.bond !== undefined)
writer.writeMessage(1, this.bond, () => this.bond.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondByIdResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondByIdResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.bond, () => message.bond = dependency_2.vulcanize.bond.v1beta1.Bond.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondByIdResponse {
return QueryGetBondByIdResponse.deserialize(bytes);
}
}
export class QueryGetBondsByOwnerRequest extends pb_1.Message {
constructor(data?: any[] | {
owner?: string;
pagination?: dependency_4.cosmos.base.query.v1beta1.PageResponse;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("owner" in data && data.owner != undefined) {
this.owner = data.owner;
}
if ("pagination" in data && data.pagination != undefined) {
this.pagination = data.pagination;
}
}
}
get owner() {
return pb_1.Message.getField(this, 1) as string;
}
set owner(value: string) {
pb_1.Message.setField(this, 1, value);
}
get pagination() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.query.v1beta1.PageResponse, 2) as dependency_4.cosmos.base.query.v1beta1.PageResponse;
}
set pagination(value: dependency_4.cosmos.base.query.v1beta1.PageResponse) {
pb_1.Message.setWrapperField(this, 2, value);
}
static fromObject(data: {
owner?: string;
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageResponse.prototype.toObject>;
}) {
const message = new QueryGetBondsByOwnerRequest({});
if (data.owner != null) {
message.owner = data.owner;
}
if (data.pagination != null) {
message.pagination = dependency_4.cosmos.base.query.v1beta1.PageResponse.fromObject(data.pagination);
}
return message;
}
toObject() {
const data: {
owner?: string;
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageResponse.prototype.toObject>;
} = {};
if (this.owner != null) {
data.owner = this.owner;
}
if (this.pagination != null) {
data.pagination = this.pagination.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.owner === "string" && this.owner.length)
writer.writeString(1, this.owner);
if (this.pagination !== undefined)
writer.writeMessage(2, this.pagination, () => this.pagination.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondsByOwnerRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondsByOwnerRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.owner = reader.readString();
break;
case 2:
reader.readMessage(message.pagination, () => message.pagination = dependency_4.cosmos.base.query.v1beta1.PageResponse.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondsByOwnerRequest {
return QueryGetBondsByOwnerRequest.deserialize(bytes);
}
}
export class QueryGetBondsByOwnerResponse extends pb_1.Message {
constructor(data?: any[] | {
bonds?: dependency_2.vulcanize.bond.v1beta1.Bond[];
pagination?: dependency_4.cosmos.base.query.v1beta1.PageResponse;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("bonds" in data && data.bonds != undefined) {
this.bonds = data.bonds;
}
if ("pagination" in data && data.pagination != undefined) {
this.pagination = data.pagination;
}
}
}
get bonds() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.bond.v1beta1.Bond, 1) as dependency_2.vulcanize.bond.v1beta1.Bond[];
}
set bonds(value: dependency_2.vulcanize.bond.v1beta1.Bond[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
get pagination() {
return pb_1.Message.getWrapperField(this, dependency_4.cosmos.base.query.v1beta1.PageResponse, 2) as dependency_4.cosmos.base.query.v1beta1.PageResponse;
}
set pagination(value: dependency_4.cosmos.base.query.v1beta1.PageResponse) {
pb_1.Message.setWrapperField(this, 2, value);
}
static fromObject(data: {
bonds?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>[];
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageResponse.prototype.toObject>;
}) {
const message = new QueryGetBondsByOwnerResponse({});
if (data.bonds != null) {
message.bonds = data.bonds.map(item => dependency_2.vulcanize.bond.v1beta1.Bond.fromObject(item));
}
if (data.pagination != null) {
message.pagination = dependency_4.cosmos.base.query.v1beta1.PageResponse.fromObject(data.pagination);
}
return message;
}
toObject() {
const data: {
bonds?: ReturnType<typeof dependency_2.vulcanize.bond.v1beta1.Bond.prototype.toObject>[];
pagination?: ReturnType<typeof dependency_4.cosmos.base.query.v1beta1.PageResponse.prototype.toObject>;
} = {};
if (this.bonds != null) {
data.bonds = this.bonds.map((item: dependency_2.vulcanize.bond.v1beta1.Bond) => item.toObject());
}
if (this.pagination != null) {
data.pagination = this.pagination.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.bonds !== undefined)
writer.writeRepeatedMessage(1, this.bonds, (item: dependency_2.vulcanize.bond.v1beta1.Bond) => item.serialize(writer));
if (this.pagination !== undefined)
writer.writeMessage(2, this.pagination, () => this.pagination.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondsByOwnerResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondsByOwnerResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.bonds, () => pb_1.Message.addToRepeatedWrapperField(message, 1, dependency_2.vulcanize.bond.v1beta1.Bond.deserialize(reader), dependency_2.vulcanize.bond.v1beta1.Bond));
break;
case 2:
reader.readMessage(message.pagination, () => message.pagination = dependency_4.cosmos.base.query.v1beta1.PageResponse.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondsByOwnerResponse {
return QueryGetBondsByOwnerResponse.deserialize(bytes);
}
}
export class QueryGetBondModuleBalanceRequest extends pb_1.Message {
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}) {
const message = new QueryGetBondModuleBalanceRequest({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondModuleBalanceRequest {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondModuleBalanceRequest();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondModuleBalanceRequest {
return QueryGetBondModuleBalanceRequest.deserialize(bytes);
}
}
export class QueryGetBondModuleBalanceResponse extends pb_1.Message {
constructor(data?: any[] | {
balance?: dependency_5.cosmos.base.v1beta1.Coin[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("balance" in data && data.balance != undefined) {
this.balance = data.balance;
}
}
}
get balance() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_5.cosmos.base.v1beta1.Coin, 2) as dependency_5.cosmos.base.v1beta1.Coin[];
}
set balance(value: dependency_5.cosmos.base.v1beta1.Coin[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
static fromObject(data: {
balance?: ReturnType<typeof dependency_5.cosmos.base.v1beta1.Coin.prototype.toObject>[];
}) {
const message = new QueryGetBondModuleBalanceResponse({});
if (data.balance != null) {
message.balance = data.balance.map(item => dependency_5.cosmos.base.v1beta1.Coin.fromObject(item));
}
return message;
}
toObject() {
const data: {
balance?: ReturnType<typeof dependency_5.cosmos.base.v1beta1.Coin.prototype.toObject>[];
} = {};
if (this.balance != null) {
data.balance = this.balance.map((item: dependency_5.cosmos.base.v1beta1.Coin) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.balance !== undefined)
writer.writeRepeatedMessage(2, this.balance, (item: dependency_5.cosmos.base.v1beta1.Coin) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): QueryGetBondModuleBalanceResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new QueryGetBondModuleBalanceResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 2:
reader.readMessage(message.balance, () => pb_1.Message.addToRepeatedWrapperField(message, 2, dependency_5.cosmos.base.v1beta1.Coin.deserialize(reader), dependency_5.cosmos.base.v1beta1.Coin));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): QueryGetBondModuleBalanceResponse {
return QueryGetBondModuleBalanceResponse.deserialize(bytes);
}
}
}
+597
View File
@@ -0,0 +1,597 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/bond/v1beta1/tx.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./../../../cosmos/base/v1beta1/coin";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.bond.v1beta1 {
export class MsgCreateBond extends pb_1.Message {
constructor(data?: any[] | {
signer?: string;
coins?: dependency_2.cosmos.base.v1beta1.Coin[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
if ("coins" in data && data.coins != undefined) {
this.coins = data.coins;
}
}
}
get signer() {
return pb_1.Message.getField(this, 1) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 1, value);
}
get coins() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.cosmos.base.v1beta1.Coin, 2) as dependency_2.cosmos.base.v1beta1.Coin[];
}
set coins(value: dependency_2.cosmos.base.v1beta1.Coin[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
static fromObject(data: {
signer?: string;
coins?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
}) {
const message = new MsgCreateBond({});
if (data.signer != null) {
message.signer = data.signer;
}
if (data.coins != null) {
message.coins = data.coins.map(item => dependency_2.cosmos.base.v1beta1.Coin.fromObject(item));
}
return message;
}
toObject() {
const data: {
signer?: string;
coins?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
} = {};
if (this.signer != null) {
data.signer = this.signer;
}
if (this.coins != null) {
data.coins = this.coins.map((item: dependency_2.cosmos.base.v1beta1.Coin) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(1, this.signer);
if (this.coins !== undefined)
writer.writeRepeatedMessage(2, this.coins, (item: dependency_2.cosmos.base.v1beta1.Coin) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCreateBond {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCreateBond();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.signer = reader.readString();
break;
case 2:
reader.readMessage(message.coins, () => pb_1.Message.addToRepeatedWrapperField(message, 2, dependency_2.cosmos.base.v1beta1.Coin.deserialize(reader), dependency_2.cosmos.base.v1beta1.Coin));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCreateBond {
return MsgCreateBond.deserialize(bytes);
}
}
export class MsgCreateBondResponse extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
id?: string;
}) {
const message = new MsgCreateBondResponse({});
if (data.id != null) {
message.id = data.id;
}
return message;
}
toObject() {
const data: {
id?: string;
} = {};
if (this.id != null) {
data.id = this.id;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCreateBondResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCreateBondResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCreateBondResponse {
return MsgCreateBondResponse.deserialize(bytes);
}
}
export class MsgRefillBond extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
signer?: string;
coins?: dependency_2.cosmos.base.v1beta1.Coin[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
if ("coins" in data && data.coins != undefined) {
this.coins = data.coins;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get signer() {
return pb_1.Message.getField(this, 2) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 2, value);
}
get coins() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.cosmos.base.v1beta1.Coin, 3) as dependency_2.cosmos.base.v1beta1.Coin[];
}
set coins(value: dependency_2.cosmos.base.v1beta1.Coin[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
static fromObject(data: {
id?: string;
signer?: string;
coins?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
}) {
const message = new MsgRefillBond({});
if (data.id != null) {
message.id = data.id;
}
if (data.signer != null) {
message.signer = data.signer;
}
if (data.coins != null) {
message.coins = data.coins.map(item => dependency_2.cosmos.base.v1beta1.Coin.fromObject(item));
}
return message;
}
toObject() {
const data: {
id?: string;
signer?: string;
coins?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.signer != null) {
data.signer = this.signer;
}
if (this.coins != null) {
data.coins = this.coins.map((item: dependency_2.cosmos.base.v1beta1.Coin) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(2, this.signer);
if (this.coins !== undefined)
writer.writeRepeatedMessage(3, this.coins, (item: dependency_2.cosmos.base.v1beta1.Coin) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgRefillBond {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgRefillBond();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.signer = reader.readString();
break;
case 3:
reader.readMessage(message.coins, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_2.cosmos.base.v1beta1.Coin.deserialize(reader), dependency_2.cosmos.base.v1beta1.Coin));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgRefillBond {
return MsgRefillBond.deserialize(bytes);
}
}
export class MsgRefillBondResponse extends pb_1.Message {
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}) {
const message = new MsgRefillBondResponse({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgRefillBondResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgRefillBondResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgRefillBondResponse {
return MsgRefillBondResponse.deserialize(bytes);
}
}
export class MsgWithdrawBond extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
signer?: string;
coins?: dependency_2.cosmos.base.v1beta1.Coin[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
if ("coins" in data && data.coins != undefined) {
this.coins = data.coins;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get signer() {
return pb_1.Message.getField(this, 2) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 2, value);
}
get coins() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.cosmos.base.v1beta1.Coin, 3) as dependency_2.cosmos.base.v1beta1.Coin[];
}
set coins(value: dependency_2.cosmos.base.v1beta1.Coin[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
static fromObject(data: {
id?: string;
signer?: string;
coins?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
}) {
const message = new MsgWithdrawBond({});
if (data.id != null) {
message.id = data.id;
}
if (data.signer != null) {
message.signer = data.signer;
}
if (data.coins != null) {
message.coins = data.coins.map(item => dependency_2.cosmos.base.v1beta1.Coin.fromObject(item));
}
return message;
}
toObject() {
const data: {
id?: string;
signer?: string;
coins?: ReturnType<typeof dependency_2.cosmos.base.v1beta1.Coin.prototype.toObject>[];
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.signer != null) {
data.signer = this.signer;
}
if (this.coins != null) {
data.coins = this.coins.map((item: dependency_2.cosmos.base.v1beta1.Coin) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(2, this.signer);
if (this.coins !== undefined)
writer.writeRepeatedMessage(3, this.coins, (item: dependency_2.cosmos.base.v1beta1.Coin) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgWithdrawBond {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgWithdrawBond();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.signer = reader.readString();
break;
case 3:
reader.readMessage(message.coins, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_2.cosmos.base.v1beta1.Coin.deserialize(reader), dependency_2.cosmos.base.v1beta1.Coin));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgWithdrawBond {
return MsgWithdrawBond.deserialize(bytes);
}
}
export class MsgWithdrawBondResponse extends pb_1.Message {
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}) {
const message = new MsgWithdrawBondResponse({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgWithdrawBondResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgWithdrawBondResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgWithdrawBondResponse {
return MsgWithdrawBondResponse.deserialize(bytes);
}
}
export class MsgCancelBond extends pb_1.Message {
constructor(data?: any[] | {
id?: string;
signer?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("signer" in data && data.signer != undefined) {
this.signer = data.signer;
}
}
}
get id() {
return pb_1.Message.getField(this, 1) as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get signer() {
return pb_1.Message.getField(this, 2) as string;
}
set signer(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
id?: string;
signer?: string;
}) {
const message = new MsgCancelBond({});
if (data.id != null) {
message.id = data.id;
}
if (data.signer != null) {
message.signer = data.signer;
}
return message;
}
toObject() {
const data: {
id?: string;
signer?: string;
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.signer != null) {
data.signer = this.signer;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (typeof this.id === "string" && this.id.length)
writer.writeString(1, this.id);
if (typeof this.signer === "string" && this.signer.length)
writer.writeString(2, this.signer);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCancelBond {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCancelBond();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.signer = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCancelBond {
return MsgCancelBond.deserialize(bytes);
}
}
export class MsgCancelBondResponse extends pb_1.Message {
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}) {
const message = new MsgCancelBondResponse({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MsgCancelBondResponse {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MsgCancelBondResponse();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): MsgCancelBondResponse {
return MsgCancelBondResponse.deserialize(bytes);
}
}
}
@@ -0,0 +1,147 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.14.0
* source: vulcanize/nameservice/v1beta1/genesis.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../../../gogoproto/gogo";
import * as dependency_2 from "./nameservice";
import * as pb_1 from "google-protobuf";
export namespace vulcanize.nameservice.v1beta1 {
export class GenesisState extends pb_1.Message {
constructor(data?: any[] | {
params?: dependency_2.vulcanize.nameservice.v1beta1.Params;
records?: dependency_2.vulcanize.nameservice.v1beta1.Record[];
authorities?: dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry[];
names?: dependency_2.vulcanize.nameservice.v1beta1.NameEntry[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4], []);
if (!Array.isArray(data) && typeof data == "object") {
if ("params" in data && data.params != undefined) {
this.params = data.params;
}
if ("records" in data && data.records != undefined) {
this.records = data.records;
}
if ("authorities" in data && data.authorities != undefined) {
this.authorities = data.authorities;
}
if ("names" in data && data.names != undefined) {
this.names = data.names;
}
}
}
get params() {
return pb_1.Message.getWrapperField(this, dependency_2.vulcanize.nameservice.v1beta1.Params, 1) as dependency_2.vulcanize.nameservice.v1beta1.Params;
}
set params(value: dependency_2.vulcanize.nameservice.v1beta1.Params) {
pb_1.Message.setWrapperField(this, 1, value);
}
get records() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.nameservice.v1beta1.Record, 2) as dependency_2.vulcanize.nameservice.v1beta1.Record[];
}
set records(value: dependency_2.vulcanize.nameservice.v1beta1.Record[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
get authorities() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry, 3) as dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry[];
}
set authorities(value: dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
get names() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_2.vulcanize.nameservice.v1beta1.NameEntry, 4) as dependency_2.vulcanize.nameservice.v1beta1.NameEntry[];
}
set names(value: dependency_2.vulcanize.nameservice.v1beta1.NameEntry[]) {
pb_1.Message.setRepeatedWrapperField(this, 4, value);
}
static fromObject(data: {
params?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.Params.prototype.toObject>;
records?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.Record.prototype.toObject>[];
authorities?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry.prototype.toObject>[];
names?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.NameEntry.prototype.toObject>[];
}) {
const message = new GenesisState({});
if (data.params != null) {
message.params = dependency_2.vulcanize.nameservice.v1beta1.Params.fromObject(data.params);
}
if (data.records != null) {
message.records = data.records.map(item => dependency_2.vulcanize.nameservice.v1beta1.Record.fromObject(item));
}
if (data.authorities != null) {
message.authorities = data.authorities.map(item => dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry.fromObject(item));
}
if (data.names != null) {
message.names = data.names.map(item => dependency_2.vulcanize.nameservice.v1beta1.NameEntry.fromObject(item));
}
return message;
}
toObject() {
const data: {
params?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.Params.prototype.toObject>;
records?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.Record.prototype.toObject>[];
authorities?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry.prototype.toObject>[];
names?: ReturnType<typeof dependency_2.vulcanize.nameservice.v1beta1.NameEntry.prototype.toObject>[];
} = {};
if (this.params != null) {
data.params = this.params.toObject();
}
if (this.records != null) {
data.records = this.records.map((item: dependency_2.vulcanize.nameservice.v1beta1.Record) => item.toObject());
}
if (this.authorities != null) {
data.authorities = this.authorities.map((item: dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry) => item.toObject());
}
if (this.names != null) {
data.names = this.names.map((item: dependency_2.vulcanize.nameservice.v1beta1.NameEntry) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.params !== undefined)
writer.writeMessage(1, this.params, () => this.params.serialize(writer));
if (this.records !== undefined)
writer.writeRepeatedMessage(2, this.records, (item: dependency_2.vulcanize.nameservice.v1beta1.Record) => item.serialize(writer));
if (this.authorities !== undefined)
writer.writeRepeatedMessage(3, this.authorities, (item: dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry) => item.serialize(writer));
if (this.names !== undefined)
writer.writeRepeatedMessage(4, this.names, (item: dependency_2.vulcanize.nameservice.v1beta1.NameEntry) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GenesisState {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GenesisState();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.params, () => message.params = dependency_2.vulcanize.nameservice.v1beta1.Params.deserialize(reader));
break;
case 2:
reader.readMessage(message.records, () => pb_1.Message.addToRepeatedWrapperField(message, 2, dependency_2.vulcanize.nameservice.v1beta1.Record.deserialize(reader), dependency_2.vulcanize.nameservice.v1beta1.Record));
break;
case 3:
reader.readMessage(message.authorities, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry.deserialize(reader), dependency_2.vulcanize.nameservice.v1beta1.AuthorityEntry));
break;
case 4:
reader.readMessage(message.names, () => pb_1.Message.addToRepeatedWrapperField(message, 4, dependency_2.vulcanize.nameservice.v1beta1.NameEntry.deserialize(reader), dependency_2.vulcanize.nameservice.v1beta1.NameEntry));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GenesisState {
return GenesisState.deserialize(bytes);
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+429
View File
@@ -0,0 +1,429 @@
import assert from 'assert';
import axios from 'axios';
import graphqlClient from 'graphql.js'
import { get, set } from 'lodash'
import { generateEndpointAccount, generateEndpointBroadcast } from '@tharsis/provider';
import { Util } from './util';
const attributeField = `
attributes {
key
value {
null
int
float
string
boolean
json
reference {
id
}
}
}
`;
const refsField = `
references {
id
}
`;
const historyFields = `
history {
id
height
}
`;
const auctionFields = `
id
status
ownerAddress
createTime
commitsEndTime
revealsEndTime
commitFee {
type
quantity
}
revealFee {
type
quantity
}
minimumBid {
type
quantity
}
winnerAddress
winnerBid {
type
quantity
}
winnerPrice {
type
quantity
}
bids {
bidderAddress
status
commitHash
commitTime
revealTime
commitFee {
type
quantity
}
revealFee {
type
quantity
}
bidAmount {
type
quantity
}
}
`;
/**
* Registry
*/
export class RegistryClient {
_restEndpoint: string
_graph: any
/**
* Get query result.
*/
static async getResult(query: any, key: string, modifier?: (rows: any[]) => {}) {
const result = await query;
if (result && result[key] && result[key].length && result[key][0] !== null) {
if (modifier) {
return modifier(result[key]);
}
return result[key];
}
return [];
}
/**
* Prepare response attributes.
*/
static prepareAttributes(path: string) {
return (rows: any[]) => {
const result = rows.map(r => {
set(r, path, Util.fromGQLAttributes(get(r, path)));
return r;
});
return result;
};
}
/**
* New Client.
*/
constructor(gqlEndpoint: string, restEndpoint: string) {
assert(gqlEndpoint);
this._graph = graphqlClient(gqlEndpoint, {
method: 'POST',
asJSON: true
});
this._restEndpoint = restEndpoint;
}
/**
* Get server status.
*/
async getStatus() {
const query = `query {
getStatus {
version
node {
id
network
moniker
}
sync {
latest_block_hash
latest_block_height
latest_block_time
catching_up
}
validator {
address
voting_power
}
validators {
address
voting_power
proposer_priority
}
num_peers
peers {
node {
id
network
moniker
}
is_outbound
remote_ip
}
disk_usage
}
}`;
const { getStatus: status } = await this._graph(query)();
return status;
}
/**
* Fetch Accounts.
*/
async getAccounts(addresses: string[]) {
assert(addresses);
assert(addresses.length);
const query = `query ($addresses: [String!]) {
getAccounts(addresses: $addresses) {
address
pubKey
number
sequence
balance {
type
quantity
}
}
}`;
const variables = {
addresses
};
return RegistryClient.getResult(this._graph(query)(variables), 'getAccounts');
}
/**
* Get records by ids.
*/
async getRecordsByIds(ids: string[], refs = false) {
assert(ids);
assert(ids.length);
const query = `query ($ids: [String!]) {
getRecordsByIds(ids: $ids) {
id
names
owners
bondId
createTime
expiryTime
${attributeField}
${refs ? refsField : ''}
}
}`;
const variables = {
ids
};
return RegistryClient.getResult(this._graph(query)(variables), 'getRecordsByIds', RegistryClient.prepareAttributes('attributes'));
}
/**
* Get records by attributes.
*/
async queryRecords(attributes: {[key: string]: any}, all = false, refs = false) {
if (!attributes) {
attributes = {};
}
const query = `query ($attributes: [KeyValueInput!], $all: Boolean) {
queryRecords(attributes: $attributes, all: $all) {
id
names
owners
bondId
createTime
expiryTime
${attributeField}
${refs ? refsField : ''}
}
}`;
const variables = {
attributes: Util.toGQLAttributes(attributes),
all
};
let result = (await this._graph(query)(variables))['queryRecords'];
result = RegistryClient.prepareAttributes('attributes')(result);
return result;
}
/**
* Lookup authorities by names.
*/
async lookupAuthorities(names: string[], auction = false) {
assert(names.length);
const query = `query ($names: [String!]) {
lookupAuthorities(names: $names) {
ownerAddress
ownerPublicKey
height
status
bondId
expiryTime
${auction ? ('auction { ' + auctionFields + ' }') : ''}
}
}`;
const variables = {
names
};
const result = await this._graph(query)(variables);
return result['lookupAuthorities'];
}
/**
* Get auctions by ids.
*/
async getAuctionsByIds(ids: string[]) {
assert(ids);
assert(ids.length);
const query = `query ($ids: [String!]) {
getAuctionsByIds(ids: $ids) {
${auctionFields}
}
}`;
const variables = {
ids
};
return RegistryClient.getResult(this._graph(query)(variables), 'getAuctionsByIds');
}
/**
* Lookup names.
*/
async lookupNames(names: string[], history = false) {
assert(names.length);
const query = `query ($names: [String!]) {
lookupNames(names: $names) {
latest {
id
height
}
${history ? historyFields : ''}
}
}`;
const variables = {
names
};
const result = await this._graph(query)(variables);
return result['lookupNames'];
}
/**
* Resolve names to records.
*/
async resolveNames(names: string[], refs = false) {
assert(names.length);
const query = `query ($names: [String!]) {
resolveNames(names: $names) {
id
names
owners
bondId
createTime
expiryTime
${attributeField}
${refs ? refsField : ''}
}
}`;
const variables = {
names
};
let result = (await this._graph(query)(variables))['resolveNames'];
result = RegistryClient.prepareAttributes('attributes')(result);
return result;
}
/**
* Get bonds by ids.
*/
async getBondsByIds(ids: string[]) {
assert(ids);
assert(ids.length);
const query = `query ($ids: [String!]) {
getBondsByIds(ids: $ids) {
id
owner
balance {
type
quantity
}
}
}`;
const variables = {
ids
};
return RegistryClient.getResult(this._graph(query)(variables), 'getBondsByIds');
}
/**
* Get records by attributes.
*/
async queryBonds(attributes = {}) {
const query = `query ($attributes: [KeyValueInput!]) {
queryBonds(attributes: $attributes) {
id
owner
balance {
type
quantity
}
}
}`;
const variables = {
attributes: Util.toGQLAttributes(attributes)
};
return RegistryClient.getResult(this._graph(query)(variables), 'queryBonds');
}
/**
* Submit transaction.
*/
async submit(tx: string) {
assert(tx);
// Broadcast transaction.
const { data } = await axios.post(
`${this._restEndpoint}${generateEndpointBroadcast()}`,
tx
)
return data;
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/schema#",
"id": "/Record",
"type": "object"
}
+79
View File
@@ -0,0 +1,79 @@
import path from 'path';
import { Registry } from './index';
import { getConfig, ensureUpdatedConfig, provisionBondId } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(40 * 1000);
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
describe('Querying', () => {
let watcher: any;
let registry: Registry;
let bondId: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
bondId = await provisionBondId(registry, privateKey, fee);
const publishNewWatcherVersion = async () => {
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
await registry.setRecord({ privateKey, record: watcher.record, bondId }, privateKey, fee);
return watcher.record.version;
};
await publishNewWatcherVersion();
});
test('Endpoint and chain ID.', async () => {
expect(registry.endpoints.rest).toBe(restEndpoint);
expect(registry.endpoints.gql).toBe(gqlEndpoint);
expect(registry.chainID).toBe(chainId);
});
test('Get status.', async () => {
const status = await registry.getStatus();
expect(status).toBeDefined();
expect(status.version).toBeDefined();
});
test('List records.', async () => {
const records = await registry.queryRecords({}, true);
expect(records.length).toBeGreaterThanOrEqual(1);
});
test('Query records by reference.', async () => {
const { protocol } = watcher.record;
const records = await registry.queryRecords({ protocol }, true);
expect(records.length).toBeGreaterThanOrEqual(1);
const { attributes: { protocol: recordProtocol } } = records[0];
expect(protocol['/']).toBe(recordProtocol['/']);
});
test('Query records by attributes.', async () => {
const { version, name } = watcher.record;
const records = await registry.queryRecords({ version, name }, true);
expect(records.length).toBe(1);
[ watcher ] = records;
const { attributes: { version: recordVersion, name: recordName } } = watcher;
expect(recordVersion).toBe(version);
expect(recordName).toBe(name);
});
test('Query records by id.', async () => {
const records = await registry.getRecordsByIds([watcher.id]);
expect(records.length).toBe(1);
expect(records[0].id).toBe(watcher.id);
});
test('Query records passing refs true.', async () => {
const [record] = await registry.getRecordsByIds([watcher.id], true);
expect(record.id).toBe(watcher.id);
expect(record.references).toBeDefined();
expect(record.references).toHaveLength(1);
});
});
+6
View File
@@ -0,0 +1,6 @@
record:
type: watcher
name: ERC20 Watcher
version: 1.0.0
protocol:
/: QmdeazkS38aCrqG6qKwaio2fQnShE6RGpmNdqStLkkZcQN
+50
View File
@@ -0,0 +1,50 @@
import assert from 'assert';
import yaml from 'node-yaml';
import semver from 'semver';
import { Fee } from '@tharsis/transactions';
import { DEFAULT_CHAIN_ID, Registry } from '../index';
export const ensureUpdatedConfig = async (path: string) => {
const conf = await yaml.read(path);
conf.record.version = semver.inc(conf.record.version, 'patch');
await yaml.write(path, conf);
return conf;
};
export const getBaseConfig = async (path: string) => {
const conf = await yaml.read(path);
conf.record.version = '0.0.1';
return conf;
};
/**
* Provision a bond for record registration.
*/
export const provisionBondId = async (registry: Registry, privateKey: string, fee: Fee) => {
let bonds = await registry.queryBonds();
if (!bonds.length) {
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
bonds = await registry.queryBonds();
}
return bonds[0].id;
};
export const getConfig = () => {
assert(process.env.PRIVATE_KEY);
return {
chainId: process.env.COSMOS_CHAIN_ID || DEFAULT_CHAIN_ID,
privateKey: process.env.PRIVATE_KEY,
restEndpoint: process.env.LACONICD_REST_ENDPOINT || 'http://localhost:1317',
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
fee: {
amount: '30',
denom: 'aphoton',
gas: '300000',
}
}
};
+25
View File
@@ -0,0 +1,25 @@
import assert from 'assert';
import {
createTxRawEIP712,
signatureToWeb3Extension,
Chain,
Sender
} from '@tharsis/transactions'
import { Account } from './account';
/**
* Generate a cosmos-sdk transaction.
*/
export const createTransaction = (message: any, account: Account, sender: Sender, chain: Chain) => {
assert(message);
assert(account);
// Sign transaction.
const signature = account.sign(message);
let extension = signatureToWeb3Extension(chain, sender, signature)
// Create the txRaw.
return createTxRawEIP712(message.legacyAmino.body, message.legacyAmino.authInfo, extension)
};
+130
View File
@@ -0,0 +1,130 @@
import assert from 'assert';
import { Validator } from 'jsonschema';
import RecordSchema from './schema/record.json';
import { Util } from './util';
/**
* Record.
*/
export class Record {
_record: any
/**
* New Record.
*/
constructor(record: any) {
assert(record);
const validator = new Validator();
const result = validator.validate(record, RecordSchema);
if (!result.valid) {
result.errors.map(console.error);
throw new Error('Invalid record input.');
}
this._record = record;
}
get attributes() {
return Buffer.from(JSON.stringify(this._record), 'binary').toString('base64')
}
/**
* Serialize record.
*/
serialize() {
return {
'id': '_',
'bond_id': '_',
'create_time': '_',
'expiry_time': '_',
// Setting deleted as false (zero value) throws error in EIP712 signature verification.
'deleted': true,
'attributes': this.attributes,
}
}
/**
* Get message to calculate record signature.
*/
getMessageToSign() {
return Util.sortJSON(this._record);
}
}
/**
* Record Signature.
*/
export class Signature {
_pubKey: string
_sig: string
/**
* New Signature.
*/
constructor(pubKey: string, sig: string) {
assert(pubKey);
assert(sig);
this._pubKey = pubKey;
this._sig = sig;
}
/**
* Serialize Signature.
*/
serialize() {
return Util.sortJSON({
'pub_key': this._pubKey,
'sig': this._sig
});
}
}
/**
* Message Payload.
*/
export class Payload {
_record: Record
_signatures: Signature[]
/**
* New Payload.
*/
constructor(record: Record, ...signatures: Signature[]) {
assert(record);
this._record = record;
this._signatures = signatures;
}
get record() {
return this._record;
}
get signatures() {
return this._signatures;
}
/**
* Add message signature to payload.
*/
addSignature(signature: any) {
assert(signature);
this._signatures.push(signature);
}
/**
* Serialize Payload.
*/
serialize() {
// return Util.sortJSON({
// });
return {
'record': this._record.serialize(),
'signatures': this._signatures.map(s => s.serialize())
}
}
}
+48
View File
@@ -0,0 +1,48 @@
import path from 'path';
import { Registry } from './index';
import { getBaseConfig, getConfig } from './testing/helper';
import { Util } from './util';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(90 * 1000);
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
const utilTests = () => {
let registry: Registry;
let bondId: string;
let watcher: any;
let watcherId: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
// Create bond.
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// Create watcher.
watcher = await getBaseConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
bondId,
record: watcher.record
},
privateKey,
fee
)
watcherId = result.data.id;
});
test('Generate content id.', async () => {
const cid = await Util.getContentId(watcher.record);
expect(cid).toBe(watcherId)
});
}
describe('Util', utilTests);
+100
View File
@@ -0,0 +1,100 @@
import * as Block from 'multiformats/block'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
import * as dagCBOR from '@ipld/dag-cbor'
import * as dagJSON from '@ipld/dag-json'
/**
* Utils
*/
export class Util {
/**
* Sorts JSON object.
*/
static sortJSON(object: any) {
if (object instanceof Array) {
for (let i = 0; i < object.length; i++) {
object[i] = Util.sortJSON(object[i]);
}
return object;
}
if (typeof object !== 'object' || object === null) return object;
let keys = Object.keys(object);
keys = keys.sort();
const newObject: {[key: string]: any} = {};
for (let i = 0; i < keys.length; i++) {
newObject[keys[i]] = Util.sortJSON(object[keys[i]]);
}
return newObject;
}
/**
* Marshal object into gql 'attributes' variable.
*/
static toGQLAttributes(object: any) {
const vars: any[] = [];
Object.keys(object).forEach(key => {
let type: string = typeof object[key];
if (object[key] === null) {
vars.push({ key, value: { 'null': true } });
} else if (type === 'number') {
type = (object[key] % 1 === 0) ? 'int' : 'float';
vars.push({ key, value: { [type]: object[key] } });
} else if (type === 'string') {
vars.push({ key, value: { 'string': object[key] } });
} else if (type === 'boolean') {
vars.push({ key, value: { 'boolean': object[key] } });
} else if (type === 'object') {
const nestedObject = object[key];
if (nestedObject['/'] !== undefined) {
vars.push({ key, value: { 'reference': { id: nestedObject['/'] } } });
}
}
});
return vars;
}
/**
* Unmarshal attributes array to object.
*/
static fromGQLAttributes(attributes: any[] = []) {
const res: {[key: string]: any} = {};
attributes.forEach(attr => {
if (attr.value.null) {
res[attr.key] = null;
} else if (attr.value.json) {
res[attr.key] = JSON.parse(attr.value.json);
} else if (attr.value.reference) {
// Convert GQL reference to IPLD style link.
const ref = attr.value.reference;
res[attr.key] = { '/': ref.id };
} else {
const { values, null: n, ...types } = attr.value;
const value = Object.values(types).find(v => v !== null);
res[attr.key] = value;
}
});
return res;
}
/**
* Get record content ID.
*/
static async getContentId(record: any) {
const serialized = dagJSON.encode(record)
const recordData = dagJSON.decode(serialized)
const block = await Block.encode({
value: recordData,
codec: dagCBOR,
hasher
})
return block.cid.toString();
}
}
+107
View File
@@ -0,0 +1,107 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": [
"src/**/*"
],
"exclude": [
"src/**/*.test.ts"
]
}
+3452
View File
File diff suppressed because it is too large Load Diff