diff --git a/es/account/index.js b/es/account/index.js index 802efae919..2f64b9c4a2 100644 --- a/es/account/index.js +++ b/es/account/index.js @@ -30,11 +30,6 @@ import { TX_TYPE } from '../tx/builder/schema' const DEFAULT_NETWORK_ID = `ae_mainnet` -export const ADDRESS_FORMAT = { - sophia: 1, - api: 2, - raw: 3 -} /** * Sign encoded transaction * @instance @@ -74,11 +69,6 @@ const Account = stampit({ if (!this.networkId && networkId) { this.networkId = networkId } - // Add address formatter - this.getAddress = this.address - this.address = async function (format) { - return Crypto.formatAddress(format, await this.getAddress()) - } }, methods: { signTransaction }, deepConf: { diff --git a/es/account/memory.js b/es/account/memory.js index 60a66666ee..5f3abbb23e 100644 --- a/es/account/memory.js +++ b/es/account/memory.js @@ -31,8 +31,8 @@ async function sign (data) { return Promise.resolve(Crypto.sign(data, secrets.get(this).secretKey)) } -async function address () { - return Promise.resolve(secrets.get(this).publicKey) +async function address (format = Crypto.ADDRESS_FORMAT.api) { + return Promise.resolve(Crypto.formatAddress(format, secrets.get(this).publicKey)) } /** diff --git a/es/ae/aepp.js b/es/ae/aepp.js index c911f75e73..268e5c2aee 100644 --- a/es/ae/aepp.js +++ b/es/ae/aepp.js @@ -24,7 +24,7 @@ import Ae from './' import Aens from './aens' -import Contract from './contract' +import { Contract } from './contract' import Rpc from '../rpc/client' /** diff --git a/es/ae/contract.js b/es/ae/contract.js index 4e49443b8f..da08c3c52d 100644 --- a/es/ae/contract.js +++ b/es/ae/contract.js @@ -32,6 +32,7 @@ import * as R from 'ramda' import { isBase64 } from '../utils/crypto' import ContractCompilerAPI from '../contract/compiler' import ContractACI from '../contract/aci' +import ContractBase from '../contract' /** * Handle contract call error @@ -228,7 +229,7 @@ async function contractCompile (source, options = {}) { * @param {Object} [options={}] - Initializer object * @return {Object} Contract instance */ -const Contract = Ae.compose(ContractACI, ContractCompilerAPI, { +export const Contract = Ae.compose(ContractBase, ContractACI, { methods: { contractCompile, contractCallStatic, @@ -252,4 +253,6 @@ const Contract = Ae.compose(ContractACI, ContractCompilerAPI, { } }) -export default Contract +export const ContractWithCompiler = Contract.compose(ContractCompilerAPI) + +export default ContractWithCompiler diff --git a/es/contract/index.js b/es/contract/index.js index f0318476d0..cdfcc7a40f 100644 --- a/es/contract/index.js +++ b/es/contract/index.js @@ -43,7 +43,8 @@ const ContractBase = stampit({ methods: [ 'contractEncodeCallDataAPI', 'contractDecodeDataAPI', - 'compileContractAPI' + 'compileContractAPI', + 'contractGetACI' ] } } @@ -51,7 +52,8 @@ const ContractBase = stampit({ methods: { contractEncodeCallDataAPI: required, contractDecodeDataAPI: required, - compileContractAPI: required + compileContractAPI: required, + contractGetACI: required } })) diff --git a/es/utils/crypto.js b/es/utils/crypto.js index 2e2afad73b..41472579b1 100644 --- a/es/utils/crypto.js +++ b/es/utils/crypto.js @@ -28,7 +28,6 @@ import nacl from 'tweetnacl' import aesjs from 'aes-js' import { leftPad, rightPad, toBytes } from './bytes' import shajs from 'sha.js' -import { ADDRESS_FORMAT } from '../account' import { decode as decodeNode } from '../tx/builder/helpers' const Ecb = aesjs.ModeOfOperation.ecb @@ -46,6 +45,12 @@ export function isBase64 (str) { return !!(index === -1 || str.slice(index).match(/={1,2}/)) } +export const ADDRESS_FORMAT = { + sophia: 1, + api: 2, + raw: 3 +} + /** * Format account address * @rtype (format: String, address: String) => tx: Promise[String] diff --git a/es/utils/http.js b/es/utils/http.js index 5bec3702ac..812bbf6c0c 100644 --- a/es/utils/http.js +++ b/es/utils/http.js @@ -52,7 +52,6 @@ const processResponse = async (res) => { const Http = stampit({ init ({ baseUrl }) { - if (!baseUrl) console.warn('You need to provider base url.') this.baseUrl = baseUrl }, methods: { diff --git a/examples/connect-two-ae/aepp/src/components/Home.vue b/examples/connect-two-ae/aepp/src/components/Home.vue index 88fa5d9a7b..28caf24457 100644 --- a/examples/connect-two-ae/aepp/src/components/Home.vue +++ b/examples/connect-two-ae/aepp/src/components/Home.vue @@ -114,7 +114,7 @@ export default { type state = () function main(x : int) = x`, byteCode: null, - contractInitState: '()', + contractInitState: [], deployInfo: null } }, @@ -134,19 +134,19 @@ export default { async deploy (code, options = {}) { console.log(`Deploying contract...`) try { - return await this.client.contractDeploy(this.byteCode, this.abi, { initState: this.contractInitState, options }) + return await this.client.contractDeploy(this.byteCode, this.contractCode, this.contractInitState, options) } catch (err) { this.deployErr = err console.error(err) } }, - async call (code, abi, contractAddress, method = 'main', returnType = 'int', args = '(5)', options = {}) { + async call (code, abi, contractAddress, method = 'main', returnType = 'int', args = ['5'], options = {}) { console.log(`Deploying contract...`) try { - const { result } = await this.client.contractCall(this.byteCode, this.abi, this.deployInfo.address, method, { args: args, options }) + const result = await this.client.contractCall(this.contractCode, this.deployInfo.address, method, args, options) return Object.assign( result, - { decodedRes: await this.client.contractDecodeData(returnType, result.returnValue) } + { decodedRes: await result.decode(returnType) } ) } catch (err) { this.deployErr = err @@ -181,12 +181,6 @@ export default { this.pub = address }) .catch(e => { this.pub = `Rejected: ${e}` }) - // // AENS - // ae.aensPreclaim(`test${Math.floor(Math.random() * 101)}.test`) - // .then(name => { return name.claim() }) - // .then(name => { return name.update('ak_bAxmQLxXv8UnVEKfHpvDwp8qEsrVE3tnezBffLdtVMVKP6GC2') }) - // .then(name => { return name.revoke() }) - // .catch(e => {debugger}) }) } } diff --git a/examples/connect-two-ae/identity/src/components/Home.vue b/examples/connect-two-ae/identity/src/components/Home.vue index 4554a89320..2196ae4fb3 100644 --- a/examples/connect-two-ae/identity/src/components/Home.vue +++ b/examples/connect-two-ae/identity/src/components/Home.vue @@ -54,8 +54,9 @@ export default { wallet: null, balance: null, height: null, - url: 'https://sdk-mainnet.aepps.com', - internalUrl: 'https://sdk-mainnet.aepps.com', + url: 'http://localhost:3013', + internalUrl: 'http://localhost:3113', + compilerUrl: 'https://compiler.aepps.com', aeppUrl: '//0.0.0.0:9001' } }, @@ -73,6 +74,7 @@ export default { Wallet({ url: this.url, internalUrl: this.internalUrl, + compilerUrl: this.compilerUrl, accounts: [MemoryAccount({keypair: {secretKey: this.priv, publicKey: this.pub}})], address: this.pub, onTx: this.confirmDialog, diff --git a/test/integration/index.js b/test/integration/index.js index 23c36b19c1..1d84426463 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -14,6 +14,7 @@ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ + import Ae from '../../es/ae/universal' import * as Crypto from '../../es/utils/crypto' import { BigNumber } from 'bignumber.js'