-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from AAStarCommunity/v0.01-rc0
V0.01 rc0
- Loading branch information
Showing
30 changed files
with
14,297 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish Package to npmjs | ||
|
||
on: | ||
push: | ||
branches-ignore: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm install | ||
- run: npm publish --access public --tag alpha | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,19 @@ | ||
name: Publish Package to npmjs | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,3 @@ | ||
{ | ||
"Codegeex.Chat.LanguagePreference": "English" | ||
} |
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 |
---|---|---|
@@ -1,2 +1,35 @@ | ||
# EthPaymaster_sdk_ts | ||
EthPaymaster typescript Sdk | ||
|
||
```tsx | ||
let client = EthPaymasterClient.development(address) | ||
|
||
const healthResponse = await client.health() | ||
|
||
const authResponse = await client.auth("API-KEY") | ||
|
||
const token = authResponse.token | ||
|
||
const strategyResponse = await client.getSupportStrategyV1(Network.Ethereum, authResponse.token) | ||
|
||
const entrypointResponse = await client.getSupportEntryPointV1(Network.Ethereum, authResponse.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 tryPayResponse = await client.tryPayUserOperationV1(authResponse.token, request) | ||
``` |
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,19 @@ | ||
interface Person { | ||
firstName: string; | ||
lastName: string; | ||
|
||
} | ||
class Student implements Person{ | ||
fullName: string; | ||
constructor(public firstName: string, public middleInitial: string, public lastName: string) { | ||
|
||
|
||
this.fullName = firstName + " " + middleInitial + " " + lastName; | ||
} | ||
} | ||
|
||
export function greeter(person: Person) { | ||
return "Hello, " + person.firstName + " " + person.lastName; | ||
} | ||
|
||
let user = { firstName: "Jane", lastName: "User" }; |
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,72 @@ | ||
// 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 () => { | ||
// 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 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)) | ||
// }) | ||
|
||
// }) | ||
|
||
|
||
|
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,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"; | ||
|
||
// describe("UTIL", () => { | ||
// test("generateUrl", () => { | ||
// const health = Path.Health | ||
// let str = generateUrl(DefaultProdHost, Path.Health) | ||
// console.log(str) | ||
// }) | ||
|
||
// }) | ||
|
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,6 @@ | ||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', { targets: { node: 'current' } }], | ||
'@babel/preset-typescript', | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HealthRes, AuthRes, EntryPointRes, StrategyRes, UserOpReq, 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: (data: UserOpReq) => Promise<TryPayUserOpRes | any>; |
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,99 @@ | ||
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 UserOpReq { | ||
forceStrategyId: string; | ||
userOperation: { | ||
callData: string; | ||
callGasLimit: string; | ||
initCode: string; | ||
maxFeePerGas: string; | ||
maxPriorityFeePerGas: string; | ||
nonce: string; | ||
preVerificationGas: string; | ||
sender: string; | ||
signature: string; | ||
verificationGasLimit: string; | ||
paymasterAndData: string; | ||
}; | ||
} | ||
export {}; |
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,4 @@ | ||
declare const Path: { | ||
[key: string]: string; | ||
}; | ||
export default Path; |
Oops, something went wrong.