Skip to content

Commit

Permalink
feat: use rollup built
Browse files Browse the repository at this point in the history
  • Loading branch information
snaildarter committed Mar 29, 2024
1 parent cdd6d5a commit db597bd
Show file tree
Hide file tree
Showing 30 changed files with 6,172 additions and 431 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ bin-release/
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
node_modules
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Codegeex.Chat.LanguagePreference": "English"
}
128 changes: 64 additions & 64 deletions __test__/paymaster.test.ts
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
import {describe, test} from "@jest/globals";
import {EthPaymasterClient} from "../src/ethPaymasterClient";
import {Network, Token, TryPayUserOpRequestV1} from "../src/common/type";
// import { describe, test } from "@jest/globals";
// import { health } from "../dist/index.esm.js";

const devAddres = "https://relay-ethpaymaster-pr-20.onrender.com/"
describe("PAYMASTER Health", () => {
test("Health", async () => {
let client = EthPaymasterClient.development(devAddres)
const response = await client.health()
console.log("response :" + JSON.stringify(response))
})
})
// const devAddres = "https://relay-ethpaymaster-pr-20.onrender.com/"
// describe("PAYMASTER Health", () => {
// test("Health", async () => {
// const response = await health()
// console.log("response :" + JSON.stringify(response))
// console.log(response);

describe("PAYMASTER Auth", () => {
test("Auth", async () => {
let client = EthPaymasterClient.development(devAddres)
const response = await client.auth("string")
console.log("response :" + JSON.stringify(response))
})
})
describe("PAYMASTER Try Pay Sponsor Operation", () => {
test("Try Pay Sponsor Operation", async () => {
let client = EthPaymasterClient.development(devAddres)
const authResponse = await client.auth("string");
const token = authResponse.token
console.log("token : " + token)
const request: TryPayUserOpRequestV1 = {
force_strategy_id: "1",
user_operation: {
call_data: "0xb61d27f6000000000000000000000000c206b552ab127608c3f666156c8e03a8471c72df000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
call_gas_limit: "39837",
init_code: "0xe19e9755942bb0bd0cccce25b1742596b8a8250b3bf2c3e700000000000000000000000078d4f01f56b982a3b03c4e127a5d3afa8ebee6860000000000000000000000008b388a082f370d8ac2e2b3997e9151168bd09ff50000000000000000000000000000000000000000000000000000000000000000",
max_fee_per_gas: "44020",
max_priority_fee_per_gas: "1743509478",
nonce: "1",
pre_verification_gas: "44020",
sender: "0x4A2FD3215420376DA4eD32853C19E4755deeC4D1",
signature: "0x760868cd7d9539c6e31c2169c4cab6817beb8247516a90e4301e929011451658623455035b83d38e987ef2e57558695040a25219c39eaa0e31a0ead16a5c925c1c",
verification_gas_limit: "100000",
paymaster_and_data : "0x"
}
// })
// })

}
const response = await client.tryPayUserOperationV1(authResponse.token, request)
console.log("response :" + JSON.stringify(response))
})
})
// describe("PAYMASTER Auth", () => {
// test("Auth", async () => {
// let client = EthPaymasterClient.development(devAddres)
// const response = await client.auth("string")
// console.log("response :" + JSON.stringify(response))
// })
// })
// describe("PAYMASTER Try Pay Sponsor Operation", () => {
// test("Try Pay Sponsor Operation", async () => {
// let client = EthPaymasterClient.development(devAddres)
// const authResponse = await client.auth("string");
// const token = authResponse.token
// console.log("token : " + token)
// const request: TryPayUserOpRequestV1 = {
// force_strategy_id: "1",
// user_operation: {
// call_data: "0xb61d27f6000000000000000000000000c206b552ab127608c3f666156c8e03a8471c72df000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
// call_gas_limit: "39837",
// init_code: "0xe19e9755942bb0bd0cccce25b1742596b8a8250b3bf2c3e700000000000000000000000078d4f01f56b982a3b03c4e127a5d3afa8ebee6860000000000000000000000008b388a082f370d8ac2e2b3997e9151168bd09ff50000000000000000000000000000000000000000000000000000000000000000",
// max_fee_per_gas: "44020",
// max_priority_fee_per_gas: "1743509478",
// nonce: "1",
// pre_verification_gas: "44020",
// sender: "0x4A2FD3215420376DA4eD32853C19E4755deeC4D1",
// signature: "0x760868cd7d9539c6e31c2169c4cab6817beb8247516a90e4301e929011451658623455035b83d38e987ef2e57558695040a25219c39eaa0e31a0ead16a5c925c1c",
// verification_gas_limit: "100000",
// paymaster_and_data: "0x"
// }

