Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat: Transformer middleware with DsProxy impl #165

Merged
merged 12 commits into from
Jan 22, 2021

Conversation

roynalnaruto
Copy link
Collaborator

@roynalnaruto roynalnaruto commented Jan 16, 2021

Motivation

This PR adds support for proxy wallets, eg. DsProxy

Solution

  • The Transformer trait must be implemented by a wallet like DsProxy
  • The TransformerMiddleware can intercept and transform tx requests to send them as the appropriate txs that the proxy contract can execute.

Usage

  • Using DsProxy as a Transformer
// instantiate wallet and provider
// instantiate signer middleware
let middleware = SignerMiddleware::new(provider, wallet);
let middleware = Arc::new(middleware);

// instantiate DsProxy as the transformer
let ds_proxy = DsProxy::build::<HttpWallet, Arc<HttpWallet>>(
    Arc::clone(&middleware),
    Some(ds_proxy_factory.address()),
    provider.address(),
).await?;
let transformer_middleware = TransformerMiddleware::new(Arc::clone(&middleware), ds_proxy);

// send txs via DsProxy
transformer_middleware.send_transaction(tx_request, None).await?.await?;
  • Using DsProxy standalone
// instantiate DsProxy as the transformer
let ds_proxy = DsProxy::build::<HttpWallet, Arc<HttpWallet>>(
    Arc::clone(&middleware),
    Some(ds_proxy_factory.address()),
    provider.address(),
).await?;

// execute(bytes memory _code, bytes memory _data)
ds_proxy
    .execute::<HttpWallet, Arc<HttpWallet>>(
        Arc::clone(&middleware),
        AddressOrBytes::Bytes(bytecode),
        calldata,
    )
    .await;

// execute(address _target, bytes memory _data)
ds_proxy
    .execute::<HttpWallet, Arc<HttpWallet>>(
        Arc::clone(&middleware),
        AddressOrBytes::Address(target),
        calldata,
    )
    .await;

Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good! Left some comments. Thank you for the contribution as usual

ethers-middleware/src/proxy_wallet/ds_proxy/mod.rs Outdated Show resolved Hide resolved
ethers-middleware/src/proxy_wallet/ds_proxy/mod.rs Outdated Show resolved Hide resolved
ethers-middleware/src/proxy_wallet/ds_proxy/mod.rs Outdated Show resolved Hide resolved
ethers-middleware/src/proxy_wallet/gnosis_safe/mod.rs Outdated Show resolved Hide resolved
ethers-middleware/src/proxy_wallet/gnosis_safe/mod.rs Outdated Show resolved Hide resolved
ethers-middleware/src/proxy_wallet/ds_proxy/mod.rs Outdated Show resolved Hide resolved
ethers-middleware/src/proxy_wallet/mod.rs Outdated Show resolved Hide resolved
@roynalnaruto roynalnaruto changed the title feat: basic structure of proxy wallet middleware with DsProxy feat: Transformer middleware with DsProxy Jan 22, 2021
@roynalnaruto roynalnaruto changed the title feat: Transformer middleware with DsProxy feat: Transformer middleware with DsProxy impl Jan 22, 2021
@roynalnaruto roynalnaruto marked this pull request as ready for review January 22, 2021 07:55
@gakonst gakonst merged commit 3105431 into gakonst:master Jan 22, 2021
@roynalnaruto roynalnaruto deleted the feat/proxy-wallet branch April 16, 2022 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants