1- import { Contract , ContractTransaction , Signer , BigNumberish , providers , BigNumber } from 'ethers' ;
1+ import { BigNumber , BigNumberish , Contract , ContractTransaction , providers , Signer } from 'ethers' ;
22import { erc20FeeProxyArtifact } from '@requestnetwork/smart-contracts' ;
33import {
4+ ERC20__factory ,
45 ERC20FeeProxy__factory ,
56 ERC20Proxy__factory ,
6- ERC20__factory ,
77} from '@requestnetwork/smart-contracts/types' ;
88import { ClientTypes , ExtensionTypes } from '@requestnetwork/types' ;
99import { Erc20PaymentNetwork , getPaymentNetworkExtension } from '@requestnetwork/payment-detection' ;
1010import { EvmChains } from '@requestnetwork/currency' ;
1111import {
1212 getAmountToPay ,
1313 getProvider ,
14+ getProxyAddress ,
1415 getRequestPaymentValues ,
1516 getSigner ,
16- validateRequest ,
1717 validateErc20FeeProxyRequest ,
18- getProxyAddress ,
18+ validateRequest ,
1919} from './utils' ;
2020import { IPreparedPrivateTransaction } from './prepared-transaction' ;
2121
@@ -85,10 +85,8 @@ export async function payErc20ProxyRequestFromHinkalShieldedAddress(
8585 const signer = getSigner ( signerOrProvider ) ;
8686 const hinkalObject = await addToHinkalStore ( signer ) ;
8787
88- const { amountToPay, tokenAddress, ops } = prepareErc20ProxyPaymentFromHinkalShieldedAddress (
89- request ,
90- amount ,
91- ) ;
88+ const { amountToPay, tokenAddress, ops } =
89+ await prepareErc20ProxyPaymentFromHinkalShieldedAddress ( request , amount ) ;
9290
9391 return hinkalObject . actionPrivateWallet (
9492 [ tokenAddress ] ,
@@ -114,11 +112,8 @@ export async function payErc20FeeProxyRequestFromHinkalShieldedAddress(
114112 const signer = getSigner ( signerOrProvider ) ;
115113 const hinkalObject = await addToHinkalStore ( signer ) ;
116114
117- const { amountToPay, tokenAddress, ops } = prepareErc20FeeProxyPaymentFromHinkalShieldedAddress (
118- request ,
119- amount ,
120- feeAmount ,
121- ) ;
115+ const { amountToPay, tokenAddress, ops } =
116+ await prepareErc20FeeProxyPaymentFromHinkalShieldedAddress ( request , amount , feeAmount ) ;
122117
123118 return hinkalObject . actionPrivateWallet (
124119 [ tokenAddress ] ,
@@ -133,10 +128,10 @@ export async function payErc20FeeProxyRequestFromHinkalShieldedAddress(
133128 * @param request request to pay
134129 * @param amount optionally, the amount to pay. Defaults to remaining amount of the request.
135130 */
136- export function prepareErc20ProxyPaymentFromHinkalShieldedAddress (
131+ export async function prepareErc20ProxyPaymentFromHinkalShieldedAddress (
137132 request : ClientTypes . IRequestData ,
138133 amount ?: BigNumberish ,
139- ) : IPreparedPrivateTransaction {
134+ ) : Promise < IPreparedPrivateTransaction > {
140135 validateRequest ( request , ExtensionTypes . PAYMENT_NETWORK_ID . ERC20_PROXY_CONTRACT ) ;
141136
142137 const { value : tokenAddress } = request . currencyInfo ;
@@ -152,7 +147,6 @@ export function prepareErc20ProxyPaymentFromHinkalShieldedAddress(
152147 const amountToPay = getAmountToPay ( request , amount ) ;
153148 const { emporiumOp } = await import ( '@hinkal/common' ) ;
154149
155-
156150 const ops = [
157151 emporiumOp ( tokenContract , 'approve' , [ proxyContract . address , amountToPay ] ) ,
158152 emporiumOp ( proxyContract , 'transferFromWithReference' , [
@@ -176,11 +170,11 @@ export function prepareErc20ProxyPaymentFromHinkalShieldedAddress(
176170 * @param amount optionally, the amount to pay. Defaults to remaining amount of the request.
177171 * @param feeAmountOverride optionally, the fee amount to pay. Defaults to the fee amount of the request.
178172 */
179- export function prepareErc20FeeProxyPaymentFromHinkalShieldedAddress (
173+ export async function prepareErc20FeeProxyPaymentFromHinkalShieldedAddress (
180174 request : ClientTypes . IRequestData ,
181175 amount ?: BigNumberish ,
182176 feeAmountOverride ?: BigNumberish ,
183- ) : IPreparedPrivateTransaction {
177+ ) : Promise < IPreparedPrivateTransaction > {
184178 validateErc20FeeProxyRequest ( request , amount , feeAmountOverride ) ;
185179
186180 const { value : tokenAddress , network } = request . currencyInfo ;
0 commit comments