Skip to content

Commit

Permalink
Merge pull request #12 from frankcrypto2023/dev
Browse files Browse the repository at this point in the history
add meerchange abi && fix not automatically publish when the version did not change
  • Loading branch information
dindinw authored Sep 13, 2024
2 parents 51a5ad6 + b04ee4b commit 014b1a9
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 6 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ jobs:
echo "::set-output name=version_changed::false";
fi
- name: Use Node.js ${{ matrix.node-version }}
if: steps.check_version.outputs.version_changed == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- run: npm install
- run: npm run build
- run: npm publish --provenance --access public

- name: Publish to npm
if: steps.check_version.outputs.version_changed == 'true'
run: |
npm ci
npm run build
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 9 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/eip4337/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ import {
HttpRpcClient,
BaseAccountAPI,
} from "./qngAccountAPI";
export { QngAccountAPI, PaymasterAPI, HttpRpcClient, BaseAccountAPI };
import { MeerChangeAPI } from "./meerchange";
export {
QngAccountAPI,
PaymasterAPI,
HttpRpcClient,
BaseAccountAPI,
MeerChangeAPI,
};
47 changes: 47 additions & 0 deletions src/eip4337/meerchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as contracts from "@qng/meerchange-contracts";

import { Provider } from "@ethersproject/providers";
import { ethers } from "ethers";
export class MeerChangeAPI {
meerchangeContract: any;
meerchangeAddr: string;
provider: Provider;
constructor(params: any) {
this.provider = params.provider;
this.meerchangeAddr = params.meerchangeAddr;
}
async _getMeerChangeContract() {
if (this.meerchangeContract == null) {
this.meerchangeContract = await contracts.MeerChange__factory.connect(
await this.getMeerChangeAddress(),
this.provider
);
}
return this.meerchangeContract;
}
async encodeExport4337(
txid: string,
idx: number,
fee: number,
signature: string
) {
if (!txid.startsWith("0x")) {
txid = `0x${txid}`;
}
const meerchangeContract = await this._getMeerChangeContract();
return meerchangeContract.interface.encodeFunctionData("export4337", [
ethers.utils.hexZeroPad(txid, 32),
idx,
fee,
signature,
]);
}

async getMeerChangeAddress() {
// TODO
// {
// "id":1,"jsonrpc":"2.0","method":"qng_getMeerChangeAddress","params":[]
//}
return this.meerchangeAddr;
}
}
2 changes: 2 additions & 0 deletions src/eip4337/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"keywords": [
"sdk",
"qitmeer",
"qng",
"smart",
"contracts",
Expand All @@ -26,6 +27,7 @@
},
"devDependencies": {
"@qng/eip4337-contracts": "^0.6.0",
"@qng/meerchange-contracts": "^0.0.1",
"@account-abstraction/sdk": "^0.6.0"
}
}

0 comments on commit 014b1a9

Please sign in to comment.