diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index e9c02f08d..1752ed1e3 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -3,7 +3,7 @@ import { migrator, defaults, version } from '@0xsequence/migration' import { ChainId, NetworkConfig } from '@0xsequence/network' import { FeeOption, FeeQuote, isRelayer, Relayer, RpcRelayer } from '@0xsequence/relayer' import { tracker } from '@0xsequence/sessions' -import { Orchestrator } from '@0xsequence/signhub' +import { SignatureOrchestrator } from '@0xsequence/signhub' import { encodeTypedDataDigest, getDefaultConnectionInfo } from '@0xsequence/utils' import { Wallet } from '@0xsequence/wallet' import { ethers, TypedDataDomain, TypedDataField } from 'ethers' @@ -48,7 +48,7 @@ export type AccountOptions = { migrations?: migrator.Migrations // Orchestrator manages signing messages and transactions - orchestrator: Orchestrator + orchestrator: SignatureOrchestrator // Networks information and providers networks: NetworkConfig[] @@ -93,7 +93,7 @@ export class Account { public readonly migrator: migrator.Migrator public readonly migrations: migrator.Migrations - private orchestrator: Orchestrator + private orchestrator: SignatureOrchestrator constructor(options: AccountOptions) { this.address = ethers.utils.getAddress(options.address) @@ -115,7 +115,7 @@ export class Account { config: commons.config.SimpleConfig tracker: tracker.ConfigTracker & migrator.PresignedMigrationTracker contexts: commons.context.VersionedContext - orchestrator: Orchestrator + orchestrator: SignatureOrchestrator networks: NetworkConfig[] migrations?: migrator.Migrations }): Promise { @@ -195,7 +195,7 @@ export class Account { return new RpcRelayer(found.relayer) } - setOrchestrator(orchestrator: Orchestrator) { + setOrchestrator(orchestrator: SignatureOrchestrator) { this.orchestrator = orchestrator } diff --git a/packages/auth/src/session.ts b/packages/auth/src/session.ts index 151a90375..fba557d50 100644 --- a/packages/auth/src/session.ts +++ b/packages/auth/src/session.ts @@ -3,7 +3,7 @@ import { jwtDecodeClaims } from '@0xsequence/utils' import { Account } from '@0xsequence/account' import { ethers } from 'ethers' import { tracker, trackers } from '@0xsequence/sessions' -import { Orchestrator } from '@0xsequence/signhub' +import { Orchestrator, SignatureOrchestrator } from '@0xsequence/signhub' import { migrator } from '@0xsequence/migration' import { commons, universal, v1 } from '@0xsequence/core' import { Services, ServicesSettings, SessionJWT, SessionMeta } from './services' @@ -137,7 +137,7 @@ export class Session { static async open(args: { settings?: Partial - orchestrator: Orchestrator + orchestrator: SignatureOrchestrator addSigners?: commons.config.SimpleSigner[] referenceSigner: string threshold?: ethers.BigNumberish @@ -286,7 +286,7 @@ export class Session { static async load(args: { settings?: Partial - orchestrator: Orchestrator + orchestrator: SignatureOrchestrator dump: SessionDumpV1 | SessionDumpV2 editConfigOnMigration: (config: commons.config.Config) => commons.config.Config onMigration?: (account: Account) => Promise diff --git a/packages/auth/tests/session.spec.ts b/packages/auth/tests/session.spec.ts index ea17cae83..480920d8a 100644 --- a/packages/auth/tests/session.spec.ts +++ b/packages/auth/tests/session.spec.ts @@ -5,7 +5,7 @@ import { migrator } from '@0xsequence/migration' import { NetworkConfig } from '@0xsequence/network' import { LocalRelayer } from '@0xsequence/relayer' import { tracker, trackers } from '@0xsequence/sessions' -import { Orchestrator } from '@0xsequence/signhub' +import { Orchestrator, SignatureOrchestrator } from '@0xsequence/signhub' import * as utils from '@0xsequence/tests' import { CallReceiverMock, HookCallerMock } from '@0xsequence/wallet-contracts' import * as chai from 'chai' @@ -70,7 +70,7 @@ describe('Wallet integration', function () { let networks: NetworkConfig[] let tracker: tracker.ConfigTracker & migrator.PresignedMigrationTracker - let orchestrator: Orchestrator + let orchestrator: SignatureOrchestrator let simpleSettings: SessionSettings before(async () => { diff --git a/packages/signhub/src/orchestrator.ts b/packages/signhub/src/orchestrator.ts index e6c6b55ec..a08883d49 100644 --- a/packages/signhub/src/orchestrator.ts +++ b/packages/signhub/src/orchestrator.ts @@ -38,6 +38,17 @@ export function isSignerStatusPending(status: SignerStatus): status is SignerSta export const InitialSituation = 'Initial' +export interface SignatureOrchestrator { + getSigners(): Promise + + signMessage(args: { + candidates: string[] + message: ethers.BytesLike + metadata: Object + callback: (status: Status, onNewMetadata: (metadata: Object) => void) => boolean + }): Promise +} + /** * It orchestrates the signing of a single digest by multiple signers. * It can provide internal visibility of the signing process, and it also diff --git a/packages/wallet/src/wallet.ts b/packages/wallet/src/wallet.ts index b1030b491..2541577c1 100644 --- a/packages/wallet/src/wallet.ts +++ b/packages/wallet/src/wallet.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { commons, v1, v2 } from '@0xsequence/core' -import { isSignerStatusSigned, Orchestrator, Status } from '@0xsequence/signhub' +import { isSignerStatusSigned, SignatureOrchestrator, Status } from '@0xsequence/signhub' import { Deferrable, subDigestOf } from '@0xsequence/utils' import { FeeQuote, Relayer, SimulateResult } from '@0xsequence/relayer' import { walletContracts } from '@0xsequence/abi' @@ -24,7 +24,7 @@ export type WalletOptions< chainId: ethers.BigNumberish address: string - orchestrator: Orchestrator + orchestrator: SignatureOrchestrator reader?: commons.reader.Reader provider?: ethers.providers.Provider @@ -78,7 +78,7 @@ export class Wallet< config: commons.config.ConfigCoder } - private orchestrator: Orchestrator + private orchestrator: SignatureOrchestrator private _reader?: commons.reader.Reader constructor(options: WalletOptions) { @@ -119,7 +119,7 @@ export class Wallet< this.config = config } - setOrchestrator(orchestrator: Orchestrator) { + setOrchestrator(orchestrator: SignatureOrchestrator) { this.orchestrator = orchestrator } diff --git a/packages/wallet/tests/wallet.spec.ts b/packages/wallet/tests/wallet.spec.ts index 8ece59bcd..381cbe4f9 100644 --- a/packages/wallet/tests/wallet.spec.ts +++ b/packages/wallet/tests/wallet.spec.ts @@ -5,7 +5,7 @@ import { commons, v1, v2 } from '@0xsequence/core' import { context } from '@0xsequence/tests' import { ethers } from 'ethers' import { SequenceOrchestratorWrapper, Wallet } from '../src/index' -import { Orchestrator, signers as hubsigners } from '@0xsequence/signhub' +import { Orchestrator, SignatureOrchestrator, signers as hubsigners } from '@0xsequence/signhub' import { LocalRelayer } from '@0xsequence/relayer' const { expect } = chai @@ -192,7 +192,7 @@ describe('Wallet (primitive)', () => { } ].map(({ name, signers }) => { describe(`Using ${name}`, () => { - let orchestrator: Orchestrator + let orchestrator: SignatureOrchestrator let config: commons.config.Config beforeEach(async () => {