aurora-is-near / rainbow-bridge-client

Monorepo containing Aurora-maintained libraries for using the Rainbow Bridge
https://github.com/near/rainbow-bridge-client/tree/main/packages/client#readme
MIT License
25 stars 7 forks source link

Standardize connector APIs. #55

Closed paouvrard closed 2 years ago

paouvrard commented 3 years ago

Aurora and Rainbow bridge connectors currently implement different APIs for creating transfers.

naturalErc20.sendToNear({ erc20Address, amount, sender, recipient }) https://github.com/aurora-is-near/rainbow-bridge-client/blob/39ae822e0d72da8a66a68cce7c65afdc044b759b/packages/nep141-erc20/src/natural-erc20/sendToNear/index.js#L185

naturalErc20.sendToAurora({ amount, token }) https://github.com/aurora-is-near/rainbow-bridge-client/blob/152b0755d550998adf3533e1dc1f4c0e5f3892c2/packages/aurora-erc20/src/natural-erc20/sendToAurora/index.js#L181

Proposed API:

sendTo...({
    erc20Address: string,
    amount: string | ethers.Bignumber,
    recipient: string, 
    options?: {
        symbol: string,
        decimals: number,
        sender: string,
        recipient: string,
        provider: ethers.providers.Web3Provider,
        connectorAddress: string, // erc20Locker | etherCustodian | auroraEvm | erc20Factory | nativeNearLocker
        connectorAbi: string
    }
})

cc @mfornet

mfornet commented 3 years ago

+1 to the new proposal.

Where are we using connectorAddress and connectorAbi, if they are optional how are we using it if not passed?

paouvrard commented 3 years ago

Environment variables defined by the frontend. But on 2nd thought I think we shouldn't add those arguments here because transfer finalization still relies on them and so they would still need to be defined in process.env.

mfornet commented 3 years ago

btw, shouldn't we put each field of options as optional, rather than the whole object? i.e

    options?: {
        symbol?: string,
        decimals?: number,
        sender?: string,
        recipient?: string,
        provider?: ethers.providers.Web3Provider,
        connectorAddress?: string, // erc20Locker | etherCustodian | auroraEvm | erc20Factory | nativeNearLocker
        connectorAbi?: string
    }
paouvrard commented 3 years ago

Related conversation: https://github.com/aurora-is-near/rainbow-bridge-client/pull/56#pullrequestreview-706507819

paouvrard commented 2 years ago

Implementation: https://github.com/aurora-is-near/rainbow-bridge-client/pull/58