Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/npm_and_yarn-b901f…
Browse files Browse the repository at this point in the history
…867dd
  • Loading branch information
Lomet authored Dec 31, 2024
2 parents 76fb795 + 2f42b27 commit b67027d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poolzfinance/reacthelper",
"version": "2.1.8",
"version": "2.1.12",
"description": "",
"type": "module",
"source": "src/index.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/configs/Avalanche.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ export const AvalancheChainConfig: TChainConfig = {
simpleRefundBuilder: {
address: "0xff1f0872f5462b30acdA92a08D2388612F7Bf7EE",
nameVersion: "[email protected]"
},
multiSenderV2: {
address: "0x1E947Ec4F6B74c746F13604438cE1A3026f30553",
nameVersion: "[email protected]"
}
}
4 changes: 4 additions & 0 deletions src/contracts/configs/BinanceTest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,9 @@ export const BinanceTestChainConfig: TChainConfig = {
tokenNFTConnector: {
address: "0x99dfade11d9cd4c2b192efda205c50d982cd76a1",
nameVersion: "[email protected]"
},
dispenserProvider: {
address: "0xeff8a476a62Ba2Ff1C8a202BEC40b45B7b822EC1",
nameVersion: "[email protected]"
}
}
8 changes: 4 additions & 4 deletions src/hooks/useTheSiwe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ interface ISiwe {
IssuedAt: string
ExpirationAt: string
}
type TProps = () => Partial<ISiwe>
type TProps = () => Promise<Partial<ISiwe>>

export const useTheSiwe = (props: TProps) => {
const thePoolz = useThePoolz()
const { web3, account } = thePoolz

const templateEip4361message = useCallback(() => {
const { Domain, URI, Statement, Version, ChainId, Nonce, IssuedAt, ExpirationAt } = props()
const templateEip4361message = useCallback(async () => {
const { Domain, URI, Statement, Version, ChainId, Nonce, IssuedAt, ExpirationAt } = await props()
const { host: domain, href: uri } = window.location
return `${Domain ?? domain} wants you to sign in with your Ethereum account:
${account}
Expand All @@ -36,7 +36,7 @@ Expiration Time: ${ExpirationAt ?? new Date(new Date().getTime() + 1000 * 60 * 6
return useMemo(() => {
const signInWithEthereum = async () => {
if (!web3.currentProvider || !account) throw new Error("No web3 provider or account")
const eip4361message = templateEip4361message()
const eip4361message = await templateEip4361message()
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const signature = (await web3.currentProvider.request({
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTheSiwe } from "./hooks/useTheSiwe"
import { useSidNameForAddress } from "./hooks/useSid"

export { ThePoolzProvider, useThePoolz, useConnectWallet, useSidNameForAddress, useTheSiwe }
export type { IThePoolzInterface, IERC20Info } from "./types/IThePoolzInterface"
export type { IThePoolzInterface, IERC20Info, IChainConfig, TChainConfig } from "./types/IThePoolzInterface"
export * from "./utils"
export * from "./constants"
export type { Contract } from "web3-eth-contract"
18 changes: 17 additions & 1 deletion src/poolz/ThePoolz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ThePoolz implements EnforceInterface<IThePoolzInterface, ThePoolz> {
public delayVaultProviderContract: IThePoolzInterface["delayVaultProviderContract"]
public delayVaultMigratorContract: IThePoolzInterface["delayVaultMigratorContract"]
public tokenNFTConnectorContract: IThePoolzInterface["tokenNFTConnectorContract"]
public dispenserProviderContract: IThePoolzInterface["dispenserProviderContract"]

#provider: typeof Web3.givenProvider
#contracts = new Map<string, Contract>()
Expand Down Expand Up @@ -108,7 +109,8 @@ class ThePoolz implements EnforceInterface<IThePoolzInterface, ThePoolz> {
multiSenderV2,
delayVaultProvider,
delayVaultMigrator,
tokenNFTConnector
tokenNFTConnector,
dispenserProvider
} = chainConfig

this.poolzTokenAddress = poolzTokenAddress
Expand Down Expand Up @@ -344,6 +346,20 @@ class ThePoolz implements EnforceInterface<IThePoolzInterface, ThePoolz> {
})
)
}
if (dispenserProvider) {
abifetchPromises.push(
this.fetchContractAbi(dispenserProvider.nameVersion)
.then((abi) => {
this.dispenserProviderContract = {
...dispenserProvider,
contract: new this.web3.eth.Contract(abi as AbiItem[], dispenserProvider.address)
}
})
.catch((e) => {
console.error(e)
})
)
}

try {
await Promise.allSettled(abifetchPromises)
Expand Down
4 changes: 4 additions & 0 deletions src/types/IThePoolzInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type AcceptableContractNames =
| "DelayVaultMigrator"
| "TokenNFTConnector"
| "MultiSenderV2"
| "DispenserProvider"

export type VersionNumber = `${number}.${number}.${number}`

Expand Down Expand Up @@ -97,6 +98,7 @@ export interface IThePoolzInterface {
delayVaultProviderContract?: IContractInfo
delayVaultMigratorContract?: IContractInfo
tokenNFTConnectorContract?: IContractInfo
dispenserProviderContract?: IContractInfo

init(): Promise<void>
getChaincoinInfo(k?: number): Promise<IChainInfo | undefined>
Expand Down Expand Up @@ -148,6 +150,8 @@ export interface IChainConfig {
delayVaultProvider: Omit<NonNullable<IThePoolzInterface["delayVaultProviderContract"]>, "contract">
delayVaultMigrator: Omit<NonNullable<IThePoolzInterface["delayVaultMigratorContract"]>, "contract">
tokenNFTConnector: Omit<NonNullable<IThePoolzInterface["tokenNFTConnectorContract"]>, "contract">

dispenserProvider: Omit<NonNullable<IThePoolzInterface["dispenserProviderContract"]>, "contract">
}

// copy chain data from https://chainid.network/chains.json
Expand Down

0 comments on commit b67027d

Please sign in to comment.