From e18bf2f963ec1a211ce0a18e2b18f7f2e5e3c8b7 Mon Sep 17 00:00:00 2001 From: Barry <67917837+BarryTong98@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:33:38 +1030 Subject: [PATCH] fix: network (#8) Co-authored-by: BarryTong65 --- dist/tsc/paymasterclient.js | 4 ++-- dist/tsc/paymasterclient.js.map | 2 +- dist/tsc/sponsorclient.js | 2 +- dist/tsc/sponsorclient.js.map | 2 +- src/paymasterclient.ts | 4 ++-- src/sponsorclient.ts | 2 +- tests/env.ts | 2 +- tests/utils.ts | 6 +++--- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/tsc/paymasterclient.js b/dist/tsc/paymasterclient.js index 97dfb61..c78bea6 100644 --- a/dist/tsc/paymasterclient.js +++ b/dist/tsc/paymasterclient.js @@ -18,11 +18,11 @@ class PaymasterClient extends ethers_1.ethers.JsonRpcProvider { } // Static method to create a new standard PaymasterClient static new(url, network, options) { - return new PaymasterClient(url, network, options); + return new PaymasterClient(url, network, { batchMaxCount: 1 }); } // Static method to create a new PaymasterClient with private policy static newPrivatePaymaster(url, privatePolicyUUID, network, options) { - return new PaymasterClient(url, network, options, privatePolicyUUID); + return new PaymasterClient(url, network, { batchMaxCount: 1 }, privatePolicyUUID); } chainID() { return tslib_1.__awaiter(this, void 0, void 0, function* () { diff --git a/dist/tsc/paymasterclient.js.map b/dist/tsc/paymasterclient.js.map index 007fb81..99256a6 100644 --- a/dist/tsc/paymasterclient.js.map +++ b/dist/tsc/paymasterclient.js.map @@ -1 +1 @@ -{"version":3,"file":"paymasterclient.js","sourceRoot":"","sources":["../../src/paymasterclient.ts"],"names":[],"mappings":";;;;AAAA,mCAAsG;AAetG,IAAY,wBAAwF;AAApG,WAAY,wBAAwB;IAAG,qEAAO,CAAA;IAAE,6EAAW,CAAA;IAAE,iFAAa,CAAA;IAAE,2EAAU,CAAA;IAAE,6EAAW,CAAA;AAAA,CAAC,EAAxF,wBAAwB,GAAxB,gCAAwB,KAAx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,CAAC,eAAe,CACzC,aAAa,EACZ,IAAY,CAAC,QAAQ,EACtB;oBACE,aAAa,EAAG,IAAY,CAAC,QAAQ;oBACrC,aAAa,EAAG,IAAY,CAAC,aAAa;oBAC1C,OAAO,EAAG,IAAY,CAAC,OAAO;iBAC/B,CACF,CAAA;gBAED,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;aACjE;YACD,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC9D,CAAC;KAAA;IAEK,2BAA2B,CAAC,IAAY;;YAC5C,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,iCAAiC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;QACnE,CAAC;KAAA;IAEK,oBAAoB,CAAC,IAAY;;YACrC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;QAC3D,CAAC;KAAA;IAEK,wBAAwB,CAAC,UAAkB;;YAC/C,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;QACrE,CAAC;KAAA;IAEK,eAAe,CAAC,UAAkB;;YACtC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;QAC5D,CAAC;KAAA;CACF;AAjGD,0CAiGC"} \ No newline at end of file diff --git a/dist/tsc/sponsorclient.js b/dist/tsc/sponsorclient.js index a1848a9..b31798d 100644 --- a/dist/tsc/sponsorclient.js +++ b/dist/tsc/sponsorclient.js @@ -12,7 +12,7 @@ var WhitelistType; })(WhitelistType = exports.WhitelistType || (exports.WhitelistType = {})); class SponsorClient extends ethers_1.ethers.JsonRpcProvider { constructor(url, network, options) { - super(url, network, options); + super(url, network, { batchMaxCount: 1 }); } addToWhitelist(params) { return tslib_1.__awaiter(this, void 0, void 0, function* () { diff --git a/dist/tsc/sponsorclient.js.map b/dist/tsc/sponsorclient.js.map index 262fa00..cd8e730 100644 --- a/dist/tsc/sponsorclient.js.map +++ b/dist/tsc/sponsorclient.js.map @@ -1 +1 @@ -{"version":3,"file":"sponsorclient.js","sourceRoot":"","sources":["../../src/sponsorclient.ts"],"names":[],"mappings":";;;;AAAA,mCAAkF;AAIlF,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,8DAA6C,CAAA;IAC7C,0DAAyC,CAAA;IACzC,0EAAyD,CAAA;IACzD,kEAAiD,CAAA;AACnD,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB;AAmCD,MAAa,aAAc,SAAQ,eAAM,CAAC,eAAe;IACvD,YAAY,GAA2B,EAAE,OAAoB,EAAE,OAAmC;QAChG,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC;IAEK,cAAc,CAAC,MAAqB;;YACxC,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;QACjD,CAAC;KAAA;IAEK,mBAAmB,CAAC,MAAqB;;YAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;QAClD,CAAC;KAAA;IAEK,cAAc,CAAC,MAA0B;;YAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;QACjD,CAAC;KAAA;IAEK,YAAY,CAAC,MAAwB;;YACzC,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;QAC/C,CAAC;KAAA;IAEK,gBAAgB,CAAC,WAAwB,EAAE,UAAkB;;YACjE,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAA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AAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAA;QACpE,CAAC;KAAA;IAEK,kBAAkB,CAAC,UAAkB;;YACzC,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;QACzD,CAAC;KAAA;CACF;AA5BD,sCA4BC"} \ No newline at end of file diff --git a/src/paymasterclient.ts b/src/paymasterclient.ts index c095f97..472be1c 100644 --- a/src/paymasterclient.ts +++ b/src/paymasterclient.ts @@ -71,7 +71,7 @@ export class PaymasterClient extends ethers.JsonRpcProvider { network?: Networkish, options?: JsonRpcApiProviderOptions ): PaymasterClient { - return new PaymasterClient(url, network, options) + return new PaymasterClient(url, network, {batchMaxCount: 1}) } // Static method to create a new PaymasterClient with private policy @@ -81,7 +81,7 @@ export class PaymasterClient extends ethers.JsonRpcProvider { network?: Networkish, options?: JsonRpcApiProviderOptions ): PaymasterClient { - return new PaymasterClient(url, network, options, privatePolicyUUID) + return new PaymasterClient(url, network, {batchMaxCount: 1}, privatePolicyUUID) } async chainID(): Promise { diff --git a/src/sponsorclient.ts b/src/sponsorclient.ts index ebd64f1..9d6357a 100644 --- a/src/sponsorclient.ts +++ b/src/sponsorclient.ts @@ -44,7 +44,7 @@ export type PolicySpendData = { export class SponsorClient extends ethers.JsonRpcProvider { constructor(url?: string | FetchRequest, network?: Networkish, options?: JsonRpcApiProviderOptions) { - super(url, network, options) + super(url, network, {batchMaxCount: 1}) } async addToWhitelist(params: WhitelistArgs): Promise { diff --git a/tests/env.ts b/tests/env.ts index acb3036..f2628ce 100644 --- a/tests/env.ts +++ b/tests/env.ts @@ -6,7 +6,7 @@ dotenv.config({ // testnet env export const OPEN_PLATFORM_PRIVATE_KEY = process.env.OPEN_PLATFORM_PRIVATE_KEY -export const SPONSOR_URL = `https://open-platform-ap.nodereal.io/${OPEN_PLATFORM_PRIVATE_KEY}/megafuel-testnet` +export const SPONSOR_URL = `https://open-platform-ap.nodereal.io/${OPEN_PLATFORM_PRIVATE_KEY}/megafuel-testnet/97` export const CHAIN_ID = '97' export const CHAIN_URL = `https://bsc-testnet.nodereal.io/v1/${OPEN_PLATFORM_PRIVATE_KEY}` export const PAYMASTER_URL = 'https://bsc-megafuel-testnet.nodereal.io/97' diff --git a/tests/utils.ts b/tests/utils.ts index 4619567..08f3718 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -11,14 +11,14 @@ import {CHAIN_ID, SPONSOR_URL, CHAIN_URL, PAYMASTER_URL, PRIVATE_KEY, TOKEN_CONT import {ethers} from 'ethers' -export const sponsorClient = new SponsorClient(SPONSOR_URL+"/"+CHAIN_ID, undefined, {staticNetwork: ethers.Network.from(Number(CHAIN_ID))}) +export const sponsorClient = new SponsorClient(SPONSOR_URL) // Provider for assembling the transaction (e.g., testnet) export const assemblyProvider = new ethers.JsonRpcProvider(CHAIN_URL) // Provider for sending the transaction (e.g., could be a different network or provider) -export const paymasterClient = PaymasterClient.new(PAYMASTER_URL, undefined, {staticNetwork: ethers.Network.from(Number(CHAIN_ID))}) -export const privatePaymasterClient = PaymasterClient.newPrivatePaymaster(SPONSOR_URL+"/"+CHAIN_ID, PRIVATE_POLICY_UUID, undefined, {staticNetwork: ethers.Network.from(Number(CHAIN_ID))}) +export const paymasterClient = PaymasterClient.new(PAYMASTER_URL) +export const privatePaymasterClient = PaymasterClient.newPrivatePaymaster(SPONSOR_URL, PRIVATE_POLICY_UUID) export const wallet = new ethers.Wallet(PRIVATE_KEY, assemblyProvider) // ERC20 token ABI (only including the transfer function)