mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-11 10:34:06 +00:00
[Spending Limit] Integration PR (#2308)
* Added spending limit reset function and call (#2262) * Added spending limit reset function and call * Fix: don't use DELEGATE_CALL in multisend tx and spending limits * Changed reset spending limit operation parameter from DELEGATE_CALL to CALL * Deleted operation parameter from MultiSendTx * Remove sort for Spent and ResetTime columns (#2295) * Fix spending limit enable check (#2299) * fix spending limit existence check Co-authored-by: juampibermani <30930241+juampibermani@users.noreply.github.com> Co-authored-by: katspaugh <katspaugh@gmail.com> Co-authored-by: nicolas <nicosampler@users.noreply.github.com> Co-authored-by: Fernando <fernando.greco@gmail.com>
This commit is contained in:
parent
7ad8ecf4c7
commit
08953e36c0
@ -157,7 +157,6 @@ export const enableSpendingLimitModuleMultiSendTx = (safeAddress: string): Multi
|
||||
to: multiSendTx.to,
|
||||
value: Number(multiSendTx.valueInWei),
|
||||
data: multiSendTx.txData as string,
|
||||
operation: DELEGATE_CALL,
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +167,16 @@ export const addSpendingLimitBeneficiaryMultiSendTx = (beneficiary: string): Mul
|
||||
to: SPENDING_LIMIT_MODULE_ADDRESS,
|
||||
value: 0,
|
||||
data: spendingLimitContract.methods.addDelegate(beneficiary).encodeABI(),
|
||||
operation: DELEGATE_CALL,
|
||||
}
|
||||
}
|
||||
|
||||
export const getResetSpendingLimitTx = (beneficiary: string, token: string): MultiSendTx => {
|
||||
const spendingLimitContract = getSpendingLimitContract()
|
||||
|
||||
return {
|
||||
to: SPENDING_LIMIT_MODULE_ADDRESS,
|
||||
value: 0,
|
||||
data: spendingLimitContract.methods.resetAllowance(beneficiary, token).encodeABI(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +218,6 @@ export const setSpendingLimitMultiSendTx = (args: SpendingLimitTxParams): MultiS
|
||||
to: tx.to,
|
||||
value: Number(tx.valueInWei),
|
||||
data: tx.txData as string,
|
||||
operation: DELEGATE_CALL,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,11 @@ describe('Upgrade a Safe', () => {
|
||||
const updateSafeTxData = safeInstance.methods.changeMasterCopy(SAFE_MASTER_COPY_ADDRESS).encodeABI()
|
||||
const txs = [
|
||||
{
|
||||
operation: 0,
|
||||
to: safeAddress,
|
||||
value: 0,
|
||||
data: updateSafeTxData,
|
||||
},
|
||||
{
|
||||
operation: 0,
|
||||
to: safeAddress,
|
||||
value: 0,
|
||||
data: fallbackHandlerTxData,
|
||||
|
@ -10,7 +10,6 @@ import { getWeb3 } from 'src/logic/wallets/getWeb3'
|
||||
import { MultiSend } from 'src/types/contracts/MultiSend.d'
|
||||
|
||||
export interface MultiSendTx {
|
||||
operation: number
|
||||
to: string
|
||||
value: number
|
||||
data: string
|
||||
@ -54,13 +53,11 @@ export const getUpgradeSafeTransactionHash = async (safeAddress: string): Promis
|
||||
const updateSafeTxData = safeInstance.methods.changeMasterCopy(SAFE_MASTER_COPY_ADDRESS).encodeABI()
|
||||
const txs = [
|
||||
{
|
||||
operation: 0,
|
||||
to: safeAddress,
|
||||
value: 0,
|
||||
data: updateSafeTxData,
|
||||
},
|
||||
{
|
||||
operation: 0,
|
||||
to: safeAddress,
|
||||
value: 0,
|
||||
data: fallbackHandlerTxData,
|
||||
|
@ -55,6 +55,7 @@ export const generateColumns = (): List<TableColumn> => {
|
||||
id: SPENDING_LIMIT_TABLE_SPENT_ID,
|
||||
label: 'Spent',
|
||||
order: false,
|
||||
static: true,
|
||||
}
|
||||
|
||||
const resetColumn: TableColumn = {
|
||||
@ -64,6 +65,7 @@ export const generateColumns = (): List<TableColumn> => {
|
||||
id: SPENDING_LIMIT_TABLE_RESET_TIME_ID,
|
||||
label: 'Reset Time',
|
||||
order: false,
|
||||
static: true,
|
||||
}
|
||||
|
||||
const actionsColumn: TableColumn = {
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
addSpendingLimitBeneficiaryMultiSendTx,
|
||||
currentMinutes,
|
||||
enableSpendingLimitModuleMultiSendTx,
|
||||
getResetSpendingLimitTx,
|
||||
setSpendingLimitMultiSendTx,
|
||||
setSpendingLimitTx,
|
||||
spendingLimitMultiSendTx,
|
||||
@ -80,7 +81,8 @@ const calculateSpendingLimitsTxData = (
|
||||
resetBaseMin: number
|
||||
}
|
||||
} => {
|
||||
const isSpendingLimitEnabled = spendingLimits !== null
|
||||
// enabled if it's an array with at least one element
|
||||
const isSpendingLimitEnabled = !!spendingLimits?.length
|
||||
const transactions: MultiSendTx[] = []
|
||||
|
||||
// is spendingLimit module enabled? -> if not, create the tx to enable it, and encode it
|
||||
@ -98,6 +100,10 @@ const calculateSpendingLimitsTxData = (
|
||||
transactions.push(addSpendingLimitBeneficiaryMultiSendTx(values.beneficiary))
|
||||
}
|
||||
|
||||
if (existentSpendingLimit && existentSpendingLimit.spent !== '0') {
|
||||
transactions.push(getResetSpendingLimitTx(existentSpendingLimit.delegate, txToken.address))
|
||||
}
|
||||
|
||||
// prepare the setAllowance tx
|
||||
const startTime = currentMinutes() - 30
|
||||
const spendingLimitArgs = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user