-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
985c344
commit b18615c
Showing
5 changed files
with
176 additions
and
48 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 was deleted.
Oops, something went wrong.
74 changes: 70 additions & 4 deletions
74
src/transaction-flow/input/BulkRenewal/BulkRenewal-flow.tsx
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,102 @@ | ||
import { TFunction } from 'react-i18next' | ||
import { goerli, holesky, localhost, mainnet, sepolia } from 'viem/chains' | ||
import { encodeFunctionData } from 'viem/utils' | ||
|
||
import type { Transaction, TransactionDisplayItem, TransactionFunctionParameters } from '@app/types' | ||
|
||
type Data = { names: `0x${string}`[]; durations: bigint[]; prices: bigint[] } | ||
|
||
export const targetExpiryAbi = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'string[]', | ||
name: 'names', | ||
type: 'string[]', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'targetExpiry', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'getTargetExpiryPriceData', | ||
outputs: [ | ||
{ | ||
internalType: 'uint256', | ||
name: 'total', | ||
type: 'uint256', | ||
}, | ||
{ | ||
internalType: 'uint256[]', | ||
name: 'durations', | ||
type: 'uint256[]', | ||
}, | ||
{ | ||
internalType: 'uint256[]', | ||
name: 'prices', | ||
type: 'uint256[]', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'string[]', | ||
name: 'names', | ||
type: 'string[]', | ||
}, | ||
{ | ||
internalType: 'uint256[]', | ||
name: 'durations', | ||
type: 'uint256[]', | ||
}, | ||
{ | ||
internalType: 'uint256[]', | ||
name: 'prices', | ||
type: 'uint256[]', | ||
}, | ||
], | ||
name: 'renewAllWithTargetExpiry', | ||
outputs: [], | ||
stateMutability: 'payable', | ||
type: 'function', | ||
}, | ||
] as const | ||
|
||
export const bulkRenewalContract = { | ||
[mainnet.id]: '0xnotdeployedyet', | ||
[goerli.id]: '0xdeprecated', | ||
[localhost.id]: '0xnotdeployedyet', | ||
[holesky.id]: '0x76aafA281Ed5155f83926a12ACB92e237e322A8C', | ||
[sepolia.id]: '0xf9c8c83adda8d52d9284cdbef23da10b5f9869bf', | ||
} as const | ||
|
||
const displayItems = ( | ||
{ names }: Data, | ||
t: TFunction<'translation', undefined>, | ||
): TransactionDisplayItem[] => [ | ||
{ | ||
label: 'names', | ||
value: names.map((name) => `0x${name}`).join(', '), | ||
}, | ||
{ | ||
label: 'action', | ||
value: t('transaction.info.fuses.CAN_EXTEND_EXPIRY'), | ||
}, | ||
] | ||
|
||
const transaction = async ({ client, data }: TransactionFunctionParameters<Data>) => { | ||
return { | ||
to: bulkRenewalContract[client.chain.id], | ||
data: encodeFunctionData({ | ||
abi: targetExpiryAbi, | ||
functionName: 'renewAllWithTargetExpiry', | ||
args: [data.names, data.durations, data.prices], | ||
}), | ||
} | ||
} | ||
|
||
export default { displayItems, transaction } satisfies Transaction<Data> |
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