@0xsequence/network
Advanced tools
Comparing version 0.9.1 to 0.9.3
# @0xsequence/network | ||
## 0.9.3 | ||
### Patch Changes | ||
- - minor improvements | ||
- Updated dependencies [undefined] | ||
- @0xsequence/utils@0.9.3 | ||
## 0.9.1 | ||
@@ -4,0 +12,0 @@ |
@@ -596,10 +596,5 @@ 'use strict'; | ||
// EagerProvider will eagerly respond to a provider request from pre-initialized data values. | ||
// | ||
// This is useful for saving a few remote calls for responses we're already expecting when | ||
// communicating to a specific network provider. | ||
class EagerProvider { | ||
constructor(accountAddress, _chainId) { | ||
this._accountAddress = void 0; | ||
this._chainId = void 0; | ||
constructor(props) { | ||
this.props = void 0; | ||
@@ -615,7 +610,7 @@ this.sendAsyncMiddleware = next => { | ||
case 'net_version': | ||
if (this._chainId) { | ||
if (this.props.chainId) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: `${this._chainId}` | ||
result: `${this.props.chainId}` | ||
}); | ||
@@ -628,7 +623,7 @@ return; | ||
case 'eth_chainId': | ||
if (this._chainId) { | ||
if (this.props.chainId) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: ethers.ethers.utils.hexlify(this._chainId) | ||
result: ethers.ethers.utils.hexlify(this.props.chainId) | ||
}); | ||
@@ -641,7 +636,7 @@ return; | ||
case 'eth_accounts': | ||
if (this._accountAddress) { | ||
if (this.props.accountAddress) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: [this._accountAddress.toLowerCase()] | ||
result: [this.props.accountAddress.toLowerCase()] | ||
}); | ||
@@ -652,2 +647,14 @@ return; | ||
break; | ||
case 'sequence_getWalletContext': | ||
if (this.props.walletContext) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: this.props.walletContext | ||
}); | ||
return; | ||
} | ||
break; | ||
} | ||
@@ -659,4 +666,3 @@ | ||
this._accountAddress = accountAddress; | ||
this._chainId = _chainId; | ||
this.props = props; | ||
} | ||
@@ -663,0 +669,0 @@ |
@@ -596,10 +596,5 @@ 'use strict'; | ||
// EagerProvider will eagerly respond to a provider request from pre-initialized data values. | ||
// | ||
// This is useful for saving a few remote calls for responses we're already expecting when | ||
// communicating to a specific network provider. | ||
class EagerProvider { | ||
constructor(accountAddress, _chainId) { | ||
this._accountAddress = void 0; | ||
this._chainId = void 0; | ||
constructor(props) { | ||
this.props = void 0; | ||
@@ -615,7 +610,7 @@ this.sendAsyncMiddleware = next => { | ||
case 'net_version': | ||
if (this._chainId) { | ||
if (this.props.chainId) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: `${this._chainId}` | ||
result: `${this.props.chainId}` | ||
}); | ||
@@ -628,7 +623,7 @@ return; | ||
case 'eth_chainId': | ||
if (this._chainId) { | ||
if (this.props.chainId) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: ethers.ethers.utils.hexlify(this._chainId) | ||
result: ethers.ethers.utils.hexlify(this.props.chainId) | ||
}); | ||
@@ -641,7 +636,7 @@ return; | ||
case 'eth_accounts': | ||
if (this._accountAddress) { | ||
if (this.props.accountAddress) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: [this._accountAddress.toLowerCase()] | ||
result: [this.props.accountAddress.toLowerCase()] | ||
}); | ||
@@ -652,2 +647,14 @@ return; | ||
break; | ||
case 'sequence_getWalletContext': | ||
if (this.props.walletContext) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: this.props.walletContext | ||
}); | ||
return; | ||
} | ||
break; | ||
} | ||
@@ -659,4 +666,3 @@ | ||
this._accountAddress = accountAddress; | ||
this._chainId = _chainId; | ||
this.props = props; | ||
} | ||
@@ -663,0 +669,0 @@ |
@@ -592,10 +592,5 @@ import { urlClean } from '@0xsequence/utils'; | ||
// EagerProvider will eagerly respond to a provider request from pre-initialized data values. | ||
// | ||
// This is useful for saving a few remote calls for responses we're already expecting when | ||
// communicating to a specific network provider. | ||
class EagerProvider { | ||
constructor(accountAddress, _chainId) { | ||
this._accountAddress = void 0; | ||
this._chainId = void 0; | ||
constructor(props) { | ||
this.props = void 0; | ||
@@ -611,7 +606,7 @@ this.sendAsyncMiddleware = next => { | ||
case 'net_version': | ||
if (this._chainId) { | ||
if (this.props.chainId) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: `${this._chainId}` | ||
result: `${this.props.chainId}` | ||
}); | ||
@@ -624,7 +619,7 @@ return; | ||
case 'eth_chainId': | ||
if (this._chainId) { | ||
if (this.props.chainId) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: ethers.utils.hexlify(this._chainId) | ||
result: ethers.utils.hexlify(this.props.chainId) | ||
}); | ||
@@ -637,7 +632,7 @@ return; | ||
case 'eth_accounts': | ||
if (this._accountAddress) { | ||
if (this.props.accountAddress) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: [this._accountAddress.toLowerCase()] | ||
result: [this.props.accountAddress.toLowerCase()] | ||
}); | ||
@@ -648,2 +643,14 @@ return; | ||
break; | ||
case 'sequence_getWalletContext': | ||
if (this.props.walletContext) { | ||
callback(undefined, { | ||
jsonrpc: '2.0', | ||
id, | ||
result: this.props.walletContext | ||
}); | ||
return; | ||
} | ||
break; | ||
} | ||
@@ -655,4 +662,3 @@ | ||
this._accountAddress = accountAddress; | ||
this._chainId = _chainId; | ||
this.props = props; | ||
} | ||
@@ -659,0 +665,0 @@ |
import { JsonRpcHandlerFunc, JsonRpcRequest, JsonRpcResponseCallback, JsonRpcMiddlewareHandler } from '../types'; | ||
import { WalletContext } from '../../context'; | ||
export declare type EagerProviderProps = { | ||
accountAddress?: string; | ||
chainId?: number; | ||
walletContext?: WalletContext; | ||
}; | ||
export declare class EagerProvider implements JsonRpcMiddlewareHandler { | ||
readonly _accountAddress: string; | ||
readonly _chainId: number; | ||
constructor(accountAddress: string, chainId?: number); | ||
readonly props: EagerProviderProps; | ||
constructor(props: EagerProviderProps); | ||
sendAsyncMiddleware: (next: JsonRpcHandlerFunc) => (request: JsonRpcRequest, callback: JsonRpcResponseCallback, chainId?: number) => void; | ||
} |
{ | ||
"name": "@0xsequence/network", | ||
"version": "0.9.1", | ||
"version": "0.9.3", | ||
"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.9.1", | ||
"@0xsequence/utils": "^0.9.3", | ||
"@ethersproject/providers": "^5.0.20", | ||
@@ -19,0 +19,0 @@ "ethers": "^5.0.27" |
import { ethers } from 'ethers' | ||
import { JsonRpcHandlerFunc, JsonRpcRequest, JsonRpcResponseCallback, JsonRpcResponse, JsonRpcMiddlewareHandler } from '../types' | ||
import { WalletContext } from '../../context' | ||
@@ -8,10 +9,15 @@ // EagerProvider will eagerly respond to a provider request from pre-initialized data values. | ||
// communicating to a specific network provider. | ||
export type EagerProviderProps = { | ||
accountAddress?: string, | ||
chainId?: number, | ||
walletContext?: WalletContext | ||
} | ||
export class EagerProvider implements JsonRpcMiddlewareHandler { | ||
readonly _accountAddress: string | ||
readonly _chainId: number | ||
readonly props: EagerProviderProps | ||
constructor(accountAddress: string, chainId?: number) { | ||
this._accountAddress = accountAddress | ||
this._chainId = chainId | ||
constructor(props: EagerProviderProps) { | ||
this.props = props | ||
} | ||
@@ -26,4 +32,4 @@ | ||
case 'net_version': | ||
if (this._chainId) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: `${this._chainId}` }) | ||
if (this.props.chainId) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: `${this.props.chainId}` }) | ||
return | ||
@@ -34,4 +40,4 @@ } | ||
case 'eth_chainId': | ||
if (this._chainId) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: ethers.utils.hexlify(this._chainId) }) | ||
if (this.props.chainId) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: ethers.utils.hexlify(this.props.chainId) }) | ||
return | ||
@@ -42,4 +48,4 @@ } | ||
case 'eth_accounts': | ||
if (this._accountAddress) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: [this._accountAddress.toLowerCase()] }) | ||
if (this.props.accountAddress) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: [this.props.accountAddress.toLowerCase()] }) | ||
return | ||
@@ -49,2 +55,9 @@ } | ||
case 'sequence_getWalletContext': | ||
if (this.props.walletContext) { | ||
callback(undefined, { jsonrpc: '2.0', id, result: this.props.walletContext }) | ||
return | ||
} | ||
break | ||
default: | ||
@@ -51,0 +64,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113450
3011
Updated@0xsequence/utils@^0.9.3