Skip to content

Commit

Permalink
refactor(contract)!: remove deprecated contractCall
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jan 28, 2022
1 parent 4535c07 commit c079e6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 38 deletions.
27 changes: 0 additions & 27 deletions src/ae/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,6 @@ async function contractCallStatic (source, contractAddress, name, args = [], opt
return contract.call(name, args, { ...options, callStatic: true })
}

/**
* Call contract function
* @function
* @alias module:@aeternity/aepp-sdk/es/ae/contract
* @category async
* @deprecated
* @param {String} source Contract source code
* @param {String} contractAddress Contract address or AENS name
* @param {String} name Name of function to call
* @param {Array} args Arguments array for call/deploy transaction
* @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
* @param {Object} [options.filesystem] Contract external namespaces map
* @return {Promise<Object>} Result object
* @example
* const callResult = await client.contractCall(source, address, fnName, args = [], options)
* {
* hash: TX_HASH,
* result: TX_DATA,
* decode: (type) => Decode call result
* }
*/
async function contractCall (source, contractAddress, name, args, options) {
const contract = await this.getContractInstance({ ...options, source, contractAddress })
return contract.call(name, args, options)
}

/**
* Deploy contract to the node
* @function
Expand Down Expand Up @@ -245,7 +219,6 @@ export default Ae.compose(ContractCompilerHttp, {
contractCompile,
contractCallStatic,
contractDeploy,
contractCall,
// Delegation for contract
delegateSignatureCommon,
// AENS
Expand Down
4 changes: 2 additions & 2 deletions src/contract/aci.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export default async function getContractInstance ({
rawTx,
txData,
address: contractId,
call: (name, args, options) =>
this.contractCall(instance.source, contractId, name, args, { ...opt, ...options }),
call: (name, args = [], options) =>
instance.methods[name].send(...args, { ...opt, ...options }),
callStatic: (name, args, options) =>
this.contractCallStatic(instance.source, contractId, name, args, { ...opt, ...options }),
createdAt: new Date()
Expand Down
17 changes: 8 additions & 9 deletions test/integration/aens.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ describe('Aens', function () {
})

it('Call contract using AENS name', async () => {
const identityContract =
'contract Identity =\n' +
const source =
'contract Identity =' +
' entrypoint getArg(x : int) = x'
const bytecode = await sdk.contractCompile(identityContract)
const deployed = await bytecode.deploy([])
const contract = await sdk.getContractInstance({ source })
await contract.deploy([])
const nameObject = await sdk.aensQuery(name)
await nameObject.update({ contract_pubkey: deployed.address })
const callRes = await sdk.contractCall(identityContract, name, 'getArg', [1])
const callResStatic = await sdk.contractCallStatic(identityContract, name, 'getArg', [1])
callResStatic.result.returnType.should.be.equal('ok')
callRes.hash.split('_')[0].should.be.equal('th')
await nameObject.update({ contract_pubkey: contract.deployInfo.address })

const contractByName = await sdk.getContractInstance({ source, contractAddress: name })
expect((await contractByName.methods.getArg(42)).decodedResult).to.be.equal(42n)
})

const address = generateKeyPair().publicKey
Expand Down

0 comments on commit c079e6e

Please sign in to comment.