Skip to content

Commit

Permalink
Update Abi
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciXie committed Nov 22, 2018
1 parent 9537cad commit 034036d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Abi.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const Abi = {
"base": "",
"fields": {
"contract": "string",
"contract_abi": "bytes"
"contract_abi": "bytes",
"filetype": "string"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bottos-sdk-js",
"version": "0.2.5",
"version": "0.2.6",
"main": "index.js",
"typings": "./index.d.ts",
"files": [
Expand Down
11 changes: 9 additions & 2 deletions src/contractFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function contractFactory(Tool) {
* @function Contract.deployABI
* @param {Object} param
* @param {(string|Uint8Array|ArrayBuffer)} param.contract_abi - ABI content or file buffer.
* @param {string} [param.filetype=js] - ABI file type, js or wasm. Default is js.
* @param {Object} senderInfo - The sender
* @param {string} senderInfo.account - sender's account
* @param {string|Buffer} senderInfo.privateKey - sender's privateKey
Expand All @@ -63,16 +64,22 @@ function contractFactory(Tool) {
code = BasicPack.PackStr16(code).slice(3)
} else if (code instanceof ArrayBuffer) {
code = new Uint8Array(code)
} else if (!(code instanceof Uint8Array)) {
console.warn('Type error. param contract_abi: ' + param.contract_abi + ' could not be transcode to Uint8Array')
}

console.assert(code instanceof Uint8Array, 'Type error. param contract_abi: ' + param.contract_abi + ' could not be transcode to Uint8Array')
let filetype = param.filetype || 'js'
if (filetype != 'js' && filetype != 'wasm') {
console.error('Params error, the value of filetype must be "js" or "wasm".')
}

let params = {
sender: senderInfo.account,
method: "deployabi",
param: {
contract: senderInfo.account,
contract_abi: code
contract_abi: code,
filetype
}
}

Expand Down

0 comments on commit 034036d

Please sign in to comment.