-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from frankcrypto2023/dev
add meerchange abi && fix not automatically publish when the version did not change
- Loading branch information
Showing
5 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters