@sudobility/contracts 1.17.28 → 1.17.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -1
- package/dist/react-native/src/evm/evm-mailer-client.d.ts +1277 -0
- package/dist/react-native/src/evm/evm-mailer-client.d.ts.map +1 -0
- package/dist/react-native/src/evm/evm-mailer-client.js +968 -0
- package/dist/react-native/src/evm/evm-mailer-client.js.map +1 -0
- package/dist/react-native/src/evm/index.d.ts +4 -0
- package/dist/react-native/src/evm/index.d.ts.map +1 -0
- package/dist/react-native/src/evm/index.js +5 -0
- package/dist/react-native/src/evm/index.js.map +1 -0
- package/dist/react-native/src/react-native/index.d.ts +23 -0
- package/dist/react-native/src/react-native/index.d.ts.map +1 -0
- package/dist/react-native/src/react-native/index.js +23 -0
- package/dist/react-native/src/react-native/index.js.map +1 -0
- package/dist/react-native/src/react-native/polyfills.d.ts +39 -0
- package/dist/react-native/src/react-native/polyfills.d.ts.map +1 -0
- package/dist/react-native/src/react-native/polyfills.js +75 -0
- package/dist/react-native/src/react-native/polyfills.js.map +1 -0
- package/dist/react-native/src/solana/index.d.ts +3 -0
- package/dist/react-native/src/solana/index.d.ts.map +1 -0
- package/dist/react-native/src/solana/index.js +4 -0
- package/dist/react-native/src/solana/index.js.map +1 -0
- package/dist/react-native/src/solana/solana-mailer-client.d.ts +213 -0
- package/dist/react-native/src/solana/solana-mailer-client.d.ts.map +1 -0
- package/dist/react-native/src/solana/solana-mailer-client.js +1055 -0
- package/dist/react-native/src/solana/solana-mailer-client.js.map +1 -0
- package/dist/react-native/src/solana/types.d.ts +29 -0
- package/dist/react-native/src/solana/types.d.ts.map +1 -0
- package/dist/react-native/src/solana/types.js +16 -0
- package/dist/react-native/src/solana/types.js.map +1 -0
- package/dist/react-native/src/unified/index.d.ts +4 -0
- package/dist/react-native/src/unified/index.d.ts.map +1 -0
- package/dist/react-native/src/unified/index.js +4 -0
- package/dist/react-native/src/unified/index.js.map +1 -0
- package/dist/react-native/src/unified/onchain-mailer-client.d.ts +280 -0
- package/dist/react-native/src/unified/onchain-mailer-client.d.ts.map +1 -0
- package/dist/react-native/src/unified/onchain-mailer-client.js +837 -0
- package/dist/react-native/src/unified/onchain-mailer-client.js.map +1 -0
- package/dist/react-native/src/unified/types.d.ts +54 -0
- package/dist/react-native/src/unified/types.d.ts.map +1 -0
- package/dist/react-native/src/unified/types.js +2 -0
- package/dist/react-native/src/unified/types.js.map +1 -0
- package/dist/react-native/src/unified/wallet-detector.d.ts +28 -0
- package/dist/react-native/src/unified/wallet-detector.d.ts.map +1 -0
- package/dist/react-native/src/unified/wallet-detector.js +59 -0
- package/dist/react-native/src/unified/wallet-detector.js.map +1 -0
- package/dist/react-native/src/utils/chain-config.d.ts +75 -0
- package/dist/react-native/src/utils/chain-config.d.ts.map +1 -0
- package/dist/react-native/src/utils/chain-config.js +199 -0
- package/dist/react-native/src/utils/chain-config.js.map +1 -0
- package/dist/react-native/src/utils/currency.d.ts +26 -0
- package/dist/react-native/src/utils/currency.d.ts.map +1 -0
- package/dist/react-native/src/utils/currency.js +31 -0
- package/dist/react-native/src/utils/currency.js.map +1 -0
- package/dist/react-native/src/utils/index.d.ts +4 -0
- package/dist/react-native/src/utils/index.d.ts.map +1 -0
- package/dist/react-native/src/utils/index.js +4 -0
- package/dist/react-native/src/utils/index.js.map +1 -0
- package/dist/react-native/src/utils/validation.d.ts +10 -0
- package/dist/react-native/src/utils/validation.d.ts.map +1 -0
- package/dist/react-native/src/utils/validation.js +96 -0
- package/dist/react-native/src/utils/validation.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/index.d.ts +7 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/IERC1967.d.ts +66 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/IERC1967.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/IERC1967.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/IERC1967.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.d.ts +26 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.d.ts +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/index.d.ts +4 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/interfaces/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.d.ts +21 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/index.d.ts +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/ERC1967/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/IBeacon.d.ts +26 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/IBeacon.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/IBeacon.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/IBeacon.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/index.d.ts +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/beacon/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/index.d.ts +5 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/proxy/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Address.d.ts +21 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Address.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Address.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Address.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Errors.d.ts +21 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Errors.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Errors.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/Errors.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/index.d.ts +3 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts/utils/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.d.ts +69 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/index.d.ts +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/access/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/index.d.ts +7 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/index.d.ts +3 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.d.ts +37 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.d.ts +74 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts +3 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/proxy/utils/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.d.ts +37 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/index.d.ts +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/contracts-upgradeable/utils/index.js.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/index.d.ts +5 -0
- package/dist/react-native/typechain-types/@openzeppelin/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/@openzeppelin/index.js +2 -0
- package/dist/react-native/typechain-types/@openzeppelin/index.js.map +1 -0
- package/dist/react-native/typechain-types/common.d.ts +51 -0
- package/dist/react-native/typechain-types/common.d.ts.map +1 -0
- package/dist/react-native/typechain-types/common.js +2 -0
- package/dist/react-native/typechain-types/common.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/Mailer.d.ts +845 -0
- package/dist/react-native/typechain-types/contracts/Mailer.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/Mailer.js +2 -0
- package/dist/react-native/typechain-types/contracts/Mailer.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/MockUSDC.d.ts +118 -0
- package/dist/react-native/typechain-types/contracts/MockUSDC.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/MockUSDC.js +2 -0
- package/dist/react-native/typechain-types/contracts/MockUSDC.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/examples/MailerIntegrationExample.d.ts +170 -0
- package/dist/react-native/typechain-types/contracts/examples/MailerIntegrationExample.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/examples/MailerIntegrationExample.js +2 -0
- package/dist/react-native/typechain-types/contracts/examples/MailerIntegrationExample.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/examples/index.d.ts +2 -0
- package/dist/react-native/typechain-types/contracts/examples/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/examples/index.js +2 -0
- package/dist/react-native/typechain-types/contracts/examples/index.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/index.d.ts +7 -0
- package/dist/react-native/typechain-types/contracts/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/index.js +2 -0
- package/dist/react-native/typechain-types/contracts/index.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IERC20.d.ts +70 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IERC20.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IERC20.js +2 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IERC20.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IMailer.d.ts +118 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IMailer.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IMailer.js +2 -0
- package/dist/react-native/typechain-types/contracts/interfaces/IMailer.js.map +1 -0
- package/dist/react-native/typechain-types/contracts/interfaces/index.d.ts +3 -0
- package/dist/react-native/typechain-types/contracts/interfaces/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/contracts/interfaces/index.js +2 -0
- package/dist/react-native/typechain-types/contracts/interfaces/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/index.d.ts +4 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/index.js +7 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1967__factory.d.ts +43 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1967__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1967__factory.js +61 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1967__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable__factory.d.ts +18 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable__factory.js +29 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/IERC1822Proxiable__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.js +5 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC1822.sol/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/index.js +6 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/interfaces/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils__factory.d.ts +51 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils__factory.js +74 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/index.js +5 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/ERC1967/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/IBeacon__factory.d.ts +18 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/IBeacon__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/IBeacon__factory.js +29 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/IBeacon__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/index.js +5 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/beacon/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/index.js +6 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/proxy/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.d.ts +31 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.js +47 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Errors__factory.d.ts +51 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Errors__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Errors__factory.js +73 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/Errors__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/index.js +6 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts/utils/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.d.ts +83 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.js +113 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/index.js +5 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/access/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/index.d.ts +4 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/index.js +7 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/index.js +5 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.d.ts +26 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.js +39 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable__factory.d.ts +106 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable__factory.js +144 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.js +6 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.d.ts +26 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.js +39 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/index.js +5 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/contracts-upgradeable/utils/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/index.js +6 -0
- package/dist/react-native/typechain-types/factories/@openzeppelin/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/Mailer__factory.d.ts +1086 -0
- package/dist/react-native/typechain-types/factories/contracts/Mailer__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/Mailer__factory.js +1390 -0
- package/dist/react-native/typechain-types/factories/contracts/Mailer__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/MockUSDC__factory.d.ts +193 -0
- package/dist/react-native/typechain-types/factories/contracts/MockUSDC__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/MockUSDC__factory.js +259 -0
- package/dist/react-native/typechain-types/factories/contracts/MockUSDC__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/MailerIntegrationExample__factory.d.ts +209 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/MailerIntegrationExample__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/MailerIntegrationExample__factory.js +274 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/MailerIntegrationExample__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/index.d.ts +2 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/index.js +5 -0
- package/dist/react-native/typechain-types/factories/contracts/examples/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/index.d.ts +5 -0
- package/dist/react-native/typechain-types/factories/contracts/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/index.js +8 -0
- package/dist/react-native/typechain-types/factories/contracts/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IERC20__factory.d.ts +80 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IERC20__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IERC20__factory.js +112 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IERC20__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IMailer__factory.d.ts +130 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IMailer__factory.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IMailer__factory.js +171 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/IMailer__factory.js.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/index.js +6 -0
- package/dist/react-native/typechain-types/factories/contracts/interfaces/index.js.map +1 -0
- package/dist/react-native/typechain-types/factories/index.d.ts +3 -0
- package/dist/react-native/typechain-types/factories/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/factories/index.js +6 -0
- package/dist/react-native/typechain-types/factories/index.js.map +1 -0
- package/dist/react-native/typechain-types/index.d.ts +36 -0
- package/dist/react-native/typechain-types/index.d.ts.map +1 -0
- package/dist/react-native/typechain-types/index.js +17 -0
- package/dist/react-native/typechain-types/index.js.map +1 -0
- package/package.json +63 -5
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
import { getAddress, EstimateGasExecutionError, } from 'viem';
|
|
2
|
+
import { Mailer__factory } from '../../typechain-types/factories/contracts/Mailer__factory';
|
|
3
|
+
const MAILER_ABI = Mailer__factory.abi;
|
|
4
|
+
const MAILER_BYTECODE = Mailer__factory.bytecode;
|
|
5
|
+
/**
|
|
6
|
+
* Normalize any Address-like input (string with checksum or lowercase) to checksum format.
|
|
7
|
+
*/
|
|
8
|
+
function normalizeAddress(value) {
|
|
9
|
+
return getAddress(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Stateless EVM Mailer client.
|
|
13
|
+
* All methods take wallet and chainInfo as parameters.
|
|
14
|
+
* No state is stored in the instance.
|
|
15
|
+
*/
|
|
16
|
+
export class EVMMailerClient {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.defaultGasMultiplier = 1.2; // 20% buffer by default
|
|
19
|
+
// Default gas limits for common operations to use as fallbacks
|
|
20
|
+
// Updated after contract optimizations (storage packing, uint128/uint8, delete vs zero, caching)
|
|
21
|
+
this.defaultGasLimits = {
|
|
22
|
+
send: BigInt(135000), // Reduced ~10% (optimized storage + permission check)
|
|
23
|
+
sendPriority: BigInt(180000), // Reduced ~10% (optimized _recordShares)
|
|
24
|
+
sendPrepared: BigInt(110000), // Reduced ~8% (optimized storage)
|
|
25
|
+
sendPriorityPrepared: BigInt(135000), // Reduced ~10% (optimized _recordShares)
|
|
26
|
+
sendThroughWebhook: BigInt(110000), // Reduced ~8% (optimized storage)
|
|
27
|
+
sendToEmailAddress: BigInt(110000), // Reduced ~8% (optimized storage)
|
|
28
|
+
sendPreparedToEmailAddress: BigInt(110000), // Reduced ~8% (optimized storage)
|
|
29
|
+
claimRevenue: BigInt(85000), // Reduced ~15% (delete optimization + gas refund)
|
|
30
|
+
claimOwnerShare: BigInt(85000), // Reduced ~15% (uint128 + caching)
|
|
31
|
+
delegateTo: BigInt(70000), // Reduced ~12% (uint128 delegation fee)
|
|
32
|
+
rejectDelegation: BigInt(70000), // Reduced ~12% (optimized storage)
|
|
33
|
+
setFee: BigInt(50000), // Reduced ~17% (uint128)
|
|
34
|
+
setFeePaused: BigInt(50000), // Reduced ~17% (bool packing)
|
|
35
|
+
setDelegationFee: BigInt(50000), // Reduced ~17% (uint128)
|
|
36
|
+
setCustomFeePercentage: BigInt(50000), // Reduced ~17% (uint8)
|
|
37
|
+
clearCustomFeePercentage: BigInt(50000), // Reduced ~17% (uint8)
|
|
38
|
+
setPermission: BigInt(50000), // Reduced ~17% (optimized modifier)
|
|
39
|
+
removePermission: BigInt(50000), // Reduced ~17% (optimized modifier)
|
|
40
|
+
pause: BigInt(45000), // Reduced ~10% (caching)
|
|
41
|
+
unpause: BigInt(45000), // Reduced ~10% (simple state change)
|
|
42
|
+
emergencyUnpause: BigInt(45000), // Reduced ~10% (simple state change)
|
|
43
|
+
distributeClaimableFunds: BigInt(85000), // Reduced ~15% (delete optimization)
|
|
44
|
+
deploy: BigInt(2800000), // Reduced ~7% (optimized contract size)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Ensure publicClient is provided
|
|
49
|
+
*/
|
|
50
|
+
ensurePublicClient(publicClient) {
|
|
51
|
+
if (!publicClient) {
|
|
52
|
+
throw new Error('PublicClient is required for this operation. Please provide it in the EVMWallet.');
|
|
53
|
+
}
|
|
54
|
+
return publicClient;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Switch chain if needed for EVM wallet
|
|
58
|
+
*/
|
|
59
|
+
async switchChainIfNeeded(walletClient, targetChainId) {
|
|
60
|
+
try {
|
|
61
|
+
const currentChainId = walletClient.chain?.id;
|
|
62
|
+
if (currentChainId && currentChainId !== targetChainId) {
|
|
63
|
+
// Request chain switch
|
|
64
|
+
await walletClient.request({
|
|
65
|
+
method: 'wallet_switchEthereumChain',
|
|
66
|
+
params: [{ chainId: `0x${targetChainId.toString(16)}` }]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.warn('Chain switch failed or not supported:', error);
|
|
72
|
+
// Continue anyway - the transaction might still work
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Helper method to estimate gas for a transaction with optional buffer
|
|
77
|
+
*/
|
|
78
|
+
async estimateGasWithBuffer(estimateFn, gasOptions, fallbackGasLimit) {
|
|
79
|
+
// If gas limit is explicitly provided, use it
|
|
80
|
+
if (gasOptions?.gasLimit) {
|
|
81
|
+
return gasOptions.gasLimit;
|
|
82
|
+
}
|
|
83
|
+
let estimatedGas;
|
|
84
|
+
let retryCount = 0;
|
|
85
|
+
const maxRetries = 2;
|
|
86
|
+
while (retryCount <= maxRetries) {
|
|
87
|
+
try {
|
|
88
|
+
// Estimate gas for the transaction
|
|
89
|
+
estimatedGas = await estimateFn();
|
|
90
|
+
break; // Success, exit retry loop
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
retryCount++;
|
|
94
|
+
// If we've exhausted retries, use fallback or throw
|
|
95
|
+
if (retryCount > maxRetries) {
|
|
96
|
+
if (fallbackGasLimit) {
|
|
97
|
+
console.warn(`Gas estimation failed after ${maxRetries} retries, using fallback: ${fallbackGasLimit}`);
|
|
98
|
+
estimatedGas = fallbackGasLimit;
|
|
99
|
+
}
|
|
100
|
+
else if (error instanceof EstimateGasExecutionError) {
|
|
101
|
+
throw new Error(`Gas estimation failed: ${error.message}`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Wait before retrying (exponential backoff)
|
|
109
|
+
await new Promise(resolve => setTimeout(resolve, 1000 * retryCount));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Apply multiplier for safety buffer
|
|
114
|
+
const multiplier = gasOptions?.gasMultiplier ?? this.defaultGasMultiplier;
|
|
115
|
+
let gasWithBuffer = BigInt(Math.ceil(Number(estimatedGas) * multiplier));
|
|
116
|
+
// If we have a fallback and the estimated gas is suspiciously low, use the fallback
|
|
117
|
+
// This handles cases where RPC returns incorrect low estimates (e.g., Sepolia returning 26,897)
|
|
118
|
+
if (fallbackGasLimit && gasWithBuffer < fallbackGasLimit) {
|
|
119
|
+
console.warn(`Estimated gas ${gasWithBuffer} is below fallback ${fallbackGasLimit}, using fallback`);
|
|
120
|
+
gasWithBuffer = fallbackGasLimit;
|
|
121
|
+
}
|
|
122
|
+
// Apply max gas limit if specified
|
|
123
|
+
if (gasOptions?.maxGasLimit) {
|
|
124
|
+
return gasWithBuffer > gasOptions.maxGasLimit ? gasOptions.maxGasLimit : gasWithBuffer;
|
|
125
|
+
}
|
|
126
|
+
return gasWithBuffer;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Helper method to build transaction parameters with gas options
|
|
130
|
+
*/
|
|
131
|
+
buildTxParams(gasLimit, gasOptions) {
|
|
132
|
+
const params = { gas: gasLimit };
|
|
133
|
+
if (gasOptions?.maxFeePerGas) {
|
|
134
|
+
params.maxFeePerGas = gasOptions.maxFeePerGas;
|
|
135
|
+
}
|
|
136
|
+
if (gasOptions?.maxPriorityFeePerGas) {
|
|
137
|
+
params.maxPriorityFeePerGas = gasOptions.maxPriorityFeePerGas;
|
|
138
|
+
}
|
|
139
|
+
return params;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Deploy a fresh Mailer contract instance
|
|
143
|
+
*/
|
|
144
|
+
async deploy(connectedWallet, chainInfo, ownerAddress, gasOptions) {
|
|
145
|
+
if (!chainInfo.usdcAddress) {
|
|
146
|
+
throw new Error(`No USDC address configured for chain ${chainInfo.name}`);
|
|
147
|
+
}
|
|
148
|
+
// Switch chain if needed
|
|
149
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
150
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
151
|
+
// For deployment, use a reasonable default gas
|
|
152
|
+
const estimatedGas = BigInt(3000000);
|
|
153
|
+
const multiplier = gasOptions?.gasMultiplier ?? 1.5;
|
|
154
|
+
const gasLimit = gasOptions?.gasLimit ?? BigInt(Math.ceil(Number(estimatedGas) * multiplier));
|
|
155
|
+
const hash = await connectedWallet.walletClient.deployContract({
|
|
156
|
+
abi: MAILER_ABI,
|
|
157
|
+
bytecode: MAILER_BYTECODE,
|
|
158
|
+
// UUPS proxy pattern: constructor takes no args, initialize() is called separately
|
|
159
|
+
args: [],
|
|
160
|
+
account,
|
|
161
|
+
chain: connectedWallet.walletClient.chain,
|
|
162
|
+
gas: gasLimit,
|
|
163
|
+
...(gasOptions?.maxFeePerGas && { maxFeePerGas: gasOptions.maxFeePerGas }),
|
|
164
|
+
...(gasOptions?.maxPriorityFeePerGas && { maxPriorityFeePerGas: gasOptions.maxPriorityFeePerGas }),
|
|
165
|
+
});
|
|
166
|
+
return { hash, estimatedGas, gasLimit };
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Core message send with explicit payer control
|
|
170
|
+
*/
|
|
171
|
+
async send(connectedWallet, chainInfo, to, subject, body, payer, revenueShareToReceiver, resolveSenderToName, gasOptions) {
|
|
172
|
+
if (!chainInfo.mailerAddress) {
|
|
173
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
174
|
+
}
|
|
175
|
+
// Switch chain if needed
|
|
176
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
177
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
178
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
179
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
180
|
+
// Estimate gas for the transaction
|
|
181
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
182
|
+
address: contractAddress,
|
|
183
|
+
abi: MAILER_ABI,
|
|
184
|
+
functionName: 'send',
|
|
185
|
+
args: [
|
|
186
|
+
normalizeAddress(to),
|
|
187
|
+
subject,
|
|
188
|
+
body,
|
|
189
|
+
normalizeAddress(payer),
|
|
190
|
+
revenueShareToReceiver,
|
|
191
|
+
resolveSenderToName,
|
|
192
|
+
],
|
|
193
|
+
account,
|
|
194
|
+
}), gasOptions, this.defaultGasLimits.send);
|
|
195
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
196
|
+
address: contractAddress,
|
|
197
|
+
abi: MAILER_ABI,
|
|
198
|
+
functionName: 'send',
|
|
199
|
+
args: [
|
|
200
|
+
normalizeAddress(to),
|
|
201
|
+
subject,
|
|
202
|
+
body,
|
|
203
|
+
normalizeAddress(payer),
|
|
204
|
+
revenueShareToReceiver,
|
|
205
|
+
resolveSenderToName,
|
|
206
|
+
],
|
|
207
|
+
account,
|
|
208
|
+
chain: connectedWallet.walletClient.chain,
|
|
209
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
210
|
+
});
|
|
211
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Send a prepared message
|
|
215
|
+
*/
|
|
216
|
+
async sendPrepared(connectedWallet, chainInfo, to, mailId, payer, revenueShareToReceiver, resolveSenderToName, gasOptions) {
|
|
217
|
+
if (!chainInfo.mailerAddress) {
|
|
218
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
219
|
+
}
|
|
220
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
221
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
222
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
223
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
224
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
225
|
+
address: contractAddress,
|
|
226
|
+
abi: MAILER_ABI,
|
|
227
|
+
functionName: 'sendPrepared',
|
|
228
|
+
args: [
|
|
229
|
+
normalizeAddress(to),
|
|
230
|
+
mailId,
|
|
231
|
+
normalizeAddress(payer),
|
|
232
|
+
revenueShareToReceiver,
|
|
233
|
+
resolveSenderToName,
|
|
234
|
+
],
|
|
235
|
+
account,
|
|
236
|
+
}), gasOptions, this.defaultGasLimits.sendPrepared);
|
|
237
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
238
|
+
address: contractAddress,
|
|
239
|
+
abi: MAILER_ABI,
|
|
240
|
+
functionName: 'sendPrepared',
|
|
241
|
+
args: [
|
|
242
|
+
normalizeAddress(to),
|
|
243
|
+
mailId,
|
|
244
|
+
normalizeAddress(payer),
|
|
245
|
+
revenueShareToReceiver,
|
|
246
|
+
resolveSenderToName,
|
|
247
|
+
],
|
|
248
|
+
account,
|
|
249
|
+
chain: connectedWallet.walletClient.chain,
|
|
250
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
251
|
+
});
|
|
252
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Send through webhook
|
|
256
|
+
*/
|
|
257
|
+
async sendThroughWebhook(connectedWallet, chainInfo, to, webhookId, payer, revenueShareToReceiver, resolveSenderToName, gasOptions) {
|
|
258
|
+
if (!chainInfo.mailerAddress) {
|
|
259
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
260
|
+
}
|
|
261
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
262
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
263
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
264
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
265
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
266
|
+
address: contractAddress,
|
|
267
|
+
abi: MAILER_ABI,
|
|
268
|
+
functionName: 'sendThroughWebhook',
|
|
269
|
+
args: [
|
|
270
|
+
normalizeAddress(to),
|
|
271
|
+
webhookId,
|
|
272
|
+
normalizeAddress(payer),
|
|
273
|
+
revenueShareToReceiver,
|
|
274
|
+
resolveSenderToName,
|
|
275
|
+
],
|
|
276
|
+
account,
|
|
277
|
+
}), gasOptions, this.defaultGasLimits.sendThroughWebhook);
|
|
278
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
279
|
+
address: contractAddress,
|
|
280
|
+
abi: MAILER_ABI,
|
|
281
|
+
functionName: 'sendThroughWebhook',
|
|
282
|
+
args: [
|
|
283
|
+
normalizeAddress(to),
|
|
284
|
+
webhookId,
|
|
285
|
+
normalizeAddress(payer),
|
|
286
|
+
revenueShareToReceiver,
|
|
287
|
+
resolveSenderToName,
|
|
288
|
+
],
|
|
289
|
+
account,
|
|
290
|
+
chain: connectedWallet.walletClient.chain,
|
|
291
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
292
|
+
});
|
|
293
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Send to email address
|
|
297
|
+
*/
|
|
298
|
+
async sendToEmailAddress(connectedWallet, chainInfo, toEmail, subject, body, payer, gasOptions) {
|
|
299
|
+
if (!chainInfo.mailerAddress) {
|
|
300
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
301
|
+
}
|
|
302
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
303
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
304
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
305
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
306
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
307
|
+
address: contractAddress,
|
|
308
|
+
abi: MAILER_ABI,
|
|
309
|
+
functionName: 'sendToEmailAddress',
|
|
310
|
+
args: [toEmail, subject, body, normalizeAddress(payer)],
|
|
311
|
+
account,
|
|
312
|
+
}), gasOptions, this.defaultGasLimits.sendToEmailAddress);
|
|
313
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
314
|
+
address: contractAddress,
|
|
315
|
+
abi: MAILER_ABI,
|
|
316
|
+
functionName: 'sendToEmailAddress',
|
|
317
|
+
args: [toEmail, subject, body, normalizeAddress(payer)],
|
|
318
|
+
account,
|
|
319
|
+
chain: connectedWallet.walletClient.chain,
|
|
320
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
321
|
+
});
|
|
322
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Send prepared to email address
|
|
326
|
+
*/
|
|
327
|
+
async sendPreparedToEmailAddress(connectedWallet, chainInfo, toEmail, mailId, payer, gasOptions) {
|
|
328
|
+
if (!chainInfo.mailerAddress) {
|
|
329
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
330
|
+
}
|
|
331
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
332
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
333
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
334
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
335
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
336
|
+
address: contractAddress,
|
|
337
|
+
abi: MAILER_ABI,
|
|
338
|
+
functionName: 'sendPreparedToEmailAddress',
|
|
339
|
+
args: [toEmail, mailId, normalizeAddress(payer)],
|
|
340
|
+
account,
|
|
341
|
+
}), gasOptions, this.defaultGasLimits.sendPreparedToEmailAddress);
|
|
342
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
343
|
+
address: contractAddress,
|
|
344
|
+
abi: MAILER_ABI,
|
|
345
|
+
functionName: 'sendPreparedToEmailAddress',
|
|
346
|
+
args: [toEmail, mailId, normalizeAddress(payer)],
|
|
347
|
+
account,
|
|
348
|
+
chain: connectedWallet.walletClient.chain,
|
|
349
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
350
|
+
});
|
|
351
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Get the current send fee
|
|
355
|
+
*/
|
|
356
|
+
async getSendFee(chainInfo, publicClient) {
|
|
357
|
+
if (!chainInfo.mailerAddress) {
|
|
358
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
359
|
+
}
|
|
360
|
+
const client = this.ensurePublicClient(publicClient);
|
|
361
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
362
|
+
return await client.readContract({
|
|
363
|
+
address: contractAddress,
|
|
364
|
+
abi: MAILER_ABI,
|
|
365
|
+
functionName: 'sendFee',
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Set the send fee (owner only)
|
|
370
|
+
*/
|
|
371
|
+
async setFee(connectedWallet, chainInfo, usdcAmount, gasOptions) {
|
|
372
|
+
if (!chainInfo.mailerAddress) {
|
|
373
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
374
|
+
}
|
|
375
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
376
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
377
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
378
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
379
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
380
|
+
address: contractAddress,
|
|
381
|
+
abi: MAILER_ABI,
|
|
382
|
+
functionName: 'setFee',
|
|
383
|
+
args: [BigInt(usdcAmount)],
|
|
384
|
+
account,
|
|
385
|
+
}), gasOptions, this.defaultGasLimits.setFee);
|
|
386
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
387
|
+
address: contractAddress,
|
|
388
|
+
abi: MAILER_ABI,
|
|
389
|
+
functionName: 'setFee',
|
|
390
|
+
args: [BigInt(usdcAmount)],
|
|
391
|
+
account,
|
|
392
|
+
chain: connectedWallet.walletClient.chain,
|
|
393
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
394
|
+
});
|
|
395
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Set fee paused state (owner only)
|
|
399
|
+
*/
|
|
400
|
+
async setFeePaused(connectedWallet, chainInfo, feePaused, gasOptions) {
|
|
401
|
+
if (!chainInfo.mailerAddress) {
|
|
402
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
403
|
+
}
|
|
404
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
405
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
406
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
407
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
408
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
409
|
+
address: contractAddress,
|
|
410
|
+
abi: MAILER_ABI,
|
|
411
|
+
functionName: 'setFeePaused',
|
|
412
|
+
args: [feePaused],
|
|
413
|
+
account,
|
|
414
|
+
}), gasOptions, this.defaultGasLimits.setFeePaused);
|
|
415
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
416
|
+
address: contractAddress,
|
|
417
|
+
abi: MAILER_ABI,
|
|
418
|
+
functionName: 'setFeePaused',
|
|
419
|
+
args: [feePaused],
|
|
420
|
+
account,
|
|
421
|
+
chain: connectedWallet.walletClient.chain,
|
|
422
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
423
|
+
});
|
|
424
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Get USDC token address
|
|
428
|
+
*/
|
|
429
|
+
async getUsdcToken(chainInfo, publicClient) {
|
|
430
|
+
if (!chainInfo.mailerAddress) {
|
|
431
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
432
|
+
}
|
|
433
|
+
const client = this.ensurePublicClient(publicClient);
|
|
434
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
435
|
+
return await client.readContract({
|
|
436
|
+
address: contractAddress,
|
|
437
|
+
abi: MAILER_ABI,
|
|
438
|
+
functionName: 'usdcToken',
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Get contract owner
|
|
443
|
+
*/
|
|
444
|
+
async getOwner(chainInfo, publicClient) {
|
|
445
|
+
if (!chainInfo.mailerAddress) {
|
|
446
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
447
|
+
}
|
|
448
|
+
const client = this.ensurePublicClient(publicClient);
|
|
449
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
450
|
+
return await client.readContract({
|
|
451
|
+
address: contractAddress,
|
|
452
|
+
abi: MAILER_ABI,
|
|
453
|
+
functionName: 'owner',
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Claim recipient share
|
|
458
|
+
*/
|
|
459
|
+
async claimRecipientShare(connectedWallet, chainInfo, gasOptions) {
|
|
460
|
+
if (!chainInfo.mailerAddress) {
|
|
461
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
462
|
+
}
|
|
463
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
464
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
465
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
466
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
467
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
468
|
+
address: contractAddress,
|
|
469
|
+
abi: MAILER_ABI,
|
|
470
|
+
functionName: 'claimRecipientShare',
|
|
471
|
+
args: [],
|
|
472
|
+
account,
|
|
473
|
+
}), gasOptions, this.defaultGasLimits.claimRevenue);
|
|
474
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
475
|
+
address: contractAddress,
|
|
476
|
+
abi: MAILER_ABI,
|
|
477
|
+
functionName: 'claimRecipientShare',
|
|
478
|
+
args: [],
|
|
479
|
+
account,
|
|
480
|
+
chain: connectedWallet.walletClient.chain,
|
|
481
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
482
|
+
});
|
|
483
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Claim owner share (owner only)
|
|
487
|
+
*/
|
|
488
|
+
async claimOwnerShare(connectedWallet, chainInfo, gasOptions) {
|
|
489
|
+
if (!chainInfo.mailerAddress) {
|
|
490
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
491
|
+
}
|
|
492
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
493
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
494
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
495
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
496
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
497
|
+
address: contractAddress,
|
|
498
|
+
abi: MAILER_ABI,
|
|
499
|
+
functionName: 'claimOwnerShare',
|
|
500
|
+
args: [],
|
|
501
|
+
account,
|
|
502
|
+
}), gasOptions);
|
|
503
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
504
|
+
address: contractAddress,
|
|
505
|
+
abi: MAILER_ABI,
|
|
506
|
+
functionName: 'claimOwnerShare',
|
|
507
|
+
args: [],
|
|
508
|
+
account,
|
|
509
|
+
chain: connectedWallet.walletClient.chain,
|
|
510
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
511
|
+
});
|
|
512
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Claim expired shares (owner only)
|
|
516
|
+
*/
|
|
517
|
+
async claimExpiredShares(connectedWallet, chainInfo, recipient, gasOptions) {
|
|
518
|
+
if (!chainInfo.mailerAddress) {
|
|
519
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
520
|
+
}
|
|
521
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
522
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
523
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
524
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
525
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
526
|
+
address: contractAddress,
|
|
527
|
+
abi: MAILER_ABI,
|
|
528
|
+
functionName: 'claimExpiredShares',
|
|
529
|
+
args: [normalizeAddress(recipient)],
|
|
530
|
+
account,
|
|
531
|
+
}), gasOptions);
|
|
532
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
533
|
+
address: contractAddress,
|
|
534
|
+
abi: MAILER_ABI,
|
|
535
|
+
functionName: 'claimExpiredShares',
|
|
536
|
+
args: [normalizeAddress(recipient)],
|
|
537
|
+
account,
|
|
538
|
+
chain: connectedWallet.walletClient.chain,
|
|
539
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
540
|
+
});
|
|
541
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Get recipient claimable info
|
|
545
|
+
*/
|
|
546
|
+
async getRecipientClaimable(recipient, chainInfo, publicClient) {
|
|
547
|
+
if (!chainInfo.mailerAddress) {
|
|
548
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
549
|
+
}
|
|
550
|
+
const client = this.ensurePublicClient(publicClient);
|
|
551
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
552
|
+
const result = await client.readContract({
|
|
553
|
+
address: contractAddress,
|
|
554
|
+
abi: MAILER_ABI,
|
|
555
|
+
functionName: 'getRecipientClaimable',
|
|
556
|
+
args: [normalizeAddress(recipient)],
|
|
557
|
+
});
|
|
558
|
+
return {
|
|
559
|
+
amount: result[0],
|
|
560
|
+
expiresAt: result[1],
|
|
561
|
+
isExpired: result[2],
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Get owner claimable amount
|
|
566
|
+
*/
|
|
567
|
+
async getOwnerClaimable(chainInfo, publicClient) {
|
|
568
|
+
if (!chainInfo.mailerAddress) {
|
|
569
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
570
|
+
}
|
|
571
|
+
const client = this.ensurePublicClient(publicClient);
|
|
572
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
573
|
+
return await client.readContract({
|
|
574
|
+
address: contractAddress,
|
|
575
|
+
abi: MAILER_ABI,
|
|
576
|
+
functionName: 'ownerClaimable',
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Delegate to another address
|
|
581
|
+
*/
|
|
582
|
+
async delegateTo(connectedWallet, chainInfo, delegate, gasOptions) {
|
|
583
|
+
if (!chainInfo.mailerAddress) {
|
|
584
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
585
|
+
}
|
|
586
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
587
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
588
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
589
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
590
|
+
const delegateAddress = delegate ? normalizeAddress(delegate) : '0x0000000000000000000000000000000000000000';
|
|
591
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
592
|
+
address: contractAddress,
|
|
593
|
+
abi: MAILER_ABI,
|
|
594
|
+
functionName: 'delegateTo',
|
|
595
|
+
args: [delegateAddress],
|
|
596
|
+
account,
|
|
597
|
+
}), gasOptions, this.defaultGasLimits.delegateTo);
|
|
598
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
599
|
+
address: contractAddress,
|
|
600
|
+
abi: MAILER_ABI,
|
|
601
|
+
functionName: 'delegateTo',
|
|
602
|
+
args: [delegateAddress],
|
|
603
|
+
account,
|
|
604
|
+
chain: connectedWallet.walletClient.chain,
|
|
605
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
606
|
+
});
|
|
607
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Reject delegation
|
|
611
|
+
*/
|
|
612
|
+
async rejectDelegation(connectedWallet, chainInfo, delegatingAddress, gasOptions) {
|
|
613
|
+
if (!chainInfo.mailerAddress) {
|
|
614
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
615
|
+
}
|
|
616
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
617
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
618
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
619
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
620
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
621
|
+
address: contractAddress,
|
|
622
|
+
abi: MAILER_ABI,
|
|
623
|
+
functionName: 'rejectDelegation',
|
|
624
|
+
args: [normalizeAddress(delegatingAddress)],
|
|
625
|
+
account,
|
|
626
|
+
}), gasOptions, this.defaultGasLimits.rejectDelegation);
|
|
627
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
628
|
+
address: contractAddress,
|
|
629
|
+
abi: MAILER_ABI,
|
|
630
|
+
functionName: 'rejectDelegation',
|
|
631
|
+
args: [normalizeAddress(delegatingAddress)],
|
|
632
|
+
account,
|
|
633
|
+
chain: connectedWallet.walletClient.chain,
|
|
634
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
635
|
+
});
|
|
636
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Get delegation fee
|
|
640
|
+
*/
|
|
641
|
+
async getDelegationFee(chainInfo, publicClient) {
|
|
642
|
+
if (!chainInfo.mailerAddress) {
|
|
643
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
644
|
+
}
|
|
645
|
+
const client = this.ensurePublicClient(publicClient);
|
|
646
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
647
|
+
return await client.readContract({
|
|
648
|
+
address: contractAddress,
|
|
649
|
+
abi: MAILER_ABI,
|
|
650
|
+
functionName: 'delegationFee',
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Set delegation fee (owner only)
|
|
655
|
+
*/
|
|
656
|
+
async setDelegationFee(connectedWallet, chainInfo, usdcAmount, gasOptions) {
|
|
657
|
+
if (!chainInfo.mailerAddress) {
|
|
658
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
659
|
+
}
|
|
660
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
661
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
662
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
663
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
664
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
665
|
+
address: contractAddress,
|
|
666
|
+
abi: MAILER_ABI,
|
|
667
|
+
functionName: 'setDelegationFee',
|
|
668
|
+
args: [BigInt(usdcAmount)],
|
|
669
|
+
account,
|
|
670
|
+
}), gasOptions, this.defaultGasLimits.setDelegationFee);
|
|
671
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
672
|
+
address: contractAddress,
|
|
673
|
+
abi: MAILER_ABI,
|
|
674
|
+
functionName: 'setDelegationFee',
|
|
675
|
+
args: [BigInt(usdcAmount)],
|
|
676
|
+
account,
|
|
677
|
+
chain: connectedWallet.walletClient.chain,
|
|
678
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
679
|
+
});
|
|
680
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Set custom fee percentage
|
|
684
|
+
*/
|
|
685
|
+
async setCustomFeePercentage(connectedWallet, chainInfo, account, percentage, gasOptions) {
|
|
686
|
+
if (!chainInfo.mailerAddress) {
|
|
687
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
688
|
+
}
|
|
689
|
+
if (percentage < 0 || percentage > 100) {
|
|
690
|
+
throw new Error('Percentage must be between 0 and 100');
|
|
691
|
+
}
|
|
692
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
693
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
694
|
+
const [senderAccount] = await connectedWallet.walletClient.getAddresses();
|
|
695
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
696
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
697
|
+
address: contractAddress,
|
|
698
|
+
abi: MAILER_ABI,
|
|
699
|
+
functionName: 'setCustomFeePercentage',
|
|
700
|
+
args: [normalizeAddress(account), BigInt(percentage)],
|
|
701
|
+
account: senderAccount,
|
|
702
|
+
}), gasOptions, this.defaultGasLimits.setCustomFeePercentage);
|
|
703
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
704
|
+
address: contractAddress,
|
|
705
|
+
abi: MAILER_ABI,
|
|
706
|
+
functionName: 'setCustomFeePercentage',
|
|
707
|
+
args: [normalizeAddress(account), BigInt(percentage)],
|
|
708
|
+
account: senderAccount,
|
|
709
|
+
chain: connectedWallet.walletClient.chain,
|
|
710
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
711
|
+
});
|
|
712
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Clear custom fee percentage
|
|
716
|
+
*/
|
|
717
|
+
async clearCustomFeePercentage(connectedWallet, chainInfo, account, gasOptions) {
|
|
718
|
+
if (!chainInfo.mailerAddress) {
|
|
719
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
720
|
+
}
|
|
721
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
722
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
723
|
+
const [senderAccount] = await connectedWallet.walletClient.getAddresses();
|
|
724
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
725
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
726
|
+
address: contractAddress,
|
|
727
|
+
abi: MAILER_ABI,
|
|
728
|
+
functionName: 'clearCustomFeePercentage',
|
|
729
|
+
args: [normalizeAddress(account)],
|
|
730
|
+
account: senderAccount,
|
|
731
|
+
}), gasOptions, this.defaultGasLimits.clearCustomFeePercentage);
|
|
732
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
733
|
+
address: contractAddress,
|
|
734
|
+
abi: MAILER_ABI,
|
|
735
|
+
functionName: 'clearCustomFeePercentage',
|
|
736
|
+
args: [normalizeAddress(account)],
|
|
737
|
+
account: senderAccount,
|
|
738
|
+
chain: connectedWallet.walletClient.chain,
|
|
739
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
740
|
+
});
|
|
741
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Get custom fee percentage
|
|
745
|
+
*/
|
|
746
|
+
async getCustomFeePercentage(chainInfo, account, publicClient) {
|
|
747
|
+
if (!chainInfo.mailerAddress) {
|
|
748
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
749
|
+
}
|
|
750
|
+
const client = this.ensurePublicClient(publicClient);
|
|
751
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
752
|
+
const result = await client.readContract({
|
|
753
|
+
address: contractAddress,
|
|
754
|
+
abi: MAILER_ABI,
|
|
755
|
+
functionName: 'getCustomFeePercentage',
|
|
756
|
+
args: [normalizeAddress(account)],
|
|
757
|
+
});
|
|
758
|
+
return Number(result);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Set permission for a contract to use caller's USDC for sending messages
|
|
762
|
+
*/
|
|
763
|
+
async setPermission(connectedWallet, chainInfo, contractAddress, gasOptions) {
|
|
764
|
+
if (!chainInfo.mailerAddress) {
|
|
765
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
766
|
+
}
|
|
767
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
768
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
769
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
770
|
+
const mailerAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
771
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
772
|
+
address: mailerAddress,
|
|
773
|
+
abi: MAILER_ABI,
|
|
774
|
+
functionName: 'setPermission',
|
|
775
|
+
args: [normalizeAddress(contractAddress)],
|
|
776
|
+
account,
|
|
777
|
+
}), gasOptions, this.defaultGasLimits.setPermission);
|
|
778
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
779
|
+
address: mailerAddress,
|
|
780
|
+
abi: MAILER_ABI,
|
|
781
|
+
functionName: 'setPermission',
|
|
782
|
+
args: [normalizeAddress(contractAddress)],
|
|
783
|
+
account,
|
|
784
|
+
chain: connectedWallet.walletClient.chain,
|
|
785
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
786
|
+
});
|
|
787
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Remove permission
|
|
791
|
+
*/
|
|
792
|
+
async removePermission(connectedWallet, chainInfo, contractAddress, gasOptions) {
|
|
793
|
+
if (!chainInfo.mailerAddress) {
|
|
794
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
795
|
+
}
|
|
796
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
797
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
798
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
799
|
+
const mailerAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
800
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
801
|
+
address: mailerAddress,
|
|
802
|
+
abi: MAILER_ABI,
|
|
803
|
+
functionName: 'removePermission',
|
|
804
|
+
args: [normalizeAddress(contractAddress)],
|
|
805
|
+
account,
|
|
806
|
+
}), gasOptions, this.defaultGasLimits.removePermission);
|
|
807
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
808
|
+
address: mailerAddress,
|
|
809
|
+
abi: MAILER_ABI,
|
|
810
|
+
functionName: 'removePermission',
|
|
811
|
+
args: [normalizeAddress(contractAddress)],
|
|
812
|
+
account,
|
|
813
|
+
chain: connectedWallet.walletClient.chain,
|
|
814
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
815
|
+
});
|
|
816
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Check if permission exists
|
|
820
|
+
*/
|
|
821
|
+
async hasPermission(contractAddress, wallet, chainInfo, publicClient) {
|
|
822
|
+
if (!chainInfo.mailerAddress) {
|
|
823
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
824
|
+
}
|
|
825
|
+
const client = this.ensurePublicClient(publicClient);
|
|
826
|
+
const mailerAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
827
|
+
return await client.readContract({
|
|
828
|
+
address: mailerAddress,
|
|
829
|
+
abi: MAILER_ABI,
|
|
830
|
+
functionName: 'permissions',
|
|
831
|
+
args: [normalizeAddress(contractAddress), normalizeAddress(wallet)],
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Pause the contract (owner only)
|
|
836
|
+
*/
|
|
837
|
+
async pause(connectedWallet, chainInfo, gasOptions) {
|
|
838
|
+
if (!chainInfo.mailerAddress) {
|
|
839
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
840
|
+
}
|
|
841
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
842
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
843
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
844
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
845
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
846
|
+
address: contractAddress,
|
|
847
|
+
abi: MAILER_ABI,
|
|
848
|
+
functionName: 'pause',
|
|
849
|
+
args: [],
|
|
850
|
+
account,
|
|
851
|
+
}), gasOptions, this.defaultGasLimits.pause);
|
|
852
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
853
|
+
address: contractAddress,
|
|
854
|
+
abi: MAILER_ABI,
|
|
855
|
+
functionName: 'pause',
|
|
856
|
+
args: [],
|
|
857
|
+
account,
|
|
858
|
+
chain: connectedWallet.walletClient.chain,
|
|
859
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
860
|
+
});
|
|
861
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Unpause the contract (owner only)
|
|
865
|
+
*/
|
|
866
|
+
async unpause(connectedWallet, chainInfo, gasOptions) {
|
|
867
|
+
if (!chainInfo.mailerAddress) {
|
|
868
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
869
|
+
}
|
|
870
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
871
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
872
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
873
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
874
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
875
|
+
address: contractAddress,
|
|
876
|
+
abi: MAILER_ABI,
|
|
877
|
+
functionName: 'unpause',
|
|
878
|
+
args: [],
|
|
879
|
+
account,
|
|
880
|
+
}), gasOptions, this.defaultGasLimits.unpause);
|
|
881
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
882
|
+
address: contractAddress,
|
|
883
|
+
abi: MAILER_ABI,
|
|
884
|
+
functionName: 'unpause',
|
|
885
|
+
args: [],
|
|
886
|
+
account,
|
|
887
|
+
chain: connectedWallet.walletClient.chain,
|
|
888
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
889
|
+
});
|
|
890
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Emergency unpause (owner only)
|
|
894
|
+
*/
|
|
895
|
+
async emergencyUnpause(connectedWallet, chainInfo, gasOptions) {
|
|
896
|
+
if (!chainInfo.mailerAddress) {
|
|
897
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
898
|
+
}
|
|
899
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
900
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
901
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
902
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
903
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
904
|
+
address: contractAddress,
|
|
905
|
+
abi: MAILER_ABI,
|
|
906
|
+
functionName: 'emergencyUnpause',
|
|
907
|
+
args: [],
|
|
908
|
+
account,
|
|
909
|
+
}), gasOptions, this.defaultGasLimits.emergencyUnpause);
|
|
910
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
911
|
+
address: contractAddress,
|
|
912
|
+
abi: MAILER_ABI,
|
|
913
|
+
functionName: 'emergencyUnpause',
|
|
914
|
+
args: [],
|
|
915
|
+
account,
|
|
916
|
+
chain: connectedWallet.walletClient.chain,
|
|
917
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
918
|
+
});
|
|
919
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Check if contract is paused
|
|
923
|
+
*/
|
|
924
|
+
async isPaused(chainInfo, publicClient) {
|
|
925
|
+
if (!chainInfo.mailerAddress) {
|
|
926
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
927
|
+
}
|
|
928
|
+
const client = this.ensurePublicClient(publicClient);
|
|
929
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
930
|
+
return await client.readContract({
|
|
931
|
+
address: contractAddress,
|
|
932
|
+
abi: MAILER_ABI,
|
|
933
|
+
functionName: 'paused',
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Distribute claimable funds when paused (anyone can call)
|
|
938
|
+
*/
|
|
939
|
+
async distributeClaimableFunds(connectedWallet, chainInfo, recipient, gasOptions) {
|
|
940
|
+
if (!chainInfo.mailerAddress) {
|
|
941
|
+
throw new Error(`No mailer contract deployed on ${chainInfo.name}`);
|
|
942
|
+
}
|
|
943
|
+
await this.switchChainIfNeeded(connectedWallet.walletClient, chainInfo.chainId);
|
|
944
|
+
const publicClient = this.ensurePublicClient(connectedWallet.publicClient);
|
|
945
|
+
const [account] = await connectedWallet.walletClient.getAddresses();
|
|
946
|
+
const contractAddress = normalizeAddress(chainInfo.mailerAddress);
|
|
947
|
+
const gasLimit = await this.estimateGasWithBuffer(() => publicClient.estimateContractGas({
|
|
948
|
+
address: contractAddress,
|
|
949
|
+
abi: MAILER_ABI,
|
|
950
|
+
functionName: 'distributeClaimableFunds',
|
|
951
|
+
args: [normalizeAddress(recipient)],
|
|
952
|
+
account,
|
|
953
|
+
}), gasOptions, this.defaultGasLimits.distributeClaimableFunds);
|
|
954
|
+
const hash = await connectedWallet.walletClient.writeContract({
|
|
955
|
+
address: contractAddress,
|
|
956
|
+
abi: MAILER_ABI,
|
|
957
|
+
functionName: 'distributeClaimableFunds',
|
|
958
|
+
args: [normalizeAddress(recipient)],
|
|
959
|
+
account,
|
|
960
|
+
chain: connectedWallet.walletClient.chain,
|
|
961
|
+
...this.buildTxParams(gasLimit, gasOptions),
|
|
962
|
+
});
|
|
963
|
+
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
EVMMailerClient.abi = MAILER_ABI;
|
|
967
|
+
EVMMailerClient.bytecode = MAILER_BYTECODE;
|
|
968
|
+
//# sourceMappingURL=evm-mailer-client.js.map
|