Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
Matthew Lam committed Mar 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 950ae07 commit 6e911e4
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions contracts/src/TeleporterTokenDestination.sol
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ abstract contract TeleporterTokenDestination is
/// @notice The ERC20 token this contract uses to pay for Teleporter fees.
address public immutable feeTokenAddress;

// TODO: these are values brought from the example ERC20Bridge contract.
// Need to figure out appropriate values.
uint256 public constant SEND_TOKENS_REQUIRED_GAS = 300_000;

/**
5 changes: 4 additions & 1 deletion contracts/src/TeleporterTokenSource.sol
Original file line number Diff line number Diff line change
@@ -41,6 +41,8 @@ abstract contract TeleporterTokenSource is ITeleporterTokenBridge, TeleporterOwn
=> mapping(address destinationBridgeAddress => uint256 balance)
) public bridgedBalances;

// TODO: these are values brought from the example ERC20Bridge contract.
// Need to figure out appropriate values.
uint256 public constant SEND_TOKENS_REQUIRED_GAS = 300_000;

/**
@@ -145,7 +147,8 @@ abstract contract TeleporterTokenSource is ITeleporterTokenBridge, TeleporterOwn
// Decrement the bridge balance by the unwrap amount
bridgedBalances[sourceBlockchainID][originSenderAddress] = senderBalance - amount;

// decrement totalAmount from bridge balance
// If the final destination of the transfer is this source bridge instance, withdraw the tokens.abi
// Otherwise, perform a multihop transfer to the input destination bridge instance.
if (input.destinationBlockchainID == blockchainID) {
require(
input.destinationBridgeAddress == address(this),
1 change: 1 addition & 0 deletions scripts/abi_bindings.sh
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ source $TELEPORTER_PATH/scripts/utils.sh

setARCH

# Contract names to generate Go bindings for
DEFAULT_CONTRACT_LIST="ERC20Source ERC20Destination"

CONTRACT_LIST=
2 changes: 1 addition & 1 deletion tests/flows/basic_erc20_send_receive.go
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ func BasicERC20SendReceive(network interfaces.Network) {
fundedKey,
subnetBInfo,
fundedAddress,
subnetAInfo,
subnetAInfo.BlockchainID,
erc20SourceAddress,
tokenName,
tokenSymbol,
22 changes: 11 additions & 11 deletions tests/utils/utils.go
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import (
"crypto/ecdsa"
"math/big"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
"github.com/ava-labs/subnet-evm/core/types"
erc20destination "github.com/ava-labs/teleporter-token-bridge/abi-bindings/go/ERC20Destination"
@@ -52,12 +53,11 @@ func DeployERC20Destination(
senderKey *ecdsa.PrivateKey,
subnet interfaces.SubnetTestInfo,
teleporterManager common.Address,
sourceSubnet interfaces.SubnetTestInfo,
sourceBlockchainID ids.ID,
tokenSourceAddress common.Address,
tokenName string,
tokenSymbol string,
tokenDecimals uint8,

) (common.Address, *erc20destination.ERC20Destination) {
opts, err := bind.NewKeyedTransactorWithChainID(
senderKey,
@@ -69,7 +69,7 @@ func DeployERC20Destination(
subnet.RPCClient,
subnet.TeleporterRegistryAddress,
teleporterManager,
sourceSubnet.BlockchainID,
sourceBlockchainID,
tokenSourceAddress,
tokenName,
tokenSymbol,
@@ -164,27 +164,27 @@ func CheckERC20SourceWithdrawal(
ctx context.Context,
erc20SourceAddress common.Address,
sourceToken *exampleerc20.ExampleERC20,
recipientAddress common.Address,
amount *big.Int,
receipt *types.Receipt,
expectedRecipientAddress common.Address,
expectedAmount *big.Int,
) {
sourceTransferEvent, err := teleporterUtils.GetEventFromLogs(receipt.Logs, sourceToken.ParseTransfer)
Expect(err).Should(BeNil())
Expect(sourceTransferEvent.From).Should(Equal(erc20SourceAddress))
Expect(sourceTransferEvent.To).Should(Equal(recipientAddress))
Expect(sourceTransferEvent.Value).Should(Equal(amount))
Expect(sourceTransferEvent.To).Should(Equal(expectedRecipientAddress))
Expect(sourceTransferEvent.Value).Should(Equal(expectedAmount))
}

func CheckERC20DestinationWithdrawal(
ctx context.Context,
erc20Destination *erc20destination.ERC20Destination,
recipientAddress common.Address,
amount *big.Int,
receipt *types.Receipt,
expectedRecipientAddress common.Address,
expectedAmount *big.Int,
) {
transferEvent, err := teleporterUtils.GetEventFromLogs(receipt.Logs, erc20Destination.ParseTransfer)
Expect(err).Should(BeNil())
Expect(transferEvent.From).Should(Equal(common.Address{}))
Expect(transferEvent.To).Should(Equal(recipientAddress))
Expect(transferEvent.Value).Should(Equal(amount))
Expect(transferEvent.To).Should(Equal(expectedRecipientAddress))
Expect(transferEvent.Value).Should(Equal(expectedAmount))
}

0 comments on commit 6e911e4

Please sign in to comment.