Trying to implement this cosigning flow
My cosignTransaction()
function sends transaction body to the backend and gets back modified transaction with prepended noop
action and a valid signature for the new transaction signed by resource provider.
Here’s the snippet:
async function handleAnchor(actions: Action[]) {
const session = await anchor.login();
if (!session) return "";
const [ info, abis ] = await Promise.all([
session.client.v1.chain.get_info(),
session.client.v1.chain.get_abi(actions[0].account)
]);
const header = info.getTransactionHeader(300)
const trx = Transaction.from({
...header,
actions
}, abis.abi);
const { transaction, signatures } = await cosignTransaction( trx, session.auth );
const signedTransaction = SignedTransaction.from({
...transaction,
signatures,
})
const result = await session.transact({ transaction: signedTransaction});
return result.transaction.id;
}
But looks like session.transact()
ignores supplied signature.
So after signing it in Anchor I get this error (note that the only signature here is the one I signed in Anchor):
transaction declares authority '{"actor":"<resourceacc>","permission":"noop"}', but does not have signatures for it under a provided delay of 0 ms, provided permissions [], provided keys ["EOS4w768L97otYaqNcoippcMVKAPwmj2dVZaog7eLLDFsZQteRHCu"], and a delay max limit of 3888000000 ms
Am I doing it wrong?