Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("multiple witnesses", () => {
const signer = createTransactionSigner();
signer.signWithWitness(
new tx.Witness(ACCOUNTS_WITNESSES[0]),
new tx.Witness(ACCOUNTS_WITNESSES[1])
);
expect(signer.transaction.scripts[0].export()).toEqual(
ACCOUNTS_WITNESSES[0]
);
expect(signer.transaction.scripts[1].export()).toEqual(
ACCOUNTS_WITNESSES[1]
);
});
test("multiple witnesses", () => {
const signer = createTransactionSigner();
signer.signWithWitness(
new tx.Witness(ACCOUNTS_WITNESSES[0]),
new tx.Witness(ACCOUNTS_WITNESSES[1])
);
expect(signer.transaction.scripts[0].export()).toEqual(
ACCOUNTS_WITNESSES[0]
);
expect(signer.transaction.scripts[1].export()).toEqual(
ACCOUNTS_WITNESSES[1]
);
});
const signWithInvalidWitness = (): void => {
signer.signWithWitness(
new tx.Witness({
invocationScript: "abcd",
verificationScript:
"21032879f12ac79b9305bf768bb50f1c1c889330361fee037fe886f820bcaa521553ac"
})
);
};
expect(signWithInvalidWitness).toThrowError();
...ACCOUNTS_WITNESSES.map(obj => new tx.Witness(obj))
);
export async function getVerificationSignatureForSmartContract(
url: string,
smartContractScriptHash: string
): Promise {
const contractState = await rpc.Query.getContractState(
smartContractScriptHash
).execute(url);
const { parameters } = contractState.result;
const witness = new tx.Witness({
invocationScript: "00".repeat(parameters.length),
verificationScript: ""
});
witness.scriptHash = smartContractScriptHash;
return witness;
}