Skip to content

Instantly share code, notes, and snippets.

@aaroncox
Last active March 15, 2024 14:57
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aaroncox/102a70a9a6a37a9c2a90b6fabfbc86e7 to your computer and use it in GitHub Desktop.
Save aaroncox/102a70a9a6a37a9c2a90b6fabfbc86e7 to your computer and use it in GitHub Desktop.
Using a custom authority provider within eosjs for Greymass Fuel
// A custom cosigner AuthorityProvider for EOSJS v2
// This provider overrides the checks on all keys,
// allowing a partially signed transaction to be
// broadcast to the API node.
class CosignAuthorityProvider {
async getRequiredKeys(args) {
const { transaction } = args;
// Iterate over the actions and authorizations
transaction.actions.forEach((action, ti) => {
action.authorization.forEach((auth, ai) => {
// If the authorization matches the expected cosigner
// then remove it from the transaction while checking
// for what public keys are required
if (
auth.actor === 'greymassfuel'
&& auth.permission === 'cosign'
) {
delete transaction.actions[ti].authorization.splice(ai, 1)
}
})
});
return convertLegacyPublicKeys((await rpc.fetch('/v1/chain/get_required_keys', {
transaction,
available_keys: args.availableKeys,
})).required_keys);
}
}
// Pass in new authorityProvider
const api = new Api({
authorityProvider: new CosignAuthorityProvider(),
// the rest of your configuration
});
@jmgayosso
Copy link

Hi @aaroncox I have exactly the same issue, Did you find the way to solve it??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment