Closed radleylewis closed 5 months ago
Building on the above, the amended addKey
method would take an option (on the existing options
object of signOnly: boolean
. If set to true, then the didManagerAddKey
(via the provider addKey
method would return an object that looks like the following TypeScript tuple type (which conforms to the function parameters of metaEthrDid.setAttributeSigned
):
type TxnParams = [
attrName: string,
attrValue: string,
ttl: number,
signature: { sigV: number; sigR: string; sigS: string },
options: Record<string, any>,
];
In the introduced didManagerSubmitTransaction
the function signature would then look like the following:
async didManagerSubmitTransaction(args: TxnParams, context: IAgentContext<IKeyManager>): Promise<unknown>;
This method (didManagerSubmitTransaction
) can then be called from another context (in an agent not constrained by the snap environment) referencing the options.metaIdentifierKeyId
for submission to the network.
async didManagerSubmitTransaction(args: TxnParams, context: IAgentContext<IKeyManager>): Promise<any> {
// this method invokes a new provider method, which means that the calling agent calls `metaEthrDid.setAttributeSigned`
// with the provided txnParams (that were returned from the agent call in the first invocation within the MM Snap.
return provider.submitTransaction(args, context); // additional function made available on `did-ethr-provider`
}
Providing an update for the sake of completeness. In our case, the concern was that the eth_sendRawTransaction
method was not supported within the context of the MetaMask Snap, and therefore, a workaround (such as signing the transaction and submitting via a proxy such as Infura, or on a server) was proposed.
However, the eth_sendRawTransaction
method has since been unblocked by the MetaMask Snaps developers (refer to this PR), and as such, the above, while still relevant in some scenarios no longer applies in the case of MetaMask Snaps.
Is your feature request related to a problem? Please describe. We need to invoke the below methods (using
ethr-did-provider
) which result in writes to the network:didManagerAddKey
(specificallyX25519
andEd25519
key types); and,didManagerAddService
(e.g. did-comm endpoint). As these calls invokeeth_sendTransaction
which are listed asBLOCKED_RPC_METHODS
within MetaMask Snaps (more information here) the calls to these methods fail (see bottom of issue for error example).Describe the solution you'd like I am open to suggestions on how best to approach this issue. One approach would be to allow an option/flag that would not submit the transaction to the network, but rather return the prepared (signed) transaction for submission in another context (i.e. via a Veramo agent instantiated in the DApp invoking). The addKey method looks like the below (did-ethr):
The returned (prepared and signed but not submitted) return type would look something like the below:
Describe alternatives you've considered The approach that I have outlined above would necessitate the implementation of a new function (e.g.
submitAddKey
) so I am keen to hear other approaches.Additional context Any method that invokes the
eth_sendTransaction
is going to result in this issue with errors corresponding broadly to the below example: