Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(async (resolve, reject) => {
const amount = (this.pramsData.dynamicInvoke === 'true' ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
const fromAddress = this.neon.wallet.accounts[0].address;
let newTx = new tx.InvocationTransaction();
// tslint:disable-next-line: no-bitwise
const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
(this.pramsData.isPayable === 'true' ? 4 : 0);
const sb = new ScriptBuilder();
sb.emitPush(str2hexstring(this.pramsData.description))
.emitPush(str2hexstring(this.pramsData.email))
.emitPush(str2hexstring(this.pramsData.author))
.emitPush(str2hexstring(this.pramsData.version))
.emitPush(str2hexstring(this.pramsData.name))
.emitPush(num)
.emitPush(this.pramsData.returnType || 'ff00')
.emitPush(this.pramsData.parameterList)
.emitPush(this.pramsData.code)
.emitSysCall('Neo.Contract.Create');
try {
newTx.script = sb.str;
test("performs operation on empty tx", async () => {
const config: DoInvokeConfig = {
api: mockProvider,
account: new wallet.Account("ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW"),
tx: new tx.InvocationTransaction(),
script: ""
};
const result = await common.modifyTransactionForEmptyTransaction(config);
expect(result.tx.attributes.length).toBe(2);
});
export async function createInvocationTx(
config: DoInvokeConfig
): Promise {
checkProperty(config, "script");
const processedScript =
typeof config.script === "object"
? sc.createScript(config.script)
: config.script;
config.tx = new tx.InvocationTransaction(
Object.assign(
{
outputs: config.intents || [],
script: processedScript,
gas: config.gas || 0
},
config.override
)
);
config.tx.calculate(
config.balance || new wallet.Balance(),
undefined,
config.fees
);
return config;
}
return new Promise(async (resolve, reject) => {
const fromScript = wallet.getScriptHashFromAddress(this.neon.address);
const toScript = this.scriptHash.startsWith('0x') && this.scriptHash.length === 42 ? this.scriptHash.substring(2) : this.scriptHash;
let newTx = new tx.InvocationTransaction();
if (this.scriptHash.length !== 42 && this.scriptHash.length !== 40) {
this.chrome.windowCallback({
error: ERRORS.MALFORMED_INPUT,
return: requestTarget.Invoke,
ID: this.messageID
});
this.loading = false;
this.loadingMsg = '';
window.close();
return null;
}
try {
newTx.script = sc.createScript({
scriptHash: this.scriptHash.startsWith('0x') && this.scriptHash.length === 42 ? this.scriptHash.substring(2) : this.scriptHash,
operation: this.operation,
args: this.args