@zilliqa-js/contract
Advanced tools
Comparing version 0.8.9 to 0.9.0
@@ -57,2 +57,3 @@ import { Transaction, Wallet } from '@zilliqa-js/account'; | ||
deploy(params: DeployParams, attempts?: number, interval?: number, toDs?: boolean): Promise<[Transaction, Contract]>; | ||
callWithoutConfirm(transition: string, args: Value[], params: CallParams, toDs?: boolean): Promise<Transaction>; | ||
/** | ||
@@ -59,0 +60,0 @@ * call |
@@ -203,2 +203,35 @@ "use strict"; | ||
}; | ||
Contract.prototype.callWithoutConfirm = function (transition, args, params, toDs) { | ||
if (toDs === void 0) { toDs = false; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var data, tx, err_3; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = { | ||
_tag: transition, | ||
params: args, | ||
}; | ||
if (this.error) { | ||
return [2 /*return*/, Promise.reject(this.error)]; | ||
} | ||
if (!this.address) { | ||
return [2 /*return*/, Promise.reject('Contract has not been deployed!')]; | ||
} | ||
tx = new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, 0 /* Initialised */, toDs); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.prepare(tx)]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, tx]; | ||
case 3: | ||
err_3 = _a.sent(); | ||
throw err_3; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -216,3 +249,3 @@ * call | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var data, err_3; | ||
var data, err_4; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -237,4 +270,4 @@ switch (_a.label) { | ||
case 3: | ||
err_3 = _a.sent(); | ||
throw err_3; | ||
err_4 = _a.sent(); | ||
throw err_4; | ||
case 4: return [2 /*return*/]; | ||
@@ -241,0 +274,0 @@ } |
@@ -262,2 +262,35 @@ import { Transaction, util } from '@zilliqa-js/account'; | ||
}; | ||
Contract.prototype.callWithoutConfirm = function (transition, args, params, toDs) { | ||
if (toDs === void 0) { toDs = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, tx, err_3; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = { | ||
_tag: transition, | ||
params: args, | ||
}; | ||
if (this.error) { | ||
return [2 /*return*/, Promise.reject(this.error)]; | ||
} | ||
if (!this.address) { | ||
return [2 /*return*/, Promise.reject('Contract has not been deployed!')]; | ||
} | ||
tx = new Transaction(__assign(__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, 0 /* Initialised */, toDs); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.prepare(tx)]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, tx]; | ||
case 3: | ||
err_3 = _a.sent(); | ||
throw err_3; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -275,3 +308,3 @@ * call | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, err_3; | ||
var data, err_4; | ||
return __generator(this, function (_a) { | ||
@@ -296,4 +329,4 @@ switch (_a.label) { | ||
case 3: | ||
err_3 = _a.sent(); | ||
throw err_3; | ||
err_4 = _a.sent(); | ||
throw err_4; | ||
case 4: return [2 /*return*/]; | ||
@@ -300,0 +333,0 @@ } |
@@ -264,2 +264,35 @@ (function (global, factory) { | ||
}; | ||
Contract.prototype.callWithoutConfirm = function (transition, args, params, toDs) { | ||
if (toDs === void 0) { toDs = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, tx, err_3; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = { | ||
_tag: transition, | ||
params: args, | ||
}; | ||
if (this.error) { | ||
return [2 /*return*/, Promise.reject(this.error)]; | ||
} | ||
if (!this.address) { | ||
return [2 /*return*/, Promise.reject('Contract has not been deployed!')]; | ||
} | ||
tx = new account.Transaction(__assign(__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, 0 /* Initialised */, toDs); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.prepare(tx)]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, tx]; | ||
case 3: | ||
err_3 = _a.sent(); | ||
throw err_3; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -277,3 +310,3 @@ * call | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, err_3; | ||
var data, err_4; | ||
return __generator(this, function (_a) { | ||
@@ -298,4 +331,4 @@ switch (_a.label) { | ||
case 3: | ||
err_3 = _a.sent(); | ||
throw err_3; | ||
err_4 = _a.sent(); | ||
throw err_4; | ||
case 4: return [2 /*return*/]; | ||
@@ -302,0 +335,0 @@ } |
{ | ||
"name": "@zilliqa-js/contract", | ||
"version": "0.8.9", | ||
"version": "0.9.0", | ||
"description": "Contract-related functionality.", | ||
@@ -28,7 +28,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@zilliqa-js/account": "0.8.9", | ||
"@zilliqa-js/blockchain": "0.8.9", | ||
"@zilliqa-js/core": "0.8.9", | ||
"@zilliqa-js/crypto": "0.8.9", | ||
"@zilliqa-js/util": "0.8.8", | ||
"@zilliqa-js/account": "0.9.0", | ||
"@zilliqa-js/blockchain": "0.9.0", | ||
"@zilliqa-js/core": "0.9.0", | ||
"@zilliqa-js/crypto": "0.9.0", | ||
"@zilliqa-js/util": "0.9.0", | ||
"hash.js": "^1.1.5", | ||
@@ -40,3 +40,3 @@ "utility-types": "^2.1.0" | ||
}, | ||
"gitHead": "e2c15537bad7337f20382e5bc077f3a9aa6d501f" | ||
"gitHead": "cea5f0ce19eeaf37dfba1754a7b406c4bbb3c2f3" | ||
} |
@@ -253,2 +253,40 @@ // This file is part of Zilliqa-Javascript-Library. | ||
async callWithoutConfirm( | ||
transition: string, | ||
args: Value[], | ||
params: CallParams, | ||
toDs: boolean = false, | ||
): Promise<Transaction> { | ||
const data = { | ||
_tag: transition, | ||
params: args, | ||
}; | ||
if (this.error) { | ||
return Promise.reject(this.error); | ||
} | ||
if (!this.address) { | ||
return Promise.reject('Contract has not been deployed!'); | ||
} | ||
const tx = new Transaction( | ||
{ | ||
...params, | ||
toAddr: this.address, | ||
data: JSON.stringify(data), | ||
}, | ||
this.provider, | ||
TxStatus.Initialised, | ||
toDs, | ||
); | ||
try { | ||
await this.prepare(tx); | ||
return tx; | ||
} catch (err) { | ||
throw err; | ||
} | ||
} | ||
/** | ||
@@ -255,0 +293,0 @@ * call |
@@ -516,2 +516,102 @@ import { Wallet } from '@zilliqa-js/account'; | ||
it('should be able to call a transition without confirmation', async () => { | ||
const responses = [ | ||
{ | ||
id: 1, | ||
jsonrpc: '2.0', | ||
result: { | ||
balance: 888, | ||
nonce: 1, | ||
}, | ||
}, | ||
{ | ||
id: 1, | ||
jsonrpc: '2.0', | ||
result: { | ||
TranID: 'some_hash', | ||
}, | ||
}, | ||
{ | ||
id: 1, | ||
jsonrpc: '2.0', | ||
result: { | ||
ID: 'some_hash', | ||
senderPubKey: | ||
'0314738163B9BB67AD11AA464FE69A1147DF263E8970D7DCFD8F993DDD39E81BD9', | ||
receipt: { | ||
success: true, | ||
cumulative_gas: 1000, | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: 1, | ||
jsonrpc: '2.0', | ||
result: { | ||
balance: 888, | ||
nonce: 2, | ||
}, | ||
}, | ||
{ | ||
id: 1, | ||
jsonrpc: '2.0', | ||
result: { | ||
TranID: 'some_hash', | ||
}, | ||
}, | ||
{ | ||
id: 1, | ||
jsonrpc: '2.0', | ||
result: { | ||
ID: 'some_hash', | ||
senderPubKey: | ||
'0314738163B9BB67AD11AA464FE69A1147DF263E8970D7DCFD8F993DDD39E81BD9', | ||
receipt: { | ||
success: true, | ||
cumulative_gas: 1000, | ||
}, | ||
}, | ||
}, | ||
].map((res) => [JSON.stringify(res)] as [string]); | ||
fetch.mockResponses(...responses); | ||
const [, contract] = await contractFactory | ||
.new( | ||
testContract, | ||
[ | ||
{ | ||
vname: 'contractOwner', | ||
type: 'ByStr20', | ||
value: '0x124567890124567890124567890124567890', | ||
}, | ||
{ vname: 'name', type: 'String', value: 'NonFungibleToken' }, | ||
{ vname: 'symbol', type: 'String', value: 'NFT' }, | ||
], | ||
abi, | ||
) | ||
.deploy({ | ||
version: VERSION, | ||
gasPrice: new BN(1000), | ||
gasLimit: Long.fromNumber(1000), | ||
}); | ||
const callTx = await contract.callWithoutConfirm( | ||
'myTransition', | ||
[ | ||
{ vname: 'param_1', type: 'String', value: 'hello' }, | ||
{ vname: 'param_2', type: 'String', value: 'world' }, | ||
], | ||
{ | ||
version: VERSION, | ||
amount: new BN(0), | ||
gasPrice: new BN(1000), | ||
gasLimit: Long.fromNumber(1000), | ||
}, | ||
); | ||
expect(callTx.id).toEqual('some_hash'); | ||
expect(callTx.isPending()).toBeTruthy(); | ||
}); | ||
it('should normalise addresses to base16 checksum', () => { | ||
@@ -518,0 +618,0 @@ const contractAt = contractFactory.at( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
374337
4031
1
+ Added@zilliqa-js/account@0.9.0(transitive)
+ Added@zilliqa-js/blockchain@0.9.0(transitive)
+ Added@zilliqa-js/core@0.9.0(transitive)
+ Added@zilliqa-js/crypto@0.9.0(transitive)
+ Added@zilliqa-js/proto@0.9.0(transitive)
+ Added@zilliqa-js/util@0.9.0(transitive)
- Removed@zilliqa-js/account@0.8.9(transitive)
- Removed@zilliqa-js/blockchain@0.8.9(transitive)
- Removed@zilliqa-js/core@0.8.9(transitive)
- Removed@zilliqa-js/crypto@0.8.9(transitive)
- Removed@zilliqa-js/proto@0.8.3(transitive)
- Removed@zilliqa-js/util@0.8.8(transitive)
Updated@zilliqa-js/account@0.9.0
Updated@zilliqa-js/blockchain@0.9.0
Updated@zilliqa-js/core@0.9.0
Updated@zilliqa-js/crypto@0.9.0
Updated@zilliqa-js/util@0.9.0