-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish deployer refund implementation
Fix warning from SlideIn prop name Add useThrottle hook
- Loading branch information
Showing
11 changed files
with
228 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const MIN_CHAIN_BALANCE = 1; // 1 Wei | ||
export const WARP_DEPLOY_GAS_UNITS = BigInt(3e7); | ||
export const WARP_DEPLOY_GAS_UNITS = BigInt(1e7); | ||
export const REFUND_FEE_PADDING_FACTOR = 1.1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
getChainIdNumber, | ||
MultiProtocolProvider, | ||
ProviderType, | ||
Token, | ||
TypedTransaction, | ||
TypedTransactionReceipt, | ||
WarpTxCategory, | ||
WarpTypedTransaction, | ||
} from '@hyperlane-xyz/sdk'; | ||
import { ProtocolType } from '@hyperlane-xyz/utils'; | ||
import { TypedWallet } from './types'; | ||
|
||
// TODO edit Widgets lib to default to TypedTransaction instead of WarpTypedTransaction? | ||
export async function getTransferTx( | ||
recipient: Address, | ||
amount: bigint, | ||
token: Token, | ||
multiProvider: MultiProtocolProvider, | ||
): Promise<WarpTypedTransaction> { | ||
const chainMetadata = multiProvider.getChainMetadata(token.chainName); | ||
|
||
let txParams = (await token | ||
.getAdapter(multiProvider) | ||
.populateTransferTx({ recipient, weiAmountOrId: amount })) as object; | ||
|
||
if (token.protocol === ProtocolType.Ethereum) { | ||
// Add chainId to help reduce likely of wallet signing on wrong chain | ||
const chainId = getChainIdNumber(chainMetadata); | ||
// TODO remove data when widgets lib is updated | ||
txParams = { ...txParams, chainId, data: '0x' }; | ||
} | ||
|
||
return { | ||
// TODO use TOKEN_STANDARD_TO_PROVIDER_TYPE here when it's exported from the SDK | ||
// type: TOKEN_STANDARD_TO_PROVIDER_TYPE[token.standard], | ||
type: ProviderType.EthersV5, | ||
transaction: txParams, | ||
category: WarpTxCategory.Transfer, | ||
} as WarpTypedTransaction; | ||
} | ||
|
||
// TODO multi-protocol support | ||
export async function sendTxFromWallet( | ||
typedWallet: TypedWallet, | ||
typedTx: TypedTransaction, | ||
chainName: ChainName, | ||
multiProvider: MultiProtocolProvider, | ||
): Promise<TypedTransactionReceipt> { | ||
if (typedTx.type === ProviderType.EthersV5 && typedWallet.type === ProviderType.EthersV5) { | ||
const provider = multiProvider.getEthersV5Provider(chainName); | ||
const response = await typedWallet.wallet | ||
.connect(provider) | ||
.sendTransaction(typedTx.transaction); | ||
const receipt = await response.wait(); | ||
return { | ||
type: ProviderType.EthersV5, | ||
receipt, | ||
}; | ||
} else { | ||
throw new Error(`Unsupported provider type for sending txs: ${typedWallet.type}`); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.