@0xsequence/provider 1.9.16 → 1.9.18
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 +43 -32
- package/dist/0xsequence-provider.cjs.prod.js +43 -32
- package/dist/0xsequence-provider.esm.js +43 -33
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/transactions.d.ts +2 -0
- package/package.json +10 -10
- package/src/index.ts +1 -0
- package/src/transactions.ts +23 -0
|
@@ -2,15 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var abi = require('@0xsequence/abi');
|
|
6
|
+
var core = require('@0xsequence/core');
|
|
7
|
+
var ethers = require('ethers');
|
|
5
8
|
var eventemitter2 = require('eventemitter2');
|
|
6
9
|
var utils = require('@0xsequence/utils');
|
|
7
|
-
var ethers = require('ethers');
|
|
8
10
|
var network = require('@0xsequence/network');
|
|
9
|
-
var core = require('@0xsequence/core');
|
|
10
11
|
var auth = require('@0xsequence/auth');
|
|
11
|
-
var abi = require('@0xsequence/abi');
|
|
12
12
|
var tracker = require('@databeat/tracker');
|
|
13
13
|
|
|
14
|
+
const PROHIBITED_FUNCTIONS = new Map(['addHook(bytes4,address)', 'clearExtraImageHashes(bytes32[])', 'removeHook(bytes4)', 'setExtraImageHash(bytes32,uint256)', 'updateIPFSRoot(bytes32)', 'updateImageHash(bytes32)', 'updateImageHashAndIPFS(bytes32,bytes32)', 'updateImplementation(address)'].map(signature => [ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(signature)).slice(0, 10), signature]));
|
|
15
|
+
function validateTransactionRequest(wallet, transaction) {
|
|
16
|
+
const transactions = core.commons.transaction.fromTransactionish(wallet, transaction);
|
|
17
|
+
const unwound = core.commons.transaction.unwind(wallet, transactions);
|
|
18
|
+
unwound.forEach(transaction => validateTransaction(wallet, transaction));
|
|
19
|
+
}
|
|
20
|
+
function validateTransaction(wallet, transaction) {
|
|
21
|
+
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
22
|
+
if (transaction.data) {
|
|
23
|
+
const data = ethers.ethers.utils.arrayify(transaction.data);
|
|
24
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
25
|
+
throw new Error('self calls are forbidden');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (transaction.delegateCall) {
|
|
30
|
+
throw new Error('delegate calls are forbidden');
|
|
31
|
+
}
|
|
32
|
+
if (transaction.data) {
|
|
33
|
+
const data = ethers.ethers.utils.hexlify(transaction.data);
|
|
34
|
+
const selector = data.slice(0, 10);
|
|
35
|
+
const signature = PROHIBITED_FUNCTIONS.get(selector);
|
|
36
|
+
if (signature) {
|
|
37
|
+
const name = signature.slice(0, signature.indexOf('('));
|
|
38
|
+
throw new Error(`${name} calls are forbidden`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isCreateContractCall(data) {
|
|
43
|
+
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
44
|
+
try {
|
|
45
|
+
walletInterface.decodeFunctionData('createContract', data);
|
|
46
|
+
return true;
|
|
47
|
+
} catch (_unused) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
14
52
|
function _extends() {
|
|
15
53
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
16
54
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -2150,34 +2188,6 @@ function fromExtended(transaction) {
|
|
|
2150
2188
|
return [transaction, ...(transaction.auxiliary || [])];
|
|
2151
2189
|
}
|
|
2152
2190
|
|
|
2153
|
-
function validateTransactionRequest(wallet, transaction) {
|
|
2154
|
-
const transactions = core.commons.transaction.fromTransactionish(wallet, transaction);
|
|
2155
|
-
const unwound = core.commons.transaction.unwind(wallet, transactions);
|
|
2156
|
-
unwound.forEach(transaction => validateTransaction(wallet, transaction));
|
|
2157
|
-
}
|
|
2158
|
-
function validateTransaction(wallet, transaction) {
|
|
2159
|
-
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
2160
|
-
if (transaction.data) {
|
|
2161
|
-
const data = ethers.ethers.utils.arrayify(transaction.data);
|
|
2162
|
-
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
2163
|
-
throw new Error('self calls are forbidden');
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
if (transaction.delegateCall) {
|
|
2168
|
-
throw new Error('delegate calls are forbidden');
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
function isCreateContractCall(data) {
|
|
2172
|
-
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
2173
|
-
try {
|
|
2174
|
-
walletInterface.decodeFunctionData('createContract', data);
|
|
2175
|
-
return true;
|
|
2176
|
-
} catch (_unused) {
|
|
2177
|
-
return false;
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
2191
|
const SIGNER_READY_TIMEOUT = 10000;
|
|
2182
2192
|
class WalletRequestHandler {
|
|
2183
2193
|
constructor(_account, prompter, networks) {
|
|
@@ -3612,7 +3622,7 @@ const setupAnalytics = (projectAccessKey, server) => {
|
|
|
3612
3622
|
|
|
3613
3623
|
var packageJson = {
|
|
3614
3624
|
name: "@0xsequence/provider",
|
|
3615
|
-
version: "1.9.
|
|
3625
|
+
version: "1.9.18",
|
|
3616
3626
|
description: "provider sub-package for Sequence",
|
|
3617
3627
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3618
3628
|
source: "src/index.ts",
|
|
@@ -4280,3 +4290,4 @@ exports.resolveArrayProperties = resolveArrayProperties;
|
|
|
4280
4290
|
exports.trimEIP191Prefix = trimEIP191Prefix;
|
|
4281
4291
|
exports.unregisterWallet = unregisterWallet;
|
|
4282
4292
|
exports.useBestStore = useBestStore;
|
|
4293
|
+
exports.validateTransactionRequest = validateTransactionRequest;
|
|
@@ -2,15 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var abi = require('@0xsequence/abi');
|
|
6
|
+
var core = require('@0xsequence/core');
|
|
7
|
+
var ethers = require('ethers');
|
|
5
8
|
var eventemitter2 = require('eventemitter2');
|
|
6
9
|
var utils = require('@0xsequence/utils');
|
|
7
|
-
var ethers = require('ethers');
|
|
8
10
|
var network = require('@0xsequence/network');
|
|
9
|
-
var core = require('@0xsequence/core');
|
|
10
11
|
var auth = require('@0xsequence/auth');
|
|
11
|
-
var abi = require('@0xsequence/abi');
|
|
12
12
|
var tracker = require('@databeat/tracker');
|
|
13
13
|
|
|
14
|
+
const PROHIBITED_FUNCTIONS = new Map(['addHook(bytes4,address)', 'clearExtraImageHashes(bytes32[])', 'removeHook(bytes4)', 'setExtraImageHash(bytes32,uint256)', 'updateIPFSRoot(bytes32)', 'updateImageHash(bytes32)', 'updateImageHashAndIPFS(bytes32,bytes32)', 'updateImplementation(address)'].map(signature => [ethers.ethers.utils.keccak256(ethers.ethers.utils.toUtf8Bytes(signature)).slice(0, 10), signature]));
|
|
15
|
+
function validateTransactionRequest(wallet, transaction) {
|
|
16
|
+
const transactions = core.commons.transaction.fromTransactionish(wallet, transaction);
|
|
17
|
+
const unwound = core.commons.transaction.unwind(wallet, transactions);
|
|
18
|
+
unwound.forEach(transaction => validateTransaction(wallet, transaction));
|
|
19
|
+
}
|
|
20
|
+
function validateTransaction(wallet, transaction) {
|
|
21
|
+
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
22
|
+
if (transaction.data) {
|
|
23
|
+
const data = ethers.ethers.utils.arrayify(transaction.data);
|
|
24
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
25
|
+
throw new Error('self calls are forbidden');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (transaction.delegateCall) {
|
|
30
|
+
throw new Error('delegate calls are forbidden');
|
|
31
|
+
}
|
|
32
|
+
if (transaction.data) {
|
|
33
|
+
const data = ethers.ethers.utils.hexlify(transaction.data);
|
|
34
|
+
const selector = data.slice(0, 10);
|
|
35
|
+
const signature = PROHIBITED_FUNCTIONS.get(selector);
|
|
36
|
+
if (signature) {
|
|
37
|
+
const name = signature.slice(0, signature.indexOf('('));
|
|
38
|
+
throw new Error(`${name} calls are forbidden`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isCreateContractCall(data) {
|
|
43
|
+
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
44
|
+
try {
|
|
45
|
+
walletInterface.decodeFunctionData('createContract', data);
|
|
46
|
+
return true;
|
|
47
|
+
} catch (_unused) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
14
52
|
function _extends() {
|
|
15
53
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
16
54
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -2150,34 +2188,6 @@ function fromExtended(transaction) {
|
|
|
2150
2188
|
return [transaction, ...(transaction.auxiliary || [])];
|
|
2151
2189
|
}
|
|
2152
2190
|
|
|
2153
|
-
function validateTransactionRequest(wallet, transaction) {
|
|
2154
|
-
const transactions = core.commons.transaction.fromTransactionish(wallet, transaction);
|
|
2155
|
-
const unwound = core.commons.transaction.unwind(wallet, transactions);
|
|
2156
|
-
unwound.forEach(transaction => validateTransaction(wallet, transaction));
|
|
2157
|
-
}
|
|
2158
|
-
function validateTransaction(wallet, transaction) {
|
|
2159
|
-
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
2160
|
-
if (transaction.data) {
|
|
2161
|
-
const data = ethers.ethers.utils.arrayify(transaction.data);
|
|
2162
|
-
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
2163
|
-
throw new Error('self calls are forbidden');
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
if (transaction.delegateCall) {
|
|
2168
|
-
throw new Error('delegate calls are forbidden');
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
function isCreateContractCall(data) {
|
|
2172
|
-
const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
|
|
2173
|
-
try {
|
|
2174
|
-
walletInterface.decodeFunctionData('createContract', data);
|
|
2175
|
-
return true;
|
|
2176
|
-
} catch (_unused) {
|
|
2177
|
-
return false;
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
2191
|
const SIGNER_READY_TIMEOUT = 10000;
|
|
2182
2192
|
class WalletRequestHandler {
|
|
2183
2193
|
constructor(_account, prompter, networks) {
|
|
@@ -3612,7 +3622,7 @@ const setupAnalytics = (projectAccessKey, server) => {
|
|
|
3612
3622
|
|
|
3613
3623
|
var packageJson = {
|
|
3614
3624
|
name: "@0xsequence/provider",
|
|
3615
|
-
version: "1.9.
|
|
3625
|
+
version: "1.9.18",
|
|
3616
3626
|
description: "provider sub-package for Sequence",
|
|
3617
3627
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3618
3628
|
source: "src/index.ts",
|
|
@@ -4280,3 +4290,4 @@ exports.resolveArrayProperties = resolveArrayProperties;
|
|
|
4280
4290
|
exports.trimEIP191Prefix = trimEIP191Prefix;
|
|
4281
4291
|
exports.unregisterWallet = unregisterWallet;
|
|
4282
4292
|
exports.useBestStore = useBestStore;
|
|
4293
|
+
exports.validateTransactionRequest = validateTransactionRequest;
|
|
@@ -1,12 +1,50 @@
|
|
|
1
|
+
import { walletContracts } from '@0xsequence/abi';
|
|
2
|
+
import { commons } from '@0xsequence/core';
|
|
3
|
+
import { ethers, BigNumber } from 'ethers';
|
|
1
4
|
import { EventEmitter2 } from 'eventemitter2';
|
|
2
5
|
import { logger, encodeMessageDigest, encodeTypedDataDigest, sanitizeNumberString, sanitizeHost, sanitizeAlphanumeric, base64EncodeObject, base64DecodeObject } from '@0xsequence/utils';
|
|
3
|
-
import { ethers, BigNumber } from 'ethers';
|
|
4
6
|
import { findSupportedNetwork, ChainId, findNetworkConfig, allNetworks, JsonRpcRouter, loggingProviderMiddleware, exceptionProviderMiddleware, CachedProvider, JsonRpcSender } from '@0xsequence/network';
|
|
5
|
-
import { commons } from '@0xsequence/core';
|
|
6
7
|
import { signAuthorization } from '@0xsequence/auth';
|
|
7
|
-
import { walletContracts } from '@0xsequence/abi';
|
|
8
8
|
import { isBrowser, Databeat } from '@databeat/tracker';
|
|
9
9
|
|
|
10
|
+
const PROHIBITED_FUNCTIONS = new Map(['addHook(bytes4,address)', 'clearExtraImageHashes(bytes32[])', 'removeHook(bytes4)', 'setExtraImageHash(bytes32,uint256)', 'updateIPFSRoot(bytes32)', 'updateImageHash(bytes32)', 'updateImageHashAndIPFS(bytes32,bytes32)', 'updateImplementation(address)'].map(signature => [ethers.utils.keccak256(ethers.utils.toUtf8Bytes(signature)).slice(0, 10), signature]));
|
|
11
|
+
function validateTransactionRequest(wallet, transaction) {
|
|
12
|
+
const transactions = commons.transaction.fromTransactionish(wallet, transaction);
|
|
13
|
+
const unwound = commons.transaction.unwind(wallet, transactions);
|
|
14
|
+
unwound.forEach(transaction => validateTransaction(wallet, transaction));
|
|
15
|
+
}
|
|
16
|
+
function validateTransaction(wallet, transaction) {
|
|
17
|
+
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
18
|
+
if (transaction.data) {
|
|
19
|
+
const data = ethers.utils.arrayify(transaction.data);
|
|
20
|
+
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
21
|
+
throw new Error('self calls are forbidden');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (transaction.delegateCall) {
|
|
26
|
+
throw new Error('delegate calls are forbidden');
|
|
27
|
+
}
|
|
28
|
+
if (transaction.data) {
|
|
29
|
+
const data = ethers.utils.hexlify(transaction.data);
|
|
30
|
+
const selector = data.slice(0, 10);
|
|
31
|
+
const signature = PROHIBITED_FUNCTIONS.get(selector);
|
|
32
|
+
if (signature) {
|
|
33
|
+
const name = signature.slice(0, signature.indexOf('('));
|
|
34
|
+
throw new Error(`${name} calls are forbidden`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function isCreateContractCall(data) {
|
|
39
|
+
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi);
|
|
40
|
+
try {
|
|
41
|
+
walletInterface.decodeFunctionData('createContract', data);
|
|
42
|
+
return true;
|
|
43
|
+
} catch (_unused) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
10
48
|
function _extends() {
|
|
11
49
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
12
50
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -2146,34 +2184,6 @@ function fromExtended(transaction) {
|
|
|
2146
2184
|
return [transaction, ...(transaction.auxiliary || [])];
|
|
2147
2185
|
}
|
|
2148
2186
|
|
|
2149
|
-
function validateTransactionRequest(wallet, transaction) {
|
|
2150
|
-
const transactions = commons.transaction.fromTransactionish(wallet, transaction);
|
|
2151
|
-
const unwound = commons.transaction.unwind(wallet, transactions);
|
|
2152
|
-
unwound.forEach(transaction => validateTransaction(wallet, transaction));
|
|
2153
|
-
}
|
|
2154
|
-
function validateTransaction(wallet, transaction) {
|
|
2155
|
-
if (transaction.to.toLowerCase() === wallet.toLowerCase()) {
|
|
2156
|
-
if (transaction.data) {
|
|
2157
|
-
const data = ethers.utils.arrayify(transaction.data);
|
|
2158
|
-
if (data.length >= 4 && !isCreateContractCall(data)) {
|
|
2159
|
-
throw new Error('self calls are forbidden');
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
if (transaction.delegateCall) {
|
|
2164
|
-
throw new Error('delegate calls are forbidden');
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
function isCreateContractCall(data) {
|
|
2168
|
-
const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi);
|
|
2169
|
-
try {
|
|
2170
|
-
walletInterface.decodeFunctionData('createContract', data);
|
|
2171
|
-
return true;
|
|
2172
|
-
} catch (_unused) {
|
|
2173
|
-
return false;
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
2187
|
const SIGNER_READY_TIMEOUT = 10000;
|
|
2178
2188
|
class WalletRequestHandler {
|
|
2179
2189
|
constructor(_account, prompter, networks) {
|
|
@@ -3608,7 +3618,7 @@ const setupAnalytics = (projectAccessKey, server) => {
|
|
|
3608
3618
|
|
|
3609
3619
|
var packageJson = {
|
|
3610
3620
|
name: "@0xsequence/provider",
|
|
3611
|
-
version: "1.9.
|
|
3621
|
+
version: "1.9.18",
|
|
3612
3622
|
description: "provider sub-package for Sequence",
|
|
3613
3623
|
repository: "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
3614
3624
|
source: "src/index.ts",
|
|
@@ -4226,4 +4236,4 @@ const getWallet = () => {
|
|
|
4226
4236
|
return sequenceWalletProvider;
|
|
4227
4237
|
};
|
|
4228
4238
|
|
|
4229
|
-
export { BaseInjectedTransport, BaseProviderTransport, BaseWalletTransport, CHANNEL_ID, DefaultChainIdTracker, DefaultProviderConfig, ErrSignedInRequired, EventType, ExtensionMessageHandler, ExtensionMessageProvider, InitState, LocalStorage, MemoryItemStore, MuxMessageProvider, OpenState, PROVIDER_OPEN_TIMEOUT, ProviderError, ProxyMessageChannel, ProxyMessageChannelPort, ProxyMessageHandler, ProxyMessageProvider, SequenceClient, SequenceClientSession, SequenceProvider, SequenceSigner, SingleNetworkSequenceProvider, SingleNetworkSequenceSigner, UnrealMessageHandler, UnrealMessageProvider, WalletRequestHandler, WindowMessageHandler, WindowMessageProvider, WindowSessionParams, getWallet, initWallet, isBrowserExtension, isMuxTransportTemplate, isProviderTransport, isUnityPlugin, isValidMessageSignature, isValidSignature, isValidTypedDataSignature, isWalletUpToDate, messageToBytes, nextMessageIdx, prefixEIP191Message, resolveArrayProperties, trimEIP191Prefix, unregisterWallet, useBestStore };
|
|
4239
|
+
export { BaseInjectedTransport, BaseProviderTransport, BaseWalletTransport, CHANNEL_ID, DefaultChainIdTracker, DefaultProviderConfig, ErrSignedInRequired, EventType, ExtensionMessageHandler, ExtensionMessageProvider, InitState, LocalStorage, MemoryItemStore, MuxMessageProvider, OpenState, PROVIDER_OPEN_TIMEOUT, ProviderError, ProxyMessageChannel, ProxyMessageChannelPort, ProxyMessageHandler, ProxyMessageProvider, SequenceClient, SequenceClientSession, SequenceProvider, SequenceSigner, SingleNetworkSequenceProvider, SingleNetworkSequenceSigner, UnrealMessageHandler, UnrealMessageProvider, WalletRequestHandler, WindowMessageHandler, WindowMessageProvider, WindowSessionParams, getWallet, initWallet, isBrowserExtension, isMuxTransportTemplate, isProviderTransport, isUnityPlugin, isValidMessageSignature, isValidSignature, isValidTypedDataSignature, isWalletUpToDate, messageToBytes, nextMessageIdx, prefixEIP191Message, resolveArrayProperties, trimEIP191Prefix, unregisterWallet, useBestStore, validateTransactionRequest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.18",
|
|
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",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"@databeat/tracker": "^0.9.1",
|
|
13
13
|
"eventemitter2": "^6.4.5",
|
|
14
14
|
"webextension-polyfill": "^0.10.0",
|
|
15
|
-
"@0xsequence/abi": "1.9.
|
|
16
|
-
"@0xsequence/account": "1.9.
|
|
17
|
-
"@0xsequence/auth": "1.9.
|
|
18
|
-
"@0xsequence/core": "1.9.
|
|
19
|
-
"@0xsequence/migration": "1.9.
|
|
20
|
-
"@0xsequence/network": "1.9.
|
|
21
|
-
"@0xsequence/relayer": "1.9.
|
|
22
|
-
"@0xsequence/utils": "1.9.
|
|
23
|
-
"@0xsequence/wallet": "1.9.
|
|
15
|
+
"@0xsequence/abi": "1.9.18",
|
|
16
|
+
"@0xsequence/account": "1.9.18",
|
|
17
|
+
"@0xsequence/auth": "1.9.18",
|
|
18
|
+
"@0xsequence/core": "1.9.18",
|
|
19
|
+
"@0xsequence/migration": "1.9.18",
|
|
20
|
+
"@0xsequence/network": "1.9.18",
|
|
21
|
+
"@0xsequence/relayer": "1.9.18",
|
|
22
|
+
"@0xsequence/utils": "1.9.18",
|
|
23
|
+
"@0xsequence/wallet": "1.9.18"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"ethers": ">=5.5 < 6"
|
package/src/index.ts
CHANGED
package/src/transactions.ts
CHANGED
|
@@ -2,6 +2,19 @@ import { walletContracts } from '@0xsequence/abi'
|
|
|
2
2
|
import { commons } from '@0xsequence/core'
|
|
3
3
|
import { ethers } from 'ethers'
|
|
4
4
|
|
|
5
|
+
const PROHIBITED_FUNCTIONS = new Map(
|
|
6
|
+
[
|
|
7
|
+
'addHook(bytes4,address)',
|
|
8
|
+
'clearExtraImageHashes(bytes32[])',
|
|
9
|
+
'removeHook(bytes4)',
|
|
10
|
+
'setExtraImageHash(bytes32,uint256)',
|
|
11
|
+
'updateIPFSRoot(bytes32)',
|
|
12
|
+
'updateImageHash(bytes32)',
|
|
13
|
+
'updateImageHashAndIPFS(bytes32,bytes32)',
|
|
14
|
+
'updateImplementation(address)'
|
|
15
|
+
].map(signature => [ethers.utils.keccak256(ethers.utils.toUtf8Bytes(signature)).slice(0, 10), signature])
|
|
16
|
+
)
|
|
17
|
+
|
|
5
18
|
export function validateTransactionRequest(wallet: string, transaction: commons.transaction.Transactionish) {
|
|
6
19
|
const transactions = commons.transaction.fromTransactionish(wallet, transaction)
|
|
7
20
|
const unwound = commons.transaction.unwind(wallet, transactions)
|
|
@@ -21,6 +34,16 @@ function validateTransaction(wallet: string, transaction: commons.transaction.Tr
|
|
|
21
34
|
if (transaction.delegateCall) {
|
|
22
35
|
throw new Error('delegate calls are forbidden')
|
|
23
36
|
}
|
|
37
|
+
|
|
38
|
+
if (transaction.data) {
|
|
39
|
+
const data = ethers.utils.hexlify(transaction.data)
|
|
40
|
+
const selector = data.slice(0, 10)
|
|
41
|
+
const signature = PROHIBITED_FUNCTIONS.get(selector)
|
|
42
|
+
if (signature) {
|
|
43
|
+
const name = signature.slice(0, signature.indexOf('('))
|
|
44
|
+
throw new Error(`${name} calls are forbidden`)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
24
47
|
}
|
|
25
48
|
|
|
26
49
|
function isCreateContractCall(data: ethers.BytesLike): boolean {
|