New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@0xsequence/network

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xsequence/network - npm Package Compare versions

Comparing version

to
0.0.0-20220506174803

@@ -27,5 +27,2 @@ 'use strict';

};
const getAuthNetwork = networks => {
return networks.find(network => network.isAuthChain);
};
const isValidNetworkConfig = (networkConfig, raise = false, skipRelayerCheck = false) => {

@@ -71,3 +68,2 @@ if (!networkConfig) throw new Error(`invalid network config: empty config`);

let defaultChain = false;
let authChain = false;

@@ -97,10 +93,2 @@ for (let i = 0; i < configs.length; i++) {

}
if (c.isAuthChain) {
if (authChain) {
if (raise) throw new Error(`invalid network config for chainId ${c.chainId}: AuthChain is already set by another config`);
}
authChain = true;
}
}

@@ -113,7 +101,2 @@

if (!authChain) {
if (raise) throw new Error(`invalid network config: AuthChain must be set`);
return false;
}
return true;

@@ -135,3 +118,3 @@ };

return true;
}; // sortNetworks orders the network config list by: defaultChain, authChain, ..rest by chainId ascending numbers
}; // sortNetworks orders the network config list by: defaultChain, ..rest by chainId ascending numbers

@@ -161,16 +144,7 @@ const sortNetworks = (networks, defaultChainId) => {

}
} // // AuthChain goes first
// const authConfigIdx = config.findIndex(c => c.isAuthChain)
// if (authConfigIdx > 0) config.splice(0, 0, config.splice(authConfigIdx, 1)[0])
// // DefaultChain goes second
// const defaultConfigIdx = config.findIndex(c => c.isDefaultChain && c.isAuthChain !== true)
// if (defaultConfigIdx > 0) config.splice(1, 0, config.splice(defaultConfigIdx, 1)[0])
// DefaultChain goes first
} // DefaultChain goes first
const defaultConfigIdx = config.findIndex(c => c.isDefaultChain);
if (defaultConfigIdx > 0) config.splice(0, 0, config.splice(defaultConfigIdx, 1)[0]); // AuthChain goes second
const authConfigIdx = config.findIndex(c => c.isAuthChain && c.isDefaultChain !== true);
if (authConfigIdx > 0) config.splice(1, 0, config.splice(authConfigIdx, 1)[0]);
if (defaultConfigIdx > 0) config.splice(0, 0, config.splice(defaultConfigIdx, 1)[0]);
return config;

@@ -204,10 +178,3 @@ };

dest.ensAddress = src.ensAddress;
} // NOTE: we do not set default or auth chain from here
// if (src.isDefaultChain) {
// dest.isDefaultChain = src.isDefaultChain
// }
// if (src.isAuthChain) {
// dest.isAuthChain = src.isAuthChain
// }
}
};

@@ -298,5 +265,5 @@ const createNetworkConfig = (networks, defaultChainId, vars) => {

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/mainnet`)
},
isDefaultChain: true
url: utils.urlClean(`${vars.baseRelayerUrl}/mainnet`),
provider: utils.urlClean(`${vars.baseRpcUrl}/mainnet`)
}
}, {

@@ -308,5 +275,5 @@ title: 'Polygon',

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/matic`)
},
isAuthChain: true
url: utils.urlClean(`${vars.baseRelayerUrl}/matic`),
provider: utils.urlClean(`${vars.baseRpcUrl}/matic`)
}
}], 1, {

@@ -323,3 +290,4 @@ baseRpcUrl: 'https://nodes.sequence.app',

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/rinkeby`)
url: utils.urlClean(`${vars.baseRelayerUrl}/rinkeby`),
provider: utils.urlClean(`${vars.baseRpcUrl}/rinkeby`)
},

@@ -334,5 +302,5 @@ isDefaultChain: true

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/goerli`)
},
isAuthChain: true
url: utils.urlClean(`${vars.baseRelayerUrl}/goerli`),
provider: utils.urlClean(`${vars.baseRpcUrl}/goerli`)
}
} // {

@@ -371,2 +339,3 @@ // name: 'ropsten',

guestModule: '0x02390F3E6E5FD1C6786CB78FD3027C117a9955A7',
sessionUtils: '0x300C03193BfC2f64462D0F309666806329d631DB',
sequenceUtils: '0xd130B43062D875a4B7aF3f8fc036Bc6e9D3E1B3E',

