Compare commits
2 Commits
main
...
zach/upgra
Author | SHA1 | Date | |
---|---|---|---|
|
d78cf76163 | ||
|
9d5b00ee29 |
@ -44,14 +44,14 @@ jobs:
|
|||||||
working-directory: laconicd/tests/sdk_tests
|
working-directory: laconicd/tests/sdk_tests
|
||||||
run: ./run-tests.sh
|
run: ./run-tests.sh
|
||||||
|
|
||||||
- name: Start containers (authority auctions enabled)
|
- name: Start containers (auctions enabled)
|
||||||
working-directory: laconicd/tests/sdk_tests
|
working-directory: laconicd/tests/sdk_tests
|
||||||
env:
|
env:
|
||||||
TEST_AUCTION_ENABLED: true
|
TEST_AUCTION_ENABLED: true
|
||||||
run: docker compose up -d
|
run: docker compose up -d
|
||||||
- name: Run authority auction tests
|
- name: Run auction tests
|
||||||
working-directory: laconicd/tests/sdk_tests
|
working-directory: laconicd/tests/sdk_tests
|
||||||
run: ./run-tests.sh test:authority-auctions
|
run: ./run-tests.sh test:auctions
|
||||||
|
|
||||||
- name: Start containers (expiry enabled)
|
- name: Start containers (expiry enabled)
|
||||||
working-directory: laconicd/tests/sdk_tests
|
working-directory: laconicd/tests/sdk_tests
|
||||||
|
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@ -5,6 +5,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- release/**
|
- release/**
|
||||||
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sdk_tests:
|
sdk_tests:
|
||||||
|
@ -53,7 +53,7 @@ Follow these steps to run the tests:
|
|||||||
- Run tests:
|
- Run tests:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn test:authority-auctions
|
yarn test:auctions
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run the tests for record and authority expiry
|
- Run the tests for record and authority expiry
|
||||||
|
12345
package-lock.json
generated
Normal file
12345
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cerc-io/registry-sdk",
|
"name": "@cerc-io/registry-sdk",
|
||||||
"version": "0.2.11",
|
"version": "0.2.6",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"repository": "git@github.com:cerc-io/registry-sdk.git",
|
"repository": "git@github.com:cerc-io/registry-sdk.git",
|
||||||
@ -62,7 +62,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --runInBand --verbose --testPathPattern=src",
|
"test": "jest --runInBand --verbose --testPathPattern=src",
|
||||||
"test:authority-auctions": "TEST_AUCTIONS_ENABLED=1 jest --runInBand --verbose src/authority-auction.test.ts",
|
"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",
|
"test:nameservice-expiry": "TEST_NAMESERVICE_EXPIRY=1 jest --runInBand --verbose src/nameservice-expiry.test.ts",
|
||||||
"test:onboarding": "ONBOARDING_ENABLED=1 jest --runInBand --verbose src/onboarding.test.ts",
|
"test:onboarding": "ONBOARDING_ENABLED=1 jest --runInBand --verbose src/onboarding.test.ts",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
@ -10,8 +10,4 @@ message Module {
|
|||||||
option (cosmos.app.v1alpha1.module) = {
|
option (cosmos.app.v1alpha1.module) = {
|
||||||
go_import : "git.vdb.to/cerc-io/laconicd/x/auction"
|
go_import : "git.vdb.to/cerc-io/laconicd/x/auction"
|
||||||
};
|
};
|
||||||
|
|
||||||
// authority defines the custom module authority. If not set, defaults to the
|
|
||||||
// governance module.
|
|
||||||
string authority = 2;
|
|
||||||
}
|
}
|
||||||
|
@ -3,44 +3,76 @@ syntax = "proto3";
|
|||||||
package cerc.auction.v1;
|
package cerc.auction.v1;
|
||||||
|
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
|
import "google/protobuf/duration.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
import "cosmos/base/v1beta1/coin.proto";
|
import "cosmos/base/v1beta1/coin.proto";
|
||||||
|
|
||||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/auction";
|
option go_package = "git.vdb.to/cerc-io/laconicd/x/auction";
|
||||||
|
|
||||||
// Params defines the auction module parameters
|
// Params defines the auction module parameters
|
||||||
message Params {}
|
message Params {
|
||||||
|
// Write custom stringer method
|
||||||
|
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
|
// Auction represents a sealed-bid on-chain auction
|
||||||
message Auction {
|
message Auction {
|
||||||
option (gogoproto.goproto_getters) = false;
|
option (gogoproto.goproto_getters) = false;
|
||||||
|
|
||||||
string id = 1;
|
string id = 1;
|
||||||
|
string status = 2;
|
||||||
// Auction kind (vickrey | provider)
|
|
||||||
string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
|
|
||||||
|
|
||||||
string status = 3;
|
|
||||||
|
|
||||||
// Address of the creator of the auction
|
// Address of the creator of the auction
|
||||||
string owner_address = 4;
|
string owner_address = 3;
|
||||||
|
|
||||||
// Timestamp at which the auction was created
|
// Timestamp at which the auction was created
|
||||||
google.protobuf.Timestamp create_time = 5 [
|
google.protobuf.Timestamp create_time = 4 [
|
||||||
(gogoproto.stdtime) = true,
|
(gogoproto.stdtime) = true,
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"create_time\" yaml:\"create_time\""
|
(gogoproto.moretags) = "json:\"create_time\" yaml:\"create_time\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Timestamp at which the commits phase concluded
|
// Timestamp at which the commits phase concluded
|
||||||
google.protobuf.Timestamp commits_end_time = 6 [
|
google.protobuf.Timestamp commits_end_time = 5 [
|
||||||
(gogoproto.stdtime) = true,
|
(gogoproto.stdtime) = true,
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"commits_end_time\" yaml:\"commits_end_time\""
|
(gogoproto.moretags) = "json:\"commits_end_time\" yaml:\"commits_end_time\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Timestamp at which the reveals phase concluded
|
// Timestamp at which the reveals phase concluded
|
||||||
google.protobuf.Timestamp reveals_end_time = 7 [
|
google.protobuf.Timestamp reveals_end_time = 6 [
|
||||||
(gogoproto.stdtime) = true,
|
(gogoproto.stdtime) = true,
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"reveals_end_time\" yaml:\"reveals_end_time\""
|
(gogoproto.moretags) = "json:\"reveals_end_time\" yaml:\"reveals_end_time\""
|
||||||
@ -48,56 +80,35 @@ message Auction {
|
|||||||
|
|
||||||
// Commit and reveal fees must both be paid when committing a bid
|
// Commit and reveal fees must both be paid when committing a bid
|
||||||
// Reveal fee is returned only if the bid is revealed
|
// Reveal fee is returned only if the bid is revealed
|
||||||
cosmos.base.v1beta1.Coin commit_fee = 8 [
|
cosmos.base.v1beta1.Coin commit_fee = 7 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||||
];
|
];
|
||||||
cosmos.base.v1beta1.Coin reveal_fee = 9 [
|
cosmos.base.v1beta1.Coin reveal_fee = 8 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Minimum acceptable bid amount for a valid commit
|
// Minimum acceptable bid amount for a valid commit
|
||||||
// Only applicable in vickrey auctions
|
cosmos.base.v1beta1.Coin minimum_bid = 9 [
|
||||||
cosmos.base.v1beta1.Coin minimum_bid = 10 [
|
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Addresses of the winners
|
// Address of the winner
|
||||||
// (single winner for vickrey auction)
|
string winner_address = 10;
|
||||||
// (multiple winners for provider auctions)
|
|
||||||
repeated string winner_addresses = 11;
|
|
||||||
|
|
||||||
// Winning bids, i.e. the best bids
|
// Winning bid, i.e., the highest bid
|
||||||
repeated cosmos.base.v1beta1.Coin winning_bids = 12 [
|
cosmos.base.v1beta1.Coin winning_bid = 11 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"winning_bids\" yaml:\"winning_bids\""
|
(gogoproto.moretags) = "json:\"winning_bid\" yaml:\"winning_bid\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Auction winning price
|
// Amount the winner pays, i.e. the second highest auction
|
||||||
// vickrey auction: second highest bid, paid by the winner
|
cosmos.base.v1beta1.Coin winning_price = 12 [
|
||||||
// provider auction: higest bid amongst winning_bids, paid by auction creator
|
|
||||||
// to each winner
|
|
||||||
cosmos.base.v1beta1.Coin winning_price = 13 [
|
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\""
|
(gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Maximum acceptable bid amount for a valid commit
|
|
||||||
// Only applicable in provider auctions
|
|
||||||
cosmos.base.v1beta1.Coin max_price = 14 [
|
|
||||||
(gogoproto.nullable) = false,
|
|
||||||
(gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\""
|
|
||||||
];
|
|
||||||
|
|
||||||
// Number of desired providers (num of auction winners)
|
|
||||||
// Only applicable in provider auctions
|
|
||||||
int32 num_providers = 15;
|
|
||||||
|
|
||||||
bool funds_released = 16 [
|
|
||||||
(gogoproto.moretags) =
|
|
||||||
"json:\"funds_released\" yaml:\"funds_released\"" ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auctions represent all the auctions in the module
|
// Auctions represent all the auctions in the module
|
||||||
|
@ -7,7 +7,6 @@ import "gogoproto/gogo.proto";
|
|||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
import "google/protobuf/duration.proto";
|
import "google/protobuf/duration.proto";
|
||||||
import "cosmos/base/v1beta1/coin.proto";
|
import "cosmos/base/v1beta1/coin.proto";
|
||||||
import "cosmos_proto/cosmos.proto";
|
|
||||||
import "cerc/auction/v1/auction.proto";
|
import "cerc/auction/v1/auction.proto";
|
||||||
|
|
||||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/auction";
|
option go_package = "git.vdb.to/cerc-io/laconicd/x/auction";
|
||||||
@ -30,15 +29,6 @@ service Msg {
|
|||||||
rpc RevealBid(MsgRevealBid) returns (MsgRevealBidResponse) {
|
rpc RevealBid(MsgRevealBid) returns (MsgRevealBidResponse) {
|
||||||
option (google.api.http).post = "/cerc/auction/v1/reveal_bid";
|
option (google.api.http).post = "/cerc/auction/v1/reveal_bid";
|
||||||
};
|
};
|
||||||
|
|
||||||
// UpdateParams defines an operation for updating the x/staking module
|
|
||||||
// parameters.
|
|
||||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
|
||||||
|
|
||||||
// ReleaseFunds is the command for paying the winners of provider auctions
|
|
||||||
rpc ReleaseFunds(MsgReleaseFunds) returns (MsgReleaseFundsResponse) {
|
|
||||||
option (google.api.http).post = "/cerc/auction/v1/release_funds";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgCreateAuction defines a create auction message
|
// MsgCreateAuction defines a create auction message
|
||||||
@ -46,56 +36,41 @@ message MsgCreateAuction {
|
|||||||
option (gogoproto.goproto_getters) = false;
|
option (gogoproto.goproto_getters) = false;
|
||||||
option (cosmos.msg.v1.signer) = "signer";
|
option (cosmos.msg.v1.signer) = "signer";
|
||||||
|
|
||||||
// Address of the signer
|
|
||||||
string signer = 1
|
|
||||||
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
|
|
||||||
|
|
||||||
// Auction kind (vickrey | provider)
|
|
||||||
string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ];
|
|
||||||
|
|
||||||
// Duration of the commits phase in seconds
|
// Duration of the commits phase in seconds
|
||||||
google.protobuf.Duration commits_duration = 3 [
|
google.protobuf.Duration commits_duration = 1 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.stdduration) = true,
|
(gogoproto.stdduration) = true,
|
||||||
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
|
(gogoproto.moretags) = "json:\"commits_duration\" yaml:\"commits_duration\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Duration of the reveals phase in seconds
|
// Duration of the reveals phase in seconds
|
||||||
google.protobuf.Duration reveals_duration = 4 [
|
google.protobuf.Duration reveals_duration = 2 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.stdduration) = true,
|
(gogoproto.stdduration) = true,
|
||||||
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
|
(gogoproto.moretags) = "json:\"reveals_duration\" yaml:\"reveals_duration\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Commit fees
|
// Commit fees
|
||||||
cosmos.base.v1beta1.Coin commit_fee = 5 [
|
cosmos.base.v1beta1.Coin commit_fee = 3 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
(gogoproto.moretags) = "json:\"commit_fee\" yaml:\"commit_fee\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Reveal fees
|
// Reveal fees
|
||||||
cosmos.base.v1beta1.Coin reveal_fee = 6 [
|
cosmos.base.v1beta1.Coin reveal_fee = 4 [
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
(gogoproto.moretags) = "json:\"reveal_fee\" yaml:\"reveal_fee\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Minimum acceptable bid amount
|
// Minimum acceptable bid amount
|
||||||
// Only applicable in vickrey auctions
|
cosmos.base.v1beta1.Coin minimum_bid = 5 [
|
||||||
cosmos.base.v1beta1.Coin minimum_bid = 7 [
|
|
||||||
(gogoproto.nullable) = false,
|
(gogoproto.nullable) = false,
|
||||||
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
(gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\""
|
||||||
];
|
];
|
||||||
|
|
||||||
// Maximum acceptable bid amount
|
// Address of the signer
|
||||||
// Only applicable in provider auctions
|
string signer = 6
|
||||||
cosmos.base.v1beta1.Coin max_price = 8 [
|
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
|
||||||
(gogoproto.nullable) = false,
|
|
||||||
(gogoproto.moretags) = "json:\"max_price\" yaml:\"max_price\""
|
|
||||||
];
|
|
||||||
|
|
||||||
// Number of desired providers (num of auction winners)
|
|
||||||
// Only applicable in provider auctions
|
|
||||||
int32 num_providers = 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgCreateAuctionResponse returns the details of the created auction
|
// MsgCreateAuctionResponse returns the details of the created auction
|
||||||
@ -159,44 +134,3 @@ message MsgRevealBidResponse {
|
|||||||
Auction auction = 1
|
Auction auction = 1
|
||||||
[ (gogoproto.moretags) = "json:\"auction\" yaml:\"auction\"" ];
|
[ (gogoproto.moretags) = "json:\"auction\" yaml:\"auction\"" ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
|
||||||
message MsgUpdateParams {
|
|
||||||
option (cosmos.msg.v1.signer) = "authority";
|
|
||||||
|
|
||||||
// authority is the address that controls the module (defaults to x/gov unless
|
|
||||||
// overwritten).
|
|
||||||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
|
|
||||||
|
|
||||||
// params defines the x/auction parameters to update.
|
|
||||||
//
|
|
||||||
// NOTE: All parameters must be supplied.
|
|
||||||
Params params = 2 [ (gogoproto.nullable) = false ];
|
|
||||||
}
|
|
||||||
|
|
||||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
|
||||||
// MsgUpdateParams message.
|
|
||||||
message MsgUpdateParamsResponse {};
|
|
||||||
|
|
||||||
// ReleaseFunds defines the message to pay the winners of provider auctions
|
|
||||||
message MsgReleaseFunds {
|
|
||||||
option (gogoproto.goproto_getters) = false;
|
|
||||||
option (cosmos.msg.v1.signer) = "signer";
|
|
||||||
|
|
||||||
// Auction id
|
|
||||||
string auction_id = 1
|
|
||||||
[ (gogoproto.moretags) = "json:\"auction_id\" yaml:\"auction_id\"" ];
|
|
||||||
|
|
||||||
// Address of the signer
|
|
||||||
string signer = 2
|
|
||||||
[ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ];
|
|
||||||
}
|
|
||||||
|
|
||||||
// MsgReleaseFundsResponse returns the state of the auction after releasing the funds
|
|
||||||
message MsgReleaseFundsResponse {
|
|
||||||
option (gogoproto.goproto_getters) = false;
|
|
||||||
|
|
||||||
// Auction details
|
|
||||||
Auction auction = 1
|
|
||||||
[ (gogoproto.moretags) = "json:\"auction\" yaml:\"auction\"" ];
|
|
||||||
}
|
|
||||||
|
@ -10,8 +10,4 @@ message Module {
|
|||||||
option (cosmos.app.v1alpha1.module) = {
|
option (cosmos.app.v1alpha1.module) = {
|
||||||
go_import : "git.vdb.to/cerc-io/laconicd/x/bond"
|
go_import : "git.vdb.to/cerc-io/laconicd/x/bond"
|
||||||
};
|
};
|
||||||
|
|
||||||
// authority defines the custom module authority. If not set, defaults to the
|
|
||||||
// governance module.
|
|
||||||
string authority = 2;
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,6 @@ import "cosmos/msg/v1/msg.proto";
|
|||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
import "cosmos/base/v1beta1/coin.proto";
|
import "cosmos/base/v1beta1/coin.proto";
|
||||||
import "cosmos_proto/cosmos.proto";
|
|
||||||
import "cerc/bond/v1/bond.proto";
|
|
||||||
|
|
||||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/bond";
|
option go_package = "git.vdb.to/cerc-io/laconicd/x/bond";
|
||||||
|
|
||||||
@ -34,10 +32,6 @@ service Msg {
|
|||||||
rpc CancelBond(MsgCancelBond) returns (MsgCancelBondResponse) {
|
rpc CancelBond(MsgCancelBond) returns (MsgCancelBondResponse) {
|
||||||
option (google.api.http).post = "/cerc/bond/v1/cancel_bond";
|
option (google.api.http).post = "/cerc/bond/v1/cancel_bond";
|
||||||
};
|
};
|
||||||
|
|
||||||
// UpdateParams defines an operation for updating the x/staking module
|
|
||||||
// parameters.
|
|
||||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgCreateBond defines a SDK message for creating a new bond.
|
// MsgCreateBond defines a SDK message for creating a new bond.
|
||||||
@ -97,21 +91,3 @@ message MsgCancelBond {
|
|||||||
|
|
||||||
// MsgCancelBondResponse defines the Msg/CancelBond response type.
|
// MsgCancelBondResponse defines the Msg/CancelBond response type.
|
||||||
message MsgCancelBondResponse {}
|
message MsgCancelBondResponse {}
|
||||||
|
|
||||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
|
||||||
message MsgUpdateParams {
|
|
||||||
option (cosmos.msg.v1.signer) = "authority";
|
|
||||||
|
|
||||||
// authority is the address that controls the module (defaults to x/gov unless
|
|
||||||
// overwritten).
|
|
||||||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
|
|
||||||
|
|
||||||
// params defines the x/bond parameters to update.
|
|
||||||
//
|
|
||||||
// NOTE: All parameters must be supplied.
|
|
||||||
Params params = 2 [ (gogoproto.nullable) = false ];
|
|
||||||
}
|
|
||||||
|
|
||||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
|
||||||
// MsgUpdateParams message.
|
|
||||||
message MsgUpdateParamsResponse {};
|
|
||||||
|
@ -10,8 +10,4 @@ message Module {
|
|||||||
option (cosmos.app.v1alpha1.module) = {
|
option (cosmos.app.v1alpha1.module) = {
|
||||||
go_import : "git.vdb.to/cerc-io/laconicd/x/registry"
|
go_import : "git.vdb.to/cerc-io/laconicd/x/registry"
|
||||||
};
|
};
|
||||||
|
|
||||||
// authority defines the custom module authority. If not set, defaults to the
|
|
||||||
// governance module.
|
|
||||||
string authority = 2;
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import "google/api/annotations.proto";
|
|||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "cosmos/msg/v1/msg.proto";
|
import "cosmos/msg/v1/msg.proto";
|
||||||
import "cerc/registry/v1/registry.proto";
|
import "cerc/registry/v1/registry.proto";
|
||||||
import "cosmos_proto/cosmos.proto";
|
|
||||||
|
|
||||||
option go_package = "git.vdb.to/cerc-io/laconicd/x/registry";
|
option go_package = "git.vdb.to/cerc-io/laconicd/x/registry";
|
||||||
|
|
||||||
@ -67,10 +66,6 @@ service Msg {
|
|||||||
returns (MsgSetAuthorityBondResponse) {
|
returns (MsgSetAuthorityBondResponse) {
|
||||||
option (google.api.http).post = "/cerc/registry/v1/set_authority_bond";
|
option (google.api.http).post = "/cerc/registry/v1/set_authority_bond";
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateParams defines an operation for updating the x/staking module
|
|
||||||
// parameters.
|
|
||||||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgSetRecord
|
// MsgSetRecord
|
||||||
@ -208,21 +203,3 @@ message MsgReassociateRecords {
|
|||||||
|
|
||||||
// MsgReassociateRecordsResponse
|
// MsgReassociateRecordsResponse
|
||||||
message MsgReassociateRecordsResponse {}
|
message MsgReassociateRecordsResponse {}
|
||||||
|
|
||||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
|
||||||
message MsgUpdateParams {
|
|
||||||
option (cosmos.msg.v1.signer) = "authority";
|
|
||||||
|
|
||||||
// authority is the address that controls the module (defaults to x/gov unless
|
|
||||||
// overwritten).
|
|
||||||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
|
|
||||||
|
|
||||||
// params defines the x/registry parameters to update.
|
|
||||||
//
|
|
||||||
// NOTE: All parameters must be supplied.
|
|
||||||
Params params = 2 [ (gogoproto.nullable) = false ];
|
|
||||||
}
|
|
||||||
|
|
||||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
|
||||||
// MsgUpdateParams message.
|
|
||||||
message MsgUpdateParamsResponse {}
|
|
||||||
|
@ -1,390 +1,129 @@
|
|||||||
import { Registry, Account, createBid } from './index';
|
import { Registry, Account, createBid } from './index';
|
||||||
import { createTestAccounts, getConfig } from './testing/helper';
|
import { getConfig } from './testing/helper';
|
||||||
import { DENOM } from './constants';
|
import { DENOM } from './constants';
|
||||||
import { INVALID_BID_ERROR, OWNER_MISMATCH_ERROR, RELEASE_FUNDS_ERROR } from './types/cerc/auction/message';
|
|
||||||
|
|
||||||
jest.setTimeout(30 * 60 * 1000);
|
jest.setTimeout(30 * 60 * 1000);
|
||||||
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
||||||
|
|
||||||
const DURATION = 60;
|
const auctionTests = (numBidders = 3) => {
|
||||||
const TX_FEES = Number(fee.amount[0].amount);
|
|
||||||
const COMMIT_FEE = '1000';
|
|
||||||
const REVEAL_FEE = '1000';
|
|
||||||
|
|
||||||
const CREATOR_INITIAL_BALANCE = 1000000000000;
|
|
||||||
const BIDDER_INITIAL_BALANCE = 20000000;
|
|
||||||
const LOWEST_BID_AMOUNT = 10000000;
|
|
||||||
|
|
||||||
const auctionTests = () => {
|
|
||||||
let registry: Registry;
|
let registry: Registry;
|
||||||
|
|
||||||
|
const accounts: { address: string, privateKey: string, bid?: any }[] = [];
|
||||||
|
|
||||||
let auctionId: string;
|
let auctionId: string;
|
||||||
|
let authorityName: string;
|
||||||
let auctionCreatorAccount: { address: string, privateKey: string };
|
|
||||||
let bidderAccounts: { address: string, privateKey: string, bid?: any }[] = [];
|
|
||||||
|
|
||||||
const numBidders = 3;
|
|
||||||
let bidAmounts: string[] = [];
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
console.log('Running auction tests with num bidders', numBidders);
|
||||||
|
|
||||||
// Create auction creator account
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
const [auctionCreator] = await createTestAccounts(1);
|
});
|
||||||
await registry.sendCoins({ denom: DENOM, amount: CREATOR_INITIAL_BALANCE.toString(), destinationAddress: auctionCreator.address }, privateKey, fee);
|
|
||||||
auctionCreatorAccount = { address: auctionCreator.address, privateKey: auctionCreator.privateKey.toString('hex') };
|
|
||||||
|
|
||||||
// Create bidder accounts
|
test('Setup bidder accounts', async () => {
|
||||||
const accounts = await createTestAccounts(numBidders);
|
|
||||||
for (let i = 0; i < numBidders; i++) {
|
for (let i = 0; i < numBidders; i++) {
|
||||||
await registry.sendCoins({ denom: DENOM, amount: BIDDER_INITIAL_BALANCE.toString(), destinationAddress: accounts[i].address }, privateKey, fee);
|
const mnenonic = Account.generateMnemonic();
|
||||||
bidderAccounts.push({ address: accounts[i].address, privateKey: accounts[i].privateKey.toString('hex') });
|
const account = await Account.generateFromMnemonic(mnenonic);
|
||||||
|
await account.init();
|
||||||
|
await registry.sendCoins({ denom: DENOM, amount: '20000000', destinationAddress: account.address }, privateKey, fee);
|
||||||
|
accounts.push({ address: account.address, privateKey: account.privateKey.toString('hex') });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Create a vickrey auction', async () => {
|
test('Reserve authority.', async () => {
|
||||||
const minimumBid = '1000000';
|
authorityName = `laconic-${Date.now()}`;
|
||||||
|
await registry.reserveAuthority({ name: authorityName }, accounts[0].privateKey, fee);
|
||||||
|
});
|
||||||
|
|
||||||
const auction = await registry.createAuction(
|
test('Authority should be under auction.', async () => {
|
||||||
{
|
const [record] = await registry.lookupAuthorities([authorityName], true);
|
||||||
commitsDuration: DURATION.toString(),
|
expect(record.ownerAddress).toEqual('');
|
||||||
revealsDuration: DURATION.toString(),
|
expect(record.height).toBeDefined();
|
||||||
denom: DENOM,
|
expect(record.status).toEqual('auction');
|
||||||
commitFee: COMMIT_FEE,
|
|
||||||
revealFee: REVEAL_FEE,
|
|
||||||
minimumBid
|
|
||||||
},
|
|
||||||
auctionCreatorAccount.privateKey,
|
|
||||||
fee
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(auction.auction?.id).toBeDefined();
|
expect(record.auction.id).toBeDefined();
|
||||||
|
expect(record.auction.status).toEqual('commit');
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
auctionId = record.auction.id;
|
||||||
auctionId = auction.auction!.id;
|
|
||||||
expect(auction.auction?.status).toEqual('commit');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Commit bids.', async () => {
|
test('Commit bids.', async () => {
|
||||||
for (let i = 0; i < numBidders; i++) {
|
for (let i = 0; i < numBidders; i++) {
|
||||||
bidAmounts.push((LOWEST_BID_AMOUNT + (i * 500)).toString());
|
accounts[i].bid = await createBid(chainId, auctionId, accounts[i].address, `${10000000 + (i * 500)}${DENOM}`);
|
||||||
|
await registry.commitBid({ auctionId, commitHash: accounts[i].bid.commitHash }, accounts[i].privateKey, fee);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await Promise.all(bidderAccounts.map(async (bidderAccount, i) => {
|
test('Check bids are committed', async () => {
|
||||||
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccount.address, `${bidAmounts[i]}${DENOM}`);
|
const [record] = await registry.lookupAuthorities([authorityName], true);
|
||||||
return registry.commitBid({ auctionId, commitHash: bidderAccount.bid.commitHash }, bidderAccount.privateKey, fee);
|
expect(record.auction.id).toBeDefined();
|
||||||
}));
|
expect(record.auction.status).toEqual('commit');
|
||||||
|
expect(record.auction.bids).toHaveLength(accounts.length);
|
||||||
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
record.auction.bids.forEach((bid: any) => {
|
||||||
expect(auction.status).toEqual('commit');
|
|
||||||
expect(auction.bids.length).toEqual(3);
|
|
||||||
auction.bids.forEach((bid: any) => {
|
|
||||||
expect(bid.status).toEqual('commit');
|
expect(bid.status).toEqual('commit');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Wait for reveal phase.', (done) => {
|
test('Wait for reveal phase.', (done) => {
|
||||||
const commitTime = DURATION * 1000;
|
setTimeout(done, 60 * 1000);
|
||||||
const waitTime = commitTime + (6 * 1000);
|
|
||||||
|
|
||||||
setTimeout(done, waitTime);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Reveal bids.', async () => {
|
test('Reveal bids.', async () => {
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
||||||
expect(auction.status).toEqual('reveal');
|
expect(auction.status).toEqual('reveal');
|
||||||
|
|
||||||
await Promise.all(bidderAccounts.map(async bidderAccount => {
|
for (let i = 0; i < numBidders; i++) {
|
||||||
return registry.revealBid({ auctionId, reveal: bidderAccount.bid.revealString }, bidderAccount.privateKey, fee);
|
await registry.revealBid({ auctionId, reveal: accounts[i].bid.revealString }, accounts[i].privateKey, fee);
|
||||||
}));
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Check bids are revealed', async () => {
|
test('Check bids are revealed', async () => {
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
||||||
expect(auction.status).toEqual('reveal');
|
expect(auction.status).toEqual('reveal');
|
||||||
|
|
||||||
auction.bids.forEach((bid: any) => {
|
auction.bids.forEach((bid: any) => {
|
||||||
expect(bid.status).toEqual('reveal');
|
expect(bid.status).toEqual('reveal');
|
||||||
});
|
});
|
||||||
|
|
||||||
const expectedBidAmounts = bidAmounts.map(bidAmount => { return { quantity: bidAmount.toString(), type: DENOM }; });
|
|
||||||
const actualBidAmounts = auction.bids.map((bid: any) => bid.bidAmount);
|
|
||||||
expect(actualBidAmounts).toEqual(expect.arrayContaining(expectedBidAmounts));
|
|
||||||
|
|
||||||
// Check that the bid amounts are locked after reveal phase
|
|
||||||
for (let i = 0; i < numBidders; i++) {
|
|
||||||
// The bid amount, commit fee, reveal fee and tx fees (for commit and reveal txs) will be deducted from the bidder's acoount
|
|
||||||
const expectedBalance = BIDDER_INITIAL_BALANCE - parseInt(bidAmounts[i]) - (2 * TX_FEES) - parseInt(COMMIT_FEE) - parseInt(REVEAL_FEE);
|
|
||||||
await checkAccountBalance(registry, bidderAccounts[i].address, expectedBalance);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Wait for auction completion.', (done) => {
|
test('Wait for auction completion.', (done) => {
|
||||||
const revealTime = DURATION * 1000;
|
setTimeout(done, 60 * 1000);
|
||||||
const waitTime = revealTime + (6 * 1000);
|
|
||||||
|
|
||||||
setTimeout(done, waitTime);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Check auction status, winner address and balance.', async () => {
|
test('Check auction winner, authority owner and status.', async () => {
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
||||||
expect(auction.status).toEqual('completed');
|
expect(auction.status).toEqual('completed');
|
||||||
|
|
||||||
const highestBidder = bidderAccounts[bidderAccounts.length - 1];
|
const highestBidder = accounts[accounts.length - 1];
|
||||||
const secondHighestBidder = bidderAccounts[bidderAccounts.length - 2];
|
const secondHighestBidder = (accounts.length > 1 ? accounts[accounts.length - 2] : highestBidder);
|
||||||
|
|
||||||
expect(auction.winnerAddresses).toHaveLength(1);
|
expect(auction.winnerAddress).toEqual(highestBidder.address);
|
||||||
|
expect(highestBidder.bid.reveal.bidAmount).toEqual(`${auction.winnerBid.quantity}${auction.winnerBid.type}`);
|
||||||
expect(auction.winnerAddresses[0]).toEqual(highestBidder.address);
|
|
||||||
expect(highestBidder.bid.reveal.bidAmount).toEqual(`${auction.winnerBids[0].quantity}${auction.winnerBids[0].type}`);
|
|
||||||
expect(secondHighestBidder.bid.reveal.bidAmount).toEqual(`${auction.winnerPrice.quantity}${auction.winnerPrice.type}`);
|
expect(secondHighestBidder.bid.reveal.bidAmount).toEqual(`${auction.winnerPrice.quantity}${auction.winnerPrice.type}`);
|
||||||
|
|
||||||
const winningPriceAmount = parseInt(auction.winnerPrice.quantity);
|
const [record] = await registry.lookupAuthorities([authorityName], true);
|
||||||
|
expect(record.ownerAddress).toEqual(highestBidder.address);
|
||||||
// The winning price will get deducted after auction completion
|
expect(record.height).toBeDefined();
|
||||||
const expectedBalance = BIDDER_INITIAL_BALANCE - winningPriceAmount - (2 * TX_FEES) - parseInt(COMMIT_FEE);
|
expect(record.status).toEqual('active');
|
||||||
await checkAccountBalance(registry, highestBidder.address, expectedBalance);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const providerAuctionTestsWithBids = (bidAmounts: number[], numProviders: number) => {
|
const withNumBidders = (numBidders: number) => () => auctionTests(numBidders);
|
||||||
let registry: Registry;
|
|
||||||
let auctionId: string;
|
|
||||||
|
|
||||||
let auctionCreatorAccount: { address: string, privateKey: string };
|
if (!process.env.TEST_AUCTIONS_ENABLED) {
|
||||||
let bidderAccounts: { address: string, privateKey: string, bid?: any }[] = [];
|
// Required as jest complains if file has no tests.
|
||||||
let sortedBidders: { address: string, privateKey: string, bid?: any }[] = [];
|
test('skipping auction tests', () => {});
|
||||||
let filteredBidders: { address: string, privateKey: string, bid?: any }[] = [];
|
} else {
|
||||||
let invalidBidderAddress: string;
|
/**
|
||||||
let otherAccount: { address: string, privateKey: string };
|
Running these tests requires name auctions enabled. In laconicd repo run:
|
||||||
|
|
||||||
const numBidders = bidAmounts.length;
|
TEST_AUCTION_ENABLED=true ./init.sh
|
||||||
const maxPrice = 10 * LOWEST_BID_AMOUNT;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
Run tests:
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
|
||||||
|
|
||||||
// Create auction creator account
|
yarn test:auctions
|
||||||
const [auctionCreator] = await createTestAccounts(1);
|
*/
|
||||||
await registry.sendCoins({ denom: DENOM, amount: CREATOR_INITIAL_BALANCE.toString(), destinationAddress: auctionCreator.address }, privateKey, fee);
|
describe('Auction (1 bidder)', withNumBidders(1));
|
||||||
auctionCreatorAccount = { address: auctionCreator.address, privateKey: auctionCreator.privateKey.toString('hex') };
|
describe('Auction (2 bidders)', withNumBidders(2));
|
||||||
|
describe('Auction (4 bidders)', withNumBidders(4));
|
||||||
// Create bidder accounts
|
}
|
||||||
const accounts = await createTestAccounts(numBidders);
|
|
||||||
for (let i = 0; i < numBidders; i++) {
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount: BIDDER_INITIAL_BALANCE.toString(), destinationAddress: accounts[i].address }, privateKey, fee);
|
|
||||||
bidderAccounts.push({ address: accounts[i].address, privateKey: accounts[i].privateKey.toString('hex') });
|
|
||||||
}
|
|
||||||
|
|
||||||
const mnenonic3 = Account.generateMnemonic();
|
|
||||||
const otherAcc = await Account.generateFromMnemonic(mnenonic3);
|
|
||||||
await otherAcc.init();
|
|
||||||
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount: BIDDER_INITIAL_BALANCE.toString(), destinationAddress: otherAcc.address }, privateKey, fee);
|
|
||||||
otherAccount = { address: otherAcc.address, privateKey: otherAcc.privateKey.toString('hex') };
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Create a provider auction', async () => {
|
|
||||||
const auction = await registry.createProviderAuction(
|
|
||||||
{
|
|
||||||
commitsDuration: DURATION.toString(),
|
|
||||||
revealsDuration: DURATION.toString(),
|
|
||||||
denom: DENOM,
|
|
||||||
commitFee: COMMIT_FEE,
|
|
||||||
revealFee: REVEAL_FEE,
|
|
||||||
maxPrice: maxPrice.toString(),
|
|
||||||
numProviders
|
|
||||||
},
|
|
||||||
auctionCreatorAccount.privateKey, fee
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(auction.auction?.id).toBeDefined();
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
auctionId = auction.auction!.id;
|
|
||||||
expect(auction.auction?.status).toEqual('commit');
|
|
||||||
|
|
||||||
// The locked amount and tx fees are deducted from the auction creator's account
|
|
||||||
const expectedBalance = CREATOR_INITIAL_BALANCE - (maxPrice * numProviders) - TX_FEES;
|
|
||||||
await checkAccountBalance(registry, auctionCreatorAccount.address, expectedBalance);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Commit bids.', async () => {
|
|
||||||
await Promise.all(bidderAccounts.map(async (bidderAccount, i) => {
|
|
||||||
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccount.address, `${bidAmounts[i]}${DENOM}`);
|
|
||||||
return registry.commitBid({ auctionId, commitHash: bidderAccount.bid.commitHash }, bidderAccount.privateKey, fee);
|
|
||||||
}));
|
|
||||||
|
|
||||||
sortedBidders = bidderAccounts.slice().sort((a, b) => {
|
|
||||||
return parseInt(a.bid.reveal.bidAmount) - parseInt(b.bid.reveal.bidAmount);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const bidder of sortedBidders) {
|
|
||||||
if (parseInt(bidder.bid.reveal.bidAmount) > maxPrice) {
|
|
||||||
invalidBidderAddress = bidder.address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
|
||||||
expect(auction.status).toEqual('commit');
|
|
||||||
expect(auction.bids.length).toEqual(numBidders);
|
|
||||||
auction.bids.forEach((bid: any) => {
|
|
||||||
expect(bid.status).toEqual('commit');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Wait for reveal phase.', (done) => {
|
|
||||||
const commitTime = DURATION * 1000;
|
|
||||||
const waitTime = commitTime + (6 * 1000);
|
|
||||||
|
|
||||||
setTimeout(done, waitTime);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Reveal bids.', async () => {
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
|
||||||
expect(auction.status).toEqual('reveal');
|
|
||||||
|
|
||||||
await Promise.all(bidderAccounts.map(async bidderAccount => {
|
|
||||||
try {
|
|
||||||
await registry.revealBid(
|
|
||||||
{ auctionId, reveal: bidderAccount.bid.revealString },
|
|
||||||
bidderAccount.privateKey,
|
|
||||||
fee
|
|
||||||
);
|
|
||||||
} catch (error: any) {
|
|
||||||
if (bidderAccount.address === invalidBidderAddress) {
|
|
||||||
expect(error.toString()).toContain(INVALID_BID_ERROR);
|
|
||||||
} else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Check bids are revealed', async () => {
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
|
||||||
expect(auction.status).toEqual('reveal');
|
|
||||||
|
|
||||||
const expectedBids = sortedBidders.map((bidder: any) => {
|
|
||||||
if (invalidBidderAddress === bidder.address) {
|
|
||||||
return '0';
|
|
||||||
}
|
|
||||||
return bidder.bid.reveal.bidAmount;
|
|
||||||
});
|
|
||||||
|
|
||||||
const actualBidAmounts = auction.bids.map((bid: any) => `${bid.bidAmount.quantity}${bid.bidAmount.type}`);
|
|
||||||
expect(actualBidAmounts).toEqual(expect.arrayContaining(expectedBids));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Wait for auction completion.', (done) => {
|
|
||||||
const revealTime = DURATION * 1000;
|
|
||||||
const waitTime = revealTime + (6 * 1000);
|
|
||||||
|
|
||||||
setTimeout(done, waitTime);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Check auction status, winners and creator balance.', async () => {
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
|
||||||
expect(auction.status).toEqual('completed');
|
|
||||||
|
|
||||||
// Filter bidders to exclude bids exceeding maxPrice
|
|
||||||
filteredBidders = sortedBidders.filter(bidder => {
|
|
||||||
return parseInt(bidder.bid.reveal.bidAmount) <= parseInt(`${maxPrice}${DENOM}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
const numWinners = Math.min(filteredBidders.length, numProviders);
|
|
||||||
const winningBidders = filteredBidders.slice(0, numWinners);
|
|
||||||
|
|
||||||
// Check winner price is equal to highest winning bid
|
|
||||||
const expectedWinningPrice = winningBidders[numWinners - 1].bid.reveal.bidAmount;
|
|
||||||
expect(`${auction.winnerPrice.quantity}${auction.winnerPrice.type}`).toEqual(expectedWinningPrice);
|
|
||||||
|
|
||||||
// The total winning amount will get deducted and the leftover locked amount is returned
|
|
||||||
const totalWinningAmount = parseInt(auction.winnerPrice.quantity) * winningBidders.length;
|
|
||||||
const expectedCreatorBalance = CREATOR_INITIAL_BALANCE - totalWinningAmount - TX_FEES;
|
|
||||||
await checkAccountBalance(registry, auctionCreatorAccount.address, expectedCreatorBalance);
|
|
||||||
|
|
||||||
// Funds should not be given to winners on auction completion
|
|
||||||
for (let i = 0; i < winningBidders.length; i++) {
|
|
||||||
const bidWinner = winningBidders[i];
|
|
||||||
|
|
||||||
expect(auction.winnerAddresses[i]).toEqual(bidWinner.address);
|
|
||||||
expect(`${auction.winnerBids[i].quantity}${auction.winnerBids[i].type}`).toEqual(bidWinner.bid.reveal.bidAmount);
|
|
||||||
|
|
||||||
const expectedBidderBalance = BIDDER_INITIAL_BALANCE - (2 * TX_FEES) - parseInt(COMMIT_FEE);
|
|
||||||
await checkAccountBalance(registry, bidWinner.address, expectedBidderBalance);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Release funds and check provider balances.', async () => {
|
|
||||||
const [auction] = await registry.getAuctionsByIds([auctionId]);
|
|
||||||
|
|
||||||
const numWinners = Math.min(filteredBidders.length, numProviders);
|
|
||||||
const winningBidders = filteredBidders.slice(0, numWinners);
|
|
||||||
const losingBidders = bidderAccounts.filter(bidder => !winningBidders.includes(bidder));
|
|
||||||
|
|
||||||
const winningBidAmount = parseInt(auction.winnerPrice.quantity);
|
|
||||||
|
|
||||||
// Only owner can release funds
|
|
||||||
try {
|
|
||||||
await registry.releaseFunds({ auctionId }, otherAccount.privateKey, fee);
|
|
||||||
} catch (error: any) {
|
|
||||||
expect(error.toString()).toContain(OWNER_MISMATCH_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release funds
|
|
||||||
const auctionObj = await registry.releaseFunds({ auctionId }, auctionCreatorAccount.privateKey, fee);
|
|
||||||
expect(auctionObj.auction?.fundsReleased).toBe(true);
|
|
||||||
|
|
||||||
// Auction winners get the winning amount after funds are released
|
|
||||||
const expectedBidderBalance = BIDDER_INITIAL_BALANCE + winningBidAmount - (2 * TX_FEES) - parseInt(COMMIT_FEE);
|
|
||||||
for (let i = 0; i < winningBidders.length; i++) {
|
|
||||||
const bidWinner = winningBidders[i];
|
|
||||||
|
|
||||||
expect(auction.winnerAddresses[i]).toEqual(bidWinner.address);
|
|
||||||
expect(`${auction.winnerBids[i].quantity}${auction.winnerBids[i].type}`).toEqual(bidWinner.bid.reveal.bidAmount);
|
|
||||||
|
|
||||||
await checkAccountBalance(registry, bidWinner.address, expectedBidderBalance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check balances of non-winners
|
|
||||||
for (const bidder of losingBidders) {
|
|
||||||
let expectedBidderBalance: number;
|
|
||||||
if (invalidBidderAddress !== bidder.address) {
|
|
||||||
expectedBidderBalance = BIDDER_INITIAL_BALANCE - (2 * TX_FEES) - parseInt(COMMIT_FEE);
|
|
||||||
} else {
|
|
||||||
// Bid is invalid, reveal fees are not returned
|
|
||||||
expectedBidderBalance = BIDDER_INITIAL_BALANCE - (2 * TX_FEES) - parseInt(COMMIT_FEE) - parseInt(REVEAL_FEE);
|
|
||||||
}
|
|
||||||
|
|
||||||
await checkAccountBalance(registry, bidder.address, expectedBidderBalance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Funds cannot be released twice
|
|
||||||
try {
|
|
||||||
await registry.releaseFunds({ auctionId }, auctionCreatorAccount.privateKey, fee);
|
|
||||||
} catch (error: any) {
|
|
||||||
expect(error.toString()).toContain(RELEASE_FUNDS_ERROR);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const checkAccountBalance = async (registry: Registry, address: string, expectedBalance: number): Promise<void> => {
|
|
||||||
const [winnerAccountObj] = await registry.getAccounts([address]);
|
|
||||||
const [{ type, quantity }] = winnerAccountObj.balance;
|
|
||||||
const actualBalance = parseInt(quantity);
|
|
||||||
|
|
||||||
expect(actualBalance).toBe(expectedBalance);
|
|
||||||
expect(type).toBe(DENOM);
|
|
||||||
};
|
|
||||||
|
|
||||||
const providerAuctionTests = () => {
|
|
||||||
// With a bid amount greater than the max price
|
|
||||||
const bids = [10002000, 10009000, 10006000 * 10, 10004000];
|
|
||||||
|
|
||||||
// Number of providers is less than number of bidders
|
|
||||||
describe('Auction with numProviders < numBidders', () => providerAuctionTestsWithBids(bids, 3));
|
|
||||||
// Number of providers is greater than number of bidders
|
|
||||||
describe('Auction numProviders > numBidders', () => providerAuctionTestsWithBids(bids, 5));
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Vickrey Auction', () => auctionTests());
|
|
||||||
describe('Provider Auction', () => providerAuctionTests());
|
|
||||||
|
@ -1,139 +0,0 @@
|
|||||||
import { Registry, Account, createBid } from './index';
|
|
||||||
import { getConfig } from './testing/helper';
|
|
||||||
import { DENOM } from './constants';
|
|
||||||
|
|
||||||
jest.setTimeout(30 * 60 * 1000);
|
|
||||||
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
|
||||||
|
|
||||||
const DURATION = 60;
|
|
||||||
|
|
||||||
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, rpcEndpoint, { chainId });
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Setup bidder accounts', async () => {
|
|
||||||
for (let i = 0; i < numBidders; i++) {
|
|
||||||
const mnenonic = Account.generateMnemonic();
|
|
||||||
const account = await Account.generateFromMnemonic(mnenonic);
|
|
||||||
await account.init();
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount: '20000000', destinationAddress: account.address }, privateKey, fee);
|
|
||||||
accounts.push({ address: account.address, 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)}${DENOM}`);
|
|
||||||
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) => {
|
|
||||||
const commitTime = DURATION * 1000;
|
|
||||||
const waitTime = commitTime + (6 * 1000);
|
|
||||||
|
|
||||||
setTimeout(done, waitTime);
|
|
||||||
});
|
|
||||||
|
|
||||||
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) => {
|
|
||||||
const revealTime = DURATION * 1000;
|
|
||||||
const waitTime = revealTime + (6 * 1000);
|
|
||||||
|
|
||||||
setTimeout(done, waitTime);
|
|
||||||
});
|
|
||||||
|
|
||||||
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.winnerAddresses).toHaveLength(1);
|
|
||||||
|
|
||||||
expect(auction.winnerAddresses[0]).toEqual(highestBidder.address);
|
|
||||||
expect(`${auction.winnerBids[0].quantity}${auction.winnerBids[0].type}`).toEqual(highestBidder.bid.reveal.bidAmount);
|
|
||||||
expect(`${auction.winnerPrice.quantity}${auction.winnerPrice.type}`).toEqual(secondHighestBidder.bid.reveal.bidAmount);
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { Account, Registry } from './index';
|
import { Registry } from './index';
|
||||||
import { ensureUpdatedConfig, getConfig } from './testing/helper';
|
import { ensureUpdatedConfig, getConfig } from './testing/helper';
|
||||||
import { DENOM } from './constants';
|
import { DENOM } from './constants';
|
||||||
|
|
||||||
@ -13,7 +13,6 @@ jest.setTimeout(90 * 1000);
|
|||||||
|
|
||||||
const bondTests = () => {
|
const bondTests = () => {
|
||||||
let registry: Registry;
|
let registry: Registry;
|
||||||
let bond0: { id: string, owner: string };
|
|
||||||
|
|
||||||
const publishNewWatcherVersion = async (bondId: string) => {
|
const publishNewWatcherVersion = async (bondId: string) => {
|
||||||
let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
|
let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
|
||||||
@ -22,19 +21,17 @@ const bondTests = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Create bond.', async () => {
|
test('Create bond.', async () => {
|
||||||
let bondId = await registry.getNextBondId(privateKey);
|
let bondId = await registry.getNextBondId(privateKey);
|
||||||
expect(bondId).toBeDefined();
|
expect(bondId).toBeDefined();
|
||||||
await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, privateKey, fee);
|
await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, privateKey, fee);
|
||||||
|
|
||||||
[bond0] = await registry.getBondsByIds([bondId]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('With bond created', () => {
|
describe('With bond created', () => {
|
||||||
let bond1: { id: string, owner: string };
|
let bond1: any;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
let bondId1 = await registry.getNextBondId(privateKey);
|
let bondId1 = await registry.getNextBondId(privateKey);
|
||||||
@ -57,31 +54,15 @@ const bondTests = () => {
|
|||||||
test('Query bonds.', async () => {
|
test('Query bonds.', async () => {
|
||||||
const bonds = await registry.queryBonds();
|
const bonds = await registry.queryBonds();
|
||||||
expect(bonds).toBeDefined();
|
expect(bonds).toBeDefined();
|
||||||
|
const bond = bonds.filter((bond: any) => bond.id === bond1.id);
|
||||||
const filteredBonds = bonds.filter((bond: any) => bond.id === bond1.id);
|
expect(bond).toBeDefined();
|
||||||
expect(filteredBonds).toHaveLength(1);
|
|
||||||
expect(filteredBonds[0]).toMatchObject({ id: bond1.id, owner: bond1.owner });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Query bonds by owner.', async () => {
|
test('Query bonds by owner.', async () => {
|
||||||
const mnenonic = Account.generateMnemonic();
|
const bonds = await registry.queryBonds({ owner: bond1.owner });
|
||||||
const otherAccount = await Account.generateFromMnemonic(mnenonic);
|
expect(bonds).toBeDefined();
|
||||||
await otherAccount.init();
|
const bond = bonds.filter((bond: any) => bond.id === bond1.id);
|
||||||
await registry.sendCoins({ denom: DENOM, amount: '1000000000000', destinationAddress: otherAccount.address }, privateKey, fee);
|
expect(bond).toBeDefined();
|
||||||
|
|
||||||
const { id: bondId2 } = await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, otherAccount.getPrivateKey(), fee);
|
|
||||||
|
|
||||||
const [owner1Bonds] = await registry.queryBondsByOwners([bond0.owner]);
|
|
||||||
const owner1Bond1 = owner1Bonds.bonds.filter((b: any) => b.id === bond0.id);
|
|
||||||
const owner1Bond2 = owner1Bonds.bonds.filter((b: any) => b.id === bond1.id);
|
|
||||||
expect(owner1Bond1).toBeDefined();
|
|
||||||
expect(owner1Bond2).toBeDefined();
|
|
||||||
|
|
||||||
const [bond2] = await registry.getBondsByIds([bondId2]);
|
|
||||||
const [owner2Bonds] = await registry.queryBondsByOwners([bond2.owner]);
|
|
||||||
expect(owner2Bonds.bonds).toHaveLength(1);
|
|
||||||
const owner2Bond = owner2Bonds.bonds.filter((b: any) => b.id === bondId2);
|
|
||||||
expect(owner2Bond).toBeDefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Refill bond.', async () => {
|
test('Refill bond.', async () => {
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
import { GasPrice } from '@cosmjs/stargate';
|
|
||||||
|
|
||||||
import { Account } from './account';
|
|
||||||
import { DENOM } from './constants';
|
|
||||||
import { Registry } from './index';
|
|
||||||
import { createTestAccounts, getConfig } from './testing/helper';
|
|
||||||
|
|
||||||
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
|
||||||
|
|
||||||
jest.setTimeout(90 * 1000);
|
|
||||||
|
|
||||||
const configTests = () => {
|
|
||||||
let registry: Registry;
|
|
||||||
let testAccount: Account;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
|
||||||
|
|
||||||
// Fund a new account for the test
|
|
||||||
[testAccount] = await createTestAccounts(1);
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount: '10000000', destinationAddress: testAccount.address }, privateKey, fee);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('StdFee fees with gas price not set', async () => {
|
|
||||||
const testFees = {
|
|
||||||
amount: [{ denom: 'alnt', amount: '400000' }],
|
|
||||||
gas: '400000'
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send a bond creation tx
|
|
||||||
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees);
|
|
||||||
|
|
||||||
// Check that bond gets created
|
|
||||||
const [result] = await registry.queryBondsByOwners([testAccount.address]);
|
|
||||||
expect(result.bonds).toHaveLength(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('StdFee fees with gas price set', async () => {
|
|
||||||
const testFees = {
|
|
||||||
amount: [{ denom: 'alnt', amount: '400000' }],
|
|
||||||
gas: '400000'
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set gas price lower than min gas price
|
|
||||||
const testGasPrice = GasPrice.fromString(String('0.00001alnt'));
|
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
|
||||||
|
|
||||||
// Send a bond creation tx
|
|
||||||
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees);
|
|
||||||
|
|
||||||
// Check that bond gets created (gas price ignored)
|
|
||||||
const [result] = await registry.queryBondsByOwners([testAccount.address]);
|
|
||||||
expect(result.bonds).toHaveLength(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Gas price with fees not set (default gas estimation multiplier)', async () => {
|
|
||||||
// Set gas price
|
|
||||||
const testGasPrice = GasPrice.fromString('1alnt');
|
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
|
||||||
|
|
||||||
// Send a bond creation tx
|
|
||||||
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey());
|
|
||||||
|
|
||||||
// Check that bond gets created (gas price ignored)
|
|
||||||
const [result] = await registry.queryBondsByOwners([testAccount.address]);
|
|
||||||
expect(result.bonds).toHaveLength(3);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Gas price with fees set (fees as the gas estimation multiplier)', async () => {
|
|
||||||
const testFees = 2.1;
|
|
||||||
|
|
||||||
// Set gas price
|
|
||||||
const testGasPrice = GasPrice.fromString('1alnt');
|
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice: testGasPrice });
|
|
||||||
|
|
||||||
// Send a bond creation tx
|
|
||||||
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees);
|
|
||||||
|
|
||||||
// Check that bond gets created (gas price ignored)
|
|
||||||
const [result] = await registry.queryBondsByOwners([testAccount.address]);
|
|
||||||
expect(result.bonds).toHaveLength(4);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Error on fees and gas price both not set', async () => {
|
|
||||||
const errorMsg = 'Gas price must be set in the client options when auto gas is used';
|
|
||||||
|
|
||||||
// Create registry without gasPrice
|
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
|
||||||
|
|
||||||
// Send a bond creation tx
|
|
||||||
try {
|
|
||||||
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey());
|
|
||||||
} catch (error: any) {
|
|
||||||
expect(error.toString()).toContain(errorMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that bond doesn't get created
|
|
||||||
const [result] = await registry.queryBondsByOwners([testAccount.address]);
|
|
||||||
expect(result.bonds).toHaveLength(4);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Config', configTests);
|
|
@ -1,5 +1 @@
|
|||||||
export const DENOM = 'alnt';
|
export const DENOM = 'alnt';
|
||||||
export const DEFAULT_GAS_ESTIMATION_MULTIPLIER = 2;
|
|
||||||
|
|
||||||
export const AUCTION_KIND_VICKREY = 'vickrey';
|
|
||||||
export const AUCTION_KIND_PROVIDER = 'provider';
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Account } from './account';
|
import { Account } from './account';
|
||||||
import { DENOM } from './constants';
|
import { DENOM } from './constants';
|
||||||
import { Registry } from './index';
|
import { Registry } from './index';
|
||||||
import { createTestAccounts, getConfig } from './testing/helper';
|
import { getConfig } from './testing/helper';
|
||||||
|
|
||||||
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ const registryTests = () => {
|
|||||||
let registry: Registry;
|
let registry: Registry;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get account info.', async () => {
|
test('Get account info.', async () => {
|
||||||
@ -43,40 +43,6 @@ const registryTests = () => {
|
|||||||
expect(type).toBe(DENOM);
|
expect(type).toBe(DENOM);
|
||||||
expect(quantity).toBe('10000');
|
expect(quantity).toBe('10000');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Batch txs', () => {
|
|
||||||
let accounts: Account[];
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
// Fund 5 new accounts for the test
|
|
||||||
accounts = await createTestAccounts(5);
|
|
||||||
for (let i = 0; i < accounts.length; i++) {
|
|
||||||
await registry.sendCoins({ denom: DENOM, amount: '1000000', destinationAddress: accounts[i].address }, privateKey, fee);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('Multiple txs get included in a block.', async () => {
|
|
||||||
// Send a bond creation tx from each account (send from different accounts to avoid sequence errors)
|
|
||||||
await Promise.all(accounts.map((account) =>
|
|
||||||
registry.createBond({ denom: DENOM, amount: '100000' }, account.getPrivateKey(), fee)
|
|
||||||
));
|
|
||||||
|
|
||||||
const laconicClient = await registry.getLaconicClient(accounts[0]);
|
|
||||||
const bondCreationTxHeights = await Promise.all(accounts.map(async (account) => {
|
|
||||||
// Get the bond creation tx for each account
|
|
||||||
const [tx] = await laconicClient.searchTx(`message.sender='${account.address}' AND message.action='/cerc.bond.v1.MsgCreateBond'`);
|
|
||||||
return tx.height;
|
|
||||||
}));
|
|
||||||
|
|
||||||
bondCreationTxHeights.forEach((txHeight, i) => {
|
|
||||||
console.log('tx', accounts[i].address, txHeight);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check that all txs are within two blocks
|
|
||||||
const expectedBlockHeight = bondCreationTxHeights.sort()[0];
|
|
||||||
expect(bondCreationTxHeights.every(txHeight => txHeight === expectedBlockHeight || txHeight === expectedBlockHeight + 1)).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Registry', registryTests);
|
describe('Registry', registryTests);
|
||||||
|
175
src/index.ts
175
src/index.ts
@ -1,6 +1,6 @@
|
|||||||
import { sha256 } from 'js-sha256';
|
import { sha256 } from 'js-sha256';
|
||||||
|
|
||||||
import { DeliverTxResponse, StdFee, GasPrice } from '@cosmjs/stargate';
|
import { DeliverTxResponse, StdFee } from '@cosmjs/stargate';
|
||||||
|
|
||||||
import { RegistryClient } from './registry-client';
|
import { RegistryClient } from './registry-client';
|
||||||
import { Account } from './account';
|
import { Account } from './account';
|
||||||
@ -22,10 +22,7 @@ import {
|
|||||||
} from './types/cerc/registry/message';
|
} from './types/cerc/registry/message';
|
||||||
import {
|
import {
|
||||||
MessageMsgCommitBid,
|
MessageMsgCommitBid,
|
||||||
MessageMsgRevealBid,
|
MessageMsgRevealBid
|
||||||
MessageCreateVickreyAuction,
|
|
||||||
MessageCreateProviderAuction,
|
|
||||||
MessageMsgReleaseFunds
|
|
||||||
} from './types/cerc/auction/message';
|
} from './types/cerc/auction/message';
|
||||||
import { MessageMsgSendCoins } from './types/cosmos/bank/message';
|
import { MessageMsgSendCoins } from './types/cosmos/bank/message';
|
||||||
import { MessageMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
import { MessageMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
||||||
@ -34,8 +31,8 @@ import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
|||||||
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
||||||
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
||||||
import { MsgSendResponse } from './proto/cosmos/bank/v1beta1/tx';
|
import { MsgSendResponse } from './proto/cosmos/bank/v1beta1/tx';
|
||||||
import { AUCTION_KIND_PROVIDER, AUCTION_KIND_VICKREY, DEFAULT_GAS_ESTIMATION_MULTIPLIER } from './constants';
|
|
||||||
import { MsgCreateAuctionResponse } from './proto/cerc/auction/v1/tx';
|
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an auction bid.
|
* Create an auction bid.
|
||||||
@ -63,26 +60,19 @@ export const createBid = async (chainId: string, auctionId: string, bidderAddres
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
interface RegistryOptions {
|
|
||||||
chainId: string
|
|
||||||
gasPrice?: GasPrice
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Registry {
|
export class Registry {
|
||||||
_endpoints: { [key: string]: string };
|
_endpoints: { [key: string]: string };
|
||||||
_chainID: string;
|
_chainID: string;
|
||||||
_client: RegistryClient;
|
_client: RegistryClient;
|
||||||
_gasPrice?: GasPrice;
|
|
||||||
|
|
||||||
constructor (gqlUrl: string, rpcUrl = '', options: RegistryOptions) {
|
constructor (gqlUrl: string, rpcUrl = '', chainId: string = DEFAULT_CHAIN_ID) {
|
||||||
this._endpoints = {
|
this._endpoints = {
|
||||||
rpc: rpcUrl,
|
rpc: rpcUrl,
|
||||||
gql: gqlUrl
|
gql: gqlUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
this._client = new RegistryClient(gqlUrl, rpcUrl);
|
this._client = new RegistryClient(gqlUrl, rpcUrl);
|
||||||
this._chainID = options.chainId;
|
this._chainID = chainId;
|
||||||
this._gasPrice = options.gasPrice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,8 +107,8 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Get records by attributes.
|
* Get records by attributes.
|
||||||
*/
|
*/
|
||||||
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false, limit?: number, offset?: number) {
|
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) {
|
||||||
return this._client.queryRecords(attributes, all, refs, limit, offset);
|
return this._client.queryRecords(attributes, all, refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +125,7 @@ export class Registry {
|
|||||||
async setRecord (
|
async setRecord (
|
||||||
{ privateKey, record, bondId }: { privateKey: string, record: any, bondId: string },
|
{ privateKey, record, bondId }: { privateKey: string, record: any, bondId: string },
|
||||||
transactionPrivateKey: string,
|
transactionPrivateKey: string,
|
||||||
fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER
|
fee: StdFee
|
||||||
) {
|
) {
|
||||||
const account = new Account(Buffer.from(transactionPrivateKey, 'hex'));
|
const account = new Account(Buffer.from(transactionPrivateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
@ -150,7 +140,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Send coins.
|
* Send coins.
|
||||||
*/
|
*/
|
||||||
async sendCoins ({ amount, denom, destinationAddress }: MessageMsgSendCoins, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async sendCoins ({ amount, denom, destinationAddress }: MessageMsgSendCoins, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -196,23 +186,16 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query bonds.
|
* Query bonds by attributes.
|
||||||
*/
|
*/
|
||||||
async queryBonds () {
|
async queryBonds (attributes = {}) {
|
||||||
return this._client.queryBonds();
|
return this._client.queryBonds(attributes);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query bonds by owner(s).
|
|
||||||
*/
|
|
||||||
async queryBondsByOwners (owners: string[]) {
|
|
||||||
return this._client.queryBondsByOwners(owners);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create bond.
|
* Create bond.
|
||||||
*/
|
*/
|
||||||
async createBond ({ denom, amount }: MessageMsgCreateBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER): Promise<MsgCreateBondResponse> {
|
async createBond ({ denom, amount }: MessageMsgCreateBond, privateKey: string, fee: StdFee): Promise<MsgCreateBondResponse> {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -228,7 +211,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Refill bond.
|
* Refill bond.
|
||||||
*/
|
*/
|
||||||
async refillBond ({ denom, amount, id }: MessageMsgRefillBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER): Promise<MsgRefillBondResponse> {
|
async refillBond ({ denom, amount, id }: MessageMsgRefillBond, privateKey: string, fee: StdFee): Promise<MsgRefillBondResponse> {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -245,7 +228,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Withdraw (from) bond.
|
* Withdraw (from) bond.
|
||||||
*/
|
*/
|
||||||
async withdrawBond ({ denom, amount, id }: MessageMsgWithdrawBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER): Promise<MsgWithdrawBondResponse> {
|
async withdrawBond ({ denom, amount, id }: MessageMsgWithdrawBond, privateKey: string, fee: StdFee): Promise<MsgWithdrawBondResponse> {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -262,7 +245,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Cancel bond.
|
* Cancel bond.
|
||||||
*/
|
*/
|
||||||
async cancelBond ({ id }: MessageMsgCancelBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER): Promise<MsgCancelBondResponse> {
|
async cancelBond ({ id }: MessageMsgCancelBond, privateKey: string, fee: StdFee): Promise<MsgCancelBondResponse> {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -277,7 +260,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Associate record with bond.
|
* Associate record with bond.
|
||||||
*/
|
*/
|
||||||
async associateBond ({ bondId, recordId }: MessageMsgAssociateBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async associateBond ({ bondId, recordId }: MessageMsgAssociateBond, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -293,7 +276,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Dissociate record from bond.
|
* Dissociate record from bond.
|
||||||
*/
|
*/
|
||||||
async dissociateBond ({ recordId }: MessageMsgDissociateBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async dissociateBond ({ recordId }: MessageMsgDissociateBond, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -308,7 +291,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Dissociate all records from bond.
|
* Dissociate all records from bond.
|
||||||
*/
|
*/
|
||||||
async dissociateRecords ({ bondId }: MessageMsgDissociateRecords, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async dissociateRecords ({ bondId }: MessageMsgDissociateRecords, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -323,7 +306,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Reassociate records (switch bond).
|
* Reassociate records (switch bond).
|
||||||
*/
|
*/
|
||||||
async reassociateRecords ({ newBondId, oldBondId }: MessageMsgReAssociateRecords, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async reassociateRecords ({ newBondId, oldBondId }: MessageMsgReAssociateRecords, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -339,7 +322,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Reserve authority.
|
* Reserve authority.
|
||||||
*/
|
*/
|
||||||
async reserveAuthority ({ name, owner }: { name: string, owner?: string }, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async reserveAuthority ({ name, owner }: { name: string, owner?: string }, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -355,7 +338,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Set authority bond.
|
* Set authority bond.
|
||||||
*/
|
*/
|
||||||
async setAuthorityBond ({ bondId, name }: MessageMsgSetAuthorityBond, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async setAuthorityBond ({ bondId, name }: MessageMsgSetAuthorityBond, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -371,7 +354,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Commit auction bid.
|
* Commit auction bid.
|
||||||
*/
|
*/
|
||||||
async commitBid ({ auctionId, commitHash }: MessageMsgCommitBid, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async commitBid ({ auctionId, commitHash }: MessageMsgCommitBid, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -387,7 +370,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Reveal auction bid.
|
* Reveal auction bid.
|
||||||
*/
|
*/
|
||||||
async revealBid ({ auctionId, reveal }: MessageMsgRevealBid, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async revealBid ({ auctionId, reveal }: MessageMsgRevealBid, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -423,7 +406,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Set name (LRN) to record ID (CID).
|
* Set name (LRN) to record ID (CID).
|
||||||
*/
|
*/
|
||||||
async setName ({ cid, lrn }: MessageMsgSetName, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async setName ({ cid, lrn }: MessageMsgSetName, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -446,7 +429,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Delete name (LRN) mapping.
|
* Delete name (LRN) mapping.
|
||||||
*/
|
*/
|
||||||
async deleteName ({ lrn }: MessageMsgDeleteName, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
async deleteName ({ lrn }: MessageMsgDeleteName, privateKey: string, fee: StdFee) {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -457,10 +440,14 @@ export class Registry {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLaconicClient (account: Account) {
|
||||||
|
return LaconicClient.connectWithSigner(this._endpoints.rpc, account.wallet);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Onboard participant.
|
* Onboard participant.
|
||||||
*/
|
*/
|
||||||
async onboardParticipant ({ ethPayload, ethSignature, role, kycId }: MessageMsgOnboardParticipant, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER): Promise<MsgOnboardParticipantResponse> {
|
async onboardParticipant ({ ethPayload, ethSignature, role, kycId }: MessageMsgOnboardParticipant, privateKey: string, fee: StdFee): Promise<MsgOnboardParticipantResponse> {
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
const account = new Account(Buffer.from(privateKey, 'hex'));
|
||||||
await account.init();
|
await account.init();
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
const laconicClient = await this.getLaconicClient(account);
|
||||||
@ -476,116 +463,28 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query participants.
|
* Query participants.
|
||||||
*/
|
*/
|
||||||
async getParticipants () {
|
async getParticipants () {
|
||||||
return this._client.getParticipants();
|
return this._client.getParticipants();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get participant by cosmos (laconic) address.
|
* Get participant by cosmos (laconic) address.
|
||||||
*/
|
*/
|
||||||
async getParticipantByAddress (address: string) {
|
async getParticipantByAddress (address: string) {
|
||||||
return this._client.getParticipantByAddress(address);
|
return this._client.getParticipantByAddress(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get participant by nitro address.
|
* Get participant by nitro address.
|
||||||
*/
|
*/
|
||||||
async getParticipantByNitroAddress (nitroAddress: string) {
|
async getParticipantByNitroAddress (nitroAddress: string) {
|
||||||
return this._client.getParticipantByNitroAddress(nitroAddress);
|
return this._client.getParticipantByNitroAddress(nitroAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLaconicClient (account: Account) {
|
|
||||||
return LaconicClient.connectWithSigner(
|
|
||||||
this._endpoints.rpc,
|
|
||||||
account.wallet,
|
|
||||||
{ gasPrice: this._gasPrice }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async createAuction (
|
|
||||||
{
|
|
||||||
commitsDuration,
|
|
||||||
revealsDuration,
|
|
||||||
denom,
|
|
||||||
commitFee,
|
|
||||||
revealFee,
|
|
||||||
minimumBid
|
|
||||||
}: MessageCreateVickreyAuction,
|
|
||||||
privateKey: string,
|
|
||||||
fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER
|
|
||||||
): Promise<MsgCreateAuctionResponse> {
|
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
|
||||||
await account.init();
|
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
|
||||||
|
|
||||||
return laconicClient.createAuction(
|
|
||||||
account.address,
|
|
||||||
AUCTION_KIND_VICKREY,
|
|
||||||
commitsDuration,
|
|
||||||
revealsDuration,
|
|
||||||
denom,
|
|
||||||
commitFee,
|
|
||||||
revealFee,
|
|
||||||
minimumBid,
|
|
||||||
'',
|
|
||||||
0,
|
|
||||||
fee
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async createProviderAuction (
|
|
||||||
{
|
|
||||||
commitsDuration,
|
|
||||||
revealsDuration,
|
|
||||||
denom,
|
|
||||||
commitFee,
|
|
||||||
revealFee,
|
|
||||||
maxPrice,
|
|
||||||
numProviders
|
|
||||||
}: MessageCreateProviderAuction,
|
|
||||||
privateKey: string,
|
|
||||||
fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER
|
|
||||||
): Promise<MsgCreateAuctionResponse> {
|
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
|
||||||
await account.init();
|
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
|
||||||
|
|
||||||
return laconicClient.createAuction(
|
|
||||||
account.address,
|
|
||||||
AUCTION_KIND_PROVIDER,
|
|
||||||
commitsDuration,
|
|
||||||
revealsDuration,
|
|
||||||
denom,
|
|
||||||
commitFee,
|
|
||||||
revealFee,
|
|
||||||
'',
|
|
||||||
maxPrice,
|
|
||||||
numProviders,
|
|
||||||
fee
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Release provider auction winner funds.
|
|
||||||
*/
|
|
||||||
async releaseFunds ({ auctionId }: MessageMsgReleaseFunds, privateKey: string, fee: StdFee | number = DEFAULT_GAS_ESTIMATION_MULTIPLIER) {
|
|
||||||
const account = new Account(Buffer.from(privateKey, 'hex'));
|
|
||||||
await account.init();
|
|
||||||
const laconicClient = await this.getLaconicClient(account);
|
|
||||||
|
|
||||||
return laconicClient.releaseFunds(
|
|
||||||
account.address,
|
|
||||||
auctionId,
|
|
||||||
fee
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Account };
|
export { Account };
|
||||||
export { LaconicClient };
|
export { LaconicClient };
|
||||||
export * from './constants';
|
|
||||||
export * from './types/cerc/bond/message';
|
export * from './types/cerc/bond/message';
|
||||||
export * from './types/cerc/onboarding/message';
|
export * from './types/cerc/onboarding/message';
|
||||||
export { getGasPrice, parseGasAndFees } from './util';
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import Long from 'long';
|
|
||||||
|
|
||||||
import { GeneratedType, OfflineSigner, Registry } from '@cosmjs/proto-signing';
|
import { GeneratedType, OfflineSigner, Registry } from '@cosmjs/proto-signing';
|
||||||
import {
|
import {
|
||||||
@ -13,18 +12,17 @@ import { Comet38Client } from '@cosmjs/tendermint-rpc';
|
|||||||
import { MsgCancelBondEncodeObject, MsgCreateBondEncodeObject, MsgRefillBondEncodeObject, MsgWithdrawBondEncodeObject, bondTypes, typeUrlMsgCancelBond, typeUrlMsgCreateBond, typeUrlMsgRefillBond, typeUrlMsgWithdrawBond } from './types/cerc/bond/message';
|
import { MsgCancelBondEncodeObject, MsgCreateBondEncodeObject, MsgRefillBondEncodeObject, MsgWithdrawBondEncodeObject, bondTypes, typeUrlMsgCancelBond, typeUrlMsgCreateBond, typeUrlMsgRefillBond, typeUrlMsgWithdrawBond } from './types/cerc/bond/message';
|
||||||
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
import { Coin } from './proto/cosmos/base/v1beta1/coin';
|
||||||
import { MsgAssociateBondEncodeObject, MsgDeleteNameEncodeObject, MsgDissociateBondEncodeObject, MsgDissociateRecordsEncodeObject, MsgReassociateRecordsEncodeObject, MsgReserveAuthorityEncodeObject, MsgSetAuthorityBondEncodeObject, MsgSetNameEncodeObject, MsgSetRecordEncodeObject, registryTypes, typeUrlMsgAssociateBond, typeUrlMsgDeleteName, typeUrlMsgDissociateBond, typeUrlMsgDissociateRecords, typeUrlMsgReassociateRecords, typeUrlMsgReserveAuthority, typeUrlMsgSetAuthorityBond, typeUrlMsgSetName, typeUrlMsgSetRecord, NAMESERVICE_ERRORS } from './types/cerc/registry/message';
|
import { MsgAssociateBondEncodeObject, MsgDeleteNameEncodeObject, MsgDissociateBondEncodeObject, MsgDissociateRecordsEncodeObject, MsgReassociateRecordsEncodeObject, MsgReserveAuthorityEncodeObject, MsgSetAuthorityBondEncodeObject, MsgSetNameEncodeObject, MsgSetRecordEncodeObject, registryTypes, typeUrlMsgAssociateBond, typeUrlMsgDeleteName, typeUrlMsgDissociateBond, typeUrlMsgDissociateRecords, typeUrlMsgReassociateRecords, typeUrlMsgReserveAuthority, typeUrlMsgSetAuthorityBond, typeUrlMsgSetName, typeUrlMsgSetRecord, NAMESERVICE_ERRORS } from './types/cerc/registry/message';
|
||||||
import { AUCTION_ERRORS, MsgCommitBidEncodeObject, MsgCreateAuctionEncodeObject, MsgReleaseFundsEncodeObject, MsgRevealBidEncodeObject, auctionTypes, typeUrlMsgCommitBid, typeUrlMsgCreateAuction, typeUrlMsgReleaseFunds, typeUrlMsgRevealBid } from './types/cerc/auction/message';
|
import { MsgCommitBidEncodeObject, MsgRevealBidEncodeObject, auctionTypes, typeUrlMsgCommitBid, typeUrlMsgRevealBid } from './types/cerc/auction/message';
|
||||||
import { MsgOnboardParticipantEncodeObject, ONBOARDING_DISABLED_ERROR, onboardingTypes, typeUrlMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
import { MsgOnboardParticipantEncodeObject, onboardingTypes, typeUrlMsgOnboardParticipant } from './types/cerc/onboarding/message';
|
||||||
import { MsgAssociateBondResponse, MsgDeleteNameResponse, MsgDissociateBondResponse, MsgDissociateRecordsResponse, MsgReassociateRecordsResponse, MsgReserveAuthorityResponse, MsgSetAuthorityBondResponse, MsgSetNameResponse, MsgSetRecordResponse, Payload } from './proto/cerc/registry/v1/tx';
|
import { MsgAssociateBondResponse, MsgDeleteNameResponse, MsgDissociateBondResponse, MsgDissociateRecordsResponse, MsgReassociateRecordsResponse, MsgReserveAuthorityResponse, MsgSetAuthorityBondResponse, MsgSetNameResponse, MsgSetRecordResponse, Payload } from './proto/cerc/registry/v1/tx';
|
||||||
import { Record, Signature } from './proto/cerc/registry/v1/registry';
|
import { Record, Signature } from './proto/cerc/registry/v1/registry';
|
||||||
import { Account } from './account';
|
import { Account } from './account';
|
||||||
import { Util } from './util';
|
import { Util } from './util';
|
||||||
import { MsgCommitBidResponse, MsgCreateAuction, MsgCreateAuctionResponse, MsgReleaseFundsResponse, MsgRevealBidResponse } from './proto/cerc/auction/v1/tx';
|
import { MsgCommitBidResponse, MsgRevealBidResponse } from './proto/cerc/auction/v1/tx';
|
||||||
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
|
||||||
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
|
||||||
import { bankTypes } from './types/cosmos/bank/message';
|
import { bankTypes } from './types/cosmos/bank/message';
|
||||||
import { EthPayload } from './proto/cerc/onboarding/v1/onboarding';
|
import { EthPayload } from './proto/cerc/onboarding/v1/onboarding';
|
||||||
import { Duration } from './proto/google/protobuf/duration';
|
|
||||||
|
|
||||||
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
||||||
|
|
||||||
@ -383,7 +381,7 @@ export class LaconicClient extends SigningStargateClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processWriteError (error: string) {
|
processWriteError (error: string) {
|
||||||
const errorMessage = [...NAMESERVICE_ERRORS, ...AUCTION_ERRORS, ONBOARDING_DISABLED_ERROR].find(message => error.includes(message));
|
const errorMessage = NAMESERVICE_ERRORS.find(message => error.includes(message));
|
||||||
|
|
||||||
if (!errorMessage) {
|
if (!errorMessage) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -415,55 +413,4 @@ export class LaconicClient extends SigningStargateClient {
|
|||||||
const response = await this.signAndBroadcast(signer, [onboardParticipantMsg], fee, memo);
|
const response = await this.signAndBroadcast(signer, [onboardParticipantMsg], fee, memo);
|
||||||
return this.parseResponse<MsgOnboardParticipantResponse>(response);
|
return this.parseResponse<MsgOnboardParticipantResponse>(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createAuction (
|
|
||||||
signer: string,
|
|
||||||
kind: string,
|
|
||||||
commitsDuration: string,
|
|
||||||
revealsDuration: string,
|
|
||||||
denom: string,
|
|
||||||
commitFee: string,
|
|
||||||
revealFee: string,
|
|
||||||
minimumBid: string,
|
|
||||||
maxPrice: string,
|
|
||||||
numProviders: number,
|
|
||||||
fee: StdFee | 'auto' | number,
|
|
||||||
memo = ''
|
|
||||||
) {
|
|
||||||
const createAuctionMsg: MsgCreateAuctionEncodeObject = {
|
|
||||||
typeUrl: typeUrlMsgCreateAuction,
|
|
||||||
value: {
|
|
||||||
signer,
|
|
||||||
kind,
|
|
||||||
commitsDuration: Duration.fromPartial({ seconds: Long.fromString(commitsDuration) }),
|
|
||||||
revealsDuration: Duration.fromPartial({ seconds: Long.fromString(revealsDuration) }),
|
|
||||||
commitFee: Coin.fromPartial({ amount: commitFee, denom }),
|
|
||||||
revealFee: Coin.fromPartial({ amount: revealFee, denom }),
|
|
||||||
minimumBid: Coin.fromPartial({ amount: minimumBid, denom }),
|
|
||||||
maxPrice: Coin.fromPartial({ amount: maxPrice, denom }),
|
|
||||||
numProviders
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await this.signAndBroadcast(signer, [createAuctionMsg], fee, memo);
|
|
||||||
return this.parseResponse<MsgCreateAuctionResponse>(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async releaseFunds (
|
|
||||||
signer: string,
|
|
||||||
auctionId: string,
|
|
||||||
fee: StdFee | 'auto' | number,
|
|
||||||
memo = ''
|
|
||||||
) {
|
|
||||||
const createMsg: MsgReleaseFundsEncodeObject = {
|
|
||||||
typeUrl: typeUrlMsgReleaseFunds,
|
|
||||||
value: {
|
|
||||||
signer,
|
|
||||||
auctionId
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await this.signAndBroadcast(signer, [createMsg], fee, memo);
|
|
||||||
return this.parseResponse<MsgReleaseFundsResponse>(response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ const nameserviceExpiryTests = () => {
|
|||||||
let recordExpiryTime: Date;
|
let recordExpiryTime: Date;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
@ -34,7 +34,7 @@ const namingTests = () => {
|
|||||||
let account: CosmosAccount;
|
let account: CosmosAccount;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
@ -2,7 +2,7 @@ import { Wallet } from 'ethers';
|
|||||||
|
|
||||||
import { DirectSecp256k1Wallet, AccountData as CosmosAccount } from '@cosmjs/proto-signing';
|
import { DirectSecp256k1Wallet, AccountData as CosmosAccount } from '@cosmjs/proto-signing';
|
||||||
|
|
||||||
import { Registry, Account, ONBOARDING_DISABLED_ERROR } from './index';
|
import { Registry, Account } from './index';
|
||||||
import { getConfig } from './testing/helper';
|
import { getConfig } from './testing/helper';
|
||||||
import { Participant } from './proto/cerc/onboarding/v1/onboarding';
|
import { Participant } from './proto/cerc/onboarding/v1/onboarding';
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ const onboardingEnabledTests = () => {
|
|||||||
let expectedParticipants: Participant[] = [];
|
let expectedParticipants: Participant[] = [];
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
const mnemonic = Account.generateMnemonic();
|
const mnemonic = Account.generateMnemonic();
|
||||||
ethWallet = Wallet.fromMnemonic(mnemonic);
|
ethWallet = Wallet.fromMnemonic(mnemonic);
|
||||||
@ -76,10 +76,11 @@ const onboardingDisabledTests = () => {
|
|||||||
let ethWallet: Wallet;
|
let ethWallet: Wallet;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Error on onboarding attempt.', async () => {
|
test('Error on onboarding attempt.', async () => {
|
||||||
|
const errorMsg = 'Validator onboarding is disabled: invalid request';
|
||||||
const mnemonic = Account.generateMnemonic();
|
const mnemonic = Account.generateMnemonic();
|
||||||
ethWallet = Wallet.fromMnemonic(mnemonic);
|
ethWallet = Wallet.fromMnemonic(mnemonic);
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ const onboardingDisabledTests = () => {
|
|||||||
kycId: DUMMY_KYC_ID
|
kycId: DUMMY_KYC_ID
|
||||||
}, privateKey, fee);
|
}, privateKey, fee);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
expect(error.toString()).toContain(ONBOARDING_DISABLED_ERROR);
|
expect(error.toString()).toContain(errorMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,26 +8,14 @@ export const protobufPackage = "cerc.auction.module.v1";
|
|||||||
* Module is the app config object of the module.
|
* Module is the app config object of the module.
|
||||||
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
||||||
*/
|
*/
|
||||||
export interface Module {
|
export interface Module {}
|
||||||
/**
|
|
||||||
* authority defines the custom module authority. If not set, defaults to the
|
|
||||||
* governance module.
|
|
||||||
*/
|
|
||||||
authority: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBaseModule(): Module {
|
function createBaseModule(): Module {
|
||||||
return { authority: "" };
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Module = {
|
export const Module = {
|
||||||
encode(
|
encode(_: Module, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||||
message: Module,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.authority !== "") {
|
|
||||||
writer.uint32(18).string(message.authority);
|
|
||||||
}
|
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -38,9 +26,6 @@ export const Module = {
|
|||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 2:
|
|
||||||
message.authority = reader.string();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
reader.skipType(tag & 7);
|
reader.skipType(tag & 7);
|
||||||
break;
|
break;
|
||||||
@ -49,21 +34,17 @@ export const Module = {
|
|||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromJSON(object: any): Module {
|
fromJSON(_: any): Module {
|
||||||
return {
|
return {};
|
||||||
authority: isSet(object.authority) ? String(object.authority) : "",
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON(message: Module): unknown {
|
toJSON(_: Module): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.authority !== undefined && (obj.authority = message.authority);
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<Module>, I>>(object: I): Module {
|
fromPartial<I extends Exact<DeepPartial<Module>, I>>(_: I): Module {
|
||||||
const message = createBaseModule();
|
const message = createBaseModule();
|
||||||
message.authority = object.authority ?? "";
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -100,7 +81,3 @@ if (_m0.util.Long !== Long) {
|
|||||||
_m0.util.Long = Long as any;
|
_m0.util.Long = Long as any;
|
||||||
_m0.configure();
|
_m0.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSet(value: any): boolean {
|
|
||||||
return value !== null && value !== undefined;
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
import { Duration } from "../../../google/protobuf/duration";
|
||||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||||
import { Timestamp } from "../../../google/protobuf/timestamp";
|
import { Timestamp } from "../../../google/protobuf/timestamp";
|
||||||
import Long from "long";
|
import Long from "long";
|
||||||
@ -7,13 +8,22 @@ import _m0 from "protobufjs/minimal";
|
|||||||
export const protobufPackage = "cerc.auction.v1";
|
export const protobufPackage = "cerc.auction.v1";
|
||||||
|
|
||||||
/** Params defines the auction module parameters */
|
/** Params defines the auction module parameters */
|
||||||
export interface Params {}
|
export interface Params {
|
||||||
|
/** Duration of the commits phase in seconds */
|
||||||
|
commitsDuration?: Duration;
|
||||||
|
/** Duration of the reveals phase in seconds */
|
||||||
|
revealsDuration?: Duration;
|
||||||
|
/** Commit fees */
|
||||||
|
commitFee?: Coin;
|
||||||
|
/** Reveal fees */
|
||||||
|
revealFee?: Coin;
|
||||||
|
/** Minimum acceptable bid amount */
|
||||||
|
minimumBid?: Coin;
|
||||||
|
}
|
||||||
|
|
||||||
/** Auction represents a sealed-bid on-chain auction */
|
/** Auction represents a sealed-bid on-chain auction */
|
||||||
export interface Auction {
|
export interface Auction {
|
||||||
id: string;
|
id: string;
|
||||||
/** Auction kind (vickrey | provider) */
|
|
||||||
kind: string;
|
|
||||||
status: string;
|
status: string;
|
||||||
/** Address of the creator of the auction */
|
/** Address of the creator of the auction */
|
||||||
ownerAddress: string;
|
ownerAddress: string;
|
||||||
@ -29,37 +39,14 @@ export interface Auction {
|
|||||||
*/
|
*/
|
||||||
commitFee?: Coin;
|
commitFee?: Coin;
|
||||||
revealFee?: Coin;
|
revealFee?: Coin;
|
||||||
/**
|
/** Minimum acceptable bid amount for a valid commit */
|
||||||
* Minimum acceptable bid amount for a valid commit
|
|
||||||
* Only applicable in vickrey auctions
|
|
||||||
*/
|
|
||||||
minimumBid?: Coin;
|
minimumBid?: Coin;
|
||||||
/**
|
/** Address of the winner */
|
||||||
* Addresses of the winners
|
winnerAddress: string;
|
||||||
* (single winner for vickrey auction)
|
/** Winning bid, i.e., the highest bid */
|
||||||
* (multiple winners for provider auctions)
|
winningBid?: Coin;
|
||||||
*/
|
/** Amount the winner pays, i.e. the second highest auction */
|
||||||
winnerAddresses: string[];
|
|
||||||
/** Winning bids, i.e. the best bids */
|
|
||||||
winningBids: Coin[];
|
|
||||||
/**
|
|
||||||
* Auction winning price
|
|
||||||
* vickrey auction: second highest bid, paid by the winner
|
|
||||||
* provider auction: higest bid amongst winning_bids, paid by auction creator
|
|
||||||
* to each winner
|
|
||||||
*/
|
|
||||||
winningPrice?: Coin;
|
winningPrice?: Coin;
|
||||||
/**
|
|
||||||
* Maximum acceptable bid amount for a valid commit
|
|
||||||
* Only applicable in provider auctions
|
|
||||||
*/
|
|
||||||
maxPrice?: Coin;
|
|
||||||
/**
|
|
||||||
* Number of desired providers (num of auction winners)
|
|
||||||
* Only applicable in provider auctions
|
|
||||||
*/
|
|
||||||
numProviders: number;
|
|
||||||
fundsReleased: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Auctions represent all the auctions in the module */
|
/** Auctions represent all the auctions in the module */
|
||||||
@ -81,11 +68,41 @@ export interface Bid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createBaseParams(): Params {
|
function createBaseParams(): Params {
|
||||||
return {};
|
return {
|
||||||
|
commitsDuration: undefined,
|
||||||
|
revealsDuration: undefined,
|
||||||
|
commitFee: undefined,
|
||||||
|
revealFee: undefined,
|
||||||
|
minimumBid: undefined,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Params = {
|
export const Params = {
|
||||||
encode(_: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
encode(
|
||||||
|
message: Params,
|
||||||
|
writer: _m0.Writer = _m0.Writer.create()
|
||||||
|
): _m0.Writer {
|
||||||
|
if (message.commitsDuration !== undefined) {
|
||||||
|
Duration.encode(
|
||||||
|
message.commitsDuration,
|
||||||
|
writer.uint32(10).fork()
|
||||||
|
).ldelim();
|
||||||
|
}
|
||||||
|
if (message.revealsDuration !== undefined) {
|
||||||
|
Duration.encode(
|
||||||
|
message.revealsDuration,
|
||||||
|
writer.uint32(18).fork()
|
||||||
|
).ldelim();
|
||||||
|
}
|
||||||
|
if (message.commitFee !== undefined) {
|
||||||
|
Coin.encode(message.commitFee, writer.uint32(26).fork()).ldelim();
|
||||||
|
}
|
||||||
|
if (message.revealFee !== undefined) {
|
||||||
|
Coin.encode(message.revealFee, writer.uint32(34).fork()).ldelim();
|
||||||
|
}
|
||||||
|
if (message.minimumBid !== undefined) {
|
||||||
|
Coin.encode(message.minimumBid, writer.uint32(42).fork()).ldelim();
|
||||||
|
}
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -96,6 +113,21 @@ export const Params = {
|
|||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
|
case 1:
|
||||||
|
message.commitsDuration = Duration.decode(reader, reader.uint32());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
message.revealsDuration = Duration.decode(reader, reader.uint32());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
message.commitFee = Coin.decode(reader, reader.uint32());
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
message.revealFee = Coin.decode(reader, reader.uint32());
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
message.minimumBid = Coin.decode(reader, reader.uint32());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
reader.skipType(tag & 7);
|
reader.skipType(tag & 7);
|
||||||
break;
|
break;
|
||||||
@ -104,17 +136,73 @@ export const Params = {
|
|||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromJSON(_: any): Params {
|
fromJSON(object: any): Params {
|
||||||
return {};
|
return {
|
||||||
|
commitsDuration: isSet(object.commitsDuration)
|
||||||
|
? Duration.fromJSON(object.commitsDuration)
|
||||||
|
: undefined,
|
||||||
|
revealsDuration: isSet(object.revealsDuration)
|
||||||
|
? Duration.fromJSON(object.revealsDuration)
|
||||||
|
: undefined,
|
||||||
|
commitFee: isSet(object.commitFee)
|
||||||
|
? Coin.fromJSON(object.commitFee)
|
||||||
|
: undefined,
|
||||||
|
revealFee: isSet(object.revealFee)
|
||||||
|
? Coin.fromJSON(object.revealFee)
|
||||||
|
: undefined,
|
||||||
|
minimumBid: isSet(object.minimumBid)
|
||||||
|
? Coin.fromJSON(object.minimumBid)
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON(_: Params): unknown {
|
toJSON(message: Params): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
|
message.commitsDuration !== undefined &&
|
||||||
|
(obj.commitsDuration = message.commitsDuration
|
||||||
|
? Duration.toJSON(message.commitsDuration)
|
||||||
|
: undefined);
|
||||||
|
message.revealsDuration !== undefined &&
|
||||||
|
(obj.revealsDuration = message.revealsDuration
|
||||||
|
? Duration.toJSON(message.revealsDuration)
|
||||||
|
: undefined);
|
||||||
|
message.commitFee !== undefined &&
|
||||||
|
(obj.commitFee = message.commitFee
|
||||||
|
? Coin.toJSON(message.commitFee)
|
||||||
|
: undefined);
|
||||||
|
message.revealFee !== undefined &&
|
||||||
|
(obj.revealFee = message.revealFee
|
||||||
|
? Coin.toJSON(message.revealFee)
|
||||||
|
: undefined);
|
||||||
|
message.minimumBid !== undefined &&
|
||||||
|
(obj.minimumBid = message.minimumBid
|
||||||
|
? Coin.toJSON(message.minimumBid)
|
||||||
|
: undefined);
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<Params>, I>>(_: I): Params {
|
fromPartial<I extends Exact<DeepPartial<Params>, I>>(object: I): Params {
|
||||||
const message = createBaseParams();
|
const message = createBaseParams();
|
||||||
|
message.commitsDuration =
|
||||||
|
object.commitsDuration !== undefined && object.commitsDuration !== null
|
||||||
|
? Duration.fromPartial(object.commitsDuration)
|
||||||
|
: undefined;
|
||||||
|
message.revealsDuration =
|
||||||
|
object.revealsDuration !== undefined && object.revealsDuration !== null
|
||||||
|
? Duration.fromPartial(object.revealsDuration)
|
||||||
|
: undefined;
|
||||||
|
message.commitFee =
|
||||||
|
object.commitFee !== undefined && object.commitFee !== null
|
||||||
|
? Coin.fromPartial(object.commitFee)
|
||||||
|
: undefined;
|
||||||
|
message.revealFee =
|
||||||
|
object.revealFee !== undefined && object.revealFee !== null
|
||||||
|
? Coin.fromPartial(object.revealFee)
|
||||||
|
: undefined;
|
||||||
|
message.minimumBid =
|
||||||
|
object.minimumBid !== undefined && object.minimumBid !== null
|
||||||
|
? Coin.fromPartial(object.minimumBid)
|
||||||
|
: undefined;
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -122,7 +210,6 @@ export const Params = {
|
|||||||
function createBaseAuction(): Auction {
|
function createBaseAuction(): Auction {
|
||||||
return {
|
return {
|
||||||
id: "",
|
id: "",
|
||||||
kind: "",
|
|
||||||
status: "",
|
status: "",
|
||||||
ownerAddress: "",
|
ownerAddress: "",
|
||||||
createTime: undefined,
|
createTime: undefined,
|
||||||
@ -131,12 +218,9 @@ function createBaseAuction(): Auction {
|
|||||||
commitFee: undefined,
|
commitFee: undefined,
|
||||||
revealFee: undefined,
|
revealFee: undefined,
|
||||||
minimumBid: undefined,
|
minimumBid: undefined,
|
||||||
winnerAddresses: [],
|
winnerAddress: "",
|
||||||
winningBids: [],
|
winningBid: undefined,
|
||||||
winningPrice: undefined,
|
winningPrice: undefined,
|
||||||
maxPrice: undefined,
|
|
||||||
numProviders: 0,
|
|
||||||
fundsReleased: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,59 +232,47 @@ export const Auction = {
|
|||||||
if (message.id !== "") {
|
if (message.id !== "") {
|
||||||
writer.uint32(10).string(message.id);
|
writer.uint32(10).string(message.id);
|
||||||
}
|
}
|
||||||
if (message.kind !== "") {
|
|
||||||
writer.uint32(18).string(message.kind);
|
|
||||||
}
|
|
||||||
if (message.status !== "") {
|
if (message.status !== "") {
|
||||||
writer.uint32(26).string(message.status);
|
writer.uint32(18).string(message.status);
|
||||||
}
|
}
|
||||||
if (message.ownerAddress !== "") {
|
if (message.ownerAddress !== "") {
|
||||||
writer.uint32(34).string(message.ownerAddress);
|
writer.uint32(26).string(message.ownerAddress);
|
||||||
}
|
}
|
||||||
if (message.createTime !== undefined) {
|
if (message.createTime !== undefined) {
|
||||||
Timestamp.encode(
|
Timestamp.encode(
|
||||||
toTimestamp(message.createTime),
|
toTimestamp(message.createTime),
|
||||||
writer.uint32(42).fork()
|
writer.uint32(34).fork()
|
||||||
).ldelim();
|
).ldelim();
|
||||||
}
|
}
|
||||||
if (message.commitsEndTime !== undefined) {
|
if (message.commitsEndTime !== undefined) {
|
||||||
Timestamp.encode(
|
Timestamp.encode(
|
||||||
toTimestamp(message.commitsEndTime),
|
toTimestamp(message.commitsEndTime),
|
||||||
writer.uint32(50).fork()
|
writer.uint32(42).fork()
|
||||||
).ldelim();
|
).ldelim();
|
||||||
}
|
}
|
||||||
if (message.revealsEndTime !== undefined) {
|
if (message.revealsEndTime !== undefined) {
|
||||||
Timestamp.encode(
|
Timestamp.encode(
|
||||||
toTimestamp(message.revealsEndTime),
|
toTimestamp(message.revealsEndTime),
|
||||||
writer.uint32(58).fork()
|
writer.uint32(50).fork()
|
||||||
).ldelim();
|
).ldelim();
|
||||||
}
|
}
|
||||||
if (message.commitFee !== undefined) {
|
if (message.commitFee !== undefined) {
|
||||||
Coin.encode(message.commitFee, writer.uint32(66).fork()).ldelim();
|
Coin.encode(message.commitFee, writer.uint32(58).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.revealFee !== undefined) {
|
if (message.revealFee !== undefined) {
|
||||||
Coin.encode(message.revealFee, writer.uint32(74).fork()).ldelim();
|
Coin.encode(message.revealFee, writer.uint32(66).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.minimumBid !== undefined) {
|
if (message.minimumBid !== undefined) {
|
||||||
Coin.encode(message.minimumBid, writer.uint32(82).fork()).ldelim();
|
Coin.encode(message.minimumBid, writer.uint32(74).fork()).ldelim();
|
||||||
}
|
}
|
||||||
for (const v of message.winnerAddresses) {
|
if (message.winnerAddress !== "") {
|
||||||
writer.uint32(90).string(v!);
|
writer.uint32(82).string(message.winnerAddress);
|
||||||
}
|
}
|
||||||
for (const v of message.winningBids) {
|
if (message.winningBid !== undefined) {
|
||||||
Coin.encode(v!, writer.uint32(98).fork()).ldelim();
|
Coin.encode(message.winningBid, writer.uint32(90).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.winningPrice !== undefined) {
|
if (message.winningPrice !== undefined) {
|
||||||
Coin.encode(message.winningPrice, writer.uint32(106).fork()).ldelim();
|
Coin.encode(message.winningPrice, writer.uint32(98).fork()).ldelim();
|
||||||
}
|
|
||||||
if (message.maxPrice !== undefined) {
|
|
||||||
Coin.encode(message.maxPrice, writer.uint32(114).fork()).ldelim();
|
|
||||||
}
|
|
||||||
if (message.numProviders !== 0) {
|
|
||||||
writer.uint32(120).int32(message.numProviders);
|
|
||||||
}
|
|
||||||
if (message.fundsReleased === true) {
|
|
||||||
writer.uint32(128).bool(message.fundsReleased);
|
|
||||||
}
|
}
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
@ -216,56 +288,44 @@ export const Auction = {
|
|||||||
message.id = reader.string();
|
message.id = reader.string();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
message.kind = reader.string();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
message.status = reader.string();
|
message.status = reader.string();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
message.ownerAddress = reader.string();
|
message.ownerAddress = reader.string();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 4:
|
||||||
message.createTime = fromTimestamp(
|
message.createTime = fromTimestamp(
|
||||||
Timestamp.decode(reader, reader.uint32())
|
Timestamp.decode(reader, reader.uint32())
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 5:
|
||||||
message.commitsEndTime = fromTimestamp(
|
message.commitsEndTime = fromTimestamp(
|
||||||
Timestamp.decode(reader, reader.uint32())
|
Timestamp.decode(reader, reader.uint32())
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 6:
|
||||||
message.revealsEndTime = fromTimestamp(
|
message.revealsEndTime = fromTimestamp(
|
||||||
Timestamp.decode(reader, reader.uint32())
|
Timestamp.decode(reader, reader.uint32())
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 7:
|
||||||
message.commitFee = Coin.decode(reader, reader.uint32());
|
message.commitFee = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 8:
|
||||||
message.revealFee = Coin.decode(reader, reader.uint32());
|
message.revealFee = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 9:
|
||||||
message.minimumBid = Coin.decode(reader, reader.uint32());
|
message.minimumBid = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
|
case 10:
|
||||||
|
message.winnerAddress = reader.string();
|
||||||
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
message.winnerAddresses.push(reader.string());
|
message.winningBid = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
message.winningBids.push(Coin.decode(reader, reader.uint32()));
|
|
||||||
break;
|
|
||||||
case 13:
|
|
||||||
message.winningPrice = Coin.decode(reader, reader.uint32());
|
message.winningPrice = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 14:
|
|
||||||
message.maxPrice = Coin.decode(reader, reader.uint32());
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
message.numProviders = reader.int32();
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
message.fundsReleased = reader.bool();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
reader.skipType(tag & 7);
|
reader.skipType(tag & 7);
|
||||||
break;
|
break;
|
||||||
@ -277,7 +337,6 @@ export const Auction = {
|
|||||||
fromJSON(object: any): Auction {
|
fromJSON(object: any): Auction {
|
||||||
return {
|
return {
|
||||||
id: isSet(object.id) ? String(object.id) : "",
|
id: isSet(object.id) ? String(object.id) : "",
|
||||||
kind: isSet(object.kind) ? String(object.kind) : "",
|
|
||||||
status: isSet(object.status) ? String(object.status) : "",
|
status: isSet(object.status) ? String(object.status) : "",
|
||||||
ownerAddress: isSet(object.ownerAddress)
|
ownerAddress: isSet(object.ownerAddress)
|
||||||
? String(object.ownerAddress)
|
? String(object.ownerAddress)
|
||||||
@ -300,31 +359,21 @@ export const Auction = {
|
|||||||
minimumBid: isSet(object.minimumBid)
|
minimumBid: isSet(object.minimumBid)
|
||||||
? Coin.fromJSON(object.minimumBid)
|
? Coin.fromJSON(object.minimumBid)
|
||||||
: undefined,
|
: undefined,
|
||||||
winnerAddresses: Array.isArray(object?.winnerAddresses)
|
winnerAddress: isSet(object.winnerAddress)
|
||||||
? object.winnerAddresses.map((e: any) => String(e))
|
? String(object.winnerAddress)
|
||||||
: [],
|
: "",
|
||||||
winningBids: Array.isArray(object?.winningBids)
|
winningBid: isSet(object.winningBid)
|
||||||
? object.winningBids.map((e: any) => Coin.fromJSON(e))
|
? Coin.fromJSON(object.winningBid)
|
||||||
: [],
|
: undefined,
|
||||||
winningPrice: isSet(object.winningPrice)
|
winningPrice: isSet(object.winningPrice)
|
||||||
? Coin.fromJSON(object.winningPrice)
|
? Coin.fromJSON(object.winningPrice)
|
||||||
: undefined,
|
: undefined,
|
||||||
maxPrice: isSet(object.maxPrice)
|
|
||||||
? Coin.fromJSON(object.maxPrice)
|
|
||||||
: undefined,
|
|
||||||
numProviders: isSet(object.numProviders)
|
|
||||||
? Number(object.numProviders)
|
|
||||||
: 0,
|
|
||||||
fundsReleased: isSet(object.fundsReleased)
|
|
||||||
? Boolean(object.fundsReleased)
|
|
||||||
: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON(message: Auction): unknown {
|
toJSON(message: Auction): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.id !== undefined && (obj.id = message.id);
|
message.id !== undefined && (obj.id = message.id);
|
||||||
message.kind !== undefined && (obj.kind = message.kind);
|
|
||||||
message.status !== undefined && (obj.status = message.status);
|
message.status !== undefined && (obj.status = message.status);
|
||||||
message.ownerAddress !== undefined &&
|
message.ownerAddress !== undefined &&
|
||||||
(obj.ownerAddress = message.ownerAddress);
|
(obj.ownerAddress = message.ownerAddress);
|
||||||
@ -346,37 +395,22 @@ export const Auction = {
|
|||||||
(obj.minimumBid = message.minimumBid
|
(obj.minimumBid = message.minimumBid
|
||||||
? Coin.toJSON(message.minimumBid)
|
? Coin.toJSON(message.minimumBid)
|
||||||
: undefined);
|
: undefined);
|
||||||
if (message.winnerAddresses) {
|
message.winnerAddress !== undefined &&
|
||||||
obj.winnerAddresses = message.winnerAddresses.map((e) => e);
|
(obj.winnerAddress = message.winnerAddress);
|
||||||
} else {
|
message.winningBid !== undefined &&
|
||||||
obj.winnerAddresses = [];
|
(obj.winningBid = message.winningBid
|
||||||
}
|
? Coin.toJSON(message.winningBid)
|
||||||
if (message.winningBids) {
|
: undefined);
|
||||||
obj.winningBids = message.winningBids.map((e) =>
|
|
||||||
e ? Coin.toJSON(e) : undefined
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
obj.winningBids = [];
|
|
||||||
}
|
|
||||||
message.winningPrice !== undefined &&
|
message.winningPrice !== undefined &&
|
||||||
(obj.winningPrice = message.winningPrice
|
(obj.winningPrice = message.winningPrice
|
||||||
? Coin.toJSON(message.winningPrice)
|
? Coin.toJSON(message.winningPrice)
|
||||||
: undefined);
|
: undefined);
|
||||||
message.maxPrice !== undefined &&
|
|
||||||
(obj.maxPrice = message.maxPrice
|
|
||||||
? Coin.toJSON(message.maxPrice)
|
|
||||||
: undefined);
|
|
||||||
message.numProviders !== undefined &&
|
|
||||||
(obj.numProviders = Math.round(message.numProviders));
|
|
||||||
message.fundsReleased !== undefined &&
|
|
||||||
(obj.fundsReleased = message.fundsReleased);
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<Auction>, I>>(object: I): Auction {
|
fromPartial<I extends Exact<DeepPartial<Auction>, I>>(object: I): Auction {
|
||||||
const message = createBaseAuction();
|
const message = createBaseAuction();
|
||||||
message.id = object.id ?? "";
|
message.id = object.id ?? "";
|
||||||
message.kind = object.kind ?? "";
|
|
||||||
message.status = object.status ?? "";
|
message.status = object.status ?? "";
|
||||||
message.ownerAddress = object.ownerAddress ?? "";
|
message.ownerAddress = object.ownerAddress ?? "";
|
||||||
message.createTime = object.createTime ?? undefined;
|
message.createTime = object.createTime ?? undefined;
|
||||||
@ -394,19 +428,15 @@ export const Auction = {
|
|||||||
object.minimumBid !== undefined && object.minimumBid !== null
|
object.minimumBid !== undefined && object.minimumBid !== null
|
||||||
? Coin.fromPartial(object.minimumBid)
|
? Coin.fromPartial(object.minimumBid)
|
||||||
: undefined;
|
: undefined;
|
||||||
message.winnerAddresses = object.winnerAddresses?.map((e) => e) || [];
|
message.winnerAddress = object.winnerAddress ?? "";
|
||||||
message.winningBids =
|
message.winningBid =
|
||||||
object.winningBids?.map((e) => Coin.fromPartial(e)) || [];
|
object.winningBid !== undefined && object.winningBid !== null
|
||||||
|
? Coin.fromPartial(object.winningBid)
|
||||||
|
: undefined;
|
||||||
message.winningPrice =
|
message.winningPrice =
|
||||||
object.winningPrice !== undefined && object.winningPrice !== null
|
object.winningPrice !== undefined && object.winningPrice !== null
|
||||||
? Coin.fromPartial(object.winningPrice)
|
? Coin.fromPartial(object.winningPrice)
|
||||||
: undefined;
|
: undefined;
|
||||||
message.maxPrice =
|
|
||||||
object.maxPrice !== undefined && object.maxPrice !== null
|
|
||||||
? Coin.fromPartial(object.maxPrice)
|
|
||||||
: undefined;
|
|
||||||
message.numProviders = object.numProviders ?? 0;
|
|
||||||
message.fundsReleased = object.fundsReleased ?? false;
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { Duration } from "../../../google/protobuf/duration";
|
import { Duration } from "../../../google/protobuf/duration";
|
||||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||||
import { Auction, Bid, Params } from "./auction";
|
import { Auction, Bid } from "./auction";
|
||||||
import Long from "long";
|
import Long from "long";
|
||||||
import _m0 from "protobufjs/minimal";
|
import _m0 from "protobufjs/minimal";
|
||||||
|
|
||||||
@ -9,10 +9,6 @@ export const protobufPackage = "cerc.auction.v1";
|
|||||||
|
|
||||||
/** MsgCreateAuction defines a create auction message */
|
/** MsgCreateAuction defines a create auction message */
|
||||||
export interface MsgCreateAuction {
|
export interface MsgCreateAuction {
|
||||||
/** Address of the signer */
|
|
||||||
signer: string;
|
|
||||||
/** Auction kind (vickrey | provider) */
|
|
||||||
kind: string;
|
|
||||||
/** Duration of the commits phase in seconds */
|
/** Duration of the commits phase in seconds */
|
||||||
commitsDuration?: Duration;
|
commitsDuration?: Duration;
|
||||||
/** Duration of the reveals phase in seconds */
|
/** Duration of the reveals phase in seconds */
|
||||||
@ -21,21 +17,10 @@ export interface MsgCreateAuction {
|
|||||||
commitFee?: Coin;
|
commitFee?: Coin;
|
||||||
/** Reveal fees */
|
/** Reveal fees */
|
||||||
revealFee?: Coin;
|
revealFee?: Coin;
|
||||||
/**
|
/** Minimum acceptable bid amount */
|
||||||
* Minimum acceptable bid amount
|
|
||||||
* Only applicable in vickrey auctions
|
|
||||||
*/
|
|
||||||
minimumBid?: Coin;
|
minimumBid?: Coin;
|
||||||
/**
|
/** Address of the signer */
|
||||||
* Maximum acceptable bid amount
|
signer: string;
|
||||||
* Only applicable in provider auctions
|
|
||||||
*/
|
|
||||||
maxPrice?: Coin;
|
|
||||||
/**
|
|
||||||
* Number of desired providers (num of auction winners)
|
|
||||||
* Only applicable in provider auctions
|
|
||||||
*/
|
|
||||||
numProviders: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** MsgCreateAuctionResponse returns the details of the created auction */
|
/** MsgCreateAuctionResponse returns the details of the created auction */
|
||||||
@ -76,52 +61,14 @@ export interface MsgRevealBidResponse {
|
|||||||
auction?: Auction;
|
auction?: Auction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** MsgUpdateParams is the Msg/UpdateParams request type. */
|
|
||||||
export interface MsgUpdateParams {
|
|
||||||
/**
|
|
||||||
* authority is the address that controls the module (defaults to x/gov unless
|
|
||||||
* overwritten).
|
|
||||||
*/
|
|
||||||
authority: string;
|
|
||||||
/**
|
|
||||||
* params defines the x/auction parameters to update.
|
|
||||||
*
|
|
||||||
* NOTE: All parameters must be supplied.
|
|
||||||
*/
|
|
||||||
params?: Params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MsgUpdateParamsResponse defines the response structure for executing a
|
|
||||||
* MsgUpdateParams message.
|
|
||||||
*/
|
|
||||||
export interface MsgUpdateParamsResponse {}
|
|
||||||
|
|
||||||
/** ReleaseFunds defines the message to pay the winners of provider auctions */
|
|
||||||
export interface MsgReleaseFunds {
|
|
||||||
/** Auction id */
|
|
||||||
auctionId: string;
|
|
||||||
/** Address of the signer */
|
|
||||||
signer: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** MsgReleaseFundsResponse returns the state of the auction after releasing the funds */
|
|
||||||
export interface MsgReleaseFundsResponse {
|
|
||||||
/** Auction details */
|
|
||||||
auction?: Auction;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBaseMsgCreateAuction(): MsgCreateAuction {
|
function createBaseMsgCreateAuction(): MsgCreateAuction {
|
||||||
return {
|
return {
|
||||||
signer: "",
|
|
||||||
kind: "",
|
|
||||||
commitsDuration: undefined,
|
commitsDuration: undefined,
|
||||||
revealsDuration: undefined,
|
revealsDuration: undefined,
|
||||||
commitFee: undefined,
|
commitFee: undefined,
|
||||||
revealFee: undefined,
|
revealFee: undefined,
|
||||||
minimumBid: undefined,
|
minimumBid: undefined,
|
||||||
maxPrice: undefined,
|
signer: "",
|
||||||
numProviders: 0,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,38 +77,29 @@ export const MsgCreateAuction = {
|
|||||||
message: MsgCreateAuction,
|
message: MsgCreateAuction,
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
writer: _m0.Writer = _m0.Writer.create()
|
||||||
): _m0.Writer {
|
): _m0.Writer {
|
||||||
if (message.signer !== "") {
|
|
||||||
writer.uint32(10).string(message.signer);
|
|
||||||
}
|
|
||||||
if (message.kind !== "") {
|
|
||||||
writer.uint32(18).string(message.kind);
|
|
||||||
}
|
|
||||||
if (message.commitsDuration !== undefined) {
|
if (message.commitsDuration !== undefined) {
|
||||||
Duration.encode(
|
Duration.encode(
|
||||||
message.commitsDuration,
|
message.commitsDuration,
|
||||||
writer.uint32(26).fork()
|
writer.uint32(10).fork()
|
||||||
).ldelim();
|
).ldelim();
|
||||||
}
|
}
|
||||||
if (message.revealsDuration !== undefined) {
|
if (message.revealsDuration !== undefined) {
|
||||||
Duration.encode(
|
Duration.encode(
|
||||||
message.revealsDuration,
|
message.revealsDuration,
|
||||||
writer.uint32(34).fork()
|
writer.uint32(18).fork()
|
||||||
).ldelim();
|
).ldelim();
|
||||||
}
|
}
|
||||||
if (message.commitFee !== undefined) {
|
if (message.commitFee !== undefined) {
|
||||||
Coin.encode(message.commitFee, writer.uint32(42).fork()).ldelim();
|
Coin.encode(message.commitFee, writer.uint32(26).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.revealFee !== undefined) {
|
if (message.revealFee !== undefined) {
|
||||||
Coin.encode(message.revealFee, writer.uint32(50).fork()).ldelim();
|
Coin.encode(message.revealFee, writer.uint32(34).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.minimumBid !== undefined) {
|
if (message.minimumBid !== undefined) {
|
||||||
Coin.encode(message.minimumBid, writer.uint32(58).fork()).ldelim();
|
Coin.encode(message.minimumBid, writer.uint32(42).fork()).ldelim();
|
||||||
}
|
}
|
||||||
if (message.maxPrice !== undefined) {
|
if (message.signer !== "") {
|
||||||
Coin.encode(message.maxPrice, writer.uint32(66).fork()).ldelim();
|
writer.uint32(50).string(message.signer);
|
||||||
}
|
|
||||||
if (message.numProviders !== 0) {
|
|
||||||
writer.uint32(72).int32(message.numProviders);
|
|
||||||
}
|
}
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
@ -174,31 +112,22 @@ export const MsgCreateAuction = {
|
|||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 1:
|
case 1:
|
||||||
message.signer = reader.string();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
message.kind = reader.string();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
message.commitsDuration = Duration.decode(reader, reader.uint32());
|
message.commitsDuration = Duration.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 2:
|
||||||
message.revealsDuration = Duration.decode(reader, reader.uint32());
|
message.revealsDuration = Duration.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 3:
|
||||||
message.commitFee = Coin.decode(reader, reader.uint32());
|
message.commitFee = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 4:
|
||||||
message.revealFee = Coin.decode(reader, reader.uint32());
|
message.revealFee = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 5:
|
||||||
message.minimumBid = Coin.decode(reader, reader.uint32());
|
message.minimumBid = Coin.decode(reader, reader.uint32());
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 6:
|
||||||
message.maxPrice = Coin.decode(reader, reader.uint32());
|
message.signer = reader.string();
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
message.numProviders = reader.int32();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
reader.skipType(tag & 7);
|
reader.skipType(tag & 7);
|
||||||
@ -210,8 +139,6 @@ export const MsgCreateAuction = {
|
|||||||
|
|
||||||
fromJSON(object: any): MsgCreateAuction {
|
fromJSON(object: any): MsgCreateAuction {
|
||||||
return {
|
return {
|
||||||
signer: isSet(object.signer) ? String(object.signer) : "",
|
|
||||||
kind: isSet(object.kind) ? String(object.kind) : "",
|
|
||||||
commitsDuration: isSet(object.commitsDuration)
|
commitsDuration: isSet(object.commitsDuration)
|
||||||
? Duration.fromJSON(object.commitsDuration)
|
? Duration.fromJSON(object.commitsDuration)
|
||||||
: undefined,
|
: undefined,
|
||||||
@ -227,19 +154,12 @@ export const MsgCreateAuction = {
|
|||||||
minimumBid: isSet(object.minimumBid)
|
minimumBid: isSet(object.minimumBid)
|
||||||
? Coin.fromJSON(object.minimumBid)
|
? Coin.fromJSON(object.minimumBid)
|
||||||
: undefined,
|
: undefined,
|
||||||
maxPrice: isSet(object.maxPrice)
|
signer: isSet(object.signer) ? String(object.signer) : "",
|
||||||
? Coin.fromJSON(object.maxPrice)
|
|
||||||
: undefined,
|
|
||||||
numProviders: isSet(object.numProviders)
|
|
||||||
? Number(object.numProviders)
|
|
||||||
: 0,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON(message: MsgCreateAuction): unknown {
|
toJSON(message: MsgCreateAuction): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.signer !== undefined && (obj.signer = message.signer);
|
|
||||||
message.kind !== undefined && (obj.kind = message.kind);
|
|
||||||
message.commitsDuration !== undefined &&
|
message.commitsDuration !== undefined &&
|
||||||
(obj.commitsDuration = message.commitsDuration
|
(obj.commitsDuration = message.commitsDuration
|
||||||
? Duration.toJSON(message.commitsDuration)
|
? Duration.toJSON(message.commitsDuration)
|
||||||
@ -260,12 +180,7 @@ export const MsgCreateAuction = {
|
|||||||
(obj.minimumBid = message.minimumBid
|
(obj.minimumBid = message.minimumBid
|
||||||
? Coin.toJSON(message.minimumBid)
|
? Coin.toJSON(message.minimumBid)
|
||||||
: undefined);
|
: undefined);
|
||||||
message.maxPrice !== undefined &&
|
message.signer !== undefined && (obj.signer = message.signer);
|
||||||
(obj.maxPrice = message.maxPrice
|
|
||||||
? Coin.toJSON(message.maxPrice)
|
|
||||||
: undefined);
|
|
||||||
message.numProviders !== undefined &&
|
|
||||||
(obj.numProviders = Math.round(message.numProviders));
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -273,8 +188,6 @@ export const MsgCreateAuction = {
|
|||||||
object: I
|
object: I
|
||||||
): MsgCreateAuction {
|
): MsgCreateAuction {
|
||||||
const message = createBaseMsgCreateAuction();
|
const message = createBaseMsgCreateAuction();
|
||||||
message.signer = object.signer ?? "";
|
|
||||||
message.kind = object.kind ?? "";
|
|
||||||
message.commitsDuration =
|
message.commitsDuration =
|
||||||
object.commitsDuration !== undefined && object.commitsDuration !== null
|
object.commitsDuration !== undefined && object.commitsDuration !== null
|
||||||
? Duration.fromPartial(object.commitsDuration)
|
? Duration.fromPartial(object.commitsDuration)
|
||||||
@ -295,11 +208,7 @@ export const MsgCreateAuction = {
|
|||||||
object.minimumBid !== undefined && object.minimumBid !== null
|
object.minimumBid !== undefined && object.minimumBid !== null
|
||||||
? Coin.fromPartial(object.minimumBid)
|
? Coin.fromPartial(object.minimumBid)
|
||||||
: undefined;
|
: undefined;
|
||||||
message.maxPrice =
|
message.signer = object.signer ?? "";
|
||||||
object.maxPrice !== undefined && object.maxPrice !== null
|
|
||||||
? Coin.fromPartial(object.maxPrice)
|
|
||||||
: undefined;
|
|
||||||
message.numProviders = object.numProviders ?? 0;
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -639,248 +548,6 @@ export const MsgRevealBidResponse = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function createBaseMsgUpdateParams(): MsgUpdateParams {
|
|
||||||
return { authority: "", params: undefined };
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgUpdateParams = {
|
|
||||||
encode(
|
|
||||||
message: MsgUpdateParams,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.authority !== "") {
|
|
||||||
writer.uint32(10).string(message.authority);
|
|
||||||
}
|
|
||||||
if (message.params !== undefined) {
|
|
||||||
Params.encode(message.params, writer.uint32(18).fork()).ldelim();
|
|
||||||
}
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateParams {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgUpdateParams();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
case 1:
|
|
||||||
message.authority = reader.string();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
message.params = Params.decode(reader, reader.uint32());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(object: any): MsgUpdateParams {
|
|
||||||
return {
|
|
||||||
authority: isSet(object.authority) ? String(object.authority) : "",
|
|
||||||
params: isSet(object.params) ? Params.fromJSON(object.params) : undefined,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(message: MsgUpdateParams): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
message.authority !== undefined && (obj.authority = message.authority);
|
|
||||||
message.params !== undefined &&
|
|
||||||
(obj.params = message.params ? Params.toJSON(message.params) : undefined);
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgUpdateParams>, I>>(
|
|
||||||
object: I
|
|
||||||
): MsgUpdateParams {
|
|
||||||
const message = createBaseMsgUpdateParams();
|
|
||||||
message.authority = object.authority ?? "";
|
|
||||||
message.params =
|
|
||||||
object.params !== undefined && object.params !== null
|
|
||||||
? Params.fromPartial(object.params)
|
|
||||||
: undefined;
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgUpdateParamsResponse = {
|
|
||||||
encode(
|
|
||||||
_: MsgUpdateParamsResponse,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(
|
|
||||||
input: _m0.Reader | Uint8Array,
|
|
||||||
length?: number
|
|
||||||
): MsgUpdateParamsResponse {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgUpdateParamsResponse();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(_: any): MsgUpdateParamsResponse {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(_: MsgUpdateParamsResponse): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgUpdateParamsResponse>, I>>(
|
|
||||||
_: I
|
|
||||||
): MsgUpdateParamsResponse {
|
|
||||||
const message = createBaseMsgUpdateParamsResponse();
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function createBaseMsgReleaseFunds(): MsgReleaseFunds {
|
|
||||||
return { auctionId: "", signer: "" };
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgReleaseFunds = {
|
|
||||||
encode(
|
|
||||||
message: MsgReleaseFunds,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.auctionId !== "") {
|
|
||||||
writer.uint32(10).string(message.auctionId);
|
|
||||||
}
|
|
||||||
if (message.signer !== "") {
|
|
||||||
writer.uint32(18).string(message.signer);
|
|
||||||
}
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgReleaseFunds {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgReleaseFunds();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
case 1:
|
|
||||||
message.auctionId = reader.string();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
message.signer = reader.string();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(object: any): MsgReleaseFunds {
|
|
||||||
return {
|
|
||||||
auctionId: isSet(object.auctionId) ? String(object.auctionId) : "",
|
|
||||||
signer: isSet(object.signer) ? String(object.signer) : "",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(message: MsgReleaseFunds): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
message.auctionId !== undefined && (obj.auctionId = message.auctionId);
|
|
||||||
message.signer !== undefined && (obj.signer = message.signer);
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgReleaseFunds>, I>>(
|
|
||||||
object: I
|
|
||||||
): MsgReleaseFunds {
|
|
||||||
const message = createBaseMsgReleaseFunds();
|
|
||||||
message.auctionId = object.auctionId ?? "";
|
|
||||||
message.signer = object.signer ?? "";
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function createBaseMsgReleaseFundsResponse(): MsgReleaseFundsResponse {
|
|
||||||
return { auction: undefined };
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgReleaseFundsResponse = {
|
|
||||||
encode(
|
|
||||||
message: MsgReleaseFundsResponse,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.auction !== undefined) {
|
|
||||||
Auction.encode(message.auction, writer.uint32(10).fork()).ldelim();
|
|
||||||
}
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(
|
|
||||||
input: _m0.Reader | Uint8Array,
|
|
||||||
length?: number
|
|
||||||
): MsgReleaseFundsResponse {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgReleaseFundsResponse();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
case 1:
|
|
||||||
message.auction = Auction.decode(reader, reader.uint32());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(object: any): MsgReleaseFundsResponse {
|
|
||||||
return {
|
|
||||||
auction: isSet(object.auction)
|
|
||||||
? Auction.fromJSON(object.auction)
|
|
||||||
: undefined,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(message: MsgReleaseFundsResponse): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
message.auction !== undefined &&
|
|
||||||
(obj.auction = message.auction
|
|
||||||
? Auction.toJSON(message.auction)
|
|
||||||
: undefined);
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgReleaseFundsResponse>, I>>(
|
|
||||||
object: I
|
|
||||||
): MsgReleaseFundsResponse {
|
|
||||||
const message = createBaseMsgReleaseFundsResponse();
|
|
||||||
message.auction =
|
|
||||||
object.auction !== undefined && object.auction !== null
|
|
||||||
? Auction.fromPartial(object.auction)
|
|
||||||
: undefined;
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Tx defines the gRPC tx interface */
|
/** Tx defines the gRPC tx interface */
|
||||||
export interface Msg {
|
export interface Msg {
|
||||||
/** CreateAuction is the command for creating an auction */
|
/** CreateAuction is the command for creating an auction */
|
||||||
@ -889,13 +556,6 @@ export interface Msg {
|
|||||||
CommitBid(request: MsgCommitBid): Promise<MsgCommitBidResponse>;
|
CommitBid(request: MsgCommitBid): Promise<MsgCommitBidResponse>;
|
||||||
/** RevealBid is the command for revealing a bid */
|
/** RevealBid is the command for revealing a bid */
|
||||||
RevealBid(request: MsgRevealBid): Promise<MsgRevealBidResponse>;
|
RevealBid(request: MsgRevealBid): Promise<MsgRevealBidResponse>;
|
||||||
/**
|
|
||||||
* UpdateParams defines an operation for updating the x/staking module
|
|
||||||
* parameters.
|
|
||||||
*/
|
|
||||||
UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse>;
|
|
||||||
/** ReleaseFunds is the command for paying the winners of provider auctions */
|
|
||||||
ReleaseFunds(request: MsgReleaseFunds): Promise<MsgReleaseFundsResponse>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MsgClientImpl implements Msg {
|
export class MsgClientImpl implements Msg {
|
||||||
@ -905,8 +565,6 @@ export class MsgClientImpl implements Msg {
|
|||||||
this.CreateAuction = this.CreateAuction.bind(this);
|
this.CreateAuction = this.CreateAuction.bind(this);
|
||||||
this.CommitBid = this.CommitBid.bind(this);
|
this.CommitBid = this.CommitBid.bind(this);
|
||||||
this.RevealBid = this.RevealBid.bind(this);
|
this.RevealBid = this.RevealBid.bind(this);
|
||||||
this.UpdateParams = this.UpdateParams.bind(this);
|
|
||||||
this.ReleaseFunds = this.ReleaseFunds.bind(this);
|
|
||||||
}
|
}
|
||||||
CreateAuction(request: MsgCreateAuction): Promise<MsgCreateAuctionResponse> {
|
CreateAuction(request: MsgCreateAuction): Promise<MsgCreateAuctionResponse> {
|
||||||
const data = MsgCreateAuction.encode(request).finish();
|
const data = MsgCreateAuction.encode(request).finish();
|
||||||
@ -935,30 +593,6 @@ export class MsgClientImpl implements Msg {
|
|||||||
MsgRevealBidResponse.decode(new _m0.Reader(data))
|
MsgRevealBidResponse.decode(new _m0.Reader(data))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse> {
|
|
||||||
const data = MsgUpdateParams.encode(request).finish();
|
|
||||||
const promise = this.rpc.request(
|
|
||||||
"cerc.auction.v1.Msg",
|
|
||||||
"UpdateParams",
|
|
||||||
data
|
|
||||||
);
|
|
||||||
return promise.then((data) =>
|
|
||||||
MsgUpdateParamsResponse.decode(new _m0.Reader(data))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReleaseFunds(request: MsgReleaseFunds): Promise<MsgReleaseFundsResponse> {
|
|
||||||
const data = MsgReleaseFunds.encode(request).finish();
|
|
||||||
const promise = this.rpc.request(
|
|
||||||
"cerc.auction.v1.Msg",
|
|
||||||
"ReleaseFunds",
|
|
||||||
data
|
|
||||||
);
|
|
||||||
return promise.then((data) =>
|
|
||||||
MsgReleaseFundsResponse.decode(new _m0.Reader(data))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Rpc {
|
interface Rpc {
|
||||||
|
@ -8,26 +8,14 @@ export const protobufPackage = "cerc.bond.module.v1";
|
|||||||
* Module is the app config object of the module.
|
* Module is the app config object of the module.
|
||||||
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
||||||
*/
|
*/
|
||||||
export interface Module {
|
export interface Module {}
|
||||||
/**
|
|
||||||
* authority defines the custom module authority. If not set, defaults to the
|
|
||||||
* governance module.
|
|
||||||
*/
|
|
||||||
authority: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBaseModule(): Module {
|
function createBaseModule(): Module {
|
||||||
return { authority: "" };
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Module = {
|
export const Module = {
|
||||||
encode(
|
encode(_: Module, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||||
message: Module,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.authority !== "") {
|
|
||||||
writer.uint32(18).string(message.authority);
|
|
||||||
}
|
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -38,9 +26,6 @@ export const Module = {
|
|||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 2:
|
|
||||||
message.authority = reader.string();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
reader.skipType(tag & 7);
|
reader.skipType(tag & 7);
|
||||||
break;
|
break;
|
||||||
@ -49,21 +34,17 @@ export const Module = {
|
|||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromJSON(object: any): Module {
|
fromJSON(_: any): Module {
|
||||||
return {
|
return {};
|
||||||
authority: isSet(object.authority) ? String(object.authority) : "",
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON(message: Module): unknown {
|
toJSON(_: Module): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.authority !== undefined && (obj.authority = message.authority);
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<Module>, I>>(object: I): Module {
|
fromPartial<I extends Exact<DeepPartial<Module>, I>>(_: I): Module {
|
||||||
const message = createBaseModule();
|
const message = createBaseModule();
|
||||||
message.authority = object.authority ?? "";
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -100,7 +81,3 @@ if (_m0.util.Long !== Long) {
|
|||||||
_m0.util.Long = Long as any;
|
_m0.util.Long = Long as any;
|
||||||
_m0.configure();
|
_m0.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSet(value: any): boolean {
|
|
||||||
return value !== null && value !== undefined;
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { Params } from "./bond";
|
|
||||||
import Long from "long";
|
import Long from "long";
|
||||||
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
||||||
import _m0 from "protobufjs/minimal";
|
import _m0 from "protobufjs/minimal";
|
||||||
@ -46,27 +45,6 @@ export interface MsgCancelBond {
|
|||||||
/** MsgCancelBondResponse defines the Msg/CancelBond response type. */
|
/** MsgCancelBondResponse defines the Msg/CancelBond response type. */
|
||||||
export interface MsgCancelBondResponse {}
|
export interface MsgCancelBondResponse {}
|
||||||
|
|
||||||
/** MsgUpdateParams is the Msg/UpdateParams request type. */
|
|
||||||
export interface MsgUpdateParams {
|
|
||||||
/**
|
|
||||||
* authority is the address that controls the module (defaults to x/gov unless
|
|
||||||
* overwritten).
|
|
||||||
*/
|
|
||||||
authority: string;
|
|
||||||
/**
|
|
||||||
* params defines the x/bond parameters to update.
|
|
||||||
*
|
|
||||||
* NOTE: All parameters must be supplied.
|
|
||||||
*/
|
|
||||||
params?: Params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MsgUpdateParamsResponse defines the response structure for executing a
|
|
||||||
* MsgUpdateParams message.
|
|
||||||
*/
|
|
||||||
export interface MsgUpdateParamsResponse {}
|
|
||||||
|
|
||||||
function createBaseMsgCreateBond(): MsgCreateBond {
|
function createBaseMsgCreateBond(): MsgCreateBond {
|
||||||
return { signer: "", coins: [] };
|
return { signer: "", coins: [] };
|
||||||
}
|
}
|
||||||
@ -553,120 +531,6 @@ export const MsgCancelBondResponse = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function createBaseMsgUpdateParams(): MsgUpdateParams {
|
|
||||||
return { authority: "", params: undefined };
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgUpdateParams = {
|
|
||||||
encode(
|
|
||||||
message: MsgUpdateParams,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.authority !== "") {
|
|
||||||
writer.uint32(10).string(message.authority);
|
|
||||||
}
|
|
||||||
if (message.params !== undefined) {
|
|
||||||
Params.encode(message.params, writer.uint32(18).fork()).ldelim();
|
|
||||||
}
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateParams {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgUpdateParams();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
case 1:
|
|
||||||
message.authority = reader.string();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
message.params = Params.decode(reader, reader.uint32());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(object: any): MsgUpdateParams {
|
|
||||||
return {
|
|
||||||
authority: isSet(object.authority) ? String(object.authority) : "",
|
|
||||||
params: isSet(object.params) ? Params.fromJSON(object.params) : undefined,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(message: MsgUpdateParams): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
message.authority !== undefined && (obj.authority = message.authority);
|
|
||||||
message.params !== undefined &&
|
|
||||||
(obj.params = message.params ? Params.toJSON(message.params) : undefined);
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgUpdateParams>, I>>(
|
|
||||||
object: I
|
|
||||||
): MsgUpdateParams {
|
|
||||||
const message = createBaseMsgUpdateParams();
|
|
||||||
message.authority = object.authority ?? "";
|
|
||||||
message.params =
|
|
||||||
object.params !== undefined && object.params !== null
|
|
||||||
? Params.fromPartial(object.params)
|
|
||||||
: undefined;
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgUpdateParamsResponse = {
|
|
||||||
encode(
|
|
||||||
_: MsgUpdateParamsResponse,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(
|
|
||||||
input: _m0.Reader | Uint8Array,
|
|
||||||
length?: number
|
|
||||||
): MsgUpdateParamsResponse {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgUpdateParamsResponse();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(_: any): MsgUpdateParamsResponse {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(_: MsgUpdateParamsResponse): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgUpdateParamsResponse>, I>>(
|
|
||||||
_: I
|
|
||||||
): MsgUpdateParamsResponse {
|
|
||||||
const message = createBaseMsgUpdateParamsResponse();
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Msg defines the bond Msg service. */
|
/** Msg defines the bond Msg service. */
|
||||||
export interface Msg {
|
export interface Msg {
|
||||||
/** CreateBond defines a method for creating a new bond. */
|
/** CreateBond defines a method for creating a new bond. */
|
||||||
@ -677,11 +541,6 @@ export interface Msg {
|
|||||||
WithdrawBond(request: MsgWithdrawBond): Promise<MsgWithdrawBondResponse>;
|
WithdrawBond(request: MsgWithdrawBond): Promise<MsgWithdrawBondResponse>;
|
||||||
/** CancelBond defines a method for cancelling a bond. */
|
/** CancelBond defines a method for cancelling a bond. */
|
||||||
CancelBond(request: MsgCancelBond): Promise<MsgCancelBondResponse>;
|
CancelBond(request: MsgCancelBond): Promise<MsgCancelBondResponse>;
|
||||||
/**
|
|
||||||
* UpdateParams defines an operation for updating the x/staking module
|
|
||||||
* parameters.
|
|
||||||
*/
|
|
||||||
UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MsgClientImpl implements Msg {
|
export class MsgClientImpl implements Msg {
|
||||||
@ -692,7 +551,6 @@ export class MsgClientImpl implements Msg {
|
|||||||
this.RefillBond = this.RefillBond.bind(this);
|
this.RefillBond = this.RefillBond.bind(this);
|
||||||
this.WithdrawBond = this.WithdrawBond.bind(this);
|
this.WithdrawBond = this.WithdrawBond.bind(this);
|
||||||
this.CancelBond = this.CancelBond.bind(this);
|
this.CancelBond = this.CancelBond.bind(this);
|
||||||
this.UpdateParams = this.UpdateParams.bind(this);
|
|
||||||
}
|
}
|
||||||
CreateBond(request: MsgCreateBond): Promise<MsgCreateBondResponse> {
|
CreateBond(request: MsgCreateBond): Promise<MsgCreateBondResponse> {
|
||||||
const data = MsgCreateBond.encode(request).finish();
|
const data = MsgCreateBond.encode(request).finish();
|
||||||
@ -725,14 +583,6 @@ export class MsgClientImpl implements Msg {
|
|||||||
MsgCancelBondResponse.decode(new _m0.Reader(data))
|
MsgCancelBondResponse.decode(new _m0.Reader(data))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse> {
|
|
||||||
const data = MsgUpdateParams.encode(request).finish();
|
|
||||||
const promise = this.rpc.request("cerc.bond.v1.Msg", "UpdateParams", data);
|
|
||||||
return promise.then((data) =>
|
|
||||||
MsgUpdateParamsResponse.decode(new _m0.Reader(data))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Rpc {
|
interface Rpc {
|
||||||
|
@ -8,26 +8,14 @@ export const protobufPackage = "cerc.registry.module.v1";
|
|||||||
* Module is the app config object of the module.
|
* Module is the app config object of the module.
|
||||||
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
* Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
||||||
*/
|
*/
|
||||||
export interface Module {
|
export interface Module {}
|
||||||
/**
|
|
||||||
* authority defines the custom module authority. If not set, defaults to the
|
|
||||||
* governance module.
|
|
||||||
*/
|
|
||||||
authority: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBaseModule(): Module {
|
function createBaseModule(): Module {
|
||||||
return { authority: "" };
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Module = {
|
export const Module = {
|
||||||
encode(
|
encode(_: Module, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||||
message: Module,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.authority !== "") {
|
|
||||||
writer.uint32(18).string(message.authority);
|
|
||||||
}
|
|
||||||
return writer;
|
return writer;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -38,9 +26,6 @@ export const Module = {
|
|||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 2:
|
|
||||||
message.authority = reader.string();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
reader.skipType(tag & 7);
|
reader.skipType(tag & 7);
|
||||||
break;
|
break;
|
||||||
@ -49,21 +34,17 @@ export const Module = {
|
|||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromJSON(object: any): Module {
|
fromJSON(_: any): Module {
|
||||||
return {
|
return {};
|
||||||
authority: isSet(object.authority) ? String(object.authority) : "",
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toJSON(message: Module): unknown {
|
toJSON(_: Module): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.authority !== undefined && (obj.authority = message.authority);
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<Module>, I>>(object: I): Module {
|
fromPartial<I extends Exact<DeepPartial<Module>, I>>(_: I): Module {
|
||||||
const message = createBaseModule();
|
const message = createBaseModule();
|
||||||
message.authority = object.authority ?? "";
|
|
||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -100,7 +81,3 @@ if (_m0.util.Long !== Long) {
|
|||||||
_m0.util.Long = Long as any;
|
_m0.util.Long = Long as any;
|
||||||
_m0.configure();
|
_m0.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSet(value: any): boolean {
|
|
||||||
return value !== null && value !== undefined;
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { Record, Params, Signature } from "./registry";
|
import { Record, Signature } from "./registry";
|
||||||
import Long from "long";
|
import Long from "long";
|
||||||
import _m0 from "protobufjs/minimal";
|
import _m0 from "protobufjs/minimal";
|
||||||
|
|
||||||
@ -110,27 +110,6 @@ export interface MsgReassociateRecords {
|
|||||||
/** MsgReassociateRecordsResponse */
|
/** MsgReassociateRecordsResponse */
|
||||||
export interface MsgReassociateRecordsResponse {}
|
export interface MsgReassociateRecordsResponse {}
|
||||||
|
|
||||||
/** MsgUpdateParams is the Msg/UpdateParams request type. */
|
|
||||||
export interface MsgUpdateParams {
|
|
||||||
/**
|
|
||||||
* authority is the address that controls the module (defaults to x/gov unless
|
|
||||||
* overwritten).
|
|
||||||
*/
|
|
||||||
authority: string;
|
|
||||||
/**
|
|
||||||
* params defines the x/registry parameters to update.
|
|
||||||
*
|
|
||||||
* NOTE: All parameters must be supplied.
|
|
||||||
*/
|
|
||||||
params?: Params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MsgUpdateParamsResponse defines the response structure for executing a
|
|
||||||
* MsgUpdateParams message.
|
|
||||||
*/
|
|
||||||
export interface MsgUpdateParamsResponse {}
|
|
||||||
|
|
||||||
function createBaseMsgSetRecord(): MsgSetRecord {
|
function createBaseMsgSetRecord(): MsgSetRecord {
|
||||||
return { bondId: "", signer: "", payload: undefined };
|
return { bondId: "", signer: "", payload: undefined };
|
||||||
}
|
}
|
||||||
@ -1380,120 +1359,6 @@ export const MsgReassociateRecordsResponse = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function createBaseMsgUpdateParams(): MsgUpdateParams {
|
|
||||||
return { authority: "", params: undefined };
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgUpdateParams = {
|
|
||||||
encode(
|
|
||||||
message: MsgUpdateParams,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
if (message.authority !== "") {
|
|
||||||
writer.uint32(10).string(message.authority);
|
|
||||||
}
|
|
||||||
if (message.params !== undefined) {
|
|
||||||
Params.encode(message.params, writer.uint32(18).fork()).ldelim();
|
|
||||||
}
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateParams {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgUpdateParams();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
case 1:
|
|
||||||
message.authority = reader.string();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
message.params = Params.decode(reader, reader.uint32());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(object: any): MsgUpdateParams {
|
|
||||||
return {
|
|
||||||
authority: isSet(object.authority) ? String(object.authority) : "",
|
|
||||||
params: isSet(object.params) ? Params.fromJSON(object.params) : undefined,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(message: MsgUpdateParams): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
message.authority !== undefined && (obj.authority = message.authority);
|
|
||||||
message.params !== undefined &&
|
|
||||||
(obj.params = message.params ? Params.toJSON(message.params) : undefined);
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgUpdateParams>, I>>(
|
|
||||||
object: I
|
|
||||||
): MsgUpdateParams {
|
|
||||||
const message = createBaseMsgUpdateParams();
|
|
||||||
message.authority = object.authority ?? "";
|
|
||||||
message.params =
|
|
||||||
object.params !== undefined && object.params !== null
|
|
||||||
? Params.fromPartial(object.params)
|
|
||||||
: undefined;
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function createBaseMsgUpdateParamsResponse(): MsgUpdateParamsResponse {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MsgUpdateParamsResponse = {
|
|
||||||
encode(
|
|
||||||
_: MsgUpdateParamsResponse,
|
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
|
||||||
): _m0.Writer {
|
|
||||||
return writer;
|
|
||||||
},
|
|
||||||
|
|
||||||
decode(
|
|
||||||
input: _m0.Reader | Uint8Array,
|
|
||||||
length?: number
|
|
||||||
): MsgUpdateParamsResponse {
|
|
||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
||||||
let end = length === undefined ? reader.len : reader.pos + length;
|
|
||||||
const message = createBaseMsgUpdateParamsResponse();
|
|
||||||
while (reader.pos < end) {
|
|
||||||
const tag = reader.uint32();
|
|
||||||
switch (tag >>> 3) {
|
|
||||||
default:
|
|
||||||
reader.skipType(tag & 7);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON(_: any): MsgUpdateParamsResponse {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON(_: MsgUpdateParamsResponse): unknown {
|
|
||||||
const obj: any = {};
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
|
|
||||||
fromPartial<I extends Exact<DeepPartial<MsgUpdateParamsResponse>, I>>(
|
|
||||||
_: I
|
|
||||||
): MsgUpdateParamsResponse {
|
|
||||||
const message = createBaseMsgUpdateParamsResponse();
|
|
||||||
return message;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Msg is a service which exposes the registry functionality */
|
/** Msg is a service which exposes the registry functionality */
|
||||||
export interface Msg {
|
export interface Msg {
|
||||||
/** SetRecord records a new record with given payload and bond id */
|
/** SetRecord records a new record with given payload and bond id */
|
||||||
@ -1526,11 +1391,6 @@ export interface Msg {
|
|||||||
SetAuthorityBond(
|
SetAuthorityBond(
|
||||||
request: MsgSetAuthorityBond
|
request: MsgSetAuthorityBond
|
||||||
): Promise<MsgSetAuthorityBondResponse>;
|
): Promise<MsgSetAuthorityBondResponse>;
|
||||||
/**
|
|
||||||
* UpdateParams defines an operation for updating the x/staking module
|
|
||||||
* parameters.
|
|
||||||
*/
|
|
||||||
UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MsgClientImpl implements Msg {
|
export class MsgClientImpl implements Msg {
|
||||||
@ -1547,7 +1407,6 @@ export class MsgClientImpl implements Msg {
|
|||||||
this.DeleteName = this.DeleteName.bind(this);
|
this.DeleteName = this.DeleteName.bind(this);
|
||||||
this.ReserveAuthority = this.ReserveAuthority.bind(this);
|
this.ReserveAuthority = this.ReserveAuthority.bind(this);
|
||||||
this.SetAuthorityBond = this.SetAuthorityBond.bind(this);
|
this.SetAuthorityBond = this.SetAuthorityBond.bind(this);
|
||||||
this.UpdateParams = this.UpdateParams.bind(this);
|
|
||||||
}
|
}
|
||||||
SetRecord(request: MsgSetRecord): Promise<MsgSetRecordResponse> {
|
SetRecord(request: MsgSetRecord): Promise<MsgSetRecordResponse> {
|
||||||
const data = MsgSetRecord.encode(request).finish();
|
const data = MsgSetRecord.encode(request).finish();
|
||||||
@ -1670,18 +1529,6 @@ export class MsgClientImpl implements Msg {
|
|||||||
MsgSetAuthorityBondResponse.decode(new _m0.Reader(data))
|
MsgSetAuthorityBondResponse.decode(new _m0.Reader(data))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse> {
|
|
||||||
const data = MsgUpdateParams.encode(request).finish();
|
|
||||||
const promise = this.rpc.request(
|
|
||||||
"cerc.registry.v1.Msg",
|
|
||||||
"UpdateParams",
|
|
||||||
data
|
|
||||||
);
|
|
||||||
return promise.then((data) =>
|
|
||||||
MsgUpdateParamsResponse.decode(new _m0.Reader(data))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Rpc {
|
interface Rpc {
|
||||||
|
@ -44,7 +44,6 @@ const historyFields = `
|
|||||||
|
|
||||||
const auctionFields = `
|
const auctionFields = `
|
||||||
id
|
id
|
||||||
kind
|
|
||||||
status
|
status
|
||||||
ownerAddress
|
ownerAddress
|
||||||
createTime
|
createTime
|
||||||
@ -62,8 +61,8 @@ const auctionFields = `
|
|||||||
type
|
type
|
||||||
quantity
|
quantity
|
||||||
}
|
}
|
||||||
winnerAddresses
|
winnerAddress
|
||||||
winnerBids {
|
winnerBid {
|
||||||
type
|
type
|
||||||
quantity
|
quantity
|
||||||
}
|
}
|
||||||
@ -71,12 +70,6 @@ const auctionFields = `
|
|||||||
type
|
type
|
||||||
quantity
|
quantity
|
||||||
}
|
}
|
||||||
maxPrice {
|
|
||||||
type
|
|
||||||
quantity
|
|
||||||
}
|
|
||||||
numProviders
|
|
||||||
fundsReleased
|
|
||||||
bids {
|
bids {
|
||||||
bidderAddress
|
bidderAddress
|
||||||
status
|
status
|
||||||
@ -248,13 +241,13 @@ export class RegistryClient {
|
|||||||
/**
|
/**
|
||||||
* Get records by attributes.
|
* Get records by attributes.
|
||||||
*/
|
*/
|
||||||
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false, limit?: number, offset?: number) {
|
async queryRecords (attributes: { [key: string]: any }, all = false, refs = false) {
|
||||||
if (!attributes) {
|
if (!attributes) {
|
||||||
attributes = {};
|
attributes = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = `query ($attributes: [KeyValueInput!], $all: Boolean, $limit: Int, $offset: Int) {
|
const query = `query ($attributes: [KeyValueInput!], $all: Boolean) {
|
||||||
queryRecords(attributes: $attributes, all: $all, limit: $limit, offset: $offset) {
|
queryRecords(attributes: $attributes, all: $all) {
|
||||||
id
|
id
|
||||||
names
|
names
|
||||||
owners
|
owners
|
||||||
@ -268,9 +261,7 @@ export class RegistryClient {
|
|||||||
|
|
||||||
const variables = {
|
const variables = {
|
||||||
attributes: Util.toGQLAttributes(attributes),
|
attributes: Util.toGQLAttributes(attributes),
|
||||||
all,
|
all
|
||||||
limit,
|
|
||||||
offset
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = (await this._graph(query)(variables)).queryRecords;
|
let result = (await this._graph(query)(variables)).queryRecords;
|
||||||
@ -434,11 +425,11 @@ export class RegistryClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get bonds.
|
* Get bonds by attributes.
|
||||||
*/
|
*/
|
||||||
async queryBonds () {
|
async queryBonds (attributes = {}) {
|
||||||
const query = `query {
|
const query = `query ($attributes: [KeyValueInput!]) {
|
||||||
queryBonds {
|
queryBonds(attributes: $attributes) {
|
||||||
id
|
id
|
||||||
owner
|
owner
|
||||||
balance {
|
balance {
|
||||||
@ -448,32 +439,11 @@ export class RegistryClient {
|
|||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
return RegistryClient.getResult(this._graph(query)({}), 'queryBonds');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get bonds by owner(s).
|
|
||||||
*/
|
|
||||||
async queryBondsByOwners (ownerAddresses: string[]) {
|
|
||||||
const query = `query ($ownerAddresses: [String!]) {
|
|
||||||
queryBondsByOwner(ownerAddresses: $ownerAddresses) {
|
|
||||||
owner
|
|
||||||
bonds {
|
|
||||||
id
|
|
||||||
owner
|
|
||||||
balance {
|
|
||||||
type
|
|
||||||
quantity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
|
|
||||||
const variables = {
|
const variables = {
|
||||||
ownerAddresses
|
attributes: Util.toGQLAttributes(attributes)
|
||||||
};
|
};
|
||||||
|
|
||||||
return RegistryClient.getResult(this._graph(query)(variables), 'queryBondsByOwner');
|
return RegistryClient.getResult(this._graph(query)(variables), 'queryBonds');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ describe('Querying', () => {
|
|||||||
let bondId: string;
|
let bondId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
await registry.createBond({ denom: DENOM, amount: '1000000000' }, privateKey, fee);
|
await registry.createBond({ denom: DENOM, amount: '1000000000' }, privateKey, fee);
|
||||||
|
@ -2,9 +2,7 @@ import assert from 'assert';
|
|||||||
import yaml from 'node-yaml';
|
import yaml from 'node-yaml';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
|
|
||||||
import { Account, Registry } from '../index';
|
import { DEFAULT_CHAIN_ID } from '../index';
|
||||||
|
|
||||||
const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
|
||||||
|
|
||||||
export const ensureUpdatedConfig = async (path: string) => {
|
export const ensureUpdatedConfig = async (path: string) => {
|
||||||
const conf = await yaml.read(path);
|
const conf = await yaml.read(path);
|
||||||
@ -30,21 +28,8 @@ export const getConfig = () => {
|
|||||||
rpcEndpoint: process.env.LACONICD_RPC_ENDPOINT || 'http://localhost:26657',
|
rpcEndpoint: process.env.LACONICD_RPC_ENDPOINT || 'http://localhost:26657',
|
||||||
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
||||||
fee: {
|
fee: {
|
||||||
amount: [{ denom: 'alnt', amount: '200000' }],
|
amount: [{ denom: 'alnt', amount: '400000' }],
|
||||||
gas: '200000'
|
gas: '400000'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createTestAccounts = async (numAccounts: number): Promise<Account[]> => {
|
|
||||||
const accounts: Account[] = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < numAccounts; i++) {
|
|
||||||
const mnemonic = Account.generateMnemonic();
|
|
||||||
const account = await Account.generateFromMnemonic(mnemonic);
|
|
||||||
await account.init();
|
|
||||||
accounts.push(account);
|
|
||||||
}
|
|
||||||
|
|
||||||
return accounts;
|
|
||||||
};
|
|
||||||
|
@ -1,32 +1,19 @@
|
|||||||
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
||||||
|
|
||||||
import { MsgCommitBidResponse, MsgCommitBid, MsgRevealBid, MsgRevealBidResponse, MsgCreateAuction, MsgCreateAuctionResponse, MsgReleaseFunds, MsgReleaseFundsResponse } from '../../../proto/cerc/auction/v1/tx';
|
import { MsgCommitBidResponse, MsgCommitBid, MsgRevealBid, MsgRevealBidResponse } from '../../../proto/cerc/auction/v1/tx';
|
||||||
|
|
||||||
export const typeUrlMsgCreateAuction = '/cerc.auction.v1.MsgCreateAuction';
|
|
||||||
export const typeUrlMsgCommitBid = '/cerc.auction.v1.MsgCommitBid';
|
export const typeUrlMsgCommitBid = '/cerc.auction.v1.MsgCommitBid';
|
||||||
export const typeUrlMsgCommitBidResponse = '/cerc.auction.v1.MsgCommitBidResponse';
|
export const typeUrlMsgCommitBidResponse = '/cerc.auction.v1.MsgCommitBidResponse';
|
||||||
export const typeUrlMsgRevealBid = '/cerc.auction.v1.MsgRevealBid';
|
export const typeUrlMsgRevealBid = '/cerc.auction.v1.MsgRevealBid';
|
||||||
export const typeUrlMsgRevealBidResponse = '/cerc.auction.v1.MsgRevealBidResponse';
|
export const typeUrlMsgRevealBidResponse = '/cerc.auction.v1.MsgRevealBidResponse';
|
||||||
export const typeUrlMsgCreateAuctionResponse = '/cerc.auction.v1.MsgCreateAuctionResponse';
|
|
||||||
export const typeUrlMsgReleaseFunds = '/cerc.auction.v1.MsgReleaseFunds';
|
|
||||||
export const typeUrlMsgReleaseFundsResponse = '/cerc.auction.v1.MsgReleaseFundsResponse';
|
|
||||||
|
|
||||||
export const auctionTypes: ReadonlyArray<[string, GeneratedType]> = [
|
export const auctionTypes: ReadonlyArray<[string, GeneratedType]> = [
|
||||||
[typeUrlMsgCreateAuction, MsgCreateAuction],
|
|
||||||
[typeUrlMsgCommitBid, MsgCommitBid],
|
[typeUrlMsgCommitBid, MsgCommitBid],
|
||||||
[typeUrlMsgCommitBidResponse, MsgCommitBidResponse],
|
[typeUrlMsgCommitBidResponse, MsgCommitBidResponse],
|
||||||
[typeUrlMsgRevealBid, MsgRevealBid],
|
[typeUrlMsgRevealBid, MsgRevealBid],
|
||||||
[typeUrlMsgRevealBidResponse, MsgRevealBidResponse],
|
[typeUrlMsgRevealBidResponse, MsgRevealBidResponse]
|
||||||
[typeUrlMsgCreateAuctionResponse, MsgCreateAuctionResponse],
|
|
||||||
[typeUrlMsgReleaseFunds, MsgReleaseFunds],
|
|
||||||
[typeUrlMsgReleaseFundsResponse, MsgReleaseFundsResponse]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export interface MsgCreateAuctionEncodeObject extends EncodeObject {
|
|
||||||
readonly typeUrl: '/cerc.auction.v1.MsgCreateAuction';
|
|
||||||
readonly value: Partial<MsgCreateAuction>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MsgCommitBidEncodeObject extends EncodeObject {
|
export interface MsgCommitBidEncodeObject extends EncodeObject {
|
||||||
readonly typeUrl: '/cerc.auction.v1.MsgCommitBid';
|
readonly typeUrl: '/cerc.auction.v1.MsgCommitBid';
|
||||||
readonly value: Partial<MsgCommitBid>;
|
readonly value: Partial<MsgCommitBid>;
|
||||||
@ -37,16 +24,6 @@ export interface MsgRevealBidEncodeObject extends EncodeObject {
|
|||||||
readonly value: Partial<MsgRevealBid>;
|
readonly value: Partial<MsgRevealBid>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MsgReleaseFundsEncodeObject extends EncodeObject {
|
|
||||||
readonly typeUrl: '/cerc.auction.v1.MsgReleaseFunds';
|
|
||||||
readonly value: Partial<MsgReleaseFunds>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const INVALID_BID_ERROR = 'Bid is higher than max price';
|
|
||||||
export const RELEASE_FUNDS_ERROR = 'Auction funds already released';
|
|
||||||
export const OWNER_MISMATCH_ERROR = 'Only auction owner can release funds';
|
|
||||||
export const AUCTION_ERRORS = [INVALID_BID_ERROR, RELEASE_FUNDS_ERROR, OWNER_MISMATCH_ERROR];
|
|
||||||
|
|
||||||
export interface MessageMsgCommitBid {
|
export interface MessageMsgCommitBid {
|
||||||
auctionId: string,
|
auctionId: string,
|
||||||
commitHash: string,
|
commitHash: string,
|
||||||
@ -56,26 +33,3 @@ export interface MessageMsgRevealBid {
|
|||||||
auctionId: string,
|
auctionId: string,
|
||||||
reveal: string,
|
reveal: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageCreateVickreyAuction {
|
|
||||||
commitsDuration: string;
|
|
||||||
revealsDuration: string;
|
|
||||||
denom: string;
|
|
||||||
commitFee: string;
|
|
||||||
revealFee: string;
|
|
||||||
minimumBid: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MessageCreateProviderAuction {
|
|
||||||
commitsDuration: string;
|
|
||||||
revealsDuration: string;
|
|
||||||
denom: string;
|
|
||||||
commitFee: string;
|
|
||||||
revealFee: string;
|
|
||||||
maxPrice: string;
|
|
||||||
numProviders: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MessageMsgReleaseFunds {
|
|
||||||
auctionId: string
|
|
||||||
}
|
|
||||||
|
@ -15,8 +15,6 @@ export interface MsgOnboardParticipantEncodeObject extends EncodeObject {
|
|||||||
readonly value: MsgOnboardParticipant;
|
readonly value: MsgOnboardParticipant;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ONBOARDING_DISABLED_ERROR = 'Onboarding is disabled';
|
|
||||||
|
|
||||||
interface ethPayload {
|
interface ethPayload {
|
||||||
address: string
|
address: string
|
||||||
msg: string
|
msg: string
|
||||||
|
@ -19,7 +19,7 @@ const utilTests = () => {
|
|||||||
let watcherId: string;
|
let watcherId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
36
src/util.ts
36
src/util.ts
@ -1,8 +1,6 @@
|
|||||||
import * as Block from 'multiformats/block';
|
import * as Block from 'multiformats/block';
|
||||||
import { sha256 as hasher } from 'multiformats/hashes/sha2';
|
import { sha256 as hasher } from 'multiformats/hashes/sha2';
|
||||||
import assert from 'assert';
|
|
||||||
|
|
||||||
import { GasPrice, StdFee, parseCoins } from '@cosmjs/stargate';
|
|
||||||
import * as dagCBOR from '@ipld/dag-cbor';
|
import * as dagCBOR from '@ipld/dag-cbor';
|
||||||
import * as dagJSON from '@ipld/dag-json';
|
import * as dagJSON from '@ipld/dag-json';
|
||||||
|
|
||||||
@ -24,7 +22,7 @@ export class Util {
|
|||||||
|
|
||||||
let keys = Object.keys(obj);
|
let keys = Object.keys(obj);
|
||||||
keys = keys.sort();
|
keys = keys.sort();
|
||||||
const newObject: { [key: string]: any } = {};
|
const newObject: {[key: string]: any} = {};
|
||||||
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
newObject[keys[i]] = Util.sortJSON(obj[keys[i]]);
|
newObject[keys[i]] = Util.sortJSON(obj[keys[i]]);
|
||||||
@ -79,7 +77,7 @@ export class Util {
|
|||||||
* Unmarshal attributes array to object.
|
* Unmarshal attributes array to object.
|
||||||
*/
|
*/
|
||||||
static fromGQLAttributes (attributes: any[] = []) {
|
static fromGQLAttributes (attributes: any[] = []) {
|
||||||
const res: { [key: string]: any } = {};
|
const res: {[key: string]: any} = {};
|
||||||
|
|
||||||
attributes.forEach(attr => {
|
attributes.forEach(attr => {
|
||||||
res[attr.key] = (attr.value === null) ? null : this.fromGQLValue(attr.value);
|
res[attr.key] = (attr.value === null) ? null : this.fromGQLValue(attr.value);
|
||||||
@ -121,33 +119,3 @@ export class Util {
|
|||||||
return block.cid.toString();
|
return block.cid.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get gas in proper format
|
|
||||||
*/
|
|
||||||
export const parseGasAndFees = (gas?: string, fees?: string): StdFee | undefined | number => {
|
|
||||||
// If fees is not given or a number, treat it as a gas estimation multiplier
|
|
||||||
if (fees === null || fees === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFeesANumber = !isNaN(Number(fees));
|
|
||||||
if (isFeesANumber) {
|
|
||||||
return Number(fees);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If fees is not a gas estimation multiplier, gas is required
|
|
||||||
assert(gas, 'Invalid gas.');
|
|
||||||
|
|
||||||
return {
|
|
||||||
amount: parseCoins(String(fees)),
|
|
||||||
gas: String(gas)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get gas price in proper format
|
|
||||||
*/
|
|
||||||
export const getGasPrice = (gasPrice: string | null): GasPrice | undefined => {
|
|
||||||
return gasPrice != null ? GasPrice.fromString(String(gasPrice)) : undefined;
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user