Add test for deposit erc20 from message input
LuizAsFight opened this issue · comments
Luiz Gomes commented
bridgeERC20.ts is testing the deposit erc20 process, but when mounting the inputs to pay the transaction, it only considers Coin inputs.
- should add a test to validate if deposit erc20 token from CoinMessage works
- bridge (deposit) ETH to a fuel account
- then bridge(deposit) erc20 to the same fuel account
export function resourcesToInputs(resources: Array<Resource>) {
const coinResources: Coin[] = resources.filter((r) =>
isCoin(r)
) as unknown as Coin[];
const coinInputs: Array<TransactionRequestInput> = coinResources.map(
(r: Coin) => ({
type: InputType.Coin,
id: r.id,
owner: r.owner.toB256(),
amount: r.amount.toHex(),
assetId: r.assetId,
txPointer: ZeroBytes32,
witnessIndex: 0,
})
);
const messageCoinResources: MessageCoin[] = resources.filter((r) =>
isMessage(r)
) as unknown as MessageCoin[];
const messageCoinInputs: Array<TransactionRequestInput> =
messageCoinResources.map((r: MessageCoin) => ({
type: InputType.Message,
assetId: r.assetId,
sender: r.sender.toB256(),
recipient: r.recipient.toB256(),
nonce: r.nonce,
amount: r.amount.toHex(),
daHeight: r.daHeight.toHex(),
witnessIndex: 0,
}));
// return coinInputs;
return [...coinInputs, ...messageCoinInputs];
}
Mad commented
I am not sure I understand this issue - could you please elaborate?
Luiz Gomes commented
[transaction.ts](https://github.com/FuelLabs/fuel- bridge/blob/cad3939bcb615da22f45075d9a29253435c4f65a/packages/test-utils/src/utils/fuels/transaction.ts#L4)
this function is only considering coin
inputs, but it can be a message
input if the ETH you have came from a bridge deposit operation
this issue consists in:
- add support to message inputs
- create a test that validate this scenario working