@@ -854,3 +823,2 @@ libs: {

exports.findNetworkConfig = findNetworkConfig;
exports.getAuthNetwork = getAuthNetwork;
exports.getChainId = getChainId;

@@ -857,0 +825,0 @@ exports.isJsonRpcHandler = isJsonRpcHandler;

@@ -27,5 +27,2 @@ 'use strict';

};
const getAuthNetwork = networks => {
return networks.find(network => network.isAuthChain);
};
const isValidNetworkConfig = (networkConfig, raise = false, skipRelayerCheck = false) => {

@@ -71,3 +68,2 @@ if (!networkConfig) throw new Error(`invalid network config: empty config`);

let defaultChain = false;
let authChain = false;

@@ -97,10 +93,2 @@ for (let i = 0; i < configs.length; i++) {

}
if (c.isAuthChain) {
if (authChain) {
if (raise) throw new Error(`invalid network config for chainId ${c.chainId}: AuthChain is already set by another config`);
}
authChain = true;
}
}

@@ -113,7 +101,2 @@

if (!authChain) {
if (raise) throw new Error(`invalid network config: AuthChain must be set`);
return false;
}
return true;

@@ -135,3 +118,3 @@ };

return true;
}; // sortNetworks orders the network config list by: defaultChain, authChain, ..rest by chainId ascending numbers
}; // sortNetworks orders the network config list by: defaultChain, ..rest by chainId ascending numbers

@@ -161,16 +144,7 @@ const sortNetworks = (networks, defaultChainId) => {

}
} // // AuthChain goes first
// const authConfigIdx = config.findIndex(c => c.isAuthChain)
// if (authConfigIdx > 0) config.splice(0, 0, config.splice(authConfigIdx, 1)[0])
// // DefaultChain goes second
// const defaultConfigIdx = config.findIndex(c => c.isDefaultChain && c.isAuthChain !== true)
// if (defaultConfigIdx > 0) config.splice(1, 0, config.splice(defaultConfigIdx, 1)[0])
// DefaultChain goes first
} // DefaultChain goes first
const defaultConfigIdx = config.findIndex(c => c.isDefaultChain);
if (defaultConfigIdx > 0) config.splice(0, 0, config.splice(defaultConfigIdx, 1)[0]); // AuthChain goes second
const authConfigIdx = config.findIndex(c => c.isAuthChain && c.isDefaultChain !== true);
if (authConfigIdx > 0) config.splice(1, 0, config.splice(authConfigIdx, 1)[0]);
if (defaultConfigIdx > 0) config.splice(0, 0, config.splice(defaultConfigIdx, 1)[0]);
return config;

@@ -204,10 +178,3 @@ };

dest.ensAddress = src.ensAddress;
} // NOTE: we do not set default or auth chain from here
// if (src.isDefaultChain) {
// dest.isDefaultChain = src.isDefaultChain
// }
// if (src.isAuthChain) {
// dest.isAuthChain = src.isAuthChain
// }
}
};

