diff --git a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts index 696e18397..060dfe53f 100644 --- a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts @@ -21,7 +21,7 @@ export type SubscribeUnsubscribeOptions = { export type UserSetting = { enabled: boolean; - value?: number; + value?: number | {lower: number, upper: number}; }; export type AliasOptions = Omit<GetAliasInfoOptionsType, 'env'>; @@ -100,7 +100,7 @@ export type CreateChannelOptions = { export type NotificationSetting = { type: number; - default: number; + default: number | { upper: number; lower: number }; description: string; data?: { upper: number; diff --git a/packages/restapi/src/lib/pushNotification/pushNotificationBase.ts b/packages/restapi/src/lib/pushNotification/pushNotificationBase.ts index 2bbfc8557..6a1e91417 100644 --- a/packages/restapi/src/lib/pushNotification/pushNotificationBase.ts +++ b/packages/restapi/src/lib/pushNotification/pushNotificationBase.ts @@ -36,6 +36,7 @@ const LENGTH_UPPER_LIMIT = 125; const LENGTH_LOWER_LIMTI = 1; const SETTING_DELIMITER = '-'; const SETTING_SEPARATOR = '+'; +const RANGE_TYPE = 3; const SLIDER_TYPE = 2; const BOOLEAN_TYPE = 1; const DEFAULT_ENABLE_VALUE = '1'; @@ -160,7 +161,7 @@ export class PushNotificationBaseClass { // fetch the minimal version based on conifg that was passed let index = ''; if (options.payload?.category && settings) { - if (settings[options.payload.category - 1].type == 2) { + if (settings[options.payload.category - 1].type == SLIDER_TYPE) { index = options.payload.category + SETTING_DELIMITER + @@ -168,9 +169,17 @@ export class PushNotificationBaseClass { SETTING_DELIMITER + settings[options.payload.category - 1].default; } - if (settings[options.payload.category - 1].type == 1) { + if (settings[options.payload.category - 1].type == BOOLEAN_TYPE) { index = options.payload.category + SETTING_DELIMITER + BOOLEAN_TYPE; } + if (settings[options.payload.category - 1].type == RANGE_TYPE) { + index = + options.payload.category + + SETTING_DELIMITER + + RANGE_TYPE + + SETTING_DELIMITER + + settings[options.payload.category - 1].default.lower; + } } const notificationPayload: ISendNotificationInputOptions = { signer: signer, @@ -715,6 +724,31 @@ export class PushNotificationBaseClass { ele.description; } } + if (ele.type == RANGE_TYPE) { + if (ele.default && typeof ele.default == 'object' && ele.data) { + const enabled = + ele.data && ele.data.enabled != undefined + ? Number(ele.data.enabled).toString() + : DEFAULT_ENABLE_VALUE; + const ticker = ele.data.ticker ?? DEFAULT_TICKER_VALUE; + notificationSetting = + notificationSetting + + SETTING_SEPARATOR + + RANGE_TYPE + + SETTING_DELIMITER + + enabled + + SETTING_DELIMITER + + ele.default.lower + + SETTING_DELIMITER + + ele.default.upper + + SETTING_DELIMITER + + ele.data.lower + + SETTING_DELIMITER + + ele.data.upper + + SETTING_DELIMITER + + ticker; + } + } } return { setting: notificationSetting.replace(/^\+/, ''), diff --git a/packages/restapi/src/lib/pushapi/PushAPI.ts b/packages/restapi/src/lib/pushapi/PushAPI.ts index c70dfcd43..5411089a9 100644 --- a/packages/restapi/src/lib/pushapi/PushAPI.ts +++ b/packages/restapi/src/lib/pushapi/PushAPI.ts @@ -1,6 +1,6 @@ import Constants, { ENV } from '../constants'; import { SignerType, ProgressHookType } from '../types'; -import { PushAPIInitializeProps } from './pushAPITypes'; +import { InfoOptions, PushAPIInitializeProps } from './pushAPITypes'; import * as PUSH_USER from '../user'; import * as PUSH_CHAT from '../chat'; import { getAccountAddress, getWallet } from '../chat/helpers'; @@ -240,9 +240,10 @@ export class PushAPI { return this.stream; } - async info() { + async info(options?: InfoOptions) { + const accountToUse = options?.overrideAccount || this.account; return await PUSH_USER.get({ - account: this.account, + account: accountToUse, env: this.env, }); } diff --git a/packages/restapi/src/lib/pushapi/chat.ts b/packages/restapi/src/lib/pushapi/chat.ts index 3d0b821de..0f650708f 100644 --- a/packages/restapi/src/lib/pushapi/chat.ts +++ b/packages/restapi/src/lib/pushapi/chat.ts @@ -61,10 +61,13 @@ export class Chat { */ page?: number; limit?: number; + overrideAccount?: string; } ): Promise<IFeeds[]> { + const accountToUse = options?.overrideAccount || this.account; + const listParams = { - account: this.account, + account: accountToUse, pgpPrivateKey: this.decryptedPgpPvtKey, page: options?.page, limit: options?.limit, @@ -188,7 +191,7 @@ export class Chat { } async block(users: Array<string>): Promise<IUser> { - if (!this.signer) { + if (!this.signer || !this.decryptedPgpPvtKey) { throw new Error(PushAPI.ensureSignerMessage()); } const user = await PUSH_USER.get({ diff --git a/packages/restapi/src/lib/pushapi/profile.ts b/packages/restapi/src/lib/pushapi/profile.ts index efe602841..156947e1e 100644 --- a/packages/restapi/src/lib/pushapi/profile.ts +++ b/packages/restapi/src/lib/pushapi/profile.ts @@ -2,6 +2,7 @@ import { ProgressHookType } from '../types'; import * as PUSH_USER from '../user'; import { ENV } from '../constants'; import { PushAPI } from './PushAPI'; +import { InfoOptions } from './pushAPITypes'; export class Profile { constructor( @@ -11,18 +12,19 @@ export class Profile { private progressHook?: (progress: ProgressHookType) => void ) {} - async info() { + async info(options?: InfoOptions) { + const accountToUse = options?.overrideAccount || this.account; const response = await PUSH_USER.get({ - account: this.account, + account: accountToUse, env: this.env, }); return response.profile; } async update(options: { name?: string; desc?: string; picture?: string }) { - if (!this.decryptedPgpPvtKey) { - throw new Error(PushAPI.ensureSignerMessage()); - } + if (!this.decryptedPgpPvtKey) { + throw new Error(PushAPI.ensureSignerMessage()); + } const { name, desc, picture } = options; const response = await PUSH_USER.profile.update({ pgpPrivateKey: this.decryptedPgpPvtKey, diff --git a/packages/restapi/src/lib/pushapi/pushAPITypes.ts b/packages/restapi/src/lib/pushapi/pushAPITypes.ts index 280873f57..b17cf8fbc 100644 --- a/packages/restapi/src/lib/pushapi/pushAPITypes.ts +++ b/packages/restapi/src/lib/pushapi/pushAPITypes.ts @@ -52,3 +52,8 @@ export interface GroupUpdateOptions { meta?: string | null; rules?: Rules | null; } + +export interface InfoOptions { + overrideAccount?: string; +} + diff --git a/packages/restapi/src/lib/pushapi/user.ts b/packages/restapi/src/lib/pushapi/user.ts index 4a485e787..c640c2fd3 100644 --- a/packages/restapi/src/lib/pushapi/user.ts +++ b/packages/restapi/src/lib/pushapi/user.ts @@ -1,12 +1,14 @@ import * as PUSH_USER from '../user'; import { ENV } from '../constants'; +import { InfoOptions } from './pushAPITypes'; export class User { constructor(private account: string, private env: ENV) {} - async info() { + async info(options?: InfoOptions) { + const accountToUse = options?.overrideAccount || this.account; return await PUSH_USER.get({ - account: this.account, + account: accountToUse, env: this.env, }); } diff --git a/packages/restapi/tests/lib/notification/base.test.ts b/packages/restapi/tests/lib/notification/base.test.ts new file mode 100644 index 000000000..041b9ff2b --- /dev/null +++ b/packages/restapi/tests/lib/notification/base.test.ts @@ -0,0 +1,256 @@ +import * as path from 'path'; +import * as dotenv from 'dotenv'; +dotenv.config({ path: path.resolve(__dirname, '../../../.env') }); +import { expect } from 'chai'; +import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; +import { PushNotificationBaseClass } from '../../../src/lib/pushNotification/pushNotificationBase'; +import * as config from '../../../src/lib/config'; +import { + createWalletClient, + http, + getContract, + createPublicClient, +} from 'viem'; +import { abi } from './tokenABI'; +import { goerli, polygonMumbai } from 'viem/chains'; +import { BigNumber, ethers } from 'ethers'; + +enum ENV { + PROD = 'prod', + STAGING = 'staging', + DEV = 'dev', + /** + * **This is for local development only** + */ + LOCAL = 'local', +} +describe.only('test', () => { + const signer = createWalletClient({ + account: privateKeyToAccount(`0x${process.env['WALLET_PRIVATE_KEY']}`), + chain: goerli, + transport: http('https://goerli.blockpi.network/v1/rpc/public'), + }); + + const signer3 = createWalletClient({ + account: privateKeyToAccount(`0x${process.env['WALLET_PRIVATE_KEY']}`), + chain: polygonMumbai, + transport: http(), + }); + + const provider = new ethers.providers.JsonRpcProvider( + 'https://goerli.blockpi.network/v1/rpc/public' + ); + const signer2 = new ethers.Wallet( + `0x${process.env['WALLET_PRIVATE_KEY']}`, + provider + ); + + // it.only('Test minimal conversion', async () => { + // const account2 = await signer2.getAddress(); + // const viemUser = new PushNotificationBaseClass( + // signer, + // ENV.STAGING, + // account2 + // ); + // viemUser.getMinimalUserSetting([ + // { enabled: true }, + // { enabled: false, value: 10 }, + // { enabled: false }, + // { enabled: true, value: 10 }, + // ]); + // }); + // it('testing with viem', async () => { + // const account2 = await signer2.getAddress(); + // const viemUser = new PushNotificationBaseClass(signer, ENV.STAGING, account2) + // const contract = viemUser.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) + // const res = await viemUser.fetchUpdateCounter(contract, account2); + // console.log(res) + // const viemContract = await userViem.createContractInstance( + // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', + // abi, + // goerli + // ); + // const balance = await userViem.fetchBalance( + // viemContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681' + // ); + // console.log(balance); + // const allowance = await userViem.fetchAllownace( + // viemContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681', + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' + // ); + // console.log(allowance); + // const approveAmount = ethers.BigNumber.from(10000); + // const approveRes = await userViem.approveToken( + // viemContract, + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', + // approveAmount + // ); + // console.log(approveRes); + + // const addDelegate = await userViem.delegate.add( + // 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681' + // ); + // console.log(addDelegate); + // }); + + // it.only('test with ethers', async () => { + // const account2 = await signer2.getAddress(); + // const userEthers = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); + // const contract = userEthers.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) + // const res = await userEthers.fetchUpdateCounter(contract, account2); + // console.log(res) + // const ethersContract = await userEthers.createContractInstance( + // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', + // abi, + // goerli + // ); + // const balance2 = await userEthers.fetchBalance( + // ethersContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681' + // ); + // console.log(balance2); + // const allowance2 = await userEthers.fetchAllownace( + // ethersContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681', + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' + // ); + // console.log(allowance2); + // const approveAmount2 = ethers.BigNumber.from(10000); + // const approveRes2 = await userEthers.approveToken( + // ethersContract, + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', + // approveAmount2 + // ); + // console.log(approveRes2); + // }); + // it('Should get proper minnimal payload', async() => { + // const inputData = [ + // { + // type: 1, + // default: 1, + // description: 'test1', + // }, + // { + // type: 2, + // default: 10, + // description: 'test2', + // data: { + // upper: 100, + // lower: 1, + // }, + // }, + // { + // type: 3, + // default: { + // lower: 10, + // upper: 50 + // }, + // description: 'test3', + // data: { + // upper: 100, + // lower: 1, + // enabled:true, + // ticker:2 + // } + // } + // ]; + // const account2 = await signer2.getAddress(); + // const userAlice = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); + // const minimalSettings = userAlice.getMinimalSetting(inputData); + // // console.log(minimalSettings); + // expect(minimalSettings).not.null + // }); + + // it('Should get proper minnimal payload', async() => { + // const inputData = [ + // { + // type: 1, + // default: 10, + // description: 'test2', + // data: { + // upper: 100, + // lower: 1, + // enabled: false + // }, + // }, + // { + // type: 0, + // default: 1, + // description: 'test1', + // }, + // ]; + // const account2 = await signer2.getAddress(); + // const userAlice = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); + // const minimalSettings = userAlice.getMinimalSetting(inputData); + // // console.log(minimalSettings); + // expect(minimalSettings).not.null + // }); + // it('testing with viem', async () => { + // const account2 = await signer2.getAddress(); + // const viemUser = new PushNotificationBaseClass(signer, ENV.STAGING, account2) + // const contract = viemUser.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) + // const res = await viemUser.fetchUpdateCounter(contract, account2); + // console.log(res) + // const viemContract = await userViem.createContractInstance( + // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', + // abi, + // goerli + // ); + // const balance = await userViem.fetchBalance( + // viemContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681' + // ); + // console.log(balance); + // const allowance = await userViem.fetchAllownace( + // viemContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681', + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' + // ); + // console.log(allowance); + // const approveAmount = ethers.BigNumber.from(10000); + // const approveRes = await userViem.approveToken( + // viemContract, + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', + // approveAmount + // ); + // console.log(approveRes); + + // const addDelegate = await userViem.delegate.add( + // 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681' + // ); + // console.log(addDelegate); + // }); + + // it.only('test with ethers', async () => { + // const account2 = await signer2.getAddress(); + // const userEthers = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); + // const contract = userEthers.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) + // const res = await userEthers.fetchUpdateCounter(contract, account2); + // console.log(res) + // const ethersContract = await userEthers.createContractInstance( + // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', + // abi, + // goerli + // ); + // const balance2 = await userEthers.fetchBalance( + // ethersContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681' + // ); + // console.log(balance2); + // const allowance2 = await userEthers.fetchAllownace( + // ethersContract, + // '0xD8634C39BBFd4033c0d3289C4515275102423681', + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' + // ); + // console.log(allowance2); + // const approveAmount2 = ethers.BigNumber.from(10000); + // const approveRes2 = await userEthers.approveToken( + // ethersContract, + // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', + // approveAmount2 + // ); + // console.log(approveRes2); + // }); +}); diff --git a/packages/restapi/tests/lib/notification/channel.test.ts b/packages/restapi/tests/lib/notification/channel.test.ts index c325d99e8..0f12730c3 100644 --- a/packages/restapi/tests/lib/notification/channel.test.ts +++ b/packages/restapi/tests/lib/notification/channel.test.ts @@ -224,6 +224,29 @@ describe('PushAPI.channel functionality', () => { expect(res.status).to.equal(204); }); + it('With signer : subset : Should send notification with title and body along with additional options', async () => { + const res = await userAlice.channel.send( + [ + 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681', + 'eip155:11155111:0x93A829d16DE51745Db0530A0F8E8A9B8CA5370E5', + ], + { + notification: { + title: 'hi', + body: 'test-targeted', + }, + payload: { + title: 'testing first notification', + body: 'testing with random body', + cta: 'https://google.com/', + embed: 'https://avatars.githubusercontent.com/u/64157541?s=200&v=4', + category: 3, + }, + } + ); + expect(res.status).to.equal(204); + }); + it('With signer : subset : Should send notification with title and body along with additional options', async () => { const res = await userAlice.channel.send( [ diff --git a/packages/restapi/tests/lib/notification/onchain.test.ts b/packages/restapi/tests/lib/notification/onchain.test.ts index dd30958a7..e69de29bb 100644 --- a/packages/restapi/tests/lib/notification/onchain.test.ts +++ b/packages/restapi/tests/lib/notification/onchain.test.ts @@ -1,251 +0,0 @@ -// import * as path from 'path'; -// import * as dotenv from 'dotenv'; -// dotenv.config({ path: path.resolve(__dirname, '../../../.env') }); -// import { expect } from 'chai'; -// import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'; -// import { PushNotificationBaseClass } from '../../../src/lib/pushNotification/pushNotificationBase'; -// import * as config from '../../../src/lib/config'; -// import { -// createWalletClient, -// http, -// getContract, -// createPublicClient, -// } from 'viem'; -// import { abi } from './tokenABI'; -// import { goerli, polygonMumbai } from 'viem/chains'; -// import { BigNumber, ethers } from 'ethers'; - -// enum ENV { -// PROD = 'prod', -// STAGING = 'staging', -// DEV = 'dev', -// /** -// * **This is for local development only** -// */ -// LOCAL = 'local', -// } -// describe.only('test', () => { -// const signer = createWalletClient({ -// account: privateKeyToAccount(`0x${process.env['WALLET_PRIVATE_KEY']}`), -// chain: goerli, -// transport: http('https://goerli.blockpi.network/v1/rpc/public'), -// }); - -// const signer3 = createWalletClient({ -// account: privateKeyToAccount(`0x${process.env['WALLET_PRIVATE_KEY']}`), -// chain: polygonMumbai, -// transport: http(), -// }); - -// const provider = new ethers.providers.JsonRpcProvider( -// 'https://goerli.blockpi.network/v1/rpc/public' -// ); -// const signer2 = new ethers.Wallet( -// `0x${process.env['WALLET_PRIVATE_KEY']}`, -// provider -// ); - - // it.only('Test minimal conversion', async () => { - // const account2 = await signer2.getAddress(); - // const viemUser = new PushNotificationBaseClass( - // signer, - // ENV.STAGING, - // account2 - // ); - // viemUser.getMinimalUserSetting([ - // { enabled: true }, - // { enabled: false, value: 10 }, - // { enabled: false }, - // { enabled: true, value: 10 }, - // ]); - // }); - // it('testing with viem', async () => { - // const account2 = await signer2.getAddress(); - // const viemUser = new PushNotificationBaseClass(signer, ENV.STAGING, account2) - // const contract = viemUser.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) - // const res = await viemUser.fetchUpdateCounter(contract, account2); - // console.log(res) - // const viemContract = await userViem.createContractInstance( - // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', - // abi, - // goerli - // ); - // const balance = await userViem.fetchBalance( - // viemContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681' - // ); - // console.log(balance); - // const allowance = await userViem.fetchAllownace( - // viemContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681', - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' - // ); - // console.log(allowance); - // const approveAmount = ethers.BigNumber.from(10000); - // const approveRes = await userViem.approveToken( - // viemContract, - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', - // approveAmount - // ); - // console.log(approveRes); - - // const addDelegate = await userViem.delegate.add( - // 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681' - // ); - // console.log(addDelegate); - // }); - - // it.only('test with ethers', async () => { - // const account2 = await signer2.getAddress(); - // const userEthers = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); - // const contract = userEthers.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) - // const res = await userEthers.fetchUpdateCounter(contract, account2); - // console.log(res) - // const ethersContract = await userEthers.createContractInstance( - // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', - // abi, - // goerli - // ); - // const balance2 = await userEthers.fetchBalance( - // ethersContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681' - // ); - // console.log(balance2); - // const allowance2 = await userEthers.fetchAllownace( - // ethersContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681', - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' - // ); - // console.log(allowance2); - // const approveAmount2 = ethers.BigNumber.from(10000); - // const approveRes2 = await userEthers.approveToken( - // ethersContract, - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', - // approveAmount2 - // ); - // console.log(approveRes2); - // }); - // it.only('Should get proper minnimal payload', async() => { - // const inputData = [ - // { - // type: 1, - // default: 1, - // description: 'test1', - // }, - // { - // type: 2, - // default: 10, - // description: 'test2', - // data: { - // upper: 100, - // lower: 1, - // }, - // }, - // ]; - // const account2 = await signer2.getAddress(); - // const userAlice = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); - // const minimalSettings = userAlice.getMinimalSetting(inputData); - // console.log(minimalSettings); - // }); - - // it.only('Should get proper minnimal payload', async() => { - // const inputData = [ - // { - // type: 1, - // default: 10, - // description: 'test2', - // data: { - // upper: 100, - // lower: 1, - // enabled: false - // }, - // }, - // { - // type: 0, - // default: 1, - // description: 'test1', - // }, - // ]; - // const account2 = await signer2.getAddress(); - // const userAlice = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); - // const minimalSettings = userAlice.getMinimalSetting(inputData); - // console.log(minimalSettings); - // }); - // it('testing with viem', async () => { - // const account2 = await signer2.getAddress(); - // const viemUser = new PushNotificationBaseClass(signer, ENV.STAGING, account2) - // const contract = viemUser.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) - // const res = await viemUser.fetchUpdateCounter(contract, account2); - // console.log(res) - // const viemContract = await userViem.createContractInstance( - // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', - // abi, - // goerli - // ); - // const balance = await userViem.fetchBalance( - // viemContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681' - // ); - // console.log(balance); - // const allowance = await userViem.fetchAllownace( - // viemContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681', - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' - // ); - // console.log(allowance); - // const approveAmount = ethers.BigNumber.from(10000); - // const approveRes = await userViem.approveToken( - // viemContract, - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', - // approveAmount - // ); - // console.log(approveRes); - - // const addDelegate = await userViem.delegate.add( - // 'eip155:5:0xD8634C39BBFd4033c0d3289C4515275102423681' - // ); - // console.log(addDelegate); - // }); - - // it.only('test with ethers', async () => { - // const account2 = await signer2.getAddress(); - // const userEthers = new PushNotificationBaseClass(signer2, ENV.STAGING, account2,); - // const contract = userEthers.createContractInstance("0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C", config.ABIS.CORE, goerli) - // const res = await userEthers.fetchUpdateCounter(contract, account2); - // console.log(res) - // const ethersContract = await userEthers.createContractInstance( - // '0x2b9bE9259a4F5Ba6344c1b1c07911539642a2D33', - // abi, - // goerli - // ); - // const balance2 = await userEthers.fetchBalance( - // ethersContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681' - // ); - // console.log(balance2); - // const allowance2 = await userEthers.fetchAllownace( - // ethersContract, - // '0xD8634C39BBFd4033c0d3289C4515275102423681', - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C' - // ); - // console.log(allowance2); - // const approveAmount2 = ethers.BigNumber.from(10000); - // const approveRes2 = await userEthers.approveToken( - // ethersContract, - // '0xd4E3ceC407cD36d9e3767cD189ccCaFBF549202C', - // approveAmount2 - // ); - // console.log(approveRes2); - // }); - // it.only('Test for channel info', async() => { - // const account2 = await signer2.getAddress(); - // const userEthers = new PushNotificationBaseClass( - // signer2, - // ENV.STAGING, - // account2 - // ); - - // const res = await userEthers.getChannelOrAliasInfo("eip155:80001:0xC8c243a4fd7F34c49901fe441958953402b7C024") - // console.log(res) - // }); -// });