diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c943789d..62c2095bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 4b4c0eb8cc..701776f4a5 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/packages/api-contract/README.md b/packages/api-contract/README.md index 46f70ad392..0effeb787a 100644 --- a/packages/api-contract/README.md +++ b/packages/api-contract/README.md @@ -7,7 +7,7 @@ import { Abi } from '@polkadot/api-contract'; const abi = new Abi(<...JSON ABI...>); -api.tx.contract +api.tx.contracts .call(, , , abi.messages.(<...params...>)) .signAndSend(, (result: SubmittableResult) => { ... }); ``` diff --git a/packages/api-derive/src/contract/fees.ts b/packages/api-derive/src/contracts/fees.ts similarity index 70% rename from packages/api-derive/src/contract/fees.ts rename to packages/api-derive/src/contracts/fees.ts index f4a83b6722..d85409e82f 100644 --- a/packages/api-derive/src/contract/fees.ts +++ b/packages/api-derive/src/contracts/fees.ts @@ -16,17 +16,20 @@ import { drr } from '../util/drr'; */ export function fees (api: ApiInterface$Rx) { return (): Observable => { + 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>).pipe( map(([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, transactionBaseFee, transactionByteFee, transferFee, tombstoneDeposit]) => ({ callBaseFee, diff --git a/packages/api-derive/src/contract/index.ts b/packages/api-derive/src/contracts/index.ts similarity index 100% rename from packages/api-derive/src/contract/index.ts rename to packages/api-derive/src/contracts/index.ts diff --git a/packages/api-derive/src/index.ts b/packages/api-derive/src/index.ts index b864d31b2d..bfcf4c73c9 100644 --- a/packages/api-derive/src/index.ts +++ b/packages/api-derive/src/index.ts @@ -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 (api: ApiInterface$Rx, allSections: AllSec }, {} as DeriveSections); } -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 = {}) { diff --git a/packages/api/test/e2e/promise-contract.spec.ts b/packages/api/test/e2e/promise-contract.spec.ts index fc8f7f77ac..3924b9c9ea 100644 --- a/packages/api/test/e2e/promise-contract.spec.ts +++ b/packages/api/test/e2e/promise-contract.spec.ts @@ -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)); diff --git a/yarn.lock b/yarn.lock index 5bd9ed0877..ab89219323 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"