s/contract/contracts/ (#1036)

* s/contract/contracts/

* Derive rename
This commit is contained in:
Jaco Greeff
2019-06-19 21:12:16 +02:00
committed by GitHub
parent 7b461e7f21
commit 7023214581
8 changed files with 25 additions and 21 deletions
+1
View File
@@ -2,6 +2,7 @@
- **Breaking change** The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
- **Breaking change** `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally u64) and WASM (always u32) code. Use one of the `u32` or `u64` types explicitly.
- **Breaking change** `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feture detection is used so it supports both 1.x and 2.x chains)
- Update with latest substrate 2.x types
# 0.81.1
+1 -1
View File
@@ -26,7 +26,7 @@
"@babel/core": "^7.4.5",
"@babel/register": "^7.4.4",
"@babel/runtime": "^7.4.5",
"@polkadot/dev": "^0.30.0-beta.14",
"@polkadot/dev": "^0.30.0-beta.15",
"@polkadot/ts": "^0.1.60",
"gh-pages": "^2.0.1"
}
+1 -1
View File
@@ -7,7 +7,7 @@ import { Abi } from '@polkadot/api-contract';
const abi = new Abi(<...JSON ABI...>);
api.tx.contract
api.tx.contracts
.call(<contract addr>, <value>, <max gas>, abi.messages.<method name>(<...params...>))
.signAndSend(<keyring pair>, (result: SubmittableResult) => { ... });
```
@@ -16,17 +16,20 @@ import { drr } from '../util/drr';
*/
export function fees (api: ApiInterface$Rx) {
return (): Observable<DerivedContractFees> => {
const queryBase = api.query.contracts || api.query.contract;
// FIXME A numnber of these are being moved https://github.com/paritytech/substrate/pull/2883
return (api.queryMulti([
api.query.contract.callBaseFee,
api.query.contract.contractFee,
api.query.contract.createBaseFee,
api.query.contract.creationFee,
api.query.contract.rentByteFee,
api.query.contract.rentDepositOffset,
api.query.contract.transactionBaseFee,
api.query.contract.transactionByteFee,
api.query.contract.transferFee,
api.query.contract.tombstoneDeposit
queryBase.callBaseFee,
queryBase.contractFee,
queryBase.createBaseFee,
queryBase.creationFee,
queryBase.rentByteFee,
queryBase.rentDepositOffset,
queryBase.transactionBaseFee,
queryBase.transactionByteFee,
queryBase.transferFee,
queryBase.tombstoneDeposit
]) as any as Observable<Array<BN>>).pipe(
map(([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, transactionBaseFee, transactionByteFee, transferFee, tombstoneDeposit]) => ({
callBaseFee,
+2 -2
View File
@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
import * as accounts from './accounts';
import * as balances from './balances';
import * as chain from './chain';
import * as contract from './contract';
import * as contracts from './contracts';
import * as democracy from './democracy';
import * as session from './session';
import * as staking from './staking';
@@ -59,7 +59,7 @@ function injectFunctions<AllSections> (api: ApiInterface$Rx, allSections: AllSec
}, {} as DeriveSections<AllSections>);
}
export const derive = { accounts, balances, chain, contract, democracy, session, staking };
export const derive = { accounts, balances, chain, contracts, democracy, session, staking };
export type Derive = typeof derive;
export default function decorateDerive (api: ApiInterface$Rx, custom: DeriveCustom = {}) {
@@ -46,7 +46,7 @@ describe.skip('Promise e2e contracts', () => {
it('allows putCode', (done) => {
return (
api.tx.contract
api.tx.contracts
.putCode(MAX_GAS, `0x${flipperCode}`)
.signAndSend(keyring.eve, (result: SubmittableResult) => {
console.error('putCode', JSON.stringify(result));
@@ -68,7 +68,7 @@ describe.skip('Promise e2e contracts', () => {
expect(codeHash).toBeDefined();
return (
api.tx.contract
api.tx.contracts
.create(12345, MAX_GAS, codeHash, abi.deploy())
.signAndSend(keyring.bob, (result: SubmittableResult) => {
console.error('create', JSON.stringify(result));
@@ -90,7 +90,7 @@ describe.skip('Promise e2e contracts', () => {
expect(address).toBeDefined();
return (
api.tx.contract
api.tx.contracts
.call(address, 12345, MAX_GAS, abi.messages.flip())
.signAndSend(keyring.bob, (result: SubmittableResult) => {
console.error('call', JSON.stringify(result));
+4 -4
View File
@@ -1764,10 +1764,10 @@
universal-user-agent "^2.0.0"
url-template "^2.0.8"
"@polkadot/dev@^0.30.0-beta.14":
version "0.30.0-beta.14"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.30.0-beta.14.tgz#25ed5a03f91c63f353a35abd73586f92dffbba2d"
integrity sha512-G3r0wf9I1yKxtG8k5oSY4+916XX9SXO/4INRbQiK8mUomhJO8N80BXfKNJfaHHZMkFxwGcgS/WgfVIiBKYYTDQ==
"@polkadot/dev@^0.30.0-beta.15":
version "0.30.0-beta.15"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.30.0-beta.15.tgz#be01c44c27d2234a3471f4c8795c8307a6a5aa7a"
integrity sha512-4FY/xiunongOQiwSN4PXOME5xdqJQUnr5KKCia3DwxA8bQ7baQhUfi10SR/dklu4HNRFMHLiAd1plMUC2cHT/g==
dependencies:
"@babel/cli" "^7.4.4"
"@babel/core" "^7.4.5"