@0xsequence/provider 1.2.9 → 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.
- package/dist/0xsequence-provider.cjs.dev.js +19 -8
- package/dist/0xsequence-provider.cjs.prod.js +19 -8
- package/dist/0xsequence-provider.esm.js +19 -8
- package/dist/declarations/src/client.d.ts +2 -1
- package/dist/declarations/src/init.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +3 -0
- package/package.json +10 -10
- package/src/client.ts +10 -1
- package/src/init.ts +24 -6
- package/src/transports/wallet-request-handler.ts +2 -2
- package/src/types.ts +4 -0
|
@@ -2341,9 +2341,10 @@ class WalletRequestHandler {
|
|
|
2341
2341
|
validateTransactionRequest(account.address, transactionParams);
|
|
2342
2342
|
let txnHash = '';
|
|
2343
2343
|
if (_this.prompter === null) {
|
|
2344
|
+
var _txnResponse$hash;
|
|
2344
2345
|
// prompter is null, so we'll send from here
|
|
2345
2346
|
const txnResponse = await account.sendTransaction(transactionParams, chainId != null ? chainId : _this.defaultChainId());
|
|
2346
|
-
txnHash = txnResponse.hash;
|
|
2347
|
+
txnHash = (_txnResponse$hash = txnResponse == null ? void 0 : txnResponse.hash) != null ? _txnResponse$hash : '';
|
|
2347
2348
|
} else {
|
|
2348
2349
|
// prompt user to provide the response
|
|
2349
2350
|
txnHash = await _this.prompter.promptSendTransaction(transactionParams, chainId, _this.connectOptions);
|
|
@@ -2708,7 +2709,7 @@ class WalletRequestHandler {
|
|
|
2708
2709
|
}
|
|
2709
2710
|
|
|
2710
2711
|
// Build session response for connect details
|
|
2711
|
-
connectDetails.session =
|
|
2712
|
+
connectDetails.session = this.walletSession(chainId);
|
|
2712
2713
|
return connectDetails;
|
|
2713
2714
|
}
|
|
2714
2715
|
// sendMessageRequest will unwrap the ProviderMessageRequest and send it to the JsonRpcHandler
|
|
@@ -3532,7 +3533,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3532
3533
|
|
|
3533
3534
|
var packageJson = {
|
|
3534
3535
|
name: "@0xsequence/provider",
|
|
3535
|
-
version: "1.
|
|
3536
|
+
version: "1.4.0",
|
|
3536
3537
|
description: "provider sub-package for Sequence",
|
|
3537
3538
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3538
3539
|
source: "src/index.ts",
|
|
@@ -3660,11 +3661,12 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3660
3661
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3661
3662
|
*s
|
|
3662
3663
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3663
|
-
*/
|
|
3664
|
+
*/ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3664
3665
|
class SequenceClient {
|
|
3665
|
-
constructor(transport, store, options) {
|
|
3666
|
+
constructor(transport, store, options, projectAccessKey) {
|
|
3666
3667
|
var _options$defaultEIP;
|
|
3667
3668
|
this.callbacks = {};
|
|
3669
|
+
this.projectAccessKey = projectAccessKey;
|
|
3668
3670
|
if (isMuxTransportTemplate(transport)) {
|
|
3669
3671
|
this.transport = MuxMessageProvider.new(transport);
|
|
3670
3672
|
} else if (isProviderTransport(transport)) {
|
|
@@ -3809,6 +3811,7 @@ class SequenceClient {
|
|
|
3809
3811
|
if ((options == null ? void 0 : options.refresh) === true) {
|
|
3810
3812
|
this.disconnect();
|
|
3811
3813
|
}
|
|
3814
|
+
options.projectAccessKey = this.projectAccessKey;
|
|
3812
3815
|
if (options) {
|
|
3813
3816
|
if (options.authorize) {
|
|
3814
3817
|
if (!options.app) {
|
|
@@ -4004,6 +4007,10 @@ const DefaultProviderConfig = {
|
|
|
4004
4007
|
let sequenceWalletProvider;
|
|
4005
4008
|
const initWallet = partialConfig => {
|
|
4006
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
|
+
}
|
|
4007
4014
|
if (sequenceWalletProvider) {
|
|
4008
4015
|
return sequenceWalletProvider;
|
|
4009
4016
|
}
|
|
@@ -4025,9 +4032,13 @@ const initWallet = partialConfig => {
|
|
|
4025
4032
|
var _config$networks2;
|
|
4026
4033
|
const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
|
|
4027
4034
|
return network ? _extends({}, n, network) : n;
|
|
4028
|
-
}).concat(newNetworks)
|
|
4035
|
+
}).concat(newNetworks).map(network => {
|
|
4036
|
+
const toAppend = projectAccessKey ? `/${projectAccessKey}` : '';
|
|
4037
|
+
network.rpcUrl = network.rpcUrl + toAppend;
|
|
4038
|
+
return network;
|
|
4039
|
+
});
|
|
4029
4040
|
|
|
4030
|
-
// This
|
|
4041
|
+
// This builds a "public rpc" on demand, we build them on demand because we don't want to
|
|
4031
4042
|
// generate a bunch of providers for networks that aren't used.
|
|
4032
4043
|
const providerForChainId = chainId => {
|
|
4033
4044
|
if (!rpcProviders[chainId]) {
|
|
@@ -4058,7 +4069,7 @@ const initWallet = partialConfig => {
|
|
|
4058
4069
|
const client = new SequenceClient(config.transports, itemStore, {
|
|
4059
4070
|
defaultChainId: defaultNetwork,
|
|
4060
4071
|
defaultEIP6492: config.defaultEIP6492
|
|
4061
|
-
});
|
|
4072
|
+
}, projectAccessKey);
|
|
4062
4073
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
4063
4074
|
return sequenceWalletProvider;
|
|
4064
4075
|
};
|
|
@@ -2341,9 +2341,10 @@ class WalletRequestHandler {
|
|
|
2341
2341
|
validateTransactionRequest(account.address, transactionParams);
|
|
2342
2342
|
let txnHash = '';
|
|
2343
2343
|
if (_this.prompter === null) {
|
|
2344
|
+
var _txnResponse$hash;
|
|
2344
2345
|
// prompter is null, so we'll send from here
|
|
2345
2346
|
const txnResponse = await account.sendTransaction(transactionParams, chainId != null ? chainId : _this.defaultChainId());
|
|
2346
|
-
txnHash = txnResponse.hash;
|
|
2347
|
+
txnHash = (_txnResponse$hash = txnResponse == null ? void 0 : txnResponse.hash) != null ? _txnResponse$hash : '';
|
|
2347
2348
|
} else {
|
|
2348
2349
|
// prompt user to provide the response
|
|
2349
2350
|
txnHash = await _this.prompter.promptSendTransaction(transactionParams, chainId, _this.connectOptions);
|
|
@@ -2708,7 +2709,7 @@ class WalletRequestHandler {
|
|
|
2708
2709
|
}
|
|
2709
2710
|
|
|
2710
2711
|
// Build session response for connect details
|
|
2711
|
-
connectDetails.session =
|
|
2712
|
+
connectDetails.session = this.walletSession(chainId);
|
|
2712
2713
|
return connectDetails;
|
|
2713
2714
|
}
|
|
2714
2715
|
// sendMessageRequest will unwrap the ProviderMessageRequest and send it to the JsonRpcHandler
|
|
@@ -3532,7 +3533,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3532
3533
|
|
|
3533
3534
|
var packageJson = {
|
|
3534
3535
|
name: "@0xsequence/provider",
|
|
3535
|
-
version: "1.
|
|
3536
|
+
version: "1.4.0",
|
|
3536
3537
|
description: "provider sub-package for Sequence",
|
|
3537
3538
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3538
3539
|
source: "src/index.ts",
|
|
@@ -3660,11 +3661,12 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3660
3661
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3661
3662
|
*s
|
|
3662
3663
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3663
|
-
*/
|
|
3664
|
+
*/ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3664
3665
|
class SequenceClient {
|
|
3665
|
-
constructor(transport, store, options) {
|
|
3666
|
+
constructor(transport, store, options, projectAccessKey) {
|
|
3666
3667
|
var _options$defaultEIP;
|
|
3667
3668
|
this.callbacks = {};
|
|
3669
|
+
this.projectAccessKey = projectAccessKey;
|
|
3668
3670
|
if (isMuxTransportTemplate(transport)) {
|
|
3669
3671
|
this.transport = MuxMessageProvider.new(transport);
|
|
3670
3672
|
} else if (isProviderTransport(transport)) {
|
|
@@ -3809,6 +3811,7 @@ class SequenceClient {
|
|
|
3809
3811
|
if ((options == null ? void 0 : options.refresh) === true) {
|
|
3810
3812
|
this.disconnect();
|
|
3811
3813
|
}
|
|
3814
|
+
options.projectAccessKey = this.projectAccessKey;
|
|
3812
3815
|
if (options) {
|
|
3813
3816
|
if (options.authorize) {
|
|
3814
3817
|
if (!options.app) {
|
|
@@ -4004,6 +4007,10 @@ const DefaultProviderConfig = {
|
|
|
4004
4007
|
let sequenceWalletProvider;
|
|
4005
4008
|
const initWallet = partialConfig => {
|
|
4006
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
|
+
}
|
|
4007
4014
|
if (sequenceWalletProvider) {
|
|
4008
4015
|
return sequenceWalletProvider;
|
|
4009
4016
|
}
|
|
@@ -4025,9 +4032,13 @@ const initWallet = partialConfig => {
|
|
|
4025
4032
|
var _config$networks2;
|
|
4026
4033
|
const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
|
|
4027
4034
|
return network ? _extends({}, n, network) : n;
|
|
4028
|
-
}).concat(newNetworks)
|
|
4035
|
+
}).concat(newNetworks).map(network => {
|
|
4036
|
+
const toAppend = projectAccessKey ? `/${projectAccessKey}` : '';
|
|
4037
|
+
network.rpcUrl = network.rpcUrl + toAppend;
|
|
4038
|
+
return network;
|
|
4039
|
+
});
|
|
4029
4040
|
|
|
4030
|
-
// This
|
|
4041
|
+
// This builds a "public rpc" on demand, we build them on demand because we don't want to
|
|
4031
4042
|
// generate a bunch of providers for networks that aren't used.
|
|
4032
4043
|
const providerForChainId = chainId => {
|
|
4033
4044
|
if (!rpcProviders[chainId]) {
|
|
@@ -4058,7 +4069,7 @@ const initWallet = partialConfig => {
|
|
|
4058
4069
|
const client = new SequenceClient(config.transports, itemStore, {
|
|
4059
4070
|
defaultChainId: defaultNetwork,
|
|
4060
4071
|
defaultEIP6492: config.defaultEIP6492
|
|
4061
|
-
});
|
|
4072
|
+
}, projectAccessKey);
|
|
4062
4073
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
4063
4074
|
return sequenceWalletProvider;
|
|
4064
4075
|
};
|
|
@@ -2337,9 +2337,10 @@ class WalletRequestHandler {
|
|
|
2337
2337
|
validateTransactionRequest(account.address, transactionParams);
|
|
2338
2338
|
let txnHash = '';
|
|
2339
2339
|
if (_this.prompter === null) {
|
|
2340
|
+
var _txnResponse$hash;
|
|
2340
2341
|
// prompter is null, so we'll send from here
|
|
2341
2342
|
const txnResponse = await account.sendTransaction(transactionParams, chainId != null ? chainId : _this.defaultChainId());
|
|
2342
|
-
txnHash = txnResponse.hash;
|
|
2343
|
+
txnHash = (_txnResponse$hash = txnResponse == null ? void 0 : txnResponse.hash) != null ? _txnResponse$hash : '';
|
|
2343
2344
|
} else {
|
|
2344
2345
|
// prompt user to provide the response
|
|
2345
2346
|
txnHash = await _this.prompter.promptSendTransaction(transactionParams, chainId, _this.connectOptions);
|
|
@@ -2704,7 +2705,7 @@ class WalletRequestHandler {
|
|
|
2704
2705
|
}
|
|
2705
2706
|
|
|
2706
2707
|
// Build session response for connect details
|
|
2707
|
-
connectDetails.session =
|
|
2708
|
+
connectDetails.session = this.walletSession(chainId);
|
|
2708
2709
|
return connectDetails;
|
|
2709
2710
|
}
|
|
2710
2711
|
// sendMessageRequest will unwrap the ProviderMessageRequest and send it to the JsonRpcHandler
|
|
@@ -3528,7 +3529,7 @@ class SingleNetworkSequenceProvider extends SequenceProvider {
|
|
|
3528
3529
|
|
|
3529
3530
|
var packageJson = {
|
|
3530
3531
|
name: "@0xsequence/provider",
|
|
3531
|
-
version: "1.
|
|
3532
|
+
version: "1.4.0",
|
|
3532
3533
|
description: "provider sub-package for Sequence",
|
|
3533
3534
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3534
3535
|
source: "src/index.ts",
|
|
@@ -3656,11 +3657,12 @@ DefaultChainIdTracker.SESSION_CHAIN_ID_KEY = '@sequence.session.defaultChainId';
|
|
|
3656
3657
|
* and it allows to perform all sequence specific (or write) operations related to the wallet.
|
|
3657
3658
|
*s
|
|
3658
3659
|
* It doesn't implement a full ethereum Provider, it doesn't include read-only methods.
|
|
3659
|
-
*/
|
|
3660
|
+
*/ // TODO: rename Client to transport.. or something.. like SequenceTransport ..
|
|
3660
3661
|
class SequenceClient {
|
|
3661
|
-
constructor(transport, store, options) {
|
|
3662
|
+
constructor(transport, store, options, projectAccessKey) {
|
|
3662
3663
|
var _options$defaultEIP;
|
|
3663
3664
|
this.callbacks = {};
|
|
3665
|
+
this.projectAccessKey = projectAccessKey;
|
|
3664
3666
|
if (isMuxTransportTemplate(transport)) {
|
|
3665
3667
|
this.transport = MuxMessageProvider.new(transport);
|
|
3666
3668
|
} else if (isProviderTransport(transport)) {
|
|
@@ -3805,6 +3807,7 @@ class SequenceClient {
|
|
|
3805
3807
|
if ((options == null ? void 0 : options.refresh) === true) {
|
|
3806
3808
|
this.disconnect();
|
|
3807
3809
|
}
|
|
3810
|
+
options.projectAccessKey = this.projectAccessKey;
|
|
3808
3811
|
if (options) {
|
|
3809
3812
|
if (options.authorize) {
|
|
3810
3813
|
if (!options.app) {
|
|
@@ -4000,6 +4003,10 @@ const DefaultProviderConfig = {
|
|
|
4000
4003
|
let sequenceWalletProvider;
|
|
4001
4004
|
const initWallet = partialConfig => {
|
|
4002
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
|
+
}
|
|
4003
4010
|
if (sequenceWalletProvider) {
|
|
4004
4011
|
return sequenceWalletProvider;
|
|
4005
4012
|
}
|
|
@@ -4021,9 +4028,13 @@ const initWallet = partialConfig => {
|
|
|
4021
4028
|
var _config$networks2;
|
|
4022
4029
|
const network = (_config$networks2 = config.networks) == null ? void 0 : _config$networks2.find(cn => cn.chainId === n.chainId);
|
|
4023
4030
|
return network ? _extends({}, n, network) : n;
|
|
4024
|
-
}).concat(newNetworks)
|
|
4031
|
+
}).concat(newNetworks).map(network => {
|
|
4032
|
+
const toAppend = projectAccessKey ? `/${projectAccessKey}` : '';
|
|
4033
|
+
network.rpcUrl = network.rpcUrl + toAppend;
|
|
4034
|
+
return network;
|
|
4035
|
+
});
|
|
4025
4036
|
|
|
4026
|
-
// This
|
|
4037
|
+
// This builds a "public rpc" on demand, we build them on demand because we don't want to
|
|
4027
4038
|
// generate a bunch of providers for networks that aren't used.
|
|
4028
4039
|
const providerForChainId = chainId => {
|
|
4029
4040
|
if (!rpcProviders[chainId]) {
|
|
@@ -4054,7 +4065,7 @@ const initWallet = partialConfig => {
|
|
|
4054
4065
|
const client = new SequenceClient(config.transports, itemStore, {
|
|
4055
4066
|
defaultChainId: defaultNetwork,
|
|
4056
4067
|
defaultEIP6492: config.defaultEIP6492
|
|
4057
|
-
});
|
|
4068
|
+
}, projectAccessKey);
|
|
4058
4069
|
sequenceWalletProvider = new SequenceProvider(client, providerForChainId);
|
|
4059
4070
|
return sequenceWalletProvider;
|
|
4060
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
|
+
"version": "1.4.0",
|
|
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/
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
18
|
-
"@0xsequence/
|
|
19
|
-
"@0xsequence/network": "1.
|
|
20
|
-
"@0xsequence/relayer": "1.
|
|
21
|
-
"@0xsequence/utils": "1.
|
|
22
|
-
"@0xsequence/wallet": "1.
|
|
14
|
+
"@0xsequence/abi": "1.4.0",
|
|
15
|
+
"@0xsequence/account": "1.4.0",
|
|
16
|
+
"@0xsequence/auth": "1.4.0",
|
|
17
|
+
"@0xsequence/core": "1.4.0",
|
|
18
|
+
"@0xsequence/migration": "1.4.0",
|
|
19
|
+
"@0xsequence/network": "1.4.0",
|
|
20
|
+
"@0xsequence/relayer": "1.4.0",
|
|
21
|
+
"@0xsequence/utils": "1.4.0",
|
|
22
|
+
"@0xsequence/wallet": "1.4.0"
|
|
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(
|
|
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
|
|
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(
|
|
122
|
-
|
|
123
|
-
|
|
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 =
|
|
183
|
+
connectDetails.session = this.walletSession(chainId)
|
|
184
184
|
|
|
185
185
|
return connectDetails
|
|
186
186
|
}
|
|
@@ -424,7 +424,7 @@ export class WalletRequestHandler implements ExternalProvider, JsonRpcHandler, P
|
|
|
424
424
|
if (this.prompter === null) {
|
|
425
425
|
// prompter is null, so we'll send from here
|
|
426
426
|
const txnResponse = await account.sendTransaction(transactionParams, chainId ?? this.defaultChainId())
|
|
427
|
-
txnHash = txnResponse
|
|
427
|
+
txnHash = txnResponse?.hash ?? ''
|
|
428
428
|
} else {
|
|
429
429
|
// prompt user to provide the response
|
|
430
430
|
txnHash = await this.prompter.promptSendTransaction(transactionParams, chainId, this.connectOptions)
|
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
|
|