@0xsequence/provider 2.0.25 → 2.1.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 +25 -14
- package/dist/0xsequence-provider.cjs.prod.js +25 -14
- package/dist/0xsequence-provider.esm.js +25 -14
- package/dist/declarations/src/transports/base-provider-transport.d.ts +2 -1
- package/dist/declarations/src/transports/mux-transport/mux-message-provider.d.ts +3 -2
- package/dist/declarations/src/transports/wallet-request-handler.d.ts +8 -6
- package/dist/declarations/src/transports/window-transport/window-message-provider.d.ts +1 -1
- package/dist/declarations/src/types.d.ts +1 -0
- package/package.json +10 -10
- package/src/transports/base-provider-transport.ts +7 -2
- package/src/transports/mux-transport/mux-message-provider.ts +5 -3
- package/src/transports/wallet-request-handler.ts +45 -17
- package/src/transports/window-transport/window-message-handler.ts +3 -0
- package/src/transports/window-transport/window-message-provider.ts +2 -2
- package/src/types.ts +1 -0
|
@@ -127,7 +127,7 @@ const PROVIDER_OPEN_TIMEOUT = 30000; // in ms
|
|
|
127
127
|
let _messageIdx = 0;
|
|
128
128
|
const nextMessageIdx = () => ++_messageIdx;
|
|
129
129
|
class BaseProviderTransport {
|
|
130
|
-
constructor() {
|
|
130
|
+
constructor(projectAccessKey) {
|
|
131
131
|
var _this = this;
|
|
132
132
|
this.pendingMessageRequests = [];
|
|
133
133
|
this.responseCallbacks = new Map();
|
|
@@ -142,6 +142,7 @@ class BaseProviderTransport {
|
|
|
142
142
|
this._sessionId = void 0;
|
|
143
143
|
this._init = void 0;
|
|
144
144
|
this._registered = void 0;
|
|
145
|
+
this.projectAccessKey = void 0;
|
|
145
146
|
// sendMessageRequest sends a ProviderMessageRequest over the wire to the wallet
|
|
146
147
|
this.sendMessageRequest = async function (message) {
|
|
147
148
|
return new Promise((resolve, reject) => {
|
|
@@ -226,6 +227,7 @@ class BaseProviderTransport {
|
|
|
226
227
|
this.state = OpenState.CLOSED;
|
|
227
228
|
this._registered = false;
|
|
228
229
|
this._init = InitState.NIL;
|
|
230
|
+
this.projectAccessKey = projectAccessKey;
|
|
229
231
|
}
|
|
230
232
|
get registered() {
|
|
231
233
|
return this._registered;
|
|
@@ -276,7 +278,8 @@ class BaseProviderTransport {
|
|
|
276
278
|
type: EventType.MESSAGE,
|
|
277
279
|
data: request,
|
|
278
280
|
chainId: request.chainId,
|
|
279
|
-
clientVersion: core.VERSION
|
|
281
|
+
clientVersion: core.VERSION,
|
|
282
|
+
projectAccessKey: this.projectAccessKey
|
|
280
283
|
});
|
|
281
284
|
return response.data;
|
|
282
285
|
}
|
|
@@ -1691,8 +1694,8 @@ class BaseInjectedTransport extends eventemitter2.EventEmitter2 {
|
|
|
1691
1694
|
// ..
|
|
1692
1695
|
let registeredWindowMessageProvider;
|
|
1693
1696
|
class WindowMessageProvider extends BaseProviderTransport {
|
|
1694
|
-
constructor(walletAppURL) {
|
|
1695
|
-
super();
|
|
1697
|
+
constructor(walletAppURL, projectAccessKey) {
|
|
1698
|
+
super(projectAccessKey);
|
|
1696
1699
|
this.walletURL = void 0;
|
|
1697
1700
|
this.walletWindow = void 0;
|
|
1698
1701
|
this.register = () => {
|
|
@@ -1869,6 +1872,7 @@ class WindowMessageHandler extends BaseWalletTransport {
|
|
|
1869
1872
|
// onmessage is called when (the wallet) receives request messages from the dapp
|
|
1870
1873
|
// over the window post-messaging transport
|
|
1871
1874
|
this.onWindowEvent = async function (event) {
|
|
1875
|
+
var _request, _request$origin;
|
|
1872
1876
|
if (!event.origin || event.origin === '') {
|
|
1873
1877
|
// skip same-origin or when event.origin is empty/undefined
|
|
1874
1878
|
return;
|
|
@@ -1886,6 +1890,9 @@ class WindowMessageHandler extends BaseWalletTransport {
|
|
|
1886
1890
|
// event is not a ProviderMessage JSON object, skip
|
|
1887
1891
|
return;
|
|
1888
1892
|
}
|
|
1893
|
+
|
|
1894
|
+
// Set the origin on the request
|
|
1895
|
+
(_request$origin = (_request = request).origin) != null ? _request$origin : _request.origin = event.origin;
|
|
1889
1896
|
utils.logger.debug('RECEIVED MESSAGE', request);
|
|
1890
1897
|
|
|
1891
1898
|
// Record event origin for valid init ack
|
|
@@ -2010,10 +2017,11 @@ function isMuxTransportTemplate(obj) {
|
|
|
2010
2017
|
obj.windowTransport && obj.windowTransport.enabled || obj.proxyTransport && obj.proxyTransport.enabled || obj.extensionTransport && obj.extensionTransport.enabled || obj.unrealTransport && obj.unrealTransport.enabled);
|
|
2011
2018
|
}
|
|
2012
2019
|
class MuxMessageProvider {
|
|
2013
|
-
constructor(
|
|
2020
|
+
constructor(messageProviders = [], projectAccessKey) {
|
|
2014
2021
|
var _this = this;
|
|
2015
2022
|
this.messageProviders = void 0;
|
|
2016
2023
|
this.provider = void 0;
|
|
2024
|
+
this.projectAccessKey = void 0;
|
|
2017
2025
|
this.register = () => {
|
|
2018
2026
|
if (this.messageProviders.length === 1) {
|
|
2019
2027
|
this.provider = this.messageProviders[0];
|
|
@@ -2073,12 +2081,13 @@ class MuxMessageProvider {
|
|
|
2073
2081
|
};
|
|
2074
2082
|
this.messageProviders = messageProviders;
|
|
2075
2083
|
this.provider = undefined;
|
|
2084
|
+
this.projectAccessKey = projectAccessKey;
|
|
2076
2085
|
}
|
|
2077
|
-
static new(template) {
|
|
2086
|
+
static new(template, projectAccessKey) {
|
|
2078
2087
|
var _template$windowTrans, _template$proxyTransp, _template$extensionTr, _template$unrealTrans;
|
|
2079
2088
|
const muxMessageProvider = new MuxMessageProvider();
|
|
2080
2089
|
if ((_template$windowTrans = template.windowTransport) != null && _template$windowTrans.enabled && typeof window === 'object' && template.walletAppURL) {
|
|
2081
|
-
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL);
|
|
2090
|
+
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL, projectAccessKey);
|
|
2082
2091
|
muxMessageProvider.add(windowMessageProvider);
|
|
2083
2092
|
}
|
|
2084
2093
|
if ((_template$proxyTransp = template.proxyTransport) != null && _template$proxyTransp.enabled) {
|
|
@@ -2367,7 +2376,9 @@ class WalletRequestHandler {
|
|
|
2367
2376
|
const result = await this.request({
|
|
2368
2377
|
method: message.data.method,
|
|
2369
2378
|
params: message.data.params,
|
|
2370
|
-
chainId: message.chainId
|
|
2379
|
+
chainId: message.chainId,
|
|
2380
|
+
origin: message.origin,
|
|
2381
|
+
projectAccessKey: message.projectAccessKey
|
|
2371
2382
|
});
|
|
2372
2383
|
return _extends({}, message, {
|
|
2373
2384
|
data: isJsonRpcResponse ? _extends({}, jsonRpcResponse, {
|
|
@@ -2480,7 +2491,7 @@ class WalletRequestHandler {
|
|
|
2480
2491
|
chainId: request.chainId,
|
|
2481
2492
|
message: ethers.ethers.getBytes(prefixedMessage),
|
|
2482
2493
|
eip6492: sequenceVerified
|
|
2483
|
-
},
|
|
2494
|
+
}, request.origin, request.projectAccessKey);
|
|
2484
2495
|
}
|
|
2485
2496
|
if (sig && sig.length > 0) {
|
|
2486
2497
|
return sig;
|
|
@@ -2520,7 +2531,7 @@ class WalletRequestHandler {
|
|
|
2520
2531
|
chainId: request.chainId,
|
|
2521
2532
|
typedData: typedData,
|
|
2522
2533
|
eip6492: sequenceVerified
|
|
2523
|
-
},
|
|
2534
|
+
}, request.origin, request.projectAccessKey);
|
|
2524
2535
|
}
|
|
2525
2536
|
if (sig && sig.length > 0) {
|
|
2526
2537
|
return sig;
|
|
@@ -2550,7 +2561,7 @@ class WalletRequestHandler {
|
|
|
2550
2561
|
txnHash = (_txnResponse$hash = txnResponse == null ? void 0 : txnResponse.hash) != null ? _txnResponse$hash : '';
|
|
2551
2562
|
} else {
|
|
2552
2563
|
// prompt user to provide the response
|
|
2553
|
-
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId,
|
|
2564
|
+
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId, request.origin, request.projectAccessKey);
|
|
2554
2565
|
}
|
|
2555
2566
|
if (txnHash) {
|
|
2556
2567
|
return txnHash;
|
|
@@ -2577,7 +2588,7 @@ class WalletRequestHandler {
|
|
|
2577
2588
|
// we will want to resolveProperties the big number values to hex strings
|
|
2578
2589
|
return await account.signTransactions(transaction, (_request$chainId5 = request.chainId) != null ? _request$chainId5 : this.defaultChainId());
|
|
2579
2590
|
} else {
|
|
2580
|
-
return await this.prompter.promptSignTransaction(transaction, request.chainId,
|
|
2591
|
+
return await this.prompter.promptSignTransaction(transaction, request.chainId, request.origin, request.projectAccessKey);
|
|
2581
2592
|
}
|
|
2582
2593
|
}
|
|
2583
2594
|
case 'eth_sendRawTransaction':
|
|
@@ -2890,7 +2901,7 @@ class WalletRequestHandler {
|
|
|
2890
2901
|
this.signerReadyCallbacks = [];
|
|
2891
2902
|
}
|
|
2892
2903
|
}
|
|
2893
|
-
async handleConfirmWalletDeployPrompt(prompter, account, sequenceVerified, chainId) {
|
|
2904
|
+
async handleConfirmWalletDeployPrompt(prompter, account, sequenceVerified, chainId, origin) {
|
|
2894
2905
|
// check if wallet is deployed and up to date, if not, prompt user to deploy
|
|
2895
2906
|
// if no chainId is provided, we'll assume the wallet is auth chain wallet and is up to date
|
|
2896
2907
|
if (!chainId) {
|
|
@@ -2903,7 +2914,7 @@ class WalletRequestHandler {
|
|
|
2903
2914
|
if (skipsDeploy(status)) {
|
|
2904
2915
|
return true;
|
|
2905
2916
|
}
|
|
2906
|
-
const promptResult = await prompter.promptConfirmWalletDeploy(chainId,
|
|
2917
|
+
const promptResult = await prompter.promptConfirmWalletDeploy(chainId, origin);
|
|
2907
2918
|
|
|
2908
2919
|
// if client returned true, check again to make sure wallet is deployed and up to date
|
|
2909
2920
|
if (promptResult) {
|
|
@@ -127,7 +127,7 @@ const PROVIDER_OPEN_TIMEOUT = 30000; // in ms
|
|
|
127
127
|
let _messageIdx = 0;
|
|
128
128
|
const nextMessageIdx = () => ++_messageIdx;
|
|
129
129
|
class BaseProviderTransport {
|
|
130
|
-
constructor() {
|
|
130
|
+
constructor(projectAccessKey) {
|
|
131
131
|
var _this = this;
|
|
132
132
|
this.pendingMessageRequests = [];
|
|
133
133
|
this.responseCallbacks = new Map();
|
|
@@ -142,6 +142,7 @@ class BaseProviderTransport {
|
|
|
142
142
|
this._sessionId = void 0;
|
|
143
143
|
this._init = void 0;
|
|
144
144
|
this._registered = void 0;
|
|
145
|
+
this.projectAccessKey = void 0;
|
|
145
146
|
// sendMessageRequest sends a ProviderMessageRequest over the wire to the wallet
|
|
146
147
|
this.sendMessageRequest = async function (message) {
|
|
147
148
|
return new Promise((resolve, reject) => {
|
|
@@ -226,6 +227,7 @@ class BaseProviderTransport {
|
|
|
226
227
|
this.state = OpenState.CLOSED;
|
|
227
228
|
this._registered = false;
|
|
228
229
|
this._init = InitState.NIL;
|
|
230
|
+
this.projectAccessKey = projectAccessKey;
|
|
229
231
|
}
|
|
230
232
|
get registered() {
|
|
231
233
|
return this._registered;
|
|
@@ -276,7 +278,8 @@ class BaseProviderTransport {
|
|
|
276
278
|
type: EventType.MESSAGE,
|
|
277
279
|
data: request,
|
|
278
280
|
chainId: request.chainId,
|
|
279
|
-
clientVersion: core.VERSION
|
|
281
|
+
clientVersion: core.VERSION,
|
|
282
|
+
projectAccessKey: this.projectAccessKey
|
|
280
283
|
});
|
|
281
284
|
return response.data;
|
|
282
285
|
}
|
|
@@ -1691,8 +1694,8 @@ class BaseInjectedTransport extends eventemitter2.EventEmitter2 {
|
|
|
1691
1694
|
// ..
|
|
1692
1695
|
let registeredWindowMessageProvider;
|
|
1693
1696
|
class WindowMessageProvider extends BaseProviderTransport {
|
|
1694
|
-
constructor(walletAppURL) {
|
|
1695
|
-
super();
|
|
1697
|
+
constructor(walletAppURL, projectAccessKey) {
|
|
1698
|
+
super(projectAccessKey);
|
|
1696
1699
|
this.walletURL = void 0;
|
|
1697
1700
|
this.walletWindow = void 0;
|
|
1698
1701
|
this.register = () => {
|
|
@@ -1869,6 +1872,7 @@ class WindowMessageHandler extends BaseWalletTransport {
|
|
|
1869
1872
|
// onmessage is called when (the wallet) receives request messages from the dapp
|
|
1870
1873
|
// over the window post-messaging transport
|
|
1871
1874
|
this.onWindowEvent = async function (event) {
|
|
1875
|
+
var _request, _request$origin;
|
|
1872
1876
|
if (!event.origin || event.origin === '') {
|
|
1873
1877
|
// skip same-origin or when event.origin is empty/undefined
|
|
1874
1878
|
return;
|
|
@@ -1886,6 +1890,9 @@ class WindowMessageHandler extends BaseWalletTransport {
|
|
|
1886
1890
|
// event is not a ProviderMessage JSON object, skip
|
|
1887
1891
|
return;
|
|
1888
1892
|
}
|
|
1893
|
+
|
|
1894
|
+
// Set the origin on the request
|
|
1895
|
+
(_request$origin = (_request = request).origin) != null ? _request$origin : _request.origin = event.origin;
|
|
1889
1896
|
utils.logger.debug('RECEIVED MESSAGE', request);
|
|
1890
1897
|
|
|
1891
1898
|
// Record event origin for valid init ack
|
|
@@ -2010,10 +2017,11 @@ function isMuxTransportTemplate(obj) {
|
|
|
2010
2017
|
obj.windowTransport && obj.windowTransport.enabled || obj.proxyTransport && obj.proxyTransport.enabled || obj.extensionTransport && obj.extensionTransport.enabled || obj.unrealTransport && obj.unrealTransport.enabled);
|
|
2011
2018
|
}
|
|
2012
2019
|
class MuxMessageProvider {
|
|
2013
|
-
constructor(
|
|
2020
|
+
constructor(messageProviders = [], projectAccessKey) {
|
|
2014
2021
|
var _this = this;
|
|
2015
2022
|
this.messageProviders = void 0;
|
|
2016
2023
|
this.provider = void 0;
|
|
2024
|
+
this.projectAccessKey = void 0;
|
|
2017
2025
|
this.register = () => {
|
|
2018
2026
|
if (this.messageProviders.length === 1) {
|
|
2019
2027
|
this.provider = this.messageProviders[0];
|
|
@@ -2073,12 +2081,13 @@ class MuxMessageProvider {
|
|
|
2073
2081
|
};
|
|
2074
2082
|
this.messageProviders = messageProviders;
|
|
2075
2083
|
this.provider = undefined;
|
|
2084
|
+
this.projectAccessKey = projectAccessKey;
|
|
2076
2085
|
}
|
|
2077
|
-
static new(template) {
|
|
2086
|
+
static new(template, projectAccessKey) {
|
|
2078
2087
|
var _template$windowTrans, _template$proxyTransp, _template$extensionTr, _template$unrealTrans;
|
|
2079
2088
|
const muxMessageProvider = new MuxMessageProvider();
|
|
2080
2089
|
if ((_template$windowTrans = template.windowTransport) != null && _template$windowTrans.enabled && typeof window === 'object' && template.walletAppURL) {
|
|
2081
|
-
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL);
|
|
2090
|
+
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL, projectAccessKey);
|
|
2082
2091
|
muxMessageProvider.add(windowMessageProvider);
|
|
2083
2092
|
}
|
|
2084
2093
|
if ((_template$proxyTransp = template.proxyTransport) != null && _template$proxyTransp.enabled) {
|
|
@@ -2367,7 +2376,9 @@ class WalletRequestHandler {
|
|
|
2367
2376
|
const result = await this.request({
|
|
2368
2377
|
method: message.data.method,
|
|
2369
2378
|
params: message.data.params,
|
|
2370
|
-
chainId: message.chainId
|
|
2379
|
+
chainId: message.chainId,
|
|
2380
|
+
origin: message.origin,
|
|
2381
|
+
projectAccessKey: message.projectAccessKey
|
|
2371
2382
|
});
|
|
2372
2383
|
return _extends({}, message, {
|
|
2373
2384
|
data: isJsonRpcResponse ? _extends({}, jsonRpcResponse, {
|
|
@@ -2480,7 +2491,7 @@ class WalletRequestHandler {
|
|
|
2480
2491
|
chainId: request.chainId,
|
|
2481
2492
|
message: ethers.ethers.getBytes(prefixedMessage),
|
|
2482
2493
|
eip6492: sequenceVerified
|
|
2483
|
-
},
|
|
2494
|
+
}, request.origin, request.projectAccessKey);
|
|
2484
2495
|
}
|
|
2485
2496
|
if (sig && sig.length > 0) {
|
|
2486
2497
|
return sig;
|
|
@@ -2520,7 +2531,7 @@ class WalletRequestHandler {
|
|
|
2520
2531
|
chainId: request.chainId,
|
|
2521
2532
|
typedData: typedData,
|
|
2522
2533
|
eip6492: sequenceVerified
|
|
2523
|
-
},
|
|
2534
|
+
}, request.origin, request.projectAccessKey);
|
|
2524
2535
|
}
|
|
2525
2536
|
if (sig && sig.length > 0) {
|
|
2526
2537
|
return sig;
|
|
@@ -2550,7 +2561,7 @@ class WalletRequestHandler {
|
|
|
2550
2561
|
txnHash = (_txnResponse$hash = txnResponse == null ? void 0 : txnResponse.hash) != null ? _txnResponse$hash : '';
|
|
2551
2562
|
} else {
|
|
2552
2563
|
// prompt user to provide the response
|
|
2553
|
-
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId,
|
|
2564
|
+
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId, request.origin, request.projectAccessKey);
|
|
2554
2565
|
}
|
|
2555
2566
|
if (txnHash) {
|
|
2556
2567
|
return txnHash;
|
|
@@ -2577,7 +2588,7 @@ class WalletRequestHandler {
|
|
|
2577
2588
|
// we will want to resolveProperties the big number values to hex strings
|
|
2578
2589
|
return await account.signTransactions(transaction, (_request$chainId5 = request.chainId) != null ? _request$chainId5 : this.defaultChainId());
|
|
2579
2590
|
} else {
|
|
2580
|
-
return await this.prompter.promptSignTransaction(transaction, request.chainId,
|
|
2591
|
+
return await this.prompter.promptSignTransaction(transaction, request.chainId, request.origin, request.projectAccessKey);
|
|
2581
2592
|
}
|
|
2582
2593
|
}
|
|
2583
2594
|
case 'eth_sendRawTransaction':
|
|
@@ -2890,7 +2901,7 @@ class WalletRequestHandler {
|
|
|
2890
2901
|
this.signerReadyCallbacks = [];
|
|
2891
2902
|
}
|
|
2892
2903
|
}
|
|
2893
|
-
async handleConfirmWalletDeployPrompt(prompter, account, sequenceVerified, chainId) {
|
|
2904
|
+
async handleConfirmWalletDeployPrompt(prompter, account, sequenceVerified, chainId, origin) {
|
|
2894
2905
|
// check if wallet is deployed and up to date, if not, prompt user to deploy
|
|
2895
2906
|
// if no chainId is provided, we'll assume the wallet is auth chain wallet and is up to date
|
|
2896
2907
|
if (!chainId) {
|
|
@@ -2903,7 +2914,7 @@ class WalletRequestHandler {
|
|
|
2903
2914
|
if (skipsDeploy(status)) {
|
|
2904
2915
|
return true;
|
|
2905
2916
|
}
|
|
2906
|
-
const promptResult = await prompter.promptConfirmWalletDeploy(chainId,
|
|
2917
|
+
const promptResult = await prompter.promptConfirmWalletDeploy(chainId, origin);
|
|
2907
2918
|
|
|
2908
2919
|
// if client returned true, check again to make sure wallet is deployed and up to date
|
|
2909
2920
|
if (promptResult) {
|
|
@@ -123,7 +123,7 @@ const PROVIDER_OPEN_TIMEOUT = 30000; // in ms
|
|
|
123
123
|
let _messageIdx = 0;
|
|
124
124
|
const nextMessageIdx = () => ++_messageIdx;
|
|
125
125
|
class BaseProviderTransport {
|
|
126
|
-
constructor() {
|
|
126
|
+
constructor(projectAccessKey) {
|
|
127
127
|
var _this = this;
|
|
128
128
|
this.pendingMessageRequests = [];
|
|
129
129
|
this.responseCallbacks = new Map();
|
|
@@ -138,6 +138,7 @@ class BaseProviderTransport {
|
|
|
138
138
|
this._sessionId = void 0;
|
|
139
139
|
this._init = void 0;
|
|
140
140
|
this._registered = void 0;
|
|
141
|
+
this.projectAccessKey = void 0;
|
|
141
142
|
// sendMessageRequest sends a ProviderMessageRequest over the wire to the wallet
|
|
142
143
|
this.sendMessageRequest = async function (message) {
|
|
143
144
|
return new Promise((resolve, reject) => {
|
|
@@ -222,6 +223,7 @@ class BaseProviderTransport {
|
|
|
222
223
|
this.state = OpenState.CLOSED;
|
|
223
224
|
this._registered = false;
|
|
224
225
|
this._init = InitState.NIL;
|
|
226
|
+
this.projectAccessKey = projectAccessKey;
|
|
225
227
|
}
|
|
226
228
|
get registered() {
|
|
227
229
|
return this._registered;
|
|
@@ -272,7 +274,8 @@ class BaseProviderTransport {
|
|
|
272
274
|
type: EventType.MESSAGE,
|
|
273
275
|
data: request,
|
|
274
276
|
chainId: request.chainId,
|
|
275
|
-
clientVersion: VERSION
|
|
277
|
+
clientVersion: VERSION,
|
|
278
|
+
projectAccessKey: this.projectAccessKey
|
|
276
279
|
});
|
|
277
280
|
return response.data;
|
|
278
281
|
}
|
|
@@ -1687,8 +1690,8 @@ class BaseInjectedTransport extends EventEmitter2 {
|
|
|
1687
1690
|
// ..
|
|
1688
1691
|
let registeredWindowMessageProvider;
|
|
1689
1692
|
class WindowMessageProvider extends BaseProviderTransport {
|
|
1690
|
-
constructor(walletAppURL) {
|
|
1691
|
-
super();
|
|
1693
|
+
constructor(walletAppURL, projectAccessKey) {
|
|
1694
|
+
super(projectAccessKey);
|
|
1692
1695
|
this.walletURL = void 0;
|
|
1693
1696
|
this.walletWindow = void 0;
|
|
1694
1697
|
this.register = () => {
|
|
@@ -1865,6 +1868,7 @@ class WindowMessageHandler extends BaseWalletTransport {
|
|
|
1865
1868
|
// onmessage is called when (the wallet) receives request messages from the dapp
|
|
1866
1869
|
// over the window post-messaging transport
|
|
1867
1870
|
this.onWindowEvent = async function (event) {
|
|
1871
|
+
var _request, _request$origin;
|
|
1868
1872
|
if (!event.origin || event.origin === '') {
|
|
1869
1873
|
// skip same-origin or when event.origin is empty/undefined
|
|
1870
1874
|
return;
|
|
@@ -1882,6 +1886,9 @@ class WindowMessageHandler extends BaseWalletTransport {
|
|
|
1882
1886
|
// event is not a ProviderMessage JSON object, skip
|
|
1883
1887
|
return;
|
|
1884
1888
|
}
|
|
1889
|
+
|
|
1890
|
+
// Set the origin on the request
|
|
1891
|
+
(_request$origin = (_request = request).origin) != null ? _request$origin : _request.origin = event.origin;
|
|
1885
1892
|
logger.debug('RECEIVED MESSAGE', request);
|
|
1886
1893
|
|
|
1887
1894
|
// Record event origin for valid init ack
|
|
@@ -2006,10 +2013,11 @@ function isMuxTransportTemplate(obj) {
|
|
|
2006
2013
|
obj.windowTransport && obj.windowTransport.enabled || obj.proxyTransport && obj.proxyTransport.enabled || obj.extensionTransport && obj.extensionTransport.enabled || obj.unrealTransport && obj.unrealTransport.enabled);
|
|
2007
2014
|
}
|
|
2008
2015
|
class MuxMessageProvider {
|
|
2009
|
-
constructor(
|
|
2016
|
+
constructor(messageProviders = [], projectAccessKey) {
|
|
2010
2017
|
var _this = this;
|
|
2011
2018
|
this.messageProviders = void 0;
|
|
2012
2019
|
this.provider = void 0;
|
|
2020
|
+
this.projectAccessKey = void 0;
|
|
2013
2021
|
this.register = () => {
|
|
2014
2022
|
if (this.messageProviders.length === 1) {
|
|
2015
2023
|
this.provider = this.messageProviders[0];
|
|
@@ -2069,12 +2077,13 @@ class MuxMessageProvider {
|
|
|
2069
2077
|
};
|
|
2070
2078
|
this.messageProviders = messageProviders;
|
|
2071
2079
|
this.provider = undefined;
|
|
2080
|
+
this.projectAccessKey = projectAccessKey;
|
|
2072
2081
|
}
|
|
2073
|
-
static new(template) {
|
|
2082
|
+
static new(template, projectAccessKey) {
|
|
2074
2083
|
var _template$windowTrans, _template$proxyTransp, _template$extensionTr, _template$unrealTrans;
|
|
2075
2084
|
const muxMessageProvider = new MuxMessageProvider();
|
|
2076
2085
|
if ((_template$windowTrans = template.windowTransport) != null && _template$windowTrans.enabled && typeof window === 'object' && template.walletAppURL) {
|
|
2077
|
-
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL);
|
|
2086
|
+
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL, projectAccessKey);
|
|
2078
2087
|
muxMessageProvider.add(windowMessageProvider);
|
|
2079
2088
|
}
|
|
2080
2089
|
if ((_template$proxyTransp = template.proxyTransport) != null && _template$proxyTransp.enabled) {
|
|
@@ -2363,7 +2372,9 @@ class WalletRequestHandler {
|
|
|
2363
2372
|
const result = await this.request({
|
|
2364
2373
|
method: message.data.method,
|
|
2365
2374
|
params: message.data.params,
|
|
2366
|
-
chainId: message.chainId
|
|
2375
|
+
chainId: message.chainId,
|
|
2376
|
+
origin: message.origin,
|
|
2377
|
+
projectAccessKey: message.projectAccessKey
|
|
2367
2378
|
});
|
|
2368
2379
|
return _extends({}, message, {
|
|
2369
2380
|
data: isJsonRpcResponse ? _extends({}, jsonRpcResponse, {
|
|
@@ -2476,7 +2487,7 @@ class WalletRequestHandler {
|
|
|
2476
2487
|
chainId: request.chainId,
|
|
2477
2488
|
message: ethers.getBytes(prefixedMessage),
|
|
2478
2489
|
eip6492: sequenceVerified
|
|
2479
|
-
},
|
|
2490
|
+
}, request.origin, request.projectAccessKey);
|
|
2480
2491
|
}
|
|
2481
2492
|
if (sig && sig.length > 0) {
|
|
2482
2493
|
return sig;
|
|
@@ -2516,7 +2527,7 @@ class WalletRequestHandler {
|
|
|
2516
2527
|
chainId: request.chainId,
|
|
2517
2528
|
typedData: typedData,
|
|
2518
2529
|
eip6492: sequenceVerified
|
|
2519
|
-
},
|
|
2530
|
+
}, request.origin, request.projectAccessKey);
|
|
2520
2531
|
}
|
|
2521
2532
|
if (sig && sig.length > 0) {
|
|
2522
2533
|
return sig;
|
|
@@ -2546,7 +2557,7 @@ class WalletRequestHandler {
|
|
|
2546
2557
|
txnHash = (_txnResponse$hash = txnResponse == null ? void 0 : txnResponse.hash) != null ? _txnResponse$hash : '';
|
|
2547
2558
|
} else {
|
|
2548
2559
|
// prompt user to provide the response
|
|
2549
|
-
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId,
|
|
2560
|
+
txnHash = await this.prompter.promptSendTransaction(transactionParams, request.chainId, request.origin, request.projectAccessKey);
|
|
2550
2561
|
}
|
|
2551
2562
|
if (txnHash) {
|
|
2552
2563
|
return txnHash;
|
|
@@ -2573,7 +2584,7 @@ class WalletRequestHandler {
|
|
|
2573
2584
|
// we will want to resolveProperties the big number values to hex strings
|
|
2574
2585
|
return await account.signTransactions(transaction, (_request$chainId5 = request.chainId) != null ? _request$chainId5 : this.defaultChainId());
|
|
2575
2586
|
} else {
|
|
2576
|
-
return await this.prompter.promptSignTransaction(transaction, request.chainId,
|
|
2587
|
+
return await this.prompter.promptSignTransaction(transaction, request.chainId, request.origin, request.projectAccessKey);
|
|
2577
2588
|
}
|
|
2578
2589
|
}
|
|
2579
2590
|
case 'eth_sendRawTransaction':
|
|
@@ -2886,7 +2897,7 @@ class WalletRequestHandler {
|
|
|
2886
2897
|
this.signerReadyCallbacks = [];
|
|
2887
2898
|
}
|
|
2888
2899
|
}
|
|
2889
|
-
async handleConfirmWalletDeployPrompt(prompter, account, sequenceVerified, chainId) {
|
|
2900
|
+
async handleConfirmWalletDeployPrompt(prompter, account, sequenceVerified, chainId, origin) {
|
|
2890
2901
|
// check if wallet is deployed and up to date, if not, prompt user to deploy
|
|
2891
2902
|
// if no chainId is provided, we'll assume the wallet is auth chain wallet and is up to date
|
|
2892
2903
|
if (!chainId) {
|
|
@@ -2899,7 +2910,7 @@ class WalletRequestHandler {
|
|
|
2899
2910
|
if (skipsDeploy(status)) {
|
|
2900
2911
|
return true;
|
|
2901
2912
|
}
|
|
2902
|
-
const promptResult = await prompter.promptConfirmWalletDeploy(chainId,
|
|
2913
|
+
const promptResult = await prompter.promptConfirmWalletDeploy(chainId, origin);
|
|
2903
2914
|
|
|
2904
2915
|
// if client returned true, check again to make sure wallet is deployed and up to date
|
|
2905
2916
|
if (promptResult) {
|
|
@@ -23,7 +23,8 @@ export declare abstract class BaseProviderTransport implements ProviderTransport
|
|
|
23
23
|
protected _sessionId?: string;
|
|
24
24
|
protected _init: InitState;
|
|
25
25
|
protected _registered: boolean;
|
|
26
|
-
|
|
26
|
+
readonly projectAccessKey?: string;
|
|
27
|
+
constructor(projectAccessKey?: string);
|
|
27
28
|
get registered(): boolean;
|
|
28
29
|
register(): void;
|
|
29
30
|
unregister(): void;
|
|
@@ -22,8 +22,9 @@ export declare function isMuxTransportTemplate(obj: any): obj is MuxTransportTem
|
|
|
22
22
|
export declare class MuxMessageProvider implements ProviderTransport {
|
|
23
23
|
private messageProviders;
|
|
24
24
|
private provider;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
private projectAccessKey?;
|
|
26
|
+
constructor(messageProviders?: ProviderTransport[], projectAccessKey?: string);
|
|
27
|
+
static new(template: MuxTransportTemplate, projectAccessKey?: string): MuxMessageProvider;
|
|
27
28
|
add(...messageProviders: ProviderTransport[]): void;
|
|
28
29
|
register: () => void;
|
|
29
30
|
unregister: () => void;
|
|
@@ -28,6 +28,8 @@ export declare class WalletRequestHandler implements EIP1193Provider, ProviderMe
|
|
|
28
28
|
method: string;
|
|
29
29
|
params?: any[];
|
|
30
30
|
chainId?: number;
|
|
31
|
+
origin?: string;
|
|
32
|
+
projectAccessKey?: string;
|
|
31
33
|
}): Promise<any>;
|
|
32
34
|
on<K extends keyof ProviderEventTypes>(event: K, fn: ProviderEventTypes[K]): void;
|
|
33
35
|
once<K extends keyof ProviderEventTypes>(event: K, fn: ProviderEventTypes[K]): void;
|
|
@@ -52,11 +54,11 @@ export declare class WalletRequestHandler implements EIP1193Provider, ProviderMe
|
|
|
52
54
|
}
|
|
53
55
|
export interface WalletUserPrompter {
|
|
54
56
|
getDefaultChainId(): number;
|
|
55
|
-
promptConnect(
|
|
56
|
-
promptSignInConnect(
|
|
57
|
-
promptSignMessage(message: MessageToSign,
|
|
58
|
-
promptSignTransaction(txn: commons.transaction.Transactionish, chainId?: number,
|
|
59
|
-
promptSendTransaction(txn: commons.transaction.Transactionish, chainId?: number,
|
|
60
|
-
promptConfirmWalletDeploy(chainId: number,
|
|
57
|
+
promptConnect(connectOptions?: ConnectOptions): Promise<PromptConnectDetails>;
|
|
58
|
+
promptSignInConnect(connectOptions?: ConnectOptions): Promise<PromptConnectDetails>;
|
|
59
|
+
promptSignMessage(message: MessageToSign, origin?: string, projectAccessKey?: string): Promise<string>;
|
|
60
|
+
promptSignTransaction(txn: commons.transaction.Transactionish, chainId?: number, origin?: string, projectAccessKey?: string): Promise<string>;
|
|
61
|
+
promptSendTransaction(txn: commons.transaction.Transactionish, chainId?: number, origin?: string, projectAccessKey?: string): Promise<string>;
|
|
62
|
+
promptConfirmWalletDeploy(chainId: number, origin?: string): Promise<boolean>;
|
|
61
63
|
promptChangeNetwork(chainId: number): Promise<boolean>;
|
|
62
64
|
}
|
|
@@ -3,7 +3,7 @@ import { BaseProviderTransport } from "../base-provider-transport.js";
|
|
|
3
3
|
export declare class WindowMessageProvider extends BaseProviderTransport {
|
|
4
4
|
private walletURL;
|
|
5
5
|
private walletWindow;
|
|
6
|
-
constructor(walletAppURL: string);
|
|
6
|
+
constructor(walletAppURL: string, projectAccessKey?: string);
|
|
7
7
|
register: () => void;
|
|
8
8
|
unregister: () => void;
|
|
9
9
|
openWallet: (path?: string, intent?: OpenWalletIntent, networkId?: string | number) => void;
|
|
@@ -38,6 +38,7 @@ export interface ProviderMessage<T> {
|
|
|
38
38
|
chainId?: number;
|
|
39
39
|
origin?: string;
|
|
40
40
|
clientVersion: string;
|
|
41
|
+
projectAccessKey?: string;
|
|
41
42
|
}
|
|
42
43
|
export type ProviderMessageRequest = ProviderMessage<JsonRpcRequest>;
|
|
43
44
|
export type ProviderMessageResponse = ProviderMessage<JsonRpcResponse | any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.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",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"@databeat/tracker": "^0.9.3",
|
|
16
16
|
"eventemitter2": "^6.4.5",
|
|
17
17
|
"webextension-polyfill": "^0.10.0",
|
|
18
|
-
"@0xsequence/abi": "2.0
|
|
19
|
-
"@0xsequence/account": "2.0
|
|
20
|
-
"@0xsequence/auth": "2.0
|
|
21
|
-
"@0xsequence/core": "2.0
|
|
22
|
-
"@0xsequence/
|
|
23
|
-
"@0xsequence/
|
|
24
|
-
"@0xsequence/relayer": "2.0
|
|
25
|
-
"@0xsequence/
|
|
26
|
-
"@0xsequence/
|
|
18
|
+
"@0xsequence/abi": "2.1.0",
|
|
19
|
+
"@0xsequence/account": "2.1.0",
|
|
20
|
+
"@0xsequence/auth": "2.1.0",
|
|
21
|
+
"@0xsequence/core": "2.1.0",
|
|
22
|
+
"@0xsequence/migration": "2.1.0",
|
|
23
|
+
"@0xsequence/network": "2.1.0",
|
|
24
|
+
"@0xsequence/relayer": "2.1.0",
|
|
25
|
+
"@0xsequence/wallet": "2.1.0",
|
|
26
|
+
"@0xsequence/utils": "2.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/webextension-polyfill": "^0.10.0",
|
|
@@ -46,10 +46,14 @@ export abstract class BaseProviderTransport implements ProviderTransport {
|
|
|
46
46
|
protected _init: InitState
|
|
47
47
|
protected _registered: boolean
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
readonly projectAccessKey?: string
|
|
50
|
+
|
|
51
|
+
constructor(projectAccessKey?: string) {
|
|
50
52
|
this.state = OpenState.CLOSED
|
|
51
53
|
this._registered = false
|
|
52
54
|
this._init = InitState.NIL
|
|
55
|
+
|
|
56
|
+
this.projectAccessKey = projectAccessKey
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
get registered(): boolean {
|
|
@@ -113,7 +117,8 @@ export abstract class BaseProviderTransport implements ProviderTransport {
|
|
|
113
117
|
type: EventType.MESSAGE,
|
|
114
118
|
data: request,
|
|
115
119
|
chainId: request.chainId,
|
|
116
|
-
clientVersion: VERSION
|
|
120
|
+
clientVersion: VERSION,
|
|
121
|
+
projectAccessKey: this.projectAccessKey
|
|
117
122
|
})
|
|
118
123
|
|
|
119
124
|
return response.data
|
|
@@ -61,17 +61,19 @@ export function isMuxTransportTemplate(obj: any): obj is MuxTransportTemplate {
|
|
|
61
61
|
export class MuxMessageProvider implements ProviderTransport {
|
|
62
62
|
private messageProviders: ProviderTransport[]
|
|
63
63
|
private provider: ProviderTransport | undefined
|
|
64
|
+
private projectAccessKey?: string
|
|
64
65
|
|
|
65
|
-
constructor(
|
|
66
|
+
constructor(messageProviders: ProviderTransport[] = [], projectAccessKey?: string) {
|
|
66
67
|
this.messageProviders = messageProviders
|
|
67
68
|
this.provider = undefined
|
|
69
|
+
this.projectAccessKey = projectAccessKey
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
static new(template: MuxTransportTemplate): MuxMessageProvider {
|
|
72
|
+
static new(template: MuxTransportTemplate, projectAccessKey?: string): MuxMessageProvider {
|
|
71
73
|
const muxMessageProvider = new MuxMessageProvider()
|
|
72
74
|
|
|
73
75
|
if (template.windowTransport?.enabled && typeof window === 'object' && template.walletAppURL) {
|
|
74
|
-
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL)
|
|
76
|
+
const windowMessageProvider = new WindowMessageProvider(template.walletAppURL, projectAccessKey)
|
|
75
77
|
muxMessageProvider.add(windowMessageProvider)
|
|
76
78
|
}
|
|
77
79
|
|
|
@@ -226,7 +226,9 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
226
226
|
const result = await this.request({
|
|
227
227
|
method: message.data.method,
|
|
228
228
|
params: message.data.params,
|
|
229
|
-
chainId: message.chainId
|
|
229
|
+
chainId: message.chainId,
|
|
230
|
+
origin: message.origin,
|
|
231
|
+
projectAccessKey: message.projectAccessKey
|
|
230
232
|
})
|
|
231
233
|
|
|
232
234
|
return {
|
|
@@ -241,7 +243,13 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
|
|
244
|
-
async request(request: {
|
|
246
|
+
async request(request: {
|
|
247
|
+
method: string
|
|
248
|
+
params?: any[]
|
|
249
|
+
chainId?: number
|
|
250
|
+
origin?: string
|
|
251
|
+
projectAccessKey?: string
|
|
252
|
+
}): Promise<any> {
|
|
245
253
|
await this.getAccount()
|
|
246
254
|
|
|
247
255
|
try {
|
|
@@ -344,7 +352,8 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
344
352
|
message: ethers.getBytes(prefixedMessage),
|
|
345
353
|
eip6492: sequenceVerified
|
|
346
354
|
},
|
|
347
|
-
|
|
355
|
+
request.origin,
|
|
356
|
+
request.projectAccessKey
|
|
348
357
|
)
|
|
349
358
|
}
|
|
350
359
|
|
|
@@ -397,7 +406,8 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
397
406
|
typedData: typedData,
|
|
398
407
|
eip6492: sequenceVerified
|
|
399
408
|
},
|
|
400
|
-
|
|
409
|
+
request.origin,
|
|
410
|
+
request.projectAccessKey
|
|
401
411
|
)
|
|
402
412
|
}
|
|
403
413
|
|
|
@@ -431,7 +441,12 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
431
441
|
txnHash = txnResponse?.hash ?? ''
|
|
432
442
|
} else {
|
|
433
443
|
// prompt user to provide the response
|
|
434
|
-
txnHash = await this.prompter.promptSendTransaction(
|
|
444
|
+
txnHash = await this.prompter.promptSendTransaction(
|
|
445
|
+
transactionParams,
|
|
446
|
+
request.chainId,
|
|
447
|
+
request.origin,
|
|
448
|
+
request.projectAccessKey
|
|
449
|
+
)
|
|
435
450
|
}
|
|
436
451
|
|
|
437
452
|
if (txnHash) {
|
|
@@ -461,7 +476,12 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
461
476
|
// we will want to resolveProperties the big number values to hex strings
|
|
462
477
|
return await account.signTransactions(transaction, request.chainId ?? this.defaultChainId())
|
|
463
478
|
} else {
|
|
464
|
-
return await this.prompter.promptSignTransaction(
|
|
479
|
+
return await this.prompter.promptSignTransaction(
|
|
480
|
+
transaction,
|
|
481
|
+
request.chainId,
|
|
482
|
+
request.origin,
|
|
483
|
+
request.projectAccessKey
|
|
484
|
+
)
|
|
465
485
|
}
|
|
466
486
|
}
|
|
467
487
|
|
|
@@ -800,7 +820,8 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
800
820
|
prompter: WalletUserPrompter,
|
|
801
821
|
account: Account,
|
|
802
822
|
sequenceVerified: boolean,
|
|
803
|
-
chainId?: number
|
|
823
|
+
chainId?: number,
|
|
824
|
+
origin?: string
|
|
804
825
|
): Promise<boolean> {
|
|
805
826
|
// check if wallet is deployed and up to date, if not, prompt user to deploy
|
|
806
827
|
// if no chainId is provided, we'll assume the wallet is auth chain wallet and is up to date
|
|
@@ -817,7 +838,7 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
817
838
|
return true
|
|
818
839
|
}
|
|
819
840
|
|
|
820
|
-
const promptResult = await prompter.promptConfirmWalletDeploy(chainId,
|
|
841
|
+
const promptResult = await prompter.promptConfirmWalletDeploy(chainId, origin)
|
|
821
842
|
|
|
822
843
|
// if client returned true, check again to make sure wallet is deployed and up to date
|
|
823
844
|
if (promptResult) {
|
|
@@ -837,15 +858,22 @@ export class WalletRequestHandler implements EIP1193Provider, ProviderMessageReq
|
|
|
837
858
|
|
|
838
859
|
export interface WalletUserPrompter {
|
|
839
860
|
getDefaultChainId(): number
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
861
|
+
promptConnect(connectOptions?: ConnectOptions): Promise<PromptConnectDetails>
|
|
862
|
+
promptSignInConnect(connectOptions?: ConnectOptions): Promise<PromptConnectDetails>
|
|
863
|
+
promptSignMessage(message: MessageToSign, origin?: string, projectAccessKey?: string): Promise<string>
|
|
864
|
+
promptSignTransaction(
|
|
865
|
+
txn: commons.transaction.Transactionish,
|
|
866
|
+
chainId?: number,
|
|
867
|
+
origin?: string,
|
|
868
|
+
projectAccessKey?: string
|
|
869
|
+
): Promise<string>
|
|
870
|
+
promptSendTransaction(
|
|
871
|
+
txn: commons.transaction.Transactionish,
|
|
872
|
+
chainId?: number,
|
|
873
|
+
origin?: string,
|
|
874
|
+
projectAccessKey?: string
|
|
875
|
+
): Promise<string>
|
|
876
|
+
promptConfirmWalletDeploy(chainId: number, origin?: string): Promise<boolean>
|
|
849
877
|
promptChangeNetwork(chainId: number): Promise<boolean>
|
|
850
878
|
}
|
|
851
879
|
|
|
@@ -99,6 +99,9 @@ export class WindowMessageHandler extends BaseWalletTransport {
|
|
|
99
99
|
return
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// Set the origin on the request
|
|
103
|
+
request.origin ??= event.origin
|
|
104
|
+
|
|
102
105
|
logger.debug('RECEIVED MESSAGE', request)
|
|
103
106
|
|
|
104
107
|
// Record event origin for valid init ack
|
|
@@ -10,8 +10,8 @@ export class WindowMessageProvider extends BaseProviderTransport {
|
|
|
10
10
|
private walletURL: URL
|
|
11
11
|
private walletWindow: Window | null
|
|
12
12
|
|
|
13
|
-
constructor(walletAppURL: string) {
|
|
14
|
-
super()
|
|
13
|
+
constructor(walletAppURL: string, projectAccessKey?: string) {
|
|
14
|
+
super(projectAccessKey)
|
|
15
15
|
this.walletURL = new URL(walletAppURL)
|
|
16
16
|
}
|
|
17
17
|
|
package/src/types.ts
CHANGED
|
@@ -62,6 +62,7 @@ export interface ProviderMessage<T> {
|
|
|
62
62
|
chainId?: number // chain id which the message is intended
|
|
63
63
|
origin?: string // origin of the message
|
|
64
64
|
clientVersion: string // client version of the message
|
|
65
|
+
projectAccessKey?: string // project access key
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export type ProviderMessageRequest = ProviderMessage<JsonRpcRequest>
|