@0xsequence/provider 1.3.0 → 1.4.1

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.
@@ -2709,7 +2709,7 @@ class WalletRequestHandler {
2709
2709
  }
2710
2710
 
2711
2711
  // Build session response for connect details
2712
- connectDetails.session = await this.walletSession(chainId);
2712
+ connectDetails.session = this.walletSession(chainId);
2713
2713
  return connectDetails;
2714
2714
  }
2715
2715
  // sendMessageRequest will unwrap the ProviderMessageRequest and send it to the JsonRpcHandler
@@ -3533,7 +3533,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3533
3533
 
3534
3534
  var packageJson = {
3535
3535
  name: "@0xsequence/provider",
3536
- version: "1.3.0",
3536
+ version: "1.4.1",
3537
3537
  description: "provider sub-package for Sequence",
3538
3538
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3539
3539
  source: "src/index.ts",
@@ -3661,11 +3661,12 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3661
3661
  * and it allows to perform all sequence specific (or write) operations related to the wallet.
3662
3662
  *s
3663
3663
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3664
- */
3664
+ */ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3665
3665
  class SequenceClient {
3666
- constructor(transport, store, options) {
3666
+ constructor(transport, store, options, projectAccessKey) {
3667
3667
  var _options$defaultEIP;
3668
3668
  this.callbacks = {};
3669
+ this.projectAccessKey = projectAccessKey;
3669
3670
  if (isMuxTransportTemplate(transport)) {
3670
3671
  this.transport = MuxMessageProvider.new(transport);
3671
3672
  } else if (isProviderTransport(transport)) {
@@ -3810,6 +3811,7 @@ class SequenceClient {
3810
3811
  if ((options == null ? void 0 : options.refresh) === true) {
3811
3812
  this.disconnect();
3812
3813
  }
3814
+ options.projectAccessKey = this.projectAccessKey;
3813
3815
  if (options) {
3814
3816
  if (options.authorize) {
3815
3817
  if (!options.app) {
@@ -4005,6 +4007,10 @@ const DefaultProviderConfig = {
4005
4007
  let sequenceWalletProvider;
4006
4008
  const initWallet = partialConfig => {
4007
4009
  var _config$networks$filt, _config$networks, _findNetworkConfig;
4010
+ const projectAccessKey = partialConfig == null ? void 0 : partialConfig.projectAccessKey;
4011
+ if (!projectAccessKey) {
4012
+ console.warn('Please pass a projectAccessKey in initWallet config as it will be required in near future.');
4013
+ }
4008
4014
  if (sequenceWalletProvider) {
4009
4015
  return sequenceWalletProvider;
4010
4016
  }
@@ -4026,9 +4032,13 @@ const initWallet = partialConfig => {
4026
4032
  var _config$networks2;
4027
4033
  const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
4028
4034
  return network ? _extends({}, n, network) : n;
4029
- }).concat(newNetworks);
4035
+ }).concat(newNetworks).map(network => {
4036
+ const toAppend = projectAccessKey ? `/${projectAccessKey}` : '';
4037
+ network.rpcUrl = network.rpcUrl + toAppend;
4038
+ return network;
4039
+ });
4030
4040
 
4031
- // This build a "public rpc" on demand, we build them on demand because we don't want to
4041
+ // This builds a "public rpc" on demand, we build them on demand because we don't want to
4032
4042
  // generate a bunch of providers for networks that aren't used.
4033
4043
  const providerForChainId = chainId => {
4034
4044
  if (!rpcProviders[chainId]) {
@@ -4059,7 +4069,7 @@ const initWallet = partialConfig => {
4059
4069
  const client = new SequenceClient(config.transports, itemStore, {
4060
4070
  defaultChainId: defaultNetwork,
4061
4071
  defaultEIP6492: config.defaultEIP6492
4062
- });
4072
+ }, projectAccessKey);
4063
4073
  sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
4064
4074
  return sequenceWalletProvider;
4065
4075
  };
@@ -2709,7 +2709,7 @@ class WalletRequestHandler {
2709
2709
  }
2710
2710
 
2711
2711
  // Build session response for connect details
2712
- connectDetails.session = await this.walletSession(chainId);
2712
+ connectDetails.session = this.walletSession(chainId);
2713
2713
  return connectDetails;
2714
2714
  }
2715
2715
  // sendMessageRequest will unwrap the ProviderMessageRequest and send it to the JsonRpcHandler
@@ -3533,7 +3533,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3533
3533
 
3534
3534
  var packageJson = {
3535
3535
  name: "@0xsequence/provider",
3536
- version: "1.3.0",
3536
+ version: "1.4.1",
3537
3537
  description: "provider sub-package for Sequence",
3538
3538
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3539
3539
  source: "src/index.ts",
@@ -3661,11 +3661,12 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3661
3661
  * and it allows to perform all sequence specific (or write) operations related to the wallet.
3662
3662
  *s
3663
3663
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3664
- */
3664
+ */ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3665
3665
  class SequenceClient {
3666
- constructor(transport, store, options) {
3666
+ constructor(transport, store, options, projectAccessKey) {
3667
3667
  var _options$defaultEIP;
3668
3668
  this.callbacks = {};
3669
+ this.projectAccessKey = projectAccessKey;
3669
3670
  if (isMuxTransportTemplate(transport)) {
3670
3671
  this.transport = MuxMessageProvider.new(transport);
3671
3672
  } else if (isProviderTransport(transport)) {
@@ -3810,6 +3811,7 @@ class SequenceClient {
3810
3811
  if ((options == null ? void 0 : options.refresh) === true) {
3811
3812
  this.disconnect();
3812
3813
  }
3814
+ options.projectAccessKey = this.projectAccessKey;
3813
3815
  if (options) {
3814
3816
  if (options.authorize) {
3815
3817
  if (!options.app) {
@@ -4005,6 +4007,10 @@ const DefaultProviderConfig = {
4005
4007
  let sequenceWalletProvider;
4006
4008
  const initWallet = partialConfig => {
4007
4009
  var _config$networks$filt, _config$networks, _findNetworkConfig;
4010
+ const projectAccessKey = partialConfig == null ? void 0 : partialConfig.projectAccessKey;
4011
+ if (!projectAccessKey) {
4012
+ console.warn('Please pass a projectAccessKey in initWallet config as it will be required in near future.');
4013
+ }
4008
4014
  if (sequenceWalletProvider) {
4009
4015
  return sequenceWalletProvider;
4010
4016
  }
@@ -4026,9 +4032,13 @@ const initWallet = partialConfig => {
4026
4032
  var _config$networks2;
4027
4033
  const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
4028
4034
  return network ? _extends({}, n, network) : n;
4029
- }).concat(newNetworks);
4035
+ }).concat(newNetworks).map(network => {
4036
+ const toAppend = projectAccessKey ? `/${projectAccessKey}` : '';
4037
+ network.rpcUrl = network.rpcUrl + toAppend;
4038
+ return network;
4039
+ });
4030
4040
 
4031
- // This build a "public rpc" on demand, we build them on demand because we don't want to
4041
+ // This builds a "public rpc" on demand, we build them on demand because we don't want to
4032
4042
  // generate a bunch of providers for networks that aren't used.
4033
4043
  const providerForChainId = chainId => {
4034
4044
  if (!rpcProviders[chainId]) {
@@ -4059,7 +4069,7 @@ const initWallet = partialConfig => {
4059
4069
  const client = new SequenceClient(config.transports, itemStore, {
4060
4070
  defaultChainId: defaultNetwork,
4061
4071
  defaultEIP6492: config.defaultEIP6492
4062
- });
4072
+ }, projectAccessKey);
4063
4073
  sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
4064
4074
  return sequenceWalletProvider;
4065
4075
  };
@@ -2705,7 +2705,7 @@ class WalletRequestHandler {
2705
2705
  }
2706
2706
 
2707
2707
  // Build session response for connect details
2708
- connectDetails.session = await this.walletSession(chainId);
2708
+ connectDetails.session = this.walletSession(chainId);
2709
2709
  return connectDetails;
2710
2710
  }
2711
2711
  // sendMessageRequest will unwrap the ProviderMessageRequest and send it to the JsonRpcHandler
@@ -3529,7 +3529,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
3529
3529
 
3530
3530
  var packageJson = {
3531
3531
  name: "@0xsequence/provider",
3532
- version: "1.3.0",
3532
+ version: "1.4.1",
3533
3533
  description: "provider sub-package for Sequence",
3534
3534
  repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
3535
3535
  source: "src/index.ts",
@@ -3657,11 +3657,12 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
3657
3657
  * and it allows to perform all sequence specific (or write) operations related to the wallet.
3658
3658
  *s
3659
3659
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
3660
- */
3660
+ */ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
3661
3661
  class SequenceClient {
3662
- constructor(transport, store, options) {
3662
+ constructor(transport, store, options, projectAccessKey) {
3663
3663
  var _options$defaultEIP;
3664
3664
  this.callbacks = {};
3665
+ this.projectAccessKey = projectAccessKey;
3665
3666
  if (isMuxTransportTemplate(transport)) {
3666
3667
  this.transport = MuxMessageProvider.new(transport);
3667
3668
  } else if (isProviderTransport(transport)) {
@@ -3806,6 +3807,7 @@ class SequenceClient {
3806
3807
  if ((options == null ? void 0 : options.refresh) === true) {
3807
3808
  this.disconnect();
3808
3809
  }
3810
+ options.projectAccessKey = this.projectAccessKey;
3809
3811
  if (options) {
3810
3812
  if (options.authorize) {
3811
3813
  if (!options.app) {
@@ -4001,6 +4003,10 @@ const DefaultProviderConfig = {
4001
4003
  let sequenceWalletProvider;
4002
4004
  const initWallet = partialConfig => {
4003
4005
  var _config$networks$filt, _config$networks, _findNetworkConfig;
4006
+ const projectAccessKey = partialConfig == null ? void 0 : partialConfig.projectAccessKey;
4007
+ if (!projectAccessKey) {
4008
+ console.warn('Please pass a projectAccessKey in initWallet config as it will be required in near future.');
4009
+ }
4004
4010
  if (sequenceWalletProvider) {
4005
4011
  return sequenceWalletProvider;
4006
4012
  }
@@ -4022,9 +4028,13 @@ const initWallet = partialConfig => {
4022
4028
  var _config$networks2;
4023
4029
  const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
4024
4030
  return network ? _extends({}, n, network) : n;
4025
- }).concat(newNetworks);
4031
+ }).concat(newNetworks).map(network => {
4032
+ const toAppend = projectAccessKey ? `/${projectAccessKey}` : '';
4033
+ network.rpcUrl = network.rpcUrl + toAppend;
4034
+ return network;
4035
+ });
4026
4036
 
4027
- // This build a "public rpc" on demand, we build them on demand because we don't want to
4037
+ // This builds a "public rpc" on demand, we build them on demand because we don't want to
4028
4038
  // generate a bunch of providers for networks that aren't used.
4029
4039
  const providerForChainId = chainId => {
4030
4040
  if (!rpcProviders[chainId]) {
@@ -4055,7 +4065,7 @@ const initWallet = partialConfig => {
4055
4065
  const client = new SequenceClient(config.transports, itemStore, {
4056
4066
  defaultChainId: defaultNetwork,
4057
4067
  defaultEIP6492: config.defaultEIP6492
4058
- });
4068
+ }, projectAccessKey);
4059
4069
  sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
4060
4070
  return sequenceWalletProvider;
4061
4071
  };
@@ -44,12 +44,13 @@ export type SequenceClientOptions = {
44
44
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
45
45
  */
46
46
  export declare class SequenceClient {
47
+ projectAccessKey?: string | undefined;
47
48
  private readonly session;
48
49
  private readonly defaultChainId;
49
50
  private readonly callbacks;
50
51
  readonly transport: ProviderTransport;
51
52
  readonly defaultEIP6492: boolean;
52
- constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions | number);
53
+ constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions | number, projectAccessKey?: string | undefined);
53
54
  registerCallback<K extends keyof WalletEventTypes>(eventName: K, callback: WalletEventTypes[K]): () => void;
54
55
  onOpen(callback: WalletEventTypes['open']): () => void;
55
56
  onClose(callback: WalletEventTypes['close']): () => void;
@@ -3,6 +3,7 @@ import { MuxTransportTemplate } from "./transports/index.js";
3
3
  import { ItemStore } from "./utils.js";
4
4
  import { SequenceProvider } from "./provider.js";
5
5
  export interface ProviderConfig {
6
+ projectAccessKey?: string;
6
7
  localStorage?: ItemStore;
7
8
  defaultNetwork?: ChainIdLike;
8
9
  defaultEIP6492?: boolean;
@@ -111,6 +111,9 @@ export interface ConnectOptions {
111
111
  /** origin hint of the dapp's host opening the wallet. This value will automatically
112
112
  * be determined and verified for integrity, and can be omitted. */
113
113
  origin?: string;
114
+ /** access key for the project that can be obtained from Sequence Builder on sequence.build.
115
+ * This value will be automatically populated using the key passed in initWallet. */
116
+ projectAccessKey?: string;
114
117
  /** expiry number (in seconds) that is used for ETHAuth proof. Default is 1 week in seconds. */
115
118
  expiry?: number;
116
119
  /** authorize will perform an ETHAuth eip712 signing and return the proof to the dapp. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/provider",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "provider sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
6
6
  "source": "src/index.ts",
@@ -11,15 +11,15 @@
11
11
  "dependencies": {
12
12
  "eventemitter2": "^6.4.5",
13
13
  "webextension-polyfill": "^0.10.0",
14
- "@0xsequence/abi": "1.3.0",
15
- "@0xsequence/account": "1.3.0",
16
- "@0xsequence/core": "1.3.0",
17
- "@0xsequence/auth": "1.3.0",
18
- "@0xsequence/migration": "1.3.0",
19
- "@0xsequence/network": "1.3.0",
20
- "@0xsequence/relayer": "1.3.0",
21
- "@0xsequence/utils": "1.3.0",
22
- "@0xsequence/wallet": "1.3.0"
14
+ "@0xsequence/abi": "1.4.1",
15
+ "@0xsequence/account": "1.4.1",
16
+ "@0xsequence/auth": "1.4.1",
17
+ "@0xsequence/core": "1.4.1",
18
+ "@0xsequence/network": "1.4.1",
19
+ "@0xsequence/migration": "1.4.1",
20
+ "@0xsequence/relayer": "1.4.1",
21
+ "@0xsequence/utils": "1.4.1",
22
+ "@0xsequence/wallet": "1.4.1"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "ethers": ">=5.5 < 6"
package/src/client.ts CHANGED
@@ -125,6 +125,8 @@ export type SequenceClientOptions = {
125
125
  *s
126
126
  * It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
127
127
  */
128
+
129
+ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
128
130
  export class SequenceClient {
129
131
  private readonly session: SequenceClientSession
130
132
  private readonly defaultChainId: DefaultChainIdTracker
@@ -134,7 +136,12 @@ export class SequenceClient {
134
136
 
135
137
  public readonly defaultEIP6492: boolean
136
138
 
137
- constructor(transport: ProviderTransport | MuxTransportTemplate, store: ItemStore, options?: SequenceClientOptions | number) {
139
+ constructor(
140
+ transport: ProviderTransport | MuxTransportTemplate,
141
+ store: ItemStore,
142
+ options?: SequenceClientOptions | number,
143
+ public projectAccessKey?: string
144
+ ) {
138
145
  if (isMuxTransportTemplate(transport)) {
139
146
  this.transport = MuxMessageProvider.new(transport)
140
147
  } else if (isProviderTransport(transport)) {
@@ -302,6 +309,8 @@ export class SequenceClient {
302
309
  this.disconnect()
303
310
  }
304
311
 
312
+ options.projectAccessKey = this.projectAccessKey
313
+
305
314
  if (options) {
306
315
  if (options.authorize) {
307
316
  if (!options.app) {
package/src/init.ts CHANGED
@@ -16,6 +16,9 @@ import { SequenceClient } from './client'
16
16
  import { SequenceProvider } from './provider'
17
17
 
18
18
  export interface ProviderConfig {
19
+ // Access key for the project that can be obtained from Sequence Builder on sequence.build
20
+ projectAccessKey?: string
21
+
19
22
  // The local storage dependency for the wallet provider, defaults to window.localStorage.
20
23
  // For example, this option should be used when using React Native since window.localStorage is not available.
21
24
  localStorage?: ItemStore
@@ -55,6 +58,12 @@ export const DefaultProviderConfig = {
55
58
  let sequenceWalletProvider: SequenceProvider | undefined
56
59
 
57
60
  export const initWallet = (partialConfig?: Partial<ProviderConfig>) => {
61
+ const projectAccessKey = partialConfig?.projectAccessKey
62
+
63
+ if (!projectAccessKey) {
64
+ console.warn('Please pass a projectAccessKey in initWallet config as it will be required in near future.')
65
+ }
66
+
58
67
  if (sequenceWalletProvider) {
59
68
  return sequenceWalletProvider
60
69
  }
@@ -84,8 +93,13 @@ export const initWallet = (partialConfig?: Partial<ProviderConfig>) => {
84
93
  return network ? { ...n, ...network } : n
85
94
  })
86
95
  .concat(newNetworks)
96
+ .map(network => {
97
+ const toAppend = projectAccessKey ? `/${projectAccessKey}` : ''
98
+ network.rpcUrl = network.rpcUrl + toAppend
99
+ return network
100
+ })
87
101
 
88
- // This build a "public rpc" on demand, we build them on demand because we don't want to
102
+ // This builds a "public rpc" on demand, we build them on demand because we don't want to
89
103
  // generate a bunch of providers for networks that aren't used.
90
104
  const providerForChainId = (chainId: number) => {
91
105
  if (!rpcProviders[chainId]) {
@@ -118,10 +132,15 @@ export const initWallet = (partialConfig?: Partial<ProviderConfig>) => {
118
132
  const itemStore = config.localStorage || useBestStore()
119
133
 
120
134
  // Create client, provider and return signer
121
- const client = new SequenceClient(config.transports, itemStore, {
122
- defaultChainId: defaultNetwork,
123
- defaultEIP6492: config.defaultEIP6492
124
- })
135
+ const client = new SequenceClient(
136
+ config.transports,
137
+ itemStore,
138
+ {
139
+ defaultChainId: defaultNetwork,
140
+ defaultEIP6492: config.defaultEIP6492
141
+ },
142
+ projectAccessKey
143
+ )
125
144
 
126
145
  sequenceWalletProvider = new SequenceProvider(client, providerForChainId)
127
146
  return sequenceWalletProvider
@@ -138,6 +157,5 @@ export const getWallet = () => {
138
157
  if (!sequenceWalletProvider) {
139
158
  throw new Error('Wallet has not been initialized, call sequence.initWallet(config) first.')
140
159
  }
141
-
142
160
  return sequenceWalletProvider
143
161
  }
@@ -180,7 +180,7 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
180
180
  }
181
181
 
182
182
  // Build session response for connect details
183
- connectDetails.session = await this.walletSession(chainId)
183
+ connectDetails.session = this.walletSession(chainId)
184
184
 
185
185
  return connectDetails
186
186
  }
package/src/types.ts CHANGED
@@ -165,6 +165,10 @@ export interface ConnectOptions {
165
165
  * be determined and verified for integrity, and can be omitted. */
166
166
  origin?: string
167
167
 
168
+ /** access key for the project that can be obtained from Sequence Builder on sequence.build.
169
+ * This value will be automatically populated using the key passed in initWallet. */
170
+ projectAccessKey?: string
171
+
168
172
  /** expiry number (in seconds) that is used for ETHAuth proof. Default is 1 week in seconds. */
169
173
  expiry?: number
170
174