From 470c885fd6696c5a0eff82dc990150a8f2bc0f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Mon, 4 Apr 2022 16:02:58 +0200 Subject: [PATCH] tools: TypeScript implementation, tests --- docs/runtime/transactions.md | 214 ++++-- tools/extract-runtime-txs/main.go | 4 + .../extract-runtime-txs/parsers/typescript.go | 164 ++++ .../parsers/typescript_test.go | 60 ++ tools/extract-runtime-txs/parsers/utils.go | 4 +- .../tests/typescript/contracts.ts | 63 ++ .../tests/typescript/types.ts | 721 ++++++++++++++++++ 7 files changed, 1154 insertions(+), 76 deletions(-) create mode 100644 tools/extract-runtime-txs/parsers/typescript.go create mode 100644 tools/extract-runtime-txs/parsers/typescript_test.go create mode 100644 tools/extract-runtime-txs/tests/typescript/contracts.ts create mode 100644 tools/extract-runtime-txs/tests/typescript/types.ts diff --git a/docs/runtime/transactions.md b/docs/runtime/transactions.md index aa34c52b54..db10973a40 100644 --- a/docs/runtime/transactions.md +++ b/docs/runtime/transactions.md @@ -10,42 +10,47 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. ## accounts ### accounts.Addresses (query) {#accounts-addresses} -[[Rust][rust-accounts.Addresses] | [Go][go-accounts.Addresses]] +[[Rust][rust-accounts.Addresses] | [Go][go-accounts.Addresses] | [TypeScript][typescript-accounts.Addresses]] -#### Parameters [[Rust][rust-accounts.Addresses-params] | [Go][go-accounts.Addresses-params]] +#### Parameters [[Rust][rust-accounts.Addresses-params] | [Go][go-accounts.Addresses-params] | [TypeScript][typescript-accounts.Addresses-params]] - `denomination: token::Denomination` [rust-accounts.Addresses]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/mod.rs#L710-L720 [go-accounts.Addresses]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/accounts.go#L93-L101 -[go-accounts.Addresses-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/types.go#L44-L45 +[typescript-accounts.Addresses]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/accounts.ts#L49-L51 [rust-accounts.Addresses-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L30-L34 +[go-accounts.Addresses-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/types.go#L44-L45 +[typescript-accounts.Addresses-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L111-L116 ### accounts.Balances (query) {#accounts-balances} -[[Rust][rust-accounts.Balances] | [Go][go-accounts.Balances]] +[[Rust][rust-accounts.Balances] | [Go][go-accounts.Balances] | [TypeScript][typescript-accounts.Balances]] -#### Parameters [[Rust][rust-accounts.Balances-params] | [Go][go-accounts.Balances-params]] +#### Parameters [[Rust][rust-accounts.Balances-params] | [Go][go-accounts.Balances-params] | [TypeScript][typescript-accounts.Balances-params]] - `address: Address` -#### Result [[Rust][rust-accounts.Balances-result]] +#### Result [[Rust][rust-accounts.Balances-result] | [TypeScript][typescript-accounts.Balances-result]] - `balances: BTreeMap` [rust-accounts.Balances]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/mod.rs#L722-L728 [go-accounts.Balances]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/accounts.go#L83-L91 +[typescript-accounts.Balances]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/accounts.ts#L43-L47 [rust-accounts.Balances-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L36-L40 [go-accounts.Balances-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/types.go#L18-L21 +[typescript-accounts.Balances-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L87-L92 [rust-accounts.Balances-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L42-L46 +[typescript-accounts.Balances-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L80-L85 ### accounts.DenominationInfo (query) {#accounts-denominationinfo} -[[Rust][rust-accounts.DenominationInfo] | [Go][go-accounts.DenominationInfo]] +[[Rust][rust-accounts.DenominationInfo] | [Go][go-accounts.DenominationInfo] | [TypeScript][typescript-accounts.DenominationInfo]] -#### Parameters [[Rust][rust-accounts.DenominationInfo-params] | [Go][go-accounts.DenominationInfo-params]] +#### Parameters [[Rust][rust-accounts.DenominationInfo-params] | [Go][go-accounts.DenominationInfo-params] | [TypeScript][typescript-accounts.DenominationInfo-params]] - `denomination: token::Denomination` -#### Result [[Rust][rust-accounts.DenominationInfo-result]] +#### Result [[Rust][rust-accounts.DenominationInfo-result] | [TypeScript][typescript-accounts.DenominationInfo-result]] - `decimals: u8` @@ -54,97 +59,113 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-accounts.DenominationInfo]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/mod.rs#L730-L736 [go-accounts.DenominationInfo]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/accounts.go#L103-L111 +[typescript-accounts.DenominationInfo]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/accounts.ts#L53-L57 [rust-accounts.DenominationInfo-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L48-L52 [go-accounts.DenominationInfo-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/types.go#L38-L42 +[typescript-accounts.DenominationInfo-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L118-L123 [rust-accounts.DenominationInfo-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L54-L59 +[typescript-accounts.DenominationInfo-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L125-L130 ### accounts.Nonce (query) {#accounts-nonce} -[[Rust][rust-accounts.Nonce] | [Go][go-accounts.Nonce]] +[[Rust][rust-accounts.Nonce] | [Go][go-accounts.Nonce] | [TypeScript][typescript-accounts.Nonce]] -#### Parameters [[Rust][rust-accounts.Nonce-params] | [Go][go-accounts.Nonce-params]] +#### Parameters [[Rust][rust-accounts.Nonce-params] | [Go][go-accounts.Nonce-params] | [TypeScript][typescript-accounts.Nonce-params]] - `address: Address` [rust-accounts.Nonce]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/mod.rs#L705-L708 [go-accounts.Nonce]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/accounts.go#L73-L81 +[typescript-accounts.Nonce]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/accounts.ts#L39-L41 [rust-accounts.Nonce-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L24-L28 [go-accounts.Nonce-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/types.go#L13-L16 +[typescript-accounts.Nonce-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L104-L109 ### accounts.Transfer (call) {#accounts-transfer} -[[Rust][rust-accounts.Transfer] | [Go][go-accounts.Transfer]] +[[Rust][rust-accounts.Transfer] | [Go][go-accounts.Transfer] | [TypeScript][typescript-accounts.Transfer]] -#### Parameters [[Rust][rust-accounts.Transfer-params] | [Go][go-accounts.Transfer-params]] +#### Parameters [[Rust][rust-accounts.Transfer-params] | [Go][go-accounts.Transfer-params] | [TypeScript][typescript-accounts.Transfer-params]] - `to: Address` - `amount: token::BaseUnits` -[go-accounts.Transfer]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/accounts.go#L55-L61 [rust-accounts.Transfer]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/mod.rs#L689-L703 +[go-accounts.Transfer]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/accounts.go#L55-L61 +[typescript-accounts.Transfer]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/accounts.ts#L35-L37 +[typescript-accounts.Transfer-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L132-L138 [rust-accounts.Transfer-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/accounts/types.rs#L8-L13 [go-accounts.Transfer-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/accounts/types.go#L7-L11 ## consensus ### consensus.Account (query) {#consensus-account} -[[Rust][rust-consensus.Account]] +[[Rust][rust-consensus.Account] | [TypeScript][typescript-consensus.Account]] -#### Parameters [[Rust][rust-consensus.Account-params] | [Go][go-consensus.Account-params]] +#### Parameters [[Rust][rust-consensus.Account-params] | [Go][go-consensus.Account-params] | [TypeScript][typescript-consensus.Account-params]] - `address: Address` [rust-consensus.Account]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/mod.rs#L297-L303 +[typescript-consensus.Account]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/consensus_accounts.ts#L45-L47 +[typescript-consensus.Account-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L366-L371 [rust-consensus.Account-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L31-L35 [go-consensus.Account-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/types.go#L27-L30 ### consensus.Balance (query) {#consensus-balance} -[[Rust][rust-consensus.Balance] | [Go][go-consensus.Balance]] +[[Rust][rust-consensus.Balance] | [Go][go-consensus.Balance] | [TypeScript][typescript-consensus.Balance]] -#### Parameters [[Rust][rust-consensus.Balance-params] | [Go][go-consensus.Balance-params]] +#### Parameters [[Rust][rust-consensus.Balance-params] | [Go][go-consensus.Balance-params] | [TypeScript][typescript-consensus.Balance-params]] - `address: Address` -#### Result [[Rust][rust-consensus.Balance-result]] +#### Result [[Rust][rust-consensus.Balance-result] | [TypeScript][typescript-consensus.Balance-result]] - `balance: u128` +[typescript-consensus.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/consensus_accounts.ts#L39-L43 [rust-consensus.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/mod.rs#L281-L295 [go-consensus.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/consensus_accounts.go#L78-L86 -[rust-consensus.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L25-L29 [go-consensus.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/types.go#L17-L20 +[typescript-consensus.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L352-L357 +[rust-consensus.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L25-L29 [rust-consensus.Balance-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L37-L40 +[typescript-consensus.Balance-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L359-L364 ### consensus.Deposit (call) {#consensus-deposit} -[[Rust][rust-consensus.Deposit] | [Go][go-consensus.Deposit]] +[[Rust][rust-consensus.Deposit] | [Go][go-consensus.Deposit] | [TypeScript][typescript-consensus.Deposit]] -#### Parameters [[Rust][rust-consensus.Deposit-params] | [Go][go-consensus.Deposit-params]] +#### Parameters [[Rust][rust-consensus.Deposit-params] | [Go][go-consensus.Deposit-params] | [TypeScript][typescript-consensus.Deposit-params]] - `to: Option
` - `amount: token::BaseUnits` [rust-consensus.Deposit]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/mod.rs#L228-L240 [go-consensus.Deposit]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/consensus_accounts.go#L52-L58 +[typescript-consensus.Deposit]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/consensus_accounts.ts#L31-L33 +[typescript-consensus.Deposit-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L336-L342 [rust-consensus.Deposit-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L4-L13 [go-consensus.Deposit-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/types.go#L5-L9 ### consensus.Withdraw (call) {#consensus-withdraw} -[[Rust][rust-consensus.Withdraw] | [Go][go-consensus.Withdraw]] +[[Rust][rust-consensus.Withdraw] | [Go][go-consensus.Withdraw] | [TypeScript][typescript-consensus.Withdraw]] -#### Parameters [[Rust][rust-consensus.Withdraw-params] | [Go][go-consensus.Withdraw-params]] +#### Parameters [[Rust][rust-consensus.Withdraw-params] | [Go][go-consensus.Withdraw-params] | [TypeScript][typescript-consensus.Withdraw-params]] - `to: Option
` - `amount: token::BaseUnits` [rust-consensus.Withdraw]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/mod.rs#L262-L279 [go-consensus.Withdraw]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/consensus_accounts.go#L60-L66 -[rust-consensus.Withdraw-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L15-L23 +[typescript-consensus.Withdraw]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/consensus_accounts.ts#L35-L37 [go-consensus.Withdraw-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/consensusaccounts/types.go#L11-L15 +[typescript-consensus.Withdraw-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L344-L350 +[rust-consensus.Withdraw-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/consensus_accounts/types.rs#L15-L23 ## contracts ### contracts.Call (call) {#contracts-call} -[[Rust][rust-contracts.Call] | [Go][go-contracts.Call]] +[[Rust][rust-contracts.Call] | [Go][go-contracts.Call] | [TypeScript][typescript-contracts.Call]] -#### Parameters [[Rust][rust-contracts.Call-params] | [Go][go-contracts.Call-params]] +#### Parameters [[Rust][rust-contracts.Call-params] | [Go][go-contracts.Call-params] | [TypeScript][typescript-contracts.Call-params]] - `id: InstanceId` @@ -162,23 +183,25 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. #### Result [[Go][go-contracts.Call-result]] -[rust-contracts.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L485-L528 [go-contracts.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L144-L147 +[typescript-contracts.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L58-L60 +[rust-contracts.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L485-L528 [rust-contracts.Call-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L138-L149 [go-contracts.Call-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L109-L117 +[typescript-contracts.Call-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L534-L550 [go-contracts.Call-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L119-L120 ### contracts.Code (query) {#contracts-code} -[[Rust][rust-contracts.Code] | [Go][go-contracts.Code]] +[[Rust][rust-contracts.Code] | [Go][go-contracts.Code] | [TypeScript][typescript-contracts.Code]] -#### Parameters [[Rust][rust-contracts.Code-params] | [Go][go-contracts.Code-params]] +#### Parameters [[Rust][rust-contracts.Code-params] | [Go][go-contracts.Code-params] | [TypeScript][typescript-contracts.Code-params]] - `id: CodeId` Code identifier. -#### Result [[Rust][rust-contracts.Code-result]] +#### Result [[Rust][rust-contracts.Code-result] | [TypeScript][typescript-contracts.Code-result]] - `id: CodeId` @@ -201,16 +224,19 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. Who is allowed to instantiate this code. -[go-contracts.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L164-L172 +[typescript-contracts.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L64-L66 [rust-contracts.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L599-L605 +[go-contracts.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L164-L172 [rust-contracts.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L172-L177 [go-contracts.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L134-L138 +[typescript-contracts.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L574-L582 [rust-contracts.Code-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L48-L65 +[typescript-contracts.Code-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L584-L608 ### contracts.Custom (query) {#contracts-custom} -[[Rust][rust-contracts.Custom] | [Go][go-contracts.Custom]] +[[Rust][rust-contracts.Custom] | [Go][go-contracts.Custom] | [TypeScript][typescript-contracts.Custom]] -#### Parameters [[Rust][rust-contracts.Custom-params] | [Go][go-contracts.Custom-params]] +#### Parameters [[Rust][rust-contracts.Custom-params] | [Go][go-contracts.Custom-params] | [TypeScript][typescript-contracts.Custom-params]] - `id: InstanceId` @@ -224,23 +250,25 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. #### Result [[Go][go-contracts.Custom-result]] -[go-contracts.Custom]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L214-L224 [rust-contracts.Custom]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L637-L672 +[go-contracts.Custom]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L214-L224 +[typescript-contracts.Custom]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L81-L83 [rust-contracts.Custom-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L232-L240 [go-contracts.Custom-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L186-L192 +[typescript-contracts.Custom-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L695-L707 [go-contracts.Custom-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L194-L195 ### contracts.Instance (query) {#contracts-instance} -[[Rust][rust-contracts.Instance] | [Go][go-contracts.Instance]] +[[Rust][rust-contracts.Instance] | [Go][go-contracts.Instance] | [TypeScript][typescript-contracts.Instance]] -#### Parameters [[Rust][rust-contracts.Instance-params] | [Go][go-contracts.Instance-params]] +#### Parameters [[Rust][rust-contracts.Instance-params] | [Go][go-contracts.Instance-params] | [TypeScript][typescript-contracts.Instance-params]] - `id: InstanceId` Instance identifier. -#### Result [[Rust][rust-contracts.Instance-result]] +#### Result [[Rust][rust-contracts.Instance-result] | [TypeScript][typescript-contracts.Instance-result]] - `id: InstanceId` @@ -259,14 +287,17 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. Who is allowed to upgrade this instance. -[rust-contracts.Instance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L607-L613 [go-contracts.Instance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L174-L182 +[typescript-contracts.Instance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L67-L69 +[rust-contracts.Instance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L607-L613 [rust-contracts.Instance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L179-L184 [go-contracts.Instance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L140-L144 +[typescript-contracts.Instance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L610-L618 [rust-contracts.Instance-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L67-L81 +[typescript-contracts.Instance-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L620-L640 ### contracts.InstanceStorage (query) {#contracts-instancestorage} -[[Rust][rust-contracts.InstanceStorage] | [Go][go-contracts.InstanceStorage]] +[[Rust][rust-contracts.InstanceStorage] | [Go][go-contracts.InstanceStorage] | [TypeScript][typescript-contracts.InstanceStorage]] #### Parameters [[Rust][rust-contracts.InstanceStorage-params] | [Go][go-contracts.InstanceStorage-params]] @@ -288,15 +319,16 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-contracts.InstanceStorage]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L615-L627 [go-contracts.InstanceStorage]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L184-L192 +[typescript-contracts.InstanceStorage]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L70-L75 [rust-contracts.InstanceStorage-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L186-L194 [go-contracts.InstanceStorage-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L146-L152 [rust-contracts.InstanceStorage-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L196-L200 [go-contracts.InstanceStorage-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L154-L158 ### contracts.Instantiate (call) {#contracts-instantiate} -[[Rust][rust-contracts.Instantiate] | [Go][go-contracts.Instantiate]] +[[Rust][rust-contracts.Instantiate] | [Go][go-contracts.Instantiate] | [TypeScript][typescript-contracts.Instantiate]] -#### Parameters [[Rust][rust-contracts.Instantiate-params] | [Go][go-contracts.Instantiate-params]] +#### Parameters [[Rust][rust-contracts.Instantiate-params] | [Go][go-contracts.Instantiate-params] | [TypeScript][typescript-contracts.Instantiate-params]] - `code_id: CodeId` @@ -315,7 +347,7 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. Tokens that should be sent to the contract as part of the instantiate call. -#### Result [[Rust][rust-contracts.Instantiate-result] | [Go][go-contracts.Instantiate-result]] +#### Result [[Rust][rust-contracts.Instantiate-result] | [Go][go-contracts.Instantiate-result] | [TypeScript][typescript-contracts.Instantiate-result]] - `id: InstanceId` @@ -324,15 +356,18 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-contracts.Instantiate]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L423-L483 [go-contracts.Instantiate]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L130-L133 +[typescript-contracts.Instantiate]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L53-L57 [rust-contracts.Instantiate-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L115-L129 [go-contracts.Instantiate-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L91-L101 +[typescript-contracts.Instantiate-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L502-L522 [rust-contracts.Instantiate-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L131-L136 [go-contracts.Instantiate-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L103-L107 +[typescript-contracts.Instantiate-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L524-L532 ### contracts.PublicKey (query) {#contracts-publickey} -[[Rust][rust-contracts.PublicKey] | [Go][go-contracts.PublicKey]] +[[Rust][rust-contracts.PublicKey] | [Go][go-contracts.PublicKey] | [TypeScript][typescript-contracts.PublicKey]] -#### Parameters [[Rust][rust-contracts.PublicKey-params] | [Go][go-contracts.PublicKey-params]] +#### Parameters [[Rust][rust-contracts.PublicKey-params] | [Go][go-contracts.PublicKey-params] | [TypeScript][typescript-contracts.PublicKey-params]] - `id: InstanceId` @@ -343,7 +378,7 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. Kind of public key. -#### Result [[Rust][rust-contracts.PublicKey-result] | [Go][go-contracts.PublicKey-result]] +#### Result [[Rust][rust-contracts.PublicKey-result] | [Go][go-contracts.PublicKey-result] | [TypeScript][typescript-contracts.PublicKey-result]] - `key: Vec` @@ -360,15 +395,18 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-contracts.PublicKey]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L629-L635 [go-contracts.PublicKey]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L194-L202 +[typescript-contracts.PublicKey]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L76-L80 [rust-contracts.PublicKey-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L209-L217 [go-contracts.PublicKey-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L168-L174 +[typescript-contracts.PublicKey-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L663-L675 [rust-contracts.PublicKey-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L219-L230 [go-contracts.PublicKey-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L176-L184 +[typescript-contracts.PublicKey-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L677-L693 ### contracts.Upgrade (call) {#contracts-upgrade} -[[Rust][rust-contracts.Upgrade] | [Go][go-contracts.Upgrade]] +[[Rust][rust-contracts.Upgrade] | [Go][go-contracts.Upgrade] | [TypeScript][typescript-contracts.Upgrade]] -#### Parameters [[Rust][rust-contracts.Upgrade-params] | [Go][go-contracts.Upgrade-params]] +#### Parameters [[Rust][rust-contracts.Upgrade-params] | [Go][go-contracts.Upgrade-params] | [TypeScript][typescript-contracts.Upgrade-params]] - `id: InstanceId` @@ -389,13 +427,15 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-contracts.Upgrade]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L530-L597 [go-contracts.Upgrade]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L159-L162 +[typescript-contracts.Upgrade]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L61-L63 +[typescript-contracts.Upgrade-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L552-L572 [rust-contracts.Upgrade-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L156-L170 [go-contracts.Upgrade-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L122-L132 ### contracts.Upload (call) {#contracts-upload} -[[Rust][rust-contracts.Upload] | [Go][go-contracts.Upload]] +[[Rust][rust-contracts.Upload] | [Go][go-contracts.Upload] | [TypeScript][typescript-contracts.Upload]] -#### Parameters [[Rust][rust-contracts.Upload-params] | [Go][go-contracts.Upload-params]] +#### Parameters [[Rust][rust-contracts.Upload-params] | [Go][go-contracts.Upload-params] | [TypeScript][typescript-contracts.Upload-params]] - `abi: ABI` @@ -410,7 +450,7 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. Compiled contract code. -#### Result [[Rust][rust-contracts.Upload-result] | [Go][go-contracts.Upload-result]] +#### Result [[Rust][rust-contracts.Upload-result] | [Go][go-contracts.Upload-result] | [TypeScript][typescript-contracts.Upload-result]] - `id: CodeId` @@ -419,15 +459,18 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-contracts.Upload]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/lib.rs#L331-L421 [go-contracts.Upload]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/contracts.go#L111-L118 +[typescript-contracts.Upload]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/contracts.ts#L50-L52 [rust-contracts.Upload-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L95-L106 [go-contracts.Upload-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L75-L83 +[typescript-contracts.Upload-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L474-L490 +[typescript-contracts.Upload-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L492-L500 [rust-contracts.Upload-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/contracts/src/types.rs#L108-L113 [go-contracts.Upload-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/contracts/types.go#L85-L89 ## core ### core.CallDataPublicKey (query) {#core-calldatapublickey} -[[Rust][rust-core.CallDataPublicKey]] +[[Rust][rust-core.CallDataPublicKey] | [TypeScript][typescript-core.CallDataPublicKey]] #### Parameters [[Rust][rust-core.CallDataPublicKey-params]] @@ -436,19 +479,21 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. Public key used for deriving the shared secret for encrypting call data. -#### Result [[Rust][rust-core.CallDataPublicKey-result]] +#### Result [[Rust][rust-core.CallDataPublicKey-result] | [TypeScript][typescript-core.CallDataPublicKey-result]] - `public_key: SignedPublicKey` Public key used for deriving the shared secret for encrypting call data. +[typescript-core.CallDataPublicKey]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/core.ts#L61-L65 [rust-core.CallDataPublicKey]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/mod.rs#L438-L453 [rust-core.CallDataPublicKey-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L29-L34 [rust-core.CallDataPublicKey-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L29-L34 +[typescript-core.CallDataPublicKey-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L11-L19 ### core.CheckInvariants (query) {#core-checkinvariants} -[[Rust][rust-core.CheckInvariants]] +[[Rust][rust-core.CheckInvariants] | [TypeScript][typescript-core.CheckInvariants]] #### Parameters [[Rust][rust-core.CheckInvariants-params]] @@ -465,13 +510,14 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-core.CheckInvariants]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/mod.rs#L428-L436 +[typescript-core.CheckInvariants]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/core.ts#L57-L59 [rust-core.CheckInvariants-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L29-L34 [rust-core.CheckInvariants-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L29-L34 ### core.EstimateGas (query) {#core-estimategas} -[[Rust][rust-core.EstimateGas] | [Go][go-core.EstimateGas]] +[[Rust][rust-core.EstimateGas] | [Go][go-core.EstimateGas] | [TypeScript][typescript-core.EstimateGas]] -#### Parameters [[Rust][rust-core.EstimateGas-params] | [Go][go-core.EstimateGas-params]] +#### Parameters [[Rust][rust-core.EstimateGas-params] | [Go][go-core.EstimateGas-params] | [TypeScript][typescript-core.EstimateGas-params]] - `caller: Option` - `tx: Transaction` @@ -479,13 +525,15 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. The unsigned transaction to estimate. +[typescript-core.EstimateGas]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/core.ts#L53-L55 [rust-core.EstimateGas]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/mod.rs#L348-L426 [go-core.EstimateGas]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/core/core.go#L57-L65 +[typescript-core.EstimateGas-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L3-L9 [rust-core.EstimateGas-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L18-L27 [go-core.EstimateGas-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/core/types.go#L10-L17 ### core.MinGasPrice (query) {#core-mingasprice} -[[Rust][rust-core.MinGasPrice] | [Go][go-core.MinGasPrice]] +[[Rust][rust-core.MinGasPrice] | [Go][go-core.MinGasPrice] | [TypeScript][typescript-core.MinGasPrice]] #### Parameters [[Rust][rust-core.MinGasPrice-params]] @@ -494,12 +542,13 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. A set of state versions for all supported modules. +[typescript-core.MinGasPrice]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/core.ts#L67-L69 [rust-core.MinGasPrice]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/mod.rs#L455-L473 [go-core.MinGasPrice]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/core/core.go#L81-L89 [rust-core.MinGasPrice-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L11-L16 ### core.RuntimeInfo (query) {#core-runtimeinfo} -[[Rust][rust-core.RuntimeInfo] | [Go][go-core.RuntimeInfo]] +[[Rust][rust-core.RuntimeInfo] | [Go][go-core.RuntimeInfo] | [TypeScript][typescript-core.RuntimeInfo]] #### Parameters [[Rust][rust-core.RuntimeInfo-params]] @@ -508,67 +557,80 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. A set of state versions for all supported modules. +#### Result [[TypeScript][typescript-core.RuntimeInfo-result]] + + [rust-core.RuntimeInfo]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/mod.rs#L475-L486 [go-core.RuntimeInfo]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/core/core.go#L141-L149 +[typescript-core.RuntimeInfo]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/core.ts#L71-L73 [rust-core.RuntimeInfo-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/src/modules/core/types.rs#L11-L16 +[typescript-core.RuntimeInfo-result]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L28-L35 ## evm ### evm.Balance (query) {#evm-balance} -[[Rust][rust-evm.Balance] | [Go][go-evm.Balance]] +[[Rust][rust-evm.Balance] | [Go][go-evm.Balance] | [TypeScript][typescript-evm.Balance]] -#### Parameters [[Rust][rust-evm.Balance-params] | [Go][go-evm.Balance-params]] +#### Parameters [[Rust][rust-evm.Balance-params] | [Go][go-evm.Balance-params] | [TypeScript][typescript-evm.Balance-params]] - `address: H160` -[go-evm.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L117-L127 [rust-evm.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/lib.rs#L613-L616 -[rust-evm.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L31-L35 +[go-evm.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L117-L127 +[typescript-evm.Balance]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/evm.ts#L52-L54 [go-evm.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L30-L33 +[typescript-evm.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L426-L431 +[rust-evm.Balance-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L31-L35 ### evm.Call (call) {#evm-call} -[[Rust][rust-evm.Call] | [Go][go-evm.Call]] +[[Rust][rust-evm.Call] | [Go][go-evm.Call] | [TypeScript][typescript-evm.Call]] -#### Parameters [[Rust][rust-evm.Call-params] | [Go][go-evm.Call-params]] +#### Parameters [[Rust][rust-evm.Call-params] | [Go][go-evm.Call-params] | [TypeScript][typescript-evm.Call-params]] - `address: H160` - `value: U256` - `data: Vec` -[go-evm.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L73-L80 [rust-evm.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/lib.rs#L598-L601 +[go-evm.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L73-L80 +[typescript-evm.Call]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/evm.ts#L40-L42 [rust-evm.Call-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L10-L16 [go-evm.Call-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L12-L17 +[typescript-evm.Call-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L402-L409 ### evm.Code (query) {#evm-code} -[[Rust][rust-evm.Code] | [Go][go-evm.Code]] +[[Rust][rust-evm.Code] | [Go][go-evm.Code] | [TypeScript][typescript-evm.Code]] -#### Parameters [[Rust][rust-evm.Code-params] | [Go][go-evm.Code-params]] +#### Parameters [[Rust][rust-evm.Code-params] | [Go][go-evm.Code-params] | [TypeScript][typescript-evm.Code-params]] - `address: H160` [rust-evm.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/lib.rs#L608-L611 [go-evm.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L105-L115 -[go-evm.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L25-L28 +[typescript-evm.Code]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/evm.ts#L48-L50 [rust-evm.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L25-L29 +[go-evm.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L25-L28 +[typescript-evm.Code-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L419-L424 ### evm.Create (call) {#evm-create} -[[Rust][rust-evm.Create] | [Go][go-evm.Create]] +[[Rust][rust-evm.Create] | [Go][go-evm.Create] | [TypeScript][typescript-evm.Create]] -#### Parameters [[Rust][rust-evm.Create-params] | [Go][go-evm.Create-params]] +#### Parameters [[Rust][rust-evm.Create-params] | [Go][go-evm.Create-params] | [TypeScript][typescript-evm.Create-params]] - `value: U256` - `init_code: Vec` [rust-evm.Create]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/lib.rs#L593-L596 [go-evm.Create]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L65-L71 +[typescript-evm.Create]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/evm.ts#L36-L38 [rust-evm.Create-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L3-L8 [go-evm.Create-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L6-L10 +[typescript-evm.Create-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L394-L400 ### evm.SimulateCall (query) {#evm-simulatecall} -[[Rust][rust-evm.SimulateCall] | [Go][go-evm.SimulateCall]] +[[Rust][rust-evm.SimulateCall] | [Go][go-evm.SimulateCall] | [TypeScript][typescript-evm.SimulateCall]] -#### Parameters [[Rust][rust-evm.SimulateCall-params] | [Go][go-evm.SimulateCall-params]] +#### Parameters [[Rust][rust-evm.SimulateCall-params] | [Go][go-evm.SimulateCall-params] | [TypeScript][typescript-evm.SimulateCall-params]] - `gas_price: U256` - `gas_limit: u64` @@ -579,21 +641,25 @@ with references to Go, Rust and TypeScript bindings in Oasis SDK. [rust-evm.SimulateCall]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/lib.rs#L618-L632 [go-evm.SimulateCall]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L129-L144 +[typescript-evm.SimulateCall]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/evm.ts#L56-L58 +[typescript-evm.SimulateCall-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L433-L443 [rust-evm.SimulateCall-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L37-L46 [go-evm.SimulateCall-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L35-L43 ### evm.Storage (query) {#evm-storage} -[[Rust][rust-evm.Storage] | [Go][go-evm.Storage]] +[[Rust][rust-evm.Storage] | [Go][go-evm.Storage] | [TypeScript][typescript-evm.Storage]] -#### Parameters [[Rust][rust-evm.Storage-params] | [Go][go-evm.Storage-params]] +#### Parameters [[Rust][rust-evm.Storage-params] | [Go][go-evm.Storage-params] | [TypeScript][typescript-evm.Storage-params]] - `address: H160` - `index: H256` +[typescript-evm.Storage]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/evm.ts#L44-L46 [rust-evm.Storage]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/lib.rs#L603-L606 [go-evm.Storage]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/evm.go#L92-L103 [rust-evm.Storage-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/runtime-sdk/modules/evm/src/types.rs#L18-L23 [go-evm.Storage-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/go/modules/evm/types.go#L19-L23 +[typescript-evm.Storage-params]: https://github.com/oasisprotocol/oasis-sdk/tree/master/client-sdk/ts-web/rt/src/types.ts#L411-L417 diff --git a/tools/extract-runtime-txs/main.go b/tools/extract-runtime-txs/main.go index 4a06b1988e..fff6121e38 100644 --- a/tools/extract-runtime-txs/main.go +++ b/tools/extract-runtime-txs/main.go @@ -168,6 +168,7 @@ func doExtractRuntimeTxs(cmd *cobra.Command, args []string) { } parsers.PopulateGoRefs(transactions, viper.GetString(CfgCodebasePath)+"/client-sdk/go") + parsers.PopulateTypeScriptRefs(transactions, viper.GetString(CfgCodebasePath)+"/client-sdk/ts-web") if viper.GetBool(CfgMarkdown) { printMarkdown(transactions) @@ -181,6 +182,9 @@ func doExtractRuntimeTxs(cmd *cobra.Command, args []string) { for _, w := range parsers.GolangWarnings { fmt.Fprintln(os.Stderr, w) } + for _, w := range parsers.TypeScriptWarnings { + fmt.Fprintln(os.Stderr, w) + } } // extractValue returns string value of the identifier or literal. diff --git a/tools/extract-runtime-txs/parsers/typescript.go b/tools/extract-runtime-txs/parsers/typescript.go new file mode 100644 index 0000000000..c6c03a9e8c --- /dev/null +++ b/tools/extract-runtime-txs/parsers/typescript.go @@ -0,0 +1,164 @@ +package parsers + +import ( + "fmt" + "log" + "os" + "path/filepath" + "regexp" + "strings" + + "github.com/oasisprotocol/oasis-sdk/tools/extract-runtime-txs/types" +) + +var TypeScriptWarnings = []error{} + +type TypeScriptParser struct { + filename string + txs map[string]string + txParams map[string]string + txResults map[string]string +} + +func NewTypeScriptParser(filename string) TypeScriptParser { + return TypeScriptParser{ + filename: filename, + txs: map[string]string{}, + txParams: map[string]string{}, + txResults: map[string]string{}, + } +} + +func PopulateTypeScriptRefs(transactions map[string]types.Tx, searchDir string) error { + err := filepath.Walk(searchDir, func(path string, f os.FileInfo, err error) error { + if err != nil { + log.Fatal(err) + } + if f.IsDir() { + return nil + } + // Ts source files only, ignore types.ts, because we parse it indirectly. + if !strings.HasSuffix(f.Name(), ".ts") || f.Name() == "types.ts" { + return nil + } + tsParser := NewTypeScriptParser(path) + e := tsParser.populateTransactionRefs(transactions) + if e != nil { + return e + } + + return nil + }) + if err != nil { + return err + } + + return nil +} + +func (p *TypeScriptParser) populateTransactionRefs(txs map[string]types.Tx) error { + text, err := readFile(p.filename) + if err != nil { + return err + } + + // export const METHOD_SOME_METHOD = 'some_module.SomeMethod'; + regMethodMatch, _ := regexp.Compile("export const METHOD_.+ = '([a-zA-Z_\\.]+)'") + // callSomeMethod() { or querySomeMethod() { + regCallQueryMatch, _ := regexp.Compile(" (call|query)(.+)\\(\\) \\{") + // callSomeMethod() { or querySomeMethod() { + regTxTypesMatch, _ := regexp.Compile(" return this\\.(call|query)<(.+), (.+)>") + + // Collect name -> fullName of transactions in this file. + // Collect TxTypeName -> fullName of transaction params and results in the file. + for lineIdx := 0; lineIdx < len(text); lineIdx += 1 { + methodMatch := regMethodMatch.FindStringSubmatch(text[lineIdx]) + if len(methodMatch) > 0 { + fullNameSplit := strings.Split(methodMatch[1], ".") + _, found := txs[methodMatch[1]] + if !found { + TypeScriptWarnings = append(TypeScriptWarnings, fmt.Errorf("unknown method %s in file %s:%d", methodMatch[1], p.filename, lineIdx+1)) + } + p.txs[fullNameSplit[1]] = methodMatch[1] + } + + callQueryMatch := regCallQueryMatch.FindStringSubmatch(text[lineIdx]) + if len(callQueryMatch) == 3 { + fullName, valid := p.txs[callQueryMatch[2]] + if !valid { + TypeScriptWarnings = append(TypeScriptWarnings, fmt.Errorf("implementation of %s not defined as method in the beginning of %s", callQueryMatch[2], p.filename)) + continue + } + if _, valid = txs[fullName]; !valid { + continue + } + + txTypesMatch := regTxTypesMatch.FindStringSubmatch(text[lineIdx+1]) + if len(txTypesMatch) == 4 { + if strings.HasPrefix(txTypesMatch[2], "types.") { + name := strings.TrimPrefix(txTypesMatch[2], "types.") + p.txParams[name] = fullName + } + if strings.HasPrefix(txTypesMatch[3], "types.") { + name := strings.TrimPrefix(txTypesMatch[3], "types.") + p.txResults[name] = fullName + } + } + + _, lineFrom := findComment(text, lineIdx, " ") + lineTo, err := findEndBlock(text, lineIdx, " ", fullName) + if err != nil { + return err + } + txs[fullName].Ref[types.TypeScript] = types.Snippet{ + Path: p.filename, + LineFrom: lineFrom, + LineTo: lineTo, + } + } + } + + // Open types.ts of the same module and collect parameters and result snippets. + if len(p.txs) > 0 { + if err := p.populateParamsResultRefs(txs); err != nil { + return err + } + } + + return nil +} + +// populateParamsResultRefs opens types.ts file, finds corresponding parameters and results snippets +// for the provided transactions and populates the refs of global transactions. +func (p *TypeScriptParser) populateParamsResultRefs(txs map[string]types.Tx) error { + typesPath := filepath.Join(filepath.Dir(p.filename), "types.ts") + text, err := readFile(typesPath) + if err != nil { + return err + } + + regTypeMatch, _ := regexp.Compile("export interface ([a-zA-Z]+)") + for lineIdx := 0; lineIdx < len(text); lineIdx += 1 { + typeMatch := regTypeMatch.FindStringSubmatch(text[lineIdx]) + if len(typeMatch) > 0 { + _, lineFrom := findComment(text, lineIdx, "") + lineTo, err := findEndBlock(text, lineIdx, "", typeMatch[1]) + if err != nil { + return err + } + + snippet := types.Snippet{ + Path: typesPath, + LineFrom: lineFrom, + LineTo: lineTo, + } + if fullName, valid := p.txParams[typeMatch[1]]; valid { + txs[fullName].ParametersRef[types.TypeScript] = snippet + } else if fullName, valid := p.txResults[typeMatch[1]]; valid { + txs[fullName].ResultRef[types.TypeScript] = snippet + } + } + } + + return nil +} diff --git a/tools/extract-runtime-txs/parsers/typescript_test.go b/tools/extract-runtime-txs/parsers/typescript_test.go new file mode 100644 index 0000000000..307b19c2eb --- /dev/null +++ b/tools/extract-runtime-txs/parsers/typescript_test.go @@ -0,0 +1,60 @@ +package parsers + +import ( + "fmt" + "testing" + + "github.com/oasisprotocol/oasis-sdk/tools/extract-runtime-txs/types" + + "github.com/stretchr/testify/require" +) + +func TestPopulateTypeScriptRefs(t *testing.T) { + require := require.New(t) + + txs := map[string]types.Tx{ + "contracts.Upload": { + Module: "contracts", + Name: "Upload", + Comment: "", + Type: types.Call, + Ref: map[types.Lang]types.Snippet{}, + Parameters: []types.Parameter{}, + ParametersRef: make(map[types.Lang]types.Snippet), + Result: []types.Parameter{}, + ResultRef: map[types.Lang]types.Snippet{}, + }, + } + + tsParser := NewTypeScriptParser("../tests/typescript/contracts.ts") + err := tsParser.populateTransactionRefs(txs) + require.NoError(err) + fmt.Println(txs["contracts.Upload"].Ref) + require.Equal( + types.Snippet{ + Path: "../tests/typescript/contracts.ts", + LineFrom: 50, + LineTo: 52, + }, + txs["contracts.Upload"].Ref[types.TypeScript], + "check implementation reference from TypeScript source file", + ) + require.Equal( + types.Snippet{ + Path: "../tests/typescript/types.ts", + LineFrom: 474, + LineTo: 490, + }, + txs["contracts.Upload"].ParametersRef[types.TypeScript], + "check parameters reference from TypeScript source file", + ) + require.Equal( + types.Snippet{ + Path: "../tests/typescript/types.ts", + LineFrom: 492, + LineTo: 500, + }, + txs["contracts.Upload"].ResultRef[types.TypeScript], + "check result reference from TypeScript source file", + ) +} diff --git a/tools/extract-runtime-txs/parsers/utils.go b/tools/extract-runtime-txs/parsers/utils.go index 502cd91ee6..b8fb743e4f 100644 --- a/tools/extract-runtime-txs/parsers/utils.go +++ b/tools/extract-runtime-txs/parsers/utils.go @@ -31,14 +31,14 @@ func readFile(filename string) ([]string, error) { // extracts the content. If the comment is not found, the initial line is // returned + 1. func findComment(text []string, lineIdx int, indent string) (string, int) { - regMatchComment, _ := regexp.Compile(indent + "///? (.*)") + regMatchComment, _ := regexp.Compile(indent + "(///? |/\\*\\*| \\* | \\*/)(.*)") comment := "" for commentLine := lineIdx - 1; commentLine > 0; commentLine -= 1 { commentMatch := regMatchComment.FindStringSubmatch(text[commentLine]) if len(commentMatch) == 0 { break } - comment = commentMatch[1] + " " + comment + comment = commentMatch[2] + " " + comment lineIdx -= 1 } comment = strings.TrimSpace(comment) diff --git a/tools/extract-runtime-txs/tests/typescript/contracts.ts b/tools/extract-runtime-txs/tests/typescript/contracts.ts new file mode 100644 index 0000000000..961a119299 --- /dev/null +++ b/tools/extract-runtime-txs/tests/typescript/contracts.ts @@ -0,0 +1,63 @@ +import * as transaction from './transaction'; +import * as types from './types'; +import * as wrapper from './wrapper'; + +/** + * Unique module name. + */ +export const MODULE_NAME = 'contracts'; + +export const ERR_INVALID_ARGUMENT_CODE = 1; +export const ERR_CODE_TOO_LARGE_CODE = 2; +export const ERR_CODE_MALFORMED_CODE = 3; +export const ERR_UNSUPPORTED_ABI_CODE = 4; +export const ERR_CODE_MISSING_REQUIRED_EXPORT_CODE = 5; +export const ERR_CODE_DECLARES_RESERVED_EXPORT_CODE = 6; +export const ERR_CODE_DECLARES_START_FUNCTION_CODE = 7; +export const ERR_CODE_DECLARES_TOO_MANY_MEMORIES_CODE = 8; +export const ERR_CODE_NOT_FOUND_CODE = 9; +export const ERR_INSTANCE_NOT_FOUND_CODE = 10; +export const ERR_MODULE_LOADING_FAILED_CODE = 11; +export const ERR_EXECUTION_FAILED_CODE = 12; +export const ERR_FORBIDDEN_CODE = 13; +export const ERR_UNSUPPORTED_CODE = 14; +export const ERR_INSUFFICIENT_CALLER_BALANCE_CODE = 15; +export const ERR_CALL_DEPTH_EXCEEDED_CODE = 16; +export const ERR_RESULT_TOO_LARGE_CODE = 17; +export const ERR_TOO_MANY_SUBCALLS_CODE = 18; +export const ERR_CODE_ALREADY_UPGRADED_CODE = 19; + +// Callable methods. +export const METHOD_UPLOAD = 'contracts.Upload'; +export const METHOD_INSTANTIATE = 'contracts.Instantiate'; +export const METHOD_CALL = 'contracts.Call'; +export const METHOD_UPGRADE = 'contracts.Upgrade'; +// Queries. +export const METHOD_CODE = 'contracts.Code'; +export const METHOD_INSTANCE = 'contracts.Instance'; +export const METHOD_INSTANCE_STORAGE = 'contracts.InstanceStorage'; +export const METHOD_PUBLIC_KEY = 'contracts.PublicKey'; +export const METHOD_CUSTOM = 'contracts.Custom'; + +// Public key kind. +export const PUBLIC_KEY_KIND_TRANSACTION = 1; + +export class Wrapper extends wrapper.Base { + constructor(runtimeID: Uint8Array) { + super(runtimeID); + } + + callUpload() { + return this.call(METHOD_UPLOAD); + } +} + +/** + * Use this as a part of a {@link transaction.CallHandlers}. + */ +export type TransactionCallHandlers = { + [METHOD_UPLOAD]?: transaction.CallHandler; + [METHOD_INSTANTIATE]?: transaction.CallHandler; + [METHOD_CALL]?: transaction.CallHandler; + [METHOD_UPGRADE]?: transaction.CallHandler; +}; diff --git a/tools/extract-runtime-txs/tests/typescript/types.ts b/tools/extract-runtime-txs/tests/typescript/types.ts new file mode 100644 index 0000000000..b38a8689c4 --- /dev/null +++ b/tools/extract-runtime-txs/tests/typescript/types.ts @@ -0,0 +1,721 @@ +import * as oasis from '@oasisprotocol/client'; + +/** + * Arguments for the EstimateGas query. + */ +export interface CoreEstimateGasQuery { + caller?: CallerAddress; + tx: Transaction; +} + +/** + * Response to the call data public key query. + */ +export interface CoreCallDataPublicKeyQueryResponse { + /** + * Public key used for deriving the shared secret for encrypting call data. + */ + public_key: KeyManagerSignedPublicKey; +} + +/** + * Core module Gas used event. + */ +export interface CoreGasUsedEvent { + amount: oasis.types.longnum; +} + +/** + * Response to the RuntimeInfo query. + */ +export interface CoreRuntimeInfoQueryResponse { + runtime_version: oasis.types.Version; + state_version: number; + modules: {[key: string]: CoreModuleInfo}; +} + +/** + * Metadata for an individual module within the runtime. + */ +export interface CoreModuleInfo { + version: number; + params: any; + methods: CoreMethodHandlerInfo[]; +} + +export interface CoreMethodHandlerInfo { + name: string; + // Keep these in sync with the `METHODHANDLERKIND_*` constants. + kind: 'call' | 'query' | 'message_result'; +} + +/** + * Caller address. + */ +export interface CallerAddress { + address?: Uint8Array; + eth_address?: Uint8Array; +} + +// The below is imported from oasis-core (Rust), but it's never used from the oasis-node side. +// So I'm putting this here in the runtime package. +/** + * Signed public key. + */ +export interface KeyManagerSignedPublicKey { + /** + * Public key. + */ + key: Uint8Array; + /** + * Checksum of the key manager state. + */ + checksum: Uint8Array; + /** + * Sign(sk, (key || checksum)) from the key manager. + */ + signature: Uint8Array; +} + +/** + * Balances in an account. + */ +export interface AccountsAccountBalances { + balances: Map; +} + +/** + * Arguments for the Balances query. + */ +export interface AccountsBalancesQuery { + address: Uint8Array; +} + +export interface AccountsBurnEvent { + owner: Uint8Array; + amount: BaseUnits; +} + +export interface AccountsMintEvent { + owner: Uint8Array; + amount: BaseUnits; +} + +/** + * Arguments for the Nonce query. + */ +export interface AccountsNonceQuery { + address: Uint8Array; +} + +/** + * Arguments for the Addresses query. + */ +export interface AccountsAddressesQuery { + denomination: Uint8Array; +} + +/** + * Arguments for the DenominationInfo query. + */ +export interface AccountsDenominationInfoQuery { + denomination: Uint8Array; +} + +/** + * Information about a denomination. + */ +export interface AccountsDenominationInfo { + decimals: number; +} + +/** + * Transfer call. + */ +export interface AccountsTransfer { + to: Uint8Array; + amount: BaseUnits; +} + +export interface AccountsTransferEvent { + from: Uint8Array; + to: Uint8Array; + amount: BaseUnits; +} + +/** + * Parameters for the rewards module. + */ +export interface RewardsParameters { + schedule: RewardsRewardSchedule; + + participation_threshold_numerator: number; + participation_threshold_denominator: number; +} + +/** + * A reward schedule. + */ +export interface RewardsRewardSchedule { + steps: RewardsRewardStep[]; +} + +/** + * One of the time periods in the reward schedule. + */ +export interface RewardsRewardStep { + until: oasis.types.longnum; + amount: BaseUnits; +} + +/** + * Common information that specifies an address as well as how to authenticate. + */ +export interface AddressSpec { + /** + * For _signature_ authentication. + */ + signature?: SignatureAddressSpec; + /** + * For _multisig_ authentication. + */ + multisig?: MultisigConfig; +} + +/** + * Information for signature-based authentication and public key-based address derivation. + */ +export interface SignatureAddressSpec { + /** + * Ed25519 address derivation compatible with the consensus layer. + */ + ed25519?: Uint8Array; + /** + * Ethereum-compatible address derivation from Secp256k1 public keys. + */ + secp256k1eth?: Uint8Array; +} + +/** + * Transaction authentication information. + */ +export interface AuthInfo { + si: SignerInfo[]; + fee: Fee; +} + +/** + * A container for data that authenticates a transaction. + */ +export interface AuthProof { + /** + * For _signature_ authentication. + */ + signature?: Uint8Array; + /** + * For _multisig_ authentication. + */ + multisig?: Uint8Array[]; + /** + * A flag to use module-controlled decoding. The string is an encoding scheme name that a + * module must handle. When using this variant, the scheme name must not be empty. + */ + module?: string; +} + +/** + * Token amount of given denomination in base units. + */ +export type BaseUnits = [amount: Uint8Array, denomination: Uint8Array]; + +/** + * Format used for encoding the call (and output) information. + */ +export type CallFormat = number; + +/** + * Method call. + */ +export interface Call { + format?: CallFormat; + method: string; + body: unknown; +} + +/** + * Call result. + */ +export interface CallResult { + ok?: unknown; + fail?: FailedCallResult; + unknown?: Uint8Array; +} + +export interface FailedCallResult { + module: string; + code: number; + message?: string; +} + +/** + * Transaction fee. + */ +export interface Fee { + amount: BaseUnits; + gas: oasis.types.longnum; + consensus_messages: number; +} + +/** + * A multisig configuration. + * A set of signers with total "weight" greater than or equal to a "threshold" can authenticate + * for the configuration. + */ +export interface MultisigConfig { + /** + * The signers. + */ + signers: MultisigSigner[]; + /** + * The threshold. + */ + threshold: oasis.types.longnum; +} + +/** + * One of the signers in a multisig configuration. + */ +export interface MultisigSigner { + /** + * The public key of the signer. + */ + public_key: PublicKey; + /** + * The weight of the signer. + */ + weight: oasis.types.longnum; +} + +/** + * A public key used for signing. + */ +export interface PublicKey { + ed25519?: Uint8Array; + secp256k1?: Uint8Array; +} + +/** + * Transaction signer information. + */ +export interface SignerInfo { + address_spec: AddressSpec; + nonce: oasis.types.longnum; +} + +/** + * Transaction. + */ +export interface Transaction extends oasis.types.CBORVersioned { + call: Call; + ai: AuthInfo; +} + +/** + * An unverified signed transaction. + */ +export type UnverifiedTransaction = [body: Uint8Array, authProofs: AuthProof[]]; + +/** + * Parameters for the consensus module. + */ +export interface ConsensusParameters { + consensus_denomination: Uint8Array; + consensus_scaling_factor: oasis.types.longnum; +} + +/** + * Consensus deposit call. + */ +export interface ConsensusDeposit { + to?: Uint8Array; + amount: BaseUnits; +} + +/** + * Consensus withdraw call. + */ +export interface ConsensusWithdraw { + to?: Uint8Array; + amount: BaseUnits; +} + +/** + * Consensus balance query. + */ +export interface ConsensusBalanceQuery { + address: Uint8Array; +} + +/** + * Consensus account balance. + */ +export interface ConsensusAccountBalance { + balance: Uint8Array; +} + +/** + * Consensus account query. + */ +export interface ConsensusAccountQuery { + address: Uint8Array; +} + +export interface ConsensusAccountsConsensusError { + module?: string; + code: number; +} + +export interface ConsensusAccountsDepositEvent { + from: Uint8Array; + nonce: oasis.types.longnum; + to: Uint8Array; + amount: BaseUnits; + error?: ConsensusAccountsConsensusError; +} + +export interface ConsensusAccountsWithdrawEvent { + from: Uint8Array; + nonce: oasis.types.longnum; + to: Uint8Array; + amount: BaseUnits; + error?: ConsensusAccountsConsensusError; +} + +/** + * Transaction body for creating an EVM contract. + */ +export interface EVMCreate { + value: Uint8Array; + init_code: Uint8Array; +} + +/** + * Transaction body for calling an EVM contract. + */ +export interface EVMCall { + address: Uint8Array; + value: Uint8Array; + data: Uint8Array; +} + +/** + * Transaction body for peeking into EVM storage. + */ +export interface EVMStorageQuery { + address: Uint8Array; + index: Uint8Array; +} + +/** + * Transaction body for peeking into EVM code storage. + */ +export interface EVMCodeQuery { + address: Uint8Array; +} + +/** + * Transaction body for fetching EVM account's balance. + */ +export interface EVMBalanceQuery { + address: Uint8Array; +} + +/** + * Transaction body for simulating an EVM call. + */ +export interface EVMSimulateCallQuery { + gas_price: Uint8Array; + gas_limit: oasis.types.longnum; + caller: Uint8Array; + address: Uint8Array; + value: Uint8Array; + data: Uint8Array; +} + +export interface EVMLogEvent { + address: Uint8Array; + topics: Uint8Array[]; + data: Uint8Array; +} + +/** + * A call envelope when using the CALLFORMAT_ENCRYPTED_X25519DEOXYSII format. + */ +export interface CallEnvelopeX25519DeoxysII { + pk: Uint8Array; + nonce: Uint8Array; + data: Uint8Array; +} + +/** + * A result envelope when using the CALLFORMAT_ENCRYPTED_X25519DEOXYSII format. + */ +export interface ResultEnvelopeX25519DeoxysII { + nonce: Uint8Array; + data: Uint8Array; +} + +export interface ContractsPolicy { + nobody?: {}; + address?: Uint8Array; + everyone?: {}; +} + +/** + * Upload call. + */ +export interface ContractsUpload { + /** + * ABI. + */ + abi: number; + /** + * Who is allowed to instantiate this code. + */ + instantiate_policy: ContractsPolicy; + /** + * Compiled contract code. + */ + code: Uint8Array; +} + +/** + * Upload call result. + */ +export interface ContractsUploadResult { + /** + * Assigned code identifier. + */ + id: oasis.types.longnum; +} + +/** + * Instantiate call. + */ +export interface ContractsInstantiate { + /** + * Identifier of code used by the instance. + */ + code_id: oasis.types.longnum; + /** + * Who is allowed to upgrade this instance. + */ + upgrades_policy: ContractsPolicy; + /** + * Arguments to contract's instantiation function. + */ + data: Uint8Array; + /** + * Tokens that should be sent to the contract as part of the instantiate call. + */ + tokens: BaseUnits[]; +} + +/** + * Instantiate call result. + */ +export interface ContractsInstantiateResult { + /** + * Assigned instance identifier. + */ + id: oasis.types.longnum; +} + +/** + * Contract call. + */ +export interface ContractsCall { + /** + * Instance identifier. + */ + id: oasis.types.longnum; + /** + * Call arguments. + */ + data: Uint8Array; + /** + * Tokens that should be sent to the contract as part of the call. + */ + tokens: BaseUnits[]; +} + +/** + * Upgrade call. + */ +export interface ContractsUpgrade { + /** + * Instance identifier. + */ + id: oasis.types.longnum; + /** + * Updated code identifier. + */ + code_id: oasis.types.longnum; + /** + * Arguments to contract's upgrade function. + */ + data: Uint8Array; + /** + * Tokens that should be sent to the contract as part of the call. + */ + tokens: BaseUnits[]; +} + +/** + * Code information query. + */ +export interface ContractsCodeQuery { + /** + * Code identifier. + */ + id: oasis.types.longnum; +} + +/** + * Stored code information. + */ +export interface ContractsCode { + /** + * Unique code identifier. + */ + id: oasis.types.longnum; + /** + * Code hash. + */ + hash: Uint8Array; + /** + * ABI. + */ + abi: number; + /** + * Code uploader address. + */ + uploader: Uint8Array; + /** + * Who is allowed to instantiate this code. + */ + instantiate_policy: ContractsPolicy; +} + +/** + * Instance information query. + */ +export interface ContractsInstanceQuery { + /** + * Instance identifier. + */ + id: oasis.types.longnum; +} + +/** + * Deployed code instance information. + */ +export interface ContractsInstance { + /** + * Unique instance identifier. + */ + id: oasis.types.longnum; + /** + * Identifier of code used by the instance. + */ + code_id: oasis.types.longnum; + /** + * Instance creator address. + */ + creator: Uint8Array; + /** + * Who is allowed to upgrade this instance. + */ + upgrades_policy: ContractsPolicy; +} + +/** + * Instance storage query. + */ +export interface ContractsInstanceStorageQuery { + /** + * Instance identifier. + */ + id: oasis.types.longnum; + /** + * Storage key. + */ + key: Uint8Array; +} + +export interface ContractsInstanceStorageQueryResult { + /** + * Storage value or `None` if key doesn't exist. + */ + value: Uint8Array | null; +} + +/** + * Public key query. + */ +export interface ContractsPublicKeyQuery { + /** + * Instance identifier. + */ + id: oasis.types.longnum; + /** + * Kind of public key. + */ + kind: number; +} + +/** + * Public key query result. + */ +export interface ContractsPublicKeyQueryResult { + /** + * Public key. + */ + key: Uint8Array; + /** + * Checksum of the key manager state. + */ + checksum: Uint8Array; + /** + * Sign(sk, (key || checksum)) from the key manager. + */ + signature: Uint8Array; +} + +/** + * Custom contract query. + */ +export interface ContractsCustomQuery { + /** + * Instance identifier. + */ + id: oasis.types.longnum; + /** + * Query arguments. + */ + data: Uint8Array; +} + +/** + * An event emitted from a contract, wrapped to include additional metadata. + */ +export interface ContractsContractEvent { + /** + * Identifier of the instance that emitted the event. + */ + id: oasis.types.longnum; + /** + * Raw event data emitted by the instance. + */ + data?: Uint8Array; +}