diff --git a/package-lock.json b/package-lock.json index 9237949..154ef35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1521,9 +1521,9 @@ "link": true }, "node_modules/@qng/meerchange-contracts": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@qng/meerchange-contracts/-/meerchange-contracts-0.0.3.tgz", - "integrity": "sha512-Sn/aJnaZZVu0fyw988xbqlXnAal6vv8peZPsfdiQvl4cb5Z+4vh8XADokCTCnRCP+SBnvEowD+u8mpvAs9qrMg==", + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@qng/meerchange-contracts/-/meerchange-contracts-0.0.4.tgz", + "integrity": "sha512-Vm7vq8fayAxnxEFaOzix8dENiG6Y6IC2zQaJAZsqpVJR7KXkvQhA6Bz2E6YXDRVVvsP6FcYMGMhWh4FZh3f5Sg==", "dev": true }, "node_modules/@scure/base": { @@ -11783,7 +11783,8 @@ } }, "src/eip4337": { - "version": "0.6.6", + "name": "@qng/eip4337-sdk", + "version": "0.6.10", "license": "MIT", "devDependencies": { "@account-abstraction/sdk": "^0.6.0", @@ -11791,7 +11792,7 @@ "@nomicfoundation/hardhat-toolbox": "^1.0.2", "@nomiclabs/hardhat-ethers": "^2.0.0", "@qng/eip4337-contracts": "^0.6.0", - "@qng/meerchange-contracts": "^0.0.3", + "@qng/meerchange-contracts": "^0.0.4", "chai": "^4.3.6", "hardhat": "^2.11.0" } diff --git a/src/eip4337/address.ts b/src/eip4337/address.ts index baa86ca..f9d52ea 100644 --- a/src/eip4337/address.ts +++ b/src/eip4337/address.ts @@ -1,4 +1,4 @@ export const EntryPointAddr = `0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789`; -export const QngAccountFactoryAddr = `0xa95a633294a8ce18298B488858d90c4E16FD0AB0`; -export const QngPaymasterAddr = `0x016001559A8685af58C45f0d6408fF88075343c5`; -export const MeerChangeAddr = `0x09654c5D28b462BA219038e534e685f703B2EE5f`; +export const QngAccountFactoryAddr = `0x5c5ac24588658551bdc7C18D266AbF28d47e6039`; +export const QngPaymasterAddr = `0x6A8E1b74a5e06687ce47959575dE51A20004be0F`; +export const MeerChangeAddr = `0x7D698C4E800dBc1E9B7e915BefeDdB59Aa9E8BB6`; diff --git a/src/eip4337/meerchange.ts b/src/eip4337/meerchange.ts index 35414eb..62c7349 100644 --- a/src/eip4337/meerchange.ts +++ b/src/eip4337/meerchange.ts @@ -1,7 +1,6 @@ import * as contracts from "@qng/meerchange-contracts"; import { Provider } from "@ethersproject/providers"; -import { ethers } from "ethers"; export class MeerChangeAPI { meerchangeContract: any; meerchangeAddr: string; @@ -19,19 +18,10 @@ export class MeerChangeAPI { } return this.meerchangeContract; } - async encodeExport4337( - txid: string, - idx: number, - fee: number, - signature: string - ) { - if (!txid.startsWith("0x")) { - txid = `0x${txid}`; - } + async encodeExport4337(ops: string, fee: number, signature: string) { const meerchangeContract = await this._getMeerChangeContract(); return meerchangeContract.interface.encodeFunctionData("export", [ - ethers.utils.hexZeroPad(txid, 32), - idx, + ops, fee, signature, ]); diff --git a/src/eip4337/package.json b/src/eip4337/package.json index f26eb20..dee0138 100644 --- a/src/eip4337/package.json +++ b/src/eip4337/package.json @@ -1,7 +1,7 @@ { "name": "@qng/eip4337-sdk", "description": "Qng Account Abstraction (EIP 4337) contracts SDK", - "version": "0.6.8", + "version": "0.6.10", "main": "./dist/index.js", "files": [ "dist/" @@ -32,7 +32,7 @@ }, "devDependencies": { "@qng/eip4337-contracts": "^0.6.0", - "@qng/meerchange-contracts": "^0.0.3", + "@qng/meerchange-contracts": "^0.0.4", "@account-abstraction/sdk": "^0.6.0", "@nomicfoundation/hardhat-chai-matchers": "^1.0.3", "@nomicfoundation/hardhat-toolbox": "^1.0.2", diff --git a/src/eip4337/test/4-encodeExport4337.test.ts b/src/eip4337/test/4-encodeExport4337.test.ts new file mode 100644 index 0000000..0a1d517 --- /dev/null +++ b/src/eip4337/test/4-encodeExport4337.test.ts @@ -0,0 +1,16 @@ +import { MeerChangeAPI, MeerChangeAddr } from "../"; + +describe("export4337", () => { + const abi = new MeerChangeAPI({ + meerchangeAddr: MeerChangeAddr, + }); + + it("returns a gas value proportional to sigSize", async () => { + const data = await abi.encodeExport4337( + "d47e847a8ac828abc27109b3f94a053c4dba53ccc6eb37cb7872435e0ee8936a:0", + 10000, + "3097947d270698a7f7d6bd5b9f4b725af77c9c866219893f75b63f2207370d5279249ec5cccc4973c343f299d086412c9443bb4f30e283a628f7043c6c0b14be00" + ); + console.log(data); + }); +});