Skip to content

Commit

Permalink
Generate upgradability types & impl missing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Jun 9, 2023
1 parent dacb6b4 commit 96af4f0
Show file tree
Hide file tree
Showing 12 changed files with 1,338 additions and 28 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"unresolved-macro-call",
"unresolved-proc-macro"
],

"[rust]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "rust-lang.rust-analyzer"
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o errexit -o nounset -o pipefail
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

rm -rf "${SCRIPT_PATH}/SecretNetwork"
git clone --depth 1 --branch ibc-switch-middleware https://github.com/scrtlabs/SecretNetwork "${SCRIPT_PATH}/SecretNetwork"
git clone --depth 1 --branch contract-upgrade-v2 https://github.com/scrtlabs/SecretNetwork "${SCRIPT_PATH}/SecretNetwork"

# plugins paths, note this must be an abolsute path on Windows

Expand Down
32 changes: 32 additions & 0 deletions src/grpc_gateway/secret/compute/v1beta1/msg.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type MsgInstantiateContract = {
init_msg?: Uint8Array
init_funds?: CosmosBaseV1beta1Coin.Coin[]
callback_sig?: Uint8Array
admin?: Uint8Array
}

export type MsgInstantiateContractResponse = {
Expand All @@ -45,6 +46,34 @@ export type MsgExecuteContractResponse = {
data?: Uint8Array
}

export type MsgMigrateContract = {
sender?: string
contract?: string
code_id?: string
msg?: Uint8Array
}

export type MsgMigrateContractResponse = {
data?: Uint8Array
}

export type MsgUpdateAdmin = {
sender?: string
new_admin?: string
contract?: string
}

export type MsgUpdateAdminResponse = {
}

export type MsgClearAdmin = {
sender?: string
contract?: string
}

export type MsgClearAdminResponse = {
}

export class Msg {
static StoreCode(req: MsgStoreCode, initReq?: fm.InitReq): Promise<MsgStoreCodeResponse> {
return fm.fetchReq<MsgStoreCode, MsgStoreCodeResponse>(`/secret.compute.v1beta1.Msg/StoreCode`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
Expand All @@ -55,4 +84,7 @@ export class Msg {
static ExecuteContract(req: MsgExecuteContract, initReq?: fm.InitReq): Promise<MsgExecuteContractResponse> {
return fm.fetchReq<MsgExecuteContract, MsgExecuteContractResponse>(`/secret.compute.v1beta1.Msg/ExecuteContract`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
}
static MigrateContract(req: MsgMigrateContract, initReq?: fm.InitReq): Promise<MsgMigrateContractResponse> {
return fm.fetchReq<MsgMigrateContract, MsgMigrateContractResponse>(`/secret.compute.v1beta1.Msg/MigrateContract`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
}
}
14 changes: 14 additions & 0 deletions src/grpc_gateway/secret/compute/v1beta1/query.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import * as CosmosBaseAbciV1beta1Abci from "../../../cosmos/base/abci/v1beta1/abci.pb"
import * as CosmosBaseQueryV1beta1Pagination from "../../../cosmos/base/query/v1beta1/pagination.pb"
import * as fm from "../../../fetch.pb"
import * as GoogleProtobufEmpty from "../../../google/protobuf/empty.pb"
import * as SecretComputeV1beta1Types from "./types.pb"
Expand Down Expand Up @@ -86,6 +87,16 @@ export type DecryptedAnswers = {
plaintext_error?: string
}

export type QueryContractHistoryRequest = {
contract_address?: string
pagination?: CosmosBaseQueryV1beta1Pagination.PageRequest
}

export type QueryContractHistoryResponse = {
entries?: SecretComputeV1beta1Types.ContractCodeHistoryEntry[]
pagination?: CosmosBaseQueryV1beta1Pagination.PageResponse
}

export class Query {
static ContractInfo(req: QueryByContractAddressRequest, initReq?: fm.InitReq): Promise<QueryContractInfoResponse> {
return fm.fetchReq<QueryByContractAddressRequest, QueryContractInfoResponse>(`/compute/v1beta1/info/${req["contract_address"]}?${fm.renderURLSearchParams(req, ["contract_address"])}`, {...initReq, method: "GET"})
Expand Down Expand Up @@ -114,4 +125,7 @@ export class Query {
static AddressByLabel(req: QueryByLabelRequest, initReq?: fm.InitReq): Promise<QueryContractAddressResponse> {
return fm.fetchReq<QueryByLabelRequest, QueryContractAddressResponse>(`/compute/v1beta1/contract_address/${req["label"]}?${fm.renderURLSearchParams(req, ["label"])}`, {...initReq, method: "GET"})
}
static ContractHistory(req: QueryContractHistoryRequest, initReq?: fm.InitReq): Promise<QueryContractHistoryResponse> {
return fm.fetchReq<QueryContractHistoryRequest, QueryContractHistoryResponse>(`/compute/v1beta1/contract_history/${req["contract_address"]}?${fm.renderURLSearchParams(req, ["contract_address"])}`, {...initReq, method: "GET"})
}
}
26 changes: 26 additions & 0 deletions src/grpc_gateway/secret/compute/v1beta1/types.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export enum AccessType {
EVERYBODY = "EVERYBODY",
}

export enum ContractCodeHistoryOperationType {
CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED",
CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT",
CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE",
CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS",
}

export type AccessTypeParam = {
value?: AccessType
}
Expand All @@ -27,12 +34,24 @@ export type ContractCustomInfo = {
label?: string
}

export type ContractKey = {
key?: Uint8Array
original?: ContractKeyWithProof
}

export type ContractKeyWithProof = {
key?: Uint8Array
proof?: Uint8Array
}

export type ContractInfo = {
code_id?: string
creator?: Uint8Array
label?: string
created?: AbsoluteTxPosition
ibc_port_id?: string
admin?: Uint8Array
admin_proof?: Uint8Array
}

export type AbsoluteTxPosition = {
Expand All @@ -43,4 +62,11 @@ export type AbsoluteTxPosition = {
export type Model = {
Key?: Uint8Array
Value?: Uint8Array
}

export type ContractCodeHistoryEntry = {
operation?: ContractCodeHistoryOperationType
code_id?: string
updated?: AbsoluteTxPosition
msg?: Uint8Array
}
Loading

0 comments on commit 96af4f0

Please sign in to comment.