describe("PAYMASTER Get Support Entry Point", () => {
test("Get Support Entry Point", async () => {
let client = EthPaymasterClient.development(devAddres)
const authResponse = await client.auth("string");
const token = authResponse.token
console.log("token : " + token)
const response = await client.getSupportEntryPointV1(Network.Ethereum, authResponse.token)
console.log("response :" + JSON.stringify(response))
})
})
describe("PAYMASTER Get Support Strategy", () => {
test("Get Support Strategy", async () => {
let client = EthPaymasterClient.development(devAddres)
const authResponse = await client.auth("string");
const token = authResponse.token
console.log("token : " + token)
const response = await client.getSupportStrategyV1(Network.Ethereum, authResponse.token)
console.log("response :" + JSON.stringify(response))
})
// }
// const response = await client.tryPayUserOperationV1(authResponse.token, request)
// console.log("response :" + JSON.stringify(response))
// })
// })

})
// describe("PAYMASTER Get Support Entry Point", () => {
// test("Get Support Entry Point", async () => {
// let client = EthPaymasterClient.development(devAddres)
// const authResponse = await client.auth("string");
// const token = authResponse.token
// console.log("token : " + token)
// const response = await client.getSupportEntryPointV1(Network.Ethereum, authResponse.token)
// console.log("response :" + JSON.stringify(response))
// })
// })
// describe("PAYMASTER Get Support Strategy", () => {
// test("Get Support Strategy", async () => {
// let client = EthPaymasterClient.development(devAddres)
// const authResponse = await client.auth("string");
// const token = authResponse.token
// console.log("token : " + token)
// const response = await client.getSupportStrategyV1(Network.Ethereum, authResponse.token)
// console.log("response :" + JSON.stringify(response))
// })

// })



26 changes: 13 additions & 13 deletions __test__/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {describe, test} from "@jest/globals";
import {Path} from "../src/common/path";
import {utils} from "ethers";
import {generateUrl} from "../src/common/PaymasterUtil";
import {ENV} from "../src/common/type";
import {DefaultProdHost} from "../src/ethPaymasterClient";
// import {describe, test} from "@jest/globals";
// import {Path} from "../src/common/path";
// import {utils} from "ethers";
// import {generateUrl} from "../src/common/PaymasterUtil";
// import {ENV} from "../src/common/type";
// import {DefaultProdHost} from "../src/ethPaymasterClient";

describe("UTIL", () => {
test("generateUrl", () => {
const health = Path.Health
let str = generateUrl(DefaultProdHost, Path.Health)
console.log(str)
})
// describe("UTIL", () => {
// test("generateUrl", () => {
// const health = Path.Health
// let str = generateUrl(DefaultProdHost, Path.Health)
// console.log(str)
// })

})
// })

11 changes: 5 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
6 changes: 6 additions & 0 deletions dist/__test__/hello.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface Person {
firstName: string;
lastName: string;
}
export declare function greeter(person: Person): string;
export {};
Empty file.
Empty file added dist/__test__/util.test.d.ts
Empty file.
1 change: 1 addition & 0 deletions dist/index.cjs.js

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

1 change: 1 addition & 0 deletions dist/index.esm.js

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

21 changes: 21 additions & 0 deletions dist/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { HealthRes, AuthRes, EntryPointRes, StrategyRes, UserOp, TryPayUserOpRes } from '@/types/response';
/**
* Change the base url to the production or development url
*
* @param isProdUrl is production url
*/
export declare function init(isProdUrl?: boolean): void;
/**
*
* @returns server is health or not
*/
export declare const health: () => Promise<HealthRes | any>;
/**
*
* @param apiKey
* @returns
*/
export declare const auth: (apiKey: string) => Promise<AuthRes | any>;
export declare const getSupportEntryPointV1: (network?: string) => Promise<EntryPointRes | any>;
export declare const getSupportStrategyV1: (network?: string) => Promise<StrategyRes | any>;
export declare const tryPayUserOperationV1: (userOp: UserOp) => Promise<TryPayUserOpRes | any>;
86 changes: 86 additions & 0 deletions dist/src/types/response.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
interface BaseRes {
code: number;
message: string;
cost: string;
}
export interface HealthRes extends BaseRes {
data: {
environment: string;
hello: string;
time: string;
version: string;
};
}
export interface AuthRes {
code: number;
expire: string;
token: string;
}
export interface EntryPoint {
address: string;
desc: string;
network: string;
strategy_id: string;
}
export interface EntryPointRes extends BaseRes {
data: EntryPoint[];
}
interface ExecuteRestriction {
ban_sender_address: string;
effective_start_time: number;
effective_end_time: number;
global_max_usd: number;
global_max_op_count: number;
}
interface Strategy {
description: string;
enable_4844: boolean;
enable_7560: boolean;
enable_currency: boolean;
enable_eoa: boolean;
enable_erc20: boolean;
entrypoint_address: string;
entrypoint_tag: string;
execute_restriction: ExecuteRestriction[];
id: string;
network: string;
pay_type: string;
paymaster_address: string;
token: string;
}
export interface StrategyRes extends BaseRes {
data: Strategy[];
}
export interface TryPayUserOpRes extends BaseRes {
data: {
strategy_id: string;
entrypoint_address: string;
paymaster_address: string;
paymaster_signature: string;
paymaster_and_data: string;
pay_receipt: {
transaction_hash: string;
sponsor: string;
};
gas_info: {
gas_info: {
max_base_price_wei: number;
max_base_price_gwei: number;
max_base_price_ether: string;
max_priority_price_wei: number;
max_priority_price_gwei: number;
max_priority_price_ether: string;
};
token_cost: string;
network: string;
token: string;
usd_cost: number;
blob_enable: boolean;
max_fee: number;
};
};
}
export interface UserOp {
sender: string;
}
export {};
4 changes: 4 additions & 0 deletions dist/src/utils/path.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare const Path: {
[key: string]: string;
};
export default Path;
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

Loading

0 comments on commit db597bd

Please sign in to comment.