Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmony-js/contract

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmony-js/contract - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

4

dist/contract.d.ts
import { Wallet } from '@harmony-js/account';
import { Messenger } from '@harmony-js/network';
import { Transaction } from '@harmony-js/transaction';

@@ -13,3 +14,3 @@ import { ContractOptions } from './utils/options';

options: ContractOptions | any;
wallet: Wallet;
wallet: Wallet | any;
transaction?: Transaction;

@@ -32,3 +33,4 @@ status: ContractStatus;

connect(wallet: Wallet): void;
setMessegner(messenger: Messenger): void;
}
//# sourceMappingURL=contract.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var account_1 = require("@harmony-js/account");
var index_1 = require("./abi/index");

@@ -94,2 +95,10 @@ var mapper_1 = require("./utils/mapper");

};
Contract.prototype.setMessegner = function (messenger) {
if (this.wallet instanceof account_1.Wallet) {
this.wallet.setMessenger(messenger);
}
else {
this.wallet.messenger = messenger;
}
};
return Contract;

@@ -96,0 +105,0 @@ }());

@@ -10,3 +10,3 @@ import { Wallet } from '@harmony-js/account';

methodKey: string;
wallet: Wallet;
wallet: Wallet | any;
abiItem: AbiItemModel;

@@ -25,3 +25,3 @@ callResponse?: any;

};
protected signTransaction(updateNonce: boolean): Promise<Transaction>;
protected signTransaction(updateNonce: boolean): Promise<any>;
protected sendTransaction(signed: Transaction): Promise<[Transaction, string]>;

@@ -28,0 +28,0 @@ protected confirm(id: string): Promise<void>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var account_1 = require("@harmony-js/account");
var transaction_1 = require("@harmony-js/transaction");

@@ -78,11 +79,9 @@ var network_1 = require("@harmony-js/network");

case 6:
// tslint:disable-next-line: prefer-conditional-expression
if (this.wallet.signer) {
from_1 =
options && options.from ? options.from : this.wallet.signer.address;
from_1 = options && options.from ? options.from : this.wallet.signer.address;
}
else {
from_1 =
options && options.from
? options.from
: '0x0000000000000000000000000000000000000000';
options && options.from ? options.from : '0x0000000000000000000000000000000000000000';
}

@@ -111,6 +110,3 @@ this.transaction = this.transaction.map(function (tx) {

}
return [4 /*yield*/, this.wallet.messenger.send("hmy_call" /* Call */, [
sendPayload,
blockNumber,
])];
return [4 /*yield*/, this.wallet.messenger.send("hmy_call" /* Call */, [sendPayload, blockNumber])];
case 7:

@@ -185,17 +181,26 @@ result = _e.sent();

return tslib_1.__awaiter(this, void 0, void 0, function () {
var signed, error_3;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
var signed, _a, error_3;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a.trys.push([0, 2, , 3]);
_b.trys.push([0, 5, , 6]);
signed = void 0;
if (!(this.wallet instanceof account_1.Wallet)) return [3 /*break*/, 2];
return [4 /*yield*/, this.wallet.signTransaction(this.transaction, this.wallet.signer, undefined, updateNonce, 'rlp', 'latest')];
case 1:
signed = _a.sent();
_a = _b.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.wallet.signTransaction(this.transaction, updateNonce, 'rlp', 'latest')];
case 3:
_a = _b.sent();
_b.label = 4;
case 4:
signed = _a;
this.contract.address = transaction_1.TransactionFactory.getContractAddress(signed);
this.contract.setStatus(status_1.ContractStatus.SIGNED);
return [2 /*return*/, signed];
case 2:
error_3 = _a.sent();
case 5:
error_3 = _b.sent();
throw error_3;
case 3: return [2 /*return*/];
case 6: return [2 /*return*/];
}

@@ -267,5 +272,3 @@ });

}
var txObject = tslib_1.__assign({}, this.params[0], { to: this.contract.address === '0x'
? '0x'
: crypto_1.getAddress(this.contract.address).checksum, data: this.encodeABI() });
var txObject = tslib_1.__assign({}, this.params[0], { to: this.contract.address === '0x' ? '0x' : crypto_1.getAddress(this.contract.address).checksum, data: this.encodeABI() });
var result = new transaction_1.TransactionFactory(this.wallet.messenger).newTx(txObject);

@@ -272,0 +275,0 @@ return result;

