Compare commits

..
13 Commits
Author SHA1 Message Date
nabarun 1177a17516 WIP: Send eth tx wrapped in cosmos tx message 2023-03-08 20:30:11 +05:30
nabarun 7d0a84b701 Fix protoc-gen-ts error with updated typescript 2023-03-08 20:27:59 +05:30
Michael 2493e2c706 Revert "remaining record types support (#27)" (#35)
This reverts commit db3f9707d2.
2023-03-06 16:54:02 -05:00
Michael 81f45e95a8 debugging statements for provisionBondId (#34)
* debugging statements for provisionBondId

* always create new bond with provisionBondId helper call
2023-03-06 16:30:04 -05:00
Murali Krishna Komatireddy db3f9707d2 remaining record types support (#27)
* remaining record types support

* fix sdk tests

* create record types from examples

* bond tests

* registry expiry tests

* fix typos
2023-03-06 16:17:43 -05:00
Michael 2870a7543a version bump to 0.1.6 (#31) 2023-02-15 10:23:49 -05:00
Michael 77af2e5e22 Auction nameservice tests (#28)
* truncated testing until questions of intent answered

* nameservice passes local tests

* first pass running tests from sdk side

* lint cleanup

* move into dir rather than args

* double bond in naming test

* first pass building test container on sdk side... only basic tests this iteration

* missing jest

* docker compose exec got dropped

* start both containers, not just laconicd

* script cleanup in action

* working directory

* diagnostic

* diagnostic

* run against dev branch of laconicd

* run auction and nameservice-expiry tests

* switch to main branch
2023-02-10 14:44:23 -05:00
Michael 663ebbf8e0 Merge pull request #30 from cerc-io/readme_quick
quick README update to reflect reality
2023-02-06 12:48:21 -05:00
Michael Shaw c6a37ac419 quick README update to reflect reality 2023-02-06 12:47:29 -05:00
Ian Norden 80348594f8 Merge pull request #20 from cerc-io/zramsay-patch-1
remove duplicate line in tests
2023-01-12 18:59:34 -06:00
Zach 55675c7b55 rm duplicate line (typo?) 2023-01-11 18:27:00 -05:00
Zach 10d58ca028 Merge pull request #19 from cerc-io/ian/bump_version
Update package to 0.1.5
2023-01-11 17:02:56 -05:00
i-norden 95bdacb4a1 version 0.1.5 2023-01-11 15:48:24 -06:00
33 changed files with 8545 additions and 51 deletions
+72
View File
@@ -0,0 +1,72 @@
name: Tests
on:
pull_request:
push:
branches:
- main
- release/**
jobs:
sdk_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout laconicd
uses: actions/checkout@v3
with:
path: "./laconicd/"
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
- name: Environment
run: ls -tlh && env
- name: build containers scripts
working-directory: laconicd/tests/sdk_tests
run: ./build-laconicd-container.sh
- name: build test-container
run: docker build -t cerc-io/laconic-sdk-tester:local-test -f laconicd/tests/sdk_tests/Dockerfile-sdk .
- name: start containers
working-directory: laconicd/tests/sdk_tests
run: docker compose up -d
- name: run basic tests
working-directory: laconicd/tests/sdk_tests
run: |
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://laconicd:1317
laconicd_gql_endpoint=http://laconicd:9473/api
sleep 30s
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test"
- name: stop containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down
- name: start auction containers
working-directory: laconicd/tests/sdk_tests
run: docker compose -f docker-compose-auctions.yml up -d
- name: run auction tests
working-directory: laconicd/tests/sdk_tests
run: |
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://laconicd:1317
laconicd_gql_endpoint=http://laconicd:9473/api
sleep 30s
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:auctions"
- name: start containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down
- name: start containers
working-directory: laconicd/tests/sdk_tests
run: docker compose -f docker-compose-nameservice.yml up -d
- name: run nameservice expiry tests
working-directory: laconicd/tests/sdk_tests
run: |
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://laconicd:1317
laconicd_gql_endpoint=http://laconicd:9473/api
sleep 30s
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:nameservice-expiry"
- name: stop nameservice containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down
+1 -1
View File
@@ -1,4 +1,4 @@
node_modules
dist
.env
.idea/
.idea*
+54
View File
@@ -0,0 +1,54 @@
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=16-bullseye
FROM node:${VARIANT}
ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global
# Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
RUN \
# Configure global npm install location, use group to adapt to UID/GID changes
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
&& usermod -a -G npm ${USERNAME} \
&& umask 0002 \
&& mkdir -p ${NPM_GLOBAL} \
&& touch /usr/local/etc/npmrc \
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
&& chmod g+s ${NPM_GLOBAL} \
&& npm config -g set prefix ${NPM_GLOBAL} \
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
# Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint lerna jest" \
&& npm cache clean --force > /dev/null 2>&1
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
WORKDIR /
RUN mkdir node_modules && mkdir proto && mkdir scripts && mkdir src
COPY node_modules ./node_modules/
COPY proto . ./proto/
COPY scripts ./scripts/
COPY src ./src/
COPY entrypoint.sh .
ENTRYPOINT ["/entrypoint.sh"]
# Placeholder CMD : generally this will be overridden at run time like :
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
CMD node --version
# Temp hack, clone the laconic-sdk repo here
WORKDIR /app
RUN yarn install
WORKDIR /app/laconic-sdk
+1 -1
View File
@@ -57,7 +57,7 @@ Follow these steps to run the tests:
- In laconicd repo run:
```bash
TEST_NAMESERVICE_EXPIRY=true ./init.sh
TEST_REGISTRY_EXPIRY=true ./init.sh
```
- Export the private key and change it in `.env` file again using:
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
exec "$@"
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.4",
"version": "0.1.6",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/laconic-sdk.git",
@@ -14,7 +14,7 @@
"dotenv": "^16.0.0",
"google-protobuf": "^3.21.0",
"jest": "29.0.0",
"protoc-gen-ts": "^0.8.5",
"protoc-gen-ts": "^0.8.6-rc1",
"ts-jest": "^29.0.2",
"typescript": "^4.6.2"
},
+97
View File
@@ -0,0 +1,97 @@
syntax = "proto3";
package cosmos_proto;
import "google/protobuf/descriptor.proto";
option go_package = "github.com/cosmos/cosmos-proto;cosmos_proto";
extend google.protobuf.MessageOptions {
// implements_interface is used to indicate the type name of the interface
// that a message implements so that it can be used in google.protobuf.Any
// fields that accept that interface. A message can implement multiple
// interfaces. Interfaces should be declared using a declare_interface
// file option.
repeated string implements_interface = 93001;
}
extend google.protobuf.FieldOptions {
// accepts_interface is used to annotate that a google.protobuf.Any
// field accepts messages that implement the specified interface.
// Interfaces should be declared using a declare_interface file option.
string accepts_interface = 93001;
// scalar is used to indicate that this field follows the formatting defined
// by the named scalar which should be declared with declare_scalar. Code
// generators may choose to use this information to map this field to a
// language-specific type representing the scalar.
string scalar = 93002;
}
extend google.protobuf.FileOptions {
// declare_interface declares an interface type to be used with
// accepts_interface and implements_interface. Interface names are
// expected to follow the following convention such that their declaration
// can be discovered by tools: for a given interface type a.b.C, it is
// expected that the declaration will be found in a protobuf file named
// a/b/interfaces.proto in the file descriptor set.
repeated InterfaceDescriptor declare_interface = 793021;
// declare_scalar declares a scalar type to be used with
// the scalar field option. Scalar names are
// expected to follow the following convention such that their declaration
// can be discovered by tools: for a given scalar type a.b.C, it is
// expected that the declaration will be found in a protobuf file named
// a/b/scalars.proto in the file descriptor set.
repeated ScalarDescriptor declare_scalar = 793022;
}
// InterfaceDescriptor describes an interface type to be used with
// accepts_interface and implements_interface and declared by declare_interface.
message InterfaceDescriptor {
// name is the name of the interface. It should be a short-name (without
// a period) such that the fully qualified name of the interface will be
// package.name, ex. for the package a.b and interface named C, the
// fully-qualified name will be a.b.C.
string name = 1;
// description is a human-readable description of the interface and its
// purpose.
string description = 2;
}
// ScalarDescriptor describes an scalar type to be used with
// the scalar field option and declared by declare_scalar.
// Scalars extend simple protobuf built-in types with additional
// syntax and semantics, for instance to represent big integers.
// Scalars should ideally define an encoding such that there is only one
// valid syntactical representation for a given semantic meaning,
// i.e. the encoding should be deterministic.
message ScalarDescriptor {
// name is the name of the scalar. It should be a short-name (without
// a period) such that the fully qualified name of the scalar will be
// package.name, ex. for the package a.b and scalar named C, the
// fully-qualified name will be a.b.C.
string name = 1;
// description is a human-readable description of the scalar and its
// encoding format. For instance a big integer or decimal scalar should
// specify precisely the expected encoding format.
string description = 2;
// field_type is the type of field with which this scalar can be used.
// Scalars can be used with one and only one type of field so that
// encoding standards and simple and clear. Currently only string and
// bytes fields are supported for scalars.
repeated ScalarType field_type = 3;
}
enum ScalarType {
SCALAR_TYPE_UNSPECIFIED = 0;
SCALAR_TYPE_STRING = 1;
SCALAR_TYPE_BYTES = 2;
}
+243
View File
@@ -0,0 +1,243 @@
syntax = "proto3";
package ethermint.evm.v1;
import "gogoproto/gogo.proto";
option go_package = "github.com/cerc-io/laconicd/x/evm/types";
// Params defines the EVM module parameters
message Params {
// evm_denom represents the token denomination used to run the EVM state
// transitions.
string evm_denom = 1 [(gogoproto.moretags) = "yaml:\"evm_denom\""];
// enable_create toggles state transitions that use the vm.Create function
bool enable_create = 2 [(gogoproto.moretags) = "yaml:\"enable_create\""];
// enable_call toggles state transitions that use the vm.Call function
bool enable_call = 3 [(gogoproto.moretags) = "yaml:\"enable_call\""];
// extra_eips defines the additional EIPs for the vm.Config
repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
// chain_config defines the EVM chain configuration parameters
ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
// signed) transactions can be executed on the state machine.
bool allow_unprotected_txs = 6;
}
// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
// instead of *big.Int.
message ChainConfig {
// homestead_block switch (nil no fork, 0 = already homestead)
string homestead_block = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"homestead_block\""
];
// dao_fork_block corresponds to TheDAO hard-fork switch block (nil no fork)
string dao_fork_block = 2 [
(gogoproto.customname) = "DAOForkBlock",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"dao_fork_block\""
];
// dao_fork_support defines whether the nodes supports or opposes the DAO hard-fork
bool dao_fork_support = 3
[(gogoproto.customname) = "DAOForkSupport", (gogoproto.moretags) = "yaml:\"dao_fork_support\""];
// eip150_block: EIP150 implements the Gas price changes
// (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil no fork)
string eip150_block = 4 [
(gogoproto.customname) = "EIP150Block",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"eip150_block\""
];
// eip150_hash: EIP150 HF hash (needed for header only clients as only gas pricing changed)
string eip150_hash = 5 [(gogoproto.customname) = "EIP150Hash", (gogoproto.moretags) = "yaml:\"byzantium_block\""];
// eip155_block: EIP155Block HF block
string eip155_block = 6 [
(gogoproto.customname) = "EIP155Block",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"eip155_block\""
];
// eip158_block: EIP158 HF block
string eip158_block = 7 [
(gogoproto.customname) = "EIP158Block",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"eip158_block\""
];
// byzantium_block: Byzantium switch block (nil no fork, 0 = already on byzantium)
string byzantium_block = 8 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"byzantium_block\""
];
// constantinople_block: Constantinople switch block (nil no fork, 0 = already activated)
string constantinople_block = 9 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"constantinople_block\""
];
// petersburg_block: Petersburg switch block (nil same as Constantinople)
string petersburg_block = 10 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"petersburg_block\""
];
// istanbul_block: Istanbul switch block (nil no fork, 0 = already on istanbul)
string istanbul_block = 11 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"istanbul_block\""
];
// muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, 0 = already activated)
string muir_glacier_block = 12 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"muir_glacier_block\""
];
// berlin_block: Berlin switch block (nil = no fork, 0 = already on berlin)
string berlin_block = 13 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"berlin_block\""
];
// DEPRECATED: EWASM, YOLOV3 and Catalyst block have been deprecated
reserved 14, 15, 16;
reserved "yolo_v3_block", "ewasm_block", "catalyst_block";
// london_block: London switch block (nil = no fork, 0 = already on london)
string london_block = 17 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"london_block\""
];
// arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
string arrow_glacier_block = 18 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"arrow_glacier_block\""
];
// DEPRECATED: merge fork block was deprecated: https://github.com/ethereum/go-ethereum/pull/24904
reserved 19;
reserved "merge_fork_block";
// gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
string gray_glacier_block = 20 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"gray_glacier_block\""
];
// merge_netsplit_block: Virtual fork after The Merge to use as a network splitter
string merge_netsplit_block = 21 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"merge_netsplit_block\""
];
// shanghai_block switch block (nil = no fork, 0 = already on shanghai)
string shanghai_block = 22 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"shanghai_block\""
];
// cancun_block switch block (nil = no fork, 0 = already on cancun)
string cancun_block = 23 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"cancun_block\""
];
}
// State represents a single Storage key value pair item.
message State {
// key is the stored key
string key = 1;
// value is the stored value for the given key
string value = 2;
}
// TransactionLogs define the logs generated from a transaction execution
// with a given hash. It it used for import/export data as transactions are not
// persisted on blockchain state after an upgrade.
message TransactionLogs {
// hash of the transaction
string hash = 1;
// logs is an array of Logs for the given transaction hash
repeated Log logs = 2;
}
// Log represents an protobuf compatible Ethereum Log that defines a contract
// log event. These events are generated by the LOG opcode and stored/indexed by
// the node.
//
// NOTE: address, topics and data are consensus fields. The rest of the fields
// are derived, i.e. filled in by the nodes, but not secured by consensus.
message Log {
// address of the contract that generated the event
string address = 1;
// topics is a list of topics provided by the contract.
repeated string topics = 2;
// data which is supplied by the contract, usually ABI-encoded
bytes data = 3;
// block_number of the block in which the transaction was included
uint64 block_number = 4 [(gogoproto.jsontag) = "blockNumber"];
// tx_hash is the transaction hash
string tx_hash = 5 [(gogoproto.jsontag) = "transactionHash"];
// tx_index of the transaction in the block
uint64 tx_index = 6 [(gogoproto.jsontag) = "transactionIndex"];
// block_hash of the block in which the transaction was included
string block_hash = 7 [(gogoproto.jsontag) = "blockHash"];
// index of the log in the block
uint64 index = 8 [(gogoproto.jsontag) = "logIndex"];
// removed is true if this log was reverted due to a chain
// reorganisation. You must pay attention to this field if you receive logs
// through a filter query.
bool removed = 9;
}
// TxResult stores results of Tx execution.
message TxResult {
option (gogoproto.goproto_getters) = false;
// contract_address contains the ethereum address of the created contract (if
// any). If the state transition is an evm.Call, the contract address will be
// empty.
string contract_address = 1 [(gogoproto.moretags) = "yaml:\"contract_address\""];
// bloom represents the bloom filter bytes
bytes bloom = 2;
// tx_logs contains the transaction hash and the proto-compatible ethereum
// logs.
TransactionLogs tx_logs = 3 [(gogoproto.moretags) = "yaml:\"tx_logs\"", (gogoproto.nullable) = false];
// ret defines the bytes from the execution.
bytes ret = 4;
// reverted flag is set to true when the call has been reverted
bool reverted = 5;
// gas_used notes the amount of gas consumed while execution
uint64 gas_used = 6;
}
// AccessTuple is the element type of an access list.
message AccessTuple {
option (gogoproto.goproto_getters) = false;
// address is a hex formatted ethereum address
string address = 1;
// storage_keys are hex formatted hashes of the storage keys
repeated string storage_keys = 2 [(gogoproto.jsontag) = "storageKeys"];
}
// TraceConfig holds extra parameters to trace functions.
message TraceConfig {
// DEPRECATED: DisableMemory and DisableReturnData have been renamed to
// Enable*.
reserved 4, 7;
reserved "disable_memory", "disable_return_data";
// tracer is a custom javascript tracer
string tracer = 1;
// timeout overrides the default timeout of 5 seconds for JavaScript-based tracing
// calls
string timeout = 2;
// reexec defines the number of blocks the tracer is willing to go back
uint64 reexec = 3;
// disable_stack switches stack capture
bool disable_stack = 5 [(gogoproto.jsontag) = "disableStack"];
// disable_storage switches storage capture
bool disable_storage = 6 [(gogoproto.jsontag) = "disableStorage"];
// debug can be used to print output during capture end
bool debug = 8;
// limit defines the maximum length of output, but zero means unlimited
int32 limit = 9;
// overrides can be used to execute a trace using future fork rules
ChainConfig overrides = 10;
// enable_memory switches memory capture
bool enable_memory = 11 [(gogoproto.jsontag) = "enableMemory"];
// enable_return_data switches the capture of return data
bool enable_return_data = 12 [(gogoproto.jsontag) = "enableReturnData"];
// tracer_json_config configures the tracer using a JSON string
string tracer_json_config = 13 [(gogoproto.jsontag) = "tracerConfig"];
}
+27
View File
@@ -0,0 +1,27 @@
syntax = "proto3";
package ethermint.evm.v1;
import "ethermint/evm/v1/evm.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/cerc-io/laconicd/x/evm/types";
// GenesisState defines the evm module's genesis state.
message GenesisState {
// accounts is an array containing the ethereum genesis accounts.
repeated GenesisAccount accounts = 1 [(gogoproto.nullable) = false];
// params defines all the parameters of the module.
Params params = 2 [(gogoproto.nullable) = false];
}
// GenesisAccount defines an account to be initialized in the genesis state.
// Its main difference between with Geth's GenesisAccount is that it uses a
// custom storage type and that it doesn't contain the private key field.
message GenesisAccount {
// address defines an ethereum hex formated address of an account
string address = 1;
// code defines the hex bytes of the account code.
string code = 2;
// storage defines the set of state key values for the account.
repeated State storage = 3 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "Storage"];
}
+298
View File
@@ -0,0 +1,298 @@
syntax = "proto3";
package ethermint.evm.v1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "ethermint/evm/v1/evm.proto";
import "ethermint/evm/v1/tx.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/cerc-io/laconicd/x/evm/types";
// Query defines the gRPC querier service.
service Query {
// Account queries an Ethereum account.
rpc Account(QueryAccountRequest) returns (QueryAccountResponse) {
option (google.api.http).get = "/ethermint/evm/v1/account/{address}";
}
// CosmosAccount queries an Ethereum account's Cosmos Address.
rpc CosmosAccount(QueryCosmosAccountRequest) returns (QueryCosmosAccountResponse) {
option (google.api.http).get = "/ethermint/evm/v1/cosmos_account/{address}";
}
// ValidatorAccount queries an Ethereum account's from a validator consensus
// Address.
rpc ValidatorAccount(QueryValidatorAccountRequest) returns (QueryValidatorAccountResponse) {
option (google.api.http).get = "/ethermint/evm/v1/validator_account/{cons_address}";
}
// Balance queries the balance of a the EVM denomination for a single
// EthAccount.
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
option (google.api.http).get = "/ethermint/evm/v1/balances/{address}";
}
// Storage queries the balance of all coins for a single account.
rpc Storage(QueryStorageRequest) returns (QueryStorageResponse) {
option (google.api.http).get = "/ethermint/evm/v1/storage/{address}/{key}";
}
// Code queries the balance of all coins for a single account.
rpc Code(QueryCodeRequest) returns (QueryCodeResponse) {
option (google.api.http).get = "/ethermint/evm/v1/codes/{address}";
}
// Params queries the parameters of x/evm module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/ethermint/evm/v1/params";
}
// EthCall implements the `eth_call` rpc api
rpc EthCall(EthCallRequest) returns (MsgEthereumTxResponse) {
option (google.api.http).get = "/ethermint/evm/v1/eth_call";
}
// EstimateGas implements the `eth_estimateGas` rpc api
rpc EstimateGas(EthCallRequest) returns (EstimateGasResponse) {
option (google.api.http).get = "/ethermint/evm/v1/estimate_gas";
}
// TraceTx implements the `debug_traceTransaction` rpc api
rpc TraceTx(QueryTraceTxRequest) returns (QueryTraceTxResponse) {
option (google.api.http).get = "/ethermint/evm/v1/trace_tx";
}
// TraceBlock implements the `debug_traceBlockByNumber` and `debug_traceBlockByHash` rpc api
rpc TraceBlock(QueryTraceBlockRequest) returns (QueryTraceBlockResponse) {
option (google.api.http).get = "/ethermint/evm/v1/trace_block";
}
// BaseFee queries the base fee of the parent block of the current block,
// it's similar to feemarket module's method, but also checks london hardfork status.
rpc BaseFee(QueryBaseFeeRequest) returns (QueryBaseFeeResponse) {
option (google.api.http).get = "/ethermint/evm/v1/base_fee";
}
}
// QueryAccountRequest is the request type for the Query/Account RPC method.
message QueryAccountRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// address is the ethereum hex address to query the account for.
string address = 1;
}
// QueryAccountResponse is the response type for the Query/Account RPC method.
message QueryAccountResponse {
// balance is the balance of the EVM denomination.
string balance = 1;
// code_hash is the hex-formatted code bytes from the EOA.
string code_hash = 2;
// nonce is the account's sequence number.
uint64 nonce = 3;
}
// QueryCosmosAccountRequest is the request type for the Query/CosmosAccount RPC
// method.
message QueryCosmosAccountRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// address is the ethereum hex address to query the account for.
string address = 1;
}
// QueryCosmosAccountResponse is the response type for the Query/CosmosAccount
// RPC method.
message QueryCosmosAccountResponse {
// cosmos_address is the cosmos address of the account.
string cosmos_address = 1;
// sequence is the account's sequence number.
uint64 sequence = 2;
// account_number is the account number
uint64 account_number = 3;
}
// QueryValidatorAccountRequest is the request type for the
// Query/ValidatorAccount RPC method.
message QueryValidatorAccountRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// cons_address is the validator cons address to query the account for.
string cons_address = 1;
}
// QueryValidatorAccountResponse is the response type for the
// Query/ValidatorAccount RPC method.
message QueryValidatorAccountResponse {
// account_address is the cosmos address of the account in bech32 format.
string account_address = 1;
// sequence is the account's sequence number.
uint64 sequence = 2;
// account_number is the account number
uint64 account_number = 3;
}
// QueryBalanceRequest is the request type for the Query/Balance RPC method.
message QueryBalanceRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// address is the ethereum hex address to query the balance for.
string address = 1;
}
// QueryBalanceResponse is the response type for the Query/Balance RPC method.
message QueryBalanceResponse {
// balance is the balance of the EVM denomination.
string balance = 1;
}
// QueryStorageRequest is the request type for the Query/Storage RPC method.
message QueryStorageRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// address is the ethereum hex address to query the storage state for.
string address = 1;
// key defines the key of the storage state
string key = 2;
}
// QueryStorageResponse is the response type for the Query/Storage RPC
// method.
message QueryStorageResponse {
// value defines the storage state value hash associated with the given key.
string value = 1;
}
// QueryCodeRequest is the request type for the Query/Code RPC method.
message QueryCodeRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// address is the ethereum hex address to query the code for.
string address = 1;
}
// QueryCodeResponse is the response type for the Query/Code RPC
// method.
message QueryCodeResponse {
// code represents the code bytes from an ethereum address.
bytes code = 1;
}
// QueryTxLogsRequest is the request type for the Query/TxLogs RPC method.
message QueryTxLogsRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
// hash is the ethereum transaction hex hash to query the logs for.
string hash = 1;
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryTxLogsResponse is the response type for the Query/TxLogs RPC method.
message QueryTxLogsResponse {
// logs represents the ethereum logs generated from the given transaction.
repeated Log logs = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
// QueryParamsRequest defines the request type for querying x/evm parameters.
message QueryParamsRequest {}
// QueryParamsResponse defines the response type for querying x/evm parameters.
message QueryParamsResponse {
// params define the evm module parameters.
Params params = 1 [(gogoproto.nullable) = false];
}
// EthCallRequest defines EthCall request
message EthCallRequest {
// args uses the same json format as the json rpc api.
bytes args = 1;
// gas_cap defines the default gas cap to be used
uint64 gas_cap = 2;
// proposer_address of the requested block in hex format
bytes proposer_address = 3 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress"];
// chain_id is the eip155 chain id parsed from the requested block header
int64 chain_id = 4;
}
// EstimateGasResponse defines EstimateGas response
message EstimateGasResponse {
// gas returns the estimated gas
uint64 gas = 1;
}
// QueryTraceTxRequest defines TraceTx request
message QueryTraceTxRequest {
// msg is the MsgEthereumTx for the requested transaction
MsgEthereumTx msg = 1;
// tx_index is not necessary anymore
reserved 2;
reserved "tx_index";
// trace_config holds extra parameters to trace functions.
TraceConfig trace_config = 3;
// predecessors is an array of transactions included in the same block
// need to be replayed first to get correct context for tracing.
repeated MsgEthereumTx predecessors = 4;
// block_number of requested transaction
int64 block_number = 5;
// block_hash of requested transaction
string block_hash = 6;
// block_time of requested transaction
google.protobuf.Timestamp block_time = 7 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// proposer_address is the proposer of the requested block
bytes proposer_address = 8 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress"];
// chain_id is the the eip155 chain id parsed from the requested block header
int64 chain_id = 9;
}
// QueryTraceTxResponse defines TraceTx response
message QueryTraceTxResponse {
// data is the response serialized in bytes
bytes data = 1;
}
// QueryTraceBlockRequest defines TraceTx request
message QueryTraceBlockRequest {
// txs is an array of messages in the block
repeated MsgEthereumTx txs = 1;
// trace_config holds extra parameters to trace functions.
TraceConfig trace_config = 3;
// block_number of the traced block
int64 block_number = 5;
// block_hash (hex) of the traced block
string block_hash = 6;
// block_time of the traced block
google.protobuf.Timestamp block_time = 7 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// proposer_address is the address of the requested block
bytes proposer_address = 8 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress"];
// chain_id is the eip155 chain id parsed from the requested block header
int64 chain_id = 9;
}
// QueryTraceBlockResponse defines TraceBlock response
message QueryTraceBlockResponse {
// data is the response serialized in bytes
bytes data = 1;
}
// QueryBaseFeeRequest defines the request type for querying the EIP1559 base
// fee.
message QueryBaseFeeRequest {}
// QueryBaseFeeResponse returns the EIP1559 base fee.
message QueryBaseFeeResponse {
// base_fee is the EIP1559 base fee
string base_fee = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
}
+160
View File
@@ -0,0 +1,160 @@
syntax = "proto3";
package ethermint.evm.v1;
import "cosmos_proto/cosmos.proto";
import "ethermint/evm/v1/evm.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";
option go_package = "github.com/cerc-io/laconicd/x/evm/types";
// Msg defines the evm Msg service.
service Msg {
// EthereumTx defines a method submitting Ethereum transactions.
rpc EthereumTx(MsgEthereumTx) returns (MsgEthereumTxResponse) {
option (google.api.http).post = "/ethermint/evm/v1/ethereum_tx";
};
}
// MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.
message MsgEthereumTx {
option (gogoproto.goproto_getters) = false;
// data is inner transaction data of the Ethereum transaction
google.protobuf.Any data = 1;
// size is the encoded storage size of the transaction (DEPRECATED)
double size = 2 [(gogoproto.jsontag) = "-"];
// hash of the transaction in hex format
string hash = 3 [(gogoproto.moretags) = "rlp:\"-\""];
// from is the ethereum signer address in hex format. This address value is checked
// against the address derived from the signature (V, R, S) using the
// secp256k1 elliptic curve
string from = 4;
}
// LegacyTx is the transaction data of regular Ethereum transactions.
// NOTE: All non-protected transactions (i.e non EIP155 signed) will fail if the
// AllowUnprotectedTxs parameter is disabled.
message LegacyTx {
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "TxData";
// nonce corresponds to the account nonce (transaction sequence).
uint64 nonce = 1;
// gas_price defines the value for each gas unit
string gas_price = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
// gas defines the gas limit defined for the transaction.
uint64 gas = 3 [(gogoproto.customname) = "GasLimit"];
// to is the hex formatted address of the recipient
string to = 4;
// value defines the unsigned integer value of the transaction amount.
string value = 5
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 6;
// v defines the signature value
bytes v = 7;
// r defines the signature value
bytes r = 8;
// s define the signature value
bytes s = 9;
}
// AccessListTx is the data of EIP-2930 access list transactions.
message AccessListTx {
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "TxData";
// chain_id of the destination EVM chain
string chain_id = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.customname) = "ChainID",
(gogoproto.jsontag) = "chainID"
];
// nonce corresponds to the account nonce (transaction sequence).
uint64 nonce = 2;
// gas_price defines the value for each gas unit
string gas_price = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
// gas defines the gas limit defined for the transaction.
uint64 gas = 4 [(gogoproto.customname) = "GasLimit"];
// to is the recipient address in hex format
string to = 5;
// value defines the unsigned integer value of the transaction amount.
string value = 6
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 7;
// accesses is an array of access tuples
repeated AccessTuple accesses = 8
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
// v defines the signature value
bytes v = 9;
// r defines the signature value
bytes r = 10;
// s define the signature value
bytes s = 11;
}
// DynamicFeeTx is the data of EIP-1559 dinamic fee transactions.
message DynamicFeeTx {
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "TxData";
// chain_id of the destination EVM chain
string chain_id = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.customname) = "ChainID",
(gogoproto.jsontag) = "chainID"
];
// nonce corresponds to the account nonce (transaction sequence).
uint64 nonce = 2;
// gas_tip_cap defines the max value for the gas tip
string gas_tip_cap = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
// gas_fee_cap defines the max value for the gas fee
string gas_fee_cap = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];
// gas defines the gas limit defined for the transaction.
uint64 gas = 5 [(gogoproto.customname) = "GasLimit"];
// to is the hex formatted address of the recipient
string to = 6;
// value defines the the transaction amount.
string value = 7
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 8;
// accesses is an array of access tuples
repeated AccessTuple accesses = 9
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
// v defines the signature value
bytes v = 10;
// r defines the signature value
bytes r = 11;
// s define the signature value
bytes s = 12;
}
// ExtensionOptionsEthereumTx is an extension option for ethereum transactions
message ExtensionOptionsEthereumTx {
option (gogoproto.goproto_getters) = false;
}
// MsgEthereumTxResponse defines the Msg/EthereumTx response type.
message MsgEthereumTxResponse {
option (gogoproto.goproto_getters) = false;
// hash of the ethereum transaction in hex format. This hash differs from the
// Tendermint sha256 hash of the transaction bytes. See
// https://github.com/tendermint/tendermint/issues/6539 for reference
string hash = 1;
// logs contains the transaction hash and the proto-compatible ethereum
// logs.
repeated Log logs = 2;
// ret is the returned data from evm function (result or data supplied with revert
// opcode)
bytes ret = 3;
// vm_error is the error returned by vm execution
string vm_error = 4;
// gas_used specifies how much gas was consumed by the transaction
uint64 gas_used = 5;
}
+1 -1
View File
@@ -9,4 +9,4 @@ protoc \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--ts_out=$DEST_TS \
--proto_path=$I \
$(find $(pwd)/proto/vulcanize -iname "*.proto")
$(find $(pwd)/proto/vulcanize $(pwd)/proto/ethermint -iname "*.proto")
File diff suppressed because one or more lines are too long
+51
View File
@@ -0,0 +1,51 @@
import { ethers } from 'ethers';
import { Account } from './account';
import { Registry } from './index';
import { getConfig } from './testing/helper';
import { abi } from './artifacts/PhisherRegistry.json'
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
jest.setTimeout(90 * 1000);
const CONTRACT_ADDRESS = "0xD035Adc6d41f9136C9C19434E0500F7706664e66"
const ETH_RPC_ENDPOINT = "http://localhost:8545"
const evmTests = () => {
let registry: Registry;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
});
test.only('Send eth tx for contract method.', async() => {
// TODO: Refactor inside sendEthTx?
const provider = new ethers.providers.JsonRpcProvider(ETH_RPC_ENDPOINT)
const signer = new ethers.Wallet(privateKey, provider)
const contract = new ethers.Contract(CONTRACT_ADDRESS, abi, signer);
const populatedTx = await contract.populateTransaction
.claimIfPhisher('phisher1', true);
const signerPopulatedTx = await signer.populateTransaction(populatedTx);
const signedTxString = await signer.signTransaction(signerPopulatedTx);
const tx = ethers.utils.parseTransaction(signedTxString);
// TODO: Use laconicd queries in evm module
tx.gasLimit = await provider.estimateGas(signerPopulatedTx);
console.log('tx', tx)
await registry.sendEthTx(
{
tx,
from: signer.address
},
privateKey,
fee
);
})
}
describe('evm', evmTests);
+28 -1
View File
@@ -7,11 +7,12 @@ import {
createMessageSend,
MessageSendParams
} from '@tharsis/transactions'
import { ethers } from 'ethers';
import { RegistryClient } from "./registry-client";
import { Account } from "./account";
import { createTransaction } from "./txbuilder";
import { Payload, Record } from './types';
import { EthereumTxData, Payload, Record } from './types';
import { Util } from './util';
import {
createTxMsgAssociateBond,
@@ -51,6 +52,7 @@ import {
MessageMsgCommitBid,
MessageMsgRevealBid
} from './messages/auction';
import { createTxMsgEthereumTx, MessageMsgEthereumTx } from './messages/evm';
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
@@ -462,6 +464,31 @@ export class Registry {
return parseTxResponse(result);
}
/**
* Send ethereum transaction.
*/
async sendEthTx(
{ tx, from }: { tx: ethers.Transaction, from: string },
privateKey: string,
fee: Fee
) {
let result;
const account = new Account(Buffer.from(privateKey, 'hex'));
console.log('account.registryAddress', account.registryAddress);
const sender = await this._getSender(account);
const msgParams = {
data: new EthereumTxData(tx),
hash: tx.hash!,
from
}
const msg = createTxMsgEthereumTx(this._chain, sender, fee, '', msgParams)
result = await this._submitTx(msg, privateKey, sender);
return parseTxResponse(result);
}
/**
* Submit record transaction.
* @param privateKey - private key in HEX to sign message.
+87
View File
@@ -0,0 +1,87 @@
import {
generateTypes,
} from '@tharsis/eip712'
import {
Chain,
Sender,
Fee,
} from '@tharsis/transactions'
import * as evmTx from '../proto/ethermint/evm/v1/tx'
import * as registry from '../proto/vulcanize/registry/v1beta1/registry'
import { EthereumTxData } from '../types'
import { createTx } from './util'
const MSG_ETHEREUM_TX_TYPES = {
MsgValue: [
{ name: 'data', type: 'TypeData' },
{ name: 'hash', type: 'string' },
{ name: 'from', type: 'string' }
],
TypeData: [
{ name: 'type_url', type: 'string' },
{ name: 'value', type: 'uint8[]' },
],
}
export interface MessageMsgEthereumTx {
data: EthereumTxData,
hash: string,
from: string
}
export function createTxMsgEthereumTx(
chain: Chain,
sender: Sender,
fee: Fee,
memo: string,
params: MessageMsgEthereumTx,
) {
const types = generateTypes(MSG_ETHEREUM_TX_TYPES)
const msg = createMsgEthereumTx(
params.data,
params.hash,
params.from
)
const msgCosmos = protoCreateMsgEthereumTx(
params.data,
params.hash,
params.from
)
return createTx(chain, sender, fee, memo, types, msg, msgCosmos)
}
function createMsgEthereumTx(
data: EthereumTxData,
hash: string,
from: string
) {
return {
type: 'evm/EthereumTx',
value: {
data: data.serialize(),
hash,
from
},
}
}
const protoCreateMsgEthereumTx = (
data: EthereumTxData,
hash: string,
from: string
) => {
const ethereumTxMessage = new evmTx.ethermint.evm.v1.MsgEthereumTx({
data: data.serialize(),
hash,
from,
})
return {
message: ethereumTxMessage,
path: 'ethermint.evm.v1.MsgEthereumTx',
}
}
+3 -1
View File
@@ -75,10 +75,12 @@ export const parseMsgSetRecordResponse = (data: string) => {
const responseBytes = Buffer.from(data, 'hex')
// TODO: Decode response using protobuf.
// const msgSetRecordResponse = registryTx.vulcanize.registry.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
// const msgSetRecordResponse = nameserviceTx.vulcanize.nameservice.v1beta1.MsgSetRecordResponse.deserialize(responseBytes);
// return msgSetRecordResponse.toObject();
// Workaround as proto based decoding is not working.
const [_, id] = responseBytes.toString().split(';')
return { id }
}
+9 -8
View File
@@ -30,7 +30,7 @@ const nameserviceExpiryTests = () => {
test('Set record and check bond balance', async () => {
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
await registry.setRecord(
const result = await registry.setRecord(
{
privateKey,
bondId,
@@ -39,8 +39,8 @@ const nameserviceExpiryTests = () => {
privateKey,
fee
)
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
console.log("SetRecordResult: " + result.data.id)
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
recordExpiryTime = new Date(record.expiryTime);
const [bond] = await registry.getBondsByIds([bondId]);
@@ -63,21 +63,22 @@ const nameserviceExpiryTests = () => {
});
test('Check record expiry time', async() => {
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
const updatedExpiryTime = new Date(record.expiryTime);
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
const updatedExpiryTime = new Date();
expect(updatedExpiryTime.getTime()).toBeGreaterThan(recordExpiryTime.getTime());
recordExpiryTime = updatedExpiryTime;
})
test('Check authority expiry time', async() => {
const [authority] = await registry.lookupAuthorities([authorityName]);
const updatedExpiryTime = new Date(authority.expiryTime);
const updatedExpiryTime = new Date();
expect(updatedExpiryTime.getTime()).toBeGreaterThan(authorityExpiryTime.getTime());
authorityExpiryTime = updatedExpiryTime;
})
test('Check bond balance', async () => {
const [bond] = await registry.getBondsByIds([bondId]);
console.log(bond)
expect(bond).toBeDefined();
expect(bond.balance).toHaveLength(0);
})
@@ -87,7 +88,7 @@ const nameserviceExpiryTests = () => {
});
test('Check record deleted without bond balance', async() => {
const records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
expect(records).toHaveLength(0);
})
@@ -104,7 +105,7 @@ if (!process.env.TEST_NAMESERVICE_EXPIRY) {
/**
Running these tests requires timers to be set. In laconicd repo run:
TEST_NAMESERVICE_EXPIRY=true ./init.sh
TEST_REGISTRY_EXPIRY=true ./init.sh
Run tests:
+1 -2
View File
@@ -29,7 +29,7 @@ const namingTests = () => {
// Create bond.
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
await registry.createBond({ denom: 'aphoton', amount: '2000000000' }, privateKey, fee);
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
@@ -244,7 +244,6 @@ const namingTests = () => {
const records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest }] = records;
@@ -37,7 +37,7 @@ export namespace cosmos.base.query.v1beta1 {
}
}
get key() {
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
}
set key(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
@@ -184,7 +184,7 @@ export namespace cosmos.base.query.v1beta1 {
}
}
get next_key() {
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
}
set next_key(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
+219
View File
@@ -0,0 +1,219 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* source: cosmos_proto/cosmos.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./../google/protobuf/descriptor";
import * as pb_1 from "google-protobuf";
export namespace cosmos_proto {
export enum ScalarType {
SCALAR_TYPE_UNSPECIFIED = 0,
SCALAR_TYPE_STRING = 1,
SCALAR_TYPE_BYTES = 2
}
export class InterfaceDescriptor extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
name?: string;
description?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("name" in data && data.name != undefined) {
this.name = data.name;
}
if ("description" in data && data.description != undefined) {
this.description = data.description;
}
}
}
get name() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 1, value);
}
get description() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set description(value: string) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
name?: string;
description?: string;
}): InterfaceDescriptor {
const message = new InterfaceDescriptor({});
if (data.name != null) {
message.name = data.name;
}
if (data.description != null) {
message.description = data.description;
}
return message;
}
toObject() {
const data: {
name?: string;
description?: string;
} = {};
if (this.name != null) {
data.name = this.name;
}
if (this.description != null) {
data.description = this.description;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.name.length)
writer.writeString(1, this.name);
if (this.description.length)
writer.writeString(2, this.description);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): InterfaceDescriptor {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new InterfaceDescriptor();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.name = reader.readString();
break;
case 2:
message.description = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): InterfaceDescriptor {
return InterfaceDescriptor.deserialize(bytes);
}
}
export class ScalarDescriptor extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
name?: string;
description?: string;
field_type?: ScalarType[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("name" in data && data.name != undefined) {
this.name = data.name;
}
if ("description" in data && data.description != undefined) {
this.description = data.description;
}
if ("field_type" in data && data.field_type != undefined) {
this.field_type = data.field_type;
}
}
}
get name() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 1, value);
}
get description() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set description(value: string) {
pb_1.Message.setField(this, 2, value);
}
get field_type() {
return pb_1.Message.getFieldWithDefault(this, 3, []) as ScalarType[];
}
set field_type(value: ScalarType[]) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
name?: string;
description?: string;
field_type?: ScalarType[];
}): ScalarDescriptor {
const message = new ScalarDescriptor({});
if (data.name != null) {
message.name = data.name;
}
if (data.description != null) {
message.description = data.description;
}
if (data.field_type != null) {
message.field_type = data.field_type;
}
return message;
}
toObject() {
const data: {
name?: string;
description?: string;
field_type?: ScalarType[];
} = {};
if (this.name != null) {
data.name = this.name;
}
if (this.description != null) {
data.description = this.description;
}
if (this.field_type != null) {
data.field_type = this.field_type;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.name.length)
writer.writeString(1, this.name);
if (this.description.length)
writer.writeString(2, this.description);
if (this.field_type.length)
writer.writePackedEnum(3, this.field_type);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ScalarDescriptor {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ScalarDescriptor();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.name = reader.readString();
break;
case 2:
message.description = reader.readString();
break;
case 3:
message.field_type = reader.readPackedEnum();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): ScalarDescriptor {
return ScalarDescriptor.deserialize(bytes);
}
}
}
File diff suppressed because it is too large Load Diff
+218
View File
@@ -0,0 +1,218 @@
// @ts-nocheck
/* eslint-disable */
/**
* Generated by the protoc-gen-ts. DO NOT EDIT!
* compiler version: 3.12.4
* source: ethermint/evm/v1/genesis.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./evm";
import * as dependency_2 from "./../../../gogoproto/gogo";
import * as pb_1 from "google-protobuf";
export namespace ethermint.evm.v1 {
export class GenesisState extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
accounts?: GenesisAccount[];
params?: dependency_1.ethermint.evm.v1.Params;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("accounts" in data && data.accounts != undefined) {
this.accounts = data.accounts;
}
if ("params" in data && data.params != undefined) {
this.params = data.params;
}
}
}
get accounts() {
return pb_1.Message.getRepeatedWrapperField(this, GenesisAccount, 1) as GenesisAccount[];
}
set accounts(value: GenesisAccount[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
get params() {
return pb_1.Message.getWrapperField(this, dependency_1.ethermint.evm.v1.Params, 2) as dependency_1.ethermint.evm.v1.Params;
}
set params(value: dependency_1.ethermint.evm.v1.Params) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_params() {
return pb_1.Message.getField(this, 2) != null;
}
static fromObject(data: {
accounts?: ReturnType<typeof GenesisAccount.prototype.toObject>[];
params?: ReturnType<typeof dependency_1.ethermint.evm.v1.Params.prototype.toObject>;
}): GenesisState {
const message = new GenesisState({});
if (data.accounts != null) {
message.accounts = data.accounts.map(item => GenesisAccount.fromObject(item));
}
if (data.params != null) {
message.params = dependency_1.ethermint.evm.v1.Params.fromObject(data.params);
}
return message;
}
toObject() {
const data: {
accounts?: ReturnType<typeof GenesisAccount.prototype.toObject>[];
params?: ReturnType<typeof dependency_1.ethermint.evm.v1.Params.prototype.toObject>;
} = {};
if (this.accounts != null) {
data.accounts = this.accounts.map((item: GenesisAccount) => item.toObject());
}
if (this.params != null) {
data.params = this.params.toObject();
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.accounts.length)
writer.writeRepeatedMessage(1, this.accounts, (item: GenesisAccount) => item.serialize(writer));
if (this.has_params)
writer.writeMessage(2, this.params, () => this.params.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GenesisState {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GenesisState();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.accounts, () => pb_1.Message.addToRepeatedWrapperField(message, 1, GenesisAccount.deserialize(reader), GenesisAccount));
break;
case 2:
reader.readMessage(message.params, () => message.params = dependency_1.ethermint.evm.v1.Params.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GenesisState {
return GenesisState.deserialize(bytes);
}
}
export class GenesisAccount extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
address?: string;
code?: string;
storage?: dependency_1.ethermint.evm.v1.State[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("address" in data && data.address != undefined) {
this.address = data.address;
}
if ("code" in data && data.code != undefined) {
this.code = data.code;
}
if ("storage" in data && data.storage != undefined) {
this.storage = data.storage;
}
}
}
get address() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set address(value: string) {
pb_1.Message.setField(this, 1, value);
}
get code() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set code(value: string) {
pb_1.Message.setField(this, 2, value);
}
get storage() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_1.ethermint.evm.v1.State, 3) as dependency_1.ethermint.evm.v1.State[];
}
set storage(value: dependency_1.ethermint.evm.v1.State[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
static fromObject(data: {
address?: string;
code?: string;
storage?: ReturnType<typeof dependency_1.ethermint.evm.v1.State.prototype.toObject>[];
}): GenesisAccount {
const message = new GenesisAccount({});
if (data.address != null) {
message.address = data.address;
}
if (data.code != null) {
message.code = data.code;
}
if (data.storage != null) {
message.storage = data.storage.map(item => dependency_1.ethermint.evm.v1.State.fromObject(item));
}
return message;
}
toObject() {
const data: {
address?: string;
code?: string;
storage?: ReturnType<typeof dependency_1.ethermint.evm.v1.State.prototype.toObject>[];
} = {};
if (this.address != null) {
data.address = this.address;
}
if (this.code != null) {
data.code = this.code;
}
if (this.storage != null) {
data.storage = this.storage.map((item: dependency_1.ethermint.evm.v1.State) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.address.length)
writer.writeString(1, this.address);
if (this.code.length)
writer.writeString(2, this.code);
if (this.storage.length)
writer.writeRepeatedMessage(3, this.storage, (item: dependency_1.ethermint.evm.v1.State) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GenesisAccount {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GenesisAccount();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.address = reader.readString();
break;
case 2:
message.code = reader.readString();
break;
case 3:
reader.readMessage(message.storage, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_1.ethermint.evm.v1.State.deserialize(reader), dependency_1.ethermint.evm.v1.State));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GenesisAccount {
return GenesisAccount.deserialize(bytes);
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -32,7 +32,7 @@ export namespace google.protobuf {
pb_1.Message.setField(this, 1, value);
}
get value() {
return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0)) as Uint8Array;
}
set value(value: Uint8Array) {
pb_1.Message.setField(this, 2, value);
+1 -1
View File
@@ -3604,7 +3604,7 @@ export namespace google.protobuf {
return pb_1.Message.getField(this, 6) != null;
}
get string_value() {
return pb_1.Message.getFieldWithDefault(this, 7, new Uint8Array()) as Uint8Array;
return pb_1.Message.getFieldWithDefault(this, 7, new Uint8Array(0)) as Uint8Array;
}
set string_value(value: Uint8Array) {
pb_1.Message.setField(this, 7, value);
+1 -1
View File
@@ -4,4 +4,4 @@ record:
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.17
version: 1.0.23
+12 -7
View File
@@ -24,13 +24,18 @@ export const getBaseConfig = async (path: string) => {
* Provision a bond for record registration.
*/
export const provisionBondId = async (registry: Registry, privateKey: string, fee: Fee) => {
let bonds = await registry.queryBonds();
if (!bonds.length) {
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
bonds = await registry.queryBonds();
}
return bonds[0].id;
// let bonds = await registry.queryBonds();
// console.log("found bonds: " + bonds.length)
// if (!bonds.length) {
// await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// bonds = await registry.queryBonds();
// console.log("created bond and got back: " + bonds.length)
// }
let bondId: string;
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
return bondId
//return bonds[0].id;
};
export const getConfig = () => {
+32
View File
@@ -1,9 +1,11 @@
import assert from 'assert';
import { Validator } from 'jsonschema';
import { ethers } from 'ethers';
import RecordSchema from './schema/record.json';
import { Util } from './util';
import * as attributes from './proto/vulcanize/registry/v1beta1/attributes';
import * as evmTx from './proto/ethermint/evm/v1/tx';
import * as any from './proto/google/protobuf/any';
/**
@@ -140,3 +142,33 @@ export class Payload {
}
}
}
export class EthereumTxData {
_tx: ethers.Transaction
constructor (tx: ethers.Transaction) {
this._tx = tx
}
serialize () {
var data= new evmTx.ethermint.evm.v1.LegacyTx({
nonce: this._tx.nonce,
data: ethers.utils.arrayify(this._tx.data),
gas: this._tx.gasLimit.toNumber(),
gas_price: this._tx.gasPrice?.toString(),
r: ethers.utils.arrayify(this._tx.r!),
s: ethers.utils.arrayify(this._tx.s!),
// TODO: Check if need to put in array
v: ethers.utils.arrayify([this._tx.v!]),
to: this._tx.to,
value: this._tx.value.toString()
})
return new any.google.protobuf.Any({
type_url: "/ethermint.evm.v1.TxData",
value: data.serialize()
});
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ const utilTests = () => {
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
// Create watcher.
watcher = await getBaseConfig(WATCHER_YML_PATH); //this overwrites version to 0.0.1
watcher = await getBaseConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
+1 -17
View File
@@ -2,8 +2,6 @@ import * as Block from 'multiformats/block'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
import * as dagCBOR from '@ipld/dag-cbor'
import * as dagJSON from '@ipld/dag-json'
//import { CID } from 'multiformats/cid'
//import * as json from 'multiformats/codecs/json'
/**
* Utils
@@ -88,29 +86,15 @@ export class Util {
* Get record content ID.
*/
static async getContentId(record: any) {
//this encode/decode does nothing, afaict
const serialized = dagJSON.encode(record)
const recordData = dagJSON.decode(serialized)
//these are for version 0.0.1 of watcher.yml test data:
//const dside = {"build_artifact_cid":"QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9","repo_registration_record_cid":"QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D","tls_cert_cid":"QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR","type":"WebsiteRegistrationRecord","url":"https://cerc.io","version":"0.0.1"}
//bafyreiek4hnoqmits66bjyxswapplweuoqe4en2ux6u772o4y3askpd3ny is the CBOR encoding w/ sha 256 hasher
//bafyreifalhff7dp6o4hd573b5zdbbnl2wml5q2nrms474lrzp7dgptwxkm is expected DAG-CBOR w/ sha 256 hasher
//bafyreihpfkdvib5muloxlj5b3tgdwibjdcu3zdsuhyft33z7gtgnlzlkpm is CBOR??? encoding of empty json payload.
const block = await Block.encode({
value: recordData,
codec: dagCBOR,
hasher
})
//manual CID construction
//const dbytes = dagCBOR.encode(dside)
//console.log("BYTES: " + dbytes)
//const hash = await hasher.digest(dbytes)
//console.log("HASH: " + hash)
//const cid = CID.create(1, dagCBOR.code, hash)
//console.log("TEST CID: " + cid.toString())
return block.cid.toString();
}
}
+4 -4
View File
@@ -3086,10 +3086,10 @@ protobufjs@~6.11.2:
"@types/node" ">=13.7.0"
long "^4.0.0"
protoc-gen-ts@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/protoc-gen-ts/-/protoc-gen-ts-0.8.5.tgz#5c277ff90b6b38f52313b1b0ad69e6c825305b29"
integrity sha512-LHZ+w/+DqmdgnhPtShgqtPtdv+hJ9bAXEIqNU0kkY2bPcCVIEWz5seOv20FCw6gbKorriTGP8xgz2RsIcrRvVw==
protoc-gen-ts@^0.8.6-rc1:
version "0.8.6-rc1"
resolved "https://registry.yarnpkg.com/protoc-gen-ts/-/protoc-gen-ts-0.8.6-rc1.tgz#6c0a247ec4e67bbaf09546263b1ec18b52c2638d"
integrity sha512-UfnuENo5T32nKC/jEEpobDeQQU94xtSe3ku4CH3q2/xGLcZ9KpIsUChdh5PK+Yl5Ed7KemU895ZmqeZex4nB5w==
randombytes@^2.0.1, randombytes@^2.1.0:
version "2.1.0"