Skip to content

Commit

Permalink
include DeployedWalletContexts as part of the library, and use as def…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
pkieltyka committed Jul 13, 2023
1 parent 9494443 commit b0d43fd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/v1/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { WalletContext } from '../commons/context'

export * as config from './config'
export * as signature from './signature'

export const version = 1

export const DeployedWalletContext: WalletContext = {
version: version,
factory: '0xf9D09D634Fb818b05149329C1dcCFAeA53639d96',
guestModule: '0x02390F3E6E5FD1C6786CB78FD3027C117a9955A7',
mainModule: '0xd01F11855bCcb95f88D7A48492F66410d4637313',
mainModuleUpgradable: '0x7EFE6cE415956c5f80C6530cC6cc81b4808F6118',
walletCreationCode: '',
}
10 changes: 10 additions & 0 deletions packages/core/src/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WalletContext } from '../commons/context'

export * as config from "./config"
export * as signature from "./signature"
Expand All @@ -13,3 +14,12 @@ export const coders = {
}

export const version = 2

export const DeployedWalletContext: WalletContext = {
version: version,
factory: '0xFaA5c0b14d1bED5C888Ca655B9a8A5911F78eF4A',
guestModule: '0xfea230Ee243f88BC698dD8f1aE93F8301B6cdfaE',
mainModule: '0xfBf8f1A5E00034762D928f46d438B947f5d4065d',
mainModuleUpgradable: '0x4222dcA3974E39A8b41c411FeDDE9b09Ae14b911',
walletCreationCode: '',
}
17 changes: 10 additions & 7 deletions packages/provider/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers, BytesLike } from 'ethers'
import { Web3Provider } from './provider'
import { messageIsExemptFromEIP191Prefix } from './eip191exceptions'
import { AccountStatus } from '@0xsequence/account'
import { commons } from '@0xsequence/core'
import { commons, allVersions } from '@0xsequence/core'
import { encodeMessageDigest, TypedData, encodeTypedDataDigest } from '@0xsequence/utils'

const eip191prefix = ethers.utils.toUtf8Bytes('\x19Ethereum Signed Message:\n')
Expand Down Expand Up @@ -69,9 +69,10 @@ export const isValidSignature = async (
digest: Uint8Array,
sig: string,
provider: Web3Provider | ethers.providers.Web3Provider,
contexts: { [key: number]: commons.context.WalletContext }
contexts?: { [key: number]: commons.context.WalletContext }
): Promise<boolean> => {
const reader = new commons.reader.OnChainReader(provider, contexts)
const deployedContexts = allVersions.map(v => v.DeployedWalletContext)
const reader = new commons.reader.OnChainReader(provider, contexts || deployedContexts)
return reader.isValidSignature(address, digest, sig)
}

Expand All @@ -81,11 +82,12 @@ export const isValidMessageSignature = async (
message: string | Uint8Array,
signature: string,
provider: Web3Provider | ethers.providers.Web3Provider,
contexts: { [key: number]: commons.context.WalletContext }
contexts?: { [key: number]: commons.context.WalletContext }
): Promise<boolean> => {
const deployedContexts = allVersions.map(v => v.DeployedWalletContext)
const prefixed = prefixEIP191Message(message)
const digest = encodeMessageDigest(prefixed)
return isValidSignature(address, digest, signature, provider, contexts)
return isValidSignature(address, digest, signature, provider, contexts || deployedContexts)
}

// Verify typedData signature
Expand All @@ -94,9 +96,10 @@ export const isValidTypedDataSignature = (
typedData: TypedData,
signature: string,
provider: Web3Provider | ethers.providers.Web3Provider,
contexts: { [key: number]: commons.context.WalletContext }
contexts?: { [key: number]: commons.context.WalletContext }
): Promise<boolean> => {
return isValidSignature(address, encodeTypedDataDigest(typedData), signature, provider, contexts)
const deployedContexts = allVersions.map(v => v.DeployedWalletContext)
return isValidSignature(address, encodeTypedDataDigest(typedData), signature, provider, contexts || deployedContexts)
}

// export const recoverWalletConfig = async (
Expand Down
2 changes: 0 additions & 2 deletions packages/tests/src/context/v1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ethers } from "ethers"
import { v1 } from '../builds'
import { deployContract } from "../singletonFactory"
import { isContract } from "../utils"

// These are the Sequence v1 contracts
Expand Down

0 comments on commit b0d43fd

Please sign in to comment.