mirror of
https://github.com/getwax/eth-global-lisbon-hackathon.git
synced 2026-01-09 15:57:55 -05:00
Add sign and send tx function to sign page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BigNumber, BigNumberish } from 'ethers';
|
||||
import { BigNumber, BigNumberish, ethers } from 'ethers';
|
||||
import {
|
||||
SafeProxy,
|
||||
SafeProxy__factory,
|
||||
@@ -16,6 +16,7 @@ import { Signer } from '@ethersproject/abstract-signer';
|
||||
import { BaseAccountAPI } from '@account-abstraction/sdk';
|
||||
import { BaseApiParams } from '@account-abstraction/sdk/src/BaseAccountAPI';
|
||||
import { TransactionDetailsForUserOp } from '@account-abstraction/sdk/src/TransactionDetailsForUserOp';
|
||||
import { solG1 } from '@thehubbleproject/bls/dist/mcl';
|
||||
|
||||
/**
|
||||
* constructor params, added no top of base params:
|
||||
@@ -71,8 +72,11 @@ export class AccountAPI extends BaseAccountAPI {
|
||||
);
|
||||
}
|
||||
|
||||
setNextAggBlsSignature(sig: string) {
|
||||
this.nextAggBlsSignature = sig;
|
||||
setNextAggBlsSignature(sig: solG1) {
|
||||
this.nextAggBlsSignature = ethers.utils.defaultAbiCoder.encode(
|
||||
['uint256[2]'],
|
||||
[sig],
|
||||
);
|
||||
}
|
||||
|
||||
async _getAccountContract(): Promise<SafeProxy> {
|
||||
|
||||
@@ -4,6 +4,8 @@ import PaymentChannel, { Payment } from '../PaymentChannel';
|
||||
import Transaction from '../components/Transaction';
|
||||
import AppContext from '../AppContext';
|
||||
import calculateSignaturesNeeded from '../utils/calculateSignaturesNeeded';
|
||||
import { IERC20__factory } from '../ERC20/IERC20__factory';
|
||||
import { AccountAPI } from '../account/AccountAPI';
|
||||
|
||||
export default function Page() {
|
||||
const appContext = AppContext.use();
|
||||
@@ -37,6 +39,23 @@ export default function Page() {
|
||||
|
||||
const addSignatureAndSend = async () => {
|
||||
await addSignature();
|
||||
|
||||
const provider = appContext?.aaProvider;
|
||||
const signer = provider?.getSigner();
|
||||
|
||||
if (!id) return;
|
||||
const channel = new PaymentChannel(id);
|
||||
const signedTx = await channel.getSignedPayment();
|
||||
|
||||
const accountApi = provider?.smartAccountAPI as AccountAPI;
|
||||
accountApi.setNextAggBlsSignature(signedTx.signature);
|
||||
|
||||
if (!payment || !signer) return;
|
||||
const ERC20 = IERC20__factory.connect(payment.token, signer);
|
||||
|
||||
const transferTx = await ERC20.transfer(payment.to, payment.amount);
|
||||
const reciept = await transferTx.wait();
|
||||
console.log('reciept', reciept);
|
||||
};
|
||||
|
||||
if (!payment)
|
||||
|
||||
Reference in New Issue
Block a user