diff --git a/packages/background/src/secret-wasm/enigma-utils.ts b/packages/background/src/secret-wasm/enigma-utils.ts index fc1ccd6130..2d28d2f5b1 100644 --- a/packages/background/src/secret-wasm/enigma-utils.ts +++ b/packages/background/src/secret-wasm/enigma-utils.ts @@ -2,18 +2,13 @@ import { generateKeyPair, sharedKey as x25519 } from "curve25519-js"; import { hkdf } from "@noble/hashes/hkdf"; import { sha256 } from "@noble/hashes/sha256"; import * as miscreant from "miscreant"; -import { - simpleFetch, - isSimpleFetchError, - SimpleFetchError, -} from "@keplr-wallet/simple-fetch"; +import { simpleFetch } from "@keplr-wallet/simple-fetch"; import { Buffer } from "buffer/"; import { ChainIdHelper } from "@keplr-wallet/cosmos"; const cryptoProvider = new miscreant.PolyfillCryptoProvider(); export interface EncryptionUtils { - isNewApi: boolean; getPubkey: () => Promise; decrypt: (ciphertext: Uint8Array, nonce: Uint8Array) => Promise; encrypt: (contractCodeHash: string, msg: object) => Promise; @@ -34,7 +29,6 @@ const secretConsensusIoPubKey = new Uint8Array( export class EnigmaUtils implements EncryptionUtils { private readonly privkey: Uint8Array; public readonly pubkey: Uint8Array; - public isNewApi: boolean; private consensusIoPubKey: Uint8Array = new Uint8Array(); // cache public constructor( @@ -55,7 +49,6 @@ export class EnigmaUtils implements EncryptionUtils { if (ChainIdHelper.parse(chainId).identifier === "secret") { this.consensusIoPubKey = secretConsensusIoPubKey; } - this.isNewApi = false; } private static secureRandom(count: number): Uint8Array { @@ -78,36 +71,14 @@ export class EnigmaUtils implements EncryptionUtils { return this.consensusIoPubKey; } - // try to fetch from the old API - try { - const response = await simpleFetch<{ result: { TxKey: string } }>( - this.url, - "/reg/tx-key" - ); - - this.consensusIoPubKey = new Uint8Array( - Buffer.from(response.data.result.TxKey, "base64") - ); - } catch (e: any) { - if ( - !isSimpleFetchError(e) || - !(e as SimpleFetchError).response || - (e as SimpleFetchError).response?.status != 501 - ) { - throw e; - } - - // if old API is not implemented, use the new one - const response = await simpleFetch<{ key: string }>( - this.url, - "/registration/v1beta1/tx-key" - ); - - this.consensusIoPubKey = new Uint8Array( - Buffer.from(response.data.key, "base64") - ); - this.isNewApi = true; - } + const response = await simpleFetch<{ key: string }>( + this.url, + "/registration/v1beta1/tx-key" + ); + + this.consensusIoPubKey = new Uint8Array( + Buffer.from(response.data.key, "base64") + ); return this.consensusIoPubKey; } diff --git a/packages/background/src/secret-wasm/handler.ts b/packages/background/src/secret-wasm/handler.ts index 98f8ef72e9..23f752ec0b 100644 --- a/packages/background/src/secret-wasm/handler.ts +++ b/packages/background/src/secret-wasm/handler.ts @@ -10,7 +10,6 @@ import { GetTxEncryptionKeyMsg, ReqeustEncryptMsg, RequestDecryptMsg, - IsNewApiMsg, } from "./messages"; import { SecretWasmService } from "./service"; import { PermissionInteractiveService } from "../permission-interactive"; @@ -41,11 +40,6 @@ export const getHandler: ( service, permissionInteractionService )(env, msg as GetTxEncryptionKeyMsg); - case IsNewApiMsg: - return handleIsNewApiMsg(service, permissionInteractionService)( - env, - msg as IsNewApiMsg - ); default: throw new KeplrError("secret-wasm", 120, "Unknown msg type"); } @@ -70,21 +64,6 @@ const handleGetPubkeyMsg: ( }; }; -const handleIsNewApiMsg: ( - service: SecretWasmService, - permissionInteractionService: PermissionInteractiveService -) => InternalHandler = (service, permissionInteractionService) => { - return async (env, msg) => { - await permissionInteractionService.ensureEnabled( - env, - [msg.chainId], - msg.origin - ); - - return await service.isNewApi(msg.chainId); - }; -}; - const handleReqeustEncryptMsg: ( service: SecretWasmService, permissionInteractionService: PermissionInteractiveService diff --git a/packages/background/src/secret-wasm/init.ts b/packages/background/src/secret-wasm/init.ts index 702cfafcdd..7b8485a6fb 100644 --- a/packages/background/src/secret-wasm/init.ts +++ b/packages/background/src/secret-wasm/init.ts @@ -4,7 +4,6 @@ import { GetTxEncryptionKeyMsg, ReqeustEncryptMsg, RequestDecryptMsg, - IsNewApiMsg, } from "./messages"; import { SecretWasmService } from "./service"; import { ROUTE } from "./constants"; @@ -20,7 +19,6 @@ export function init( router.registerMessage(ReqeustEncryptMsg); router.registerMessage(RequestDecryptMsg); router.registerMessage(GetTxEncryptionKeyMsg); - router.registerMessage(IsNewApiMsg); router.addHandler(ROUTE, getHandler(service, permissionInteractionService)); } diff --git a/packages/background/src/secret-wasm/messages.ts b/packages/background/src/secret-wasm/messages.ts index b3bab676b3..b4e036a09e 100644 --- a/packages/background/src/secret-wasm/messages.ts +++ b/packages/background/src/secret-wasm/messages.ts @@ -145,31 +145,3 @@ export class GetTxEncryptionKeyMsg extends Message { return GetTxEncryptionKeyMsg.type(); } } - -export class IsNewApiMsg extends Message { - public static type() { - return "is-new-api-msg"; - } - - constructor(public readonly chainId: string) { - super(); - } - - validateBasic(): void { - if (!this.chainId) { - throw new KeplrError("secret-wasm", 100, "chain id not set"); - } - } - - override approveExternal(): boolean { - return true; - } - - route(): string { - return ROUTE; - } - - type(): string { - return IsNewApiMsg.type(); - } -} diff --git a/packages/background/src/secret-wasm/service.ts b/packages/background/src/secret-wasm/service.ts index 3e0549c660..51681a5404 100644 --- a/packages/background/src/secret-wasm/service.ts +++ b/packages/background/src/secret-wasm/service.ts @@ -75,19 +75,6 @@ export class SecretWasmService { return utils.getTxEncryptionKey(nonce); } - async isNewApi(chainId: string): Promise { - const chainInfo = await this.chainsService.getChainInfoOrThrow(chainId); - - // XXX: Keplr should generate the seed deterministically according to the account. - // Otherwise, it will lost the encryption/decryption key if Keplr is uninstalled or local storage is cleared. - // For now, use the signature of some string to generate the seed. - // It need to more research. - const seed = await this.getSeed(chainInfo); - - const utils = this.getEnigmaUtils(chainInfo, seed); - return utils.isNewApi; - } - async encrypt( chainId: string, contractCodeHash: string, diff --git a/packages/proto-types/outputHash b/packages/proto-types/outputHash index b233996e8e..3fdf2b18f8 100644 --- a/packages/proto-types/outputHash +++ b/packages/proto-types/outputHash @@ -1 +1 @@ -47xVj6yH8GxPnu1BOIH1MiJVtlE6POLMYvtUZYTBu/5MPH+/VZKmDSx8zscGTLTJpxn9rxdR/+cPKXJdeaqXzulJEYlXTSU7x80PSUD7rlp2mWT0RYGFDIN+Fik5sFOv7Um1WRmAnzsEu+hDNatREyB47p1Gxms6JX0klLRyAyxUnUJRvDIjqQiAHvjtBGK0z5Fgtw08ei6MwIGQTf1GQHMO/FAQfd3uq8plIG5KNxinIvHEhmHGgaIg4xI/FZ/rWiyM34f1rcsIV73pCYbInRh3jcatX/QI80oBDMXBo9DCv5IaZQQs1G7JPcfzThPmjPz23bqwLBrP7svv9Bpxo/uu41Y= \ No newline at end of file +47xVj6yH8GxPnu1BOIH1MiJVtlE6POLMYvtUZYTBu/5MPH+/VZKmDSx8zscGTLTJpxn9rxdR/+cPKXJdeaqXzulJEYlXTSU7x80PSUD7rlp2mWT0RYGFDIN+Fik5sFOv7Um1WRmAnzsEu+hDNatREyB47p1Gxms6JX0klLRyAyxUnUJRvDIjqQiAHvjtBGK0z5Fgtw08ei6MwIGQTf1GQHMO/FAQfd3uq8plIG5KNxinIvHE5Y2JdKTWTeBl2xwmCpZBoqBYhKYIV73pCYbInRh3jcatX/QI80oBDMXBo9DCv5IaZQQs1G7JPcfzThPmjPz23bqwLBrP7svv9Bpxo/uu41Y= \ No newline at end of file diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/genesis.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1/genesis.proto deleted file mode 100644 index 15e4a5bc2e..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/genesis.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; -package secret.compute.v1; - -import "gogoproto/gogo.proto"; -import "secret/compute/v1beta1/types.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; - -// GenesisState - genesis state of x/wasm -message GenesisState { - // Params params = 1 [(gogoproto.nullable) = false]; - repeated Code codes = 2 - [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "codes,omitempty" ]; - repeated Contract contracts = 3 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "contracts,omitempty" - ]; - repeated Sequence sequences = 4 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "sequences,omitempty" - ]; -} - -// Code struct encompasses CodeInfo and CodeBytes -message Code { - uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; - CodeInfo code_info = 2 [ (gogoproto.nullable) = false ]; - bytes code_bytes = 3; -} - -// Contract struct encompasses ContractAddress, ContractInfo, and ContractState -message Contract { - bytes contract_address = 1 - [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - ContractInfo contract_info = 2 [ (gogoproto.nullable) = false ]; - repeated Model contract_state = 3 [ (gogoproto.nullable) = false ]; - ContractCustomInfo contract_custom_info = 4; -} - -// Sequence id and value of a counter -message Sequence { - bytes id_key = 1 [ (gogoproto.customname) = "IDKey" ]; - uint64 value = 2; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/msg.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1/msg.proto deleted file mode 100644 index c4a29f4c2e..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/msg.proto +++ /dev/null @@ -1,181 +0,0 @@ -syntax = "proto3"; -package secret.compute.v1; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; - -import "gogoproto/gogo.proto"; -import "cosmos/msg/v1/msg.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "amino/amino.proto"; - -// Msg defines the wasm Msg service. -service Msg { - option (cosmos.msg.v1.service) = true; - // StoreCode to submit Wasm code to the system - rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse); - // Instantiate creates a new smart contract instance for the given code id. - rpc InstantiateContract(MsgInstantiateContract) - returns (MsgInstantiateContractResponse); - // Execute submits the given message data to a smart contract - rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse); - // Migrate runs a code upgrade/ downgrade for a smart contract - rpc MigrateContract(MsgMigrateContract) returns (MsgMigrateContractResponse); - // UpdateAdmin sets a new admin for a smart contract - rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse); - // ClearAdmin removes any admin stored for a smart contract - rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse); -} - -message MsgStoreCode { - option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "wasm/MsgStoreCode"; - - // sender is the canonical address of the sender - bytes sender = 1 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - // WASMByteCode can be raw or gzip compressed - bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode" ]; - // Source is a valid absolute HTTPS URI to the contract's source code, - // optional - string source = 3; - // Builder is a valid docker image name with tag, optional - string builder = 4; -} - -// MsgStoreCodeResponse returns store result data. -message MsgStoreCodeResponse { - // CodeID is the reference to the stored WASM code - uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; -} - -message MsgInstantiateContract { - option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "wasm/MsgInstantiateContract"; - - // sender is the canonical address of the sender - bytes sender = 1 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - string callback_code_hash = 2; - uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; - string label = 4; - // init_msg is an encrypted input to pass to the contract on init - bytes init_msg = 5; - repeated cosmos.base.v1beta1.Coin init_funds = 6 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - // used internally for encryption, should always be empty in a signed - // transaction - bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; - // Admin is an optional address that can execute migrations - string admin = 8; -} - -// MsgInstantiateContractResponse return instantiation result data -message MsgInstantiateContractResponse { - // Address is the bech32 address of the new contract instance. - string address = 1; - // Data contains base64-encoded bytes to returned from the contract - bytes data = 2; -} - -message MsgExecuteContract { - option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "wasm/MsgExecuteContract"; - - // sender is the canonical address of the sender - bytes sender = 1 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - // contract is the canonical address of the contract - bytes contract = 2 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - // msg is an encrypted input to pass to the contract on execute - bytes msg = 3; - // used internally for encryption, should always be empty in a signed - // transaction - string callback_code_hash = 4; - repeated cosmos.base.v1beta1.Coin sent_funds = 5 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - // used internally for encryption, should always be empty in a signed - // transaction - bytes callback_sig = 6 [ (gogoproto.customname) = "CallbackSig" ]; -} - -// MsgExecuteContractResponse returns execution result data. -message MsgExecuteContractResponse { - // Data contains base64-encoded bytes to returned from the contract - bytes data = 1; -} - -// MsgMigrateContract runs a code upgrade/ downgrade for a smart contract -message MsgMigrateContract { - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "wasm/MsgMigrateContract"; - - // Sender is the that actor that signed the messages - string sender = 1; - // Contract is the address of the smart contract - string contract = 2; - // CodeID references the new WASM code - uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; - // msg is an encrypted input to pass to the contract on migration - bytes msg = 4; - // used internally for encryption, should always be empty in a signed - // transaction - bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; - // used internally for encryption, should always be empty in a signed - // transaction - string callback_code_hash = 8; -} - -// MsgMigrateContractResponse returns contract migration result data. -message MsgMigrateContractResponse { - // Data contains same raw bytes returned as data from the wasm contract. - // (May be empty) - bytes data = 1; -} - -// MsgUpdateAdmin sets a new admin for a smart contract -message MsgUpdateAdmin { - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "wasm/MsgUpdateAdmin"; - - // Sender is the that actor that signed the messages - string sender = 1; - // NewAdmin address to be set - string new_admin = 2; - // Contract is the address of the smart contract - string contract = 3; - // used internally for encryption, should always be empty in a signed - // transaction - bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; -} - -// MsgUpdateAdminResponse returns empty data -message MsgUpdateAdminResponse {} - -// MsgClearAdmin removes any admin stored for a smart contract -message MsgClearAdmin { - option (cosmos.msg.v1.signer) = "sender"; - option (amino.name) = "wasm/MsgClearAdmin"; - - // Sender is the that actor that signed the messages - string sender = 1; - // Contract is the address of the smart contract - string contract = 3; - // used internally for encryption, should always be empty in a signed - // transaction - bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; -} - -// MsgClearAdminResponse returns empty data -message MsgClearAdminResponse {} diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/query.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1/query.proto deleted file mode 100644 index 5aa00e1d10..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/query.proto +++ /dev/null @@ -1,172 +0,0 @@ -syntax = "proto3"; -package secret.compute.v1; - -import "gogoproto/gogo.proto"; -import "secret/compute/v1beta1/types.proto"; -import "google/protobuf/empty.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/abci/v1beta1/abci.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -// Query defines the gRPC querier service -service Query { - // Query contract info by address - rpc ContractInfo(QueryByContractAddressRequest) - returns (QueryContractInfoResponse) { - option (google.api.http).get = "/compute/v1beta1/info/{contract_address}"; - } - // Query code info by id - rpc ContractsByCodeId(QueryByCodeIdRequest) - returns (QueryContractsByCodeIdResponse) { - option (google.api.http).get = "/compute/v1beta1/contracts/{code_id}"; - } - // Query secret contract - rpc QuerySecretContract(QuerySecretContractRequest) - returns (QuerySecretContractResponse) { - option (google.api.http).get = "/compute/v1beta1/query/{contract_address}"; - } - // Query a specific contract code by id - rpc Code(QueryByCodeIdRequest) returns (QueryCodeResponse) { - option (google.api.http).get = "/compute/v1beta1/code/{code_id}"; - } - // Query all contract codes on-chain - rpc Codes(google.protobuf.Empty) returns (QueryCodesResponse) { - option (google.api.http).get = "/compute/v1beta1/codes"; - } - // Query code hash by contract address - rpc CodeHashByContractAddress(QueryByContractAddressRequest) - returns (QueryCodeHashResponse) { - option (google.api.http).get = - "/compute/v1beta1/code_hash/by_contract_address/{contract_address}"; - } - // Query code hash by code id - rpc CodeHashByCodeId(QueryByCodeIdRequest) returns (QueryCodeHashResponse) { - option (google.api.http).get = - "/compute/v1beta1/code_hash/by_code_id/{code_id}"; - } - // Query contract label by address - rpc LabelByAddress(QueryByContractAddressRequest) - returns (QueryContractLabelResponse) { - option (google.api.http).get = "/compute/v1beta1/label/{contract_address}"; - } - // Query contract address by label - rpc AddressByLabel(QueryByLabelRequest) - returns (QueryContractAddressResponse) { - option (google.api.http).get = "/compute/v1beta1/contract_address/{label}"; - } - // ContractHistory gets the contract code history - rpc ContractHistory(QueryContractHistoryRequest) - returns (QueryContractHistoryResponse) { - option (google.api.http).get = - "/compute/v1beta1/contract_history/{contract_address}"; - } -} - -message QuerySecretContractRequest { - // address is the bech32 human readable address of the contract - string contract_address = 1; - bytes query = 2; -} - -message QueryByLabelRequest { string label = 1; } - -message QueryByContractAddressRequest { - // address is the bech32 human readable address of the contract - string contract_address = 1; -} - -message QueryByCodeIdRequest { uint64 code_id = 1; } - -message QuerySecretContractResponse { bytes data = 1; } - -// QueryContractInfoResponse is the response type for the Query/ContractInfo RPC -// method -message QueryContractInfoResponse { - // contract_address is the bech32 human readable address of the contract - string contract_address = 1; - ContractInfo contract_info = 2 - [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ]; -} - -// ContractInfoWithAddress adds the contract address to the ContractInfo -// representation -message ContractInfoWithAddress { - // contract_address is the bech32 human readable address of the contract - string contract_address = 1; - ContractInfo contract_info = 2 - [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ]; -} - -message QueryContractsByCodeIdResponse { - repeated ContractInfoWithAddress contract_infos = 1 - [ (gogoproto.nullable) = false ]; -} - -message CodeInfoResponse { - uint64 code_id = 1; - // creator is the bech32 human readable address of the contract - string creator = 2; - string code_hash = 3; - string source = 4; - string builder = 5; -} - -message QueryCodeResponse { - CodeInfoResponse code_info = 1 - [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ]; - bytes wasm = 2; -} - -message QueryCodesResponse { - repeated CodeInfoResponse code_infos = 1 [ (gogoproto.nullable) = false ]; -} - -message QueryContractAddressResponse { - // address is the bech32 human readable address of the contract - string contract_address = 1; -} - -message QueryContractLabelResponse { string label = 1; } - -message QueryCodeHashResponse { string code_hash = 1; } - -// DecryptedAnswer is a struct that represents a decrypted tx-query -message DecryptedAnswer { - option (gogoproto.equal) = false; - - string type = 1; - string input = 2; - string output_data = 3; - string output_data_as_string = 4; -} - -message DecryptedAnswers { - option (gogoproto.equal) = false; - - repeated DecryptedAnswer answers = 1; - repeated cosmos.base.abci.v1beta1.StringEvent output_logs = 2 - [ (gogoproto.nullable) = false ]; - string output_error = 3; - string plaintext_error = 4; -} - -// QueryContractHistoryRequest is the request type for the Query/ContractHistory -// RPC method -message QueryContractHistoryRequest { - option (gogoproto.equal) = false; - // address is the address of the contract to query - string contract_address = 1; -} - -// QueryContractHistoryResponse is the response type for the -// Query/ContractHistory RPC method -message QueryContractHistoryResponse { - option (gogoproto.equal) = false; - - repeated ContractCodeHistoryEntry entries = 1 - [ (gogoproto.nullable) = false ]; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/types.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1/types.proto deleted file mode 100644 index 75e670d51e..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1/types.proto +++ /dev/null @@ -1,110 +0,0 @@ -syntax = "proto3"; -package secret.compute.v1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -enum AccessType { - option (gogoproto.goproto_enum_prefix) = false; - option (gogoproto.goproto_enum_stringer) = false; - UNDEFINED = 0 [ (gogoproto.enumvalue_customname) = "AccessTypeUndefined" ]; - NOBODY = 1 [ (gogoproto.enumvalue_customname) = "AccessTypeNobody" ]; - ONLY_ADDRESS = 2 - [ (gogoproto.enumvalue_customname) = "AccessTypeOnlyAddress" ]; - EVERYBODY = 3 [ (gogoproto.enumvalue_customname) = "AccessTypeEverybody" ]; -} - -message AccessTypeParam { - option (gogoproto.goproto_stringer) = true; - AccessType value = 1 [ (gogoproto.moretags) = "yaml:\"value\"" ]; -} - -// CodeInfo is data for the uploaded contract WASM code -message CodeInfo { - bytes code_hash = 1; - bytes creator = 2 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - string source = 3; - string builder = 4; -} - -message ContractKey { - bytes og_contract_key = 1; - bytes current_contract_key = 2; - bytes current_contract_key_proof = 3; -} - -message ContractCustomInfo { - ContractKey enclave_key = 1 [ (gogoproto.customname) = "EnclaveKey" ]; - string label = 2; -} - -// ContractInfo stores a WASM contract instance -message ContractInfo { - // CodeID is the reference to the stored Wasm code - uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; - // Creator address who initially instantiated the contract - bytes creator = 2 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - // Label is mandatory metadata to be stored with a contract instance. - string label = 4; - // Created Tx position when the contract was instantiated. - AbsoluteTxPosition created = 5; - string ibc_port_id = 6 [ (gogoproto.customname) = "IBCPortID" ]; - // Admin is an optional address that can execute migrations - string admin = 7; - // Proof that enclave executed the instantiate command - bytes admin_proof = 8; -} - -// AbsoluteTxPosition can be used to sort contracts -message AbsoluteTxPosition { - // BlockHeight is the block the contract was created at - int64 block_height = 1; - // TxIndex is a monotonic counter within the block (actual transaction index, - // or gas consumed) - uint64 tx_index = 2; -} - -// Model is a struct that holds a KV pair -message Model { - // hex-encode key to read it better (this is often ascii) - bytes Key = 1 [ (gogoproto.casttype) = - "github.com/cometbft/cometbft/libs/bytes.HexBytes" ]; - // base64-encode raw value - bytes Value = 2; -} - -// ContractCodeHistoryOperationType actions that caused a code change -enum ContractCodeHistoryOperationType { - option (gogoproto.goproto_enum_prefix) = false; - // ContractCodeHistoryOperationTypeUnspecified placeholder for empty value - CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0 - [ (gogoproto.enumvalue_customname) = - "ContractCodeHistoryOperationTypeUnspecified" ]; - // ContractCodeHistoryOperationTypeInit on chain contract instantiation - CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1 - [ (gogoproto.enumvalue_customname) = - "ContractCodeHistoryOperationTypeInit" ]; - // ContractCodeHistoryOperationTypeMigrate code migration - CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2 - [ (gogoproto.enumvalue_customname) = - "ContractCodeHistoryOperationTypeMigrate" ]; - // ContractCodeHistoryOperationTypeGenesis based on genesis data - CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3 - [ (gogoproto.enumvalue_customname) = - "ContractCodeHistoryOperationTypeGenesis" ]; -} - -// ContractCodeHistoryEntry metadata to a contract. -message ContractCodeHistoryEntry { - ContractCodeHistoryOperationType operation = 1; - // CodeID is the reference to the stored WASM code - uint64 code_id = 2 [ (gogoproto.customname) = "CodeID" ]; - // Updated Tx position when the operation was executed. - AbsoluteTxPosition updated = 3; - bytes msg = 4; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/genesis.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/genesis.proto index ab3a415cd2..15e4a5bc2e 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/genesis.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/genesis.proto @@ -1,36 +1,45 @@ syntax = "proto3"; -package secret.compute.v1beta1; +package secret.compute.v1; import "gogoproto/gogo.proto"; import "secret/compute/v1beta1/types.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/compute/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; // GenesisState - genesis state of x/wasm message GenesisState { -// Params params = 1 [(gogoproto.nullable) = false]; - repeated Code codes = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "codes,omitempty"]; - repeated Contract contracts = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "contracts,omitempty"]; - repeated Sequence sequences = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "sequences,omitempty"]; + // Params params = 1 [(gogoproto.nullable) = false]; + repeated Code codes = 2 + [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "codes,omitempty" ]; + repeated Contract contracts = 3 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "contracts,omitempty" + ]; + repeated Sequence sequences = 4 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "sequences,omitempty" + ]; } // Code struct encompasses CodeInfo and CodeBytes message Code { - uint64 code_id = 1 [(gogoproto.customname) = "CodeID"]; - CodeInfo code_info = 2 [(gogoproto.nullable) = false]; - bytes code_bytes = 3; + uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; + CodeInfo code_info = 2 [ (gogoproto.nullable) = false ]; + bytes code_bytes = 3; } // Contract struct encompasses ContractAddress, ContractInfo, and ContractState message Contract { - bytes contract_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - ContractInfo contract_info = 2 [(gogoproto.nullable) = false]; - repeated Model contract_state = 3 [(gogoproto.nullable) = false]; - ContractCustomInfo contract_custom_info = 4; + bytes contract_address = 1 + [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + ContractInfo contract_info = 2 [ (gogoproto.nullable) = false ]; + repeated Model contract_state = 3 [ (gogoproto.nullable) = false ]; + ContractCustomInfo contract_custom_info = 4; } // Sequence id and value of a counter message Sequence { - bytes id_key = 1 [(gogoproto.customname) = "IDKey"]; - uint64 value = 2; -} \ No newline at end of file + bytes id_key = 1 [ (gogoproto.customname) = "IDKey" ]; + uint64 value = 2; +} diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/msg.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/msg.proto index 417f7c2b11..c4a29f4c2e 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/msg.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/msg.proto @@ -1,117 +1,181 @@ syntax = "proto3"; -package secret.compute.v1beta1; +package secret.compute.v1; -option go_package = "github.com/enigmampc/SecretNetwork/x/compute/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "amino/amino.proto"; -//import "x/compute/internal/types/types.proto"; - +// Msg defines the wasm Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // StoreCode to submit Wasm code to the system + rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse); + // Instantiate creates a new smart contract instance for the given code id. + rpc InstantiateContract(MsgInstantiateContract) + returns (MsgInstantiateContractResponse); + // Execute submits the given message data to a smart contract + rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse); + // Migrate runs a code upgrade/ downgrade for a smart contract + rpc MigrateContract(MsgMigrateContract) returns (MsgMigrateContractResponse); + // UpdateAdmin sets a new admin for a smart contract + rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse); + // ClearAdmin removes any admin stored for a smart contract + rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse); +} message MsgStoreCode { option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "wasm/MsgStoreCode"; - bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + // sender is the canonical address of the sender + bytes sender = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; // WASMByteCode can be raw or gzip compressed - bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"]; - // Source is a valid absolute HTTPS URI to the contract's source code, optional + bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode" ]; + // Source is a valid absolute HTTPS URI to the contract's source code, + // optional string source = 3; // Builder is a valid docker image name with tag, optional string builder = 4; - // InstantiatePermission to apply on contract creation, optional -// AccessConfig InstantiatePermission = 5; +} + +// MsgStoreCodeResponse returns store result data. +message MsgStoreCodeResponse { + // CodeID is the reference to the stored WASM code + uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; } message MsgInstantiateContract { option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "wasm/MsgInstantiateContract"; - bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - // Admin is an optional address that can execute migrations -// bytes admin = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + // sender is the canonical address of the sender + bytes sender = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; string callback_code_hash = 2; - uint64 code_id = 3 [(gogoproto.customname) = "CodeID"]; + uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; string label = 4; + // init_msg is an encrypted input to pass to the contract on init bytes init_msg = 5; - repeated cosmos.base.v1beta1.Coin init_funds = 6 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - bytes callback_sig = 7 [(gogoproto.customname) = "CallbackSig"]; + repeated cosmos.base.v1beta1.Coin init_funds = 6 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // used internally for encryption, should always be empty in a signed + // transaction + bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; + // Admin is an optional address that can execute migrations + string admin = 8; +} + +// MsgInstantiateContractResponse return instantiation result data +message MsgInstantiateContractResponse { + // Address is the bech32 address of the new contract instance. + string address = 1; + // Data contains base64-encoded bytes to returned from the contract + bytes data = 2; } message MsgExecuteContract { option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "wasm/MsgExecuteContract"; - bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes contract = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + // sender is the canonical address of the sender + bytes sender = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + // contract is the canonical address of the contract + bytes contract = 2 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + // msg is an encrypted input to pass to the contract on execute bytes msg = 3; + // used internally for encryption, should always be empty in a signed + // transaction string callback_code_hash = 4; - repeated cosmos.base.v1beta1.Coin sent_funds = 5 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - bytes callback_sig = 6 [(gogoproto.customname) = "CallbackSig"]; + repeated cosmos.base.v1beta1.Coin sent_funds = 5 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // used internally for encryption, should always be empty in a signed + // transaction + bytes callback_sig = 6 [ (gogoproto.customname) = "CallbackSig" ]; +} + +// MsgExecuteContractResponse returns execution result data. +message MsgExecuteContractResponse { + // Data contains base64-encoded bytes to returned from the contract + bytes data = 1; +} + +// MsgMigrateContract runs a code upgrade/ downgrade for a smart contract +message MsgMigrateContract { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "wasm/MsgMigrateContract"; + + // Sender is the that actor that signed the messages + string sender = 1; + // Contract is the address of the smart contract + string contract = 2; + // CodeID references the new WASM code + uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ]; + // msg is an encrypted input to pass to the contract on migration + bytes msg = 4; + // used internally for encryption, should always be empty in a signed + // transaction + bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; + // used internally for encryption, should always be empty in a signed + // transaction + string callback_code_hash = 8; +} + +// MsgMigrateContractResponse returns contract migration result data. +message MsgMigrateContractResponse { + // Data contains same raw bytes returned as data from the wasm contract. + // (May be empty) + bytes data = 1; +} + +// MsgUpdateAdmin sets a new admin for a smart contract +message MsgUpdateAdmin { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "wasm/MsgUpdateAdmin"; + + // Sender is the that actor that signed the messages + string sender = 1; + // NewAdmin address to be set + string new_admin = 2; + // Contract is the address of the smart contract + string contract = 3; + // used internally for encryption, should always be empty in a signed + // transaction + bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; +} + +// MsgUpdateAdminResponse returns empty data +message MsgUpdateAdminResponse {} + +// MsgClearAdmin removes any admin stored for a smart contract +message MsgClearAdmin { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "wasm/MsgClearAdmin"; + + // Sender is the that actor that signed the messages + string sender = 1; + // Contract is the address of the smart contract + string contract = 3; + // used internally for encryption, should always be empty in a signed + // transaction + bytes callback_sig = 7 [ (gogoproto.customname) = "CallbackSig" ]; } -// Todo: keeping this here for future replacing of bytes -> string -//syntax = "proto3"; -//package secret.compute.v1beta1; -// -//option go_package = "github.com/enigmampc/SecretNetwork/x/compute/internal/types"; -// -//import "gogoproto/gogo.proto"; -//import "cosmos/base/v1beta1/coin.proto"; -// -////import "x/compute/internal/types/types.proto"; -// -// -//message MsgStoreCode { -// option (gogoproto.goproto_getters) = false; -// -// // -// string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; -// // WASMByteCode can be raw or gzip compressed -// bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"]; -// // Source is a valid absolute HTTPS URI to the contract's source code, optional -// string source = 3 [(gogoproto.moretags) = "yaml:\"source\""]; -// // Builder is a valid docker image name with tag, optional -// string builder = 4 [(gogoproto.moretags) = "yaml:\"builder\""]; -//} -// -//message MsgInstantiateContract { -// option (gogoproto.goproto_getters) = false; -// -// // -// string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; -// // -// string callback_code_hash = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"callback_code_hash\"" ]; -// // -// uint64 code_id = 3 [(gogoproto.customname) = "CodeID", (gogoproto.moretags) = "yaml:\"code_id\""]; -// // -// string label = 4 [(gogoproto.moretags) = "yaml:\"label\""]; -// // -// bytes init_msg = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"init_msg\"" ]; -// // -// repeated cosmos.base.v1beta1.Coin init_funds = 6 [ -// (gogoproto.nullable) = false, -// (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", -// (gogoproto.moretags) = "yaml:\"init_funds\"" -// ]; -// // -// bytes callback_sig = 7 [(gogoproto.customname) = "CallbackSig", (gogoproto.moretags) = "yaml:\"callback_sig\""]; -//} -// -//message MsgExecuteContract { -// option (gogoproto.goproto_getters) = false; -// // -// string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; -// // -// string contract = 2 [(gogoproto.moretags) = "yaml:\"contract\""]; -// // -// bytes msg = 3 [(gogoproto.moretags) = "yaml:\"msg\""]; -// // -// string callback_code_hash = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"callback_code_hash\"" ]; -// // -// repeated cosmos.base.v1beta1.Coin sent_funds = 5 [ -// (gogoproto.nullable) = false, -// (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", -// (gogoproto.moretags) = "yaml:\"sent_funds\"" -// ]; -// // -// bytes callback_sig = 6 [(gogoproto.customname) = "CallbackSig", (gogoproto.moretags) = "yaml:\"callback_sig\""]; -//} \ No newline at end of file +// MsgClearAdminResponse returns empty data +message MsgClearAdminResponse {} diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/query.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/query.proto index e5c874dc29..5aa00e1d10 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/query.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/query.proto @@ -1,167 +1,172 @@ syntax = "proto3"; -package secret.compute.v1beta1; +package secret.compute.v1; import "gogoproto/gogo.proto"; import "secret/compute/v1beta1/types.proto"; import "google/protobuf/empty.proto"; import "google/api/annotations.proto"; import "cosmos/base/abci/v1beta1/abci.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/compute/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; - -// Query provides defines the gRPC querier service +// Query defines the gRPC querier service service Query { - // Query contract - rpc ContractInfo (QueryContractInfoRequest) returns (QueryContractInfoResponse) { - option (google.api.http).get = "/compute/v1beta1/contract/{address}"; - } - // Query contract - rpc ContractsByCode (QueryContractsByCodeRequest) returns (QueryContractsByCodeResponse) { - option (google.api.http).get = "/compute/v1beta1/code/{code_id}/contracts"; - } - // Query contract - rpc SmartContractState (QuerySmartContractStateRequest) returns (QuerySmartContractStateResponse) { - option (google.api.http).get = "/compute/v1beta1/contract/{address}/smart"; - } - // Query a specific contract code - rpc Code (QueryCodeRequest) returns (QueryCodeResponse) { - option (google.api.http).get = "/compute/v1beta1/code/{code_id}"; - } - // Query all contract codes on-chain - rpc Codes (google.protobuf.Empty) returns (QueryCodesResponse) { - option (google.api.http).get = "/compute/v1beta1/code"; - } -} - -// QueryContractInfoRequest is the request type for the Query/ContractInfo RPC method -message QueryContractInfoRequest { - // address is the address of the contract to query - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; -} -// QueryContractInfoResponse is the response type for the Query/ContractInfo RPC method + // Query contract info by address + rpc ContractInfo(QueryByContractAddressRequest) + returns (QueryContractInfoResponse) { + option (google.api.http).get = "/compute/v1beta1/info/{contract_address}"; + } + // Query code info by id + rpc ContractsByCodeId(QueryByCodeIdRequest) + returns (QueryContractsByCodeIdResponse) { + option (google.api.http).get = "/compute/v1beta1/contracts/{code_id}"; + } + // Query secret contract + rpc QuerySecretContract(QuerySecretContractRequest) + returns (QuerySecretContractResponse) { + option (google.api.http).get = "/compute/v1beta1/query/{contract_address}"; + } + // Query a specific contract code by id + rpc Code(QueryByCodeIdRequest) returns (QueryCodeResponse) { + option (google.api.http).get = "/compute/v1beta1/code/{code_id}"; + } + // Query all contract codes on-chain + rpc Codes(google.protobuf.Empty) returns (QueryCodesResponse) { + option (google.api.http).get = "/compute/v1beta1/codes"; + } + // Query code hash by contract address + rpc CodeHashByContractAddress(QueryByContractAddressRequest) + returns (QueryCodeHashResponse) { + option (google.api.http).get = + "/compute/v1beta1/code_hash/by_contract_address/{contract_address}"; + } + // Query code hash by code id + rpc CodeHashByCodeId(QueryByCodeIdRequest) returns (QueryCodeHashResponse) { + option (google.api.http).get = + "/compute/v1beta1/code_hash/by_code_id/{code_id}"; + } + // Query contract label by address + rpc LabelByAddress(QueryByContractAddressRequest) + returns (QueryContractLabelResponse) { + option (google.api.http).get = "/compute/v1beta1/label/{contract_address}"; + } + // Query contract address by label + rpc AddressByLabel(QueryByLabelRequest) + returns (QueryContractAddressResponse) { + option (google.api.http).get = "/compute/v1beta1/contract_address/{label}"; + } + // ContractHistory gets the contract code history + rpc ContractHistory(QueryContractHistoryRequest) + returns (QueryContractHistoryResponse) { + option (google.api.http).get = + "/compute/v1beta1/contract_history/{contract_address}"; + } +} + +message QuerySecretContractRequest { + // address is the bech32 human readable address of the contract + string contract_address = 1; + bytes query = 2; +} + +message QueryByLabelRequest { string label = 1; } + +message QueryByContractAddressRequest { + // address is the bech32 human readable address of the contract + string contract_address = 1; +} + +message QueryByCodeIdRequest { uint64 code_id = 1; } + +message QuerySecretContractResponse { bytes data = 1; } + +// QueryContractInfoResponse is the response type for the Query/ContractInfo RPC +// method message QueryContractInfoResponse { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - ContractInfo ContractInfo = 2 [(gogoproto.embed) = true, (gogoproto.jsontag) = ""]; -} - -message QueryContractHistoryRequest { - // address is the address of the contract to query - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; -} - -/* -message QueryContractHistoryResponse { - repeated ContractCodeHistoryEntry entries = 1 [(gogoproto.nullable) = false]; + // contract_address is the bech32 human readable address of the contract + string contract_address = 1; + ContractInfo contract_info = 2 + [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ]; } -*/ -message QueryContractsByCodeRequest { - uint64 code_id = 1; // grpc-gateway_out does not support Go style CodID -} - -// ContractInfoWithAddress adds the address (key) to the ContractInfo representation +// ContractInfoWithAddress adds the contract address to the ContractInfo +// representation message ContractInfoWithAddress { - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - ContractInfo ContractInfo = 2 [(gogoproto.embed) = true, (gogoproto.jsontag) = ""]; + // contract_address is the bech32 human readable address of the contract + string contract_address = 1; + ContractInfo contract_info = 2 + [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ]; } -message QueryContractsByCodeResponse { - repeated ContractInfoWithAddress contract_infos = 1 [(gogoproto.nullable) = false]; +message QueryContractsByCodeIdResponse { + repeated ContractInfoWithAddress contract_infos = 1 + [ (gogoproto.nullable) = false ]; } -/* -message QueryAllContractStateRequest { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; -} - -message QueryAllContractStateResponse { - repeated Model models = 1 [(gogoproto.nullable) = false]; -} - -message QueryRawContractStateRequest { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes query_data = 2; -} - -message QueryRawContractStateResponse { - bytes data = 1; -} -*/ - -message QuerySmartContractStateRequest { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes query_data = 2; +message CodeInfoResponse { + uint64 code_id = 1; + // creator is the bech32 human readable address of the contract + string creator = 2; + string code_hash = 3; + string source = 4; + string builder = 5; } -message QueryContractAddressByLabelRequest { - string label = 1; +message QueryCodeResponse { + CodeInfoResponse code_info = 1 + [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ]; + bytes wasm = 2; } -message QueryContractKeyRequest { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +message QueryCodesResponse { + repeated CodeInfoResponse code_infos = 1 [ (gogoproto.nullable) = false ]; } -message QueryContractHashRequest { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +message QueryContractAddressResponse { + // address is the bech32 human readable address of the contract + string contract_address = 1; } -message QuerySmartContractStateResponse { - bytes data = 1; -} +message QueryContractLabelResponse { string label = 1; } -message QueryCodeRequest { - uint64 code_id = 1; // grpc-gateway_out does not support Go style CodID -} +message QueryCodeHashResponse { string code_hash = 1; } -message CodeInfoResponse { - uint64 code_id = 1 [(gogoproto.customname) = "CodeID", (gogoproto.jsontag) = "id"]; // id for legacy support - bytes creator = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes data_hash = 3 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; - string source = 4; - string builder = 5; -} +// DecryptedAnswer is a struct that represents a decrypted tx-query +message DecryptedAnswer { + option (gogoproto.equal) = false; -message QueryCodeResponse { - CodeInfoResponse code_info = 1 [(gogoproto.embed) = true, (gogoproto.jsontag) = ""]; - bytes data = 2 [(gogoproto.jsontag) = "data"]; + string type = 1; + string input = 2; + string output_data = 3; + string output_data_as_string = 4; } -message QueryCodesResponse { - repeated CodeInfoResponse code_infos = 1 [(gogoproto.nullable) = false]; -} +message DecryptedAnswers { + option (gogoproto.equal) = false; -message QueryContractAddressByLabelResponse { - // address is the address of the contract - bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + repeated DecryptedAnswer answers = 1; + repeated cosmos.base.abci.v1beta1.StringEvent output_logs = 2 + [ (gogoproto.nullable) = false ]; + string output_error = 3; + string plaintext_error = 4; } -message QueryContractKeyResponse { - // address is the address of the contract - bytes key = 1 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; +// QueryContractHistoryRequest is the request type for the Query/ContractHistory +// RPC method +message QueryContractHistoryRequest { + option (gogoproto.equal) = false; + // address is the address of the contract to query + string contract_address = 1; } -message QueryContractHashResponse { - bytes code_hash = 1 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; -} +// QueryContractHistoryResponse is the response type for the +// Query/ContractHistory RPC method +message QueryContractHistoryResponse { + option (gogoproto.equal) = false; -// DecryptedAnswer is a struct that represents a decrypted tx-query -message DecryptedAnswer { - option (gogoproto.equal) = false; - - string type = 1; - string input = 2; - string output_data = 3; - string output_data_as_string = 4; - repeated cosmos.base.abci.v1beta1.StringEvent output_logs = 5 [(gogoproto.nullable) = false]; - bytes output_error = 6 [(gogoproto.casttype) = "encoding/json.RawMessage"]; - string plaintext_error = 7; + repeated ContractCodeHistoryEntry entries = 1 + [ (gogoproto.nullable) = false ]; } diff --git a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/types.proto b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/types.proto index 216dff18a3..75e670d51e 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/types.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/compute/v1beta1/types.proto @@ -1,111 +1,110 @@ syntax = "proto3"; -package secret.compute.v1beta1; +package secret.compute.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/compute/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; enum AccessType { - option (gogoproto.goproto_enum_prefix) = false; - option (gogoproto.goproto_enum_stringer) = false; - UNDEFINED = 0 [(gogoproto.enumvalue_customname) = "AccessTypeUndefined"]; - NOBODY = 1 [(gogoproto.enumvalue_customname) = "AccessTypeNobody"]; - ONLY_ADDRESS = 2 [(gogoproto.enumvalue_customname) = "AccessTypeOnlyAddress"]; - EVERYBODY = 3 [(gogoproto.enumvalue_customname) = "AccessTypeEverybody"]; + option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.goproto_enum_stringer) = false; + UNDEFINED = 0 [ (gogoproto.enumvalue_customname) = "AccessTypeUndefined" ]; + NOBODY = 1 [ (gogoproto.enumvalue_customname) = "AccessTypeNobody" ]; + ONLY_ADDRESS = 2 + [ (gogoproto.enumvalue_customname) = "AccessTypeOnlyAddress" ]; + EVERYBODY = 3 [ (gogoproto.enumvalue_customname) = "AccessTypeEverybody" ]; } message AccessTypeParam { - option (gogoproto.goproto_stringer) = true; - AccessType value = 1 [(gogoproto.moretags) = "yaml:\"value\""]; + option (gogoproto.goproto_stringer) = true; + AccessType value = 1 [ (gogoproto.moretags) = "yaml:\"value\"" ]; } -/* -message AccessConfig { - option (gogoproto.goproto_stringer) = true; - AccessType permission = 1 [(gogoproto.moretags) = "yaml:\"permission\""]; - bytes address = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"address\""]; -} - */ - -/* -// Params defines the set of wasm parameters. -message Params { - option (gogoproto.goproto_stringer) = false; - AccessConfig code_upload_access = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"code_upload_access\""]; - AccessType instantiate_default_permission = 2 [(gogoproto.moretags) = "yaml:\"instantiate_default_permission\""]; -} -*/ - // CodeInfo is data for the uploaded contract WASM code message CodeInfo { - bytes code_hash = 1; - bytes creator = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - string source = 3; - string builder = 4; -// AccessConfig instantiate_config = 5 [(gogoproto.nullable) = false]; + bytes code_hash = 1; + bytes creator = 2 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + string source = 3; + string builder = 4; +} + +message ContractKey { + bytes og_contract_key = 1; + bytes current_contract_key = 2; + bytes current_contract_key_proof = 3; } message ContractCustomInfo { - bytes enclave_key = 1 [(gogoproto.customname) = "EnclaveKey"]; - string label = 2; + ContractKey enclave_key = 1 [ (gogoproto.customname) = "EnclaveKey" ]; + string label = 2; } // ContractInfo stores a WASM contract instance message ContractInfo { - uint64 code_id = 1 [(gogoproto.customname) = "CodeID"]; - bytes creator = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; -// bytes admin = 3 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - string label = 4; - // never show this in query results, just use for sorting - // (Note: when using json tag "-" amino refused to serialize it...) - AbsoluteTxPosition created = 5; - // bytes init_msg = 5 [(gogoproto.casttype) = "encoding/json.RawMessage"]; - // - // AbsoluteTxPosition last_updated = 7; - // uint64 previous_code_id = 8 [(gogoproto.customname) = "PreviousCodeID"]; + // CodeID is the reference to the stored Wasm code + uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ]; + // Creator address who initially instantiated the contract + bytes creator = 2 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + // Label is mandatory metadata to be stored with a contract instance. + string label = 4; + // Created Tx position when the contract was instantiated. + AbsoluteTxPosition created = 5; + string ibc_port_id = 6 [ (gogoproto.customname) = "IBCPortID" ]; + // Admin is an optional address that can execute migrations + string admin = 7; + // Proof that enclave executed the instantiate command + bytes admin_proof = 8; } -/* -enum ContractCodeHistoryOperationType { - option (gogoproto.goproto_enum_prefix) = false; - Undefined = 0; - Init = 1 [(gogoproto.enumvalue_customname) = "ContractCodeHistoryTypeInit"]; - Migrate = 2 [(gogoproto.enumvalue_customname) = "ContractCodeHistoryTypeMigrate"]; - Genesis = 3 [(gogoproto.enumvalue_customname) = "ContractCodeHistoryTypeGenesis"]; +// AbsoluteTxPosition can be used to sort contracts +message AbsoluteTxPosition { + // BlockHeight is the block the contract was created at + int64 block_height = 1; + // TxIndex is a monotonic counter within the block (actual transaction index, + // or gas consumed) + uint64 tx_index = 2; } -*/ -/* -message ContractHistory { - repeated ContractCodeHistoryEntry code_history_entries = 1 [(gogoproto.nullable) = false]; +// Model is a struct that holds a KV pair +message Model { + // hex-encode key to read it better (this is often ascii) + bytes Key = 1 [ (gogoproto.casttype) = + "github.com/cometbft/cometbft/libs/bytes.HexBytes" ]; + // base64-encode raw value + bytes Value = 2; } -*/ - -/* -// ContractCodeHistoryEntry stores code updates to a contract. -message ContractCodeHistoryEntry { - ContractCodeHistoryOperationType operation = 1; - uint64 code_id = 2 [(gogoproto.customname) = "CodeID"]; - AbsoluteTxPosition updated = 3; - bytes msg = 4 [(gogoproto.casttype) = "encoding/json.RawMessage"]; +// ContractCodeHistoryOperationType actions that caused a code change +enum ContractCodeHistoryOperationType { + option (gogoproto.goproto_enum_prefix) = false; + // ContractCodeHistoryOperationTypeUnspecified placeholder for empty value + CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = + "ContractCodeHistoryOperationTypeUnspecified" ]; + // ContractCodeHistoryOperationTypeInit on chain contract instantiation + CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1 + [ (gogoproto.enumvalue_customname) = + "ContractCodeHistoryOperationTypeInit" ]; + // ContractCodeHistoryOperationTypeMigrate code migration + CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2 + [ (gogoproto.enumvalue_customname) = + "ContractCodeHistoryOperationTypeMigrate" ]; + // ContractCodeHistoryOperationTypeGenesis based on genesis data + CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3 + [ (gogoproto.enumvalue_customname) = + "ContractCodeHistoryOperationTypeGenesis" ]; } -*/ -// AbsoluteTxPosition can be used to sort contracts -message AbsoluteTxPosition { - // BlockHeight is the block the contract was created at - int64 block_height = 1; - // TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) - uint64 tx_index = 2; +// ContractCodeHistoryEntry metadata to a contract. +message ContractCodeHistoryEntry { + ContractCodeHistoryOperationType operation = 1; + // CodeID is the reference to the stored WASM code + uint64 code_id = 2 [ (gogoproto.customname) = "CodeID" ]; + // Updated Tx position when the operation was executed. + AbsoluteTxPosition updated = 3; + bytes msg = 4; } - -// Model is a struct that holds a KV pair -message Model { - // hex-encode key to read it better (this is often ascii) - bytes Key = 1 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; - // base64-encode raw value - bytes Value = 2; -} \ No newline at end of file diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/genesis.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1/genesis.proto deleted file mode 100644 index e727fa89f3..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/genesis.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package secret.registration.v1; - -import "gogoproto/gogo.proto"; -import "secret/registration/v1beta1/types.proto"; -import "secret/registration/v1beta1/msg.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -message GenesisState { - repeated RegistrationNodeInfo registration = 1 - [ (gogoproto.jsontag) = "reg_info" ]; - MasterKey node_exch_master_key = 2 [ (gogoproto.jsontag) = "node_exch_key" ]; - MasterKey io_master_key = 3 [ (gogoproto.jsontag) = "io_exch_key" ]; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/msg.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1/msg.proto deleted file mode 100644 index 44829ce1ce..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/msg.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; -package secret.registration.v1; - -import "gogoproto/gogo.proto"; -import "cosmos/msg/v1/msg.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -// Msg defines the wasm Msg service. -service Msg { - option (cosmos.msg.v1.service) = true; - // Register and authenticate new node - rpc RegisterAuth(RaAuthenticate) returns (RaAuthenticateResponse); -} - -message RaAuthenticate { - option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "sender"; - bytes sender = 1 [ (gogoproto.casttype) = - "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; - bytes certificate = 2 [ - (gogoproto.casttype) = "github.com/scrtlabs/SecretNetwork/x/registration/" - "remote_attestation.Certificate", - (gogoproto.jsontag) = "ra_cert" - ]; -} - -message RaAuthenticateResponse { - string data = 1; - string events = 2; -} - -message MasterKey { bytes bytes = 1; } - -message Key { bytes key = 1 [ (gogoproto.jsontag) = "key" ]; } diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/query.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1/query.proto deleted file mode 100644 index e93c483fd3..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/query.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; -package secret.registration.v1; - -import "gogoproto/gogo.proto"; -import "google/protobuf/empty.proto"; -import "google/api/annotations.proto"; -import "secret/registration/v1beta1/msg.proto"; -import "secret/registration/v1beta1/genesis.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -// Query provides defines the gRPC querier service -service Query { - // Returns the key used for transactions - rpc TxKey(google.protobuf.Empty) returns (Key) { - option (google.api.http).get = "/registration/v1beta1/tx-key"; - } - // Returns the key used for registration - rpc RegistrationKey(google.protobuf.Empty) returns (Key) { - option (google.api.http).get = "/registration/v1beta1/registration-key"; - } - - // Returns the encrypted seed for a registered node by public key - rpc EncryptedSeed(QueryEncryptedSeedRequest) - returns (QueryEncryptedSeedResponse) { - option (google.api.http).get = - "/registration/v1beta1/encrypted-seed/{pub_key}"; - } -} - -message QueryEncryptedSeedRequest { bytes pub_key = 1; } - -message QueryEncryptedSeedResponse { - bytes encrypted_seed = 1; // [(gogoproto.nullable) = false]; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/remote_attestation/types.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1/remote_attestation/types.proto deleted file mode 100644 index 4f241e16bc..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/remote_attestation/types.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; -package secret.registration.remote_attestation.v1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/remote_attestation"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -message QuoteReport { - string id = 1 [ (gogoproto.customname) = "ID" ]; - string timestamp = 2; - uint64 version = 3; - string isv_enclave_quote_status = 4 - [ (gogoproto.jsontag) = "isvEnclaveQuoteStatus" ]; - string platform_info_blob = 5 [ (gogoproto.jsontag) = "platformInfoBlob" ]; - string isv_enclave_quote_body = 6 - [ (gogoproto.jsontag) = "isvEnclaveQuoteBody" ]; - repeated string advisory_ids = 7 [ - (gogoproto.customname) = "AdvisoryIDs", - (gogoproto.jsontag) = "advisoryIDs" - ]; -} - -message QuoteReportBody { - string mr_enclave = 1; - string mr_signer = 2; - string report_data = 3; -} - -message QuoteReportData { - uint64 version = 1; - uint64 sign_type = 2; - QuoteReportBody report_body = 3; -} - -message EndorsedAttestationReport { - bytes report = 1; - bytes signature = 2; - bytes signing_cert = 3; -} - -message SGXEC256Signature { - string gx = 1; - string gy = 2; -} - -message PlatformInfoBlob { - uint32 sgx_epid_group_flags = 1; - uint32 sgx_tcb_evaluation_flags = 2; - uint32 pse_evaluation_flags = 3; - string latest_equivalent_tcb_psvn = 4; - string latest_pse_isvsvn = 5; - string latest_psda_svn = 6; - uint32 xeid = 7; - uint32 gid = 8; - SGXEC256Signature sgx_ec256_signature_t = 9; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/types.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1/types.proto deleted file mode 100644 index b8354be874..0000000000 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1/types.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; -package secret.registration.v1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; - -message SeedConfig { - string master_key = 1 [ (gogoproto.jsontag) = "pk2" ]; - string encrypted_key = 2 [ (gogoproto.jsontag) = "encKey" ]; - uint32 version = 3 [ (gogoproto.jsontag) = "version" ]; -} - -message LegacySeedConfig { - string master_cert = 1 [ (gogoproto.jsontag) = "pk" ]; - string encrypted_key = 2 [ (gogoproto.jsontag) = "encKey" ]; -} - -message RegistrationNodeInfo { - bytes certificate = 1 - [ (gogoproto.casttype) = "github.com/scrtlabs/SecretNetwork/x/" - "registration/remote_attestation.Certificate" ]; - bytes encrypted_seed = 2; -} diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/genesis.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/genesis.proto index 14edb9374b..e727fa89f3 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/genesis.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/genesis.proto @@ -1,16 +1,17 @@ syntax = "proto3"; -package secret.registration.v1beta1; +package secret.registration.v1; import "gogoproto/gogo.proto"; import "secret/registration/v1beta1/types.proto"; import "secret/registration/v1beta1/msg.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/registration/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; message GenesisState { - repeated RegistrationNodeInfo registration = 1 [(gogoproto.jsontag) = "reg_info"]; - MasterCertificate node_exch_master_certificate = 2 [(gogoproto.jsontag) = "node_exch_cert"]; - MasterCertificate io_master_certificate = 3 [(gogoproto.jsontag) = "io_exch_cert"]; -} \ No newline at end of file + repeated RegistrationNodeInfo registration = 1 + [ (gogoproto.jsontag) = "reg_info" ]; + MasterKey node_exch_master_key = 2 [ (gogoproto.jsontag) = "node_exch_key" ]; + MasterKey io_master_key = 3 [ (gogoproto.jsontag) = "io_exch_key" ]; +} diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/msg.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/msg.proto index 369b31d554..44829ce1ce 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/msg.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/msg.proto @@ -1,21 +1,37 @@ syntax = "proto3"; -package secret.registration.v1beta1; +package secret.registration.v1; import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/registration/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; +// Msg defines the wasm Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + // Register and authenticate new node + rpc RegisterAuth(RaAuthenticate) returns (RaAuthenticateResponse); +} + message RaAuthenticate { - bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; - bytes certificate = 2 [(gogoproto.casttype) = "github.com/enigmampc/SecretNetwork/x/registration/remote_attestation.Certificate", (gogoproto.jsontag) = "ra_cert"]; + option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "sender"; + bytes sender = 1 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; + bytes certificate = 2 [ + (gogoproto.casttype) = "github.com/scrtlabs/SecretNetwork/x/registration/" + "remote_attestation.Certificate", + (gogoproto.jsontag) = "ra_cert" + ]; } -message MasterCertificate { - bytes bytes = 1; +message RaAuthenticateResponse { + string data = 1; + string events = 2; } -message Key { - bytes key = 1 [(gogoproto.jsontag) = "key"]; -} \ No newline at end of file +message MasterKey { bytes bytes = 1; } + +message Key { bytes key = 1 [ (gogoproto.jsontag) = "key" ]; } diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/query.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/query.proto index 0226e0220e..e93c483fd3 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/query.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/query.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package secret.registration.v1beta1; +package secret.registration.v1; import "gogoproto/gogo.proto"; import "google/protobuf/empty.proto"; @@ -7,33 +7,31 @@ import "google/api/annotations.proto"; import "secret/registration/v1beta1/msg.proto"; import "secret/registration/v1beta1/genesis.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/registration/internal/types"; -option (gogoproto.goproto_getters_all) = false; -option (gogoproto.equal_all) = true; +option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = true; // Query provides defines the gRPC querier service service Query { // Returns the key used for transactions - rpc TxKey (google.protobuf.Empty) returns (Key) { + rpc TxKey(google.protobuf.Empty) returns (Key) { option (google.api.http).get = "/registration/v1beta1/tx-key"; } // Returns the key used for registration - rpc RegistrationKey (google.protobuf.Empty) returns (Key) { + rpc RegistrationKey(google.protobuf.Empty) returns (Key) { option (google.api.http).get = "/registration/v1beta1/registration-key"; } // Returns the encrypted seed for a registered node by public key - rpc EncryptedSeed (QueryEncryptedSeedRequest) returns (QueryEncryptedSeedResponse) { - option (google.api.http).get = "/registration/v1beta1/encrypted-seed/{pub_key}"; + rpc EncryptedSeed(QueryEncryptedSeedRequest) + returns (QueryEncryptedSeedResponse) { + option (google.api.http).get = + "/registration/v1beta1/encrypted-seed/{pub_key}"; } } -message QueryEncryptedSeedRequest { - bytes pub_key = 1; -} +message QueryEncryptedSeedRequest { bytes pub_key = 1; } message QueryEncryptedSeedResponse { bytes encrypted_seed = 1; // [(gogoproto.nullable) = false]; } - - diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/remote_attestation/types.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/remote_attestation/types.proto index 3498d09b91..4f241e16bc 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/remote_attestation/types.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/remote_attestation/types.proto @@ -1,20 +1,25 @@ syntax = "proto3"; -package secret.registration.remote_attestation.v1beta1; +package secret.registration.remote_attestation.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/registration/remote_attestation"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/remote_attestation"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; message QuoteReport { - string id = 1 [(gogoproto.customname) = "ID"]; + string id = 1 [ (gogoproto.customname) = "ID" ]; string timestamp = 2; uint64 version = 3; - string isv_enclave_quote_status = 4 [(gogoproto.jsontag) = "isvEnclaveQuoteStatus"]; - string platform_info_blob = 5 [(gogoproto.jsontag) = "platformInfoBlob"]; - string isv_enclave_quote_body = 6 [(gogoproto.jsontag) = "isvEnclaveQuoteBody"]; - repeated string advisory_ids = 7 [(gogoproto.customname) = "AdvisoryIDs", (gogoproto.jsontag) = "advisoryIDs"]; + string isv_enclave_quote_status = 4 + [ (gogoproto.jsontag) = "isvEnclaveQuoteStatus" ]; + string platform_info_blob = 5 [ (gogoproto.jsontag) = "platformInfoBlob" ]; + string isv_enclave_quote_body = 6 + [ (gogoproto.jsontag) = "isvEnclaveQuoteBody" ]; + repeated string advisory_ids = 7 [ + (gogoproto.customname) = "AdvisoryIDs", + (gogoproto.jsontag) = "advisoryIDs" + ]; } message QuoteReportBody { diff --git a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/types.proto b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/types.proto index 09260e0d1e..b8354be874 100644 --- a/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/types.proto +++ b/packages/proto-types/proto-types-gen/proto/secret/registration/v1beta1/types.proto @@ -1,18 +1,26 @@ syntax = "proto3"; -package secret.registration.v1beta1; +package secret.registration.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/enigmampc/SecretNetwork/x/registration/internal/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/registration/internal/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = true; message SeedConfig { - string master_cert = 1 [(gogoproto.jsontag) = "pk"]; - string encrypted_key = 2 [(gogoproto.jsontag) = "encKey"]; + string master_key = 1 [ (gogoproto.jsontag) = "pk2" ]; + string encrypted_key = 2 [ (gogoproto.jsontag) = "encKey" ]; + uint32 version = 3 [ (gogoproto.jsontag) = "version" ]; +} + +message LegacySeedConfig { + string master_cert = 1 [ (gogoproto.jsontag) = "pk" ]; + string encrypted_key = 2 [ (gogoproto.jsontag) = "encKey" ]; } message RegistrationNodeInfo { - bytes certificate = 1 [(gogoproto.casttype) = "github.com/enigmampc/SecretNetwork/x/registration/remote_attestation.Certificate"]; + bytes certificate = 1 + [ (gogoproto.casttype) = "github.com/scrtlabs/SecretNetwork/x/" + "registration/remote_attestation.Certificate" ]; bytes encrypted_seed = 2; } diff --git a/packages/proto-types/proto-types-gen/scripts/proto-gen.mjs b/packages/proto-types/proto-types-gen/scripts/proto-gen.mjs index 2a58363222..f1cd6e546a 100644 --- a/packages/proto-types/proto-types-gen/scripts/proto-gen.mjs +++ b/packages/proto-types/proto-types-gen/scripts/proto-gen.mjs @@ -116,7 +116,6 @@ function setOutputHash(root, hash) { "ibc/applications/fee/v1/fee.proto", "ibc/applications/fee/v1/tx.proto", "secret/compute/v1beta1/msg.proto", - "secret/compute/v1/msg.proto", "ethermint/types/v1/web3.proto", "stride/stakeibc/validator.proto", "stride/stakeibc/tx.proto", diff --git a/packages/provider-extension/src/enigma.ts b/packages/provider-extension/src/enigma.ts index 77fde485ca..7f993d4411 100644 --- a/packages/provider-extension/src/enigma.ts +++ b/packages/provider-extension/src/enigma.ts @@ -9,10 +9,6 @@ export class KeplrEnigmaUtils implements SecretUtils { protected readonly keplr: Keplr ) {} - async isNewApi(): Promise { - return await this.keplr.enigmaIsNewApi(this.chainId); - } - async getPubkey(): Promise { return await this.keplr.getEnigmaPubKey(this.chainId); } diff --git a/packages/provider-extension/src/keplr.ts b/packages/provider-extension/src/keplr.ts index 7b28fccfd8..f59d67b06d 100644 --- a/packages/provider-extension/src/keplr.ts +++ b/packages/provider-extension/src/keplr.ts @@ -504,10 +504,6 @@ export class Keplr implements IKeplr { ]); } - async enigmaIsNewApi(chainId: string): Promise { - return await Keplr.requestMethod("enigmaIsNewApi", [chainId]); - } - getEnigmaUtils(chainId: string): SecretUtils { if (this.enigmaUtils.has(chainId)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/packages/provider-mock/src/mock.ts b/packages/provider-mock/src/mock.ts index 02aca99f02..67c9be692a 100644 --- a/packages/provider-mock/src/mock.ts +++ b/packages/provider-mock/src/mock.ts @@ -100,10 +100,6 @@ export class MockKeplr implements Keplr { throw new Error("Not implemented"); } - enigmaIsNewApi(): Promise { - throw new Error("Not implemented"); - } - experimentalSuggestChain(): Promise { throw new Error("Not implemented"); } diff --git a/packages/provider/src/core.ts b/packages/provider/src/core.ts index 219eb26cc0..c2bface5e0 100644 --- a/packages/provider/src/core.ts +++ b/packages/provider/src/core.ts @@ -765,18 +765,6 @@ export class Keplr implements IKeplr, KeplrCoreTypes { }); } - async enigmaIsNewApi(chainId: string): Promise { - return await sendSimpleMessage( - this.requester, - BACKGROUND_PORT, - "secret-wasm", - "is-new-api-msg", - { - chainId, - } - ); - } - async enigmaEncrypt( chainId: string, contractCodeHash: string, diff --git a/packages/provider/src/enigma.ts b/packages/provider/src/enigma.ts index 77fde485ca..7f993d4411 100644 --- a/packages/provider/src/enigma.ts +++ b/packages/provider/src/enigma.ts @@ -9,10 +9,6 @@ export class KeplrEnigmaUtils implements SecretUtils { protected readonly keplr: Keplr ) {} - async isNewApi(): Promise { - return await this.keplr.enigmaIsNewApi(this.chainId); - } - async getPubkey(): Promise { return await this.keplr.getEnigmaPubKey(this.chainId); } diff --git a/packages/provider/src/inject.ts b/packages/provider/src/inject.ts index cc141954c8..dad055e9e5 100644 --- a/packages/provider/src/inject.ts +++ b/packages/provider/src/inject.ts @@ -876,10 +876,6 @@ export class InjectedKeplr implements IKeplr, KeplrCoreTypes { ]); } - async enigmaIsNewApi(chainId: string): Promise { - return await this.requestMethod("enigmaIsNewApi", [chainId]); - } - getEnigmaUtils(chainId: string): SecretUtils { if (this.enigmaUtils.has(chainId)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/packages/stores/src/account/secret.ts b/packages/stores/src/account/secret.ts index 35ab11517e..1de5ae6e35 100644 --- a/packages/stores/src/account/secret.ts +++ b/packages/stores/src/account/secret.ts @@ -4,16 +4,10 @@ import { Buffer } from "buffer/"; import { CoinPrimitive } from "../common"; import { ChainGetter } from "../chain"; import { DenomHelper } from "@keplr-wallet/common"; -import { MsgExecuteContract as MsgExecuteContractV1Beta1 } from "@keplr-wallet/proto-types/secret/compute/v1beta1/msg"; -import { MsgExecuteContract as MsgExecuteContractV1 } from "@keplr-wallet/proto-types/secret/compute/v1/msg"; +import { MsgExecuteContract } from "@keplr-wallet/proto-types/secret/compute/v1beta1/msg"; import { Bech32Address } from "@keplr-wallet/cosmos"; import { Dec, DecUtils } from "@keplr-wallet/unit"; -import { - AppCurrency, - KeplrSignOptions, - StdFee, - SecretUtils, -} from "@keplr-wallet/types"; +import { AppCurrency, KeplrSignOptions, StdFee } from "@keplr-wallet/types"; import { DeepPartial, DeepReadonly, Optional } from "utility-types"; import { CosmosAccount } from "./cosmos"; import deepmerge from "deepmerge"; @@ -220,76 +214,42 @@ export class SecretAccountImpl { return this.base.cosmos.makeTx( type, async () => { - const keplr = await this.base.getKeplr(); - if (!keplr) { - throw new Error("Can't get the Keplr API"); - } - - const enigmaUtils = keplr.getEnigmaUtils(this.chainId); - encryptedMsg = await this.encryptSecretContractMsg( contractAddress, - obj, - enigmaUtils + obj ); - const msg = (await enigmaUtils.isNewApi()) - ? { - type: this.msgOpts.executeSecretWasm.type, - value: { - sender: Buffer.from( - Bech32Address.fromBech32(this.base.bech32Address).address - ).toString("base64"), - contract: Buffer.from( - Bech32Address.fromBech32(contractAddress).address - ).toString("base64"), - // callback_code_hash: "", - msg: Buffer.from(encryptedMsg).toString("base64"), - sent_funds: sentFunds, - // callback_sig: null, - }, - } - : { - type: this.msgOpts.executeSecretWasm.type, - value: { - sender: this.base.bech32Address, - contract: contractAddress, - // callback_code_hash: "", - msg: Buffer.from(encryptedMsg).toString("base64"), - sent_funds: sentFunds, - // callback_sig: null, - }, - }; - - const protoMsg = (await enigmaUtils.isNewApi()) - ? { - // type url must be with v1beta1 + const msg = { + type: this.msgOpts.executeSecretWasm.type, + value: { + sender: Buffer.from( + Bech32Address.fromBech32(this.base.bech32Address).address + ).toString("base64"), + contract: Buffer.from( + Bech32Address.fromBech32(contractAddress).address + ).toString("base64"), + // callback_code_hash: "", + msg: Buffer.from(encryptedMsg).toString("base64"), + sent_funds: sentFunds, + // callback_sig: null, + }, + }; + + return { + aminoMsgs: [msg], + protoMsgs: [ + { typeUrl: "/secret.compute.v1beta1.MsgExecuteContract", - value: MsgExecuteContractV1.encode( - MsgExecuteContractV1.fromPartial({ + value: MsgExecuteContract.encode( + MsgExecuteContract.fromPartial({ sender: Buffer.from(msg.value.sender, "base64"), contract: Buffer.from(msg.value.contract, "base64"), msg: Buffer.from(msg.value.msg, "base64"), sentFunds: msg.value.sent_funds, }) ).finish(), - } - : { - typeUrl: "/secret.compute.v1beta1.MsgExecuteContract", - value: MsgExecuteContractV1Beta1.encode( - MsgExecuteContractV1Beta1.fromPartial({ - sender: Bech32Address.fromBech32(msg.value.sender).address, - contract: Bech32Address.fromBech32(msg.value.contract) - .address, - msg: Buffer.from(msg.value.msg, "base64"), - sentFunds: msg.value.sent_funds, - }) - ).finish(), - }; - - return { - aminoMsgs: [msg], - protoMsgs: [protoMsg], + }, + ], }; }, preOnTxEvents @@ -321,76 +281,42 @@ export class SecretAccountImpl { await this.base.cosmos.sendMsgs( type, async () => { - const keplr = await this.base.getKeplr(); - if (!keplr) { - throw new Error("Can't get the Keplr API"); - } - - const enigmaUtils = keplr.getEnigmaUtils(this.chainId); - encryptedMsg = await this.encryptSecretContractMsg( contractAddress, - obj, - enigmaUtils + obj ); - const msg = (await enigmaUtils.isNewApi()) - ? { - type: this.msgOpts.executeSecretWasm.type, - value: { - sender: Buffer.from( - Bech32Address.fromBech32(this.base.bech32Address).address - ).toString("base64"), - contract: Buffer.from( - Bech32Address.fromBech32(contractAddress).address - ).toString("base64"), - // callback_code_hash: "", - msg: Buffer.from(encryptedMsg).toString("base64"), - sent_funds: sentFunds, - // callback_sig: null, - }, - } - : { - type: this.msgOpts.executeSecretWasm.type, - value: { - sender: this.base.bech32Address, - contract: contractAddress, - // callback_code_hash: "", - msg: Buffer.from(encryptedMsg).toString("base64"), - sent_funds: sentFunds, - // callback_sig: null, - }, - }; - - const protoMsg = (await enigmaUtils.isNewApi()) - ? { - // type url must be with v1beta1 + const msg = { + type: this.msgOpts.executeSecretWasm.type, + value: { + sender: Buffer.from( + Bech32Address.fromBech32(this.base.bech32Address).address + ).toString("base64"), + contract: Buffer.from( + Bech32Address.fromBech32(contractAddress).address + ).toString("base64"), + // callback_code_hash: "", + msg: Buffer.from(encryptedMsg).toString("base64"), + sent_funds: sentFunds, + // callback_sig: null, + }, + }; + + return { + aminoMsgs: [msg], + protoMsgs: [ + { typeUrl: "/secret.compute.v1beta1.MsgExecuteContract", - value: MsgExecuteContractV1.encode( - MsgExecuteContractV1.fromPartial({ + value: MsgExecuteContract.encode( + MsgExecuteContract.fromPartial({ sender: Buffer.from(msg.value.sender, "base64"), contract: Buffer.from(msg.value.contract, "base64"), msg: Buffer.from(msg.value.msg, "base64"), sentFunds: msg.value.sent_funds, }) ).finish(), - } - : { - typeUrl: "/secret.compute.v1beta1.MsgExecuteContract", - value: MsgExecuteContractV1Beta1.encode( - MsgExecuteContractV1Beta1.fromPartial({ - sender: Bech32Address.fromBech32(msg.value.sender).address, - contract: Bech32Address.fromBech32(msg.value.contract) - .address, - msg: Buffer.from(msg.value.msg, "base64"), - sentFunds: msg.value.sent_funds, - }) - ).finish(), - }; - - return { - aminoMsgs: [msg], - protoMsgs: [protoMsg], + }, + ], }; }, memo, @@ -409,8 +335,7 @@ export class SecretAccountImpl { protected async encryptSecretContractMsg( contractAddress: string, // eslint-disable-next-line @typescript-eslint/ban-types - obj: object, - enigmaUtils: SecretUtils + obj: object ): Promise { const queryContractCodeHashResponse = await this.queries.secret.querySecretContractCodeHash @@ -425,6 +350,12 @@ export class SecretAccountImpl { const contractCodeHash = queryContractCodeHashResponse.data.code_hash; + const keplr = await this.base.getKeplr(); + if (!keplr) { + throw new Error("Can't get the Keplr API"); + } + + const enigmaUtils = keplr.getEnigmaUtils(this.chainId); return await enigmaUtils.encrypt(contractCodeHash, obj); } diff --git a/packages/types/src/secretjs.ts b/packages/types/src/secretjs.ts index 9b73049215..1c1c23cd43 100644 --- a/packages/types/src/secretjs.ts +++ b/packages/types/src/secretjs.ts @@ -1,5 +1,4 @@ export interface SecretUtils { - isNewApi: () => Promise; getPubkey: () => Promise; decrypt: (ciphertext: Uint8Array, nonce: Uint8Array) => Promise; encrypt: ( diff --git a/packages/types/src/wallet/keplr.ts b/packages/types/src/wallet/keplr.ts index 14acbb8300..361c214fc1 100644 --- a/packages/types/src/wallet/keplr.ts +++ b/packages/types/src/wallet/keplr.ts @@ -208,7 +208,6 @@ export interface Keplr { ciphertext: Uint8Array, nonce: Uint8Array ): Promise; - enigmaIsNewApi(chainId: string): Promise; /** * Sign the sign doc with ethermint's EIP-712 format. diff --git a/packages/wc-client/src/index.ts b/packages/wc-client/src/index.ts index 1ec027663d..e49320348e 100644 --- a/packages/wc-client/src/index.ts +++ b/packages/wc-client/src/index.ts @@ -430,10 +430,6 @@ export class KeplrWalletConnectV2 implements Keplr { throw new Error("Not yet implemented"); } - enigmaIsNewApi(_chainId: string): Promise { - throw new Error("Not yet implemented"); - } - experimentalSignEIP712CosmosTx_v0( _chainId: string, _signer: string,