@@ -298,5 +265,5 @@ const createNetworkConfig = (networks, defaultChainId, vars) => {

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/mainnet`)
},
isDefaultChain: true
url: utils.urlClean(`${vars.baseRelayerUrl}/mainnet`),
provider: utils.urlClean(`${vars.baseRpcUrl}/mainnet`)
}
}, {

@@ -308,5 +275,5 @@ title: 'Polygon',

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/matic`)
},
isAuthChain: true
url: utils.urlClean(`${vars.baseRelayerUrl}/matic`),
provider: utils.urlClean(`${vars.baseRpcUrl}/matic`)
}
}], 1, {

@@ -323,3 +290,4 @@ baseRpcUrl: 'https://nodes.sequence.app',

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/rinkeby`)
url: utils.urlClean(`${vars.baseRelayerUrl}/rinkeby`),
provider: utils.urlClean(`${vars.baseRpcUrl}/rinkeby`)
},

@@ -334,5 +302,5 @@ isDefaultChain: true

relayer: {
url: utils.urlClean(`${vars.baseRelayerUrl}/goerli`)
},
isAuthChain: true
url: utils.urlClean(`${vars.baseRelayerUrl}/goerli`),
provider: utils.urlClean(`${vars.baseRpcUrl}/goerli`)
}
} // {

@@ -371,2 +339,3 @@ // name: 'ropsten',

guestModule: '0x02390F3E6E5FD1C6786CB78FD3027C117a9955A7',
sessionUtils: '0x300C03193BfC2f64462D0F309666806329d631DB',
sequenceUtils: '0xd130B43062D875a4B7aF3f8fc036Bc6e9D3E1B3E',

@@ -854,3 +823,2 @@ libs: {

exports.findNetworkConfig = findNetworkConfig;
exports.getAuthNetwork = getAuthNetwork;
exports.getChainId = getChainId;

@@ -857,0 +825,0 @@ exports.isJsonRpcHandler = isJsonRpcHandler;

@@ -23,5 +23,2 @@ import { urlClean, logger } from '@0xsequence/utils';

};
const getAuthNetwork = networks => {
return networks.find(network => network.isAuthChain);
};
const isValidNetworkConfig = (networkConfig, raise = false, skipRelayerCheck = false) => {

@@ -67,3 +64,2 @@ if (!networkConfig) throw new Error(`invalid network config: empty config`);

let defaultChain = false;
let authChain = false;

@@ -93,10 +89,2 @@ for (let i = 0; i < configs.length; i++) {

}
if (c.isAuthChain) {
if (authChain) {
if (raise) throw new Error(`invalid network config for chainId ${c.chainId}: AuthChain is already set by another config`);
}
authChain = true;
}
}

@@ -109,7 +97,2 @@

if (!authChain) {
if (raise) throw new Error(`invalid network config: AuthChain must be set`);
return false;
}
return true;

@@ -131,3 +114,3 @@ };

return true;
}; // sortNetworks orders the network config list by: defaultChain, authChain, ..rest by chainId ascending numbers
}; // sortNetworks orders the network config list by: defaultChain, ..rest by chainId ascending numbers

@@ -157,16 +140,7 @@ const sortNetworks = (networks, defaultChainId) => {

}
} // // AuthChain goes first
// const authConfigIdx = config.findIndex(c => c.isAuthChain)
// if (authConfigIdx > 0) config.splice(0, 0, config.splice(authConfigIdx, 1)[0])
// // DefaultChain goes second
// const defaultConfigIdx = config.findIndex(c => c.isDefaultChain && c.isAuthChain !== true)
// if (defaultConfigIdx > 0) config.splice(1, 0, config.splice(defaultConfigIdx, 1)[0])
// DefaultChain goes first
} // DefaultChain goes first
const defaultConfigIdx = config.findIndex(c => c.isDefaultChain);
if (defaultConfigIdx > 0) config.splice(0, 0, config.splice(defaultConfigIdx, 1)[0]); // AuthChain goes second
const authConfigIdx = config.findIndex(c => c.isAuthChain && c.isDefaultChain !== true);
if (authConfigIdx > 0) config.splice(1, 0, config.splice(authConfigIdx, 1)[0]);
if (defaultConfigIdx > 0) config.splice(0, 0, config.splice(defaultConfigIdx, 1)[0]);
return config;

@@ -200,10 +174,3 @@ };

dest.ensAddress = src.ensAddress;
} // NOTE: we do not set default or auth chain from here
// if (src.isDefaultChain) {
// dest.isDefaultChain = src.isDefaultChain
// }
// if (src.isAuthChain) {
// dest.isAuthChain = src.isAuthChain
// }
}
};

@@ -294,5 +261,5 @@ const createNetworkConfig = (networks, defaultChainId, vars) => {

relayer: {
url: urlClean(`${vars.baseRelayerUrl}/mainnet`)
},
isDefaultChain: true
url: urlClean(`${vars.baseRelayerUrl}/mainnet`),
provider: urlClean(`${vars.baseRpcUrl}/mainnet`)
}
}, {

@@ -304,5 +271,5 @@ title: 'Polygon',

relayer: {
url: urlClean(`${vars.baseRelayerUrl}/matic`)
},
isAuthChain: true
url: urlClean(`${vars.baseRelayerUrl}/matic`),
provider: urlClean(`${vars.baseRpcUrl}/matic`)
}
}], 1, {

@@ -319,3 +286,4 @@ baseRpcUrl: 'https://nodes.sequence.app',

relayer: {
url: urlClean(`${vars.baseRelayerUrl}/rinkeby`)
url: urlClean(`${vars.baseRelayerUrl}/rinkeby`),
provider: urlClean(`${vars.baseRpcUrl}/rinkeby`)
},

@@ -330,5 +298,5 @@ isDefaultChain: true

relayer: {
url: urlClean(`${vars.baseRelayerUrl}/goerli`)
},
isAuthChain: true
url: urlClean(`${vars.baseRelayerUrl}/goerli`),
provider: urlClean(`${vars.baseRpcUrl}/goerli`)
}
} // {

@@ -367,2 +335,3 @@ // name: 'ropsten',

guestModule: '0x02390F3E6E5FD1C6786CB78FD3027C117a9955A7',
sessionUtils: '0x300C03193BfC2f64462D0F309666806329d631DB',
sequenceUtils: '0xd130B43062D875a4B7aF3f8fc036Bc6e9D3E1B3E',

@@ -833,2 +802,2 @@ libs: {

export { AllowProvider, CachedProvider, ChainId, EagerProvider, JsonRpcExternalProvider, JsonRpcRouter, JsonRpcSender, JsonRpcVersion, PublicProvider, SigningProvider, allowProviderMiddleware, checkNetworkConfig, createJsonRpcMiddlewareStack, createNetworkConfig, ensureUniqueNetworks, ensureValidNetworks, exceptionProviderMiddleware, findNetworkConfig, getAuthNetwork, getChainId, isJsonRpcHandler, isJsonRpcProvider, isNetworkConfig, isValidNetworkConfig, loggingProviderMiddleware, mainnetNetworks, maybeChainId, networkProviderMiddleware, networksIndex, sequenceContext, sortNetworks, testnetNetworks, updateNetworkConfig };
export { AllowProvider, CachedProvider, ChainId, EagerProvider, JsonRpcExternalProvider, JsonRpcRouter, JsonRpcSender, JsonRpcVersion, PublicProvider, SigningProvider, allowProviderMiddleware, checkNetworkConfig, createJsonRpcMiddlewareStack, createNetworkConfig, ensureUniqueNetworks, ensureValidNetworks, exceptionProviderMiddleware, findNetworkConfig, getChainId, isJsonRpcHandler, isJsonRpcProvider, isNetworkConfig, isValidNetworkConfig, loggingProviderMiddleware, mainnetNetworks, maybeChainId, networkProviderMiddleware, networksIndex, sequenceContext, sortNetworks, testnetNetworks, updateNetworkConfig };

@@ -37,3 +37,2 @@ import { BigNumberish } from 'ethers';

isDefaultChain?: boolean;
isAuthChain?: boolean;
}

@@ -40,0 +39,0 @@ export declare type Networks = NetworkConfig[];

@@ -5,2 +5,3 @@ export interface WalletContext {

mainModuleUpgradable: string;
sessionUtils: string;
guestModule?: string;

@@ -7,0 +8,0 @@ sequenceUtils?: string;

@@ -6,3 +6,2 @@ import { ChainIdLike } from '.';

export declare const maybeChainId: (chainId?: ChainIdLike | undefined) => number | undefined;
export declare const getAuthNetwork: (networks: NetworkConfig[]) => NetworkConfig | undefined;
export declare const isValidNetworkConfig: (networkConfig: NetworkConfig | NetworkConfig[], raise?: boolean, skipRelayerCheck?: boolean) => boolean;

@@ -9,0 +8,0 @@ export declare const ensureValidNetworks: (networks: NetworkConfig[], skipRelayerCheck?: boolean) => NetworkConfig[];

{
"name": "@0xsequence/network",
"version": "0.0.0-20220427162812",
"version": "0.0.0-20220506174803",
"description": "network sub-package for Sequence",

@@ -16,3 +16,3 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/network",

"dependencies": {
"@0xsequence/utils": "^0.0.0-20220427162812",
"@0xsequence/utils": "^0.0.0-20220506174803",
"@ethersproject/providers": "^5.5.1",

@@ -19,0 +19,0 @@ "ethers": "^5.5.2"

@@ -64,5 +64,2 @@ import { BigNumberish } from 'ethers'

isDefaultChain?: boolean
// isAuthChain identifies the network containing wallet config contents.
isAuthChain?: boolean
}

@@ -84,4 +81,6 @@

rpcUrl: urlClean(`${vars.baseRpcUrl}/mainnet`),
relayer: { url: urlClean(`${vars.baseRelayerUrl}/mainnet`) },
isDefaultChain: true
relayer: {
url: urlClean(`${vars.baseRelayerUrl}/mainnet`),
provider: urlClean(`${vars.baseRpcUrl}/mainnet`)
},
},

@@ -93,4 +92,6 @@ {

rpcUrl: 'https://rpc-mainnet.matic.network',
relayer: { url: urlClean(`${vars.baseRelayerUrl}/matic`) },
isAuthChain: true
relayer: {
url: urlClean(`${vars.baseRelayerUrl}/matic`),
provider: urlClean(`${vars.baseRpcUrl}/matic`)
},
}

@@ -113,3 +114,6 @@ ],

rpcUrl: urlClean(`${vars.baseRpcUrl}/rinkeby`),
relayer: { url: urlClean(`${vars.baseRelayerUrl}/rinkeby`) },
relayer: {
url: urlClean(`${vars.baseRelayerUrl}/rinkeby`),
provider: urlClean(`${vars.baseRpcUrl}/rinkeby`)
},
isDefaultChain: true

@@ -123,4 +127,6 @@ },

rpcUrl: urlClean(`${vars.baseRpcUrl}/goerli`),
relayer: { url: urlClean(`${vars.baseRelayerUrl}/goerli`) },
isAuthChain: true
relayer: {
url: urlClean(`${vars.baseRelayerUrl}/goerli`),
provider: urlClean(`${vars.baseRpcUrl}/goerli`),
},
}

@@ -127,0 +133,0 @@ // {

@@ -7,2 +7,4 @@ // WalletContext is the module addresses deployed on a network, aka the context / environment

mainModuleUpgradable: string
sessionUtils: string
guestModule?: string

@@ -24,2 +26,3 @@ sequenceUtils?: string

guestModule: '0x02390F3E6E5FD1C6786CB78FD3027C117a9955A7',
sessionUtils: '0x300C03193BfC2f64462D0F309666806329d631DB',
sequenceUtils: '0xd130B43062D875a4B7aF3f8fc036Bc6e9D3E1B3E',

@@ -26,0 +29,0 @@ libs: {

@@ -24,5 +24,2 @@ import { ethers, BigNumberish } from 'ethers'

export const getAuthNetwork = (networks: NetworkConfig[]): NetworkConfig | undefined => {
return networks.find(network => network.isAuthChain)
}

@@ -72,3 +69,2 @@ export const isValidNetworkConfig = (

let defaultChain = false
let authChain = false
for (let i = 0; i < configs.length; i++) {

@@ -94,8 +90,2 @@ const c = configs[i]

}
if (c.isAuthChain) {
if (authChain) {
if (raise) throw new Error(`invalid network config for chainId ${c.chainId}: AuthChain is already set by another config`)
}
authChain = true
}
}

@@ -107,7 +97,2 @@

}
if (!authChain) {
if (raise) throw new Error(`invalid network config: AuthChain must be set`)
return false
}
return true

@@ -131,3 +116,3 @@ }

// sortNetworks orders the network config list by: defaultChain, authChain, ..rest by chainId ascending numbers
// sortNetworks orders the network config list by: defaultChain, ..rest by chainId ascending numbers
export const sortNetworks = (networks: Networks, defaultChainId?: string | number): Networks => {

@@ -158,10 +143,2 @@ if (!networks) return []

// // AuthChain goes first
// const authConfigIdx = config.findIndex(c => c.isAuthChain)
// if (authConfigIdx > 0) config.splice(0, 0, config.splice(authConfigIdx, 1)[0])
// // DefaultChain goes second
// const defaultConfigIdx = config.findIndex(c => c.isDefaultChain && c.isAuthChain !== true)
// if (defaultConfigIdx > 0) config.splice(1, 0, config.splice(defaultConfigIdx, 1)[0])
// DefaultChain goes first

@@ -171,6 +148,2 @@ const defaultConfigIdx = config.findIndex(c => c.isDefaultChain)

// AuthChain goes second
const authConfigIdx = config.findIndex(c => c.isAuthChain && c.isDefaultChain !== true)
if (authConfigIdx > 0) config.splice(1, 0, config.splice(authConfigIdx, 1)[0])
return config

@@ -202,9 +175,2 @@ }

}
// NOTE: we do not set default or auth chain from here
// if (src.isDefaultChain) {
// dest.isDefaultChain = src.isDefaultChain
// }
// if (src.isAuthChain) {
// dest.isAuthChain = src.isAuthChain
// }
}

@@ -211,0 +177,0 @@