@zilliqa-js/contract
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -23,2 +23,3 @@ "use strict"; | ||
var factory_1 = require("./factory"); | ||
var types_1 = require("./types"); | ||
var NIL_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
@@ -36,3 +37,3 @@ var Contract = /** @class */ (function () { | ||
this.state = state; | ||
this.status = 0 /* Deployed */; | ||
this.status = types_1.ContractStatus.Deployed; | ||
} | ||
@@ -44,3 +45,3 @@ else { | ||
this.init = init; | ||
this.status = 2 /* Initialised */; | ||
this.status = types_1.ContractStatus.Initialised; | ||
} | ||
@@ -56,3 +57,3 @@ } | ||
Contract.prototype.isInitialised = function () { | ||
return this.status === 2 /* Initialised */; | ||
return this.status === types_1.ContractStatus.Initialised; | ||
}; | ||
@@ -67,3 +68,3 @@ /** | ||
Contract.prototype.isDeployed = function () { | ||
return this.status === 0 /* Deployed */; | ||
return this.status === types_1.ContractStatus.Deployed; | ||
}; | ||
@@ -79,3 +80,3 @@ /** | ||
Contract.prototype.isRejected = function () { | ||
return this.status === 1 /* Rejected */; | ||
return this.status === types_1.ContractStatus.Rejected; | ||
}; | ||
@@ -89,3 +90,3 @@ Contract.prototype.prepareTx = function (tx, attempts, interval, isDeploy) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.provider.send("CreateTransaction" /* CreateTransaction */, tslib_1.__assign(tslib_1.__assign({}, tx.txParams), { priority: tx.toDS }))]; | ||
case 0: return [4 /*yield*/, this.provider.send(core_1.RPCMethod.CreateTransaction, tslib_1.__assign(tslib_1.__assign({}, tx.txParams), { priority: tx.toDS }))]; | ||
case 1: | ||
@@ -96,3 +97,3 @@ response = _a.sent(); | ||
this.error = response.error; | ||
return [2 /*return*/, tx.setStatus(3 /* Rejected */)]; | ||
return [2 /*return*/, tx.setStatus(account_1.TxStatus.Rejected)]; | ||
} | ||
@@ -114,3 +115,3 @@ if (isDeploy) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.provider.send("CreateTransaction" /* CreateTransaction */, tslib_1.__assign(tslib_1.__assign({}, tx.txParams), { priority: tx.toDS }))]; | ||
case 0: return [4 /*yield*/, this.provider.send(core_1.RPCMethod.CreateTransaction, tslib_1.__assign(tslib_1.__assign({}, tx.txParams), { priority: tx.toDS }))]; | ||
case 1: | ||
@@ -121,7 +122,7 @@ response = _a.sent(); | ||
this.error = response.error; | ||
tx.setStatus(3 /* Rejected */); | ||
tx.setStatus(account_1.TxStatus.Rejected); | ||
} | ||
else { | ||
tx.id = response.result.TranID; | ||
tx.setStatus(1 /* Pending */); | ||
tx.setStatus(account_1.TxStatus.Pending); | ||
return [2 /*return*/, response.result.ContractAddress]; | ||
@@ -149,3 +150,3 @@ } | ||
} | ||
tx = new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: NIL_ADDRESS, amount: new util_1.BN(0), code: this.code, data: JSON.stringify(this.init).replace(/\\"/g, '"') }), this.provider, 0 /* Initialised */, toDs); | ||
tx = new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: NIL_ADDRESS, amount: new util_1.BN(0), code: this.code, data: JSON.stringify(this.init).replace(/\\"/g, '"') }), this.provider, account_1.TxStatus.Initialised, toDs); | ||
_b.label = 1; | ||
@@ -160,4 +161,4 @@ case 1: | ||
this.address === undefined | ||
? 1 /* Rejected */ | ||
: 2 /* Initialised */; | ||
? types_1.ContractStatus.Rejected | ||
: types_1.ContractStatus.Initialised; | ||
return [2 /*return*/, [tx, this]]; | ||
@@ -193,11 +194,11 @@ case 3: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.prepareTx(new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: NIL_ADDRESS, amount: new util_1.BN(0), code: this.code, data: JSON.stringify(this.init).replace(/\\"/g, '"') }), this.provider, 0 /* Initialised */, toDs), attempts, interval, true)]; | ||
return [4 /*yield*/, this.prepareTx(new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: NIL_ADDRESS, amount: new util_1.BN(0), code: this.code, data: JSON.stringify(this.init).replace(/\\"/g, '"') }), this.provider, account_1.TxStatus.Initialised, toDs), attempts, interval, true)]; | ||
case 2: | ||
tx = _a.sent(); | ||
if (tx.isRejected()) { | ||
this.status = 1 /* Rejected */; | ||
this.status = types_1.ContractStatus.Rejected; | ||
this.address = undefined; | ||
return [2 /*return*/, [tx, this]]; | ||
} | ||
this.status = 0 /* Deployed */; | ||
this.status = types_1.ContractStatus.Deployed; | ||
this.address = | ||
@@ -233,3 +234,3 @@ this.address && crypto_1.isValidChecksumAddress(this.address) | ||
} | ||
tx = new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, 0 /* Initialised */, toDs); | ||
tx = new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, account_1.TxStatus.Initialised, toDs); | ||
_a.label = 1; | ||
@@ -279,3 +280,3 @@ case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.prepareTx(new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, 0 /* Initialised */, toDs), attempts, interval, false)]; | ||
return [4 /*yield*/, this.prepareTx(new account_1.Transaction(tslib_1.__assign(tslib_1.__assign({}, params), { toAddr: this.address, data: JSON.stringify(data) }), this.provider, account_1.TxStatus.Initialised, toDs), attempts, interval, false)]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
@@ -297,3 +298,3 @@ case 3: | ||
case 0: | ||
if (this.status !== 0 /* Deployed */) { | ||
if (this.status !== types_1.ContractStatus.Deployed) { | ||
return [2 /*return*/, Promise.resolve([])]; | ||
@@ -304,3 +305,3 @@ } | ||
} | ||
return [4 /*yield*/, this.provider.send("GetSmartContractState" /* GetSmartContractState */, this.address.replace('0x', '').toLowerCase())]; | ||
return [4 /*yield*/, this.provider.send(core_1.RPCMethod.GetSmartContractState, this.address.replace('0x', '').toLowerCase())]; | ||
case 1: | ||
@@ -327,3 +328,3 @@ response = _a.sent(); | ||
case 0: | ||
if (this.status !== 0 /* Deployed */) { | ||
if (this.status !== types_1.ContractStatus.Deployed) { | ||
return [2 /*return*/, Promise.resolve([])]; | ||
@@ -337,3 +338,3 @@ } | ||
} | ||
return [4 /*yield*/, this.provider.send("GetSmartContractSubState" /* GetSmartContractSubState */, this.address.replace('0x', '').toLowerCase(), variableName, indices === undefined ? [] : indices)]; | ||
return [4 /*yield*/, this.provider.send(core_1.RPCMethod.GetSmartContractSubState, this.address.replace('0x', '').toLowerCase(), variableName, indices === undefined ? [] : indices)]; | ||
case 1: | ||
@@ -353,3 +354,3 @@ response = _a.sent(); | ||
case 0: | ||
if (this.status !== 0 /* Deployed */) { | ||
if (this.status !== types_1.ContractStatus.Deployed) { | ||
return [2 /*return*/, Promise.resolve([])]; | ||
@@ -360,3 +361,3 @@ } | ||
} | ||
return [4 /*yield*/, this.provider.send("GetSmartContractInit" /* GetSmartContractInit */, this.address.replace('0x', '').toLowerCase())]; | ||
return [4 /*yield*/, this.provider.send(core_1.RPCMethod.GetSmartContractInit, this.address.replace('0x', '').toLowerCase())]; | ||
case 1: | ||
@@ -363,0 +364,0 @@ response = _a.sent(); |
@@ -21,2 +21,3 @@ "use strict"; | ||
var crypto_1 = require("@zilliqa-js/crypto"); | ||
var core_1 = require("@zilliqa-js/core"); | ||
var util_1 = require("@zilliqa-js/util"); | ||
@@ -35,3 +36,3 @@ var contract_1 = require("./contract"); | ||
this.provider = provider; | ||
this.provider.middleware.request.use(account_1.util.formatOutgoingTx, "CreateTransaction" /* CreateTransaction */); | ||
this.provider.middleware.request.use(account_1.util.formatOutgoingTx, core_1.RPCMethod.CreateTransaction); | ||
this.signer = signer; | ||
@@ -38,0 +39,0 @@ } |
import { Omit } from 'utility-types'; | ||
import { TxParams } from '@zilliqa-js/account'; | ||
export declare const enum ContractStatus { | ||
export declare enum ContractStatus { | ||
Deployed = 0, | ||
@@ -5,0 +5,0 @@ Rejected = 1, |
{ | ||
"name": "@zilliqa-js/contract", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "Contract-related functionality.", | ||
@@ -28,7 +28,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@zilliqa-js/account": "0.10.1", | ||
"@zilliqa-js/blockchain": "0.10.1", | ||
"@zilliqa-js/core": "0.10.1", | ||
"@zilliqa-js/crypto": "0.10.1", | ||
"@zilliqa-js/util": "0.10.1", | ||
"@zilliqa-js/account": "0.11.0", | ||
"@zilliqa-js/blockchain": "0.11.0", | ||
"@zilliqa-js/core": "0.11.0", | ||
"@zilliqa-js/crypto": "0.11.0", | ||
"@zilliqa-js/util": "0.11.0", | ||
"hash.js": "^1.1.5", | ||
@@ -38,5 +38,5 @@ "utility-types": "^2.1.0" | ||
"engines": { | ||
"node": ">=10.0.0 <=12.16.3" | ||
"node": ">=10.0.0 <13" | ||
}, | ||
"gitHead": "2c8e5329af545adaad9013aff65d92b38254d90c" | ||
"gitHead": "8546f884024213c7e97e9584e330002048feb5bd" | ||
} |
@@ -19,3 +19,3 @@ // This file is part of Zilliqa-Javascript-Library. | ||
export const enum ContractStatus { | ||
export enum ContractStatus { | ||
Deployed, | ||
@@ -22,0 +22,0 @@ Rejected, |
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
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
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
375097
4027
+ Added@types/node@22.10.0(transitive)
+ Added@zilliqa-js/account@0.11.0(transitive)
+ Added@zilliqa-js/blockchain@0.11.0(transitive)
+ Added@zilliqa-js/core@0.11.0(transitive)
+ Added@zilliqa-js/crypto@0.11.0(transitive)
+ Added@zilliqa-js/proto@0.11.0(transitive)
+ Added@zilliqa-js/util@0.11.0(transitive)
+ Addedcipher-base@1.0.6(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@types/node@22.9.2(transitive)
- Removed@zilliqa-js/account@0.10.1(transitive)
- Removed@zilliqa-js/blockchain@0.10.1(transitive)
- Removed@zilliqa-js/core@0.10.1(transitive)
- Removed@zilliqa-js/crypto@0.10.1(transitive)
- Removed@zilliqa-js/proto@0.10.0(transitive)
- Removed@zilliqa-js/util@0.10.1(transitive)
- Removedcipher-base@1.0.5(transitive)
- Removedundici-types@6.19.8(transitive)
Updated@zilliqa-js/account@0.11.0
Updated@zilliqa-js/core@0.11.0
Updated@zilliqa-js/crypto@0.11.0
Updated@zilliqa-js/util@0.11.0