@sudobility/contracts 0.14.0
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 +353 -0
- package/artifacts/contracts/Mailer.sol/Mailer.d.ts +1146 -0
- package/artifacts/contracts/Mailer.sol/Mailer.dbg.json +4 -0
- package/artifacts/contracts/Mailer.sol/Mailer.json +1096 -0
- package/artifacts/contracts/Mailer.sol/artifacts.d.ts +21 -0
- package/artifacts/contracts/MockUSDC.sol/MockUSDC.d.ts +284 -0
- package/artifacts/contracts/MockUSDC.sol/MockUSDC.dbg.json +4 -0
- package/artifacts/contracts/MockUSDC.sol/MockUSDC.json +234 -0
- package/artifacts/contracts/MockUSDC.sol/artifacts.d.ts +21 -0
- package/artifacts/contracts/interfaces/IERC20.sol/IERC20.d.ts +157 -0
- package/artifacts/contracts/interfaces/IERC20.sol/IERC20.dbg.json +4 -0
- package/artifacts/contracts/interfaces/IERC20.sol/IERC20.json +107 -0
- package/artifacts/contracts/interfaces/IERC20.sol/artifacts.d.ts +21 -0
- package/dist/evm/src/evm/index.d.ts +4 -0
- package/dist/evm/src/evm/index.d.ts.map +1 -0
- package/dist/evm/src/evm/index.js +10 -0
- package/dist/evm/src/evm/index.js.map +1 -0
- package/dist/evm/src/evm/mailer-client.d.ts +966 -0
- package/dist/evm/src/evm/mailer-client.d.ts.map +1 -0
- package/dist/evm/src/evm/mailer-client.js +619 -0
- package/dist/evm/src/evm/mailer-client.js.map +1 -0
- package/dist/evm/typechain-types/Mailer.d.ts +698 -0
- package/dist/evm/typechain-types/Mailer.d.ts.map +1 -0
- package/dist/evm/typechain-types/Mailer.js +3 -0
- package/dist/evm/typechain-types/Mailer.js.map +1 -0
- package/dist/evm/typechain-types/MockUSDC.d.ts +118 -0
- package/dist/evm/typechain-types/MockUSDC.d.ts.map +1 -0
- package/dist/evm/typechain-types/MockUSDC.js +3 -0
- package/dist/evm/typechain-types/MockUSDC.js.map +1 -0
- package/dist/evm/typechain-types/common.d.ts +51 -0
- package/dist/evm/typechain-types/common.d.ts.map +1 -0
- package/dist/evm/typechain-types/common.js +3 -0
- package/dist/evm/typechain-types/common.js.map +1 -0
- package/dist/evm/typechain-types/factories/Mailer__factory.d.ts +875 -0
- package/dist/evm/typechain-types/factories/Mailer__factory.d.ts.map +1 -0
- package/dist/evm/typechain-types/factories/Mailer__factory.js +1125 -0
- package/dist/evm/typechain-types/factories/Mailer__factory.js.map +1 -0
- package/dist/evm/typechain-types/factories/MockUSDC__factory.d.ts +193 -0
- package/dist/evm/typechain-types/factories/MockUSDC__factory.d.ts.map +1 -0
- package/dist/evm/typechain-types/factories/MockUSDC__factory.js +263 -0
- package/dist/evm/typechain-types/factories/MockUSDC__factory.js.map +1 -0
- package/dist/evm/typechain-types/factories/index.d.ts +4 -0
- package/dist/evm/typechain-types/factories/index.d.ts.map +1 -0
- package/dist/evm/typechain-types/factories/index.js +45 -0
- package/dist/evm/typechain-types/factories/index.js.map +1 -0
- package/dist/evm/typechain-types/factories/interfaces/IERC20__factory.d.ts +80 -0
- package/dist/evm/typechain-types/factories/interfaces/IERC20__factory.d.ts.map +1 -0
- package/dist/evm/typechain-types/factories/interfaces/IERC20__factory.js +116 -0
- package/dist/evm/typechain-types/factories/interfaces/IERC20__factory.js.map +1 -0
- package/dist/evm/typechain-types/factories/interfaces/index.d.ts +2 -0
- package/dist/evm/typechain-types/factories/interfaces/index.d.ts.map +1 -0
- package/dist/evm/typechain-types/factories/interfaces/index.js +9 -0
- package/dist/evm/typechain-types/factories/interfaces/index.js.map +1 -0
- package/dist/evm/typechain-types/index.d.ts +10 -0
- package/dist/evm/typechain-types/index.d.ts.map +1 -0
- package/dist/evm/typechain-types/index.js +44 -0
- package/dist/evm/typechain-types/index.js.map +1 -0
- package/dist/evm/typechain-types/interfaces/IERC20.d.ts +70 -0
- package/dist/evm/typechain-types/interfaces/IERC20.d.ts.map +1 -0
- package/dist/evm/typechain-types/interfaces/IERC20.js +3 -0
- package/dist/evm/typechain-types/interfaces/IERC20.js.map +1 -0
- package/dist/evm/typechain-types/interfaces/index.d.ts +2 -0
- package/dist/evm/typechain-types/interfaces/index.d.ts.map +1 -0
- package/dist/evm/typechain-types/interfaces/index.js +3 -0
- package/dist/evm/typechain-types/interfaces/index.js.map +1 -0
- package/dist/solana/solana/index.d.ts +3 -0
- package/dist/solana/solana/index.d.ts.map +1 -0
- package/dist/solana/solana/index.js +21 -0
- package/dist/solana/solana/index.js.map +1 -0
- package/dist/solana/solana/mailer-client.d.ts +282 -0
- package/dist/solana/solana/mailer-client.d.ts.map +1 -0
- package/dist/solana/solana/mailer-client.js +989 -0
- package/dist/solana/solana/mailer-client.js.map +1 -0
- package/dist/solana/solana/types.d.ts +28 -0
- package/dist/solana/solana/types.d.ts.map +1 -0
- package/dist/solana/solana/types.js +23 -0
- package/dist/solana/solana/types.js.map +1 -0
- package/dist/solana/utils/currency.d.ts +26 -0
- package/dist/solana/utils/currency.d.ts.map +1 -0
- package/dist/solana/utils/currency.js +36 -0
- package/dist/solana/utils/currency.js.map +1 -0
- package/dist/unified/package.json +3 -0
- package/dist/unified/src/evm/index.d.ts +4 -0
- package/dist/unified/src/evm/index.d.ts.map +1 -0
- package/dist/unified/src/evm/index.js +10 -0
- package/dist/unified/src/evm/index.js.map +1 -0
- package/dist/unified/src/evm/mailer-client.d.ts +966 -0
- package/dist/unified/src/evm/mailer-client.d.ts.map +1 -0
- package/dist/unified/src/evm/mailer-client.js +619 -0
- package/dist/unified/src/evm/mailer-client.js.map +1 -0
- package/dist/unified/src/react/context/MailerProvider.d.ts +102 -0
- package/dist/unified/src/react/context/MailerProvider.d.ts.map +1 -0
- package/dist/unified/src/react/context/MailerProvider.js +160 -0
- package/dist/unified/src/react/context/MailerProvider.js.map +1 -0
- package/dist/unified/src/react/hooks/useMailerMutations.d.ts +301 -0
- package/dist/unified/src/react/hooks/useMailerMutations.d.ts.map +1 -0
- package/dist/unified/src/react/hooks/useMailerMutations.js +417 -0
- package/dist/unified/src/react/hooks/useMailerMutations.js.map +1 -0
- package/dist/unified/src/react/hooks/useMailerQueries.d.ts +130 -0
- package/dist/unified/src/react/hooks/useMailerQueries.d.ts.map +1 -0
- package/dist/unified/src/react/hooks/useMailerQueries.js +197 -0
- package/dist/unified/src/react/hooks/useMailerQueries.js.map +1 -0
- package/dist/unified/src/react/index.d.ts +37 -0
- package/dist/unified/src/react/index.d.ts.map +1 -0
- package/dist/unified/src/react/index.js +70 -0
- package/dist/unified/src/react/index.js.map +1 -0
- package/dist/unified/src/solana/index.d.ts +3 -0
- package/dist/unified/src/solana/index.d.ts.map +1 -0
- package/dist/unified/src/solana/index.js +21 -0
- package/dist/unified/src/solana/index.js.map +1 -0
- package/dist/unified/src/solana/mailer-client.d.ts +282 -0
- package/dist/unified/src/solana/mailer-client.d.ts.map +1 -0
- package/dist/unified/src/solana/mailer-client.js +989 -0
- package/dist/unified/src/solana/mailer-client.js.map +1 -0
- package/dist/unified/src/solana/types.d.ts +28 -0
- package/dist/unified/src/solana/types.d.ts.map +1 -0
- package/dist/unified/src/solana/types.js +23 -0
- package/dist/unified/src/solana/types.js.map +1 -0
- package/dist/unified/src/unified/index.d.ts +4 -0
- package/dist/unified/src/unified/index.d.ts.map +1 -0
- package/dist/unified/src/unified/index.js +9 -0
- package/dist/unified/src/unified/index.js.map +1 -0
- package/dist/unified/src/unified/onchain-mailer-client.d.ts +173 -0
- package/dist/unified/src/unified/onchain-mailer-client.d.ts.map +1 -0
- package/dist/unified/src/unified/onchain-mailer-client.js +1048 -0
- package/dist/unified/src/unified/onchain-mailer-client.js.map +1 -0
- package/dist/unified/src/unified/types.d.ts +47 -0
- package/dist/unified/src/unified/types.d.ts.map +1 -0
- package/dist/unified/src/unified/types.js +3 -0
- package/dist/unified/src/unified/types.js.map +1 -0
- package/dist/unified/src/unified/wallet-detector.d.ts +28 -0
- package/dist/unified/src/unified/wallet-detector.d.ts.map +1 -0
- package/dist/unified/src/unified/wallet-detector.js +63 -0
- package/dist/unified/src/unified/wallet-detector.js.map +1 -0
- package/dist/unified/src/utils/chain-config.d.ts +75 -0
- package/dist/unified/src/utils/chain-config.d.ts.map +1 -0
- package/dist/unified/src/utils/chain-config.js +203 -0
- package/dist/unified/src/utils/chain-config.js.map +1 -0
- package/dist/unified/src/utils/currency.d.ts +26 -0
- package/dist/unified/src/utils/currency.d.ts.map +1 -0
- package/dist/unified/src/utils/currency.js +36 -0
- package/dist/unified/src/utils/currency.js.map +1 -0
- package/dist/unified/src/utils/index.d.ts +4 -0
- package/dist/unified/src/utils/index.d.ts.map +1 -0
- package/dist/unified/src/utils/index.js +20 -0
- package/dist/unified/src/utils/index.js.map +1 -0
- package/dist/unified/src/utils/validation.d.ts +10 -0
- package/dist/unified/src/utils/validation.d.ts.map +1 -0
- package/dist/unified/src/utils/validation.js +102 -0
- package/dist/unified/src/utils/validation.js.map +1 -0
- package/dist/unified/typechain-types/Mailer.d.ts +698 -0
- package/dist/unified/typechain-types/Mailer.d.ts.map +1 -0
- package/dist/unified/typechain-types/Mailer.js +3 -0
- package/dist/unified/typechain-types/Mailer.js.map +1 -0
- package/dist/unified/typechain-types/MockUSDC.d.ts +118 -0
- package/dist/unified/typechain-types/MockUSDC.d.ts.map +1 -0
- package/dist/unified/typechain-types/MockUSDC.js +3 -0
- package/dist/unified/typechain-types/MockUSDC.js.map +1 -0
- package/dist/unified/typechain-types/common.d.ts +51 -0
- package/dist/unified/typechain-types/common.d.ts.map +1 -0
- package/dist/unified/typechain-types/common.js +3 -0
- package/dist/unified/typechain-types/common.js.map +1 -0
- package/dist/unified/typechain-types/factories/Mailer__factory.d.ts +875 -0
- package/dist/unified/typechain-types/factories/Mailer__factory.d.ts.map +1 -0
- package/dist/unified/typechain-types/factories/Mailer__factory.js +1125 -0
- package/dist/unified/typechain-types/factories/Mailer__factory.js.map +1 -0
- package/dist/unified/typechain-types/factories/MockUSDC__factory.d.ts +193 -0
- package/dist/unified/typechain-types/factories/MockUSDC__factory.d.ts.map +1 -0
- package/dist/unified/typechain-types/factories/MockUSDC__factory.js +263 -0
- package/dist/unified/typechain-types/factories/MockUSDC__factory.js.map +1 -0
- package/dist/unified/typechain-types/factories/index.d.ts +4 -0
- package/dist/unified/typechain-types/factories/index.d.ts.map +1 -0
- package/dist/unified/typechain-types/factories/index.js +45 -0
- package/dist/unified/typechain-types/factories/index.js.map +1 -0
- package/dist/unified/typechain-types/factories/interfaces/IERC20__factory.d.ts +80 -0
- package/dist/unified/typechain-types/factories/interfaces/IERC20__factory.d.ts.map +1 -0
- package/dist/unified/typechain-types/factories/interfaces/IERC20__factory.js +116 -0
- package/dist/unified/typechain-types/factories/interfaces/IERC20__factory.js.map +1 -0
- package/dist/unified/typechain-types/factories/interfaces/index.d.ts +2 -0
- package/dist/unified/typechain-types/factories/interfaces/index.d.ts.map +1 -0
- package/dist/unified/typechain-types/factories/interfaces/index.js +9 -0
- package/dist/unified/typechain-types/factories/interfaces/index.js.map +1 -0
- package/dist/unified/typechain-types/index.d.ts +10 -0
- package/dist/unified/typechain-types/index.d.ts.map +1 -0
- package/dist/unified/typechain-types/index.js +44 -0
- package/dist/unified/typechain-types/index.js.map +1 -0
- package/dist/unified/typechain-types/interfaces/IERC20.d.ts +70 -0
- package/dist/unified/typechain-types/interfaces/IERC20.d.ts.map +1 -0
- package/dist/unified/typechain-types/interfaces/IERC20.js +3 -0
- package/dist/unified/typechain-types/interfaces/IERC20.js.map +1 -0
- package/dist/unified/typechain-types/interfaces/index.d.ts +2 -0
- package/dist/unified/typechain-types/interfaces/index.d.ts.map +1 -0
- package/dist/unified/typechain-types/interfaces/index.js +3 -0
- package/dist/unified/typechain-types/interfaces/index.js.map +1 -0
- package/dist/unified-esm/src/evm/index.d.ts +4 -0
- package/dist/unified-esm/src/evm/index.d.ts.map +1 -0
- package/dist/unified-esm/src/evm/index.js +5 -0
- package/dist/unified-esm/src/evm/index.js.map +1 -0
- package/dist/unified-esm/src/evm/mailer-client.d.ts +966 -0
- package/dist/unified-esm/src/evm/mailer-client.d.ts.map +1 -0
- package/dist/unified-esm/src/evm/mailer-client.js +615 -0
- package/dist/unified-esm/src/evm/mailer-client.js.map +1 -0
- package/dist/unified-esm/src/react/context/MailerProvider.d.ts +102 -0
- package/dist/unified-esm/src/react/context/MailerProvider.d.ts.map +1 -0
- package/dist/unified-esm/src/react/context/MailerProvider.js +120 -0
- package/dist/unified-esm/src/react/context/MailerProvider.js.map +1 -0
- package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts +301 -0
- package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts.map +1 -0
- package/dist/unified-esm/src/react/hooks/useMailerMutations.js +400 -0
- package/dist/unified-esm/src/react/hooks/useMailerMutations.js.map +1 -0
- package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts +130 -0
- package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts.map +1 -0
- package/dist/unified-esm/src/react/hooks/useMailerQueries.js +186 -0
- package/dist/unified-esm/src/react/hooks/useMailerQueries.js.map +1 -0
- package/dist/unified-esm/src/react/index.d.ts +37 -0
- package/dist/unified-esm/src/react/index.d.ts.map +1 -0
- package/dist/unified-esm/src/react/index.js +39 -0
- package/dist/unified-esm/src/react/index.js.map +1 -0
- package/dist/unified-esm/src/solana/index.d.ts +3 -0
- package/dist/unified-esm/src/solana/index.d.ts.map +1 -0
- package/dist/unified-esm/src/solana/index.js +3 -0
- package/dist/unified-esm/src/solana/index.js.map +1 -0
- package/dist/unified-esm/src/solana/mailer-client.d.ts +282 -0
- package/dist/unified-esm/src/solana/mailer-client.d.ts.map +1 -0
- package/dist/unified-esm/src/solana/mailer-client.js +985 -0
- package/dist/unified-esm/src/solana/mailer-client.js.map +1 -0
- package/dist/unified-esm/src/solana/types.d.ts +28 -0
- package/dist/unified-esm/src/solana/types.d.ts.map +1 -0
- package/dist/unified-esm/src/solana/types.js +16 -0
- package/dist/unified-esm/src/solana/types.js.map +1 -0
- package/dist/unified-esm/src/unified/index.d.ts +4 -0
- package/dist/unified-esm/src/unified/index.d.ts.map +1 -0
- package/dist/unified-esm/src/unified/index.js +4 -0
- package/dist/unified-esm/src/unified/index.js.map +1 -0
- package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts +173 -0
- package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts.map +1 -0
- package/dist/unified-esm/src/unified/onchain-mailer-client.js +1011 -0
- package/dist/unified-esm/src/unified/onchain-mailer-client.js.map +1 -0
- package/dist/unified-esm/src/unified/types.d.ts +47 -0
- package/dist/unified-esm/src/unified/types.d.ts.map +1 -0
- package/dist/unified-esm/src/unified/types.js +2 -0
- package/dist/unified-esm/src/unified/types.js.map +1 -0
- package/dist/unified-esm/src/unified/wallet-detector.d.ts +28 -0
- package/dist/unified-esm/src/unified/wallet-detector.d.ts.map +1 -0
- package/dist/unified-esm/src/unified/wallet-detector.js +59 -0
- package/dist/unified-esm/src/unified/wallet-detector.js.map +1 -0
- package/dist/unified-esm/src/utils/chain-config.d.ts +75 -0
- package/dist/unified-esm/src/utils/chain-config.d.ts.map +1 -0
- package/dist/unified-esm/src/utils/chain-config.js +199 -0
- package/dist/unified-esm/src/utils/chain-config.js.map +1 -0
- package/dist/unified-esm/src/utils/currency.d.ts +26 -0
- package/dist/unified-esm/src/utils/currency.d.ts.map +1 -0
- package/dist/unified-esm/src/utils/currency.js +31 -0
- package/dist/unified-esm/src/utils/currency.js.map +1 -0
- package/dist/unified-esm/src/utils/index.d.ts +4 -0
- package/dist/unified-esm/src/utils/index.d.ts.map +1 -0
- package/dist/unified-esm/src/utils/index.js +4 -0
- package/dist/unified-esm/src/utils/index.js.map +1 -0
- package/dist/unified-esm/src/utils/validation.d.ts +10 -0
- package/dist/unified-esm/src/utils/validation.d.ts.map +1 -0
- package/dist/unified-esm/src/utils/validation.js +96 -0
- package/dist/unified-esm/src/utils/validation.js.map +1 -0
- package/dist/unified-esm/typechain-types/Mailer.d.ts +698 -0
- package/dist/unified-esm/typechain-types/Mailer.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/Mailer.js +2 -0
- package/dist/unified-esm/typechain-types/Mailer.js.map +1 -0
- package/dist/unified-esm/typechain-types/MockUSDC.d.ts +118 -0
- package/dist/unified-esm/typechain-types/MockUSDC.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/MockUSDC.js +2 -0
- package/dist/unified-esm/typechain-types/MockUSDC.js.map +1 -0
- package/dist/unified-esm/typechain-types/common.d.ts +51 -0
- package/dist/unified-esm/typechain-types/common.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/common.js +2 -0
- package/dist/unified-esm/typechain-types/common.js.map +1 -0
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts +875 -0
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.js +1121 -0
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.js.map +1 -0
- package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.d.ts +193 -0
- package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.js +259 -0
- package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.js.map +1 -0
- package/dist/unified-esm/typechain-types/factories/index.d.ts +4 -0
- package/dist/unified-esm/typechain-types/factories/index.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/factories/index.js +7 -0
- package/dist/unified-esm/typechain-types/factories/index.js.map +1 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.d.ts +80 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.js +112 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.js.map +1 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/index.d.ts +2 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/index.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/index.js +5 -0
- package/dist/unified-esm/typechain-types/factories/interfaces/index.js.map +1 -0
- package/dist/unified-esm/typechain-types/index.d.ts +10 -0
- package/dist/unified-esm/typechain-types/index.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/index.js +5 -0
- package/dist/unified-esm/typechain-types/index.js.map +1 -0
- package/dist/unified-esm/typechain-types/interfaces/IERC20.d.ts +70 -0
- package/dist/unified-esm/typechain-types/interfaces/IERC20.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/interfaces/IERC20.js +2 -0
- package/dist/unified-esm/typechain-types/interfaces/IERC20.js.map +1 -0
- package/dist/unified-esm/typechain-types/interfaces/index.d.ts +2 -0
- package/dist/unified-esm/typechain-types/interfaces/index.d.ts.map +1 -0
- package/dist/unified-esm/typechain-types/interfaces/index.js +2 -0
- package/dist/unified-esm/typechain-types/interfaces/index.js.map +1 -0
- package/package.json +250 -0
- package/programs/mailer/Cargo.toml +29 -0
- package/programs/mailer/src/lib.rs +2034 -0
- package/programs/mailer/tests/integration_tests.rs +1236 -0
- package/typechain-types/Mailer.ts +1393 -0
- package/typechain-types/MockUSDC.ts +236 -0
- package/typechain-types/common.ts +131 -0
- package/typechain-types/factories/Mailer__factory.ts +1157 -0
- package/typechain-types/factories/MockUSDC__factory.ts +284 -0
- package/typechain-types/factories/index.ts +6 -0
- package/typechain-types/factories/interfaces/IERC20__factory.ts +115 -0
- package/typechain-types/factories/interfaces/index.ts +4 -0
- package/typechain-types/hardhat.d.ts +99 -0
- package/typechain-types/index.ts +12 -0
- package/typechain-types/interfaces/IERC20.ts +148 -0
- package/typechain-types/interfaces/index.ts +4 -0
|
@@ -0,0 +1,1011 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
// @ts-nocheck - Suppress false TypeScript errors with ESNext modules accessing class properties
|
|
3
|
+
import { ChainType } from '@sudobility/types';
|
|
4
|
+
/**
|
|
5
|
+
* OnchainMailerClient v2 - Refactored to use standard wallet libraries
|
|
6
|
+
*
|
|
7
|
+
* This version removes the UnifiedWallet abstraction and instead accepts
|
|
8
|
+
* standard wallet clients from wagmi (EVM) or wallet-adapter (Solana).
|
|
9
|
+
*
|
|
10
|
+
* @example EVM Usage with wagmi
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { createWalletClient, createPublicClient, http } from 'viem';
|
|
13
|
+
* import { mainnet } from 'viem/chains';
|
|
14
|
+
*
|
|
15
|
+
* const walletClient = createWalletClient({
|
|
16
|
+
* chain: mainnet,
|
|
17
|
+
* transport: http()
|
|
18
|
+
* });
|
|
19
|
+
* const publicClient = createPublicClient({
|
|
20
|
+
* chain: mainnet,
|
|
21
|
+
* transport: http()
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const client = OnchainMailerClient.forEVM(
|
|
25
|
+
* walletClient,
|
|
26
|
+
* publicClient,
|
|
27
|
+
* '0xMailerContractAddress',
|
|
28
|
+
* '0xUSDCAddress'
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Solana Usage with wallet-adapter
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { useWallet } from '@solana/wallet-adapter-react';
|
|
35
|
+
* import { Connection } from '@solana/web3.js';
|
|
36
|
+
*
|
|
37
|
+
* const wallet = useWallet();
|
|
38
|
+
* const connection = new Connection('https://api.mainnet-beta.solana.com');
|
|
39
|
+
*
|
|
40
|
+
* const client = OnchainMailerClient.forSolana(
|
|
41
|
+
* wallet,
|
|
42
|
+
* connection,
|
|
43
|
+
* 'MailerProgramId',
|
|
44
|
+
* 'USDCMintAddress'
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export class OnchainMailerClient {
|
|
49
|
+
/**
|
|
50
|
+
* Create an OnchainMailerClient for EVM chains using wagmi clients
|
|
51
|
+
*
|
|
52
|
+
* @param walletClient - wagmi WalletClient for signing transactions
|
|
53
|
+
* @param publicClient - wagmi PublicClient for reading chain data
|
|
54
|
+
* @param mailerAddress - Deployed Mailer contract address
|
|
55
|
+
* @param usdcAddress - USDC token contract address
|
|
56
|
+
* @returns Configured OnchainMailerClient for EVM
|
|
57
|
+
*/
|
|
58
|
+
static forEVM(walletClient, publicClient, mailerAddress, usdcAddress) {
|
|
59
|
+
const client = new OnchainMailerClient({}, { evm: undefined, solana: undefined });
|
|
60
|
+
client.chainType = ChainType.EVM;
|
|
61
|
+
client.evmWalletClient = walletClient;
|
|
62
|
+
client.evmPublicClient = publicClient;
|
|
63
|
+
client.evmContractAddress = mailerAddress;
|
|
64
|
+
client.evmUsdcAddress = usdcAddress;
|
|
65
|
+
return client;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create an OnchainMailerClient for Solana using wallet-adapter
|
|
69
|
+
*
|
|
70
|
+
* @param wallet - Solana wallet adapter
|
|
71
|
+
* @param connection - Solana connection
|
|
72
|
+
* @param programId - Deployed Mailer program ID
|
|
73
|
+
* @param usdcMint - USDC mint address
|
|
74
|
+
* @returns Configured OnchainMailerClient for Solana
|
|
75
|
+
*/
|
|
76
|
+
static forSolana(
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
wallet, // Wallet adapter interface
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
connection, // Connection
|
|
81
|
+
programId, usdcMint) {
|
|
82
|
+
const client = new OnchainMailerClient({}, { evm: undefined, solana: undefined });
|
|
83
|
+
client.chainType = ChainType.SOLANA;
|
|
84
|
+
client.solanaWallet = wallet;
|
|
85
|
+
client.solanaConnection = connection;
|
|
86
|
+
client.solanaProgramId = programId;
|
|
87
|
+
client.solanaUsdcMint = usdcMint;
|
|
88
|
+
return client;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create an OnchainMailerClient from a generic config (backward compatibility)
|
|
92
|
+
* This constructor is provided for backward compatibility with React provider
|
|
93
|
+
*/
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
constructor(wallet, config) {
|
|
96
|
+
// Simple chain detection based on wallet properties
|
|
97
|
+
const hasEthereumProperties = wallet && (wallet.address || wallet.request || wallet.selectedAddress);
|
|
98
|
+
const hasSolanaProperties = wallet && wallet.publicKey && typeof wallet.signTransaction === 'function';
|
|
99
|
+
if (hasEthereumProperties) {
|
|
100
|
+
this.chainType = ChainType.EVM;
|
|
101
|
+
if (config.evm) {
|
|
102
|
+
// Store config for lazy initialization
|
|
103
|
+
this.evmContractAddress = config.evm.contracts.mailer;
|
|
104
|
+
this.evmUsdcAddress = config.evm.contracts.usdc;
|
|
105
|
+
// Wallet and public clients will be created on first use
|
|
106
|
+
// Store raw wallet for backward compatibility
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
this._rawEvmWallet = wallet;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
throw new Error('EVM configuration required for EVM wallet');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (hasSolanaProperties) {
|
|
115
|
+
this.chainType = ChainType.SOLANA;
|
|
116
|
+
if (config.solana) {
|
|
117
|
+
this.solanaWallet = wallet;
|
|
118
|
+
// Connection will be created on first use
|
|
119
|
+
this.solanaProgramId = config.solana.programs.mailer;
|
|
120
|
+
this.solanaUsdcMint = config.solana.usdcMint;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new Error('Solana configuration required for Solana wallet');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
throw new Error('Unable to detect wallet type from provided wallet object');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Send a message using the appropriate chain implementation
|
|
132
|
+
* Note: For backward compatibility, 'to' defaults to sender's own address
|
|
133
|
+
*/
|
|
134
|
+
async sendMessage(subject, body, priority = false, resolveSenderToName = false, to) {
|
|
135
|
+
// For backward compatibility, default to sending to self
|
|
136
|
+
const recipient = to || await this.getWalletAddressAsync();
|
|
137
|
+
if (this.chainType === ChainType.EVM) {
|
|
138
|
+
return this.sendEVMMessage(recipient, subject, body, priority, resolveSenderToName);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return this.sendSolanaMessage(recipient, subject, body, priority, resolveSenderToName);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Register a domain (not implemented - for backward compatibility)
|
|
146
|
+
*/
|
|
147
|
+
async registerDomain(_domain) {
|
|
148
|
+
throw new Error('Domain registration not yet implemented');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Delegate to another address
|
|
152
|
+
*/
|
|
153
|
+
async delegateTo(delegate) {
|
|
154
|
+
if (this.chainType === ChainType.EVM) {
|
|
155
|
+
return this.delegateEVM(delegate);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return this.delegateSolana(delegate);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Claim revenue share
|
|
163
|
+
*/
|
|
164
|
+
async claimRevenue() {
|
|
165
|
+
if (this.chainType === ChainType.EVM) {
|
|
166
|
+
return this.claimEVMRevenue();
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return this.claimSolanaRevenue();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Performance optimization: cache module imports
|
|
173
|
+
async getEVMModules() {
|
|
174
|
+
if (!OnchainMailerClient.evmModules) {
|
|
175
|
+
const evmModule = await import('../evm/index.js');
|
|
176
|
+
OnchainMailerClient.evmModules = {
|
|
177
|
+
MailerClient: evmModule.MailerClient
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return OnchainMailerClient.evmModules;
|
|
181
|
+
}
|
|
182
|
+
async getSolanaModules() {
|
|
183
|
+
if (!OnchainMailerClient.solanaModules) {
|
|
184
|
+
const [solanaModule, web3Module] = await Promise.all([
|
|
185
|
+
import('../solana/index.js'),
|
|
186
|
+
import('@solana/web3.js')
|
|
187
|
+
]);
|
|
188
|
+
OnchainMailerClient.solanaModules = {
|
|
189
|
+
MailerClient: solanaModule.MailerClient,
|
|
190
|
+
PublicKey: web3Module.PublicKey,
|
|
191
|
+
Connection: web3Module.Connection
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return OnchainMailerClient.solanaModules;
|
|
195
|
+
}
|
|
196
|
+
// EVM implementation methods
|
|
197
|
+
async sendEVMMessage(to, subject, body, priority, resolveSenderToName) {
|
|
198
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
199
|
+
throw new Error('EVM client not properly initialized');
|
|
200
|
+
}
|
|
201
|
+
const { MailerClient } = await this.getEVMModules();
|
|
202
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
203
|
+
// Validate message
|
|
204
|
+
if (!subject || subject.length > 200) {
|
|
205
|
+
throw new Error('Subject must be 1-200 characters');
|
|
206
|
+
}
|
|
207
|
+
if (!body || body.length > 10000) {
|
|
208
|
+
throw new Error('Body must be 1-10000 characters');
|
|
209
|
+
}
|
|
210
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
211
|
+
const payer = account;
|
|
212
|
+
const result = await client.send(to, subject, body, payer, priority, resolveSenderToName, this.evmWalletClient, account);
|
|
213
|
+
// Convert to MessageResult format
|
|
214
|
+
return {
|
|
215
|
+
transactionHash: result.hash,
|
|
216
|
+
chainType: ChainType.EVM,
|
|
217
|
+
fee: BigInt(priority ? '100000' : '10000'),
|
|
218
|
+
gasUsed: result.gasUsed,
|
|
219
|
+
isPriority: priority,
|
|
220
|
+
success: true
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async delegateEVM(delegate) {
|
|
224
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
225
|
+
throw new Error('EVM client not properly initialized');
|
|
226
|
+
}
|
|
227
|
+
const { MailerClient } = await this.getEVMModules();
|
|
228
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
229
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
230
|
+
const result = await client.delegateTo(delegate, this.evmWalletClient, account);
|
|
231
|
+
return {
|
|
232
|
+
transactionHash: result.hash,
|
|
233
|
+
chainType: ChainType.EVM,
|
|
234
|
+
delegate,
|
|
235
|
+
success: true
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
async claimEVMRevenue() {
|
|
239
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
240
|
+
throw new Error('EVM client not properly initialized');
|
|
241
|
+
}
|
|
242
|
+
const { MailerClient } = await this.getEVMModules();
|
|
243
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
244
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
245
|
+
const result = await client.claimRecipientShare(this.evmWalletClient, account);
|
|
246
|
+
return {
|
|
247
|
+
hash: result.hash,
|
|
248
|
+
chainType: ChainType.EVM,
|
|
249
|
+
blockNumber: result.blockNumber,
|
|
250
|
+
timestamp: Date.now()
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// Solana implementation methods
|
|
254
|
+
async sendSolanaMessage(to, subject, body, priority, resolveSenderToName) {
|
|
255
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
256
|
+
throw new Error('Solana client not properly initialized');
|
|
257
|
+
}
|
|
258
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
259
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
260
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
261
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
262
|
+
const result = await client.send(to, subject, body, priority, resolveSenderToName);
|
|
263
|
+
// Get current fees
|
|
264
|
+
const fees = await client.getFees();
|
|
265
|
+
return {
|
|
266
|
+
transactionHash: result.signature,
|
|
267
|
+
chainType: ChainType.SOLANA,
|
|
268
|
+
fee: priority ? fees.sendFee : fees.sendFee / 10,
|
|
269
|
+
isPriority: priority,
|
|
270
|
+
success: true
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
async delegateSolana(delegate) {
|
|
274
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
275
|
+
throw new Error('Solana client not properly initialized');
|
|
276
|
+
}
|
|
277
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
278
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
279
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
280
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
281
|
+
const result = await client.delegateTo(delegate);
|
|
282
|
+
return {
|
|
283
|
+
transactionHash: result.signature,
|
|
284
|
+
chainType: ChainType.SOLANA,
|
|
285
|
+
delegate,
|
|
286
|
+
success: true
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
async claimSolanaRevenue() {
|
|
290
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
291
|
+
throw new Error('Solana client not properly initialized');
|
|
292
|
+
}
|
|
293
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
294
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
295
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
296
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
297
|
+
const result = await client.claimRecipientShare();
|
|
298
|
+
const slot = await this.solanaConnection.getSlot();
|
|
299
|
+
return {
|
|
300
|
+
hash: result.signature,
|
|
301
|
+
chainType: ChainType.SOLANA,
|
|
302
|
+
slot,
|
|
303
|
+
timestamp: Date.now()
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// Read methods
|
|
307
|
+
async getSendFee() {
|
|
308
|
+
if (this.chainType === ChainType.EVM) {
|
|
309
|
+
return this.getEVMSendFee();
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
return this.getSolanaSendFee();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async getEVMSendFee() {
|
|
316
|
+
if (!this.evmPublicClient || !this.evmContractAddress) {
|
|
317
|
+
throw new Error('EVM client not properly initialized');
|
|
318
|
+
}
|
|
319
|
+
const { MailerClient } = await this.getEVMModules();
|
|
320
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
321
|
+
return client.getSendFee();
|
|
322
|
+
}
|
|
323
|
+
async getSolanaSendFee() {
|
|
324
|
+
if (!this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
325
|
+
throw new Error('Solana client not properly initialized');
|
|
326
|
+
}
|
|
327
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
328
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
329
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
330
|
+
// Create a minimal wallet object for reading
|
|
331
|
+
const wallet = { publicKey: PublicKey.default, signTransaction: async (tx) => tx };
|
|
332
|
+
const client = new MailerClient(this.solanaConnection, wallet, programId, usdcMint);
|
|
333
|
+
const fees = await client.getFees();
|
|
334
|
+
return BigInt(fees.sendFee);
|
|
335
|
+
}
|
|
336
|
+
// Additional read methods
|
|
337
|
+
async getClaimableAmount(address) {
|
|
338
|
+
const targetAddress = address || await this.getWalletAddressAsync();
|
|
339
|
+
if (this.chainType === ChainType.EVM) {
|
|
340
|
+
return this.getEVMClaimableAmount(targetAddress);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
return this.getSolanaClaimableAmount(targetAddress);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async getEVMClaimableAmount(address) {
|
|
347
|
+
if (!this.evmPublicClient || !this.evmContractAddress) {
|
|
348
|
+
throw new Error('EVM client not properly initialized');
|
|
349
|
+
}
|
|
350
|
+
const { MailerClient } = await this.getEVMModules();
|
|
351
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
352
|
+
const result = await client.getRecipientClaimable(address);
|
|
353
|
+
return result.amount;
|
|
354
|
+
}
|
|
355
|
+
async getSolanaClaimableAmount(address) {
|
|
356
|
+
if (!this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
357
|
+
throw new Error('Solana client not properly initialized');
|
|
358
|
+
}
|
|
359
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
360
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
361
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
362
|
+
const wallet = { publicKey: PublicKey.default, signTransaction: async (tx) => tx };
|
|
363
|
+
const client = new MailerClient(this.solanaConnection, wallet, programId, usdcMint);
|
|
364
|
+
const recipientKey = new PublicKey(address);
|
|
365
|
+
const claimInfo = await client.getRecipientClaimable(recipientKey);
|
|
366
|
+
return claimInfo ? BigInt(claimInfo.amount) : 0n;
|
|
367
|
+
}
|
|
368
|
+
async getOwnerClaimable() {
|
|
369
|
+
if (this.chainType === ChainType.EVM) {
|
|
370
|
+
return this.getEVMOwnerClaimable();
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
return this.getSolanaOwnerClaimable();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async getEVMOwnerClaimable() {
|
|
377
|
+
if (!this.evmPublicClient || !this.evmContractAddress) {
|
|
378
|
+
throw new Error('EVM client not properly initialized');
|
|
379
|
+
}
|
|
380
|
+
const { MailerClient } = await this.getEVMModules();
|
|
381
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
382
|
+
return client.getOwnerClaimable();
|
|
383
|
+
}
|
|
384
|
+
async getSolanaOwnerClaimable() {
|
|
385
|
+
if (!this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
386
|
+
throw new Error('Solana client not properly initialized');
|
|
387
|
+
}
|
|
388
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
389
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
390
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
391
|
+
const wallet = { publicKey: PublicKey.default, signTransaction: async (tx) => tx };
|
|
392
|
+
const client = new MailerClient(this.solanaConnection, wallet, programId, usdcMint);
|
|
393
|
+
const amount = await client.getOwnerClaimable();
|
|
394
|
+
return BigInt(amount);
|
|
395
|
+
}
|
|
396
|
+
async getDelegation(address) {
|
|
397
|
+
const targetAddress = address || await this.getWalletAddressAsync();
|
|
398
|
+
if (this.chainType === ChainType.EVM) {
|
|
399
|
+
return this.getEVMDelegation(targetAddress);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
return this.getSolanaDelegation(targetAddress);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
async getEVMDelegation(_address) {
|
|
406
|
+
// Delegation read not implemented in EVM client yet
|
|
407
|
+
throw new Error('getDelegation not yet implemented for EVM');
|
|
408
|
+
}
|
|
409
|
+
async getSolanaDelegation(address) {
|
|
410
|
+
if (!this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
411
|
+
throw new Error('Solana client not properly initialized');
|
|
412
|
+
}
|
|
413
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
414
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
415
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
416
|
+
const wallet = { publicKey: PublicKey.default, signTransaction: async (tx) => tx };
|
|
417
|
+
const client = new MailerClient(this.solanaConnection, wallet, programId, usdcMint);
|
|
418
|
+
const delegatorKey = new PublicKey(address);
|
|
419
|
+
const delegationInfo = await client.getDelegation(delegatorKey);
|
|
420
|
+
return delegationInfo?.delegate || null;
|
|
421
|
+
}
|
|
422
|
+
async getDelegationFee() {
|
|
423
|
+
if (this.chainType === ChainType.EVM) {
|
|
424
|
+
return this.getEVMDelegationFee();
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
return this.getSolanaDelegationFee();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
async getEVMDelegationFee() {
|
|
431
|
+
if (!this.evmPublicClient || !this.evmContractAddress) {
|
|
432
|
+
throw new Error('EVM client not properly initialized');
|
|
433
|
+
}
|
|
434
|
+
const { MailerClient } = await this.getEVMModules();
|
|
435
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
436
|
+
return client.getDelegationFee();
|
|
437
|
+
}
|
|
438
|
+
async getSolanaDelegationFee() {
|
|
439
|
+
if (!this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
440
|
+
throw new Error('Solana client not properly initialized');
|
|
441
|
+
}
|
|
442
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
443
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
444
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
445
|
+
const wallet = { publicKey: PublicKey.default, signTransaction: async (tx) => tx };
|
|
446
|
+
const client = new MailerClient(this.solanaConnection, wallet, programId, usdcMint);
|
|
447
|
+
const fees = await client.getFees();
|
|
448
|
+
return BigInt(fees.delegationFee);
|
|
449
|
+
}
|
|
450
|
+
async isPaused() {
|
|
451
|
+
if (this.chainType === ChainType.EVM) {
|
|
452
|
+
return this.isPausedEVM();
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
return this.isPausedSolana();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
async isPausedEVM() {
|
|
459
|
+
if (!this.evmPublicClient || !this.evmContractAddress) {
|
|
460
|
+
throw new Error('EVM client not properly initialized');
|
|
461
|
+
}
|
|
462
|
+
const { MailerClient } = await this.getEVMModules();
|
|
463
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
464
|
+
return client.isPaused();
|
|
465
|
+
}
|
|
466
|
+
async isPausedSolana() {
|
|
467
|
+
if (!this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
468
|
+
throw new Error('Solana client not properly initialized');
|
|
469
|
+
}
|
|
470
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
471
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
472
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
473
|
+
const wallet = { publicKey: PublicKey.default, signTransaction: async (tx) => tx };
|
|
474
|
+
const client = new MailerClient(this.solanaConnection, wallet, programId, usdcMint);
|
|
475
|
+
return client.isPaused();
|
|
476
|
+
}
|
|
477
|
+
// Write methods for contract management
|
|
478
|
+
async unpause() {
|
|
479
|
+
if (this.chainType === ChainType.EVM) {
|
|
480
|
+
return this.unpauseEVM();
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
return this.unpauseSolana();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
async unpauseEVM() {
|
|
487
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
488
|
+
throw new Error('EVM client not properly initialized');
|
|
489
|
+
}
|
|
490
|
+
const { MailerClient } = await this.getEVMModules();
|
|
491
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
492
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
493
|
+
const result = await client.unpause(this.evmWalletClient, account);
|
|
494
|
+
return {
|
|
495
|
+
hash: result.hash,
|
|
496
|
+
chainType: ChainType.EVM,
|
|
497
|
+
blockNumber: result.blockNumber,
|
|
498
|
+
timestamp: Date.now()
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
async unpauseSolana() {
|
|
502
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
503
|
+
throw new Error('Solana client not properly initialized');
|
|
504
|
+
}
|
|
505
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
506
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
507
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
508
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
509
|
+
const result = await client.unpause();
|
|
510
|
+
const slot = await this.solanaConnection.getSlot();
|
|
511
|
+
return {
|
|
512
|
+
hash: result.signature,
|
|
513
|
+
chainType: ChainType.SOLANA,
|
|
514
|
+
slot,
|
|
515
|
+
timestamp: Date.now()
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
async emergencyUnpause() {
|
|
519
|
+
if (this.chainType === ChainType.EVM) {
|
|
520
|
+
return this.emergencyUnpauseEVM();
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
return this.emergencyUnpauseSolana();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async emergencyUnpauseEVM() {
|
|
527
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
528
|
+
throw new Error('EVM client not properly initialized');
|
|
529
|
+
}
|
|
530
|
+
const { MailerClient } = await this.getEVMModules();
|
|
531
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
532
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
533
|
+
const result = await client.emergencyUnpause(this.evmWalletClient, account);
|
|
534
|
+
return {
|
|
535
|
+
hash: result.hash,
|
|
536
|
+
chainType: ChainType.EVM,
|
|
537
|
+
blockNumber: result.blockNumber,
|
|
538
|
+
timestamp: Date.now()
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
async emergencyUnpauseSolana() {
|
|
542
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
543
|
+
throw new Error('Solana client not properly initialized');
|
|
544
|
+
}
|
|
545
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
546
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
547
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
548
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
549
|
+
const result = await client.emergencyUnpause();
|
|
550
|
+
const slot = await this.solanaConnection.getSlot();
|
|
551
|
+
return {
|
|
552
|
+
hash: result.signature,
|
|
553
|
+
chainType: ChainType.SOLANA,
|
|
554
|
+
slot,
|
|
555
|
+
timestamp: Date.now()
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
async distributeClaimableFunds(recipient) {
|
|
559
|
+
if (this.chainType === ChainType.EVM) {
|
|
560
|
+
return this.distributeClaimableFundsEVM(recipient);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
return this.distributeClaimableFundsSolana(recipient);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
async distributeClaimableFundsEVM(recipient) {
|
|
567
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
568
|
+
throw new Error('EVM client not properly initialized');
|
|
569
|
+
}
|
|
570
|
+
const { MailerClient } = await this.getEVMModules();
|
|
571
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
572
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
573
|
+
const result = await client.distributeClaimableFunds(recipient, this.evmWalletClient, account);
|
|
574
|
+
return {
|
|
575
|
+
hash: result.hash,
|
|
576
|
+
chainType: ChainType.EVM,
|
|
577
|
+
blockNumber: result.blockNumber,
|
|
578
|
+
timestamp: Date.now()
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
async distributeClaimableFundsSolana(recipient) {
|
|
582
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
583
|
+
throw new Error('Solana client not properly initialized');
|
|
584
|
+
}
|
|
585
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
586
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
587
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
588
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
589
|
+
const result = await client.distributeClaimableFunds(recipient);
|
|
590
|
+
const slot = await this.solanaConnection.getSlot();
|
|
591
|
+
return {
|
|
592
|
+
hash: result.signature,
|
|
593
|
+
chainType: ChainType.SOLANA,
|
|
594
|
+
slot,
|
|
595
|
+
timestamp: Date.now()
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
// Additional methods for complete API compatibility
|
|
599
|
+
async sendPrepared(to, mailId, priority = false, resolveSenderToName = false) {
|
|
600
|
+
if (this.chainType === ChainType.EVM) {
|
|
601
|
+
return this.sendPreparedEVM(to, mailId, priority, resolveSenderToName);
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
return this.sendPreparedSolana(to, mailId, priority, resolveSenderToName);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
async sendPreparedEVM(to, mailId, priority, resolveSenderToName) {
|
|
608
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
609
|
+
throw new Error('EVM client not properly initialized');
|
|
610
|
+
}
|
|
611
|
+
const { MailerClient } = await this.getEVMModules();
|
|
612
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
613
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
614
|
+
const payer = account;
|
|
615
|
+
const result = await client.sendPrepared(to, mailId, payer, priority, resolveSenderToName, this.evmWalletClient, account);
|
|
616
|
+
return {
|
|
617
|
+
transactionHash: result.hash,
|
|
618
|
+
chainType: ChainType.EVM,
|
|
619
|
+
fee: BigInt(priority ? '100000' : '10000'),
|
|
620
|
+
gasUsed: result.gasUsed,
|
|
621
|
+
isPriority: priority,
|
|
622
|
+
success: true
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
async sendPreparedSolana(to, mailId, priority, resolveSenderToName) {
|
|
626
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
627
|
+
throw new Error('Solana client not properly initialized');
|
|
628
|
+
}
|
|
629
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
630
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
631
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
632
|
+
const recipientKey = new PublicKey(to);
|
|
633
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
634
|
+
const result = await client.sendPrepared(recipientKey, mailId, priority, resolveSenderToName);
|
|
635
|
+
const fees = await client.getFees();
|
|
636
|
+
return {
|
|
637
|
+
transactionHash: result.signature,
|
|
638
|
+
chainType: ChainType.SOLANA,
|
|
639
|
+
fee: priority ? fees.sendFee : fees.sendFee / 10,
|
|
640
|
+
isPriority: priority,
|
|
641
|
+
success: true
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
async sendToEmail(toEmail, subject, body) {
|
|
645
|
+
if (this.chainType === ChainType.EVM) {
|
|
646
|
+
return this.sendToEmailEVM(toEmail, subject, body);
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
return this.sendToEmailSolana(toEmail, subject, body);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
async sendToEmailEVM(toEmail, subject, body) {
|
|
653
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
654
|
+
throw new Error('EVM client not properly initialized');
|
|
655
|
+
}
|
|
656
|
+
const { MailerClient } = await this.getEVMModules();
|
|
657
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
658
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
659
|
+
const payer = account;
|
|
660
|
+
const result = await client.sendToEmailAddress(toEmail, subject, body, payer, this.evmWalletClient, account);
|
|
661
|
+
return {
|
|
662
|
+
transactionHash: result.hash,
|
|
663
|
+
chainType: ChainType.EVM,
|
|
664
|
+
fee: BigInt('10000'), // 10% fee only
|
|
665
|
+
gasUsed: result.gasUsed,
|
|
666
|
+
isPriority: false,
|
|
667
|
+
success: true
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
async sendToEmailSolana(toEmail, subject, body) {
|
|
671
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
672
|
+
throw new Error('Solana client not properly initialized');
|
|
673
|
+
}
|
|
674
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
675
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
676
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
677
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
678
|
+
const result = await client.sendToEmail(toEmail, subject, body);
|
|
679
|
+
const fees = await client.getFees();
|
|
680
|
+
return {
|
|
681
|
+
transactionHash: result.signature,
|
|
682
|
+
chainType: ChainType.SOLANA,
|
|
683
|
+
fee: fees.sendFee / 10, // 10% fee only
|
|
684
|
+
isPriority: false,
|
|
685
|
+
success: true
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
async sendPreparedToEmail(toEmail, mailId) {
|
|
689
|
+
if (this.chainType === ChainType.EVM) {
|
|
690
|
+
return this.sendPreparedToEmailEVM(toEmail, mailId);
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
return this.sendPreparedToEmailSolana(toEmail, mailId);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
async sendPreparedToEmailEVM(toEmail, mailId) {
|
|
697
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
698
|
+
throw new Error('EVM client not properly initialized');
|
|
699
|
+
}
|
|
700
|
+
const { MailerClient } = await this.getEVMModules();
|
|
701
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
702
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
703
|
+
const payer = account;
|
|
704
|
+
const result = await client.sendPreparedToEmailAddress(toEmail, mailId, payer, this.evmWalletClient, account);
|
|
705
|
+
return {
|
|
706
|
+
transactionHash: result.hash,
|
|
707
|
+
chainType: ChainType.EVM,
|
|
708
|
+
fee: BigInt('10000'), // 10% fee only
|
|
709
|
+
gasUsed: result.gasUsed,
|
|
710
|
+
isPriority: false,
|
|
711
|
+
success: true
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
async sendPreparedToEmailSolana(toEmail, mailId) {
|
|
715
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
716
|
+
throw new Error('Solana client not properly initialized');
|
|
717
|
+
}
|
|
718
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
719
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
720
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
721
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
722
|
+
const result = await client.sendPreparedToEmail(toEmail, mailId);
|
|
723
|
+
const fees = await client.getFees();
|
|
724
|
+
return {
|
|
725
|
+
transactionHash: result.signature,
|
|
726
|
+
chainType: ChainType.SOLANA,
|
|
727
|
+
fee: fees.sendFee / 10, // 10% fee only
|
|
728
|
+
isPriority: false,
|
|
729
|
+
success: true
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
async claimOwnerShare() {
|
|
733
|
+
if (this.chainType === ChainType.EVM) {
|
|
734
|
+
return this.claimOwnerShareEVM();
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
return this.claimOwnerShareSolana();
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
async claimOwnerShareEVM() {
|
|
741
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
742
|
+
throw new Error('EVM client not properly initialized');
|
|
743
|
+
}
|
|
744
|
+
const { MailerClient } = await this.getEVMModules();
|
|
745
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
746
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
747
|
+
const result = await client.claimOwnerShare(this.evmWalletClient, account);
|
|
748
|
+
return {
|
|
749
|
+
hash: result.hash,
|
|
750
|
+
chainType: ChainType.EVM,
|
|
751
|
+
blockNumber: result.blockNumber,
|
|
752
|
+
timestamp: Date.now()
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
async claimOwnerShareSolana() {
|
|
756
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
757
|
+
throw new Error('Solana client not properly initialized');
|
|
758
|
+
}
|
|
759
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
760
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
761
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
762
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
763
|
+
const result = await client.claimOwnerShare();
|
|
764
|
+
const slot = await this.solanaConnection.getSlot();
|
|
765
|
+
return {
|
|
766
|
+
hash: result.signature,
|
|
767
|
+
chainType: ChainType.SOLANA,
|
|
768
|
+
slot,
|
|
769
|
+
timestamp: Date.now()
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
async claimExpiredShares(recipient) {
|
|
773
|
+
if (this.chainType === ChainType.EVM) {
|
|
774
|
+
return this.claimExpiredSharesEVM(recipient);
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
return this.claimExpiredSharesSolana(recipient);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
async claimExpiredSharesEVM(recipient) {
|
|
781
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
782
|
+
throw new Error('EVM client not properly initialized');
|
|
783
|
+
}
|
|
784
|
+
const { MailerClient } = await this.getEVMModules();
|
|
785
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
786
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
787
|
+
const result = await client.claimExpiredShares(recipient, this.evmWalletClient, account);
|
|
788
|
+
return {
|
|
789
|
+
hash: result.hash,
|
|
790
|
+
chainType: ChainType.EVM,
|
|
791
|
+
blockNumber: result.blockNumber,
|
|
792
|
+
timestamp: Date.now()
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
async claimExpiredSharesSolana(recipient) {
|
|
796
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
797
|
+
throw new Error('Solana client not properly initialized');
|
|
798
|
+
}
|
|
799
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
800
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
801
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
802
|
+
const recipientKey = new PublicKey(recipient);
|
|
803
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
804
|
+
const result = await client.claimExpiredShares(recipientKey);
|
|
805
|
+
const slot = await this.solanaConnection.getSlot();
|
|
806
|
+
return {
|
|
807
|
+
hash: result.signature,
|
|
808
|
+
chainType: ChainType.SOLANA,
|
|
809
|
+
slot,
|
|
810
|
+
timestamp: Date.now()
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
async rejectDelegation(delegatorAddress) {
|
|
814
|
+
if (this.chainType === ChainType.EVM) {
|
|
815
|
+
return this.rejectDelegationEVM(delegatorAddress);
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
return this.rejectDelegationSolana(delegatorAddress);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
async rejectDelegationEVM(delegatorAddress) {
|
|
822
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
823
|
+
throw new Error('EVM client not properly initialized');
|
|
824
|
+
}
|
|
825
|
+
const { MailerClient } = await this.getEVMModules();
|
|
826
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
827
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
828
|
+
const result = await client.rejectDelegation(delegatorAddress, this.evmWalletClient, account);
|
|
829
|
+
return {
|
|
830
|
+
hash: result.hash,
|
|
831
|
+
chainType: ChainType.EVM,
|
|
832
|
+
blockNumber: result.blockNumber,
|
|
833
|
+
timestamp: Date.now()
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
async rejectDelegationSolana(delegatorAddress) {
|
|
837
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
838
|
+
throw new Error('Solana client not properly initialized');
|
|
839
|
+
}
|
|
840
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
841
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
842
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
843
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
844
|
+
const result = await client.rejectDelegation(delegatorAddress);
|
|
845
|
+
const slot = await this.solanaConnection.getSlot();
|
|
846
|
+
return {
|
|
847
|
+
hash: result.signature,
|
|
848
|
+
chainType: ChainType.SOLANA,
|
|
849
|
+
slot,
|
|
850
|
+
timestamp: Date.now()
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
async setFee(newFee) {
|
|
854
|
+
if (this.chainType === ChainType.EVM) {
|
|
855
|
+
return this.setFeeEVM(newFee);
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
return this.setFeeSolana(newFee);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
async setFeeEVM(newFee) {
|
|
862
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
863
|
+
throw new Error('EVM client not properly initialized');
|
|
864
|
+
}
|
|
865
|
+
const { MailerClient } = await this.getEVMModules();
|
|
866
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
867
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
868
|
+
const result = await client.setFee(newFee, this.evmWalletClient, account);
|
|
869
|
+
return {
|
|
870
|
+
hash: result.hash,
|
|
871
|
+
chainType: ChainType.EVM,
|
|
872
|
+
blockNumber: result.blockNumber,
|
|
873
|
+
timestamp: Date.now()
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
async setFeeSolana(newFee) {
|
|
877
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
878
|
+
throw new Error('Solana client not properly initialized');
|
|
879
|
+
}
|
|
880
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
881
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
882
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
883
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
884
|
+
const result = await client.setFee(newFee);
|
|
885
|
+
const slot = await this.solanaConnection.getSlot();
|
|
886
|
+
return {
|
|
887
|
+
hash: result.signature,
|
|
888
|
+
chainType: ChainType.SOLANA,
|
|
889
|
+
slot,
|
|
890
|
+
timestamp: Date.now()
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
async setDelegationFee(newFee) {
|
|
894
|
+
if (this.chainType === ChainType.EVM) {
|
|
895
|
+
return this.setDelegationFeeEVM(newFee);
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
return this.setDelegationFeeSolana(newFee);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
async setDelegationFeeEVM(newFee) {
|
|
902
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
903
|
+
throw new Error('EVM client not properly initialized');
|
|
904
|
+
}
|
|
905
|
+
const { MailerClient } = await this.getEVMModules();
|
|
906
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
907
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
908
|
+
const result = await client.setDelegationFee(newFee, this.evmWalletClient, account);
|
|
909
|
+
return {
|
|
910
|
+
hash: result.hash,
|
|
911
|
+
chainType: ChainType.EVM,
|
|
912
|
+
blockNumber: result.blockNumber,
|
|
913
|
+
timestamp: Date.now()
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
async setDelegationFeeSolana(newFee) {
|
|
917
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
918
|
+
throw new Error('Solana client not properly initialized');
|
|
919
|
+
}
|
|
920
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
921
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
922
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
923
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
924
|
+
const result = await client.setDelegationFee(newFee);
|
|
925
|
+
const slot = await this.solanaConnection.getSlot();
|
|
926
|
+
return {
|
|
927
|
+
hash: result.signature,
|
|
928
|
+
chainType: ChainType.SOLANA,
|
|
929
|
+
slot,
|
|
930
|
+
timestamp: Date.now()
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
async pause() {
|
|
934
|
+
if (this.chainType === ChainType.EVM) {
|
|
935
|
+
return this.pauseEVM();
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
return this.pauseSolana();
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
async pauseEVM() {
|
|
942
|
+
if (!this.evmWalletClient || !this.evmPublicClient || !this.evmContractAddress) {
|
|
943
|
+
throw new Error('EVM client not properly initialized');
|
|
944
|
+
}
|
|
945
|
+
const { MailerClient } = await this.getEVMModules();
|
|
946
|
+
const client = new MailerClient(this.evmContractAddress, this.evmPublicClient);
|
|
947
|
+
const [account] = await this.evmWalletClient.getAddresses();
|
|
948
|
+
const result = await client.pause(this.evmWalletClient, account);
|
|
949
|
+
return {
|
|
950
|
+
hash: result.hash,
|
|
951
|
+
chainType: ChainType.EVM,
|
|
952
|
+
blockNumber: result.blockNumber,
|
|
953
|
+
timestamp: Date.now()
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
async pauseSolana() {
|
|
957
|
+
if (!this.solanaWallet || !this.solanaConnection || !this.solanaProgramId || !this.solanaUsdcMint) {
|
|
958
|
+
throw new Error('Solana client not properly initialized');
|
|
959
|
+
}
|
|
960
|
+
const { MailerClient, PublicKey } = await this.getSolanaModules();
|
|
961
|
+
const programId = new PublicKey(this.solanaProgramId);
|
|
962
|
+
const usdcMint = new PublicKey(this.solanaUsdcMint);
|
|
963
|
+
const client = new MailerClient(this.solanaConnection, this.solanaWallet, programId, usdcMint);
|
|
964
|
+
const result = await client.pause();
|
|
965
|
+
const slot = await this.solanaConnection.getSlot();
|
|
966
|
+
return {
|
|
967
|
+
hash: result.signature,
|
|
968
|
+
chainType: ChainType.SOLANA,
|
|
969
|
+
slot,
|
|
970
|
+
timestamp: Date.now()
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
// Utility methods
|
|
974
|
+
getChainType() {
|
|
975
|
+
return this.chainType;
|
|
976
|
+
}
|
|
977
|
+
getWalletAddress() {
|
|
978
|
+
if (this.chainType === ChainType.EVM) {
|
|
979
|
+
// Try to get address from raw wallet for backward compatibility
|
|
980
|
+
// @ts-ignore
|
|
981
|
+
if (this._rawEvmWallet) {
|
|
982
|
+
// @ts-ignore
|
|
983
|
+
return this._rawEvmWallet.address || this._rawEvmWallet.selectedAddress || '';
|
|
984
|
+
}
|
|
985
|
+
return ''; // Caller should use getWalletAddressAsync() for accurate address
|
|
986
|
+
}
|
|
987
|
+
else if (this.chainType === ChainType.SOLANA && this.solanaWallet) {
|
|
988
|
+
return this.solanaWallet.publicKey?.toString() || '';
|
|
989
|
+
}
|
|
990
|
+
return '';
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Get wallet address asynchronously
|
|
994
|
+
*/
|
|
995
|
+
async getWalletAddressAsync() {
|
|
996
|
+
if (this.chainType === ChainType.EVM && this.evmWalletClient) {
|
|
997
|
+
const [address] = await this.evmWalletClient.getAddresses();
|
|
998
|
+
return address;
|
|
999
|
+
}
|
|
1000
|
+
else if (this.chainType === ChainType.SOLANA && this.solanaWallet) {
|
|
1001
|
+
return this.solanaWallet.publicKey?.toString() || '';
|
|
1002
|
+
}
|
|
1003
|
+
throw new Error('Wallet not initialized');
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
// Cache for dynamic imports
|
|
1007
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1008
|
+
OnchainMailerClient.evmModules = null;
|
|
1009
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1010
|
+
OnchainMailerClient.solanaModules = null;
|
|
1011
|
+
//# sourceMappingURL=onchain-mailer-client.js.map
|