@0xsequence/account 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -210,6 +210,7 @@ class Account {
210
210
  this.tracker = options.tracker;
211
211
  this.networks = options.networks;
212
212
  this.orchestrator = options.orchestrator;
213
+ this.jwt = options.jwt;
213
214
  this.migrations = options.migrations || migration.defaults.DefaultMigrations;
214
215
  this.migrator = new migration.migrator.Migrator(options.tracker, this.migrations, this.contexts);
215
216
  }
@@ -260,7 +261,7 @@ class Account {
260
261
  providerFor(chainId) {
261
262
  const found = this.network(chainId);
262
263
  if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
263
- return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getDefaultConnectionInfo(found.rpcUrl), {
264
+ return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getEthersConnectionInfo(found.rpcUrl, undefined, this.jwt), {
264
265
  name: '',
265
266
  chainId: ethers.ethers.BigNumber.from(chainId).toNumber()
266
267
  });
@@ -276,11 +277,16 @@ class Account {
276
277
  const found = this.network(chainId);
277
278
  if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
278
279
  if (relayer.isRelayer(found.relayer)) return found.relayer;
279
- return new relayer.RpcRelayer(found.relayer);
280
+ return new relayer.RpcRelayer(_extends({}, found.relayer, {
281
+ jwtAuth: this.jwt
282
+ }));
280
283
  }
281
284
  setOrchestrator(orchestrator) {
282
285
  this.orchestrator = orchestrator;
283
286
  }
287
+ setJwt(jwt) {
288
+ this.jwt = jwt;
289
+ }
284
290
  contextFor(version) {
285
291
  const ctx = this.contexts[version];
286
292
  if (!ctx) throw new Error(`Context not found for version ${version}`);
@@ -210,6 +210,7 @@ class Account {
210
210
  this.tracker = options.tracker;
211
211
  this.networks = options.networks;
212
212
  this.orchestrator = options.orchestrator;
213
+ this.jwt = options.jwt;
213
214
  this.migrations = options.migrations || migration.defaults.DefaultMigrations;
214
215
  this.migrator = new migration.migrator.Migrator(options.tracker, this.migrations, this.contexts);
215
216
  }
@@ -260,7 +261,7 @@ class Account {
260
261
  providerFor(chainId) {
261
262
  const found = this.network(chainId);
262
263
  if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
263
- return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getDefaultConnectionInfo(found.rpcUrl), {
264
+ return found.provider || new ethers.ethers.providers.StaticJsonRpcProvider(utils.getEthersConnectionInfo(found.rpcUrl, undefined, this.jwt), {
264
265
  name: '',
265
266
  chainId: ethers.ethers.BigNumber.from(chainId).toNumber()
266
267
  });
@@ -276,11 +277,16 @@ class Account {
276
277
  const found = this.network(chainId);
277
278
  if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
278
279
  if (relayer.isRelayer(found.relayer)) return found.relayer;
279
- return new relayer.RpcRelayer(found.relayer);
280
+ return new relayer.RpcRelayer(_extends({}, found.relayer, {
281
+ jwtAuth: this.jwt
282
+ }));
280
283
  }
281
284
  setOrchestrator(orchestrator) {
282
285
  this.orchestrator = orchestrator;
283
286
  }
287
+ setJwt(jwt) {
288
+ this.jwt = jwt;
289
+ }
284
290
  contextFor(version) {
285
291
  const ctx = this.contexts[version];
286
292
  if (!ctx) throw new Error(`Context not found for version ${version}`);
@@ -1,7 +1,7 @@
1
1
  import { commons, universal } from '@0xsequence/core';
2
2
  import { defaults, migrator, version } from '@0xsequence/migration';
3
3
  import { proto, isRelayer, RpcRelayer } from '@0xsequence/relayer';
4
- import { getDefaultConnectionInfo, encodeTypedDataDigest } from '@0xsequence/utils';
4
+ import { getEthersConnectionInfo, encodeTypedDataDigest } from '@0xsequence/utils';
5
5
  import { Wallet } from '@0xsequence/wallet';
6
6
  import { ethers } from 'ethers';
7
7
 
@@ -206,6 +206,7 @@ class Account {
206
206
  this.tracker = options.tracker;
207
207
  this.networks = options.networks;
208
208
  this.orchestrator = options.orchestrator;
209
+ this.jwt = options.jwt;
209
210
  this.migrations = options.migrations || defaults.DefaultMigrations;
210
211
  this.migrator = new migrator.Migrator(options.tracker, this.migrations, this.contexts);
211
212
  }
@@ -256,7 +257,7 @@ class Account {
256
257
  providerFor(chainId) {
257
258
  const found = this.network(chainId);
258
259
  if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`);
259
- return found.provider || new ethers.providers.StaticJsonRpcProvider(getDefaultConnectionInfo(found.rpcUrl), {
260
+ return found.provider || new ethers.providers.StaticJsonRpcProvider(getEthersConnectionInfo(found.rpcUrl, undefined, this.jwt), {
260
261
  name: '',
261
262
  chainId: ethers.BigNumber.from(chainId).toNumber()
262
263
  });
@@ -272,11 +273,16 @@ class Account {
272
273
  const found = this.network(chainId);
273
274
  if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`);
274
275
  if (isRelayer(found.relayer)) return found.relayer;
275
- return new RpcRelayer(found.relayer);
276
+ return new RpcRelayer(_extends({}, found.relayer, {
277
+ jwtAuth: this.jwt
278
+ }));
276
279
  }
277
280
  setOrchestrator(orchestrator) {
278
281
  this.orchestrator = orchestrator;
279
282
  }
283
+ setJwt(jwt) {
284
+ this.jwt = jwt;
285
+ }
280
286
  contextFor(version) {
281
287
  const ctx = this.contexts[version];
282
288
  if (!ctx) throw new Error(`Context not found for version ${version}`);
@@ -35,6 +35,7 @@ export type AccountOptions = {
35
35
  migrations?: migrator.Migrations;
36
36
  orchestrator: Orchestrator;
37
37
  networks: NetworkConfig[];
38
+ jwt?: string;
38
39
  };
39
40
  export interface PreparedTransactions {
40
41
  transactions: commons.transaction.SimulatedTransaction[];
@@ -50,6 +51,7 @@ export declare class Account {
50
51
  readonly migrator: migrator.Migrator;
51
52
  readonly migrations: migrator.Migrations;
52
53
  private orchestrator;
54
+ private jwt?;
53
55
  constructor(options: AccountOptions);
54
56
  getSigner(chainId: ChainId, options?: AccountSignerOptions): AccountSigner;
55
57
  static new(options: {
@@ -71,6 +73,7 @@ export declare class Account {
71
73
  reader(chainId: ethers.BigNumberish): commons.reader.Reader;
72
74
  relayer(chainId: ethers.BigNumberish): Relayer;
73
75
  setOrchestrator(orchestrator: Orchestrator): void;
76
+ setJwt(jwt: string): void;
74
77
  contextFor(version: number): commons.context.WalletContext;
75
78
  walletForStatus(chainId: ethers.BigNumberish, status: Pick<AccountStatus, 'version'> & Pick<AccountStatus, 'config'>): Wallet;
76
79
  walletFor(chainId: ethers.BigNumberish, context: commons.context.WalletContext, config: commons.config.Config, coders: typeof this.coders): Wallet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/account",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "tools for migrating sequence wallets to new versions",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account",
6
6
  "source": "src/index.ts",
@@ -10,19 +10,19 @@
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "ethers": "^5.5.2",
13
- "@0xsequence/core": "1.3.0",
14
- "@0xsequence/migration": "1.3.0",
15
- "@0xsequence/network": "1.3.0",
16
- "@0xsequence/relayer": "1.3.0",
17
- "@0xsequence/utils": "1.3.0",
18
- "@0xsequence/sessions": "1.3.0",
19
- "@0xsequence/wallet": "1.3.0"
13
+ "@0xsequence/core": "1.4.0",
14
+ "@0xsequence/migration": "1.4.0",
15
+ "@0xsequence/network": "1.4.0",
16
+ "@0xsequence/relayer": "1.4.0",
17
+ "@0xsequence/sessions": "1.4.0",
18
+ "@0xsequence/utils": "1.4.0",
19
+ "@0xsequence/wallet": "1.4.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
23
23
  "nyc": "^15.1.0",
24
- "@0xsequence/signhub": "1.3.0",
25
- "@0xsequence/tests": "1.3.0"
24
+ "@0xsequence/signhub": "1.4.0",
25
+ "@0xsequence/tests": "1.4.0"
26
26
  },
27
27
  "files": [
28
28
  "src",
package/src/account.ts CHANGED
@@ -5,7 +5,7 @@ import { ChainId, NetworkConfig } from '@0xsequence/network'
5
5
  import { FeeOption, FeeQuote, isRelayer, Relayer, RpcRelayer } from '@0xsequence/relayer'
6
6
  import { tracker } from '@0xsequence/sessions'
7
7
  import { Orchestrator } from '@0xsequence/signhub'
8
- import { encodeTypedDataDigest, getDefaultConnectionInfo } from '@0xsequence/utils'
8
+ import { encodeTypedDataDigest, getEthersConnectionInfo } from '@0xsequence/utils'
9
9
  import { Wallet } from '@0xsequence/wallet'
10
10
  import { ethers, TypedDataDomain, TypedDataField } from 'ethers'
11
11
  import { AccountSigner, AccountSignerOptions } from './signer'
@@ -53,6 +53,9 @@ export type AccountOptions = {
53
53
 
54
54
  // Networks information and providers
55
55
  networks: NetworkConfig[]
56
+
57
+ // Jwt
58
+ jwt?: string
56
59
  }
57
60
 
58
61
  export interface PreparedTransactions {
@@ -96,6 +99,8 @@ export class Account {
96
99
 
97
100
  private orchestrator: Orchestrator
98
101
 
102
+ private jwt?: string
103
+
99
104
  constructor(options: AccountOptions) {
100
105
  this.address = ethers.utils.getAddress(options.address)
101
106
 
@@ -103,6 +108,7 @@ export class Account {
103
108
  this.tracker = options.tracker
104
109
  this.networks = options.networks
105
110
  this.orchestrator = options.orchestrator
111
+ this.jwt = options.jwt
106
112
 
107
113
  this.migrations = options.migrations || defaults.DefaultMigrations
108
114
  this.migrator = new migrator.Migrator(options.tracker, this.migrations, this.contexts)
@@ -174,7 +180,7 @@ export class Account {
174
180
  if (!found.provider && !found.rpcUrl) throw new Error(`Provider not found for chainId ${chainId}`)
175
181
  return (
176
182
  found.provider ||
177
- new ethers.providers.StaticJsonRpcProvider(getDefaultConnectionInfo(found.rpcUrl), {
183
+ new ethers.providers.StaticJsonRpcProvider(getEthersConnectionInfo(found.rpcUrl, undefined, this.jwt), {
178
184
  name: '',
179
185
  chainId: ethers.BigNumber.from(chainId).toNumber()
180
186
  })
@@ -193,13 +199,17 @@ export class Account {
193
199
  const found = this.network(chainId)
194
200
  if (!found.relayer) throw new Error(`Relayer not found for chainId ${chainId}`)
195
201
  if (isRelayer(found.relayer)) return found.relayer
196
- return new RpcRelayer(found.relayer)
202
+ return new RpcRelayer({ ...found.relayer, jwtAuth: this.jwt })
197
203
  }
198
204
 
199
205
  setOrchestrator(orchestrator: Orchestrator) {
200
206
  this.orchestrator = orchestrator
201
207
  }
202
208
 
209
+ setJwt(jwt: string) {
210
+ this.jwt = jwt
211
+ }
212
+
203
213
  contextFor(version: number): commons.context.WalletContext {
204
214
  const ctx = this.contexts[version]
205
215
  if (!ctx) throw new Error(`Context not found for version ${version}`)