Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test("transfer", () => {
const account = new wallet.Account(
"9ab7e154840daca3a2efadaf0df93cd3a5b51768c632f5433f86909d9b994a69"
);
const amtToSendTest = 922.33720369;
const generator = abi.transfer(
"9488220e8654d798f9b9cb9e74bd611ecc83fd0f",
account.address,
account.address,
amtToSendTest
);
const builder = generator();
const script =
"0531e28e79151435b20010db73bf86371075ddfba4e6596f1ff35d1435b20010db73bf86371075ddfba4e6596f1ff35d53c1087472616e73666572670ffd83cc1e61bd749ecbb9f998d754860e228894";
expect(builder["str"]).toBe(script);
});
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);
});
const signWithInvlidAccount = (): void => {
signer.signWithAccount(new wallet.Account());
};
expect(signWithInvlidAccount).toThrowError();
const ACCOUNTS = PRIVATE_KEYS.map(key => new wallet.Account(key));
private _checkAcc(account: wallet.Account | string): void {
const acc = new wallet.Account(account);
this._assertShouldSign(acc.scriptHash);
}
export function makeIntent(
assetAmts: { [k: string]: number },
address: string
): tx.TransactionOutput[] {
const acct = new wallet.Account(address);
return Object.keys(assetAmts).map(key => {
return new tx.TransactionOutput({
assetId: CONST.ASSET_ID[key],
value: assetAmts[key],
scriptHash: acct.scriptHash
});
});
}
export function signWithPrivateKey(
privateKey: string
): (tx: string, publicKey: string) => Promise {
const pubKey = new wallet.Account(privateKey).publicKey;
return async (txString: string, publicKey?: string) => {
const sig = wallet.sign(txString, privateKey);
const witness = tx.Witness.fromSignature(sig, publicKey || pubKey);
return witness.serialize();
};
}