{
"name": "@harmony-js/contract",
"version": "0.1.7",
"version": "0.1.8",
"description": "contract libraries for harmony",

@@ -21,3 +21,3 @@ "main": "dist/index.js",

"dependencies": {
"@harmony-js/account": "0.1.7",
"@harmony-js/account": "0.1.8",
"@harmony-js/crypto": "0.1.7",

@@ -28,3 +28,3 @@ "@harmony-js/network": "0.1.7",

},
"gitHead": "b2300964739641778b379b575fdaf45bff34740b"
"gitHead": "b1b1ef5b75c42cd63a63f84dd86408e3f42dfd92"
}
import { Wallet } from '@harmony-js/account';
// import { Emitter } from '@harmony-js/network';
import { Messenger } from '@harmony-js/network';
import { Transaction } from '@harmony-js/transaction';

@@ -20,3 +20,3 @@ import { AbiCoder } from './abi/index';

options: ContractOptions | any;
wallet: Wallet;
wallet: Wallet | any;
transaction?: Transaction;

@@ -107,2 +107,9 @@ status: ContractStatus;

}
setMessegner(messenger: Messenger) {
if (this.wallet instanceof Wallet) {
this.wallet.setMessenger(messenger);
} else {
this.wallet.messenger = messenger;
}
}
}
import { Wallet } from '@harmony-js/account';
import {
TransactionFactory,
Transaction,
TxStatus,
} from '@harmony-js/transaction';
import { TransactionFactory, Transaction, TxStatus } from '@harmony-js/transaction';
import { RPCMethod, getResultForData, Emitter } from '@harmony-js/network';

@@ -21,3 +17,3 @@ import { hexToNumber, hexToBN } from '@harmony-js/utils';

methodKey: string;
wallet: Wallet;
wallet: Wallet | any;
abiItem: AbiItemModel;

@@ -28,8 +24,3 @@ callResponse?: any;

protected transaction: Transaction;
constructor(
methodKey: string,
params: any,
abiItem: AbiItemModel,
contract: Contract,
) {
constructor(methodKey: string, params: any, abiItem: AbiItemModel, contract: Contract) {
this.methodKey = methodKey;

@@ -87,10 +78,8 @@ this.contract = contract;

let from: string;
// tslint:disable-next-line: prefer-conditional-expression
if (this.wallet.signer) {
from =
options && options.from ? options.from : this.wallet.signer.address;
from = options && options.from ? options.from : this.wallet.signer.address;
} else {
from =
options && options.from
? options.from
: '0x0000000000000000000000000000000000000000';
options && options.from ? options.from : '0x0000000000000000000000000000000000000000';
}

@@ -143,6 +132,3 @@

const result = await this.wallet.messenger.send(RPCMethod.Call, [
sendPayload,
blockNumber,
]);
const result = await this.wallet.messenger.send(RPCMethod.Call, [sendPayload, blockNumber]);
this.callPayload = sendPayload;

@@ -187,7 +173,3 @@ this.callResponse = result;

encodeABI() {
return methodEncoder(
this.contract.abiCoder,
this.abiItem,
this.contract.data,
);
return methodEncoder(this.contract.abiCoder, this.abiItem, this.contract.data);
}

@@ -204,10 +186,19 @@

try {
const signed = await this.wallet.signTransaction(
this.transaction,
this.wallet.signer,
undefined,
updateNonce,
'rlp',
'latest', // 'pending',
);
let signed;
signed =
this.wallet instanceof Wallet
? await this.wallet.signTransaction(
this.transaction,
this.wallet.signer,
undefined,
updateNonce,
'rlp',
'latest', // 'pending',
)
: await this.wallet.signTransaction(
this.transaction,
updateNonce,
'rlp',
'latest', // 'pending',
);
this.contract.address = TransactionFactory.getContractAddress(signed);

@@ -261,12 +252,7 @@ this.contract.setStatus(ContractStatus.SIGNED);

...this.params[0],
to:
this.contract.address === '0x'
? '0x'
: getAddress(this.contract.address).checksum,
to: this.contract.address === '0x' ? '0x' : getAddress(this.contract.address).checksum,
data: this.encodeABI(),
};
const result = new TransactionFactory(this.wallet.messenger).newTx(
txObject,
);
const result = new TransactionFactory(this.wallet.messenger).newTx(txObject);

@@ -273,0 +259,0 @@ return result;

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc